diff --git a/app/DumpGiBUUEvents.cxx b/app/DumpGiBUUEvents.cxx
index d8c456f..e3e571f 100644
--- a/app/DumpGiBUUEvents.cxx
+++ b/app/DumpGiBUUEvents.cxx
@@ -1,49 +1,49 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#include
#include "FitLogger.h"
#include "StdHepEvt.h"
int main(int argv, char const *argc[]) {
if (argv != 2) {
- QTHROW("[ERROR]: expected a single input GiBUU rootracker file.");
+ NUIS_ABORT("[ERROR]: expected a single input GiBUU rootracker file.");
}
std::string inpf(argc[1]);
if (!inpf.length()) {
- QTHROW("[ERROR]: expected an input GiBUU rootracker file.");
+ NUIS_ABORT("[ERROR]: expected an input GiBUU rootracker file.");
}
TChain tn("giRooTracker");
tn.AddFile(inpf.c_str());
GiBUUStdHepReader giRead;
bool ok = giRead.SetBranchAddresses(&tn);
if (!ok) {
- QTHROW("[ERROR]: Could not correctly set branch address for input file.");
+ NUIS_ABORT("[ERROR]: Could not correctly set branch address for input file.");
}
for (Long64_t ievt = 0; ievt < tn.GetEntries(); ++ievt) {
tn.GetEntry(ievt);
- QLOG(EVT, WriteGiBUUEvent(giRead));
+ NUIS_LOG(EVT, WriteGiBUUEvent(giRead));
}
}
diff --git a/app/PrepareGENIE.cxx b/app/PrepareGENIE.cxx
index 06030f0..8196e5e 100644
--- a/app/PrepareGENIE.cxx
+++ b/app/PrepareGENIE.cxx
@@ -1,938 +1,938 @@
#include "FitLogger.h"
#include "PlotUtils.h"
#include "TFile.h"
#include "TH1D.h"
#include "TTree.h"
#include
#include
#ifdef __GENIE_ENABLED__
#ifdef GENIE_PRE_R3
#include "Conventions/Units.h"
#include "GHEP/GHepParticle.h"
#include "PDG/PDGUtils.h"
#else
#include "Framework/Conventions/Units.h"
#include "Framework/GHEP/GHepParticle.h"
#include "Framework/ParticleData/PDGUtils.h"
#endif
#endif
std::string gInputFiles = "";
std::string gOutputFile = "";
std::string gFluxFile = "";
std::string gTarget = "";
double MonoEnergy;
int gNEvents = -999;
bool IsMonoE = false;
void PrintOptions();
void ParseOptions(int argc, char *argv[]);
void RunGENIEPrepareMono(std::string input, std::string target,
std::string output);
void RunGENIEPrepare(std::string input, std::string flux, std::string target,
std::string output);
int main(int argc, char *argv[]) {
ParseOptions(argc, argv);
if (IsMonoE) {
RunGENIEPrepareMono(gInputFiles, gTarget, gOutputFile);
} else {
RunGENIEPrepare(gInputFiles, gFluxFile, gTarget, gOutputFile);
}
}
void RunGENIEPrepareMono(std::string input, std::string target,
std::string output) {
- QLOG(FIT, "Running GENIE Prepare in mono energetic with E = " << MonoEnergy
+ NUIS_LOG(FIT, "Running GENIE Prepare in mono energetic with E = " << MonoEnergy
<< " GeV");
// Setup TTree
TChain *tn = new TChain("gtree");
tn->AddFile(input.c_str());
if (tn->GetFile() == NULL) {
tn->Print();
- QERROR(FTL, "gtree not located in GENIE file: " << input);
- QTHROW("Check your inputs, they may need to be completely regenerated!");
+ NUIS_ERR(FTL, "gtree not located in GENIE file: " << input);
+ NUIS_ABORT("Check your inputs, they may need to be completely regenerated!");
throw;
}
int nevt = tn->GetEntries();
if (gNEvents != -999) {
- QLOG(FIT, "Overriding number of events by user from " << nevt << " to "
+ NUIS_LOG(FIT, "Overriding number of events by user from " << nevt << " to "
<< gNEvents);
nevt = gNEvents;
}
NtpMCEventRecord *genientpl = NULL;
tn->SetBranchAddress("gmcrec", &genientpl);
// Have the TH1D go from MonoEnergy/2 to MonoEnergy/2
TH1D *fluxhist =
new TH1D("flux", "flux", 1000, MonoEnergy / 2., MonoEnergy * 2.);
fluxhist->Fill(MonoEnergy);
fluxhist->Scale(1, "width");
// Make Event Hist
TH1D *eventhist = (TH1D *)fluxhist->Clone();
eventhist->Reset();
TH1D *xsechist = (TH1D *)eventhist->Clone();
// Create maps
std::map modexsec;
std::map modecount;
std::vector genieids;
std::vector targetids;
std::vector interids;
// Loop over all events
for (int i = 0; i < nevt; i++) {
tn->GetEntry(i);
StopTalking();
EventRecord &event = *(genientpl->event);
GHepParticle *neu = event.Probe();
StartTalking();
// Get XSec From Spline
GHepRecord genie_record = static_cast(event);
double xsec = (genie_record.XSec() / (1E-38 * genie::units::cm2));
// Parse Interaction String
std::string mode = genie_record.Summary()->AsString();
std::vector modevec = GeneralUtils::ParseToStr(mode, ";");
std::string targ = (modevec[0] + ";" + modevec[1]);
std::string inter = mode;
// Fill lists of Unique IDS
if (std::find(targetids.begin(), targetids.end(), targ) ==
targetids.end()) {
targetids.push_back(targ);
}
if (std::find(interids.begin(), interids.end(), inter) == interids.end()) {
interids.push_back(inter);
}
// Create entries Mode Maps
if (modexsec.find(mode) == modexsec.end()) {
genieids.push_back(mode);
modexsec[mode] = (TH1D *)xsechist->Clone();
modecount[mode] = (TH1D *)xsechist->Clone();
modexsec[mode]->GetYaxis()->SetTitle(
"d#sigma/dE_{#nu} #times 10^{-38} (events weighted by #sigma)");
modecount[mode]->GetYaxis()->SetTitle("Number of events in file");
}
// Fill XSec Histograms
modexsec[mode]->Fill(neu->E(), xsec);
modecount[mode]->Fill(neu->E());
// Fill total event hist
eventhist->Fill(neu->E());
// Clear Event
genientpl->Clear();
size_t freq = nevt / 20;
if (freq && !(i % freq)) {
- QLOG(FIT, "Processed "
+ NUIS_LOG(FIT, "Processed "
<< i << "/" << nevt << " GENIE events (E: " << neu->E()
<< " GeV, xsec: " << xsec << " E-38 cm^2/nucleon)");
}
}
- QLOG(FIT, "Processed all events");
+ NUIS_LOG(FIT, "Processed all events");
TFile *outputfile;
// If no output is specified just append to the file
if (!gOutputFile.length()) {
tn->GetEntry(0);
outputfile = tn->GetFile();
outputfile->cd();
} else {
outputfile = new TFile(gOutputFile.c_str(), "RECREATE");
outputfile->cd();
- QLOG(FIT, "Cloning input vector to output file: " << gOutputFile);
+ NUIS_LOG(FIT, "Cloning input vector to output file: " << gOutputFile);
TTree *cloneTree = tn->CloneTree(-1, "fast");
cloneTree->SetDirectory(outputfile);
cloneTree->Write();
- QLOG(FIT, "Cloning input nova_wgts to output file: " << gOutputFile);
+ NUIS_LOG(FIT, "Cloning input nova_wgts to output file: " << gOutputFile);
// ***********************************
// ***********************************
// FUDGE FOR NOVA MINERVA WORKSHOP
// Also check for the nova_wgts tree from Jeremy
TChain *nova_chain = new TChain("nova_wgts");
nova_chain->AddFile(input.c_str());
TTree *nova_tree = nova_chain->GetTree();
if (!nova_tree) {
- QLOG(FIT, "Could not find nova_wgts tree in " << gOutputFile);
+ NUIS_LOG(FIT, "Could not find nova_wgts tree in " << gOutputFile);
} else {
- QLOG(FIT, "Found nova_wgts tree in " << gOutputFile);
+ NUIS_LOG(FIT, "Found nova_wgts tree in " << gOutputFile);
}
if (nova_tree) {
nova_tree->SetDirectory(outputfile);
nova_tree->Write();
}
- QLOG(FIT, "Done cloning tree.");
+ NUIS_LOG(FIT, "Done cloning tree.");
}
- QLOG(FIT, "Getting splines in mono-energetic...");
+ NUIS_LOG(FIT, "Getting splines in mono-energetic...");
// Save each of the reconstructed splines to file
std::map modeavg;
TDirectory *inddir = (TDirectory *)outputfile->Get("IndividualGENIESplines");
if (!inddir)
inddir = (TDirectory *)outputfile->mkdir("IndividualGENIESplines");
inddir->cd();
// Loop over GENIE ID's and get MEC count
int MECcount = 0;
bool MECcorrect = FitPar::Config().GetParB("CorrectGENIEMECNorm");
for (UInt_t i = 0; i < genieids.size(); i++) {
if (genieids[i].find("MEC") != std::string::npos) {
MECcount++;
}
}
- QLOG(FIT, "Found " << MECcount << " repeated MEC instances.");
+ NUIS_LOG(FIT, "Found " << MECcount << " repeated MEC instances.");
for (UInt_t i = 0; i < genieids.size(); i++) {
std::string mode = genieids[i];
modexsec[mode]->Write((mode + "_summed_xsec").c_str(), TObject::kOverwrite);
modecount[mode]->Write((mode + "_summed_evt").c_str(), TObject::kOverwrite);
// Form extra avg xsec map -> Reconstructed spline
modeavg[mode] = (TH1D *)modexsec[mode]->Clone();
modeavg[mode]->GetYaxis()->SetTitle(
"#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/target)");
modeavg[mode]->Divide(modecount[mode]);
if (MECcorrect && (mode.find("MEC") != std::string::npos)) {
modeavg[mode]->Scale(1.0 / double(MECcount));
}
modeavg[mode]->Write((mode + "_rec_spline").c_str(), TObject::kOverwrite);
}
TDirectory *targdir = (TDirectory *)outputfile->Get("TargetGENIESplines");
if (!targdir)
targdir = (TDirectory *)outputfile->mkdir("TargetGENIESplines");
targdir->cd();
- QLOG(FIT, "Getting Target Splines");
+ NUIS_LOG(FIT, "Getting Target Splines");
// For each target save a total spline
std::map targetsplines;
for (uint i = 0; i < targetids.size(); i++) {
std::string targ = targetids[i];
- QLOG(FIT, "Getting target " << i << ": " << targ);
+ NUIS_LOG(FIT, "Getting target " << i << ": " << targ);
targetsplines[targ] = (TH1D *)xsechist->Clone();
targetsplines[targ]->GetYaxis()->SetTitle(
"#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/target)");
- QLOG(FIT, "Created target spline for " << targ);
+ NUIS_LOG(FIT, "Created target spline for " << targ);
for (uint j = 0; j < genieids.size(); j++) {
std::string mode = genieids[j];
if (mode.find(targ) != std::string::npos) {
- QLOG(FIT, " Mode " << mode << " contains " << targ << " target");
+ NUIS_LOG(FIT, " Mode " << mode << " contains " << targ << " target");
targetsplines[targ]->Add(modeavg[mode]);
- QLOG(FIT,
+ NUIS_LOG(FIT,
"Finished with Mode " << mode << " " << modeavg[mode]->Integral());
}
}
- QLOG(FIT, "Saving target spline:" << targ);
+ NUIS_LOG(FIT, "Saving target spline:" << targ);
targetsplines[targ]->Write(("Total_" + targ).c_str(), TObject::kOverwrite);
}
- QLOG(FIT, "Getting total splines");
+ NUIS_LOG(FIT, "Getting total splines");
// Now we have each of the targets we need to create a total cross-section.
int totalnucl = 0;
// Get the targets specified by the user, separated by commas
// This has structure target1[fraction1], target2[fraction2]
std::vector targprs = GeneralUtils::ParseToStr(target, ",");
std::vector targ_list;
std::vector frac_list;
// Chop up the target string which has format
// TARGET1[fraction1],TARGET2[fraction2]
// std::cout << "Targets: " << std::endl;
// Loop over the vector of strings "TARGET1[fraction1]" "TARGET2[fraction2]"
for (std::vector::iterator it = targprs.begin();
it != targprs.end(); ++it) {
// Cut into "TARGET1" and "fraction1]"
std::vector targind = GeneralUtils::ParseToStr(*it, "[");
// std::cout << " " << *it << std::endl;
// Cut into "TARGET1" and "fraction1"
for (std::vector::iterator jt = targind.begin();
jt != targind.end(); ++jt) {
if ((*jt).find("]") != std::string::npos) {
(*jt) = (*jt).substr(0, (*jt).find("]"));
//*jt = "hello";
frac_list.push_back(*jt);
// Won't find bracket for target
} else {
targ_list.push_back(*jt);
}
}
}
targprs = targ_list;
std::vector targ_fractions;
double minimum = 1.0;
for (std::vector::iterator it = frac_list.begin();
it != frac_list.end(); it++) {
// std::cout << " " << *it << std::endl;
double frac = std::atof((*it).c_str());
targ_fractions.push_back(frac);
if (frac < minimum)
minimum = frac;
}
std::vector::iterator it = targ_fractions.begin();
std::vector::iterator jt = targ_list.begin();
double scaling = 0;
for (; it != targ_fractions.end(); it++, jt++) {
// First get the mass number from the targ_list
int nucl = atoi((*jt).c_str());
nucl = (nucl % 10000) / 10;
// Gets the relative portions right
*it = (*it) / minimum;
// Scale relative the atomic mass
//(*it) *= (double(nucl)/(*it));
double tempscaling = double(nucl) / (*it);
if (tempscaling > scaling)
scaling = tempscaling;
}
it = targ_fractions.begin();
for (; it != targ_fractions.end(); it++) {
// Round the scaling to nearest integer and multiply
*it *= int(scaling + 0.5);
// Round to nearest integer
*it = int(*it + 0.5);
totalnucl += *it;
}
if (totalnucl == 0) {
- QTHROW("Didn't find any nucleons in input file. Did you really specify the "
+ NUIS_ABORT("Didn't find any nucleons in input file. Did you really specify the "
"target ratios?\ne.g. TARGET1[fraction1],TARGET2[fraction2]");
}
TH1D *totalxsec = (TH1D *)xsechist->Clone();
for (uint i = 0; i < targprs.size(); i++) {
std::string targpdg = targprs[i];
// Check that we found the user requested target in GENIE
bool FoundTarget = false;
for (std::map::iterator iter = targetsplines.begin();
iter != targetsplines.end(); iter++) {
std::string targstr = iter->first;
TH1D *xsec = iter->second;
// Match the user targets to the targets found in GENIE
if (targstr.find(targpdg) != std::string::npos) {
FoundTarget = true;
- QLOG(FIT, "Adding target spline "
+ NUIS_LOG(FIT, "Adding target spline "
<< targstr << " Integral = " << xsec->Integral("width"));
totalxsec->Add(xsec);
// int nucl = atoi(targpdg.c_str());
// totalnucl += int((nucl % 10000) / 10);
}
}
// Check that targets were all found
if (!FoundTarget) {
- QERROR(WRN, "Didn't find target "
+ NUIS_ERR(WRN, "Didn't find target "
<< targpdg
<< " in the list of targets recorded by GENIE");
- QERROR(WRN, " The list of targets you requested is: ");
+ NUIS_ERR(WRN, " The list of targets you requested is: ");
for (uint i = 0; i < targprs.size(); ++i)
- QERROR(WRN, " " << targprs[i]);
- QERROR(WRN, " The list of targets found in GENIE is: ");
+ NUIS_ERR(WRN, " " << targprs[i]);
+ NUIS_ERR(WRN, " The list of targets found in GENIE is: ");
for (std::map::iterator iter = targetsplines.begin();
iter != targetsplines.end(); iter++)
- QERROR(WRN, " " << iter->first);
+ NUIS_ERR(WRN, " " << iter->first);
}
}
outputfile->cd();
totalxsec->GetYaxis()->SetTitle(
"#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/nucleon)");
totalxsec->Write("nuisance_xsec", TObject::kOverwrite);
eventhist = (TH1D *)fluxhist->Clone();
eventhist->Multiply(totalxsec);
eventhist->GetYaxis()->SetTitle(
(std::string("Event rate (N = #sigma #times #Phi) #times 10^{-38} "
"(cm^{2}/nucleon) #times ") +
eventhist->GetYaxis()->GetTitle())
.c_str());
- QLOG(FIT, "Dividing by Total Nucl = " << totalnucl);
+ NUIS_LOG(FIT, "Dividing by Total Nucl = " << totalnucl);
eventhist->Scale(1.0 / double(totalnucl));
eventhist->Write("nuisance_events", TObject::kOverwrite);
fluxhist->Write("nuisance_flux", TObject::kOverwrite);
- QLOG(FIT, "Inclusive XSec Per Nucleon = " << eventhist->Integral("width") *
+ NUIS_LOG(FIT, "Inclusive XSec Per Nucleon = " << eventhist->Integral("width") *
1E-38 /
fluxhist->Integral("width"));
- QLOG(FIT, "XSec Hist Integral = " << totalxsec->Integral("width"));
+ NUIS_LOG(FIT, "XSec Hist Integral = " << totalxsec->Integral("width"));
outputfile->Close();
return;
}
void RunGENIEPrepare(std::string input, std::string flux, std::string target,
std::string output) {
- QLOG(FIT, "Running GENIE Prepare with flux...");
+ NUIS_LOG(FIT, "Running GENIE Prepare with flux...");
// Get Flux Hist
std::vector fluxvect = GeneralUtils::ParseToStr(flux, ",");
TH1 *fluxhist = NULL;
if (fluxvect.size() == 3) {
double from = GeneralUtils::StrToDbl(fluxvect[0]);
double to = GeneralUtils::StrToDbl(fluxvect[1]);
double step = GeneralUtils::StrToDbl(fluxvect[2]);
int nstep = ceil((to - from) / step);
to = from + step * nstep;
- QLOG(FIT, "Generating flat flux histogram from "
+ NUIS_LOG(FIT, "Generating flat flux histogram from "
<< from << " to " << to << " with bins " << step
<< " wide (NBins = " << nstep << ").");
fluxhist =
new TH1D("spectrum", ";E_{#nu} (GeV);Count (A.U.)", nstep, from, to);
for (Int_t bi_it = 1; bi_it < fluxhist->GetXaxis()->GetNbins(); ++bi_it) {
fluxhist->SetBinContent(bi_it, 1.0 / double(step * nstep));
}
fluxhist->SetDirectory(0);
} else if (fluxvect.size() == 2) {
TFile *fluxfile = new TFile(fluxvect[0].c_str(), "READ");
if (!fluxfile->IsZombie()) {
fluxhist = dynamic_cast(fluxfile->Get(fluxvect[1].c_str()));
if (!fluxhist) {
- QERROR(FTL, "Couldn't find histogram named: \""
+ NUIS_ERR(FTL, "Couldn't find histogram named: \""
<< fluxvect[1] << "\" in file: \"" << fluxvect[0]);
throw;
}
fluxhist->SetDirectory(0);
}
} else if (fluxvect.size() == 1) {
MonoEnergy = GeneralUtils::StrToDbl(fluxvect[0]);
RunGENIEPrepareMono(input, target, output);
return;
} else {
- QLOG(FTL, "Bad flux specification: \"" << flux << "\".");
+ NUIS_LOG(FTL, "Bad flux specification: \"" << flux << "\".");
throw;
}
// Setup TTree
TChain *tn = new TChain("gtree");
std::string first_file = "";
if (input.find_first_of(',') != std::string::npos) {
std::vector inputvect = GeneralUtils::ParseToStr(input, ",");
for (size_t iv_it = 0; iv_it < inputvect.size(); ++iv_it) {
tn->AddFile(inputvect[iv_it].c_str());
- QLOG(FIT, "Added input file: " << inputvect[iv_it]);
+ NUIS_LOG(FIT, "Added input file: " << inputvect[iv_it]);
if (!first_file.length()) {
first_file = inputvect[iv_it];
}
}
} else { // The Add form can accept wildcards.
tn->Add(input.c_str());
first_file = input;
}
if (tn->GetFile() == NULL) {
tn->Print();
- QERROR(FTL, "gtree not located in GENIE file: " << input);
- QTHROW("Check your inputs, they may need to be completely regenerated!");
+ NUIS_ERR(FTL, "gtree not located in GENIE file: " << input);
+ NUIS_ABORT("Check your inputs, they may need to be completely regenerated!");
throw;
}
int nevt = tn->GetEntries();
if (gNEvents != -999) {
- QLOG(FIT, "Overriding number of events by user from " << nevt << " to "
+ NUIS_LOG(FIT, "Overriding number of events by user from " << nevt << " to "
<< gNEvents);
nevt = gNEvents;
}
if (!nevt) {
- QTHROW("Couldn't load any events from input specification: \""
+ NUIS_ABORT("Couldn't load any events from input specification: \""
<< input.c_str() << "\"");
} else {
- QLOG(FIT, "Found " << nevt << " input entries in " << input);
+ NUIS_LOG(FIT, "Found " << nevt << " input entries in " << input);
}
NtpMCEventRecord *genientpl = NULL;
tn->SetBranchAddress("gmcrec", &genientpl);
// Make Event and xsec Hist
TH1D *eventhist = (TH1D *)fluxhist->Clone();
eventhist->SetDirectory(NULL);
eventhist->Reset();
TH1D *xsechist = (TH1D *)eventhist->Clone();
xsechist->SetDirectory(NULL);
// Create maps
std::map modexsec;
std::map modecount;
std::vector genieids;
std::vector targetids;
std::vector interids;
// Loop over all events
for (int i = 0; i < nevt; i++) {
tn->GetEntry(i);
// Hussssch GENIE
StopTalking();
// Get the event
EventRecord &event = *(genientpl->event);
// Get the neutrino
GHepParticle *neu = event.Probe();
StartTalking();
// Get XSec From Spline
// Get the GHepRecord
GHepRecord genie_record = static_cast(event);
double xsec = (genie_record.XSec() / (1E-38 * genie::units::cm2));
// Parse Interaction String
std::string mode = genie_record.Summary()->AsString();
std::vector modevec = GeneralUtils::ParseToStr(mode, ";");
std::string targ = (modevec[0] + ";" + modevec[1]);
std::string inter = mode;
// Get target nucleus
// Alternative ways of getting the summaries
// GHepParticle *target = genie_record.TargetNucleus();
// int pdg = target->Pdg();
// Fill lists of Unique IDS (neutrino and target)
if (std::find(targetids.begin(), targetids.end(), targ) ==
targetids.end()) {
targetids.push_back(targ);
}
// The full interaction list
if (std::find(interids.begin(), interids.end(), inter) == interids.end()) {
interids.push_back(inter);
}
// Create entries Mode Maps
if (modexsec.find(mode) == modexsec.end()) {
genieids.push_back(mode);
modexsec[mode] = (TH1D *)xsechist->Clone();
modecount[mode] = (TH1D *)xsechist->Clone();
modexsec[mode]->SetDirectory(NULL);
modecount[mode]->SetDirectory(NULL);
modexsec[mode]->GetYaxis()->SetTitle(
"d#sigma/dE_{#nu} #times 10^{-38} (events weighted by #sigma)");
modecount[mode]->GetYaxis()->SetTitle("Number of events in file");
}
// Fill XSec Histograms
modexsec[mode]->Fill(neu->E(), xsec);
modecount[mode]->Fill(neu->E());
// Fill total event hist
eventhist->Fill(neu->E());
if (i % (nevt / 20) == 0) {
- QLOG(FIT, "Processed "
+ NUIS_LOG(FIT, "Processed "
<< i << "/" << nevt << " GENIE events (E: " << neu->E()
<< " GeV, xsec: " << xsec << " E-38 cm^2/nucleon)");
}
// Clear Event
genientpl->Clear();
}
- QLOG(FIT, "Processed all events");
+ NUIS_LOG(FIT, "Processed all events");
// Once event loop is done we can start saving stuff into the file
TFile *outputfile;
if (!gOutputFile.length()) {
// Shut the chain;
delete tn;
outputfile = new TFile(first_file.c_str(), "UPDATE");
} else {
outputfile = new TFile(gOutputFile.c_str(), "RECREATE");
outputfile->cd();
- QLOG(FIT, "Cloning input vector to output file: " << gOutputFile);
+ NUIS_LOG(FIT, "Cloning input vector to output file: " << gOutputFile);
TTree *cloneTree = tn->CloneTree(-1, "fast");
cloneTree->SetDirectory(outputfile);
cloneTree->Write();
// ********************************
// CLUDGE KLUDGE KLUDGE FOR NOVA
- QLOG(FIT, "Cloning input nova_wgts to output file: " << gOutputFile);
+ NUIS_LOG(FIT, "Cloning input nova_wgts to output file: " << gOutputFile);
// Also check for the nova_wgts tree from Jeremy
TChain *nova_chain = new TChain("nova_wgts");
nova_chain->AddFile(input.c_str());
TTree *nova_tree = nova_chain->CloneTree(-1, "fast");
if (!nova_tree) {
- QLOG(FIT, "Could not find nova_wgts tree in " << input);
+ NUIS_LOG(FIT, "Could not find nova_wgts tree in " << input);
} else {
- QLOG(FIT, "Found nova_wgts tree in " << input);
+ NUIS_LOG(FIT, "Found nova_wgts tree in " << input);
nova_tree->SetDirectory(outputfile);
nova_tree->Write();
}
- QLOG(FIT, "Done cloning tree.");
+ NUIS_LOG(FIT, "Done cloning tree.");
}
- QLOG(FIT, "Getting splines...");
+ NUIS_LOG(FIT, "Getting splines...");
// Save each of the reconstructed splines to file
std::map modeavg;
TDirectory *inddir = (TDirectory *)outputfile->Get("IndividualGENIESplines");
if (!inddir)
inddir = (TDirectory *)outputfile->mkdir("IndividualGENIESplines");
inddir->cd();
// Loop over GENIE ID's and get MEC count
int MECcount = 0;
bool MECcorrect = FitPar::Config().GetParB("CorrectGENIEMECNorm");
for (UInt_t i = 0; i < genieids.size(); i++) {
if (genieids[i].find("MEC") != std::string::npos) {
MECcount++;
}
}
- QLOG(FIT, "Found " << MECcount << " repeated MEC instances.");
+ NUIS_LOG(FIT, "Found " << MECcount << " repeated MEC instances.");
for (UInt_t i = 0; i < genieids.size(); i++) {
std::string mode = genieids[i];
modexsec[mode]->Write((mode + "_summed_xsec").c_str(), TObject::kOverwrite);
modecount[mode]->Write((mode + "_summed_evt").c_str(), TObject::kOverwrite);
// Form extra avg xsec map -> Reconstructed spline
modeavg[mode] = (TH1D *)modexsec[mode]->Clone();
modeavg[mode]->GetYaxis()->SetTitle(
"#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/target)");
modeavg[mode]->Divide(modecount[mode]);
if (MECcorrect && (mode.find("MEC") != std::string::npos)) {
modeavg[mode]->Scale(1.0 / double(MECcount));
}
modeavg[mode]->Write((mode + "_rec_spline").c_str(), TObject::kOverwrite);
}
TDirectory *targdir = (TDirectory *)outputfile->Get("TargetGENIESplines");
if (!targdir)
targdir = (TDirectory *)outputfile->mkdir("TargetGENIESplines");
targdir->cd();
- QLOG(FIT, "Getting Target Splines");
+ NUIS_LOG(FIT, "Getting Target Splines");
// For each target save a total spline
std::map targetsplines;
for (uint i = 0; i < targetids.size(); i++) {
std::string targ = targetids[i];
- QLOG(FIT, "Getting target " << i << ": " << targ);
+ NUIS_LOG(FIT, "Getting target " << i << ": " << targ);
targetsplines[targ] = (TH1D *)xsechist->Clone();
targetsplines[targ]->GetYaxis()->SetTitle(
"#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/target)");
- QLOG(FIT, "Created target spline for " << targ);
+ NUIS_LOG(FIT, "Created target spline for " << targ);
for (uint j = 0; j < genieids.size(); j++) {
std::string mode = genieids[j];
// Look at all matching modes/targets
if (mode.find(targ) != std::string::npos) {
- QLOG(FIT, " Mode " << mode << " contains " << targ << " target");
+ NUIS_LOG(FIT, " Mode " << mode << " contains " << targ << " target");
targetsplines[targ]->Add(modeavg[mode]);
- QLOG(FIT,
+ NUIS_LOG(FIT,
"Finished with Mode " << mode << " " << modeavg[mode]->Integral());
}
}
- QLOG(FIT, "Saving target spline: " << targ);
+ NUIS_LOG(FIT, "Saving target spline: " << targ);
targetsplines[targ]->Write(("Total_" + targ).c_str(), TObject::kOverwrite);
}
- QLOG(FIT, "Getting total splines");
+ NUIS_LOG(FIT, "Getting total splines");
// Now we have each of the targets we need to create a total cross-section.
int totalnucl = 0;
// This has structure target1[fraction1], target2[fraction2]
std::vector targprs = GeneralUtils::ParseToStr(target, ",");
std::vector targ_list;
std::vector frac_list;
// Chop up the target string which has format
// TARGET1[fraction1],TARGET2[fraction2]
// std::cout << "Targets: " << std::endl;
// Loop over the vector of strings "TARGET1[fraction1]" "TARGET2[fraction2]"
for (std::vector::iterator it = targprs.begin();
it != targprs.end(); ++it) {
// Cut into "TARGET1" and "fraction1]"
std::vector targind = GeneralUtils::ParseToStr(*it, "[");
// std::cout << " " << *it << std::endl;
// Cut into "TARGET1" and "fraction1"
for (std::vector::iterator jt = targind.begin();
jt != targind.end(); ++jt) {
if ((*jt).find("]") != std::string::npos) {
(*jt) = (*jt).substr(0, (*jt).find("]"));
//*jt = "hello";
frac_list.push_back(*jt);
// Won't find bracket for target
} else {
targ_list.push_back(*jt);
}
}
}
targprs = targ_list;
std::vector targ_fractions;
double minimum = 1.0;
for (std::vector::iterator it = frac_list.begin();
it != frac_list.end(); it++) {
// std::cout << " " << *it << std::endl;
double frac = std::atof((*it).c_str());
targ_fractions.push_back(frac);
if (frac < minimum)
minimum = frac;
}
std::vector::iterator it = targ_fractions.begin();
std::vector::iterator jt = targ_list.begin();
double scaling = 0;
for (; it != targ_fractions.end(); it++, jt++) {
// First get the mass number from the targ_list
int nucl = atoi((*jt).c_str());
nucl = (nucl % 10000) / 10;
// Gets the relative portions right
*it = (*it) / minimum;
// Scale relative the atomic mass
//(*it) *= (double(nucl)/(*it));
double tempscaling = double(nucl) / (*it);
if (tempscaling > scaling)
scaling = tempscaling;
}
it = targ_fractions.begin();
for (; it != targ_fractions.end(); it++) {
// Round the scaling to nearest integer and multiply
*it *= int(scaling + 0.5);
// Round to nearest integer
*it = int(*it + 0.5);
totalnucl += *it;
}
if (totalnucl == 0) {
- QTHROW("Didn't find any nucleons in input file. Did you really specify the "
+ NUIS_ABORT("Didn't find any nucleons in input file. Did you really specify the "
"target ratios?\ne.g. TARGET1[fraction1],TARGET2[fraction2]");
}
TH1D *totalxsec = (TH1D *)xsechist->Clone();
// Loop over the specified targets by the user
for (uint i = 0; i < targprs.size(); i++) {
std::string targpdg = targprs[i];
// Check that we found the user requested target in GENIE
bool FoundTarget = false;
for (std::map::iterator iter = targetsplines.begin();
iter != targetsplines.end(); iter++) {
std::string targstr = iter->first;
TH1D *xsec = iter->second;
// Match the user targets to the targets found in GENIE
if (targstr.find(targpdg) != std::string::npos) {
FoundTarget = true;
- QLOG(FIT, "Adding target spline "
+ NUIS_LOG(FIT, "Adding target spline "
<< targstr << " Integral = " << xsec->Integral("width"));
totalxsec->Add(xsec);
// int nucl = atoi(targpdg.c_str());
// totalnucl += int((nucl % 10000) / 10);
}
} // Looped over target splines
// Check that targets were all found
if (!FoundTarget) {
- QERROR(WRN, "Didn't find target "
+ NUIS_ERR(WRN, "Didn't find target "
<< targpdg
<< " in the list of targets recorded by GENIE");
- QERROR(WRN, " The list of targets you requested is: ");
+ NUIS_ERR(WRN, " The list of targets you requested is: ");
for (uint i = 0; i < targprs.size(); ++i)
- QERROR(WRN, " " << targprs[i]);
- QERROR(WRN, " The list of targets found in GENIE is: ");
+ NUIS_ERR(WRN, " " << targprs[i]);
+ NUIS_ERR(WRN, " The list of targets found in GENIE is: ");
for (std::map::iterator iter = targetsplines.begin();
iter != targetsplines.end(); iter++)
- QERROR(WRN, " " << iter->first);
+ NUIS_ERR(WRN, " " << iter->first);
}
}
outputfile->cd();
totalxsec->GetYaxis()->SetTitle(
"#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/nucleon)");
totalxsec->Write("nuisance_xsec", TObject::kOverwrite);
eventhist = (TH1D *)fluxhist->Clone();
eventhist->Multiply(totalxsec);
eventhist->GetYaxis()->SetTitle(
(std::string("Event rate (N = #sigma #times #Phi) #times 10^{-38} "
"(cm^{2}/nucleon) #times ") +
eventhist->GetYaxis()->GetTitle())
.c_str());
- QLOG(FIT, "Dividing by Total Nucl = " << totalnucl);
+ NUIS_LOG(FIT, "Dividing by Total Nucl = " << totalnucl);
eventhist->Scale(1.0 / double(totalnucl));
eventhist->Write("nuisance_events", TObject::kOverwrite);
fluxhist->Write("nuisance_flux", TObject::kOverwrite);
- QLOG(FIT, "Inclusive XSec Per Nucleon = " << eventhist->Integral("width") *
+ NUIS_LOG(FIT, "Inclusive XSec Per Nucleon = " << eventhist->Integral("width") *
1E-38 /
fluxhist->Integral("width"));
- QLOG(FIT, "XSec Hist Integral = " << totalxsec->Integral());
+ NUIS_LOG(FIT, "XSec Hist Integral = " << totalxsec->Integral());
outputfile->Close();
return;
};
void PrintOptions() {
std::cout << "PrepareGENIEEvents NUISANCE app. " << std::endl
<< "Takes GHep Outputs and prepares events for NUISANCE."
<< std::endl
<< std::endl
<< "PrepareGENIE [-h,-help,--h,--help] [-i "
"inputfile1.root,inputfile2.root,inputfile3.root,...] "
<< "[-f flux_root_file.root,flux_hist_name] [-t "
"target1[frac1],target2[frac2],...]"
<< "[-n number_of_events (experimental)]" << std::endl
<< std::endl;
std::cout << "Prepare Mode [Default] : Takes a single GHep file, "
"reconstructs the original GENIE splines, "
<< " and creates a duplicate file that also contains the flux, "
"event rate, and xsec predictions that NUISANCE needs. "
<< std::endl;
std::cout << "Following options are required for Prepare Mode:" << std::endl;
std::cout << " [ -i inputfile.root ] : Reads in a single GHep input file "
"that needs the xsec calculation ran on it. "
<< std::endl;
std::cout << " [ -f flux_file.root,hist_name ] : Path to root file "
"containing the flux histogram the GHep records were generated "
"with."
<< " A simple method is to point this to the flux histogram genie "
"generatrs '-f /path/to/events/input-flux.root,spectrum'. "
<< std::endl;
std::cout << " [ -f elow,ehigh,estep ] : Energy range specification when no "
"flux file was used."
<< std::endl;
std::cout << " [ -t target ] : Target that GHepRecords were generated with. "
"Comma seperated list. E.g. for CH2 "
"target=1000060120,1000010010,1000010010"
<< std::endl;
std::cout << " [ -o outputfile.root ] : File to write prepared input file to."
<< std::endl;
std::cout << " [ -m Mono_E_nu_GeV ] : Run in mono-energetic mode with m GeV "
"neutrino energy."
<< std::endl;
std::cout << " [ -n number_of_evt ] : Run with a reduced number of events "
"for debugging purposes"
<< std::endl;
}
void ParseOptions(int argc, char *argv[]) {
bool flagopt = false;
// If No Arguments print commands
for (int i = 1; i < argc; ++i) {
if (!std::strcmp(argv[i], "-h")) {
flagopt = true;
break;
}
if (i + 1 != argc) {
// Cardfile
if (!std::strcmp(argv[i], "-h")) {
flagopt = true;
break;
} else if (!std::strcmp(argv[i], "-i")) {
gInputFiles = argv[i + 1];
++i;
} else if (!std::strcmp(argv[i], "-o")) {
gOutputFile = argv[i + 1];
++i;
} else if (!std::strcmp(argv[i], "-f")) {
gFluxFile = argv[i + 1];
++i;
} else if (!std::strcmp(argv[i], "-t")) {
gTarget = argv[i + 1];
++i;
} else if (!std::strcmp(argv[i], "-n")) {
gNEvents = GeneralUtils::StrToInt(argv[i + 1]);
++i;
} else if (!std::strcmp(argv[i], "-m")) {
MonoEnergy = GeneralUtils::StrToDbl(argv[i + 1]);
IsMonoE = true;
++i;
} else {
- QERROR(FTL, "ERROR: unknown command line option given! - '"
+ NUIS_ERR(FTL, "ERROR: unknown command line option given! - '"
<< argv[i] << " " << argv[i + 1] << "'");
PrintOptions();
break;
}
}
}
if (gInputFiles == "" && !flagopt) {
- QERROR(FTL, "No input file(s) specified!");
+ NUIS_ERR(FTL, "No input file(s) specified!");
flagopt = true;
}
if (gFluxFile == "" && !flagopt && !IsMonoE) {
- QERROR(FTL, "No flux input specified for Prepare Mode");
+ NUIS_ERR(FTL, "No flux input specified for Prepare Mode");
flagopt = true;
}
if (gTarget == "" && !flagopt) {
- QERROR(FTL, "No target specified for Prepare Mode");
+ NUIS_ERR(FTL, "No target specified for Prepare Mode");
flagopt = true;
}
if (gTarget.find("[") == std::string::npos ||
gTarget.find("]") == std::string::npos) {
- QERROR(FTL, "Didn't specify target ratios in Prepare Mode");
- QERROR(FTL, "Are you sure you gave it as -t "
+ NUIS_ERR(FTL, "Didn't specify target ratios in Prepare Mode");
+ NUIS_ERR(FTL, "Are you sure you gave it as -t "
"\"TARGET1[fraction1],TARGET2[fraction]\"?");
flagopt = true;
}
if (argc < 1 || flagopt) {
PrintOptions();
exit(-1);
}
return;
}
diff --git a/app/PrepareNEUT.cxx b/app/PrepareNEUT.cxx
index 0d929f6..d95d069 100644
--- a/app/PrepareNEUT.cxx
+++ b/app/PrepareNEUT.cxx
@@ -1,416 +1,416 @@
#include "FitLogger.h"
#include "PlotUtils.h"
#include "StatUtils.h"
#include "TFile.h"
#include "TH1D.h"
#include "TTree.h"
#include
#include
// If you don't have NEUT enabled, you shouldn't compile this...
#include "neutpart.h"
#include "neutvect.h"
std::string fInputFiles = "";
std::string fOutputFile = "";
std::string fFluxFile = "";
bool fFluxInGeV = false;
bool fIsMonoEFlux = false;
double fMonoEEnergy = 0xdeadbeef;
void PrintOptions();
void ParseOptions(int argc, char *argv[]);
void AddMonoRateHistogram(std::string inputList, double MonoE,
std::string output);
void CreateRateHistogram(std::string inputList, std::string flux,
std::string output);
//*******************************
int main(int argc, char *argv[]) {
//*******************************
LOG_VERB(FitPar::Config().GetParI("VERBOSITY"));
ERR_VERB(FitPar::Config().GetParI("ERROR"));
ParseOptions(argc, argv);
- QLOG(FIT, "Running PrepareNEUT");
+ NUIS_LOG(FIT, "Running PrepareNEUT");
if (fIsMonoEFlux) {
AddMonoRateHistogram(fInputFiles, fMonoEEnergy, fOutputFile);
} else {
CreateRateHistogram(fInputFiles, fFluxFile, fOutputFile);
}
};
void AddMonoRateHistogram(std::string inputList, double MonoE,
std::string output) {
// Need to allow for more than one file... will do soon
TChain *tn = new TChain("neuttree");
std::vector inputs = GeneralUtils::ParseToStr(inputList, ",");
for (std::vector::iterator it = inputs.begin();
it != inputs.end(); ++it) {
- QLOG(FIT, "Adding " << *it << " to the output");
+ NUIS_LOG(FIT, "Adding " << *it << " to the output");
tn->AddFile((*it).c_str());
}
if (inputs.size() > 1 && output.empty()) {
- QTHROW("You must provide a new output file name if you want to have "
+ NUIS_ABORT("You must provide a new output file name if you want to have "
"more than 1 input file!");
}
int nevts = tn->GetEntries();
if (!nevts) {
- QTHROW("Either the input file is not from NEUT, or it's empty...");
+ NUIS_ABORT("Either the input file is not from NEUT, or it's empty...");
}
NeutVect *fNeutVect = NULL;
tn->SetBranchAddress("vectorbranch", &fNeutVect);
TH1D *fluxHist = new TH1D("flux", "flux", 1000, 0, fFluxInGeV ? 10 : 10000);
fluxHist->Fill(MonoE);
fluxHist->Scale(1, "width");
// Make Event Hist
TH1D *xsecHist = (TH1D *)fluxHist->Clone();
xsecHist->Reset();
// Make a total cross section hist for shits and giggles
TH1D *entryHist = (TH1D *)xsecHist->Clone();
double MeanE = 0;
for (int i = 0; i < nevts; ++i) {
tn->GetEntry(i);
NeutPart *part = fNeutVect->PartInfo(0);
double E = part->fP.E();
double xsec = fNeutVect->Totcrs;
// Unit conversion
if (fFluxInGeV)
E *= 1E-3;
xsecHist->Fill(E, xsec);
entryHist->Fill(E);
MeanE += E;
if (i % (nevts / 20) == 0) {
- QLOG(FIT, "Processed " << i << "/" << nevts << " NEUT events.");
+ NUIS_LOG(FIT, "Processed " << i << "/" << nevts << " NEUT events.");
}
}
MeanE /= double(nevts);
- QLOG(FIT, "Processed all events");
+ NUIS_LOG(FIT, "Processed all events");
xsecHist->Divide(entryHist);
// This will be the evtrt histogram
TH1D *evtHist = (TH1D *)xsecHist->Clone();
evtHist->Multiply(fluxHist);
// Check whether the overflow is empty. If not, advise that either the wrong
// flux histogram or units were used...
// If the events were generated with a limited range of the flux histogram,
// this may be benign
if (evtHist->Integral(0, -1) != evtHist->Integral() ||
evtHist->Integral(0, -1) == 0) {
- QERROR(WRN, "The input file("
+ NUIS_ERR(WRN, "The input file("
<< evtHist->Integral(0, -1)
<< ") and flux histogram provided do not match... ");
- QERROR(WRN, "Are the units correct (MeanE = "
+ NUIS_ERR(WRN, "Are the units correct (MeanE = "
<< MeanE << ", FluxHistoUpperLim: "
<< fluxHist->GetXaxis()->GetBinUpEdge(1000)
<< ")? Did you provide the correct flux file?");
- QERROR(WRN, "Use output with caution...");
+ NUIS_ERR(WRN, "Use output with caution...");
}
// Pick where the output should go
TFile *outFile = NULL;
if (!output.empty()) {
- QLOG(FIT, "Saving histograms in " << output);
+ NUIS_LOG(FIT, "Saving histograms in " << output);
outFile = new TFile(output.c_str(), "RECREATE");
} else {
- QLOG(FIT, "Saving histograms in " << inputs[0]);
+ NUIS_LOG(FIT, "Saving histograms in " << inputs[0]);
outFile = new TFile(inputs[0].c_str(), "UPDATE");
}
outFile->cd();
std::string xsec_name = "xsec_PrepareNeut";
std::string flux_name = "flux_PrepareNeut";
std::string rate_name = "evtrt_PrepareNeut";
if (output.empty()) {
// Check whether we should overwrite existing histograms
std::string input_xsec = PlotUtils::GetObjectWithName(outFile, "xsec");
std::string input_flux = PlotUtils::GetObjectWithName(outFile, "flux");
std::string input_rate = PlotUtils::GetObjectWithName(outFile, "evtrt");
if (!input_xsec.empty()) {
- QLOG(FIT, "Updating histogram: " << input_xsec);
+ NUIS_LOG(FIT, "Updating histogram: " << input_xsec);
xsec_name = input_xsec;
}
if (!input_flux.empty()) {
- QLOG(FIT, "Updating histogram: " << input_flux);
+ NUIS_LOG(FIT, "Updating histogram: " << input_flux);
flux_name = input_flux;
}
if (!input_rate.empty()) {
- QLOG(FIT, "Updating histogram: " << input_rate);
+ NUIS_LOG(FIT, "Updating histogram: " << input_rate);
rate_name = input_rate;
}
} else {
- QLOG(FIT, "Cloning neuttree into output file.");
+ NUIS_LOG(FIT, "Cloning neuttree into output file.");
StopTalking();
TTree *newtree = (TTree *)tn->CloneTree(-1, "fast");
StartTalking();
newtree->Write();
}
xsecHist->Write(xsec_name.c_str(), TObject::kOverwrite);
fluxHist->Write(flux_name.c_str(), TObject::kOverwrite);
evtHist->Write(rate_name.c_str(), TObject::kOverwrite);
outFile->Close();
}
//*******************************
void CreateRateHistogram(std::string inputList, std::string flux,
std::string output) {
//*******************************
// Need to allow for more than one file... will do soon
TChain *tn = new TChain("neuttree");
std::vector inputs = GeneralUtils::ParseToStr(inputList, ",");
for (std::vector::iterator it = inputs.begin();
it != inputs.end(); ++it) {
- QLOG(FIT, "Adding " << *it << " to the output");
+ NUIS_LOG(FIT, "Adding " << *it << " to the output");
tn->AddFile((*it).c_str());
}
if (inputs.size() > 1 && output.empty()) {
- QTHROW("You must provide a new output file name if you want to have "
+ NUIS_ABORT("You must provide a new output file name if you want to have "
"more than 1 input file!");
}
int nevts = tn->GetEntries();
if (!nevts) {
- QTHROW("Either the input file is not from NEUT, or it's empty...");
+ NUIS_ABORT("Either the input file is not from NEUT, or it's empty...");
}
NeutVect *fNeutVect = NULL;
tn->SetBranchAddress("vectorbranch", &fNeutVect);
// Get Flux Hist
std::vector fluxvect = GeneralUtils::ParseToStr(flux, ",");
TH1D *fluxHist = NULL;
if (fluxvect.size() > 1) {
TFile *fluxfile = new TFile(fluxvect[0].c_str(), "READ");
fluxHist = (TH1D *)fluxfile->Get(fluxvect[1].c_str());
fluxHist->SetDirectory(0);
} else {
- QTHROW("NO FLUX SPECIFIED");
+ NUIS_ABORT("NO FLUX SPECIFIED");
}
// Decide what type of flux was given
if (fFluxInGeV) {
- QLOG(FIT, "Assuming flux histogram is in GeV");
+ NUIS_LOG(FIT, "Assuming flux histogram is in GeV");
} else {
- QLOG(FIT, "Assuming flux histogram is in MeV");
+ NUIS_LOG(FIT, "Assuming flux histogram is in MeV");
}
// Make Event Hist
TH1D *xsecHist = (TH1D *)fluxHist->Clone();
xsecHist->Reset();
// Make a total cross section hist for shits and giggles
TH1D *entryHist = (TH1D *)xsecHist->Clone();
for (int i = 0; i < nevts; ++i) {
tn->GetEntry(i);
NeutPart *part = fNeutVect->PartInfo(0);
double E = part->fP.E();
double xsec = fNeutVect->Totcrs;
// Unit conversion
if (fFluxInGeV)
E *= 1E-3;
xsecHist->Fill(E, xsec);
entryHist->Fill(E);
if (i % (nevts / 20) == 0) {
- QLOG(FIT, "Processed " << i << "/" << nevts << " NEUT events."
+ NUIS_LOG(FIT, "Processed " << i << "/" << nevts << " NEUT events."
<< "(Enu = " << E << ", xsec = " << xsec << ") ");
}
}
- QLOG(FIT, "Processed all events");
+ NUIS_LOG(FIT, "Processed all events");
xsecHist->Divide(entryHist);
// This will be the evtrt histogram
TH1D *evtHist = NULL;
// If the integral of xsecHist is 0 the input file used a really old version
// of NEUT without Totcrs
if (!xsecHist->Integral(0, -1)) {
- QERROR(WRN, "Old NEUT input file: events will not be correctly normalized");
+ NUIS_ERR(WRN, "Old NEUT input file: events will not be correctly normalized");
evtHist = (TH1D *)entryHist->Clone();
if (evtHist->Integral() != 0)
evtHist->Scale(fluxHist->Integral() / float(evtHist->Integral()));
} else {
evtHist = (TH1D *)xsecHist->Clone();
evtHist->Multiply(fluxHist);
}
// Check whether the overflow is empty. If not, advise that either the wrong
// flux histogram or units were used...
// If the events were generated with a limited range of the flux histogram,
// this may be benign
if (evtHist->Integral(0, -1) != evtHist->Integral() ||
evtHist->Integral(0, -1) == 0) {
- QERROR(WRN, "The input file("
+ NUIS_ERR(WRN, "The input file("
<< evtHist->Integral(0, -1)
<< ") and flux histogram provided do not match... ");
- QERROR(WRN,
+ NUIS_ERR(WRN,
"Are the units correct? Did you provide the correct flux file?");
- QERROR(WRN, "Use output with caution...");
+ NUIS_ERR(WRN, "Use output with caution...");
}
// Pick where the output should go
TFile *outFile = NULL;
if (!output.empty()) {
- QLOG(FIT, "Saving histograms in " << output);
+ NUIS_LOG(FIT, "Saving histograms in " << output);
outFile = new TFile(output.c_str(), "RECREATE");
} else {
- QLOG(FIT, "Saving histograms in " << inputs[0]);
+ NUIS_LOG(FIT, "Saving histograms in " << inputs[0]);
outFile = new TFile(inputs[0].c_str(), "UPDATE");
}
outFile->cd();
std::string xsec_name = "xsec_PrepareNeut";
std::string flux_name = "flux_PrepareNeut";
std::string rate_name = "evtrt_PrepareNeut";
if (output.empty()) {
// Check whether we should overwrite existing histograms
std::string input_xsec = PlotUtils::GetObjectWithName(outFile, "xsec");
std::string input_flux = PlotUtils::GetObjectWithName(outFile, "flux");
std::string input_rate = PlotUtils::GetObjectWithName(outFile, "evtrt");
if (!input_xsec.empty()) {
- QLOG(FIT, "Updating histogram: " << input_xsec);
+ NUIS_LOG(FIT, "Updating histogram: " << input_xsec);
xsec_name = input_xsec;
}
if (!input_flux.empty()) {
- QLOG(FIT, "Updating histogram: " << input_flux);
+ NUIS_LOG(FIT, "Updating histogram: " << input_flux);
flux_name = input_flux;
}
if (!input_rate.empty()) {
- QLOG(FIT, "Updating histogram: " << input_rate);
+ NUIS_LOG(FIT, "Updating histogram: " << input_rate);
rate_name = input_rate;
}
} else {
- QLOG(FIT, "Cloning neuttree into output file.");
+ NUIS_LOG(FIT, "Cloning neuttree into output file.");
StopTalking();
TTree *newtree = (TTree *)tn->CloneTree(-1, "fast");
StartTalking();
newtree->Write();
}
xsecHist->Write(xsec_name.c_str(), TObject::kOverwrite);
fluxHist->Write(flux_name.c_str(), TObject::kOverwrite);
evtHist->Write(rate_name.c_str(), TObject::kOverwrite);
outFile->Close();
return;
}
void PrintOptions() {
std::cout << "PrepareNEUT NUISANCE app. " << std::endl
<< "Produces or recalculates evtrt and flux histograms necessary "
"for NUISANCE normalization."
<< std::endl;
std::cout << "PrepareNEUT: " << std::endl;
std::cout << " [-h,-help,--h,--help]" << std::endl;
std::cout << " -i inputfile1.root,inputfile2.root,inputfile3.root,..."
<< std::endl;
std::cout << " Takes any number of files, but assumes all are "
"produced with a single flux"
<< std::endl;
std::cout << " -f flux_root_file.root,flux_hist_name" << std::endl;
std::cout << " Path to root file containing the flux histogram used "
"when generating the NEUT files"
<< std::endl;
std::cout << " [-o outputfile.root] " << std::endl;
std::cout
<< " If an output file is not given, the input file will be used"
<< std::endl;
std::cout << " If more than one input file is given, an output file "
"must be given"
<< std::endl;
std::cout << " [-G]" << std::endl;
std::cout << " Flux is assumed to be in MeV. This switch indicates "
"the input flux is in GeV"
<< std::endl;
std::cout << " [-m E_nu]" << std::endl;
std::cout << " Used to add dummy flux and evt rate histograms to "
"mono-energetic vectors. Adheres to the -G flag."
<< std::endl;
}
void ParseOptions(int argc, char *argv[]) {
bool flagopt = false;
// If No Arguments print commands
for (int i = 1; i < argc; ++i) {
if (!std::strcmp(argv[i], "-h")) {
flagopt = true;
break;
} else if (!std::strcmp(argv[i], "-G")) {
fFluxInGeV = true;
continue;
}
if (i + 1 != argc) {
// Cardfile
if (!std::strcmp(argv[i], "-h")) {
flagopt = true;
break;
} else if (!std::strcmp(argv[i], "-i")) {
fInputFiles = argv[i + 1];
++i;
} else if (!std::strcmp(argv[i], "-o")) {
fOutputFile = argv[i + 1];
++i;
} else if (!std::strcmp(argv[i], "-f")) {
fFluxFile = argv[i + 1];
++i;
} else if (!std::strcmp(argv[i], "-m")) {
fIsMonoEFlux = true;
fMonoEEnergy = GeneralUtils::StrToDbl(argv[i + 1]);
++i;
} else {
- QERROR(FTL, "ERROR: unknown command line option given! - '"
+ NUIS_ERR(FTL, "ERROR: unknown command line option given! - '"
<< argv[i] << " " << argv[i + 1] << "'");
PrintOptions();
break;
}
}
}
if (fInputFiles == "" && !flagopt) {
- QERROR(FTL, "No input file(s) specified!");
+ NUIS_ERR(FTL, "No input file(s) specified!");
flagopt = true;
}
if (fFluxFile == "" && (!flagopt) && (!fIsMonoEFlux)) {
- QERROR(FTL, "No flux input specified!");
+ NUIS_ERR(FTL, "No flux input specified!");
flagopt = true;
}
if (argc < 1 || flagopt) {
PrintOptions();
exit(-1);
}
return;
}
diff --git a/app/PrepareNuwroEvents.cxx b/app/PrepareNuwroEvents.cxx
index ba52a84..c6daed4 100644
--- a/app/PrepareNuwroEvents.cxx
+++ b/app/PrepareNuwroEvents.cxx
@@ -1,492 +1,492 @@
#include "event1.h"
#include
#include
// Hopefully we don't need these as they're included above.
// #include "params_all.h"
// #include "params.h"
#include "FitLogger.h"
#include "PlotUtils.h"
#include "TFile.h"
#include "TH1D.h"
#include "TTree.h"
void printInputCommands(char *argv[]) {
std::cout << "[USAGE]: " << argv[0]
<< " [-h] [-f] [-F ,] [-o output.root] "
"inputfile.root [file2.root ...]"
<< std::endl
<< "\t-h : Print this message." << std::endl
<< "\t-f : Pass -f argument to '$ hadd' invocation." << std::endl
<< "\t-F : Read input flux from input descriptor." << std::endl
<< "\t-o : Write full output to a new file." << std::endl
<< std::endl;
};
void CreateRateHistograms(std::string inputs, bool force_out);
void HaddNuwroFiles(std::vector &inputs, bool force_out);
bool outputNewFile = false;
std::string ofile = "";
bool haveFluxInputs = false;
struct FluxInputBlob {
FluxInputBlob(std::string _File, std::string _Hist, int _PDG,
double _Fraction)
: File(_File), Hist(_Hist), PDG(_PDG), Fraction(_Fraction) {}
std::string File;
std::string Hist;
int PDG;
double Fraction;
};
std::vector FluxInputs;
bool haddedFiles = false;
TH1D *F2D(TH1F *f) {
Double_t *bins = new Double_t[f->GetXaxis()->GetNbins() + 1];
for (Int_t bi_it = 0; bi_it < f->GetXaxis()->GetNbins(); ++bi_it) {
bins[bi_it] = f->GetXaxis()->GetBinLowEdge(bi_it + 1);
}
bins[f->GetXaxis()->GetNbins()] =
f->GetXaxis()->GetBinUpEdge(f->GetXaxis()->GetNbins());
TH1D *d = new TH1D((std::string(f->GetName()) + "_f").c_str(), f->GetTitle(),
f->GetXaxis()->GetNbins(), bins);
std::cout << "Converted TH1F with " << f->GetXaxis()->GetXbins()
<< " bins : " << std::endl;
for (Int_t bi_it = 0; bi_it < f->GetXaxis()->GetNbins() + 2; ++bi_it) {
d->SetBinContent(bi_it, f->GetBinContent(bi_it));
d->SetBinError(bi_it, f->GetBinError(bi_it));
std::cout << "\tF " << f->GetXaxis()->GetBinLowEdge(bi_it) << "--[" << bi_it
<< "]--" << f->GetXaxis()->GetBinUpEdge(bi_it) << ": "
<< f->GetBinContent(bi_it) << " D "
<< d->GetXaxis()->GetBinLowEdge(bi_it) << "--[" << bi_it << "]--"
<< d->GetXaxis()->GetBinUpEdge(bi_it) << ": "
<< d->GetBinContent(bi_it) << std::endl;
}
delete bins;
return d;
}
TH1D *GetTH1DFromFile(std::string const &rootFile,
std::string const &histName) {
TFile *inpFile = new TFile(rootFile.c_str(), "READ");
if (!inpFile || !inpFile->IsOpen()) {
- QTHROW("Cannot open input root file: " << rootFile
+ NUIS_ABORT("Cannot open input root file: " << rootFile
<< " to read input histo.");
}
TH1D *histD = dynamic_cast(inpFile->Get(histName.c_str()));
if (!histD) {
TH1F *histF = dynamic_cast(inpFile->Get(histName.c_str()));
if (!histF) {
- QTHROW("Cannot find TH1D/F: " << histName << " in root file: " << rootFile
+ NUIS_ABORT("Cannot find TH1D/F: " << histName << " in root file: " << rootFile
<< ".");
}
histD = F2D(histF);
} else {
histD = static_cast(histD->Clone());
}
histD->SetDirectory(NULL);
inpFile->Close();
return histD;
}
//*******************************
int main(int argc, char *argv[]) {
//*******************************
// If No Arguments print commands
if (argc == 1) {
printInputCommands(argv);
return 0;
}
std::vector inputfiles;
bool force_output = false;
// Get Inputs
for (int i = 1; i < argc; ++i) {
if (!std::strcmp(argv[i], "-h")) {
printInputCommands(argv);
return 0;
} else if (!std::strcmp(argv[i], "-f")) {
force_output = true;
} else if (!std::strcmp(argv[i], "-o")) {
outputNewFile = true;
ofile = argv[++i];
} else if (!std::strcmp(argv[i], "-F")) {
std::string inpLine = argv[++i];
std::vector fluxInputDescriptor =
GeneralUtils::ParseToStr(inpLine, ",");
if ((fluxInputDescriptor.size() != 2) &&
(fluxInputDescriptor.size() != 3) &&
(fluxInputDescriptor.size() != 4)) {
- QTHROW("Received -F argument with option: \""
+ NUIS_ABORT("Received -F argument with option: \""
<< inpLine
<< "\", was expecting "
",[,PDG[,speciesFraction]].");
}
haveFluxInputs = true;
FluxInputs.push_back(
FluxInputBlob(fluxInputDescriptor[0], fluxInputDescriptor[1],
(fluxInputDescriptor.size() > 2)
? GeneralUtils::StrToInt(fluxInputDescriptor[2])
: 14,
(fluxInputDescriptor.size() > 3)
? GeneralUtils::StrToDbl(fluxInputDescriptor[3])
: 1));
if (!FluxInputs.back().File.length() ||
!FluxInputs.back().Hist.length()) {
- QTHROW("Received -F argument with option: \""
+ NUIS_ABORT("Received -F argument with option: \""
<< inpLine
<< "\", was expecting "
",[,PDG[,speciesFraction]].");
}
} else {
inputfiles.push_back(std::string(argv[i]));
}
}
// If one input file just create flux histograms
if (inputfiles.size() > (UInt_t)1) {
HaddNuwroFiles(inputfiles, force_output);
} else if (inputfiles.size() < (UInt_t)1) {
printInputCommands(argv);
}
CreateRateHistograms(inputfiles[0], force_output);
- QLOG(FIT, "Finished NUWRO Prep.");
+ NUIS_LOG(FIT, "Finished NUWRO Prep.");
};
//*******************************
void CreateRateHistograms(std::string inputs, bool force_out) {
//*******************************
// Open root file
TFile *outRootFile = 0;
TTree *nuwrotree = 0;
if (!haddedFiles &&
outputNewFile) { // we need to make the new file and clone the tree.
TFile *inpFile = new TFile(inputs.c_str(), "READ");
if (!inpFile || !inpFile->IsOpen()) {
- QTHROW("Cannot open input root file: " << inputs);
+ NUIS_ABORT("Cannot open input root file: " << inputs);
}
TTree *inpTree = dynamic_cast(inpFile->Get("treeout"));
if (!inpTree) {
- QTHROW("Cannot find TTree \"treeout\" in input root file: "
+ NUIS_ABORT("Cannot find TTree \"treeout\" in input root file: "
<< inputs.c_str());
}
outRootFile = new TFile(ofile.c_str(), force_out ? "RECREATE" : "CREATE");
if (!outRootFile || !outRootFile->IsOpen()) {
- QTHROW("Couldn't open root file: "
+ NUIS_ABORT("Couldn't open root file: "
<< ofile << " for writing, does it already exist?");
}
nuwrotree = inpTree->CloneTree(-1, "fast");
nuwrotree->SetDirectory(outRootFile);
nuwrotree->Write(nuwrotree->GetName());
} else {
outRootFile = new TFile(inputs.c_str(), "UPDATE");
if (!outRootFile || !outRootFile->IsOpen()) {
- QTHROW("Cannot open input root file: " << inputs);
+ NUIS_ABORT("Cannot open input root file: " << inputs);
}
nuwrotree = dynamic_cast(outRootFile->Get("treeout"));
if (!nuwrotree) {
- QTHROW("Cannot find TTree \"treeout\" in input root file: "
+ NUIS_ABORT("Cannot find TTree \"treeout\" in input root file: "
<< inputs.c_str());
}
}
// Get Flux Histogram
event *evt = new event();
nuwrotree->SetBranchAddress("e", &evt);
nuwrotree->GetEntry(0);
int fluxtype = evt->par.beam_type;
std::map fluxlist;
std::map eventlist;
std::vector allpdg;
std::map nevtlist;
std::map intxseclist;
// Did the input file have a mono-energetic flux?
bool isMono = false;
nevtlist[0] = 0.0;
intxseclist[0] = 0.0;
allpdg.push_back(0);
- QLOG(FIT, "Nuwro fluxtype = " << fluxtype);
+ NUIS_LOG(FIT, "Nuwro fluxtype = " << fluxtype);
if (haveFluxInputs) {
double totalFraction = 0;
for (size_t flux_it = 0; flux_it < FluxInputs.size(); ++flux_it) {
FluxInputBlob &fb = FluxInputs[flux_it];
int pdg = fb.PDG;
TH1D *fluxHist = GetTH1DFromFile(fb.File, fb.Hist);
double pctg = fb.Fraction;
totalFraction += pctg;
double Elow = fluxHist->GetXaxis()->GetBinLowEdge(1);
double Ehigh = fluxHist->GetXaxis()->GetBinLowEdge(
fluxHist->GetXaxis()->GetNbins() + 1);
- QLOG(FIT, "Adding new nuwro flux "
+ NUIS_LOG(FIT, "Adding new nuwro flux "
<< "pdg: " << pdg << " pctg: " << pctg << " Elow: " << Elow
<< " Ehigh: " << Ehigh);
// Sort total flux plot
if (!fluxlist[0]) {
// Setup total flux
fluxlist[0] = (TH1D *)fluxHist->Clone();
fluxlist[0]->SetNameTitle("FluxHist", "FluxHist");
// Prep empty total events
eventlist[0] = (TH1D *)fluxHist->Clone();
eventlist[0]->SetNameTitle("EvtHist", "EvtHist");
eventlist[0]->Reset();
} else {
// Add up each new plot
fluxlist[0]->Add(fluxHist);
}
fluxHist->SetNameTitle(Form("nuwro_pdg%i_pct%f_Flux", pdg, pctg),
Form("nuwro_pdg%i_pct%f_Flux", pdg, pctg));
TH1D *eventplot = (TH1D *)fluxHist->Clone();
eventplot->SetNameTitle(Form("nuwro_pdg%i_pct%f_Evt", pdg, pctg),
Form("nuwro_pdg%i_pct%f_Evt", pdg, pctg));
eventplot->Reset();
fluxlist[pdg] = (TH1D *)fluxHist->Clone();
eventlist[pdg] = eventplot;
nevtlist[pdg] = 0;
intxseclist[pdg] = 0.0;
allpdg.push_back(pdg);
delete fluxHist;
}
if (fabs(totalFraction - 1) > 1E-5) {
- QTHROW(FTL, "Total species fraction for input flux histos = "
+ NUIS_ABORT(FTL, "Total species fraction for input flux histos = "
<< totalFraction << ", expected to sum to 1.");
}
} else if (fluxtype == 0) {
std::string fluxstring = evt->par.beam_energy;
std::vector fluxvals = GeneralUtils::ParseToDbl(fluxstring, " ");
int pdg = evt->par.beam_particle;
double Elow = double(fluxvals[0]) / 1000.0;
double Ehigh = double(fluxvals[1]) / 1000.0;
TH1D *fluxplot = NULL;
if (Elow > Ehigh)
isMono = true;
// For files produced with a flux distribution
if (!isMono) {
- QLOG(FIT, "Adding new nuwro flux "
+ NUIS_LOG(FIT, "Adding new nuwro flux "
<< "pdg: " << pdg << " Elow: " << Elow
<< " Ehigh: " << Ehigh);
fluxplot =
new TH1D("fluxplot", "fluxplot", fluxvals.size() - 4, Elow, Ehigh);
for (uint j = 2; j < fluxvals.size(); j++) {
- QLOG(DEB, j << " " << fluxvals[j]);
+ NUIS_LOG(DEB, j << " " << fluxvals[j]);
fluxplot->SetBinContent(j - 1, fluxvals[j]);
}
} else { // For monoenergetic fluxes
- QLOG(FIT, "Adding mono-energetic nuwro flux "
+ NUIS_LOG(FIT, "Adding mono-energetic nuwro flux "
<< "pdg: " << pdg << " E: " << Elow);
fluxplot = new TH1D("fluxplot", "fluxplot", 100, 0, Elow * 2);
fluxplot->SetBinContent(fluxplot->FindBin(Elow), 1);
}
// Setup total flux
fluxlist[0] = (TH1D *)fluxplot->Clone();
fluxlist[0]->SetNameTitle("FluxHist", "FluxHist");
// Prep empty total events
eventlist[0] = (TH1D *)fluxplot->Clone();
eventlist[0]->SetNameTitle("EvtHist", "EvtHist");
eventlist[0]->Reset();
fluxplot->SetNameTitle(Form("nuwro_pdg%i_Flux", pdg),
Form("nuwro_pdg%i_Flux", pdg));
TH1D *eventplot = (TH1D *)fluxplot->Clone();
eventplot->SetNameTitle(Form("nuwro_pdg%i_Evt", pdg),
Form("nuwro_pdg%i_Evt", pdg));
eventplot->Reset();
fluxlist[pdg] = fluxplot;
eventlist[pdg] = eventplot;
nevtlist[pdg] = 0;
intxseclist[pdg] = 0.0;
allpdg.push_back(pdg);
} else if (fluxtype == 1) {
std::string fluxstring = evt->par.beam_content;
std::vector fluxlines =
GeneralUtils::ParseToStr(fluxstring, "\n");
for (uint i = 0; i < fluxlines.size(); i++) {
std::vector fluxvals =
GeneralUtils::ParseToDbl(fluxlines[i], " ");
int pdg = int(fluxvals[0]);
double pctg = double(fluxvals[1]) / 100.0;
double Elow = double(fluxvals[2]) / 1000.0;
double Ehigh = double(fluxvals[3]) / 1000.0;
- QLOG(FIT, "Adding new nuwro flux "
+ NUIS_LOG(FIT, "Adding new nuwro flux "
<< "pdg: " << pdg << " pctg: " << pctg << " Elow: " << Elow
<< " Ehigh: " << Ehigh);
TH1D *fluxplot =
new TH1D("fluxplot", "fluxplot", fluxvals.size() - 4, Elow, Ehigh);
for (uint j = 4; j < fluxvals.size(); j++) {
fluxplot->SetBinContent(j + 1, fluxvals[j]);
}
// Sort total flux plot
if (!fluxlist[0]) {
// Setup total flux
fluxlist[0] = (TH1D *)fluxplot->Clone();
fluxlist[0]->SetNameTitle("FluxHist", "FluxHist");
// Prep empty total events
eventlist[0] = (TH1D *)fluxplot->Clone();
eventlist[0]->SetNameTitle("EvtHist", "EvtHist");
eventlist[0]->Reset();
} else {
// Add up each new plot
fluxlist[0]->Add(fluxplot);
}
fluxplot->SetNameTitle(Form("nuwro_pdg%i_pct%f_Flux", pdg, pctg),
Form("nuwro_pdg%i_pct%f_Flux", pdg, pctg));
TH1D *eventplot = (TH1D *)fluxplot->Clone();
eventplot->SetNameTitle(Form("nuwro_pdg%i_pct%f_Evt", pdg, pctg),
Form("nuwro_pdg%i_pct%f_Evt", pdg, pctg));
eventplot->Reset();
fluxlist[pdg] = fluxplot;
eventlist[pdg] = eventplot;
nevtlist[pdg] = 0;
intxseclist[pdg] = 0.0;
allpdg.push_back(pdg);
}
}
// Start main event loop to fill plots
int nevents = nuwrotree->GetEntries();
double Enu = 0.0;
double TotXSec = 0.0;
// double totaleventmode = 0.0;
// double totalevents = 0.0;
int pdg = 0;
int countwidth = nevents / 50.0;
countwidth = countwidth ? countwidth : 1;
for (int i = 0; i < nevents; i++) {
nuwrotree->GetEntry(i);
// Get Variables
Enu = evt->in[0].t / 1000.0;
TotXSec = evt->weight;
pdg = evt->in[0].pdg;
eventlist[0]->Fill(Enu);
eventlist[pdg]->Fill(Enu);
nevtlist[0] += 1;
nevtlist[pdg] += 1;
intxseclist[0] += TotXSec;
intxseclist[pdg] += TotXSec;
if (i % countwidth == 0) {
- QLOG(FIT, "Processed " << i << " events "
+ NUIS_LOG(FIT, "Processed " << i << " events "
<< " (" << int(i * 100.0 / nevents) << "%)"
<< " : E, W, PDG = " << Enu << ", " << TotXSec
<< ", " << pdg)
}
}
TH1D *zeroevents = (TH1D *)eventlist[0]->Clone();
outRootFile->cd();
// Loop over eventlist
for (uint i = 0; i < allpdg.size(); i++) {
int pdg = allpdg[i];
double AvgXSec = intxseclist[0] * 1E38 / double(nevtlist[0]);
- QLOG(FIT, pdg << " Avg XSec = " << AvgXSec);
- QLOG(FIT, pdg << " nevents = " << double(nevtlist[pdg]));
+ NUIS_LOG(FIT, pdg << " Avg XSec = " << AvgXSec);
+ NUIS_LOG(FIT, pdg << " nevents = " << double(nevtlist[pdg]));
if (!isMono) {
// Convert events to PDF
eventlist[pdg]->Scale(1.0 / zeroevents->Integral("width"));
// Multiply by total predicted event rate
eventlist[pdg]->Scale(fluxlist[0]->Integral("width") * AvgXSec);
} else {
// If a mono-energetic flux was used, width should not be used
// The output is (now) forced to be flux = 1, evtrt = xsec (in 1E38 * nb
// cm^2)
eventlist[pdg]->Scale(1.0 / zeroevents->Integral());
eventlist[pdg]->Scale(fluxlist[0]->Integral() * AvgXSec);
}
// Save everything
fluxlist[pdg]->Write("", TObject::kOverwrite);
eventlist[pdg]->Write("", TObject::kOverwrite);
}
// Tidy up
outRootFile->Close();
fluxlist.clear();
eventlist.clear();
// Exit Program
return;
}
//*******************************
void HaddNuwroFiles(std::vector &inputs, bool force_out) {
//*******************************
// Get output file name
std::string outputname = inputs[0];
// Make command line string
std::string cmd = "hadd ";
if (outputNewFile) {
cmd += ofile + " ";
outputname = ofile;
} else if (force_out) {
cmd += "-f ";
}
for (UInt_t i = 0; i < inputs.size(); i++) {
cmd += inputs[i] + " ";
}
- QLOG(FIT, " Running HADD from PrepareNuwro: " << cmd);
+ NUIS_LOG(FIT, " Running HADD from PrepareNuwro: " << cmd);
// Start HADD
system(cmd.c_str());
// Return name of output file
inputs.clear();
inputs.push_back(outputname);
haddedFiles = true;
return;
}
diff --git a/app/neut_NUISANCE.cxx b/app/neut_NUISANCE.cxx
index b216a81..c3d0a39 100644
--- a/app/neut_NUISANCE.cxx
+++ b/app/neut_NUISANCE.cxx
@@ -1,911 +1,911 @@
#ifdef __NEUT_ENABLED__
#include "ComparisonRoutines.h"
#include "ParserUtils.h"
#include "TargetUtils.h"
#ifdef WINDOWS
#include
#define GetCurrentDir _getcwd
#else
#include
#define GetCurrentDir getcwd
#endif
// All possible inputs
std::string gOptEnergyDef;
std::vector gOptEnergyRange;
int gOptNumberEvents = -1;
int gOptNumberTestEvents = 5E6;
std::string gOptGeneratorList = "Default";
std::string gOptCrossSections =
"Default"; // If default this will look in
// $NUISANCE/data/neut/Default_params.txt
int gOptSeed = time(NULL);
std::string gOptTargetDef = "";
std::string gOptFluxDef = "";
std::string gOptOutputFile = "";
int gOptRunNumber = -1;
using namespace TargetUtils;
void GetCommandLineArgs(int argc, char **argv);
void PrintSyntax(void);
std::string GETCWD() {
char cCurrentPath[FILENAME_MAX];
if (!GetCurrentDir(cCurrentPath, sizeof(cCurrentPath))) {
- QTHROW("CANT FIND CURRENT DIRECTORY!");
+ NUIS_ABORT("CANT FIND CURRENT DIRECTORY!");
}
std::string curdir = std::string(cCurrentPath);
return curdir;
}
std::string ExpandPath(std::string name) {
// Get Current
char cCurrentPath[FILENAME_MAX];
if (!GetCurrentDir(cCurrentPath, sizeof(cCurrentPath))) {
- QTHROW("CANT FIND CURRENT DIRECTORY!");
+ NUIS_ABORT("CANT FIND CURRENT DIRECTORY!");
}
std::string curdir = std::string(cCurrentPath);
// If first entry is not / then add the current working directory
if (!name.empty() and name.at(0) != '/') {
name = curdir + "/" + name;
}
return name;
}
std::string GetBaseName(std::string name) {
std::vector splitfile = GeneralUtils::ParseToStr(name, "/");
std::string filename = "";
if (splitfile.size() == 1) {
filename = splitfile[0];
} else if (splitfile.size() > 1) {
filename = splitfile[splitfile.size() - 1];
} else {
- QTHROW("Cannot split filename: " << name);
+ NUIS_ABORT("Cannot split filename: " << name);
}
return filename;
}
std::string GetDynamicModes(std::string list, bool neutrino) {
- QLOG(FIT, "Using " << list << " to define interaction modes for Neutrino="
+ NUIS_LOG(FIT, "Using " << list << " to define interaction modes for Neutrino="
<< neutrino);
std::map modes;
std::vector ids;
// Create vector of ids for the print out and future reference
/*
C
C nu nub
C 1: CC Q.E. CC Q.E.( Free )
C 2-4: CC 1pi CC 1pi
C 5: CC DIS 1320 CC DIS 1.3 < W < 2.0
C 6-9: NC 1pi NC 1pi
C 10: NC DIS 1320 NC DIS 1.3 < W < 2.0
C 11: NC els CC Q.E.( Bound )
C 12: NC els NC els
C 13: NC els NC els
C 14: coherent NC els
C 15: coherent coherent
C 16: CC eta coherent
C 17 NC eta CC eta
C 18: NC eta NC eta
C 19: CC K NC eta
C 20 NC K CC K
C 21: NC K NC K
C 22: N/A NC K
C 23: CC DIS CC DIS (W > 2.0)
C 24: NC DIS NC DIS (W > 2.0)
C 25: CC 1 gamma CC 1 gamma
C 26: NC 1 gamma NC 1 gamma
C 27: NC 1 gamma NC 1 gamma
C 28: 2p2h 2p2h
*/
ids.push_back("crsmode_CCQE");
ids.push_back("crsmode_CC2P2H");
ids.push_back("crsmode_CC1pi");
ids.push_back("crsmode_CCDIS_lowW");
ids.push_back("crsmode_NC1pi");
ids.push_back("crsmode_NCDIS_lowW");
ids.push_back("crsmode_NCEL");
ids.push_back("crsmode_CCCOH");
ids.push_back("crsmode_NCCOH");
ids.push_back("crsmode_CCETA");
ids.push_back("crsmode_NCETA");
ids.push_back("crsmode_CCKAON");
ids.push_back("crsmode_NCKAON");
ids.push_back("crsmode_CCDIS_highW");
ids.push_back("crsmode_NCDIS_highW");
ids.push_back("crsmode_CCGAMMA");
ids.push_back("crsmode_NCGAMMA");
// Now define possible models
if (!list.compare("Default")) { // Everything but MEC
modes["crsmode_CCQE"] = 1;
modes["crsmode_CC2P2H"] = 0;
modes["crsmode_CC1pi"] = 1;
modes["crsmode_CCDIS_lowW"] = 1;
modes["crsmode_CCCOH"] = 1;
modes["crsmode_CCETA"] = 1;
modes["crsmode_CCKAON"] = 1;
modes["crsmode_CCDIS_highW"] = 1;
modes["crsmode_CCGAMMA"] = 1;
modes["crsmode_NC1pi"] = 1;
modes["crsmode_NCDIS_lowW"] = 1;
modes["crsmode_NCEL"] = 1;
modes["crsmode_NCCOH"] = 1;
modes["crsmode_NCETA"] = 1;
modes["crsmode_NCKAON"] = 1;
modes["crsmode_NCDIS_highW"] = 1;
modes["crsmode_NCGAMMA"] = 1;
} else if (!list.compare("DefaultFree")) {
modes["crsmode_CCQE"] = 1;
modes["crsmode_CC2P2H"] = 0;
modes["crsmode_CC1pi"] = 1;
modes["crsmode_CCDIS_lowW"] = 1;
modes["crsmode_CCCOH"] = 0;
modes["crsmode_CCETA"] = 1;
modes["crsmode_CCKAON"] = 1;
modes["crsmode_CCDIS_highW"] = 1;
modes["crsmode_CCGAMMA"] = 1;
modes["crsmode_NC1pi"] = 1;
modes["crsmode_NCDIS_lowW"] = 1;
modes["crsmode_NCEL"] = 1;
modes["crsmode_NCCOH"] = 0;
modes["crsmode_NCETA"] = 1;
modes["crsmode_NCKAON"] = 1;
modes["crsmode_NCDIS_highW"] = 1;
modes["crsmode_NCGAMMA"] = 1;
} else if (!list.compare("Default+MEC")) {
modes["crsmode_CCQE"] = 1;
modes["crsmode_CC2P2H"] = 1;
modes["crsmode_CC1pi"] = 1;
modes["crsmode_CCDIS_lowW"] = 1;
modes["crsmode_CCCOH"] = 1;
modes["crsmode_CCETA"] = 1;
modes["crsmode_CCKAON"] = 1;
modes["crsmode_CCDIS_highW"] = 1;
modes["crsmode_CCGAMMA"] = 1;
modes["crsmode_NC1pi"] = 1;
modes["crsmode_NCDIS_lowW"] = 1;
modes["crsmode_NCEL"] = 1;
modes["crsmode_NCCOH"] = 1;
modes["crsmode_NCETA"] = 1;
modes["crsmode_NCKAON"] = 1;
modes["crsmode_NCDIS_highW"] = 1;
modes["crsmode_NCGAMMA"] = 1;
} else {
- QTHROW("Event generator list " << list << " not found!");
+ NUIS_ABORT("Event generator list " << list << " not found!");
}
// Now we actually have to make the conversion because NEUTS modes
// organisation are a mess.
/*
C
C nu nub
C 1: CC Q.E. CC Q.E.( Free )
C 2-4: CC 1pi CC 1pi
C 5: CC DIS 1320 CC DIS 1.3 < W < 2.0
C 6-9: NC 1pi NC 1pi
C 10: NC DIS 1320 NC DIS 1.3 < W < 2.0
C 11: NC els CC Q.E.( Bound )
C 12: NC els NC els
C 13: NC els NC els
C 14: coherent NC els
C 15: coherent coherent
C 16: CC eta coherent
C 17 NC eta CC eta
C 18: NC eta NC eta
C 19: CC K NC eta
C 20 NC K CC K
C 21: NC K NC K
C 22: N/A NC K
C 23: CC DIS CC DIS (W > 2.0)
C 24: NC DIS NC DIS (W > 2.0)
C 25: CC 1 gamma CC 1 gamma
C 26,27: NC 1 gamma NC 1 gamma
*/
std::string modestring_neutrino = "NEUT-CRS ";
std::string modestring_antineutrino = "NEUT-CRSB ";
// Neutrino First
if (neutrino) {
// Fill empty NEUT-CRSB
for (size_t i = 0; i < 27; i++) {
modestring_antineutrino += " 0";
}
modestring_neutrino += (modes["crsmode_CCQE"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_CC1pi"] ? " 1 1 1" : " 0 0 0");
modestring_neutrino += (modes["crsmode_CCDIS_lowW"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_NC1pi"] ? " 1 1 1 1" : " 0 0 0 0");
modestring_neutrino += (modes["crsmode_NCDIS_lowW"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_NCEL"] ? " 1 1 1" : " 0 0 0");
modestring_neutrino += (modes["crsmode_CCCOH"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_NCCOH"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_CCETA"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_NCETA"] ? " 1 1" : " 0 0");
modestring_neutrino += (modes["crsmode_CCKAON"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_NCKAON"] ? " 1 1" : " 0 0");
modestring_neutrino += " 1"; // /NA
modestring_neutrino += (modes["crsmode_CCDIS_highW"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_NCDIS_highW"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_CCGAMMA"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_NCGAMMA"] ? " 1" : " 0");
modestring_neutrino += (modes["crsmode_CC2P2H"] ? " 1" : " 0");
} else {
// Fill Empty NEUT CRS
for (size_t i = 0; i < 27; i++) {
modestring_neutrino += " 0";
}
modestring_antineutrino += (modes["crsmode_CCQE"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_CC1pi"] ? " 1 1 1" : " 0 0 0");
modestring_antineutrino += (modes["crsmode_CCDIS_lowW"] ? " 1" : " 0");
modestring_antineutrino +=
(modes["crsmode_NC1pi"] ? " 1 1 1 1" : " 0 0 0 0");
modestring_antineutrino += (modes["crsmode_NCDIS_lowW"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_CCQE"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_NCEL"] ? " 1 1 1" : " 0 0 0");
modestring_antineutrino += (modes["crsmode_CCCOH"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_NCCOH"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_CCETA"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_NCETA"] ? " 1 1" : " 0 0");
modestring_antineutrino += (modes["crsmode_CCKAON"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_NCKAON"] ? " 1 1" : " 0 0");
modestring_antineutrino += (modes["crsmode_CCDIS_highW"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_NCDIS_highW"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_CCGAMMA"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_NCGAMMA"] ? " 1" : " 0");
modestring_antineutrino += (modes["crsmode_CC2P2H"] ? " 1" : " 0");
}
return "NEUT-MODE -1 \n" + modestring_neutrino + "\n" +
modestring_antineutrino;
}
std::map MakeNewFluxFile(std::string flux,
std::string out) {
- QLOG(FIT, "Using " << flux << " to define NEUT beam.");
+ NUIS_LOG(FIT, "Using " << flux << " to define NEUT beam.");
std::vector fluxargs = GeneralUtils::ParseToStr(flux, ",");
if (fluxargs.size() < 2) {
- QTHROW("Expected flux in the format: file.root,hist_name1[pdg1],... : "
+ NUIS_ABORT("Expected flux in the format: file.root,hist_name1[pdg1],... : "
"reveived : "
<< flux);
}
// Build Map
std::map fluxmap;
fluxmap["beam_type"] = "6";
fluxmap["beam_inputroot"] = fluxargs[0];
fluxmap["beam_inputroot_nue"] = "";
fluxmap["beam_inputroot_nueb"] = "";
fluxmap["beam_inputroot_numu"] = "";
fluxmap["beam_inputroot_numub"] = "";
fluxmap["beam_inputroot_nutau"] = "";
fluxmap["beam_inputroot_nutaub"] = "";
// Split by beam bdgs
for (uint i = 1; i < fluxargs.size(); i++) {
std::string histdef = fluxargs[i];
string::size_type open_bracket = histdef.find("[");
string::size_type close_bracket = histdef.find("]");
string::size_type ibeg = 0;
string::size_type iend = open_bracket;
string::size_type jbeg = open_bracket + 1;
string::size_type jend = close_bracket - 1;
std::string name = std::string(histdef.substr(ibeg, iend).c_str());
int pdg = atoi(histdef.substr(jbeg, jend).c_str());
if (pdg == 12)
fluxmap["beam_inputroot_nue"] = name;
else if (pdg == -12)
fluxmap["beam_inputroot_nueb"] = name;
else if (pdg == 14)
fluxmap["beam_inputroot_numu"] = name;
else if (pdg == -14)
fluxmap["beam_inputroot_numub"] = name;
else if (pdg == 16)
fluxmap["beam_inputroot_tau"] = name;
else if (pdg == -16)
fluxmap["beam_inputroot_taub"] = name;
}
// Now create a new flux file matching the output file
std::cout << " -> Moving flux from '" + fluxmap["beam_inputroot"] +
"' to current directory to keep everything organised."
<< std::endl;
TFile *fluxread = new TFile(fluxmap["beam_inputroot"].c_str(), "READ");
TFile *fluxwrite = new TFile((out + ".flux.root").c_str(), "RECREATE");
for (std::map::iterator iter = fluxmap.begin();
iter != fluxmap.end(); iter++) {
TH1 *temp = (TH1 *)fluxread->Get(iter->second.c_str());
if (!temp)
continue;
TH1D *cuthist = (TH1D *)temp->Clone();
// Restrict energy range if required
if (gOptEnergyRange.size() == 2) {
for (int i = 0; i < cuthist->GetNbinsX(); i++) {
if (cuthist->GetXaxis()->GetBinCenter(i + 1) < gOptEnergyRange[0] or
cuthist->GetXaxis()->GetBinCenter(i + 1) > gOptEnergyRange[1]) {
cuthist->SetBinContent(i + 1, 0.0);
}
}
}
// Check Flux
if (cuthist->Integral() <= 0.0) {
- QTHROW("Flux histogram " << iter->second << " has integral <= 0.0");
+ NUIS_ABORT("Flux histogram " << iter->second << " has integral <= 0.0");
}
// Save
fluxwrite->cd();
cuthist->Write();
}
std::cout << " ->-> Saved to : " << (out + ".flux.root") << std::endl;
fluxmap["beam_inputroot"] = (out + ".flux.root");
fluxwrite->Close();
return fluxmap;
}
std::string GetFluxDefinition(std::string fluxfile, std::string fluxhist,
std::string fluxid) {
// Get base name of flux file as its being copied to NEUT Run Directory
std::vector splitfluxfile =
GeneralUtils::ParseToStr(fluxfile, "/");
std::string filename = "";
if (splitfluxfile.size() == 1) {
filename = splitfluxfile[0];
} else if (splitfluxfile.size() > 1) {
filename = splitfluxfile[splitfluxfile.size() - 1];
} else {
- QTHROW("NO FILENAME FOR FLUX DEFINITION FOUND!");
+ NUIS_ABORT("NO FILENAME FOR FLUX DEFINITION FOUND!");
}
// Build string
std::string fluxparams = "";
fluxparams += "EVCT-FILENM \'" + filename + "\' \n";
fluxparams += "EVCT-HISTNM \'" + fluxhist + "\' \n";
fluxparams += "EVCT-INMEV 0 \n";
fluxparams += "EVCT-MPV 3 \n";
// Set PDG Code
if (!fluxid.compare("nue"))
fluxparams += "EVCT-IDPT 12";
else if (!fluxid.compare("nueb"))
fluxparams += "EVCT-IDPT -12";
else if (!fluxid.compare("numu"))
fluxparams += "EVCT-IDPT 14";
else if (!fluxid.compare("numub"))
fluxparams += "EVCT-IDPT -14";
else if (!fluxid.compare("nutau"))
fluxparams += "EVCT-IDPT 16";
else if (!fluxid.compare("nutaub"))
fluxparams += "EVCT-IDPT -16";
else {
- QTHROW("UNKNOWN FLUX ID GIVEN!");
+ NUIS_ABORT("UNKNOWN FLUX ID GIVEN!");
}
return fluxparams;
}
std::string GetTargetDefinition(std::string target) {
- QLOG(FIT, "Defining NEUT Target from : " << target);
+ NUIS_LOG(FIT, "Defining NEUT Target from : " << target);
// Target is given as either a single PDG, or a combo with the total number of
// nucleons
std::vector trgts = GeneralUtils::ParseToStr(target, ",");
std::string targetstring = "";
// NEUT only lets us pass C and CH type inputs.
// Single Target
if (trgts.size() == 1) {
int PDG = GeneralUtils::StrToInt(trgts[0]);
int Z = TargetUtils::GetTargetZFromPDG(PDG);
int N = TargetUtils::GetTargetAFromPDG(PDG) - Z;
targetstring += "NEUT-NUMBNDP " + GeneralUtils::IntToStr(Z) + "\n";
targetstring += "NEUT-NUMBNDN " + GeneralUtils::IntToStr(N) + "\n";
targetstring += "NEUT-NUMFREP 0\n";
targetstring += "NEUT-NUMATOM " + GeneralUtils::IntToStr(Z + N) + "\n";
// Combined target
} else if (trgts.size() == 3) {
int NUCLEONS = GeneralUtils::StrToInt(trgts[0]);
std::string target1 = trgts[1];
std::string target2 = trgts[2];
// Parse target strings
string::size_type open_bracket = target1.find("[");
string::size_type close_bracket = target1.find("]");
string::size_type ibeg = 0;
string::size_type iend = open_bracket;
string::size_type jbeg = open_bracket + 1;
string::size_type jend = close_bracket - 1;
int PDG1 = atoi(target1.substr(ibeg, iend).c_str());
double W1 = atof(target1.substr(jbeg, jend).c_str());
open_bracket = target2.find("[");
close_bracket = target2.find("]");
ibeg = 0;
iend = open_bracket;
jbeg = open_bracket + 1;
jend = close_bracket - 1;
int PDG2 = atoi(target2.substr(ibeg, iend).c_str());
double W2 = atof(target2.substr(jbeg, jend).c_str());
// Can only have H as a secondary target!
if (PDG1 != 1000010010 && PDG2 != 1000010010) {
- QTHROW(
+ NUIS_ABORT(
"NEUT Doesn't support composite targets apart fromn Target+H. E.g. "
"CH");
}
// Switch so H is PDG2 if given
if (PDG1 == 1000010010 && PDG2 != 1000010010) {
PDG1 = PDG2;
PDG2 = 1000010010;
double temp1 = W1;
W1 = W2;
W2 = temp1;
}
// Now build string
int Z = TargetUtils::GetTargetZFromPDG(PDG1);
int N = TargetUtils::GetTargetAFromPDG(PDG1) - Z;
int NHydrogen = int(W2 * double(NUCLEONS));
if (double(W2 * double(NUCLEONS)) - (double(NHydrogen)) > 0.5) {
NHydrogen++; // awkward rounding bug fix
}
targetstring += "NEUT-NUMBNDP " + GeneralUtils::IntToStr(Z) + "\n";
targetstring += "NEUT-NUMBNDN " + GeneralUtils::IntToStr(N) + "\n";
targetstring += "NEUT-NUMFREP " + GeneralUtils::IntToStr(NHydrogen) + "\n";
targetstring += "NEUT-NUMATOM " + GeneralUtils::IntToStr(Z + N) + "\n";
} else {
- QTHROW("NEUT only supports single targets or ones with a secondary H!");
+ NUIS_ABORT("NEUT only supports single targets or ones with a secondary H!");
}
return targetstring;
}
std::string GetEventAndSeedDefinition(int nevents, int seed) {
std::string eventdef = "";
eventdef += "EVCT-NEVT " + GeneralUtils::IntToStr(nevents) + "\n";
- QLOG(FIT, "Event Definition: ");
+ NUIS_LOG(FIT, "Event Definition: ");
std::cout << " -> EVCT-NEVT : " << nevents << std::endl;
return eventdef;
}
//____________________________________________________________________________
int main(int argc, char **argv) {
- QLOG(FIT, "==== RUNNING neut_nuisance Event Generator =====");
+ NUIS_LOG(FIT, "==== RUNNING neut_nuisance Event Generator =====");
GetCommandLineArgs(argc, argv);
std::string neutroot = std::string(getenv("NEUT_ROOT")) + "/src/neutsmpl/";
// Calculate the dynamic modes definition
// Read Target string
std::string targetparamsdef = GetTargetDefinition(gOptTargetDef);
//____________________________
// NEUT doesn't let us do combined flux inputs so have to loop over each flux.
std::map newfluxdef =
MakeNewFluxFile(gOptFluxDef, gOptOutputFile);
// Quick fix to make flux also save to pid_time.root.flux.root
std::stringstream ss;
ss << getpid() << "_" << time(NULL) << ".root";
newfluxdef = MakeNewFluxFile(gOptFluxDef, ss.str());
// Copy this file to the NEUT working directory
- QLOG(FIT, "Copying flux to NEUT working directory");
+ NUIS_LOG(FIT, "Copying flux to NEUT working directory");
system(
("cp -v " + newfluxdef["beam_inputroot"] + " " + neutroot + "/").c_str());
TFile *fluxrootfile = new TFile(newfluxdef["beam_inputroot"].c_str(), "READ");
// Setup possible beams and get relative fractions
std::vector possiblefluxids;
std::vector fluxfractions;
possiblefluxids.push_back("nue");
possiblefluxids.push_back("nueb");
possiblefluxids.push_back("numu");
possiblefluxids.push_back("numub");
possiblefluxids.push_back("tau");
possiblefluxids.push_back("taub");
// Total up integrals
double totintflux = 0.0;
for (size_t i = 0; i < possiblefluxids.size(); i++) {
if (newfluxdef["beam_inputroot_" + possiblefluxids[i]].empty()) {
fluxfractions.push_back(0.0);
} else {
TH1D *fluxhist = (TH1D *)fluxrootfile->Get(
newfluxdef["beam_inputroot_" + possiblefluxids[i]].c_str());
if (!fluxhist) {
- QTHROW("FLUX HIST : "
+ NUIS_ABORT("FLUX HIST : "
<< newfluxdef["beam_inputroot_" + possiblefluxids[i]]
<< " not found!");
}
fluxfractions.push_back(fluxhist->Integral());
totintflux += fluxhist->Integral();
}
}
fluxrootfile->Close();
// Now loop over and actually generate jobs!
for (size_t i = 0; i < possiblefluxids.size(); i++) {
if (fluxfractions[i] == 0.0)
continue;
// Get number of events for this subbeam
int nevents = int(double(gOptNumberEvents) * fluxfractions[i] / totintflux);
std::cout << "NEVENTS = " << gOptNumberEvents << " " << fluxfractions[i]
<< " " << totintflux << " " << nevents << std::endl;
std::string eventparamsdef = GetEventAndSeedDefinition(nevents, gOptSeed);
bool neutrino = true;
if (possiblefluxids[i].find("b") != std::string::npos)
neutrino = false;
std::string dynparamsdef = GetDynamicModes(gOptGeneratorList, neutrino);
std::string fluxparamsdef = GetFluxDefinition(
newfluxdef["beam_inputroot"],
newfluxdef["beam_inputroot_" + possiblefluxids[i]], possiblefluxids[i]);
- QLOG(FIT,"==== Generating CardFiles NEUT! ===");
+ NUIS_LOG(FIT,"==== Generating CardFiles NEUT! ===");
std::cout << dynparamsdef << std::endl;
std::cout << targetparamsdef << std::endl;
std::cout << eventparamsdef << std::endl;
std::cout << fluxparamsdef << std::endl;
// Create card file
std::ifstream incardfile;
std::ofstream outcardfile;
std::string line;
incardfile.open(gOptCrossSections.c_str(), ios::in);
outcardfile.open(
(gOptOutputFile + "." + possiblefluxids[i] + ".par").c_str(), ios::out);
// Copy base card file
if (incardfile.is_open()) {
while (getline(incardfile, line)) {
outcardfile << line << '\n';
}
} else {
- QTHROW("Cannot find card file : " << gOptCrossSections);
+ NUIS_ABORT("Cannot find card file : " << gOptCrossSections);
}
// Now copy our strings
outcardfile << eventparamsdef << '\n';
outcardfile << dynparamsdef << '\n';
outcardfile << targetparamsdef << '\n';
outcardfile << fluxparamsdef << '\n';
// Close card and keep name for future use.
outcardfile.close();
}
- QLOG(FIT, "GENERATING");
+ NUIS_LOG(FIT, "GENERATING");
for (size_t i = 0; i < possiblefluxids.size(); i++) {
if (fluxfractions[i] == 0.0)
continue;
int nevents = int(double(gOptNumberEvents) * fluxfractions[i] / totintflux);
if (nevents <= 0)
continue;
std::string cardfile =
ExpandPath(gOptOutputFile + "." + possiblefluxids[i] + ".par");
std::string outputfile =
ExpandPath(gOptOutputFile + "." + possiblefluxids[i] + ".root");
std::string basecardfile = GetBaseName(cardfile);
std::string baseoutputfile = ss.str();
std::cout << "CARDFILE = " << cardfile << " : " << basecardfile
<< std::endl;
std::cout << "OUTPUTFILE = " << outputfile << " : " << baseoutputfile
<< std::endl;
system(("cp " + cardfile + " " + neutroot).c_str());
std::string cwd = GETCWD();
chdir(neutroot.c_str());
// int attempts = 0;
// while(true){
// Break if too many attempts
// attempts++;
// if (attempts > 20) continue;
// Actually run neutroot2
system(("./neutroot2 " + basecardfile + " " + baseoutputfile).c_str());
// Check the output is valid, sometimes NEUT aborts mid run.
// TFile* f = new TFile(baseoutputfile.c_str(),"READ");
// if (!f or f->IsZombie()) continue;
// Check neutttree is there and filled correctly.
// TTree* tn = (TTree*) f->Get("neuttree");
// if (!tn) continue;
// if (tn->GetEntries() < nevents * 0.9) continue;
// break;
// }
// Move the finished file back and clean this directory of card files
system(("mv -v " + baseoutputfile + " " + outputfile).c_str());
system(("rm -v " + basecardfile).c_str());
chdir(cwd.c_str());
}
return 0;
}
//____________________________________________________________________________
void GetCommandLineArgs(int argc, char **argv) {
// Check for -h flag.
for (int i = 0; i < argc; i++) {
if (!std::string(argv[i]).compare("-h"))
PrintSyntax();
}
// Format is neut -r run_number -n n events
std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv);
ParserUtils::ParseArgument(args, "-n", gOptNumberEvents, false);
if (gOptNumberEvents == -1) {
- QTHROW("No event count passed to neut_NUISANCE!");
+ NUIS_ABORT("No event count passed to neut_NUISANCE!");
}
// Flux/Energy Specs
ParserUtils::ParseArgument(args, "-e", gOptEnergyDef, false);
gOptEnergyRange = GeneralUtils::ParseToDbl(gOptEnergyDef, ",");
ParserUtils::ParseArgument(args, "-f", gOptFluxDef, false);
if (gOptFluxDef.empty() and gOptEnergyRange.size() < 1) {
- QTHROW("No flux or energy range given to neut_nuisance!");
+ NUIS_ABORT("No flux or energy range given to neut_nuisance!");
} else if (gOptFluxDef.empty() and gOptEnergyRange.size() == 1) {
// Fixed energy, make sure -p is given
- QTHROW("neut_NUISANCE cannot yet do fixed energy!");
+ NUIS_ABORT("neut_NUISANCE cannot yet do fixed energy!");
} else if (gOptFluxDef.empty() and gOptEnergyRange.size() == 2) {
// Uniform energy range
- QTHROW("neut_NUISANCE cannot yet do a uniform energy range!");
+ NUIS_ABORT("neut_NUISANCE cannot yet do a uniform energy range!");
} else if (!gOptFluxDef.empty()) {
// Try to convert the flux definition if possible.
std::string convflux = BeamUtils::ConvertFluxIDs(gOptFluxDef);
if (!convflux.empty())
gOptFluxDef = convflux;
} else {
- QTHROW("Unknown flux energy range combination!");
+ NUIS_ABORT("Unknown flux energy range combination!");
}
ParserUtils::ParseArgument(args, "-t", gOptTargetDef, false);
if (gOptTargetDef.empty()) {
- QTHROW("No Target passed to neut_nuisance! use the '-t' argument.");
+ NUIS_ABORT("No Target passed to neut_nuisance! use the '-t' argument.");
} else {
std::string convtarget = TargetUtils::ConvertTargetIDs(gOptTargetDef);
if (!convtarget.empty())
gOptTargetDef = convtarget;
}
ParserUtils::ParseArgument(args, "-r", gOptRunNumber, false);
ParserUtils::ParseArgument(args, "-o", gOptOutputFile, false);
if (gOptOutputFile.empty()) {
if (gOptRunNumber == -1)
gOptRunNumber = 1;
- QLOG(FIT, "No output file given! Saving file to : neutgen."
+ NUIS_LOG(FIT, "No output file given! Saving file to : neutgen."
<< gOptRunNumber << ".neutvect.root");
gOptOutputFile =
"neutgen." + GeneralUtils::IntToStr(gOptRunNumber) + ".neutvect.root";
} else {
// if no run number given leave as is, else add run number.
if (gOptRunNumber != -1) {
gOptOutputFile += "." + GeneralUtils::IntToStr(gOptRunNumber) + ".root";
} else {
gOptRunNumber = 0;
}
}
ParserUtils::ParseArgument(args, "--cross-section", gOptCrossSections, false);
if (!gOptCrossSections.compare("Default")) {
- QLOG(FIT, "No Parameters File passed. Using default neut one.");
+ NUIS_LOG(FIT, "No Parameters File passed. Using default neut one.");
char *const var = getenv("NUISANCE");
if (!var) {
std::cout << "Cannot find top level directory! Set the NUISANCE "
"environmental variable"
<< std::endl;
exit(-1);
}
std::string topnuisancedir = string(var);
gOptCrossSections = topnuisancedir + "/neut/Default_params.txt";
}
ParserUtils::ParseArgument(args, "--event-generator-list", gOptGeneratorList,
false);
// Final Check and output
if (args.size() > 0) {
PrintSyntax();
ParserUtils::CheckBadArguments(args);
}
- QLOG(FIT, "Generating Neut Events with the following properties:"
+ NUIS_LOG(FIT, "Generating Neut Events with the following properties:"
<< std::endl
<< " -> Energy : " << gOptEnergyDef << " ("
<< gOptEnergyRange.size() << ")" << std::endl
<< " -> NEvents : " << gOptNumberEvents << std::endl
<< " -> Generators : " << gOptGeneratorList << std::endl
<< " -> XSecPars : " << gOptCrossSections << std::endl
<< " -> Target : " << gOptTargetDef << std::endl
<< " -> Flux : " << gOptFluxDef << std::endl
<< " -> Output : " << gOptOutputFile << std::endl
<< " -> Run : " << gOptRunNumber);
return;
}
//____________________________________________________________________________
void PrintSyntax(void) {
- QLOG(FIT, "\n\n"
+ NUIS_LOG(FIT, "\n\n"
<< "Syntax:"
<< "\n"
<< "\n neut_nuisance [-h]"
<< "\n -n nev"
<< "\n -f flux_description"
<< "\n -t target_description"
<< "\n [ -r run_number ]"
<< "\n [ -o output_file ]"
<< "\n [ --cross-section /path/to/params.txt ]"
<< "\n [ --event-generator-list mode_definition ]"
<< "\n \n");
- QLOG(
+ NUIS_LOG(
FIT,
"\n\n Arguments:"
<< "\n"
<< "\n -n nev"
<< "\n -> Total number of events to generate (e.g. 2500000)"
<< "\n"
<< "\n -f flux_description"
<< "\n Definition of the flux to be read in from a ROOT file."
<< "\n"
<< "\n Multiple histograms can be read in from the same file using"
<< "\n the format '-f file.root,hist1[pdg1],hist2[pdg2]"
<< "\n e.g. \'-f "
"./flux/myfluxfile.root,numu_flux[14],numubar_flux[-14]\'"
<< "\n"
<< "\n A flux can also be given according to any of the flux IDs "
"shown"
<< "\n at the end of this help message."
<< "\n e.g. \' -f MINERvA_fhc_numu\' "
<< "\n"
<< "\n WARNING: NEUT can't actually generate combined fluxes yet"
<< "\n if you want a composite flux, pass them in as normal, but "
"the "
"app"
<< "\n will generate you the files seperately, with reduced "
"nevents "
"in each"
<< "\n so that the statistics are roughly okay."
<< "\n"
<< "\n -t target_description"
<< "\n Definition of the target to be used. Multiple targets can "
"be "
"given."
<< "\n"
<< "\n To pass a single target just provide the target PDG"
<< "\n e.g. \' -t 1000060120 \'"
<< "\n"
<< "\n To pass a combined target provide a list containing the "
"following"
<< "\n \' -t TotalNucleons,Target1[Weight1],Target2[Weight2],.. "
"where "
"the "
<< "\n TotalNucleons is the total nucleons combined, Target1 is "
"the "
"PDG "
<< "\n of the first target, and Weight1 is the fractional weight "
"of "
"the "
<< "\n first target."
<< "\n e.g. \' -t 13,1000060120[0.9231],1000010010[0.0769] \'"
<< "\n"
<< "\n Target can also be specified by the target IDs given at "
"the "
"end of"
<< "\n this help message."
<< "\n e.g. \' -t CH2 \'"
<< "\n"
<< "\n WARNING: NEUT can only generate A+H targets. E.g. CH or "
"CH2 "
"will work, but "
<< "\n Fe+Pb will not. You will have to generate each seperately "
"if "
"you want"
<< "\n something other than A+NH."
<< "\n"
<< "\n -r run_number"
<< "\n run number ID that can be used when generating large "
"samples "
"in small "
<< "\n jobs. Must be an integer. When given neut_nuisance will "
"update "
"the "
<< "\n output file from 'output.root' to "
"'output.root.run_number.root'"
<< "\n"
<< "\n -o output_file"
<< "\n Path to the output_file you want to save events to."
<< "\n"
<< "\n If this is not given but '-r' is then events will be saved "
"to "
<< "\n the file 'neutgen.run_number.neutvect.root'"
<< "\n"
<< "\n If a run number is given alongside '-o' then events will "
"be "
"saved "
<< "\n to 'output.root.run_number.root'"
<< "\n"
<< "\n --cross-section /path/to/params.txt"
<< "\n Path to the neut model definition. If this is not given, "
"then "
"this "
<< "\n will default to $NUISANCE/data/neut/Default_params.txt"
<< "\n"
<< "\n Look in $NUISANCE/data/neut/Default_params.txt for "
"examples "
"when "
<< "\n writing your own card files."
<< "\n"
<< "\n --event-generator-list mode_definition"
<< "\n Name of modes to run. This sets the CRS and CRSB values in "
"NEUT."
<< "\n e.g. --event-generator-list Default+MEC"
<< "\n"
<< "\n Allowed mode_definitions are given at the end of this help "
"message."
<< "\n"
<< "\n\n");
std::cout << "-----------------" << std::endl;
TargetUtils::ListTargetIDs();
std::cout << "-----------------" << std::endl;
BeamUtils::ListFluxIDs();
std::cout << "-----------------" << std::endl;
- QLOG(FIT) << "Allowed Mode Definitions:" << std::endl
+ NUIS_LOG(FIT) << "Allowed Mode Definitions:" << std::endl
<< " - Default : Default CC+NC modes, no MEC" << std::endl
<< " - Default+MEC : Default CC+NC modes + 2p2h MEC " << std::endl
<< " - DefaultFree : Default CC+NC modes, no Coherent or MEC ");
std::cout << "----------------" << std::endl;
exit(0);
}
//____________________________________________________________________________
#endif
diff --git a/app/nuisbayes.cxx b/app/nuisbayes.cxx
index 7a5ca21..98c9c3f 100644
--- a/app/nuisbayes.cxx
+++ b/app/nuisbayes.cxx
@@ -1,68 +1,68 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
// Author: Patrick Stowell 09/2016
/*
Usage: ./nuissyst -c card file -o output file, where the results of the throws are stored
where:
*/
#include "BayesianRoutines.h"
//*******************************
void printInputCommands(){
//*******************************
exit(-1);
};
//*******************************
int main(int argc, char* argv[]){
//*******************************
// Program status;
int status = 0;
// If No Arguments print commands
if (argc == 1) printInputCommands();
for (int i = 1; i< argc; ++i){
// Cardfile
if (!std::strcmp(argv[i], "-h")) printInputCommands();
else break;
}
// Read input arguments such as card file, parameter arguments, and fit routines
- QLOG(FIT,"Starting nuissyst");
+ NUIS_LOG(FIT,"Starting nuissyst");
// Make systematic class and run fit
BayesianRoutines* min = new BayesianRoutines(argc, argv);
min->Run();
// Show Final Status
- QLOG(FIT,"-------------------------------------");
- QLOG(FIT,"FINISHED");
- QLOG(FIT,"-------------------------------------");
+ NUIS_LOG(FIT,"-------------------------------------");
+ NUIS_LOG(FIT,"FINISHED");
+ NUIS_LOG(FIT,"-------------------------------------");
return status;
}
diff --git a/app/nuiscomp.cxx b/app/nuiscomp.cxx
index d21ff6d..b04cef7 100644
--- a/app/nuiscomp.cxx
+++ b/app/nuiscomp.cxx
@@ -1,293 +1,293 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#include "ComparisonRoutines.h"
//*******************************
void printInputCommands() {
//*******************************
std::cout << "nuiscomp : NUISANCE Data Comparison App \n" << std::endl;
std::cout
<< "# Running nuiscomp with a card file #\n"
<< "######################################\n"
<< "nuiscomp -c cardfile.xml [ -o outputfile.root ] [ -f routines ] [ "
"-n maxevents ] \n"
<< " [ -i 'cardstructure' ] [ -d fakedata ] [ -q config=val ] [ "
"+e/-e ] [ +v/-v ] \n"
<< "\n"
<< "# Running nuiscomp with structures at cmd line #\n"
<< "################################################\n"
<< "nuiscomp -i 'cardstructure' -o outputfile.root [ -c cardfile.xml [ "
"-f routines ] [ -n maxevents ] \n"
<< " [ -d fakedata ] [ -q config=val ] [ +e/-e ] [ +v/-v ] \n"
<< std::endl;
sleep(4);
std::cout
<< ""
<< "\n"
<< " \n"
<< " -c cardfile.xml : NUISANCE format card file defining "
"comparisons. \n"
<< " \n"
<< " -o outputfile.root : Output file that histograms will be "
"saved in. If a card file is \n"
<< " given but no output file this will "
"default to cardfile.xml.root \n"
<< " \n"
<< " -f routines : Comma separated list of comparison "
"routines to run in order. \n"
<< " Allowed Routines : "
" \n"
<< " Compare : Fixed comparison at "
"nominal dial values. \n"
<< " \n"
<< " -n maxevents : Set limit on the number of event "
"entries to process. \n"
<< " \n"
<< " -i \'cardstructure\' : Define card structure like those "
"available in the standard NUISANCE \n"
<< " card format, but on the command line "
"at runtime. MUST be enclosed \n"
<< " in single quotation marks. See "
"examples below for usage. \n"
<< " \n"
<< " It is possible to entirely define "
"the comparison using \' -i\' commands \n"
<< " without the need to write a card "
"file explicitly. If you do this, \n"
<< " make sure to also use the \' -o\' "
"flag to tell it where to go. \n"
<< " \n"
<< " -d fakedata : Define a fake data set to be used. "
"All data in NUISANCE will be set \n"
<< " to the values defined in this fake "
"data before comparisons are made. \n"
<< " \n"
<< " There are two possible methods. Fake "
"data from MC or a previous file.\n"
<< " fakedata = \'MC\' : Sets the MC to "
"the values defined by \'fake_parameters\' \n"
<< " shown in the "
"examples below, and then sets the data \n"
<< " to be equal to "
"this MC prediction. \n"
<< " fakedata = \'file.root\' : Reads in "
"the ROOT file at the specified path \n"
<< " assuming "
"its a standard NUISANCE file. Takes \n"
<< " MC "
"predictions in this file and uses them as \n"
<< " fake data. "
"\n"
<< " \n"
<< " -q config=val : Overrides default configurations "
"provided in the cardfile and in \n"
<< " '$NUISANCE/parameters/config.xml\'. "
"Any config parameter can be set. \n"
<< " Examples : \n"
<< " \'-q VERBOSITY=4\' \n"
<< " \'-q EventManager=1\' \n"
<< " \'-q drawOpts=DATA/MC\' \n"
<< " \n"
<< " +e/-e : Increase/Decrease the default error "
"verbosity by 1. \n"
<< " \n"
<< " +v/-v : Increase/Decrease the default "
"logging verbosity by 1.\n"
<< " \n\n"
<< std::endl;
sleep(4);
std::cout
<< "# nuiscomp Running Examples #"
<< "############################# \n"
<< " \n"
<< " 1. Generate cardfile comparisons with increased verbosity and only "
"50000 events \n\n"
<< " nuiscomp -c cardfile.card -o mycomp.root -n 50000 +v +v \n"
<< " \n\n"
<< " 2. Generate a comparison to MiniBooNE data using simple structure, "
"saving it to outfile.root \n\n"
<< " nuiscomp -o outfile.root -i \'sample "
"MiniBooNE_CCQE_XSec_1DQ2_nu NEUT:neutevents.root\' \n"
<< " \n\n"
<< " 3. Generate a comparison to MiniBooNE data using xml structure, "
"reweight MaCCQE, and save the prediction to outfile.root \n\n"
<< " nuiscomp -o outfile.root -i \'sample "
"name=\"MiniBooNE_CCQE_XSec_1DQ2_nu\" "
"input=\"NEUT:neutevents.root\"\' \\ \n"
<< " -i \'sample "
"name=\"MiniBooNE_CC1pip_XSec_1DQ2_nu\" "
"input=\"NEUT:neutevents.root\"\' \\ \n"
<< " -i \'parameter name=\"MaCCQE\" "
"nominal=\"1.0\" type=\"neut_parameter\"\' \n "
<< " \n\n"
<< " 4. Generate a comparison, using fake data from the MC predictions "
"inside the fakedata.root \n\n"
<< " nuiscomp -c cardfile.card -o myfakecomp.root -d fakedata.root "
"\n"
<< " \n\n"
<< " 5. Generate a comparison using fake data defined on the command "
"line use fake parameters \n\n"
<< " nuiscomp -c cardfile.card -d MC -i \'fakeparameter "
"name=\"MaCCQE\" nominal=\"1.0\"\' \n "
<< " -i \'parameter name=\"MaCCQE\" "
"nominal=\"1.0\" type=\"neut_parameter\"' "
<< " \n\n"
<< std::endl;
sleep(4);
std::cout << "# NUISANCE Card Format Structure Examples # \n"
<< "########################################### \n"
<< "\n"
<< "The NUISANCE card can be defined as a simple text file, or an "
"xml file. \n"
<< "Examples for both with relevant structures are given below. \n"
<< std::endl;
std::cout
<< "# XML Card File Example # \n"
<< "cardfile.xml: \n"
<< ""
<< "\n"
<< " \n"
<< " \n"
<< " \n"
<< "\n"
<< " \n"
<< " "
"\n"
<< " \n"
<< " \n"
<< " \n"
<< " \n"
<< " \n"
<< "\n"
<< " \n"
<< " \n"
<< "\n"
<< "\n"
<< " \n"
<< " \n"
<< " \n"
<< " \n"
<< " \n"
<< "\n"
<< " \n"
<< "\n"
<< " \n"
<< " \n"
<< " \n"
<< " \n"
<< " \n"
<< "\n"
<< " \n"
<< "\n"
<< " \n\n"
<< std::endl;
std::cout
<< "# Simple Card File Example # \n"
<< "cardfile.card: \n"
<< "\n"
<< "# CONFIG STRUCTURE \n"
<< "# config name val \n"
<< "config VERBOSITY 4 \n"
<< "\n"
<< "# Sample Structure \n"
<< "# ID Corresponds to names given in src/FCN/SampleList.cxx \n"
<< "# TYPE is the generator type (NEUT,NUWRO,GENIE,GIBUU). \n"
<< "# FILE is the input generator events file. \n"
<< "# TYPE is optional and used to define options for a class. e.g. FREE "
" \n"
<< "# NORM is optional and sets sample normalisations. \n"
<< "# sample ID TYPE:FILE TYPE 1.0 \n"
<< "\n"
<< "sample MiniBooNE_CCQE_XSec_1DQ2_nu GENIE:genieevents.root \n"
<< "sample MiniBooNE_CC1pip_XSec_1DQ2_nu GENIE:genieevents.root SHAPE \n"
<< "\n"
<< "\n"
<< "# Parameter Structure \n"
<< "# ID is the name of the dial in each generator RW engine \n"
<< "# TYPE is the dial type (neut,newer,genie,niwg,t2k,custom,norm) \n"
<< "# VAL is the nominal value in 1-sigma variation for the comparison \n"
<< "# TYPE_parameter ID VAL \n"
<< "\n"
<< "neut_parameter MaCCQE 0.5 \n"
<< "\n"
<< "# Fake Parameter Structure \n"
<< "# Sets values for fake data defined using the ‘MC’ flag. \n"
<< "# ID is the dial name, it MUST be specified before hand using a "
"normal parameter structure \n"
<< "# VAL is the value to use for the fake data \n"
<< "# fake_parameter ID VAL \n"
<< "\n"
<< "fake_parameter MaCCQE 1.0 \n"
<< "\n"
<< std::endl;
exit(-1);
};
//*******************************
int main(int argc, char *argv[]) {
//*******************************
// Program status;
int status = 0;
// If No Arguments print commands
if (argc == 1)
printInputCommands();
for (int i = 1; i < argc; ++i) {
// Cardfile
if (!std::strcmp(argv[i], "-h"))
printInputCommands();
else
break;
}
// Read input arguments such as card file, parameter arguments, and fit
// routines
- QLOG(FIT, "Starting nuiscomp.exe");
+ NUIS_LOG(FIT, "Starting nuiscomp.exe");
// Make minimizer class and run fit
ComparisonRoutines *comp = new ComparisonRoutines(argc, argv);
comp->Run();
delete comp;
// Show Final Status
- QLOG(FIT, "------------------------------------ -");
- QLOG(FIT, "Comparison Complete.");
- QLOG(FIT, "------------------------------------ -");
+ NUIS_LOG(FIT, "------------------------------------ -");
+ NUIS_LOG(FIT, "Comparison Complete.");
+ NUIS_LOG(FIT, "------------------------------------ -");
return status;
}
diff --git a/app/nuisflat.cxx b/app/nuisflat.cxx
index a15e9b5..25fa4ed 100644
--- a/app/nuisflat.cxx
+++ b/app/nuisflat.cxx
@@ -1,391 +1,391 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#include "ComparisonRoutines.h"
#include "GenericFlux_Tester.h"
#include "GenericFlux_Vectors.h"
#include "InputUtils.h"
#include "MeasurementBase.h"
#include "Smearceptance_Tester.h"
// Global Arguments
std::string gOptInputFile = "";
std::string gOptFormat = "";
std::string gOptOutputFile = "";
std::string gOptType = "DEFAULT";
std::string gOptNumberEvents = "NULL";
std::string gOptCardInput = "";
std::string gOptOptions = "";
// Input Dial Vals
std::vector fParams; ///< Vector of dial names.
std::map fStateVals; ///< Map of dial states
std::map fCurVals; ///< Map of dial values
std::map fTypeVals; ///< Map of dial type enums.
// Fake Dial Vals
std::map fFakeVals; ///< Map of fake data settings.
void SetupComparisonsFromXML();
void SetupRWEngine();
//*******************************
void PrintSyntax() {
//*******************************
std::cout << "nuisflat -i input [-f format] [-o outfile] [-n nevents] [-t "
"options] [-q con=val] \n";
std::cout
<< "\n Arguments : "
<< "\n\t -i input : Path to input vector of events to flatten"
<< "\n\t"
<< "\n\t This should be given in the same format a normal "
"input file"
<< "\n\t is given to NUISANCE. {e.g. NUWRO:eventsout.root}."
<< "\n\t"
<< "\n\t -f format : FlatTree format to output. If none given "
"GenericVectors used."
<< "\n\t\t GenericFlux : Flat event summary format."
<< "\n\t\t GenericVectors : Standard event summary format with "
"particle vectors."
<< "\n\t "
<< "\n\t[-c crd.xml]: Input card file to override configs or set dial "
"values."
<< "\n\t "
<< "\n\t[-o outfile]: Optional output file path. "
<< "\n\t "
<< "\n\t If none given, input.format.root is chosen."
<< "\n\t"
<< "\n\t[-n nevents]: Optional choice of Nevents to run over. Default is "
"all."
<< "\n\t"
<< "\n\t[-t options]: Pass OPTION to the FlatTree sample. "
<< "\n\t Similar to type field in comparison xml configs."
<< "\n\t"
<< "\n\t[-q con=val]: Configuration overrides." << std::endl;
exit(-1);
};
//____________________________________________________________________________
void GetCommandLineArgs(int argc, char **argv) {
// Check for -h flag.
for (int i = 0; i < argc; i++) {
if ((!std::string(argv[i]).compare("-h")) ||
(!std::string(argv[i]).compare("-?")) ||
(!std::string(argv[i]).compare("--help")))
PrintSyntax();
}
// Format is nuwro -r run_number -n n events
std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv);
// Parse input file
ParserUtils::ParseArgument(args, "-i", gOptInputFile, false);
if (gOptInputFile == "") {
- QTHROW("Need to provide a valid input file to nuisflat using -i flag!");
+ NUIS_ABORT("Need to provide a valid input file to nuisflat using -i flag!");
} else {
- QLOG(FIT, "Reading Input File = " << gOptInputFile);
+ NUIS_LOG(FIT, "Reading Input File = " << gOptInputFile);
}
// Get Output Format
ParserUtils::ParseArgument(args, "-f", gOptFormat, false);
if (gOptFormat == "") {
gOptFormat = "GenericVectors";
- QLOG(FIT, "Saving flattree in default format = " << gOptFormat);
+ NUIS_LOG(FIT, "Saving flattree in default format = " << gOptFormat);
} else {
- QLOG(FIT, "Saving flattree in format = " << gOptFormat);
+ NUIS_LOG(FIT, "Saving flattree in format = " << gOptFormat);
}
// Get Output File
ParserUtils::ParseArgument(args, "-o", gOptOutputFile, false);
if (gOptOutputFile == "") {
gOptOutputFile = gOptInputFile + "." + gOptFormat + ".root";
- QLOG(FIT, "No output file given so saving nuisflat output to:"
+ NUIS_LOG(FIT, "No output file given so saving nuisflat output to:"
<< gOptOutputFile);
} else {
- QLOG(FIT, "Saving nuisflat output to " << gOptOutputFile);
+ NUIS_LOG(FIT, "Saving nuisflat output to " << gOptOutputFile);
}
// Get N Events and Configs
nuisconfig configuration = Config::Get();
ParserUtils::ParseArgument(args, "-n", gOptNumberEvents, false);
if (gOptNumberEvents.compare("NULL")) {
configuration.OverrideConfig("MAXEVENTS=" + gOptNumberEvents);
}
std::vector configargs;
ParserUtils::ParseArgument(args, "-q", configargs);
for (size_t i = 0; i < configargs.size(); i++) {
configuration.OverrideConfig(configargs[i]);
}
ParserUtils::ParseArgument(args, "-c", gOptCardInput, false);
if (gOptCardInput != "") {
- QLOG(FIT, "Reading cardfile: " << gOptCardInput);
+ NUIS_LOG(FIT, "Reading cardfile: " << gOptCardInput);
configuration.LoadSettings(gOptCardInput, "");
}
ParserUtils::ParseArgument(args, "-t", gOptOptions, false);
if (gOptOptions != "") {
- QLOG(FIT, "Read options: \"" << gOptOptions << "\'");
+ NUIS_LOG(FIT, "Read options: \"" << gOptOptions << "\'");
}
return;
}
//*******************************
int main(int argc, char *argv[]) {
//*******************************
// Parse
GetCommandLineArgs(argc, argv);
// Make output file
TFile *f = new TFile(gOptOutputFile.c_str(), "RECREATE");
if (f->IsZombie()) {
- QTHROW("Cannot create output file!");
+ NUIS_ABORT("Cannot create output file!");
}
f->cd();
FitPar::Config().out = f;
// Create a new measurementbase class depending on the Format
MeasurementBase *flattreecreator = NULL;
SetupComparisonsFromXML();
SetupRWEngine();
// SetupFCN();
// Make a new sample key for the format of interest.
nuiskey samplekey = Config::CreateKey("sample");
if (!gOptFormat.compare("GenericFlux")) {
samplekey.Set("name", "FlatTree");
samplekey.Set("input", gOptInputFile);
samplekey.Set("type", gOptType);
flattreecreator = new GenericFlux_Tester("FlatTree", gOptInputFile,
FitBase::GetRW(), gOptType, "");
} else if (!gOptFormat.compare("GenericVectors")) {
samplekey.Set("name", "FlatTree");
samplekey.Set("input", gOptInputFile);
samplekey.Set("type", gOptType);
flattreecreator = new GenericFlux_Vectors("FlatTree", gOptInputFile,
FitBase::GetRW(), gOptType, "");
} else {
- QERROR(FTL, "Unknown FlatTree format!");
+ NUIS_ERR(FTL, "Unknown FlatTree format!");
}
// Make the FlatTree reconfigure
flattreecreator->Reconfigure();
f->cd();
flattreecreator->Write();
f->Close();
// Show Final Status
- QLOG(FIT, "-------------------------------------");
- QLOG(FIT, "Flattree Generation Complete.");
- QLOG(FIT, "-------------------------------------");
+ NUIS_LOG(FIT, "-------------------------------------");
+ NUIS_LOG(FIT, "Flattree Generation Complete.");
+ NUIS_LOG(FIT, "-------------------------------------");
return 0;
}
//*************************************
void SetupComparisonsFromXML() {
//*************************************
- QLOG(FIT, "Setting up nuiscomp");
+ NUIS_LOG(FIT, "Setting up nuiscomp");
// Setup Parameters ------------------------------------------
std::vector parkeys = Config::QueryKeys("parameter");
if (!parkeys.empty()) {
- QLOG(FIT, "Number of parameters : " << parkeys.size());
+ NUIS_LOG(FIT, "Number of parameters : " << parkeys.size());
}
for (size_t i = 0; i < parkeys.size(); i++) {
nuiskey key = parkeys.at(i);
// Check for type,name,nom
if (!key.Has("type")) {
- QERROR(FTL, "No type given for parameter " << i);
- QERROR(FTL, "type='PARAMETER_TYPE'");
+ NUIS_ERR(FTL, "No type given for parameter " << i);
+ NUIS_ERR(FTL, "type='PARAMETER_TYPE'");
throw;
} else if (!key.Has("name")) {
- QERROR(FTL, "No name given for parameter " << i);
- QERROR(FTL, "name='SAMPLE_NAME'");
+ NUIS_ERR(FTL, "No name given for parameter " << i);
+ NUIS_ERR(FTL, "name='SAMPLE_NAME'");
throw;
} else if (!key.Has("nominal")) {
- QERROR(FTL, "No nominal given for parameter " << i);
- QERROR(FTL, "nominal='NOMINAL_VALUE'");
+ NUIS_ERR(FTL, "No nominal given for parameter " << i);
+ NUIS_ERR(FTL, "nominal='NOMINAL_VALUE'");
throw;
}
// Get Inputs
std::string partype = key.GetS("type");
std::string parname = key.GetS("name");
double parnom = key.GetD("nominal");
double parlow = parnom - 1;
double parhigh = parnom + 1;
double parstep = 1;
// override if state not given
if (!key.Has("state")) {
key.SetS("state", "FIX");
}
std::string parstate = key.GetS("state");
// Check for incomplete limtis
int limdef =
((int)key.Has("low") + (int)key.Has("high") + (int)key.Has("step"));
if (limdef > 0 and limdef < 3) {
- QERROR(FTL, "Incomplete limit set given for parameter : " << parname);
- QERROR(
+ NUIS_ERR(FTL, "Incomplete limit set given for parameter : " << parname);
+ NUIS_ERR(
FTL,
"Requires: low='LOWER_LIMIT' high='UPPER_LIMIT' step='STEP_SIZE' ");
throw;
}
// Extra limits
if (key.Has("low")) {
parlow = key.GetD("low");
parhigh = key.GetD("high");
parstep = key.GetD("step");
- QLOG(FIT, "Read " << partype << " : " << parname << " = " << parnom
+ NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom
<< " : " << parlow << " < p < " << parhigh << " : "
<< parstate);
} else {
- QLOG(FIT, "Read " << partype << " : " << parname << " = " << parnom
+ NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom
<< " : " << parstate);
}
// Convert if required
if (parstate.find("ABS") != std::string::npos) {
parnom = FitBase::RWAbsToSigma(partype, parname, parnom);
parlow = FitBase::RWAbsToSigma(partype, parname, parlow);
parhigh = FitBase::RWAbsToSigma(partype, parname, parhigh);
parstep = FitBase::RWAbsToSigma(partype, parname, parstep);
} else if (parstate.find("FRAC") != std::string::npos) {
parnom = FitBase::RWFracToSigma(partype, parname, parnom);
parlow = FitBase::RWFracToSigma(partype, parname, parlow);
parhigh = FitBase::RWFracToSigma(partype, parname, parhigh);
parstep = FitBase::RWFracToSigma(partype, parname, parstep);
}
// Push into vectors
fParams.push_back(parname);
fTypeVals[parname] = FitBase::ConvDialType(partype);
;
fCurVals[parname] = parnom;
fStateVals[parname] = parstate;
}
// Setup Samples ----------------------------------------------
std::vector samplekeys = Config::QueryKeys("sample");
if (!samplekeys.empty()) {
- QLOG(FIT,"Number of samples : " << samplekeys.size());
+ NUIS_LOG(FIT,"Number of samples : " << samplekeys.size());
}
for (size_t i = 0; i < samplekeys.size(); i++) {
nuiskey key = samplekeys.at(i);
// Get Sample Options
std::string samplename = key.GetS("name");
std::string samplefile = key.GetS("input");
std::string sampletype = key.Has("type") ? key.GetS("type") : "DEFAULT";
double samplenorm = key.Has("norm") ? key.GetD("norm") : 1.0;
// Print out
- QLOG(FIT, "Read Sample " << i << ". : " << samplename << " ("
+ NUIS_LOG(FIT, "Read Sample " << i << ". : " << samplename << " ("
<< sampletype << ") [Norm=" << samplenorm << "]" << std::endl
<< " -> input='" << samplefile
<< "'");
// If FREE add to parameters otherwise continue
if (sampletype.find("FREE") == std::string::npos) {
continue;
}
// Form norm dial from samplename + sampletype + "_norm";
std::string normname = samplename + "_norm";
// Check normname not already present
if (fTypeVals.find("normname") != fTypeVals.end()) {
continue;
}
// Add new norm dial to list if its passed above checks
fParams.push_back(normname);
fTypeVals[normname] = kNORM;
fStateVals[normname] = sampletype;
fCurVals[normname] = samplenorm;
}
// Setup Fake Parameters -----------------------------
std::vector fakekeys = Config::QueryKeys("fakeparameter");
if (!fakekeys.empty()) {
- QLOG(FIT,"Number of fake parameters : " << fakekeys.size());
+ NUIS_LOG(FIT,"Number of fake parameters : " << fakekeys.size());
}
for (size_t i = 0; i < fakekeys.size(); i++) {
nuiskey key = fakekeys.at(i);
// Check for type,name,nom
if (!key.Has("name")) {
- QERROR(FTL, "No name given for fakeparameter " << i);
+ NUIS_ERR(FTL, "No name given for fakeparameter " << i);
throw;
} else if (!key.Has("nominal")) {
- QERROR(FTL, "No nominal given for fakeparameter " << i);
+ NUIS_ERR(FTL, "No nominal given for fakeparameter " << i);
throw;
}
// Get Inputs
std::string parname = key.GetS("name");
double parnom = key.GetD("nominal");
// Push into vectors
fFakeVals[parname] = parnom;
}
}
//*************************************
void SetupRWEngine() {
//*************************************
- QLOG(FIT,"Setting up FitWeight Engine");
+ NUIS_LOG(FIT,"Setting up FitWeight Engine");
for (UInt_t i = 0; i < fParams.size(); i++) {
std::string name = fParams[i];
FitBase::GetRW()->IncludeDial(name, fTypeVals.at(name));
}
for (UInt_t i = 0; i < fParams.size(); i++) {
std::string name = fParams[i];
if (fCurVals.find(name) == fCurVals.end())
continue;
FitBase::GetRW()->SetDialValue(name, fCurVals.at(name));
}
FitBase::GetRW()->Reconfigure();
return;
}
diff --git a/app/nuismin.cxx b/app/nuismin.cxx
index c8175ab..7b965d5 100644
--- a/app/nuismin.cxx
+++ b/app/nuismin.cxx
@@ -1,141 +1,141 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
// Author: Callum Wilkinson 01/2014
// Patrick Stowell 09/2015
/**
Usage: ./GSLminimizerWithReWeight.exe -c card file, where samples and
parameters are defined -o output file, where the results of the fit are stored
where:
*/
#include "MinimizerRoutines.h"
//*******************************
void printInputCommands() {
//*******************************
std::cout
<< "ExtFit_minimizer.exe -c cardFile -o outFile [-f fitStategy] [-d "
"fakeDataFile] [-i inputFile] [-q config_name=config_val] \n";
std::cout << std::endl;
std::cout << "Arguments:" << std::endl;
std::cout << " -c cardFile: Path to card file that defines fit "
"samples, free parameters, and config overrides \n";
std::cout << " -o outFile: Path to root file that will be created to "
"save output file.\n";
std::cout << " To turn automatically overwrite outFile if "
"one exists turn off use 'config overwrite_output 1'\n";
std::cout << " To automatically use previous outFile as "
"an inputFile if it exists so that the fit can be continued\n";
std::cout << " use the flag 'config use_previous_output "
"1'. (A warning will be printed when doing this). \n";
std::cout << " -f fitStategy: Pass a comma seperated list of fit "
"routines to run in order. Default is Migrad,FixAtLim \n";
std::cout << " Possible Options: \n";
std::cout << " 1. Migrad - Minuit2 Migrad Minimizer \n";
std::cout << " 2. Simplex - Simplex Minimizer \n";
std::cout << " 3. Scan - Brute force scan of parameter "
"space \n";
std::cout << " 4. FixAtLim - Takes any free parameters "
"close to a limit and fixes them \n";
std::cout << " 5. Scan1D - Make 1D Scans and save them "
"in a folder \n";
std::cout << " 6. Contours - Make Contour Scans \n";
std::cout << " 7. Save - Will save the state of the "
"fitter (Always done by default at the end) \n";
std::cout << " Extra option LowStatFit will perform "
"each of these options with a lower number \n";
std::cout << " of fit events (config lowstat). Example: "
"LowStatMigrad, LowStatScan \n";
std::cout << " -d fakeDataFile: Uses the MC generated from a previous "
"fit as a fake data set for these fits \n";
std::cout << " Can also specify MC to set the fake-data "
"to the Monte-Carlo prediction\n";
std::cout << " In this case, you can specify "
"fake_parameter PARAM_NAME PARAM_VALUE in the card\n";
std::cout << " to reweight the MC parameter "
"PARAM_NAME to some PARAM_VALUE. The minimiser will start\n";
std::cout << " at whatever neut_parameter or "
"genie_parameter is set to in the cardfile.\n";
std::cout << " -i inputFile: Uses the results from a previous fit file "
"as starting input for these fits \n";
std::cout << " -q config_name=config_val : Allows any config parameter "
"to be overridden from the command line.\n";
std::cout << " This will take priority over "
"those given in the default, or cardFile. \n";
std::cout << " example: -q verbosity=6 -q "
"maxevents=10000 \n";
exit(-1);
};
//*******************************
int main(int argc, char *argv[]) {
//*******************************
// Program status;
int status = 0;
// If No Arguments print commands
if (argc == 1)
printInputCommands();
for (int i = 1; i < argc; ++i) {
// Cardfile
if (!std::strcmp(argv[i], "-h"))
printInputCommands();
else
break;
}
// Read input arguments such as card file, parameter arguments, and fit
// routines
- QLOG(FIT, "Starting ExtFit_minimizer.exe");
+ NUIS_LOG(FIT, "Starting ExtFit_minimizer.exe");
// Make minimizer class and run fit
MinimizerRoutines *min = new MinimizerRoutines(argc, argv);
// Save Starting States
if (FitPar::Config().GetParB("savenominal"))
min->SaveNominal();
if (FitPar::Config().GetParB("saveprefit"))
min->SavePrefit();
// Run the fit routines
min->Run();
// Save by default
min->SaveResults();
// Get Status
status = min->GetStatus();
// Show Final Status
- QLOG(FIT, "-------------------------------------");
+ NUIS_LOG(FIT, "-------------------------------------");
if (status == 0) {
- QLOG(FIT, "Minimizer Complete.");
+ NUIS_LOG(FIT, "Minimizer Complete.");
} else {
- QERROR(WRN, "Minimizer Failed (error state = " << status << ")");
+ NUIS_ERR(WRN, "Minimizer Failed (error state = " << status << ")");
}
- QLOG(FIT, "-------------------------------------");
+ NUIS_LOG(FIT, "-------------------------------------");
return status;
}
diff --git a/app/nuissmear.cxx b/app/nuissmear.cxx
index a649139..d085fbe 100644
--- a/app/nuissmear.cxx
+++ b/app/nuissmear.cxx
@@ -1,218 +1,218 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#include "ComparisonRoutines.h"
#include "InputUtils.h"
#include "Smearceptance_Tester.h"
// Global Arguments
std::string gOptInputFile = "";
std::string gOptOutputFile = "";
std::string gOptType = "DEFAULT";
std::string gOptNumberEvents = "NULL";
std::string gOptCardInput = "";
std::string gOptOptions = "";
//*******************************
void PrintSyntax() {
//*******************************
std::cout << "nuisflat -i input [-o outfile] [-n nevents] [-t "
"options] [-q con=val] \n";
std::cout
<< "\n Arguments : "
<< "\n\t -i input : Path to input vector of events to flatten"
<< "\n\t"
<< "\n\t This should be given in the same format a normal "
"input file"
<< "\n\t is given to NUISANCE. {e.g. NUWRO:eventsout.root}."
<< "\n\t"
<< "\n\t[-c crd.xml]: Input card file to override configs or define "
"smearcepters."
<< "\n\t "
<< "\n\t[-o outfile]: Optional output file path. "
<< "\n\t "
<< "\n\t If none given, input.smear.root is chosen."
<< "\n\t"
<< "\n\t[-n nevents]: Optional choice of Nevents to run over. Default is "
"all."
<< "\n\t"
<< "\n\t[-t options]: Pass OPTION to the smearception sample. "
<< "\n\t Similar to type field in comparison xml configs."
<< "\n\t"
<< "\n\t[-q con=val]: Configuration overrides." << std::endl;
exit(-1);
};
//____________________________________________________________________________
void GetCommandLineArgs(int argc, char **argv) {
// Check for -h flag.
for (int i = 0; i < argc; i++) {
if ((!std::string(argv[i]).compare("-h")) ||
(!std::string(argv[i]).compare("-?")) ||
(!std::string(argv[i]).compare("--help")))
PrintSyntax();
}
// Format is nuwro -r run_number -n n events
std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv);
// Parse input file
ParserUtils::ParseArgument(args, "-i", gOptInputFile, false);
if (gOptInputFile == "") {
- QTHROW("Need to provide a valid input file to nuisflat using -i flag!");
+ NUIS_ABORT("Need to provide a valid input file to nuisflat using -i flag!");
} else {
- QLOG(FIT, "Reading Input File = " << gOptInputFile);
+ NUIS_LOG(FIT, "Reading Input File = " << gOptInputFile);
gOptInputFile = InputUtils::PrependGuessedInputTypeToName(gOptInputFile);
}
// Get Output File
ParserUtils::ParseArgument(args, "-o", gOptOutputFile, false);
if (gOptOutputFile == "") {
gOptOutputFile = gOptInputFile + ".smear.root";
- QLOG(FIT, "No output file given so saving nuisflat output to:"
+ NUIS_LOG(FIT, "No output file given so saving nuisflat output to:"
<< gOptOutputFile);
} else {
- QLOG(FIT, "Saving nuisflat output to " << gOptOutputFile);
+ NUIS_LOG(FIT, "Saving nuisflat output to " << gOptOutputFile);
}
// Get N Events and Configs
nuisconfig configuration = Config::Get();
ParserUtils::ParseArgument(args, "-n", gOptNumberEvents, false);
if (gOptNumberEvents.compare("NULL")) {
configuration.OverrideConfig("MAXEVENTS=" + gOptNumberEvents);
}
std::vector configargs;
ParserUtils::ParseArgument(args, "-q", configargs);
for (size_t i = 0; i < configargs.size(); i++) {
configuration.OverrideConfig(configargs[i]);
}
ParserUtils::ParseArgument(args, "-c", gOptCardInput, false);
if (gOptCardInput != "") {
- QLOG(FIT, "Reading cardfile: " << gOptCardInput);
+ NUIS_LOG(FIT, "Reading cardfile: " << gOptCardInput);
configuration.LoadSettings(gOptCardInput, "");
}
ParserUtils::ParseArgument(args, "-t", gOptOptions, false);
if (gOptOptions != "") {
- QLOG(FIT, "Read options: \"" << gOptOptions << "\'");
+ NUIS_LOG(FIT, "Read options: \"" << gOptOptions << "\'");
}
return;
}
void SetupRW() {
std::vector parkeys = Config::QueryKeys("parameter");
if (!parkeys.empty()) {
- QLOG(FIT, "Number of parameters : " << parkeys.size());
+ NUIS_LOG(FIT, "Number of parameters : " << parkeys.size());
}
std::vector Params;
std::map TypeVals;
std::map CurrVals;
for (size_t i = 0; i < parkeys.size(); i++) {
nuiskey key = parkeys.at(i);
// Check for type,name,nom
if (!key.Has("type")) {
- QERROR(FTL, "No type given for parameter " << i);
- QTHROW("type='PARAMETER_TYPE'");
+ NUIS_ERR(FTL, "No type given for parameter " << i);
+ NUIS_ABORT("type='PARAMETER_TYPE'");
} else if (!key.Has("name")) {
- QERROR(FTL, "No name given for parameter " << i);
- QTHROW("name='SAMPLE_NAME'");
+ NUIS_ERR(FTL, "No name given for parameter " << i);
+ NUIS_ABORT("name='SAMPLE_NAME'");
} else if (!key.Has("nominal")) {
- QERROR(FTL, "No nominal given for parameter " << i);
- QTHROW("nominal='NOMINAL_VALUE'");
+ NUIS_ERR(FTL, "No nominal given for parameter " << i);
+ NUIS_ABORT("nominal='NOMINAL_VALUE'");
}
// Get Inputs
std::string partype = key.GetS("type");
std::string parname = key.GetS("name");
double parnom = key.GetD("nominal");
// Push into vectors
Params.push_back(parname);
TypeVals[parname] = FitBase::ConvDialType(partype);
CurrVals[parname] = parnom;
}
for (UInt_t i = 0; i < Params.size(); i++) {
FitBase::GetRW()->IncludeDial(Params[i], TypeVals[Params[i]]);
FitBase::GetRW()->SetDialValue(Params[i], CurrVals[Params[i]]);
}
FitBase::GetRW()->Reconfigure();
}
//*******************************
int main(int argc, char *argv[]) {
//*******************************
// Parse
GetCommandLineArgs(argc, argv);
// Make output file
TFile *f = new TFile(gOptOutputFile.c_str(), "RECREATE");
if (f->IsZombie()) {
- QTHROW("Cannot create output file!");
+ NUIS_ABORT("Cannot create output file!");
}
f->cd();
Config::Get().out = f;
// Create a new measurementbase class depending on the Format
MeasurementBase *flattreecreator = NULL;
// Make a new sample key for the format of interest.
nuiskey samplekey = Config::CreateKey("sample");
samplekey.Set("name", "FlatTree");
samplekey.Set("smearceptor", gOptOptions);
samplekey.Set("input", gOptInputFile);
samplekey.Set("type", gOptType);
if (gOptOptions == "") {
- QTHROW("Attempting to flatten with Smearceptor, but no Smearceptor given. "
+ NUIS_ABORT("Attempting to flatten with Smearceptor, but no Smearceptor given. "
"Please supply a -t option.");
}
if (gOptCardInput == "") {
- QTHROW("Attempting to flatten with Smearceptor, but no card passed with "
+ NUIS_ABORT("Attempting to flatten with Smearceptor, but no card passed with "
"Smearceptors configured. Please supply a -c option.");
}
SetupRW();
flattreecreator = new Smearceptance_Tester(samplekey);
// Make the FlatTree reconfigure
flattreecreator->Reconfigure();
f->cd();
flattreecreator->Write();
f->Close();
// Show Final Status
- QLOG(FIT, "-------------------------------------");
- QLOG(FIT, "Flattree Generation Complete.");
- QLOG(FIT, "-------------------------------------");
+ NUIS_LOG(FIT, "-------------------------------------");
+ NUIS_LOG(FIT, "Flattree Generation Complete.");
+ NUIS_LOG(FIT, "-------------------------------------");
return 0;
}
diff --git a/app/nuissplines.cxx b/app/nuissplines.cxx
index e66685b..2ab79eb 100644
--- a/app/nuissplines.cxx
+++ b/app/nuissplines.cxx
@@ -1,105 +1,105 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
// Author: Callum Wilkinson 01/2014
// Patrick Stowell 09/2015
/**
Usage: ./GSLminimizerWithReWeight.exe -c card file, where samples and
parameters are defined -o output file, where the results of the fit are stored
where:
*/
#include "SplineRoutines.h"
//*******************************
void printInputCommands(){
//*******************************
/*
std::cout<<"ExtFit_splines.exe -c cardFile -f [spline_routines] [-q
config_name=config_val] \n"; std::cout<Run();
// Show Final Status
- QLOG(FIT, "-------------------------------------");
- QLOG(FIT, "Spline Generation/Validation Finished.");
- QLOG(FIT, "-------------------------------------");
+ NUIS_LOG(FIT, "-------------------------------------");
+ NUIS_LOG(FIT, "Spline Generation/Validation Finished.");
+ NUIS_LOG(FIT, "-------------------------------------");
return 0;
}
diff --git a/app/nuissyst.cxx b/app/nuissyst.cxx
index cdc1746..5e66265 100644
--- a/app/nuissyst.cxx
+++ b/app/nuissyst.cxx
@@ -1,83 +1,83 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
// Author: Patrick Stowell 09/2016
/*
Usage: ./nuissyst -c card file -o output file, where the results of the throws
are stored where:
*/
#include "SystematicRoutines.h"
//*******************************
void printInputCommands() {
//*******************************
std::cout << "nuissyst.exe -c cardFile -o outFile [-f fitStategy] [-d "
"fakeDataFile] [-i inputFile] [-q config_name=config_val] \n";
std::cout << std::endl;
std::cout << "Arguments:" << std::endl;
std::cout << " -c cardFile: Path to card file that defines fit "
"samples, free parameters, and config overrides \n";
std::cout << " -o outFile: Path to root file that will be created to "
"save output file.\n";
std::cout << " -f Strategy: ErrorBands (default) or PlotLimits\n"
<< std::endl;
exit(-1);
};
//*******************************
int main(int argc, char *argv[]) {
//*******************************
// Program status;
int status = 0;
// If No Arguments print commands
if (argc == 1)
printInputCommands();
for (int i = 1; i < argc; ++i) {
// Cardfile
if (!std::strcmp(argv[i], "-h"))
printInputCommands();
else
break;
}
// Read input arguments such as card file, parameter arguments, and fit
// routines
- QLOG(FIT, "Starting nuissyst");
+ NUIS_LOG(FIT, "Starting nuissyst");
// Make systematic class and run fit
SystematicRoutines *min = new SystematicRoutines(argc, argv);
min->Run();
// Show Final Status
- QLOG(FIT, "-------------------------------------");
+ NUIS_LOG(FIT, "-------------------------------------");
if (status == 0) {
- QLOG(FIT, "Systematic Complete.");
+ NUIS_LOG(FIT, "Systematic Complete.");
} else {
- QERROR(FTL, "Systematic Failed (error state = " << status << ")");
+ NUIS_ERR(FTL, "Systematic Failed (error state = " << status << ")");
}
- QLOG(FIT, "-------------------------------------");
+ NUIS_LOG(FIT, "-------------------------------------");
return status;
}
diff --git a/app/nuwro_NUISANCE.cxx b/app/nuwro_NUISANCE.cxx
index 6d54cb4..5501730 100644
--- a/app/nuwro_NUISANCE.cxx
+++ b/app/nuwro_NUISANCE.cxx
@@ -1,535 +1,535 @@
#ifdef __NUWRO_ENABLED__
#include "ComparisonRoutines.h"
#include "ParserUtils.h"
#include "TargetUtils.h"
// All possible inputs
std::string gOptEnergyDef;
std::vector gOptEnergyRange;
int gOptNumberEvents = -1;
int gOptNumberTestEvents = 5E6;
std::string gOptGeneratorList = "Default";
std::string gOptCrossSections =
"Default"; // If default this will look in
// $NUISANCE/data/nuwro/default_params.txt
int gOptSeed = time(NULL);
std::string gOptTargetDef = "";
std::string gOptFluxDef = "";
std::string gOptOutputFile = "";
int gOptRunNumber = -1;
void GetCommandLineArgs(int argc, char **argv);
void PrintSyntax(void);
std::string GetDynamicModes(std::string list) {
- QLOG(FIT, "Using " << list << " to define interaction modes.");
+ NUIS_LOG(FIT, "Using " << list << " to define interaction modes.");
std::map modes;
if (!list.compare("Default")) {
modes["dyn_qel_cc"] = 1; // Quasi elastic charged current
modes["dyn_qel_nc"] = 1; // Quasi elastic neutral current
modes["dyn_res_cc"] = 1; // Resonant charged current
modes["dyn_res_nc"] = 1; // Resonant neutral current
modes["dyn_dis_cc"] = 1; // Deep inelastic charged current
modes["dyn_dis_nc"] = 1; // Deep inelastic neutral current
modes["dyn_coh_cc"] = 1; // Coherent charged current
modes["dyn_coh_nc"] = 1; // Coherent neutral current
modes["dyn_mec_cc"] = 0; // Meson exchange charged current
modes["dyn_mec_nc"] = 0; // Meson exchange neutral current
} else if (!list.compare("DefaultFree")) {
modes["dyn_qel_cc"] = 1; // Quasi elastic charged current
modes["dyn_qel_nc"] = 1; // Quasi elastic neutral current
modes["dyn_res_cc"] = 1; // Resonant charged current
modes["dyn_res_nc"] = 1; // Resonant neutral current
modes["dyn_dis_cc"] = 1; // Deep inelastic charged current
modes["dyn_dis_nc"] = 1; // Deep inelastic neutral current
modes["dyn_coh_cc"] = 0; // Coherent charged current
modes["dyn_coh_nc"] = 0; // Coherent neutral current
modes["dyn_mec_cc"] = 0; // Meson exchange charged current
modes["dyn_mec_nc"] = 0; // Meson exchange neutral current
} else if (!list.compare("Default+MEC")) {
modes["dyn_qel_cc"] = 1; // Quasi elastic charged current
modes["dyn_qel_nc"] = 1; // Quasi elastic neutral current
modes["dyn_res_cc"] = 1; // Resonant charged current
modes["dyn_res_nc"] = 1; // Resonant neutral current
modes["dyn_dis_cc"] = 1; // Deep inelastic charged current
modes["dyn_dis_nc"] = 1; // Deep inelastic neutral current
modes["dyn_coh_cc"] = 1; // Coherent charged current
modes["dyn_coh_nc"] = 1; // Coherent neutral current
modes["dyn_mec_cc"] = 1; // Meson exchange charged current
modes["dyn_mec_nc"] = 1; // Meson exchange neutral current
} else {
- QTHROW("Event generator list " << list << " not found!");
+ NUIS_ABORT("Event generator list " << list << " not found!");
}
std::string modestring = "";
for (std::map::iterator iter = modes.begin();
iter != modes.end(); iter++) {
std::cout << " -> " << iter->first << " : " << iter->second << std::endl;
modestring += " -p \"" + iter->first + "=" +
GeneralUtils::IntToStr(iter->second) + "\"";
}
return modestring;
}
std::string GetFluxDefinition(std::string flux, std::string out) {
- QLOG(FIT, "Using " << flux << " to define NuWro beam.");
+ NUIS_LOG(FIT, "Using " << flux << " to define NuWro beam.");
// By default the flux is type 6 with a root file
std::vector fluxargs = GeneralUtils::ParseToStr(flux, ",");
if (fluxargs.size() < 2) {
- QTHROW("Expected flux in the format: file.root,hist_name1[pdg1],... : "
+ NUIS_ABORT("Expected flux in the format: file.root,hist_name1[pdg1],... : "
"reveived : "
<< flux);
}
// Build Map
std::map fluxmap;
fluxmap["beam_type"] = "6";
fluxmap["beam_inputroot"] = fluxargs[0];
fluxmap["beam_inputroot_nue"] = "";
fluxmap["beam_inputroot_nueb"] = "";
fluxmap["beam_inputroot_numu"] = "";
fluxmap["beam_inputroot_numub"] = "";
fluxmap["beam_inputroot_nutau"] = "";
fluxmap["beam_inputroot_nutaub"] = "";
// Split by beam bdgs
for (int i = 1; i < fluxargs.size(); i++) {
std::string histdef = fluxargs[i];
string::size_type open_bracket = histdef.find("[");
string::size_type close_bracket = histdef.find("]");
string::size_type ibeg = 0;
string::size_type iend = open_bracket;
string::size_type jbeg = open_bracket + 1;
string::size_type jend = close_bracket - 1;
std::string name = std::string(histdef.substr(ibeg, iend).c_str());
int pdg = atoi(histdef.substr(jbeg, jend).c_str());
if (pdg == 12)
fluxmap["beam_inputroot_nue"] = name;
else if (pdg == -12)
fluxmap["beam_inputroot_nueb"] = name;
else if (pdg == 14)
fluxmap["beam_inputroot_numu"] = name;
else if (pdg == -14)
fluxmap["beam_inputroot_numub"] = name;
else if (pdg == 16)
fluxmap["beam_inputroot_nutau"] = name;
else if (pdg == -16)
fluxmap["beam_inputroot_nutaub"] = name;
}
// Now create a new flux file matching the output file
std::cout << " -> Moving flux from '" + fluxmap["beam_inputroot"] +
"' to current directory to keep everything organised."
<< std::endl;
TFile *fluxread = new TFile(fluxmap["beam_inputroot"].c_str(), "READ");
TFile *fluxwrite = new TFile((out + ".flux.root").c_str(), "RECREATE");
for (std::map::iterator iter = fluxmap.begin();
iter != fluxmap.end(); iter++) {
TH1 *temp = (TH1 *)fluxread->Get(iter->second.c_str());
if (!temp)
continue;
TH1D *cuthist = (TH1D *)temp->Clone();
// Restrict energy range if required
if (gOptEnergyRange.size() == 2) {
for (int i = 0; i < cuthist->GetNbinsX(); i++) {
if (cuthist->GetXaxis()->GetBinCenter(i + 1) < gOptEnergyRange[0] or
cuthist->GetXaxis()->GetBinCenter(i + 1) > gOptEnergyRange[1]) {
cuthist->SetBinContent(i + 1, 0.0);
}
}
}
// Check Flux
if (cuthist->Integral() <= 0.0) {
- QTHROW("Flux histogram " << iter->second << " has integral <= 0.0");
+ NUIS_ABORT("Flux histogram " << iter->second << " has integral <= 0.0");
}
// Save
fluxwrite->cd();
cuthist->Write();
}
std::cout << " ->-> Saved to : " << (out + ".flux.root") << std::endl;
fluxmap["beam_inputroot"] = (out + ".flux.root");
fluxwrite->Close();
// Return a parameters string
std::string fluxstring = "";
for (std::map::iterator iter = fluxmap.begin();
iter != fluxmap.end(); iter++) {
std::cout << " -> " << iter->first << " : " << iter->second << std::endl;
fluxstring += " -p \"" + iter->first + "=" + iter->second + "\"";
}
return fluxstring;
}
std::string GetTargetDefinition(std::string target) {
- QLOG(FIT, "Defining NuWro Target from : " << target);
+ NUIS_LOG(FIT, "Defining NuWro Target from : " << target);
// Target is given as either a single PDG, or a combo with the total number of
// nucleons
std::vector trgts = GeneralUtils::ParseToStr(target, ",");
std::string targetstring = "";
// Single Target
if (trgts.size() == 1) {
int PDG = GeneralUtils::StrToInt(trgts[0]);
int Z = TargetUtils::GetTargetZFromPDG(PDG);
int N = TargetUtils::GetTargetAFromPDG(PDG) - Z;
int TOTAL = 1;
targetstring += (" -p \"target_content=" + GeneralUtils::IntToStr(Z) + " " +
GeneralUtils::IntToStr(N) + " " +
GeneralUtils::IntToStr(TOTAL) + "x" + "\"");
// Combined target
} else if (trgts.size() > 1) {
int NUCLEONS = GeneralUtils::StrToInt(trgts[0]);
// Loop over all targets
for (size_t i = 1; i < trgts.size(); i++) {
// Extra PDG and W
std::string tgtdef = trgts[i];
string::size_type open_bracket = tgtdef.find("[");
string::size_type close_bracket = tgtdef.find("]");
string::size_type ibeg = 0;
string::size_type iend = open_bracket;
string::size_type jbeg = open_bracket + 1;
string::size_type jend = close_bracket - 1;
int PDG = atoi(tgtdef.substr(ibeg, iend).c_str());
double W = atof(tgtdef.substr(jbeg, jend).c_str());
// extract Z N
int Z = TargetUtils::GetTargetZFromPDG(PDG);
int A = TargetUtils::GetTargetAFromPDG(PDG);
int N = TargetUtils::GetTargetAFromPDG(PDG) - Z;
std::cout << "Target " << PDG << " Z" << Z << " N" << N << std::endl;
// extract weight
int TOTAL = round(double(NUCLEONS) * W / A);
if (i == 1) {
targetstring += (" -p \"target_content=" + GeneralUtils::IntToStr(Z) +
" " + GeneralUtils::IntToStr(N) + " " +
GeneralUtils::IntToStr(TOTAL) + "x" + "\"");
} else {
targetstring += (" -p \"target_content+=" + GeneralUtils::IntToStr(Z) +
" " + GeneralUtils::IntToStr(N) + " " +
GeneralUtils::IntToStr(TOTAL) + "x" + "\"");
}
}
// No target given!
} else {
- QTHROW("No target given : " << target);
+ NUIS_ABORT("No target given : " << target);
}
std::cout << " -> " << targetstring << std::endl;
return targetstring;
}
std::string GetEventAndSeedDefinition(int nevents, int ntestevents, int seed) {
std::string eventdef = "";
eventdef +=
" -p \"number_of_events=" + GeneralUtils::IntToStr(nevents) + "\"";
eventdef +=
" -p \"number_of_test_events=" + GeneralUtils::IntToStr(ntestevents) +
"\"";
eventdef += " -p \"random_seed=" + GeneralUtils::IntToStr(seed) + "\"";
- QLOG(FIT, "Event Definition: ");
- QLOG(FIT, " -> number_of_events : " << nevents);
- QLOG(FIT, " -> number_of_test_events : " << ntestevents);
- QLOG(FIT, " -> seed : " << seed);
+ NUIS_LOG(FIT, "Event Definition: ");
+ NUIS_LOG(FIT, " -> number_of_events : " << nevents);
+ NUIS_LOG(FIT, " -> number_of_test_events : " << ntestevents);
+ NUIS_LOG(FIT, " -> seed : " << seed);
return eventdef;
}
//____________________________________________________________________________
int main(int argc, char **argv) {
- QLOG(FIT, "==== RUNNING nuwro_nuisance Event Generator =====");
+ NUIS_LOG(FIT, "==== RUNNING nuwro_nuisance Event Generator =====");
GetCommandLineArgs(argc, argv);
// Calculate the dynamic modes definition
std::string dynparamsdef = GetDynamicModes(gOptGeneratorList);
// Get Flux and Target definition
std::string fluxparamsdef = GetFluxDefinition(gOptFluxDef, gOptOutputFile);
std::string targetparamsdef = GetTargetDefinition(gOptTargetDef);
// Get Run Definition
std::string eventparamsdef = GetEventAndSeedDefinition(
gOptNumberEvents, gOptNumberTestEvents, gOptSeed);
// Run NuWro Externally!
- QLOG(FIT, "==== Actually running nuwro! ===");
+ NUIS_LOG(FIT, "==== Actually running nuwro! ===");
std::string nuwrocommand = "nuwro";
nuwrocommand += " -i " + gOptCrossSections;
nuwrocommand += " -o " + gOptOutputFile;
nuwrocommand += " " + fluxparamsdef;
nuwrocommand += " " + dynparamsdef;
nuwrocommand += " " + eventparamsdef;
nuwrocommand += " " + targetparamsdef;
std::cout << nuwrocommand << std::endl;
sleep(10);
system((nuwrocommand).c_str());
return 0;
}
//____________________________________________________________________________
void GetCommandLineArgs(int argc, char **argv) {
// Check for -h flag.
for (int i = 0; i < argc; i++) {
if (!std::string(argv[i]).compare("-h"))
PrintSyntax();
}
// Format is nuwro -r run_number -n n events
std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv);
ParserUtils::ParseArgument(args, "-n", gOptNumberEvents, false);
if (gOptNumberEvents == -1) {
- QTHROW("No event count passed to nuwro_NUISANCE!");
+ NUIS_ABORT("No event count passed to nuwro_NUISANCE!");
}
// Flux/Energy Specs
ParserUtils::ParseArgument(args, "-e", gOptEnergyDef, false);
gOptEnergyRange = GeneralUtils::ParseToDbl(gOptEnergyDef, ",");
ParserUtils::ParseArgument(args, "-f", gOptFluxDef, false);
if (gOptFluxDef.empty() and gOptEnergyRange.size() < 1) {
- QTHROW("No flux or energy range given to nuwro_nuisance!");
+ NUIS_ABORT("No flux or energy range given to nuwro_nuisance!");
} else if (gOptFluxDef.empty() and gOptEnergyRange.size() == 1) {
// Fixed energy, make sure -p is given
- QTHROW("nuwro_NUISANCE cannot yet do fixed energy!");
+ NUIS_ABORT("nuwro_NUISANCE cannot yet do fixed energy!");
} else if (gOptFluxDef.empty() and gOptEnergyRange.size() == 2) {
// Uniform energy range
- QTHROW("nuwro_NUISANCE cannot yet do a uniform energy range!");
+ NUIS_ABORT("nuwro_NUISANCE cannot yet do a uniform energy range!");
} else if (!gOptFluxDef.empty()) {
// Try to convert the flux definition if possible.
std::string convflux = BeamUtils::ConvertFluxIDs(gOptFluxDef);
if (!convflux.empty())
gOptFluxDef = convflux;
} else {
- QTHROW("Unknown flux energy range combination!");
+ NUIS_ABORT("Unknown flux energy range combination!");
}
ParserUtils::ParseArgument(args, "-t", gOptTargetDef, false);
if (gOptTargetDef.empty()) {
- QTHROW("No Target passed to nuwro_nuisance! use the '-t' argument.");
+ NUIS_ABORT("No Target passed to nuwro_nuisance! use the '-t' argument.");
} else {
std::string convtarget = TargetUtils::ConvertTargetIDs(gOptTargetDef);
if (!convtarget.empty())
gOptTargetDef = convtarget;
}
ParserUtils::ParseArgument(args, "-r", gOptRunNumber, false);
ParserUtils::ParseArgument(args, "-o", gOptOutputFile, false);
if (gOptOutputFile.empty()) {
if (gOptRunNumber == -1)
gOptRunNumber = 1;
- QLOG(FIT, "No output file given! Saving file to : nuwrogen."
+ NUIS_LOG(FIT, "No output file given! Saving file to : nuwrogen."
<< gOptRunNumber << ".event.root");
gOptOutputFile =
"nuwrogen." + GeneralUtils::IntToStr(gOptRunNumber) + ".event.root";
} else {
// if no run number given leave as is, else add run number.
if (gOptRunNumber != -1) {
gOptOutputFile += "." + GeneralUtils::IntToStr(gOptRunNumber) + ".root";
} else {
gOptRunNumber = 0;
}
}
ParserUtils::ParseArgument(args, "--cross-section", gOptCrossSections, false);
if (!gOptCrossSections.compare("Default")) {
- QLOG(FIT, "No Parameters File passed. Using default NuWro one.");
+ NUIS_LOG(FIT, "No Parameters File passed. Using default NuWro one.");
char *const var = getenv("NUISANCE");
if (!var) {
std::cout << "Cannot find top level directory! Set the NUISANCE "
"environmental variable"
<< std::endl;
exit(-1);
}
std::string topnuisancedir = string(var);
gOptCrossSections = topnuisancedir + "/nuwro/Default_params.txt";
}
ParserUtils::ParseArgument(args, "--event-generator-list", gOptGeneratorList,
false);
ParserUtils::ParseArgument(args, "--seed", gOptSeed, false);
ParserUtils::ParseArgument(args, "--test-events", gOptNumberTestEvents,
false);
// Final Check and output
if (args.size() > 0) {
PrintSyntax();
ParserUtils::CheckBadArguments(args);
}
- QLOG(FIT, "Generating NuWro Events with the following properties:"
+ NUIS_LOG(FIT, "Generating NuWro Events with the following properties:"
<< std::endl
<< " -> Energy : " << gOptEnergyDef << " ("
<< gOptEnergyRange.size() << ")" << std::endl
<< " -> NEvents : " << gOptNumberEvents << std::endl
<< " -> NTestEvents : " << gOptNumberTestEvents << std::endl
<< " -> Generators : " << gOptGeneratorList << std::endl
<< " -> XSecPars : " << gOptCrossSections << std::endl
<< " -> Seed : " << gOptSeed << std::endl
<< " -> Target : " << gOptTargetDef << std::endl
<< " -> Flux : " << gOptFluxDef << std::endl
<< " -> Output : " << gOptOutputFile << std::endl
<< " -> Run : " << gOptRunNumber);
return;
}
//____________________________________________________________________________
void PrintSyntax(void) {
- QLOG(FIT, "\n\n"
+ NUIS_LOG(FIT, "\n\n"
<< "Syntax:"
<< "\n"
<< "\n nuwro_nuisance [-h]"
<< "\n -n nev"
<< "\n -f flux_description"
<< "\n -t target_description"
<< "\n [ -r run_number ]"
<< "\n [ -o output_file ]"
<< "\n [ --cross-section /path/to/params.txt ]"
<< "\n [ --event-generator-list mode_definition ]"
<< "\n [ --seed seed_value ]"
<< "\n [ --test-events ntest ]"
<< "\n \n");
- QLOG(
+ NUIS_LOG(
FIT,
"\n\n Arguments:"
<< "\n"
<< "\n -n nev"
<< "\n -> Total number of events to generate (e.g. 2500000)"
<< "\n"
<< "\n -f flux_description"
<< "\n Definition of the flux to be read in from a ROOT file."
<< "\n"
<< "\n Multiple histograms can be read in from the same file using"
<< "\n the format '-f file.root,hist1[pdg1],hist2[pdg2]"
<< "\n e.g. \'-f "
"./flux/myfluxfile.root,numu_flux[14],numubar_flux[-14]\'"
<< "\n"
<< "\n When passing in multiple histograms, the nuwro_nuisance "
"will"
<< "\n generate a single file containing both sets of events with "
"the"
<< "\n correct ratios for each set."
<< "\n"
<< "\n A flux can also be given according to any of the flux IDs "
"shown"
<< "\n at the end of this help message."
<< "\n e.g. \' -f MINERvA_fhc_numu\' "
<< "\n"
<< "\n -t target_description"
<< "\n Definition of the target to be used. Multiple targets can "
"be "
"given."
<< "\n"
<< "\n To pass a single target just provide the target PDG"
<< "\n e.g. \' -t 1000060120 \'"
<< "\n"
<< "\n To pass a combined target provide a list containing the "
"following"
<< "\n \' -t TotalNucleons,Target1[Weight1],Target2[Weight2],.. "
"where "
"the "
<< "\n TotalNucleons is the total nucleons combined, Target1 is "
"the "
"PDG "
<< "\n of the first target, and Weight1 is the fractional weight "
"of "
"the "
<< "\n first target."
<< "\n e.g. \' -t 13,1000060120[0.9231],1000010010[0.0769] \'"
<< "\n"
<< "\n Target can also be specified by the target IDs given at "
"the "
"end of"
<< "\n this help message."
<< "\n e.g. \' -t CH2 \'"
<< "\n"
<< "\n -r run_number"
<< "\n run number ID that can be used when generating large "
"samples "
"in small "
<< "\n jobs. Must be an integer. When given nuwro_nuisance will "
"update the "
<< "\n output file from 'output.root' to "
"'output.root.run_number.root'"
<< "\n"
<< "\n -o output_file"
<< "\n Path to the output_file you want to save events to."
<< "\n"
<< "\n If this is not given but '-r' is then events will be saved "
"to "
<< "\n the file 'nuwrogen.run_number.events.root'"
<< "\n"
<< "\n If a run number is given alongside '-o' then events will "
"be "
"saved "
<< "\n to 'output.root.run_number.root'"
<< "\n"
<< "\n --cross-section /path/to/params.txt"
<< "\n Path to the nuwro model definition. If this is not given, "
"then "
"this "
<< "\n will default to $NUISANCE/data/nuwro/Default_params.txt"
<< "\n"
<< "\n Look in $NUISANCE/data/nuwro/Default_params.txt for "
"examples "
"when "
<< "\n writing your own card files."
<< "\n"
<< "\n --event-generator-list mode_definition"
<< "\n Name of modes to run. This sets the dynamic mode settings "
"in "
"nuwro."
<< "\n e.g. --event-generator-list Default+MEC"
<< "\n"
<< "\n Allowed mode_definitions are given at the end of this help "
"message."
<< "\n"
<< "\n --seed seed_value "
<< "\n Value to use as the seed. If seed isn't given, time(NULL) "
"is "
"used."
<< "\n"
<< "\n --test-events ntest "
<< "\n Sets the number of test events for Nuwro to use. If this "
"option "
<< "\n isn't given then we assume 5E6 test events by default."
<< "\n\n");
std::cout << "-----------------" << std::endl;
TargetUtils::ListTargetIDs();
std::cout << "-----------------" << std::endl;
BeamUtils::ListFluxIDs();
std::cout << "-----------------" << std::endl;
- QLOG(FIT, "Allowed Mode Definitions:"
+ NUIS_LOG(FIT, "Allowed Mode Definitions:"
<< std::endl
<< " - Default : Default CC+NC modes, no MEC" << std::endl
<< " - Default+MEC : Default CC+NC modes + 2p2h MEC "
<< std::endl
<< " - DefaultFree : Default CC+NC modes, no Coherent or MEC "
<< std::endl
<< "----------------");
exit(0);
}
//____________________________________________________________________________
#endif
diff --git a/cmake/pythia6Setup.cmake b/cmake/pythia6Setup.cmake
index 1a89b0c..3a496e6 100644
--- a/cmake/pythia6Setup.cmake
+++ b/cmake/pythia6Setup.cmake
@@ -1,29 +1,36 @@
# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
################################################################################
# This file is part of NUISANCE.
#
# NUISANCE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NUISANCE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NUISANCE. If not, see .
################################################################################
if(NEED_PYTHIA6)
+
+ if(DEFINED ENV{PYTHIA6_LIBRARY} AND PYTHIA6 STREQUAL "")
+ SET(PYTHIA6 $ENV{PYTHIA6_LIBRARY} CACHE PATH
+ "Path to directory containing libPythia6.so. Overrides environment variable \$PYTHIA6 <>"
+ FORCE)
+ endif()
+
if(PYTHIA6 STREQUAL "")
cmessage(FATAL_ERROR "Variable PYTHIA6 is not defined. This must be set to point to a prebuilt PYTHIA6 instance, please set the \$PYTHIA6 environment variable or configure with -DPYTHIA6=/path/to/pythia6.")
endif()
LIST(APPEND EXTRA_LINK_DIRS ${PYTHIA6})
LIST(APPEND EXTRA_LIBS Pythia6 gfortran)
endif()
diff --git a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx
index e81e3fa..070d4dc 100644
--- a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx
+++ b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx
@@ -1,142 +1,142 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
/**
* Radecky et al. Phys Rev D, 3rd series, volume 25, number 5, 1 March 1982, p
* 1161-1173
*/
#include "ANL_CC1npip_XSec_1DEnu_nu.h"
//********************************************************************
ANL_CC1npip_XSec_1DEnu_nu::ANL_CC1npip_XSec_1DEnu_nu(nuiskey samplekey) {
//********************************************************************
// Sample overview ---------------------------------------------------
std::string descrip = "ANL CC1npip Event Rate 1DQ2 nu sample. \n"
"Target: D2 \n"
"Flux: \n"
"Signal: \n";
// Setup common settings
fSettings = LoadSampleSettings(samplekey);
fSettings.SetDescription(descrip);
fSettings.SetXTitle("E_{#nu} (GeV)");
fSettings.SetYTitle("#sigma (cm^{2}/nucleon)");
fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG");
fSettings.SetEnuRange(0.0, 1.5);
fSettings.SetS("norm_error", "0.20");
fSettings.DefineAllowedTargets("D,H");
// plot information
fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}");
fSettings.DefineAllowedSpecies("numu");
// User can specifiy to use uncorrected data
UseCorrectedData = !fSettings.Found("name", "Uncorr");
// User can specify "W14" for W < 1.4 GeV cut
// "W16" for W < 1.6 GeV cut
// The default is W < 2.0
if (fSettings.Found("name", "W14Cut"))
wTrueCut = 1.4;
else if (fSettings.Found("name", "W16Cut"))
wTrueCut = 1.6;
else
wTrueCut = 10.0;
// Flag for bad combo
if (UseCorrectedData && wTrueCut == 1.6) {
- QERROR(WRN, "Can not run ANL CC1pi+1n W < 1.6 GeV with CORRECTION, because "
+ NUIS_ERR(WRN, "Can not run ANL CC1pi+1n W < 1.6 GeV with CORRECTION, because "
"the data DOES NOT EXIST");
- QERROR(WRN, "Correction exists for W < 1.4 GeV and no W cut data ONLY");
- QERROR(WRN, "Reverting to using uncorrected data!");
+ NUIS_ERR(WRN, "Correction exists for W < 1.4 GeV and no W cut data ONLY");
+ NUIS_ERR(WRN, "Reverting to using uncorrected data!");
UseCorrectedData = false;
}
// Now read in different data depending on what the user has specified
std::string DataLocation =
GeneralUtils::GetTopLevelDir() + "/data/ANL/CC1pip_on_n/";
// If we're using corrected data
if (UseCorrectedData) {
if (wTrueCut == 1.4) {
DataLocation += "anl82corr-numu-n-to-mu-n-piplus-lowW_edges.txt";
// No W cut
} else {
DataLocation += "anl82corr-numu-n-to-mu-n-piplus-noW_edges.txt";
}
// If we're using raw uncorrected data
} else {
if (wTrueCut == 1.4) {
DataLocation += "anl82-numu-cc1npip-14Wcut.txt";
} else if (wTrueCut == 1.6) {
DataLocation += "anl82-numu-cc1npip-16Wcut.txt";
} else if (wTrueCut == 10.0) {
DataLocation += "anl82-numu-cc1npip-noWcut.txt";
}
}
fSettings.SetDataInput(DataLocation);
FinaliseSampleSettings();
// Scaling Setup ---------------------------------------------------
// ScaleFactor automatically setup for DiffXSec/cm2/Nucleon
fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 * 2.0 / 1.0 /
(fNEvents + 0.));
// Plot Setup -------------------------------------------------------
SetDataFromTextFile(fSettings.GetDataInput());
SetCovarFromDiagonal();
// Final setup ---------------------------------------------------
FinaliseMeasurement();
};
void ANL_CC1npip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 ||
event->NumFSParticle(13) == 0) {
return;
}
TLorentzVector Pnu = event->GetNeutrinoIn()->fP;
TLorentzVector Pn = event->GetHMFSParticle(2112)->fP;
TLorentzVector Ppip = event->GetHMFSParticle(211)->fP;
TLorentzVector Pmu = event->GetHMFSParticle(13)->fP;
double hadMass = FitUtils::MpPi(Pn, Ppip);
double Enu = -1.0;
// ANL has a W cuts at 1.4, 1.6 and no w cut
// This is set by user, or defaults to 2.0
if (hadMass < wTrueCut * 1000.) {
Enu = Pnu.E() / 1.E3;
}
fXVar = Enu;
return;
};
bool ANL_CC1npip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax);
}
diff --git a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx
index 19ef7a7..fe39e89 100644
--- a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx
+++ b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx
@@ -1,137 +1,137 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
/**
* Radecky et al. Phys Rev D, 3rd series, volume 25, number 5, 1 March 1982, p 1161-1173
*/
#include "ANL_CC1pi0_XSec_1DEnu_nu.h"
//********************************************************************
ANL_CC1pi0_XSec_1DEnu_nu::ANL_CC1pi0_XSec_1DEnu_nu(nuiskey samplekey) {
//********************************************************************
// Sample overview ---------------------------------------------------
std::string descrip = "ANL CC1pi0 Event Rate 1DQ2 nu sample. \n" \
"Target: D2 \n" \
"Flux: \n" \
"Signal: \n";
// Setup common settings
fSettings = LoadSampleSettings(samplekey);
fSettings.SetDescription(descrip);
fSettings.SetXTitle("E_{#nu} (GeV)");
fSettings.SetYTitle("#sigma (cm^{2}/neutron)");
fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG");
fSettings.SetEnuRange(0.0, 1.5);
fSettings.SetS("norm_error", "0.20");
fSettings.DefineAllowedTargets("D,H");
// plot information
fSettings.SetTitle("ANL #nu_mu CC1#pi^{0}");
fSettings.DefineAllowedSpecies("numu");
// User can specifiy to use uncorrected data
UseCorrectedData = !fSettings.Found("name", "Uncorr");
// User can specify "W14" for W < 1.4 GeV cut
// "W16" for W < 1.6 GeV cut
// The default is W < 2.0
if (fSettings.Found("name", "W14Cut")) wTrueCut = 1.4;
else if (fSettings.Found("name", "W16Cut")) wTrueCut = 1.6;
else wTrueCut = 10.0;
// Flag for bad combo
if (UseCorrectedData && wTrueCut == 1.6) {
- QERROR(WRN, "Can not run ANL CC1pi0 W < 1.6 GeV with CORRECTION, because "
+ NUIS_ERR(WRN, "Can not run ANL CC1pi0 W < 1.6 GeV with CORRECTION, because "
"the data DOES NOT EXIST");
- QERROR(WRN, "Correction exists for W < 1.4 GeV and no W cut data ONLY");
- QERROR(WRN, "Reverting to using uncorrected data!");
+ NUIS_ERR(WRN, "Correction exists for W < 1.4 GeV and no W cut data ONLY");
+ NUIS_ERR(WRN, "Reverting to using uncorrected data!");
UseCorrectedData = false;
}
// Now read in different data depending on what the user has specified
std::string DataLocation = GeneralUtils::GetTopLevelDir() + "/data/ANL/CC1pi0_on_n/";
// If we're using corrected data
if (UseCorrectedData) {
if (wTrueCut == 1.4) {
DataLocation += "anl82corr-numu-n-to-mu-p-pi0-lowW_edges.txt";
} else if (wTrueCut == 10.0) {
DataLocation += "anl82corr-numu-n-to-mu-p-pi0-noW_edges.txt";
}
// If we're using raw uncorrected data
} else {
if (wTrueCut == 1.4) {
DataLocation += "anl82-numu-cc1pi0-14Wcut.txt";
} else if (wTrueCut == 1.6) {
DataLocation += "anl82-numu-cc1pi0-16Wcut.txt";
} else if (wTrueCut == 10.0) {
DataLocation += "anl82-numu-cc1pi0-noWcut.txt";
}
}
fSettings.SetDataInput(DataLocation);
FinaliseSampleSettings();
// Scaling Setup ---------------------------------------------------
// ScaleFactor automatically setup for DiffXSec/cm2/Nucleon
fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 * 2.0 / 1.0 / (fNEvents + 0.));
// Plot Setup -------------------------------------------------------
SetDataFromTextFile( fSettings.GetDataInput() );
SetCovarFromDiagonal();
// Final setup ---------------------------------------------------
FinaliseMeasurement();
};
void ANL_CC1pi0_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) {
return;
}
TLorentzVector Pnu = event->GetNeutrinoIn()->fP;
TLorentzVector Pp = event->GetHMFSParticle(2212)->fP;
TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP;
TLorentzVector Pmu = event->GetHMFSParticle(13)->fP;
double hadMass = FitUtils::MpPi(Pp, Ppi0);
double Enu = -1.0;
if (hadMass/1000. < wTrueCut) {
Enu = Pnu.E()/1.E3;
}
fXVar = Enu;
return;
};
bool ANL_CC1pi0_XSec_1DEnu_nu::isSignal(FitEvent *event) {
return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax);
}
diff --git a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx
index cb15beb..fa5af57 100644
--- a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx
+++ b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx
@@ -1,139 +1,139 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
/**
* Radecky et al. Phys Rev D, 3rd series, volume 25, number 5, 1 March 1982, p 1161-1173
*/
#include "ANL_CC1ppip_XSec_1DEnu_nu.h"
//********************************************************************
ANL_CC1ppip_XSec_1DEnu_nu::ANL_CC1ppip_XSec_1DEnu_nu(nuiskey samplekey) {
//********************************************************************
// Sample overview ---------------------------------------------------
std::string descrip = "ANL CC1pip XSec Enu nu sample. \n" \
"Target: D2 \n" \
"Flux: \n" \
"Signal: \n";
// Setup common settings
fSettings = LoadSampleSettings(samplekey);
fSettings.SetDescription(descrip);
fSettings.SetXTitle("E_{#nu} (GeV)");
fSettings.SetYTitle("#sigma (cm^{2}/nucleon)");
fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG");
fSettings.SetEnuRange(0.0, 6.0);
fSettings.SetS("norm_error", "0.20");
fSettings.DefineAllowedTargets("D,H");
// plot information
fSettings.SetTitle("ANL #nu_mu CC1#pi^{0}");
fSettings.DefineAllowedSpecies("numu");
// User can specifiy to use uncorrected data
UseCorrectedData = !fSettings.Found("name", "Uncorr");
// User can specify "W14" for W < 1.4 GeV cut
// "W16" for W < 1.6 GeV cut
// The default is no W cut
if (fSettings.Found("name", "W14Cut")) wTrueCut = 1.4;
else if (fSettings.Found("name", "W16Cut")) wTrueCut = 1.6;
else wTrueCut = 10.0;
// Flag for bad combo
if (UseCorrectedData && wTrueCut == 1.6) {
- QERROR(WRN, "Can not run ANL CC1pi+1p W < 1.6 GeV with CORRECTION, because "
+ NUIS_ERR(WRN, "Can not run ANL CC1pi+1p W < 1.6 GeV with CORRECTION, because "
"the data DOES NOT EXIST");
- QERROR(WRN, "Correction exists for W < 1.4 GeV and no W cut data ONLY");
- QERROR(WRN, "Reverting to using uncorrected data!");
+ NUIS_ERR(WRN, "Correction exists for W < 1.4 GeV and no W cut data ONLY");
+ NUIS_ERR(WRN, "Reverting to using uncorrected data!");
UseCorrectedData = false;
}
// Now read in different data depending on what the user has specified
std::string DataLocation = GeneralUtils::GetTopLevelDir() + "/data/ANL/CC1pip_on_p/";
// If we're using corrected data
if (UseCorrectedData) {
if (wTrueCut == 1.4) {
DataLocation += "anl82corr-numu-p-to-mu-p-piplus-lowW_edges.txt";
} else if (wTrueCut == 10.0) {
DataLocation += "anl82corr-numu-p-to-mu-p-piplus-noW_edges.txt";
}
// If we're using raw uncorrected data
} else {
if (wTrueCut == 1.4) {
DataLocation += "anl82-numu-cc1ppip-14Wcut.txt";
} else if (wTrueCut == 1.6) {
DataLocation += "anl82-numu-cc1ppip-16Wcut.txt";
} else if (wTrueCut == 10.0) {
DataLocation += "anl82-numu-cc1ppip-noWcut.txt";
}
}
fSettings.SetDataInput(DataLocation);
FinaliseSampleSettings();
// Scaling Setup ---------------------------------------------------
// ScaleFactor automatically setup for DiffXSec/cm2/Nucleon
fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 * 2.0 / 1.0 / (fNEvents + 0.));
// Plot Setup -------------------------------------------------------
SetDataFromTextFile( fSettings.GetDataInput() );
SetCovarFromDiagonal();
// Final setup ---------------------------------------------------
FinaliseMeasurement();
};
void ANL_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) {
return;
}
TLorentzVector Pnu = event->GetNeutrinoIn()->fP;
TLorentzVector Pp = event->GetHMFSParticle(2212)->fP;
TLorentzVector Ppip = event->GetHMFSParticle(211)->fP;
TLorentzVector Pmu = event->GetHMFSParticle(13)->fP;
double hadMass = FitUtils::MpPi(Pp, Ppip);
double Enu = -1.0;
// ANL has a W cuts at 1.4, 1.6 and no w cut
// This is set by user, or defaults to 2.0
if (hadMass/1000. < wTrueCut) {
Enu = Pnu.E()/1.E3;
}
fXVar = Enu;
return;
}
bool ANL_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax);
}
diff --git a/src/Config/NuisConfig.cxx b/src/Config/NuisConfig.cxx
index ba6db79..c1d3915 100644
--- a/src/Config/NuisConfig.cxx
+++ b/src/Config/NuisConfig.cxx
@@ -1,817 +1,817 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#include "NuisConfig.h"
#include "FitLogger.h"
#include "GeneralUtils.h"
#include "TXMLEngine.h"
namespace Config {
nuisconfig &Get() { return nuisconfig::GetConfig(); };
std::string GetPar(std::string const &name) { return Get().GetConfig(name); }
bool HasPar(std::string const &name) { return Get().HasConfig(name); }
std::string GetParS(std::string const &name) { return Get().GetConfigS(name); }
int GetParI(std::string const &name) { return Get().GetConfigI(name); }
bool GetParB(std::string const &name) { return Get().GetConfigB(name); }
float GetParF(std::string const &name) { return Get().GetConfigF(name); }
double GetParD(std::string const &name) { return Get().GetConfigD(name); }
void SetPar(std::string const &name, std::string const &val) {
Get().SetConfig(name, val);
}
void SetPar(std::string const &name, char const *val) {
Get().SetConfig(name, val);
}
void SetPar(std::string const &name, bool val) { Get().SetConfig(name, val); }
void SetPar(std::string const &name, int val) { Get().SetConfig(name, val); }
void SetPar(std::string const &name, float val) { Get().SetConfig(name, val); }
void SetPar(std::string const &name, double val) { Get().SetConfig(name, val); }
}
namespace FitPar {
std::string GetDataBase() { return GeneralUtils::GetTopLevelDir() + "/data/"; };
nuisconfig &Config() { return Config::Get(); };
}
nuisconfig *nuisconfig::m_nuisconfigInstance = NULL;
nuisconfig &nuisconfig::GetConfig(void) {
if (!m_nuisconfigInstance) m_nuisconfigInstance = new nuisconfig;
return *m_nuisconfigInstance;
};
// Main Class Definition
nuisconfig::nuisconfig() {
// Load default Parameters
std::string filename =
(GeneralUtils::GetTopLevelDir() + "/parameters/config.xml");
std::cout << "[ NUISANCE ]: Loading DEFAULT settings from : " << filename;
// Create XML Engine
fXML = new TXMLEngine;
fXML->SetSkipComments(true);
// Load in documents
fXMLDocs.push_back(fXML->ParseFile(filename.c_str(), 1000000));
if (!fXMLDocs[0]) {
- QTHROW("Cannot Read Parameters File!");
+ NUIS_ABORT("Cannot Read Parameters File!");
}
// Setup Main XML Node to be the first file read
fMainNode = fXML->DocGetRootElement(fXMLDocs[0]);
// Print result
std::cout << " -> DONE." << std::endl;
}
nuisconfig::~nuisconfig() {
// Should really delete XML objects here but we don't
}
void nuisconfig::LoadSettings(std::string const &filename,
std::string const &state) {
// Open file and see if its XML
std::cout << "[ NUISANCE ]: Trying to parse file : " << filename;
StopTalking();
XMLDocPointer_t readdoc = fXML->ParseFile(filename.c_str(), 1000000);
StartTalking();
// If it is parse it as a nice XML config file
if (readdoc) {
std::cout << " -> Found XML file." << std::endl;
LoadXMLSettings(filename, state);
// Otherwise its an old simple card file
} else {
std::cout << " -> Assuming its a simple card file." << std::endl;
LoadCardSettings(filename, state);
}
}
void nuisconfig::LoadXMLSettings(std::string const &filename,
std::string const &state) {
std::cout << "[ NUISANCE ]: Loading XML settings from : " << filename
<< std::endl;
// Add new file to xml docs list
fXMLDocs.push_back(fXML->ParseFile(filename.c_str(), 1000000));
if (!fXMLDocs.back()) {
- QTHROW("Failed to read: " << filename);
+ NUIS_ABORT("Failed to read: " << filename);
}
// Loop over children and add
XMLNodePointer_t child =
fXML->GetChild(fXML->DocGetRootElement(fXMLDocs.back()));
// // Here we manually load all the children from the card file into our root
// node
if (!child) {
- QTHROW("CANNOT Find child inside settings file!");
+ NUIS_ABORT("CANNOT Find child inside settings file!");
}
while (child) {
// SPECIAL CONFIG CASE
// If its a config node, then remove previous attributes, overriding old
// value
if (!std::string(fXML->GetNodeName(child)).compare("config")) {
// Loop over attribues
XMLAttrPointer_t attr1 = fXML->GetFirstAttr(child);
while (attr1) {
// If a valid attribute name is given then compare
if (!GetConfigS(fXML->GetAttrName(attr1)).empty()) {
// Get full list of present configs
std::vector confignodes = GetNodes("config");
// Loop over present configs and compare
for (size_t i = 0; i < confignodes.size(); i++) {
// If we already have this config, free the old attribute
if (fXML->HasAttr(confignodes[i], fXML->GetAttrName(attr1))) {
fXML->FreeAttr(confignodes[i], fXML->GetAttrName(attr1));
break;
}
}
}
// Move onto next config attribute
attr1 = fXML->GetNextAttr(attr1);
}
}
TString nodeStr;
fXML->SaveSingleNode(child, &nodeStr);
XMLNodePointer_t copyNode = fXML->ReadSingleNode(nodeStr.Data());
// std::cout << "copying node..." << std::endl;
// PrintXML(copyNode);
// Add this child to the main config list
fXML->AddChild(fMainNode, copyNode);
// std::cout << "Done, was it added?" << std::endl;
// PrintXML(fMainNode);
// Get Next Child
child = fXML->GetNext(child);
}
std::cout << " -> DONE." << std::endl;
}
void nuisconfig::LoadCardSettings(std::string const &filename,
std::string const &state) {
std::cout << "[ NUISANCE ]: Loading simple config from : " << filename;
// Build XML Config from the card file by parsing each line
std::vector cardlines =
GeneralUtils::ParseFileToStr(filename, "\n");
int linecount = 0;
// Loop over all input lines
for (std::vector::iterator iter = cardlines.begin();
iter != cardlines.end(); iter++) {
std::string line = (*iter);
linecount++;
// Skip Comments
if (line.empty()) continue;
if (line.c_str()[0] == '#') continue;
// Parse whitespace
std::vector strvct = GeneralUtils::ParseToStr(line, " ");
if (strvct.empty()) continue;
// Get Identifier
std::string id = strvct[0];
// Build backwards compatible xml configs
// Sample structure
if (!id.compare("sample")) {
CreateSampleNodeFromLine(line);
}
// Any parameter structure
if (id.find("_parameter") != std::string::npos) {
CreateParameterNodeFromLine(line);
}
// Any covar structure
if (!id.compare("covar") || !id.compare("pull") || !id.compare("throw")) {
CreatePullNodeFromLine(line);
}
// Any config structure
if (!id.compare("config")) {
CreateOldConfigNodeFromLine(line);
}
}
std::cout << " -> DONE." << std::endl;
}
XMLNodePointer_t nuisconfig::CreateSampleNodeFromLine(std::string const &line) {
// Create new node entry
XMLNodePointer_t samplenode = CreateNode("sample");
// Parse line
std::vector strvct = GeneralUtils::ParseToStr(line, " ");
// Add line elements to the node
// name input type norm
if (strvct.size() > 1) Set(samplenode, "name", strvct[1]);
if (strvct.size() > 2) Set(samplenode, "input", strvct[2]);
if (strvct.size() > 3) Set(samplenode, "type", strvct[3]);
if (strvct.size() > 4) Set(samplenode, "norm", strvct[4]);
return samplenode;
}
XMLNodePointer_t nuisconfig::CreateParameterNodeFromLine(
std::string const &line) {
// Create new node entry
XMLNodePointer_t parnode = CreateNode("parameter");
// Parse line
std::vector strvct = GeneralUtils::ParseToStr(line, " ");
// Add line elements to the node
// type name nominal [low] [high] [step] state
if (strvct.size() > 0) Set(parnode, "type", strvct[0]);
if (strvct.size() > 1) Set(parnode, "name", strvct[1]);
if (strvct.size() > 2) Set(parnode, "nominal", strvct[2]);
// If free structure
if (strvct.size() == 7) {
Set(parnode, "low", strvct[3]);
Set(parnode, "high", strvct[4]);
Set(parnode, "step", strvct[5]);
Set(parnode, "state", strvct[6]);
// Fixed param structure
} else if (strvct.size() == 3) {
Set(parnode, "state", "FIX");
} else if (strvct.size() == 4) {
Set(parnode, "state", strvct[3]);
}
return parnode;
}
XMLNodePointer_t nuisconfig::CreatePullNodeFromLine(std::string const &line) {
// Create new node entry
XMLNodePointer_t parnode = CreateNode("covar");
// Parse line
std::vector strvct = GeneralUtils::ParseToStr(line, " ");
// Add line elements to the node
// name input type
if (strvct.size() > 1) Set(parnode, "name", strvct[1]);
if (strvct.size() > 2) Set(parnode, "input", strvct[2]);
if (strvct.size() > 3) Set(parnode, "type", strvct[3]);
return parnode;
}
XMLNodePointer_t nuisconfig::CreateOldConfigNodeFromLine(
std::string const &line) {
// Create new node entry
XMLNodePointer_t confignode = CreateNode("config");
// Parse line
std::vector strvct = GeneralUtils::ParseToStr(line, " ");
// Add line elements to the node
// name value
if (strvct.size() > 2) Set(confignode, strvct[1], strvct[2]);
return confignode;
}
void nuisconfig::FinaliseSettings(std::string const &name) {
std::cout << "[ NUISANCE ]: Finalising run settings";
WriteSettings(name);
// Save full config to file
RemoveEmptyNodes();
RemoveIdenticalNodes();
std::cout << " -> DONE." << std::endl;
}
void nuisconfig::WriteSettings(std::string const &outputname) {
// Create a New XML Doc
XMLDocPointer_t newxmldoc = fXML->NewDoc();
fXML->DocSetRootElement(newxmldoc, fMainNode);
// Save document to file
if (GetConfigB("SaveParsedXMLFile")) {
fXML->SaveDoc(newxmldoc, outputname.c_str());
}
}
void nuisconfig::PrintXML(XMLNodePointer_t node, int indent) {
if (!node) {
node = fMainNode;
}
std::stringstream ss("");
for (int i = 0; i < indent; ++i) {
ss << " ";
}
std::cout << ss.str() << "<" << fXML->GetNodeName(node) << std::flush;
XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
while (attr) {
std::cout << " " << fXML->GetAttrName(attr) << "=\""
<< fXML->GetAttrValue(attr) << "\"" << std::flush;
attr = fXML->GetNextAttr(attr);
}
if (!fXML->GetChild(node)) {
std::cout << " />" << std::endl;
return;
}
std::cout << " >" << std::endl;
XMLNodePointer_t child = fXML->GetChild(node);
while (child) {
PrintXML(child, indent + 1);
child = fXML->GetNext(child);
}
std::cout << ss.str() << "" << fXML->GetNodeName(node) << ">" << std::endl;
}
XMLNodePointer_t nuisconfig::CreateNode(std::string const &name) {
return fXML->NewChild(fMainNode, 0, name.c_str());
}
XMLNodePointer_t nuisconfig::CreateNode(XMLNodePointer_t node,
std::string const &name) {
return fXML->NewChild(node, 0, name.c_str());
}
XMLNodePointer_t nuisconfig::GetNode(XMLNodePointer_t node,
std::string const &type) {
/// Loop over all children
XMLNodePointer_t child = fXML->GetChild(node);
while (child != 0) {
/// Get nodes for given type (if type empty return all)
if (std::string(fXML->GetNodeName(child)) == type.c_str() or type.empty()) {
return child;
}
// Next child
child = fXML->GetNext(child);
}
// Child not found
return 0;
}
void nuisconfig::RemoveEmptyNodes() {
std::vector nodelist = Config::Get().GetNodes();
for (size_t i = 0; i < nodelist.size(); i++) {
if (fXML->IsEmptyNode(nodelist[i])) {
std::cout << "Removing empty node: " << fXML->GetNodeName(nodelist[i])
<< ", with child ?" << bool(fXML->GetChild(nodelist[i]))
<< std::endl;
RemoveNode(nodelist[i]);
}
}
}
void nuisconfig::RemoveIdenticalNodes() {
std::vector removed;
// Loop over all nodes and check for identical nodes
std::vector nodelist = Config::Get().GetNodes();
for (size_t i = 0; i < nodelist.size(); i++) {
for (size_t j = 0; j < nodelist.size(); j++) {
if (i == j) continue;
XMLNodePointer_t node1 = nodelist[i];
XMLNodePointer_t node2 = nodelist[j];
// Check node already removed.
if (std::find(removed.begin(), removed.end(), node1) != removed.end()) {
continue;
}
if (std::find(removed.begin(), removed.end(), node2) != removed.end()) {
continue;
}
// Check matching
if (!MatchingNodes(node1, node2)) {
continue;
}
if (std::string(fXML->GetNodeName(node1)).compare("config") and
fXML->IsEmptyNode(node1)) {
// Matching so print out warning
std::cout << "Matching nodes given! Removing node1!" << std::endl
<< "Node 1" << std::endl;
PrintNode(node1);
std::cout << "Node 2" << std::endl;
PrintNode(node2);
}
// Remove node
removed.push_back(node1);
}
}
// Now go through and remove this node.
for (size_t i = 0; i < removed.size(); i++) {
RemoveNode(removed.at(i));
}
return;
}
void nuisconfig::RemoveNode(XMLNodePointer_t node) {
std::cout << "[INFO]: Removing node: " << fXML->GetNodeName(node)
<< std::endl;
fXML->FreeAllAttr(node);
fXML->CleanNode(node);
fXML->FreeNode(node);
fXML->UnlinkNode(node);
}
void nuisconfig::PrintNode(XMLNodePointer_t node) {
// Print Node Name
std::cout << fXML->GetNodeName(node) << std::endl;
// Loop and print all attributes
XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
while (attr != 0) {
std::cout << " -> " << fXML->GetAttrName(attr) << " : "
<< fXML->GetAttrValue(attr) << std::endl;
attr = fXML->GetNextAttr(attr);
}
}
bool nuisconfig::MatchingNodes(XMLNodePointer_t node1, XMLNodePointer_t node2) {
bool matching = true;
XMLAttrPointer_t attr = fXML->GetFirstAttr(node1);
while (attr != 0) {
if (GetS(node2, fXML->GetAttrName(attr)) != fXML->GetAttrValue(attr))
matching = false;
attr = fXML->GetNextAttr(attr);
}
return matching;
}
XMLNodePointer_t nuisconfig::GetNode(std::string const &type) {
return GetNode(fMainNode, type);
}
std::vector nuisconfig::GetNodes(XMLNodePointer_t node,
std::string const &type) {
// Create new vector for nodes
std::vector nodelist;
/// Loop over all children
XMLNodePointer_t child = fXML->GetChild(node);
while (child != 0) {
/// Get nodes for given type (if type empty return all)
if (std::string(fXML->GetNodeName(child)) == type.c_str() or type.empty()) {
nodelist.push_back(child);
}
// Next child
child = fXML->GetNext(child);
}
// return list
return nodelist;
}
std::vector nuisconfig::GetNodes(std::string const &type) {
return GetNodes(fMainNode, type);
}
void nuisconfig::Set(XMLNodePointer_t node, std::string const &name,
std::string const &val) {
// Remove and re-add attribute
if (fXML->HasAttr(node, name.c_str())) {
fXML->FreeAttr(node, name.c_str());
}
fXML->NewAttr(node, 0, name.c_str(), val.c_str());
}
void nuisconfig::Set(XMLNodePointer_t node, std::string const &name,
char const *val) {
Set(node, name, std::string(val));
}
void nuisconfig::Set(XMLNodePointer_t node, std::string const &name, bool val) {
Set(node, name, GeneralUtils::BoolToStr(val));
}
void nuisconfig::Set(XMLNodePointer_t node, std::string const &name, int val) {
Set(node, name, GeneralUtils::IntToStr(val));
}
void nuisconfig::Set(XMLNodePointer_t node, std::string const &name,
float val) {
Set(node, name, GeneralUtils::DblToStr(val));
}
void nuisconfig::Set(XMLNodePointer_t node, std::string const &name,
double val) {
Set(node, name, GeneralUtils::DblToStr(val));
}
void nuisconfig::SetS(XMLNodePointer_t node, std::string const &name,
std::string const &val) {
Set(node, name, val);
}
void nuisconfig::SetB(XMLNodePointer_t node, std::string const &name,
bool val) {
Set(node, name, GeneralUtils::BoolToStr(val));
}
void nuisconfig::SetI(XMLNodePointer_t node, std::string const &name, int val) {
Set(node, name, GeneralUtils::IntToStr(val));
}
void nuisconfig::SetF(XMLNodePointer_t node, std::string const &name,
float val) {
Set(node, name, GeneralUtils::DblToStr(val));
}
void nuisconfig::SetD(XMLNodePointer_t node, std::string const &name,
double val) {
Set(node, name, GeneralUtils::DblToStr(val));
}
bool nuisconfig::Has(XMLNodePointer_t node, std::string const &name) {
// If node empty return empty
if (node == 0) return false;
// Search attributes
XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
bool found = false;
// Loop over all attributes
while (attr != 0) {
// Find value of correct name
if (std::string(fXML->GetAttrName(attr)) == name.c_str()) {
found = true;
break;
}
// Next Attribute
attr = fXML->GetNextAttr(attr);
}
return found;
}
std::string nuisconfig::Get(XMLNodePointer_t node, std::string const &name) {
// If node empty return empty
if (node == 0) return "";
// Get Attribute from child with name
XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
std::string temp = "";
// Loop over all attributes
while (attr != 0) {
// If valid match then save
if (std::string(fXML->GetAttrName(attr)) == name.c_str()) {
temp = fXML->GetAttrValue(attr);
}
// Next Attribute
attr = fXML->GetNextAttr(attr);
}
return temp;
}
std::string nuisconfig::GetS(XMLNodePointer_t node, std::string const &name) {
return Get(node, name);
}
bool nuisconfig::GetB(XMLNodePointer_t node, std::string const &name) {
std::string tempattr = Get(node, name);
return GeneralUtils::StrToBool(tempattr);
}
int nuisconfig::GetI(XMLNodePointer_t node, std::string const &name) {
std::string tempattr = Get(node, name);
return GeneralUtils::StrToInt(tempattr);
}
float nuisconfig::GetF(XMLNodePointer_t node, std::string const &name) {
std::string tempattr = Get(node, name);
return GeneralUtils::StrToDbl(tempattr);
}
double nuisconfig::GetD(XMLNodePointer_t node, std::string const &name) {
std::string tempattr = Get(node, name);
return GeneralUtils::StrToDbl(tempattr);
}
std::vector nuisconfig::GetVS(XMLNodePointer_t node,
std::string const &name,
const char *del) {
std::string tempattr = Get(node, name);
return GeneralUtils::ParseToStr(tempattr, del);
}
// std::vector nuisconfig::GetVB(XMLNodePointer_t node,
// std::string name,
// const char* del) {
// std::string tempattr = Get(node, name);
// return GeneralUtils::ParseToBool(tempattr, del);
// }
std::vector nuisconfig::GetVI(XMLNodePointer_t node,
std::string const &name, const char *del) {
std::string tempattr = Get(node, name);
return GeneralUtils::ParseToInt(tempattr, del);
}
// std::vector nuisconfig::GetVF(XMLNodePointer_t node,
// std::string name,
// const char* del) {
// std::string tempattr = Get(node, name);
// return GeneralUtils::ParseToDouble(tempattr, del);
// }
std::vector nuisconfig::GetVD(XMLNodePointer_t node,
std::string const &name,
char const *del) {
std::string tempattr = Get(node, name);
return GeneralUtils::ParseToDbl(tempattr, del);
}
std::vector nuisconfig::GetAllKeysForNode(XMLNodePointer_t node) {
//bool matching = true;
XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
std::vector keys;
while (attr != 0) {
if (!std::string(fXML->GetAttrName(attr)).empty()) {
keys.push_back(std::string(fXML->GetAttrName(attr)));
}
attr = fXML->GetNextAttr(attr);
}
return keys;
}
XMLNodePointer_t nuisconfig::GetConfigNode(std::string const &name) {
// Loop over children and look for name
XMLNodePointer_t child = fXML->GetChild(fMainNode);
while (child != 0) {
// Select only config parameters
if (!std::string(fXML->GetNodeName(child)).compare("config")) {
// Loop over config attributes and search for name
XMLAttrPointer_t attr = fXML->GetFirstAttr(child);
while (attr != 0) {
// Save name value
if (std::string(fXML->GetAttrName(attr)) == name.c_str()) {
return child;
}
// Get Next Attribute
attr = fXML->GetNextAttr(attr);
}
}
// Next Child
child = fXML->GetNext(child);
}
return 0;
}
void nuisconfig::SetConfig(std::string const &name, std::string const &val) {
XMLNodePointer_t node = GetConfigNode(name);
if (!node) node = CreateNode("config");
Set(node, name, val);
}
void nuisconfig::SetConfig(std::string const &name, char const *val) {
SetConfig(name, std::string(val));
}
void nuisconfig::SetConfig(std::string const &name, bool val) {
XMLNodePointer_t node = GetConfigNode(name);
if (!node) node = CreateNode("config");
Set(node, name, val);
}
void nuisconfig::SetConfig(std::string const &name, int val) {
XMLNodePointer_t node = GetConfigNode(name);
if (!node) node = CreateNode("config");
Set(node, name, val);
}
void nuisconfig::SetConfig(std::string const &name, float val) {
XMLNodePointer_t node = GetConfigNode(name);
if (!node) node = CreateNode("config");
Set(node, name, val);
}
void nuisconfig::SetConfig(std::string const &name, double val) {
XMLNodePointer_t node = GetConfigNode(name);
if (!node) node = CreateNode("config");
Set(node, name, val);
}
void nuisconfig::OverrideConfig(std::string const &conf) {
std::vector opts = GeneralUtils::ParseToStr(conf, "=");
SetConfig(opts[0], opts[1]);
}
std::string nuisconfig::GetConfig(std::string const &name) {
XMLNodePointer_t node = GetConfigNode(name);
if (!node) return "";
XMLAttrPointer_t attr = fXML->GetFirstAttr(node);
std::string temp = "";
// Loop config attributes
while (attr != 0) {
// Find match
if (std::string(fXML->GetAttrName(attr)) == name.c_str()) {
temp = fXML->GetAttrValue(attr);
}
// Get Next Attribute
attr = fXML->GetNextAttr(attr);
}
return temp;
}
bool nuisconfig::HasConfig(std::string const &name) {
return bool(GetConfigNode(name));
}
std::string nuisconfig::GetConfigS(std::string const &name) {
return GetConfig(name);
}
bool nuisconfig::GetConfigB(std::string const &name) {
std::string pars = GetConfig(name);
return GeneralUtils::StrToBool(pars);
}
int nuisconfig::GetConfigI(std::string const &name) {
std::string pars = GetConfig(name);
return GeneralUtils::StrToInt(pars);
}
float nuisconfig::GetConfigF(std::string const &name) {
std::string pars = GetConfig(name);
return GeneralUtils::StrToDbl(pars);
}
double nuisconfig::GetConfigD(std::string const &name) {
std::string pars = GetConfig(name);
return GeneralUtils::StrToDbl(pars);
}
std::string nuisconfig::GetParDIR(std::string const &parName) {
std::string outstr = this->GetParS(parName);
// Make replacements in the string
const int nfiletypes = 2;
const std::string filetypes[nfiletypes] = {"@data", "@nuisance"};
std::string filerepl[nfiletypes] = {FitPar::GetDataBase(),
FitPar::GetDataBase() + "/../"};
for (int i = 0; i < nfiletypes; i++) {
std::string findstring = filetypes[i];
std::string replstring = filerepl[i];
if (outstr.find(findstring) != std::string::npos) {
outstr.replace(outstr.find(findstring), findstring.size(), filerepl[i]);
break;
}
}
return outstr;
};
diff --git a/src/Electron/ElectronScattering_DurhamData.cxx b/src/Electron/ElectronScattering_DurhamData.cxx
index 11d575b..7d8cf8c 100644
--- a/src/Electron/ElectronScattering_DurhamData.cxx
+++ b/src/Electron/ElectronScattering_DurhamData.cxx
@@ -1,483 +1,483 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#include "ElectronScattering_DurhamData.h"
//********************************************************************
ElectronScattering_DurhamData::ElectronScattering_DurhamData(
nuiskey samplekey) {
//********************************************************************
// Sample overview ---------------------------------------------------
std::string descrip =
"Electron Scattering Durham Data sample. \n"
"Target: Multiple \n"
"Flux: Energy should match data being handled \n"
"Signal: Any event with an electron in the final state \n";
fSettings = LoadSampleSettings(samplekey);
fSettings.SetDescription(descrip);
fSettings.DefineAllowedSpecies("electron");
fSettings.SetTitle("Electron");
fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG/NORM/MASK");
fSettings.SetXTitle("q0");
fSettings.SetYTitle("#sigma");
fIsNoWidth = true;
FinaliseSampleSettings();
// Plot Setup -------------------------------------------------------
SetDataFromName(fSettings.GetS("originalname"));
SetCovarFromDiagonal();
// Scaling Setup ---------------------------------------------------
// ScaleFactor automatically setup for DiffXSec/cm2/Nucleon
// fScaleFactor = ((GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents
// + 0.)) / TotalIntegratedFlux());
EnuMin = fZLowLim;
EnuMax = fZHighLim;
double sigscale = GetEventHistogram()->Integral() * 1E-38 / double(fNEvents) /
TotalIntegratedFlux();
// double dangle = 2 * M_PI * fabs((1. - cos(fYLowLim * M_PI / 180.)) - (1. -
// cos(fYHighLim * M_PI / 180.)));
// fScaleFactor = sigscale / dangle / fZCenter;
fScaleFactor = sigscale;
std::cout << "Event Integral = " << GetEventHistogram()->Integral()
<< std::endl;
std::cout << "Flux Integral = " << TotalIntegratedFlux() << std::endl;
std::cout << "FNEvents = " << fNEvents << std::endl;
std::cout << "Z Limits = " << fZLowLim << " " << fZHighLim << std::endl;
std::cout << "sigscale = " << sigscale << std::endl;
std::cout << "fZCenter = " << fZCenter << std::endl;
std::cout << "ScaleFactor = " << fScaleFactor << std::endl;
// Finish up
FinaliseMeasurement();
};
//********************************************************************
void ElectronScattering_DurhamData::SetDataFromName(std::string name) {
//********************************************************************
// Data Should be given in the format
// Electron_Z_A_Energy_Theta_Source
std::vector splitstring = GeneralUtils::ParseToStr(name, "_");
std::string zstring = splitstring[1];
std::string astring = splitstring[2];
std::string estring = splitstring[3];
std::string tstring = splitstring[4];
std::string sstring = splitstring[5];
fYCenter = GeneralUtils::StrToDbl(tstring);
fZCenter = GeneralUtils::StrToDbl(estring);
// Create effective E and Theta bin Edges
std::vector thetabinedges;
std::vector ebinedges;
int nthetabins = FitPar::Config().GetParI("Electron_NThetaBins");
int nebins = FitPar::Config().GetParI("Electron_NEnergyBins");
double thetawidth = FitPar::Config().GetParD("Electron_ThetaWidth");
double ewidth = FitPar::Config().GetParD("Electron_EnergyWidth");
for (int i = -nthetabins; i <= nthetabins; i++) {
thetabinedges.push_back(fYCenter + thetawidth * (double(i)));
}
for (int i = -nebins; i <= nebins; i++) {
double newval = fZCenter + ewidth * (double(i));
if (newval < 0.0) newval = 0.0;
if (newval < GetEventHistogram()->GetXaxis()->GetXmin())
newval = GetEventHistogram()->GetXaxis()->GetXmin();
if (newval > GetEventHistogram()->GetXaxis()->GetXmax())
newval = GetEventHistogram()->GetXaxis()->GetXmax();
if (std::find(ebinedges.begin(), ebinedges.end(), newval) !=
ebinedges.end())
continue;
ebinedges.push_back(newval);
}
// Determine target
std::string target = "";
if (!zstring.compare("6") && !astring.compare("12"))
target = "12C.dat";
else if (!zstring.compare("8") && !astring.compare("16"))
target = "16O.dat";
else {
- QTHROW("Target not supported in electron scattering module!"
+ NUIS_ABORT("Target not supported in electron scattering module!"
);
}
// Fill Data Points
std::string line;
std::ifstream mask((FitPar::GetDataBase() + "/Electron/" + target).c_str(),
std::ifstream::in);
if (!mask.good()) {
- QTHROW("Failed to open e-scattering database file: "
+ NUIS_ABORT("Failed to open e-scattering database file: "
<< (FitPar::GetDataBase() + "/Electron/" + target));
}
int i = 0;
std::vector pointx;
std::vector errorx;
std::vector pointy;
std::vector errory;
double scalef = 1.E-38 * 1.E5;
while (std::getline(mask >> std::ws, line, '\n')) {
// std::cout << "Line = " << line << std::endl;
if (line.empty()) continue;
std::vector lineentries = GeneralUtils::ParseToStr(line, " ");
// std::cout << "Checking : " << line << std::endl;
if (zstring.compare(lineentries[0])) continue;
if (astring.compare(lineentries[1])) continue;
if (estring.compare(lineentries[2])) continue;
if (tstring.compare(lineentries[3])) continue;
if (sstring.compare(lineentries[7])) continue;
// std::cout << "Registering data point : " << line << std::endl;
// std::cout << "Adding Graph Point : " <<
// GeneralUtils::StrToDbl(lineentries[4]) << " " <<
// GeneralUtils::StrToDbl(lineentries[5]) << std::endl;
// Loop through x and y points and find a place to insert
if (pointx.empty()) {
pointx.push_back(GeneralUtils::StrToDbl(lineentries[4]));
errorx.push_back(0.0);
pointy.push_back(GeneralUtils::StrToDbl(lineentries[5]) * scalef);
errory.push_back(GeneralUtils::StrToDbl(lineentries[6]) * scalef);
} else {
for (size_t j = 0; j < pointx.size(); j++) {
if (GeneralUtils::StrToDbl(lineentries[4]) < pointx[j] && j == 0) {
// std::cout << "Inserting at start point iterator " << std::endl;
pointx.insert(pointx.begin() + j,
GeneralUtils::StrToDbl(lineentries[4]));
errorx.insert(errorx.begin() + j, 0.0);
pointy.insert(pointy.begin() + j,
GeneralUtils::StrToDbl(lineentries[5]) * scalef);
errory.insert(errory.begin() + j,
GeneralUtils::StrToDbl(lineentries[6]) * scalef);
break;
} else if (GeneralUtils::StrToDbl(lineentries[4]) > pointx[j] &&
j == pointx.size() - 1) {
// std::cout << "Pushing back data point " << std::endl;
pointx.push_back(GeneralUtils::StrToDbl(lineentries[4]));
errorx.push_back(0.0);
pointy.push_back(GeneralUtils::StrToDbl(lineentries[5]) * scalef);
errory.push_back(GeneralUtils::StrToDbl(lineentries[6]) * scalef);
break;
} else if (GeneralUtils::StrToDbl(lineentries[4]) > pointx[j - 1] &&
GeneralUtils::StrToDbl(lineentries[4]) < pointx[j]) {
// std::cout << "Inserting at point iterator = " << j << std::endl;
pointx.insert(pointx.begin() + j,
GeneralUtils::StrToDbl(lineentries[4]));
errorx.insert(errorx.begin() + j, 0.0);
pointy.insert(pointy.begin() + j,
GeneralUtils::StrToDbl(lineentries[5]) * scalef);
errory.insert(errory.begin() + j,
GeneralUtils::StrToDbl(lineentries[6]) * scalef);
break;
}
}
}
// pointx.push_back(GeneralUtils::StrToDbl(lineentries[4]));
// errorx.push_back(0.0);
// pointy.push_back(GeneralUtils::StrToDbl(lineentries[5]));
// errory.push_back(GeneralUtils::StrToDbl(lineentries[6]));
i++;
}
if (!pointx.size() || (pointx.size() != errorx.size()) || !pointy.size() ||
(pointy.size() != errory.size())) {
- QTHROW("Failed to find dataset: " << name << "{"
+ NUIS_ABORT("Failed to find dataset: " << name << "{"
<< "Z: " << zstring << ", A: " << astring << ", E: " << estring
<< ", CTheta: " << tstring << ", PubID: " << sstring
<< " } in file: "
<< (FitPar::GetDataBase() + "/Electron/" + target));
}
// for (uint i = 0; i < pointx.size(); i++) {
// std::cout << "Q0 Point " << i << " = " << pointx[i] << std::endl;
// }
fDataGraph = new TGraphErrors(pointx.size(), &pointx[0], &pointy[0],
&errorx[0], &errory[0]);
fDataGraph->SetNameTitle((fName + "_data_GRAPH").c_str(),
(fName + "_data_GRAPH").c_str());
// Now form an effective data and mc histogram
std::vector q0binedges;
const double* x = fDataGraph->GetX();
// Loop over graph and get mid way point between each data point.
for (int i = 0; i < fDataGraph->GetN(); i++) {
// std::cout << "X Point = " << x[i] << std::endl;
if (i == 0) {
// First point set lower width as half distance to point above
q0binedges.push_back(x[0] - ((x[1] - x[0]) / 2.0));
} else if (i == fDataGraph->GetN() - 1) {
// Last point set upper width as half distance to point above.
q0binedges.push_back(x[i] - ((x[i] - x[i - 1]) / 2.0));
q0binedges.push_back(x[i] + ((x[i] - x[i - 1]) / 2.0));
} else {
// Set half distance to point below
q0binedges.push_back(x[i] - ((x[i] - x[i - 1]) / 2.0));
}
}
// Bubble Sort
// for (uint i = 0; i < q0binedges.size(); i++) {
// std::cout << "Q0 Edge " << i << " = " << q0binedges[i] << std::endl;
// }
// for (uint i = 0; i < ebinedges.size(); i++) {
// std::cout << "e Edge " << i << " = " << ebinedges[i] << std::endl;
// }
// for (uint i = 0; i < thetabinedges.size(); i++) {
// std::cout << "theta Edge " << i << " = " << thetabinedges[i] <<
// std::endl;
// }
// Form the data hist, mchist, etc
fDataHist = new TH1D((fName + "_data").c_str(), (fName + "_data").c_str(),
q0binedges.size() - 1, &q0binedges[0]);
fMCHist = (TH1D*)fDataHist->Clone("MC");
const double* y = fDataGraph->GetY();
const double* ey = fDataGraph->GetEY();
for (int i = 0; i < fDataGraph->GetN(); i++) {
// std::cout << "Setting Data Bin " << i + 1 << " to " << y[i] << " +- " <<
// ey[i] << std::endl;
fDataHist->SetBinContent(i + 1, y[i]);
fDataHist->SetBinError(i + 1, ey[i]);
fMCHist->SetBinContent(i + 1, 0.0);
fMCHist->SetBinError(i + 1, 0.0);
}
fMCScan_Q0vsThetavsE =
new TH3D((fName + "_MC_q0vsthetavse").c_str(), "MC_q0vsthetavse",
q0binedges.size() - 1, &q0binedges[0], thetabinedges.size() - 1,
&thetabinedges[0], ebinedges.size() - 1, &ebinedges[0]);
fMCScan_Q0vsThetavsE->Reset();
fMCScan_Q0vsTheta = new TH2D(
(fName + "_MC_q0vstheta").c_str(), "MC_q0vstheta", q0binedges.size() - 1,
&q0binedges[0], thetabinedges.size() - 1, &thetabinedges[0]);
fMCScan_Q0vsTheta->Reset();
fMCScan_Q0vsE =
new TH2D((fName + "_MC_q0vse").c_str(), "MC_q0vse", q0binedges.size() - 1,
&q0binedges[0], ebinedges.size() - 1, &ebinedges[0]);
fMCScan_Q0vsE->Reset();
fXLowLim = fMCScan_Q0vsThetavsE->GetXaxis()->GetBinLowEdge(1);
fXHighLim = fMCScan_Q0vsThetavsE->GetXaxis()->GetBinLowEdge(
fMCScan_Q0vsThetavsE->GetNbinsX() + 2);
fYLowLim = fMCScan_Q0vsThetavsE->GetYaxis()->GetBinLowEdge(1);
fYHighLim = fMCScan_Q0vsThetavsE->GetYaxis()->GetBinLowEdge(
fMCScan_Q0vsThetavsE->GetNbinsY() + 2);
fZLowLim = fMCScan_Q0vsThetavsE->GetZaxis()->GetBinLowEdge(1);
fZHighLim = fMCScan_Q0vsThetavsE->GetZaxis()->GetBinLowEdge(
fMCScan_Q0vsThetavsE->GetNbinsZ() + 2);
std::cout << "Sample " << name << "initialised: "
<< "{" << fXLowLim << "--" << fXHighLim << ", " << fYLowLim << "--"
<< fYHighLim << ", " << fZLowLim << "--" << fZHighLim << "}"
<< std::endl;
}
//********************************************************************
void ElectronScattering_DurhamData::FillEventVariables(FitEvent* event) {
//********************************************************************
if (event->NumFSParticle(11) == 0) return;
FitParticle* ein = event->PartInfo(0);
FitParticle* eout = event->GetHMFSParticle(11);
double q0 = fabs(ein->fP.E() - eout->fP.E()) / 1000.0;
double E = ein->fP.E() / 1000.0;
double theta = ein->fP.Vect().Angle(eout->fP.Vect()) * 180. / M_PI;
fXVar = q0;
fYVar = theta;
fZVar = E;
return;
};
//********************************************************************
bool ElectronScattering_DurhamData::isSignal(FitEvent* event) {
//********************************************************************
if (event->NumFSParticle(11) == 0) {
std::cout << "Ev Cut due to no FS electron." << std::endl;
return false;
}
// std::cout << "fXVar = " << fXVar << " " << fXLowLim << " " << fXHighLim <<
// std::endl;
// std::cout << "fYVar = " << fYVar << " " << fYLowLim << " " << fYHighLim <<
// std::endl;
// std::cout << "fZVar = " << fZVar << " " << fZLowLim << " " << fZHighLim <<
// std::endl;
// std::cout << "iWeight: " << event->InputWeight << std::endl;
if (fXVar < fXLowLim or fXVar > fXHighLim) {
// std::cout << "Ev Cut due to X lims: " << fXLowLim << " -- " << fXHighLim
// << " !<> " << fXVar << std::endl;
return false;
}
if (fYVar < fYLowLim or fYVar > fYHighLim) {
// std::cout << "Ev Cut due to Y lims: " << fYLowLim << " -- " << fYHighLim
// << " !<> " << fXVar << std::endl;
return false;
}
if (fZVar < fZLowLim or fZVar > fZHighLim) {
// std::cout << "Ev Cut due to Z lims: " << fZLowLim << " -- " << fZHighLim
// << " !<> " << fXVar << std::endl;
return false;
}
return true;
};
//********************************************************************
void ElectronScattering_DurhamData::FillHistograms() {
//********************************************************************
Measurement1D::FillHistograms();
if (Signal) {
fMCScan_Q0vsThetavsE->Fill(fXVar, fYVar, fZVar);
fMCScan_Q0vsTheta->Fill(fXVar, fYVar);
fMCScan_Q0vsE->Fill(fXVar, fZVar);
}
}
// Weight = 1.0;
// if (Signal) {
// fMCHist->Fill(fXVar, Weight);
// fMCFine->Fill(fXVar, Weight);
// fMCStat->Fill(fXVar, 1.0);
// if (fMCHist_Modes) fMCHist_Modes->Fill(Mode, fXVar, Weight);
// }
// }
void ElectronScattering_DurhamData::ResetAll() {
Measurement1D::ResetAll();
fMCScan_Q0vsThetavsE->Reset();
fMCScan_Q0vsTheta->Reset();
fMCScan_Q0vsE->Reset();
}
void ElectronScattering_DurhamData::ApplyNormScale(double norm) {
Measurement1D::ApplyNormScale(norm);
fMCScan_Q0vsThetavsE->Scale(1.0 / norm);
fMCScan_Q0vsTheta->Scale(1.0 / norm);
fMCScan_Q0vsE->Scale(1.0 / norm);
}
//********************************************************************
void ElectronScattering_DurhamData::ScaleEvents() {
//********************************************************************
Measurement1D::ScaleEvents();
/*
fMCScan_Q0vsThetavsE->Scale(fScaleFactor, "width");
// Project into fMCScan_Q0vsTheta
for (int x = 0; x < fMCScan_Q0vsThetavsE->GetNbinsX(); x++) {
for (int y = 0; y < fMCScan_Q0vsThetavsE->GetNbinsY(); y++) {
double total = 0.;
for (int z = 0; z < fMCScan_Q0vsThetavsE->GetNbinsZ(); z++) {
double zwidth = fMCScan_Q0vsThetavsE->GetZaxis()->GetBinWidth(z + 1);
total += fMCScan_Q0vsThetavsE->GetBinContent(x + 1, y + 1, z + 1) *
zwidth;
}
fMCScan_Q0vsTheta->SetBinContent(x + 1, y + 1, total);
}
}
// Project into fMCScan_Q0vsE
for (int x = 0; x < fMCScan_Q0vsThetavsE->GetNbinsX(); x++) {
for (int z = 0; z < fMCScan_Q0vsThetavsE->GetNbinsZ(); z++) {
double total = 0.;
for (int y = 0; y < fMCScan_Q0vsThetavsE->GetNbinsY(); y++) {
double ywidth = fMCScan_Q0vsThetavsE->GetYaxis()->GetBinWidth(y + 1);
total += fMCScan_Q0vsThetavsE->GetBinContent(x + 1, y + 1, z + 1) *
ywidth;
}
fMCScan_Q0vsE->SetBinContent(x + 1, z + 1, total);
}
}
// Project fMCScan_Q0vsTheta into MC Hist
for (int x = 0; x < fMCScan_Q0vsTheta->GetNbinsX(); x++) {
double total = 0.;
for (int y = 0; y < fMCScan_Q0vsTheta->GetNbinsY(); y++) {
double ywidth = fMCScan_Q0vsTheta->GetYaxis()->GetBinWidth(y + 1);
total += fMCScan_Q0vsTheta->GetBinContent(x + 1, y + 1);
}
double xwidth = fMCScan_Q0vsTheta->GetXaxis()->GetBinWidth(x + 1);
fMCHist->SetBinContent(x + 1, total * xwidth);
}
fMCHist->Scale(fDataHist->Integral() / fMCHist->Integral());
*/
}
//********************************************************************
int ElectronScattering_DurhamData::GetNDOF() {
//********************************************************************
return fDataGraph->GetN();
}
void ElectronScattering_DurhamData::Write(std::string drawOpts) {
Measurement1D::Write(drawOpts);
fMCScan_Q0vsThetavsE->Write();
fMCScan_Q0vsTheta->Write();
fMCScan_Q0vsE->Write();
fDataGraph->Write();
}
double ElectronScattering_DurhamData::GetLikelihood() { return 0.0; }
void ElectronScattering_DurhamData::SetFitOptions(std::string opt) { return; }
TH1D* ElectronScattering_DurhamData::GetMCHistogram(void) { return fMCHist; }
TH1D* ElectronScattering_DurhamData::GetDataHistogram(void) {
return fDataHist;
}
diff --git a/src/FCN/JointFCN.cxx b/src/FCN/JointFCN.cxx
index a19273c..64d00b6 100755
--- a/src/FCN/JointFCN.cxx
+++ b/src/FCN/JointFCN.cxx
@@ -1,1123 +1,1123 @@
#include "JointFCN.h"
#include "FitUtils.h"
#include
//***************************************************
JointFCN::JointFCN(TFile *outfile) {
//***************************************************
fOutputDir = gDirectory;
if (outfile)
Config::Get().out = outfile;
std::vector samplekeys = Config::QueryKeys("sample");
LoadSamples(samplekeys);
std::vector covarkeys = Config::QueryKeys("covar");
LoadPulls(covarkeys);
fCurIter = 0;
fMCFilled = false;
fIterationTree = false;
fDialVals = NULL;
fNDials = 0;
fUsingEventManager = FitPar::Config().GetParB("EventManager");
fOutputDir->cd();
}
//***************************************************
JointFCN::JointFCN(std::vector samplekeys, TFile *outfile) {
//***************************************************
fOutputDir = gDirectory;
if (outfile)
Config::Get().out = outfile;
LoadSamples(samplekeys);
fCurIter = 0;
fMCFilled = false;
fOutputDir->cd();
fIterationTree = false;
fDialVals = NULL;
fNDials = 0;
fUsingEventManager = FitPar::Config().GetParB("EventManager");
fOutputDir->cd();
}
//***************************************************
JointFCN::~JointFCN() {
//***************************************************
// Delete Samples
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
delete exp;
}
for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) {
ParamPull *pull = *iter;
delete pull;
}
// Sort Tree
if (fIterationTree)
DestroyIterationTree();
if (fDialVals)
delete fDialVals;
if (fSampleLikes)
delete fSampleLikes;
};
//***************************************************
void JointFCN::CreateIterationTree(std::string name, FitWeight *rw) {
//***************************************************
- QLOG(FIT, " Creating new iteration container! ");
+ NUIS_LOG(FIT, " Creating new iteration container! ");
DestroyIterationTree();
fIterationTreeName = name;
// Add sample likelihoods and ndof
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
std::string name = exp->GetName();
std::string liketag = name + "_likelihood";
fNameValues.push_back(liketag);
fCurrentValues.push_back(0.0);
std::string ndoftag = name + "_ndof";
fNameValues.push_back(ndoftag);
fCurrentValues.push_back(0.0);
}
// Add Pull terms
for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) {
ParamPull *pull = *iter;
std::string name = pull->GetName();
std::string liketag = name + "_likelihood";
fNameValues.push_back(liketag);
fCurrentValues.push_back(0.0);
std::string ndoftag = name + "_ndof";
fNameValues.push_back(ndoftag);
fCurrentValues.push_back(0.0);
}
// Add Likelihoods
fNameValues.push_back("total_likelihood");
fCurrentValues.push_back(0.0);
fNameValues.push_back("total_ndof");
fCurrentValues.push_back(0.0);
// Setup Containers
fSampleN = fSamples.size() + fPulls.size();
fSampleLikes = new double[fSampleN];
fSampleNDOF = new int[fSampleN];
// Add Dials
std::vector dials = rw->GetDialNames();
for (size_t i = 0; i < dials.size(); i++) {
fNameValues.push_back(dials[i]);
fCurrentValues.push_back(0.0);
}
fNDials = dials.size();
fDialVals = new double[fNDials];
// Set IterationTree Flag
fIterationTree = true;
}
//***************************************************
void JointFCN::DestroyIterationTree() {
//***************************************************
fIterationCount.clear();
fCurrentValues.clear();
fNameValues.clear();
fIterationValues.clear();
}
//***************************************************
void JointFCN::WriteIterationTree() {
//***************************************************
- QLOG(FIT, "Writing iteration tree");
+ NUIS_LOG(FIT, "Writing iteration tree");
// Make a new TTree
TTree *itree =
new TTree(fIterationTreeName.c_str(), fIterationTreeName.c_str());
double *vals = new double[fNameValues.size()];
int count = 0;
itree->Branch("iteration", &count, "Iteration/I");
for (size_t i = 0; i < fNameValues.size(); i++) {
itree->Branch(fNameValues[i].c_str(), &vals[i],
(fNameValues[i] + "/D").c_str());
}
// Fill Iterations
for (size_t i = 0; i < fIterationValues.size(); i++) {
std::vector itervals = fIterationValues[i];
// Fill iteration state
count = fIterationCount[i];
for (size_t j = 0; j < itervals.size(); j++) {
vals[j] = itervals[j];
}
// Save to TTree
itree->Fill();
}
// Write to file
itree->Write();
}
//***************************************************
void JointFCN::FillIterationTree(FitWeight *rw) {
//***************************************************
// Loop over samples count
int count = 0;
for (int i = 0; i < fSampleN; i++) {
fCurrentValues[count++] = fSampleLikes[i];
fCurrentValues[count++] = double(fSampleNDOF[i]);
}
// Fill Totals
fCurrentValues[count++] = fLikelihood;
fCurrentValues[count++] = double(fNDOF);
// Loop Over Parameter Counts
rw->GetAllDials(fDialVals, fNDials);
for (int i = 0; i < fNDials; i++) {
fCurrentValues[count++] = double(fDialVals[i]);
}
// Push Back Into Container
fIterationCount.push_back(fCurIter);
fIterationValues.push_back(fCurrentValues);
}
//***************************************************
double JointFCN::DoEval(const double *x) {
//***************************************************
// WEIGHT ENGINE
fDialChanged = FitBase::GetRW()->HasRWDialChanged(x);
FitBase::GetRW()->UpdateWeightEngine(x);
if (fDialChanged) {
FitBase::GetRW()->Reconfigure();
FitBase::EvtManager().ResetWeightFlags();
}
if (LOG_LEVEL(REC)) {
FitBase::GetRW()->Print();
}
// SORT SAMPLES
ReconfigureSamples();
// GET TEST STAT
fLikelihood = GetLikelihood();
fNDOF = GetNDOF();
// PRINT PROGRESS
- QLOG(FIT, "Current Stat (iter. " << this->fCurIter << ") = " << fLikelihood);
+ NUIS_LOG(FIT, "Current Stat (iter. " << this->fCurIter << ") = " << fLikelihood);
// UPDATE TREE
if (fIterationTree)
FillIterationTree(FitBase::GetRW());
return fLikelihood;
}
//***************************************************
int JointFCN::GetNDOF() {
//***************************************************
int totaldof = 0;
int count = 0;
// Total number of Free bins in each MC prediction
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
int dof = exp->GetNDOF();
// Save Seperate DOF
if (fIterationTree) {
fSampleNDOF[count] = dof;
}
// Add to total
totaldof += dof;
count++;
}
// Loop over pulls
for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) {
ParamPull *pull = *iter;
double dof = pull->GetLikelihood();
// Save seperate DOF
if (fIterationTree) {
fSampleNDOF[count] = dof;
}
// Add to total
totaldof += dof;
count++;
}
// Set Data Variable
if (fIterationTree) {
fSampleNDOF[count] = totaldof;
}
return totaldof;
}
//***************************************************
double JointFCN::GetLikelihood() {
//***************************************************
- QLOG(MIN, std::left << std::setw(43) << "Getting likelihoods..."
+ NUIS_LOG(MIN, std::left << std::setw(43) << "Getting likelihoods..."
<< " : "
<< "-2logL");
// Loop and add up likelihoods in an uncorrelated way
double like = 0.0;
int count = 0;
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
double newlike = exp->GetLikelihood();
int ndof = exp->GetNDOF();
// Save seperate likelihoods
if (fIterationTree) {
fSampleLikes[count] = newlike;
}
- QLOG(MIN, "-> " << std::left << std::setw(40) << exp->GetName() << " : "
+ NUIS_LOG(MIN, "-> " << std::left << std::setw(40) << exp->GetName() << " : "
<< newlike << "/" << ndof);
// Add Weight Scaling
// like *= FitBase::GetRW()->GetSampleLikelihoodWeight(exp->GetName());
// Add to total
like += newlike;
count++;
}
// Loop over pulls
for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) {
ParamPull *pull = *iter;
double newlike = pull->GetLikelihood();
// Save seperate likelihoods
if (fIterationTree) {
fSampleLikes[count] = newlike;
}
// Add to total
like += newlike;
count++;
}
// Set Data Variable
fLikelihood = like;
if (fIterationTree) {
fSampleLikes[count] = fLikelihood;
}
return like;
};
void JointFCN::LoadSamples(std::vector samplekeys) {
- QLOG(MIN, "Loading Samples : " << samplekeys.size());
+ NUIS_LOG(MIN, "Loading Samples : " << samplekeys.size());
for (size_t i = 0; i < samplekeys.size(); i++) {
nuiskey key = samplekeys[i];
// Get Sample Options
std::string samplename = key.GetS("name");
std::string samplefile = key.GetS("input");
std::string sampletype = key.GetS("type");
std::string fakeData = "";
- QLOG(MIN, "Loading Sample : " << samplename);
+ NUIS_LOG(MIN, "Loading Sample : " << samplename);
fOutputDir->cd();
MeasurementBase *NewLoadedSample = SampleUtils::CreateSample(key);
if (!NewLoadedSample) {
- QERROR(FTL, "Could not load sample provided: " << samplename);
- QERROR(FTL, "Check spelling with that in src/FCN/SampleList.cxx");
+ NUIS_ERR(FTL, "Could not load sample provided: " << samplename);
+ NUIS_ERR(FTL, "Check spelling with that in src/FCN/SampleList.cxx");
throw;
} else {
fSamples.push_back(NewLoadedSample);
}
}
}
//***************************************************
void JointFCN::LoadPulls(std::vector pullkeys) {
//***************************************************
for (size_t i = 0; i < pullkeys.size(); i++) {
nuiskey key = pullkeys[i];
std::string pullname = key.GetS("name");
std::string pullfile = key.GetS("input");
std::string pulltype = key.GetS("type");
fOutputDir->cd();
fPulls.push_back(new ParamPull(pullname, pullfile, pulltype));
}
}
//***************************************************
void JointFCN::ReconfigureSamples(bool fullconfig) {
//***************************************************
int starttime = time(NULL);
- QLOG(REC, "Starting Reconfigure iter. " << this->fCurIter);
+ NUIS_LOG(REC, "Starting Reconfigure iter. " << this->fCurIter);
// std::cout << fUsingEventManager << " " << fullconfig << " " << fMCFilled <<
// std::endl;
// Event Manager Reconf
if (fUsingEventManager) {
if (!fullconfig && fMCFilled)
ReconfigureFastUsingManager();
else
ReconfigureUsingManager();
} else {
// Loop over all Measurement Classes
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
// If RW Either do signal or full reconfigure.
if (fDialChanged or !fMCFilled or fullconfig) {
if (!fullconfig and fMCFilled)
exp->ReconfigureFast();
else
exp->Reconfigure();
// If RW Not needed just do normalisation
} else {
exp->Renormalise();
}
}
}
// Loop over pulls and update
for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) {
ParamPull *pull = *iter;
pull->Reconfigure();
}
fMCFilled = true;
- QLOG(MIN, "Finished Reconfigure iter. " << fCurIter << " in "
+ NUIS_LOG(MIN, "Finished Reconfigure iter. " << fCurIter << " in "
<< time(NULL) - starttime << "s");
fCurIter++;
}
//***************************************************
void JointFCN::ReconfigureSignal() {
//***************************************************
ReconfigureSamples(false);
}
//***************************************************
void JointFCN::ReconfigureAllEvents() {
//***************************************************
FitBase::GetRW()->Reconfigure();
FitBase::EvtManager().ResetWeightFlags();
ReconfigureSamples(true);
}
std::vector JointFCN::GetInputList() {
std::vector InputList;
fIsAllSplines = true;
MeasListConstIter iterSam = fSamples.begin();
for (; iterSam != fSamples.end(); iterSam++) {
MeasurementBase *exp = (*iterSam);
std::vector subsamples = exp->GetSubSamples();
for (size_t i = 0; i < subsamples.size(); i++) {
InputHandlerBase *inp = subsamples[i]->GetInput();
if (std::find(InputList.begin(), InputList.end(), inp) ==
InputList.end()) {
if (subsamples[i]->GetInput()->GetType() != kSPLINEPARAMETER)
fIsAllSplines = false;
InputList.push_back(subsamples[i]->GetInput());
}
}
}
return InputList;
}
std::vector JointFCN::GetSubSampleList() {
std::vector SampleList;
MeasListConstIter iterSam = fSamples.begin();
for (; iterSam != fSamples.end(); iterSam++) {
MeasurementBase *exp = (*iterSam);
std::vector subsamples = exp->GetSubSamples();
for (size_t i = 0; i < subsamples.size(); i++) {
SampleList.push_back(subsamples[i]);
}
}
return SampleList;
}
//***************************************************
void JointFCN::ReconfigureUsingManager() {
//***************************************************
// 'Slow' Event Manager Reconfigure
- QLOG(REC, "Event Manager Reconfigure");
+ NUIS_LOG(REC, "Event Manager Reconfigure");
int timestart = time(NULL);
// Reset all samples
MeasListConstIter iterSam = fSamples.begin();
for (; iterSam != fSamples.end(); iterSam++) {
MeasurementBase *exp = (*iterSam);
exp->ResetAll();
}
// If we are siving signal, reset all containers.
bool savesignal = (FitPar::Config().GetParB("SignalReconfigures"));
if (savesignal) {
// Reset all of our event signal vectors
fSignalEventBoxes.clear();
fSignalEventFlags.clear();
fSampleSignalFlags.clear();
fSignalEventSplines.clear();
}
// Make sure we have a list of inputs
if (fInputList.empty()) {
fInputList = GetInputList();
fSubSampleList = GetSubSampleList();
}
// If all inputs are splines make sure the readers are told
// they need to be reconfigured.
std::vector::iterator inp_iter = fInputList.begin();
if (fIsAllSplines) {
for (; inp_iter != fInputList.end(); inp_iter++) {
InputHandlerBase *curinput = (*inp_iter);
// Tell reader in each BaseEvent it needs a Reconfigure next weight calc.
BaseFitEvt *curevent = curinput->FirstBaseEvent();
if (curevent->fSplineRead) {
curevent->fSplineRead->SetNeedsReconfigure(true);
}
}
}
// MAIN INPUT LOOP ====================
int fillcount = 0;
int inputcount = 0;
inp_iter = fInputList.begin();
// Loop over each input in manager
for (; inp_iter != fInputList.end(); inp_iter++) {
InputHandlerBase *curinput = (*inp_iter);
// Get event information
FitEvent *curevent = curinput->FirstNuisanceEvent();
curinput->CreateCache();
int i = 0;
int nevents = curinput->GetNEvents();
int countwidth = nevents / 10;
// Start event loop iterating until we get a NULL pointer.
while (curevent) {
// Get Event Weight
// The reweighting weight
curevent->RWWeight = FitBase::GetRW()->CalcWeight(curevent);
// The Custom weight and reweight
curevent->Weight =
curevent->RWWeight * curevent->InputWeight * curevent->CustomWeight;
if (LOGGING(REC)) {
if (countwidth && (i % countwidth == 0)) {
- QLOG(REC, curinput->GetName()
+ NUIS_LOG(REC, curinput->GetName()
<< " : Processed " << i << " events. [M, W] = ["
<< curevent->Mode << ", " << curevent->Weight << "]");
}
}
// Setup flag for if signal found in at least one sample
bool foundsignal = false;
// Create a new signal bitset for this event
std::vector signalbitset(fSubSampleList.size());
// Create a new signal box vector for this event
std::vector signalboxes;
// Start measurement iterator
size_t measitercount = 0;
std::vector::iterator meas_iter =
fSubSampleList.begin();
// Loop over all subsamples (sub in JointMeas)
for (; meas_iter != fSubSampleList.end(); meas_iter++) {
MeasurementBase *curmeas = (*meas_iter);
// Compare input pointers, to current input, skip if not.
// Pointer tells us if it matches without doing ID checks.
if (curinput != curmeas->GetInput()) {
if (savesignal) {
// Set bit to 0 as definitely not signal
signalbitset[measitercount] = 0;
}
// Count up what measurement we are on.
measitercount++;
// Skip sample as input not signal.
continue;
}
// Fill events for matching inputs.
MeasurementVariableBox *box = curmeas->FillVariableBox(curevent);
bool signal = curmeas->isSignal(curevent);
curmeas->SetSignal(signal);
curmeas->FillHistograms(curevent->Weight);
// If its Signal tally up fills
if (signal) {
fillcount++;
}
// If we are saving signal/splines fill the bitset
if (savesignal) {
signalbitset[measitercount] = signal;
}
// If signal save a clone of the event box for use later.
if (savesignal and signal) {
foundsignal = true;
signalboxes.push_back(box->CloneSignalBox());
}
// Keep track of Measurement we are on.
measitercount++;
}
// Once we've filled the measurements, if saving signal
// push back if any sample flagged this event as signal
if (savesignal) {
fSignalEventFlags.push_back(foundsignal);
}
// Save the vector of signal boxes for this event
if (savesignal && foundsignal) {
fSignalEventBoxes.push_back(signalboxes);
fSampleSignalFlags.push_back(signalbitset);
}
// If all inputs are splines we can save the spline coefficients
// for fast in memory reconfigures later.
if (fIsAllSplines && savesignal && foundsignal) {
// Make temp vector to push back with
std::vector coeff;
for (size_t l = 0; l < (UInt_t)curevent->fSplineRead->GetNPar(); l++) {
coeff.push_back(curevent->fSplineCoeff[l]);
}
// Push back to signal event splines. Kept in sync with
// fSignalEventBoxes size.
// int splinecount = fSignalEventSplines.size();
fSignalEventSplines.push_back(coeff);
// if (splinecount % 1000 == 0) {
// std::cout << "Pushed Back Coeff " << splinecount << " : ";
// for (size_t l = 0; l < fSignalEventSplines[splinecount].size(); l++)
// {
// std::cout << " " << fSignalEventSplines[splinecount][l];
// }
// std::cout << std::endl;
// }
}
// Clean up vectors once done with this event
signalboxes.clear();
signalbitset.clear();
// Iterate to the next event.
curevent = curinput->NextNuisanceEvent();
i++;
}
// curinput->RemoveCache();
// Keep track of what input we are on.
inputcount++;
}
// End of Event Loop ===============================
// Now event loop is finished loop over all Measurements
// Converting Binned events to XSec Distributions
iterSam = fSamples.begin();
for (; iterSam != fSamples.end(); iterSam++) {
MeasurementBase *exp = (*iterSam);
exp->ConvertEventRates();
}
// Print out statements on approximate memory usage for profiling.
- QLOG(REC, "Filled " << fillcount << " signal events.");
+ NUIS_LOG(REC, "Filled " << fillcount << " signal events.");
if (savesignal) {
int mem = ( // sizeof(fSignalEventBoxes) +
// fSignalEventBoxes.size() * sizeof(fSignalEventBoxes.at(0)) +
sizeof(MeasurementVariableBox1D) * fillcount) *
1E-6;
- QLOG(REC, " -> Saved " << fillcount << " signal boxes for faster access. (~"
+ NUIS_LOG(REC, " -> Saved " << fillcount << " signal boxes for faster access. (~"
<< mem << " MB)");
if (fIsAllSplines and !fSignalEventSplines.empty()) {
int splmem = sizeof(float) * fSignalEventSplines.size() *
fSignalEventSplines[0].size() * 1E-6;
- QLOG(REC, " -> Saved " << fillcount << " " << fSignalEventSplines.size()
+ NUIS_LOG(REC, " -> Saved " << fillcount << " " << fSignalEventSplines.size()
<< " spline sets into memory. (~" << splmem
<< " MB)");
}
}
- QLOG(REC,
+ NUIS_LOG(REC,
"Time taken ReconfigureUsingManager() : " << time(NULL) - timestart);
// Check SignalReconfigures works for all samples
if (savesignal) {
double likefull = GetLikelihood();
ReconfigureFastUsingManager();
double likefast = GetLikelihood();
if (fabs(likefull - likefast) > 0.0001) {
- QERROR(FTL, "Fast and Full Likelihoods DIFFER! : " << likefull << " : "
+ NUIS_ERR(FTL, "Fast and Full Likelihoods DIFFER! : " << likefull << " : "
<< likefast);
- QERROR(FTL, "This means some samples you are using are not setup to use "
+ NUIS_ERR(FTL, "This means some samples you are using are not setup to use "
"SignalReconfigures=1");
- QERROR(FTL, "Please turn OFF signal reconfigures.");
+ NUIS_ERR(FTL, "Please turn OFF signal reconfigures.");
throw;
} else {
- QLOG(FIT,
+ NUIS_LOG(FIT,
"Likelihoods for FULL and FAST match. Will use FAST next time.");
}
}
};
//***************************************************
void JointFCN::ReconfigureFastUsingManager() {
//***************************************************
- QLOG(FIT, " -> Doing FAST using manager");
+ NUIS_LOG(FIT, " -> Doing FAST using manager");
// Get Start time for profilling
int timestart = time(NULL);
// Reset all samples
MeasListConstIter iterSam = fSamples.begin();
for (; iterSam != fSamples.end(); iterSam++) {
MeasurementBase *exp = (*iterSam);
exp->ResetAll();
}
// Check for saved variables if not do a full reconfigure.
if (fSignalEventFlags.empty()) {
- QERROR(WRN, "Signal Flags Empty! Using normal manager.");
+ NUIS_ERR(WRN, "Signal Flags Empty! Using normal manager.");
ReconfigureUsingManager();
return;
}
bool fFillNuisanceEvent =
FitPar::Config().GetParB("FullEventOnSignalReconfigure");
// Setup fast vector iterators.
std::vector::iterator inpsig_iter = fSignalEventFlags.begin();
std::vector>::iterator box_iter =
fSignalEventBoxes.begin();
std::vector>::iterator spline_iter =
fSignalEventSplines.begin();
std::vector>::iterator samsig_iter =
fSampleSignalFlags.begin();
int splinecount = 0;
// Setup stuff for logging
int fillcount = 0;
// This is just the total number of events
// int nevents = fSignalEventFlags.size();
// This is the number of events that are signal
int nevents = fSignalEventBoxes.size();
int countwidth = nevents / 10;
// If All Splines tell splines they need a reconfigure.
std::vector::iterator inp_iter = fInputList.begin();
if (fIsAllSplines) {
- QLOG(REC, "All Spline Inputs so using fast spline loop.");
+ NUIS_LOG(REC, "All Spline Inputs so using fast spline loop.");
for (; inp_iter != fInputList.end(); inp_iter++) {
InputHandlerBase *curinput = (*inp_iter);
// Tell each fSplineRead in BaseFitEvent to reconf next weight calc
BaseFitEvt *curevent = curinput->FirstBaseEvent();
if (curevent->fSplineRead)
curevent->fSplineRead->SetNeedsReconfigure(true);
}
}
// Loop over all possible spline inputs
double *coreeventweights = new double[fSignalEventBoxes.size()];
splinecount = 0;
inp_iter = fInputList.begin();
inpsig_iter = fSignalEventFlags.begin();
spline_iter = fSignalEventSplines.begin();
// Loop over all signal flags
// For each valid signal flag add one to splinecount
// Get Splines from that count and add to weight
// Add splinecount
int sigcount = 0;
// #pragma omp parallel for shared(splinecount,sigcount)
for (uint iinput = 0; iinput < fInputList.size(); iinput++) {
InputHandlerBase *curinput = fInputList[iinput];
BaseFitEvt *curevent = curinput->FirstBaseEvent();
// Loop over the events in each input
for (int i = 0; i < curinput->GetNEvents(); i++) {
double rwweight = 0.0;
// If the event is a signal event
if (fSignalEventFlags[sigcount]) {
// Get Event Info
if (!fIsAllSplines) {
if (fFillNuisanceEvent) {
curevent = curinput->GetNuisanceEvent(i);
} else {
curevent = curinput->GetBaseEvent(i);
}
} else {
curevent->fSplineCoeff = &fSignalEventSplines[splinecount][0];
}
curevent->RWWeight = FitBase::GetRW()->CalcWeight(curevent);
curevent->Weight =
curevent->RWWeight * curevent->InputWeight * curevent->CustomWeight;
rwweight = curevent->Weight;
coreeventweights[splinecount] = rwweight;
if (countwidth && ((splinecount % countwidth) == 0)) {
- QLOG(REC, curinput->GetName()
+ NUIS_LOG(REC, curinput->GetName()
<< " : Processed " << i
<< " events. W = " << curevent->Weight << std::endl);
}
// #pragma omp atomic
splinecount++;
}
// #pragma omp atomic
sigcount++;
}
}
- QLOG(SAM, "Processed event weights.");
+ NUIS_LOG(SAM, "Processed event weights.");
// #pragma omp barrier
// Reset Iterators
inpsig_iter = fSignalEventFlags.begin();
spline_iter = fSignalEventSplines.begin();
box_iter = fSignalEventBoxes.begin();
samsig_iter = fSampleSignalFlags.begin();
int nsplineweights = splinecount;
splinecount = 0;
// Start of Fast Event Loop ============================
// Start input iterators
// Loop over number of inputs
for (int ispline = 0; ispline < nsplineweights; ispline++) {
double rwweight = coreeventweights[ispline];
// Get iterators for this event
std::vector::iterator subsamsig_iter = (*samsig_iter).begin();
std::vector::iterator subbox_iter =
(*box_iter).begin();
// Loop over all sub measurements.
std::vector::iterator meas_iter = fSubSampleList.begin();
for (; meas_iter != fSubSampleList.end(); meas_iter++, subsamsig_iter++) {
MeasurementBase *curmeas = (*meas_iter);
// If event flagged as signal for this sample fill from the box.
if (*subsamsig_iter) {
curmeas->SetSignal(true);
curmeas->FillHistogramsFromBox((*subbox_iter), rwweight);
// Move onto next box if there is one.
subbox_iter++;
fillcount++;
}
}
if (ispline % countwidth == 0) {
- QLOG(REC, "Filled " << ispline << " sample weights.");
+ NUIS_LOG(REC, "Filled " << ispline << " sample weights.");
}
// Iterate over the main signal event containers.
samsig_iter++;
box_iter++;
spline_iter++;
splinecount++;
}
// End of Fast Event Loop ===================
- QLOG(SAM, "Filled sample distributions.");
+ NUIS_LOG(SAM, "Filled sample distributions.");
// Now loop over all Measurements
// Convert Binned events
iterSam = fSamples.begin();
for (; iterSam != fSamples.end(); iterSam++) {
MeasurementBase *exp = (*iterSam);
exp->ConvertEventRates();
}
// Cleanup coreeventweights
delete coreeventweights;
// Print some reconfigure profiling.
- QLOG(REC, "Filled " << fillcount << " signal events.");
- QLOG(REC,
+ NUIS_LOG(REC, "Filled " << fillcount << " signal events.");
+ NUIS_LOG(REC,
"Time taken ReconfigureFastUsingManager() : " << time(NULL) - timestart);
}
//***************************************************
void JointFCN::Write() {
//***************************************************
// Save a likelihood/ndof plot
- QLOG(MIN, "Writing likelihood plot...");
+ NUIS_LOG(MIN, "Writing likelihood plot...");
std::vector likes;
std::vector ndofs;
std::vector names;
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
double like = exp->GetLikelihood();
double ndof = exp->GetNDOF();
std::string name = exp->GetName();
likes.push_back(like);
ndofs.push_back(ndof);
names.push_back(name);
}
if (likes.size()) {
TH1D likehist = TH1D("likelihood_hist", "likelihood_hist", likes.size(),
0.0, double(likes.size()));
TH1D ndofhist =
TH1D("ndof_hist", "ndof_hist", ndofs.size(), 0.0, double(ndofs.size()));
TH1D divhist = TH1D("likedivndof_hist", "likedivndof_hist", likes.size(),
0.0, double(likes.size()));
for (int i = 0; i < likehist.GetNbinsX(); i++) {
likehist.SetBinContent(i + 1, likes[i]);
ndofhist.SetBinContent(i + 1, ndofs[i]);
if (ndofs[i] != 0.0) {
divhist.SetBinContent(i + 1, likes[i] / ndofs[i]);
}
likehist.GetXaxis()->SetBinLabel(i + 1, names[i].c_str());
ndofhist.GetXaxis()->SetBinLabel(i + 1, names[i].c_str());
divhist.GetXaxis()->SetBinLabel(i + 1, names[i].c_str());
}
likehist.Write();
ndofhist.Write();
divhist.Write();
}
// Loop over individual experiments and call Write
- QLOG(MIN, "Writing each of the data classes...");
+ NUIS_LOG(MIN, "Writing each of the data classes...");
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
exp->Write();
}
// Save Pull Terms
for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) {
ParamPull *pull = *iter;
pull->Write();
}
if (FitPar::Config().GetParB("EventManager")) {
// Get list of inputs
std::map fInputs =
FitBase::EvtManager().GetInputs();
std::map::const_iterator iterInp;
for (iterInp = fInputs.begin(); iterInp != fInputs.end(); iterInp++) {
InputHandlerBase *input = (iterInp->second);
input->GetFluxHistogram()->Write();
input->GetXSecHistogram()->Write();
input->GetEventHistogram()->Write();
}
}
};
//***************************************************
void JointFCN::SetFakeData(std::string fakeinput) {
//***************************************************
- QLOG(MIN, "Setting fake data from " << fakeinput);
+ NUIS_LOG(MIN, "Setting fake data from " << fakeinput);
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
exp->SetFakeDataValues(fakeinput);
}
return;
}
//***************************************************
void JointFCN::ThrowDataToy() {
//***************************************************
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
exp->ThrowDataToy();
}
return;
}
//***************************************************
std::vector JointFCN::GetAllNames() {
//***************************************************
// Vect of all likelihoods and total
std::vector namevect;
// Loop over samples first
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
// Get Likelihoods and push to vector
namevect.push_back(exp->GetName());
}
// Loop over pulls second
for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) {
ParamPull *pull = *iter;
// Push back to vector
namevect.push_back(pull->GetName());
}
// Finally add the total
namevect.push_back("total");
return namevect;
}
//***************************************************
std::vector JointFCN::GetAllLikelihoods() {
//***************************************************
// Vect of all likelihoods and total
std::vector likevect;
double total_likelihood = 0.0;
- QLOG(MIN, "Likelihoods : ");
+ NUIS_LOG(MIN, "Likelihoods : ");
// Loop over samples first
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
// Get Likelihoods and push to vector
double singlelike = exp->GetLikelihood();
likevect.push_back(singlelike);
total_likelihood += singlelike;
// Print Out
- QLOG(MIN, "-> " << std::left << std::setw(40) << exp->GetName() << " : "
+ NUIS_LOG(MIN, "-> " << std::left << std::setw(40) << exp->GetName() << " : "
<< singlelike);
}
// Loop over pulls second
for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) {
ParamPull *pull = *iter;
// Push back to vector
double singlelike = pull->GetLikelihood();
likevect.push_back(singlelike);
total_likelihood += singlelike;
// Print Out
- QLOG(MIN, "-> " << std::left << std::setw(40) << pull->GetName() << " : "
+ NUIS_LOG(MIN, "-> " << std::left << std::setw(40) << pull->GetName() << " : "
<< singlelike);
}
// Finally add the total likelihood
likevect.push_back(total_likelihood);
return likevect;
}
//***************************************************
std::vector JointFCN::GetAllNDOF() {
//***************************************************
// Vect of all ndof and total
std::vector ndofvect;
int total_ndof = 0;
// Loop over samples first
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end();
iter++) {
MeasurementBase *exp = *iter;
// Get Likelihoods and push to vector
int singlendof = exp->GetNDOF();
ndofvect.push_back(singlendof);
total_ndof += singlendof;
}
// Loop over pulls second
for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) {
ParamPull *pull = *iter;
// Push back to vector
int singlendof = pull->GetNDOF();
ndofvect.push_back(singlendof);
total_ndof += singlendof;
}
// Finally add the total ndof
ndofvect.push_back(total_ndof);
return ndofvect;
}
diff --git a/src/FCN/MinimizerFCN.h b/src/FCN/MinimizerFCN.h
index 0114fec..c86fa75 100755
--- a/src/FCN/MinimizerFCN.h
+++ b/src/FCN/MinimizerFCN.h
@@ -1,81 +1,81 @@
#ifndef _MINIMIZER_FCN_H_
#define _MINIMIZER_FCN_H_
/*!
* \addtogroup FCN
* @{
*/
#include
#include
#include "FitLogger.h"
#include "JointFCN.h"
//! Wrapper for JointFCN to make ROOT minimization behave sensibly.
class MinimizerFCN{
public:
// Empty Construction
MinimizerFCN(){
fFCN = NULL;
}
// Construct from function
MinimizerFCN(JointFCN* f){
SetFCN(f);
};
// Destroy (Doesn't delete FCN)
~MinimizerFCN(){
};
/*
inline double Up() const
{
return 1.;
}
*/
// Set FCN
inline void SetFCN(JointFCN* f)
{
fFCN = f;
};
// Get FCN
inline JointFCN* GetFCN() const
{
return fFCN;
};
// Wrapper for jointFCN Eval
inline double DoEval(const double *x) const
{
if (!fFCN){
- QERROR(FTL,"No FCN Found in MinimizerFCN!");
- QTHROW("Exiting!");
+ NUIS_ERR(FTL,"No FCN Found in MinimizerFCN!");
+ NUIS_ABORT("Exiting!");
}
return fFCN->DoEval(x);
};
// Func Operator for vectors
inline double operator() (const std::vector & x) const
{
double* x_array = new double[x.size()];
return this->DoEval(x_array);
};
// Func Operator for arrays
inline double operator() (const double *x) const
{
return this->DoEval(x);
};
private:
JointFCN* fFCN;
};
/*! @} */
#endif // _MINIMIZER_FCN_H_
diff --git a/src/FCN/SampleList.cxx b/src/FCN/SampleList.cxx
index 176f692..ff323b7 100644
--- a/src/FCN/SampleList.cxx
+++ b/src/FCN/SampleList.cxx
@@ -1,1440 +1,1440 @@
#include "SampleList.h"
#ifndef __NO_ANL__
#include "ANL_CCQE_Evt_1DQ2_nu.h"
#include "ANL_CCQE_XSec_1DEnu_nu.h"
// ANL CC1ppip
#include "ANL_CC1ppip_Evt_1DQ2_nu.h"
#include "ANL_CC1ppip_Evt_1DcosmuStar_nu.h"
#include "ANL_CC1ppip_Evt_1DcosmuStar_nu.h"
#include "ANL_CC1ppip_Evt_1DcosthAdler_nu.h"
#include "ANL_CC1ppip_Evt_1Dphi_nu.h"
#include "ANL_CC1ppip_Evt_1Dppi_nu.h"
#include "ANL_CC1ppip_Evt_1Dthpr_nu.h"
#include "ANL_CC1ppip_XSec_1DEnu_nu.h"
#include "ANL_CC1ppip_XSec_1DQ2_nu.h"
// ANL CC1npip
#include "ANL_CC1npip_Evt_1DQ2_nu.h"
#include "ANL_CC1npip_Evt_1DcosmuStar_nu.h"
#include "ANL_CC1npip_Evt_1Dppi_nu.h"
#include "ANL_CC1npip_XSec_1DEnu_nu.h"
// ANL CC1pi0
#include "ANL_CC1pi0_Evt_1DQ2_nu.h"
#include "ANL_CC1pi0_Evt_1DcosmuStar_nu.h"
#include "ANL_CC1pi0_XSec_1DEnu_nu.h"
// ANL NC1npip (mm, exotic!)
#include "ANL_NC1npip_Evt_1Dppi_nu.h"
// ANL NC1ppim (mm, exotic!)
#include "ANL_NC1ppim_Evt_1DcosmuStar_nu.h"
#include "ANL_NC1ppim_XSec_1DEnu_nu.h"
// ANL CC2pi 1pim1pip (mm, even more exotic!)
#include "ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.h"
#include "ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.h"
#include "ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.h"
#include "ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.h"
#include "ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.h"
// ANL CC2pi 1pip1pip (mm, even more exotic!)
#include "ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.h"
#include "ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.h"
#include "ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.h"
#include "ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.h"
#include "ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.h"
// ANL CC2pi 1pip1pi0 (mm, even more exotic!)
#include "ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.h"
#include "ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.h"
#include "ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.h"
#include "ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.h"
#include "ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.h"
#endif
#ifndef __NO_ArgoNeuT__
// ArgoNeuT CC1Pi
#include "ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.h"
#include "ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.h"
#include "ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.h"
#include "ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.h"
#include "ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.h"
#include "ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.h"
#include "ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.h"
#include "ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.h"
// ArgoNeuT CC-inclusive
#include "ArgoNeuT_CCInc_XSec_1Dpmu_antinu.h"
#include "ArgoNeuT_CCInc_XSec_1Dpmu_nu.h"
#include "ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.h"
#include "ArgoNeuT_CCInc_XSec_1Dthetamu_nu.h"
#endif
#ifndef __NO_BNL__
// BNL CCQE
#include "BNL_CCQE_Evt_1DQ2_nu.h"
#include "BNL_CCQE_XSec_1DEnu_nu.h"
// BNL CC1ppip
#include "BNL_CC1ppip_Evt_1DQ2_nu.h"
#include "BNL_CC1ppip_Evt_1DQ2_nu.h"
#include "BNL_CC1ppip_Evt_1DcosthAdler_nu.h"
#include "BNL_CC1ppip_Evt_1Dphi_nu.h"
#include "BNL_CC1ppip_XSec_1DEnu_nu.h"
// BNL CC1npip
#include "BNL_CC1npip_Evt_1DQ2_nu.h"
#include "BNL_CC1npip_XSec_1DEnu_nu.h"
// BNL CC1pi0
#include "BNL_CC1pi0_Evt_1DQ2_nu.h"
#include "BNL_CC1pi0_XSec_1DEnu_nu.h"
#endif
#ifndef __NO_FNAL__
// FNAL CCQE
#include "FNAL_CCQE_Evt_1DQ2_nu.h"
// FNAL CC1ppip
#include "FNAL_CC1ppip_Evt_1DQ2_nu.h"
#include "FNAL_CC1ppip_XSec_1DEnu_nu.h"
#include "FNAL_CC1ppip_XSec_1DQ2_nu.h"
// FNAL CC1ppim
#include "FNAL_CC1ppim_XSec_1DEnu_antinu.h"
#endif
#ifndef __NO_BEBC__
// BEBC CCQE
#include "BEBC_CCQE_XSec_1DQ2_nu.h"
// BEBC CC1ppip
#include "BEBC_CC1ppip_XSec_1DEnu_nu.h"
#include "BEBC_CC1ppip_XSec_1DQ2_nu.h"
// BEBC CC1npip
#include "BEBC_CC1npip_XSec_1DEnu_nu.h"
#include "BEBC_CC1npip_XSec_1DQ2_nu.h"
// BEBC CC1pi0
#include "BEBC_CC1pi0_XSec_1DEnu_nu.h"
#include "BEBC_CC1pi0_XSec_1DQ2_nu.h"
// BEBC CC1npim
#include "BEBC_CC1npim_XSec_1DEnu_antinu.h"
#include "BEBC_CC1npim_XSec_1DQ2_antinu.h"
// BEBC CC1ppim
#include "BEBC_CC1ppim_XSec_1DEnu_antinu.h"
#include "BEBC_CC1ppim_XSec_1DQ2_antinu.h"
#endif
#ifndef __NO_GGM__
// GGM CC1ppip
#include "GGM_CC1ppip_Evt_1DQ2_nu.h"
#include "GGM_CC1ppip_XSec_1DEnu_nu.h"
#endif
#ifndef __NO_MiniBooNE__
// MiniBooNE CCQE
#include "MiniBooNE_CCQE_XSec_1DQ2_antinu.h"
#include "MiniBooNE_CCQE_XSec_1DQ2_nu.h"
#include "MiniBooNE_CCQE_XSec_2DTcos_antinu.h"
#include "MiniBooNE_CCQE_XSec_2DTcos_antinu.h"
#include "MiniBooNE_CCQE_XSec_2DTcos_nu.h"
// MiniBooNE CC1pi+ 1D
#include "MiniBooNE_CC1pip_XSec_1DEnu_nu.h"
#include "MiniBooNE_CC1pip_XSec_1DQ2_nu.h"
#include "MiniBooNE_CC1pip_XSec_1DTpi_nu.h"
#include "MiniBooNE_CC1pip_XSec_1DTu_nu.h"
// MiniBooNE CC1pi+ 2D
#include "MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.h"
#include "MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.h"
#include "MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.h"
#include "MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.h"
#include "MiniBooNE_CC1pip_XSec_2DTuEnu_nu.h"
// MiniBooNE CC1pi0
#include "MiniBooNE_CC1pi0_XSec_1DEnu_nu.h"
#include "MiniBooNE_CC1pi0_XSec_1DQ2_nu.h"
#include "MiniBooNE_CC1pi0_XSec_1DTu_nu.h"
#include "MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.h"
#include "MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.h"
#include "MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h"
#include "MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.h"
#include "MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.h"
#include "MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.h"
#include "MiniBooNE_NC1pi0_XSec_1Dppi0_nu.h"
// MiniBooNE NC1pi0
//#include "MiniBooNE_NCpi0_XSec_1Dppi0_nu.h"
// MiniBooNE NCEL
#include "MiniBooNE_NCEL_XSec_Treco_nu.h"
#endif
#ifndef __NO_MicroBooNE__
#include "MicroBooNE_CCInc_XSec_2DPcos_nu.h"
#endif
#ifndef __NO_MINERvA__
// MINERvA CCQE
#include "MINERvA_CCQE_XSec_1DQ2_antinu.h"
#include "MINERvA_CCQE_XSec_1DQ2_joint.h"
#include "MINERvA_CCQE_XSec_1DQ2_nu.h"
// MINERvA CC0pi
#include "MINERvA_CC0pi_XSec_1DEe_nue.h"
#include "MINERvA_CC0pi_XSec_1DQ2_nu_proton.h"
#include "MINERvA_CC0pi_XSec_1DQ2_nue.h"
#include "MINERvA_CC0pi_XSec_1DThetae_nue.h"
// 2018 MINERvA CC0pi STV
#include "MINERvA_CC0pinp_STV_XSec_1D_nu.h"
// 2018 MINERvA CC0pi 2D
#include "MINERvA_CC0pi_XSec_2D_nu.h"
#include "MINERvA_CC0pi_XSec_1D_2018_nu.h"
// 2018 MINERvA CC0pi 2D antinu
#include "MINERvA_CC0pi_XSec_2D_antinu.h"
// MINERvA CC1pi+
#include "MINERvA_CC1pip_XSec_1DTpi_20deg_nu.h"
#include "MINERvA_CC1pip_XSec_1DTpi_nu.h"
#include "MINERvA_CC1pip_XSec_1Dth_20deg_nu.h"
#include "MINERvA_CC1pip_XSec_1Dth_nu.h"
// 2017 data update
#include "MINERvA_CC1pip_XSec_1D_2017Update.h"
// MINERvA CCNpi+
#include "MINERvA_CCNpip_XSec_1DEnu_nu.h"
#include "MINERvA_CCNpip_XSec_1DQ2_nu.h"
#include "MINERvA_CCNpip_XSec_1DTpi_nu.h"
#include "MINERvA_CCNpip_XSec_1Dpmu_nu.h"
#include "MINERvA_CCNpip_XSec_1Dth_nu.h"
#include "MINERvA_CCNpip_XSec_1Dthmu_nu.h"
// MINERvA CC1pi0
#include "MINERvA_CC1pi0_XSec_1DEnu_antinu.h"
#include "MINERvA_CC1pi0_XSec_1DQ2_antinu.h"
#include "MINERvA_CC1pi0_XSec_1DTpi0_antinu.h"
#include "MINERvA_CC1pi0_XSec_1Dpmu_antinu.h"
#include "MINERvA_CC1pi0_XSec_1Dppi0_antinu.h"
#include "MINERvA_CC1pi0_XSec_1Dth_antinu.h"
#include "MINERvA_CC1pi0_XSec_1Dthmu_antinu.h"
// MINERvA CC1pi0 neutrino
#include "MINERvA_CC1pi0_XSec_1D_nu.h"
// MINERvA CCINC
#include "MINERvA_CCinc_XSec_1DEnu_ratio.h"
#include "MINERvA_CCinc_XSec_1Dx_ratio.h"
#include "MINERvA_CCinc_XSec_2DEavq3_nu.h"
// MINERvA CCDIS
#include "MINERvA_CCDIS_XSec_1DEnu_ratio.h"
#include "MINERvA_CCDIS_XSec_1Dx_ratio.h"
// MINERvA CCCOH pion
#include "MINERvA_CCCOHPI_XSec_1DEnu_antinu.h"
#include "MINERvA_CCCOHPI_XSec_1DEnu_antinu.h"
#include "MINERvA_CCCOHPI_XSec_1DEpi_antinu.h"
#include "MINERvA_CCCOHPI_XSec_1DQ2_antinu.h"
#include "MINERvA_CCCOHPI_XSec_1DEpi_nu.h"
#include "MINERvA_CCCOHPI_XSec_1DQ2_nu.h"
#include "MINERvA_CCCOHPI_XSec_1Dth_nu.h"
#include "MINERvA_CCCOHPI_XSec_1Dth_nu.h"
#include "MINERvA_CCCOHPI_XSec_joint.h"
#include "MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.h"
#include "MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.h"
#endif
#ifndef __NO_T2K__
// T2K CC0pi 2016
#include "T2K_CC0pi_XSec_2DPcos_nu.h"
// T2K CC-inclusive with full acceptance 2018
#include "T2K_CCinc_XSec_2DPcos_nu_nonuniform.h"
// T2K STV CC0pi 2018
#include "T2K_CC0pi_XSec_2DPcos_nu_nonuniform.h"
#include "T2K_CC0pinp_STV_XSec_1Ddpt_nu.h"
#include "T2K_CC0pinp_STV_XSec_1Ddphit_nu.h"
#include "T2K_CC0pinp_STV_XSec_1Ddat_nu.h"
#include "T2K_CC0pi1p_XSec_3DPcoscos_nu_nonuniform.h"
#include "T2K_CC0pinp_ifk_XSec_3Dinfp_nu.h"
#include "T2K_CC0pinp_ifk_XSec_3Dinfa_nu.h"
#include "T2K_CC0pinp_ifk_XSec_3Dinfip_nu.h"
// T2K CC1pi+ on CH
#include "T2K_CC1pip_CH_XSec_2Dpmucosmu_nu.h"
#include "T2K_CC1pip_CH_XSec_1Dppi_nu.h"
#include "T2K_CC1pip_CH_XSec_1Dthpi_nu.h"
#include "T2K_CC1pip_CH_XSec_1Dthmupi_nu.h"
#include "T2K_CC1pip_CH_XSec_1DQ2_nu.h"
#include "T2K_CC1pip_CH_XSec_1DAdlerPhi_nu.h"
#include "T2K_CC1pip_CH_XSec_1DCosThAdler_nu.h"
//#include "T2K_CC1pip_CH_XSec_1Dthq3pi_nu.h"
//#include "T2K_CC1pip_CH_XSec_1DWrec_nu.h"
//#include "T2K_CC1pip_CH_XSec_1Dq3_nu.h"
// T2K CC1pi+ on H2O
#include "T2K_CC1pip_H2O_XSec_1DEnuDelta_nu.h"
#include "T2K_CC1pip_H2O_XSec_1DEnuMB_nu.h"
#include "T2K_CC1pip_H2O_XSec_1Dcosmu_nu.h"
#include "T2K_CC1pip_H2O_XSec_1Dcosmupi_nu.h"
#include "T2K_CC1pip_H2O_XSec_1Dcospi_nu.h"
#include "T2K_CC1pip_H2O_XSec_1Dpmu_nu.h"
#include "T2K_CC1pip_H2O_XSec_1Dppi_nu.h"
#endif
#ifndef __NO_SciBooNE__
// SciBooNE COH studies
#include "SciBooNE_CCCOH_1TRK_1DQ2_nu.h"
#include "SciBooNE_CCCOH_1TRK_1Dpmu_nu.h"
#include "SciBooNE_CCCOH_1TRK_1Dthetamu_nu.h"
#include "SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu.h"
#include "SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu.h"
#include "SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu.h"
#include "SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu.h"
#include "SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu.h"
#include "SciBooNE_CCCOH_MuPiVA_1DQ2_nu.h"
#include "SciBooNE_CCCOH_MuPiVA_1Dpmu_nu.h"
#include "SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu.h"
#include "SciBooNE_CCCOH_MuPr_1DQ2_nu.h"
#include "SciBooNE_CCCOH_MuPr_1Dpmu_nu.h"
#include "SciBooNE_CCCOH_MuPr_1Dthetamu_nu.h"
#include "SciBooNE_CCCOH_STOPFINAL_1DQ2_nu.h"
#include "SciBooNE_CCCOH_STOP_NTrks_nu.h"
#endif
#ifndef __NO_K2K__
// K2K NC1pi0
#include "K2K_NC1pi0_Evt_1Dppi0_nu.h"
#endif
// MC Studies
#include "ExpMultDist_CCQE_XSec_1DVar_FakeStudy.h"
#include "ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h"
#include "MCStudy_CCQEHistograms.h"
#include "GenericFlux_Tester.h"
#include "GenericFlux_Vectors.h"
#include "ElectronFlux_FlatTree.h"
#include "ElectronScattering_DurhamData.h"
#include "MCStudy_KaonPreSelection.h"
#include "MCStudy_MuonValidation.h"
#include "OfficialNIWGPlots.h"
#include "T2K2017_FakeData.h"
#include "Simple_Osc.h"
#include "Smear_SVDUnfold_Propagation_Osc.h"
#include "FitWeight.h"
#include "NuisConfig.h"
#include "NuisKey.h"
#ifdef __USE_DYNSAMPLES__
#include "TRegexp.h"
#include
// linux
#include
DynamicSampleFactory::DynamicSampleFactory() : NSamples(0), NManifests(0) {
LoadPlugins();
- QLOG(FIT, "Loaded " << NSamples << " from " << NManifests
+ NUIS_LOG(FIT, "Loaded " << NSamples << " from " << NManifests
<< " shared object libraries.");
}
DynamicSampleFactory* DynamicSampleFactory::glblDSF = NULL;
DynamicSampleFactory::PluginManifest::~PluginManifest() {
for (size_t i_it = 0; i_it < Instances.size(); ++i_it) {
(*(DSF_DestroySample))(Instances[i_it]);
}
}
std::string EnsureTrailingSlash(std::string const& inp) {
if (!inp.length()) {
return "/";
}
if (inp[inp.length() - 1] == '/') {
return inp;
}
return inp + "/";
}
void DynamicSampleFactory::LoadPlugins() {
std::vector SearchDirectories;
if (Config::HasPar("dynamic_sample.path")) {
SearchDirectories =
GeneralUtils::ParseToStr(Config::GetParS("dynamic_sample.path"), ":");
}
char const* envPath = getenv("NUISANCE_DS_PATH");
if (envPath) {
std::vector envPaths = GeneralUtils::ParseToStr(envPath, ":");
for (size_t ep_it = 0; ep_it < envPaths.size(); ++ep_it) {
SearchDirectories.push_back(envPaths[ep_it]);
}
}
if (!SearchDirectories.size()) {
char const* pwdPath = getenv("PWD");
if (pwdPath) {
SearchDirectories.push_back(pwdPath);
}
}
for (size_t sp_it = 0; sp_it < SearchDirectories.size(); ++sp_it) {
std::string dirpath = EnsureTrailingSlash(SearchDirectories[sp_it]);
- QLOG(FIT, "Searching for dynamic sample manifests in: " << dirpath);
+ NUIS_LOG(FIT, "Searching for dynamic sample manifests in: " << dirpath);
Ssiz_t len = 0;
DIR* dir;
struct dirent* ent;
dir = opendir(dirpath.c_str());
if (dir != NULL) {
TRegexp matchExp("*.so", true);
while ((ent = readdir(dir)) != NULL) {
if (matchExp.Index(TString(ent->d_name), &len) != Ssiz_t(-1)) {
- QLOG(FIT, "\tFound shared object: "
+ NUIS_LOG(FIT, "\tFound shared object: "
<< ent->d_name << " checking for relevant methods...");
void* dlobj =
dlopen((dirpath + ent->d_name).c_str(), RTLD_NOW | RTLD_GLOBAL);
char const* dlerr_cstr = dlerror();
std::string dlerr;
if (dlerr_cstr) {
dlerr = dlerr_cstr;
}
if (dlerr.length()) {
- QERROR(WRN, "\tDL Load Error: " << dlerr);
+ NUIS_ERR(WRN, "\tDL Load Error: " << dlerr);
continue;
}
PluginManifest plgManif;
plgManif.dllib = dlobj;
plgManif.soloc = (dirpath + ent->d_name);
plgManif.DSF_NSamples =
reinterpret_cast(dlsym(dlobj, "DSF_NSamples"));
dlerr = "";
dlerr_cstr = dlerror();
if (dlerr_cstr) {
dlerr = dlerr_cstr;
}
if (dlerr.length()) {
- QERROR(WRN, "\tFailed to load symbol \"DSF_NSamples\" from "
+ NUIS_ERR(WRN, "\tFailed to load symbol \"DSF_NSamples\" from "
<< (dirpath + ent->d_name) << ": " << dlerr);
dlclose(dlobj);
continue;
}
plgManif.DSF_GetSampleName = reinterpret_cast(
dlsym(dlobj, "DSF_GetSampleName"));
dlerr = "";
dlerr_cstr = dlerror();
if (dlerr_cstr) {
dlerr = dlerr_cstr;
}
if (dlerr.length()) {
- QERROR(WRN, "\tFailed to load symbol \"DSF_GetSampleName\" from "
+ NUIS_ERR(WRN, "\tFailed to load symbol \"DSF_GetSampleName\" from "
<< (dirpath + ent->d_name) << ": " << dlerr);
dlclose(dlobj);
continue;
}
plgManif.DSF_GetSample = reinterpret_cast(
dlsym(dlobj, "DSF_GetSample"));
dlerr = "";
dlerr_cstr = dlerror();
if (dlerr_cstr) {
dlerr = dlerr_cstr;
}
if (dlerr.length()) {
- QERROR(WRN, "\tFailed to load symbol \"DSF_GetSample\" from "
+ NUIS_ERR(WRN, "\tFailed to load symbol \"DSF_GetSample\" from "
<< (dirpath + ent->d_name) << ": " << dlerr);
dlclose(dlobj);
continue;
}
plgManif.DSF_DestroySample = reinterpret_cast(
dlsym(dlobj, "DSF_DestroySample"));
dlerr = "";
dlerr_cstr = dlerror();
if (dlerr_cstr) {
dlerr = dlerr_cstr;
}
if (dlerr.length()) {
- QERROR(WRN, "Failed to load symbol \"DSF_DestroySample\" from "
+ NUIS_ERR(WRN, "Failed to load symbol \"DSF_DestroySample\" from "
<< (dirpath + ent->d_name) << ": " << dlerr);
dlclose(dlobj);
continue;
}
plgManif.NSamples = (*(plgManif.DSF_NSamples))();
- QLOG(FIT, "\tSuccessfully loaded dynamic sample manifest: "
+ NUIS_LOG(FIT, "\tSuccessfully loaded dynamic sample manifest: "
<< plgManif.soloc << ". Contains " << plgManif.NSamples
<< " samples.");
for (size_t smp_it = 0; smp_it < plgManif.NSamples; ++smp_it) {
char const* smp_name = (*(plgManif.DSF_GetSampleName))(smp_it);
if (!smp_name) {
- QTHROW("Could not load sample " << smp_it << " / "
+ NUIS_ABORT("Could not load sample " << smp_it << " / "
<< plgManif.NSamples << " from "
<< plgManif.soloc);
}
if (Samples.count(smp_name)) {
- QERROR(WRN, "Already loaded a sample named: \""
+ NUIS_ERR(WRN, "Already loaded a sample named: \""
<< smp_name << "\". cannot load duplciates. This "
"sample will be skipped.");
continue;
}
plgManif.SamplesProvided.push_back(smp_name);
Samples[smp_name] = std::make_pair(plgManif.soloc, smp_it);
- QLOG(FIT, "\t\t" << smp_name);
+ NUIS_LOG(FIT, "\t\t" << smp_name);
}
if (plgManif.SamplesProvided.size()) {
Manifests[plgManif.soloc] = plgManif;
NSamples += plgManif.SamplesProvided.size();
NManifests++;
} else {
dlclose(dlobj);
}
}
}
closedir(dir);
} else {
- QERROR(WRN, "Tried to open non-existant directory.");
+ NUIS_ERR(WRN, "Tried to open non-existant directory.");
}
}
}
DynamicSampleFactory& DynamicSampleFactory::Get() {
if (!glblDSF) {
glblDSF = new DynamicSampleFactory();
}
return *glblDSF;
}
void DynamicSampleFactory::Print() {
std::map > ManifestSamples;
for (std::map >::iterator smp_it =
Samples.begin();
smp_it != Samples.end(); ++smp_it) {
if (!ManifestSamples.count(smp_it->second.first)) {
ManifestSamples[smp_it->second.first] = std::vector();
}
ManifestSamples[smp_it->second.first].push_back(smp_it->first);
}
- QLOG(FIT, "Dynamic sample manifest: ");
+ NUIS_LOG(FIT, "Dynamic sample manifest: ");
for (std::map >::iterator m_it =
ManifestSamples.begin();
m_it != ManifestSamples.end(); ++m_it) {
- QLOG(FIT, "\tLibrary " << m_it->first << " contains: ");
+ NUIS_LOG(FIT, "\tLibrary " << m_it->first << " contains: ");
for (size_t s_it = 0; s_it < m_it->second.size(); ++s_it) {
- QLOG(FIT, "\t\t" << m_it->second[s_it]);
+ NUIS_LOG(FIT, "\t\t" << m_it->second[s_it]);
}
}
}
bool DynamicSampleFactory::HasSample(std::string const& name) {
return Samples.count(name);
}
bool DynamicSampleFactory::HasSample(nuiskey& samplekey) {
return HasSample(samplekey.GetS("name"));
}
MeasurementBase* DynamicSampleFactory::CreateSample(nuiskey& samplekey) {
if (!HasSample(samplekey)) {
- QERROR(WRN, "Asked to load unknown sample: \"" << samplekey.GetS("name")
+ NUIS_ERR(WRN, "Asked to load unknown sample: \"" << samplekey.GetS("name")
<< "\".");
return NULL;
}
std::pair sample = Samples[samplekey.GetS("name")];
- QLOG(SAM, "\tLoading sample " << sample.second << " from " << sample.first);
+ NUIS_LOG(SAM, "\tLoading sample " << sample.second << " from " << sample.first);
return (*(Manifests[sample.first].DSF_GetSample))(sample.second, &samplekey);
}
DynamicSampleFactory::~DynamicSampleFactory() { Manifests.clear(); }
#endif
//! Functions to make it easier for samples to be created and handled.
namespace SampleUtils {
//! Create a given sample given its name, file, type, fakdata(fkdt) file and the
//! current rw engine and push it back into the list fChain.
MeasurementBase* CreateSample(std::string name, std::string file,
std::string type, std::string fkdt,
FitWeight* rw) {
nuiskey samplekey = Config::CreateKey("sample");
samplekey.Set("name", name);
samplekey.Set("input", file);
samplekey.Set("type", type);
return CreateSample(samplekey);
}
MeasurementBase* CreateSample(nuiskey samplekey) {
#ifdef __USE_DYNSAMPLES__
if (DynamicSampleFactory::Get().HasSample(samplekey)) {
- QLOG(SAM, "Instantiating dynamic sample...");
+ NUIS_LOG(SAM, "Instantiating dynamic sample...");
MeasurementBase* ds = DynamicSampleFactory::Get().CreateSample(samplekey);
if (ds) {
- QLOG(SAM, "Done.");
+ NUIS_LOG(SAM, "Done.");
return ds;
}
- QTHROW("Failed to instantiate dynamic sample.");
+ NUIS_ABORT("Failed to instantiate dynamic sample.");
}
#endif
FitWeight* rw = FitBase::GetRW();
std::string name = samplekey.GetS("name");
std::string file = samplekey.GetS("input");
std::string type = samplekey.GetS("type");
std::string fkdt = "";
/*
ANL CCQE Samples
*/
#ifndef __NO_ANL__
if (!name.compare("ANL_CCQE_XSec_1DEnu_nu") ||
!name.compare("ANL_CCQE_XSec_1DEnu_nu_PRD26") ||
!name.compare("ANL_CCQE_XSec_1DEnu_nu_PRL31") ||
!name.compare("ANL_CCQE_XSec_1DEnu_nu_PRD16")) {
return (new ANL_CCQE_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("ANL_CCQE_Evt_1DQ2_nu") ||
!name.compare("ANL_CCQE_Evt_1DQ2_nu_PRL31") ||
!name.compare("ANL_CCQE_Evt_1DQ2_nu_PRD26") ||
!name.compare("ANL_CCQE_Evt_1DQ2_nu_PRD16")) {
return (new ANL_CCQE_Evt_1DQ2_nu(samplekey));
/*
ANL CC1ppip samples
*/
} else if (!name.compare("ANL_CC1ppip_XSec_1DEnu_nu") ||
!name.compare("ANL_CC1ppip_XSec_1DEnu_nu_W14Cut") ||
!name.compare("ANL_CC1ppip_XSec_1DEnu_nu_Uncorr") ||
!name.compare("ANL_CC1ppip_XSec_1DEnu_nu_W14Cut_Uncorr") ||
!name.compare("ANL_CC1ppip_XSec_1DEnu_nu_W16Cut_Uncorr")) {
return (new ANL_CC1ppip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("ANL_CC1ppip_XSec_1DQ2_nu")) {
return (new ANL_CC1ppip_XSec_1DQ2_nu(samplekey));
} else if (!name.compare("ANL_CC1ppip_Evt_1DQ2_nu") ||
!name.compare("ANL_CC1ppip_Evt_1DQ2_nu_W14Cut")) {
return (new ANL_CC1ppip_Evt_1DQ2_nu(samplekey));
} else if (!name.compare("ANL_CC1ppip_Evt_1Dppi_nu")) {
return (new ANL_CC1ppip_Evt_1Dppi_nu(samplekey));
} else if (!name.compare("ANL_CC1ppip_Evt_1Dthpr_nu")) {
return (new ANL_CC1ppip_Evt_1Dthpr_nu(samplekey));
} else if (!name.compare("ANL_CC1ppip_Evt_1DcosmuStar_nu")) {
return (new ANL_CC1ppip_Evt_1DcosmuStar_nu(samplekey));
} else if (!name.compare("ANL_CC1ppip_Evt_1DcosthAdler_nu")) {
return (new ANL_CC1ppip_Evt_1DcosthAdler_nu(samplekey));
} else if (!name.compare("ANL_CC1ppip_Evt_1Dphi_nu")) {
return (new ANL_CC1ppip_Evt_1Dphi_nu(samplekey));
/*
ANL CC1npip sample
*/
} else if (!name.compare("ANL_CC1npip_XSec_1DEnu_nu") ||
!name.compare("ANL_CC1npip_XSec_1DEnu_nu_W14Cut") ||
!name.compare("ANL_CC1npip_XSec_1DEnu_nu_Uncorr") ||
!name.compare("ANL_CC1npip_XSec_1DEnu_nu_W14Cut_Uncorr") ||
!name.compare("ANL_CC1npip_XSec_1DEnu_nu_W16Cut_Uncorr")) {
return (new ANL_CC1npip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("ANL_CC1npip_Evt_1DQ2_nu") ||
!name.compare("ANL_CC1npip_Evt_1DQ2_nu_W14Cut")) {
return (new ANL_CC1npip_Evt_1DQ2_nu(samplekey));
} else if (!name.compare("ANL_CC1npip_Evt_1Dppi_nu")) {
return (new ANL_CC1npip_Evt_1Dppi_nu(samplekey));
} else if (!name.compare("ANL_CC1npip_Evt_1DcosmuStar_nu")) {
return (new ANL_CC1npip_Evt_1DcosmuStar_nu(samplekey));
/*
ANL CC1pi0 sample
*/
} else if (!name.compare("ANL_CC1pi0_XSec_1DEnu_nu") ||
!name.compare("ANL_CC1pi0_XSec_1DEnu_nu_W14Cut") ||
!name.compare("ANL_CC1pi0_XSec_1DEnu_nu_Uncorr") ||
!name.compare("ANL_CC1pi0_XSec_1DEnu_nu_W14Cut_Uncorr") ||
!name.compare("ANL_CC1pi0_XSec_1DEnu_nu_W16Cut_Uncorr")) {
return (new ANL_CC1pi0_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("ANL_CC1pi0_Evt_1DQ2_nu") ||
!name.compare("ANL_CC1pi0_Evt_1DQ2_nu_W14Cut")) {
return (new ANL_CC1pi0_Evt_1DQ2_nu(samplekey));
} else if (!name.compare("ANL_CC1pi0_Evt_1DcosmuStar_nu")) {
return (new ANL_CC1pi0_Evt_1DcosmuStar_nu(samplekey));
/*
ANL NC1npip sample
*/
} else if (!name.compare("ANL_NC1npip_Evt_1Dppi_nu")) {
return (new ANL_NC1npip_Evt_1Dppi_nu(samplekey));
/*
ANL NC1ppim sample
*/
} else if (!name.compare("ANL_NC1ppim_XSec_1DEnu_nu")) {
return (new ANL_NC1ppim_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("ANL_NC1ppim_Evt_1DcosmuStar_nu")) {
return (new ANL_NC1ppim_Evt_1DcosmuStar_nu(samplekey));
/*
ANL CC2pi sample
*/
} else if (!name.compare("ANL_CC2pi_1pim1pip_XSec_1DEnu_nu")) {
return (new ANL_CC2pi_1pim1pip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu")) {
return (new ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dppip_nu")) {
return (new ANL_CC2pi_1pim1pip_Evt_1Dppip_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dppim_nu")) {
return (new ANL_CC2pi_1pim1pip_Evt_1Dppim_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu")) {
return (new ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pip1pip_XSec_1DEnu_nu")) {
return (new ANL_CC2pi_1pip1pip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu")) {
return (new ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu")) {
return (new ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu")) {
return (new ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu")) {
return (new ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu")) {
return (new ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu")) {
return (new ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu")) {
return (new ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu")) {
return (new ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu(samplekey));
} else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu")) {
return (new ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu(samplekey));
/*
ArgoNeut Samples
*/
} else
#endif
#ifndef __NO_ArgoNeuT__
if (!name.compare("ArgoNeuT_CCInc_XSec_1Dpmu_antinu")) {
return (new ArgoNeuT_CCInc_XSec_1Dpmu_antinu(samplekey));
} else if (!name.compare("ArgoNeuT_CCInc_XSec_1Dpmu_nu")) {
return (new ArgoNeuT_CCInc_XSec_1Dpmu_nu(samplekey));
} else if (!name.compare("ArgoNeuT_CCInc_XSec_1Dthetamu_antinu")) {
return (new ArgoNeuT_CCInc_XSec_1Dthetamu_antinu(samplekey));
} else if (!name.compare("ArgoNeuT_CCInc_XSec_1Dthetamu_nu")) {
return (new ArgoNeuT_CCInc_XSec_1Dthetamu_nu(samplekey));
} else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dpmu_nu")) {
return (new ArgoNeuT_CC1Pi_XSec_1Dpmu_nu(samplekey));
} else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu")) {
return (new ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu(samplekey));
} else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu")) {
return (new ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu(samplekey));
} else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu")) {
return (new ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu(samplekey));
} else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu")) {
return (new ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu(samplekey));
} else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu")) {
return (new ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu(samplekey));
} else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu")) {
return (new ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu(samplekey));
} else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu")) {
return (new ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu(samplekey));
/*
BNL Samples
*/
} else
#endif
#ifndef __NO_BNL__
if (!name.compare("BNL_CCQE_XSec_1DEnu_nu")) {
return (new BNL_CCQE_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("BNL_CCQE_Evt_1DQ2_nu")) {
return (new BNL_CCQE_Evt_1DQ2_nu(samplekey));
/*
BNL CC1ppip samples
*/
} else if (!name.compare("BNL_CC1ppip_XSec_1DEnu_nu") ||
!name.compare("BNL_CC1ppip_XSec_1DEnu_nu_Uncorr") ||
!name.compare("BNL_CC1ppip_XSec_1DEnu_nu_W14Cut") ||
!name.compare("BNL_CC1ppip_XSec_1DEnu_nu_W14Cut_Uncorr")) {
return (new BNL_CC1ppip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("BNL_CC1ppip_Evt_1DQ2_nu") ||
!name.compare("BNL_CC1ppip_Evt_1DQ2_nu_W14Cut")) {
return (new BNL_CC1ppip_Evt_1DQ2_nu(samplekey));
} else if (!name.compare("BNL_CC1ppip_Evt_1DcosthAdler_nu")) {
return (new BNL_CC1ppip_Evt_1DcosthAdler_nu(samplekey));
} else if (!name.compare("BNL_CC1ppip_Evt_1Dphi_nu")) {
return (new BNL_CC1ppip_Evt_1Dphi_nu(samplekey));
/*
BNL CC1npip samples
*/
} else if (!name.compare("BNL_CC1npip_XSec_1DEnu_nu") ||
!name.compare("BNL_CC1npip_XSec_1DEnu_nu_Uncorr")) {
return (new BNL_CC1npip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("BNL_CC1npip_Evt_1DQ2_nu")) {
return (new BNL_CC1npip_Evt_1DQ2_nu(samplekey));
/*
BNL CC1pi0 samples
*/
} else if (!name.compare("BNL_CC1pi0_XSec_1DEnu_nu")) {
return (new BNL_CC1pi0_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("BNL_CC1pi0_Evt_1DQ2_nu")) {
return (new BNL_CC1pi0_Evt_1DQ2_nu(samplekey));
/*
FNAL Samples
*/
} else
#endif
#ifndef __NO_FNAL__
if (!name.compare("FNAL_CCQE_Evt_1DQ2_nu")) {
return (new FNAL_CCQE_Evt_1DQ2_nu(samplekey));
/*
FNAL CC1ppip
*/
} else if (!name.compare("FNAL_CC1ppip_XSec_1DEnu_nu")) {
return (new FNAL_CC1ppip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("FNAL_CC1ppip_XSec_1DQ2_nu")) {
return (new FNAL_CC1ppip_XSec_1DQ2_nu(samplekey));
} else if (!name.compare("FNAL_CC1ppip_Evt_1DQ2_nu")) {
return (new FNAL_CC1ppip_Evt_1DQ2_nu(samplekey));
/*
FNAL CC1ppim
*/
} else if (!name.compare("FNAL_CC1ppim_XSec_1DEnu_antinu")) {
return (new FNAL_CC1ppim_XSec_1DEnu_antinu(samplekey));
/*
BEBC Samples
*/
} else
#endif
#ifndef __NO_BEBC__
if (!name.compare("BEBC_CCQE_XSec_1DQ2_nu")) {
return (new BEBC_CCQE_XSec_1DQ2_nu(samplekey));
/*
BEBC CC1ppip samples
*/
} else if (!name.compare("BEBC_CC1ppip_XSec_1DEnu_nu")) {
return (new BEBC_CC1ppip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("BEBC_CC1ppip_XSec_1DQ2_nu")) {
return (new BEBC_CC1ppip_XSec_1DQ2_nu(samplekey));
/*
BEBC CC1npip samples
*/
} else if (!name.compare("BEBC_CC1npip_XSec_1DEnu_nu")) {
return (new BEBC_CC1npip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("BEBC_CC1npip_XSec_1DQ2_nu")) {
return (new BEBC_CC1npip_XSec_1DQ2_nu(samplekey));
/*
BEBC CC1pi0 samples
*/
} else if (!name.compare("BEBC_CC1pi0_XSec_1DEnu_nu")) {
return (new BEBC_CC1pi0_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("BEBC_CC1pi0_XSec_1DQ2_nu")) {
return (new BEBC_CC1pi0_XSec_1DQ2_nu(samplekey));
/*
BEBC CC1npim samples
*/
} else if (!name.compare("BEBC_CC1npim_XSec_1DEnu_antinu")) {
return (new BEBC_CC1npim_XSec_1DEnu_antinu(samplekey));
} else if (!name.compare("BEBC_CC1npim_XSec_1DQ2_antinu")) {
return (new BEBC_CC1npim_XSec_1DQ2_antinu(samplekey));
/*
BEBC CC1ppim samples
*/
} else if (!name.compare("BEBC_CC1ppim_XSec_1DEnu_antinu")) {
return (new BEBC_CC1ppim_XSec_1DEnu_antinu(samplekey));
} else if (!name.compare("BEBC_CC1ppim_XSec_1DQ2_antinu")) {
return (new BEBC_CC1ppim_XSec_1DQ2_antinu(samplekey));
/*
GGM CC1ppip samples
*/
} else
#endif
#ifndef __NO_GGM__
if (!name.compare("GGM_CC1ppip_XSec_1DEnu_nu")) {
return (new GGM_CC1ppip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("GGM_CC1ppip_Evt_1DQ2_nu")) {
return (new GGM_CC1ppip_Evt_1DQ2_nu(samplekey));
/*
MiniBooNE Samples
*/
/*
CCQE
*/
} else
#endif
#ifndef __NO_MiniBooNE__
if (!name.compare("MiniBooNE_CCQE_XSec_1DQ2_nu") ||
!name.compare("MiniBooNE_CCQELike_XSec_1DQ2_nu")) {
return (new MiniBooNE_CCQE_XSec_1DQ2_nu(samplekey));
} else if (!name.compare("MiniBooNE_CCQE_XSec_1DQ2_antinu") ||
!name.compare("MiniBooNE_CCQELike_XSec_1DQ2_antinu") ||
!name.compare("MiniBooNE_CCQE_CTarg_XSec_1DQ2_antinu")) {
return (new MiniBooNE_CCQE_XSec_1DQ2_antinu(samplekey));
} else if (!name.compare("MiniBooNE_CCQE_XSec_2DTcos_nu") ||
!name.compare("MiniBooNE_CCQELike_XSec_2DTcos_nu")) {
return (new MiniBooNE_CCQE_XSec_2DTcos_nu(samplekey));
} else if (!name.compare("MiniBooNE_CCQE_XSec_2DTcos_antinu") ||
!name.compare("MiniBooNE_CCQELike_XSec_2DTcos_antinu")) {
return (new MiniBooNE_CCQE_XSec_2DTcos_antinu(samplekey));
/*
MiniBooNE CC1pi+
*/
// 1D
} else if (!name.compare("MiniBooNE_CC1pip_XSec_1DEnu_nu")) {
return (new MiniBooNE_CC1pip_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pip_XSec_1DQ2_nu")) {
return (new MiniBooNE_CC1pip_XSec_1DQ2_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pip_XSec_1DTpi_nu")) {
return (new MiniBooNE_CC1pip_XSec_1DTpi_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pip_XSec_1DTu_nu")) {
return (new MiniBooNE_CC1pip_XSec_1DTu_nu(samplekey));
// 2D
} else if (!name.compare("MiniBooNE_CC1pip_XSec_2DQ2Enu_nu")) {
return (new MiniBooNE_CC1pip_XSec_2DQ2Enu_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTpiCospi_nu")) {
return (new MiniBooNE_CC1pip_XSec_2DTpiCospi_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTpiEnu_nu")) {
return (new MiniBooNE_CC1pip_XSec_2DTpiEnu_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTuCosmu_nu")) {
return (new MiniBooNE_CC1pip_XSec_2DTuCosmu_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTuEnu_nu")) {
return (new MiniBooNE_CC1pip_XSec_2DTuEnu_nu(samplekey));
/*
MiniBooNE CC1pi0
*/
} else if (!name.compare("MiniBooNE_CC1pi0_XSec_1DEnu_nu")) {
return (new MiniBooNE_CC1pi0_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pi0_XSec_1DQ2_nu")) {
return (new MiniBooNE_CC1pi0_XSec_1DQ2_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pi0_XSec_1DTu_nu")) {
return (new MiniBooNE_CC1pi0_XSec_1DTu_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pi0_XSec_1Dcosmu_nu")) {
return (new MiniBooNE_CC1pi0_XSec_1Dcosmu_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pi0_XSec_1Dcospi0_nu")) {
return (new MiniBooNE_CC1pi0_XSec_1Dcospi0_nu(samplekey));
} else if (!name.compare("MiniBooNE_CC1pi0_XSec_1Dppi0_nu")) {
return (new MiniBooNE_CC1pi0_XSec_1Dppi0_nu(samplekey));
} else if (!name.compare("MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu") ||
!name.compare("MiniBooNE_NC1pi0_XSec_1Dcospi0_rhc")) {
return (new MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu(samplekey));
} else if (!name.compare("MiniBooNE_NC1pi0_XSec_1Dcospi0_nu") ||
!name.compare("MiniBooNE_NC1pi0_XSec_1Dcospi0_fhc")) {
return (new MiniBooNE_NC1pi0_XSec_1Dcospi0_nu(samplekey));
} else if (!name.compare("MiniBooNE_NC1pi0_XSec_1Dppi0_antinu") ||
!name.compare("MiniBooNE_NC1pi0_XSec_1Dppi0_rhc")) {
return (new MiniBooNE_NC1pi0_XSec_1Dppi0_antinu(samplekey));
} else if (!name.compare("MiniBooNE_NC1pi0_XSec_1Dppi0_nu") ||
!name.compare("MiniBooNE_NC1pi0_XSec_1Dppi0_fhc")) {
return (new MiniBooNE_NC1pi0_XSec_1Dppi0_nu(samplekey));
/*
MiniBooNE NCEL
*/
} else if (!name.compare("MiniBooNE_NCEL_XSec_Treco_nu")) {
return (new MiniBooNE_NCEL_XSec_Treco_nu(samplekey));
} else
#endif
#ifndef __NO_MicroBooNE__
/*
MicroBooNE Samples
*/
/*
MicroBooNE CCinclusive
*/
if (!name.compare("MicroBooNE_CCInc_XSec_2DPcos_nu")) {
return (new MicroBooNE_CCInc_XSec_2DPcos_nu(samplekey));
} else
#endif
#ifndef __NO_MINERvA__
/*
MINERvA Samples
*/
if (!name.compare("MINERvA_CCQE_XSec_1DQ2_nu") ||
!name.compare("MINERvA_CCQE_XSec_1DQ2_nu_20deg") ||
!name.compare("MINERvA_CCQE_XSec_1DQ2_nu_oldflux") ||
!name.compare("MINERvA_CCQE_XSec_1DQ2_nu_20deg_oldflux")) {
return (new MINERvA_CCQE_XSec_1DQ2_nu(samplekey));
} else if (!name.compare("MINERvA_CCQE_XSec_1DQ2_antinu") ||
!name.compare("MINERvA_CCQE_XSec_1DQ2_antinu_20deg") ||
!name.compare("MINERvA_CCQE_XSec_1DQ2_antinu_oldflux") ||
!name.compare("MINERvA_CCQE_XSec_1DQ2_antinu_20deg_oldflux")) {
return (new MINERvA_CCQE_XSec_1DQ2_antinu(samplekey));
} else if (!name.compare("MINERvA_CCQE_XSec_1DQ2_joint_oldflux") ||
!name.compare("MINERvA_CCQE_XSec_1DQ2_joint_20deg_oldflux") ||
!name.compare("MINERvA_CCQE_XSec_1DQ2_joint") ||
!name.compare("MINERvA_CCQE_XSec_1DQ2_joint_20deg")) {
return (new MINERvA_CCQE_XSec_1DQ2_joint(samplekey));
} else if (!name.compare("MINERvA_CC0pi_XSec_1DEe_nue")) {
return (new MINERvA_CC0pi_XSec_1DEe_nue(samplekey));
} else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2_nue")) {
return (new MINERvA_CC0pi_XSec_1DQ2_nue(samplekey));
} else if (!name.compare("MINERvA_CC0pi_XSec_1DThetae_nue")) {
return (new MINERvA_CC0pi_XSec_1DThetae_nue(samplekey));
} else if (!name.compare("MINERvA_CC0pinp_STV_XSec_1Dpmu_nu") ||
!name.compare("MINERvA_CC0pinp_STV_XSec_1Dthmu_nu") ||
!name.compare("MINERvA_CC0pinp_STV_XSec_1Dpprot_nu") ||
!name.compare("MINERvA_CC0pinp_STV_XSec_1Dthprot_nu") ||
!name.compare("MINERvA_CC0pinp_STV_XSec_1Dpnreco_nu") ||
!name.compare("MINERvA_CC0pinp_STV_XSec_1Ddalphat_nu") ||
!name.compare("MINERvA_CC0pinp_STV_XSec_1Ddpt_nu") ||
!name.compare("MINERvA_CC0pinp_STV_XSec_1Ddphit_nu")) {
return (new MINERvA_CC0pinp_STV_XSec_1D_nu(samplekey));
} else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2_nu_proton")) {
return (new MINERvA_CC0pi_XSec_1DQ2_nu_proton(samplekey));
} else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtC_nu") ||
!name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtCH_nu") ||
!name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtFe_nu") ||
!name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtPb_nu")) {
return (new MINERvA_CC0pi_XSec_1DQ2_Tgt_nu(samplekey));
} else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtRatioC_nu") ||
!name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtRatioFe_nu") ||
!name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtRatioPb_nu")) {
return (new MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu(samplekey));
// Dan Ruterbories measurements of late 2018
} else if ( !name.compare("MINERvA_CC0pi_XSec_2Dptpz_nu")) {
return (new MINERvA_CC0pi_XSec_2D_nu(samplekey));
} else if ( !name.compare("MINERvA_CC0pi_XSec_1Dpt_nu") ||
!name.compare("MINERvA_CC0pi_XSec_1Dpz_nu") ||
!name.compare("MINERvA_CC0pi_XSec_1DQ2QE_nu") ||
!name.compare("MINERvA_CC0pi_XSec_1DEnuQE_nu")) {
return (new MINERvA_CC0pi_XSec_1D_2018_nu(samplekey));
// C. Patrick's early 2018 measurements
} else if ( !name.compare("MINERvA_CC0pi_XSec_2Dptpz_antinu") ||
!name.compare("MINERvA_CC0pi_XSec_2DQ2QEEnuQE_antinu") ||
!name.compare("MINERvA_CC0pi_XSec_2DQ2QEEnuTrue_antinu")) {
return (new MINERvA_CC0pi_XSec_2D_antinu(samplekey));
/*
CC1pi+
*/
// DONE
} else if (!name.compare("MINERvA_CC1pip_XSec_1DTpi_nu") ||
!name.compare("MINERvA_CC1pip_XSec_1DTpi_nu_20deg") ||
!name.compare("MINERvA_CC1pip_XSec_1DTpi_nu_fluxcorr") ||
!name.compare("MINERvA_CC1pip_XSec_1DTpi_nu_20deg_fluxcorr")) {
return (new MINERvA_CC1pip_XSec_1DTpi_nu(samplekey));
// DONE
} else if (!name.compare("MINERvA_CC1pip_XSec_1Dth_nu") ||
!name.compare("MINERvA_CC1pip_XSec_1Dth_nu_20deg") ||
!name.compare("MINERvA_CC1pip_XSec_1Dth_nu_fluxcorr") ||
!name.compare("MINERvA_CC1pip_XSec_1Dth_nu_20deg_fluxcorr")) {
return (new MINERvA_CC1pip_XSec_1Dth_nu(samplekey));
} else if (!name.compare("MINERvA_CC1pip_XSec_1DTpi_nu_2017") ||
!name.compare("MINERvA_CC1pip_XSec_1Dth_nu_2017") ||
!name.compare("MINERvA_CC1pip_XSec_1Dpmu_nu_2017") ||
!name.compare("MINERvA_CC1pip_XSec_1Dthmu_nu_2017") ||
!name.compare("MINERvA_CC1pip_XSec_1DQ2_nu_2017") ||
!name.compare("MINERvA_CC1pip_XSec_1DEnu_nu_2017")) {
return (new MINERvA_CC1pip_XSec_1D_2017Update(samplekey));
/*
CCNpi+
*/
} else if (!name.compare("MINERvA_CCNpip_XSec_1Dth_nu") ||
!name.compare("MINERvA_CCNpip_XSec_1Dth_nu_2015") ||
!name.compare("MINERvA_CCNpip_XSec_1Dth_nu_2016") ||
!name.compare("MINERvA_CCNpip_XSec_1Dth_nu_2015_20deg") ||
!name.compare("MINERvA_CCNpip_XSec_1Dth_nu_2015_fluxcorr") ||
!name.compare("MINERvA_CCNpip_XSec_1Dth_nu_2015_20deg_fluxcorr")) {
return (new MINERvA_CCNpip_XSec_1Dth_nu(samplekey));
} else if (!name.compare("MINERvA_CCNpip_XSec_1DTpi_nu") ||
!name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_2015") ||
!name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_2016") ||
!name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_2015_20deg") ||
!name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_2015_fluxcorr") ||
!name.compare(
"MINERvA_CCNpip_XSec_1DTpi_nu_2015_20deg_fluxcorr")) {
return (new MINERvA_CCNpip_XSec_1DTpi_nu(samplekey));
} else if (!name.compare("MINERvA_CCNpip_XSec_1Dthmu_nu")) {
return (new MINERvA_CCNpip_XSec_1Dthmu_nu(samplekey));
} else if (!name.compare("MINERvA_CCNpip_XSec_1Dpmu_nu")) {
return (new MINERvA_CCNpip_XSec_1Dpmu_nu(samplekey));
} else if (!name.compare("MINERvA_CCNpip_XSec_1DQ2_nu")) {
return (new MINERvA_CCNpip_XSec_1DQ2_nu(samplekey));
} else if (!name.compare("MINERvA_CCNpip_XSec_1DEnu_nu")) {
return (new MINERvA_CCNpip_XSec_1DEnu_nu(samplekey));
/*
MINERvA CC1pi0 anti-nu
*/
// Done
} else if (!name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu") ||
!name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu_2015") ||
!name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu_2016") ||
!name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu_fluxcorr") ||
!name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu_2015_fluxcorr") ||
!name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu_2016_fluxcorr")) {
return (new MINERvA_CC1pi0_XSec_1Dth_antinu(samplekey));
} else if (!name.compare("MINERvA_CC1pi0_XSec_1Dppi0_antinu") ||
!name.compare("MINERvA_CC1pi0_XSec_1Dppi0_antinu_fluxcorr")) {
return (new MINERvA_CC1pi0_XSec_1Dppi0_antinu(samplekey));
} else if (!name.compare("MINERvA_CC1pi0_XSec_1DTpi0_antinu")) {
return (new MINERvA_CC1pi0_XSec_1DTpi0_antinu(samplekey));
// Done
} else if (!name.compare("MINERvA_CC1pi0_XSec_1DQ2_antinu")) {
return (new MINERvA_CC1pi0_XSec_1DQ2_antinu(samplekey));
// Done
} else if (!name.compare("MINERvA_CC1pi0_XSec_1Dthmu_antinu")) {
return (new MINERvA_CC1pi0_XSec_1Dthmu_antinu(samplekey));
// Done
} else if (!name.compare("MINERvA_CC1pi0_XSec_1Dpmu_antinu")) {
return (new MINERvA_CC1pi0_XSec_1Dpmu_antinu(samplekey));
// Done
} else if (!name.compare("MINERvA_CC1pi0_XSec_1DEnu_antinu")) {
return (new MINERvA_CC1pi0_XSec_1DEnu_antinu(samplekey));
// MINERvA CC1pi0 nu
} else if (!name.compare("MINERvA_CC1pi0_XSec_1DTpi_nu") ||
!name.compare("MINERvA_CC1pi0_XSec_1Dth_nu") ||
!name.compare("MINERvA_CC1pi0_XSec_1Dpmu_nu") ||
!name.compare("MINERvA_CC1pi0_XSec_1Dthmu_nu") ||
!name.compare("MINERvA_CC1pi0_XSec_1DQ2_nu") ||
!name.compare("MINERvA_CC1pi0_XSec_1DEnu_nu") ||
!name.compare("MINERvA_CC1pi0_XSec_1DWexp_nu") ||
!name.compare("MINERvA_CC1pi0_XSec_1DPPi0Mass_nu") ||
!name.compare("MINERvA_CC1pi0_XSec_1DPPi0MassDelta_nu") ||
!name.compare("MINERvA_CC1pi0_XSec_1DCosAdler_nu") ||
!name.compare("MINERvA_CC1pi0_XSec_1DPhiAdler_nu")) {
return (new MINERvA_CC1pi0_XSec_1D_nu(samplekey));
/*
CCINC
*/
} else if (!name.compare("MINERvA_CCinc_XSec_2DEavq3_nu")) {
return (new MINERvA_CCinc_XSec_2DEavq3_nu(samplekey));
} else if (!name.compare("MINERvA_CCinc_XSec_1Dx_ratio_C12_CH") ||
!name.compare("MINERvA_CCinc_XSec_1Dx_ratio_Fe56_CH") ||
!name.compare("MINERvA_CCinc_XSec_1Dx_ratio_Pb208_CH")) {
return (new MINERvA_CCinc_XSec_1Dx_ratio(samplekey));
} else if (!name.compare("MINERvA_CCinc_XSec_1DEnu_ratio_C12_CH") ||
!name.compare("MINERvA_CCinc_XSec_1DEnu_ratio_Fe56_CH") ||
!name.compare("MINERvA_CCinc_XSec_1DEnu_ratio_Pb208_CH")) {
return (new MINERvA_CCinc_XSec_1DEnu_ratio(samplekey));
/*
CCDIS
*/
} else if (!name.compare("MINERvA_CCDIS_XSec_1Dx_ratio_C12_CH") ||
!name.compare("MINERvA_CCDIS_XSec_1Dx_ratio_Fe56_CH") ||
!name.compare("MINERvA_CCDIS_XSec_1Dx_ratio_Pb208_CH")) {
return (new MINERvA_CCDIS_XSec_1Dx_ratio(samplekey));
} else if (!name.compare("MINERvA_CCDIS_XSec_1DEnu_ratio_C12_CH") ||
!name.compare("MINERvA_CCDIS_XSec_1DEnu_ratio_Fe56_CH") ||
!name.compare("MINERvA_CCDIS_XSec_1DEnu_ratio_Pb208_CH")) {
return (new MINERvA_CCDIS_XSec_1DEnu_ratio(samplekey));
/*
CC-COH
*/
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEnu_nu")) {
return (new MINERvA_CCCOHPI_XSec_1DEnu_nu(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEpi_nu")) {
return (new MINERvA_CCCOHPI_XSec_1DEpi_nu(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1Dth_nu")) {
return (new MINERvA_CCCOHPI_XSec_1Dth_nu(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1DQ2_nu")) {
return (new MINERvA_CCCOHPI_XSec_1DQ2_nu(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEnu_antinu")) {
return (new MINERvA_CCCOHPI_XSec_1DEnu_antinu(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEpi_antinu")) {
return (new MINERvA_CCCOHPI_XSec_1DEpi_antinu(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1Dth_antinu")) {
return (new MINERvA_CCCOHPI_XSec_1Dth_antinu(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1DQ2_antinu")) {
return (new MINERvA_CCCOHPI_XSec_1DQ2_antinu(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEnu_joint")) {
return (new MINERvA_CCCOHPI_XSec_joint(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEpi_joint")) {
return (new MINERvA_CCCOHPI_XSec_joint(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1Dth_joint")) {
return (new MINERvA_CCCOHPI_XSec_joint(samplekey));
} else if (!name.compare("MINERvA_CCCOHPI_XSec_1DQ2_joint")) {
return (new MINERvA_CCCOHPI_XSec_joint(samplekey));
/*
T2K Samples
*/
} else
#endif
#ifndef __NO_T2K__
if (!name.compare("T2K_CC0pi_XSec_2DPcos_nu") ||
!name.compare("T2K_CC0pi_XSec_2DPcos_nu_I") ||
!name.compare("T2K_CC0pi_XSec_2DPcos_nu_II")) {
return (new T2K_CC0pi_XSec_2DPcos_nu(samplekey));
} else if (!name.compare("T2K_CC0pi_XSec_2DPcos_nu_nonuniform")) {
return (new T2K_CC0pi_XSec_2DPcos_nu_nonuniform(samplekey));
} else if (!name.compare("T2K_CCinc_XSec_2DPcos_nu_nonuniform")) {
return (new T2K_CCinc_XSec_2DPcos_nu_nonuniform(samplekey));
/*
T2K CC1pi+ CH samples
*/
// Comment these out for now because we don't have the proper data
} else if (!name.compare("T2K_CC1pip_CH_XSec_2Dpmucosmu_nu")) {
return (new T2K_CC1pip_CH_XSec_2Dpmucosmu_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_CH_XSec_1Dppi_nu")) {
return (new T2K_CC1pip_CH_XSec_1Dppi_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_CH_XSec_1Dthpi_nu")) {
return (new T2K_CC1pip_CH_XSec_1Dthpi_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_CH_XSec_1Dthmupi_nu")) {
return (new T2K_CC1pip_CH_XSec_1Dthmupi_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_CH_XSec_1DQ2_nu")) {
return (new T2K_CC1pip_CH_XSec_1DQ2_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_CH_XSec_1DAdlerPhi_nu")) {
return (new T2K_CC1pip_CH_XSec_1DAdlerPhi_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_CH_XSec_1DCosThAdler_nu")) {
return (new T2K_CC1pip_CH_XSec_1DCosThAdler_nu(samplekey));
// Maybe something for the future: were in Raquel's thesis
//} else if (!name.compare("T2K_CC1pip_CH_XSec_1Dq3_nu")) {
//return (new T2K_CC1pip_CH_XSec_1Dq3_nu(file, rw, type, fkdt));
//} else if (!name.compare("T2K_CC1pip_CH_XSec_1Dthq3pi_nu")) {
//return (new T2K_CC1pip_CH_XSec_1Dthq3pi_nu(file, rw, type, fkdt));
//} else if (!name.compare("T2K_CC1pip_CH_XSec_1DWrec_nu")) {
//return (new T2K_CC1pip_CH_XSec_1DWrec_nu(file, rw, type, fkdt));
/*
T2K CC1pi+ H2O samples
*/
} else if (!name.compare("T2K_CC1pip_H2O_XSec_1DEnuDelta_nu")) {
return (new T2K_CC1pip_H2O_XSec_1DEnuDelta_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_H2O_XSec_1DEnuMB_nu")) {
return (new T2K_CC1pip_H2O_XSec_1DEnuMB_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dcosmu_nu")) {
return (new T2K_CC1pip_H2O_XSec_1Dcosmu_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dcosmupi_nu")) {
return (new T2K_CC1pip_H2O_XSec_1Dcosmupi_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dcospi_nu")) {
return (new T2K_CC1pip_H2O_XSec_1Dcospi_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dpmu_nu")) {
return (new T2K_CC1pip_H2O_XSec_1Dpmu_nu(samplekey));
} else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dppi_nu")) {
return (new T2K_CC1pip_H2O_XSec_1Dppi_nu(samplekey));
/*
T2K CC0pi + np CH samples
*/
} else if (!name.compare("T2K_CC0pinp_STV_XSec_1Ddpt_nu")) {
return (new T2K_CC0pinp_STV_XSec_1Ddpt_nu(samplekey));
} else if (!name.compare("T2K_CC0pinp_STV_XSec_1Ddphit_nu")) {
return (new T2K_CC0pinp_STV_XSec_1Ddphit_nu(samplekey));
} else if (!name.compare("T2K_CC0pinp_STV_XSec_1Ddat_nu")) {
return (new T2K_CC0pinp_STV_XSec_1Ddat_nu(samplekey));
} else if (!name.compare("T2K_CC0pi1p_XSec_3DPcoscos_nu_nonuniform")) {
return (new T2K_CC0pi1p_XSec_3DPcoscos_nu_nonuniform(samplekey));
} else if (!name.compare("T2K_CC0pinp_ifk_XSec_3Dinfp_nu")) {
return (new T2K_CC0pinp_ifk_XSec_3Dinfp_nu(samplekey));
} else if (!name.compare("T2K_CC0pinp_ifk_XSec_3Dinfa_nu")) {
return (new T2K_CC0pinp_ifk_XSec_3Dinfa_nu(samplekey));
} else if (!name.compare("T2K_CC0pinp_ifk_XSec_3Dinfip_nu")) {
return (new T2K_CC0pinp_ifk_XSec_3Dinfip_nu(samplekey));
// SciBooNE COH studies
} else
#endif
#ifndef __NO_SciBooNE__
if (!name.compare("SciBooNE_CCCOH_STOP_NTrks_nu")) {
return (new SciBooNE_CCCOH_STOP_NTrks_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_1TRK_1DQ2_nu")) {
return (new SciBooNE_CCCOH_1TRK_1DQ2_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_1TRK_1Dpmu_nu")) {
return (new SciBooNE_CCCOH_1TRK_1Dpmu_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_1TRK_1Dthetamu_nu")) {
return (new SciBooNE_CCCOH_1TRK_1Dthetamu_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPr_1DQ2_nu")) {
return (new SciBooNE_CCCOH_MuPr_1DQ2_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPr_1Dpmu_nu")) {
return (new SciBooNE_CCCOH_MuPr_1Dpmu_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPr_1Dthetamu_nu")) {
return (new SciBooNE_CCCOH_MuPr_1Dthetamu_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPiVA_1DQ2_nu")) {
return (new SciBooNE_CCCOH_MuPiVA_1DQ2_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPiVA_1Dpmu_nu")) {
return (new SciBooNE_CCCOH_MuPiVA_1Dpmu_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu")) {
return (new SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu")) {
return (new SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu")) {
return (new SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu")) {
return (new SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu")) {
return (new SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu")) {
return (new SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu(samplekey));
} else if (!name.compare("SciBooNE_CCCOH_STOPFINAL_1DQ2_nu")) {
return (new SciBooNE_CCCOH_STOPFINAL_1DQ2_nu(samplekey));
/*
K2K Samples
*/
/*
NC1pi0
*/
} else
#endif
#ifndef __NO_K2K__
if (!name.compare("K2K_NC1pi0_Evt_1Dppi0_nu")) {
return (new K2K_NC1pi0_Evt_1Dppi0_nu(samplekey));
/*
Fake Studies
*/
} else
#endif
if (name.find("ExpMultDist_CCQE_XSec_1D") != std::string::npos &&
name.find("_FakeStudy") != std::string::npos) {
return (
new ExpMultDist_CCQE_XSec_1DVar_FakeStudy(name, file, rw, type, fkdt));
} else if (name.find("ExpMultDist_CCQE_XSec_2D") != std::string::npos &&
name.find("_FakeStudy") != std::string::npos) {
return (
new ExpMultDist_CCQE_XSec_2DVar_FakeStudy(name, file, rw, type, fkdt));
} else if (name.find("GenericFlux_") != std::string::npos) {
return (new GenericFlux_Tester(name, file, rw, type, fkdt));
} else if (name.find("GenericVectors_") != std::string::npos) {
return (new GenericFlux_Vectors(name, file, rw, type, fkdt));
} else if (!name.compare("T2K2017_FakeData")) {
return (new T2K2017_FakeData(samplekey));
} else if (!name.compare("MCStudy_CCQE")) {
return (new MCStudy_CCQEHistograms(name, file, rw, type, fkdt));
} else if (!name.compare("ElectronFlux_FlatTree")) {
return (new ElectronFlux_FlatTree(name, file, rw, type, fkdt));
} else if (name.find("ElectronData_") != std::string::npos) {
return new ElectronScattering_DurhamData(samplekey);
} else if (name.find("MuonValidation_") != std::string::npos) {
return (new MCStudy_MuonValidation(name, file, rw, type, fkdt));
} else if (!name.compare("NIWGOfficialPlots")) {
return (new OfficialNIWGPlots(samplekey));
} else if (!name.compare("Simple_Osc")) {
return (new Simple_Osc(samplekey));
} else if (!name.compare("Smear_SVDUnfold_Propagation_Osc")) {
return (new Smear_SVDUnfold_Propagation_Osc(samplekey));
} else {
- QTHROW("Error: No such sample: " << name << std::endl);
+ NUIS_ABORT("Error: No such sample: " << name << std::endl);
}
// Return NULL if no sample loaded.
return NULL;
}
}
diff --git a/src/FitBase/EventManager.cxx b/src/FitBase/EventManager.cxx
index d92ffd6..771a4ba 100644
--- a/src/FitBase/EventManager.cxx
+++ b/src/FitBase/EventManager.cxx
@@ -1,140 +1,140 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This file is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#include "EventManager.h"
EventManager* EventManager::m_evtmgrInstance = NULL;
EventManager& EventManager::Get(void) {
if (!m_evtmgrInstance) {
m_evtmgrInstance = new EventManager;
}
return *m_evtmgrInstance;
}
FitWeight* EventManager::GetRW() { return fRW; };
InputHandlerBase* EventManager::GetInput(int infile) { return finputs[infile]; };
FitEvent* EventManager::GetEvent(int infile, int i) {
/*
finputs[infile]->ReadEvent(i);
FitEvent* evtpt = finputs[infile]->GetEventPointer();
// If we don't need a full reweight
if (!frwneeded[infile][i]) {
evtpt->Weight = calc_rw[infile][i];
// if we do need a full reweight
} else {
evtpt->RWWeight = fRW->CalcWeight(evtpt);
evtpt->Weight = evtpt->RWWeight * evtpt->InputWeight;
calc_rw[infile][i] = evtpt->Weight;
frwneeded[infile][i] = false;
}
*/
return NULL;
}
double EventManager::GetEventWeight(int infile, int i) {
/*
if (!frwneeded[infile][i]) {
return calc_rw[infile][i];
}
finputs[infile]->GetTreeEntry(i);
FitEvent* evtpt = finputs[infile]->GetEventPointer();
double Weight = fRW->CalcWeight(evtpt) * evtpt->InputWeight;
calc_rw[infile][i] = Weight;
frwneeded[infile][i] = false;
*/
double Weight = 1.0;
return Weight;
}
std::map EventManager::GetInputs() { return finputs; }
InputHandlerBase* EventManager::AddInput(std::string handle, std::string infile) {
// Expect INPUTTYPE:FileLocation(s)
std::vector file_descriptor =
GeneralUtils::ParseToStr(infile, ":");
if (file_descriptor.size() != 2) {
- QTHROW("File descriptor had no filetype declaration: \"" << infile
+ NUIS_ABORT("File descriptor had no filetype declaration: \"" << infile
<< "\". expected \"FILETYPE:file.root\"");
}
InputUtils::InputType inpType =
InputUtils::ParseInputType(file_descriptor[0]);
int id = GetInputID(file_descriptor[1]);
if ((uint)id != fid.size()) {
- QLOG(SAM,"Event manager already contains " << file_descriptor[1]);
+ NUIS_LOG(SAM,"Event manager already contains " << file_descriptor[1]);
return finputs[id];
}
fid[file_descriptor[1]] = id;
finputs[id] = InputUtils::CreateInputHandler(handle, inpType, file_descriptor[1]);
frwneeded[id] = std::vector(finputs[id]->GetNEvents(), true);
calc_rw[id] = std::vector(finputs[id]->GetNEvents(), 0.0);
- QLOG(SAM,"Registered " << handle << " with EventManager.");
+ NUIS_LOG(SAM,"Registered " << handle << " with EventManager.");
return finputs[id];
}
// Reset the weight flags
// Should be called for every succesful event loop
void EventManager::ResetWeightFlags() {
/*
// Loop over the inpts
for (std::map::iterator iter = finputs.begin();
iter != finputs.end(); iter++) {
int id = iter->first;
frwneeded[id].clear();
// Reset so that all events need the reweight
frwneeded[id] = std::vector(finputs[id]->GetNEvents(), true);
}
*/
}
EventManager::EventManager() {
fRW = new FitWeight("FitWeight");
finputs.clear();
};
EventManager::~EventManager() {
delete fRW;
finputs.clear();
};
int EventManager::GetInputID(std::string infile) {
if (fid.find(infile) == fid.end()) {
return fid.size();
}
return fid[infile];
}
void EventManager::SetRW(FitWeight* rw){
fRW = rw;
}
diff --git a/src/FitBase/JointMeas1D.cxx b/src/FitBase/JointMeas1D.cxx
index 6dc1138..7d7afec 100644
--- a/src/FitBase/JointMeas1D.cxx
+++ b/src/FitBase/JointMeas1D.cxx
@@ -1,2222 +1,2222 @@
// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret
/*******************************************************************************
* This ile is part of NUISANCE.
*
* NUISANCE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NUISANCE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NUISANCE. If not, see .
*******************************************************************************/
#include "JointMeas1D.h"
//********************************************************************
JointMeas1D::JointMeas1D(void) {
//********************************************************************
// XSec Scalings
fScaleFactor = -1.0;
fCurrentNorm = 1.0;
// Histograms
fDataHist = NULL;
fDataTrue = NULL;
fMCHist = NULL;
fMCFine = NULL;
fMCWeighted = NULL;
fMaskHist = NULL;
// Covar
covar = NULL;
fFullCovar = NULL;
fCovar = NULL;
fInvert = NULL;
fDecomp = NULL;
// Fake Data
fFakeDataInput = "";
fFakeDataFile = NULL;
// Options
fDefaultTypes = "FIX/FULL/CHI2";
fAllowedTypes =
"FIX,FREE,SHAPE/FULL,DIAG/CHI2/NORM/ENUCORR/Q2CORR/ENU1D/MASK";
fIsFix = false;
fIsShape = false;
fIsFree = false;
fIsDiag = false;
fIsFull = false;
fAddNormPen = false;
fIsMask = false;
fIsChi2SVD = false;
fIsRawEvents = false;
fIsDifXSec = false;
fIsEnu1D = false;
// Inputs
fInput = NULL;
fRW = NULL;
// Extra Histograms
fMCHist_Modes = NULL;
for (std::vector::const_iterator iter = fSubChain.begin();
iter != fSubChain.end(); iter++) {
MeasurementBase *exp = *iter;
if (exp)
delete exp;
}
fSubChain.clear();
// Flags for Joint Measurements
fIsRatio = false;
fIsSummed = false;
fSaveSubMeas = false;
fIsJoint = true;
}
//********************************************************************
void JointMeas1D::SetupDefaultHist() {
//********************************************************************
// Setup fMCHist
fMCHist = (TH1D *)fDataHist->Clone();
fMCHist->SetNameTitle((fName + "_MC").c_str(),
(fName + "_MC" + fPlotTitles).c_str());
// Setup fMCFine
Int_t nBins = fMCHist->GetNbinsX();
fMCFine = new TH1D(
(fName + "_MC_FINE").c_str(), (fName + "_MC_FINE" + fPlotTitles).c_str(),
nBins * 6, fMCHist->GetBinLowEdge(1), fMCHist->GetBinLowEdge(nBins + 1));
fMCStat = (TH1D *)fMCHist->Clone();
fMCStat->Reset();
fMCHist->Reset();
fMCFine->Reset();
// Setup the NEUT Mode Array
PlotUtils::CreateNeutModeArray((TH1D *)fMCHist, (TH1 **)fMCHist_PDG);
PlotUtils::ResetNeutModeArray((TH1 **)fMCHist_PDG);
// Setup bin masks using sample name
if (fIsMask) {
std::string maskloc = FitPar::Config().GetParDIR(fName + ".mask");
if (maskloc.empty()) {
maskloc = FitPar::GetDataBase() + "/masks/" + fName + ".mask";
}
SetBinMask(maskloc);
}
fMCHist_Modes =
new TrueModeStack((fName + "_MODES").c_str(), ("True Channels"), fMCHist);
SetAutoProcessTH1(fMCHist_Modes);
return;
}
//********************************************************************
JointMeas1D::~JointMeas1D(void) {
//********************************************************************
if (fDataHist)
delete fDataHist;
if (fDataTrue)
delete fDataTrue;
if (fMCHist)
delete fMCHist;
if (fMCFine)
delete fMCFine;
if (fMCWeighted)
delete fMCWeighted;
if (fMaskHist)
delete fMaskHist;
if (covar)
delete covar;
if (fFullCovar)
delete fFullCovar;
if (fCovar)
delete fCovar;
if (fInvert)
delete fInvert;
if (fDecomp)
delete fDecomp;
for (std::vector::const_iterator iter = fSubChain.begin();
iter != fSubChain.end(); iter++) {
MeasurementBase *exp = *iter;
if (exp)
delete exp;
}
fSubChain.clear();
}
//********************************************************************
SampleSettings JointMeas1D::LoadSampleSettings(nuiskey samplekey) {
//********************************************************************
SampleSettings s = MeasurementBase::LoadSampleSettings(samplekey);
// Parse Inputs
fSubInFiles.clear();
std::vector entries =
GeneralUtils::ParseToStr(s.GetS("input"), ";");
if (entries.size() < 2) {
- QTHROW("Joint measurement expected to recieve at least two semi-colon "
+ NUIS_ABORT("Joint measurement expected to recieve at least two semi-colon "
"separated input files, but recieved: \""
<< s.GetS("input") << "\"");
}
std::vector first_file_descriptor =
GeneralUtils::ParseToStr(entries.front(), ":");
if (first_file_descriptor.size() != 2) {
- QTHROW("Found Joint measurement where the input file had no type: \""
+ NUIS_ABORT("Found Joint measurement where the input file had no type: \""
<< s.GetS("input")
<< "\", expected \"INPUTTYPE:File.root;File2.root\".");
}
std::string inpType = first_file_descriptor[0];
for (std::vector::iterator iter = entries.begin();
iter != entries.end(); iter++) {
if (GeneralUtils::ParseToStr(*iter, ":").size() != 2) {
std::stringstream ss("");
ss << inpType << ":" << (*iter);
fSubInFiles.push_back(ss.str());
} else {
fSubInFiles.push_back(*iter);
}
}
return s;
}
//********************************************************************
void JointMeas1D::FinaliseSampleSettings() {
//********************************************************************
// Setup naming + renaming
fName = fSettings.GetName();
fSettings.SetS("originalname", fName);
if (fSettings.Has("rename")) {
fName = fSettings.GetS("rename");
fSettings.SetS("name", fName);
}
// Setup all other options
- QLOG(SAM, "Finalising Sample Settings: " << fName);
+ NUIS_LOG(SAM, "Finalising Sample Settings: " << fName);
if ((fSettings.GetS("originalname").find("Evt") != std::string::npos)) {
fIsRawEvents = true;
- QLOG(SAM, "Found event rate measurement but using poisson likelihoods.");
+ NUIS_LOG(SAM, "Found event rate measurement but using poisson likelihoods.");
}
if (fSettings.GetS("originalname").find("XSec_1DEnu") != std::string::npos) {
fIsEnu1D = true;
- QLOG(SAM, "::" << fName << "::");
- QLOG(SAM, "Found XSec Enu measurement, applying flux integrated scaling, "
+ NUIS_LOG(SAM, "::" << fName << "::");
+ NUIS_LOG(SAM, "Found XSec Enu measurement, applying flux integrated scaling, "
<< "not flux averaged!");
}
if (fIsEnu1D && fIsRawEvents) {
- QLOG(SAM, "Found 1D Enu XSec distribution AND fIsRawEvents, is this "
+ NUIS_LOG(SAM, "Found 1D Enu XSec distribution AND fIsRawEvents, is this "
"really correct?!");
- QLOG(SAM,
+ NUIS_LOG(SAM,
"Check experiment constructor for " << fName << " and correct this!");
- QLOG(SAM, "I live in " << __FILE__ << ":" << __LINE__);
+ NUIS_LOG(SAM, "I live in " << __FILE__ << ":" << __LINE__);
exit(-1);
}
// Parse Inputs
fSubInFiles.clear();
std::vector entries =
GeneralUtils::ParseToStr(fSettings.GetS("input"), ";");
if (entries.size() < 2) {
- QTHROW("Joint measurement expected to recieve at least two semi-colon "
+ NUIS_ABORT("Joint measurement expected to recieve at least two semi-colon "
"separated input files, but recieved: \""
<< fSettings.GetS("input") << "\"");
}
std::vector first_file_descriptor =
GeneralUtils::ParseToStr(entries.front(), ":");
if (first_file_descriptor.size() != 2) {
- QTHROW("Found Joint measurement where the input file had no type: \""
+ NUIS_ABORT("Found Joint measurement where the input file had no type: \""
<< fSettings.GetS("input")
<< "\", expected \"INPUTTYPE:File.root;File2.root\".");
}
std::string inpType = first_file_descriptor[0];
for (std::vector::iterator iter = entries.begin();
iter != entries.end(); iter++) {
if (GeneralUtils::ParseToStr(*iter, ":").size() != 2) {
std::stringstream ss("");
ss << inpType << ":" << (*iter);
fSubInFiles.push_back(ss.str());
} else {
fSubInFiles.push_back(*iter);
}
}
// Setup options
SetFitOptions(fDefaultTypes); // defaults
SetFitOptions(fSettings.GetS("type")); // user specified
EnuMin = GeneralUtils::StrToDbl(fSettings.GetS("enu_min"));
EnuMax = GeneralUtils::StrToDbl(fSettings.GetS("enu_max"));
if (fAddNormPen) {
if (fNormError <= 0.0) {
- QERROR(FTL, "Norm error for class " << fName << " is 0.0!");
- QERROR(FTL, "If you want to use it please add fNormError=VAL");
+ NUIS_ERR(FTL, "Norm error for class " << fName << " is 0.0!");
+ NUIS_ERR(FTL, "If you want to use it please add fNormError=VAL");
throw;
}
}
if (!fRW)
fRW = FitBase::GetRW();
- QLOG(SAM, "Finalised Sample Settings");
+ NUIS_LOG(SAM, "Finalised Sample Settings");
}
//********************************************************************
void JointMeas1D::SetDataFromTextFile(std::string datafile) {
//********************************************************************
- QLOG(SAM, "Reading data from text file: " << datafile);
+ NUIS_LOG(SAM, "Reading data from text file: " << datafile);
fDataHist = PlotUtils::GetTH1DFromFile(
datafile, fSettings.GetName() + "_data", fSettings.GetFullTitles());
}
//********************************************************************
void JointMeas1D::SetDataFromRootFile(std::string datafile,
std::string histname) {
//********************************************************************
- QLOG(SAM, "Reading data from root file: " << datafile << ";" << histname);
+ NUIS_LOG(SAM, "Reading data from root file: " << datafile << ";" << histname);
fDataHist = PlotUtils::GetTH1DFromRootFile(datafile, histname);
fDataHist->SetNameTitle((fSettings.GetName() + "_data").c_str(),
(fSettings.GetFullTitles()).c_str());
return;
};
//********************************************************************
void JointMeas1D::SetPoissonErrors() {
//********************************************************************
if (!fDataHist) {
- QERROR(FTL, "Need a data hist to setup possion errors! ");
- QTHROW("Setup Data First!");
+ NUIS_ERR(FTL, "Need a data hist to setup possion errors! ");
+ NUIS_ABORT("Setup Data First!");
}
for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) {
fDataHist->SetBinError(i + 1, sqrt(fDataHist->GetBinContent(i + 1)));
}
}
//********************************************************************
void JointMeas1D::SetCovarFromDiagonal(TH1D *data) {
//********************************************************************
if (!data and fDataHist) {
data = fDataHist;
}
if (data) {
- QLOG(SAM, "Setting diagonal covariance for: " << data->GetName());
+ NUIS_LOG(SAM, "Setting diagonal covariance for: " << data->GetName());
fFullCovar = StatUtils::MakeDiagonalCovarMatrix(data);
covar = StatUtils::GetInvert(fFullCovar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
} else {
- QERROR(FTL, "No data input provided to set diagonal covar from!");
+ NUIS_ERR(FTL, "No data input provided to set diagonal covar from!");
}
if (!fIsDiag) {
- QERROR(FTL, "SetCovarMatrixFromDiag called for measurement "
+ NUIS_ERR(FTL, "SetCovarMatrixFromDiag called for measurement "
<< "that is not set as diagonal.");
throw;
}
}
//********************************************************************
void JointMeas1D::SetCovarFromTextFile(std::string covfile, int dim) {
//********************************************************************
- QLOG(SAM, "Reading covariance from text file: " << covfile);
+ NUIS_LOG(SAM, "Reading covariance from text file: " << covfile);
fFullCovar = StatUtils::GetCovarFromTextFile(covfile, dim);
covar = StatUtils::GetInvert(fFullCovar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
}
//********************************************************************
void JointMeas1D::SetCovarFromMultipleTextFiles(std::string covfiles, int dim) {
//********************************************************************
if (dim == -1) {
dim = fDataHist->GetNbinsX();
}
std::vector covList = GeneralUtils::ParseToStr(covfiles, ";");
fFullCovar = new TMatrixDSym(dim);
for (uint i = 0; i < covList.size(); ++i) {
- QLOG(SAM, "Reading covariance from text file: " << covList[i]);
+ NUIS_LOG(SAM, "Reading covariance from text file: " << covList[i]);
TMatrixDSym *temp_cov = StatUtils::GetCovarFromTextFile(covList[i], dim);
(*fFullCovar) += (*temp_cov);
delete temp_cov;
}
covar = StatUtils::GetInvert(fFullCovar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
}
//********************************************************************
void JointMeas1D::SetCovarFromRootFile(std::string covfile,
std::string histname) {
//********************************************************************
- QLOG(SAM,
+ NUIS_LOG(SAM,
"Reading covariance from text file: " << covfile << ";" << histname);
fFullCovar = StatUtils::GetCovarFromRootFile(covfile, histname);
covar = StatUtils::GetInvert(fFullCovar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
}
//********************************************************************
void JointMeas1D::SetCovarInvertFromTextFile(std::string covfile, int dim) {
//********************************************************************
- QLOG(SAM, "Reading inverted covariance from text file: " << covfile);
+ NUIS_LOG(SAM, "Reading inverted covariance from text file: " << covfile);
covar = StatUtils::GetCovarFromTextFile(covfile, dim);
fFullCovar = StatUtils::GetInvert(covar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
}
//********************************************************************
void JointMeas1D::SetCovarInvertFromRootFile(std::string covfile,
std::string histname) {
//********************************************************************
- QLOG(SAM, "Reading inverted covariance from text file: " << covfile << ";"
+ NUIS_LOG(SAM, "Reading inverted covariance from text file: " << covfile << ";"
<< histname);
covar = StatUtils::GetCovarFromRootFile(covfile, histname);
fFullCovar = StatUtils::GetInvert(covar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
}
//********************************************************************
void JointMeas1D::SetCorrelationFromTextFile(std::string covfile, int dim) {
//********************************************************************
if (dim == -1)
dim = fDataHist->GetNbinsX();
- QLOG(SAM,
+ NUIS_LOG(SAM,
"Reading data correlations from text file: " << covfile << ";" << dim);
TMatrixDSym *correlation = StatUtils::GetCovarFromTextFile(covfile, dim);
if (!fDataHist) {
- QTHROW("Trying to set correlations from text file but there is no "
+ NUIS_ABORT("Trying to set correlations from text file but there is no "
"data to build it from. \n"
<< "In constructor make sure data is set before "
"SetCorrelationFromTextFile is called. \n");
}
// Fill covar from data errors and correlations
fFullCovar = new TMatrixDSym(dim);
for (int i = 0; i < fDataHist->GetNbinsX(); i++) {
for (int j = 0; j < fDataHist->GetNbinsX(); j++) {
(*fFullCovar)(i, j) = (*correlation)(i, j) *
fDataHist->GetBinError(i + 1) *
fDataHist->GetBinError(j + 1) * 1.E76;
}
}
// Fill other covars.
covar = StatUtils::GetInvert(fFullCovar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
delete correlation;
}
//********************************************************************
void JointMeas1D::SetCorrelationFromMultipleTextFiles(std::string corrfiles,
int dim) {
//********************************************************************
if (dim == -1) {
dim = fDataHist->GetNbinsX();
}
std::vector corrList = GeneralUtils::ParseToStr(corrfiles, ";");
fFullCovar = new TMatrixDSym(dim);
for (uint i = 0; i < corrList.size(); ++i) {
- QLOG(SAM, "Reading covariance from text file: " << corrList[i]);
+ NUIS_LOG(SAM, "Reading covariance from text file: " << corrList[i]);
TMatrixDSym *temp_cov = StatUtils::GetCovarFromTextFile(corrList[i], dim);
for (int i = 0; i < fDataHist->GetNbinsX(); i++) {
for (int j = 0; j < fDataHist->GetNbinsX(); j++) {
// Note that there is a factor of 1E76 here. It is very silly indeed.
// However, if you remove it, you also need to fix the factors of 1E38
// added to the chi2 calculations!
(*temp_cov)(i, j) = (*temp_cov)(i, j) * fDataHist->GetBinError(i + 1) *
fDataHist->GetBinError(j + 1) * 1E76;
}
}
(*fFullCovar) += (*temp_cov);
delete temp_cov;
}
covar = StatUtils::GetInvert(fFullCovar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
}
//********************************************************************
void JointMeas1D::SetCorrelationFromRootFile(std::string covfile,
std::string histname) {
//********************************************************************
- QLOG(SAM, "Reading data correlations from text file: " << covfile << ";"
+ NUIS_LOG(SAM, "Reading data correlations from text file: " << covfile << ";"
<< histname);
TMatrixDSym *correlation = StatUtils::GetCovarFromRootFile(covfile, histname);
if (!fDataHist) {
- QTHROW("Trying to set correlations from text file but there is no "
+ NUIS_ABORT("Trying to set correlations from text file but there is no "
"data to build it from. \n"
<< "In constructor make sure data is set before "
"SetCorrelationFromTextFile is called. \n");
}
// Fill covar from data errors and correlations
fFullCovar = new TMatrixDSym(fDataHist->GetNbinsX());
for (int i = 0; i < fDataHist->GetNbinsX(); i++) {
for (int j = 0; j < fDataHist->GetNbinsX(); j++) {
(*fFullCovar)(i, j) = (*correlation)(i, j) *
fDataHist->GetBinError(i + 1) *
fDataHist->GetBinError(j + 1) * 1.E76;
}
}
// Fill other covars.
covar = StatUtils::GetInvert(fFullCovar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
delete correlation;
}
void JointMeas1D::SetShapeCovar() {
// Return if this is missing any pre-requisites
if (!fFullCovar)
return;
if (!fDataHist)
return;
// Also return if it's bloody stupid under the circumstances
if (fIsDiag)
return;
fShapeCovar = StatUtils::ExtractShapeOnlyCovar(fFullCovar, fDataHist);
return;
}
//********************************************************************
void JointMeas1D::SetCholDecompFromTextFile(std::string covfile, int dim) {
//********************************************************************
- QLOG(SAM, "Reading cholesky from text file: " << covfile);
+ NUIS_LOG(SAM, "Reading cholesky from text file: " << covfile);
TMatrixD *temp = StatUtils::GetMatrixFromTextFile(covfile, dim, dim);
TMatrixD *trans = (TMatrixD *)temp->Clone();
trans->T();
(*trans) *= (*temp);
fFullCovar = new TMatrixDSym(dim, trans->GetMatrixArray(), "");
covar = StatUtils::GetInvert(fFullCovar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
delete temp;
delete trans;
}
//********************************************************************
void JointMeas1D::SetCholDecompFromRootFile(std::string covfile,
std::string histname) {
//********************************************************************
- QLOG(SAM, "Reading cholesky decomp from root file: " << covfile << ";"
+ NUIS_LOG(SAM, "Reading cholesky decomp from root file: " << covfile << ";"
<< histname);
TMatrixD *temp = StatUtils::GetMatrixFromRootFile(covfile, histname);
TMatrixD *trans = (TMatrixD *)temp->Clone();
trans->T();
(*trans) *= (*temp);
fFullCovar = new TMatrixDSym(temp->GetNrows(), trans->GetMatrixArray(), "");
covar = StatUtils::GetInvert(fFullCovar);
fDecomp = StatUtils::GetDecomp(fFullCovar);
delete temp;
delete trans;
}
//********************************************************************
void JointMeas1D::ScaleData(double scale) {
//********************************************************************
fDataHist->Scale(scale);
}
//********************************************************************
void JointMeas1D::ScaleCovar(double scale) {
//********************************************************************
(*fFullCovar) *= scale;
(*covar) *= 1.0 / scale;
(*fDecomp) *= sqrt(scale);
}
//********************************************************************
void JointMeas1D::SetBinMask(std::string maskfile) {
//********************************************************************
if (!fIsMask)
return;
- QLOG(SAM, "Reading bin mask from file: " << maskfile);
+ NUIS_LOG(SAM, "Reading bin mask from file: " << maskfile);
// Create a mask histogram with dim of data
int nbins = fDataHist->GetNbinsX();
fMaskHist = new TH1I((fSettings.GetName() + "_BINMASK").c_str(),
(fSettings.GetName() + "_BINMASK; Bin; Mask?").c_str(),
nbins, 0, nbins);
std::string line;
std::ifstream mask(maskfile.c_str(), std::ifstream::in);
if (!mask.is_open()) {
- QTHROW(" Cannot find mask file: " << maskfile);
+ NUIS_ABORT(" Cannot find mask file: " << maskfile);
}
while (std::getline(mask >> std::ws, line, '\n')) {
std::vector entries = GeneralUtils::ParseToInt(line, " ");
// Skip lines with poorly formatted lines
if (entries.size() < 2) {
- QLOG(WRN, "JointMeas1D::SetBinMask(), couldn't parse line: " << line);
+ NUIS_LOG(WRN, "JointMeas1D::SetBinMask(), couldn't parse line: " << line);
continue;
}
// The first index should be the bin number, the second should be the mask
// value.
int val = 0;
if (entries[1] > 0)
val = 1;
fMaskHist->SetBinContent(entries[0], val);
}
// Apply masking by setting masked data bins to zero
PlotUtils::MaskBins(fDataHist, fMaskHist);
return;
}
//********************************************************************
void JointMeas1D::FinaliseMeasurement() {
//********************************************************************
- QLOG(SAM, "Finalising Measurement: " << fName);
+ NUIS_LOG(SAM, "Finalising Measurement: " << fName);
// Make sure data is setup
if (!fDataHist) {
- QTHROW("No data has been setup inside " << fName << " constructor!");
+ NUIS_ABORT("No data has been setup inside " << fName << " constructor!");
}
// Make sure covariances are setup
if (!fFullCovar) {
fIsDiag = true;
SetCovarFromDiagonal(fDataHist);
}
if (!covar) {
covar = StatUtils::GetInvert(fFullCovar);
}
if (!fDecomp) {
fDecomp = StatUtils::GetDecomp(fFullCovar);
}
// Push the diagonals of fFullCovar onto the data histogram
// Comment out until scaling is used consistently...
StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, 1E-38);
// Setup fMCHist from data
fMCHist = (TH1D *)fDataHist->Clone();
fMCHist->SetNameTitle((fSettings.GetName() + "_MC").c_str(),
(fSettings.GetFullTitles()).c_str());
fMCHist->Reset();
// Setup fMCFine
fMCFine = new TH1D("mcfine", "mcfine", fDataHist->GetNbinsX(),
fMCHist->GetBinLowEdge(1),
fMCHist->GetBinLowEdge(fDataHist->GetNbinsX() + 1));
fMCFine->SetNameTitle((fSettings.GetName() + "_MC_FINE").c_str(),
(fSettings.GetFullTitles()).c_str());
fMCFine->Reset();
// Setup MC Stat
fMCStat = (TH1D *)fMCHist->Clone();
fMCStat->Reset();
// Search drawopts for possible types to include by default
std::string drawopts = FitPar::Config().GetParS("drawopts");
if (drawopts.find("MODES") != std::string::npos) {
fMCHist_Modes = new TrueModeStack((fSettings.GetName() + "_MODES").c_str(),
("True Channels"), fMCHist);
SetAutoProcessTH1(fMCHist_Modes);
}
// Setup bin masks using sample name
if (fIsMask) {
std::string curname = fName;
std::string origname = fSettings.GetS("originalname");
// Check rename.mask
std::string maskloc = FitPar::Config().GetParDIR(curname + ".mask");
// Check origname.mask
if (maskloc.empty())
maskloc = FitPar::Config().GetParDIR(origname + ".mask");
// Check database
if (maskloc.empty()) {
maskloc = FitPar::GetDataBase() + "/masks/" + origname + ".mask";
}
// Setup Bin Mask
SetBinMask(maskloc);
}
/*
if (fScaleFactor < 0) {
ERR(FTL) << "I found a negative fScaleFactor in " << __FILE__ << ":" <<
__LINE__ << std::endl; ERR(FTL) << "fScaleFactor = " << fScaleFactor <<
std::endl; ERR(FTL) << "EXITING" << std::endl; throw;
}
*/
// Create and fill Weighted Histogram
if (!fMCWeighted) {
fMCWeighted = (TH1D *)fMCHist->Clone();
fMCWeighted->SetNameTitle((fName + "_MCWGHTS").c_str(),
(fName + "_MCWGHTS" + fPlotTitles).c_str());
fMCWeighted->GetYaxis()->SetTitle("Weighted Events");
}
}
//********************************************************************
void JointMeas1D::SetFitOptions(std::string opt) {
//********************************************************************
// Do nothing if default given
if (opt == "DEFAULT")
return;
// CHECK Conflicting Fit Options
std::vector fit_option_allow =
GeneralUtils::ParseToStr(fAllowedTypes, "/");
for (UInt_t i = 0; i < fit_option_allow.size(); i++) {
std::vector fit_option_section =
GeneralUtils::ParseToStr(fit_option_allow.at(i), ",");
bool found_option = false;
for (UInt_t j = 0; j < fit_option_section.size(); j++) {
std::string av_opt = fit_option_section.at(j);
if (!found_option and opt.find(av_opt) != std::string::npos) {
found_option = true;
} else if (found_option and opt.find(av_opt) != std::string::npos) {
- QTHROW("ERROR: Conflicting fit options provided: "
+ NUIS_ABORT("ERROR: Conflicting fit options provided: "
<< opt << std::endl
<< "Conflicting group = " << fit_option_section.at(i)
<< std::endl
<< "You should only supply one of these options in card file.");
}
}
}
// Check all options are allowed
std::vector fit_options_input =
GeneralUtils::ParseToStr(opt, "/");
for (UInt_t i = 0; i < fit_options_input.size(); i++) {
if (fAllowedTypes.find(fit_options_input.at(i)) == std::string::npos) {
- QERROR(FTL, "ERROR: Fit Option '"
+ NUIS_ERR(FTL, "ERROR: Fit Option '"
<< fit_options_input.at(i)
<< "' Provided is not allowed for this measurement.");
- QERROR(FTL, "Fit Options should be provided as a '/' seperated list "
+ NUIS_ERR(FTL, "Fit Options should be provided as a '/' seperated list "
"(e.g. FREE/DIAG/NORM)");
- QERROR(FTL, "Available options for " << fName << " are '" << fAllowedTypes
+ NUIS_ERR(FTL, "Available options for " << fName << " are '" << fAllowedTypes
<< "'");
throw;
}
}
// Set TYPE
fFitType = opt;
// FIX,SHAPE,FREE
if (opt.find("FIX") != std::string::npos) {
fIsFree = fIsShape = false;
fIsFix = true;
} else if (opt.find("SHAPE") != std::string::npos) {
fIsFree = fIsFix = false;
fIsShape = true;
} else if (opt.find("FREE") != std::string::npos) {
fIsFix = fIsShape = false;
fIsFree = true;
}
// DIAG,FULL (or default to full)
if (opt.find("DIAG") != std::string::npos) {
fIsDiag = true;
fIsFull = false;
} else if (opt.find("FULL") != std::string::npos) {
fIsDiag = false;
fIsFull = true;
}
// CHI2/LL (OTHERS?)
if (opt.find("LOG") != std::string::npos) {
fIsChi2 = false;
- QERROR(FTL, "No other LIKELIHOODS properly supported!");
- QERROR(FTL, "Try to use a chi2!");
+ NUIS_ERR(FTL, "No other LIKELIHOODS properly supported!");
+ NUIS_ERR(FTL, "Try to use a chi2!");
throw;
} else {
fIsChi2 = true;
}
// EXTRAS
if (opt.find("RAW") != std::string::npos)
fIsRawEvents = true;
if (opt.find("DIF") != std::string::npos)
fIsDifXSec = true;
if (opt.find("ENU1D") != std::string::npos)
fIsEnu1D = true;
if (opt.find("NORM") != std::string::npos)
fAddNormPen = true;
if (opt.find("MASK") != std::string::npos)
fIsMask = true;
return;
};
//********************************************************************
void JointMeas1D::SetSmearingMatrix(std::string smearfile, int truedim,
int recodim) {
//********************************************************************
// The smearing matrix describes the migration from true bins (rows) to reco
// bins (columns)
// Counter over the true bins!
int row = 0;
std::string line;
std::ifstream smear(smearfile.c_str(), std::ifstream::in);
// Note that the smearing matrix may be rectangular.
fSmearMatrix = new TMatrixD(truedim, recodim);
if (smear.is_open()) {
- QLOG(SAM, "Reading smearing matrix from file: " << smearfile);
+ NUIS_LOG(SAM, "Reading smearing matrix from file: " << smearfile);
} else {
- QTHROW("Smearing matrix provided is incorrect: " << smearfile);
+ NUIS_ABORT("Smearing matrix provided is incorrect: " << smearfile);
}
while (std::getline(smear >> std::ws, line, '\n')) {
int column = 0;
std::vector entries = GeneralUtils::ParseToDbl(line, " ");
for (std::vector::iterator iter = entries.begin();
iter != entries.end(); iter++) {
(*fSmearMatrix)(row, column) = (*iter) / 100.; // Convert to fraction from
// percentage (this may not be
// general enough)
column++;
}
row++;
}
return;
}
//********************************************************************
void JointMeas1D::ApplySmearingMatrix() {
//********************************************************************
if (!fSmearMatrix) {
- QERROR(WRN,
+ NUIS_ERR(WRN,
fName << ": attempted to apply smearing matrix, but none was set");
return;
}
TH1D *unsmeared = (TH1D *)fMCHist->Clone();
TH1D *smeared = (TH1D *)fMCHist->Clone();
smeared->Reset();
// Loop over reconstructed bins
// true = row; reco = column
for (int rbin = 0; rbin < fSmearMatrix->GetNcols(); ++rbin) {
// Sum up the constributions from all true bins
double rBinVal = 0;
// Loop over true bins
for (int tbin = 0; tbin < fSmearMatrix->GetNrows(); ++tbin) {
rBinVal +=
(*fSmearMatrix)(tbin, rbin) * unsmeared->GetBinContent(tbin + 1);
}
smeared->SetBinContent(rbin + 1, rBinVal);
}
fMCHist = (TH1D *)smeared->Clone();
return;
}
/*
Reconfigure LOOP
*/
//********************************************************************
void JointMeas1D::ResetAll() {
//********************************************************************
fMCHist->Reset();
fMCFine->Reset();
fMCStat->Reset();
return;
};
//********************************************************************
void JointMeas1D::FillHistograms() {
//********************************************************************
if (Signal) {
fMCHist->Fill(fXVar, Weight);
fMCFine->Fill(fXVar, Weight);
fMCStat->Fill(fXVar, 1.0);
if (fMCHist_Modes)
fMCHist_Modes->Fill(Mode, fXVar, Weight);
}
return;
};
//********************************************************************
void JointMeas1D::ScaleEvents() {
//********************************************************************
- QLOG(FIT, "Scaling JointMeas1D");
+ NUIS_LOG(FIT, "Scaling JointMeas1D");
// Fill MCWeighted;
for (int i = 0; i < fMCHist->GetNbinsX(); i++) {
fMCWeighted->SetBinContent(i + 1, fMCHist->GetBinContent(i + 1));
fMCWeighted->SetBinError(i + 1, fMCHist->GetBinError(i + 1));
}
// Setup Stat ratios for MC and MC Fine
double *statratio = new double[fMCHist->GetNbinsX()];
for (int i = 0; i < fMCHist->GetNbinsX(); i++) {
if (fMCHist->GetBinContent(i + 1) != 0) {
statratio[i] =
fMCHist->GetBinError(i + 1) / fMCHist->GetBinContent(i + 1);
} else {
statratio[i] = 0.0;
}
}
double *statratiofine = new double[fMCFine->GetNbinsX()];
for (int i = 0; i < fMCFine->GetNbinsX(); i++) {
if (fMCFine->GetBinContent(i + 1) != 0) {
statratiofine[i] =
fMCFine->GetBinError(i + 1) / fMCFine->GetBinContent(i + 1);
} else {
statratiofine[i] = 0.0;
}
}
// Scaling for raw event rates
if (fIsRawEvents) {
double datamcratio = fDataHist->Integral() / fMCHist->Integral();
fMCHist->Scale(datamcratio);
fMCFine->Scale(datamcratio);
if (fMCHist_Modes)
fMCHist_Modes->Scale(datamcratio);
// Scaling for XSec as function of Enu
} else if (fIsEnu1D) {
PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram(),
GetEventHistogram(), fScaleFactor, fNEvents);
PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram(),
GetEventHistogram(), fScaleFactor, fNEvents);
// if (fMCHist_Modes) {
// PlotUtils::FluxUnfoldedScaling(fMCHist_Modes, GetFluxHistogram(),
// GetEventHistogram(), fScaleFactor,
// fNEvents);
// }
// Any other differential scaling
} else {
fMCHist->Scale(fScaleFactor, "width");
fMCFine->Scale(fScaleFactor, "width");
if (fMCHist_Modes) {
fMCHist_Modes->Scale(fScaleFactor, "width");
}
}
// Proper error scaling - ROOT Freaks out with xsec weights sometimes
for (int i = 0; i < fMCStat->GetNbinsX(); i++) {
fMCHist->SetBinError(i + 1, fMCHist->GetBinContent(i + 1) * statratio[i]);
}
for (int i = 0; i < fMCFine->GetNbinsX(); i++) {
fMCFine->SetBinError(i + 1,
fMCFine->GetBinContent(i + 1) * statratiofine[i]);
}
// Clean up
delete statratio;
delete statratiofine;
return;
};
//********************************************************************
void JointMeas1D::ApplyNormScale(double norm) {
//********************************************************************
fCurrentNorm = norm;
fMCHist->Scale(1.0 / norm);
fMCFine->Scale(1.0 / norm);
return;
};
/*
Statistic Functions - Outsources to StatUtils
*/
//********************************************************************
int JointMeas1D::GetNDOF() {
//********************************************************************
int ndof = fDataHist->GetNbinsX();
if (fMaskHist)
ndof -= fMaskHist->Integral();
return ndof;
}
//********************************************************************
double JointMeas1D::GetLikelihood() {
//********************************************************************
// If this is for a ratio, there is no data histogram to compare to!
if (fNoData || !fDataHist)
return 0.;
// Apply Masking to MC if Required.
if (fIsMask and fMaskHist) {
PlotUtils::MaskBins(fMCHist, fMaskHist);
}
// Sort Shape Scaling
double scaleF = 0.0;
if (fIsShape) {
if (fMCHist->Integral(1, fMCHist->GetNbinsX(), "width")) {
scaleF = fDataHist->Integral(1, fDataHist->GetNbinsX(), "width") /
fMCHist->Integral(1, fMCHist->GetNbinsX(), "width");
fMCHist->Scale(scaleF);
fMCFine->Scale(scaleF);
}
}
// Likelihood Calculation
double stat = 0.;
if (fIsChi2) {
if (fIsRawEvents) {
stat = StatUtils::GetChi2FromEventRate(fDataHist, fMCHist, fMaskHist);
} else if (fIsDiag) {
stat = StatUtils::GetChi2FromDiag(fDataHist, fMCHist, fMaskHist);
} else if (!fIsDiag and !fIsRawEvents) {
stat = StatUtils::GetChi2FromCov(fDataHist, fMCHist, covar, fMaskHist);
}
}
// Sort Penalty Terms
if (fAddNormPen) {
double penalty =
(1. - fCurrentNorm) * (1. - fCurrentNorm) / (fNormError * fNormError);
stat += penalty;
}
// Return to normal scaling
if (fIsShape and !FitPar::Config().GetParB("saveshapescaling")) {
fMCHist->Scale(1. / scaleF);
fMCFine->Scale(1. / scaleF);
}
fLikelihood = stat;
return stat;
}
/*
Fake Data Functions
*/
//********************************************************************
void JointMeas1D::SetFakeDataValues(std::string fakeOption) {
//********************************************************************
// Setup original/datatrue
TH1D *tempdata = (TH1D *)fDataHist->Clone();
if (!fIsFakeData) {
fIsFakeData = true;
// Make a copy of the original data histogram.
if (!fDataOrig)
fDataOrig = (TH1D *)fDataHist->Clone((fName + "_data_original").c_str());
} else {
ResetFakeData();
}
// Setup Inputs
fFakeDataInput = fakeOption;
- QLOG(SAM, "Setting fake data from : " << fFakeDataInput);
+ NUIS_LOG(SAM, "Setting fake data from : " << fFakeDataInput);
// From MC
if (fFakeDataInput.compare("MC") == 0) {
fDataHist = (TH1D *)fMCHist->Clone((fName + "_MC").c_str());
// Fake File
} else {
if (!fFakeDataFile)
fFakeDataFile = new TFile(fFakeDataInput.c_str(), "READ");
fDataHist = (TH1D *)fFakeDataFile->Get((fName + "_MC").c_str());
}
// Setup Data Hist
fDataHist->SetNameTitle((fName + "_FAKE").c_str(),
(fName + fPlotTitles).c_str());
// Replace Data True
if (fDataTrue)
delete fDataTrue;
fDataTrue = (TH1D *)fDataHist->Clone();
fDataTrue->SetNameTitle((fName + "_FAKE_TRUE").c_str(),
(fName + fPlotTitles).c_str());
// Make a new covariance for fake data hist.
int nbins = fDataHist->GetNbinsX();
double alpha_i = 0.0;
double alpha_j = 0.0;
for (int i = 0; i < nbins; i++) {
for (int j = 0; j < nbins; j++) {
alpha_i =
fDataHist->GetBinContent(i + 1) / tempdata->GetBinContent(i + 1);
alpha_j =
fDataHist->GetBinContent(j + 1) / tempdata->GetBinContent(j + 1);
(*fFullCovar)(i, j) = alpha_i * alpha_j * (*fFullCovar)(i, j);
}
}
// Setup Covariances
if (covar)
delete covar;
covar = StatUtils::GetInvert(fFullCovar);
if (fDecomp)
delete fDecomp;
fDecomp = StatUtils::GetInvert(fFullCovar);
delete tempdata;
return;
};
//********************************************************************
void JointMeas1D::ResetFakeData() {
//********************************************************************
if (fIsFakeData) {
if (fDataHist)
delete fDataHist;
fDataHist =
(TH1D *)fDataTrue->Clone((fSettings.GetName() + "_FKDAT").c_str());
}
}
//********************************************************************
void JointMeas1D::ResetData() {
//********************************************************************
if (fIsFakeData) {
if (fDataHist)
delete fDataHist;
fDataHist =
(TH1D *)fDataOrig->Clone((fSettings.GetName() + "_data").c_str());
}
fIsFakeData = false;
}
//********************************************************************
void JointMeas1D::ThrowCovariance() {
//********************************************************************
// Take a fDecomposition and use it to throw the current dataset.
// Requires fDataTrue also be set incase used repeatedly.
if (fDataHist)
delete fDataHist;
fDataHist = StatUtils::ThrowHistogram(fDataTrue, fFullCovar);
return;
};
//********************************************************************
void JointMeas1D::ThrowDataToy() {
//********************************************************************
if (!fDataTrue)
fDataTrue = (TH1D *)fDataHist->Clone();
if (fMCHist)
delete fMCHist;
fMCHist = StatUtils::ThrowHistogram(fDataTrue, fFullCovar);
}
/*
Access Functions
*/
//********************************************************************
TH1D *JointMeas1D::GetMCHistogram() {
//********************************************************************
if (!fMCHist)
return fMCHist;
std::ostringstream chi2;
chi2 << "#chi^{2}=" << std::setprecision(5) << this->GetLikelihood();
int linecolor = kRed;
int linestyle = 1;
int linewidth = 1;
int fillcolor = 0;
int fillstyle = 1001;
if (fSettings.Has("linecolor"))
linecolor = fSettings.GetI("linecolor");
if (fSettings.Has("linestyle"))
linestyle = fSettings.GetI("linestyle");
if (fSettings.Has("linewidth"))
linewidth = fSettings.GetI("linewidth");
if (fSettings.Has("fillcolor"))
fillcolor = fSettings.GetI("fillcolor");
if (fSettings.Has("fillstyle"))
fillstyle = fSettings.GetI("fillstyle");
fMCHist->SetTitle(chi2.str().c_str());
fMCHist->SetLineColor(linecolor);
fMCHist->SetLineStyle(linestyle);
fMCHist->SetLineWidth(linewidth);
fMCHist->SetFillColor(fillcolor);
fMCHist->SetFillStyle(fillstyle);
return fMCHist;
};
//********************************************************************
TH1D *JointMeas1D::GetDataHistogram() {
//********************************************************************
if (!fDataHist)
return fDataHist;
int datacolor = kBlack;
int datastyle = 1;
int datawidth = 1;
if (fSettings.Has("datacolor"))
datacolor = fSettings.GetI("datacolor");
if (fSettings.Has("datastyle"))
datastyle = fSettings.GetI("datastyle");
if (fSettings.Has("datawidth"))
datawidth = fSettings.GetI("datawidth");
fDataHist->SetLineColor(datacolor);
fDataHist->SetLineWidth(datawidth);
fDataHist->SetMarkerStyle(datastyle);
return fDataHist;
};
/*
Write Functions
*/
// Save all the histograms at once
//********************************************************************
void JointMeas1D::Write(std::string drawOpt) {
//********************************************************************
// Get Draw Options
drawOpt = FitPar::Config().GetParS("drawopts");
// Write Settigns
if (drawOpt.find("SETTINGS") != std::string::npos) {
fSettings.Set("#chi^{2}", fLikelihood);
fSettings.Set("NDOF", this->GetNDOF());
fSettings.Set("#chi^{2}/NDOF", fLikelihood / this->GetNDOF());
fSettings.Write();
}
// Write Data/MC
GetDataHistogram()->Write();
GetMCHistogram()->Write();
// Write Fine Histogram
if (drawOpt.find("FINE") != std::string::npos)
GetFineList().at(0)->Write();
// Write Weighted Histogram
if (drawOpt.find("WEIGHTS") != std::string::npos && fMCWeighted)
fMCWeighted->Write();
// Save Flux/Evt if no event manager
if (!FitPar::Config().GetParB("EventManager")) {
if (drawOpt.find("FLUX") != std::string::npos && GetFluxHistogram())
GetFluxHistogram()->Write();
if (drawOpt.find("EVT") != std::string::npos && GetEventHistogram())
GetEventHistogram()->Write();
if (drawOpt.find("XSEC") != std::string::npos && GetEventHistogram())
GetEventHistogram()->Write();
}
// Write Mask
if (fIsMask && (drawOpt.find("MASK") != std::string::npos)) {
fMaskHist->Write();
}
// Write Covariances
if (drawOpt.find("COV") != std::string::npos && fFullCovar) {
PlotUtils::GetFullCovarPlot(fFullCovar, fSettings.GetName());
}
if (drawOpt.find("INVCOV") != std::string::npos && covar) {
PlotUtils::GetInvCovarPlot(covar, fSettings.GetName());
}
if (drawOpt.find("DECOMP") != std::string::npos && fDecomp) {
PlotUtils::GetDecompCovarPlot(fDecomp, fSettings.GetName());
}
// // Likelihood residual plots
// if (drawOpt.find("RESIDUAL") != std::string::npos) {
// WriteResidualPlots();
// }
// Ratio and Shape Plots
if (drawOpt.find("RATIO") != std::string::npos) {
WriteRatioPlot();
}
if (drawOpt.find("SHAPE") != std::string::npos) {
WriteShapePlot();
if (drawOpt.find("RATIO") != std::string::npos)
WriteShapeRatioPlot();
}
// // RATIO
// if (drawOpt.find("CANVMC") != std::string::npos) {
// TCanvas* c1 = WriteMCCanvas(fDataHist, fMCHist);
// c1->Write();
// delete c1;
// }
// // PDG
// if (drawOpt.find("CANVPDG") != std::string::npos && fMCHist_Modes) {
// TCanvas* c2 = WritePDGCanvas(fDataHist, fMCHist, fMCHist_Modes);
// c2->Write();
// delete c2;
// }
// Write Extra Histograms
AutoWriteExtraTH1();
WriteExtraHistograms();
if (fSaveSubMeas) {
for (std::vector::const_iterator expIter =
fSubChain.begin();
expIter != fSubChain.end(); expIter++) {
MeasurementBase *exp = *expIter;
exp->Write(drawOpt);
}
}
// Returning
- QLOG(SAM, "Written Histograms: " << fName);
+ NUIS_LOG(SAM, "Written Histograms: " << fName);
return;
}
//********************************************************************
void JointMeas1D::WriteRatioPlot() {
//********************************************************************
// Setup mc data ratios
TH1D *dataRatio = (TH1D *)fDataHist->Clone((fName + "_data_RATIO").c_str());
TH1D *mcRatio = (TH1D *)fMCHist->Clone((fName + "_MC_RATIO").c_str());
// Extra MC Data Ratios
for (int i = 0; i < mcRatio->GetNbinsX(); i++) {
dataRatio->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) /
fMCHist->GetBinContent(i + 1));
dataRatio->SetBinError(i + 1, fDataHist->GetBinError(i + 1) /
fMCHist->GetBinContent(i + 1));
mcRatio->SetBinContent(i + 1, fMCHist->GetBinContent(i + 1) /
fMCHist->GetBinContent(i + 1));
mcRatio->SetBinError(i + 1, fMCHist->GetBinError(i + 1) /
fMCHist->GetBinContent(i + 1));
}
// Write ratios
mcRatio->Write();
dataRatio->Write();
delete mcRatio;
delete dataRatio;
}
//********************************************************************
void JointMeas1D::WriteShapePlot() {
//********************************************************************
TH1D *mcShape = (TH1D *)fMCHist->Clone((fName + "_MC_SHAPE").c_str());
double shapeScale = 1.0;
if (fIsRawEvents) {
shapeScale = fDataHist->Integral() / fMCHist->Integral();
} else {
shapeScale = fDataHist->Integral("width") / fMCHist->Integral("width");
}
mcShape->Scale(shapeScale);
std::stringstream ss;
ss << "Scale=" << shapeScale;
mcShape->SetTitle(ss.str().c_str());
mcShape->SetLineWidth(3);
mcShape->SetLineStyle(7);
mcShape->Write();
delete mcShape;
}
//********************************************************************
void JointMeas1D::WriteShapeRatioPlot() {
//********************************************************************
// Get a mcshape histogram
TH1D *mcShape = (TH1D *)fMCHist->Clone((fName + "_MC_SHAPE").c_str());
double shapeScale = 1.0;
if (fIsRawEvents) {
shapeScale = fDataHist->Integral() / fMCHist->Integral();
} else {
shapeScale = fDataHist->Integral("width") / fMCHist->Integral("width");
}
mcShape->Scale(shapeScale);
// Create shape ratio histograms
TH1D *mcShapeRatio =
(TH1D *)mcShape->Clone((fName + "_MC_SHAPE_RATIO").c_str());
TH1D *dataShapeRatio =
(TH1D *)fDataHist->Clone((fName + "_data_SHAPE_RATIO").c_str());
// Divide the histograms
mcShapeRatio->Divide(mcShape);
dataShapeRatio->Divide(mcShape);
// Colour the shape ratio plots
mcShapeRatio->SetLineWidth(3);
mcShapeRatio->SetLineStyle(7);
mcShapeRatio->Write();
dataShapeRatio->Write();
delete mcShapeRatio;
delete dataShapeRatio;
}
/*
Setup Functions
*/
//********************************************************************
void JointMeas1D::SetupMeasurement(std::string input, std::string type,
FitWeight *rw, std::string fkdt) {
//********************************************************************
// For joint samples, input files are given as a semi-colon seperated list.
// Parse this list and save it for later, and set up the types etc.
if (FitPar::Config().GetParB("EventManager")) {
- QERROR(FTL, "Event Manager does not yet work with JointMeas1D Samples");
- QERROR(FTL, "If you want good predictions for "
+ NUIS_ERR(FTL, "Event Manager does not yet work with JointMeas1D Samples");
+ NUIS_ERR(FTL, "If you want good predictions for "
<< fName
<< " then run with it turned off! (-q EventManager=0)");
}
fSubInFiles.clear();
std::vector entries = GeneralUtils::ParseToStr(input, ";");
if (entries.size() < 2) {
- QTHROW("Joint measurement expected to recieve at least two semi-colon "
+ NUIS_ABORT("Joint measurement expected to recieve at least two semi-colon "
"separated input files, but recieved: \""
<< input << "\"");
}
std::vector first_file_descriptor =
GeneralUtils::ParseToStr(entries.front(), ":");
if (first_file_descriptor.size() != 2) {
- QTHROW("Found Joint measurement where the input file had no type: \""
+ NUIS_ABORT("Found Joint measurement where the input file had no type: \""
<< input << "\", expected \"INPUTTYPE:File.root;File2.root\".");
}
std::string inpType = first_file_descriptor[0];
for (std::vector::iterator iter = entries.begin();
iter != entries.end(); iter++) {
if (GeneralUtils::ParseToStr(*iter, ":").size() != 2) {
std::stringstream ss("");
ss << inpType << ":" << (*iter);
fSubInFiles.push_back(ss.str());
} else {
fSubInFiles.push_back(*iter);
}
}
// Set Engine and Fake Data
fRW = rw;
fFakeDataInput = fkdt;
// Set Fit Options
SetFitOptions(type);
return;
}
/*
XSec Functions
*/
//********************************************************************
double JointMeas1D::TotalIntegratedFlux(std::string intOpt, double low,
double high) {
//********************************************************************
double totalflux = 0.0;
// Destroy the job for sub samples
for (std::vector::const_iterator expIter =
fSubChain.begin();
expIter != fSubChain.end(); expIter++) {
MeasurementBase *exp = *expIter;
double expflux = exp->TotalIntegratedFlux(intOpt, low, high);
// Fill flux options
if (fIsRatio) {
totalflux = expflux;
break;
}
if (fIsSummed) {
totalflux += expflux;
}
}
return totalflux;
}
/*
Reconfigure Functions
*/
//********************************************************************
void JointMeas1D::Reconfigure() {
//********************************************************************
for (std::vector::const_iterator expIter =
fSubChain.begin();
expIter != fSubChain.end(); expIter++) {
MeasurementBase *exp = *expIter;
exp->Reconfigure();
}
ConvertEventRates();
return;
}
//********************************************************************
void JointMeas1D::ConvertEventRates() {
//********************************************************************
// Apply Event Scaling
for (std::vector::const_iterator expIter =
fSubChain.begin();
expIter != fSubChain.end(); expIter++) {
MeasurementBase *exp = static_cast(*expIter);
exp->ScaleEvents();
}
// Joint function called by top level class
MakePlots();
// Do Final Normalisation
ApplyNormScale(fRW->GetSampleNorm(this->fName));
}
//********************************************************************
void JointMeas1D::MakePlots() {
//********************************************************************
// Reset the 1D histograms but not the subClasses
ResetAll();
// If Summed
if (fIsSummed) {
for (std::vector::const_iterator expIter =
fSubChain.begin();
expIter != fSubChain.end(); expIter++) {
MeasurementBase *exp = static_cast(*expIter);
this->fMCHist->Add(exp->GetMCList().at(0));
this->fMCFine->Add(exp->GetFineList().at(0));
}
return;
}
// If Ratio
if (fIsRatio) {
int sample = 0;
for (std::vector::const_iterator expIter =
fSubChain.begin();
expIter != fSubChain.end(); expIter++) {
MeasurementBase *exp = *expIter;
if (sample == 0) {
this->fMCHist->Add(exp->GetMCList().at(0));
this->fMCFine->Add(exp->GetFineList().at(0));
} else if (sample == 1) {
this->fMCHist->Divide(exp->GetMCList().at(0));
this->fMCFine->Divide(exp->GetFineList().at(0));
} else {
break;
}
sample++;
}
return;
}
return;
}
/*
Access Functions
*/
//********************************************************************
std::vector JointMeas1D::GetMCList() {
//********************************************************************
// Make Default Vector
std::vector tempVect;
tempVect.push_back(this->fMCHist);
// Return vector from all sub samples
for (std::vector::const_iterator expIter =
fSubChain.begin();
expIter != fSubChain.end(); expIter++) {
MeasurementBase *exp = *expIter;
std::vector subTempVect = exp->GetMCList();
for (UInt_t i = 0; i < subTempVect.size(); i++) {
tempVect.push_back(subTempVect.at(i));
}
}
return tempVect;
}
//********************************************************************
std::vector JointMeas1D::GetDataList() {
//********************************************************************
// Make Default Vector
std::vector tempVect;
tempVect.push_back(this->fDataHist);
// Return vector from all sub samples
for (std::vector::const_iterator expIter =
fSubChain.begin();
expIter != fSubChain.end(); expIter++) {
MeasurementBase *exp = *expIter;
std::vector subTempVect = exp->GetDataList();
for (UInt_t i = 0; i < subTempVect.size(); i++) {
tempVect.push_back(subTempVect.at(i));
}
}
return tempVect;
}
//********************************************************************
std::vector JointMeas1D::GetFineList() {
//********************************************************************
// Make Default Vector
std::vector tempVect;
tempVect.push_back(this->fMCFine);
// Return vector from all sub samples
for (std::vector::const_iterator expIter =
fSubChain.begin();
expIter != fSubChain.end(); expIter++) {
MeasurementBase *exp = *expIter;
std::vector subTempVect = exp->GetFineList();
for (UInt_t i = 0; i < subTempVect.size(); i++) {
tempVect.push_back(subTempVect.at(i));
}
}
return tempVect;
}
//********************************************************************
std::vector JointMeas1D::GetMaskList() {
//********************************************************************
// Make Default Vector
std::vector