Page MenuHomeHEPForge

No OneTemporary

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/app/nuismin.cxx b/app/nuismin.cxx
index 359b24e..2f5e12f 100644
--- a/app/nuismin.cxx
+++ b/app/nuismin.cxx
@@ -1,110 +1,110 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
// 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<<" -f fakeDataFile: Uses the MC generated from a previous fit as a fake data set for these fits \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
std::cout<<"Starting ExtFit_minimizer.exe"<<std::endl;
// Make minimizer class and run fit
minimizerRoutines* min = new minimizerRoutines(argc, argv);
- min->initialSetup();
+ min->InitialSetup();
// Save Starting States
- if (FitPar::Config().GetParB("savenominal")) min->saveNominal();
- if (FitPar::Config().GetParB("saveprefit")) min->savePrefit();
+ if (FitPar::Config().GetParB("savenominal")) min->SaveNominal();
+ if (FitPar::Config().GetParB("saveprefit")) min->SavePrefit();
// Run the fit rotines
- min->SelfFit();
+ min->Run();
// Save by default
- min->saveFitterOutput();
+ min->SaveFitterOutput();
// Get Status
status = min->GetStatus();
// Show Final Status
std::cout<<"-------------------------------------"<<std::endl;
if (status == 0) std::cout<<"Minimizer Complete."<<std::endl;
else std::cerr<<"Minimizer Failed (error state = "<<status<<")"<<std::endl;
std::cout<<"-------------------------------------"<<std::endl;
return status;
}
diff --git a/app/nuissyst.cxx b/app/nuissyst.cxx
index 46f8869..0a572da 100644
--- a/app/nuissyst.cxx
+++ b/app/nuissyst.cxx
@@ -1,72 +1,71 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
// 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(){
//*******************************
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
std::cout<<"Starting nuissyst"<<std::endl;
// Make systematic class and run fit
- //systematicRoutines* min = new systematicRoutines(argc, argv);
- // min->initialSetup();
-
-
+ systematicRoutines* min = new systematicRoutines(argc, argv);
+ min->InitialSetup();
+ min->SelfFit();
// Show Final Status
std::cout<<"-------------------------------------"<<std::endl;
if (status == 0) std::cout<<"Systematic Complete."<<std::endl;
else std::cerr<<"Systematic Failed (error state = "<<status<<")"<<std::endl;
std::cout<<"-------------------------------------"<<std::endl;
return status;
}
diff --git a/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx
index 8dea492..56d4e8c 100644
--- a/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx
+++ b/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx
@@ -1,128 +1,128 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1npip_Evt_1DQ2_nu.h"
// The constructor
//********************************************************************
ANL_CC1npip_Evt_1DQ2_nu::ANL_CC1npip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
//********************************************************************
- measurementName = "ANL_CC1npip_Evt_1DQ2_nu";
+ fName = "ANL_CC1npip_Evt_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events";
EnuMin = 0;
EnuMax = 1.5;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_n/ANL_CC1pip_on_n_noEvents_Q2_14GeV_bin_firstQ2gone.txt");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
// Setup Covariance
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = (this->eventHist->Integral()/double(nevents))*(16./8.); // NEUT
};
//********************************************************************
void ANL_CC1npip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) {
//********************************************************************
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pn;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2112) {
Pn = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pn, Ppip);
double q2CCpip;
// ANL has a M(pi, p) < 1.4 GeV cut imposed (also no cut measurement but not useful for delta tuning)
if (hadMass < 1400) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
};
//********************************************************************
bool ANL_CC1npip_Evt_1DQ2_nu::isSignal(FitEvent *event) {
//********************************************************************
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int neutronCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2112) {
neutronCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (neutronCnt != 1) return false;
// Note, angular and momentum acceptances are corrected for in all ANL and BNL data
return true;
}
diff --git a/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx
index bd93e21..788437f 100644
--- a/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx
+++ b/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx
@@ -1,129 +1,129 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1npip_Evt_1DcosmuStar_nu.h"
// The constructor
ANL_CC1npip_Evt_1DcosmuStar_nu::ANL_CC1npip_Evt_1DcosmuStar_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1npip_Evt_1DcosmuStar_nu";
+ fName = "ANL_CC1npip_Evt_1DcosmuStar_nu";
plotTitles = "; cos(#theta*); Number of events";
EnuMin = 0;
EnuMax = 1.5;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_n/ANL_CC1npip_cosmuStar.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void ANL_CC1npip_Evt_1DcosmuStar_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pin = event->PartInfo(1)->fP;
TLorentzVector Pn;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 0; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2112) {
Pn = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pn, Ppip);
double cosmuStar;
// Now need to boost into center-of-mass frame
TLorentzVector CMS = Pnu + Pin;
// Boost the muon backwards
Pmu.Boost(-CMS.BoostVector());
// Boost the neutrino forwards
Pnu.Boost(CMS.BoostVector());
// ANL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) {
// Find angle in CMS frame
cosmuStar = cos(FitUtils::th(Pmu, Pnu));
} else {
cosmuStar = -999;
}
this->X_VAR = cosmuStar;
return;
};
bool ANL_CC1npip_Evt_1DcosmuStar_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int neutronCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2112) {
neutronCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (neutronCnt != 1) return false;
return true;
}
diff --git a/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx
index af4949b..147e88f 100644
--- a/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx
+++ b/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx
@@ -1,122 +1,122 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1npip_Evt_1Dppi_nu.h"
// The constructor
ANL_CC1npip_Evt_1Dppi_nu::ANL_CC1npip_Evt_1Dppi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1npip_Evt_1Dppi_nu";
+ fName = "ANL_CC1npip_Evt_1Dppi_nu";
plotTitles = "; p_{#pi} (MeV); Number of events";
EnuMin = 0;
// whaaa, check this
EnuMax = 1.5;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// ANL ppi has Enu < 1.5 GeV, W < 1.4 GeV
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_n/ANL_ppi_CC1npip.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/double(nevents)*(16./8.);
};
void ANL_CC1npip_Evt_1Dppi_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pn;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2112) {
Pn = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pn, Ppip);
double ppip;
// This measurement has a 1.4 GeV M(Npi) constraint
if (hadMass < 1400) {
ppip = FitUtils::p(Ppip)*1000.;
} else {
ppip = -1.0;
}
this->X_VAR = ppip;
return;
}
bool ANL_CC1npip_Evt_1Dppi_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int neutronCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2112) {
neutronCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (neutronCnt != 1) return false;
return true;
}
diff --git a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx
index 2a797fb..1006b43 100644
--- a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx
+++ b/src/ANL/ANL_CC1npip_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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1npip_XSec_1DEnu_nu.h"
// The constructor
ANL_CC1npip_XSec_1DEnu_nu::ANL_CC1npip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
// Measurement Details
- measurementName = "ANL_CC1npip_XSec_1DEnu_nu";
+ fName = "ANL_CC1npip_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV^{2}); #sigma (cm^{2}/nucleon)";
EnuMin = 0.;
EnuMax = 1.5;
isDiag = true;
normError = 0.20;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup Plots
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_n/anl82corr-numu-n-to-mu-n-piplus-lowW_edges.txt");
this->SetupDefaultHist();
// Setup Covariance
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(16./8.); // NEUT (16./8. from /nucleus -> /nucleon scaling for nucleon interactions)
};
void ANL_CC1npip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
TLorentzVector Pn;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
} else if (PID == 2112) {
Pn = event->PartInfo(j)->fP;
}
}
double hadMass = FitUtils::MpPi(Pn, Ppip);
double Enu;
if (hadMass < 1400) {
Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
};
bool ANL_CC1npip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int neutronCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
}
else if (abs(PID) == 211) {
pipCnt++;
}
else if (PID == 2112) {
neutronCnt++;
}
else
return false; // require only three prong events! (allow photons?)
}
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (neutronCnt != 1) return false;
// Angular and momentum efficiencies are already accounted for in data release, so that's it!
return true;
}
/*
void ANL_CC1npip_XSec_1DEnu_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void ANL_CC1npip_XSec_1DEnu_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.cxx b/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.cxx
index 685c002..408edac 100644
--- a/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.cxx
+++ b/src/ANL/ANL_CC1pi0_Evt_1DQ2_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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1pi0_Evt_1DQ2_nu.h"
// The constructor
ANL_CC1pi0_Evt_1DQ2_nu::ANL_CC1pi0_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1pi0_Evt_1DQ2_nu";
+ fName = "ANL_CC1pi0_Evt_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events";
EnuMin = 0;
EnuMax = 1.5;
isDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pi0_on_n/ANL_CC1pi0_on_n_noEvents_Q2_14GeV_bin_firstQ2gone.txt");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void ANL_CC1pi0_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppi0);
double q2CCpi0;
// ANL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) {
q2CCpi0 = FitUtils::Q2CC1pi0rec(Pnu, Pmu, Ppi0);
} else {
q2CCpi0 = -1.0;
}
this->X_VAR = q2CCpi0;
return;
};
bool ANL_CC1pi0_Evt_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pi0Cnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 111) {
pi0Cnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
if (pi0Cnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
/*
void ANL_CC1pi0_Evt_1DQ2_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void ANL_CC1pi0_Evt_1DQ2_nu::ScaleEvents() {
// PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
//PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx
index e402ac9..3fd1eea 100644
--- a/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx
+++ b/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx
@@ -1,129 +1,129 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1pi0_Evt_1DcosmuStar_nu.h"
// The constructor
ANL_CC1pi0_Evt_1DcosmuStar_nu::ANL_CC1pi0_Evt_1DcosmuStar_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1pi0_Evt_1DcosmuStar_nu";
+ fName = "ANL_CC1pi0_Evt_1DcosmuStar_nu";
plotTitles = "; cos(#theta*); Number of events";
EnuMin = 0;
EnuMax = 1.5;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pi0_on_n/ANL_CC1pi0_cosmuStar.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void ANL_CC1pi0_Evt_1DcosmuStar_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pin = event->PartInfo(1)->fP;
TLorentzVector Pp;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 0; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppi0);
double cosmuStar;
// Now need to boost into center-of-mass frame
TLorentzVector CMS = Pnu + Pin;
// Boost the muon backwards
Pmu.Boost(-CMS.BoostVector());
// Boost the neutrino forwards
Pnu.Boost(CMS.BoostVector());
// ANL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) {
// Find angle in CMS frame
cosmuStar = cos(FitUtils::th(Pmu, Pnu));
} else {
cosmuStar = -999;
}
this->X_VAR = cosmuStar;
return;
};
bool ANL_CC1pi0_Evt_1DcosmuStar_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pi0Cnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 111) {
pi0Cnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pi0Cnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx
index 00fb8bb..3f4783c 100644
--- a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx
+++ b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx
@@ -1,138 +1,138 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1pi0_XSec_1DEnu_nu.h"
// The constructor
ANL_CC1pi0_XSec_1DEnu_nu::ANL_CC1pi0_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "ANL_CC1pi0_XSec_1DEnu_nu";
+ fName = "ANL_CC1pi0_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)";
EnuMin = 0.;
EnuMax = 1.5;
isDiag = true;
normError = 0.20;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pi0_on_n/anl82corr-numu-n-to-mu-p-pi0-lowW_edges.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents+0.)*(16./8.);
};
void ANL_CC1pi0_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Pmu;
TLorentzVector Ppi0;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive || (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) Ppi0 = event->PartInfo(j)->fP;
else if (PID == 13) Pmu = (event->PartInfo(j))->fP;
else if (PID == 2212) Pp = event->PartInfo(j)->fP;
}
double hadMass = FitUtils::MpPi(Pp, Ppi0);
double Enu;
if (hadMass < 1400) {
Enu = FitUtils::EnuCC1pi0rec(Pnu, Pmu, Ppi0);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
};
bool ANL_CC1pi0_XSec_1DEnu_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pi0Cnt = 0;
int lepCnt = 0;
int protonCnt = 0;
// Look for final state particles
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) || (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 111) {
pi0Cnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pi0Cnt != 1)
return false;
if (lepCnt != 1)
return false;
if (protonCnt != 1)
return false;
return true;
}
/*
void ANL_CC1pi0_XSec_1DEnu_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
return;
}
void ANL_CC1pi0_XSec_1DEnu_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.cxx
index 046ece6..d9cfbd8 100644
--- a/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.cxx
+++ b/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.cxx
@@ -1,144 +1,144 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1ppip_Evt_1DQ2_nu.h"
// The constructor
ANL_CC1ppip_Evt_1DQ2_nu::ANL_CC1ppip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1ppip_Evt_1DQ2_nu";
+ fName = "ANL_CC1ppip_Evt_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events";
EnuMin = 0;
EnuMax = 6.0;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_Q2_14GeV_bin_firstQ2gone.txt");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void ANL_CC1ppip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double q2CCpip;
// ANL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
};
bool ANL_CC1ppip_Evt_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
/*
void ANL_CC1ppip_Evt_1DQ2_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void ANL_CC1ppip_Evt_1DQ2_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx
index fc013af..246a18b 100644
--- a/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx
+++ b/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx
@@ -1,129 +1,129 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1ppip_Evt_1DcosmuStar_nu.h"
// The constructor
ANL_CC1ppip_Evt_1DcosmuStar_nu::ANL_CC1ppip_Evt_1DcosmuStar_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1ppip_Evt_1DcosmuStar_nu";
+ fName = "ANL_CC1ppip_Evt_1DcosmuStar_nu";
plotTitles = "; cos(#theta*); Number of events";
EnuMin = 0;
EnuMax = 6.0;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_p/ANL_CC1ppip_cosmuStar.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void ANL_CC1ppip_Evt_1DcosmuStar_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pin = event->PartInfo(1)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 0; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double cosmuStar;
// Now need to boost into center-of-mass frame
TLorentzVector CMS = Pnu + Pin;
// Boost the muon backwards
Pmu.Boost(-CMS.BoostVector());
// Boost the neutrino forwards
Pnu.Boost(CMS.BoostVector());
// ANL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) {
// Find angle in CMS frame
cosmuStar = cos(FitUtils::th(Pmu, Pnu));
} else {
cosmuStar = -999;
}
this->X_VAR = cosmuStar;
return;
};
bool ANL_CC1ppip_Evt_1DcosmuStar_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx
index 9427da6..fc3ea67 100644
--- a/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx
+++ b/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx
@@ -1,161 +1,161 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1ppip_Evt_1DcosthAdler_nu.h"
// The constructor
ANL_CC1ppip_Evt_1DcosthAdler_nu::ANL_CC1ppip_Evt_1DcosthAdler_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1ppip_Evt_1DcosthAdler_nu";
+ fName = "ANL_CC1ppip_Evt_1DcosthAdler_nu";
plotTitles = "; cos#theta_{Adler}; Number of events";
EnuMin = 0;
EnuMax = 6.0;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_p/ANL_CC1ppip_cosTh.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void ANL_CC1ppip_Evt_1DcosthAdler_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
// Get the hadronic mass
double hadMass = FitUtils::MpPi(Pp, Ppip);
// Need to boost pion and muon into resonance rest-frame to get phi (e.g. see F. Sanchez arxiv 1511.00501v2)
//
// Get the resonance 4-vector
TLorentzVector Pres = Ppip + Pp;
// Boost in/outgoing particles into rest frame
Ppip.Boost(-Pres.BoostVector());
Pmu.Boost(-Pres.BoostVector());
Pnu.Boost(Pres.BoostVector());
// Define the vectors
TVector3 PpipVect = Ppip.Vect();
TVector3 PnuVect = Pnu.Vect();
TVector3 PmuVect = Pmu.Vect();
// Define the z-direction; should be same as Pres
TVector3 zVect = (PnuVect-PmuVect);
zVect *= 1/double(zVect.Mag());
// Then finally construct phi as the angle between pion projection and x axis
double cosThAdler;
// ANL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) {
cosThAdler = cos(PpipVect.Angle(zVect));
} else {
cosThAdler = -999;
}
this->X_VAR = cosThAdler;
return;
};
bool ANL_CC1ppip_Evt_1DcosthAdler_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
/*
void ANL_CC1ppip_Evt_1DcosthAdler_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void ANL_CC1ppip_Evt_1DcosthAdler_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx
index bf2abcb..fba88f2 100644
--- a/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx
+++ b/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx
@@ -1,191 +1,191 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1ppip_Evt_1Dphi_nu.h"
// The constructor
ANL_CC1ppip_Evt_1Dphi_nu::ANL_CC1ppip_Evt_1Dphi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1ppip_Evt_1Dphi_nu";
+ fName = "ANL_CC1ppip_Evt_1Dphi_nu";
plotTitles = "; #phi_{Adler}; Number of events";
EnuMin = 0;
EnuMax = 6.0;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_p/ANL_CC1ppip_phi.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
TRandom3 rand;
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void ANL_CC1ppip_Evt_1Dphi_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
// Get the hadronic mass
double hadMass = FitUtils::MpPi(Pp, Ppip);
// Need to boost pion and muon into resonance rest-frame to get phi (e.g. see F. Sanchez arxiv 1511.00501v2)
//
// Get the resonance 4-vector
TLorentzVector Pres = Ppip + Pp;
// Boost the outgoing and incoming particles into the resonance frame
Pnu.Boost(Pres.BoostVector());
Pmu.Boost(-Pres.BoostVector());
Ppip.Boost(-Pres.BoostVector());
// Get the vectors from the 4-vector
TVector3 PmuVect = Pmu.Vect();
TVector3 PnuVect = Pnu.Vect();
TVector3 PresVect = Pres.Vect();
TVector3 PpipVect = Ppip.Vect();
// Define the z-direction
TVector3 zVect = (PnuVect-PmuVect);
zVect *= 1/double(zVect.Mag());
// Define y direction as being z (resonance direction) x pmu*
TVector3 yVect = zVect.Cross(PmuVect);
// Normalise yVector
yVect *= 1/double(yVect.Mag());
// define x direction as being y X z
TVector3 xVect = yVect.Cross(zVect);
// Normalise zVector
xVect *= 1/double(xVect.Mag());
// Project pion onto z axis
TVector3 PpipVectZ = zVect * PpipVect.Dot(zVect);
// Then subtract this vector off the pion vector
TVector3 PpipVectPlane = PpipVect - PpipVectZ;
// Then finally construct phi as the angle between pion projection and x axis
double phi;
// ANL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) {
if (PpipVectPlane.Y() > 0) {
phi = (180./M_PI)*PpipVectPlane.Angle(xVect);
} else if (PpipVectPlane.Y() < 0) {
phi = (180./M_PI)*(2*M_PI-PpipVectPlane.Angle(xVect));
} else if (PpipVectPlane.Y() == 0) {
double randNo = rand.Rndm();
if (randNo > 0.5) {
phi = (180./M_PI)*PpipVectPlane.Angle(xVect);
} else {
phi = (180./M_PI)*(2*M_PI-PpipVectPlane.Angle(xVect));
}
}
} else {
phi = -999;
}
this->X_VAR = phi;
return;
};
bool ANL_CC1ppip_Evt_1Dphi_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
/*
void ANL_CC1ppip_Evt_1Dphi_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void ANL_CC1ppip_Evt_1Dphi_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx
index 93903cc..3938c32 100644
--- a/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx
+++ b/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx
@@ -1,116 +1,116 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1ppip_Evt_1Dppi_nu.h"
// The constructor
ANL_CC1ppip_Evt_1Dppi_nu::ANL_CC1ppip_Evt_1Dppi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1ppip_Evt_1Dppi_nu";
+ fName = "ANL_CC1ppip_Evt_1Dppi_nu";
plotTitles = "; p_{#pi} (MeV); Number of events";
EnuMin = 0;
EnuMax = 1.5; // Different EnuMax here, see M. Derrick et al, Phys Rev D, V23 N3, p572, Fig 2
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_p/ANL_ppi_CC1ppip.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*(16./8.);
};
void ANL_CC1ppip_Evt_1Dppi_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211)
Ppip = event->PartInfo(j)->fP;
else if (PID == 2212)
Pp = event->PartInfo(j)->fP;
else if (PID == 13) Pmu = (event->PartInfo(j))->fP;
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double ppip;
// This has a hadMass constraint of 1.4 GeV
if (hadMass < 1400) {
ppip = FitUtils::p(Ppip)*1000.;
} else {
ppip = -1.0;
}
this->X_VAR = ppip;
return;
};
bool ANL_CC1ppip_Evt_1Dppi_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13)
lepCnt++;
else if (PID == 211)
pipCnt++;
else if (PID == 2212)
protonCnt++;
else
return false; // require only three prong events! (allow photons?)
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx
index df273a8..1821fef 100644
--- a/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx
+++ b/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx
@@ -1,123 +1,123 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1ppip_Evt_1Dthpr_nu.h"
// The constructor
ANL_CC1ppip_Evt_1Dthpr_nu::ANL_CC1ppip_Evt_1Dthpr_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1ppip_Evt_1Dthpr_nu";
+ fName = "ANL_CC1ppip_Evt_1Dthpr_nu";
plotTitles = "; cos #theta_{p}; Number of events";
EnuMin = 0;
EnuMax = 1.5; // Different EnuMax for cos(thpr), see Derrick et al, Phys Rev D V23 N3, p572 fig 3
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// ANL ppi has Enu < 1.5 GeV, W < 1.4 GeV
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_p/ANL_thprot_CC1ppip.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/((nevents+0.))*(16./8.);
};
void ANL_CC1ppip_Evt_1Dthpr_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
//Measurement1D::FillHadMass(abs(event->Mode), hadMass, rw_weight);
double costhpr;
// This measurement has M(Npi) = W < 1.4GeV
if (hadMass < 1400) {
costhpr = cos(FitUtils::th(Pnu,Pp));
} else {
costhpr = -999;
}
this->X_VAR = costhpr;
return;
};
bool ANL_CC1ppip_Evt_1Dthpr_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx
index aa576cc..c1452a2 100644
--- a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx
+++ b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx
@@ -1,136 +1,136 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1ppip_XSec_1DEnu_nu.h"
// The constructor
ANL_CC1ppip_XSec_1DEnu_nu::ANL_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "ANL_CC1ppip_XSec_1DEnu_nu";
+ fName = "ANL_CC1ppip_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/nucleon)";
EnuMin = 0.;
EnuMax = 6.0;
isDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance
normError = 0.20; // normalisation error on ANL BNL flux
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_p/anl82corr-numu-p-to-mu-p-piplus-lowW_edges.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(16./8.);
};
void ANL_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pmu;
TLorentzVector Ppip;
TLorentzVector Pp;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double Enu; // declare here to save memory (beware of conflict with private in Measurement1D)
// ANL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) { // hadronic mass cut
Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
}
bool ANL_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212 /* && event->Ibound == 0*/) { // TEMPORARY!!!!!!! ONLY TESTING A THING
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
/*
void ANL_CC1ppip_XSec_1DEnu_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void ANL_CC1ppip_XSec_1DEnu_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.cxx b/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.cxx
index a0654c7..0aa68fd 100644
--- a/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.cxx
+++ b/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.cxx
@@ -1,115 +1,115 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CC1ppip_XSec_1DQ2_nu.h"
// The constructor
ANL_CC1ppip_XSec_1DQ2_nu::ANL_CC1ppip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "ANL_CC1ppip_XSec_1DQ2_nu";
+ fName = "ANL_CC1ppip_XSec_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ_{CC#pi^{+}}^{2} (cm^{2}/GeV^{2}/proton)";
EnuMin = 0;
EnuMax = 6;
isDiag = true;
normError = 0.20;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/CC1pip_on_p/ANL_CC1pip_on_p_dSigdQ2_W14.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/((nevents+0.)*TotalIntegratedFlux("width"))*16./8.;
};
void ANL_CC1ppip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double q2CCpip;
// I use the W < 1.4GeV cut ANL data to isolate single pion
// there is also a W < 1.6 GeV and an uncut spectrum ANL 1982
if (hadMass < 1400) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
};
bool ANL_CC1ppip_XSec_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13)
lepCnt++;
else if (PID == 211)
pipCnt++;
else if (PID == 2212 /*&& event->Ibound == 0*/)
protonCnt++;
else
return false; // require only three prong events! (allow photons?)
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx b/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx
index 7bbc9c3..fcaaa27 100755
--- a/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx
+++ b/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx
@@ -1,235 +1,235 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CCQE_Evt_1DQ2_nu.h"
//********************************************************************
/// @brief ANL CCQE Q2 Measurement on Free Nucleons (Ref: PRD16 3103)
///
/// @details Q2 Extracted assuming numu CCQE scattering of free nucleons.
ANL_CCQE_Evt_1DQ2_nu::ANL_CCQE_Evt_1DQ2_nu(std::string name, std::string inputfile,
FitWeight *rw, std::string type,
std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
EnuMin = 0.;
EnuMax = 6.;
applyQ2correction = type.find("Q2CORR") != std::string::npos;
applyEnucorrection = type.find("ENUCORR") != std::string::npos;
default_types="SHAPE/DIAG";
allowed_types="SHAPE/DIAG";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
isDiag = true;
isRawEvents = true;
// In future read most of these from a card file
if (!name.compare("ANL_CCQE_Evt_1DQ2_nu_PRL31")){
this->SetDataFromDatabase("ANL/ANL_CCQE_Data_PRL31_844.root", "ANL_1DQ2_Data");
applyEnucorrection = false;
EnuMax = 3.0; // Move EnuMax down
} else if (!name.compare("ANL_CCQE_Evt_1DQ2_nu_PRD16")){
applyEnucorrection = false;
this->SetDataFromDatabase("ANL/ANL_CCQE_Data_PRD16_3103.root", "ANL_1DQ2_Data");
} else {
this->SetDataFromDatabase("ANL/ANL_Data_PRD26_537.root","ANL_1DQ2_Data");
}
// Setup Histograms
this->SetupDefaultHist();
if (applyQ2correction){
this->CorrectionHist = PlotUtils::GetTH1DFromFile(std::string(std::getenv("EXT_FIT")) + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_1DQ2_Correction");
this->mcHist_NoCorr = (TH1D*) this->mcHist->Clone();
- this->mcHist_NoCorr->SetNameTitle( (this->measurementName + "_NOCORR").c_str(),(this->measurementName + "_NOCORR").c_str());
+ this->mcHist_NoCorr->SetNameTitle( (this->fName + "_NOCORR").c_str(),(this->fName + "_NOCORR").c_str());
}
if (applyEnucorrection){
this->EnuRatePlot = PlotUtils::GetTH1DFromFile(std::string(std::getenv("EXT_FIT")) + "/data/ANL/ANL_Data_PRD26_537.root","ANL_1DEnu_Rate");
this->EnuvsQ2Plot = PlotUtils::MergeIntoTH2D(dataHist, EnuRatePlot, "Events");
this->EnuFluxUnfoldPlot = (TH1D*)this->EnuRatePlot->Clone();
for (int i = 0; i < this->EnuFluxUnfoldPlot->GetNbinsX(); i++) this->EnuFluxUnfoldPlot->SetBinContent(i+1,1.0);
PlotUtils::FluxUnfoldedScaling(EnuFluxUnfoldPlot, fluxHist);
}
// Setup Covariance
// fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
// covar = StatUtils::GetInvert(fullcovar);
// this->eventHist->Scale(dataHist->Integral()/eventHist->Integral());
this->scaleFactor = (this->dataHist->Integral("width")/(nevents+0.));
// Set starting scale factor
scaleF = -1.0;
};
//********************************************************************
/// @details Extract q2qe from event assuming quasi-elastic scattering
void ANL_CCQE_Evt_1DQ2_nu::FillEventVariables(FitEvent *event){
//********************************************************************
// Fill histogram with reconstructed Q2 Distribution
q2qe = 0.0;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
// Look for the outgoing muon
if ((event->PartInfo(j))->fPID != 13) continue;
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
q2qe = FitUtils::Q2QErec( (event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
break;
}
this->X_VAR = q2qe;
return;
};
//********************************************************************
/// @brief Signal is defined as True CCQE numu scattering
/// @details cut 1: CCQE event
/// @details cut 2: numu event
/// @details cut 3: EnuMin < Enu < EnuMax
/// @details cut 4: Q2 non-zero
bool ANL_CCQE_Evt_1DQ2_nu::isSignal(FitEvent *event){
//********************************************************************
// Only look at CCQE Events
if (Mode != 1) return false;
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict energy range
if (Enu < this->EnuMin || Enu > this->EnuMax) return false;
// Q2 cut
if (q2qe <= 0) return false;
return true;
};
//********************************************************************
/// @details Reset the histogram uncorrect
void ANL_CCQE_Evt_1DQ2_nu::ResetAll(){
//********************************************************************
Measurement1D::ResetAll();
this->mcHist->Reset();
if (applyEnucorrection)
this->EnuvsQ2Plot->Reset();
if (applyQ2correction)
this->mcHist_NoCorr->Reset();
}
//********************************************************************
/// @details Apply additional event weights for free nucleon measurements
void ANL_CCQE_Evt_1DQ2_nu::FillHistograms(){
//********************************************************************
if (applyEnucorrection)
this->EnuvsQ2Plot->Fill(X_VAR, Enu, Weight);
if (applyQ2correction){
this->mcHist_NoCorr->Fill(X_VAR, Weight);
if (X_VAR < 0.225)
this->Weight *= this->CorrectionHist->Interpolate(X_VAR);
}
Measurement1D::FillHistograms();
}
//********************************************************************
void ANL_CCQE_Evt_1DQ2_nu::ScaleEvents(){
//********************************************************************
if (applyEnucorrection){
this->EnuvsQ2Plot->Scale(eventHist->Integral()/(nevents+0.));
for (int j = 0; j < EnuvsQ2Plot->GetNbinsY(); j++){
for (int i = 0; i < EnuvsQ2Plot->GetNbinsX(); i++){
this->EnuvsQ2Plot->SetBinContent(i+1,j+1, this->EnuvsQ2Plot->GetBinContent(i+1,j+1) * EnuFluxUnfoldPlot->GetBinContent(j+1));
}
}
}
this->mcHist->Scale(scaleFactor);
this->mcFine->Scale(scaleFactor);
if (applyQ2correction) this->mcHist_NoCorr->Scale(scaleFactor);
// Scale to match data
scaleF = PlotUtils::GetDataMCRatio(dataHist, mcHist, maskHist);
this->mcHist->Scale(scaleF);
this->mcFine->Scale(scaleF);
if (applyQ2correction){
scaleF = PlotUtils::GetDataMCRatio(dataHist, mcHist_NoCorr, maskHist);
this->mcHist_NoCorr->Scale(scaleF);
}
}
//********************************************************************
/// @brief Include Q2 Correction plots into data write
void ANL_CCQE_Evt_1DQ2_nu::Write(std::string drawOpt){
//********************************************************************
Measurement1D::Write(drawOpt);
if (applyQ2correction){
this->CorrectionHist->Write();
this->mcHist_NoCorr->Write();
}
if (applyEnucorrection){
this->EnuvsQ2Plot->Write();
((TH1D*)this->EnuvsQ2Plot->ProjectionX())->Write();
((TH1D*)this->EnuvsQ2Plot->ProjectionY())->Write();
EnuFluxUnfoldPlot->Write();
EnuRatePlot->Write();
}
return;
}
diff --git a/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx
index c488db9..9b55d75 100644
--- a/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx
+++ b/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx
@@ -1,123 +1,123 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_CCQE_XSec_1DEnu_nu.h"
ANL_CCQE_XSec_1DEnu_nu::ANL_CCQE_XSec_1DEnu_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
// Measurement Details
- measurementName = name;
+ fName = name;
EnuMin = 0.;
EnuMax = 6.;
isDiag = true;
applyQ2correction = type.find("Q2CORR") != std::string::npos;
default_types = "FIX/DIAG";
allowed_types = "FIX,FREE,SHAPE/DIAG/Q2CORR/ENUCORR";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
LOG(SAM) << "SETTING DATA"<<std::endl;
// Setup Plots
if (!name.compare("ANL_CCQE_XSec_1DEnu_nu_PRL31")){
SetDataFromDatabase("ANL/ANL_CCQE_Data_PRL31_844.root", "ANL_1DEnu_Data");
EnuMax = 3.0; // Move EnuMax down
} else {
SetDataFromDatabase("ANL/ANL_CCQE_Data_PRD16_3103.root", "ANL_1DEnu_fluxtuned_Data");
}
SetupDefaultHist();
if (applyQ2correction){
CorrectionHist = PlotUtils::GetTH1DFromFile(std::string(std::getenv("EXT_FIT")) + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_1DQ2_Correction");
}
// Setup Covariance
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Different generators require slightly different rescaling factors.
scaleFactor = (eventHist->Integral("width")*1E-38/(nevents+0.)); // NEUT
};
/// @details Extract Enu and totcrs from event assuming quasi-elastic scattering
void ANL_CCQE_XSec_1DEnu_nu::FillEventVariables(FitEvent *event){
// Get Q2
double q2qe = 0.0;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
// Look for the outgoing muon
if ((event->PartInfo(j))->fPID != 13) continue;
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
Enu_rec = FitUtils::EnuQErec((event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
q2qe = FitUtils::Q2QErec( (event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
// Once lepton is found, don't continue the loop
break;
}
X_VAR = Enu_rec;
// We save q2 into Y_VAR incase correction is applied
Y_VAR = q2qe;
return;
};
/// Signal is true CCQE scattering \n
/// \item Cut 1: numu event
/// \item Cut 2: Mode == 1
/// \item Cut 3: EnuMin < Enu < EnuMax
bool ANL_CCQE_XSec_1DEnu_nu::isSignal(FitEvent *event){
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14)
return false;
// Only CCQE
if (event->Mode != 1)
return false;
// Restrict energy range
if (event->Enu()/1000.0 < EnuMin || event->Enu()/1000.0 > EnuMax)
return false;
return true;
};
//! If Q2 correction is applied the CorrectionHist is interpolated
//! using the Q2QE value saved in Y_VAR
void ANL_CCQE_XSec_1DEnu_nu::FillHistograms(){
if (applyQ2correction){
if (Y_VAR < CorrectionHist->GetXaxis()->GetXmin())
Weight *= CorrectionHist->Interpolate(Y_VAR);
}
Measurement1D::FillHistograms();
}
diff --git a/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx b/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx
index 4d87980..4874a93 100644
--- a/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx
+++ b/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx
@@ -1,110 +1,110 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ANL_NC1npip_Evt_1Dppi_nu.h"
ANL_NC1npip_Evt_1Dppi_nu::ANL_NC1npip_Evt_1Dppi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "ANL_CC1npip_Evt_1Dppi_nu";
+ fName = "ANL_CC1npip_Evt_1Dppi_nu";
plotTitles = "; p_{#pi} (MeV); Number of events";
EnuMin = 0;
EnuMax = 1.5;
isDiag = true;
isRawEvents = true;
allowed_types="SHAPE/DIAG/EVT";
default_types="SHAPE/DIAG/EVT";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// ANL ppi has Enu < 1.5 GeV, W < 1.4 GeV
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/ANL/NC1npip/ANL_ppi_NC1npip_weight.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/((nevents+0.)*fluxHist->Integral("width"))*(16./8.);
};
void ANL_NC1npip_Evt_1Dppi_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pn;
TLorentzVector Ppip;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211)
Ppip = event->PartInfo(j)->fP;
else if (PID == 2112)
Pn = event->PartInfo(j)->fP;
}
double hadMass = FitUtils::MpPi(Pn, Ppip);
double ppip;
// ANL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) {
ppip = FitUtils::p(Ppip)*1000.;
} else {
ppip = -1.0;
}
this->X_VAR = ppip;
return;
};
bool ANL_NC1npip_Evt_1Dppi_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 14) && ((event->PartInfo(3))->fPID != 14)) return false;
int pipCnt = 0;
int neutronCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211)
pipCnt++;
else if (PID == 2112)
neutronCnt++;
else
return false; // require only three prong events! (allow photons?)
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (neutronCnt != 1) return false;
return true;
}
diff --git a/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx b/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx
index bf825c2..a5c5ab2 100644
--- a/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx
+++ b/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx
@@ -1,116 +1,116 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CC1npim_XSec_1DEnu_antinu.h"
// The constructor
BEBC_CC1npim_XSec_1DEnu_antinu::BEBC_CC1npim_XSec_1DEnu_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "BEBC_CC1npim_XSec_1DEnu_antinu";
+ fName = "BEBC_CC1npim_XSec_1DEnu_antinu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)";
EnuMin = 5.;
EnuMax = 200.;
isDiag = true;
normError = 0.20;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BEBC/theses/BEBC_theses_ANU_CC1pi-_nFin_W14.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(16./8.);
};
void BEBC_CC1npim_XSec_1DEnu_antinu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pn;
TLorentzVector Ppim;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == -211) {
Ppim = event->PartInfo(j)->fP;
} else if (PID == 2112) {
Pn = event->PartInfo(j)->fP;
} else if (PID == -13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pn, Ppim);
double Enu;
if (hadMass < 1400) {
Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppim);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
};
bool BEBC_CC1npim_XSec_1DEnu_antinu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != -14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != -13) && ((event->PartInfo(3))->fPID != -13)) return false;
int pimCnt = 0;
int lepCnt = 0;
int neutronCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == -13) {
lepCnt++;
} else if (PID == -211) {
pimCnt++;
} else if (PID == 2112) {
neutronCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pimCnt != 1) return false;
if (lepCnt != 1) return false;
if (neutronCnt != 1) return false;
return true;
}
diff --git a/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx b/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx
index 72c7df9..986d018 100644
--- a/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx
+++ b/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx
@@ -1,133 +1,133 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CC1npim_XSec_1DQ2_antinu.h"
// The constructor
BEBC_CC1npim_XSec_1DQ2_antinu::BEBC_CC1npim_XSec_1DQ2_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "BEBC_CC1npim_XSec_1DQ2_antinu";
+ fName = "BEBC_CC1npim_XSec_1DQ2_antinu";
plotTitles = "; Q^{2} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/neutron)";
EnuMin = 5.;
EnuMax = 200.;
isDiag = true;
normError = 0.20;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BEBC/Dfill/BEBC_Dfill_CC1pi-_on_n_W14_edit.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
- hadMassHist = new TH1D((measurementName+"_Wrec").c_str(),(measurementName+"_Wrec").c_str(), 100, 1000, 2000);
- hadMassHist->SetTitle((measurementName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str());
+ hadMassHist = new TH1D((fName+"_Wrec").c_str(),(fName+"_Wrec").c_str(), 100, 1000, 2000);
+ hadMassHist->SetTitle((fName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str());
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/((nevents+0.)*this->TotalIntegratedFlux("width"))*16./8.;
};
void BEBC_CC1npim_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pn;
TLorentzVector Ppim;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == -211) {
Ppim = event->PartInfo(j)->fP;
} else if (PID == 2112) {
Pn = event->PartInfo(j)->fP;
} else if (PID == -13) {
Pmu = (event->PartInfo(j))->fP;
}
}
hadMass = FitUtils::MpPi(Pn, Ppim);
double q2CCpip;
if (hadMass < 1400 && hadMass > 1100) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppim);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
};
bool BEBC_CC1npim_XSec_1DQ2_antinu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != -14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != -13) && ((event->PartInfo(3))->fPID != -13)) return false;
int pimCnt = 0;
int lepCnt = 0;
int neutronCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == -13) {
lepCnt++;
} else if (PID == -211) {
pimCnt++;
} else if (PID == 2112 /*&& event->Ibound == 0*/) {
neutronCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pimCnt != 1) return false;
if (lepCnt != 1) return false;
if (neutronCnt != 1) return false;
return true;
}
void BEBC_CC1npim_XSec_1DQ2_antinu::FillHistograms() {
Measurement1D::FillHistograms();
hadMassHist->Fill(hadMass);
return;
}
void BEBC_CC1npim_XSec_1DQ2_antinu::Write(std::string drawOpt) {
Measurement1D::Write(drawOpt);
hadMassHist->Scale(1/hadMassHist->Integral());
hadMassHist->Write();
return;
}
diff --git a/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx b/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx
index 542ba7c..4bea92b 100644
--- a/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx
+++ b/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx
@@ -1,113 +1,113 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CC1npip_XSec_1DEnu_nu.h"
// The constructor
BEBC_CC1npip_XSec_1DEnu_nu::BEBC_CC1npip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "BEBC_CC1npip_XSec_1DEnu_nu";
+ fName = "BEBC_CC1npip_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)";
EnuMin = 5.;
EnuMax = 200.;
isDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance
normError = 0.20; // normalisation error on ANL BNL flux
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BEBC/theses/BEBC_theses_CC1pip_on_n_W14.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(16./8.);
//this->scaleFactor = double(1.0E-38)/double(nevents)*(16./8.);
};
void BEBC_CC1npip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pn;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2112) {
Pn = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pn, Ppip);
double Enu;
if (hadMass < 1400) {
Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
};
bool BEBC_CC1npip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int neutronCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2112 /*&& event->Ibound == 0*/) {
neutronCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (neutronCnt != 1) return false;
return true;
}
diff --git a/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx
index e8fb0c3..c17b958 100644
--- a/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx
+++ b/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx
@@ -1,146 +1,146 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CC1npip_XSec_1DQ2_nu.h"
// The constructor
BEBC_CC1npip_XSec_1DQ2_nu::BEBC_CC1npip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "BEBC_CC1npip_XSec_1DQ2_nu";
+ fName = "BEBC_CC1npip_XSec_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/neutron)";
EnuMin = 5;
EnuMax = 200;
isDiag = true;
normError = 0.20;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BEBC/Dfill/BEBC_Dfill_CC1pi+_on_n_W14_edit.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
- hadMassHist = new TH1D((measurementName+"_Wrec").c_str(),(measurementName+"_Wrec").c_str(), 100, 1000, 2000);
- hadMassHist->SetTitle((measurementName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str());
+ hadMassHist = new TH1D((fName+"_Wrec").c_str(),(fName+"_Wrec").c_str(), 100, 1000, 2000);
+ hadMassHist->SetTitle((fName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str());
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/((nevents+0.)*this->TotalIntegratedFlux("width"))*16./8.;
};
void BEBC_CC1npip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pn;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2112) {
Pn = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
hadMass = FitUtils::MpPi(Pn, Ppip);
double q2CCpip;
// BEBC has a 1.1GeV < M(pi, p) < 1.4 GeV cut imposed (also no cut measurement but not useful for delta tuning)
if (hadMass < 1400 && hadMass > 1100) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
};
bool BEBC_CC1npip_XSec_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int neutronCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13)
lepCnt++;
else if (PID == 211)
pipCnt++;
else if (PID == 2112)
neutronCnt++;
else
return false; // require only three prong events! (allow photons?)
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (neutronCnt != 1) return false;
// This is corrected for
// this channel requires theta_(neutron, nu) > 10 deg
// theta_(mu, pi) < 150 deg
// p_neutron / p_neutrino < 0.9
/*
double th_neutron_neutrino = FitUtils::th(Pn, Pnu)*180/M_PI;
double th_mu_pi = FitUtils::th(Pmu, Ppip)*180/M_PI;
double p_neutron = FitUtils::p(Pn);
double p_neutrino = FitUtils::p(Pnu);
if (th_neutron_neutrino < 10 || th_mu_pi > 150 || p_neutron/p_neutrino > 0.9) return false;
*/
return true;
}
void BEBC_CC1npip_XSec_1DQ2_nu::FillHistograms() {
Measurement1D::FillHistograms();
hadMassHist->Fill(hadMass);
return;
}
void BEBC_CC1npip_XSec_1DQ2_nu::Write(std::string drawOpt) {
Measurement1D::Write(drawOpt);
hadMassHist->Scale(1/hadMassHist->Integral());
hadMassHist->Write();
return;
}
diff --git a/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx b/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx
index 5924cb1..c59d570 100644
--- a/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx
+++ b/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx
@@ -1,116 +1,116 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CC1pi0_XSec_1DEnu_nu.h"
// The constructor
BEBC_CC1pi0_XSec_1DEnu_nu::BEBC_CC1pi0_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "BEBC_CC1pi0_XSec_1DEnu_nu";
+ fName = "BEBC_CC1pi0_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)";
EnuMin = 5.;
EnuMax = 200.;
isDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance
normError = 0.20; // normalisation error on ANL BNL flux
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BEBC/theses/BEBC_theses_CC1pi0_W14.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(16./8.);
//this->scaleFactor = double(1.0E-38)/double(nevents)*(16./8.);
};
void BEBC_CC1pi0_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pp;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppi0);
double Enu;
// weirdly, the Enu distribution does not have a W < 1.4GeV cut
if (hadMass < 1400) {
//std::cout << "hadMass = " << hadMass << " " << "Enu = " << Enu << std::endl;
//std::cout << "Enu vec = " << Pnu.E() << std::endl;
Enu = FitUtils::EnuCC1pi0rec(Pnu, Pmu, Ppi0);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
};
bool BEBC_CC1pi0_XSec_1DEnu_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pi0Cnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 111) {
pi0Cnt++;
} else if (PID == 2212 /*&& event->Ibound == 0*/) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pi0Cnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx
index ebf1486..e4f96af 100644
--- a/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx
+++ b/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx
@@ -1,131 +1,131 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CC1pi0_XSec_1DQ2_nu.h"
// The constructor
BEBC_CC1pi0_XSec_1DQ2_nu::BEBC_CC1pi0_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "BEBC_CC1pi0_XSec_1DQ2_nu";
+ fName = "BEBC_CC1pi0_XSec_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/neutron)";
EnuMin = 5.;
EnuMax = 200.;
isDiag = true;
normError = 0.20;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BEBC/Dfill/BEBC_Dfill_CC1pi0_on_n_W14_edit.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
- hadMassHist = new TH1D((measurementName+"_Wrec").c_str(),(measurementName+"_Wrec").c_str(), 100, 1000, 2000);
- hadMassHist->SetTitle((measurementName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str());
+ hadMassHist = new TH1D((fName+"_Wrec").c_str(),(fName+"_Wrec").c_str(), 100, 1000, 2000);
+ hadMassHist->SetTitle((fName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str());
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/((nevents+0.)*this->TotalIntegratedFlux("width"))*16./8.;
};
void BEBC_CC1pi0_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
hadMass = FitUtils::MpPi(Pp, Ppi0);
double q2CCpi0;
// BEBC has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400 && hadMass > 1100) {
q2CCpi0 = FitUtils::Q2CC1pi0rec(Pnu, Pmu, Ppi0);
} else {
q2CCpi0 = -1.0;
}
this->X_VAR = q2CCpi0;
return;
};
bool BEBC_CC1pi0_XSec_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pi0Cnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 111) {
pi0Cnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
if (pi0Cnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
void BEBC_CC1pi0_XSec_1DQ2_nu::FillHistograms() {
Measurement1D::FillHistograms();
hadMassHist->Fill(hadMass);
return;
}
void BEBC_CC1pi0_XSec_1DQ2_nu::Write(std::string drawOpt) {
Measurement1D::Write(drawOpt);
hadMassHist->Scale(1/hadMassHist->Integral());
hadMassHist->Write();
return;
}
diff --git a/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx b/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx
index 59d1996..794d5d7 100644
--- a/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx
+++ b/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx
@@ -1,114 +1,114 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CC1ppim_XSec_1DEnu_antinu.h"
// The constructor
BEBC_CC1ppim_XSec_1DEnu_antinu::BEBC_CC1ppim_XSec_1DEnu_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "BEBC_CC1ppim_XSec_1DEnu_antinu";
+ fName = "BEBC_CC1ppim_XSec_1DEnu_antinu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/proton)";
EnuMin = 5.;
EnuMax = 200.;
isDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance
normError = 0.20; // normalisation error on ANL BNL flux
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BEBC/theses/BEBC_theses_ANU_CC1pi-_pFin_W14.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(16./8.);
//this->scaleFactor = double(1.0E-38)/double(nevents)*(16./8.);
};
void BEBC_CC1ppim_XSec_1DEnu_antinu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pp;
TLorentzVector Ppim;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == -211) {
Ppim = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == -13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppim);
double Enu;
if (hadMass < 1400) {
Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppim);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
};
bool BEBC_CC1ppim_XSec_1DEnu_antinu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != -14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != -13) && ((event->PartInfo(3))->fPID != -13)) return false;
int pimCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == -13) {
lepCnt++;
} else if (PID == -211) {
pimCnt++;
} else if (PID == 2212 /*&& event->Ibound == 0*/) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pimCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx b/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx
index 1d6f812..0682693 100644
--- a/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx
+++ b/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx
@@ -1,132 +1,132 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CC1ppim_XSec_1DQ2_antinu.h"
// The constructor
BEBC_CC1ppim_XSec_1DQ2_antinu::BEBC_CC1ppim_XSec_1DQ2_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "BEBC_CC1ppim_XSec_1DQ2_antinu";
+ fName = "BEBC_CC1ppim_XSec_1DQ2_antinu";
plotTitles = "; Q^{2} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/proton)";
EnuMin = 5.;
EnuMax = 200.;
isDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance
normError = 0.20; // normalisation error on ANL BNL flux
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BEBC/Dfill/BEBC_Dfill_CC1pi-_on_p_W14_edit.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
- hadMassHist = new TH1D((measurementName+"_Wrec").c_str(),(measurementName+"_Wrec").c_str(), 100, 1000, 2000);
- hadMassHist->SetTitle((measurementName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str());
+ hadMassHist = new TH1D((fName+"_Wrec").c_str(),(fName+"_Wrec").c_str(), 100, 1000, 2000);
+ hadMassHist->SetTitle((fName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str());
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/((nevents+0.)*this->TotalIntegratedFlux("width"))*16./8.;
};
void BEBC_CC1ppim_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pp;
TLorentzVector Ppim;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == -211) {
Ppim = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == -13) {
Pmu = (event->PartInfo(j))->fP;
}
}
hadMass = FitUtils::MpPi(Pp, Ppim);
double q2CCpip;
if (hadMass < 1400 && hadMass > 1100) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppim);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
};
bool BEBC_CC1ppim_XSec_1DQ2_antinu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != -14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != -13) && ((event->PartInfo(3))->fPID != -13)) return false;
int pimCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == -13) {
lepCnt++;
} else if (PID == -211) {
pimCnt++;
} else if (PID == 2212 /*&& event->Ibound == 0*/) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pimCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
void BEBC_CC1ppim_XSec_1DQ2_antinu::FillHistograms() {
Measurement1D::FillHistograms();
hadMassHist->Fill(hadMass);
return;
}
void BEBC_CC1ppim_XSec_1DQ2_antinu::Write(std::string drawOpt) {
Measurement1D::Write(drawOpt);
hadMassHist->Scale(1/hadMassHist->Integral());
hadMassHist->Write();
return;
}
diff --git a/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx b/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx
index aa76cc3..6ac0090 100644
--- a/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx
+++ b/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx
@@ -1,116 +1,116 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CC1ppip_XSec_1DEnu_nu.h"
// The constructor
BEBC_CC1ppip_XSec_1DEnu_nu::BEBC_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "BEBC_CC1ppip_XSec_1DEnu_nu";
+ fName = "BEBC_CC1ppip_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/proton)";
EnuMin = 5.;
EnuMax = 200.;
isDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance
normError = 0.20; // normalisation error on ANL BNL flux
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BEBC/theses/BEBC_theses_CC1pip_on_p_W14.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(16./8.);
//this->scaleFactor = double(1.0E-38)/double(nevents)*(16./8.);
};
void BEBC_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// wanna calculate hadronic mass, plot and cut for signal
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double Enu;
// weirdly, the Enu distribution does not have a W < 1.4GeV cut
if (hadMass < 1400) {
Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
};
bool BEBC_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212 /*&& event->Ibound == 0*/) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx
index cafa8c0..22b78d7 100644
--- a/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx
+++ b/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx
@@ -1,136 +1,136 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CC1ppip_XSec_1DQ2_nu.h"
// The constructor
BEBC_CC1ppip_XSec_1DQ2_nu::BEBC_CC1ppip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "BEBC_CC1ppip_XSec_1DQ2_nu";
+ fName = "BEBC_CC1ppip_XSec_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/proton)";
EnuMin = 5;
EnuMax = 200;
isDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance
normError = 0.20; // normalisation error on ANL BNL flux
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BEBC/Dfill/BEBC_Dfill_CC1pi+_on_p_W14_edit.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
- hadMassHist = new TH1D((measurementName+"_Wrec").c_str(),(measurementName+"_Wrec").c_str(), 100, 1000, 2000);
- hadMassHist->SetTitle((measurementName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str());
+ hadMassHist = new TH1D((fName+"_Wrec").c_str(),(fName+"_Wrec").c_str(), 100, 1000, 2000);
+ hadMassHist->SetTitle((fName+"; W_{rec} (GeV/c^{2}); Area norm. # of events").c_str());
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/((nevents+0.)*this->TotalIntegratedFlux("width"))*16./8.;
};
void BEBC_CC1ppip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
hadMass = FitUtils::MpPi(Pp, Ppip);
double q2CCpip;
// BEBC has a M(pi, p) < 1.4 GeV cut imposed only on this channel
if (hadMass < 1400 && hadMass > 1100) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
};
bool BEBC_CC1ppip_XSec_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
void BEBC_CC1ppip_XSec_1DQ2_nu::FillHistograms() {
Measurement1D::FillHistograms();
hadMassHist->Fill(hadMass);
return;
}
void BEBC_CC1ppip_XSec_1DQ2_nu::Write(std::string drawOpt) {
Measurement1D::Write(drawOpt);
hadMassHist->Scale(1/hadMassHist->Integral());
hadMassHist->Write();
return;
}
diff --git a/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx
index 7eb66f6..88a81d9 100755
--- a/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx
+++ b/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx
@@ -1,176 +1,176 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BEBC_CCQE_XSec_1DQ2_nu.h"
//********************************************************************
/// @brief BEBC CCQE Q2 Measurement on Free Nucleons (Ref: Nuc.Phys.B.343 285)
///
/// @details Q2 Extracted assuming numu CCQE scattering of free nucleons.
BEBC_CCQE_XSec_1DQ2_nu::BEBC_CCQE_XSec_1DQ2_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
EnuMin = 0.;
EnuMax = 200.;
applyQ2correction = type.find("Q2CORR") != std::string::npos;
isDiag = true;
isRawEvents = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// In future read most of these from a card file
this->SetDataFromDatabase("BEBC/BEBC_CCQE_Data_NPB343_285.root", "BEBC_XSec_1DQ2_Data");
this->SetupDefaultHist();
if (applyQ2correction){
this->CorrectionHist = PlotUtils::GetTH1DFromFile(std::string(std::getenv("EXT_FIT")) + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_XSec_1DQ2_Correction");
this->mcHist_NoCorr = (TH1D*) this->mcHist->Clone();
- this->mcHist_NoCorr->SetNameTitle( (this->measurementName + "_NOCORR").c_str(),(this->measurementName + "_NOCORR").c_str());
+ this->mcHist_NoCorr->SetNameTitle( (this->fName + "_NOCORR").c_str(),(this->fName + "_NOCORR").c_str());
}
// Setup Covariance
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Generate events on H2 to get the normalisation right.
this->scaleFactor = (this->eventHist->Integral("width")/(nevents+0.))*1E-38 / (this->TotalIntegratedFlux("width")); // NEUT
// Set starting scale factor
scaleF = -1.0;
};
//********************************************************************
/// @details Extract q2qe from event assuming quasi-elastic scattering
void BEBC_CCQE_XSec_1DQ2_nu::FillEventVariables(FitEvent *event){
//********************************************************************
// Fill histogram with reconstructed Q2 Distribution
q2qe = 0.0;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
// Look for the outgoing muon
if ((event->PartInfo(j))->fPID != 13) continue;
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
q2qe = FitUtils::Q2QErec( (event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
break;
}
this->X_VAR = q2qe;
return;
};
//********************************************************************
/// @brief Signal is defined as True CCQE numu scattering
/// @details cut 1: numu event
/// @details cut 2: EnuMin < Enu < EnuMax
/// @details cut 3: Q2 non-zero
bool BEBC_CCQE_XSec_1DQ2_nu::isSignal(FitEvent *event){
//********************************************************************
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict energy range
if (Enu < this->EnuMin || Enu > this->EnuMax) return false;
// Q2 cut
if (q2qe <= 0) return false;
return true;
};
//********************************************************************
/// @details Reset the histogram uncorrect
void BEBC_CCQE_XSec_1DQ2_nu::ResetAll(){
//********************************************************************
Measurement1D::ResetAll();
this->mcHist->Reset();
if (applyQ2correction)
this->mcHist_NoCorr->Reset();
}
//********************************************************************
/// @details Apply additional event weights for free nucleon measurements
void BEBC_CCQE_XSec_1DQ2_nu::FillHistograms(){
//********************************************************************
if (applyQ2correction){
this->mcHist_NoCorr->Fill(X_VAR, Weight);
if (this->X_VAR < 0.225)
this->Weight *= this->CorrectionHist->Interpolate(this->X_VAR);
}
Measurement1D::FillHistograms();
}
//********************************************************************
void BEBC_CCQE_XSec_1DQ2_nu::ScaleEvents(){
//********************************************************************
Measurement1D::ScaleEvents();
if (applyQ2correction) this->mcHist_NoCorr->Scale(this->scaleFactor, "width");
return;
}
//********************************************************************
void BEBC_CCQE_XSec_1DQ2_nu::ApplyNormScale(double norm){
//********************************************************************
Measurement1D::ApplyNormScale(norm);
if (norm == 0.0) scaleF = 0.0;
else scaleF = 1.0/norm;
if (applyQ2correction) this->mcHist_NoCorr->Scale(scaleF);
return;
}
//********************************************************************
/// @brief Include Q2 Correction plots into data write
void BEBC_CCQE_XSec_1DQ2_nu::Write(std::string drawOpt){
//********************************************************************
Measurement1D::Write(drawOpt);
if (applyQ2correction){
this->CorrectionHist->Write();
this->mcHist_NoCorr->Write();
}
return;
}
diff --git a/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx
index aec78e2..bcf9f7d 100644
--- a/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx
+++ b/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx
@@ -1,152 +1,152 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BNL_CC1npip_Evt_1DQ2_nu.h"
// The constructor
BNL_CC1npip_Evt_1DQ2_nu::BNL_CC1npip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "BNL_CC1npip_Evt_1DQ2_nu";
+ fName = "BNL_CC1npip_Evt_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events";
EnuMin = 0.;
EnuMax = 3.;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BNL/CC1pip_on_n/BNL_CC1pip_on_n_noEvents_q2_noWcut_firstQ2gone.txt");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void BNL_CC1npip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pn;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2112) {
Pn = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
// double hadMass = FitUtils::MpPi(Pn, Ppip);
// no hadronic mass constraint in BNL CC1n1pi+
double q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
this->X_VAR = q2CCpip;
return;
};
bool BNL_CC1npip_Evt_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int neutronCnt = 0;
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppip;
TLorentzVector Pn;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
Pmu = (event->PartInfo(j))->fP;
}
else if (PID == 211) {
pipCnt++;
Ppip = (event->PartInfo(j))->fP;
}
else if (PID == 2112) {
neutronCnt++;
Pn = (event->PartInfo(j))->fP;
}
else
return false; // require only three prong events! (allow photons?)
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (neutronCnt != 1) return false;
// No further requirements from what I can see
return true;
}
/*
void BNL_CC1npip_Evt_1DQ2_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void BNL_CC1npip_Evt_1DQ2_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx
index c2396f8..62da4df 100644
--- a/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx
+++ b/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx
@@ -1,144 +1,144 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BNL_CC1npip_XSec_1DEnu_nu.h"
// The constructor
BNL_CC1npip_XSec_1DEnu_nu::BNL_CC1npip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "BNL_CC1npip_XSec_1DEnu_nu";
+ fName = "BNL_CC1npip_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)";
EnuMin = 0.;
EnuMax = 3.0;
isDiag = true;
normError = 0.15;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BNL/CC1pip_on_n/BNL_CC1pip_on_n_1986.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/((nevents+0.))*16./8.;
};
void BNL_CC1npip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pn;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
} else if (PID == 2112) {
Pn = event->PartInfo(j)->fP;
}
}
//double hadMass = FitUtils::MpPi(Pn, Ppip);
// No W cut for BNL CC1pi+ on neutron (I'm happy if you can find it!!!)
double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip);
this->X_VAR = Enu;
return;
};
bool BNL_CC1npip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
// BNL has somewhat tricky signal definition for the selection:
// P_visible = visible 4-momentum, so the three tracks total momentum
// P_visible > 150 MeV/c2
// Theta_Pvis_nu (angle between visible momentum and neutrino direction) < 50 degrees
// At least one negative track leaves chamber without interacting or stops consistent with muon
// THESE ARE NOT IMPLEMENTED BUT SHOULD BE KNOWN BY ANYONE WHO FITS THIS DATA! (see Kitagaki et al. 2556)
//
// The only actual restriction seems to be the final state particles. There's no mention of E_nu restrictions either (events span to 10GeV in fig 2, Kitagaki)
// There's a mention of uncertainity in the neutrino flux for Enu > 6.0 GeV
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int neutronCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2112) {
neutronCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (neutronCnt != 1) return false;
// seems to be no additional signal requirements in BNL; all are corrected for!
return true;
}
/*
void BNL_CC1npip_XSec_1DEnu_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void BNL_CC1npip_XSec_1DEnu_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx
index 576d125..c54188a 100644
--- a/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx
+++ b/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx
@@ -1,118 +1,118 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BNL_CC1pi0_Evt_1DQ2_nu.h"
// The constructor
BNL_CC1pi0_Evt_1DQ2_nu::BNL_CC1pi0_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "BNL_CC1pi0_Evt_1DQ2_nu";
+ fName = "BNL_CC1pi0_Evt_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events";
EnuMin = 0;
EnuMax = 6.0;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BNL/CC1pi0_on_n/BNL_CC1pi0_on_n_noEvents_q2_noWcut_bin_firstQ2gone.txt");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void BNL_CC1pi0_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
//double hadMass = FitUtils::MpPi(Pp, Ppi0);
// no W cut on BNL CC1pi0
double q2CCpi0 = FitUtils::Q2CC1pi0rec(Pnu, Pmu, Ppi0);
this->X_VAR = q2CCpi0;
return;
};
bool BNL_CC1pi0_Evt_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pi0Cnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 111) {
pi0Cnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pi0Cnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx
index 71a4fab..2dc2661 100644
--- a/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx
+++ b/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx
@@ -1,138 +1,138 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BNL_CC1pi0_XSec_1DEnu_nu.h"
// The constructor
BNL_CC1pi0_XSec_1DEnu_nu::BNL_CC1pi0_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "BNL_CC1pi0_XSec_1DEnu_nu";
+ fName = "BNL_CC1pi0_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/neutron)";
EnuMin = 0.;
EnuMax = 6.0;
isDiag = true;
normError = 0.15;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// THIS IS DEFINITELY DODGY WITH THE "CORRECTION"; EnuMax for BNL definitely stops at 3GeV because of flux uncertainties, although correction goes to 6!
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BNL/CC1pi0_on_n/BNL_CC1pi0_on_n_1986.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/(nevents+0.)*16./8.;
};
void BNL_CC1pi0_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pp;
TLorentzVector Pmu;
TLorentzVector Ppi0;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive || (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
}
}
//double hadMass = FitUtils::MpPi(Pp, Ppi0);
//BNL doesn't have a W cut for CC1pi0 sadly (I'm super happy if you can find it!)
double Enu = FitUtils::EnuCC1pi0rec(Pnu, Pmu, Ppi0);
this->X_VAR = Enu;
return;
}
bool BNL_CC1pi0_XSec_1DEnu_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pi0Cnt = 0;
int lepCnt = 0;
int protonCnt = 0;
// Look for final state particles
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) || (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 111) {
pi0Cnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pi0Cnt != 1)
return false;
if (lepCnt != 1)
return false;
if (protonCnt != 1)
return false;
return true;
}
/*
void BNL_CC1pi0_XSec_1DEnu_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void BNL_CC1pi0_XSec_1DEnu_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx
index acdd0d0..9509d6d 100644
--- a/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx
+++ b/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx
@@ -1,144 +1,144 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BNL_CC1ppip_Evt_1DQ2_nu.h"
// The constructor
BNL_CC1ppip_Evt_1DQ2_nu::BNL_CC1ppip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "BNL_CC1ppip_Evt_1DQ2_nu";
+ fName = "BNL_CC1ppip_Evt_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); Number of events";
EnuMin = 0;
EnuMax = 3.;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BNL/CC1pip_on_p/BNL_CC1pip_on_p_noEvents_q2_w14_enu05to6_finebin_firstQ2gone.txt");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void BNL_CC1ppip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double q2CCpip;
// BNL has a M(pi, p) < 1.4 GeV cut imposed only on this channel
if (hadMass < 1400) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
};
bool BNL_CC1ppip_Evt_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
/*
void BNL_CC1ppip_Evt_1DQ2_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void BNL_CC1ppip_Evt_1DQ2_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx
index 4adc21c..5ac9a2d 100644
--- a/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx
+++ b/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx
@@ -1,161 +1,161 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BNL_CC1ppip_Evt_1DcosthAdler_nu.h"
// The constructor
BNL_CC1ppip_Evt_1DcosthAdler_nu::BNL_CC1ppip_Evt_1DcosthAdler_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "BNL_CC1ppip_Evt_1DcosthAdler_nu";
+ fName = "BNL_CC1ppip_Evt_1DcosthAdler_nu";
plotTitles = "; cos#theta_{Adler}; Number of events";
EnuMin = 0;
EnuMax = 6.0;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BNL/CC1pip_on_p/BNL_CC1ppip_W14_cosThAdler.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void BNL_CC1ppip_Evt_1DcosthAdler_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
// Get the hadronic mass
double hadMass = FitUtils::MpPi(Pp, Ppip);
// Need to boost pion and muon into resonance rest-frame to get phi (e.g. see F. Sanchez arxiv 1511.00501v2)
//
// Get the resonance 4-vector
TLorentzVector Pres = Ppip + Pp;
Ppip.Boost(-Pres.BoostVector());
Pmu.Boost(-Pres.BoostVector());
Pnu.Boost(Pres.BoostVector());
// Define the vectors
TVector3 PpipVect = Ppip.Vect();
TVector3 PnuVect = Pnu.Vect();
TVector3 PmuVect = Pmu.Vect();
// Define the z-direction; should be same as Pres
TVector3 zVect = (PnuVect-PmuVect);
zVect *= 1/double(zVect.Mag());
// Then finally construct phi as the angle between pion projection and x axis
double cosThAdler;
// BNL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) {
cosThAdler = cos(PpipVect.Angle(zVect));
} else {
cosThAdler = -999;
}
this->X_VAR = cosThAdler;
return;
};
bool BNL_CC1ppip_Evt_1DcosthAdler_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
/*
void BNL_CC1ppip_Evt_1DcosthAdler_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void BNL_CC1ppip_Evt_1DcosthAdler_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx
index 316c471..18fb5cc 100644
--- a/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx
+++ b/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx
@@ -1,190 +1,190 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BNL_CC1ppip_Evt_1Dphi_nu.h"
// The constructor
BNL_CC1ppip_Evt_1Dphi_nu::BNL_CC1ppip_Evt_1Dphi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "BNL_CC1ppip_Evt_1Dphi_nu";
+ fName = "BNL_CC1ppip_Evt_1Dphi_nu";
plotTitles = "; #phi_{Adler}; Number of events";
EnuMin = 0;
EnuMax = 6.0;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BNL/CC1pip_on_p/BNL_CC1ppip_W14_phiAdler.csv");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
TRandom3 rand;
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void BNL_CC1ppip_Evt_1Dphi_nu::FillEventVariables(FitEvent *event) {
// set up the 4-vectors from NEUT
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
// Get the hadronic mass
double hadMass = FitUtils::MpPi(Pp, Ppip);
// Need to boost pion and muon into resonance rest-frame to get phi (e.g. see F. Sanchez arxiv 1511.00501v2)
//
// Get the resonance 4-vector
TLorentzVector Pres = Ppip + Pp;
// Boost the pion 4-vector into the resonance 4-vector rest-frame
Ppip.Boost(Pres.BoostVector());
Pmu.Boost(-Pres.BoostVector());
Pp.Boost(-Pres.BoostVector());
// Get the vectors from the 4-vector
TVector3 PmuVect = Pmu.Vect();
TVector3 PnuVect = Pnu.Vect();
TVector3 PresVect = Pres.Vect();
TVector3 PpipVect = Ppip.Vect();
// Define y direction as being z (resonance direction) x pmu*
TVector3 zVect = (PnuVect-PmuVect);
zVect *= 1/double(zVect.Mag());
TVector3 yVect = zVect.Cross(PmuVect);
// Normalise yVector
yVect *= 1/double(yVect.Mag());
// define x direction as being y X z
TVector3 xVect = yVect.Cross(zVect);
// Normalise zVector
xVect *= 1/double(xVect.Mag());
// Project pion onto z axis
TVector3 PpipVectZ = zVect * PpipVect.Dot(zVect);
// Then subtract this vector off the pion vector
TVector3 PpipVectPlane = PpipVect - PpipVectZ;
// Then finally construct phi as the angle between pion projection and x axis
double phi;
// BNL has a M(pi, p) < 1.4 GeV cut imposed
if (hadMass < 1400) {
if (PpipVectPlane.Y() > 0) {
phi = (180./M_PI)*PpipVectPlane.Angle(xVect);
} else if (PpipVectPlane.Y() < 0) {
phi = (180./M_PI)*(2*M_PI-PpipVectPlane.Angle(xVect));
} else if (PpipVectPlane.Y() == 0) {
double randNo = rand.Rndm();
if (randNo > 0.5) {
phi = (180./M_PI)*PpipVectPlane.Angle(xVect);
} else {
phi = (180./M_PI)*(2*M_PI-PpipVectPlane.Angle(xVect));
}
}
} else {
phi = -999;
}
this->X_VAR = phi;
return;
};
bool BNL_CC1ppip_Evt_1Dphi_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
/*
void BNL_CC1ppip_Evt_1Dphi_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void BNL_CC1ppip_Evt_1Dphi_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx
index 9ce806b..052ba60 100644
--- a/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx
+++ b/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx
@@ -1,174 +1,174 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BNL_CC1ppip_XSec_1DEnu_nu.h"
// The constructor
BNL_CC1ppip_XSec_1DEnu_nu::BNL_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "BNL_CC1ppip_XSec_1DEnu_nu";
+ fName = "BNL_CC1ppip_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/proton)";
EnuMin = 0.;
EnuMax = 3.0;
isDiag = true;
normError = 0.15;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/BNL/CC1pip_on_p/BNL_CC1pip_on_p_W14_1986_corr_edges.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/((nevents+0.))*16./8.;
// D2 = 1 proton, 1 neutron
};
// Need this if we're reading a root file!
/*
void BNL_CC1ppip_XSec_1DEnu_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
TH1D *copy = (TH1D*)(dataFile->Get("BNL_reanalysis"));
this->data_points = copy->GetNbinsX()-1;
xBinBounds = new double[this->data_points];
dataVals = new double[this->data_points];
dataErr = new double[this->data_points];
for (int i = 0; i < data_points; i++) {
xBinBounds[i] = copy->GetBinLowEdge(i+3);
dataVals[i] = copy->GetBinContent(i+3)*1E-38;
dataErr[i] = copy->GetBinError(i+3)*1E-38;
}
this->xBins = xBinBounds;
this->data_values = dataVals;
this->data_errors = dataErr;
- this->dataHist = new TH1D((this->measurementName+"_data").c_str(), (this->measurementName+this->plotTitles).c_str(), this->data_points-1, this->xBins);
+ this->dataHist = new TH1D((this->fName+"_data").c_str(), (this->fName+this->plotTitles).c_str(), this->data_points-1, this->xBins);
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
this->dataHist->SetBinContent(i+1, this->data_values[i]);
this->dataHist->SetBinError(i+1, this->data_errors[i]);
}
dataHist->SetDirectory(0);
dataFile->Close();
};
*/
void BNL_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double Enu;
// Found a corrected one but only reliable to ~3GeV
if (hadMass < 1400) {
Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
};
bool BNL_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212 /*&& event->Ibound == 0*/) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
/*
void BNL_CC1ppip_XSec_1DEnu_nu::FillHistograms() {
if (makeHadronicMassHist) {
hadMassHist->Fill(hadMass);
}
Measurement1D::FillHistograms();
}
void BNL_CC1ppip_XSec_1DEnu_nu::ScaleEvents() {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
}
*/
diff --git a/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx
index 6ac35d6..d30ad82 100755
--- a/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx
+++ b/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx
@@ -1,209 +1,209 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BNL_CCQE_Evt_1DQ2_nu.h"
//********************************************************************
/// @brief BNL CCQE Enu Measurement on Free Nucleons (Ref:PRD23 2499)
///
/// @details Enu Extracted assuming numu CCQE scattering of free nucleons.
//********************************************************************
BNL_CCQE_Evt_1DQ2_nu::BNL_CCQE_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = "BNL_CCQE_Evt_1DQ2_nu";
+ fName = "BNL_CCQE_Evt_1DQ2_nu";
EnuMin = 0.;
EnuMax = 10.;
applyQ2correction = type.find("Q2CORR") != std::string::npos;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// override input options
isDiag = true;
isRawEvents =true;
EnuVsQ2 = new TH2D("EnuVsQ2","EnuVsQ2",25,0.0,10.0,60,0.0,3.0);
//Setup Plots
this->SetDataFromDatabase("BNL/BNL_Data_PRD23_2499.root", "BNL_1DQ2_Data");
this->SetupDefaultHist();
// Get correction hist
if (applyQ2correction){
LOG(SAM) <<"Retrieving Q2 Correction"<<std::endl;
this->CorrectionHist = PlotUtils::GetTH1DFromFile(std::string(std::getenv("EXT_FIT")) + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_1DQ2_Correction");
LOG(SAM) << "Creating mcHist NoCORR"<<std::endl;
this->mcHist_NoCorr = (TH1D*) this->mcHist->Clone();
- this->mcHist_NoCorr->SetNameTitle( (this->measurementName + "_NOCORR").c_str(),(this->measurementName + "_NOCORR").c_str());
+ this->mcHist_NoCorr->SetNameTitle( (this->fName + "_NOCORR").c_str(),(this->fName + "_NOCORR").c_str());
}
// Setup Covariance
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
LOG(SAM)<<"Setting up scaling"<<std::endl;
// Setup Scaling
this->eventHist->Scale(this->dataHist->Integral()/this->eventHist->Integral());
// Different generators require slightly different rescaling factors.
this->scaleFactor = (this->eventHist->Integral()/(nevents+0.));
scaleF = -1.0;
};
//********************************************************************
/// @details Reset the histogram uncorrect
void BNL_CCQE_Evt_1DQ2_nu::ResetAll(){
//********************************************************************
Measurement1D::ResetAll();
this->mcHist->Reset();
this->mcFine->Reset();
EnuVsQ2->Reset();
if (applyQ2correction)
this->mcHist_NoCorr->Reset();
}
//********************************************************************
/// @details Extract Enu and totcrs from event assuming quasi-elastic scattering
void BNL_CCQE_Evt_1DQ2_nu::FillEventVariables(FitEvent *event){
//********************************************************************
q2qe = -0.1;
X_VAR = q2qe;
// Fill histogram with reconstructed Q2 Distribution
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
// Look for the outgoing muon
if ((event->PartInfo(j))->fPID != 13) continue;
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
q2qe = FitUtils::Q2QErec((event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
Enu_rec = FitUtils::EnuQErec((event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
break;
}
this->X_VAR = q2qe;
return;
};
//********************************************************************
/// @details Signal is true CCQE scattering
///
/// @details cut 1: CCQE Event
/// @details Cut 2: numu event
/// @details cut 3: Q2 > 0.0
/// @details Cut 4: EnuMin < Enu < EnuMax
bool BNL_CCQE_Evt_1DQ2_nu::isSignal(FitEvent *event){
//********************************************************************
// Signal definition
// - True CCQE numu scattering
/// @details cut 1: numu event
if (Mode != 1) return false;
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict energy range
if (Enu < this->EnuMin || Enu > this->EnuMax) return false;
// Q2 cut
if (q2qe <= 0) return false;
return true;
};
//********************************************************************
/// @details Apply Q2 scaling to weight if required
void BNL_CCQE_Evt_1DQ2_nu::FillHistograms(){
//********************************************************************
if (Signal){
if (applyQ2correction){
this->mcHist_NoCorr->Fill(X_VAR,Weight);
if (X_VAR < 0.225)
this->Weight *= this->CorrectionHist->Interpolate(X_VAR);
}
EnuVsQ2->Fill(Enu,X_VAR, Weight);
}
if (Signal)
Measurement1D::FillHistograms();
// std::cout<<"X_VAR = "<<X_VAR<<" "<<Weight<<std::endl;
return;
}
//********************************************************************
/// @details Apply scaling to uncorrected mcHist_NoCorr and scale to match data
void BNL_CCQE_Evt_1DQ2_nu::ScaleEvents(){
//********************************************************************
this->mcHist->Scale(scaleFactor);
this->mcFine->Scale(scaleFactor);
if (applyQ2correction) this->mcHist_NoCorr->Scale(scaleFactor);
// Scale to match data
scaleF = PlotUtils::GetDataMCRatio(dataHist, mcHist, maskHist);
this->mcHist->Scale(scaleF);
this->mcFine->Scale(scaleF);
if (applyQ2correction){
scaleF = PlotUtils::GetDataMCRatio(dataHist, mcHist_NoCorr, maskHist);
this->mcHist_NoCorr->Scale(scaleF);
}
return;
}
//********************************************************************
/// @brief Include Q2 Correction plots into data write
void BNL_CCQE_Evt_1DQ2_nu::Write(std::string drawOpt){
//********************************************************************
Measurement1D::Write(drawOpt);
EnuVsQ2->Write();
if (applyQ2correction){
this->CorrectionHist->Write();
this->mcHist_NoCorr->Write();
}
return;
}
diff --git a/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx
index c8099f0..a57fb1a 100644
--- a/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx
+++ b/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx
@@ -1,129 +1,129 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "BNL_CCQE_XSec_1DEnu_nu.h"
//********************************************************************
/// @brief BNL CCQE Enu Measurement on Free Nucleons (Ref:PRD23 2499)
///
/// @details Enu Extracted assuming numu CCQE scattering of free nucleons.
//********************************************************************
BNL_CCQE_XSec_1DEnu_nu::BNL_CCQE_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = "BNL_CCQE_XSec_1DEnu_nu";
+ fName = "BNL_CCQE_XSec_1DEnu_nu";
EnuMin = 0.;
EnuMax = 6.;
isDiag = true;
applyQ2correction = type.find("Q2CORR") != std::string::npos;
SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup Plots
this->SetDataFromDatabase("BNL/BNL_Data_PRD23_2499.root", "BNL_1DEnu_Data");
this->SetupDefaultHist();
// Get Correction Hist
if (applyQ2correction){
this->CorrectionHist = PlotUtils::GetTH1DFromFile(std::string(std::getenv("EXT_FIT")) + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_1DQ2_Correction");
}
// Setup Covariance
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Different generators require slightly different rescaling factors.
this->scaleFactor = (this->eventHist->Integral("width")*1E-38/(nevents+0.)); // NEUT
};
//********************************************************************
///@details Fill Enu for the event
void BNL_CCQE_XSec_1DEnu_nu::FillEventVariables(FitEvent *event){
//********************************************************************
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
// Look for the outgoing muon
if ((event->PartInfo(j))->fPID != 13) continue;
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
Enu_rec = FitUtils::EnuQErec((event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
q2qe = FitUtils::Q2QErec((event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
// Once lepton is found, don't continue the loop
break;
}
this->X_VAR = Enu_rec;
return;
};
//********************************************************************
/// @details Signal is true CCQE scattering
///
/// @details Cut 1: numu event
/// @details Cut 2: Mode == 1
/// @details Cut 3: EnuMin < Enu < EnuMax
bool BNL_CCQE_XSec_1DEnu_nu::isSignal(FitEvent *event){
//********************************************************************
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Select only CCQE
if (Mode != 1) return false;
// Restrict energy range
if (Enu < this->EnuMin || Enu > this->EnuMax) return false;
return true;
};
//********************************************************************
/// @details Apply Q2 scaling to weight if required
void BNL_CCQE_XSec_1DEnu_nu::FillHistograms(){
//********************************************************************
if (applyQ2correction){
this->Weight *= this->CorrectionHist->Interpolate(q2qe);
}
Measurement1D::FillHistograms();
}
//********************************************************************
/// @details Perform flux unfolded scaling
void BNL_CCQE_XSec_1DEnu_nu::ScaleEvents(){
//********************************************************************
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
return;
};
diff --git a/src/FCN/JointFCN.cxx b/src/FCN/JointFCN.cxx
index 42b52e0..5819aa6 100755
--- a/src/FCN/JointFCN.cxx
+++ b/src/FCN/JointFCN.cxx
@@ -1,397 +1,403 @@
#include "JointFCN.h"
#include <stdio.h>
#include "FitUtils.h"
//***************************************************
JointFCN::JointFCN(std::string cardfile, TFile *outfile){
//***************************************************
fOutputDir = gDirectory;
fCardFile = cardfile;
LoadSamples(fCardFile);
fCurIter = 0;
fMCFilled = false;
fOutputDir->cd();
fIterationTree = NULL;
fDialVals = NULL;
fNDials = 0;
};
//***************************************************
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){
//***************************************************
LOG(FIT) << " Creating new iteration tree! " << endl;
if (fIterationTree &&
!name.compare(fIterationTree->GetName())){
fIterationTree->Reset();
return;
}
fIterationTree = new TTree(name.c_str(), name.c_str());
// Setup Main Branches
fIterationTree->Branch("total_likelihood",&fLikelihood,"total_likelihood/D");
fIterationTree->Branch("total_ndof", &fNDOF, "total_ndof/I");
// Setup Sample Arrays
int ninputs = fSamples.size() + fPulls.size();
fSampleLikes = new double[ninputs];
fSampleNDOF = new int[ninputs];
fNDOF = GetNDOF();
// Setup Sample Branches
int count = 0;
for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++){
MeasurementBase* exp = *iter;
std::string name = exp->GetName();
std::string liketag = name + "_likelihood";
std::string ndoftag = name + "_ndof";
fIterationTree->Branch(liketag.c_str(), &fSampleLikes[count], (liketag + "/D").c_str());
fIterationTree->Branch(ndoftag.c_str(), &fSampleNDOF[count], (ndoftag + "/D").c_str());
count++;
}
for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++){
ParamPull* pull = *iter;
std::string name = pull->GetName();
std::string liketag = name + "_likelihood";
std::string ndoftag = name + "_ndof";
fIterationTree->Branch(liketag.c_str(), &fSampleLikes[count], (liketag + "/D").c_str());
fIterationTree->Branch(ndoftag.c_str(), &fSampleNDOF[count], (ndoftag + "/D").c_str());
count++;
}
// Add Dial Branches
std::vector<std::string> dials = rw->GetDialNames();
fNDials = dials.size();
fDialVals = new double[fNDials];
for (int i = 0; i < fNDials; i++){
fIterationTree->Branch( dials[i].c_str(), &fDialVals[i],
(dials[i] + "/D").c_str() );
}
}
//***************************************************
void JointFCN::DestroyIterationTree(){
//***************************************************
if (!fIterationTree){
delete fIterationTree;
}
}
//***************************************************
void JointFCN::WriteIterationTree(){
//***************************************************
if (!fIterationTree){
ERR(FTL) << "Can't save empty iteration tree!" << endl;
throw;
}
fIterationTree->Write();
}
//***************************************************
void JointFCN::FillIterationTree(FitWeight* rw) {
//***************************************************
if (!fIterationTree){
ERR(FTL) << "Trying to fill iteration_tree when it is NULL!" << endl;
throw;
}
rw->GetAllDials( fDialVals, fNDials );
fIterationTree->Fill();
}
//***************************************************
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();
}
// SORT SAMPLES
ReconfigureSamples();
// GET TEST STAT
fLikelihood = GetLikelihood();
// PRINT PROGRESS
LOG(FIT) << "Current Stat (iter. "<< this->fCurIter << ") = "<<fLikelihood<<std::endl;
// 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;
cout << exp << endl;
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++;
}
return totaldof;
}
//***************************************************
double JointFCN::GetLikelihood() {
//***************************************************
// 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();
// Save seperate likelihoods
if (fIterationTree){
fSampleLikes[count] = newlike;
}
// 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++;
}
return like;
};
//***************************************************
void JointFCN::LoadSamples(std::string cardinput)
//***************************************************
{
LOG(MIN)<<"Initializing Samples"<<std::endl;
// Read the card file here and load objects
std::string line;
std::ifstream card(cardinput.c_str(), ifstream::in);
// Make sure they are created in correct working DIR
fOutputDir->cd();
while(std::getline(card, line, '\n')){
std::istringstream stream(line);
// Skip Empties
stream >> std::ws;
if (line.c_str()[0] == '#') continue;
if (line.empty()) continue;
// Parse line
std::vector<std::string> samplevect = PlotUtils::FillVectorSFromString(line," ");
// Sample Inputs
if (!samplevect[0].compare("sample")){;
// Get all inputs
std::string name = samplevect[1];
std::string files = samplevect[2];
std::string type = "DEFAULT";
if (samplevect.size() > 3)
type = samplevect[3];
// Create Sample Class
LOG(MIN) << "Loading up sample: "<<name<<" << " <<files << " ("<<type<<")"<<std::endl;
std::string fakeData = "";
fOutputDir->cd();
bool LoadedSample = SampleUtils::LoadSample( &fSamples, name, files, type, fakeData, FitBase::GetRW() );
if (!LoadedSample) {
ERR(FTL) << "Could not load sample provided: "<<name<<std::endl;
ERR(FTL) << "Check spelling with that in src/FCN/SampleList.cxx" << endl;
throw;
}
}
// Sample Inputs
if (!samplevect[0].compare("covar") ||
!samplevect[0].compare("pulls") ||
!samplevect[0].compare("throws")) {
// Get all inputs
std::string name = samplevect[1];
std::string files = samplevect[2];
std::string type = "DEFAULT";
if (samplevect.size() > 3){
type = samplevect[3];
} else if (!samplevect[0].compare("pull")){
type = "GAUSPULL";
} else if (!samplevect[0].compare("throws")){
type = "GAUSTHROWS";
}
// Create Pull Class
LOG(MIN) << "Loading up pull term: "<<name<<" << " <<files << " ("<<type<<")"<<std::endl;
std::string fakeData = "";
fOutputDir->cd();
fPulls.push_back( new ParamPull( name, files, type ) );
}
}
card.close();
};
//***************************************************
void JointFCN::ReconfigureSamples(bool fullconfig) {
//***************************************************
int starttime = time(NULL);
LOG(MIN) << "Starting Reconfigure iter. "<<this->fCurIter<<endl;
// 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;
LOG(MIN) << "Finished Reconfigure iter. " << fCurIter
<< " in " << time(NULL) - starttime << "s"<<endl;
fCurIter++;
}
//***************************************************
void JointFCN::ReconfigureSignal(){
//***************************************************
this->ReconfigureSamples(false);
}
//***************************************************
void JointFCN::ReconfigureAllEvents() {
//***************************************************
this->ReconfigureSamples(true);
}
//***************************************************
void JointFCN::Write(){
//***************************************************
// Loop over individual experiments and call Write
LOG(MIN)<<"Writing each of the data classes..."<<endl;
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();
}
// Save Iteration Tree
if (fIterationTree) fIterationTree->Write();
};
diff --git a/src/FCN/JointFCN.h b/src/FCN/JointFCN.h
new file mode 100755
index 0000000..d0eec88
--- /dev/null
+++ b/src/FCN/JointFCN.h
@@ -0,0 +1,132 @@
+#ifndef _JOINT_FCN_H_
+#define _JOINT_FCN_H_
+/*!
+ * \addtogroup FCN
+ * @{
+ */
+
+#include <iostream>
+#include <vector>
+#include <fstream>
+#include <list>
+
+// ROOT headers
+#include "TTree.h"
+#include "TH1D.h"
+#include "TH2D.h"
+#include <TMatrixDSym.h>
+#include "TGraphErrors.h"
+#include <TVectorD.h>
+#include <TMath.h>
+
+#include "FitUtils.h"
+
+// External fitter headers
+#include "MeasurementBase.h"
+#include "parameter_pulls.h"
+#include "SampleList.h"
+
+#define GetCurrentDir getcwd
+#include "EventManager.h"
+#include "Math/Functor.h"
+#include "ParamPull.h"
+
+using namespace FitUtils;
+using namespace FitBase;
+//! Main FCN Class which ROOT's joint function needs to evaulate the chi2 at each stage of the fit.
+class JointFCN
+{
+ public:
+
+ //! Constructor
+ //! cardfile = Path to input card file listing samples
+ JointFCN(std::string cardfile, TFile *outfile);
+
+ //! Destructor
+ ~JointFCN();
+
+ //! Create sample list from cardfile
+ void LoadSamples(std::string cardFile);
+
+ //! Main Likelihood evaluation FCN
+ double DoEval(const double *x);
+
+ //! Func Wrapper for ROOT
+ inline double operator() (const std::vector<double> & x) {
+ double* x_array = new double[x.size()];
+ return this->DoEval(x_array);
+ };
+
+ //! Func Wrapper for ROOT
+ inline double operator() (const double *x) {
+ return this->DoEval(x);
+ };
+
+ //! Create a TTree to save all dial value iterations for this FCN
+ void CreateIterationTree(std::string name, FitWeight* rw);
+
+ //! Fills dial values and sample likelihoods into tree
+ void FillIterationTree(FitWeight* rw);
+
+ //! Writes TTree to fOutput directory
+ void WriteIterationTree();
+
+ //! Deletes TTree
+ void DestroyIterationTree();
+
+ //! Get Degrees of Freedom for samples (NBins)
+ int GetNDOF();
+
+ //! Return NDOF wrapper
+ inline unsigned int NDim() {return this->GetNDOF();};
+
+ //! Reconfigure samples where we force all events to be looped over.
+ void ReconfigureAllEvents() ;
+
+ //! Call Reconfigure on samples.
+ //! Choice of reconfigure type depends on whether dials have changed
+ //! and the MC has been filled.
+ void ReconfigureSamples(bool fullconfig = false);
+
+ //! Call reconfigure on only signal events (defaults to all events if CurIter=0)
+ void ReconfigureSignal();
+
+ //! Gets likelihood for all samples in FCN (assuming uncorrelated)
+ double GetLikelihood();
+
+ //! Returns list of pointers to the samples
+ inline std::list<MeasurementBase*> GetSampleList(){ return fSamples; }
+
+ //! Return list of pointers to all the pulls
+ inline std::list<ParamPull*> GetPullList(){ return fPulls; };
+
+ //! Write all samples to output DIR
+ void Write();
+
+ private:
+
+ //! Append the experiments to include in the fit to this list
+ std::list<MeasurementBase*> fSamples;
+
+ //! Append parameter pull terms to include penalties in the fit to this list
+ std::list<ParamPull*> fPulls;
+
+ TDirectory *fOutputDir; //!< Directory to save contents
+
+ std::string fCardFile; //!< Input Card text file
+
+ bool fDialChanged; //!< Flag for if RW dials changed
+ UInt_t fCurIter; //!< Counter for how many times reconfigure called
+ bool fMCFilled; //!< Check MC has at least been filled once
+
+ TTree* fIterationTree; //!< Tree to save RW values on each function call
+ int fNDials; //!< Number of RW Dials in FitWeight
+ double* fDialVals; //!< Current Values of RW Dials
+ double fLikelihood; //!< Current likelihood for joint sample likelihood
+ double fNDOF; //!< Total NDOF
+ double* fSampleLikes; //!< Likelihoods for each individual measurement in list
+ int * fSampleNDOF; //!< NDOF for each individual measurement in list
+};
+
+/*! @} */
+#endif // _JOINT_FCN_H_
diff --git a/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx b/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx
index ff07c8a..6c3397e 100644
--- a/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx
+++ b/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx
@@ -1,120 +1,120 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "FNAL_CC1ppip_Evt_1DQ2_nu.h"
// The constructor
FNAL_CC1ppip_Evt_1DQ2_nu::FNAL_CC1ppip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "FNAL_CC1ppip_Evt_1DQ2_nu";
+ fName = "FNAL_CC1ppip_Evt_1DQ2_nu";
plotTitles = "; Q^{2}_{CC1#pi} (GeV^{2}); Number of events";
EnuMin = 10;
EnuMax = 100;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/FNAL/CC1pip_on_p/FNAL_cc1ppip_nEvent_Q2_w14_bin_edit.txt");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")/(nevents+0.)*16./8.;
};
void FNAL_CC1ppip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double q2CCpip;
// FNAL has a M(pi, p) < 1.4 GeV cut imposed only on this channel
if (hadMass < 1400) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
};
bool FNAL_CC1ppip_Evt_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx b/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx
index 249e448..7646114 100644
--- a/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx
+++ b/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx
@@ -1,112 +1,112 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "FNAL_CC1ppip_XSec_1DEnu_nu.h"
// The constructor
FNAL_CC1ppip_XSec_1DEnu_nu::FNAL_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "FNAL_CC1ppip_XSec_1DEnu_nu";
+ fName = "FNAL_CC1ppip_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/proton)";
EnuMin = 10.0;
EnuMax = 100.0;
isDiag = true;
normError = 0.20;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/FNAL/CC1pip_on_p/fnal78-numu-p-to-mu-p-piplus-lowW_edges.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(16./8.);
};
void FNAL_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// wanna calculate hadronic mass, plot and cut for signal
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double Enu;
if (hadMass < 1400) {
Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
}
bool FNAL_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212 /*&& event->Ibound == 0*/) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx b/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx
index 3c5b19d..91c3b19 100644
--- a/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx
+++ b/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx
@@ -1,115 +1,115 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "FNAL_CC1ppip_XSec_1DQ2_nu.h"
// The constructor
FNAL_CC1ppip_XSec_1DQ2_nu::FNAL_CC1ppip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "FNAL_CC1ppip_XSec_1DQ2_nu";
+ fName = "FNAL_CC1ppip_XSec_1DQ2_nu";
plotTitles = "; Q^{2}_{CC1#pi} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/proton)";
EnuMin = 10;
EnuMax = 100;
isDiag = true; // refers to covariance matrix; this measurement has none so only use errors, not covariance
normError = 0.20; // normalisation error on ANL BNL flux
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/FNAL/CC1pip_on_p/FNAL_cc1ppip_dsigdQ2_W14_edit.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = (this->eventHist->Integral("width")/TotalIntegratedFlux("width"))*double(1E-38)/double(nevents)*(16./8.);
};
void FNAL_CC1ppip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double q2CCpip;
// FNAL has a M(pi, p) < 1.4 GeV cut imposed only on this channel
if (hadMass < 1400) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
};
bool FNAL_CC1ppip_XSec_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx b/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx
index bdf4854..b31c082 100755
--- a/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx
+++ b/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx
@@ -1,181 +1,181 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "FNAL_CCQE_Evt_1DQ2_nu.h"
//********************************************************************
/// @brief FNAL CCQE Q2 Measurement on Free Nucleons (Ref: PRD16 3103)
///
/// @details Q2 Extracted assuming numu CCQE scattering of free nucleons.
FNAL_CCQE_Evt_1DQ2_nu::FNAL_CCQE_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw,
std::string type, std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = "FNAL_CCQE_Evt_1DQ2_nu";
+ fName = "FNAL_CCQE_Evt_1DQ2_nu";
EnuMin = 0.;
EnuMax = 200.;
applyQ2correction = type.find("Q2CORR") != std::string::npos;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
isDiag = true;
isRawEvents = true;
this->SetDataFromDatabase("FNAL/FNAL_CCQE_Data_PRD29_436.root", "FNAL_CCQE_Data_1DQ2");
this->SetupDefaultHist();
if (applyQ2correction){
this->CorrectionHist = PlotUtils::GetTH1DFromFile(std::string(std::getenv("EXT_FIT")) + "/data/ANL/ANL_CCQE_Data_PRL31_844.root","ANL_1DQ2_Correction");
this->mcHist_NoCorr = (TH1D*) this->mcHist->Clone();
- this->mcHist_NoCorr->SetNameTitle( (this->measurementName + "_NOCORR").c_str(),(this->measurementName + "_NOCORR").c_str());
+ this->mcHist_NoCorr->SetNameTitle( (this->fName + "_NOCORR").c_str(),(this->fName + "_NOCORR").c_str());
}
// Mask out the first bin if required
this->SetBinMask(std::string(std::getenv("EXT_FIT")) + "/data/FNAL/FNAL_CCQE_BinMask_PRD29_436.dat");
// Setup Covariance
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Different generators require slightly different rescaling factors.
this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // NEUT
// Set starting scale factor
scaleF = -1.0;
};
//********************************************************************
/// @details Extract q2qe from event assuming quasi-elastic scattering
void FNAL_CCQE_Evt_1DQ2_nu::FillEventVariables(FitEvent *event){
//********************************************************************
// Fill histogram with reconstructed Q2 Distribution
q2qe = 0.0;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
// Look for the outgoing muon
if ((event->PartInfo(j))->fPID != 13) continue;
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
q2qe = FitUtils::Q2QErec( (event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
break;
}
this->X_VAR = q2qe;
return;
};
//********************************************************************
/// @brief Signal is defined as True CCQE numu scattering
/// @details cut 1: numu event
/// @details cut 2: EnuMin < Enu < EnuMax
/// @details cut 3: Q2 non-zero
bool FNAL_CCQE_Evt_1DQ2_nu::isSignal(FitEvent *event){
//********************************************************************
// Only look at CCQE Events
if (Mode != 1) return false;
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict energy range
if (Enu < this->EnuMin || Enu > this->EnuMax) return false;
// Q2 cut
if (q2qe <= 0) return false;
return true;
};
//********************************************************************
/// @details Reset the histogram uncorrect
void FNAL_CCQE_Evt_1DQ2_nu::ResetAll(){
//********************************************************************
Measurement1D::ResetAll();
this->mcHist->Reset();
if (applyQ2correction)
this->mcHist_NoCorr->Reset();
}
//********************************************************************
/// @details Apply additional event weights for free nucleon measurements
void FNAL_CCQE_Evt_1DQ2_nu::FillHistograms(){
//********************************************************************
if (applyQ2correction){
this->mcHist_NoCorr->Fill(X_VAR, Weight);
if (X_VAR < 0.225)
this->Weight *= this->CorrectionHist->Interpolate(X_VAR);
}
Measurement1D::FillHistograms();
}
//********************************************************************
void FNAL_CCQE_Evt_1DQ2_nu::ScaleEvents(){
//********************************************************************
this->mcHist->Scale(scaleFactor);
if (applyQ2correction) this->mcHist_NoCorr->Scale(scaleFactor);
// Scale to match data
scaleF = PlotUtils::GetDataMCRatio(dataHist, mcHist, maskHist);
this->mcHist->Scale(scaleF);
this->mcFine->Scale(scaleF);
if (applyQ2correction){
scaleF = PlotUtils::GetDataMCRatio(dataHist, mcHist_NoCorr, maskHist);
this->mcHist_NoCorr->Scale(scaleF);
}
}
//********************************************************************
/// @brief Include Q2 Correction plots into data write
void FNAL_CCQE_Evt_1DQ2_nu::Write(std::string drawOpt){
//********************************************************************
Measurement1D::Write(drawOpt);
if (applyQ2correction){
this->CorrectionHist->Write();
this->mcHist_NoCorr->Write();
}
return;
}
diff --git a/src/FitBase/InputHandler.cxx b/src/FitBase/InputHandler.cxx
index e680b5b..ea9196e 100644
--- a/src/FitBase/InputHandler.cxx
+++ b/src/FitBase/InputHandler.cxx
@@ -1,1011 +1,1011 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "InputHandler.h"
-//***********************************
+//****************************************************************************
InputHandler::InputHandler(std::string handle, std::string infile_name) {
- //***********************************
-
+//****************************************************************************
+
LOG(SAM) << "Creating InputHandler for " << handle << "..." << std::endl;
LOG(SAM) << " -> [" << infile_name << "]" << std::endl;
- // Read in parameters for handler
- this->maxEvents = FitPar::Config().GetParI("MAXEVENTS");
- isJointInput = false;
-
- // Setup a custom Event class
- this->fEvent = new FitEvent();
- this->fSignalEvent = new BaseFitEvt();
- this->inFile = infile_name;
- this->handleName = handle;
+ // Initial Setup
+ fMaxEvents = FitPar::Config().GetParI("MAXEVENTS");
+ fIsJointInput = false;
+ fEvent = FitEvent();
+ fSignalEvent = BaseFitEvt();
+ fInput = infile_name;
+ fName = handle;
// Parse Infile to allow enviornmental flags
- this->inFile = this->ParseInputFile(this->inFile);
-
- LOG(SAM) << " -> Type = " << inType << std::endl;
- LOG(SAM) << " -> Input = " << inFile << std::endl;
+ fInputFile = ParseInputFile(fInput);
+ LOG(SAM) << " -> Type = " << fInputType << std::endl;
+ LOG(SAM) << " -> Input = " << fInputFile << std::endl;
// Automatically check what sort of event file it is
- if (inType.compare("JOINT"))
- this->inRootFile = new TFile(this->inFile.c_str(), "READ");
-
- // Check file exists
- if (this->inRootFile->IsZombie()){
- ERR(FTL) << "Cannot find InputFile!" << endl;
- throw;
+ if (fInputType.compare("JOINT")){
+ fInputRootFile = new TFile(fInputFile.c_str(), "READ");
+
+ if (!fInputRootFile || fInputRootFile->IsZombie()){
+ ERR(FTL) << "Cannot find InputFile!" << endl;
+ throw;
+ }
}
// Setup the handler for each type
- if (!inType.compare("NEUT"))
- this->ReadNeutFile();
- else if (!inType.compare("NUWRO"))
- this->ReadNuWroFile();
- else if (!inType.compare("GENIE"))
- this->ReadGenieFile();
- else if (!inType.compare("GiBUU_nu"))
- this->ReadGiBUUFile(false);
- else if (!inType.compare("GiBUU_nub"))
- this->ReadGiBUUFile(true);
- else if (!inType.compare("HIST"))
- this->ReadHistogramFile();
- else if (!inType.compare("BNSPLN"))
- this->ReadBinSplineFile();
- else if (!inType.compare("EVSPLN"))
- this->ReadEventSplineFile();
- else if (!inType.compare("NUANCE"))
- this->ReadNuanceFile();
- else if (!inType.compare("JOINT"))
- this->ReadJointFile();
+ if (!fInputType.compare("NEUT"))
+ ReadNeutFile();
+ else if (!fInputType.compare("NUWRO"))
+ ReadNuWroFile();
+ else if (!fInputType.compare("GENIE"))
+ ReadGenieFile();
+ else if (!fInputType.compare("GiBUU_nu"))
+ ReadGiBUUFile(false);
+ else if (!fInputType.compare("GiBUU_nub"))
+ ReadGiBUUFile(true);
+ else if (!fInputType.compare("HIST"))
+ ReadHistogramFile();
+ else if (!fInputType.compare("BNSPLN"))
+ ReadBinSplineFile();
+ else if (!fInputType.compare("EVSPLN"))
+ ReadEventSplineFile();
+ else if (!fInputType.compare("NUANCE"))
+ ReadNuanceFile();
+ else if (!fInputType.compare("JOINT"))
+ ReadJointFile();
else {
LOG(FTL) << " -> ERROR: Invalid Event File Type" << std::endl;
- inRootFile->ls();
- exit(-1);
+ fInputRootFile->ls();
+ throw;
}
// Setup MaxEvents After setup of ttree
- if (maxEvents > 1 and maxEvents < nEvents) {
- LOG(SAM) << " -> Reading only " << maxEvents << " events from total."
- << std::endl;
- nEvents = maxEvents;
+ if (fMaxEvents > 1 && fMaxEvents < fNEvents) {
+ LOG(SAM) << " -> Reading only " << fMaxEvents
+ << " events from total." << std::endl;
+ fNEvents = fMaxEvents;
}
- this->fluxList.push_back(this->fFluxHist);
- this->eventList.push_back(this->fEventHist);
- this->xsecList.push_back(this->fXSecHist);
+ fFluxList.push_back(fFluxHist);
+ fEventList.push_back(this->fEventHist);
+ fXSecList.push_back(this->fXSecHist);
LOG(SAM) << " -> Finished handler initialisation." << std::endl;
return;
};
//********************************************************************
std::string InputHandler::ParseInputFile(std::string inputstring) {
//********************************************************************
// Parse out the input_type
const int nfiletypes = 8;
const std::string filetypes[nfiletypes] = {"NEUT", "NUWRO", "GENIE",
"EVSPLN", "JOINT", "NUANCE",
"GiBUU_nu", "GiBUU_nub"};
for (int i = 0; i < nfiletypes; i++) {
- std::string tempTypes = filetypes[i] + ":";
- if (inputstring.find(tempTypes) != std::string::npos) {
- inType = filetypes[i];
- inputstring.replace(inputstring.find(tempTypes), tempTypes.size(), "");
+ std::string temptypes = filetypes[i] + ":";
+ if (inputstring.find(temptypes) != std::string::npos) {
+ fInputType = filetypes[i];
+ inputstring.replace(inputstring.find(temptypes), temptypes.size(), "");
break;
}
}
// If no input type ERROR!
- if (inType.empty()){
+ if (fInputType.empty()){
ERR(FTL) << "No input type supplied for InputHandler!" << endl;
ERR(FTL) << "Problematic Input: " << inputstring << endl;
throw;
}
// Parse out envir flags
const int nfiledir = 5;
const std::string filedir[nfiledir] = {"NEUT_DIR", "NUWRO_DIR", "GENIE_DIR",
"NUANCE_DIR", "EVSPLN_DIR"};
for (int i = 0; i < nfiledir; i++) {
- std::string tempDir = "@" + filedir[i];
- if (inputstring.find(tempDir) != std::string::npos) {
+ std::string tempdir = "@" + filedir[i];
+ if (inputstring.find(tempdir) != std::string::npos) {
std::string event_folder = FitPar::Config().GetParS(filedir[i]);
- inputstring.replace(inputstring.find(tempDir), tempDir.size(),
+ inputstring.replace(inputstring.find(tempdir), tempdir.size(),
event_folder);
break;
}
}
return inputstring;
}
//********************************************************************
bool InputHandler::CanIGoFast() {
- //********************************************************************
+//********************************************************************
if (eventType == 6) {
return true;
}
return false;
}
//********************************************************************
void InputHandler::ReadEventSplineFile() {
- //********************************************************************
-
+//********************************************************************
LOG(SAM) << " -> Setting up SPLINE inputs" << std::endl;
// Event Type 7 SPLINES
- this->eventType = 6;
+ fEventType = 6;
// Get flux histograms NEUT supplies
- this->fFluxHist = (TH1D*)inRootFile->Get((this->handleName + "_FLUX").c_str());
- this->fEventHist = (TH1D*)inRootFile->Get((this->handleName + "_EVT").c_str());
- this->fXSecHist = (TH1D*)inRootFile->Get((this->handleName + "_XSEC").c_str());
+ fFluxHist = (TH1D*) fInputRootFile->Get((fName + "_FLUX").c_str());
+ fEventHist = (TH1D*) fInputRootFile->Get((fName + "_EVT" ).c_str());
+ fXSecHist = (TH1D*) fInputRootFile->Get((fName + "_XSEC").c_str());
// Setup Spline Stuff
- this->splhead = (FitSplineHead*)inRootFile->Get(
- (this->handleName + "_splineHead").c_str());
- tn = new TChain(Form("%s", (this->handleName + "_splineEvents").c_str()), "");
- tn->Add(Form("%s/%s", this->inFile.c_str(),
- (this->handleName + "_splineEvents").c_str()));
+ fSplineHead = (FitSplineHead*)fInputRootFile->Get((fName + "_splineHead").c_str());
+
+ tn = new TChain(Form("%s", (fName + "_splineEvents").c_str()), "");
+ tn->Add(Form("%s/%s", fInputFile.c_str(),(fName + "_splineEvents").c_str()));
// Assign nvect
- nEvents = tn->GetEntries();
- fEvent = NULL;
+ fNEvents = tn->GetEntries();
tn->SetBranchAddress("FitEvent", &fEvent);
// Load Dial Coeffs into vector
- for (int i = 0; i < nEvents; i++) {
+ for (int i = 0; i < fNEvents; i++) {
tn->GetEntry(i);
tn->Show(i);
- spline_list.push_back(*fEvent->dial_coeff);
+ fAllSplines.push_back(*fEvent.dial_coeff);
}
- sleep(5);
// Set MAXEVENTS CALC Here before we load in splines
- if (maxEvents > 1 and maxEvents < nEvents) {
- LOG(SAM) << " -> Reading only " << maxEvents
+ if (fMaxEvents > 1 and fMaxEvents < fNEvents) {
+ LOG(SAM) << " -> Reading only " << fMaxEvents
<< " events from total spline events." << std::endl;
- nEvents = maxEvents;
+ fNEvents = fMaxEvents;
}
// Load all the splines into signal memory
- // for (int i = 0; i < nEvents; i++){
+ // for (int i = 0; i < fNEvents; i++){
// tn->GetEntry(i);
// BaseFitEvt* base_event = (new BaseFitEvt(fEvent));
// base_event->fType=6;
// fSignalEvents.push_back( base_event );
// }
// Print out what was read in
LOG(SAM) << " -> Successfully Read SPLINE file" << std::endl;
- if (LOG_LEVEL(SAM)) this->PrintStartInput();
+ if (LOG_LEVEL(SAM)) PrintStartInput();
int cnt = 1;
std::list<FitSpline*>::iterator spl_iter =
- this->splhead->SplineObjects.begin();
- for (; spl_iter != this->splhead->SplineObjects.end(); spl_iter++) {
+ this->fSplineHead->SplineObjects.begin();
+ for (; spl_iter != this->fSplineHead->SplineObjects.end(); spl_iter++) {
FitSpline* spl = (*spl_iter);
LOG(SAM) << " -> Spline " << cnt << ". " << spl->id << " " << spl->form
<< " "
<< "NDIM(" << spl->ndim << ") "
<< "NPAR(" << spl->npar << ") "
<< "PTS(" << spl->points << ") " << std::endl;
cnt++;
}
}
//********************************************************************
FitSplineHead* InputHandler::GetSplineHead() {
//********************************************************************
- return this->splhead;
+ return fSplineHead;
}
//********************************************************************
void InputHandler::ReadJointFile() {
//********************************************************************
LOG(SAM) << " -> Reading list of inputs from file" << std::endl;
- isJointInput = true;
+
+ fIsJointInput = true;
// Parse Input File
std::string line;
- std::ifstream card(inFile.c_str(), ifstream::in);
+ std::ifstream card(fInputFile.c_str(), ifstream::in);
std::vector<std::string> input_lines;
while (std::getline(card, line, '\n')) {
std::istringstream stream(line);
// Add normalisation option for second line
input_lines.push_back(line);
// Split to get normalisation
}
card.close();
// Loop over input and get the flux files
// Using a temporary input handler to do this, which is a bit dodge.
int count_low = 0;
int temp_type = -1;
for (UInt_t i = 0; i < input_lines.size(); i++) {
// Create Temporary InputHandlers inside
InputHandler* temp_input = new InputHandler(
std::string(Form("temp_input_%i", i)), input_lines.at(i));
if (temp_type != temp_input->GetType() and i > 0) {
ERR(FTL) << " Can't use joint events with mismatched trees yet!"
<< std::endl;
ERR(FTL) << " Make them all the same type!" << std::endl;
}
temp_type = temp_input->GetType();
TH1D* temp_flux = (TH1D*)temp_input->GetFluxHistogram()->Clone();
TH1D* temp_evts = (TH1D*)temp_input->GetEventHistogram()->Clone();
TH1D* temp_xsec = (TH1D*)temp_input->GetXSecHistogram()->Clone();
int temp_events = temp_input->GetNEvents();
temp_flux->SetName(
- (this->handleName + "_" + temp_input->GetInputStateString() + "_FLUX")
+ (fName + "_" + temp_input->GetInputStateString() + "_FLUX")
.c_str());
temp_evts->SetName(
- (this->handleName + "_" + temp_input->GetInputStateString() + "_EVT")
+ (fName + "_" + temp_input->GetInputStateString() + "_EVT")
.c_str());
temp_xsec->SetName(
- (this->handleName + "_" + temp_input->GetInputStateString() + "_XSEC")
+ (fName + "_" + temp_input->GetInputStateString() + "_XSEC")
.c_str());
- this->fluxList.push_back(temp_flux);
- this->eventList.push_back(temp_evts);
- this->xsecList.push_back(temp_xsec);
+ fFluxList.push_back(temp_flux);
+ fEventList.push_back(temp_evts);
+ fXSecList.push_back(temp_xsec);
- this->joint_index_low.push_back(count_low);
- this->joint_index_high.push_back(count_low + temp_events);
- this->joint_index_hist.push_back((TH1D*)temp_evts->Clone());
+ fJointIndexLow.push_back(count_low);
+ fJointIndexHigh.push_back(count_low + temp_events);
+ fJointIndexHist.push_back((TH1D*)temp_evts->Clone());
count_low += temp_events;
if (i == 0) {
- this->fFluxHist = (TH1D*)temp_flux->Clone();
- this->fEventHist = (TH1D*)temp_evts->Clone();
+ fFluxHist = (TH1D*)temp_flux->Clone();
+ fEventHist = (TH1D*)temp_evts->Clone();
} else {
- this->fFluxHist->Add(temp_flux);
- this->fEventHist->Add(temp_evts);
+ fFluxHist->Add(temp_flux);
+ fEventHist->Add(temp_evts);
}
std::cout << "Added Input File " << input_lines.at(i) << std::endl
<< " with " << temp_events << std::endl;
}
// Now have all correctly normalised histograms all we need to do is setup the
// TChains
// Input Assumes all the same type
std::string tree_name = "";
if (temp_type == 0)
tree_name = "neuttree";
else if (temp_type == 1)
tree_name = "treeout";
// Add up the TChains
tn = new TChain(tree_name.c_str());
for (UInt_t i = 0; i < input_lines.size(); i++) {
// PARSE INPUT
std::cout << "Adding new tchain " << input_lines.at(i) << std::endl;
- std::string temp_file = this->ParseInputFile(input_lines.at(i));
+ std::string temp_file = ParseInputFile(input_lines.at(i));
tn->Add(temp_file.c_str());
}
// Setup Events
- nEvents = tn->GetEntries();
+ fNEvents = tn->GetEntries();
if (temp_type == 0) {
#ifdef __NEUT_ENABLED__
- eventType = 0;
+ fEventType = 0;
neut_event = NULL;
tn->SetBranchAddress("vectorbranch", &neut_event);
- this->fEvent->SetEventAddress(&neut_event);
+ fEvent.SetEventAddress(&neut_event);
#endif
} else if (temp_type == 1) {
#ifdef __NUWRO_ENABLED__
- eventType = 1;
+ fEventType = 1;
nuwro_event = NULL;
tn->SetBranchAddress("e", &nuwro_event);
- this->fEvent->SetEventAddress(&nuwro_event);
+ fEvent.SetEventAddress(&nuwro_event);
#endif
}
// Normalise event histogram PDFS for weights
for (UInt_t i = 0; i < input_lines.size(); i++) {
- TH1D* temp_hist = (TH1D*)joint_index_hist.at(i)->Clone();
- joint_index_weight.push_back(
- double(nEvents) / fEventHist->Integral("width") *
- joint_index_hist.at(i)->Integral("width") /
- double(joint_index_high.at(i) - joint_index_low.at(i)));
+ TH1D* temp_hist = (TH1D*)fJointIndexHist.at(i)->Clone();
+ fJointIndexScale.push_back(
+ double(fNEvents) / fEventHist->Integral("width") *
+ fJointIndexHist.at(i)->Integral("width") /
+ double(fJointIndexHigh.at(i) - fJointIndexLow.at(i)));
- temp_hist->Scale(double(nEvents) / fEventHist->Integral("width"));
- temp_hist->Scale(joint_index_hist.at(i)->Integral("width") /
- double(joint_index_high.at(i)));
+ temp_hist->Scale(double(fNEvents) / fEventHist->Integral("width"));
+ temp_hist->Scale(fJointIndexHist.at(i)->Integral("width") /
+ double(fJointIndexHigh.at(i)));
- this->joint_index_hist.at(i) = temp_hist;
+ fJointIndexHist.at(i) = temp_hist;
}
- this->fEventHist->SetNameTitle((this->handleName + "_EVT").c_str(),
- (this->handleName + "_EVT").c_str());
- this->fFluxHist->SetNameTitle((this->handleName + "_FLUX").c_str(),
- (this->handleName + "_FLUX").c_str());
+ fEventHist->SetNameTitle((fName + "_EVT").c_str(),
+ (fName + "_EVT").c_str());
+ fFluxHist->SetNameTitle((fName + "_FLUX").c_str(),
+ (fName + "_FLUX").c_str());
return;
}
//********************************************************************
void InputHandler::ReadNeutFile() {
//********************************************************************
#ifdef __NEUT_ENABLED__
LOG(SAM) << " -> Setting up NEUT inputs" << std::endl;
// Event Type 0 Neut
- this->eventType = 0;
+ fEventType = kNEUT;
// Get flux histograms NEUT supplies
- this->fFluxHist = (TH1D*)inRootFile->Get(
- (PlotUtils::GetObjectWithName(inRootFile, "flux")).c_str());
- this->fFluxHist->SetNameTitle((this->handleName + "_FLUX").c_str(),
- (this->handleName + "; E_{#nu} (GeV)").c_str());
-
- this->fEventHist = (TH1D*)inRootFile->Get(
- (PlotUtils::GetObjectWithName(inRootFile, "evtrt")).c_str());
- this->fEventHist->SetNameTitle(
- (this->handleName + "_EVT").c_str(),
- (this->handleName + "; E_{#nu} (GeV); Event Rate").c_str());
-
- this->fXSecHist = (TH1D*)fEventHist->Clone();
- this->fXSecHist->Divide(this->fFluxHist);
- this->fXSecHist->SetNameTitle(
- (this->handleName + "_XSEC").c_str(),
- (this->handleName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})")
+ fFluxHist = (TH1D*)fInputRootFile->Get(
+ (PlotUtils::GetObjectWithName(fInputRootFile, "flux")).c_str());
+ fFluxHist->SetNameTitle((fName + "_FLUX").c_str(),
+ (fName + "; E_{#nu} (GeV)").c_str());
+
+ fEventHist = (TH1D*)fInputRootFile->Get(
+ (PlotUtils::GetObjectWithName(fInputRootFile, "evtrt")).c_str());
+ fEventHist->SetNameTitle(
+ (fName + "_EVT").c_str(),
+ (fName + "; E_{#nu} (GeV); Event Rate").c_str());
+
+ fXSecHist = (TH1D*)fEventHist->Clone();
+ fXSecHist->Divide(fFluxHist);
+ fXSecHist->SetNameTitle(
+ (fName + "_XSEC").c_str(),
+ (fName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})")
.c_str());
// Read in the file once only
tn = new TChain("neuttree", "");
- tn->Add(Form("%s/neuttree", this->inFile.c_str()));
+ tn->Add(Form("%s/neuttree", fInputFile.c_str()));
// Assign nvect
- nEvents = tn->GetEntries();
+ fNEvents = tn->GetEntries();
neut_event = NULL;
tn->SetBranchAddress("vectorbranch", &neut_event);
// Make the custom event read in nvect when calling CalcKinematics
- this->fEvent->SetEventAddress(&neut_event);
+ fEvent.SetEventAddress(&neut_event);
// Print out what was read in
LOG(SAM) << " -> Successfully Read NEUT file" << std::endl;
- if (LOG_LEVEL(SAM)) this->PrintStartInput();
+ if (LOG_LEVEL(SAM)) PrintStartInput();
#else
ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl;
ERR(FTL) << "NEUT Input Not Enabled." << std::endl;
ERR(FTL) << "Rebuild with --enable-neut or check FitBuild.h!" << std::endl;
exit(-1);
#endif
return;
}
//********************************************************************
void InputHandler::ReadNuWroFile() {
//********************************************************************
#ifdef __NUWRO_ENABLED__
LOG(SAM) << " -> Setting up Nuwro inputs" << std::endl;
// Event Type 1 == NuWro
- this->eventType = 1;
+ fEventType = kNUWRO;
// Setup the TChain for nuwro event tree
tn = new TChain("treeout");
- tn->AddFile(this->inFile.c_str());
+ tn->AddFile(fInputFile.c_str());
// Get entries and nuwro_event
- nEvents = tn->GetEntries();
+ fNEvents = tn->GetEntries();
nuwro_event = NULL;
tn->SetBranchAddress("e", &nuwro_event);
- this->fEvent->SetEventAddress(&nuwro_event);
+ fEvent.SetEventAddress(&nuwro_event);
// Check if we have saved an xsec histogram before
- this->fFluxHist = (TH1D*)inRootFile->Get(
- (PlotUtils::GetObjectWithName(inRootFile, "FluxHist")).c_str());
- this->fEventHist = (TH1D*)inRootFile->Get(
- (PlotUtils::GetObjectWithName(inRootFile, "EvtHist")).c_str());
+ fFluxHist = (TH1D*)fInputRootFile->Get(
+ (PlotUtils::GetObjectWithName(fInputRootFile, "FluxHist")).c_str());
+ fEventHist = (TH1D*)fInputRootFile->Get(
+ (PlotUtils::GetObjectWithName(fInputRootFile, "EvtHist")).c_str());
// Check if we are forcing plot generation (takes time)
bool regenFlux = FitPar::Config().GetParB("input.regen_nuwro_plots");
if (regenFlux)
LOG(SAM)
<< " -> Forcing NuWro XSec/Flux plots to be generated at the start. "
<< std::endl;
// Already generated flux and event histograms
if (fFluxHist and fEventHist and !regenFlux) {
- this->fXSecHist = (TH1D*)inRootFile->Get(
- (PlotUtils::GetObjectWithName(inRootFile, "xsec")).c_str());
+ fXSecHist = (TH1D*)fInputRootFile->Get(
+ (PlotUtils::GetObjectWithName(fInputRootFile, "xsec")).c_str());
- this->fFluxHist->SetNameTitle((this->handleName + "_FLUX").c_str(),
- (this->handleName + "_FLUX").c_str());
- this->fEventHist->SetNameTitle((this->handleName + "_EVT").c_str(),
- (this->handleName + "_EVT").c_str());
- this->fXSecHist->SetNameTitle((this->handleName + "_XSEC").c_str(),
- (this->handleName + "_XSEC").c_str());
+ fFluxHist->SetNameTitle((fName + "_FLUX").c_str(),
+ (fName + "_FLUX").c_str());
+ fEventHist->SetNameTitle((fName + "_EVT").c_str(),
+ (fName + "_EVT").c_str());
+ fXSecHist->SetNameTitle((fName + "_XSEC").c_str(),
+ (fName + "_XSEC").c_str());
// Need to regenerate if not found
} else {
LOG(SAM)
<< " -> No NuWro XSec or Flux Histograms found, need to regenerate!"
<< std::endl;
// Can grab flux histogram from the pars
tn->GetEntry(0);
int beamtype = nuwro_event->par.beam_type;
if (beamtype == 0) {
std::string fluxstring = nuwro_event->par.beam_energy;
std::vector<double> fluxvals =
PlotUtils::FillVectorDFromString(fluxstring, " ");
int pdg = nuwro_event->par.beam_particle;
double Elow = double(fluxvals[0]) / 1000.0;
double Ehigh = double(fluxvals[1]) / 1000.0;
std::cout << " - Adding new nuwro flux "
<< "pdg: " << pdg << "Elow: " << Elow << "Ehigh: " << Ehigh
<< std::endl;
fFluxHist = new TH1D("fluxplot", "fluxplot", fluxvals.size() - 2, Elow, Ehigh);
for (int j = 2; j < fluxvals.size(); j++) {
cout << j << " " << fluxvals[j] << endl;
fFluxHist->SetBinContent(j - 1, fluxvals[j]);
}
} else if (beamtype == 1) {
std::string fluxstring = nuwro_event->par.beam_content;
std::vector<std::string> fluxlines =
PlotUtils::FillVectorSFromString(fluxstring, "\n");
for (int i = 0; i < fluxlines.size(); i++) {
std::vector<double> fluxvals =
PlotUtils::FillVectorDFromString(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;
std::cout << " - Adding new nuwro flux "
<< "pdg: " << pdg << "pctg: " << pctg << "Elow: " << Elow
<< "Ehigh: " << Ehigh << std::endl;
TH1D* fluxplot =
new TH1D("fluxplot", "fluxplot", fluxvals.size() - 4, Elow, Ehigh);
for (int j = 4; j < fluxvals.size(); j++) {
fluxplot->SetBinContent(j + 1, fluxvals[j]);
}
- if (this->fFluxHist)
+ if (fFluxHist)
fFluxHist->Add(fluxplot);
else
- this->fFluxHist = (TH1D*)fluxplot->Clone();
+ fFluxHist = (TH1D*)fluxplot->Clone();
}
}
- this->fFluxHist->SetNameTitle("nuwro_flux",
+ fFluxHist->SetNameTitle("nuwro_flux",
"nuwro_flux;E_{#nu} (GeV); Flux");
- this->fEventHist = (TH1D*)this->fFluxHist->Clone();
- this->fEventHist->Reset();
- this->fEventHist->SetNameTitle("nuwro_evt", "nuwro_evt");
+ fEventHist = (TH1D*)fFluxHist->Clone();
+ fEventHist->Reset();
+ fEventHist->SetNameTitle("nuwro_evt", "nuwro_evt");
- this->fXSecHist = (TH1D*)this->fFluxHist->Clone();
- this->fXSecHist->Reset();
- this->fXSecHist->SetNameTitle("nuwro_xsec", "nuwro_xsec");
+ fXSecHist = (TH1D*)fFluxHist->Clone();
+ fXSecHist->Reset();
+ fXSecHist->SetNameTitle("nuwro_xsec", "nuwro_xsec");
// Start Processing
- LOG(SAM) << " -> Processing NuWro Input Flux for " << nEvents
+ LOG(SAM) << " -> Processing NuWro Input Flux for " << fNEvents
<< " events (This can take a while...) " << std::endl;
double Enu = 0.0;
double TotXSec = 0.0;
double totaleventmode = 0.0;
double totalevents = 0.0;
// --- loop
- for (int i = 0; i < nEvents; i++) {
+ for (int i = 0; i < fNEvents; i++) {
tn->GetEntry(i);
if (i % 100000 == 0) cout << " i " << i << std::endl;
// Get Variables
Enu = nuwro_event->in[0].E() / 1000.0;
TotXSec = nuwro_event->weight;
// Fill a flux and xsec histogram
- this->fEventHist->Fill(Enu);
- this->fXSecHist->Fill(Enu, TotXSec);
+ fEventHist->Fill(Enu);
+ fXSecHist->Fill(Enu, TotXSec);
// Keep Tally
totaleventmode += TotXSec;
totalevents++;
};
LOG(SAM) << " -> Flux Processing Loop Finished." << std::endl;
- if (this->fEventHist->Integral() == 0.0) {
+ if (fEventHist->Integral() == 0.0) {
std::cout << "ERROR NO EVENTS FOUND IN RANGE! " << std::endl;
exit(-1);
}
// Sort out plot scaling
double AvgXSec = (totaleventmode * 1.0E38 / (totalevents + 0.));
LOG(SAM) << " -> Average XSec = " << AvgXSec << std::endl;
- this->fEventHist->Scale(1.0 / fEventHist->Integral()); // Convert to PDF
- this->fEventHist->Scale(this->fFluxHist->Integral() *
+ fEventHist->Scale(1.0 / fEventHist->Integral()); // Convert to PDF
+ fEventHist->Scale(fFluxHist->Integral() *
AvgXSec); // Convert to Proper Event Rate
- this->fXSecHist->Add(fEventHist); // Get Event Rate Plot
- this->fXSecHist->Divide(this->fFluxHist); // Make XSec Plot
+ fXSecHist->Add(fEventHist); // Get Event Rate Plot
+ fXSecHist->Divide(fFluxHist); // Make XSec Plot
- // this->fEventHist = (TH1D*)this->fFluxHist->Clone();
- // this->fEventHist->Multiply(this->fXSecHist);
+ // fEventHist = (TH1D*)fFluxHist->Clone();
+ // fEventHist->Multiply(fXSecHist);
// Clear over/underflows incase they mess with integrals later.
- this->fFluxHist->SetBinContent(0, 0.0);
- this->fFluxHist->SetBinContent(this->fFluxHist->GetNbinsX() + 2, 0.0);
+ fFluxHist->SetBinContent(0, 0.0);
+ fFluxHist->SetBinContent(fFluxHist->GetNbinsX() + 2, 0.0);
- this->fEventHist->SetBinContent(0, 0.0);
- this->fEventHist->SetBinContent(this->fEventHist->GetNbinsX() + 2, 0.0);
+ fEventHist->SetBinContent(0, 0.0);
+ fEventHist->SetBinContent(fEventHist->GetNbinsX() + 2, 0.0);
LOG(SAM)
<< " -> Finished making NuWro event plots. Saving them for next time..."
<< std::endl;
- TFile* temp_save_file = new TFile(this->inFile.c_str(), "UPDATE");
+ TFile* temp_save_file = new TFile(fInputFile.c_str(), "UPDATE");
temp_save_file->cd();
- this->fFluxHist->Write("nuwro_flux", TObject::kOverwrite);
- this->fEventHist->Write("nuwro_evtrt", TObject::kOverwrite);
- this->fXSecHist->Write("nuwro_xsec", TObject::kOverwrite);
+ fFluxHist->Write("nuwro_flux", TObject::kOverwrite);
+ fEventHist->Write("nuwro_evtrt", TObject::kOverwrite);
+ fXSecHist->Write("nuwro_xsec", TObject::kOverwrite);
temp_save_file->ls();
temp_save_file->Close();
delete temp_save_file;
- this->fFluxHist->SetNameTitle((this->handleName + "_FLUX").c_str(),
- (this->handleName + "_FLUX").c_str());
- this->fEventHist->SetNameTitle((this->handleName + "_EVT").c_str(),
- (this->handleName + "_EVT").c_str());
- this->fXSecHist->SetNameTitle((this->handleName + "_XSEC").c_str(),
- (this->handleName + "_XSEC").c_str());
+ fFluxHist->SetNameTitle((fName + "_FLUX").c_str(),
+ (fName + "_FLUX").c_str());
+ fEventHist->SetNameTitle((fName + "_EVT").c_str(),
+ (fName + "_EVT").c_str());
+ fXSecHist->SetNameTitle((fName + "_XSEC").c_str(),
+ (fName + "_XSEC").c_str());
}
// Print out what was read in
LOG(SAM) << " -> Successfully Read NUWRO file" << std::endl;
- if (LOG_LEVEL(SAM)) this->PrintStartInput();
+ if (LOG_LEVEL(SAM)) PrintStartInput();
#else
ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl;
ERR(FTL) << "NuWro Input Not Enabled." << std::endl;
ERR(FTL) << "Rebuild with --enable-nuwro or check FitBuild.h!" << std::endl;
exit(-1);
#endif
return;
}
//********************************************************************
void InputHandler::ReadGenieFile() {
//********************************************************************
#ifdef __GENIE_ENABLED__
// Event Type 1 NuWro
- this->eventType = 5;
+ fEventType = 5;
// Open Root File
- LOG(SAM) << "Reading event file " << this->inFile << std::endl;
+ LOG(SAM) << "Reading event file " << fInputFile << std::endl;
// Get flux histograms NEUT supplies
- this->fFluxHist = (TH1D*)inRootFile->Get(
- (PlotUtils::GetObjectWithName(inRootFile, "spectrum")).c_str());
- this->fFluxHist->SetNameTitle((this->handleName + "_FLUX").c_str(),
- (this->handleName + "; E_{#nu} (GeV)").c_str());
-
- this->fEventHist = (TH1D*)inRootFile->Get(
- (PlotUtils::GetObjectWithName(inRootFile, "spectrum")).c_str());
- this->fEventHist->SetNameTitle(
- (this->handleName + "_EVT").c_str(),
- (this->handleName + "; E_{#nu} (GeV); Event Rate").c_str());
-
- this->fXSecHist = (TH1D*)inRootFile->Get(
- (PlotUtils::GetObjectWithName(inRootFile, "spectrum")).c_str());
- this->fXSecHist->SetNameTitle(
- (this->handleName + "_XSEC").c_str(),
- (this->handleName + "; E_{#nu} (GeV); Event Rate").c_str());
+ fFluxHist = (TH1D*)fInputRootFile->Get(
+ (PlotUtils::GetObjectWithName(fInputRootFile, "spectrum")).c_str());
+ fFluxHist->SetNameTitle((fName + "_FLUX").c_str(),
+ (fName + "; E_{#nu} (GeV)").c_str());
+
+ fEventHist = (TH1D*)fInputRootFile->Get(
+ (PlotUtils::GetObjectWithName(fInputRootFile, "spectrum")).c_str());
+ fEventHist->SetNameTitle(
+ (fName + "_EVT").c_str(),
+ (fName + "; E_{#nu} (GeV); Event Rate").c_str());
+
+ fXSecHist = (TH1D*)fInputRootFile->Get(
+ (PlotUtils::GetObjectWithName(fInputRootFile, "spectrum")).c_str());
+ fXSecHist->SetNameTitle(
+ (fName + "_XSEC").c_str(),
+ (fName + "; E_{#nu} (GeV); Event Rate").c_str());
double average_xsec = 0.0;
int total_events = 0;
// Setup the TChain for nuwro event tree
tn = new TChain("gtree");
- tn->AddFile(this->inFile.c_str());
+ tn->AddFile(fInputFile.c_str());
- nEvents = tn->GetEntries();
+ fNEvents = tn->GetEntries();
LOG(SAM) << "Number of GENIE Eevents " << tn->GetEntries() << std::endl;
genie_event = NULL;
mcrec = NULL;
// NtpMCEventRecord * mcrec = 0; tree->SetBranchAddress(gmrec, &mcrec);
tn->SetBranchAddress("gmcrec", &mcrec);
- this->fEventHist->Reset();
+ fEventHist->Reset();
// Make the custom event read in nvect when calling CalcKinematics
- this->fEvent->SetEventAddress(&mcrec);
+ fEvent.SetEventAddress(&mcrec);
LOG(SAM) << "Processing GENIE flux events." << std::endl;
- for (int i = 0; i < nEvents; i++) {
+ for (int i = 0; i < fNEvents; i++) {
tn->GetEntry(i);
EventRecord& event = *(mcrec->event);
GHepParticle* neu = event.Probe();
GHepRecord genie_record = static_cast<GHepRecord>(event);
// double xsec = (genie_record.XSec() / (1E-38 * genie::units::cm2));
double xsec = (1E+38/genie::units::cm2) * (1.0/2.0) * genie_record.XSec();
average_xsec += xsec;
total_events += 1;
- this->fEventHist->Fill(neu->E());
- this->fXSecHist->Fill(neu->E(), xsec);
+ fEventHist->Fill(neu->E());
+ fXSecHist->Fill(neu->E(), xsec);
mcrec->Clear();
}
average_xsec = average_xsec / (total_events + 0.);
- this->fEventHist->Scale( average_xsec * this->fFluxHist->Integral("width") / total_events, "width" );
- this->fXSecHist = (TH1D*)this->fEventHist->Clone();
- this->fXSecHist->Divide(this->fFluxHist);
+ fEventHist->Scale( average_xsec * fFluxHist->Integral("width") / total_events, "width" );
+ fXSecHist = (TH1D*)fEventHist->Clone();
+ fXSecHist->Divide(fFluxHist);
// Set Titles
- this->fEventHist->SetNameTitle((this->handleName + "_EVT").c_str(),
- (this->handleName + "_EVT;E_{#nu} (GeV); Events (1#times10^{-38})")
+ fEventHist->SetNameTitle((fName + "_EVT").c_str(),
+ (fName + "_EVT;E_{#nu} (GeV); Events (1#times10^{-38})")
.c_str());
- this->fXSecHist->SetNameTitle((this->handleName + "_XSEC").c_str(),
- (this->handleName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})")
+ fXSecHist->SetNameTitle((fName + "_XSEC").c_str(),
+ (fName + "_XSEC;E_{#nu} (GeV); XSec (1#times10^{-38} cm^{2})")
.c_str());
#else
ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl;
ERR(FTL) << "GENIE Input Not Enabled." << std::endl;
ERR(FTL) << "Rebuild with --enable-genie or check FitBuild.h!" << std::endl;
exit(-1);
#endif
return;
}
//********************************************************************
void InputHandler::ReadGiBUUFile(bool IsNuBarDominant) {
//********************************************************************
#ifdef __GiBUU_ENABLED__
- this->eventType = kGiBUU;
+ fEventType = kGiBUU;
// Open Root File
- LOG(SAM) << "Opening event file " << this->inFile << std::endl;
- TFile* rootFile = new TFile(this->inFile.c_str(), "READ");
+ LOG(SAM) << "Opening event file " << fInputFile << std::endl;
+ TFile* rootFile = new TFile(fInputFile.c_str(), "READ");
// Get flux histograms NEUT supplies
TH1D* numuFlux = dynamic_cast<TH1D*>(rootFile->Get("numu_flux"));
TH1D* numubFlux = dynamic_cast<TH1D*>(rootFile->Get("numub_flux"));
if (numuFlux) {
numuFlux = static_cast<TH1D*>(numuFlux->Clone());
numuFlux->SetDirectory(NULL);
numuFlux->SetNameTitle(
- (this->handleName + "_numu_FLUX").c_str(),
- (this->handleName + "; E_{#nu} (GeV); #Phi_{#nu} (A.U.)").c_str());
- fluxList.push_back(numuFlux);
+ (fName + "_numu_FLUX").c_str(),
+ (fName + "; E_{#nu} (GeV); #Phi_{#nu} (A.U.)").c_str());
+ fFluxList.push_back(numuFlux);
}
if (numubFlux) {
numubFlux = static_cast<TH1D*>(numubFlux->Clone());
numubFlux->SetDirectory(NULL);
numubFlux->SetNameTitle(
- (this->handleName + "_numub_FLUX").c_str(),
- (this->handleName + "; E_{#nu} (GeV); #Phi_{#bar{#nu}} (A.U.)")
+ (fName + "_numub_FLUX").c_str(),
+ (fName + "; E_{#nu} (GeV); #Phi_{#bar{#nu}} (A.U.)")
.c_str());
- fluxList.push_back(numubFlux);
+ fFluxList.push_back(numubFlux);
}
rootFile->Close();
// Set flux hist to the dominant mode
fFluxHist = IsNuBarDominant ? numubFlux : numuFlux;
if (!fFluxHist) {
ERR(FTL) << "Couldn't find: "
<< (IsNuBarDominant ? "numub_flux" : "numu_flux")
- << " in input file: " << inRootFile->GetName() << std::endl;
+ << " in input file: " << fInputRootFile->GetName() << std::endl;
exit(1);
}
fFluxHist->SetNameTitle(
- (this->handleName + "_FLUX").c_str(),
- (this->handleName + "; E_{#nu} (GeV);" +
+ (fName + "_FLUX").c_str(),
+ (fName + "; E_{#nu} (GeV);" +
(IsNuBarDominant ? "#Phi_{#bar{#nu}} (A.U.)" : "#Phi_{#nu} (A.U.)"))
.c_str());
tn = new TChain("giRooTracker");
- tn->AddFile(this->inFile.c_str());
+ tn->AddFile(fInputFile.c_str());
fEventHist =
- static_cast<TH1D*>(fFluxHist->Clone((this->handleName + "_EVT").c_str()));
+ static_cast<TH1D*>(fFluxHist->Clone((fName + "_EVT").c_str()));
fEventHist->Reset();
- nEvents = tn->GetEntries();
+ fNEvents = tn->GetEntries();
fEventHist->SetBinContent(
- 1, double(nEvents) / fEventHist->GetXaxis()->GetBinWidth(1));
+ 1, double(fNEvents) / fEventHist->GetXaxis()->GetBinWidth(1));
GiBUUStdHepReader* giRead = new GiBUUStdHepReader();
giRead->SetBranchAddresses(tn);
- fEvent->SetEventAddress(giRead);
+ fEvent.SetEventAddress(giRead);
#endif
}
//********************************************************************
void InputHandler::ReadBinSplineFile() {
//********************************************************************
// Bin Splines are saved as one event for each histogram bin.
// So just read in as normal event splines and it'll all get sorted easily.
}
//********************************************************************
void InputHandler::ReadHistogramFile() {
//********************************************************************
// Convert the raw histogram into a series of events with X variables
// So we don't have to pass stuff upsteam
}
//********************************************************************
void InputHandler::ReadNuanceFile() {
//********************************************************************
#ifdef __NUANCE_ENABLED__
// Read in Nuance output ROOT file (converted from hbook)
LOG(SAM) << " Reading NUANCE " << std::endl;
- eventType = kNUANCE;
+ fEventType = kNUANCE;
// Read in NUANCE Tree
tn = new TChain("h3");
- tn->AddFile(this->inFile.c_str());
+ tn->AddFile(fInputFile.c_str());
// Get entries and nuwro_event
- nEvents = tn->GetEntries();
+ fNEvents = tn->GetEntries();
nuance_event = new NuanceEvent();
// SetBranchAddress for Nuance
// tn->SetBranchAddress("cc",&nuance_event->cc);
// tn->SetBranchAddress("bound",&nuance_event->bound);
tn->SetBranchAddress("neutrino", &nuance_event->neutrino);
tn->SetBranchAddress("target", &nuance_event->target);
tn->SetBranchAddress("channel", &nuance_event->channel);
// tn->SetBranchAddress("iniQ", &nuance_event->iniQ);
// tn->SetBranchAddress("finQ", &nuance_event->finQ);
// tn->SetBranchAddress("lepton0", &nuance_event->lepton0);
// tn->SetBranchAddress("polar", &nuance_event->polar);
// tn->SetBranchAddress("qsq", &nuance_event->qsq);
// tn->SetBranchAddress("w", &nuance_event->w);
// tn->SetBranchAddress("x",&nuance_event->x);
// tn->SetBranchAddress("y",&nuance_event->y);
tn->SetBranchAddress("p_neutrino", &nuance_event->p_neutrino);
tn->SetBranchAddress("p_targ", &nuance_event->p_targ);
// tn->SetBranchAddress("vertex", &nuance_event->vertex);
// tn->SetBranchAddress("start",&nuance_event->start);
// tn->SetBranchAddress("depth",&nuance_event->depth);
// tn->SetBranchAddress("flux",&nuance_event->flux);
tn->SetBranchAddress("n_leptons", &nuance_event->n_leptons);
tn->SetBranchAddress("p_ltot", &nuance_event->p_ltot);
tn->SetBranchAddress("lepton", &nuance_event->lepton);
tn->SetBranchAddress("p_lepton", &nuance_event->p_lepton);
tn->SetBranchAddress("n_hadrons", &nuance_event->n_hadrons);
tn->SetBranchAddress("p_htot", &nuance_event->p_htot);
tn->SetBranchAddress("hadron", &nuance_event->hadron);
tn->SetBranchAddress("p_hadron", &nuance_event->p_hadron);
+
+ fEvent.SetEventAddress(&nuance_event);
- this->fEvent->SetEventAddress(&nuance_event);
-
- this->fFluxHist = new TH1D((this->handleName + "_FLUX").c_str(),
- (this->handleName + "_FLUX").c_str(), 1, 0.0, 1.0);
+ fFluxHist = new TH1D((fName + "_FLUX").c_str(),
+ (fName + "_FLUX").c_str(), 1, 0.0, 1.0);
- this->fFluxHist->SetBinContent(1, 1.0);
+ fFluxHist->SetBinContent(1, 1.0);
- this->fEventHist = new TH1D((this->handleName + "_EVT").c_str(),
- (this->handleName + "_EVT").c_str(), 1, 0.0, 1.0);
- this->fEventHist->SetBinContent(1, nEvents);
+ fEventHist = new TH1D((fName + "_EVT").c_str(),
+ (fName + "_EVT").c_str(), 1, 0.0, 1.0);
+ fEventHist->SetBinContent(1, fNEvents);
#else
ERR(FTL) << "ERROR: Invalid Event File Provided" << std::endl;
ERR(FTL) << "NUANCE Input Not Enabled." << std::endl;
ERR(FTL) << "Rebuild with -DUSE_NUANCE=1!" << std::endl;
exit(-1);
#endif
}
//********************************************************************
void InputHandler::PrintStartInput() {
//********************************************************************
- LOG(SAM) << " -> Total events = " << nEvents << std::endl;
+ LOG(SAM) << " -> Total events = " << fNEvents << std::endl;
LOG(SAM) << " -> Energy Range = " << fFluxHist->GetXaxis()->GetXmin() << "-"
<< fFluxHist->GetXaxis()->GetXmax() << " GeV" << std::endl;
LOG(SAM) << " -> Integrated Flux Hist = "
<< fFluxHist->Integral(0, fFluxHist->GetNbinsX(), "width")
<< std::endl;
LOG(SAM) << " -> Integrated Event Hist = "
<< fEventHist->Integral(0, fEventHist->GetNbinsX(), "width")
<< std::endl;
LOG(SAM) << " -> Integrated Inclusive XSec = "
<< (fEventHist->Integral(0, fEventHist->GetNbinsX(), "width") /
fFluxHist->Integral(0, fFluxHist->GetNbinsX(), "width")) *
1E-38
<< std::endl;
- if (eventType == kEVTSPLINE) return;
+ if (fEventType == kEVTSPLINE) return;
// Get First event info
tn->GetEntry(0);
- fEvent->CalcKinematics();
- LOG(SAM) << " -> Event 0. Neutrino PDG = " << fEvent->PartInfo(0)->fPID
+ fEvent.CalcKinematics();
+ LOG(SAM) << " -> Event 0. Neutrino PDG = " << fEvent.PartInfo(0)->fPID
<< std::endl;
- LOG(SAM) << " Target A = " << fEvent->TargetA
+ LOG(SAM) << " Target A = " << fEvent.TargetA
<< std::endl;
- LOG(SAM) << " Target Z = " << fEvent->TargetZ
+ LOG(SAM) << " Target Z = " << fEvent.TargetZ
<< std::endl;
}
//********************************************************************
std::string InputHandler::GetInputStateString() {
- //********************************************************************
+//********************************************************************
tn->GetEntry(0);
- fEvent->CalcKinematics();
+ fEvent.CalcKinematics();
std::ostringstream state;
- state << "T" << eventType << "_PDG" << fEvent->PartInfo(0)->fPID << "_Z"
- << fEvent->TargetZ << "_A" << fEvent->TargetA;
+ state << "T" << fEventType << "_PDG" << fEvent.PartInfo(0)->fPID << "_Z"
+ << fEvent.TargetZ << "_A" << fEvent.TargetA;
return state.str();
}
//********************************************************************
void InputHandler::ReadEvent(unsigned int i) {
//********************************************************************
bool using_events =
- (eventType == 0 or eventType == 5 or eventType == 1 or
- eventType == kEVTSPLINE or eventType == kNUANCE or eventType == kGiBUU);
+ (fEventType == kNEUT ||
+ fEventType == 5 ||
+ fEventType == kNUWRO ||
+ fEventType == kEVTSPLINE ||
+ fEventType == kNUANCE ||
+ fEventType == kGiBUU);
if (using_events) {
tn->GetEntry(i);
- if (eventType != kEVTSPLINE) fEvent->CalcKinematics();
+ if (fEventType != kEVTSPLINE) fEvent.CalcKinematics();
- fEvent->Index = i;
- cur_entry = i;
- fEvent->InputWeight = GetInputWeight(i);
+ fEvent.Index = i;
+ fEventIndex = i;
+ fEvent.InputWeight = GetInputWeight(i);
} else {
- this->GetTreeEntry(i);
+ GetTreeEntry(i);
}
}
//********************************************************************
void InputHandler::GetTreeEntry(const Long64_t i) {
- //********************************************************************
+//********************************************************************
- if (eventType != kEVTSPLINE)
+ if (fEventType != kEVTSPLINE)
tn->GetEntry(i);
else
- (*(fEvent->dial_coeff)) = spline_list.at(i);
+ (*(fEvent.dial_coeff)) = fAllSplines.at(i);
- cur_entry = i;
- fEvent->InputWeight = GetInputWeight(i);
+ fEventIndex = i;
+ fEvent.InputWeight = GetInputWeight(i);
}
//********************************************************************
double InputHandler::GetInputWeight(const int entry) {
- //********************************************************************
+//********************************************************************
- if (eventType == kGiBUU) {
- return fEvent->InputWeight;
+ if (fEventType == kGiBUU) {
+ return fEvent.InputWeight;
}
- if (!isJointInput) {
+ if (!fIsJointInput) {
return 1.0;
}
double weight = 1.0;
// Find Histogram
- for (UInt_t j = 0; j < joint_index_low.size(); j++) {
- if (entry >= joint_index_low.at(j) and entry < joint_index_high.at(j)) {
- weight *= joint_index_weight.at(j);
+ for (UInt_t j = 0; j < fJointIndexLow.size(); j++) {
+ if (entry >= fJointIndexLow.at(j) and entry < fJointIndexHigh.at(j)) {
+ weight *= fJointIndexScale.at(j);
break;
}
}
return weight;
}
//********************************************************************
int InputHandler::GetGenEvents() {
//********************************************************************
- if (eventType == 6)
- return this->splhead->ngen_events;
+ if (fEventType == 6)
+ return fSplineHead->ngen_events;
else
- return this->GetNEvents();
+ return GetNEvents();
}
//********************************************************************
double InputHandler::TotalIntegratedFlux(double low, double high,
std::string intOpt) {
- //********************************************************************
-
- throw;
+//********************************************************************
- int minBin = this->fFluxHist->GetXaxis()->FindBin(low);
- int maxBin = this->fFluxHist->GetXaxis()->FindBin(high);
+ if( fEventType == kGiBUU){
+ return 1.0;
+ }
+
+ int minBin = fFluxHist->GetXaxis()->FindBin(low);
+ int maxBin = fFluxHist->GetXaxis()->FindBin(high);
double integral =
- this->fFluxHist->Integral(minBin, maxBin + 1, intOpt.c_str());
+ fFluxHist->Integral(minBin, maxBin + 1, intOpt.c_str());
return integral;
};
//********************************************************************
double InputHandler::PredictedEventRate(double low, double high,
std::string intOpt) {
- //********************************************************************
+//********************************************************************
- int minBin = this->fFluxHist->GetXaxis()->FindBin(low);
- int maxBin = this->fFluxHist->GetXaxis()->FindBin(high);
+ int minBin = fFluxHist->GetXaxis()->FindBin(low);
+ int maxBin = fFluxHist->GetXaxis()->FindBin(high);
- return this->fEventHist->Integral(minBin, maxBin + 1, intOpt.c_str());
+ return fEventHist->Integral(minBin, maxBin + 1, intOpt.c_str());
}
diff --git a/src/FitBase/InputHandler.h b/src/FitBase/InputHandler.h
index ee54e1f..a431e16 100644
--- a/src/FitBase/InputHandler.h
+++ b/src/FitBase/InputHandler.h
@@ -1,192 +1,184 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#ifndef INPUT_HANDLER_H
#define INPUT_HANDLER_H
#include "TObject.h"
#include "FitEvent.h"
#include "FitWeight.h"
#include "FitParameters.h"
#include "PlotUtils.h"
#include "FitUtils.h"
#include "stdint.h"
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <cstring>
#ifdef __GENIE_ENABLED__
#include "Conventions/Units.h"
#endif
class InputHandler {
public:
- InputHandler(){};
- ~InputHandler(){};
+ InputHandler (void) {};
+ ~InputHandler (void) {};
InputHandler(std::string handle, std::string infile_name);
std::string ParseInputFile(std::string inputfile);
- void ReadBinSplineFile();
- void ReadHistogramFile();
- void ReadNeutFile();
- void ReadNuanceFile();
- void ReadGenieFile();
+ void ReadBinSplineFile (void);
+ void ReadHistogramFile (void);
+ void ReadNeutFile (void);
+ void ReadNuanceFile (void);
+ void ReadGenieFile (void);
+ void ReadNuWroFile (void);
+ void ReadEventSplineFile (void);
+ void ReadJointFile (void);
void ReadGiBUUFile(bool IsNuBarDominant);
- void ReadNuWroFile();
- void ReadEventSplineFile();
- void ReadJointFile();
- FitSplineHead* GetSplineHead();
- double PredictedEventRate(double low, double high, std::string intOpt="width");
- double TotalIntegratedFlux(double low, double high, std::string intOpt="width");
- FitEvent* GetEventPointer(){ return fEvent; };
- BaseFitEvt* GetSignalPointer(){ return fSignalEvent; };
+ FitSplineHead* GetSplineHead (void);
- int GetNEvents(){ return this->nEvents; };
- int GetGenEvents();
+ double PredictedEventRate (double low, double high, std::string intOpt="width");
+ double TotalIntegratedFlux (double low, double high, std::string intOpt="width");
+
+ inline FitEvent* GetEventPointer (void) { return &fEvent; };
+ inline BaseFitEvt* GetSignalPointer (void) { return &fSignalEvent; };
- void PrintStartInput();
- void ReadEvent(unsigned int i);
+ inline int GetNEvents (void) const { return fNEvents; };
+ int GetGenEvents (void);
- inline TH1D* GetFluxHistogram() { return fFluxHist; };
- inline TH1D* GetEventHistogram() { return fEventHist; };
- inline TH1D* GetXSecHistogram() { return fXSecHist; };
+ void PrintStartInput (void);
+ void ReadEvent(unsigned int i);
- std::vector<TH1*> GetFluxList(){ return this->fluxList;};
- std::vector<TH1*> GetEventList(){ return this->eventList;};
- std::vector<TH1*> GetXSecList(){ return this->xsecList;};
+ inline TH1D* GetFluxHistogram (void) { return fFluxHist; };
+ inline TH1D* GetEventHistogram (void) { return fEventHist; };
+ inline TH1D* GetXSecHistogram (void) { return fXSecHist; };
+
+ std::vector<TH1*> GetFluxList (void) { return this->fluxList; };
+ std::vector<TH1*> GetEventList (void) { return this->eventList; };
+ std::vector<TH1*> GetXSecList (void) { return this->xsecList; };
- int GetType(){return eventType;};
- bool CanIGoFast();
+ inline int GetType(void) const { return fEventType; };
+ bool CanIGoFast (void);
void GetTreeEntry(const Long64_t entry);
- std::string GetInputStateString();
+ std::string GetInputStateString (void);
int eventType;
double GetInputWeight(const int entry=-1);
protected:
- FitEvent* fEvent;
- BaseFitEvt* fSignalEvent;
+ FitEvent fEvent;
+ int fEventType;
+ BaseFitEvt fSignalEvent;
FitSplineHead* fSplineHead;
int fMaxEvents;
int fNEvents;
- int fCurEvt;
+ int fEventIndex;
TH1D* fFluxHist;
TH1D* fEventHist;
TH1D* fXSecHist;
std::string fName;
std::string fInput;
- std::string fInputFile;
std::string fInputType;
+ std::string fInputFile;
TFile* fInputRootFile;
std::vector<BaseFitEvt*> fAllBaseEvents;
std::vector<int> fJointIndexLow;
std::vector<int> fJointIndexHigh;
- std::vector<TH1D*> fJointIndexFlux;
+ std::vector<TH1D*> fJointIndexHist;
std::vector<double> fJointIndexScale;
bool fIsJointInput;
std::vector<TH1*> fXSecList;
std::vector<TH1*> fEventList;
std::vector<TH1*> fFluxList;
std::vector<TArrayD> fAllSplines;
// Event Objects
#ifdef __NEUT_ENABLED__
NeutVect *fNeutVect; //!< Pointer to NEUT Events
#endif
#ifdef __NUWRO_ENABLED__
event* fNuwroEvent; //!< Pointer to NuWro Events (Set to bool if NUWRO disabled)
#endif
#ifdef __GENIE_ENABLED__
GHepRecord* fGenieGHep;
NtpMCEventRecord * fGenieNtpl;
#endif
#ifdef __NUANCE_ENABLED__
NuanceEvent* fNuanceEvt;
#endif
TChain* tn;
- FitSplineHead* splhead;
-
- int maxEvents;
- int nEvents;
- int curevt_i;
-
- // Input Event rate flux/event histograms
- TH1D* fluxHist; //!< Flux Histogram
- TH1D* eventHist; //!< Event Histogram
- TH1D* xsecHist; //!< XSec Histogram
// input root files
TFile* inRootFile; //!< Input ROOT file (e.g NEUT MC)
std::string inFile; ///!< Name of input ROOT file
std::string inType; ///!< Input Type
std::vector<BaseFitEvt*> all_events;
std::string handleName;
#ifdef __NEUT_ENABLED__
NeutVect *neut_event; //!< Pointer to NEUT Events
#endif
#ifdef __NUWRO_ENABLED__
event* nuwro_event; //!< Pointer to NuWro Events (Set to bool if NUWRO disabled)
#endif
#ifdef __GENIE_ENABLED__
GHepRecord* genie_event; //!< Pointer to GENIE GHepRecord
NtpMCEventRecord * mcrec; //!< Pointer to GENIE NTuple Record
#endif
#ifdef __NUANCE_ENABLED__
NuanceEvent* nuance_event;
#endif
std::vector<int> joint_index_low;
std::vector<int> joint_index_high;
std::vector<TH1D*> joint_index_hist;
std::vector<double> joint_index_weight;
- bool isJointInput;
int cur_entry;
std::vector<TH1*> xsecList;
std::vector<TH1*> eventList;
std::vector<TH1*> fluxList;
std::vector<TArrayD> spline_list;
};
#endif
diff --git a/src/FitBase/JointMeas1D.cxx b/src/FitBase/JointMeas1D.cxx
index ebd920f..12238a0 100644
--- a/src/FitBase/JointMeas1D.cxx
+++ b/src/FitBase/JointMeas1D.cxx
@@ -1,465 +1,465 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "JointMeas1D.h"
/*
Constructor/Deconstuctor
*/
//********************************************************************
JointMeas1D::JointMeas1D(){
//********************************************************************
// Reset list
for (std::vector<MeasurementBase*>::const_iterator iter = subChain.begin(); iter != subChain.end(); iter++){
MeasurementBase* exp = *iter;
if (exp) delete exp;
}
// Reset Variables
this->Init();
}
//********************************************************************
JointMeas1D::~JointMeas1D(){
//********************************************************************
// Delete sub experiments
for (std::vector<MeasurementBase*>::const_iterator iter = subChain.begin(); iter != subChain.end(); iter++){
MeasurementBase* exp = *iter;
if (exp) delete exp;
}
}
//********************************************************************
void JointMeas1D::Init(){
//********************************************************************
// Flags for Joint Measurements
isRatio = false;
isSummed = false;
saveSubMeas = false;
// Clear Input Files
subInFiles.clear();
return;
}
/*
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.
subInFiles.clear();
std::istringstream stream(input);
std::string temp_string;
while (std::getline(stream, temp_string, ';')) {
subInFiles.push_back(temp_string);
}
// Set Engine and Fake Data
rw_engine = rw;
fakeDataFile = 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<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
double expflux = exp->TotalIntegratedFlux(intOpt,low,high);
// Fill flux options
if (isRatio){
totalflux = expflux;
break;
}
if (isSummed){
totalflux += expflux;
}
}
return totalflux;
}
/*
Reconfigure Functions
*/
//********************************************************************
void JointMeas1D::Reconfigure(){
//********************************************************************
// This will just call reconfigure explicitly and apply all the standard scalings too each sub sample.
// If you just want to fill event rates into plots make a Reconfigure in the top level sample, you will
// need to loop over each sample explicitly and cast it to an InputHandler before calling ReconfigureAllEvents.
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
exp->Reconfigure();
}
// Joint function called by top level class
MakePlots();
// Do Final Normalisation
- ApplyNormScale( rw_engine->GetSampleNorm( this->measurementName ) );
+ ApplyNormScale( rw_engine->GetSampleNorm( this->fName ) );
return;
}
//********************************************************************
void JointMeas1D::ReconfigureFast(){
//********************************************************************
// This will just call reconfigure explicitly and apply all the standard scalings too each sub sample.
// If you just want to fill event rates into plots make a Reconfigure in the top level sample, you will
// need to loop over each sample explicitly and cast it to an InputHandler before calling ReconfigureAllEvents.
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
exp->ReconfigureFast();
}
// Joint function called by top level class
MakePlots();
// Do Final Normalisation
- ApplyNormScale( rw_engine->GetSampleNorm( this->measurementName ) );
+ ApplyNormScale( rw_engine->GetSampleNorm( this->fName ) );
return;
}
//********************************************************************
void JointMeas1D::MakePlots(){
//********************************************************************
// Reset the 1D histograms but not the subClasses
Measurement1D::ResetAll();
// If Summed
if (isSummed){
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = static_cast<MeasurementBase*>(*expIter);
this->mcHist->Add( exp->GetMCList().at(0) );
this->mcFine->Add( exp->GetFineList().at(0) );
}
return;
}
// If Ratio
if (isRatio){
int sample = 0;
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
if (sample == 0){
this->mcHist->Add( exp->GetMCList().at(0) );
this->mcFine->Add( exp->GetFineList().at(0) );
} else if (sample == 1){
this->mcHist->Divide( exp->GetMCList().at(0) );
this->mcFine->Divide( exp->GetFineList().at(0) );
} else break;
sample++;
}
return;
}
return;
}
/*
Access Functions
*/
//********************************************************************
std::vector<TH1*> JointMeas1D::GetMCList(){
//********************************************************************
// Make Default Vector
std::vector<TH1*> tempVect;
tempVect.push_back( this-> mcHist );
// Return vector from all sub samples
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
std::vector<TH1*> subTempVect = exp->GetMCList();
for(UInt_t i = 0; i < subTempVect.size(); i++){
tempVect.push_back(subTempVect.at(i));
}
}
return tempVect;
}
//********************************************************************
std::vector<TH1*> JointMeas1D::GetDataList(){
//********************************************************************
// Make Default Vector
std::vector<TH1*> tempVect;
tempVect.push_back( this-> dataHist );
// Return vector from all sub samples
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
std::vector<TH1*> subTempVect = exp->GetDataList();
for(UInt_t i = 0; i < subTempVect.size(); i++){
tempVect.push_back(subTempVect.at(i));
}
}
return tempVect;
}
//********************************************************************
std::vector<TH1*> JointMeas1D::GetFineList(){
//********************************************************************
// Make Default Vector
std::vector<TH1*> tempVect;
tempVect.push_back( this-> mcFine );
// Return vector from all sub samples
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
std::vector<TH1*> subTempVect = exp->GetFineList();
for(UInt_t i = 0; i < subTempVect.size(); i++){
tempVect.push_back(subTempVect.at(i));
}
}
return tempVect;
}
//********************************************************************
std::vector<TH1*> JointMeas1D::GetMaskList(){
//********************************************************************
// Make Default Vector
std::vector<TH1*> tempVect;
tempVect.push_back( this-> maskHist );
// Return vector from all sub samples
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
std::vector<TH1*> subTempVect = exp->GetMaskList();
for(UInt_t i = 0; i < subTempVect.size(); i++){
tempVect.push_back(subTempVect.at(i));
}
}
return tempVect;
}
//********************************************************************
std::vector<TH1*> JointMeas1D::GetFluxList(){
//********************************************************************
// Make Default Vector
std::vector<TH1*> tempVect;
tempVect.push_back( this-> fluxHist );
// Return vector from all sub samples
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
std::vector<TH1*> subTempVect = exp->GetFluxList();
for(UInt_t i = 0; i < subTempVect.size(); i++){
tempVect.push_back(subTempVect.at(i));
}
}
return tempVect;
}
//********************************************************************
std::vector<TH1*> JointMeas1D::GetEventRateList(){
//********************************************************************
// Make Default Vector
std::vector<TH1*> tempVect;
tempVect.push_back( this-> eventHist );
// Return vector from all sub samples
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
std::vector<TH1*> subTempVect = exp->GetEventRateList();
for(UInt_t i = 0; i < subTempVect.size(); i++){
tempVect.push_back(subTempVect.at(i));
}
}
return tempVect;
}
//********************************************************************
std::vector<TH1*> JointMeas1D::GetXSecList(){
//********************************************************************
// Make Default Vector
std::vector<TH1*> tempVect;
tempVect.push_back( this-> xsecHist );
// Return vector from all sub samples
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
std::vector<TH1*> subTempVect = exp->GetXSecList();
for(UInt_t i = 0; i < subTempVect.size(); i++){
tempVect.push_back(subTempVect.at(i));
}
}
return tempVect;
}
//********************************************************************
TH1D* JointMeas1D::GetCombinedFlux(){
//********************************************************************
TH1D* newflux;
int sample = 0;
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
// Get flux from experiment
std::vector<TH1*> fluxVect = exp->GetFluxList();
// Setup newflux
if (sample == 0){
newflux = (TH1D*) fluxVect.at(0);
newflux->Reset();
}
// Add all fluxes
for (UInt_t i = 0; i < fluxVect.size(); i++){
newflux->Add( (TH1D*) fluxVect.at(i) );
sample++;
}
}
return newflux;
}
//********************************************************************
TH1D* JointMeas1D::GetCombinedEventRate(){
//********************************************************************
TH1D* newflux;
int sample = 0;
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
// Get flux from experiment
std::vector<TH1*> fluxVect = exp->GetFluxList();
// Setup newflux
if (sample == 0){
newflux =(TH1D*) fluxVect.at(0);
newflux->Reset();
}
// Add all fluxes
for (UInt_t i = 0; i < fluxVect.size(); i++){
newflux->Add( fluxVect.at(i) );
sample++;
}
}
return newflux;
}
/*
Write Functions
*/
//********************************************************************
void JointMeas1D::Write(std::string drawOpt){
//********************************************************************
// Write the top level class
Measurement1D::Write(drawOpt);
if (saveSubMeas){
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = *expIter;
exp->Write(drawOpt);
}
}
return;
};
diff --git a/src/FitBase/Measurement1D.cxx b/src/FitBase/Measurement1D.cxx
index 5bad88c..4cad56e 100644
--- a/src/FitBase/Measurement1D.cxx
+++ b/src/FitBase/Measurement1D.cxx
@@ -1,1216 +1,1216 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "Measurement1D.h"
/*
Constructor/destructor Functions
*/
//********************************************************************
Measurement1D::Measurement1D() {
//********************************************************************
this->currentNorm = 1.0;
this->mcHist = NULL;
this->dataHist = NULL;
this->mcFine = NULL;
this->maskHist = NULL;
this->covar = NULL;
this->fullcovar = NULL;
this->decomp = NULL;
this->fakeDataFile = "";
this->fluxHist = NULL;
this->eventHist = NULL;
this->xsecHist = NULL;
default_types = "FIX/FULL/CHI2";
allowed_types = "FIX,FREE,SHAPE/FULL,DIAG/CHI2/NORM/ENUCORR/Q2CORR/ENU1D/MASK";
isFix = false;
isShape = false;
isFree = false;
isDiag = false;
isFull = false;
addNormPenalty = false;
isMask = false;
isChi2SVD = false;
isRawEvents = false;
isDifXSec = false;
isEnu1D = false;
}
//********************************************************************
Measurement1D::~Measurement1D(){
//********************************************************************
}
//********************************************************************
void Measurement1D::Init(){
//********************************************************************
}
/*
Setup Functions
-- All these are used only at the start of the Measurement
*/
//********************************************************************
void Measurement1D::SetupMeasurement(std::string inputfile, std::string type, FitWeight *rw, std::string fkdt){
//********************************************************************
// Reset everything to NULL
Init();
// Check if name contains Evt, indicating that it is a raw number of events measurements
// and should thus be treated as once
isRawEvents = false;
- if ((measurementName.find("Evt") != std::string::npos) && isRawEvents == false) {
+ if ((fName.find("Evt") != std::string::npos) && isRawEvents == false) {
isRawEvents = true;
LOG(SAM) << "Found event rate measurement but isRawEvents == false!" << std::endl;
LOG(SAM) << "Overriding this and setting isRawEvents == true!" << std::endl;
}
isEnu1D = false;
- if (measurementName.find("XSec_1DEnu") != std::string::npos) {
+ if (fName.find("XSec_1DEnu") != std::string::npos) {
isEnu1D = true;
- LOG(SAM) << "::" << measurementName << "::" << std::endl;
+ LOG(SAM) << "::" << fName << "::" << std::endl;
LOG(SAM) << "Found XSec Enu measurement, applying flux integrated scaling, not flux averaged!" << std::endl;
}
if (isEnu1D && isRawEvents) {
LOG(SAM) << "Found 1D Enu XSec distribution AND isRawEvents, is this really correct?!" << std::endl;
- LOG(SAM) << "Check experiment constructor for " << measurementName << " and correct this!" << std::endl;
+ LOG(SAM) << "Check experiment constructor for " << fName << " and correct this!" << std::endl;
LOG(SAM) << "I live in " << __FILE__ << ":" << __LINE__ << std::endl;
exit(-1);
}
rw_engine = rw;
this->SetupInputs(inputfile);
// Set Default Options
SetFitOptions( this->default_types );
// Set Passed Options
SetFitOptions(type);
// Still adding support for flat flux inputs
// // Set Enu Flux Scaling
// if (isFlatFluxFolding) this->Input()->ApplyFluxFolding( this->defaultFluxHist );
}
//********************************************************************
void Measurement1D::SetupDefaultHist(){
//********************************************************************
// Setup mcHist
this->mcHist = (TH1D*) this->dataHist->Clone();
- this->mcHist->SetNameTitle( (this->measurementName + "_MC").c_str(), (this->measurementName + "_MC" + this->plotTitles).c_str() );
+ this->mcHist->SetNameTitle( (this->fName + "_MC").c_str(), (this->fName + "_MC" + this->plotTitles).c_str() );
// Setup mcFine
Int_t nBins = this->mcHist->GetNbinsX();
- this->mcFine = new TH1D( (this->measurementName + "_MC_FINE").c_str(), (this->measurementName + "_MC_FINE" + this->plotTitles).c_str(),
+ this->mcFine = new TH1D( (this->fName + "_MC_FINE").c_str(), (this->fName + "_MC_FINE" + this->plotTitles).c_str(),
nBins*6, this->mcHist->GetBinLowEdge(1), this->mcHist->GetBinLowEdge(nBins+1) );
mcStat = (TH1D*) mcHist->Clone();
mcStat->Reset();
this->mcHist->Reset();
this->mcFine->Reset();
// Setup the NEUT Mode Array
PlotUtils::CreateNeutModeArray((TH1D*)this->mcHist,(TH1**)this->mcHist_PDG);
PlotUtils::ResetNeutModeArray((TH1**)this->mcHist_PDG);
// Setup bin masks using sample name
if (isMask){
- std::string maskloc = FitPar::Config().GetParDIR( this->measurementName + ".mask");
+ std::string maskloc = FitPar::Config().GetParDIR( this->fName + ".mask");
if (maskloc.empty()){
- maskloc = FitPar::GetDataBase() + "/masks/" + measurementName + ".mask";
+ maskloc = FitPar::GetDataBase() + "/masks/" + fName + ".mask";
}
SetBinMask(maskloc);
}
return;
}
//********************************************************************
void Measurement1D::SetFitOptions(std::string opt){
//********************************************************************
// Do nothing if default given
if (opt == "DEFAULT") return;
// CHECK Conflicting Fit Options
std::vector<std::string> fit_option_allow = PlotUtils::FillVectorSFromString(allowed_types, "/");
for (UInt_t i = 0; i < fit_option_allow.size(); i++){
std::vector<std::string> fit_option_section = PlotUtils::FillVectorSFromString(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){
ERR(FTL) << "ERROR: Conflicting fit options provided: "<<opt<<std::endl;
ERR(FTL) << "Conflicting group = "<<fit_option_section.at(i)<<std::endl;
ERR(FTL) << "You should only supply one of these options in card file."<<std::endl;
exit(-1);
}
}
}
// Check all options are allowed
std::vector<std::string> fit_options_input = PlotUtils::FillVectorSFromString(opt,"/");
for (UInt_t i = 0; i < fit_options_input.size(); i++){
if (allowed_types.find(fit_options_input.at(i)) == std::string::npos){
ERR(FTL) <<"ERROR: Fit Option '"<<fit_options_input.at(i)<<"' Provided is not allowed for this measurement."<<std::endl;
ERR(FTL) <<"Fit Options should be provided as a '/' seperated list (e.g. FREE/DIAG/NORM)" << std::endl;
- ERR(FTL) <<"Available options for "<<measurementName<<" are '"<< allowed_types <<"'"<<std::endl;
+ ERR(FTL) <<"Available options for "<<fName<<" are '"<< allowed_types <<"'"<<std::endl;
exit(-1);
}
}
// Set TYPE
this->fitType = opt;
// FIX,SHAPE,FREE
if (opt.find("FIX") != std::string::npos){
isFree = isShape = false;
isFix = true;
} else if (opt.find("SHAPE") != std::string::npos){
isFree = isFix = false;
isShape = true;
} else if (opt.find("FREE") != std::string::npos){
isFix = isShape = false;
isFree = true;
}
// DIAG,FULL (or default to full)
if (opt.find("DIAG") != std::string::npos){
isDiag = true;
isFull = false;
} else if (opt.find("FULL") != std::string::npos){
isDiag = false;
isFull = true;
}
// CHI2/LL (OTHERS?)
if (opt.find("LOG") != std::string::npos) isChi2 = false;
else isChi2 = true;
// EXTRAS
if (opt.find("RAW") != std::string::npos) isRawEvents = true;
if (opt.find("DIF") != std::string::npos) isDifXSec = true;
if (opt.find("ENU1D") != std::string::npos) isEnu1D = true;
if (opt.find("NORM") != std::string::npos) addNormPenalty = true;
if (opt.find("MASK") != std::string::npos) isMask = true;
return;
};
//********************************************************************
void Measurement1D::SetDataValues(std::string dataFile) {
//********************************************************************
// Override this function if the input file isn't in a suitable format
LOG(SAM) << "Reading data from: " << dataFile.c_str() << std::endl;
- this->dataHist = PlotUtils::GetTH1DFromFile(dataFile, (this->measurementName+"_data"), this->plotTitles);
+ this->dataHist = PlotUtils::GetTH1DFromFile(dataFile, (this->fName+"_data"), this->plotTitles);
this->dataTrue = (TH1D*)this->dataHist->Clone();
return;
};
//********************************************************************
void Measurement1D::SetDataFromDatabase(std::string inhistfile, std::string histname){
//********************************************************************
LOG(SAM) << "Filling histogram from "<< inhistfile << "->"<< histname <<std::endl;
this->dataHist = PlotUtils::GetTH1DFromRootFile((std::string(std::getenv("EXT_FIT")) + "/data/" + inhistfile), histname);
- this->dataHist->SetNameTitle((this->measurementName+"_data").c_str(), (this->measurementName + "_data").c_str());
+ this->dataHist->SetNameTitle((this->fName+"_data").c_str(), (this->fName + "_data").c_str());
return;
};
//********************************************************************
void Measurement1D::SetDataFromFile(std::string inhistfile, std::string histname){
//********************************************************************
LOG(SAM) << "Filling histogram from "<< inhistfile << "->"<< histname <<std::endl;
this->dataHist = PlotUtils::GetTH1DFromRootFile((inhistfile), histname);
return;
};
//********************************************************************
void Measurement1D::SetCovarMatrix(std::string covarFile){
//********************************************************************
// Covariance function, only really used when reading in the MB Covariances.
TFile* tempFile = new TFile(covarFile.c_str(),"READ");
TH2D* covarPlot = new TH2D();
// TH2D* decmpPlot = new TH2D();
TH2D* covarInvPlot = new TH2D();
TH2D* fullcovarPlot = new TH2D();
std::string covName = "";
std::string covOption = FitPar::Config().GetParS("thrown_covariance");
if (this->isShape || this->isFree) covName = "shp_";
if (this->isDiag) covName += "diag";
else covName += "full";
covarPlot = (TH2D*) tempFile->Get((covName + "cov").c_str());
covarInvPlot = (TH2D*) tempFile->Get((covName + "covinv").c_str());
if (!covOption.compare("SUB")) fullcovarPlot = (TH2D*) tempFile->Get((covName + "cov").c_str());
else if (!covOption.compare("FULL")) fullcovarPlot = (TH2D*) tempFile->Get("fullcov");
else ERR(WRN) <<"Incorrect thrown_covariance option in parameters."<<std::endl;
int dim = int(this->dataHist->GetNbinsX());//-this->masked->Integral());
int covdim = int(this->dataHist->GetNbinsX());
this->covar = new TMatrixDSym(dim);
this->fullcovar = new TMatrixDSym(dim);
this->decomp = new TMatrixDSym(dim);
int row,column = 0;
row = 0;
column = 0;
for (Int_t i = 0; i < covdim; i++){
// if (this->masked->GetBinContent(i+1) > 0) continue;
for (Int_t j = 0; j < covdim; j++){
// if (this->masked->GetBinContent(j+1) > 0) continue;
(*this->covar)(row, column) = covarPlot->GetBinContent(i+1,j+1);
(*this->fullcovar)(row, column) = fullcovarPlot->GetBinContent(i+1,j+1);
column++;
}
column = 0;
row++;
}
// Set bin errors on data
if (!this->isDiag){
StatUtils::SetDataErrorFromCov(dataHist, fullcovar);
}
// Get Deteriminant and inverse matrix
covDet = this->covar->Determinant();
TDecompSVD LU = TDecompSVD(*this->covar);
this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), "");
return;
};
//********************************************************************
void Measurement1D::SetCovarMatrixFromText(std::string covarFile, int dim){
//********************************************************************
// WARNING this reads in the data CORRELATIONS
// Make a counter to track the line number
int row = 0;
std::string line;
std::ifstream covar(covarFile.c_str(),ifstream::in);
this->covar = new TMatrixDSym(dim);
this->fullcovar = new TMatrixDSym(dim);
if(covar.is_open()) LOG(SAM) << "Reading covariance matrix from file: " << covarFile << std::endl;
else ERR(FTL) <<"Covariance matrix provided is incorrect: "<<covarFile<<std::endl;
// MINERvA CC1pip needs slightly different method
// Only half the covariance matrix is given and I'm too lazy to write the full one so let the code do it instead
- if (measurementName.find("MINERvA_CC1pip") == std::string::npos && measurementName.find("MINERvA_CCNpip") == std::string::npos) {
+ if (fName.find("MINERvA_CC1pip") == std::string::npos && fName.find("MINERvA_CCNpip") == std::string::npos) {
while(std::getline(covar, line, '\n')){
std::istringstream stream(line);
double entry;
int column = 0;
// Loop over entries and insert them into matrix
// Multiply by the errors to get the covariance, rather than the correlation matrix
while(stream >> entry){
double val = entry * this->dataHist->GetBinError(row+1)*1E38*this->dataHist->GetBinError(column+1)*1E38;
(*this->covar)(row, column) = val;
(*this->fullcovar)(row, column) = val;
column++;
}
row++;
}
// Robust matrix inversion method
TDecompSVD LU = TDecompSVD(*this->covar);
this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), "");
} else { // Here's the MINERvA CC1pip method; very similar
while(std::getline(covar, line, '\n')){
std::istringstream stream(line);
double entry;
int column = 0;
while (column < dim) {
if (column < row) {
(*this->covar)(row,column) = (*this->covar)(column,row);
column++;
} else {
while(stream >> entry){
double val = entry*(this->dataHist->GetBinError(row+1)*1E38*this->dataHist->GetBinError(column+1)*1E38); // need in these units to do Cholesky
(*this->covar)(row, column) = val;
(*this->fullcovar)(row, column) = val;
column++;
}
}
}
row++;
}
// Robust matrix inversion method
TDecompChol a = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(dim, a.Invert().GetMatrixArray(), "");
} // end special treatment for MINERvA CC1pi+
return;
};
//********************************************************************
void Measurement1D::SetSmearingMatrix(std::string smearFile, int true_dim, int reco_dim){
//********************************************************************
// 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(),ifstream::in);
// Note that the smearing matrix may be rectangular.
this->smear = new TMatrixD(true_dim, reco_dim);
if(smear.is_open()) LOG(SAM) << "Reading smearing matrix from file: " << smearFile << std::endl;
else ERR(FTL) <<"Smearing matrix provided is incorrect: "<< smearFile <<std::endl;
while(std::getline(smear, line, '\n')){
std::istringstream stream(line);
double entry;
int column = 0;
while(stream >> entry){
double val = entry;
(*this->smear)(row, column) = val/100.; // Convert to fraction from percentage (this may not be general enough)
column++;
}
row++;
}
return;
}
//********************************************************************
void Measurement1D::SetCovarFromDataFile(std::string covarFile, std::string covName){
//********************************************************************
LOG(SAM) << "Getting covariance from "<<covarFile<<"->"<<covName<<std::endl;
TFile* tempFile = new TFile(covarFile.c_str(),"READ");
TH2D* covPlot = (TH2D*) tempFile->Get(covName.c_str());
covPlot->SetDirectory(0);
int dim = covPlot->GetNbinsX();
this->fullcovar = new TMatrixDSym(dim);
for (int i = 0; i < dim; i++){
for (int j = 0; j < dim; j++){
(*this->fullcovar)(i,j) = covPlot->GetBinContent(i+1,j+1);
}
}
this->covar = (TMatrixDSym*) this->fullcovar->Clone();
this->decomp =(TMatrixDSym*) this->fullcovar->Clone();
TDecompSVD LU = TDecompSVD(*this->covar);
this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), "");
TDecompChol LUChol = TDecompChol(*this->decomp);
LUChol.Decompose();
this->decomp = new TMatrixDSym(dim, LU .GetU().GetMatrixArray(), "");
return;
};
//********************************************************************
void Measurement1D::SetBinMask(std::string maskFile){
//********************************************************************
// Create a mask histogram.
int nbins = this->dataHist->GetNbinsX();
- this->maskHist = new TH1I((this->measurementName+"_maskHist").c_str(),(this->measurementName+"_maskHist; Bin; Mask?").c_str(),nbins,0,nbins);
+ this->maskHist = new TH1I((this->fName+"_maskHist").c_str(),(this->fName+"_maskHist; Bin; Mask?").c_str(),nbins,0,nbins);
std::string line;
std::ifstream mask(maskFile.c_str(),ifstream::in);
if (mask.is_open()) LOG(SAM) <<"Reading bin mask from file: "<<maskFile <<std::endl;
else std::cerr <<" Cannot find mask file."<<std::endl;
while(std::getline(mask, line, '\n')){
std::istringstream stream(line);
int column = 0;
double entry;
int bin;
while (stream >> entry){
if (column == 0) bin = int(entry);
if (column > 1) break;
column++;
}
this->maskHist->SetBinContent(bin,entry);
}
// Set masked data bins to zero
PlotUtils::MaskBins(this->dataHist, this->maskHist);
return;
}
/*
XSec Functions
*/
//********************************************************************
void Measurement1D::SetFluxHistogram(std::string fluxFile, int minE, int maxE, double fluxNorm){
//********************************************************************
// Note this expects the flux bins to be given in terms of MeV
LOG(SAM) << "Reading flux from file: " << fluxFile << std::endl;
TGraph f(fluxFile.c_str(),"%lg %lg");
- this->fluxHist = new TH1D((this->measurementName+"_flux").c_str(), (this->measurementName+"; E_{#nu} (GeV)").c_str(), f.GetN()-1, minE, maxE);
+ this->fluxHist = new TH1D((this->fName+"_flux").c_str(), (this->fName+"; E_{#nu} (GeV)").c_str(), f.GetN()-1, minE, maxE);
Double_t *yVal = f.GetY();
for (int i = 0; i<fluxHist->GetNbinsX(); ++i)
this->fluxHist->SetBinContent(i+1, yVal[i]*fluxNorm);
};
//********************************************************************
double Measurement1D::TotalIntegratedFlux(std::string intOpt, double low, double high){
//********************************************************************
if(GetInput()->GetType() == kGiBUU){
return 1.0;
}
// Set Energy Limits
if (low == -9999.9) low = this->EnuMin;
if (high == -9999.9) high = this->EnuMax;
int minBin = this->fluxHist->GetXaxis()->FindBin(low);
int maxBin = this->fluxHist->GetXaxis()->FindBin(high);
// Get integral over custom range
double integral = this->fluxHist->Integral(minBin, maxBin+1, intOpt.c_str());
return integral;
};
/*
Reconfigure LOOP
*/
//********************************************************************
void Measurement1D::ResetAll(){
//********************************************************************
// Simple function to reset the mc Histograms incase that is all that is needed.
// Clear histograms
this->mcHist->Reset();
this->mcFine->Reset();
this->mcStat->Reset();
PlotUtils::ResetNeutModeArray((TH1**)this->mcHist_PDG);
return;
};
//********************************************************************
void Measurement1D::FillHistograms(){
//********************************************************************
if (Signal){
this->mcHist->Fill(X_VAR, Weight);
this->mcFine->Fill(X_VAR, Weight);
this->mcStat->Fill(X_VAR, 1.0);
PlotUtils::FillNeutModeArray(mcHist_PDG, Mode, X_VAR, Weight);
}
return;
};
//********************************************************************
void Measurement1D::ScaleEvents(){
//********************************************************************
// Simple function to scale to xsec result if this is all that is needed.
// Scale bin errors correctly
TH1D* tempFine = (TH1D*) mcFine->Clone();
// Should apply different scaling for:
// 1D Enu distributions -- need bin by bin flux unfolding (bin by bin flux integration)
// 1D count distributions -- need shape scaling to data
// anything else -- flux averages
// Scaling for raw event rates
if (isRawEvents) {
PlotUtils::ScaleNeutModeArray((TH1**)this->mcHist_PDG, (dataHist->Integral()/mcHist->Integral()), "width");
this->mcHist->Scale(dataHist->Integral()/mcHist->Integral());
this->mcFine->Scale(dataHist->Integral()/mcFine->Integral());
// Scaling for XSec as function of Enu
} else if (isEnu1D) {
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist);
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
// Any other differential scaling
} else {
this->mcHist->Scale(this->scaleFactor, "width");
this->mcFine->Scale(this->scaleFactor, "width");
PlotUtils::ScaleNeutModeArray((TH1**)this->mcHist_PDG, this->scaleFactor, "width");
}
// Proper error scaling - ROOT Freaks out with xsec weights sometimes
// Scale the MC histogram
for(int i=0; i<mcStat->GetNbinsX();i++) {
if (mcStat->GetBinContent(i+1) != 0) {
this->mcHist->SetBinError(i+1, this->mcHist->GetBinContent(i+1) * mcStat->GetBinError(i+1) / mcStat->GetBinContent(i+1) );
} else {
this->mcHist->SetBinError(i+1, this->mcHist->Integral());
}
}
// Scale the fine MC histogram
for(int i=0; i<tempFine->GetNbinsX();i++) {
if (tempFine->GetBinContent(i+1) != 0) {
this->mcFine->SetBinError(i+1, this->mcFine->GetBinContent(i+1) * tempFine->GetBinError(i+1) / tempFine->GetBinContent(i+1) );
} else {
this->mcFine->SetBinError(i+1, this->mcFine->Integral());
}
}
return;
};
//********************************************************************
void Measurement1D::ApplyNormScale(double norm){
//********************************************************************
this->currentNorm = norm;
this->mcHist->Scale(1.0/norm);
this->mcFine->Scale(1.0/norm);
PlotUtils::ScaleNeutModeArray((TH1**)this->mcHist_PDG, 1.0/norm);
return;
};
//********************************************************************
void Measurement1D::ApplySmearingMatrix(){
//********************************************************************
if (!this->smear){
- ERR(WRN) << this->measurementName <<": attempted to apply smearing matrix, but none was set"<<std::endl;
+ ERR(WRN) << this->fName <<": attempted to apply smearing matrix, but none was set"<<std::endl;
return;
}
TH1D* unsmeared = (TH1D*)mcHist->Clone();
TH1D* smeared = (TH1D*)mcHist->Clone();
smeared->Reset();
// Loop over reconstructed bins
// true = row; reco = column
for (int rbin=0; rbin < this->smear->GetNcols(); ++rbin){
// Sum up the constributions from all true bins
double rBinVal = 0;
// Loop over true bins
for (int tbin=0; tbin < this->smear->GetNrows(); ++tbin){
rBinVal += (*this->smear)(tbin,rbin)*unsmeared->GetBinContent(tbin+1);
}
smeared->SetBinContent(rbin+1, rBinVal);
}
this->mcHist = (TH1D*)smeared->Clone();
return;
}
/*
Statistic Functions - Outsources to StatUtils
*/
//********************************************************************
int Measurement1D::GetNDOF(){
//********************************************************************
return this->dataHist->GetNbinsX(); // - this->maskHist->Integral();
}
//********************************************************************
double Measurement1D::GetLikelihood(){
//********************************************************************
double stat = 0.0;
// Fix weird masking bug
if (!isMask){
if (maskHist){
maskHist = NULL;
}
} else {
if (maskHist){
PlotUtils::MaskBins(this->mcHist, this->maskHist);
}
}
// Sort Initial Scaling
double scaleF = this->dataHist->Integral(1,this->dataHist->GetNbinsX(),"width")/this->mcHist->Integral(1, this->mcHist->GetNbinsX(), "width");
if (isShape){
this->mcHist->Scale(scaleF);
this->mcFine->Scale(scaleF);
}
// Get Chi2
if (isChi2){
if (!isDiag){
if (!isChi2SVD) {
stat = StatUtils::GetChi2FromCov(dataHist, mcHist, covar, maskHist);
} else {
stat = StatUtils::GetChi2FromSVD(dataHist,mcHist, fullcovar, maskHist);
}
} else {
if (isRawEvents) {
stat = StatUtils::GetChi2FromEventRate(dataHist, mcHist, maskHist);
} else {
stat = StatUtils::GetChi2FromDiag(dataHist, mcHist, maskHist);
}
}
} else {
if (!this->isDiag){
if (!isChi2SVD) stat = StatUtils::GetLikelihoodFromCov(dataHist, mcHist, covar, maskHist);
else stat = StatUtils::GetLikelihoodFromSVD(dataHist,mcHist, fullcovar, maskHist);
} else {
if (this->isRawEvents) stat = StatUtils::GetLikelihoodFromEventRate(dataHist, mcHist, maskHist);
else stat = StatUtils::GetLikelihoodFromDiag(dataHist, mcHist, maskHist);
}
}
// Sort Penalty Terms
if (this->addNormPenalty){
double penalty = (1. - this->currentNorm)*(1. - this->currentNorm)/(this->normError*this->normError);
stat += penalty;
}
- LOG(REC) << this->measurementName<<": Sample Chi^2 = " << stat <<std::endl;
+ LOG(REC) << this->fName<<": Sample Chi^2 = " << stat <<std::endl;
// Return to normal scaling
if (this->isShape){
this->mcHist->Scale(1./scaleF);
this->mcFine->Scale(1./scaleF);
}
return stat;
}
//********************************************************************
void Measurement1D::SetFakeDataValues(std::string fakeOption) {
//********************************************************************
// Reset things
if (usingfakedata){
this->ResetFakeData();
} else {
usingfakedata = true;
}
// Make a copy of the original data histogram.
- if (!(this->dataOrig)) this->dataOrig = (TH1D*)this->dataHist->Clone((this->measurementName+"_data_original").c_str());
+ if (!(this->dataOrig)) this->dataOrig = (TH1D*)this->dataHist->Clone((this->fName+"_data_original").c_str());
TH1D *tempData = (TH1D*)this->dataHist->Clone();
TFile *fake = new TFile();
if (fakeOption.compare("MC")==0){
LOG(SAM) << "Setting fake data from MC "<<std::endl;
- this->dataHist = (TH1D*)this->mcHist->Clone((this->measurementName+"_MC").c_str());
- if (this->mcHist->Integral() == 0.0) ERR(WRN) << this->measurementName <<": Invalid histogram"<<std::endl;
+ this->dataHist = (TH1D*)this->mcHist->Clone((this->fName+"_MC").c_str());
+ if (this->mcHist->Integral() == 0.0) ERR(WRN) << this->fName <<": Invalid histogram"<<std::endl;
}
else {
fake = new TFile(fakeOption.c_str());
- this->dataHist = (TH1D*)fake->Get((this->measurementName+"_MC").c_str());
+ this->dataHist = (TH1D*)fake->Get((this->fName+"_MC").c_str());
}
- this->dataHist ->SetNameTitle((this->measurementName+"_FAKE").c_str(), (this->measurementName+this->plotTitles).c_str());
+ this->dataHist ->SetNameTitle((this->fName+"_FAKE").c_str(), (this->fName+this->plotTitles).c_str());
this->dataTrue = (TH1D*)this->dataHist->Clone();
- this->dataTrue ->SetNameTitle((this->measurementName+"_FAKE_TRUE").c_str(), (this->measurementName+this->plotTitles).c_str());
+ this->dataTrue ->SetNameTitle((this->fName+"_FAKE_TRUE").c_str(), (this->fName+this->plotTitles).c_str());
int nbins = this->dataHist->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 = this->dataHist->GetBinContent(i+1)/tempData->GetBinContent(i+1);
alpha_j = this->dataHist->GetBinContent(j+1)/tempData->GetBinContent(j+1);
(*this->covar)(i,j) = (1.0/(alpha_i*alpha_j))*(*this->covar)(i,j);
(*this->fullcovar)(i,j) = alpha_i*alpha_j*(*this->fullcovar)(i,j);
}
}
(this->covar) = (TMatrixDSym*) this->fullcovar->Clone();
TDecompSVD LU = TDecompSVD(*this->covar);
this->covar = new TMatrixDSym(nbins, LU .Invert().GetMatrixArray(), "");
return;
};
//********************************************************************
void Measurement1D::ResetFakeData(){
//********************************************************************
if (usingfakedata)
if (this->dataHist) delete dataHist;
- this->dataHist = (TH1D*) this->dataTrue->Clone((this->measurementName+"_FKDAT").c_str());
+ this->dataHist = (TH1D*) this->dataTrue->Clone((this->fName+"_FKDAT").c_str());
return;
}
//********************************************************************
void Measurement1D::ResetData(){
//********************************************************************
if (usingfakedata)
if (this->dataHist) delete dataHist;
- this->dataHist = (TH1D*) this->dataTrue->Clone((this->measurementName+"_Data").c_str());
+ this->dataHist = (TH1D*) this->dataTrue->Clone((this->fName+"_Data").c_str());
usingfakedata = false;
}
//********************************************************************
void Measurement1D::ThrowCovariance(){
//********************************************************************
// Take a decomposition and use it to throw the current dataset.
// Requires dataTrue also be set incase used repeatedly.
delete dataHist;
this->dataHist = StatUtils::ThrowHistogram(this->dataTrue, this->fullcovar);
return;
};
/*
Access Functions
*/
//********************************************************************
std::vector<TH1*> Measurement1D::GetMCList(){
//********************************************************************
// If this isn't a NULL pointer, make the plot pretty!
if (!this->mcHist) return std::vector<TH1*> (1, this->mcHist);
std::ostringstream chi2;
chi2 << std::setprecision(5) << this->GetLikelihood();
int plotcolor = kRed;
if (FitPar::Config().GetParI("linecolour") > 0){
plotcolor = FitPar::Config().GetParI("linecolour");
}
int plotstyle = 1;
if (FitPar::Config().GetParI("linestyle") > 0){
plotstyle = FitPar::Config().GetParI("linestyle");
}
int plotfillstyle=0;
if (FitPar::Config().GetParI("fillstyle") > 0){
plotfillstyle = FitPar::Config().GetParI("fillstyle");
}
- std::cout << measurementName << " chi2 = " << GetLikelihood() << std::endl;
+ std::cout << fName << " chi2 = " << GetLikelihood() << std::endl;
this->mcHist->SetTitle(chi2.str().c_str());
this->mcHist->SetLineWidth(3);
this->mcHist->SetLineColor(plotcolor);
this->mcHist->SetFillColor(plotcolor);
this->mcHist->SetLineStyle(plotstyle);
this->mcHist->SetFillStyle(plotfillstyle);
return std::vector<TH1*> (1, this->mcHist);
};
//********************************************************************
std::vector<TH1*> Measurement1D::GetDataList(){
//********************************************************************
// If this isn't a NULL pointer, make the plot pretty!
if (!this->dataHist) return std::vector<TH1*> (1, this->dataHist);
this->dataHist->SetLineWidth(2);
this->dataHist->SetMarkerStyle(8);
this->dataHist->SetLineColor(kBlack);
return std::vector<TH1*> (1, this->dataHist);
};
//********************************************************************
void Measurement1D::GetBinContents(std::vector<double>& cont, std::vector<double>& err){
//********************************************************************
// Return a vector of the main bin contents
for (int i = 0; i < this->mcHist->GetNbinsX(); i++){
cont.push_back(this->mcHist->GetBinContent(i+1));
err.push_back(this->mcHist->GetBinError(i+1));
}
return;
};
//********************************************************************
std::vector<double> Measurement1D::GetXSec(std::string option){
//********************************************************************
std::vector<double> vals;
vals.push_back(0.0);
vals.push_back(0.0);
bool getMC = !option.compare("MC");
bool getDT = !option.compare("DATA");
for (int i = 0; i < this->mcHist->GetNbinsX(); i++){
if (this->dataHist->GetBinContent(i+1) == 0.0 and this->dataHist->GetBinError(i+1) == 0.0) continue;
if (getMC){
vals[0] += this->mcHist->GetBinContent(i+1) * this->mcHist->GetXaxis()->GetBinWidth(i+1);
vals[1] += this->mcHist->GetBinError(i+1) * this->mcHist->GetBinError(i+1) * this->mcHist->GetXaxis()->GetBinWidth(i+1) * this->mcHist->GetXaxis()->GetBinWidth(i+1);
} else if (getDT){
vals[0] += this->dataHist->GetBinContent(i+1) * this->dataHist->GetXaxis()->GetBinWidth(i+1);
vals[1] += this->dataHist->GetBinError(i+1) * this->dataHist->GetBinError(i+1) * this->dataHist->GetXaxis()->GetBinWidth(i+1) * this->dataHist->GetXaxis()->GetBinWidth(i+1);
}
}
// If not diag Get the total error from the covariance
if (!this->isDiag and !this->isRawEvents and getDT and fullcovar){
vals[1] = 0.0;
for (int i = 0; i < this->dataHist->GetNbinsX(); i++){
for(int j = 0; j < this->dataHist->GetNbinsX(); j++){
vals[1] += (*fullcovar)(i,j);
}
}
vals[1] = sqrt(vals[1]) * 1E-38;
}
return vals;
}
/*
Write Functions
*/
// Save all the histograms at once
//********************************************************************
void Measurement1D::Write(std::string drawOpt){
//********************************************************************
// If null pointer return
if (!this->mcHist and !this->dataHist){
- LOG(SAM) << this->measurementName <<"Incomplete histogram set!"<<std::endl;
+ LOG(SAM) << this->fName <<"Incomplete histogram set!"<<std::endl;
return;
}
// Get Draw Options
drawOpt = FitPar::Config().GetParS("drawopts");
bool drawData = (drawOpt.find("DATA") != std::string::npos);
bool drawNormal = (drawOpt.find("MC") != std::string::npos);
bool drawEvents = (drawOpt.find("EVT") != std::string::npos);
bool drawFine = (drawOpt.find("FINE") != std::string::npos);
bool drawRatio = (drawOpt.find("RATIO") != std::string::npos);
bool drawModes = (drawOpt.find("MODES") != std::string::npos);
bool drawShape = (drawOpt.find("SHAPE") != std::string::npos);
bool residual = (drawOpt.find("RESIDUAL") != std::string::npos);
// bool drawMatrix = (drawOpt.find("MATRIX") != std::string::npos);
// bool drawXSec = (drawOpt.find("XSEC") != std::string::npos);
bool drawFlux = (drawOpt.find("FLUX") != std::string::npos);
bool drawMask = (drawOpt.find("MASK") != std::string::npos);
bool drawCov = (drawOpt.find("COV") != std::string::npos);
bool drawInvCov = (drawOpt.find("INVCOV") != std::string::npos);
bool drawDecomp = (drawOpt.find("DECOMP") != std::string::npos);
bool drawCanvPDG = (drawOpt.find("CANVPDG") != std::string::npos);
bool drawCanvMC = (drawOpt.find("CANVMC") != std::string::npos);
LOG(SAM)<<"Writing Normal Plots" <<std::endl;
// Save standard plots
if (drawData) this->GetDataList().at(0)->Write();
if (drawNormal) this->GetMCList() .at(0)->Write();
// Save only mc and data if splines
if(this->eventType == 4 or this->eventType==3){ return; }
// Draw Extra plots
LOG(SAM)<<"Writing Fine List"<<std::endl;
if (drawFine) this->GetFineList().at(0)->Write();
LOG(SAM)<<"Writing events"<<std::endl;
if (drawFlux) this->fluxHist->Write();
LOG(SAM)<<"Writing true events"<<std::endl;
// if (drawXSec) this->xsecHist->Write();
if (drawEvents) this->eventHist->Write();
- if (isMask and drawMask) this->maskHist->Write( (this->measurementName + "_MSK").c_str() ); //< save mask
+ if (isMask and drawMask) this->maskHist->Write( (this->fName + "_MSK").c_str() ); //< save mask
// Save neut stack
if (drawModes){
LOG(SAM) << "Writing MC Hist PDG"<<std::endl;
- THStack combo_mcHist_PDG = PlotUtils::GetNeutModeStack((this->measurementName + "_MC_PDG").c_str(), (TH1**)this->mcHist_PDG, 0);
+ THStack combo_mcHist_PDG = PlotUtils::GetNeutModeStack((this->fName + "_MC_PDG").c_str(), (TH1**)this->mcHist_PDG, 0);
combo_mcHist_PDG.Write();
}
// Save Matrix plots
if (!isRawEvents and !isDiag){
if (drawCov and fullcovar){
TH2D cov = TH2D((*this->fullcovar));
- cov.SetNameTitle((this->measurementName+"_cov").c_str(),(this->measurementName+"_cov;Bins; Bins;").c_str());
+ cov.SetNameTitle((this->fName+"_cov").c_str(),(this->fName+"_cov;Bins; Bins;").c_str());
cov.Write();
}
if (drawInvCov and covar){
TH2D covinv = TH2D((*this->covar));
- covinv.SetNameTitle((this->measurementName+"_covinv").c_str(),(this->measurementName+"_cov;Bins; Bins;").c_str());
+ covinv.SetNameTitle((this->fName+"_covinv").c_str(),(this->fName+"_cov;Bins; Bins;").c_str());
covinv.Write();
}
if (drawDecomp and decomp){
TH2D covdec = TH2D((*this->decomp));
- covdec.SetNameTitle((this->measurementName+"_covdec").c_str(),(this->measurementName+"_cov;Bins; Bins;").c_str());
+ covdec.SetNameTitle((this->fName+"_covdec").c_str(),(this->fName+"_cov;Bins; Bins;").c_str());
covdec.Write();
}
}
// Save ratio plots if required
if (drawRatio){
// Needed for error bars
for(int i = 0; i < this->mcHist->GetNbinsX()*this->mcHist->GetNbinsY(); i++)
this->mcHist->SetBinError(i+1,0.0);
this->dataHist->GetSumw2();
this->mcHist->GetSumw2();
// Create Ratio Histograms
- TH1D* dataRatio = (TH1D*) this->dataHist->Clone((this->measurementName + "_data_RATIO").c_str());
- TH1D* mcRatio = (TH1D*) this->mcHist->Clone((this->measurementName + "_MC_RATIO").c_str());
+ TH1D* dataRatio = (TH1D*) this->dataHist->Clone((this->fName + "_data_RATIO").c_str());
+ TH1D* mcRatio = (TH1D*) this->mcHist->Clone((this->fName + "_MC_RATIO").c_str());
mcRatio->Divide(this->mcHist);
dataRatio->Divide(this->mcHist);
// Cancel bin errors on MC
for(int i = 0; i < mcRatio->GetNbinsX(); i++)
mcRatio->SetBinError(i+1,this->mcHist->GetBinError(i+1) / this->mcHist->GetBinContent(i+1));
mcRatio->SetMinimum(0);
mcRatio->SetMaximum(2);
dataRatio->SetMinimum(0);
dataRatio->SetMaximum(2);
mcRatio->Write();
dataRatio->Write();
delete mcRatio;
delete dataRatio;
}
// Save Shape Plots if required
if (drawShape){
// Create Shape Histogram
- TH1D* mcShape = (TH1D*) this->mcHist->Clone((this->measurementName + "_MC_SHAPE").c_str());
+ TH1D* mcShape = (TH1D*) this->mcHist->Clone((this->fName + "_MC_SHAPE").c_str());
double shapeScale = dataHist->Integral("width")/mcHist->Integral("width");
mcShape->Scale(shapeScale);
std::stringstream ss;
ss << shapeScale;
mcShape->SetTitle(ss.str().c_str());
mcShape->SetLineWidth(3);
mcShape->SetLineStyle(7); //dashes
mcShape->Write();
// Save shape ratios
if (drawRatio) {
// Needed for error bars
mcShape->GetSumw2();
// Create shape ratio histograms
- TH1D* mcShapeRatio = (TH1D*)mcShape->Clone((this->measurementName + "_MC_SHAPE_RATIO").c_str());
- TH1D* dataShapeRatio = (TH1D*)dataHist->Clone((this->measurementName + "_data_SHAPE_RATIO").c_str());
+ TH1D* mcShapeRatio = (TH1D*)mcShape->Clone((this->fName + "_MC_SHAPE_RATIO").c_str());
+ TH1D* dataShapeRatio = (TH1D*)dataHist->Clone((this->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); // dashes
mcShapeRatio ->Write();
dataShapeRatio->Write();
delete mcShapeRatio;
delete dataShapeRatio;
}
delete mcShape;
}
// Save residual calculations of what contributed to the chi2 values.
if (residual){
}
// Make a pretty PDG Canvas
if (drawCanvPDG or true){
- TCanvas* c1 = new TCanvas((this->measurementName + "_PDG_CANV").c_str(),
- (this->measurementName + "_PDG_CANV").c_str(),
+ TCanvas* c1 = new TCanvas((this->fName + "_PDG_CANV").c_str(),
+ (this->fName + "_PDG_CANV").c_str(),
800,600);
dataHist->Draw("E1");
mcHist->Draw("HIST SAME");
- THStack combo_mcHist_PDG = PlotUtils::GetNeutModeStack((this->measurementName + "_MC_PDG").c_str(),
+ THStack combo_mcHist_PDG = PlotUtils::GetNeutModeStack((this->fName + "_MC_PDG").c_str(),
(TH1**)this->mcHist_PDG, 0);
combo_mcHist_PDG.Draw("HIST SAME");
TLegend leg = PlotUtils::GenerateStackLegend(combo_mcHist_PDG, 0.6,0.6,0.9,0.9);
dataHist->Draw("E1 SAME");
//leg.Draw("SAME");
c1->Write();
}
if (drawCanvMC or true){
- TCanvas* c1 = new TCanvas((this->measurementName + "_MC_CANV").c_str(),
- (this->measurementName + "_MC_CANV").c_str(),
+ TCanvas* c1 = new TCanvas((this->fName + "_MC_CANV").c_str(),
+ (this->fName + "_MC_CANV").c_str(),
800,600);
c1->cd();
dataHist->Draw("E1");
mcHist->Draw("SAME HIST C");
- TH1D* mcShape = (TH1D*) this->mcHist->Clone((this->measurementName + "_MC_SHAPE").c_str());
+ TH1D* mcShape = (TH1D*) this->mcHist->Clone((this->fName + "_MC_SHAPE").c_str());
double shapeScale = dataHist->Integral("width")/mcHist->Integral("width");
mcShape->Scale(shapeScale);
mcShape->SetLineStyle(7);
mcShape->Draw("SAME HIST C");
TLegend* leg = new TLegend(0.6,0.6,0.9,0.9);
- leg->AddEntry(dataHist, (this->measurementName + " Data").c_str(), "ep");
- leg->AddEntry(mcHist, (this->measurementName + " MC").c_str(), "l");
- leg->AddEntry(mcShape, (this->measurementName + " Shape").c_str(), "l");
+ leg->AddEntry(dataHist, (this->fName + " Data").c_str(), "ep");
+ leg->AddEntry(mcHist, (this->fName + " MC").c_str(), "l");
+ leg->AddEntry(mcShape, (this->fName + " Shape").c_str(), "l");
}
// Returning
- LOG(SAM) << this->measurementName << "Written Histograms: "<<this->measurementName<<std::endl;
+ LOG(SAM) << this->fName << "Written Histograms: "<<this->fName<<std::endl;
return;
};
THStack Measurement1D::GetModeStack(){
- THStack combo_hist = PlotUtils::GetNeutModeStack((this->measurementName + "_MC_PDG").c_str(), (TH1**)this->mcHist_PDG, 0);
+ THStack combo_hist = PlotUtils::GetNeutModeStack((this->fName + "_MC_PDG").c_str(), (TH1**)this->mcHist_PDG, 0);
return combo_hist;
}
diff --git a/src/FitBase/Measurement2D.cxx b/src/FitBase/Measurement2D.cxx
index 1fd340b..5b13e89 100644
--- a/src/FitBase/Measurement2D.cxx
+++ b/src/FitBase/Measurement2D.cxx
@@ -1,1236 +1,1236 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "Measurement2D.h"
#include "TDecompChol.h"
//********************************************************************
Measurement2D::Measurement2D() {
//********************************************************************
covar = NULL;
decomp = NULL;
fullcovar = NULL;
mcHist = NULL;
mcFine = NULL;
dataHist = NULL;
mcHist_X = NULL;
mcHist_Y = NULL;
dataHist_X = NULL;
dataHist_Y = NULL;
maskHist = NULL;
mapHist = NULL;
dataOrig = NULL;
dataTrue = NULL;
default_types = "FIX/FULL/CHI2";
allowed_types = "FIX,FREE,SHAPE/FULL,DIAG/CHI2/NORM/ENUCORR/Q2CORR/ENU1D/FITPROJX/FITPROJY";
isFix = false;
isShape = false;
isFree = false;
isDiag = false;
isFull = false;
addNormPenalty = false;
isMask = false;
isChi2SVD = false;
isRawEvents = false;
isDifXSec = false;
isEnu1D = false;
isEnu = false;
};
//********************************************************************
Measurement2D:: ~Measurement2D() {
//********************************************************************
};
/*
Setup Functions
*/
//********************************************************************
void Measurement2D::SetupMeasurement(std::string inputfile, std::string type, FitWeight *rw, std::string fkdt){
//********************************************************************
// Reset everything to NULL
rw_engine = rw;
// Setting up 2D Inputs
this->SetupInputs(inputfile);
// Set Default Options
SetFitOptions( this->default_types );
// Set Passed Options
SetFitOptions(type);
}
//********************************************************************
void Measurement2D::SetupDefaultHist(){
//********************************************************************
// Setup mcHist
this->mcHist = (TH2D*) this->dataHist->Clone();
- this->mcHist->SetNameTitle( (this->measurementName + "_MC").c_str(), (this->measurementName + "_MC" + this->plotTitles).c_str() );
+ this->mcHist->SetNameTitle( (this->fName + "_MC").c_str(), (this->fName + "_MC" + this->plotTitles).c_str() );
// Setup mcFine
Int_t nBinsX = this->mcHist->GetNbinsX();
Int_t nBinsY = this->mcHist->GetNbinsY();
- this->mcFine = new TH2D( (this->measurementName + "_MC_FINE").c_str(), (this->measurementName + "_MC_FINE" + this->plotTitles).c_str(),
+ this->mcFine = new TH2D( (this->fName + "_MC_FINE").c_str(), (this->fName + "_MC_FINE" + this->plotTitles).c_str(),
nBinsX*3, this->mcHist->GetXaxis()->GetBinLowEdge(1), this->mcHist->GetXaxis()->GetBinLowEdge(nBinsX+1),
nBinsY*3, this->mcHist->GetYaxis()->GetBinLowEdge(1), this->mcHist->GetYaxis()->GetBinLowEdge(nBinsY+1));
// Setup the NEUT Mode Array
PlotUtils::CreateNeutModeArray(this->mcHist,(TH1**)this->mcHist_PDG);
// Setup bin masks using sample name
if (isMask){
- std::string maskloc = FitPar::Config().GetParDIR( this->measurementName + ".mask");
+ std::string maskloc = FitPar::Config().GetParDIR( this->fName + ".mask");
if (maskloc.empty()){
- maskloc = FitPar::GetDataBase() + "/masks/" + measurementName + ".mask";
+ maskloc = FitPar::GetDataBase() + "/masks/" + fName + ".mask";
}
SetBinMask(maskloc);
}
return;
}
//********************************************************************
void Measurement2D::SetFitOptions(std::string opt){
//********************************************************************
// Do nothing if set DEFAULT
if (opt == "DEFAULT") return;
// CHECK Conflicting Fit Options
std::vector<std::string> fit_option_allow = PlotUtils::FillVectorSFromString(allowed_types, "/");
for (UInt_t i = 0; i < fit_option_allow.size(); i++){
std::vector<std::string> fit_option_section = PlotUtils::FillVectorSFromString(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){
ERR(FTL) << "ERROR: Conflicting fit options provided: "<<opt<<std::endl;
ERR(FTL) << "Conflicting group = "<<fit_option_section.at(i)<<std::endl;
ERR(FTL) << "You should only supply one of these options in card file."<<std::endl;
exit(-1);
}
}
}
// Check all options are allowed
std::vector<std::string> fit_options_input = PlotUtils::FillVectorSFromString(opt,"/");
for (UInt_t i = 0; i < fit_options_input.size(); i++){
if (allowed_types.find(fit_options_input.at(i)) == std::string::npos){
ERR(FTL) <<"ERROR: Fit Option '"<<fit_options_input.at(i)<<"' Provided is not allowed for this measurement."<<std::endl;
ERR(FTL) <<"Fit Options should be provided as a '/' seperated list (e.g. FREE/DIAG/NORM)" << std::endl;
- ERR(FTL) <<"Available options for "<<measurementName<<" are '"<< allowed_types <<"'"<<std::endl;
+ ERR(FTL) <<"Available options for "<<fName<<" are '"<< allowed_types <<"'"<<std::endl;
exit(-1);
}
}
// Set TYPE
this->fitType = opt;
// FIX,SHAPE,FREE
if (opt.find("FIX") != std::string::npos){
isFree = isShape = false;
isFix = true;
} else if (opt.find("SHAPE") != std::string::npos){
isFree = isFix = false;
isShape = true;
} else if (opt.find("FREE") != std::string::npos){
isFix = isShape = false;
isFree = true;
}
// DIAG,FULL (or default to full)
if (opt.find("DIAG") != std::string::npos){
isDiag = true;
isFull = false;
} else if (opt.find("FULL") != std::string::npos){
isDiag = false;
isFull = true;
}
// CHI2/LL (OTHERS?)
if (opt.find("LOG") != std::string::npos) isChi2 = false;
else isChi2 = true;
// EXTRAS
if (opt.find("RAW") != std::string::npos) isRawEvents = true;
if (opt.find("DIF") != std::string::npos) isDifXSec = true;
if (opt.find("ENU1D") != std::string::npos) isEnu1D = true;
if (opt.find("NORM") != std::string::npos) addNormPenalty = true;
if (opt.find("MASK") != std::string::npos) isMask = true;
this->isProjFitX = (opt.find("FITPROJX") != std::string::npos);
this->isProjFitY = (opt.find("FITPROJY") != std::string::npos);
return;
};
//********************************************************************
void Measurement2D::SetDataValues(std::string dataFile, std::string TH2Dname) {
//********************************************************************
if (dataFile.find(".root") == std::string::npos) {
std::cerr << "Error! " << dataFile << " is not a .root file" << std::endl;
std::cerr << "Currently only .root file reading is supported (MiniBooNE CC1pi+ 2D), but implementing .txt should be dirt easy" << std::endl;
std::cerr << "See me at " << __FILE__ << ":" << __LINE__ << std::endl;
exit(-1);
} else {
TFile *inFile = new TFile(dataFile.c_str(), "READ");
dataHist = (TH2D*)(inFile->Get(TH2Dname.c_str())->Clone());
dataHist->SetDirectory(0);
- dataHist->SetNameTitle((measurementName+"_data").c_str(), (measurementName+"_MC"+plotTitles).c_str());
+ dataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+plotTitles).c_str());
delete inFile;
}
return;
}
//********************************************************************
void Measurement2D::SetDataValues(std::string dataFile, double dataNorm, std::string errorFile, double errorNorm) {
//********************************************************************
// Make a counter to track the line number
int yBin = 0;
std::string line;
std::ifstream data(dataFile.c_str(),ifstream::in);
- this->dataHist = new TH2D((this->measurementName+"_data").c_str(), (this->measurementName+this->plotTitles).c_str(), this->data_points_x-1, this->xBins, this->data_points_y-1, this->yBins);
+ this->dataHist = new TH2D((this->fName+"_data").c_str(), (this->fName+this->plotTitles).c_str(), this->data_points_x-1, this->xBins, this->data_points_y-1, this->yBins);
if(data.is_open()) LOG(SAM) << "Reading data from: " << dataFile.c_str() << std::endl;
while(std::getline(data, line, '\n')){
std::istringstream stream(line);
double entry;
int xBin = 0;
// Loop over entries and insert them into the histogram
while(stream >> entry){
this->dataHist->SetBinContent(xBin+1, yBin+1, entry*dataNorm);
xBin++;
}
yBin++;
}
yBin = 0;
std::ifstream error(errorFile.c_str(),ifstream::in);
if(error.is_open()) LOG(SAM) << "Reading errors from: " << errorFile.c_str() << std::endl;
while(std::getline(error, line, '\n')){
std::istringstream stream(line);
double entry;
int xBin = 0;
// Loop over entries and insert them into the histogram
while(stream >> entry){
this->dataHist->SetBinError(xBin+1, yBin+1, entry*errorNorm);
xBin++;
}
yBin++;
}
return;
};
//********************************************************************
void Measurement2D::SetDataValuesFromText(std::string dataFile, double dataNorm) {
//********************************************************************
- this->dataHist = new TH2D((this->measurementName+"_data").c_str(), (this->measurementName+this->plotTitles).c_str(),
+ this->dataHist = new TH2D((this->fName+"_data").c_str(), (this->fName+this->plotTitles).c_str(),
this->data_points_x-1, this->xBins, this->data_points_y-1, this->yBins);
LOG(SAM) <<"Reading data from: "<<dataFile<<std::endl;
PlotUtils::Set2DHistFromText(dataFile, this->dataHist, dataNorm, true);
return;
};
//********************************************************************
void Measurement2D::SetCovarMatrix(std::string covarFile){
//********************************************************************
// Used to read a covariance matrix from a root file
TFile* tempFile = new TFile(covarFile.c_str(),"READ");
// Make plots that we want
TH2D* covarPlot = new TH2D();
// TH2D* decmpPlot = new TH2D();
TH2D* covarInvPlot = new TH2D();
TH2D* fullcovarPlot = new TH2D();
// Get covariance options for fake data studies
std::string covName = "";
std::string covOption = FitPar::Config().GetParS("throw_covariance");
// Which matrix to get?
if (this->isShape || this->isFree) covName = "shp_";
if (this->isDiag) covName += "diag";
else covName += "full";
covarPlot = (TH2D*) tempFile->Get((covName + "cov").c_str());
covarInvPlot = (TH2D*) tempFile->Get((covName + "covinv").c_str());
// Throw either the sub matrix or the full matrix
if (!covOption.compare("SUB")) fullcovarPlot = (TH2D*) tempFile->Get((covName + "cov").c_str());
else if (!covOption.compare("FULL")) fullcovarPlot = (TH2D*) tempFile->Get("fullcov");
else ERR(WRN)<<" Incorrect thrown_covariance option in parameters."<<std::endl;
// Bin masking?
int dim = int(this->dataHist->GetNbinsX());//-this->masked->Integral());
int covdim = int(this->dataHist->GetNbinsX());
// Make new covars
this->covar = new TMatrixDSym(dim);
this->fullcovar = new TMatrixDSym(dim);
this->decomp = new TMatrixDSym(dim);
// Full covariance values
int row,column = 0;
row = 0;
column = 0;
for (Int_t i = 0; i < covdim; i++){
// masking can be dodgy
// if (this->masked->GetBinContent(i+1) > 0) continue;
for (Int_t j = 0; j < covdim; j++){
// if (this->masked->GetBinContent(j+1) > 0) continue;
(*this->covar)(row, column) = covarPlot->GetBinContent(i+1,j+1);
(*this->fullcovar)(row, column) = fullcovarPlot->GetBinContent(i+1,j+1);
column++;
}
column = 0;
row++;
}
// Set bin errors on data
if (!this->isDiag){
for (Int_t i = 0; i < this->dataHist->GetNbinsX(); i++){
this->dataHist->SetBinError(i+1, sqrt((covarPlot->GetBinContent(i+1,i+1)))*1E-38);
}
}
TDecompSVD LU = TDecompSVD(*this->covar);
this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), "");
tempFile->Close();
delete tempFile;
return;
};
//********************************************************************
void Measurement2D::SetCovarMatrixFromText(std::string covarFile, int dim){
//********************************************************************
// Make a counter to track the line number
int row = 0;
std::string line;
std::ifstream covar(covarFile.c_str(),ifstream::in);
this->covar = new TMatrixDSym(dim);
this->fullcovar = new TMatrixDSym(dim);
if(covar.is_open()) LOG(SAM) << "Reading covariance matrix from file: " << covarFile << std::endl;
while(std::getline(covar, line, '\n')){
std::istringstream stream(line);
double entry;
int column = 0;
// Loop over entries and insert them into matrix
// Multiply by the errors to get the covariance, rather than the correlation matrix
while(stream >> entry){
double val = entry*this->dataHist->GetBinError(row+1)*1E38*this->dataHist->GetBinError(column+1)*1E38;
(*this->covar)(row, column) = val;
(*this->fullcovar)(row, column) = val;
column++;
}
row++;
}
// Robust matrix inversion method
TDecompSVD LU = TDecompSVD(*this->covar);
this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), "");
return;
};
//********************************************************************
void Measurement2D::SetCovarMatrixFromChol(std::string covarFile, int dim){
//********************************************************************
// Make a counter to track the line number
int row = 0;
std::string line;
std::ifstream covarread(covarFile.c_str(),ifstream::in);
TMatrixD* newcov = new TMatrixD(dim,dim);
if(covarread.is_open()) LOG(SAM) << "Reading covariance matrix from file: " << covarFile << std::endl;
int column = 0;
while(std::getline(covarread, line, '\n')){
std::istringstream stream(line);
double entry;
column = 0;
// Loop over entries and insert them into matrix
// Multiply by the errors to get the covariance, rather than the correlation matrix
while(stream >> entry){
double val = entry;
(*newcov)(row, column) = val;
column++;
}
row++;
}
covarread.close();
// Form full covariance
TMatrixD* trans = (TMatrixD*) (newcov)->Clone();
trans->T();
(*trans) *= (*newcov);
newcov = (TMatrixD*) trans->Clone();
this->covar = new TMatrixDSym(dim, newcov->GetMatrixArray(), "");
this->fullcovar = new TMatrixDSym(dim, newcov->GetMatrixArray(), "");
delete newcov;
delete trans;
// Robust matrix inversion method
TDecompChol LU = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), "");
return;
};
// virtual void SetMaskValuesFromText(std::string dataFile);
//********************************************************************
void Measurement2D::SetMapValuesFromText(std::string dataFile){
//********************************************************************
- this->mapHist = new TH2I((this->measurementName+"_map").c_str(), (this->measurementName+this->plotTitles).c_str(),
+ this->mapHist = new TH2I((this->fName+"_map").c_str(), (this->fName+this->plotTitles).c_str(),
this->data_points_x-1, this->xBins, this->data_points_y-1, this->yBins);
LOG(SAM) <<"Reading map from: "<<dataFile<<std::endl;
PlotUtils::Set2DHistFromText(dataFile, this->mapHist, 1.0);
return;
};
//********************************************************************
void Measurement2D::SetBinMask(std::string maskFile){
//********************************************************************
// Create a mask histogram.
int nbinsX = this->dataHist->GetNbinsX();
int nbinsY = this->dataHist->GetNbinsY();
- this->maskHist = new TH2I((this->measurementName+"_maskHist").c_str(),(this->measurementName+"_maskHist; Bin; Mask?") \
+ this->maskHist = new TH2I((this->fName+"_maskHist").c_str(),(this->fName+"_maskHist; Bin; Mask?") \
.c_str(),nbinsX,0,nbinsX,nbinsY,0,nbinsY);
// int row ,column= 0;
std::string line;
std::ifstream mask(maskFile.c_str(),ifstream::in);
if (mask.is_open()) LOG(SAM) <<"Reading bin mask from file: "<<maskFile <<std::endl;
else std::cerr <<" Cannot find mask file."<<std::endl;
while(std::getline(mask, line, '\n')){
std::istringstream stream(line);
int column = 0;
double entry;
int binx,biny,value;
while (stream >> entry){
if (column == 0) binx = int(entry);
if (column == 1) biny = int(entry);
if (column == 2) value = int(entry);
if (column > 2) break;
column++;
}
this->maskHist->SetBinContent(binx,biny,value);
}
// Set masked data bins to zero
PlotUtils::MaskBins(this->dataHist, this->maskHist);
return;
}
/*
XSec Functions
*/
//********************************************************************
void Measurement2D::SetFluxHistogram(std::string fluxFile, int minE, int maxE, double fluxNorm){
//********************************************************************
// Note this expects the flux bins to be given in terms of MeV
// Used to read in the flux from a text file
LOG(SAM) << "Reading flux from file: " << fluxFile << std::endl;
TGraph *f = new TGraph(fluxFile.c_str(),"%lg %lg");
- this->fluxHist = new TH1D((this->measurementName+"_flux").c_str(), (this->measurementName+";E_{#nu} (GeV)").c_str(), f->GetN()-1, minE, maxE);
+ this->fluxHist = new TH1D((this->fName+"_flux").c_str(), (this->fName+";E_{#nu} (GeV)").c_str(), f->GetN()-1, minE, maxE);
// Get graph points
Double_t *yVal = f->GetY();
// Fill flux histogram from graph
for (int i = 0; i<fluxHist->GetNbinsX(); ++i)
this->fluxHist->SetBinContent(i+1, yVal[i]*fluxNorm);
delete f;
};
//********************************************************************
double Measurement2D::TotalIntegratedFlux(std::string intOpt, double low, double high){
//********************************************************************
if(GetInput()->GetType() == kGiBUU){
return 1.0;
}
// Return the integrated flux between two energy values
// If non passed return it between the experimental flux
if (low == -9999.9) low = this->EnuMin;
if (high == -9999.9) high = this->EnuMax;
// Get bin integers
int minBin = this->fluxHist->GetXaxis()->FindBin(low);
int maxBin = this->fluxHist->GetXaxis()->FindBin(high);
// Find integral
double integral = this->fluxHist->Integral(minBin, maxBin+1, intOpt.c_str());
return integral;
};
/*
Reconfigure LOOP
*/
//********************************************************************
void Measurement2D::ResetAll(){
//********************************************************************
// Simple function to reset the mc Histograms incase that is all that is needed.
// Clear histograms
this->mcHist->Reset();
this->mcFine->Reset();
return;
};
//********************************************************************
void Measurement2D::FillHistograms(){
//********************************************************************
if (Signal){
this->mcHist->Fill(X_VAR,Y_VAR,Weight);
this->mcFine->Fill(X_VAR,Y_VAR,Weight);
PlotUtils::FillNeutModeArray((TH2D**)this->mcHist_PDG, Mode, X_VAR, Y_VAR, Weight);
}
return;
}
//********************************************************************
void Measurement2D::ScaleEvents(){
//********************************************************************
if (isEnu) { // If we have Enu we need to do flux integration bin by bin
int axis = 0;
// If name is 2DEnu, means Enu is the x-axis
// Convention is 2DXVARYVAR
- if (measurementName.find("2DEnu") != std::string::npos) {
+ if (fName.find("2DEnu") != std::string::npos) {
axis = 0;
} else {
axis = 1;
}
PlotUtils::FluxUnfoldedScaling(mcHist, fluxHist, axis);
PlotUtils::FluxUnfoldedScaling(mcFine, fluxHist, axis);
LOG(SAM) << "Running 2D Flux Unfolded Scaling?" << endl;
mcHist->Scale(scaleFactor);
mcFine->Scale(scaleFactor);
} else { // Else we just do normal scaling
// Scale bin errors correctly
this->mcHist->GetSumw2();
this->mcFine->GetSumw2();
// Final Scaling factors
this->mcHist->Scale(this->scaleFactor, "width");
this->mcFine->Scale(this->scaleFactor, "width");
PlotUtils::ScaleNeutModeArray((TH1**)this->mcHist_PDG, this->scaleFactor, "width");
}
return;
};
//********************************************************************
void Measurement2D::ApplyNormScale(double norm){
//********************************************************************
this->currentNorm = norm;
double scale = 0.0;
if (norm > 0.0) scale = 1.0/norm;
this->mcHist->Scale(scale);
this->mcFine->Scale(scale);
return;
};
/*
Statistic Functions - Outsources to StatUtils
*/
//********************************************************************
int Measurement2D::GetNDOF(){
//********************************************************************
// Just incase it has gone...
if (!this->dataHist) return 0;
int nDOF = 0;
// If datahist has no errors make sure we don't include those bins as they are not data points
for (int xBin = 0; xBin < this->dataHist->GetNbinsX()+1; ++xBin){
for (int yBin = 0; yBin < this->dataHist->GetNbinsY()+1; ++yBin){
if (this->dataHist->GetBinContent(xBin, yBin) != 0 && this->dataHist->GetBinError(xBin, yBin) != 0)
++nDOF;
}
}
// Account for possible bin masking
int nMasked = 0;
if (this->maskHist and this->isMask)
if (this->maskHist->Integral()>0)
for (int xBin = 0; xBin < this->maskHist->GetNbinsX()+1; ++xBin)
for (int yBin = 0; yBin < this->maskHist->GetNbinsY()+1; ++yBin)
if (this->maskHist->GetBinContent(xBin, yBin) > 0.5) ++nMasked;
// Take away those masked DOF
nDOF -= nMasked;
return nDOF;
}
//********************************************************************
double Measurement2D::GetLikelihood(){
//********************************************************************
// Fix weird masking bug
if (!isMask){
if (maskHist){
maskHist = NULL;
}
} else {
if (maskHist){
PlotUtils::MaskBins(this->mcHist, this->maskHist);
}
}
// if (isProjFitX or isProjFitY) return GetProjectedChi2();
// Scale up the results to match each other (Not using width might be inconsistent with Meas1D)
double scaleF = this->dataHist->Integral()/this->mcHist->Integral();
if (this->isShape){
this->mcHist->Scale(scaleF);
this->mcFine->Scale(scaleF);
}
if (!mapHist){
mapHist = StatUtils::GenerateMap(dataHist);
}
// Get the chi2 from either covar or diagonals
double chi2;
if (isChi2){
if (this->isDiag) {
chi2 = StatUtils::GetChi2FromDiag(dataHist, mcHist, mapHist, maskHist);
} else {
chi2 = StatUtils::GetChi2FromCov(dataHist, mcHist, covar, mapHist, maskHist);
}
} else {
if (this->isDiag){
chi2 = StatUtils::GetLikelihoodFromDiag(dataHist, mcHist, mapHist, maskHist);
} else {
chi2 = StatUtils::GetLikelihoodFromCov(dataHist, mcHist, covar, mapHist, maskHist);
}
}
// Add a normal penalty term
if (this->addNormPenalty){
chi2 += (1- (this->currentNorm))*(1-(this->currentNorm))/(this->normError*this->normError);
LOG(REC)<<"Norm penalty = "<<(1- (this->currentNorm ))*(1-(this->currentNorm))/(this->normError*this->normError)<<std::endl;
}
// Adjust the shape back to where it was.
if (this->isShape){
this->mcHist->Scale(1./scaleF);
this->mcFine->Scale(1./scaleF);
}
- LOG(REC)<<this->measurementName+" Chi2 = "<<chi2<<" \n";
+ LOG(REC)<<this->fName+" Chi2 = "<<chi2<<" \n";
return chi2;
};
// //********************************************************************
// double Measurement2D::GetProjectedChi2(){
// //********************************************************************
// PlotUtils::MatchEmptyBins(dataHist,mcHist);
// mcHist_X = PlotUtils::GetProjectionX(mcHist, maskHist);
// mcHist_Y = PlotUtils::GetProjectionY(mcHist, maskHist);
// dataHist_X = PlotUtils::GetProjectionX(dataHist, maskHist);
// dataHist_Y = PlotUtils::GetProjectionY(dataHist, maskHist);
// // Depending on the option either the rate of only X or only Y is used.
// // If using Y rate, scale X to match data and vice versa
// // Note: Projection will have already accounted for masking.
// if (isProjFitY) mcHist_X->Scale(PlotUtils::GetDataMCRatio(dataHist_X, mcHist_X));
// if (isProjFitX) mcHist_Y->Scale(PlotUtils::GetDataMCRatio(dataHist_Y, mcHist_Y));
// // Now get individual chi2 from each
// double chi2X = StatUtils::GetChi2FromDiag(dataHist_X, mcHist_X);
// double chi2Y = StatUtils::GetChi2FromDiag(dataHist_Y, mcHist_Y);
// double chi2 = chi2X + chi2Y;
// mcHist_X->SetTitle(Form("%d", chi2X));
// mcHist_Y->SetTitle(Form("%d", chi2Y));
// return chi2;
// }
/*
Fake Data
*/
//********************************************************************
void Measurement2D::SetFakeDataValues(std::string fakeOption) {
//********************************************************************
// This is the original data
- if (!(this->dataOrig)) this->dataOrig = (TH2D*)this->dataHist->Clone((this->measurementName+"_data_original").c_str());
+ if (!(this->dataOrig)) this->dataOrig = (TH2D*)this->dataHist->Clone((this->fName+"_data_original").c_str());
TH2D *tempData = (TH2D*)this->dataHist->Clone();
TFile *fake = new TFile();
if (fakeOption.compare("MC")==0){
- LOG(SAM) << this->measurementName <<"Setting fake data from MC "<<std::endl;
- this->dataHist = (TH2D*)this->mcHist->Clone((this->measurementName+"_MC").c_str());
- if (this->mcHist->Integral() == 0.0) LOG(SAM) << this->measurementName <<"Invalid histogram"<<std::endl;
+ LOG(SAM) << this->fName <<"Setting fake data from MC "<<std::endl;
+ this->dataHist = (TH2D*)this->mcHist->Clone((this->fName+"_MC").c_str());
+ if (this->mcHist->Integral() == 0.0) LOG(SAM) << this->fName <<"Invalid histogram"<<std::endl;
}
else {
fake = new TFile(fakeOption.c_str());
- this->dataHist = (TH2D*)fake->Get((this->measurementName+"_MC").c_str());
+ this->dataHist = (TH2D*)fake->Get((this->fName+"_MC").c_str());
}
- this->dataHist ->SetNameTitle((this->measurementName+"_FAKE").c_str(), (this->measurementName+this->plotTitles).c_str());
+ this->dataHist ->SetNameTitle((this->fName+"_FAKE").c_str(), (this->fName+this->plotTitles).c_str());
int nbins_x = this->dataHist->GetNbinsX();
int nbins_y = this->dataHist->GetNbinsY();
double alpha_i = 0.0;
for (int i = 0; i < nbins_x; i++){
for (int j = 0; j < nbins_y; j++){
if (tempData->GetBinContent(i+1,j+1) == 0.0) continue;
alpha_i = this->dataHist->GetBinContent(i+1,j+1)/this->dataOrig->GetBinContent(i+1,j+1);
this->dataHist->SetBinError(i+1,j+1,alpha_i*this->dataOrig->GetBinError(i+1,j+1));
}
}
this->dataTrue = (TH2D*) this->dataHist->Clone();
fake->Close();
delete fake;
return;
};
// virtual void ResetFakeData();
// virtual void ResetData();
//********************************************************************
void Measurement2D::ThrowCovariance(){
//********************************************************************
return;
};
/*
Access Functions
*/
//********************************************************************
std::vector<TH1*> Measurement2D::GetMCList(){
//********************************************************************
// If this isn't a NULL pointer, make the plot pretty!
if (!this->mcHist) return std::vector<TH1*> (1, this->mcHist);
std::ostringstream chi2;
chi2 << std::setprecision(5) << this->GetLikelihood();
int plotcolor = kRed;
if (FitPar::Config().GetParI("linecolour") > 0){
plotcolor = FitPar::Config().GetParI("linecolour");
}
int plotstyle = 1;
if (FitPar::Config().GetParI("linestyle") > 0){
plotstyle = FitPar::Config().GetParI("linestyle");
}
int plotfillstyle=0;
if (FitPar::Config().GetParI("fillstyle") > 0){
plotfillstyle = FitPar::Config().GetParI("fillstyle");
}
- std::cout << measurementName << " chi2 = " << GetLikelihood() << std::endl;
+ std::cout << fName << " chi2 = " << GetLikelihood() << std::endl;
this->mcHist->SetTitle(chi2.str().c_str());
this->mcHist->SetLineWidth(2);
this->mcHist->SetLineColor(plotcolor);
this->mcHist->SetFillColor(plotcolor);
this->mcHist->SetLineStyle(plotstyle);
this->mcHist->SetFillStyle(plotfillstyle);
return std::vector<TH1*> (1, this->mcHist);
};
//********************************************************************
std::vector<TH1*> Measurement2D::GetDataList(){
//********************************************************************
// If this isn't a NULL pointer, make the plot pretty!
if (!this->dataHist) return std::vector<TH1*> (1, this->dataHist);
this->dataHist->SetLineWidth(2);
this->dataHist->SetLineColor(kBlue);
return std::vector<TH1*> (1, this->dataHist);
};
//********************************************************************
void Measurement2D:: GetBinContents(std::vector<double>& cont, std::vector<double>& err){
//********************************************************************
int count = 0;
for (int i = 0; i < (this->mcHist->GetNbinsX()+2) * (this->mcHist->GetNbinsY()+2); i++){
cont.push_back(this->mcHist->GetBinContent(i));
err.push_back(this->mcHist->GetBinError(i));
count++;
}
return;
};
//********************************************************************
std::vector<double> Measurement2D::GetXSec(std::string option){
//********************************************************************
std::vector<double> vals;
vals.push_back(0.0);
vals.push_back(0.0);
bool getMC = !option.compare("MC");
bool getDT = !option.compare("DATA");
for (int i = 0; i < this->mcHist->GetNbinsX(); i++){
if (this->dataHist->GetBinContent(i+1) == 0.0 and this->dataHist->GetBinError(i+1) == 0.0) continue;
if (getMC){
vals[0] += this->mcHist->GetBinContent(i+1) * this->mcHist->GetXaxis()->GetBinWidth(i+1);
vals[1] += this->mcHist->GetBinError(i+1) * this->mcHist->GetBinError(i+1) * this->mcHist->GetXaxis()->GetBinWidth(i+1) * this->mcHist->GetXaxis()->GetBinWidth(i+1);
} else if (getDT){
vals[0] += this->dataHist->GetBinContent(i+1) * this->dataHist->GetXaxis()->GetBinWidth(i+1);
vals[1] += this->dataHist->GetBinError(i+1) * this->dataHist->GetBinError(i+1) * this->dataHist->GetXaxis()->GetBinWidth(i+1) * this->dataHist->GetXaxis()->GetBinWidth(i+1);
}
}
// If not diag Get the total error from the covariance
if (!this->isDiag and getDT){
vals[1] = 0.0;
for (int i = 0; i < this->dataHist->GetNbinsX(); i++){
for(int j = 0; j < this->dataHist->GetNbinsX(); j++){
vals[1] += (*fullcovar)(i,j);
}
}
vals[1] = sqrt(vals[1]) * 1E-38;
}
return vals;
}
/*
Write Functions
*/
//********************************************************************
void Measurement2D::Write(std::string drawOpt){
//********************************************************************
// If null pointer return
if (!this->mcHist and !this->dataHist){
- LOG(SAM) << this->measurementName <<"Incomplete histogram set!"<<std::endl;
+ LOG(SAM) << this->fName <<"Incomplete histogram set!"<<std::endl;
return;
}
// Get Draw Options
drawOpt = FitPar::Config().GetParS("drawopts");
bool drawData = (drawOpt.find("DATA") != std::string::npos);
bool drawNormal = (drawOpt.find("MC") != std::string::npos);
bool drawEvents = (drawOpt.find("EVT") != std::string::npos);
bool drawFine = (drawOpt.find("FINE") != std::string::npos);
bool drawRatio = (drawOpt.find("RATIO") != std::string::npos);
bool drawModes = (drawOpt.find("MODES") != std::string::npos);
bool drawShape = (drawOpt.find("SHAPE") != std::string::npos);
bool residual = (drawOpt.find("RESIDUAL") != std::string::npos);
bool drawMatrix = (drawOpt.find("MATRIX") != std::string::npos);
bool drawFlux = (drawOpt.find("FLUX") != std::string::npos);
bool drawMask = (drawOpt.find("MASK") != std::string::npos);
bool drawMap = (drawOpt.find("MAP") != std::string::npos);
bool drawProj = (drawOpt.find("PROJ") != std::string::npos);
bool drawCanvPDG = (drawOpt.find("CANVPDG") != std::string::npos);
bool drawSliceCanvYMC = (drawOpt.find("CANVYMC") != std::string::npos);
// Save standard plots
if (drawData) this->GetDataList().at(0)->Write();
if (drawNormal) this->GetMCList() .at(0)->Write();
// Generate a simple map
if (!mapHist)
mapHist = StatUtils::GenerateMap(dataHist);
// Convert to 1D Lists
TH1D* data_1D = StatUtils::MapToTH1D(dataHist, mapHist);
TH1D* mc_1D = StatUtils::MapToTH1D(mcHist, mapHist);
TH1I* mask_1D = StatUtils::MapToMask(maskHist, mapHist);
data_1D->Write();
mc_1D->Write();
if (mask_1D){
mask_1D->Write();
TMatrixDSym* calc_cov = StatUtils::ApplyInvertedMatrixMasking(covar, mask_1D);
TH1D* calc_data = StatUtils::ApplyHistogramMasking(data_1D, mask_1D);
TH1D* calc_mc = StatUtils::ApplyHistogramMasking(mc_1D, mask_1D);
TH2D* bin_cov = new TH2D(*calc_cov);
bin_cov->Write();
calc_data->Write();
calc_mc->Write();
delete mask_1D;
delete calc_cov;
delete calc_data;
delete calc_mc;
delete bin_cov;
}
delete data_1D;
delete mc_1D;
// Save only mc and data if splines
if(this->eventType == 4 or this->eventType==3){ return; }
// Draw Extra plots
if (drawFine) this->GetFineList().at(0)->Write();
if (drawFlux) this->fluxHist->Write();
if (drawEvents) this->eventHist->Write();
- if (isMask and drawMask) this->maskHist->Write( (this->measurementName + "_MSK").c_str() ); //< save mask
- if (drawMap) this->mapHist->Write( (this->measurementName + "_MAP").c_str() ); //< save map
+ if (isMask and drawMask) this->maskHist->Write( (this->fName + "_MSK").c_str() ); //< save mask
+ if (drawMap) this->mapHist->Write( (this->fName + "_MAP").c_str() ); //< save map
// Save neut stack
if (drawModes){
- THStack combo_mcHist_PDG = PlotUtils::GetNeutModeStack((this->measurementName + "_MC_PDG").c_str(), (TH1**)this->mcHist_PDG, 0);
+ THStack combo_mcHist_PDG = PlotUtils::GetNeutModeStack((this->fName + "_MC_PDG").c_str(), (TH1**)this->mcHist_PDG, 0);
combo_mcHist_PDG.Write();
}
// Save Matrix plots
if (drawMatrix and fullcovar and covar and decomp){
TH2D cov = TH2D((*this->fullcovar));
- cov.SetNameTitle((this->measurementName+"_cov").c_str(),(this->measurementName+"_cov;Bins; Bins;").c_str());
+ cov.SetNameTitle((this->fName+"_cov").c_str(),(this->fName+"_cov;Bins; Bins;").c_str());
cov.Write();
TH2D covinv = TH2D((*this->covar));
- covinv.SetNameTitle((this->measurementName+"_covinv").c_str(),(this->measurementName+"_cov;Bins; Bins;").c_str());
+ covinv.SetNameTitle((this->fName+"_covinv").c_str(),(this->fName+"_cov;Bins; Bins;").c_str());
covinv.Write();
TH2D covdec = TH2D((*this->decomp));
- covdec.SetNameTitle((this->measurementName+"_covdec").c_str(),(this->measurementName+"_cov;Bins; Bins;").c_str());
+ covdec.SetNameTitle((this->fName+"_covdec").c_str(),(this->fName+"_cov;Bins; Bins;").c_str());
covdec.Write();
}
// Save ratio plots if required
if (drawRatio){
// Needed for error bars
for(int i = 0; i < this->mcHist->GetNbinsX()*this->mcHist->GetNbinsY(); i++)
this->mcHist->SetBinError(i+1,0.0);
this->dataHist->GetSumw2();
this->mcHist->GetSumw2();
// Create Ratio Histograms
- TH2D* dataRatio = (TH2D*) this->dataHist->Clone((this->measurementName + "_data_RATIO").c_str());
- TH2D* mcRatio = (TH2D*) this->mcHist->Clone((this->measurementName + "_MC_RATIO").c_str());
+ TH2D* dataRatio = (TH2D*) this->dataHist->Clone((this->fName + "_data_RATIO").c_str());
+ TH2D* mcRatio = (TH2D*) this->mcHist->Clone((this->fName + "_MC_RATIO").c_str());
mcRatio->Divide(this->mcHist);
dataRatio->Divide(this->mcHist);
// Cancel bin errors on MC
for(int i = 0; i < mcRatio->GetNbinsX()*mcRatio->GetNbinsY(); i++) {
mcRatio->SetBinError(i+1,this->mcHist->GetBinError(i+1) / this->mcHist->GetBinContent(i+1));
}
mcRatio->SetMinimum(0);
mcRatio->SetMaximum(2);
dataRatio->SetMinimum(0);
dataRatio->SetMaximum(2);
mcRatio->Write();
dataRatio->Write();
delete mcRatio;
delete dataRatio;
}
// Save Shape Plots if required
if (drawShape){
// Create Shape Histogram
- TH2D* mcShape = (TH2D*) this->mcHist->Clone((this->measurementName + "_MC_SHAPE").c_str());
+ TH2D* mcShape = (TH2D*) this->mcHist->Clone((this->fName + "_MC_SHAPE").c_str());
mcShape->Scale( this->dataHist->Integral("width")
/ this->mcHist->Integral("width"));
mcShape->SetLineWidth(3);
mcShape->SetLineStyle(7); //dashes
mcShape->Write();
// Save shape ratios
if (drawRatio){
// Needed for error bars
mcShape->GetSumw2();
// Create shape ratio histograms
- TH2D* mcShapeRatio = (TH2D*)mcShape->Clone((this->measurementName + "_MC_SHAPE_RATIO").c_str());
- TH2D* dataShapeRatio = (TH2D*)dataHist->Clone((this->measurementName + "_data_SHAPE_RATIO").c_str());
+ TH2D* mcShapeRatio = (TH2D*)mcShape->Clone((this->fName + "_MC_SHAPE_RATIO").c_str());
+ TH2D* dataShapeRatio = (TH2D*)dataHist->Clone((this->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); // dashes
mcShapeRatio ->Write();
dataShapeRatio->Write();
delete mcShapeRatio;
delete dataShapeRatio;
}
delete mcShape;
}
// Save residual calculations of what contributed to the chi2 values.
if (residual){
}
if (isProjFitX or isProjFitY or drawProj){
// If not already made, make the projections
if (!mcHist_X){
PlotUtils::MatchEmptyBins(dataHist,mcHist);
mcHist_X = PlotUtils::GetProjectionX(mcHist, maskHist);
mcHist_Y = PlotUtils::GetProjectionY(mcHist, maskHist);
dataHist_X = PlotUtils::GetProjectionX(dataHist, maskHist);
dataHist_Y = PlotUtils::GetProjectionY(dataHist, maskHist);
double chi2X = StatUtils::GetChi2FromDiag(dataHist_X, mcHist_X);
double chi2Y = StatUtils::GetChi2FromDiag(dataHist_Y, mcHist_Y);
mcHist_X->SetTitle(Form("%f", chi2X));
mcHist_Y->SetTitle(Form("%f", chi2Y));
}
// Save the histograms
dataHist_X->Write();
mcHist_X->Write();
dataHist_Y->Write();
mcHist_Y->Write();
}
if (drawSliceCanvYMC or true){
- TCanvas* c1 = new TCanvas((this->measurementName + "_MC_CANV_Y").c_str(),
- (this->measurementName + "_MC_CANV_Y").c_str(),
+ TCanvas* c1 = new TCanvas((this->fName + "_MC_CANV_Y").c_str(),
+ (this->fName + "_MC_CANV_Y").c_str(),
800,600);
c1->Divide( int(sqrt(dataHist->GetNbinsY()+1)), int(sqrt(dataHist->GetNbinsY()+1)) );
- TH2D* mcShape = (TH2D*) this->mcHist->Clone((this->measurementName + "_MC_SHAPE").c_str());
+ TH2D* mcShape = (TH2D*) this->mcHist->Clone((this->fName + "_MC_SHAPE").c_str());
double shapeScale = dataHist->Integral("width")/mcHist->Integral("width");
mcShape->Scale(shapeScale);
mcShape->SetLineStyle(7);
c1->cd(1);
TLegend* leg = new TLegend(0.6,0.6,0.9,0.9);
- leg->AddEntry(dataHist, (this->measurementName + " Data").c_str(), "ep");
- leg->AddEntry(mcHist, (this->measurementName + " MC").c_str(), "l");
- leg->AddEntry(mcShape, (this->measurementName + " Shape").c_str(), "l");
+ leg->AddEntry(dataHist, (this->fName + " Data").c_str(), "ep");
+ leg->AddEntry(mcHist, (this->fName + " MC").c_str(), "l");
+ leg->AddEntry(mcShape, (this->fName + " Shape").c_str(), "l");
leg->Draw("SAME");
/*
// Make Y slices
for (int i = 0; i < dataHist->GetNbinY(); i++){
c1->cd(i+2);
TH1D* dataHist_SliceY = PlotUtils::GetSliceY(dataHist, i);
dataHist_SliceY->Draw("E1");
TH1D* mcHist_SliceY = PlotUtils::GetSliceY(mcHist, i);
mcHist_SliceY->Draw("SAME HIST C");
TH1D* mcShape_SliceY = PlotUtils::GetSliceY(mcShape, i);
mcShape_SliceY->Draw("SAME HIST C");
}
*/
c1->Write();
}
// Returning
- LOG(SAM) << this->measurementName << "Written Histograms: "<<this->measurementName<<std::endl;
+ LOG(SAM) << this->fName << "Written Histograms: "<<this->fName<<std::endl;
return;
};
THStack Measurement2D::GetModeStack(){
- THStack combo_hist = PlotUtils::GetNeutModeStack((this->measurementName + "_MC_PDG").c_str(), (TH1**)this->mcHist_PDG, 0);
+ THStack combo_hist = PlotUtils::GetNeutModeStack((this->fName + "_MC_PDG").c_str(), (TH1**)this->mcHist_PDG, 0);
return combo_hist;
}
diff --git a/src/FitBase/MeasurementBase.cxx b/src/FitBase/MeasurementBase.cxx
index abae415..dc373e4 100644
--- a/src/FitBase/MeasurementBase.cxx
+++ b/src/FitBase/MeasurementBase.cxx
@@ -1,362 +1,365 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MeasurementBase.h"
/*
Constructor/Destructors
*/
//********************************************************************
// 2nd Level Constructor (Inherits From MeasurementBase.h)
MeasurementBase::MeasurementBase() {
//********************************************************************
scaleFactor = 1.0;
filledMC = false;
};
//********************************************************************
// 2nd Level Destructor (Inherits From MeasurementBase.h)
MeasurementBase::~MeasurementBase() {
//********************************************************************
};
//********************************************************************
void MeasurementBase::SetFluxHistogram(std::string fluxFile, int minE, int maxE, double fluxNorm){
//********************************************************************
// Note this expects the flux bins to be given in terms of MeV
LOG(SAM) << "Reading flux from file: " << fluxFile << std::endl;
TGraph f(fluxFile.c_str(),"%lg %lg");
- this->fluxHist = new TH1D((this->measurementName+"_flux").c_str(), (this->measurementName+"; E_{#nu} (GeV)").c_str(),\
+ this->fluxHist = new TH1D((this->fName+"_flux").c_str(), (this->fName+"; E_{#nu} (GeV)").c_str(),\
f.GetN()-1, minE, maxE);
Double_t *yVal = f.GetY();
for (int i = 0; i<fluxHist->GetNbinsX(); ++i)
this->fluxHist->SetBinContent(i+1, yVal[i]*fluxNorm);
};
//********************************************************************
double MeasurementBase::TotalIntegratedFlux(std::string intOpt, double low, double high){
- //********************************************************************
-
- if(GetInput()->GetType() == kGiBUU){
- return 1.0;
- }
+//********************************************************************
// Set Energy Limits
if (low == -9999.9) low = this->EnuMin;
if (high == -9999.9) high = this->EnuMax;
- int minBin = this->fluxHist->GetXaxis()->FindBin(low);
- int maxBin = this->fluxHist->GetXaxis()->FindBin(high);
-
- // Get integral over custom range
- double integral = this->fluxHist->Integral(minBin, maxBin+1, intOpt.c_str());
-
- return integral;
+ return GetInput()->TotalIntegratedFlux(low, high, intOpt);
};
//********************************************************************
double MeasurementBase::PredictedEventRate(std::string intOpt, double low, double high){
//********************************************************************
// Set Energy Limits
if (low == -9999.9) low = this->EnuMin;
if (high == -9999.9) high = this->EnuMax;
- int minBin = this->eventHist->GetXaxis()->FindBin(low);
- int maxBin = this->eventHist->GetXaxis()->FindBin(high);
-
- // Get integral over custom range
- double integral = this->eventHist->Integral(minBin, maxBin+1, intOpt.c_str());
+ return GetInput()->PredictedEventRate(low, high, intOpt) * 1E-38;
- return integral * 1E-38;
};
//********************************************************************
void MeasurementBase::SetupInputs(std::string inputfile){
//********************************************************************
// Add this infile to the global manager
if (FitPar::Config().GetParB("EventManager")){
- FitBase::AddInput(measurementName, inputfile);
+ FitBase::AddInput(fName, inputfile);
// Get a pointer to the input so we can grab flux stuff
// Slightly Convoluted...
input = FitBase::GetInput( FitBase::GetInputID(inputfile) );
} else {
- input = new InputHandler(measurementName, inputfile);
+ input = new InputHandler(fName, inputfile);
}
this->fluxHist = input->GetFluxHistogram();
this->eventHist = input->GetEventHistogram();
this->xsecHist = input->GetXSecHistogram();
this->nevents = input->GetNEvents();
inputfilename = inputfile;
}
//***********************************************
int MeasurementBase::GetInputID(){
//***********************************************
return FitBase::GetInputID(inputfilename);
}
//***********************************************
void MeasurementBase::Reconfigure(){
//***********************************************
- LOG(REC) << " Reconfiguring sample "<<this->measurementName<<std::endl;
+ LOG(REC) << " Reconfiguring sample "<<this->fName<<std::endl;
bool using_evtmanager = FitPar::Config().GetParB("EventManager");
int input_id = -1;
if (using_evtmanager) input_id = FitBase::GetInputID(inputfilename);
cust_event = input->GetEventPointer();
// Reset Histograms
this->ResetAll();
// READ in spline head for this input
if (input->GetType() == kEVTSPLINE){
FitBase::GetRW()->ReadSplineHead(input->GetSplineHead());
}
FitEvent* cust_event = input->GetEventPointer();
int nevents = input->GetNEvents();
int countwidth = (nevents/20);
// Reset Signal Vectors
this->X_VAR_VECT.clear();
this->Y_VAR_VECT.clear();
this->Z_VAR_VECT.clear();
this->MODE_VECT.clear();
this->INDEX_VECT.clear();
size_t NSignal = 0;
// MAIN EVENT LOOP
for (int i = 0; i < nevents; i++){
// Read in the TChain and Calc Kinematics
if (using_evtmanager){
cust_event = FitBase::EvtManager().GetEvent(input_id, i);
} else {
input->ReadEvent(i);
cust_event->RWWeight = FitBase::GetRW()->CalcWeight(cust_event);
cust_event->Weight = cust_event->RWWeight*cust_event->InputWeight;
Weight = cust_event->Weight;
}
Weight = cust_event->Weight;
// Initialize
X_VAR = 0.0;
Y_VAR = 0.0;
Z_VAR = 0.0;
Signal = false;
Mode = cust_event->Mode;
// Extract Measurement Variables
this->FillEventVariables(cust_event);
Signal = this->isSignal(cust_event);
// Push Back Signal
if (Signal){
this->X_VAR_VECT .push_back(X_VAR);
this->Y_VAR_VECT .push_back(Y_VAR);
this->Z_VAR_VECT .push_back(Z_VAR);
this->MODE_VECT .push_back(Mode);
this->INDEX_VECT .push_back( (UInt_t)i);
NSignal++;
}
// Fill Histogram Values
this->FillHistograms();
// this->FillExtraHistograms();
// Print Out
if (LOG_LEVEL(REC) and countwidth and !(i % countwidth))
LOG(REC) << "Reconfigured " << i <<" total events. [S,X,Y,Z,M,W] = ["
<< Signal << ", "
<< X_VAR << ", "<< Y_VAR << ", "
<< Z_VAR << ", "<< Mode << ", "
<< Weight << "] "<< std::endl;
}
// Finalise Histograms
filledMC = true;
this->ConvertEventRates();
}
//***********************************************
void MeasurementBase::ReconfigureFast(){
//***********************************************
- LOG(REC) << " Reconfiguring signal "<<this->measurementName<<std::endl;
+ LOG(REC) << " Reconfiguring signal "<<this->fName<<std::endl;
bool using_evtmanager = FitPar::Config().GetParB("EventManager");
int input_id = -1;
if (using_evtmanager){
input_id = FitBase::GetInputID(inputfilename);
} else {
cust_event = input->GetEventPointer();
}
// Check if we Can't Signal Reconfigure
if (!filledMC){
this->Reconfigure();
return;
}
// Reset Histograms
this->ResetAll();
// READ in spline head for this input
if (input->GetType() == kEVTSPLINE){
FitBase::GetRW()->ReadSplineHead(input->GetSplineHead());
}
// Get Pointer To Base Event (Just Generator Formats)
int countwidth = (nevents / 10);
// Setup Iterators
std::vector<double>::iterator X = X_VAR_VECT.begin();
std::vector<double>::iterator Y = Y_VAR_VECT.begin();
std::vector<double>::iterator Z = Z_VAR_VECT.begin();
std::vector<int>::iterator M = MODE_VECT.begin();
std::vector<UInt_t>::iterator I = INDEX_VECT.begin();
// SIGNAL LOOP
for (int i = 0; I != INDEX_VECT.end(); I++, i++){
// Just Update Weight
if (using_evtmanager){
Weight = FitBase::EvtManager().GetEventWeight(input_id, (*I));
} else {
input->GetTreeEntry((*I));
Weight = FitBase::GetRW()->CalcWeight(cust_event) \
* cust_event->InputWeight;
}
X_VAR = (*X);
Y_VAR = (*Y);
Z_VAR = (*Z);
Mode = (*M);
Signal = true;
// Sort Histograms
this->FillHistograms();
// Get Next Iteration
X++;
Y++;
Z++;
M++;
// Print Out
if (LOG_LEVEL(REC) && (i) % countwidth == 0)
LOG(REC) << "Reconfigured " << i <<" signal events. [X,Y,Z,M,W] = ["
<< X_VAR << ", " << Y_VAR << ", "
<< Z_VAR << ", " << Mode << ", "
<< Weight << "] " << std::endl;
}
// Finalise histograms
filledMC = true;
this->ConvertEventRates();
}
//***********************************************
void MeasurementBase::ConvertEventRates(){
//***********************************************
this->ScaleEvents();
- this->ApplyNormScale( FitBase::GetRW()->GetSampleNorm( this->measurementName ) ) ;
+ this->ApplyNormScale( FitBase::GetRW()->GetSampleNorm( this->fName ) ) ;
}
//***********************************************
InputHandler* MeasurementBase::GetInput(){
//***********************************************
if(FitPar::Config().GetParB("EventManager")){
return FitBase::GetInput(FitBase::GetInputID(inputfilename));
} else {
return this->input;
}
return NULL;
};
//***********************************************
void MeasurementBase::Renormalise(){
//***********************************************
// Called when the fitter has changed a measurements normalisation but not any reweight dials
// Means we don't have to call the time consuming reconfigure when this happens.
- double norm = FitBase::GetRW()->GetDialValue( this->measurementName + "_norm" );
+ double norm = FitBase::GetRW()->GetDialValue( this->fName + "_norm" );
if ((this->currentNorm == 0.0 and norm != 0.0) or not filledMC){
this->ReconfigureFast();
return;
}
if (this->currentNorm == norm) return;
this->ApplyNormScale( 1.0 / this->currentNorm );
this->ApplyNormScale( norm );
return;
};
//***********************************************
void MeasurementBase::SetSignal(bool sig){
//***********************************************
Signal = sig;
}
//***********************************************
void MeasurementBase::SetSignal(FitEvent* evt){
//***********************************************
Signal = this->isSignal(evt);
}
//***********************************************
void MeasurementBase::SetWeight(double wght){
//***********************************************
Weight = wght;
}
//***********************************************
void MeasurementBase::SetMode(int md){
//***********************************************
Mode = md;
}
+
+//***********************************************
+std::vector<TH1*> MeasurementBase::GetFluxList(){
+//***********************************************
+ return GetInput()->GetFluxList();
+}
+
+//***********************************************
+std::vector<TH1*> MeasurementBase::GetEventRateList(){
+//***********************************************
+ return GetInput()->GetEventList();
+}
+
+//***********************************************
+std::vector<TH1*> MeasurementBase::GetXSecList(){
+//***********************************************
+ return GetInput()->GetXSecList();
+}
diff --git a/src/FitBase/MeasurementBase.h b/src/FitBase/MeasurementBase.h
index 77b6a9c..97bb347 100644
--- a/src/FitBase/MeasurementBase.h
+++ b/src/FitBase/MeasurementBase.h
@@ -1,239 +1,235 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#ifndef INPUTHANDLER_H_SEEN
#define INPUTHANDLER_H_SEEN
/*!
* \addtogroup FitBase
* @{
*/
// C Includes
#include <stdlib.h>
#include <numeric>
#include <math.h>
#include <string>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <deque>
#include <time.h>
#include <list>
// ROOT includes
#include <TROOT.h>
#include <TH1D.h>
#include <TH2D.h>
#include <TArrayF.h>
#include <TGraph.h>
#include <TGraphErrors.h>
#include <TMatrixDSym.h>
#include <TDecompSVD.h>
#include <TDecompChol.h>
#include <TSystem.h>
// External data fit includes
#include "FitEvent.h"
#include "FitUtils.h"
#include "PlotUtils.h"
#include "StatUtils.h"
#include "FitParameters.h"
#include "FitWeight.h"
#include "TMultiDimFit.h"
#ifdef __GENIE_ENABLED__
#include "Conventions/Units.h"
#endif
#include "TObject.h"
#include "InputHandler.h"
#include "EventManager.h"
/// InputHandler Class
///
/// Inherits from Measurement base to handle whatever input is throwna t the fitter automatically.
/// All functions here handle how files are read in, converted to custom formats and reconfigures are called.
/// Used generally for the MC inputs.
//! 2nd level experiment class that handles converting MC into a common format and calling reconfigure
class MeasurementBase {
public:
/*
Constructor/Destructors
*/
//! Default Constructor. Set everything to NULL
- MeasurementBase();
+ MeasurementBase(void);
//! Default virtual destructor
- virtual ~MeasurementBase();
+ virtual ~MeasurementBase(void);
/*
Reconfigure Functions
*/
//! Function called if MC tuning dials haven't been changed and all we want to do is update the normalisation.
- virtual void Renormalise();
+ virtual void Renormalise(void);
//! Call reconfigure only looping over signal events to save time.
- virtual void ReconfigureFast();
+ virtual void ReconfigureFast(void);
//! Call reconfigure looping over all MC events including background
- virtual void Reconfigure();
+ virtual void Reconfigure(void);
- virtual TH2D GetCovarMatrix() = 0;
- virtual double GetLikelihood(){return 0.0;};
- virtual int GetNDOF(){return 0;};
- virtual void ThrowCovariance() = 0;
+ virtual TH2D GetCovarMatrix(void) = 0;
+ virtual double GetLikelihood(void){return 0.0;};
+ virtual int GetNDOF(void){return 0;};
+ virtual void ThrowCovariance(void) = 0;
virtual void SetFakeDataValues(std::string fkdt) = 0;
//! Set the flux histogram from file
virtual void SetFluxHistogram(std::string fluxFile, int minE, int maxE, double fluxNorm);
//! Get the total integrated flux between this samples energy range
virtual double TotalIntegratedFlux(std::string intOpt="width",double low=-9999.9, double high=-9999.9);
//! Get the predicted event rate for this sample
virtual double PredictedEventRate(std::string intOpt="width",double low=-9999.9, double high=-9999.9);
/*
Reconfigure LOOP
*/
// All these should be virtual
///! Reset Histograms (Handled at Measurement Stage)
- virtual void ResetAll() = 0;
+ virtual void ResetAll(void) = 0;
///! Fill the event variables for this sample (Handled in each inherited sample)
virtual void FillEventVariables(FitEvent* event){(void)event;};
///! Check whether this event is signle (Handled in each inherited sample)
virtual bool isSignal(FitEvent* event){ (void)event; return false;};
///! Fill the histogram for this event using X_VAR and Y_VAR (Handled in each inherited sample)
- virtual void FillHistograms(){};
+ virtual void FillHistograms(void){};
///! Convert event rates to whatever distributions you need.
- virtual void ConvertEventRates();
+ virtual void ConvertEventRates(void);
///! Call scale events after the plots have been filled at the end of reconfigure.
- virtual void ScaleEvents(){};
+ virtual void ScaleEvents(void){};
///! Apply the scale factor at the end of reconfigure.
virtual void ApplyNormScale(double norm){(void) norm;};
///! Save Histograms
virtual void Write(std::string drawOpt = "") = 0;
/*
Histogram Access Functions
*/
///! Virtual function to get data histogram
- virtual std::vector<TH1*> GetDataList() = 0;
+ virtual std::vector<TH1*> GetDataList(void) = 0;
///! Virtual function to get MC histogram
- virtual std::vector<TH1*> GetMCList() = 0;
- virtual std::vector<TH1*> GetFineList() = 0;
- virtual std::vector<TH1*> GetMaskList() = 0;
+ virtual std::vector<TH1*> GetMCList (void) = 0;
+ virtual std::vector<TH1*> GetFineList (void) = 0;
+ virtual std::vector<TH1*> GetMaskList (void) = 0;
- ///! Return Flux Lists as a vector
- virtual std::vector<TH1*> GetFluxList(){return std::vector<TH1*>(1,fluxHist);};
-
- ///! Return Event Rate Lists as a vector
- virtual std::vector<TH1*> GetEventRateList(){return std::vector<TH1*>(1,eventHist);};
-
- ///! Return XSec Lists as a vector
- virtual std::vector<TH1*> GetXSecList(){return std::vector<TH1*>(1,xsecHist);};
+ ///! Return flux histograms in a vector
+ virtual std::vector<TH1*> GetFluxList (void);
+ virtual std::vector<TH1*> GetEventRateList (void);
+ virtual std::vector<TH1*> GetXSecList (void);
///! Return input for this sample
- InputHandler* GetInput();
+ InputHandler* GetInput (void);
- std::string GetName(){ return measurementName; };
- double GetScaleFactor(){ return scaleFactor; };
+ std::string GetName (void){ return fName; };
+ double GetScaleFactor(void){ return scaleFactor; };
- double GetXVar(){ return this->X_VAR; };
- double GetYVar(){ return this->Y_VAR; };
- double GetZVar(){ return this->Z_VAR; };
- double GetMode(){ return this->Mode; };
- double GetEnu(){ return this->Enu; };
+ double GetXVar(void){ return this->X_VAR; };
+ double GetYVar(void){ return this->Y_VAR; };
+ double GetZVar(void){ return this->Z_VAR; };
+ double GetMode(void){ return this->Mode; };
+ double GetEnu(void){ return this->Enu; };
void SetupInputs(std::string inputfile);
- int GetInputID();
+ int GetInputID(void);
void SetSignal(bool sig);
void SetSignal(FitEvent* evt);
void SetWeight(double wght);
void SetMode(int md);
protected:
// Minimum and maximum energies
double Enu; //!< Neutrino Energy
double EnuMin; //!< Minimum incoming particle energy of events to include
double EnuMax; //!< Maximum incoming particle energy of events to include
BaseFitEvt* signal_event;
FitEvent* cust_event;
FitWeight* rw_engine; //!< Pointer to the rw engine
InputHandler* input; //!< Instance of the input handler
- std::string measurementName;
+ std::string fName;
int eventType;
// Input Event rate flux/event histograms
TH1D* fluxHist; //!< Flux Histogram
TH1D* eventHist; //!< Event Histogram
TH1D* xsecHist; //!< XSec Histogram
double exp_distance; //!< Incoming Particle flight distance (for oscillation analysis)
double scaleFactor; //!< scaleFactor applied to events to convert from eventrate to final distribution
double currentNorm; //!< current normalisation factor applied if fit is "FREE"
bool filledMC; //!< flag whether MC plots have been filled (For ApplyNormalisation)
// TEMP OBJECTS TO HANDLE MERGE
double X_VAR,Y_VAR,Z_VAR,Mode,Weight;
bool Signal;
int ievt;
int nevents;
double Enu_rec, ThetaMu, CosThetaMu;
std::vector<double> X_VAR_VECT;
std::vector<double> Y_VAR_VECT;
std::vector<double> Z_VAR_VECT;
std::vector<int> MODE_VECT;
std::vector<UInt_t> INDEX_VECT;
std::string inputfilename;
};
// Class TypeDefs
typedef std::list<MeasurementBase*>::const_iterator MeasListConstIter;
typedef std::list<MeasurementBase*>::iterator MeasListIter;
typedef std::vector<MeasurementBase*>::const_iterator MeasVectConstIter;
typedef std::vector<MeasurementBase*>::iterator MeasVectIter;
/*! @} */
#endif
diff --git a/src/FitBase/ParamPull.h b/src/FitBase/ParamPull.h
index c59470e..f41f47c 100755
--- a/src/FitBase/ParamPull.h
+++ b/src/FitBase/ParamPull.h
@@ -1,174 +1,171 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#ifndef PARAM_PULL_H_SEEN
-#define PARAM_PULl_H_SEEN
+#define PARAM_PULL_H_SEEN
/*!
* \addtogroup FitBase
* @{
*/
#include <stdlib.h>
#include <numeric>
#include <math.h>
#include <iostream>
#include <sstream>
#include <fstream>
// ROOT includes
#include <TROOT.h>
#include <TH1D.h>
#include <TTree.h>
#include <TFile.h>
#include <TMatrixDSym.h>
#include <TDecompSVD.h>
#include <TVectorD.h>
// Fit Includes
#include "PlotUtils.h"
#include "StatUtils.h"
#include "FitWeight.h"
#include "FitLogger.h"
#include "EventManager.h"
using namespace std;
//! Enums to allow Non Guassian Pulls in Future
enum FitPullTypes {
kUnknownPull = -1,
kNoPull = 0,
kGausPull = 1
};
enum FitThrowTypes {
kUnknownThrow = -1,
kNoThrow = 0,
kGausThrow = 1
};
//! Used to produce gaussian penalty terms in the fit.
class ParamPull {
-
public:
//! Default Constructor
ParamPull(std::string name, std::string inputfile, std::string type);
//! Default destructor
- virtual ~ParamPull() {};
+ virtual ~ParamPull(void) {};
// Set dial types (DEFAULT,ABS,FRAC)
void SetType(std::string type);
// Setup Histogram inputs (from previous fit file, or ROOT file)
void SetupHistograms(std::string input);
// Read a previous NUISANCE file
void ReadFitFile(std::string input);
// Read a ROOT file with any histograms in
void ReadRootFile(std::string input);
// Read Text file
void ReadTextFile(std::string input);
// Read a single dial central value and error
void ReadDialInput(std::string input);
//! Reconfigure function reads in current RW engine dials and sets their value to MC
- void Reconfigure();
+ void Reconfigure(void);
//! Get likelihood given the current values
- double GetLikelihood();
+ double GetLikelihood(void);
//! Get NDOF if used in likelihoods
- int GetNDOF();
+ int GetNDOF(void);
- //! Return the inverted covariance matrix
- TH2D GetCovar();
- inline TMatrixDSym* GetCovarMatrix(){ return fInvCovar; };
-
- //! Get the covariance matrix
- TH2D GetFullCovar();
- inline TMatrixDSym* GetFullCovarMatrix(){ return fCovar; };
+ // Get Covariance Matrices as plots
+ TH2D GetCovar(void);
+ TH2D GetFullCovar(void);
+ TH2D GetDecompCovar(void);
- //! Get the decomp covar
- TH2D GetDecompCovar();
- inline TMatrixDSym* GetDecompCovarMatrix(){ return fDecomp; };
+ // Get Covariance Matrices
+ inline TMatrixDSym GetCovarMatrix (void) const { return *fInvCovar; };
+ inline TMatrixDSym GetFullCovarMatrix (void) const { return *fCovar; };
+ inline TMatrixDSym GetDecompCovarMatrix (void) const { return *fDecomp; };
//! Save the histograms
void Write(std::string writeopt="");
//! Throw the dial values using the current covariance. Useful for parameter throws.
- void ThrowCovariance();
+ void ThrowCovariance(void);
//! Compare dials to RW
- bool CheckDialsValid();
+ bool CheckDialsValid(void);
//! Reset toy data back to original data
- inline void ResetToy(){ fDataHist = fDataTrue; };
+ inline void ResetToy(void){ fDataHist = fDataTrue; };
// Get Functions
- inline std::string GetName() const { return fName; };
- inline std::string GetInput() { return fInput; };
- inline std::string GetType() { return fType; };
- inline std::string GetFileType() { return fFileType; };
- inline std::string GetDialOptions(){ return fDialOptions; };
-
- inline TH1D GetDataHist() const { return *fDataHist; };
- inline TH1D GetDataTrue() const { return *fDataTrue; };
- inline TH1D GetMCHist() const { return *fMCHist; };
- inline TH1D GetMaxHist() const { return *fMaxHist; };
- inline TH1D GetMinHist() const { return *fMinHist; };
- inline TH1I GetDialTypes() const { return *fDialTypes; };
+ inline std::string GetName (void) const { return fName; };
+ inline std::string GetInput (void) const { return fInput; };
+ inline std::string GetType (void) const { return fType; };
+ inline std::string GetFileType (void) const { return fFileType; };
+ inline std::string GetDialOptions (void) const { return fDialOptions; };
+
+ inline TH1D GetDataHist (void) const { return *fDataHist; };
+ inline TH1D GetDataTrue (void) const { return *fDataTrue; };
+ inline TH1D GetMCHist (void) const { return *fMCHist; };
+ inline TH1D GetMaxHist (void) const { return *fMaxHist; };
+ inline TH1D GetMinHist (void) const { return *fMinHist; };
+ inline TH1I GetDialTypes (void) const { return *fDialTypes; };
private:
std::string fName; //!< Pull Name
std::string fInput; //!< Pull input string
std::string fType; //!< Pull options type
std::string fFileType; //!< Pull input file types
std::string fPlotTitles; //! Axis format
std::string fDialOptions; //!< Dial handling options
TH1D* fMCHist; //!< Current MC Histogram
TH1D* fDataHist; //!< Current data Histogram
TH1D* fDataTrue; //!< True Data (before histogram throws)
TH1D* fMaxHist; //!< Maximum limit on MC/Data
TH1D* fMinHist; //!< Maximum limit on MC/Data
TH1I* fDialTypes; //!< Dial Types
int fCalcType; //!< Method to calculate likelihood
int fThrowType; //!< Method to calculate throws
TMatrixDSym* fCovar; //!< Covariance
TMatrixDSym* fInvCovar; //!< Inverted Covariance
TMatrixDSym* fDecomp; //!< Decomposition
};
// Class TypeDefs
typedef std::list<ParamPull*>::const_iterator PullListConstIter;
typedef std::list<ParamPull*>::iterator PullListIter;
typedef std::vector<ParamPull*>::const_iterator PullVectConstIter;
typedef std::vector<ParamPull*>::iterator PullVectIter;
/*! @} */
#endif
diff --git a/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx b/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx
index 13ba512..53cafc8 100644
--- a/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx
+++ b/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx
@@ -1,119 +1,119 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "GGM_CC1ppip_Evt_1DQ2_nu.h"
// The constructor
GGM_CC1ppip_Evt_1DQ2_nu::GGM_CC1ppip_Evt_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "GGM_CC1ppip_Evt_1DQ2_nu";
- // could replace with measurementName = std::string(__FILE__).substr(0, std::string(__FILE__).find_last_of("."))
+ fName = "GGM_CC1ppip_Evt_1DQ2_nu";
+ // could replace with fName = std::string(__FILE__).substr(0, std::string(__FILE__).find_last_of("."))
plotTitles = "; Q^{2}_{CC1#pi} (GeV^{2}); Number of events";
EnuMin = 1;
EnuMax = 10;
isDiag = true;
isRawEvents = true;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/GGM/CC1pip_on_p/GGM_CC1ppip_Q2_events_bin_edit.txt");
this->SetupDefaultHist();
// set Poisson errors on dataHist (scanned does not have this)
// Simple counting experiment here
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinError(i+1, sqrt(dataHist->GetBinContent(i+1)));
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents+0.)*(16./8.);
};
void GGM_CC1ppip_Evt_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack to find relevant particles
// start at 2 because 0=nu, 1=nucleon, by NEUT default
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::MpPi(Pp, Ppip);
double q2CCpip;
// GGM has a M(pi, p) < 1.4 GeV cut imposed only on this channel
if (hadMass < 1400) {
q2CCpip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
} else {
q2CCpip = -1.0;
}
this->X_VAR = q2CCpip;
return;
}
bool GGM_CC1ppip_Evt_1DQ2_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx b/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx
index a2813bd..197b843 100644
--- a/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx
+++ b/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx
@@ -1,114 +1,114 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "GGM_CC1ppip_XSec_1DEnu_nu.h"
// The constructor
GGM_CC1ppip_XSec_1DEnu_nu::GGM_CC1ppip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "GGM_CC1ppip_XSec_1DEnu_nu";
+ fName = "GGM_CC1ppip_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/proton)";
EnuMin = 1.;
EnuMax = 10.0;
isDiag = true;
normError = 0.20;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/GGM/CC1pip_on_p/Gargamelle78-numu-p-to-mu-p-piplus-lowW_EDGES.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(16./8.);
};
void GGM_CC1ppip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pp;
TLorentzVector Ppip;
TLorentzVector Pmu;
// wanna calculate hadronic mass, plot and cut for signal
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 2212) {
Pp = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
// should probably put in a weight here!
double hadMass = FitUtils::MpPi(Pp, Ppip);
double Enu;
if (hadMass < 1400) {
Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip);
} else {
Enu = -1.0;
}
this->X_VAR = Enu;
return;
}
bool GGM_CC1ppip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0;
int lepCnt = 0;
int protonCnt = 0;
for (UInt_t j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move to next particle if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 13) {
lepCnt++;
} else if (PID == 211) {
pipCnt++;
} else if (PID == 2212 /*&& event->Ibound == 0*/) {
protonCnt++;
} else {
return false; // require only three prong events! (allow photons?)
}
}
// don't think there's away of implementing spectator proton cuts in NEUT?
// 100 MeV or larger protons
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
if (protonCnt != 1) return false;
return true;
}
diff --git a/src/K2K/K2K_CC0pi_XSec_1DCosThetaMu_nu_subtrks.cxx b/src/K2K/K2K_CC0pi_XSec_1DCosThetaMu_nu_subtrks.cxx
index bfcbdaf..ac3b33d 100755
--- a/src/K2K/K2K_CC0pi_XSec_1DCosThetaMu_nu_subtrks.cxx
+++ b/src/K2K/K2K_CC0pi_XSec_1DCosThetaMu_nu_subtrks.cxx
@@ -1,168 +1,168 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "K2K_CC0pi_XSec_1DCosThetaMu_nu_subtrks.h"
#include "TLorentzVector.h"
//********************************************************************
K2K_CC0pi_XSec_1DCosThetaMu_nu_subtrks::K2K_CC0pi_XSec_1DCosThetaMu_nu_subtrks(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Define the Measurement
- measurementName = name;
+ fName = name;
plotTitles = "; cos(#theta_{#mu}); Events";
EnuMin = 0.3;
EnuMax = 5.;
isDiag = true;
isRawEvents = true;
matchnorm = type.find("SCL") != std::string::npos;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Set the sample type
if (name.find("1trk") != std::string::npos) { k2k_sample_type = fK2K_1track; }
else if (name.find("2trkQE") != std::string::npos){ k2k_sample_type = fK2K_2trackQE; }
else if (name.find("2trkNonQE") != std::string::npos){ k2k_sample_type = fK2K_2trackNONQE; }
// Setup the cuts
switch(k2k_sample_type){
case fK2K_1track:
ncharged_cut = 1;
deltaphi_cut = 999;
break;
case fK2K_2trackQE:
ncharged_cut = 2;
deltaphi_cut = 999; // change later
break;
case fK2K_2trackNONQE:
ncharged_cut = 2;
deltaphi_cut = 999;
break;
default:
- LOG(SAM) << this->measurementName << "Incorrect K2K sample type included: " << name << std::endl;
+ LOG(SAM) << this->fName << "Incorrect K2K sample type included: " << name << std::endl;
ncharged_cut = 0;
deltaphi_cut = 0;
break;
}
// Set the plot to be read in
std::string plotname = "";
switch(k2k_sample_type){
case fK2K_1track: plotname = "Data_1DCosThetaMu_SmlAngle_1track"; break;
case fK2K_2trackQE: plotname = "Data_1DCosThetaMu_SmlAngle_2trackQE"; break;
case fK2K_2trackNONQE: plotname = "Data_1DCosThetaMu_SmlAngle_2trackNONQE"; break;
}
this->SetDataFromFile(FitPar::GetDataBase()+"/K2K/K2K_Data_PRD74_052002.root", plotname);
// Setup MC Plots
this->SetupDefaultHist();
// Forced to be diag for now
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Different generators require slightly different rescaling factors.
if (this->eventType == 0) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // NEUT
else if (this->eventType == 1) this->scaleFactor = (this->eventHist->Integral()*1E-38/(nevents+0.)); // NUWRO
else if (this->eventType == 5) this->scaleFactor = (this->eventHist->Integral()*1E-38/(nevents+0.)); // GENIE
};
//********************************************************************
void K2K_CC0pi_XSec_1DCosThetaMu_nu_subtrks::FillEventVariables(FitEvent *event){
//********************************************************************
ncharged = 0;
bad_particle = false;
CosThetaMu = 0.0;
// loop particles
for (UInt_t i = 2; i < event->Npart(); i++){
// skip bad ones
if (!(event->PartInfo(i))->fIsAlive or (event->PartInfo(i))->fStatus != 0 ) continue;
// pid check
if ((event->PartInfo(i))->fPID == 13){
CosThetaMu = cos(((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(i))->fP.Vect())));
// CC0pi like
} else if ((event->PartInfo(i))->fPID != 22 &&
(event->PartInfo(i))->fPID != 2212 &&
(event->PartInfo(i))->fPID != 2112 &&
(event->PartInfo(i))->fPID != 13){
bad_particle = true;
// ncharged particles
}
if ((event->PartInfo(i))->fPID == 2212 or
(event->PartInfo(i))->fPID == 13){
ncharged++;
}
}
this->X_VAR = CosThetaMu;
- LOG(EVT) << "Event variables for "<<this->measurementName<<std::endl;
+ LOG(EVT) << "Event variables for "<<this->fName<<std::endl;
LOG(EVT)<<"X_VAR = "<<this->X_VAR<<std::endl;
LOG(EVT)<<"ncharged = "<<ncharged<<std::endl;
LOG(EVT)<<"bad_particle = "<<bad_particle<<std::endl;
return;
}
//********************************************************************
bool K2K_CC0pi_XSec_1DCosThetaMu_nu_subtrks::isSignal(FitEvent *event){
//********************************************************************
// Signal is defined as a CC0pi sample in the final state with only 1 charged track
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict energy range
//if ((event->PartInfo(0))->fP.E() < this->EnuMin*1000 || (event->PartInfo(0))->fP.E() > this->EnuMax*1000) return false;
if (bad_particle) return false;
if (ncharged != ncharged_cut) return false;
return true;
};
//********************************************************************
void K2K_CC0pi_XSec_1DCosThetaMu_nu_subtrks::ScaleEvents(){
//********************************************************************
this->mcHist->Scale(this->scaleFactor);
this->mcFine->Scale(this->scaleFactor);
return;
}
diff --git a/src/K2K/K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks.cxx b/src/K2K/K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks.cxx
index 569952f..c00d977 100755
--- a/src/K2K/K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks.cxx
+++ b/src/K2K/K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks.cxx
@@ -1,221 +1,221 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks.h"
#include "TLorentzVector.h"
//********************************************************************
K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks::K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Define Measurement
- measurementName = "K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks";
+ fName = "K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks";
plotTitles = "; #Delta#Phi (Deg.); Events";
EnuMin = 0.3;
EnuMax = 5.;
isDiag = true;
isRawEvents = true;
matchnorm = type.find("SCL") != std::string::npos;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Set the plot to be read in
this->SetDataFromFile(FitPar::GetDataBase()+"/K2K/K2K_Data_PRD74_052002.root", "Data_1DDelTheta_2tracks");
// Forced to be diag for now
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar= StatUtils::GetInvert(fullcovar);
// Setup MC Hists
SetupDefaultHist();
this->K2KI_holder = (TH1D*) this->mcHist->Clone("K2KI_holder");
this->K2KIIa_holder = (TH1D*) this->mcHist->Clone("K2KIIa_holder");
// double POT = 0.922E20;
// double cm2 = 1.0E12 * 130000;
// double gev = 1.0E9;
// Different generators require slightly different rescaling factors.
if (this->eventType == 0) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // NEUT
else if (this->eventType == 1) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // NUWRO
else if (this->eventType == 5) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // GENIE
// Other Variables
finished_fit = false;
mcSignalEvt = 0;
dataSignalEvt = 13440;
};
//********************************************************************
void K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks::FillEventVariables(FitEvent *event){
//********************************************************************
bad_particle = false;
Pmu = 0.0;
ncharged = 0;
TLorentzVector vecpnu = (event->PartInfo(0))->fP;
TLorentzVector vecpmu;
TLorentzVector vecppr;
TLorentzVector vecpne;
// loop particles
for (UInt_t i = 0; i < event->Npart(); i++){
if (i < 2 and (event->PartInfo(i))->fPID == 2112){
vecpne = (event->PartInfo(i))->fP;
}
// skip bad ones
if (!(event->PartInfo(i))->fIsAlive or (event->PartInfo(i))->fStatus != 0 ) continue;
// pid check
if ((event->PartInfo(i))->fPID == 13){
ThetaMu = (event->PartInfo(i))->fP.Vect().Angle( (event->PartInfo(0))->fP.Vect() ) * 57.2958;
Pmu = (event->PartInfo(i))->fP.Vect().Mag()/1000.0;
ncharged++;
vecpnu = (event->PartInfo(i))->fP;
// CC0pi like
} else if ((event->PartInfo(i))->fPID == 2212){
if ((event->PartInfo(i))->fP.Vect().Mag() > 600.0){
ncharged++;
vecppr = (event->PartInfo(i))->fP;
}
} else if ((event->PartInfo(i))->fPID == -211 or
(event->PartInfo(i))->fPID == 211){
if ((event->PartInfo(i))->fP.Vect().Mag() > 200.0)
ncharged++;
} else if ((event->PartInfo(i))->fPID != 22 and
(event->PartInfo(i))->fPID != 2112){
bad_particle = true;
}
}
if (ncharged == 2){
double Mmu = 105.392;
double Mpr = 938.12;
double Mne = 935.12;
double Emu = vecpmu.E();
double Epr = vecppr.E();
double Eb = Epr - Mne;
DelPhi = acos( ( Mmu*Mmu + Mpr*Mpr + Mne*Mne + 2*Epr*Mne + 2*Eb*Emu ) /
( vecpmu.Vect().Mag() * vecppr.Vect().Mag() ) ) * 59.78;
}
this->X_VAR = DelPhi;
- LOG(EVT) << "Event variables for "<<this->measurementName<<std::endl;
+ LOG(EVT) << "Event variables for "<<this->fName<<std::endl;
LOG(EVT)<<"X_VAR = "<<this->X_VAR<<std::endl;
LOG(EVT)<<"bad_particle = "<<bad_particle<<std::endl;
LOG(EVT)<<"ncharged = "<<ncharged<<std::endl;
return;
}
//********************************************************************
bool K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks::isSignal(FitEvent *event){
//********************************************************************
// Signal is defined as a CC0pi sample in the final state with only 1 charged track
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict energy range
if ((event->PartInfo(0))->fP.E() < this->EnuMin*1000 || (event->PartInfo(0))->fP.E() > this->EnuMax*1000) return false;
// if (bad_particle) return false;
if (Pmu < 0.550 or Pmu > 3.5) return false;
if (!finished_fit and ncharged < 4) mcSignalEvt++;
if (ncharged > 2 or ncharged == 0) return false;
if (ievt < (8144.0/(4967.0+8144.0))*(nevents+0.) and
Pmu < 0.675)
return false;
return true;
};
//********************************************************************
void K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks::FillHistograms(){
//********************************************************************
if (Signal){
if (ievt < (8144.0 * (nevents + 0.)/(this->dataSignalEvt+0.)))
this->K2KI_holder->Fill(this->X_VAR, Weight);
else if (ievt >= (8144.0 * (nevents + 0.)/(this->dataSignalEvt+0.)))
if (Pmu > 0.675)
this->K2KIIa_holder->Fill(this->X_VAR, Weight);
}
Measurement1D::FillHistograms();
return;
}
//********************************************************************
void K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks::ScaleEvents(){
//********************************************************************
if (!finished_fit){
finished_fit = true;
if (matchnorm){
// this->scaleFactor = (dataSignalEvt + 0.) / (mcSignalEvt + 0.);
this->scaleFactor = (this->dataHist->Integral() + 0.) /(this->mcHist->Integral());
}
}
this->mcHist->Scale(this->scaleFactor);
this->mcFine->Scale(this->scaleFactor);
this->K2KI_holder->Scale(this->scaleFactor);
this->K2KIIa_holder->Scale(this->scaleFactor);
PlotUtils::ScaleNeutModeArray((TH1**)this->mcHist_PDG, this->scaleFactor, "");
return;
}
//********************************************************************
void K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks::ResetAll(){
//********************************************************************
this->K2KI_holder->Reset();
this->K2KIIa_holder->Reset();
return;
}
diff --git a/src/K2K/K2K_CC0pi_XSec_1DPmu_nu_Ntrks.cxx b/src/K2K/K2K_CC0pi_XSec_1DPmu_nu_Ntrks.cxx
index a41aacf..bd98de3 100755
--- a/src/K2K/K2K_CC0pi_XSec_1DPmu_nu_Ntrks.cxx
+++ b/src/K2K/K2K_CC0pi_XSec_1DPmu_nu_Ntrks.cxx
@@ -1,208 +1,208 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "K2K_CC0pi_XSec_1DPmu_nu_Ntrks.h"
#include "TLorentzVector.h"
//********************************************************************
K2K_CC0pi_XSec_1DPmu_nu_Ntrks::K2K_CC0pi_XSec_1DPmu_nu_Ntrks(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Define Measurement
- measurementName = "K2K_CC0pi_XSec_1DPmu_nu_Ntrks";
+ fName = "K2K_CC0pi_XSec_1DPmu_nu_Ntrks";
plotTitles = "; P_#mu (GeV/c^{2}); Events";
EnuMin = 0.3;
EnuMax = 5.;
isDiag = true;
isRawEvents = true;
matchnorm = type.find("SCL") != std::string::npos;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Set the plot to be read in
SetDataFromFile(FitPar::GetDataBase()+"/K2K/K2K_Data_PRD74_052002.root", "Data_1DPmu_alltracks");
// Forced to be diag for now
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar= StatUtils::GetInvert(fullcovar);
// setup mc histograms
SetupDefaultHist();
this->K2KI_holder = (TH1D*) this->mcHist->Clone("K2KI_holder");
this->K2KIIa_holder = (TH1D*) this->mcHist->Clone("K2KIIa_holder");
// double POT = 0.922E20;
// double cm2 = 1.0E12 * 130000;
// double gev = 1.0E9;
// Different generators require slightly different rescaling factors.
if (this->eventType == 0) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // NEUT
else if (this->eventType == 1) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // NUWRO
else if (this->eventType == 5) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // GENIE
// Other Variables
finished_fit = false;
mcSignalEvt = 0;
dataSignalEvt = 13440;
};
//********************************************************************
void K2K_CC0pi_XSec_1DPmu_nu_Ntrks::FillEventVariables(FitEvent *event){
//********************************************************************
bad_particle = false;
Pmu = 0.0;
ncharged = 0;
TLorentzVector vecpnu = (event->PartInfo(0))->fP;
TLorentzVector vecpmu;
TLorentzVector vecppr;
TLorentzVector vecpne;
// loop particles
for (UInt_t i = 0; i < event->Npart(); i++){
if (i < 2 and (event->PartInfo(i))->fPID == 2112){
vecpne = (event->PartInfo(i))->fP;
}
// skip bad ones
if (!(event->PartInfo(i))->fIsAlive or (event->PartInfo(i))->fStatus != 0 ) continue;
// pid check
if ((event->PartInfo(i))->fPID == 13){
ThetaMu = (event->PartInfo(i))->fP.Vect().Angle( (event->PartInfo(0))->fP.Vect() ) * 57.2958;
Pmu = (event->PartInfo(i))->fP.Vect().Mag()/1000.0;
ncharged++;
vecpnu = (event->PartInfo(i))->fP;
// CC0pi like
} else if ((event->PartInfo(i))->fPID == 2212){
if ((event->PartInfo(i))->fP.Vect().Mag() > 600.0){
ncharged++;
vecppr = (event->PartInfo(i))->fP;
}
} else if ((event->PartInfo(i))->fPID == -211 or
(event->PartInfo(i))->fPID == 211){
if ((event->PartInfo(i))->fP.Vect().Mag() > 200.0)
ncharged++;
} else if ((event->PartInfo(i))->fPID != 22 and
(event->PartInfo(i))->fPID != 2112){
bad_particle = true;
}
}
if (ncharged == 2){
TLorentzVector vecptemp = vecpnu + vecpne - vecpmu;
DelPhi = vecptemp.Vect().Angle(vecppr.Vect()) * 57.2958;
}
this->X_VAR = Pmu;
- LOG(EVT) << "Event variables for "<<this->measurementName<<std::endl;
+ LOG(EVT) << "Event variables for "<<this->fName<<std::endl;
LOG(EVT)<<"X_VAR = "<<this->X_VAR<<std::endl;
LOG(EVT)<<"bad_particle = "<<bad_particle<<std::endl;
LOG(EVT)<<"ncharged = "<<ncharged<<std::endl;
return;
}
//********************************************************************
bool K2K_CC0pi_XSec_1DPmu_nu_Ntrks::isSignal(FitEvent *event){
//********************************************************************
// Signal is defined as a CC0pi sample in the final state with only 1 charged track
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict energy range
if ((event->PartInfo(0))->fP.E() < this->EnuMin*1000 || (event->PartInfo(0))->fP.E() > this->EnuMax*1000) return false;
// if (bad_particle) return false;
if (Pmu < 0.675 or Pmu > 3.5) return false;
if (!finished_fit and ncharged < 4) mcSignalEvt++;
if (ncharged > 2 or ncharged == 0) return false;
if (ThetaMu > 35.0) return false;
return true;
};
//********************************************************************
void K2K_CC0pi_XSec_1DPmu_nu_Ntrks::FillHistograms(){
//********************************************************************
if (Signal){
if (ievt < (8144.0 * (nevents + 0.)/(this->dataSignalEvt+0.)))
this->K2KI_holder->Fill(this->X_VAR, Weight);
else if (ievt >= (8144.0 * (nevents + 0.)/(this->dataSignalEvt+0.)))
if (Pmu > 0.675)
this->K2KIIa_holder->Fill(this->X_VAR, Weight);
}
Measurement1D::FillHistograms();
return;
}
//********************************************************************
void K2K_CC0pi_XSec_1DPmu_nu_Ntrks::ScaleEvents(){
//********************************************************************
if (!finished_fit){
finished_fit = true;
if (matchnorm){
this->scaleFactor = (this->dataHist->Integral() + 0.) /(this->mcHist->Integral());
}
}
this->mcHist->Scale(this->scaleFactor);
this->mcFine->Scale(this->scaleFactor);
this->K2KI_holder->Scale(this->scaleFactor);
this->K2KIIa_holder->Scale(this->scaleFactor);
PlotUtils::ScaleNeutModeArray((TH1**)this->mcHist_PDG, this->scaleFactor, "");
return;
}
//********************************************************************
void K2K_CC0pi_XSec_1DPmu_nu_Ntrks::ResetAll(){
//********************************************************************
this->K2KI_holder->Reset();
this->K2KIIa_holder->Reset();
return;
}
diff --git a/src/K2K/K2K_CC0pi_XSec_1DQ2_nu_subtrks.cxx b/src/K2K/K2K_CC0pi_XSec_1DQ2_nu_subtrks.cxx
index 602f8d9..8d99dfc 100755
--- a/src/K2K/K2K_CC0pi_XSec_1DQ2_nu_subtrks.cxx
+++ b/src/K2K/K2K_CC0pi_XSec_1DQ2_nu_subtrks.cxx
@@ -1,220 +1,220 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "K2K_CC0pi_XSec_1DQ2_nu_subtrks.h"
#include "TLorentzVector.h"
//********************************************************************
K2K_CC0pi_XSec_1DQ2_nu_subtrks::K2K_CC0pi_XSec_1DQ2_nu_subtrks(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Define the Measurement
- measurementName = name;
+ fName = name;
plotTitles = "; Q^{2}_{QE} (GeV/c^{2}); Events";
EnuMin = 0.3;
EnuMax = 5.;
isDiag = true;
isRawEvents = true;
matchnorm = type.find("SCL") != std::string::npos;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Set the sample type
if (name.find("K2KI_") != std::string::npos){
if (name.find("_1trk") != std::string::npos){ k2k_sample_type = fK2KI_1track; }
else if (name.find("_2trkQE") != std::string::npos){ k2k_sample_type = fK2KI_2trackQE; }
else if (name.find("_2trkNonQE") != std::string::npos){ k2k_sample_type = fK2KI_2trackNONQE; }
} else if (name.find("K2KIIa_") != std::string::npos){
if (name.find("_1trk") != std::string::npos){ k2k_sample_type = fK2KIIa_1track; }
else if (name.find("_2trkQE") != std::string::npos){ k2k_sample_type = fK2KIIa_2trackQE; }
else if (name.find("_2trkNonQE") != std::string::npos){ k2k_sample_type = fK2KIIa_2trackNONQE; }
}
// Setup the cuts
switch(k2k_sample_type){
case fK2KI_1track:
case fK2KIIa_1track:
ncharged_cut = 1;
deltaphi_cut = 999;
break;
case fK2KI_2trackQE:
case fK2KIIa_2trackQE:
ncharged_cut = 2;
deltaphi_cut = 0; // change later
deltaphi_type = false;
break;
case fK2KI_2trackNONQE:
case fK2KIIa_2trackNONQE:
ncharged_cut = 2;
deltaphi_cut = 999;
deltaphi_type = true;
break;
default:
- LOG(SAM) << this->measurementName << "Incorrect K2K sample type included: " << name << std::endl;
+ LOG(SAM) << this->fName << "Incorrect K2K sample type included: " << name << std::endl;
ncharged_cut = 0;
deltaphi_cut = 0;
deltaphi_type = false;
break;
}
// Set the plot to be read in
std::string plotname = "";
switch(k2k_sample_type){
case fK2KI_1track: plotname = "Data_1DQ2_K2KI_1track"; break;
case fK2KIIa_1track: plotname = "Data_1DQ2_K2KIIa_1track"; break;
case fK2KI_2trackQE: plotname = "Data_1DQ2_K2KI_2trackQE"; break;
case fK2KIIa_2trackQE: plotname = "Data_1DQ2_K2KIIa_2trackQE"; break;
case fK2KI_2trackNONQE: plotname = "Data_1DQ2_K2KI_2trackNONQE"; break;
case fK2KIIa_2trackNONQE: plotname = "Data_1DQ2_K2KIIa_2trackNONQE"; break;
}
this->SetDataFromFile(FitPar::GetDataBase()+"/K2K/K2K_Data_PRD74_052002.root", plotname);
// Setup Covariance;
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar= StatUtils::GetInvert(fullcovar);
// setup mc histograms
SetupDefaultHist();
// Different generators require slightly different rescaling factors.
if (this->eventType == 0) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // NEUT
else if (this->eventType == 1) this->scaleFactor = (this->eventHist->Integral()*1E-38/(nevents+0.)); // NUWRO
else if (this->eventType == 5) this->scaleFactor = (this->eventHist->Integral()*1E-38/(nevents+0.)); // GENIE
};
//********************************************************************
void K2K_CC0pi_XSec_1DQ2_nu_subtrks::FillEventVariables(FitEvent *event){
//********************************************************************
ncharged = 0;
bad_particle = false;
CosThetaMu = -999.9;
q2qe = -1.0;
deltaphi = 0.0;
- LOG(EVT) << "Filling event variables for K2K" << this->measurementName<<std::endl;
+ LOG(EVT) << "Filling event variables for K2K" << this->fName<<std::endl;
// TLorentzVector pnu = (event->PartInfo(0))->fP;
// TLorentzVector pmu;
// TLorentzVector ppr;
// loop particles
for (UInt_t i = 2; i < event->Npart(); i++){
// skip bad ones
if (!(event->PartInfo(i))->fIsAlive or (event->PartInfo(i))->fStatus != 0 ) continue;
// pid check
if ((event->PartInfo(i))->fPID == 13){
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(i))->fP.Vect());
q2qe = FitUtils::Q2QErec((event->PartInfo(i))->fP, cos(ThetaMu), 34. ,true);
deltaphi = 0.0;
// FOR QE approx the momentum between the muon and proton should equal the neutrino.
// pmu = (event->PartInfo(i))->fP;
ncharged++;
// CC0pi like
} else if ((event->PartInfo(i))->fPID != 22 &&
(event->PartInfo(i))->fPID != 2212 &&
(event->PartInfo(i))->fPID != 2112 &&
(event->PartInfo(i))->fPID != 13){
bad_particle = true;
// ncharged particles
}
// if ((event->PartInfo(i))->fPID == 2212){
// ppr = (event->PartInfo(i))->fP;
// ncharged++;
// }
}
// if (ncharged == 2){
// TLorentzVector pQE = pnu - pmu;
// deltaphi = pQE.Vect().Angle(ppr.Vect());
// }
this->X_VAR = q2qe;
- LOG(EVT) << "Event variables for "<<this->measurementName<<std::endl;
+ LOG(EVT) << "Event variables for "<<this->fName<<std::endl;
LOG(EVT)<<"X_VAR = "<<this->X_VAR<<std::endl;
LOG(EVT)<<"ncharged = "<<ncharged<<std::endl;
LOG(EVT)<<"bad_particle = "<<bad_particle<<std::endl;
LOG(EVT)<<"Delta_phi = "<<deltaphi<<std::endl;
return;
}
//********************************************************************
bool K2K_CC0pi_XSec_1DQ2_nu_subtrks::isSignal(FitEvent *event){
//********************************************************************
// Signal is defined as a CC0pi sample in the final state with only 1 charged track
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict energy range
//if ((event->PartInfo(0))->fP.E() < this->EnuMin*1000 || (event->PartInfo(0))->fP.E() > this->EnuMax*1000) return false;
if (bad_particle) return false;
if (( ncharged > ncharged_cut and ncharged == 2) or ncharged == 0) return false;
// QE Cuts
if ( ( deltaphi_type and deltaphi > deltaphi_cut) or
(!deltaphi_type and deltaphi < deltaphi_cut) ) return false;
return true;
};
//********************************************************************
void K2K_CC0pi_XSec_1DQ2_nu_subtrks::ScaleEvents(){
//********************************************************************
this->mcHist->Scale(this->scaleFactor);
this->mcFine->Scale(this->scaleFactor);
// double scaleF = 5933.0/this->mcHist->Integral();
- // LOG(SAM) << this->measurementName <<"ScaleF = "<<scaleF<<std::endl;
+ // LOG(SAM) << this->fName <<"ScaleF = "<<scaleF<<std::endl;
// this->mcHist->Scale(scaleF);
// this->mcFine->Scale(scaleF);
// this->mcHist->Scale(
// this->mcFine->Scale(this->dataHist->Integral() / this->mcHist->Integral());
// PlotUtils::ScaleNeutModeArray((TH1**)this->mcHist_PDG, this->dataHist->Integral() / this->mcHist->Integral(), "");
return;
}
diff --git a/src/K2K/K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks.cxx b/src/K2K/K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks.cxx
index 62b41f5..664d8e2 100755
--- a/src/K2K/K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks.cxx
+++ b/src/K2K/K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks.cxx
@@ -1,211 +1,211 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks.h"
#include "TLorentzVector.h"
//********************************************************************
K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks::K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Define Measurement
- measurementName = "K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks";
+ fName = "K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks";
plotTitles = "; Cos(#theta_{#mu}); Events";
EnuMin = 0.3;
EnuMax = 5.;
isDiag = true;
isRawEvents = true;
matchnorm = type.find("SCL") != std::string::npos;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Set the plot to be read in
this->SetDataFromFile(FitPar::GetDataBase()+"/K2K/K2K_Data_PRD74_052002.root", "Data_1DCosThetaMu_alltracks");
// Forced to be diag for now
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar= StatUtils::GetInvert(fullcovar);
// Setup MC Hist
SetupDefaultHist();
this->K2KI_holder = (TH1D*) this->mcHist->Clone("K2KI_holder");
this->K2KIIa_holder = (TH1D*) this->mcHist->Clone("K2KIIa_holder");
// double POT = 0.922E20;
// double cm2 = 1.0E12 * 130000;
// double gev = 1.0E9;
// Different generators require slightly different rescaling factors.
if (this->eventType == 0) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // NEUT
else if (this->eventType == 1) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // NUWRO
else if (this->eventType == 5) this->scaleFactor = (this->eventHist->Integral()/(nevents+0.)); // GENIE
// Other Variables
finished_fit = false;
mcSignalEvt = 0;
dataSignalEvt = 13440;
};
//********************************************************************
void K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks::FillEventVariables(FitEvent *event){
//********************************************************************
bad_particle = false;
Pmu = 0.0;
ncharged = 0;
TLorentzVector vecpnu = (event->PartInfo(0))->fP;
TLorentzVector vecpmu;
TLorentzVector vecppr;
TLorentzVector vecpne;
// loop particles
for (UInt_t i = 0; i < event->Npart(); i++){
if (i < 2 and (event->PartInfo(i))->fPID == 2112){
vecpne = (event->PartInfo(i))->fP;
}
// skip bad ones
if (!(event->PartInfo(i))->fIsAlive or (event->PartInfo(i))->fStatus != 0 ) continue;
// pid check
if ((event->PartInfo(i))->fPID == 13){
ThetaMu = (event->PartInfo(i))->fP.Vect().Angle( (event->PartInfo(0))->fP.Vect() ) * 57.2958;
Pmu = (event->PartInfo(i))->fP.Vect().Mag()/1000.0;
ncharged++;
vecpnu = (event->PartInfo(i))->fP;
// CC0pi like
} else if ((event->PartInfo(i))->fPID == 2212){
if ((event->PartInfo(i))->fP.Vect().Mag() > 600.0){
ncharged++;
vecppr = (event->PartInfo(i))->fP;
}
} else if ((event->PartInfo(i))->fPID == -211 or
(event->PartInfo(i))->fPID == 211){
if ((event->PartInfo(i))->fP.Vect().Mag() > 200.0)
ncharged++;
} else if ((event->PartInfo(i))->fPID != 22 and
(event->PartInfo(i))->fPID != 2112){
bad_particle = true;
}
}
if (ncharged == 2){
TLorentzVector vecptemp = vecpnu + vecpne - vecpmu;
DelPhi = vecptemp.Vect().Angle(vecppr.Vect()) * 57.2958;
}
this->X_VAR = ThetaMu;
- LOG(EVT) << "Event variables for "<<this->measurementName<<std::endl;
+ LOG(EVT) << "Event variables for "<<this->fName<<std::endl;
LOG(EVT)<<"X_VAR = "<<this->X_VAR<<std::endl;
LOG(EVT)<<"bad_particle = "<<bad_particle<<std::endl;
LOG(EVT)<<"ncharged = "<<ncharged<<std::endl;
return;
}
//********************************************************************
bool K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks::isSignal(FitEvent *event){
//********************************************************************
// Signal is defined as a CC0pi sample in the final state with only 1 charged track
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict energy range
if ((event->PartInfo(0))->fP.E() < this->EnuMin*1000 || (event->PartInfo(0))->fP.E() > this->EnuMax*1000) return false;
//if (bad_particle) return false;
if (Pmu < 0.550 or Pmu > 3.5) return false;
if (!finished_fit and ncharged < 4) mcSignalEvt++;
if (ncharged > 2 or ncharged == 0) return false;
if (ievt < (8144.0/(4967.0+8144.0))*(nevents+0.) and
Pmu < 0.675)
return false;
return true;
};
//********************************************************************
void K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks::FillHistograms(){
//********************************************************************
if (Signal){
if (ievt < (8144.0 * (nevents + 0.)/(this->dataSignalEvt+0.)))
this->K2KI_holder->Fill(this->X_VAR, Weight);
else if (ievt >= (8144.0 * (nevents + 0.)/(this->dataSignalEvt+0.)))
if (Pmu > 0.675)
this->K2KIIa_holder->Fill(this->X_VAR, Weight);
}
Measurement1D::FillHistograms();
return;
}
//********************************************************************
void K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks::ScaleEvents(){
//********************************************************************
if (!finished_fit){
finished_fit = true;
if (matchnorm){
// this->scaleFactor = (dataSignalEvt + 0.) / (mcSignalEvt + 0.);
this->scaleFactor = (this->dataHist->Integral() + 0.) /(this->mcHist->Integral());
}
}
this->mcHist->Scale(this->scaleFactor);
this->mcFine->Scale(this->scaleFactor);
this->K2KI_holder->Scale(this->scaleFactor);
this->K2KIIa_holder->Scale(this->scaleFactor);
PlotUtils::ScaleNeutModeArray((TH1**)this->mcHist_PDG, this->scaleFactor, "");
return;
}
//********************************************************************
void K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks::ResetAll(){
//********************************************************************
this->K2KI_holder->Reset();
this->K2KIIa_holder->Reset();
return;
}
diff --git a/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.cxx b/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.cxx
index 90e0983..8655b02 100644
--- a/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.cxx
+++ b/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.cxx
@@ -1,64 +1,64 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "K2K_NC1pi0_Evt_1Dppi0_nu.h"
// The constructor
K2K_NC1pi0_Evt_1Dppi0_nu::K2K_NC1pi0_Evt_1Dppi0_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "K2K_NC1pi0_Evt_1Dppi0_nu";
+ fName = "K2K_NC1pi0_Evt_1Dppi0_nu";
plotTitles = "; p_{#pi^{0}} (MeV/c); Number of events";
EnuMin = 0.;
EnuMax = 5.;
isDiag = true;
normError = 0.15;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/K2K/ncpi0/ppi0.csv");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
this->scaleFactor = 1; // No need to care about scaling factors for shape measurements
};
void K2K_NC1pi0_Evt_1Dppi0_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Ppi0;
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
}
}
double ppi0 = FitUtils::p(Ppi0)*1000.;
this->X_VAR = ppi0;
return;
};
bool K2K_NC1pi0_Evt_1Dppi0_nu::isSignal(FitEvent *event) {
return SignalDef::isNC1pi0_MiniBooNE(event, EnuMin, EnuMax); // Check this signal definition
// Fairly sure K2K and MiniBooNE had same definition...
}
diff --git a/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx b/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx
index 8e2db80..7967b30 100644
--- a/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx
+++ b/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx
@@ -1,153 +1,153 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ExpMultDist_CCQE_XSec_1DVar_FakeStudy.h"
//********************************************************************
/// @brief Class to perform CCQE Fake Data Studies on a custom measurement
ExpMultDist_CCQE_XSec_1DVar_FakeStudy::ExpMultDist_CCQE_XSec_1DVar_FakeStudy(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
// Define our energy range for flux calcs
EnuMin = 0.;
EnuMax = 6.;
// Set default fitter flags
isDiag = true;
isShape = false;
isRawEvents = false;
// This function will sort out the input files automatically and parse all the inputs,flags,etc.
// There may be complex cases where you have to do this by hand, but usually this will do.
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Use the name to define what variable to measure
int nbins;
double binlow, binhigh;
if (name.find("1DQ2") != std::string::npos){
plottype = 1; plotTitles = "";
nbins = 30; binlow = 0.0; binhigh = 2.0;
} else if (name.find("1DTmu") != std::string::npos){
plottype = 2; plotTitles = "";
nbins = 20; binlow = 0.0; binhigh = 3.0;
} else if (name.find("1DCos") != std::string::npos){
plottype = 3; plotTitles = "";
nbins = 10; binlow = -1.0; binhigh = 1.0;
}
// Setup the datahist as empty, we will use fake data to fill it.
- this->dataHist = new TH1D((measurementName + "_data").c_str(), (measurementName + "_data" + plotTitles).c_str(), nbins, binlow, binhigh);
+ this->dataHist = new TH1D((fName + "_data").c_str(), (fName + "_data" + plotTitles).c_str(), nbins, binlow, binhigh);
// Once dataHist is setup this function will automatically generate matching MC histograms
this->SetupDefaultHist();
// Setup Covariance assuming a diagonal covar.
// If you want a full covariance to be used examples are given in the MINERvA 1D classes
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// 3. The generator is organised in SetupMeasurement so it gives the cross-section in "per nucleon" units.
// So some extra scaling for a specific measurement may be required. For Example to get a "per neutron" measurement on carbon
// which we do here, we have to multiple by the number of nucleons 12 and divide by the number of neutrons 6.
this->scaleFactor = (this->eventHist->Integral()*1E-38/(nevents+0.)) * (12.0 / 6.0) /this->TotalIntegratedFlux();
};
//********************************************************************
/// @details Extract Enu and totcrs from event assuming quasi-elastic scattering
void ExpMultDist_CCQE_XSec_1DVar_FakeStudy::FillEventVariables(FitEvent *event){
//********************************************************************
// MUST be defined for each new sample.
// This function reads in the FitEvent format and lets you grab any information you need
// from the event. This function is only called during the first and last iteration of each fit so that
// a vector of X_VAR variables can be filled for the signal events.
// Define empty variables
this->X_VAR = -1.0;
double q2qe = 0.0;
double CosThetaMu = -2.0;
double TMu = 0.0;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
// Look for the outgoing muon
if ((event->PartInfo(j))->fPID != 13) continue;
// Define any variables we may need
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
Enu_rec = FitUtils::EnuQErec((event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
q2qe = FitUtils::Q2QErec( (event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
CosThetaMu = cos(ThetaMu);
TMu = FitUtils::T((event->PartInfo(j))->fP);
// Once lepton is found, don't continue the loop
break;
}
if (this->plottype == 1) this->X_VAR = q2qe;
else if (this->plottype == 2) this->X_VAR = TMu;
else if (this->plottype == 3) this->X_VAR = CosThetaMu;
return;
};
//********************************************************************
/// @details Signal is true CCQE scattering
///
/// @details Cut 1: numu event
/// @details Cut 2: Mode == 1
/// @details Cut 3: EnuMin < Enu < EnuMax
bool ExpMultDist_CCQE_XSec_1DVar_FakeStudy::isSignal(FitEvent *event){
//********************************************************************
// Place cuts on each of the events here.
// MUST be defined for all new samples, there is no default signal definition.
// Check FitUtils and CutUtils for example cuts that can be used quickly.
// During a fit isSignal is only used in the first fit function call to define
// which of the events actually need to be considered, so don't worry too much if
// this function is inefficient.
// Mode and Enu are automatically avaialble in this function, they don't need to be set earlier.
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Only look at CCQE Events and MEC Events
if (Mode != 1 and Mode != 2) return false;
// Restrict energy range
if (Enu < this->EnuMin || Enu > this->EnuMax) return false;
return true;
};
diff --git a/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx b/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx
index 138f2fc..8475e26 100644
--- a/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx
+++ b/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx
@@ -1,169 +1,169 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h"
//********************************************************************
/// @brief Class to perform CCQE Fake Data Studies on a custom measurement
ExpMultDist_CCQE_XSec_2DVar_FakeStudy::ExpMultDist_CCQE_XSec_2DVar_FakeStudy(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
// Define our energy range for flux calcs
EnuMin = 0.;
EnuMax = 6.;
// Set default fitter flags
isDiag = true;
isShape = false;
isRawEvents = false;
// This function will sort out the input files automatically and parse all the inputs,flags,etc.
// There may be complex cases where you have to do this by hand, but usually this will do.
Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Use the name to define what variable to measure
int nbinsx, nbinsy;
double binlowx, binhighx;
double binlowy, binhighy;
if (name.find("Q2vsTmu") != std::string::npos){
plottype = 1; plotTitles = "";
nbinsx = 30; binlowx = 0.0; binhighx = 2.0;
nbinsy = 20; binlowy = 0.0; binhighy = 3.0;
} else if (name.find("Q2vsCos") != std::string::npos){
plottype = 2; plotTitles = "";
nbinsx = 30; binlowx = 0.0;binhighx = 2.0;
nbinsy = 10; binlowy = -1.0; binhighy = 1.0;
} else if (name.find("TmuvsCos") != std::string::npos){
plottype = 3; plotTitles = "";
nbinsx = 20; binlowx = 0.0; binhighx = 3.0;
nbinsy = 10; binlowy = -1.0; binhighy = 1.0;
}
// Setup the datahist as empty, we will use fake data to fill it.
- this->dataHist = new TH2D((measurementName + "_data").c_str(), (measurementName + "_data" + plotTitles).c_str(), nbinsx, binlowx, binhighx, nbinsy, binlowy, binhighy);
+ this->dataHist = new TH2D((fName + "_data").c_str(), (fName + "_data" + plotTitles).c_str(), nbinsx, binlowx, binhighx, nbinsy, binlowy, binhighy);
// Once dataHist is setup this function will automatically generate matching MC histograms
this->SetupDefaultHist();
double threshold = 10.0;
for (int i = 0; i < this->dataHist->GetNbinsX(); i++){
for (int j = 0; j < this->dataHist->GetNbinsY(); j++){
if (dataHist->GetBinContent(i+1,j+1) <= threshold){
dataHist->SetBinError(i+1,j+1, 0.0);
dataHist->SetBinContent(i+1,j+1, 0.0);
}
}
}
// Setup Covariance assuming a diagonal covar.
// If you want a full covariance to be used examples are given in the MINERvA 2D classes
//fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
// covar = StatUtils::GetInvert(fullcovar);
// 3. The generator is organised in SetupMeasurement so it gives the cross-section in "per nucleon" units.
// So some extra scaling for a specific measurement may be required. For Example to get a "per neutron" measurement on carbon
// which we do here, we have to multiple by the number of nucleons 12 and divide by the number of neutrons 6.
this->scaleFactor = (this->eventHist->Integral()*1E-38/(nevents+0.)) * (12.0 / 6.0) /this->TotalIntegratedFlux();
};
//********************************************************************
/// @details Extract Enu and totcrs from event assuming quasi-elastic scattering
void ExpMultDist_CCQE_XSec_2DVar_FakeStudy::FillEventVariables(FitEvent *event){
//********************************************************************
// MUST be defined for each new sample.
// This function reads in the FitEvent format and lets you grab any information you need
// from the event. This function is only called during the first and last iteration of each fit so that
// a vector of X_VAR variables can be filled for the signal events.
// Define empty variables
this->X_VAR = -1.0;
this->Y_VAR = -1.0;
double q2qe = 0.0;
double CosThetaMu = -2.0;
double TMu = 0.0;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
// Look for the outgoing muon
if ((event->PartInfo(j))->fPID != 13) continue;
// Define any variables we may need
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
Enu_rec = FitUtils::EnuQErec((event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
q2qe = FitUtils::Q2QErec( (event->PartInfo(j))->fP, cos(ThetaMu), 0.,true);
CosThetaMu = cos(ThetaMu);
TMu = FitUtils::T((event->PartInfo(j))->fP);
// Once lepton is found, don't continue the loop
break;
}
if (this->plottype == 1) {this->X_VAR = q2qe; this->Y_VAR = TMu;}
else if (this->plottype == 2) {this->X_VAR = q2qe; this->X_VAR = CosThetaMu;}
else if (this->plottype == 3) {this->X_VAR = TMu; this->Y_VAR = CosThetaMu;}
return;
};
//********************************************************************
/// @details Signal is true CCQE scattering
///
/// @details Cut 1: numu event
/// @details Cut 2: Mode == 1
/// @details Cut 3: EnuMin < Enu < EnuMax
bool ExpMultDist_CCQE_XSec_2DVar_FakeStudy::isSignal(FitEvent *event){
//********************************************************************
// Place cuts on each of the events here.
// MUST be defined for all new samples, there is no default signal definition.
// Check FitUtils and CutUtils for example cuts that can be used quickly.
// During a fit isSignal is only used in the first fit function call to define
// which of the events actually need to be considered, so don't worry too much if
// this function is inefficient.
// Mode and Enu are automatically avaialble in this function, they don't need to be set earlier.
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Only look at CCQE Events and MEC Events
if (Mode != 1 and Mode != 2) return false;
// Restrict energy range
if (Enu < this->EnuMin || Enu > this->EnuMax) return false;
return true;
};
diff --git a/src/MCStudies/GenericFlux_Tester.cxx b/src/MCStudies/GenericFlux_Tester.cxx
index a8e7c69..a0c5052 100644
--- a/src/MCStudies/GenericFlux_Tester.cxx
+++ b/src/MCStudies/GenericFlux_Tester.cxx
@@ -1,612 +1,612 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "GenericFlux_Tester.h"
//********************************************************************
/// @brief Class to perform MC Studies on a custom measurement
GenericFlux_Tester::GenericFlux_Tester(std::string name, std::string inputfile,
FitWeight *rw, std::string type,
std::string fakeDataFile) {
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
eventVariables = NULL;
// Define our energy range for flux calcs
EnuMin = 0.;
EnuMax = 100000.; // Arbritrarily high energy limit
// Set default fitter flags
isDiag = true;
isShape = false;
isRawEvents = false;
nu_4mom = 0;
pmu = 0;
ppip = 0;
ppim = 0;
ppi0 = 0;
pprot = 0;
pneut = 0;
// This function will sort out the input files automatically and parse all the
// inputs,flags,etc.
// There may be complex cases where you have to do this by hand, but usually
// this will do.
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
eventVariables = NULL;
// Setup dataHist as a placeholder
this->dataHist = new TH1D(("empty_data"), ("empty-data"), 1, 0, 1);
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// 1. The generator is organised in SetupMeasurement so it gives the
// cross-section in "per nucleon" units.
// So some extra scaling for a specific measurement may be required. For
// Example to get a "per neutron" measurement on carbon
// which we do here, we have to multiple by the number of nucleons 12 and
// divide by the number of neutrons 6.
this->scaleFactor = (this->eventHist->Integral("width") * 1E-38 / (nevents + 0.)) /
this->TotalIntegratedFlux();
LOG(SAM) << " Generic Flux Scaling Factor = "<< scaleFactor << endl;
// Setup our TTrees
this->AddEventVariablesToTree();
this->AddSignalFlagsToTree();
}
void GenericFlux_Tester::AddEventVariablesToTree() {
// Setup the TTree to save everything
if (!eventVariables) {
FitPar::Config().out->cd();
- eventVariables = new TTree((this->measurementName + "_VARS").c_str(),
- (this->measurementName + "_VARS").c_str());
+ eventVariables = new TTree((this->fName + "_VARS").c_str(),
+ (this->fName + "_VARS").c_str());
}
eventVariables->Branch("Mode", &Mode, "Mode/I");
eventVariables->Branch("PDGnu", &PDGnu, "PDGnu/I");
eventVariables->Branch("Enu_true", &Enu_true, "Enu_true/F");
eventVariables->Branch("Nleptons", &Nleptons, "Nleptons/I");
eventVariables->Branch("MLep", &MLep, "MLep/F");
eventVariables->Branch("ELep", &ELep, "ELep/F");
eventVariables->Branch("TLep", &TLep, "TLep/F");
eventVariables->Branch("CosLep", &CosLep, "CosLep/F");
eventVariables->Branch("CosPmuPpip", &CosPmuPpip, "CosPmuPpip/F");
eventVariables->Branch("CosPmuPpim", &CosPmuPpim, "CosPmuPpim/F");
eventVariables->Branch("CosPmuPpi0", &CosPmuPpi0, "CosPmuPpi0/F");
eventVariables->Branch("CosPmuPprot", &CosPmuPprot, "CosPmuPprot/F");
eventVariables->Branch("CosPmuPneut", &CosPmuPneut, "CosPmuPneut/F");
eventVariables->Branch("Nprotons", &Nprotons, "Nprotons/I");
eventVariables->Branch("MPr", &MPr, "MPr/F");
eventVariables->Branch("EPr", &EPr, "EPr/F");
eventVariables->Branch("TPr", &TPr, "TPr/F");
eventVariables->Branch("CosPr", &CosPr, "CosPr/F");
eventVariables->Branch("CosPprotPneut", &CosPprotPneut, "CosPprotPneut/F");
eventVariables->Branch("Nneutrons", &Nneutrons, "Nneutrons/I");
eventVariables->Branch("MNe", &MNe, "MNe/F");
eventVariables->Branch("ENe", &ENe, "ENe/F");
eventVariables->Branch("TNe", &TNe, "TNe/F");
eventVariables->Branch("CosNe", &CosNe, "CosNe/F");
eventVariables->Branch("Npiplus", &Npiplus, "Npiplus/I");
eventVariables->Branch("MPiP", &MPiP, "MPiP/F");
eventVariables->Branch("EPiP", &EPiP, "EPiP/F");
eventVariables->Branch("TPiP", &TPiP, "TPiP/F");
eventVariables->Branch("CosPiP", &CosPiP, "CosPiP/F");
eventVariables->Branch("CosPpipPprot", &CosPpipPprot, "CosPpipProt/F");
eventVariables->Branch("CosPpipPneut", &CosPpipPneut, "CosPpipPneut/F");
eventVariables->Branch("CosPpipPpim", &CosPpipPpim, "CosPpipPpim/F");
eventVariables->Branch("CosPpipPpi0", &CosPpipPpi0, "CosPpipPpi0/F");
eventVariables->Branch("Npineg", &Npineg, "Npineg/I");
eventVariables->Branch("MPiN", &MPiN, "MPiN/F");
eventVariables->Branch("EPiN", &EPiN, "EPiN/F");
eventVariables->Branch("TPiN", &TPiN, "TPiN/F");
eventVariables->Branch("CosPiN", &CosPiN, "CosPiN/F");
eventVariables->Branch("CosPpimPprot", &CosPpimPprot, "CosPpimPprot/F");
eventVariables->Branch("CosPpimPneut", &CosPpimPneut, "CosPpimPneut/F");
eventVariables->Branch("CosPpimPpi0", &CosPpimPpi0, "CosPpimPpi0/F");
eventVariables->Branch("Npi0", &Npi0, "Npi0/I");
eventVariables->Branch("MPi0", &MPi0, "MPi0/F");
eventVariables->Branch("EPi0", &EPi0, "EPi0/F");
eventVariables->Branch("TPi0", &TPi0, "TPi0/F");
eventVariables->Branch("CosPi0", &CosPi0, "CosPi0/F");
eventVariables->Branch("CosPi0Pprot", &CosPi0Pprot, "CosPi0Pprot/F");
eventVariables->Branch("CosPi0Pneut", &CosPi0Pneut, "CosPi0Pneut/F");
eventVariables->Branch("Q2_true", &Q2_true, "Q2_true/F");
eventVariables->Branch("q0_true", &q0_true, "q0_true/F");
eventVariables->Branch("q3_true", &q3_true, "q3_true/F");
eventVariables->Branch("Enu_QE", &Enu_QE, "Enu_QE/F");
eventVariables->Branch("Q2_QE", &Q2_QE, "Q2_QE/F");
eventVariables->Branch("W_nuc_rest", &W_nuc_rest, "W_nuc_rest/F");
eventVariables->Branch("bjorken_x", &bjorken_x, "bjorken_x/F");
eventVariables->Branch("bjorken_y", &bjorken_y, "bjorken_y/F");
eventVariables->Branch("Erecoil_true", &Erecoil_true, "Erecoil_true/F");
eventVariables->Branch("Erecoil_charged", &Erecoil_charged,
"Erecoil_charged/F");
eventVariables->Branch("Erecoil_minerva", &Erecoil_minerva,
"Erecoil_minerva/F");
eventVariables->Branch("nu_4mom", &nu_4mom);
eventVariables->Branch("pmu_4mom", &pmu);
eventVariables->Branch("hm_ppip_4mom", &ppip);
eventVariables->Branch("hm_ppim_4mom", &ppim);
eventVariables->Branch("hm_ppi0_4mom", &ppi0);
eventVariables->Branch("hm_pprot_4mom", &pprot);
eventVariables->Branch("hm_pneut_4mom", &pneut);
// Event Scaling Information
eventVariables->Branch("Weight", &Weight, "Weight/F");
eventVariables->Branch("InputWeight", &InputWeight, "InputWeight/F");
eventVariables->Branch("RWWeight", &RWWeight, "RWWeight/F");
eventVariables->Branch("FluxWeight", &FluxWeight, "FluxWeight/F");
eventVariables->Branch("scaleFactor", &xsecScaling, "scaleFactor/F");
return;
}
void GenericFlux_Tester::AddSignalFlagsToTree() {
if (!eventVariables) {
FitPar::Config().out->cd();
- eventVariables = new TTree((this->measurementName + "_VARS").c_str(),
- (this->measurementName + "_VARS").c_str());
+ eventVariables = new TTree((this->fName + "_VARS").c_str(),
+ (this->fName + "_VARS").c_str());
}
// Signal Definitions from SignalDef.cxx
eventVariables->Branch("flagCCQE_full", &flagCCQE_full, "flagCCQE_full/O");
eventVariables->Branch("flagCCQE_rest", &flagCCQE_rest, "flagCCQE_rest/O");
eventVariables->Branch("flagCCQEBar_full", &flagCCQEBar_full,
"flagCCQEBar_full/O");
eventVariables->Branch("flagCCQEBar_rest", &flagCCQEBar_rest,
"flagCCQEBar_rest/O");
eventVariables->Branch("flagCC1pip_MiniBooNE", &flagCC1pip_MiniBooNE,
"flagCC1pip_MiniBooNE/O");
eventVariables->Branch("flagCC1pip_MINERvA_full", &flagCC1pip_MINERvA_full,
"flagCC1pip_MINERvA_full/O");
eventVariables->Branch("flagCC1pip_MINERvA_rest", &flagCC1pip_MINERvA_rest,
"flagCC1pip_MINERvA_rest/O");
eventVariables->Branch("flagCCNpip_MINERvA_full", &flagCCNpip_MINERvA_full,
"flagCCNpip_MINERvA_full/O");
eventVariables->Branch("flagCCNpip_MINERvA_rest", &flagCCNpip_MINERvA_rest,
"flagCCNpip_MINERvA_rest/O");
eventVariables->Branch("flagCC1pip_T2K_Michel", &flagCC1pip_T2K_Michel,
"flagCC1pip_T2K_Michel/O");
eventVariables->Branch("flagCC1pip_T2K", &flagCC1pip_T2K, "flagCC1pip_T2K/O");
eventVariables->Branch("flagCC1pi0_MiniBooNE", &flagCC1pi0_MiniBooNE,
"flagCC1pi0_MiniBooNE/O");
eventVariables->Branch("flagCC1pi0Bar_MINERvA", &flagCC1pi0Bar_MINERvA,
"flagCC1pi0Bar_MINERvA/O");
eventVariables->Branch("flagNC1pi0_MiniBooNE", &flagNC1pi0_MiniBooNE,
"flagNC1pi0_MiniBooNE/O");
eventVariables->Branch("flagNC1pi0Bar_MiniBooNE", &flagNC1pi0Bar_MiniBooNE,
"flagNC1pi0Bar_MiniBooNE/O");
eventVariables->Branch("flagCCcoh_MINERvA", &flagCCcoh_MINERvA,
"flagCCcoh_MINERvA/O");
eventVariables->Branch("flagCCcohBar_MINERvA", &flagCCcohBar_MINERvA,
"flagCCcohBar_MINERvA/O");
eventVariables->Branch("flagCCQEnumu_MINERvA_full",
&flagCCQEnumu_MINERvA_full,
"flagCCQEnumu_MINERvA_full/O");
eventVariables->Branch("flagCCQEnumubar_MINERvA_full",
&flagCCQEnumubar_MINERvA_full,
"flagCCQEnumubar_MINERvA_full/O");
eventVariables->Branch("flagCCQEnumu_MINERvA_rest",
&flagCCQEnumu_MINERvA_rest,
"flagCCQEnumu_MINERvA_rest/O");
eventVariables->Branch("flagCCQEnumubar_MINERvA_rest",
&flagCCQEnumubar_MINERvA_rest,
"flagCCQEnumubar_MINERvA_rest/O");
eventVariables->Branch("flagCCincLowRecoil_MINERvA",
&flagCCincLowRecoil_MINERvA,
"flagCCincLowRecoil_MINERvA/O");
eventVariables->Branch("flagCCincLowRecoil_MINERvA_reqhad",
&flagCCincLowRecoil_MINERvA_reqhad,
"flagCCincLowRecoil_MINERvA_reqhad/O");
eventVariables->Branch("flagCCQELike_MiniBooNE", &flagCCQELike_MiniBooNE,
"flagCCQELike_MiniBooNE/O");
eventVariables->Branch("flagCCQE_MiniBooNE", &flagCCQE_MiniBooNE,
"flagCCQE_MiniBooNE/O");
eventVariables->Branch("flagCCQEBar_MiniBooNE", &flagCCQEBar_MiniBooNE,
"flagCCQEBar_MiniBooNE/O");
};
//********************************************************************
void GenericFlux_Tester::FillEventVariables(FitEvent *event) {
//********************************************************************
// Fill Signal Variables
FillSignalFlags(event);
// std::cout<<"Filling signal"<<std::endl;
// Function used to extract any variables of interest to the event
Mode = event->Mode;
Nleptons = 0;
Nparticles = 0;
PDGnu = 0;
PDGLep = 0;
Enu_true = Enu_QE = Q2_true = Q2_QE = TLep = TPr = TNe = TPiP = TPiN = TPi0 =
-999.9;
Nprotons = 0;
PPr = EPr = MPr = CosPr = -999.9;
Nneutrons = 0;
PNe = ENe = MNe = CosNe = -999.9;
Npiplus = 0;
PPiP = EPiP = MPiP = CosPiP = -999.9;
Npineg = 0;
PPiN = EPiN = MPiN = CosPiN = -999.9;
Npi0 = 0;
PPi0 = EPi0 = MPi0 = CosPi0 = -999.9;
// All of the angles Clarence added
CosPmuPpip = CosPmuPpim = CosPmuPpi0 = CosPmuPprot = CosPmuPneut =
CosPpipPprot = CosPpipPneut = CosPpipPpim = CosPpipPpi0 = CosPpimPprot =
CosPpimPneut = CosPpimPpi0 = CosPi0Pprot = CosPi0Pneut =
CosPprotPneut = -999.9;
float proton_highmom = -999.9;
float neutron_highmom = -999.9;
float piplus_highmom = -999.9;
float pineg_highmom = -999.9;
float pi0_highmom = -999.9;
(*nu_4mom) = event->PartInfo(0)->fP;
(*pmu) = TLorentzVector(0, 0, 0, 0);
(*ppip) = TLorentzVector(0, 0, 0, 0);
(*ppim) = TLorentzVector(0, 0, 0, 0);
(*ppi0) = TLorentzVector(0, 0, 0, 0);
(*pprot) = TLorentzVector(0, 0, 0, 0);
(*pneut) = TLorentzVector(0, 0, 0, 0);
Enu_true = nu_4mom->E();
PDGnu = event->PartInfo(0)->fPID;
bool cc = (abs(event->Mode) < 30);
(void)cc;
// Add all pion distributions for the event.
// Add classifier for CC0pi or CC1pi or CCOther
// Save Modes Properly
// Save low recoil measurements
// Start Particle Loop
UInt_t npart = event->Npart();
for (UInt_t i = 0; i < npart; i++) {
// Skip particles that weren't in the final state
bool part_alive = event->PartInfo(i)->fIsAlive;
if (!part_alive) continue;
// PDG Particle
int PDGpart = event->PartInfo(i)->fPID;
TLorentzVector part_4mom = event->PartInfo(i)->fP;
Nparticles++;
// Get Charged Lepton
if (abs(PDGpart) == abs(PDGnu) - 1) {
Nleptons++;
PDGLep = PDGpart;
TLep = FitUtils::T(part_4mom) * 1000.0;
PLep = (part_4mom.Vect().Mag());
ELep = (part_4mom.E());
MLep = (part_4mom.Mag());
CosLep = cos(part_4mom.Vect().Angle(nu_4mom->Vect()));
(*pmu) = part_4mom;
Q2_true = -1 * (part_4mom - (*nu_4mom)).Mag2();
float ThetaLep = (event->PartInfo(0))
->fP.Vect()
.Angle((event->PartInfo(i))->fP.Vect());
q0_true = (part_4mom - (*nu_4mom)).E();
q3_true = (part_4mom - (*nu_4mom)).Vect().Mag();
// Get W_true with assumption of initial state nucleon at rest
float m_n = 938.27208;
W_nuc_rest = sqrt(-Q2_true + 2 * m_n * (Enu_true - ELep) + m_n * m_n);
// Get the Bjorken x and y variables
// Assume that E_had = Enu - Emu as in MINERvA
bjorken_x = Q2_true / (2 * m_n * (Enu_true - ELep));
bjorken_y = 1 - ELep / Enu_true;
// Quasi-elastic ----------------------
// ------------------------------------
// Q2 QE Assuming Carbon Input. Should change this to be dynamic soon.
Q2_QE =
FitUtils::Q2QErec(part_4mom, cos(ThetaLep), 34., true) * 1000000.0;
Enu_QE = FitUtils::EnuQErec(part_4mom, cos(ThetaLep), 34., true) * 1000.0;
// Pion Production ----------------------
// --------------------------------------
} else if (PDGpart == 2212) {
Nprotons++;
if (part_4mom.Vect().Mag() > proton_highmom) {
proton_highmom = part_4mom.Vect().Mag();
PPr = (part_4mom.Vect().Mag());
EPr = (part_4mom.E());
TPr = FitUtils::T(part_4mom) * 1000.;
MPr = (part_4mom.Mag());
CosPr = cos(part_4mom.Vect().Angle(nu_4mom->Vect()));
(*pprot) = part_4mom;
}
} else if (PDGpart == 2112) {
Nneutrons++;
if (part_4mom.Vect().Mag() > neutron_highmom) {
neutron_highmom = part_4mom.Vect().Mag();
PNe = (part_4mom.Vect().Mag());
ENe = (part_4mom.E());
TNe = FitUtils::T(part_4mom) * 1000.;
MNe = (part_4mom.Mag());
CosNe = cos(part_4mom.Vect().Angle(nu_4mom->Vect()));
(*pneut) = part_4mom;
}
} else if (PDGpart == 211) {
Npiplus++;
if (part_4mom.Vect().Mag() > piplus_highmom) {
piplus_highmom = part_4mom.Vect().Mag();
PPiP = (part_4mom.Vect().Mag());
EPiP = (part_4mom.E());
TPiP = FitUtils::T(part_4mom) * 1000.;
MPiP = (part_4mom.Mag());
CosPiP = cos(part_4mom.Vect().Angle(nu_4mom->Vect()));
(*ppip) = part_4mom;
}
} else if (PDGpart == -211) {
Npineg++;
if (part_4mom.Vect().Mag() > pineg_highmom) {
pineg_highmom = part_4mom.Vect().Mag();
PPiN = (part_4mom.Vect().Mag());
EPiN = (part_4mom.E());
TPiN = FitUtils::T(part_4mom) * 1000.;
MPiN = (part_4mom.Mag());
CosPiN = cos(part_4mom.Vect().Angle(nu_4mom->Vect()));
(*ppim) = part_4mom;
}
} else if (PDGpart == 111) {
Npi0++;
if (part_4mom.Vect().Mag() > pi0_highmom) {
pi0_highmom = part_4mom.Vect().Mag();
PPi0 = (part_4mom.Vect().Mag());
EPi0 = (part_4mom.E());
TPi0 = FitUtils::T(part_4mom) * 1000.;
MPi0 = (part_4mom.Mag());
CosPi0 = cos(part_4mom.Vect().Angle(nu_4mom->Vect()));
(*ppi0) = part_4mom;
}
}
}
// Get Recoil Definitions ------
// -----------------------------
Erecoil_true = FitUtils::GetErecoil_TRUE(event);
Erecoil_charged = FitUtils::GetErecoil_CHARGED(event);
Erecoil_minerva = FitUtils::GetErecoil_MINERvA_LowRecoil(event);
// Do the angles between final state particles
if (Nleptons > 0 && Npiplus > 0)
CosPmuPpip = cos(pmu->Vect().Angle(ppip->Vect()));
if (Nleptons > 0 && Npineg > 0)
CosPmuPpim = cos(pmu->Vect().Angle(ppim->Vect()));
if (Nleptons > 0 && Npi0 > 0) CosPmuPpi0 = cos(pmu->Vect().Angle(ppi0->Vect()));
if (Nleptons > 0 && Nprotons > 0)
CosPmuPprot = cos(pmu->Vect().Angle(pprot->Vect()));
if (Nleptons > 0 && Nneutrons > 0)
CosPmuPneut = cos(pmu->Vect().Angle(pneut->Vect()));
if (Npiplus > 0 && Nprotons > 0)
CosPpipPprot = cos(ppip->Vect().Angle(pprot->Vect()));
if (Npiplus > 0 && Nneutrons > 0)
CosPpipPneut = cos(ppip->Vect().Angle(pneut->Vect()));
if (Npiplus > 0 && Npineg > 0)
CosPpipPpim = cos(ppip->Vect().Angle(ppim->Vect()));
if (Npiplus > 0 && Npi0 > 0)
CosPpipPpi0 = cos(ppip->Vect().Angle(ppi0->Vect()));
if (Npineg > 0 && Nprotons > 0)
CosPpimPprot = cos(ppim->Vect().Angle(pprot->Vect()));
if (Npineg > 0 && Nneutrons > 0)
CosPpimPneut = cos(ppim->Vect().Angle(pneut->Vect()));
if (Npineg > 0 && Npi0 > 0) CosPpimPpi0 = cos(ppim->Vect().Angle(ppi0->Vect()));
if (Npi0 > 0 && Nprotons > 0)
CosPi0Pprot = cos(ppi0->Vect().Angle(pprot->Vect()));
if (Npi0 > 0 && Nneutrons > 0)
CosPi0Pneut = cos(ppi0->Vect().Angle(pneut->Vect()));
if (Nprotons > 0 && Nneutrons > 0)
CosPprotPneut = cos(pprot->Vect().Angle(pneut->Vect()));
// Event Weights ----
// ------------------
Weight = event->RWWeight * event->InputWeight;
RWWeight = event->RWWeight;
InputWeight = event->InputWeight;
FluxWeight =
fluxHist->GetBinContent(fluxHist->FindBin(Enu)) / fluxHist->Integral();
xsecScaling = scaleFactor;
// Fill the eventVariables Tree
eventVariables->Fill();
return;
};
//********************************************************************
void GenericFlux_Tester::Write(std::string drawOpt) {
//********************************************************************
// First save the TTree
eventVariables->Write();
// Save Flux and Event Histograms too
GetInput()->GetFluxHistogram()->Write();
GetInput()->GetEventHistogram()->Write();
return;
}
//********************************************************************
void GenericFlux_Tester::FillSignalFlags(FitEvent *event) {
//********************************************************************
// Some example flags are given from SignalDef.
// See src/Utils/SignalDef.cxx for more.
flagCCQE_full = SignalDef::isCCQE(event, EnuMin, EnuMax, false);
flagCCQE_rest = SignalDef::isCCQE(event, EnuMin, EnuMax, true);
flagCCQEBar_full = SignalDef::isCCQEBar(event, EnuMin, EnuMax, false);
flagCCQEBar_rest = SignalDef::isCCQEBar(event, EnuMin, EnuMax, true);
flagCC1pip_MiniBooNE = SignalDef::isCC1pip_MiniBooNE(event, EnuMin, EnuMax);
flagCC1pip_MINERvA_full = SignalDef::isCC1pip_MINERvA(event, EnuMin, EnuMax);
flagCC1pip_MINERvA_rest =
SignalDef::isCC1pip_MINERvA(event, EnuMin, EnuMax, true);
int dummy;
flagCCNpip_MINERvA_full =
SignalDef::isCCNpip_MINERvA(event, dummy, EnuMin, EnuMax);
flagCCNpip_MINERvA_rest =
SignalDef::isCCNpip_MINERvA(event, dummy, EnuMin, EnuMax, true);
// Include Michel e sample so no phase space cuts on pion, only angle
flagCC1pip_T2K_Michel =
SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true);
flagCC1pip_T2K = SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, false);
flagCC1pi0_MiniBooNE = SignalDef::isCC1pi0_MiniBooNE(event, EnuMin, EnuMax);
flagCC1pi0Bar_MINERvA = SignalDef::isCC1pi0Bar_MINERvA(event, EnuMin, EnuMax);
flagNC1pi0_MiniBooNE = SignalDef::isNC1pi0_MiniBooNE(event, EnuMin, EnuMax);
flagNC1pi0Bar_MiniBooNE =
SignalDef::isNC1pi0Bar_MiniBooNE(event, EnuMin, EnuMax);
flagCCcoh_MINERvA = SignalDef::isCCcoh_MINERvA(event, EnuMin, EnuMax);
flagCCcohBar_MINERvA = SignalDef::isCCcohBar_MINERvA(event, EnuMin, EnuMax);
flagCCQEnumu_MINERvA_full =
SignalDef::isCCQEnumu_MINERvA(event, 1.5, 10.0, true);
flagCCQEnumubar_MINERvA_full =
SignalDef::isCCQEnumubar_MINERvA(event, 1.5, 10.0, true);
flagCCQEnumu_MINERvA_rest =
SignalDef::isCCQEnumu_MINERvA(event, 1.5, 10.0, false);
flagCCQEnumubar_MINERvA_rest =
SignalDef::isCCQEnumubar_MINERvA(event, 1.5, 10.0, false);
flagCCincLowRecoil_MINERvA =
SignalDef::isCCincLowRecoil_MINERvA(event, 2.0, 6.0, false);
flagCCincLowRecoil_MINERvA_reqhad =
SignalDef::isCCincLowRecoil_MINERvA(event, 2.0, 6.0, true);
flagCCQELike_MiniBooNE = SignalDef::isMiniBooNE_CCQELike(event, 0.0, 3.0);
flagCCQE_MiniBooNE = SignalDef::isMiniBooNE_CCQE(event, 0.0, 3.0);
flagCCQEBar_MiniBooNE = SignalDef::isMiniBooNE_CCQEBar(event, 0.0, 3.0);
}
// -------------------------------------------------------------------
// Purely MC Plot
// Following functions are just overrides to handle this
// -------------------------------------------------------------------
//********************************************************************
/// Everything is classed as signal...
bool GenericFlux_Tester::isSignal(FitEvent *event) {
//********************************************************************
(void)event;
return true;
};
//********************************************************************
void GenericFlux_Tester::ScaleEvents() {
//********************************************************************
// Saving everything to a TTree so no scaling required
return;
}
//********************************************************************
void GenericFlux_Tester::ApplyNormScale(float norm) {
//********************************************************************
// Saving everything to a TTree so no scaling required
this->currentNorm = norm;
return;
}
//********************************************************************
void GenericFlux_Tester::FillHistograms() {
//********************************************************************
// No Histograms need filling........
return;
}
//********************************************************************
void GenericFlux_Tester::ResetAll() {
//********************************************************************
eventVariables->Reset();
return;
}
//********************************************************************
float GenericFlux_Tester::GetChi2() {
//********************************************************************
// No Likelihood to test, purely MC
return 0.0;
}
diff --git a/src/MCStudies/parameter_pulls.cxx b/src/MCStudies/parameter_pulls.cxx
index f541c31..4848efe 100755
--- a/src/MCStudies/parameter_pulls.cxx
+++ b/src/MCStudies/parameter_pulls.cxx
@@ -1,222 +1,222 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "parameter_pulls.h"
// The constructor
parameter_pulls::parameter_pulls(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
this->inFile = inputfile;
- this->measurementName = name;
+ this->fName = name;
this->plotTitles = "; Dials; Reweight Values";
this->rw_engine = rw;
if (type.find("FRAC") != std::string::npos) dialoption = "FRAC";
else if (type.find("ABS") != std::string::npos) dialoption = "ABS";
this->SetDataValues(this->inFile); // Set the matrix and parameters from a text file.;
this->mcHist = (TH1D*) this->dataHist->Clone();
this->mcHist->Reset();
- this->mcHist->SetNameTitle((this->measurementName+"_FitVals").c_str(), (this->measurementName+this->plotTitles).c_str());
+ this->mcHist->SetNameTitle((this->fName+"_FitVals").c_str(), (this->fName+this->plotTitles).c_str());
};
void parameter_pulls::Reconfigure(double norm, bool fullconfig){
// Get Dial Names that are valid
std::vector<std::string> svec = this->rw_engine->GetDialNames();
// Set Bin Values
for (UInt_t i = 0; i < svec.size(); i++){
std::string systString = svec.at(i);
for (int j = 0; j < mcHist->GetNbinsX(); j++){
if (systString.compare( mcHist->GetXaxis()->GetBinLabel(j+1) ) == 0){
double curVal = this->rw_engine->GetDialValue(systString, dialoption);
this->mcHist->SetBinContent(j+1,curVal);
}
}
}
return;
};
void parameter_pulls::Renormalise(double norm){
return;
};
double parameter_pulls::GetChi2(){
int nbins = this->dataHist->GetNbinsX();
double chi2 = 0.0;
for (int i = 0; i < nbins; i++){
for (int j = 0; j < nbins; j++){
double idif = this->dataHist->GetBinContent(i+1) - this->mcHist->GetBinContent(i+1);
double jdif = this->dataHist->GetBinContent(j+1) - this->mcHist->GetBinContent(j+1);
chi2 += idif*jdif *(*this->covar)(i, j);
}
}
return chi2;
};
void parameter_pulls::ThrowCovariance(){
std::vector<double> randvals;
for (int i = 0; i < this->dataHist->GetNbinsX(); i++){
randvals.push_back(gRandom->Gaus(0.0,1.0));
}
for (int i = 0; i < this->dataHist->GetNbinsX(); i++){
double binmod = 0.0;
for (int j = 0; j < this->dataHist->GetNbinsX(); j++){
binmod += (*this->decomp)(j,i) * randvals.at(j);
}
this->dataHist->SetBinContent(i+1,this->dataTrue->GetBinContent(i+1) + binmod);
LOG(REC)<<"New value for "<<this->dataHist->GetXaxis()->GetBinLabel(i+1)<< " = "<<this->dataHist->GetBinContent(i+1)<<std::endl;
}
return;
};
//**********************************************
void parameter_pulls::SetDataValues(std::string dataFile){
//**********************************************
// --- Try and read ROOT file ------------------------
cout<<"Finding parameter pull from root file: "<<dataFile<<std::endl;
// Pares input file incase names provided
std::vector<std::string> inputs = PlotUtils::FillVectorSFromString(dataFile, ";");
// If no extra inputs provided use standard
if (inputs.size() == 1){
inputs.push_back("fit_dials");
inputs.push_back("covariance_free");
}
// Open Input
TFile* input = new TFile(inputs.at(0).c_str(),"READ");
if (!input){
std:: cerr<<" No input file found for parameter pulls! "<<std::endl;
exit(-1);
}
// Get covariance plot
TH2D* covarplot = (TH2D*) input->Get( inputs.at(2).c_str() );
TH1D* fitplot = (TH1D*) input->Get( inputs.at(1).c_str() );
if (!covarplot or !fitplot){
std::cerr<<"No covariance or dials plot!"<<std::endl;
exit(-1);
}
int dim = covarplot->GetNbinsX();
this->data_points = dim+1;
- this->dataHist = new TH1D((this->measurementName + "_CentralVals").c_str(),(this->measurementName + "_centralvals").c_str(),dim,0,dim);
+ this->dataHist = new TH1D((this->fName + "_CentralVals").c_str(),(this->fName + "_centralvals").c_str(),dim,0,dim);
for (int i = 0; i < dim; i++){
this->dataHist->GetXaxis()->SetBinLabel(i+1,covarplot->GetXaxis()->GetBinLabel(i+1));
this->dataHist->SetBinError(i+1,sqrt(covarplot->GetBinContent(i+1,i+1)));
}
// Fill Central Values
for (int i = 0; i < dim; i++){
for (int j = 0; j < fitplot->GetNbinsX(); j++){
std::string parname = std::string(fitplot->GetXaxis()->GetBinLabel(j+1));
if (!parname.compare(dataHist->GetXaxis()->GetBinLabel(i+1)))
dataHist->SetBinContent(i+1, fitplot->GetBinContent(j+1));
}
}
this->fullcovar = new TMatrixDSym(dim);
for (int i = 0; i < dim; i++){
for (int j = 0; j < dim; j++){
(*(this->fullcovar))(i,j) = covarplot->GetBinContent(i+1,j+1);
// std::cout<<i<<" "<<j<<" = "<<covarplot->GetBinContent(i+1,j+1)<<std::endl;
}
}
this->covar = StatUtils::GetInvert(fullcovar);
this->decomp = StatUtils::GetDecomp(fullcovar);
return;
};
void parameter_pulls::Write(std::string drawOpt){
TH2D* temp = new TH2D(*this->covar);
- temp->SetName((this->measurementName + "_INVCOVAR").c_str());
- temp->SetTitle((this->measurementName + "_INVCOVAR; Dials; Dials; Covariance").c_str());
+ temp->SetName((this->fName + "_INVCOVAR").c_str());
+ temp->SetTitle((this->fName + "_INVCOVAR; Dials; Dials; Covariance").c_str());
for(std::map<std::string,int>::iterator binIter = this->binMap.begin(); binIter != this->binMap.end(); binIter++){
this->mcHist->GetXaxis()->SetBinLabel(binIter->second, binIter->first.c_str());
this->dataHist->GetXaxis()->SetBinLabel(binIter->second, binIter->first.c_str());
temp->GetXaxis()->SetBinLabel(binIter->second, binIter->first.c_str());
temp->GetYaxis()->SetBinLabel(binIter->second, binIter->first.c_str());
}
this->mcHist->Write();
this->dataHist->Write();
temp->Write();
return;
};
TH2D parameter_pulls::GetFullCovarMatrix(){
TH2D tempCov = TH2D(*fullcovar);
for (int i = 0; i < tempCov.GetNbinsX(); i++){
tempCov.GetXaxis()->SetBinLabel(i+1,dataHist->GetXaxis()->GetBinLabel(i+1));
tempCov.GetYaxis()->SetBinLabel(i+1,dataHist->GetXaxis()->GetBinLabel(i+1));
}
return tempCov;
};
diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx
index 32b98b6..b529559 100644
--- a/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx
+++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx
@@ -1,93 +1,93 @@
#include "MINERvA_CC0pi_XSec_1DEe_nue.h"
//********************************************************************
MINERvA_CC0pi_XSec_1DEe_nue::MINERvA_CC0pi_XSec_1DEe_nue(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Define Measurement
- measurementName = "MINERvA_CC0pi_XSec_1DEe_nue";
+ fName = "MINERvA_CC0pi_XSec_1DEe_nue";
plotTitles = "; E_{e} (GeV); d#sigma/dE_{e} (cm^{2}/GeV)";
EnuMin = 0.0;
EnuMax = 10.0;
normError = 0.101;
default_types = "FIX/FULL";
allowed_types = "FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup Data File
std::string datafile = FitPar::GetDataBase()+"/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root";
std::string dist_name = "";
dist_name = "1DEe";
plotTitles = "; Q_{QE}^{2} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
SetDataFromFile(datafile, "Data_" + dist_name);
SetCovarFromDataFile(datafile, "Covar_" + dist_name);
// Setup Default MC Hists
SetupDefaultHist();
// Different generators require slightly different rescaling factors.
scaleFactor = (eventHist->Integral("width")*1E-38/(nevents+0.))/TotalIntegratedFlux();
};
//********************************************************************
void MINERvA_CC0pi_XSec_1DEe_nue::FillEventVariables(FitEvent *event){
//********************************************************************
Enu_rec = 0.0;
bad_particle = false;
// Get the relevant signal information
for (UInt_t j = 2; j < event->Npart(); ++j){
int PID = (event->PartInfo(j))->fPID;
if (!event->PartInfo(j)->fIsAlive) continue;
if (abs(PID) == 11){
Thetae = fabs((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect()));
Ee = (event->PartInfo(j))->fP.E()/1000.0;
Enu_rec = FitUtils::EnuQErec((event->PartInfo(j))->fP, cos(ThetaMu), 34.,true);
Q2QEe = FitUtils::Q2QErec((event->PartInfo(j))->fP, cos(Thetae), 34.,true);
} else if (PID != 2212 and
PID != 2112 and
PID != 22){
bad_particle = true;
}
}
LOG(EVT)<<"X_VAR = "<<Ee<<std::endl;
X_VAR = Ee;
return;
}
//********************************************************************
bool MINERvA_CC0pi_XSec_1DEe_nue::isSignal(FitEvent *event){
//*******************************************************************
// Only look at nue events
//if ( nue_flag and (event->PartInfo(0)->fPID) != 12) return false;
//if (!nue_flag and (event->PartInfo(0)->fPID) != -12) return false;
// Get Nue/NueBar events
if (fabs(event->PDGnu()) != 12) return false;
// ONLY CC0PI
if (bad_particle) return false;
// restrict energy range
if (event->Enu()/1000.0 < this->EnuMin || event->Enu()/1000.0 > this->EnuMax) return false;
// Electron Enrgy
if (Ee < 0.5) return false;
return true;
};
diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx
index bb28232..1646f02 100644
--- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx
+++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx
@@ -1,130 +1,130 @@
#include "MINERvA_CC0pi_XSec_1DQ2_nu_proton.h"
#include <string>
#include <sstream>
// The constructor
MINERvA_CC0pi_XSec_1DQ2_nu_proton::MINERvA_CC0pi_XSec_1DQ2_nu_proton(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
// Measurement Details
- measurementName = "MINERvA_CC0pi_XSec_1DQ2_nu_proton";
+ fName = "MINERvA_CC0pi_XSec_1DQ2_nu_proton";
plotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2})";
EnuMin = 0.;
EnuMax = 100.0;
normError = 0.100;
default_types = "FIX/FULL";
allowed_types = "FIX/FULL,DIAG";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(FitPar::GetDataBase()+"/MINERvA/CCQE/proton_Q2QE_nu_data.txt");
this->SetCovarMatrixFromText(FitPar::GetDataBase()+"/MINERvA/CCQE/proton_Q2QE_nu_covar.txt", 7);
this->SetupDefaultHist();
this->scaleFactor = (eventHist->Integral("width")*1E-38/(nevents+0.))/TotalIntegratedFlux();
};
void MINERvA_CC0pi_XSec_1DQ2_nu_proton::FillEventVariables(FitEvent *event){
double pE_highest;
double weight = event->weight;
// Reset Fill Variables
Enu = -999.9;
CosThetaMu = -999.0;
Emu = -999.0;
Tmu = -999.0;
Q2mu = -999.0;
q3 = -999.0;
Q2true = -999.0;
Tp = -999.0;
Ep = -999.0;
Q2p = -999.0;
Np = 0;
Nn = 0;
FSI = 0;
bad_particle = false;
pT = 0.0;
pE_highest = -999.9; // Very highland-esque way of doing things
double pE_muon = -999.0;
double pE_total = 0.0;
muon_found = false;
proton_found = false;
int protonid = 0;
int muonid = 0;
Enu = event->PartInfo(0)->fP.E()/1000.0;
this->Weight = weight;
Mode = event->Mode;
// Loop over the particle stack and find highest momentum FS proton
for (UInt_t j = 0; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive) continue;
if (event->PartInfo(j)->fPID == 2112){
Nn++;
}
if (event->PartInfo(j)->fPID == 2212){
Np++;
// if momentum is higher than saved
if (event->PartInfo(j)->fP.E() > pE_highest or pE_highest == -999.9) {
pE_highest = event->PartInfo(j)->fP.E();
Tp = event->PartInfo(j)->fP.E() - 938;
Ep = event->PartInfo(j)->fP.E();
protonid = j;
}
pE_total += event->PartInfo(j)->fP.E();
} else if (event->PartInfo(j)->fPID == 13){
pE_muon = FitUtils::Q2QErec((event->PartInfo(j))->fP,
cos(((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect()))), 34.);
CosThetaMu = cos(((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect())));
ThetaMu = ((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect()));
Emu = (event->PartInfo(j))->fP.E();
Tmu = (event->PartInfo(j))->fP.E() - 104;
Q2mu = pE_muon;
q3 = ((event->PartInfo(0))->fP.Vect() - (event->PartInfo(j))->fP.Vect()).Mag();
Q2true = (((event->PartInfo(0))->fP) - ((event->PartInfo(j))->fP)).Mag()/1000.0;
muonid = j;
} else if (event->PartInfo(j)->fPID != 13 and
event->PartInfo(j)->fPID != 22 and
event->PartInfo(j)->fPID != 2112 and
event->PartInfo(j)->fPID != 2212){
bad_particle = true;
}
}
pT = pE_highest - 0.93827203;
if (pE_highest > 0.110) proton_found = true;
if (ThetaMu < 1.22173) muon_found = false;
double q2qe = (FitUtils::ProtonQ2QErec(pE_highest,34.));
if (muon_found and proton_found )
Q2p = q2qe;
else
Q2p = -999.0;
Pmuon = pE_muon;
Coplanar = (event->PartInfo(protonid))->fP.Vect().Angle(((event->PartInfo(muonid))->fP.Vect()));
return;
};
bool MINERvA_CC0pi_XSec_1DQ2_nu_proton::isSignal(FitEvent *event){
// Look for the outgoing proton in the final state.
if (bad_particle) return false;
if (!proton_found or !muon_found) return false;
// Restrict energy range
if ((event->PartInfo(0))->fP.E() < this->EnuMin*1000 || (event->PartInfo(0))->fP.E() > this->EnuMax*1000) return false;
return true;
};
diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx
index 70d1f37..85eb672 100644
--- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx
+++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx
@@ -1,91 +1,91 @@
#include "MINERvA_CC0pi_XSec_1DQ2_nue.h"
//********************************************************************
MINERvA_CC0pi_XSec_1DQ2_nue::MINERvA_CC0pi_XSec_1DQ2_nue(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Define Measurement
- measurementName = "MINERvA_CC0pi_XSec_1DQ2_nue";
+ fName = "MINERvA_CC0pi_XSec_1DQ2_nue";
plotTitles = "; E_{e} (GeV); d#sigma/dE_{e} (cm^{2}/GeV)";
EnuMin = 0.0;
EnuMax = 10.0;
normError = 0.101;
default_types = "FIX/FULL";
allowed_types = "FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup Data File
std::string datafile = FitPar::GetDataBase()+"/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root";
std::string dist_name = "";
dist_name = "1DQ2";
plotTitles = "; Q_{QE}^{2} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
SetDataFromFile(datafile, "Data_" + dist_name);
SetCovarFromDataFile(datafile, "Covar_" + dist_name);
// Setup Default MC Hists
SetupDefaultHist();
// Different generators require slightly different rescaling factors.
scaleFactor = (this->eventHist->Integral("width")*1E-38/(nevents+0.))/this->TotalIntegratedFlux();
};
//********************************************************************
void MINERvA_CC0pi_XSec_1DQ2_nue::FillEventVariables(FitEvent *event){
//********************************************************************
Enu_rec = 0.0;
bad_particle = false;
// Get the relevant signal information
for (UInt_t j = 2; j < event->Npart(); ++j){
int PID = (event->PartInfo(j))->fPID;
if (!event->PartInfo(j)->fIsAlive) continue;
if (abs(PID) == 11){
Thetae = fabs((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect()));
Ee = (event->PartInfo(j))->fP.E()/1000.0;
Enu_rec = FitUtils::EnuQErec((event->PartInfo(j))->fP, cos(ThetaMu), 34.,true);
Q2QEe = FitUtils::Q2QErec((event->PartInfo(j))->fP, cos(Thetae), 34.,true);
} else if (PID != 2212 and
PID != 2112 and
PID != 22){
bad_particle = true;
}
}
this->X_VAR = Q2QEe;
LOG(EVT) << "X_VAR = "<<X_VAR<<std::endl;
return;
}
//********************************************************************
bool MINERvA_CC0pi_XSec_1DQ2_nue::isSignal(FitEvent *event){
//*******************************************************************
// Only look at numu events
//if ( nue_flag and (event->PartInfo(0)->fPID) != 12) return false;
//if (!nue_flag and (event->PartInfo(0)->fPID) != -12) return false;
// Get Nue/NueBar events
if (fabs(event->PDGnu()) != 12) return false;
// ONLY CC0PI
if (bad_particle) return false;
// restrict energy range
if (event->Enu()/1000.0 < this->EnuMin || event->Enu()/1000.0 > this->EnuMax) return false;
if (Ee < 0.5) return false;
return true;
};
diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx
index c4b7378..f1121c0 100644
--- a/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx
+++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx
@@ -1,91 +1,91 @@
#include "MINERvA_CC0pi_XSec_1DThetae_nue.h"
//********************************************************************
MINERvA_CC0pi_XSec_1DThetae_nue::MINERvA_CC0pi_XSec_1DThetae_nue(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Define Measurement
- measurementName = "MINERvA_CC0pi_XSec_1DThetae_nue";
+ fName = "MINERvA_CC0pi_XSec_1DThetae_nue";
plotTitles = "; E_{e} (GeV); d#sigma/dE_{e} (cm^{2}/GeV)";
EnuMin = 0.0;
EnuMax = 10.0;
normError = 0.101;
default_types = "FIX/FULL";
allowed_types = "FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup Data File
std::string datafile = FitPar::GetDataBase()+"/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root";
std::string dist_name = "";
dist_name = "1DThetae";
plotTitles = "; Q_{QE}^{2} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
SetDataFromFile(datafile, "Data_" + dist_name);
SetCovarFromDataFile(datafile, "Covar_" + dist_name);
// Setup Default MC Hists
SetupDefaultHist();
// Different generators require slightly different rescaling factors.
scaleFactor = (this->eventHist->Integral("width")*1E-38/(nevents+0.))/this->TotalIntegratedFlux();
};
//********************************************************************
void MINERvA_CC0pi_XSec_1DThetae_nue::FillEventVariables(FitEvent *event){
//********************************************************************
Enu_rec = 0.0;
bad_particle = false;
// Get the relevant signal information
for (UInt_t j = 2; j < event->Npart(); ++j){
int PID = (event->PartInfo(j))->fPID;
if (!event->PartInfo(j)->fIsAlive) continue;
if (abs(PID) == 11){
Thetae = fabs((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect()));
Ee = (event->PartInfo(j))->fP.E()/1000.0;
Enu_rec = FitUtils::EnuQErec((event->PartInfo(j))->fP, cos(ThetaMu), 34.,true);
Q2QEe = FitUtils::Q2QErec((event->PartInfo(j))->fP, cos(Thetae), 34.,true);
} else if (PID != 2212 and
PID != 2112 and
PID != 22){
bad_particle = true;
}
}
this->X_VAR = Thetae;
LOG(EVT) << "X_VAR = "<<X_VAR<<std::endl;
return;
}
//********************************************************************
bool MINERvA_CC0pi_XSec_1DThetae_nue::isSignal(FitEvent *event){
//*******************************************************************
// Only look at numu events
//if ( nue_flag and (event->PartInfo(0)->fPID) != 12) return false;
//if (!nue_flag and (event->PartInfo(0)->fPID) != -12) return false;
// Get Nue/NueBar events
if (fabs(event->PDGnu()) != 12) return false;
// ONLY CC0PI
if (bad_particle) return false;
// restrict energy range
if (event->Enu()/1000.0 < this->EnuMin || event->Enu()/1000.0 > this->EnuMax) return false;
if (Ee < 0.5) return false;
return true;
};
diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx
index e92a3d8..9bb1931 100644
--- a/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx
+++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx
@@ -1,69 +1,69 @@
#include "MINERvA_CC1pi0_XSec_1DEnu_antinu.h"
// The constructor
MINERvA_CC1pi0_XSec_1DEnu_antinu::MINERvA_CC1pi0_XSec_1DEnu_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "MINERvA_CC1pi0_XSec_1DEnu_nubar_2016";
+ fName = "MINERvA_CC1pi0_XSec_1DEnu_nubar_2016";
plotTitles = "; E_{#nu} (GeV); d#sigma(E_{#nu}) (cm^{2}/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_enu.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
//dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
//dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
// This is a correlation matrix, changed to covariance in SetCovarMatrixFromText
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_enu_corr.txt", dataHist->GetNbinsX());
this->SetupDefaultHist();
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents);
};
void MINERvA_CC1pi0_XSec_1DEnu_antinu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == -13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double Enu;
if (hadMass > 100 && hadMass < 1800) {
//Enu = FitUtils::EnuCC1pi0rec(Pnu, Pmu, Ppi0);
Enu = Pnu.E()/1000.;
} else {
Enu = -999;
}
this->X_VAR = Enu;
return;
};
//********************************************************************
bool MINERvA_CC1pi0_XSec_1DEnu_antinu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0Bar_MINERvA(event, EnuMin, EnuMax);
}
diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx
index d7774d7..cbf23e0 100644
--- a/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx
+++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx
@@ -1,68 +1,68 @@
#include "MINERvA_CC1pi0_XSec_1DQ2_antinu.h"
// The constructor
MINERvA_CC1pi0_XSec_1DQ2_antinu::MINERvA_CC1pi0_XSec_1DQ2_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CC1pi0_XSec_1DQ2_nubar_2016";
+ fName = "MINERvA_CC1pi0_XSec_1DQ2_nubar_2016";
plotTitles = "; Q^{2} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/(GeV^{2})/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_q2.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
// Scale data to proper cross-section
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_q2_corr.txt", dataHist->GetNbinsX());
this->SetupDefaultHist();
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CC1pi0_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppi0;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == -13) {
Pmu = event->PartInfo(j)->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double Q2;
if (hadMass > 100 && hadMass < 1800) {
Q2 = FitUtils::Q2CC1pi0rec(Pnu, Pmu, Ppi0);
} else {
Q2 = -999;
}
this->X_VAR = Q2;
return;
};
//********************************************************************
bool MINERvA_CC1pi0_XSec_1DQ2_antinu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0Bar_MINERvA(event, EnuMin, EnuMax);
}
diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx
index bebb3e7..f039d37 100644
--- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx
+++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx
@@ -1,68 +1,68 @@
#include "MINERvA_CC1pi0_XSec_1Dpmu_antinu.h"
// The constructor
MINERvA_CC1pi0_XSec_1Dpmu_antinu::MINERvA_CC1pi0_XSec_1Dpmu_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CC1pi0_XSec_1Dpmu_nubar_2016";
+ fName = "MINERvA_CC1pi0_XSec_1Dpmu_nubar_2016";
plotTitles = "; p_{#mu} (GeV); d#sigma/dp_{#mu} (cm^{2}/GeV/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_pmu.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
// Scale data to proper cross-section
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_pmu_corr.txt", dataHist->GetNbinsX());
this->SetupDefaultHist();
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CC1pi0_XSec_1Dpmu_antinu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppi0;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == -13) {
Pmu = event->PartInfo(j)->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double pmu;
if (hadMass > 100 && hadMass < 1800) {
pmu = FitUtils::p(Pmu);
} else {
pmu = -999;
}
this->X_VAR = pmu;
return;
};
//********************************************************************
bool MINERvA_CC1pi0_XSec_1Dpmu_antinu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0Bar_MINERvA(event, EnuMin, EnuMax);
}
diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx
index 6eb61ec..51c046f 100644
--- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx
+++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx
@@ -1,99 +1,99 @@
#include "MINERvA_CC1pi0_XSec_1Dppi0_antinu.h"
// The constructor
MINERvA_CC1pi0_XSec_1Dppi0_antinu::MINERvA_CC1pi0_XSec_1Dppi0_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
EnuMin = 1.5;
EnuMax = 10;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (type.find("NEW") != std::string::npos) {
// NEW measurement is actually Tpi, not ppi
- measurementName = "MINERvA_CC1pi0_XSec_1DTpi_nubar_2016";
+ fName = "MINERvA_CC1pi0_XSec_1DTpi_nubar_2016";
plotTitles = "; T_{#pi} (GeV); d#sigma/dT_{#pi} (cm^{2}/GeV/nucleon)";
isNew = true;
hadMassCut = 1800;
isDiag = false;
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_tpi.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_tpi_corr.txt", dataHist->GetNbinsX());
} else {
- measurementName = "MINERvA_CC1pi0_XSec_1Dppi0_nubar";
+ fName = "MINERvA_CC1pi0_XSec_1Dppi0_nubar";
plotTitles = "; p_{#pi^{0}} (GeV/c); d#sigma/dp_{#pi^{0}} (cm^{2}/(GeV/c)/nucleon)";
// Although the covariance is given for MINERvA CC1pi0 nubar from 2015, it doesn't Cholesky decompose, hinting at something bad
// I've tried adding small numbers to the diagonal but it still didn't work and the chi2s are crazy
isDiag = true;
normError = 0.15;
// No hadronic mass cut on old publication
hadMassCut = 99999;
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/ccpi0_ppi0.csv");
// Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data
// Please change when MINERvA releases new data!
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1.11);
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
}
this->SetupDefaultHist();
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CC1pi0_XSec_1Dppi0_antinu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppi0;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == -13) {
Pmu = event->PartInfo(j)->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double ppi0 = -999;
if (hadMass > 100 && hadMass < hadMassCut) {
// 2016 does pion kinetic energy in GeV
// 2015 does pion momentum in GeV
if (isNew) {
ppi0 = FitUtils::T(Ppi0);
} else {
ppi0 = FitUtils::p(Ppi0);
}
}
this->X_VAR = ppi0;
return;
};
//********************************************************************
bool MINERvA_CC1pi0_XSec_1Dppi0_antinu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0Bar_MINERvA(event, EnuMin, EnuMax);
}
diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx
index bd352a3..483ddd9 100644
--- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx
+++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx
@@ -1,95 +1,95 @@
#include "MINERvA_CC1pi0_XSec_1Dth_antinu.h"
// The constructor
MINERvA_CC1pi0_XSec_1Dth_antinu::MINERvA_CC1pi0_XSec_1Dth_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "MINERvA_CC1pi0_XSec_1Dth_nubar";
+ fName = "MINERvA_CC1pi0_XSec_1Dth_nubar";
plotTitles = "; #theta_{#pi} (degrees); d#sigma/d#theta_{#pi} (cm^{2}/degrees/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (type.find("NEW") != std::string::npos) {
- measurementName += "_2016";
+ fName += "_2016";
isNew = true;
hadMassCut = 1800;
isDiag = false;
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_thpi.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_thpi_corr.txt", dataHist->GetNbinsX());
} else {
// Although the covariance is given for MINERvA CC1pi0 nubar from 2015, it doesn't Cholesky decompose, hinting at something bad
// I've tried adding small numbers to the diagonal but it still didn't work and the chi2s are crazy
isDiag = true;
normError = 0.15;
// No hadronic mass cut on old publication
hadMassCut = 99999;
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/ccpi0_th.csv");
this->SetupDefaultHist();
// Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data
// Please change when MINERvA releases new data!
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1.11);
}
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
} // end special treatment depending on release year
this->SetupDefaultHist();
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CC1pi0_XSec_1Dth_antinu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppi0;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == -13) {
Pmu = event->PartInfo(j)->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double th;
if (hadMass > 100 && hadMass < hadMassCut) {
th = (180./M_PI)*FitUtils::th(Pnu, Ppi0);
} else {
th = -999;
}
this->X_VAR = th;
return;
};
//********************************************************************
bool MINERvA_CC1pi0_XSec_1Dth_antinu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0Bar_MINERvA(event, EnuMin, EnuMax);
}
diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx
index 8793cc5..437e03c 100644
--- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx
+++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx
@@ -1,68 +1,68 @@
#include "MINERvA_CC1pi0_XSec_1Dthmu_antinu.h"
// The constructor
MINERvA_CC1pi0_XSec_1Dthmu_antinu::MINERvA_CC1pi0_XSec_1Dthmu_antinu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CC1pi0_XSec_1Dthmu_nubar_2016";
+ fName = "MINERvA_CC1pi0_XSec_1Dthmu_nubar_2016";
plotTitles = "; #theta_{#mu}; d#sigma/d#theta_{#mu} (cm^{2}/degrees/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_thmu.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
// Scale data to proper cross-section
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pi0/2016_upd/cc1pi0_thmu_corr.txt", dataHist->GetNbinsX());
this->SetupDefaultHist();
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CC1pi0_XSec_1Dthmu_antinu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppi0;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == -13) {
Pmu = event->PartInfo(j)->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double thmu;
if (hadMass > 100 && hadMass < 1800) {
thmu = (180./M_PI)*FitUtils::th(Pnu, Pmu);
} else {
thmu = -999;
}
this->X_VAR = thmu;
return;
};
//********************************************************************
bool MINERvA_CC1pi0_XSec_1Dthmu_antinu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0Bar_MINERvA(event, EnuMin, EnuMax);
}
diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx
index a042993..203fab4 100644
--- a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx
+++ b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx
@@ -1,86 +1,86 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CC1pip_XSec_1DTpi_20deg_nu.h"
// The constructor
MINERvA_CC1pip_XSec_1DTpi_20deg_nu::MINERvA_CC1pip_XSec_1DTpi_20deg_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CC1pip_XSec_1DTpi_20deg_nu";
+ fName = "MINERvA_CC1pip_XSec_1DTpi_20deg_nu";
plotTitles = "; T_{#pi} (MeV); d#sigma/dT_{#pi} (cm^{2}/MeV/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (this->isShape) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_Tpi_20_shape.csv");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_Tpi_20_cov_shape.csv", dataHist->GetNbinsX());
} else {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_Tpi_20.csv");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_Tpi_20_cov.csv", dataHist->GetNbinsX());
}
this->SetupDefaultHist();
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1.11);
}
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CC1pip_XSec_1DTpi_20deg_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (abs(PID) == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double Tpi;
if (hadMass > 100 && hadMass < 1400) {
Tpi = FitUtils::T(Ppip)*1000.;
} else {
Tpi = -999;
}
this->X_VAR = Tpi;
return;
};
//********************************************************************
bool MINERvA_CC1pip_XSec_1DTpi_20deg_nu::isSignal(FitEvent *event) {
//********************************************************************
// Last true refers to that this is the restricted MINERvA phase space, in which only forward-going muons are accepted
return SignalDef::isCC1pip_MINERvA(event, EnuMin, EnuMax, true);
}
diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx
index 359d7d5..b8ad32c 100644
--- a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx
+++ b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx
@@ -1,84 +1,84 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CC1pip_XSec_1DTpi_nu.h"
// The constructor
MINERvA_CC1pip_XSec_1DTpi_nu::MINERvA_CC1pip_XSec_1DTpi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "MINERvA_CC1pip_XSec_1DTpi_nu";
+ fName = "MINERvA_CC1pip_XSec_1DTpi_nu";
plotTitles = "; T_{#pi} (MeV); d#sigma/dT_{#pi} (cm^{2}/MeV/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (isShape) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_Tpi_shape.csv");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_Tpi_cov_shape.csv", dataHist->GetNbinsX());
} else {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_Tpi.csv");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_Tpi_cov.csv", dataHist->GetNbinsX());
}
this->SetupDefaultHist();
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1.11);
}
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CC1pip_XSec_1DTpi_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (abs(PID) == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double Tpi;
if (hadMass > 100 && hadMass < 1400) {
Tpi = FitUtils::T(Ppip)*1000.;
} else {
Tpi = -999;
}
this->X_VAR = Tpi;
return;
};
//********************************************************************
bool MINERvA_CC1pip_XSec_1DTpi_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pip_MINERvA(event, EnuMin, EnuMax, false);
}
diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx
index 41aa115..8ca7064 100644
--- a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx
+++ b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx
@@ -1,96 +1,96 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CC1pip_XSec_1Dth_20deg_nu.h"
// The constructor
MINERvA_CC1pip_XSec_1Dth_20deg_nu::MINERvA_CC1pip_XSec_1Dth_20deg_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CC1pip_XSec_1Dth_20deg_nu";
+ fName = "MINERvA_CC1pip_XSec_1Dth_20deg_nu";
plotTitles = "; #theta_{#pi} (degrees); d#sigma/d#theta_{#pi} (cm^{2}/degrees/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (isShape) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_theta_20_shape.csv");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_theta_20_cov_shape.csv", dataHist->GetNbinsX());
} else {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_theta_20.csv");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_theta_20_cov.csv", dataHist->GetNbinsX());
}
this->SetupDefaultHist();
// Scaling for MINERvA corrected flux; roughly a normalisation change of 11%
// PLEASE CHANGE THIS WHEN NEW MINERvA MEASUREMENT IS RELEASED
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1.11);
}
- hadMassHist = new TH1D((measurementName+"_hadMass").c_str(), (measurementName+"_hadMass").c_str(), 100, 1000, 2000);
+ hadMassHist = new TH1D((fName+"_hadMass").c_str(), (fName+"_hadMass").c_str(), 100, 1000, 2000);
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CC1pip_XSec_1Dth_20deg_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (abs(PID) == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
hadMass = FitUtils::Wrec(Pnu, Pmu);
hadMassHist->Fill(hadMass);
double th;
// MINERvA CC1pi+ imposes a 0.1 < W < 1.4 GeV hadronic mass constraint
if (hadMass > 100 && hadMass < 1400) {
th = (180./M_PI)*FitUtils::th(Pnu, Ppip);
} else {
th = -999;
}
this->X_VAR = th;
return;
};
//********************************************************************
bool MINERvA_CC1pip_XSec_1Dth_20deg_nu::isSignal(FitEvent *event) {
//********************************************************************
// Last true refers to that this is the restricted MINERvA phase space, in which only forward-going muons are accepted
return SignalDef::isCC1pip_MINERvA(event, EnuMin, EnuMax, true);
}
void MINERvA_CC1pip_XSec_1Dth_20deg_nu::Write(std::string drawOpt) {
Measurement1D::Write(drawOpt);
hadMassHist->Write();
return;
}
diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx
index e66323e..2fc5a7b 100644
--- a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx
+++ b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx
@@ -1,87 +1,87 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CC1pip_XSec_1Dth_nu.h"
// The constructor
MINERvA_CC1pip_XSec_1Dth_nu::MINERvA_CC1pip_XSec_1Dth_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CC1pip_XSec_1Dth_nu";
+ fName = "MINERvA_CC1pip_XSec_1Dth_nu";
plotTitles = "; #theta_{#pi} (degrees); d#sigma/d#theta_{#pi} (cm^{2}/degrees/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (isShape) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_theta_shape.csv");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_theta_cov_shape.csv", dataHist->GetNbinsX());
} else {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_theta.csv");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CC1pip/ccpip_theta_cov.csv", dataHist->GetNbinsX());
}
this->SetupDefaultHist();
// Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data
// Please change when MINERvA releases new data!
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1.11);
}
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CC1pip_XSec_1Dth_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (abs(PID) == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double th;
if (hadMass > 100 && hadMass < 1400) {
th = (180./M_PI)*FitUtils::th(Pnu, Ppip);
} else {
th = -999;
}
this->X_VAR = th;
return;
};
//********************************************************************
bool MINERvA_CC1pip_XSec_1Dth_nu::isSignal(FitEvent *event) {
//********************************************************************
// Last false refers to that this is NOT the restricted MINERvA phase space, in which only forward-going muons are accepted
return SignalDef::isCC1pip_MINERvA(event, EnuMin, EnuMax, false);
}
diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx
index bec0ce5..9bcc464 100644
--- a/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx
+++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx
@@ -1,69 +1,69 @@
#include "MINERvA_CCNpip_XSec_1DEnu_nu.h"
// The constructor
MINERvA_CCNpip_XSec_1DEnu_nu::MINERvA_CCNpip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "MINERvA_CCNpip_XSec_1DEnu_nu_2016";
+ fName = "MINERvA_CCNpip_XSec_1DEnu_nu_2016";
plotTitles = "; E_{#nu} (GeV); d#sigma(E_{#nu}) (cm^{2}/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_enu.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
//double binOneWidth = dataHist->GetBinWidth(1);
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
//double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
//dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
//dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
// This is a correlation matrix, FIX IT
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_enu_corr.txt", dataHist->GetNbinsX());
this->SetupDefaultHist();
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents);
};
void MINERvA_CCNpip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211 && event->PartInfo(j)->fP.E() > Ppip.E()) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double Enu;
if (hadMass > 100 && hadMass < 1800) {
Enu = Pnu.E()/1000.;
} else {
Enu = -999;
}
this->X_VAR = Enu;
return;
};
//********************************************************************
bool MINERvA_CCNpip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
//********************************************************************
int dummy;
return SignalDef::isCCNpip_MINERvA(event, dummy, EnuMin, EnuMax, false);
}
diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx
index ee34e08..87bb281 100644
--- a/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx
+++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx
@@ -1,70 +1,70 @@
#include "MINERvA_CCNpip_XSec_1DQ2_nu.h"
// The constructor
MINERvA_CCNpip_XSec_1DQ2_nu::MINERvA_CCNpip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CCNpip_XSec_1DQ2_nu_2016";
+ fName = "MINERvA_CCNpip_XSec_1DQ2_nu_2016";
plotTitles = "; Q^{2} (GeV^{2}); d#sigma/dQ^{2} (cm^{2}/GeV^{2}/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_q2.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
// Scale data to proper cross-section
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
// This is a correlation matrix
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_q2_corr.txt", dataHist->GetNbinsX());
this->SetupDefaultHist();
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CCNpip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211 && event->PartInfo(j)->fP.E() > Ppip.E()) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double q2 = -999;
// Include up to some given hadronic mass cut
if (hadMass > 100 && hadMass < 1800) {
q2 = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
}
this->X_VAR = q2;
return;
};
//********************************************************************
bool MINERvA_CCNpip_XSec_1DQ2_nu::isSignal(FitEvent *event) {
//********************************************************************
// Last false refers to that this is NOT the restricted MINERvA phase space, in which only forward-going muons are accepted
int dummy;
return SignalDef::isCCNpip_MINERvA(event, dummy, EnuMin, EnuMax, false);
}
diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_20deg_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_20deg_nu.cxx
index b1b22cc..56565c8 100644
--- a/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_20deg_nu.cxx
+++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_20deg_nu.cxx
@@ -1,68 +1,68 @@
#include "MINERvA_CCNpip_XSec_1DTpi_20deg_nu.h"
// The constructor
MINERvA_CCNpip_XSec_1DTpi_20deg_nu::MINERvA_CCNpip_XSec_1DTpi_20deg_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CCNpip_XSec_1DTpi_20deg_nu";
+ fName = "MINERvA_CCNpip_XSec_1DTpi_20deg_nu";
plotTitles = "; T_{#pi} (MeV); d#sigma/dT_{#pi} (cm^{2}/MeV/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (isShape) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_Tpi_20deg_shape.txt");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_Tpi_20deg_shape_cov.txt", dataHist->GetNbinsX());
} else {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_Tpi_20deg.txt");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_Tpi_20deg_cov.txt", dataHist->GetNbinsX());
}
this->SetupDefaultHist();
// Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data
// Please change when MINERvA releases new data!
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1.11);
}
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CCNpip_XSec_1DTpi_20deg_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211 && event->PartInfo(j)->fP.E() > Ppip.E()) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double Tpi;
if (hadMass > 100 && hadMass < 1800) {
Tpi = FitUtils::T(Ppip)*1000.;
} else {
Tpi = -999;
}
this->X_VAR = Tpi;
return;
};
//********************************************************************
bool MINERvA_CCNpip_XSec_1DTpi_20deg_nu::isSignal(FitEvent *event) {
//********************************************************************
// Last false refers to that this is NOT the restricted MINERvA phase space, in which only forward-going muons are accepted
return SignalDef::isCCNpip_MINERvA(event, nPions, EnuMin, EnuMax, true);
}
diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx
index 306d0d8..309f133 100644
--- a/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx
+++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx
@@ -1,132 +1,132 @@
#include "MINERvA_CCNpip_XSec_1DTpi_nu.h"
// The constructor
MINERvA_CCNpip_XSec_1DTpi_nu::MINERvA_CCNpip_XSec_1DTpi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CCNpip_XSec_1DTpi_nu";
+ fName = "MINERvA_CCNpip_XSec_1DTpi_nu";
plotTitles = "; T_{#pi} (MeV); d#sigma/dT_{#pi} (cm^{2}/MeV/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Reserve length 3 for the number of pions
piIndex.reserve(3);
TpiVect.reserve(3);
if (type.find("NEW") != std::string::npos) {
- measurementName += "_2016";
+ fName += "_2016";
isNew = true;
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_tpi.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
// First scale to 1E-40
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
// Then set the error as absolute error, not the percent error (which the datafile is listed with)
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
// Scale the bin content
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
// This is a correlation matrix
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_tpi_corr.txt", dataHist->GetNbinsX());
} else {
isNew = false;
if (isShape) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_Tpi_shape.txt");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_Tpi_shape_cov.txt", dataHist->GetNbinsX());
} else {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_Tpi.txt");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_Tpi_cov.txt", dataHist->GetNbinsX());
}
// Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1.11);
}
}
this->SetupDefaultHist();
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CCNpip_XSec_1DTpi_nu::FillEventVariables(FitEvent *event) {
piIndex.clear();
TpiVect.clear();
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
// Only include alive particles
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
// Pick up the charged pions
if (abs(PID) == 211) {
piIndex.push_back(j);
// Find muon
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
// Hadronic mass cut in true
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double Tpi;
// If hadronic mass passes signal, loop over the pions
if (hadMass > 100 && hadMass < 1800) {
// Loop over surviving pions and pick up their kinetic energy
for (size_t k = 0; k < piIndex.size(); ++k) {
TLorentzVector Ppip = event->PartInfo(piIndex.at(k))->fP;
Tpi = FitUtils::T(Ppip)*1000.;
TpiVect.push_back(Tpi);
}
} else {
Tpi = -999;
}
this->X_VAR = Tpi;
return;
};
//********************************************************************
// Need to override FillHistograms() here because we fill the histogram N_pion times
void MINERvA_CCNpip_XSec_1DTpi_nu::FillHistograms() {
//********************************************************************
if (Signal){
// Need to loop over all the pions in the sample
for (size_t k = 0; k < TpiVect.size(); ++k) {
this->mcHist->Fill(TpiVect.at(k), Weight);
this->mcFine->Fill(TpiVect.at(k), Weight);
this->mcStat->Fill(TpiVect.at(k), 1.0);
PlotUtils::FillNeutModeArray(mcHist_PDG, Mode, TpiVect.at(k), Weight);
}
}
}
//********************************************************************
bool MINERvA_CCNpip_XSec_1DTpi_nu::isSignal(FitEvent *event) {
//********************************************************************
// Last false refers to that this is NOT the restricted MINERvA phase space, in which only forward-going muons are accepted
return SignalDef::isCCNpip_MINERvA(event, nPions, EnuMin, EnuMax, false);
}
diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx
index 655e546..4abcc98 100644
--- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx
+++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx
@@ -1,67 +1,67 @@
#include "MINERvA_CCNpip_XSec_1Dpmu_nu.h"
// The constructor
MINERvA_CCNpip_XSec_1Dpmu_nu::MINERvA_CCNpip_XSec_1Dpmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "MINERvA_CCNpip_XSec_1Dpmu_nu_2016";
+ fName = "MINERvA_CCNpip_XSec_1Dpmu_nu_2016";
plotTitles = "; p_{#mu} (GeV); d#sigma/dp_{#mu} (cm^{2}/GeV/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_pmu.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
// This is a correlation matrix, FIX IT
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_pmu_corr.txt", dataHist->GetNbinsX());
this->SetupDefaultHist();
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CCNpip_XSec_1Dpmu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211 && event->PartInfo(j)->fP.E() > Ppip.E()) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double pmu = -999;
if (hadMass > 100 && hadMass < 1800) {
pmu = FitUtils::p(Pmu);
}
this->X_VAR = pmu;
return;
};
//********************************************************************
bool MINERvA_CCNpip_XSec_1Dpmu_nu::isSignal(FitEvent *event) {
//********************************************************************
int dummy;
return SignalDef::isCCNpip_MINERvA(event, dummy, EnuMin, EnuMax, false);
}
diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_20deg_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_20deg_nu.cxx
index 7843ca2..80c6619 100644
--- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_20deg_nu.cxx
+++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_20deg_nu.cxx
@@ -1,70 +1,70 @@
#include "MINERvA_CCNpip_XSec_1Dth_20deg_nu.h"
// The constructor
MINERvA_CCNpip_XSec_1Dth_20deg_nu::MINERvA_CCNpip_XSec_1Dth_20deg_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CCNpip_XSec_1Dth_20deg_nu";
+ fName = "MINERvA_CCNpip_XSec_1Dth_20deg_nu";
plotTitles = "; #theta_{#pi} (degrees); d#sigma/d#theta_{#pi} (cm^{2}/degrees/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (isShape) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_th_20deg_shape.txt");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_th_20deg_shape_cov.txt", dataHist->GetNbinsX());
} else {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_th_20deg.txt");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_th_20deg_cov.txt", dataHist->GetNbinsX());
}
this->SetupDefaultHist();
// Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data
// Please change when MINERvA releases new data!
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1.11);
}
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CCNpip_XSec_1Dth_20deg_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
if (event->PartInfo(j)->fP.Vect().Mag() > Ppip.Vect().Mag()) {
Ppip = event->PartInfo(j)->fP;
}
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double th;
if (hadMass > 100 && hadMass < 1800) {
th = (180./M_PI)*FitUtils::th(Pnu, Ppip);
} else {
th = -999;
}
this->X_VAR = th;
return;
};
//********************************************************************
bool MINERvA_CCNpip_XSec_1Dth_20deg_nu::isSignal(FitEvent *event) {
//********************************************************************
// Last false refers to that this is NOT the restricted MINERvA phase space, in which only forward-going muons are accepted
return SignalDef::isCCNpip_MINERvA(event, nPions, EnuMin, EnuMax, true);
}
diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx
index b17d3f3..81d54a5 100644
--- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx
+++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx
@@ -1,143 +1,143 @@
#include "MINERvA_CCNpip_XSec_1Dth_nu.h"
// The constructor
MINERvA_CCNpip_XSec_1Dth_nu::MINERvA_CCNpip_XSec_1Dth_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CCNpip_XSec_1Dth_nu";
+ fName = "MINERvA_CCNpip_XSec_1Dth_nu";
plotTitles = "; #theta_{#pi} (degrees); d#sigma/d#theta_{#pi} (cm^{2}/degrees/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Reserve length 3 for the number of pions
piIndex.reserve(3);
thVect.reserve(3);
if (type.find("NEW") != std::string::npos) {
- measurementName += "_2016";
+ fName += "_2016";
isNew = true;
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_thpi.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
// This is a correlation matrix! but it's all fixed in SetCovarMatrixFromText
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_thpi_corr.txt", dataHist->GetNbinsX());
} else {
isNew = false;
if (isShape) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_th_shape.txt");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_th_shape_cov.txt", dataHist->GetNbinsX());
} else {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_th.txt");
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/MINERvA_CCNpi_th_cov.txt", dataHist->GetNbinsX());
}
// Adjust MINERvA data to flux correction; roughly a 11% normalisation increase in data
// Please change when MINERvA releases new data!
for (int i = 0; i < dataHist->GetNbinsX() + 1; i++) {
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1.11);
}
}
this->SetupDefaultHist();
- hnPions = new TH1I((measurementName+"_hNpions").c_str(), (measurementName+"_hNions; Number of pions; Counts").c_str(), 11, -1, 10);
+ hnPions = new TH1I((fName+"_hNpions").c_str(), (fName+"_hNions; Number of pions; Counts").c_str(), 11, -1, 10);
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CCNpip_XSec_1Dth_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppip;
piIndex.clear();
thVect.clear();
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
// Only include alive particles
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
// Select highest momentum (energy) charged pion
if (abs(PID) == 211) {
piIndex.push_back(j);
// Find muon
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double th;
// If hadronic mass passes signal, loop over the pions
if (hadMass > 100 && hadMass < 1800 && piIndex.size() > 0) {
// Loop over surviving pions and pick up their kinetic energy
for (unsigned int k = 0; k < piIndex.size(); ++k) {
Ppip = (event->PartInfo(piIndex.at(k)))->fP;
th = (180./M_PI)*FitUtils::th(Pnu, Ppip);
thVect.push_back(th);
}
} else {
th = -999;
}
this->X_VAR = th;
return;
};
//********************************************************************
bool MINERvA_CCNpip_XSec_1Dth_nu::isSignal(FitEvent *event) {
//********************************************************************
// Last false refers to that this is NOT the restricted MINERvA phase space, in which only forward-going muons are accepted
return SignalDef::isCCNpip_MINERvA(event, nPions, EnuMin, EnuMax, false);
}
//********************************************************************
// Need to override FillHistograms() here because we fill the histogram N_pion times
void MINERvA_CCNpip_XSec_1Dth_nu::FillHistograms() {
//********************************************************************
if (Signal){
// Need to loop over all the pions in the sample
for (size_t k = 0; k < thVect.size(); ++k) {
this->mcHist->Fill(thVect.at(k), Weight);
this->mcFine->Fill(thVect.at(k), Weight);
this->mcStat->Fill(thVect.at(k), 1.0);
PlotUtils::FillNeutModeArray(mcHist_PDG, Mode, thVect.at(k), Weight);
}
hnPions->Fill(nPions);
}
return;
}
//********************************************************************
void MINERvA_CCNpip_XSec_1Dth_nu::Write(std::string drawOpts) {
//********************************************************************
Measurement1D::Write(drawOpts);
hnPions->Write();
return;
}
diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx
index e54f7da..1475b85 100644
--- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx
+++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx
@@ -1,71 +1,71 @@
#include "MINERvA_CCNpip_XSec_1Dthmu_nu.h"
// The constructor
MINERvA_CCNpip_XSec_1Dthmu_nu::MINERvA_CCNpip_XSec_1Dthmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MINERvA_CCNpip_XSec_1Dthmu_nu_2016";
+ fName = "MINERvA_CCNpip_XSec_1Dthmu_nu_2016";
plotTitles = "; #theta_{#mu} (degrees); d#sigma/d#theta_{#mu} (cm^{2}/degrees/nucleon)";
EnuMin = 1.5;
EnuMax = 10;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_thmu.txt");
// MINERvA mucked up the scaling in the data-release where everything was bin-width normalised to the first bin, not the nth bin
double binOneWidth = dataHist->GetBinWidth(1);
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
double binNWidth = dataHist->GetBinWidth(i+1);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*1E-40);
dataHist->SetBinError(i+1, dataHist->GetBinContent(i+1)*dataHist->GetBinError(i+1)/100.);
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1)*binOneWidth/binNWidth);
dataHist->SetBinError(i+1, dataHist->GetBinError(i+1)*binOneWidth/binNWidth);
}
// This is a correlation matrix
this->SetCovarMatrixFromText(std::string(std::getenv("EXT_FIT"))+"/data/MINERvA/CCNpip/2016_upd/ccnpip_thmu_corr.txt", dataHist->GetNbinsX());
this->SetupDefaultHist();
scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
void MINERvA_CCNpip_XSec_1Dthmu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211 && event->PartInfo(j)->fP.E() > Ppip.E()) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double hadMass = FitUtils::Wrec(Pnu, Pmu);
double thmu;
// Include up to some given hadronic mass cut
if (hadMass > 100 && hadMass < 1800) {
thmu = (180./M_PI)*FitUtils::th(Pnu, Pmu);
} else {
thmu = -999;
}
this->X_VAR = thmu;
return;
};
//********************************************************************
bool MINERvA_CCNpip_XSec_1Dthmu_nu::isSignal(FitEvent *event) {
//********************************************************************
// Last false refers to that this is NOT the restricted MINERvA phase space, in which only forward-going muons are accepted
int dummy;
return SignalDef::isCCNpip_MINERvA(event, dummy, EnuMin, EnuMax, false);
}
diff --git a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx
index a1bf0c7..57966d1 100644
--- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx
+++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx
@@ -1,118 +1,118 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CCQE_XSec_1DQ2_antinu.h"
//********************************************************************
MINERvA_CCQE_XSec_1DQ2_antinu::MINERvA_CCQE_XSec_1DQ2_antinu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Setup Measurement Defaults
- measurementName = name;
+ fName = name;
plotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
isFluxFix = name.find("_newflux") != std::string::npos;
fullphasespace = name.find("_20deg") == std::string::npos;
EnuMin = 1.5;
EnuMax = 10.;
normError = 0.110;
allowed_types = "FIX,FREE,SHAPE/DIAG,FULL/NORM";
default_types = "FIX/FULL";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup the Data Plots
std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCQE/";
std::string datafilename = "";
std::string covarfilename = "";
// Full Phase Space
if (fullphasespace){
if (isFluxFix){
if (isShape) isShape = false;
datafilename = "Q2QE_numubar_data_fluxfix.txt";
covarfilename = "Q2QE_numubar_covar_fluxfix.txt";
} else {
if (isShape){
datafilename = "Q2QE_numubar_data_SHAPE-extracted.txt";
covarfilename = "Q2QE_numubar_covar_SHAPE-extracted.txt";
} else {
datafilename = "Q2QE_numubar_data.txt";
covarfilename = "Q2QE_numubar_covar.txt";
}
}
// Restricted Phase Space
} else {
if (isFluxFix){
if (isShape) isShape = false;
datafilename = "20deg_Q2QE_numubar_data_fluxfix.txt";
covarfilename = "20deg_Q2QE_numubar_covar_fluxfix.txt";
} else {
if (isShape){
datafilename = "20deg_Q2QE_numubar_data_SHAPE-extracted.txt";
covarfilename = "20deg_Q2QE_numubar_covar_SHAPE-extracted.txt";
} else {
datafilename = "20deg_Q2QE_numubar_data.txt";
covarfilename = "20deg_Q2QE_numubar_covar.txt";
}
}
}
this->SetDataValues( basedir + datafilename );
this->SetCovarMatrixFromText( basedir + covarfilename, 8 );
// Setup Default MC Histograms
this->SetupDefaultHist();
// Set Scale Factor (EventHist/nucleons) * NNucl / NNeutons
scaleFactor = (this->eventHist->Integral("width")*1E-38/(nevents+0.))*13./7./this->TotalIntegratedFlux();
};
//********************************************************************
void MINERvA_CCQE_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event){
//********************************************************************
double q2qe = -1.0;
double ThetaMu = 1.0;
// Get the relevant signal information
for (UInt_t j = 0; j < event->Npart(); ++j){
if ((event->PartInfo(j))->fPID != -13) continue;
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
q2qe = FitUtils::Q2QErec((event->PartInfo(j))->fP, cos(ThetaMu), 30., false);
break;
}
this->X_VAR = q2qe;
return;
}
//********************************************************************
bool MINERvA_CCQE_XSec_1DQ2_antinu::isSignal(FitEvent *event){
//*******************************************************************
return SignalDef::isCCQEnumubar_MINERvA(event, EnuMin, EnuMax, fullphasespace);
}
diff --git a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx
index 1ebe35e..7a8a604 100644
--- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx
+++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx
@@ -1,152 +1,152 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CCQE_XSec_1DQ2_joint.h"
//********************************************************************
MINERvA_CCQE_XSec_1DQ2_joint::MINERvA_CCQE_XSec_1DQ2_joint(std::string name, std::string inputfiles, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Setup The Measurement
- measurementName = name;
+ fName = name;
nBins = 16;
plotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
isFluxFix = name.find("_newflux") != std::string::npos;
fullphasespace = name.find("_20deg") == std::string::npos;
isRatio = false;
isSummed = false;
saveSubMeas = true;
SetupMeasurement(inputfiles, type, rw, fakeDataFile);
// Get parsed input files
if (subInFiles.size() != 2) ERR(FTL) << "MINERvA Joint requires input files in format: antinu;nu"<<std::endl;
std::string inFileAntineutrino = subInFiles.at(0);
std::string inFileNeutrino = subInFiles.at(1);
// Push classes back into list for processing loop
subChain.push_back(MIN_anu);
subChain.push_back(MIN_nu);
// Setup the Data input
std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCQE/";
std::string datafilename = "";
std::string covarfilename = "";
std::string neutrinoclass = "";
std::string antineutrinoclass = "";
// Full Phase Space
if (fullphasespace){
if (isFluxFix){
if (isShape) isShape = false;
datafilename = "Q2QE_joint_data_fluxfix.txt";
covarfilename = "Q2QE_joint_covar_fluxfix.txt";
neutrinoclass = "MINERvA_CCQE_XSec_1DQ2_nu_newflux";
antineutrinoclass = "MINERvA_CCQE_XSec_1DQ2_antinu_newflux";
} else {
if (isShape){
datafilename = "Q2QE_joint_dataa_SHAPE-extracted.txt";
covarfilename = "Q2QE_joint_covara_SHAPE-extracted.txt";
} else {
datafilename = "Q2QE_joint_data.txt";
covarfilename = "Q2QE_joint_covar.txt";
}
neutrinoclass = "MINERvA_CCQE_XSec_1DQ2_nu";
antineutrinoclass = "MINERvA_CCQE_XSec_1DQ2_antinu";
}
// Restricted Phase Space
} else {
if (isFluxFix){
if (isShape) isShape = false;
datafilename = "20deg_Q2QE_joint_data_fluxfix.txt";
covarfilename = "20deg_Q2QE_joint_covar_fluxfix.txt";
neutrinoclass = "MINERvA_CCQE_XSec_1DQ2_nu_20deg_newflux";
antineutrinoclass = "MINERvA_CCQE_XSec_1DQ2_antinu_20deg_newflux";
} else {
if (isShape){
datafilename = "20deg_Q2QE_joint_dataa_SHAPE-extracted.txt";
covarfilename = "20deg_Q2QE_joint_covara_SHAPE-extracted.txt";
} else {
datafilename = "20deg_Q2QE_joint_data.txt";
covarfilename = "20deg_Q2QE_joint_covar.txt";
}
neutrinoclass = "MINERvA_CCQE_XSec_1DQ2_nu_20deg";
antineutrinoclass = "MINERvA_CCQE_XSec_1DQ2_antinu_20deg";
}
}
// Setup Data
this->SetDataValues( basedir + datafilename );
this->SetCovarMatrixFromText( basedir + covarfilename, nBins);
// Setup Experiments
MIN_anu = new MINERvA_CCQE_XSec_1DQ2_antinu(antineutrinoclass, inFileAntineutrino, rw, type, fakeDataFile);
MIN_nu = new MINERvA_CCQE_XSec_1DQ2_nu (neutrinoclass, inFileNeutrino, rw, type, fakeDataFile);
// Add to chain for processing
this->subChain.clear();
this->subChain.push_back(MIN_anu);
this->subChain.push_back(MIN_nu);
this->fluxHist = GetCombinedFlux();
this->eventHist = GetCombinedEventRate();
// Setup Default MC Hists
SetupDefaultHist();
};
//********************************************************************
void MINERvA_CCQE_XSec_1DQ2_joint::MakePlots(){
//********************************************************************
UInt_t sample = 0;
for (std::vector<MeasurementBase*>::const_iterator expIter = subChain.begin(); expIter != subChain.end(); expIter++){
MeasurementBase* exp = static_cast<MeasurementBase*>(*expIter);
if (sample == 0){
MIN_anu = static_cast<MINERvA_CCQE_XSec_1DQ2_antinu*>(exp);
TH1D* MIN_anu_mc = (TH1D*) MIN_anu->GetMCList().at(0);
for (int i = 0; i < 8; i++){
mcHist->SetBinContent(i+1, MIN_anu_mc->GetBinContent(i+1));
mcHist->SetBinError(i+1, MIN_anu_mc->GetBinError(i+1));
}
} else if (sample == 1){
MIN_nu = static_cast<MINERvA_CCQE_XSec_1DQ2_nu*>(exp);
TH1D* MIN_nu_mc = (TH1D*) MIN_nu->GetMCList().at(0);
for (int i = 0; i < 8; i++){
mcHist->SetBinContent(i+1+8, MIN_nu_mc->GetBinContent(i+1));
}
} else break;
sample++;
}
return;
}
diff --git a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx
index 81a0183..fa40230 100644
--- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx
+++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx
@@ -1,121 +1,121 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CCQE_XSec_1DQ2_nu.h"
//********************************************************************
MINERvA_CCQE_XSec_1DQ2_nu::MINERvA_CCQE_XSec_1DQ2_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Measurement Defaults
- measurementName = name;
+ fName = name;
plotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
isFluxFix = name.find("_newflux") != std::string::npos;
fullphasespace = name.find("_20deg") == std::string::npos;
EnuMin = 1.5;
EnuMax = 10.;
normError = 0.101;
allowed_types = "FIX,FREE,SHAPE/DIAG,FULL/NORM";
default_types = "FIX/FULL";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup the Data Plots
std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCQE/";
std::string datafilename = "";
std::string covarfilename = "";
// Full Phase Space
if (fullphasespace){
if (isFluxFix){
if (isShape) isShape = false;
datafilename = "Q2QE_numu_data_fluxfix.txt";
covarfilename = "Q2QE_numu_covar_fluxfix.txt";
} else {
if (isShape){
datafilename = "Q2QE_numu_dataa_SHAPE-extracted.txt";
covarfilename = "Q2QE_numu_covara_SHAPE-extracted.txt";
} else {
datafilename = "Q2QE_numu_data.txt";
covarfilename = "Q2QE_numu_covar.txt";
}
}
// Restricted Phase Space
} else {
if (isFluxFix){
if (isShape) isShape = false;
datafilename = "20deg_Q2QE_numu_data_fluxfix.txt";
covarfilename = "20deg_Q2QE_numu_covar_fluxfix.txt";
} else {
if (isShape){
datafilename = "20deg_Q2QE_numu_dataa_SHAPE-extracted.txt";
covarfilename = "20deg_Q2QE_numu_covara_SHAPE-extracted.txt";
} else {
datafilename = "20deg_Q2QE_numu_data.txt";
covarfilename = "20deg_Q2QE_numu_covar.txt";
}
}
}
this->SetDataValues( basedir + datafilename );
this->SetCovarMatrixFromText( basedir + covarfilename, 8 );
// Setup Default MC Histograms
this->SetupDefaultHist();
// Set Scale Factor (EventHist/nucleons) * NNucl / NNeutons
scaleFactor = (this->eventHist->Integral("width")*1E-38*13.0/6.0/(nevents+0.))/this->TotalIntegratedFlux();
};
//********************************************************************
void MINERvA_CCQE_XSec_1DQ2_nu::FillEventVariables(FitEvent *event){
//********************************************************************
double q2qe = -1.0;
double ThetaMu = -1.0;
// Get the relevant signal information
for (UInt_t j = 0; j < event->Npart(); ++j){
if ((event->PartInfo(j))->fPID != 13) continue;
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
q2qe = FitUtils::Q2QErec((event->PartInfo(j))->fP, cos(ThetaMu), 34.,true);
break;
}
// Set binning variable
this->X_VAR = q2qe;
return;
}
//********************************************************************
bool MINERvA_CCQE_XSec_1DQ2_nu::isSignal(FitEvent *event){
//*******************************************************************
return SignalDef::isCCQEnumu_MINERvA(event, EnuMin, EnuMax, fullphasespace);
}
diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx
index 389ccda..a583334 100644
--- a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx
+++ b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx
@@ -1,116 +1,116 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CCinc_XSec_1DEnu_nu.h"
//********************************************************************
MINERvA_CCinc_XSec_1DEnu_nu::MINERvA_CCinc_XSec_1DEnu_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type,
std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
plotTitles = "; Neutrino energy (GeV); d#sigma/dE_{#nu} (cm^{2}/GeV/nucleon)";
EnuMin = 2.;
EnuMax = 20.;
target = "";
isRawEvents = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (name.find("C12") != std::string::npos) target = "C12";
else if (name.find("Fe56") != std::string::npos) target = "Fe56";
else if (name.find("Pb208") != std::string::npos) target = "Pb208";
if (name.find("DEN") != std::string::npos) target = "CH";
if (target == "") ERR(WRN) << "target " << target << " was not found!" << std::endl;
// Setup the Data Plots
std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCinc/";
std::string smearfilename = "CCinc_"+target+"_x_smear.csv";
int nbins = 8;
double bins[9] = {2, 3, 4, 5, 6, 8, 10, 15, 20};
// Make a dummy dataHist so it is used to construct other histograms...
this->dataHist = new TH1D(name.c_str(),(name+plotTitles).c_str(),nbins,bins);
// Setup Default MC Histograms
this->SetupDefaultHist();
// Set Scale Factor (EventHist/nucleons) so I don't need to know what the target is here
this->scaleFactor = (this->eventHist->Integral("width")*1E-38/(nevents+0.))/this->TotalIntegratedFlux(); // NEUT
};
//********************************************************************
void MINERvA_CCinc_XSec_1DEnu_nu::FillEventVariables(FitEvent *event){
//********************************************************************
Enu = (event->PartInfo(0))->fP.E()/1000.0;
// Get the relevant signal information
for (UInt_t j = 0; j < event->Npart(); ++j){
if ((event->PartInfo(j))->fPID != 13) continue;
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
break;
}
this->X_VAR = Enu;
return;
}
//********************************************************************
bool MINERvA_CCinc_XSec_1DEnu_nu::isSignal(FitEvent *event){
//*******************************************************************
// Throw away NC events
if (event->Mode > 30) return false;
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict the phase space to theta < 17 degrees
if (ThetaMu > 0.296706) return false;
// restrict energy range
if (Enu < this->EnuMin || Enu > this->EnuMax) return false;
return true;
};
//********************************************************************
void MINERvA_CCinc_XSec_1DEnu_nu::ScaleEvents(){
//********************************************************************
// Get rid of this because it causes odd behaviour
//Measurement1D::ScaleEvents();
this->mcHist->Scale(this->scaleFactor, "width");
// Proper error scaling - ROOT Freaks out with xsec weights sometimes
for(int i=0; i<this->mcStat->GetNbinsX();i++) {
if (this->mcStat->GetBinContent(i+1) != 0)
this->mcHist->SetBinError(i+1, this->mcHist->GetBinContent(i+1) * this->mcStat->GetBinError(i+1) / this->mcStat->GetBinContent(i+1) );
else this->mcHist->SetBinError(i+1, this->mcHist->Integral());
}
}
diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.cxx b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.cxx
index 002a4be..c891875 100644
--- a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.cxx
+++ b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.cxx
@@ -1,172 +1,172 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CCinc_XSec_1DEnu_ratio.h"
//********************************************************************
MINERvA_CCinc_XSec_1DEnu_ratio::MINERvA_CCinc_XSec_1DEnu_ratio(std::string name, std::string inputfiles, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Setup The Measurement
- measurementName = name;
+ fName = name;
nBins = 8;
plotTitles = "; Neutrino energy (GeV); d#sigma/dE_{#nu} (cm^{2}/GeV/nucleon)";
isRatio = true;
isDiag = false;
target = "";
SetupMeasurement(inputfiles, type, rw, fakeDataFile);
if (name.find("C12") != std::string::npos) target = "C12";
else if (name.find("Fe56") != std::string::npos) target = "Fe56";
else if (name.find("Pb208") != std::string::npos) target = "Pb208";
else ERR(WRN) << "target " << target << " was not found!" << std::endl;
// Get parsed input files
if (subInFiles.size() != 2) ERR(FTL) << "MINERvA CCinc ratio requires input files in format: NUMERATOR;DENOMINATOR"<<std::endl;
std::string inFileNUM = subInFiles.at(0);
std::string inFileDEN = subInFiles.at(1);
// Push classes back into list for processing loop
this->subChain.push_back(NUM);
this->subChain.push_back(DEN);
// Setup the Data input
std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCinc/";
std::string datafilename = "CCinc_"+target+"_CH_ratio_Enu_data.csv";
std::string covarfilename = "CCinc_"+target+"_CH_ratio_Enu_covar.csv";
this->SetDataValues( basedir + datafilename );
this->SetCovarMatrixFromText( basedir + covarfilename, nBins);
// Setup Experiments
NUM = new MINERvA_CCinc_XSec_1DEnu_nu("MINERvA_CCinc_XSec_1DEnu_"+target+"_CH_NUM", inFileNUM, rw, type, fakeDataFile);
DEN = new MINERvA_CCinc_XSec_1DEnu_nu("MINERvA_CCinc_XSec_1DEnu_"+target+"_CH_DEN", inFileDEN, rw, type, fakeDataFile);
// Add to chain for processing
this->subChain.clear();
this->subChain.push_back(NUM);
this->subChain.push_back(DEN);
// Setup Default MC Hists
this->SetupDefaultHist();
};
//********************************************************************
void MINERvA_CCinc_XSec_1DEnu_ratio::MakePlots(){
//********************************************************************
UInt_t sample = 0;
for (std::vector<MeasurementBase*>::const_iterator expIter = this->subChain.begin(); expIter != this->subChain.end(); expIter++){
MeasurementBase* exp = static_cast<MeasurementBase*>(*expIter);
if (sample == 0) this->NUM = static_cast<MINERvA_CCinc_XSec_1DEnu_nu*>(exp);
else if (sample == 1) this->DEN = static_cast<MINERvA_CCinc_XSec_1DEnu_nu*>(exp);
else break;
sample++;
}
// Now make the ratio histogram
TH1D* NUM_MC = (TH1D*)this->NUM->GetMCList().at(0)->Clone();
TH1D* DEN_MC = (TH1D*)this->DEN->GetMCList().at(0)->Clone();
for (int i=0; i < nBins; ++i){
double binVal = 0;
double binErr = 0;
if (DEN_MC->GetBinContent(i+1) && NUM_MC->GetBinContent(i+1)) {
binVal = NUM_MC->GetBinContent(i+1)/DEN_MC->GetBinContent(i+1);
double fractErrNUM = NUM_MC->GetBinError(i+1)/NUM_MC->GetBinContent(i+1);
double fractErrDEN = DEN_MC->GetBinError(i+1)/DEN_MC->GetBinContent(i+1);
binErr = binVal*sqrt(fractErrNUM*fractErrNUM + fractErrDEN*fractErrDEN);
}
this->mcHist->SetBinContent(i+1, binVal);
this->mcHist->SetBinError(i+1, binErr);
}
return;
}
//********************************************************************
void MINERvA_CCinc_XSec_1DEnu_ratio::SetCovarMatrixFromText(std::string covarFile, int dim){
//********************************************************************
// WARNING this reads in the data CORRELATIONS
// Make a counter to track the line number
int row = 0;
std::string line;
std::ifstream covar(covarFile.c_str(),ifstream::in);
this->covar = new TMatrixDSym(dim);
this->fullcovar = new TMatrixDSym(dim);
if(covar.is_open()) LOG(SAM) << "Reading covariance matrix from file: " << covarFile << std::endl;
else ERR(FTL) <<"Covariance matrix provided is incorrect: "<<covarFile<<std::endl;
while(std::getline(covar, line, '\n')){
std::istringstream stream(line);
double entry;
int column = 0;
// Loop over entries and insert them into matrix
// Multiply by the errors to get the covariance, rather than the correlation matrix
while(stream >> entry){
double val = entry * this->dataHist->GetBinError(row+1)*this->dataHist->GetBinError(column+1);
(*this->covar)(row, column) = val;
(*this->fullcovar)(row, column) = val;
column++;
}
row++;
}
// Robust matrix inversion method
TDecompSVD LU = TDecompSVD(*this->covar);
this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), "");
return;
};
//********************************************************************
void MINERvA_CCinc_XSec_1DEnu_ratio::Write(std::string drawOpt){
//********************************************************************
LOG(SAM)<<"Writing Normal Plots in MINERvA_CCinc_XSec_1DEnu_ratio::Write()" <<std::endl;
this->GetDataList().at(0)->Write();
this->GetMCList() .at(0)->Write();
if (this->fullcovar){
TH2D cov = TH2D((*this->fullcovar));
- cov.SetNameTitle((this->measurementName+"_cov").c_str(),(this->measurementName+"_cov;Bins; Bins;").c_str());
+ cov.SetNameTitle((this->fName+"_cov").c_str(),(this->fName+"_cov;Bins; Bins;").c_str());
cov.Write();
}
if (this->covar){
TH2D covinv = TH2D((*this->covar));
- covinv.SetNameTitle((this->measurementName+"_covinv").c_str(),(this->measurementName+"_covinv;Bins; Bins;").c_str());
+ covinv.SetNameTitle((this->fName+"_covinv").c_str(),(this->fName+"_covinv;Bins; Bins;").c_str());
covinv.Write();
}
return;
}
diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.cxx b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.cxx
index fdb71a1..c2c587e 100644
--- a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.cxx
+++ b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.cxx
@@ -1,129 +1,129 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CCinc_XSec_1Dx_nu.h"
//********************************************************************
MINERvA_CCinc_XSec_1Dx_nu::MINERvA_CCinc_XSec_1Dx_nu(std::string name, std::string inputfile, FitWeight *rw, std::string type,
std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
plotTitles = "; Reconstructed Bjorken x; d#sigma/dx (cm^{2}/nucleon)";
EnuMin = 2.;
EnuMax = 20.;
target = "";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (name.find("C12") != std::string::npos) target = "C12";
else if (name.find("Fe56") != std::string::npos) target = "Fe56";
else if (name.find("Pb208") != std::string::npos) target = "Pb208";
if (name.find("DEN") != std::string::npos) target = "CH";
if (target == "") ERR(WRN) << "target " << target << " was not found!" << std::endl;
// Setup the Data Plots
std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCinc/";
std::string smearfilename = "CCinc_"+target+"_x_smear.csv";
int nbins = 6;
double bins[7] = {0, 0.1, 0.3, 0.7, 0.9, 1.1, 1.5};
// Note that only the ratio is given, so I can't do this->SetDataValues or this->SetCovarMatrix
this->dataHist = new TH1D(name.c_str(),(name+plotTitles).c_str(),nbins,bins);
// Setup Default MC Histograms
this->SetupDefaultHist();
// The smearing matrix is rectangular
this->SetSmearingMatrix(basedir + smearfilename, nbins, nbins+1);
// Set Scale Factor (EventHist/nucleons) so I don't need to know what the target is here
this->scaleFactor = (this->eventHist->Integral("width")*1E-38/(nevents+0.))/this->TotalIntegratedFlux(); // NEUT
};
//********************************************************************
void MINERvA_CCinc_XSec_1Dx_nu::FillEventVariables(FitEvent *event){
//********************************************************************
Enu = (event->PartInfo(0))->fP.E()/1000.0;
// Get the relevant signal information
for (UInt_t j = 0; j < event->Npart(); ++j){
if ((event->PartInfo(j))->fPID != 13) continue;
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
TLorentzVector q = ((event->PartInfo(0))->fP - (event->PartInfo(j))->fP);
double q0 = q.E()/1000.0;
double Emu = ((event->PartInfo(j))->fP.E())/1000.0;
Enu_rec = Emu + q0;
double Q2 = 4*Enu_rec*Emu*sin(ThetaMu/2)*sin(ThetaMu/2);
bjork_x = Q2/2./q0/0.938918; // Average nucleon mass is 0.938918 GeV
break;
}
this->X_VAR = bjork_x;
return;
}
//********************************************************************
bool MINERvA_CCinc_XSec_1Dx_nu::isSignal(FitEvent *event){
//*******************************************************************
// Throw away NC events
if (event->Mode > 30) return false;
// Only look at numu events
if ((event->PartInfo(0))->fPID != 14) return false;
// Restrict the phase space to theta < 17 degrees
if (ThetaMu > 0.296706) return false;
// restrict energy range
if (Enu < this->EnuMin || Enu > this->EnuMax) return false;
if (Enu_rec < this->EnuMin || Enu_rec > this->EnuMax) return false;
return true;
};
//********************************************************************
void MINERvA_CCinc_XSec_1Dx_nu::ScaleEvents(){
//********************************************************************
this->dataHist = (TH1D*)this->GetMCList().at(0)->Clone();
- this->dataHist->SetNameTitle((this->measurementName+"_unsmear").c_str(), (this->measurementName+"_unsmear"+this->plotTitles).c_str());
+ this->dataHist->SetNameTitle((this->fName+"_unsmear").c_str(), (this->fName+"_unsmear"+this->plotTitles).c_str());
this->ApplySmearingMatrix();
// Get rid of this because it causes odd behaviour
//Measurement1D::ScaleEvents();
this->mcHist->Scale(this->scaleFactor, "width");
// Proper error scaling - ROOT Freaks out with xsec weights sometimes
for(int i=0; i<this->mcStat->GetNbinsX();i++) {
if (this->mcStat->GetBinContent(i+1) != 0)
this->mcHist->SetBinError(i+1, this->mcHist->GetBinContent(i+1) * this->mcStat->GetBinError(i+1) / this->mcStat->GetBinContent(i+1) );
else this->mcHist->SetBinError(i+1, this->mcHist->Integral());
}
}
diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.cxx b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.cxx
index b789999..dfde006 100644
--- a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.cxx
+++ b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.cxx
@@ -1,172 +1,172 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CCinc_XSec_1Dx_ratio.h"
//********************************************************************
MINERvA_CCinc_XSec_1Dx_ratio::MINERvA_CCinc_XSec_1Dx_ratio(std::string name, std::string inputfiles, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Setup The Measurement
- measurementName = name;
+ fName = name;
nBins = 6;
plotTitles = "; Reconstructed Bjorken x; d#sigma/dx (cm^{2}/nucleon)";
isRatio = true;
isDiag = false;
target = "";
SetupMeasurement(inputfiles, type, rw, fakeDataFile);
if (name.find("C12") != std::string::npos) target = "C12";
else if (name.find("Fe56") != std::string::npos) target = "Fe56";
else if (name.find("Pb208") != std::string::npos) target = "Pb208";
else ERR(WRN) << "target " << target << " was not found!" << std::endl;
// Get parsed input files
if (subInFiles.size() != 2) ERR(FTL) << "MINERvA CCinc ratio requires input files in format: NUMERATOR;DENOMINATOR"<<std::endl;
std::string inFileNUM = subInFiles.at(0);
std::string inFileDEN = subInFiles.at(1);
// Push classes back into list for processing loop
this->subChain.push_back(NUM);
this->subChain.push_back(DEN);
// Setup the Data input
std::string basedir = FitPar::GetDataBase()+"/MINERvA/CCinc/";
std::string datafilename = "CCinc_"+target+"_CH_ratio_x_data.csv";
std::string covarfilename = "CCinc_"+target+"_CH_ratio_x_covar.csv";
this->SetDataValues( basedir + datafilename );
this->SetCovarMatrixFromText( basedir + covarfilename, nBins);
// Setup Experiments
NUM = new MINERvA_CCinc_XSec_1Dx_nu("MINERvA_CCinc_XSec_1Dx_"+target+"_CH_NUM", inFileNUM, rw, type, fakeDataFile);
DEN = new MINERvA_CCinc_XSec_1Dx_nu("MINERvA_CCinc_XSec_1Dx_"+target+"_CH_DEN", inFileDEN, rw, type, fakeDataFile);
// Add to chain for processing
this->subChain.clear();
this->subChain.push_back(NUM);
this->subChain.push_back(DEN);
// Setup Default MC Hists
this->SetupDefaultHist();
};
//********************************************************************
void MINERvA_CCinc_XSec_1Dx_ratio::MakePlots(){
//********************************************************************
UInt_t sample = 0;
for (std::vector<MeasurementBase*>::const_iterator expIter = this->subChain.begin(); expIter != this->subChain.end(); expIter++){
MeasurementBase* exp = static_cast<MeasurementBase*>(*expIter);
if (sample == 0) this->NUM = static_cast<MINERvA_CCinc_XSec_1Dx_nu*>(exp);
else if (sample == 1) this->DEN = static_cast<MINERvA_CCinc_XSec_1Dx_nu*>(exp);
else break;
sample++;
}
// Now make the ratio histogram
TH1D* NUM_MC = (TH1D*)this->NUM->GetMCList().at(0)->Clone();
TH1D* DEN_MC = (TH1D*)this->DEN->GetMCList().at(0)->Clone();
for (int i=0; i < nBins; ++i){
double binVal = 0;
double binErr = 0;
if (DEN_MC->GetBinContent(i+1) && NUM_MC->GetBinContent(i+1)) {
binVal = NUM_MC->GetBinContent(i+1)/DEN_MC->GetBinContent(i+1);
double fractErrNUM = NUM_MC->GetBinError(i+1)/NUM_MC->GetBinContent(i+1);
double fractErrDEN = DEN_MC->GetBinError(i+1)/DEN_MC->GetBinContent(i+1);
binErr = binVal*sqrt(fractErrNUM*fractErrNUM + fractErrDEN*fractErrDEN);
}
this->mcHist->SetBinContent(i+1, binVal);
this->mcHist->SetBinError(i+1, binErr);
}
return;
}
//********************************************************************
void MINERvA_CCinc_XSec_1Dx_ratio::SetCovarMatrixFromText(std::string covarFile, int dim){
//********************************************************************
// WARNING this reads in the data CORRELATIONS
// Make a counter to track the line number
int row = 0;
std::string line;
std::ifstream covar(covarFile.c_str(),ifstream::in);
this->covar = new TMatrixDSym(dim);
this->fullcovar = new TMatrixDSym(dim);
if(covar.is_open()) LOG(SAM) << "Reading covariance matrix from file: " << covarFile << std::endl;
else ERR(FTL) <<"Covariance matrix provided is incorrect: "<<covarFile<<std::endl;
while(std::getline(covar, line, '\n')){
std::istringstream stream(line);
double entry;
int column = 0;
// Loop over entries and insert them into matrix
// Multiply by the errors to get the covariance, rather than the correlation matrix
while(stream >> entry){
double val = entry * this->dataHist->GetBinError(row+1)*this->dataHist->GetBinError(column+1);
(*this->covar)(row, column) = val;
(*this->fullcovar)(row, column) = val;
column++;
}
row++;
}
// Robust matrix inversion method
TDecompSVD LU = TDecompSVD(*this->covar);
this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), "");
return;
};
//********************************************************************
void MINERvA_CCinc_XSec_1Dx_ratio::Write(std::string drawOpt){
//********************************************************************
LOG(SAM)<<"Writing Normal Plots in MINERvA_CCinc_XSec_1Dx_ratio::Write()" <<std::endl;
this->GetDataList().at(0)->Write();
this->GetMCList() .at(0)->Write();
if (this->fullcovar){
TH2D cov = TH2D((*this->fullcovar));
- cov.SetNameTitle((this->measurementName+"_cov").c_str(),(this->measurementName+"_cov;Bins; Bins;").c_str());
+ cov.SetNameTitle((this->fName+"_cov").c_str(),(this->fName+"_cov;Bins; Bins;").c_str());
cov.Write();
}
if (this->covar){
TH2D covinv = TH2D((*this->covar));
- covinv.SetNameTitle((this->measurementName+"_covinv").c_str(),(this->measurementName+"_covinv;Bins; Bins;").c_str());
+ covinv.SetNameTitle((this->fName+"_covinv").c_str(),(this->fName+"_covinv;Bins; Bins;").c_str());
covinv.Write();
}
return;
}
diff --git a/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx b/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx
index d5e652e..e43bd2a 100755
--- a/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx
+++ b/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx
@@ -1,166 +1,166 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MINERvA_CCinc_XSec_2DEavq3_nu.h"
//********************************************************************
MINERvA_CCinc_XSec_2DEavq3_nu::MINERvA_CCinc_XSec_2DEavq3_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = "MINERvA_CCinc_XSec_2DEavq3_nu";
+ fName = "MINERvA_CCinc_XSec_2DEavq3_nu";
plotTitles = "; q_{3} (GeV); E_{avail} (GeV); d^{2}#sigma/dq_{3}dE_{avail} (cm^{2}/GeV^{2})";
EnuMin = 2.;
EnuMax = 6.;
hadroncut = FitPar::Config().GetParB("MINERvA_CCinc_XSec_2DEavq3_nu.hadron_cut");
useq3true = FitPar::Config().GetParB("MINERvA_CCinc_XSec_2DEavq3_nu.useq3true");
splitMEC_PN_NN = FitPar::Config().GetParB("Modes.split_PN_NN");
normError = 0.107;
default_types = "FIX/FULL";
allowed_types = "FIX,FREE,SHAPE/FULL,DIAG/MASK";
Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Binning for the 2D Histograms
this->data_points_x = 7;
this->data_points_y = 17;
Double_t tempx[7] = {0.0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8};
Double_t tempy[17] = {0.0, 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.14, 0.16, 0.20, 0.25, 0.30, 0.35, 0.40, 0.50, 0.60, 0.80};
this->xBins = tempx;
this->yBins = tempy;
// Fill data and 1Dto2D Maps for covariance
SetDataValuesFromText(FitPar::GetDataBase()+"/MINERvA/CCEavQ3/data_2D.txt", 1E-42);
SetMapValuesFromText(FitPar::GetDataBase()+"/MINERvA/CCEavQ3/map_2D.txt");
SetCovarMatrixFromChol(FitPar::GetDataBase()+"/MINERvA/CCEavQ3/covar_2D.txt", 67);
// Data is in 1E-42 and so is the covariance, need to scale accordingly.
(*this->fullcovar) *= 1E-16;
(*this->covar) *= 1E16;
// Set data errors from covariance matrix
StatUtils::SetDataErrorFromCov(dataHist, fullcovar, mapHist, 1E-38);
// Setup mc Histograms
SetupDefaultHist();
// Set Scale Factor
scaleFactor = (this->eventHist->Integral("width")*1E-42/(nevents+0.))/this->TotalIntegratedFlux();
};
//********************************************************************
void MINERvA_CCinc_XSec_2DEavq3_nu::FillEventVariables(FitEvent *event){
//********************************************************************
// Set starting variables
double Eav = 0.0; // Energy Avaiable
double q3 = 0.0; // Three momentum transfer
double q0 = 0.0; // True Energy Transfer
// Individual particle variables
int PID = 0;
double Q2 = 0.0;
TLorentzVector q = TLorentzVector(); // reset vector
double Mmu = 0.0;
double Emu = 0.0;
double pmu = 0.0;
double ThetaMu = 0.0;
// Seperate MEC
if (splitMEC_PN_NN){
int npr = 0;
int nne = 0;
for (UInt_t j = 0; j < event->Npart(); j++){
if ((event->PartInfo(j))->fIsAlive) continue;
if (event->PartInfo(j)->fPID == 2212) npr++;
else if (event->PartInfo(j)->fPID == 2112) nne++;
}
if (event->Mode == 2 and npr == 1 and nne == 1){
event->Mode = 2;
Mode = 2;
} else if (event->Mode == 2 and npr == 0 and nne == 2){
event->Mode = 3;
Mode = 3;
}
}
// Muon Variables -----------------
// Muon should be in slot 2 or 3.
for (UInt_t j = 2; j < event->Npart(); j++){
// Skip dead particles
PID = event->PartInfo(j)->fPID;
// MUON
if (PID == 13){
// Set q from muon
q = ((event->PartInfo(0))->fP - (event->PartInfo(j))->fP);
q0 = q.E()/1000.0;
// Other muon variables
ThetaMu = (event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect());
pmu = ((event->PartInfo(j))->fP.Vect().Mag())/1000.0;
Emu = ((event->PartInfo(j))->fP.E())/1000.0;
Mmu = ((event->PartInfo(j))->fP.Mag())/1000.0;
Enu_rec = Emu + q0;
// Set Q2 from reconstruction method
Q2 = 2*Enu_rec * (Emu - pmu * cos(ThetaMu)) - Mmu*Mmu;
// merge together for q3
q3 = q.Vect().Mag()/1000.0;
if (!useq3true) q3 = sqrt( Q2 + q0*q0 );
continue;
}
if (!(event->PartInfo(j))->fIsAlive) continue;
if (event->PartInfo(j)->fStatus != 0) continue;
// Eav Varible -----------------
// P and pi+- Kinetic Energy
if (PID == 2212 or PID == 211 or PID == -211){
Eav += FitUtils::T(event->PartInfo(j)->fP);
// Total Energy of non-neutrons
} else if (PID != 2112 and PID < 999 and PID != 22 and abs(PID) != 14){
Eav += (event->PartInfo(j)->fP.E())/1000.0;
}
}
// Set Hist Variables
this->X_VAR = q3;
this->Y_VAR = Eav;
return;
}
//********************************************************************
bool MINERvA_CCinc_XSec_2DEavq3_nu::isSignal(FitEvent *event){
//********************************************************************
return SignalDef::isCCincLowRecoil_MINERvA(event, EnuMin, EnuMax, hadroncut);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx
index 0d72cf3..c2773e9 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx
@@ -1,72 +1,72 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pi0_XSec_1DEnu_nu.h"
// The constructor
MiniBooNE_CC1pi0_XSec_1DEnu_nu::MiniBooNE_CC1pi0_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pi0_XSec_1DEnu_nu";
+ fName = "MiniBooNE_CC1pi0_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (GeV); #sigma(E_{#nu}) (cm^{2}/CH_{2})";
EnuMin = 0.5;
EnuMax = 2.;
isDiag = true;
isEnu1D = true;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pi0/totalxsec_edit.txt");
//this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/totalxsec_covar.txt", this->data_points-1);
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
//StatUtils::ForceNormIntoCovar(this->covar, this->dataHist, this->normError);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08);
};
void MiniBooNE_CC1pi0_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) {
// Set up the 4-vectors
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppi0;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double Enu = FitUtils::EnuCC1pi0rec(Pnu, Pmu, Ppi0);
this->X_VAR = Enu;
return;
};
bool MiniBooNE_CC1pi0_XSec_1DEnu_nu::isSignal(FitEvent *event) {
return SignalDef::isCC1pi0_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx
index a24319d..7fab6bf 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx
@@ -1,72 +1,72 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pi0_XSec_1DQ2_nu.h"
// The constructor
MiniBooNE_CC1pi0_XSec_1DQ2_nu::MiniBooNE_CC1pi0_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pi0_XSec_1DQ2_nu";
+ fName = "MiniBooNE_CC1pi0_XSec_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ_{CC#pi}^{2} (cm^{2}/GeV^{2})";
EnuMin = 0.5;
EnuMax = 2.;
isDiag = true;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pi0/dxsecdq2_edit.txt");
//this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/dxsecdq2_covar.txt", this->data_points-1);
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08)/TotalIntegratedFlux("width");
};
void MiniBooNE_CC1pi0_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
double q2CCpi0 = FitUtils::Q2CC1pi0rec(Pnu, Pmu, Ppi0);
this->X_VAR = q2CCpi0;
return;
};
//********************************************************************
bool MiniBooNE_CC1pi0_XSec_1DQ2_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx
index c28730b..8b57edd 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx
@@ -1,72 +1,72 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pi0_XSec_1DTu_nu.h"
// The constructor
MiniBooNE_CC1pi0_XSec_1DTu_nu::MiniBooNE_CC1pi0_XSec_1DTu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pi0_XSec_1DTu_nu";
+ fName = "MiniBooNE_CC1pi0_XSec_1DTu_nu";
plotTitles = "; T_{#mu} (GeV); d#sigma/dE_{#mu} (cm^{2}/GeV^{2}/CH_{2})";
EnuMin = 0.5;
EnuMax = 2.;
isDiag = true;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pi0/dxsecdemu_edit.txt");
//this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/dxsecdemu_covar.txt", this->data_points-1);
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08)/TotalIntegratedFlux("width");
};
void MiniBooNE_CC1pi0_XSec_1DTu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
double TuCCpi0 = FitUtils::T(Pmu);
this->X_VAR = TuCCpi0;
return;
};
//********************************************************************
bool MiniBooNE_CC1pi0_XSec_1DTu_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx
index 155f34d..2e36555 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx
@@ -1,73 +1,73 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.h"
// The constructor
MiniBooNE_CC1pi0_XSec_1Dcosmu_nu::MiniBooNE_CC1pi0_XSec_1Dcosmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pi0_XSec_1Dcosmu_nu";
+ fName = "MiniBooNE_CC1pi0_XSec_1Dcosmu_nu";
plotTitles = "; cos#theta_{#mu}; d#sigma/dcos#theta_{#mu} (cm^{2}/CH_{2})";
EnuMin = 0.5;
EnuMax = 2.;
isDiag = true;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pi0/dxsecdcosmu_edit.txt");
//this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/dxsecdcosmu_covar.txt", this->data_points - 1);
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08)/TotalIntegratedFlux("width");
};
void MiniBooNE_CC1pi0_XSec_1Dcosmu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
// No W cut on MiniBooNE CC1pi+
double CosMu = cos(FitUtils::th(Pnu, Pmu));
this->X_VAR = CosMu;
return;
};
//********************************************************************
bool MiniBooNE_CC1pi0_XSec_1Dcosmu_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx
index f972894..b1d2706 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx
@@ -1,72 +1,72 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.h"
// The constructor
MiniBooNE_CC1pi0_XSec_1Dcospi0_nu::MiniBooNE_CC1pi0_XSec_1Dcospi0_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pi0_XSec_1Dcospi0_nu";
+ fName = "MiniBooNE_CC1pi0_XSec_1Dcospi0_nu";
plotTitles = "; cos#theta_{#pi^{0}}; d#sigma/dcos#theta_{#pi^{0}} (cm^{2}/CH_{2})";
EnuMin = 0.5;
EnuMax = 2.;
isDiag = true;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pi0/dxsecdcospi_edit.txt");
//this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/dxsecdcospi_covar.txt", this->data_points -1 );
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08)/TotalIntegratedFlux("width");
};
void MiniBooNE_CC1pi0_XSec_1Dcospi0_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
double CosPi0 = cos(FitUtils::th(Pnu, Ppi0));
this->X_VAR = CosPi0;
return;
};
//********************************************************************
bool MiniBooNE_CC1pi0_XSec_1Dcospi0_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx
index 2b336ee..a951b49 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx
@@ -1,72 +1,72 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h"
// The constructor
MiniBooNE_CC1pi0_XSec_1Dppi0_nu::MiniBooNE_CC1pi0_XSec_1Dppi0_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pi0_XSec_1Dppi0_nu";
+ fName = "MiniBooNE_CC1pi0_XSec_1Dppi0_nu";
plotTitles = "; p_{#pi^{0}} (GeV/c); d#sigma/dp_{#pi^{0}} (cm^{2}/GeV/CH_{2})";
EnuMin = 0.5;
EnuMax = 2.;
isDiag = true;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pi0/dxsecdppi_edit.txt");
//this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/cc1pi0/dxsecdppi_covar.txt", this->data_points-1);
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08)/TotalIntegratedFlux("width");
};
void MiniBooNE_CC1pi0_XSec_1Dppi0_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppi0;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
double p_pi0 = FitUtils::p(Ppi0);
this->X_VAR = p_pi0;
return;
};
//********************************************************************
bool MiniBooNE_CC1pi0_XSec_1Dppi0_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pi0_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx
index e5f2f14..4899ec1 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx
@@ -1,80 +1,80 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pip_XSec_1DEnu_nu.h"
// The constructor
//********************************************************************
MiniBooNE_CC1pip_XSec_1DEnu_nu::MiniBooNE_CC1pip_XSec_1DEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile) {
- measurementName = "MiniBooNE_CC1pip_XSec_1DEnu_nu";
+ fName = "MiniBooNE_CC1pip_XSec_1DEnu_nu";
plotTitles = "; E_{#nu} (MeV); #sigma(E_{#nu}) (cm^{2}/CH_{2})";
EnuMin = 0.5;
EnuMax = 2.;
isDiag = true;
isEnu1D = true;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pip/ccpipXSec_enu.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
//StatUtils::ForceNormIntoCovar(this->covar, this->dataHist, this->normError);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08);
};
//********************************************************************
void MiniBooNE_CC1pip_XSec_1DEnu_nu::FillEventVariables(FitEvent* event) {
//********************************************************************
// Set up the 4-vectors
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppip;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
// No W cut on MiniBooNE data from publication
// WARNING: DRAGONS LAY HERE! Mike Wilking's thesis might not have this. Beware that the publication says W < 1.35 GeV, but this is "efficiency corrected", i.e. FILLED WITH MONTE-CARLO!!!!!!!! AAAAAH
//double hadMass = FitUtils::Wrec(Pnu, Pmu, Ppip);
double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip);
// if (isRat) Enu = Enu/1000.; //CCpi+/CCQE ratio paper puts in GeV, CCpi+ paper in MeV
this->X_VAR = Enu;
return;
};
bool MiniBooNE_CC1pip_XSec_1DEnu_nu::isSignal(FitEvent *event) {
return SignalDef::isCC1pip_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx
index addd5cb..6f0fd70 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx
@@ -1,78 +1,78 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pip_XSec_1DQ2_nu.h"
//********************************************************************
/// @brief MiniBooNE CC1pi+ numu 1DQ2 Measurement on CH2 (Ref: - )
///
// The constructor
MiniBooNE_CC1pip_XSec_1DQ2_nu::MiniBooNE_CC1pip_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pip_XSec_1DQ2_nu";
+ fName = "MiniBooNE_CC1pip_XSec_1DQ2_nu";
plotTitles = "; Q^{2}_{CC#pi} (GeV^{2}); d#sigma/dQ_{CC#pi^{+}}^{2} (cm^{2}/MeV^{2}/CH_{2})";
EnuMin = 0.5;
EnuMax = 2.;
isDiag = true;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pip/ccpipXSec_Q2.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08)/TotalIntegratedFlux("width")/1E6;
// Added /1E6. comes from Q2 being in MeV^2, not GeV^2 I think... Or maybe the units in the paper are simply wrong; 1E-45 is very small! :D
};
//********************************************************************
void MiniBooNE_CC1pip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event){
//********************************************************************
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
// No W cut on MiniBooNE CC1pi+
double Q2CC1pip = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip);
this->X_VAR = Q2CC1pip;
return;
};
//********************************************************************
bool MiniBooNE_CC1pip_XSec_1DQ2_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pip_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx
index 17f1acf..1fbc83d 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx
@@ -1,79 +1,79 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pip_XSec_1DTpi_nu.h"
// The constructor
MiniBooNE_CC1pip_XSec_1DTpi_nu::MiniBooNE_CC1pip_XSec_1DTpi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pip_XSec_1DTpi_nu";
+ fName = "MiniBooNE_CC1pip_XSec_1DTpi_nu";
plotTitles = "; T_{#pi} (MeV); d#sigma/dT_{#pi^{+}}} (cm^{2}/MeV/CH_{2})";
EnuMin = 0.5;
EnuMax = 2.;
isDiag = true;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pip/ccpipXSec_KEpi.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
//StatUtils::ForceNormIntoCovar(this->covar, this->dataHist, this->normError);
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08)/TotalIntegratedFlux("width");
};
//********************************************************************
void MiniBooNE_CC1pip_XSec_1DTpi_nu::FillEventVariables(FitEvent *event) {
//********************************************************************
// Set up the 4-vectors
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppip;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
// No W cut on MiniBooNE data from publication
// WARNING: DRAGONS LAY HERE! Mike Wilking's thesis might not have this. Beware that the publication says W < 1.35 GeV, but this is "efficiency corrected", i.e. FILLED WITH MONTE-CARLO!!!!!!!! AAAAAH
//double hadMass = FitUtils::Wrec(Pnu, Pmu, Ppip);
double Tpi = FitUtils::T(Ppip)*1000.;
this->X_VAR = Tpi;
return;
};
bool MiniBooNE_CC1pip_XSec_1DTpi_nu::isSignal(FitEvent *event) {
return SignalDef::isCC1pip_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx
index ffe2d99..1610dc0 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx
@@ -1,73 +1,73 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pip_XSec_1DTu_nu.h"
MiniBooNE_CC1pip_XSec_1DTu_nu::MiniBooNE_CC1pip_XSec_1DTu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pip_XSec_1DTu_nu";
+ fName = "MiniBooNE_CC1pip_XSec_1DTu_nu";
plotTitles = "; T_{#mu} (MeV); d#sigma/dT_{#mu} (cm^{2}/MeV/CH_{2})";
EnuMin = 0.5;
EnuMax = 2.;
isDiag = true;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pip/ccpipXSec_KEmu.txt");
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08)/TotalIntegratedFlux("width");
};
//********************************************************************
void MiniBooNE_CC1pip_XSec_1DTu_nu::FillEventVariables(FitEvent *event) {
//********************************************************************
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
// No W cut on MiniBooNE CC1pi+
double Tmu = FitUtils::T(Pmu)*1000.;
this->X_VAR = Tmu;
return;
};
bool MiniBooNE_CC1pip_XSec_1DTu_nu::isSignal(FitEvent *event) {
return SignalDef::isCC1pip_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx
index 68cfed4..3d2d8c4 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx
@@ -1,75 +1,75 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.h"
//********************************************************************
MiniBooNE_CC1pip_XSec_2DQ2Enu_nu::MiniBooNE_CC1pip_XSec_2DQ2Enu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
- measurementName = "MiniBooNE_CC1pip_XSec_2DQ2Enu_nu";
+ fName = "MiniBooNE_CC1pip_XSec_2DQ2Enu_nu";
plotTitles = "; E_{#nu} (MeV); Q^{2} (MeV^{2}/c^{4}); d#sigma(E_{#nu})/dQ^{2} (cm^{2}/(MeV^{2}/c^{4})/CH_{2})";
EnuMin = 0.5;
EnuMax = 2.0;
isDiag = true;
normError = 0.107;
Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pip/ccpipXSecs.root", std::string("QSQVENUXSec"));//data comes in .root file, yes!
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08);
};
void MiniBooNE_CC1pip_XSec_2DQ2Enu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip)*1000.;
double Q2 = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip)*1E6;
this->X_VAR = Enu;
this->Y_VAR = Q2;
return;
};
//********************************************************************
bool MiniBooNE_CC1pip_XSec_2DQ2Enu_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pip_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx
index 0209a7f..6760bac 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx
@@ -1,90 +1,90 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.h"
// The constructor
MiniBooNE_CC1pip_XSec_2DTpiCospi_nu::MiniBooNE_CC1pip_XSec_2DTpiCospi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pip_XSec_2DTpiCospi_nu";
+ fName = "MiniBooNE_CC1pip_XSec_2DTpiCospi_nu";
plotTitles = "; T_{#pi} (MeV); cos#theta_{#pi}; d^{2}#sigma/dT_{#pi}dcos#theta_{#pi} (cm^{2}/MeV)";
EnuMin = 0.5;
EnuMax = 2.0;
isDiag = true;
normError = 0.107;
Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pip/ccpipXSecs.root", std::string("PICTVKEXSec"));//data comes in .root file, yes!
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08)/TotalIntegratedFlux("width");
};
/*
void MiniBooNE_CC1pip_XSec_2DTpiCospi_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
dataHist = (TH2D*)(dataFile->Get("PICTVKEXSec")->Clone());
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
dataFile->Close();
delete dataFile;
};
*/
void MiniBooNE_CC1pip_XSec_2DTpiCospi_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
double Tpi = FitUtils::T(Ppip)*1000.;
double costh = cos(FitUtils::th(Pnu, Ppip));
this->X_VAR = Tpi;
this->Y_VAR = costh;
return;
};
//********************************************************************
bool MiniBooNE_CC1pip_XSec_2DTpiCospi_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pip_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx
index 3bf3ded..3f85b44 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx
@@ -1,93 +1,93 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.h"
//********************************************************************
MiniBooNE_CC1pip_XSec_2DTpiEnu_nu::MiniBooNE_CC1pip_XSec_2DTpiEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
- measurementName = "MiniBooNE_CC1pip_XSec_2DTpiEnu_nu";
+ fName = "MiniBooNE_CC1pip_XSec_2DTpiEnu_nu";
plotTitles = "; E_{#nu} (MeV); T_{#pi} (MeV); d#sigma(E_{#nu})/dT_{#pi} (cm^{2}/MeV)";
EnuMin = 0.5;
EnuMax = 2.0;
isDiag = true;
normError = 0.107;
Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pip/ccpipXSecs.root", std::string("PIKEVENUXSec"));//data comes in .root file, yes!
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08);
};
/*
void MiniBooNE_CC1pip_XSec_2DTpiEnu_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
dataHist = (TH2D*)(dataFile->Get("PIKEVENUXSec")->Clone());
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
dataFile->Close();
delete dataFile;
};
*/
void MiniBooNE_CC1pip_XSec_2DTpiEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip)*1000.;
double Tpi = FitUtils::T(Ppip)*1000.;
this->X_VAR = Enu;
this->Y_VAR = Tpi;
return;
};
//********************************************************************
bool MiniBooNE_CC1pip_XSec_2DTpiEnu_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pip_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx
index 29e84b1..6c3969b 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx
@@ -1,88 +1,88 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.h"
// The constructor
MiniBooNE_CC1pip_XSec_2DTuCosmu_nu::MiniBooNE_CC1pip_XSec_2DTuCosmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pip_XSec_2DTuCosmu_nu";
+ fName = "MiniBooNE_CC1pip_XSec_2DTuCosmu_nu";
plotTitles = "; T_{#mu} (MeV); cos#theta_{#mu}; d^{2}#sigma/dT_{#mu}dcos#theta_{#mu} (cm^{2}/MeV)";
EnuMin = 0.5;
EnuMax = 2.0;
isDiag = true;
normError = 0.107;
Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pip/ccpipXSecs.root", std::string("MUCTVKEXSec"));//data comes in .root file, yes!
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08)/TotalIntegratedFlux("width");
};
/*
void MiniBooNE_CC1pip_XSec_2DTuCosmu_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
dataHist = (TH2D*)(dataFile->Get("MUCTVKEXSec")->Clone());
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
dataFile->Close();
delete dataFile;
};
*/
void MiniBooNE_CC1pip_XSec_2DTuCosmu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
double Tmu = FitUtils::T(Pmu)*1000.;
double costh = cos(FitUtils::th(Pnu, Pmu));
this->X_VAR = Tmu;
this->Y_VAR = costh;
return;
};
//********************************************************************
bool MiniBooNE_CC1pip_XSec_2DTuCosmu_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pip_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx
index 57b8f2a..d6f70a5 100644
--- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx
@@ -1,88 +1,88 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CC1pip_XSec_2DTuEnu_nu.h"
// The constructor
MiniBooNE_CC1pip_XSec_2DTuEnu_nu::MiniBooNE_CC1pip_XSec_2DTuEnu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "MiniBooNE_CC1pip_XSec_2DTuEnu_nu";
+ fName = "MiniBooNE_CC1pip_XSec_2DTuEnu_nu";
plotTitles = "; E_{#nu} (MeV); T_{#mu} (MeV); d#sigma(E_{#nu})/dT_{#mu} (cm^{2}/MeV)";
EnuMin = 0.5;
EnuMax = 2.0;
isDiag = true;
normError = 0.107;
Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/MiniBooNE/CC1pip/ccpipXSecs.root", std::string("MUKEVENUXSec"));//data comes in .root file, yes!
this->SetupDefaultHist();
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
// Calculates a flux averaged cross-section from (Evt("width")/Flux("width")) * 14.08/6.0
this->scaleFactor = this->eventHist->Integral("width")*double(1E-38)/double(nevents)*(14.08);
};
/*
void MiniBooNE_CC1pip_XSec_2DTuEnu_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
dataHist = (TH2D*)(dataFile->Get("MUKEVENUXSec")->Clone());
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
dataFile->Close();
delete dataFile;
};
*/
void MiniBooNE_CC1pip_XSec_2DTuEnu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j){
if (!event->PartInfo(j)->fIsAlive || event->PartInfo(j)->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = event->PartInfo(j)->fP;
}
}
double Enu = FitUtils::EnuCC1piprec(Pnu, Pmu, Ppip)*1000.;
double Tmu = FitUtils::T(Pmu)*1000.;
this->X_VAR = Enu;
this->Y_VAR = Tmu;
return;
};
//********************************************************************
bool MiniBooNE_CC1pip_XSec_2DTuEnu_nu::isSignal(FitEvent *event) {
//********************************************************************
return SignalDef::isCC1pip_MiniBooNE(event, EnuMin, EnuMax);
}
diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx
index 5dc2efa..79bfbd4 100644
--- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx
@@ -1,223 +1,223 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CCQE_XSec_1DQ2_antinu.h"
//********************************************************************
/// @brief MiniBooNE CCQE antinumu 1DQ2 Measurement on CH2 (Ref: - )
///
//********************************************************************
MiniBooNE_CCQE_XSec_1DQ2_antinu::MiniBooNE_CCQE_XSec_1DQ2_antinu(std::string name, std::string inputfile,
FitWeight *rw, std::string type,
std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
plotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
EnuMin = 0.;
EnuMax = 3.;
normError = 0.130;
default_types="FIX/DIAG";
allowed_types="FIX,FREE,SHAPE/DIAG";
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup Plots
this->plotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
this->ccqelike = name.find("CCQELike") != std::string::npos;
this->SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/asqq_con.txt");
this->SetupDefaultHist();
if (!this->isDiag) this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/MiniBooNE_1DQ2_antinu.root");
else {
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
}
///
/// If CCQELike is used an additional the CCQELike BKG is used and a PDG Histogram is saved
if (ccqelike){
dataHist_CCQELIKE = PlotUtils::GetTH1DFromFile(FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/asqq_bkg_ccqe.txt", \
- (this->measurementName+"_data_CCQELIKE"), this->plotTitles);
+ (this->fName+"_data_CCQELIKE"), this->plotTitles);
dataHist_CCPIM = PlotUtils::GetTH1DFromFile(FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/asqq_bkg_ccpim.txt", \
- (this->measurementName+"_data_CCPIM"), this->plotTitles);
+ (this->fName+"_data_CCPIM"), this->plotTitles);
// Make NON CCPIM
dataHist_NONCCPIM = (TH1D*) dataHist_CCQELIKE->Clone();
- dataHist_NONCCPIM->SetNameTitle((this->measurementName+"_data_NONCCPIM").c_str(), (this->measurementName+"_data_NONCCPIM").c_str());
+ dataHist_NONCCPIM->SetNameTitle((this->fName+"_data_NONCCPIM").c_str(), (this->fName+"_data_NONCCPIM").c_str());
// Perform dataHist Sums
for (int i = 0; i < dataHist->GetNbinsX(); i++){
dataHist_NONCCPIM->SetBinContent(i+1, dataHist_CCQELIKE->GetBinContent(i+1) - dataHist_CCPIM->GetBinContent(i+1));
dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1) + dataHist_CCQELIKE->GetBinContent(i+1));
}
PlotUtils::CreateNeutModeArray((TH1D*)this->mcHist,(TH1**)this->mcHist_CCQELIKE);
PlotUtils::ResetNeutModeArray((TH1**)this->mcHist_CCQELIKE);
PlotUtils::CreateNeutModeArray((TH1D*)this->mcHist,(TH1**)this->mcHist_NONCCPIM);
PlotUtils::ResetNeutModeArray((TH1**)this->mcHist_NONCCPIM);
PlotUtils::CreateNeutModeArray((TH1D*)this->mcHist,(TH1**)this->mcHist_CCPIM);
PlotUtils::ResetNeutModeArray((TH1**)this->mcHist_CCPIM);
}
// ScaleFactor
scaleFactor = ((eventHist->Integral("width")*1E-38/(nevents+0.))
*14.08/8.
/ TotalIntegratedFlux());
};
//********************************************************************
/// @details Extract q2qe(X_VAR) from the event
void MiniBooNE_CCQE_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event){
//********************************************************************
// Init
q2qe = -999.9;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
int PID = fabs((event->PartInfo(j))->fPID);
// Look for the outgoing muon
if (PID == -13 or (ccqelike and PID == 13)){
// Now find the Q2QE value and fill the histogram
q2qe = FitUtils::Q2QErec((event->PartInfo(j))->fP,
cos(((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect()))), 30., false);
break;
}
}
// Set X Variables
this->X_VAR = q2qe;
return;
};
//********************************************************************
bool MiniBooNE_CCQE_XSec_1DQ2_antinu::isSignal(FitEvent *event){
//********************************************************************
// 2 Different Signal Definitions
if (ccqelike) return SignalDef::isMiniBooNE_CCQELike(event, EnuMin, EnuMax);
else return SignalDef::isMiniBooNE_CCQEBar(event, EnuMin, EnuMax);
return true;
};
//********************************************************************
/// @details Fills a ccqe-like and ccpim background plot if required
void MiniBooNE_CCQE_XSec_1DQ2_antinu::FillHistograms(){
//********************************************************************
Measurement1D::FillHistograms();
if (Mode != -1 && Mode != -2 and ccqelike and Signal){
if (fabs(Mode) == 11 or fabs(Mode) == 13) PlotUtils::FillNeutModeArray(mcHist_CCPIM, Mode, X_VAR, Weight);
else PlotUtils::FillNeutModeArray(mcHist_NONCCPIM, Mode, X_VAR, Weight);
PlotUtils::FillNeutModeArray(mcHist_CCQELIKE, Mode, X_VAR, Weight);
}
}
//********************************************************************
/// @details Extra write command to save the CCQELike/CCPIM PDG if required
void MiniBooNE_CCQE_XSec_1DQ2_antinu::Write(std::string drawOpt){
//********************************************************************
Measurement1D::Write(drawOpt);
if (ccqelike){
dataHist_CCQELIKE->Write();
- THStack combo_mcHist_CCQELIKE = PlotUtils::GetNeutModeStack((this->measurementName + "_MC_CCQELIKE").c_str(), (TH1**)this->mcHist_CCQELIKE, 0);
+ THStack combo_mcHist_CCQELIKE = PlotUtils::GetNeutModeStack((this->fName + "_MC_CCQELIKE").c_str(), (TH1**)this->mcHist_CCQELIKE, 0);
combo_mcHist_CCQELIKE.Write();
dataHist_CCPIM->Write();
- THStack combo_mcHist_CCPIM = PlotUtils::GetNeutModeStack((this->measurementName + "_MC_CCPIM").c_str(), (TH1**)this->mcHist_CCPIM, 0);
+ THStack combo_mcHist_CCPIM = PlotUtils::GetNeutModeStack((this->fName + "_MC_CCPIM").c_str(), (TH1**)this->mcHist_CCPIM, 0);
combo_mcHist_CCPIM.Write();
dataHist_NONCCPIM->Write();
- THStack combo_mcHist_NONCCPIM = PlotUtils::GetNeutModeStack((this->measurementName + "_MC_NONCCPIM").c_str(), (TH1**)this->mcHist_NONCCPIM, 0);
+ THStack combo_mcHist_NONCCPIM = PlotUtils::GetNeutModeStack((this->fName + "_MC_NONCCPIM").c_str(), (TH1**)this->mcHist_NONCCPIM, 0);
combo_mcHist_NONCCPIM.Write();
}
}
//********************************************************************
/// @details Extra scale command for CCQELIKE/CCPIM PDG Hist
void MiniBooNE_CCQE_XSec_1DQ2_antinu::ScaleEvents(){
//********************************************************************
Measurement1D::ScaleEvents();
if (ccqelike){
PlotUtils::ScaleNeutModeArray((TH1**)mcHist_CCQELIKE, scaleFactor,"width");
PlotUtils::ScaleNeutModeArray((TH1**)mcHist_CCPIM, scaleFactor,"width");
PlotUtils::ScaleNeutModeArray((TH1**)mcHist_NONCCPIM, scaleFactor,"width");
}
}
//********************************************************************
/// @details Apply norm scaling to CCQELIKE/CCPIM PDG Hist
void MiniBooNE_CCQE_XSec_1DQ2_antinu::ApplyNormScale(double norm){
//********************************************************************
Measurement1D::ApplyNormScale(norm);
if (ccqelike){
PlotUtils::ScaleNeutModeArray((TH1**)mcHist_CCQELIKE, 1.0/norm, "");
PlotUtils::ScaleNeutModeArray((TH1**)mcHist_CCPIM, 1.0/norm, "");
PlotUtils::ScaleNeutModeArray((TH1**)mcHist_NONCCPIM, 1.0/norm, "");
}
}
//******************************************************************** /// @details Extra scale command for CCQELIKE PDG Hist
void MiniBooNE_CCQE_XSec_1DQ2_antinu::ResetAll(){
//********************************************************************
if (ccqelike){
PlotUtils::ResetNeutModeArray((TH1**)mcHist_CCQELIKE);
PlotUtils::ResetNeutModeArray((TH1**)mcHist_CCPIM);
PlotUtils::ResetNeutModeArray((TH1**)mcHist_NONCCPIM);
}
}
diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx
index 85bd361..fccd55e 100644
--- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx
@@ -1,181 +1,181 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CCQE_XSec_1DQ2_nu.h"
//********************************************************************
MiniBooNE_CCQE_XSec_1DQ2_nu::MiniBooNE_CCQE_XSec_1DQ2_nu(std::string name, std::string inputfile,
FitWeight *rw, std::string type,
std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
plotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
/// Using the sample name "MiniBooNE_CCQE_XSec_1DQ2_nu_CCQELike" will allow
/// the CCQELike sample without background subtraction to be fitted.
ccqelike = name.find("CCQELike") != std::string::npos;
EnuMin = 0.;
EnuMax = 3.;
normError = 0.107;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup Plots
this->plotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
this->SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/ccqe/asqq_con.txt");
this->SetupDefaultHist();
// Setup Covariance
if (!this->isDiag) {
/// Currently has a placeholder for the matrices as work fixing them is ongoing.
this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/ccqe/MiniBooNE_1DQ2_nu.root");
StatUtils::SetDataErrorFromCov(dataHist, fullcovar, 1E-38);
} else {
/// Assume a diagonal shape-only error is default
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
}
/// If CCQELike is used an additional the CCQELike BKG is used and a PDG Histogram is saved
if (ccqelike){
dataHist_CCQELIKE = PlotUtils::GetTH1DFromFile(FitPar::GetDataBase()+"/MiniBooNE/ccqe/asqq_bkg.txt",
- (this->measurementName+"_data_CCQELIKE"), this->plotTitles);
+ (this->fName+"_data_CCQELIKE"), this->plotTitles);
for (int i = 0; i < dataHist->GetNbinsX(); i++){
this->dataHist->SetBinContent(i+1, dataHist->GetBinContent(i+1) + dataHist_CCQELIKE->GetBinContent(i+1));
}
PlotUtils::CreateNeutModeArray((TH1D*)this->mcHist,(TH1**)this->mcHist_CCQELIKE);
PlotUtils::ResetNeutModeArray((TH1**)this->mcHist_CCQELIKE);
}
// Get Scale Factor
scaleFactor = ((eventHist->Integral("width")*1E-38/(nevents+0.))
* (14.08/6.0)
/ TotalIntegratedFlux());
};
//********************************************************************
/// @details Extract q2qe(X_VAR) from the event
void MiniBooNE_CCQE_XSec_1DQ2_nu::FillEventVariables(FitEvent *event){
//********************************************************************
// Init
q2qe = -999.9;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
int PID = abs((event->PartInfo(j))->fPID);
// Look for the outgoing muon
if (PID == 13 or (ccqelike and PID == -13)){
// Now find the Q2QE value and fill the histogram
q2qe = FitUtils::Q2QErec((event->PartInfo(j))->fP,
cos(((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect()))),
34., true);
break;
}
}
// Set X Variables
this->X_VAR = q2qe;
return;
};
//********************************************************************
bool MiniBooNE_CCQE_XSec_1DQ2_nu::isSignal(FitEvent *event){
//********************************************************************
// 2 Different Signal Definitions
if (ccqelike) return SignalDef::isMiniBooNE_CCQELike(event, EnuMin, EnuMax);
else return SignalDef::isMiniBooNE_CCQE(event, EnuMin, EnuMax);
return true;
};
//********************************************************************
/// @details Fills a ccqe-like background plot if required
void MiniBooNE_CCQE_XSec_1DQ2_nu::FillHistograms(){
//********************************************************************
Measurement1D::FillHistograms();
if (Mode != 1 and Mode != 2 and ccqelike and Signal){
PlotUtils::FillNeutModeArray(mcHist_CCQELIKE, Mode, X_VAR, Weight);
}
}
//********************************************************************
/// @details Extra write command to save the CCQELike PDG if required
void MiniBooNE_CCQE_XSec_1DQ2_nu::Write(std::string drawOpt){
//********************************************************************
Measurement1D::Write(drawOpt);
if (ccqelike){
dataHist_CCQELIKE->Write();
- THStack combo_mcHist_CCQELIKE = PlotUtils::GetNeutModeStack((this->measurementName + "_MC_CCQELIKE").c_str(), (TH1**)this->mcHist_CCQELIKE, 0);
+ THStack combo_mcHist_CCQELIKE = PlotUtils::GetNeutModeStack((this->fName + "_MC_CCQELIKE").c_str(), (TH1**)this->mcHist_CCQELIKE, 0);
combo_mcHist_CCQELIKE.Write();
}
}
//********************************************************************
/// @details Extra scale command for CCQELIKE PDG Hist
void MiniBooNE_CCQE_XSec_1DQ2_nu::ResetAll(){
//********************************************************************
if (ccqelike)
PlotUtils::ResetNeutModeArray((TH1**)mcHist_CCQELIKE);
}
//********************************************************************
/// @details Extra scale command for CCQELIKE PDG Hist
void MiniBooNE_CCQE_XSec_1DQ2_nu::ScaleEvents(){
//********************************************************************
Measurement1D::ScaleEvents();
if (ccqelike)
PlotUtils::ScaleNeutModeArray((TH1**)mcHist_CCQELIKE, scaleFactor,"width");
}
//********************************************************************
/// @details Apply norm scaling to CCQELIKE PDG Hist
void MiniBooNE_CCQE_XSec_1DQ2_nu::ApplyNormScale(double norm){
//********************************************************************
Measurement1D::ApplyNormScale(norm);
if (ccqelike)
PlotUtils::ScaleNeutModeArray((TH1**)mcHist_CCQELIKE, 1.0/norm, "");
}
diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx
index 65e9248..3b925a0 100644
--- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx
@@ -1,110 +1,110 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CCQE_XSec_2DTcos_antinu.h"
//********************************************************************
MiniBooNE_CCQE_XSec_2DTcos_antinu::MiniBooNE_CCQE_XSec_2DTcos_antinu(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
plotTitles = "; Q^{2}_{QE} (GeV^{2}); d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})";
EnuMin = 0.;
EnuMax = 3.;
normError = 0.130;
default_types="FIX/DIAG";
allowed_types="FIX,FREE,SHAPE/DIAG/NORM";
Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup Plots
plotTitles = "; T_{#mu} (GeV); cos#theta_{#mu}; d^{2}#sigma/dT_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)";
ccqelike = name.find("CCQELike") != std::string::npos;
// Define Bin Edges
data_points_x = 19;
data_points_y = 21;
Double_t tempx[19] = { 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0};
Double_t tempy[21] = {-1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0};
xBins = tempx;
yBins = tempy;
// Setup Data Plots
if (!ccqelike){
SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/aski_con.txt", 1E-41,
FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/aski_err.txt", 1E-42);
} else {
SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/aski_like.txt", 1E-41,
FitPar::GetDataBase()+"/MiniBooNE/anti-ccqe/aski_err.txt", 1E-42);
}
this->SetupDefaultHist();
// Setup Covariances
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
isDiag = true;
// Set Scaling for Differential Cross-section
scaleFactor = ((eventHist->Integral("width")*1E-38/(nevents+0.))
*(14.08/8.)
/TotalIntegratedFlux());
};
//********************************************************************
void MiniBooNE_CCQE_XSec_2DTcos_antinu::FillEventVariables(FitEvent *event){
//********************************************************************
// Init
Ekmu = -999.9;
costheta = -999.9;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
int PID = (event->PartInfo(j))->fPID;
// Look for the outgoing muon
if (PID == -13 or (ccqelike and PID == 13)){
// Now find the kinematic values and fill the histogram
Ekmu = (event->PartInfo(j))->fP.E()/1000.0 - 0.105658367;
costheta = cos(((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect())));
break;
}
}
// Set X Variables
this->X_VAR = Ekmu;
this->Y_VAR = costheta;
return;
};
//********************************************************************
bool MiniBooNE_CCQE_XSec_2DTcos_antinu::isSignal(FitEvent *event){
//********************************************************************
// 2 Different Signal Definitions
if (ccqelike) return SignalDef::isMiniBooNE_CCQELike(event, EnuMin, EnuMax);
else return SignalDef::isMiniBooNE_CCQEBar(event, EnuMin, EnuMax);
return true;
};
diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx
index 4b80d03..2d9d0bd 100644
--- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx
@@ -1,115 +1,115 @@
/// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_CCQE_XSec_2DTcos_nu.h"
//********************************************************************
MiniBooNE_CCQE_XSec_2DTcos_nu::MiniBooNE_CCQE_XSec_2DTcos_nu(std::string name, std::string inputfile,
FitWeight *rw, std::string type,
std::string fakeDataFile){
//********************************************************************
// Measurement Details
- measurementName = name;
+ fName = name;
EnuMin = 0.;
EnuMax = 3.;
isDiag = true;
normError = 0.107;
default_types = "FIX/DIAG";
allowed_types = "FIX,FREE,SHAPE/DIAG/NORM";
Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
// Setup Plots
plotTitles = "; T_{#mu} (GeV); cos#theta_{#mu}; d^{2}#sigma/dT_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)";
ccqelike = name.find("CCQELike") != std::string::npos;
// Define Bin Edges
data_points_x = 19;
data_points_y = 21;
Double_t tempx[19] = { 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0};
Double_t tempy[21] = {-1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0};
xBins = tempx;
yBins = tempy;
// Setup Data Plots
if (!ccqelike){
SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/ccqe/aski_con.txt", 1E-41,
FitPar::GetDataBase()+"/MiniBooNE/ccqe/aski_err.txt", 1E-42);
} else {
SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/ccqe/aski_like.txt", 1E-41,
FitPar::GetDataBase()+"/MiniBooNE/ccqe/aski_err.txt", 1E-42);
}
SetupDefaultHist();
// Setup Covariances
fullcovar = StatUtils::MakeDiagonalCovarMatrix(dataHist);
covar = StatUtils::GetInvert(fullcovar);
isDiag = true;
// Different generators require slightly different rescaling factors.
scaleFactor = (eventHist->Integral("width")*1E-38/(nevents+0.))*14.08/6./TotalIntegratedFlux();
};
//********************************************************************
void MiniBooNE_CCQE_XSec_2DTcos_nu::FillEventVariables(FitEvent *event){
//********************************************************************
// Init
Ekmu = -999.9;
costheta = -999.9;
// Loop over the particle stack
for (UInt_t j = 2; j < event->Npart(); ++j){
int PID = (event->PartInfo(j))->fPID;
// Look for the outgoing muon
if (PID == 13 or (ccqelike and PID == -13)){
// Now find the kinematic values and fill the histogram
Ekmu = (event->PartInfo(j))->fP.E()/1000.0 - 0.105658367;
costheta = cos(((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect())));
break;
}
}
// Set X and Y Variables
this->X_VAR = Ekmu;
this->Y_VAR = costheta;
return;
};
//********************************************************************
bool MiniBooNE_CCQE_XSec_2DTcos_nu::isSignal(FitEvent *event){
//********************************************************************
bool signal = true;
// 2 Different Signal Definitions
if (ccqelike) signal = SignalDef::isMiniBooNE_CCQELike(event, EnuMin, EnuMax);
else signal = SignalDef::isMiniBooNE_CCQE(event, EnuMin, EnuMax);
//if (signal) std::cout<<"Signal Values = "<<X_VAR<<" "<<Y_VAR<<std::endl;
return signal;
};
diff --git a/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx b/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx
index 8f925c0..a3bf526 100644
--- a/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx
@@ -1,334 +1,334 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_NCEL_XSec_Treco_nu.h"
#include "TLorentzVector.h"
/// ENTIRE CLASS NEEDS FIXING
// The constructor
MiniBooNE_NCEL_XSec_Treco_nu::MiniBooNE_NCEL_XSec_Treco_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
// // Check if this is a shape only fit - for now, there is no shape option.
// if (!type.compare("SHAPE")){
// std::cout << "MiniBooNE NCEL is not available as a shape only fit... ignoring..." << std::endl;
// }
// // Set pointer to the reweighting engine
// rw_engine = rw;
// // Define the energy of the signal
// this->EnuMin = 0.;
// this->EnuMax = 10.;
// // In future read most of these from a card file
// this->inFile = inputfile;
- // this->measurementName = "MB_NCEL_XSec_Treco_nu";
+ // this->fName = "MB_NCEL_XSec_Treco_nu";
// this->plotTitles = "; T_{reco} (MeV); Events/(12 MeV)";
// // Because the binning is in Treco is fairly esoteric, hardcode here
// this->arr_treco = {40.0, 52.0, 63.9, 75.9, 87.8, 99.8, 111.8, 123.7, 135.7, 147.6, 159.6, 171.6, 183.5, 195.5,
// 207.5, 219.4, 231.4, 243.3, 255.3, 267.3, 279.2, 291.2, 303.1, 315.1, 327.1, 339.0, 351.0, 362.9, 374.9, 386.9,
// 398.8, 410.8, 422.7, 434.7, 446.7, 458.6, 470.6, 482.5, 494.5, 506.5, 518.4, 530.4, 542.4, 554.3, 566.3, 578.2,
// 590.2, 602.2, 614.1, 626.1, 638.0, 650.0};
// this->SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/ncqe/input_data.txt");
// this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/ncqe/ErrorMatrix.tab", 51);
// this->SetResponseMatrix(FitPar::GetDataBase()+"/MiniBooNE/ncqe/response_mat.txt", 51);
// // Check if we're using fake data
// if (!fakeDataFile.empty()) this->SetFakeDataValues(fakeDataFile);
// // This will be the final data histogram
- // this->mcHist = new TH1D((this->measurementName+"_MC").c_str(), (this->measurementName+this->plotTitles).c_str(), 51, this->arr_treco);
+ // this->mcHist = new TH1D((this->fName+"_MC").c_str(), (this->fName+this->plotTitles).c_str(), 51, this->arr_treco);
// // Usually, the mcFine histogram is a finer binned version of mcHist. But as NCEL requires a Ttrue histogram, co-opt mcFine for this purpose.
// // Should probably change the naming to reflect the possible other use of this histogram.
- // this->mcFine = new TH1D((this->measurementName+"_Ttrue").c_str(), (this->measurementName+this->plotTitles).c_str(), 50, 0, 900);
+ // this->mcFine = new TH1D((this->fName+"_Ttrue").c_str(), (this->fName+this->plotTitles).c_str(), 50, 0, 900);
// // Read in the histograms from the NEUT file that are required for normalisation
// TFile *in = new TFile(this->inFile.c_str());
// this->fluxHist = (TH1D*)in->Get((PlotUtils::GetObjectWithName(in, "flux")).c_str());
- // this->fluxHist->SetNameTitle((this->measurementName+"_FLUX").c_str(), (this->measurementName+";E_{#nu} (GeV)").c_str());
+ // this->fluxHist->SetNameTitle((this->fName+"_FLUX").c_str(), (this->fName+";E_{#nu} (GeV)").c_str());
// this->eventHist = (TH1D*)in->Get((PlotUtils::GetObjectWithName(in, "evtrt")).c_str());
- // this->eventHist->SetNameTitle((this->measurementName+"_EVT").c_str(), (this->measurementName+";E_{#nu} (GeV); Event Rate").c_str());
+ // this->eventHist->SetNameTitle((this->fName+"_EVT").c_str(), (this->fName+";E_{#nu} (GeV); Event Rate").c_str());
// // Read in the file once only
// tn = new TChain("neuttree", "");
// tn->Add(Form("%s/neuttree", this->inFile.c_str()));
// nevents = tn->GetEntries();
// nvect = NULL;
// tn->SetBranchAddress("vectorbranch", &nvect);
// // The scale factor is quite complicated because MB didn't divide by number of targets.
// // nMolMB is the number of CH_2 molecules in the MB FV (610.6 cm radius sphere) and 0.845 is the published density of the mineral oil.
// double nMolMB = 6.023E+23*0.845*4.0*M_PI*610.6*610.6*610.6/3.0;
// this->scaleFactor = (this->eventHist->Integral()*1E-38*14.08/(nevents+0.))*nMolMB*0.646165;
};
void MiniBooNE_NCEL_XSec_Treco_nu::Reconfigure(double norm, bool fullconfig){
// // Clear the current histogram before repopulating
// this->mcHist->Reset();
// this->mcFine->Reset();
// this->currentNorm = norm;
// // Loop over all events at each iteration of the fit
// for (int i = 0; i < nevents; ++i){
// tn->GetEntry(i);
// if (!isSignal(nvect)) continue;
// // Find the weight
// double rw_weight = 1;
// rw_weight = rw_engine->CalcWeight(customEvent);
// // Skip any events with suspiciously large weights...
// if (rw_weight > 200) {std::cout << "LARGE WEIGHT: " << rw_weight << std::endl; break;}
// // Sum of the true kinetic energies of particles
// double t_true = 0.;
// // Loop over the particle stack
// for (UInt_t j = 2; j < nvect->Npart(); ++j){
// // Add the kinetic energies of any nucleons
// if (abs((nvect->PartInfo(j))->fPID) == 2212)
// t_true += (nvect->PartInfo(j))->fP.E()/1000 - 0.93956536;
// else if (abs((nvect->PartInfo(j))->fPID) == 2112)
// t_true += (nvect->PartInfo(j))->fP.E()/1000 - 0.93827203;
// }
// // Now fill the Ttrue histogram
// this->mcFine->Fill(t_true*1000., rw_weight);
// }
// // Now convert Ttrue to Treco...
// for (int treco = 0; treco < 51; ++treco){
// double total = 0.;
// for (int ttrue = 0; ttrue < 50; ++ttrue) total += mcFine->GetBinContent(ttrue+1)*this->response_mat->GetBinContent(ttrue+1, treco+1);
// this->mcHist->SetBinContent(treco+1, total);
// }
// // Scale
// this->mcHist->Scale(this->scaleFactor, "width");
// this->mcFine->Scale(this->scaleFactor, "width");
// // Add in the backgrounds...
// for (int treco = 0; treco < 51; ++treco){
// double total = this->mcHist->GetBinContent(treco+1) + this->BKGD_other->GetBinContent(treco+1) + this->BKGD_irrid->GetBinContent(treco+1);
// this->mcHist->SetBinContent(treco+1, total);
// }
// // Normalisation factor if one has been provided.
// if (norm){
// this->mcHist->Scale(1.0/norm);
// } else {
// this->mcHist->Scale(0);
// }
// return;
};
bool MiniBooNE_NCEL_XSec_Treco_nu::isSignal(NeutVect *nvect){
// Only interested in true NCEL events
// if (nvect->Mode != 51 && nvect->Mode != 52) return false;
// // Only look at numu events
// if ((nvect->PartInfo(0))->fPID != 14 && (nvect->PartInfo(0))->fPID != 12) return false;
// // Restrict energy range
// if ((nvect->PartInfo(0))->fP.E() < this->EnuMin*1000 || (nvect->PartInfo(0))->fP.E() > this->EnuMax*1000) return false;
return true;
};
// Read in the covariance matrix from the file specified in the constructor
void MiniBooNE_NCEL_XSec_Treco_nu::SetCovarMatrix(std::string covarFile, int dim){
// // Make a counter to track the line number
// int row = 0;
// std::string line;
// std::ifstream covar(covarFile.c_str(),ifstream::in);
// this->covar = new TMatrixDSym(dim);
// if(covar.is_open()) std::cout << "Reading covariance matrix from file: " << covarFile << std::endl;
// while(std::getline(covar, line, '\n')){
// std::istringstream stream(line);
// double entry;
// int column = 0;
// // Loop over entries and insert them into matrix
// // Multiply by the errors to get the covariance, rather than the correlation matrix
// while(stream >> entry){
// (*this->covar)(row, column) = entry;
// if (row == column) this->dataHist->SetBinError(row+1, sqrt(entry));
// column++;
// }
// row++;
// }
// // Robust matrix inversion method
// TDecompSVD LU = TDecompSVD(*this->covar);
// this->covar = new TMatrixDSym(dim, LU .Invert().GetMatrixArray(), "");
return;
};
// The covariance matrix contains all of the information for the chi2 calculation
double MiniBooNE_NCEL_XSec_Treco_nu::GetChi2(){
// double chi2 = 0;
// int nBins = this->dataHist->GetNbinsX();
// for (int i = 0; i < nBins; ++i){
// for (UInt_t j = 0; j < nBins; ++j){
// double iDiff = this->dataHist->GetBinContent(i+1) - this->mcHist->GetBinContent(i+1);
// double jDiff = this->dataHist->GetBinContent(j+1) - this->mcHist->GetBinContent(j+1);
// chi2 += iDiff*(*this->covar)(i, j)*jDiff;
// }
// }
// return chi2;
};
// Function to make an Asimov dataset (so don't throw any errors)
void MiniBooNE_NCEL_XSec_Treco_nu::SetFakeDataValues(std::string fakeDataFile) {
// // This is the published data
// TH1D *tempData = (TH1D*)this->dataHist->Clone();
// TFile *fake = new TFile(fakeDataFile.c_str());
// // This is the fake data
- // this->dataHist = (TH1D*)fake->Get((this->measurementName+"_MC").c_str());
- // this->dataHist ->SetNameTitle((this->measurementName+"_FAKE").c_str(), (this->measurementName+this->plotTitles).c_str());
+ // this->dataHist = (TH1D*)fake->Get((this->fName+"_MC").c_str());
+ // this->dataHist ->SetNameTitle((this->fName+"_FAKE").c_str(), (this->fName+this->plotTitles).c_str());
// for (int xBin = 0; xBin < this->dataHist->GetNbinsX(); ++xBin){
// // If the fake data or real didn't didn't fill the bin, can't assign an error
// if (!this->dataHist->GetBinContent(xBin+1) || !tempData->GetBinContent(xBin+1)){
// this->dataHist->SetBinError(xBin+1, 0);
// continue;
// }
// double err = tempData->GetBinError(xBin+1)*
// this->dataHist->GetBinContent(xBin+1)/(tempData->GetBinContent(xBin+1)+0.);
// this->dataHist->SetBinError(xBin+1, err);
// }
// delete tempData;
// return;
};
// Override the usual function in the base class because this is more complicated for the NCEL sample...
void MiniBooNE_NCEL_XSec_Treco_nu::SetDataValues(std::string inputFile){
// std::string line;
// std::ifstream input(inputFile.c_str(),ifstream::in);
// if(input.is_open()) std::cout << "Reading data from file: " << inputFile << std::endl;
- // this->dataHist = new TH1D((this->measurementName+"_data").c_str(), (this->measurementName+this->plotTitles).c_str(),
+ // this->dataHist = new TH1D((this->fName+"_data").c_str(), (this->fName+this->plotTitles).c_str(),
// 51, this->arr_treco);
- // this->BKGD_other = new TH1D((this->measurementName+"_BKGD_other").c_str(), (this->measurementName+this->plotTitles).c_str(),
+ // this->BKGD_other = new TH1D((this->fName+"_BKGD_other").c_str(), (this->fName+this->plotTitles).c_str(),
// 51, arr_treco);
- // this->BKGD_irrid = new TH1D((this->measurementName+"_BKGD_irrid").c_str(), (this->measurementName+this->plotTitles).c_str(),
+ // this->BKGD_irrid = new TH1D((this->fName+"_BKGD_irrid").c_str(), (this->fName+this->plotTitles).c_str(),
// 51, arr_treco);
// // To get the nDOF correct...
// this->data_points= 52;
// double entry = 0;
// int xBin = 0;
// // First line is the MB data
// std::getline(input, line, '\n');
// std::istringstream stream1(line);
// while(stream1 >> entry){
// this->dataHist->SetBinContent(xBin+1, entry);
// xBin++;
// }
// // Second line is "other" backgrounds
// std::getline(input, line, '\n');
// std::istringstream stream2(line);
// entry = 0;
// xBin = 0;
// while(stream2 >> entry){
// this->BKGD_other->SetBinContent(xBin+1, entry);
// xBin++;
// }
// // Third line is the irreducible background
// std::getline(input, line, '\n');
// std::istringstream stream3(line);
// entry = 0;
// xBin = 0;
// while(stream3 >> entry){
// this->BKGD_irrid->SetBinContent(xBin+1, entry);
// xBin++;
// }
};
// Read in the response matrix -- thus far, a response matrix is unique to the NCEL sample
void MiniBooNE_NCEL_XSec_Treco_nu::SetResponseMatrix(std::string responseFile, int dim){
// Make a counter to track the line number
// int xBin = 0;
// std::string line;
// std::ifstream response(responseFile.c_str(),ifstream::in);
// // Response matrix: x axis is Ttrue, y axis is Treco
- // this->response_mat = new TH2D((this->measurementName+"_RESPONSE_MATRIX").c_str(), (this->measurementName+this->plotTitles).c_str(),
+ // this->response_mat = new TH2D((this->fName+"_RESPONSE_MATRIX").c_str(), (this->fName+this->plotTitles).c_str(),
// 50, 0, 900, 51, this->arr_treco);
// if(response.is_open()) std::cout << "Reading in the response matrix from file: " << responseFile << std::endl;
// while(std::getline(response, line, '\n')){
// std::istringstream stream(line);
// double entry;
// int yBin = 0;
// // Loop over entries and insert them into matrix
// // Multiply by the errors to get the covariance, rather than the correlation matrix
// while(stream >> entry){
// this->response_mat->SetBinContent(xBin+1, yBin+1, entry);
// yBin++;
// }
// xBin++;
// }
};
diff --git a/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx b/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx
index db5306e..11cec7f 100644
--- a/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx
+++ b/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx
@@ -1,182 +1,182 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "MiniBooNE_NCpi0_XSec_1Dppi0_nu.h"
// The constructor
MiniBooNE_NCpi0_XSec_1Dppi0_nu::MiniBooNE_NCpi0_XSec_1Dppi0_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile, Double_t *anuBins) : isComb(false) {
if (anuBins != NULL)
isComb = true;
isComb = false;
// Needs Updating
// // Set pointer to the reweighting engine
// rw_engine = rw;
// this->exp_distance = 0.541;
// // Define the energy region
// this->EnuMin = 0.;
// this->EnuMax = 4.;
// // In future read most of these from a card file
// this->inFile = inputfile;
- // this->measurementName = "MB_NCpi0_XSec_numu_1Dppi0";
+ // this->fName = "MB_NCpi0_XSec_numu_1Dppi0";
// this->plotTitles = "; p_{#pi^{0}} (GeV/c); d#sigma/dp_{#pi^{0}} (cm^{2}/(GeV/c)/nucleon)";
// this->SetCovarMatrix(FitPar::GetDataBase()+"/MiniBooNE/nc1pi0/nuppi0xsecerrormatrix.txt", 11);
// this->SetDataValues(FitPar::GetDataBase()+"/MiniBooNE/nc1pi0/nuppi0xsec_edit.txt");
// this->normError=0.107;
// if (isComb) {
- // measurementName += "_comb";
+ // fName += "_comb";
// this->data_points = 11;
// this->xBins = anuBins;
// }
- // this->mcHist = new TH1D((this->measurementName+"_MC").c_str(), (this->measurementName+this->plotTitles).c_str(), this->data_points-1, this->xBins);
- // this->mcFine = new TH1D((this->measurementName+"_MC_FINE").c_str(), (this->measurementName+this->plotTitles).c_str(), (this->data_points - 1)*10, this->xBins[0], this->xBins[this->data_points -1]);
+ // this->mcHist = new TH1D((this->fName+"_MC").c_str(), (this->fName+this->plotTitles).c_str(), this->data_points-1, this->xBins);
+ // this->mcFine = new TH1D((this->fName+"_MC_FINE").c_str(), (this->fName+this->plotTitles).c_str(), (this->data_points - 1)*10, this->xBins[0], this->xBins[this->data_points -1]);
// this->ReadEventFile();
// // Different generators require slightly different rescaling factors.
// if (this->eventType == 0) this->scaleFactor = (this->eventHist->Integral("width")*1E-38/(nevents+0.))*14.08/14.0/this->TotalIntegratedFlux(); // NEUT
// else if (this->eventType == 1) this->scaleFactor = (this->eventHist->Integral()*1E-38/(nevents+0.))*14.08*6.0/14./this->fluxHist->Integral(); // NUWRO
// else if (this->eventType == 5) this->scaleFactor = (this->eventHist->Integral()*1E-38/(nevents+0.))*14.08*6.0/14./this->fluxHist->Integral(); // GENIE
};
void MiniBooNE_NCpi0_XSec_1Dppi0_nu::FillEventVariables(FitEvent* event){
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Pmu;
TLorentzVector Ppi0;
double EHad = 0;
pi0Cnt = 0;
bad_particle = false;
for (UInt_t j = 2; j < event->Npart(); ++j){
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
double KE = (event->PartInfo(j))->fP.E() - (event->PartInfo(j))->fMass;
if (PID == 111) {
Ppi0 = event->PartInfo(j)->fP;
EHad += KE;
}
else if (PID == 2112 || PID == 2212) EHad += KE;
else if (PID == -13) Pmu = event->PartInfo(j)->fP;
if (abs(PID) >= 113 && abs(PID) <= 557) bad_particle = true;
else if (abs(PID) == 11 || abs(PID) == 13 || abs(PID) == 15 || abs(PID) == 17) bad_particle = true;
else if (PID == 111) pi0Cnt++;
}
double bind = 34.0;
if (isComb) bind = 30.0;
//double hadMass = FitUtils::Wrec(Pnu, Pmu, Ppi0);
double ppi0 = Ppi0.Vect().Mag()/1000.0;
this->X_VAR = ppi0;
return;
};
bool MiniBooNE_NCpi0_XSec_1Dppi0_nu::isSignal(FitEvent* event){
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < this->EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > this->EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 14) && ((event->PartInfo(3))->fPID != 14)) return false;
if (bad_particle) return false;
if (pi0Cnt != 1) return false;
return true;
};
void MiniBooNE_NCpi0_XSec_1Dppi0_nu::SetDataValues(std::string dataFile) {
- LOG(SAM) << this->measurementName << "Setting data for " << this->measurementName << std::endl;
- LOG(SAM) << this->measurementName << "From: " << dataFile << std::endl;
- LOG(SAM) << this->measurementName << "Reading error from covariance" << std::endl;
+ LOG(SAM) << this->fName << "Setting data for " << this->fName << std::endl;
+ LOG(SAM) << this->fName << "From: " << dataFile << std::endl;
+ LOG(SAM) << this->fName << "Reading error from covariance" << std::endl;
TGraph *gr = new TGraph(dataFile.c_str());
this->xBins = gr->GetX();
this->data_values = gr->GetY();
this->data_points = gr->GetN();
// get the diagonal elements
int rows = (this->tempCovar)->GetNrows();
Double_t errors[rows+1];
for (int i = 0; i < rows; i++) errors[i] = sqrt( (*this->tempCovar)(i,i)*1E-81);
errors[rows] = 0.;
this->data_errors = errors;
- this->dataHist = new TH1D((this->measurementName+"_data").c_str(), (this->measurementName+this->plotTitles).c_str(), this->data_points-1, this->xBins);
+ this->dataHist = new TH1D((this->fName+"_data").c_str(), (this->fName+this->plotTitles).c_str(), this->data_points-1, this->xBins);
for (int i=0; i < this->data_points; ++i) {
this->dataHist->SetBinContent(i+1, this->data_values[i]);
this->dataHist->SetBinError(i+1, this->data_errors[i]);
}
return;
}
void MiniBooNE_NCpi0_XSec_1Dppi0_nu::SetCovarMatrix(std::string covarFile, int dim) {
- LOG(SAM) << this->measurementName << "===============" << std::endl;
- LOG(SAM) << this->measurementName << "Reading covariance: " << this->measurementName << std::endl;
- LOG(SAM) << this->measurementName << "From: " << covarFile << std::endl;
+ LOG(SAM) << this->fName << "===============" << std::endl;
+ LOG(SAM) << this->fName << "Reading covariance: " << this->fName << std::endl;
+ LOG(SAM) << this->fName << "From: " << covarFile << std::endl;
// tracks line number
int row = 0;
std::string line;
std::ifstream covar(covarFile.c_str(), ifstream::in);
this->tempCovar = new TMatrixDSym(dim);
// while we're on a line in covar
while(std::getline(covar, line, '\n')) {
std::istringstream stream(line);
// this is the netry we're reading!
double entry;
// this is the column counter!
int column = 0;
while(stream >> entry) {
// get the covariance entry.
// 1E-81 from the data release listing this unit
double val = entry;// * 1E-81;
// then fill the covariance matrix's row and column with this value,
(*this->tempCovar)(row, column) = val;
column++;
}
row++;
}
this->covar = (TMatrixDSym*) this->tempCovar->Clone();
TDecompChol LU = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(dim, LU.Invert().GetMatrixArray(), "");
(*this->covar) *= 1E81 * 1E-76;
return;
};
diff --git a/src/Routines/minimizerRoutines.cxx b/src/Routines/minimizerRoutines.cxx
index c92577e..d283bbe 100755
--- a/src/Routines/minimizerRoutines.cxx
+++ b/src/Routines/minimizerRoutines.cxx
@@ -1,1720 +1,1420 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "StatusMessage.h"
#include "minimizerRoutines.h"
/*
Constructor/Destructor
*/
//************************
minimizerRoutines::minimizerRoutines(int argc, char* argv[]){
//************************
- // Set Defaults
- inputFileName = "";
- outputFileName = "";
-
- covarHist = NULL;
- covarHist_Free = NULL;
- correlHist = NULL;
- correlHist_Free = NULL;
- decompHist = NULL;
- decompHist_Free = NULL;
+ fInputFile = "";
+ fInputRootFile = NULL;
+
+ fOutputFile = "";
+ fOutputRootFile = NULL;
- inputFile = NULL;
- outputFile = NULL;
- fitStrategy = "Migrad,FixAtLim";
- fakeDataFile = "";
+ fCovar = fCovarFree = NULL;
+ fCorrel = fCorrelFree = NULL;
+ fDecomp = fDecompFree = NULL;
+
+ fStrategy = "Migrad,FixAtLim";
+ fRoutines.clear();
- minimizerObj = NULL;
- thisFCN = NULL;
- callFCN = NULL;
+ fCardFile = "";
+
+ fFakeDataInput = "";
- parseArgs(argc, argv);
+ fSampleFCN = NULL;
+
+ fMinimizer = NULL;
+ fMinimizerFCN = NULL;
+ fCallFunctor = NULL;
+
+ ParseArgs(argc, argv);
};
//*************************************
minimizerRoutines::~minimizerRoutines(){
//*************************************
};
/*
Input Functions
*/
//*************************************
-void minimizerRoutines::parseArgs(int argc, char* argv[]){
+void minimizerRoutines::ParseArgs(int argc, char* argv[]){
//*************************************
std::string maxevents_flag = "";
int verbosity_flag = 0;
int error_flag = 0;
// If No Arguments print commands
for (int i = 1; i< argc; ++i){
if (i+1 != argc){
// Cardfile
- if (!std::strcmp(argv[i], "-c")) { cardFile=argv[i+1]; ++i;}
- else if (!std::strcmp(argv[i], "-o")) { outputFileName=argv[i+1]; ++i;}
- else if (!std::strcmp(argv[i], "-f")) { fitStrategy=argv[i+1]; ++i;}
- else if (!std::strcmp(argv[i], "-i")) { inputFileName=argv[i+1]; ++i;}
+ if (!std::strcmp(argv[i], "-c")) { fCardFile=argv[i+1]; ++i;}
+ else if (!std::strcmp(argv[i], "-o")) { fOutputFile=argv[i+1]; ++i;}
+ else if (!std::strcmp(argv[i], "-f")) { fStrategy=argv[i+1]; ++i;}
else if (!std::strcmp(argv[i], "-q")) { configCmdFix.push_back(argv[i+1]); ++i;}
else if (!std::strcmp(argv[i], "-n")) { maxevents_flag=argv[i+1]; ++i;}
else if (!std::strcmp(argv[i], "-v")) { verbosity_flag -= 1; }
else if (!std::strcmp(argv[i], "+v")) { verbosity_flag += 1; }
else if (!std::strcmp(argv[i], "-e")) { error_flag -= 1; }
else if (!std::strcmp(argv[i], "+e")) { error_flag += 1; }
} else std::cerr << "ERROR: unknown command line option given! - '" <<argv[i]<<" "<<argv[i+1]<<"'"<< std::endl;
}
- if (outputFileName.empty()) std::cerr << "ERROR: output file not specified." << std::endl;
- if (cardFile.empty()) std::cerr << "ERROR: card file not specified." << std::endl;
+ if (fOutputFile.empty()) std::cerr << "ERROR: output file not specified." << std::endl;
+ if (fCardFile.empty()) std::cerr << "ERROR: card file not specified." << std::endl;
// Parse fit routine
std::string token;
- std::istringstream stream(fitStrategy);
+ std::istringstream stream(fStrategy);
- LOG(FIT)<< "Fit Routine = " << fitStrategy <<std::endl;
+ LOG(FIT)<< "Fit Routine = " << fStrategy <<std::endl;
while(std::getline(stream, token, ',')){
- fit_routines.push_back(token);
+ fRoutines.push_back(token);
}
- readCard();
- setupConfig();
-
+ ReadCard();
+ SetupConfig();
+
if (!maxevents_flag.empty()) FitPar::Config().SetParI("MAXEVENTS", atoi(maxevents_flag.c_str()));
if (verbosity_flag != 0) FitPar::Config().SetParI("VERBOSITY", FitPar::Config().GetParI("VERBOSITY") + verbosity_flag);
if (error_flag != 0) FitPar::Config().SetParI("ERROR", FitPar::Config().GetParI("ERROR") + error_flag);
-
return;
};
//*************************************
-void minimizerRoutines::initialSetup(){
+void minimizerRoutines::InitialSetup(){
//*************************************
SetupCovariance();
- // Check if an input file is provided
- if (!inputFileName.empty()) readInputFile();
-
- // Check if fit continues
- if (fitContinue){
-
- // Open previous output file to continue
- inputFileName = outputFileName;
-
- if (!checkPreviousResult()) readInputFile();
- else {return;}
- }
-
// output file open
- outputFile = new TFile(outputFileName.c_str(),"RECREATE");
+ fOutputRootFile = new TFile(fOutputFile.c_str(),"RECREATE");
FitPar::Config().Write();
// setup RW and FCN
- setupRWEngine();
- setupFCN();
+ SetupRWEngine();
+ SetupFCN();
return;
}
//*************************************
-void minimizerRoutines::readCard(){
+void minimizerRoutines::ReadCard(){
//*************************************
std::string line;
- std::ifstream card(this->cardFile.c_str(), ifstream::in);
+ std::ifstream card(this->fCardFile.c_str(), ifstream::in);
while(std::getline(card, line, '\n')){
std::istringstream stream(line);
FitPar::Config().cardLines.push_back(line);
- readParameters(line);
- readFakeDataPars(line);
- readSamples(line);
+ ReadParameters(line);
+ ReadFakeDataPars(line);
+ ReadSamples(line);
}
card.close();
return;
};
//*****************************************
-void minimizerRoutines::readParameters(std::string parstring){
+void minimizerRoutines::ReadParameters(std::string parstring){
//******************************************
std::string token, parname;
std::istringstream stream(parstring); int val = 0;
double entry;
int partype;
std::string curparstate = "";
std::string partype_str = "";
if (parstring.c_str()[0] == '#') return;
-
-
while(std::getline(stream, token, ' ')){
stream >> std::ws;
std::istringstream stoken(token);
if (val > 1 and val < 6) stoken >> entry;
// Allow (parameter name val FIX)
if (val > 2 and val < 6 and token.find("FIX") != std::string::npos) {
- startFixVals[parname] = true;
- fixVals[parname] = true;
+ fStartFixVals[parname] = true;
+ fFixVals[parname] = true;
break;
}
if (val == 0 &&
token.compare("niwg_parameter") &&
token.compare("neut_parameter") &&
token.compare("genie_parameter") &&
token.compare("nuwro_parameter") &&
token.compare("custom_parameter") &&
token.compare("t2k_parameter")) {
return;
} else if (val == 0){
partype_str = token;
if (!token.compare("neut_parameter")) partype = kNEUT;
else if (!token.compare("niwg_parameter")) partype = kNIWG;
else if (!token.compare("genie_parameter")) partype = kGENIE;
else if (!token.compare("nuwro_parameter")) partype = kNUWRO;
else if (!token.compare("custom_parameter")) partype = kCUSTOM;
else if (!token.compare("t2k_parameter")) partype = kT2K;
} else if (val == 1) {
- params.push_back(token);
+ fParams.push_back(token);
parname = token;
// Set Type
- params_type[parname] = partype;
+ fTypeVals[parname] = partype;
// Defaults
- startVals[parname] = 0.0;
- currentVals[parname] = 0.0;
- errorVals[parname] = 0.0;
+ fStartVals[parname] = 0.0;
+ fCurVals[parname] = 0.0;
+ fErrorVals[parname] = 0.0;
- fixVals[parname] = true;
- startFixVals[parname] = true;
- minVals[parname] = -1.0;
- maxVals[parname] = 1.0;
- stepVals[parname] = 0.0;
+ fFixVals[parname] = true;
+ fStartFixVals[parname] = true;
+ fMinVals[parname] = -1.0;
+ fMaxVals[parname] = 1.0;
+ fStepVals[parname] = 0.0;
} else if (val == 2){ // Nominal
- startVals[parname] = entry;
- currentVals[parname] = entry;
- errorVals[parname] = 0.0;
+ fStartVals[parname] = entry;
+ fCurVals[parname] = entry;
+ fErrorVals[parname] = 0.0;
- minVals[parname] = entry - 1.0;
- maxVals[parname] = entry + 1.0;
+ fMinVals[parname] = entry - 1.0;
+ fMaxVals[parname] = entry + 1.0;
- } else if (val == 3){ minVals[parname] = entry; // min
- } else if (val == 4){ maxVals[parname] = entry; // max
- } else if (val == 5){ stepVals[parname] = entry; // step
+ } else if (val == 3){ fMinVals[parname] = entry; // min
+ } else if (val == 4){ fMaxVals[parname] = entry; // max
+ } else if (val == 5){ fStepVals[parname] = entry; // step
} else if (val == 6){ // type
- startFixVals[parname] = ( token.find("FIX") != std::string::npos );
- fixVals[parname] = ( token.find("FIX") != std::string::npos );
+ fStartFixVals[parname] = ( token.find("FIX") != std::string::npos );
+ fFixVals[parname] = ( token.find("FIX") != std::string::npos );
curparstate = token;
} else break;
val++;
}
// Run Dial Conversions
// ABSOLUTE CONVERSION
if (curparstate.find("ABS") != std::string::npos){
- LOG(MIN)<<"Converting abs dial "<<parname<<" : "<<startVals[parname];
- startVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, startVals[parname]);
- currentVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, currentVals[parname]);
- minVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, minVals[parname]);
- maxVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, maxVals[parname]);
- stepVals[parname] = fabs((FitBase::RWAbsToSigma(partype_str, parname, startVals[parname] + stepVals[parname])
- - FitBase::RWAbsToSigma(partype_str, parname, startVals[parname])));
+ LOG(MIN)<<"Converting abs dial "<<parname<<" : "<<fStartVals[parname];
+ fStartVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, fStartVals[parname]);
+ fCurVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, fCurVals[parname]);
+ fMinVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, fMinVals[parname]);
+ fMaxVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, fMaxVals[parname]);
+ fStepVals[parname] = fabs((FitBase::RWAbsToSigma(partype_str, parname, fStartVals[parname] + fStepVals[parname])
+ - FitBase::RWAbsToSigma(partype_str, parname, fStartVals[parname])));
- LOG(MIN)<<" -> "<<startVals[parname]<<std::endl;
+ LOG(MIN)<<" -> "<<fStartVals[parname]<<std::endl;
// FRACTION CONVERSION
} else if (curparstate.find("FRAC") != std::string::npos){
- LOG(FIT)<<"Converting frac dial "<<parname<<" : "<<startVals[parname];
- startVals[parname] = FitBase::RWFracToSigma(partype_str, parname, startVals[parname]);
- currentVals[parname] = FitBase::RWFracToSigma(partype_str, parname, currentVals[parname]);
- minVals[parname] = FitBase::RWFracToSigma(partype_str, parname, minVals[parname]);
- maxVals[parname] = FitBase::RWFracToSigma(partype_str, parname, maxVals[parname]);
- stepVals[parname] = (FitBase::RWFracToSigma(partype_str, parname, stepVals[parname]));
-
-
- LOG(MIN)<<" -> "<<startVals[parname]<<std::endl;
+ LOG(FIT)<<"Converting frac dial "<<parname<<" : "<<fStartVals[parname];
+ fStartVals[parname] = FitBase::RWFracToSigma(partype_str, parname, fStartVals[parname]);
+ fCurVals[parname] = FitBase::RWFracToSigma(partype_str, parname, fCurVals[parname]);
+ fMinVals[parname] = FitBase::RWFracToSigma(partype_str, parname, fMinVals[parname]);
+ fMaxVals[parname] = FitBase::RWFracToSigma(partype_str, parname, fMaxVals[parname]);
+ fStepVals[parname] = (FitBase::RWFracToSigma(partype_str, parname, fStepVals[parname]));
+ LOG(MIN)<<" -> "<<fStartVals[parname]<<std::endl;
}
-
return;
}
void minimizerRoutines::PlotLimits(){
- TDirectory* limfolder = (TDirectory*) outputFile->mkdir("Limits");
+ TDirectory* limfolder = (TDirectory*) fOutputRootFile->mkdir("Limits");
limfolder->cd();
// Set all parameters at their starting values
- for (UInt_t i = 0; i < params.size(); i++){
- currentVals[params[i]] = startVals[params[i]];
- }
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- currentNorms[sampleDials[i]] = sampleNorms[sampleDials[i]];
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ fCurVals[fParams[i]] = fStartVals[fParams[i]];
}
TDirectory* nomfolder = (TDirectory*) limfolder->mkdir("nominal");
nomfolder->cd();
- updateRWEngine(currentVals, currentNorms);
- thisFCN->ReconfigureAllEvents();
- thisFCN->Write();
+ UpdateRWEngine(fCurVals);
+ fSampleFCN->ReconfigureAllEvents();
+ fSampleFCN->Write();
limfolder->cd();
std::vector<std::string> allfolders;
// Loop through each parameter
- for (UInt_t i = 0; i < params.size(); i++){
+ for (UInt_t i = 0; i < fParams.size(); i++){
- if (fixVals[params[i]]) continue;
+ if (fFixVals[fParams[i]]) continue;
- while (currentVals[params[i]] > minVals[params[i]]){
+ while (fCurVals[fParams[i]] > fMinVals[fParams[i]]){
- currentVals[params[i]] = currentVals[params[i]] - stepVals[params[i]];
+ fCurVals[fParams[i]] = fCurVals[fParams[i]] - fStepVals[fParams[i]];
- if (currentVals[params[i]] < minVals[params[i]])
- currentVals[params[i]] = minVals[params[i]];
+ if (fCurVals[fParams[i]] < fMinVals[fParams[i]])
+ fCurVals[fParams[i]] = fMinVals[fParams[i]];
- std::string curvalstring = std::string( Form( (params[i] + "_%f").c_str(), currentVals[params[i]] ) );
+ std::string curvalstring = std::string( Form( (fParams[i] + "_%f").c_str(), fCurVals[fParams[i]] ) );
if (std::find(allfolders.begin(), allfolders.end(), curvalstring) != allfolders.end())
break;
- TDirectory* minfolder = (TDirectory*) limfolder->mkdir(Form( (params[i] + "_%f").c_str(), currentVals[params[i]] ) );
+ TDirectory* minfolder = (TDirectory*) limfolder->mkdir(Form( (fParams[i] + "_%f").c_str(), fCurVals[fParams[i]] ) );
minfolder->cd();
allfolders.push_back(curvalstring);
- updateRWEngine(currentVals, currentNorms);
- thisFCN->ReconfigureAllEvents();
+ UpdateRWEngine(fCurVals);
+ fSampleFCN->ReconfigureAllEvents();
- thisFCN->Write();
+ fSampleFCN->Write();
}
- currentVals[params[i]] = startVals[params[i]];
+ fCurVals[fParams[i]] = fStartVals[fParams[i]];
- while (currentVals[params[i]] < maxVals[params[i]]){
+ while (fCurVals[fParams[i]] < fMaxVals[fParams[i]]){
- currentVals[params[i]] = currentVals[params[i]] + stepVals[params[i]];
+ fCurVals[fParams[i]] = fCurVals[fParams[i]] + fStepVals[fParams[i]];
- if (currentVals[params[i]] > maxVals[params[i]])
- currentVals[params[i]] = maxVals[params[i]];
+ if (fCurVals[fParams[i]] > fMaxVals[fParams[i]])
+ fCurVals[fParams[i]] = fMaxVals[fParams[i]];
- std::string curvalstring = std::string( Form( (params[i] + "_%f").c_str(), currentVals[params[i]] ) );
+ std::string curvalstring = std::string( Form( (fParams[i] + "_%f").c_str(), fCurVals[fParams[i]] ) );
if (std::find(allfolders.begin(), allfolders.end(), curvalstring) != allfolders.end())
break;
- TDirectory* maxfolder = (TDirectory*) limfolder->mkdir(Form( (params[i] + "_%f").c_str(), currentVals[params[i]] ) );
+ TDirectory* maxfolder = (TDirectory*) limfolder->mkdir(Form( (fParams[i] + "_%f").c_str(), fCurVals[fParams[i]] ) );
maxfolder->cd();
allfolders.push_back(curvalstring);
- updateRWEngine(currentVals, currentNorms);
- thisFCN->ReconfigureAllEvents();
+ UpdateRWEngine(fCurVals);
+ fSampleFCN->ReconfigureAllEvents();
- thisFCN->Write();
+ fSampleFCN->Write();
}
- currentVals[params[i]] = startVals[params[i]];
- updateRWEngine(currentVals, currentNorms);
+ fCurVals[fParams[i]] = fStartVals[fParams[i]];
+ UpdateRWEngine(fCurVals);
}
}
//*******************************************
-void minimizerRoutines::readFakeDataPars(std::string parstring){
+void minimizerRoutines::ReadFakeDataPars(std::string parstring){
//******************************************
std::string token, parname;
std::istringstream stream(parstring);
int val = 0;
double entry;
if (parstring.c_str()[0] == '#') return;
-
while(std::getline(stream, token, ' ')){
stream >> std::ws; // strip whitespace
std::istringstream stoken(token);
if (val == 2) stoken >> entry;
- if (val == 0){
- if(token.compare("fake_parameter") != 0) return;
- } else if (val == 1){
- fakeParams.push_back(token);
+ if (val == 0){
+ if(token.compare("fake_parameter") != 0 &&
+ token.compare("fake_norm") != 0) return;
+
+ } else if (val == 1){
parname = token;
+
} else if (val == 2){
-
- fakeVals[parname] = entry;
+ fFakeVals[parname] = entry;
} else {
break;
}
val++;
}
-
- val = 0;
- while(std::getline(stream, token, ' ')){
- stream >> std::ws; // strip whitespace
- std::istringstream stoken(token);
- if (val == 2) stoken >> entry;
-
- if (val == 0 && token.compare("fake_norm") != 0){ return; }
- if (val == 1){
- fakeSamples.push_back(token);
- parname = token;
- } else if (val == 2) fakeNorms[parname] = entry;
-
- val++;
- }
+
return;
}
//******************************************
-void minimizerRoutines::readSamples(std::string sampleString){
+void minimizerRoutines::ReadSamples(std::string sampleString){
//******************************************
std::string token, samplename;
std::istringstream stream(sampleString); int val = 0;
double entry;
if (sampleString.c_str()[0] == '#') return;
while(std::getline(stream, token, ' ')){
stream >> std::ws; // strip whitespace
std::istringstream stoken(token);
stoken >> entry;
if (val == 0){
if (token.compare("sample") != 0){ return; }
} else if (val == 1){
samplename = token + "_norm";
- samples.push_back(token);
- sampleDials.push_back(samplename);
-
- fixNorms[samplename] = true;
- startFixNorms[samplename] = true;
- sampleNorms[samplename] = 1.0;
- currentNorms[samplename] = 1.0;
- errorNorms[samplename] = 1.0;
-
+ fParams.push_back(samplename);
+
+ fTypeVals[samplename] = kNORM;
+ fFixVals[samplename] = true;
+ fStartFixVals[samplename] = true;
+ fStartVals[samplename] = 1.0;
+ fCurVals[samplename] = 1.0;
+ fErrorVals[samplename] = 1.0;
+ fMinVals[samplename] = 0.1;
+ fMaxVals[samplename] = 10.0;
+ fStepVals[samplename] = 0.5;
+
} else if (val == 3) {
- sampleTypes[samplename] = token;
bool fixed = (token.find("FREE") == std::string::npos);
- fixNorms[samplename] = fixed; //fixed;
- startFixNorms[samplename] = fixed; //fixed;
-
- // defaults
- sampleNorms[samplename] = 1.0;
- currentNorms[samplename] = 1.0;
- errorNorms[samplename] = 0.0;
+ fFixVals[samplename] = fixed; //fixed;
+ fStartFixVals[samplename] = fixed; //fixed;
- } else if (val == 2) { sampleFiles[samplename] = token;
+ } else if (val == 2) {
} else if (val == 4){
if (entry > 0.3 and entry < 1.7) {
- sampleNorms[samplename] = entry;
- currentNorms[samplename] = entry;
- errorNorms[samplename] = entry;
+ fStartVals[samplename] = entry;
+ fCurVals[samplename] = entry;
+ fErrorVals[samplename] = entry;
}
}
val++;
}
return;
}
-//*************************************
-void minimizerRoutines::readInputFile(){
-//*************************************
-
- // Read in file
- inputFile = new TFile(inputFileName.c_str(), "READ");
- // Check results
-
- // Set starting vals as previous result
-
- inputFile->Close();
- delete inputFile;
-
- return;
-}
-
-//*************************************
-bool minimizerRoutines::checkPreviousResult(){
-//*************************************
-
- if (inputFile) delete inputFile;
- inputFile = new TFile(inputFileName.c_str(),"READ");
-
- TH1D* fitState = (TH1D*) inputFile->Get("fit_state");
- bool isValidMinimum = false;
-
- if (fitState){
- isValidMinimum = bool(fitState->GetBinContent(1));
- }
-
- inputFile->Close();
- delete inputFile;
-
- return isValidMinimum;
-}
-
/*
Setup Functions
*/
//*************************************
-void minimizerRoutines::setupConfig(){
+void minimizerRoutines::SetupConfig(){
//*************************************
std::string par_dir = std::string(std::getenv("EXT_FIT"))+"/parameters/";
FitPar::Config().ReadParamFile( par_dir + "config.list.dat" );
- FitPar::Config().ReadParamFile( cardFile );
+ FitPar::Config().ReadParamFile( fCardFile );
for (unsigned int iter = 0; iter < configCmdFix.size(); iter++)
FitPar::Config().ForceParam(configCmdFix[iter]);
LOG_VERB(FitPar::Config().GetParS("VERBOSITY"));
ERR_VERB(FitPar::Config().GetParS("VERBOSITY"));
return;
};
//*************************************
-void minimizerRoutines::setupRWEngine(){
+void minimizerRoutines::SetupRWEngine(){
//*************************************
- for (UInt_t i = 0; i < params.size(); i++){
- std::string name = params[i];
- std::cout << "Adding parameter " << name << std::endl;
- FitBase::GetRW() -> IncludeDial(name, params_type.at(name) );
- }
-
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- std::string name = sampleDials[i];
- FitBase::GetRW()->IncludeDial(name, kNORM);
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ std::string name = fParams[i];
+ FitBase::GetRW() -> IncludeDial(name, fTypeVals.at(name) );
}
FitBase::GetRW()->Reconfigure();
- updateRWEngine(startVals, sampleNorms);
+ UpdateRWEngine(fStartVals);
std::cout<<"RW Engines updated"<<std::endl;
return;
}
//*************************************
-void minimizerRoutines::setupFCN(){
+void minimizerRoutines::SetupFCN(){
//*************************************
LOG(FIT)<<"Making the jointFCN"<<std::endl;
- if (thisFCN) delete thisFCN;
- thisFCN = new JointFCN(cardFile, outputFile);
- setFakeData();
+ if (fSampleFCN) delete fSampleFCN;
+ fSampleFCN = new JointFCN(fCardFile, fOutputRootFile);
+ SetFakeData();
- MinFCN = new MinimizerFCN(thisFCN);
- callFCN = new ROOT::Math::Functor( *MinFCN, params.size() + sampleDials.size() );
+ fMinimizerFCN = new MinimizerFCN( fSampleFCN );
+ fCallFunctor = new ROOT::Math::Functor( *fMinimizerFCN, fParams.size() );
- thisFCN->CreateIterationTree("fit_iterations",FitBase::GetRW());
+ fSampleFCN->CreateIterationTree( "fit_iterations", FitBase::GetRW() );
return;
}
//******************************************
-void minimizerRoutines::setupFitter(std::string routine){
+void minimizerRoutines::SetupFitter(std::string routine){
//******************************************
// Make the fitter
std::string fitclass = "";
std::string fittype = "";
-
// Get correct types
if (!routine.compare("Migrad")) { fitclass = "Minuit2"; fittype = "Migrad";
} else if (!routine.compare("Simplex")) { fitclass = "Minuit2"; fittype = "Simplex";
} else if (!routine.compare("Combined")) { fitclass = "Minuit2"; fittype = "Combined";
} else if (!routine.compare("Brute")) { fitclass = "Minuit2"; fittype = "Scan";
} else if (!routine.compare("Fumili")) { fitclass = "Minuit2"; fittype = "Fumili";
} else if (!routine.compare("ConjugateFR")) { fitclass = "GSLMultiMin"; fittype = "ConjugateFR";
} else if (!routine.compare("ConjugatePR")) { fitclass = "GSLMultiMin"; fittype = "ConjugatePR";
} else if (!routine.compare("BFGS")) { fitclass = "GSLMultiMin"; fittype = "BFGS";
} else if (!routine.compare("BFGS2")) { fitclass = "GSLMultiMin"; fittype = "BFGS2";
} else if (!routine.compare("SteepDesc")) { fitclass = "GSLMultiMin"; fittype = "SteepestDescent";
// } else if (!routine.compare("GSLMulti")) { fitclass = "GSLMultiFit"; fittype = ""; // Doesn't work out of the box
} else if (!routine.compare("GSLSimAn")) { fitclass = "GSLSimAn"; fittype = ""; }
-
-
// make minimizer
- if (minimizerObj) delete minimizerObj;
- minimizerObj = ROOT::Math::Factory::CreateMinimizer(fitclass, fittype);
+ if (fMinimizer) delete fMinimizer;
+ fMinimizer = ROOT::Math::Factory::CreateMinimizer(fitclass, fittype);
- minimizerObj->SetMaxFunctionCalls(FitPar::Config().GetParI("minimizer.maxcalls"));
+ fMinimizer->SetMaxFunctionCalls(FitPar::Config().GetParI("minimizer.maxcalls"));
if (!routine.compare("Brute")){
- minimizerObj->SetMaxFunctionCalls(params.size() * params.size()*4);
- minimizerObj->SetMaxIterations(params.size() * params.size()*4);
+ fMinimizer->SetMaxFunctionCalls(fParams.size() * fParams.size()*4);
+ fMinimizer->SetMaxIterations(fParams.size() * fParams.size()*4);
}
- minimizerObj->SetMaxIterations(FitPar::Config().GetParI("minimizer.maxiterations"));
- minimizerObj->SetTolerance(FitPar::Config().GetParD("minimizer.tolerance"));
-
- cout<<"Current Tolerance = "<<FitPar::Config().GetParD("minimizer.tolerance")<<endl;
- cout<<"Current Tolerance 2 = "<<FitPar::Config().GetParD("minimizer.tolerance")<<endl;
- minimizerObj->SetStrategy(FitPar::Config().GetParI("minimizer.strategy"));
- minimizerObj->SetFunction(*callFCN);
+ fMinimizer->SetMaxIterations(FitPar::Config().GetParI("minimizer.maxiterations"));
+ fMinimizer->SetTolerance(FitPar::Config().GetParD("minimizer.tolerance"));
+ fMinimizer->SetStrategy(FitPar::Config().GetParI("minimizer.strategy"));
+ fMinimizer->SetFunction(*fCallFunctor);
int ipar = 0;
//Add Fit Parameters
- for (UInt_t i = 0; i < params.size(); i++){
- std::string systString = params.at(i);
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ std::string systString = fParams.at(i);
bool fixed = true;
double vstart, vstep, vlow, vhigh;
vstart = vstep = vlow = vhigh = 0.0;
- if (currentVals.find(systString) != currentVals.end()) vstart = currentVals.at(systString);
- if (minVals.find(systString) != minVals.end() ) vlow = minVals.at(systString);
- if (maxVals.find(systString) != maxVals.end() ) vhigh = maxVals.at(systString);
- if (stepVals.find(systString) != stepVals.end()) vstep = stepVals.at(systString);
- if (fixVals.find(systString) != fixVals.end() ) fixed = fixVals.at(systString);
+ if (fCurVals.find(systString) != fCurVals.end()) vstart = fCurVals.at(systString);
+ if (fMinVals.find(systString) != fMinVals.end() ) vlow = fMinVals.at(systString);
+ if (fMaxVals.find(systString) != fMaxVals.end() ) vhigh = fMaxVals.at(systString);
+ if (fStepVals.find(systString) != fStepVals.end()) vstep = fStepVals.at(systString);
+ if (fFixVals.find(systString) != fFixVals.end() ) fixed = fFixVals.at(systString);
// fix for errors
if (vhigh == vlow) vhigh += 1.0;
- minimizerObj->SetVariable(ipar, systString, vstart, vstep);
- minimizerObj->SetVariableLimits(ipar,vlow,vhigh);
+ fMinimizer->SetVariable(ipar, systString, vstart, vstep);
+ fMinimizer->SetVariableLimits(ipar,vlow,vhigh);
if (fixed) {
- minimizerObj->FixVariable(ipar);
+ fMinimizer->FixVariable(ipar);
LOG(FIT) << "Fixed Param: "<<systString<<std::endl;
} else {
LOG(FIT) << "Free Param: "<<systString<<" Start:"<<vstart<<" Range:"<<vlow<<" to "<<vhigh<<" Step:"<<vstep<<std::endl;
}
ipar++;
}
- // Add sample norms
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- std::string sampString = sampleDials.at(i);
-
- bool fixed = true;
- double vnorm;
-
- if (currentNorms.find(sampString) != currentNorms.end()) vnorm = currentNorms.at(sampString);
- else {
- currentNorms[sampString] = 1.0;
- vnorm = 1.0;
- }
-
- if (fixNorms.find(sampString) != fixNorms.end()) fixed = fixNorms.at(sampString);
-
- minimizerObj->SetVariable(ipar, sampString, vnorm, 0.1);
- minimizerObj->SetVariableLimits(ipar,0.3, 2.0);
-
- if (fixed) {
- minimizerObj->FixVariable(ipar);
- LOG(FIT) << "Fixed Param: "<<sampString<<std::endl;
- } else {
- LOG(FIT) << "Free Param: "<<sampString<<" Start:"<<vnorm<<" Range:"<<0.3<<"-"<<2.0<<" Step:"<<0.1<<std::endl;
- }
-
- ipar++;
- }
-
- LOG(FIT) << "Setup Minimizer: "<<minimizerObj->NDim()<<"(NDim) "<<minimizerObj->NFree()<<"(NFree)"<<std::endl;
+ LOG(FIT) << "Setup Minimizer: "<<fMinimizer->NDim()<<"(NDim) "<<fMinimizer->NFree()<<"(NFree)"<<std::endl;
return;
}
//*************************************
-void minimizerRoutines::setFakeData(){
+void minimizerRoutines::SetFakeData(){
//*************************************
- if (fakeDataFile.empty()) return;
+ if (fFakeDataInput.empty()) return;
- if (fakeDataFile.compare("MC") == 0){
+ if (fFakeDataInput.compare("MC") == 0){
LOG(FIT)<<"Setting fake data from MC starting prediction." <<std::endl;
- updateRWEngine(fakeVals, fakeNorms);
+ UpdateRWEngine(fFakeVals);
FitBase::GetRW()->Reconfigure();
- thisFCN->ReconfigureAllEvents();
- // thisFCN->SetFakeData("MC");
+ fSampleFCN->ReconfigureAllEvents();
+ //fSampleFCN->SetFakeData("MC");
- updateRWEngine(currentVals, currentNorms);
+ UpdateRWEngine(fCurVals);
LOG(FIT)<<"Set all data to fake MC predictions."<<std::endl;
} else {
- // thisFCN->SetFakeData(fakeDataFile);
+ // fSampleFCN->SetFakeData(fFakeDataInput);
}
return;
}
/*
Fitting Functions
*/
//*************************************
-void minimizerRoutines::updateRWEngine(std::map<std::string,double>& updateVals, std::map<std::string,double>& updateNorms){
+void minimizerRoutines::UpdateRWEngine(std::map<std::string,double>& updateVals){
//*************************************
- for (UInt_t i = 0; i < params.size(); i++){
- std::string name = params[i];
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ std::string name = fParams[i];
if (updateVals.find(name) == updateVals.end()) continue;
FitBase::GetRW()->SetDialValue(name,updateVals.at(name));
}
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- std::string name = sampleDials[i];
-
- if (updateNorms.find(name) == updateNorms.end()){
- FitBase::GetRW()->SetDialValue(name, 1.0);
- } else {
- FitBase::GetRW()->SetDialValue(name, updateNorms.at(name));
- }
- }
-
FitBase::GetRW()->Reconfigure();
return;
}
//****************************
-void minimizerRoutines::SelfFit(){
+void minimizerRoutines::Run(){
//*************
- for (UInt_t i = 0; i < fit_routines.size(); i++){
+ for (UInt_t i = 0; i < fRoutines.size(); i++){
- std::string routine = fit_routines.at(i);
+ std::string routine = fRoutines.at(i);
LOG(FIT)<<"Running Routine: "<<routine<<std::endl;
if (routine.find("LowStat") != std::string::npos) LowStatRoutine(routine);
else if (routine.find("PlotLimits") != std::string::npos) PlotLimits();
else if (routine.find("ErrorBands") != std::string::npos) GenerateErrorBands();
else RunFitRoutine(routine);
}
return;
}
//*************************************
void minimizerRoutines::RunFitRoutine(std::string routine){
//*************************************
// Run Fix at Limit before fitter setup if required
if (routine == "FixAtLim"){ FixAtLimit(); return; }
// set fitter at the current start values
- setupFitter(routine);
- outputFile->cd();
+ SetupFitter(routine);
+ fOutputRootFile->cd();
// choose what to do with the minimizer depending on routine.
if (!routine.compare("Migrad") or
!routine.compare("Simplex") or
!routine.compare("Combined") or
!routine.compare("Brute") or
!routine.compare("Fumili") or
!routine.compare("ConjugateFR") or
!routine.compare("ConjugatePR") or
!routine.compare("BFGS") or
!routine.compare("BFGS2") or
!routine.compare("SteepDesc") or
// !routine.compare("GSLMulti") or
!routine.compare("GSLSimAn")) {
- if (minimizerObj->NFree() > 0){
- std::cout<<"Starting routine " << routine << std::endl;
- std::cout << StatusMessage(minimizerObj->Minimize()) << std::endl;
- std::cout<<"Getting State"<<std::endl;
- getMinimizerState();
+ if (fMinimizer->NFree() > 0){
+ std::cout << StatusMessage(fMinimizer->Minimize()) << std::endl;
+ GetMinimizerState();
}
}
// other otptions
else if (!routine.compare("Chi2Scan1D")) Create1DScans();
else if (!routine.compare("Chi2Scan2D")) Chi2Scan2D();
else if (!routine.compare("Contour")) CreateContours();
}
//*************************************
-void minimizerRoutines::getMinimizerState(){
+void minimizerRoutines::GetMinimizerState(){
//*************************************
LOG(FIT) << "Minimizer State: "<<std::endl;
// Get X and Err
- const double *values = minimizerObj->X();
- const double *errors = minimizerObj->Errors();
+ const double *values = fMinimizer->X();
+ const double *errors = fMinimizer->Errors();
int ipar = 0;
LOG(FIT) << " # " << left << setw(30) << "Parameter "
<< " = "
<< setw(10) << "Value" << " +- "
<< setw(10) << "Error" << " "
<< setw(8) << "Units" << " (Sigma Variation) "<<std::endl;
// loop through parameters and get the values
- for (UInt_t i = 0; i < params.size(); i++){
- std::string systString = params.at(i);
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ std::string systString = fParams.at(i);
- currentVals.at(systString) = values[ipar];
+ fCurVals.at(systString) = values[ipar];
std::ostringstream curparstring;
curparstring << " " << setw(2) << left
<< ipar << ". "
<< setw(30) << systString << " = ";
std::string curunits = "";//rw->GetUnits(systString);
std::ostringstream ss;
curparstring << setw(10) << 0.0 ;//rw->ConvertSigmaToValue(systString, values[ipar]);
- if (fixVals.at(systString)){
+ if (fFixVals.at(systString)){
curparstring << " " << setw(10) << " " << setw(8) << curunits << " (Fixed)";
- errorVals.at(systString) = 0.0;
+ fErrorVals.at(systString) = 0.0;
} else {
double err = 0.0; //rw->ConvertSigmaToValue(systString, values[ipar]+errors[ipar]) - rw->ConvertSigmaToValue(systString, values[ipar]);
curparstring << " +- " << setw(10) << err;
curparstring << " " << setw(8) << curunits;
if (curunits.compare("Sig.")) curparstring << " (" << values[ipar] << " +- "<< errors[ipar] <<")";
- errorVals.at(systString) = errors[ipar];
+ fErrorVals.at(systString) = errors[ipar];
}
LOG(FIT) << curparstring.str() <<std::endl;
ipar++;
}
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- std::string sampString = sampleDials.at(i);
-
- currentNorms.at(sampString) = values[ipar];
-
- std::ostringstream curparstring;
- curparstring << " " << left << setw(2) << ipar << ". " << setw(30) << sampString << " = ";
-
- curparstring << setw(10) << values[ipar];
-
- if (fixNorms.at(sampString)){
-
- curparstring << " " << setw(10) << " "<<setw(8) << "Frac. " << " (Fixed)";
- errorNorms.at(sampString) = 0.0;
-
- } else {
-
- curparstring << " +- " << setw(10) << errors[ipar] << " " << setw(8) << "Frac. ";
- errorNorms.at(sampString) = errors[ipar];
-
- }
- LOG(FIT)<<curparstring.str()<<std::endl;
- ipar++;
- }
LOG(FIT)<<"------------"<<std::endl;
return;
};
//*************************************
void minimizerRoutines::LowStatRoutine(std::string routine){
//*************************************
LOG(FIT) << "Running Low Statistics Routine: "<<routine<<std::endl;
int lowstatsevents = FitPar::Config().GetParI("LOWSTATEVENTS");
int maxevents = FitPar::Config().GetParI("MAXEVENTS");
int verbosity = FitPar::Config().GetParI("VERBOSITY");
std::string trueroutine = routine;
std::string substring = "LowStat";
trueroutine.erase( trueroutine.find(substring),
substring.length() );
// Set MAX EVENTS=1000
FitPar::Config().SetParI("MAXEVENTS",lowstatsevents);
FitPar::Config().SetParI("VERBOSITY",3);
- setupFCN();
+ SetupFCN();
RunFitRoutine(trueroutine);
FitPar::Config().SetParI("MAXEVENTS",maxevents);
- setupFCN();
+ SetupFCN();
FitPar::Config().SetParI("VERBOSITY",verbosity);
return;
}
//*************************************
void minimizerRoutines::Create1DScans(){
//*************************************
// At the current point create a 1D Scan for all parametes (Uncorrelated)
- for (UInt_t i = 0; i < params.size(); i++){
+ for (UInt_t i = 0; i < fParams.size(); i++){
- if (fixVals[params[i]]) continue;
+ if (fFixVals[fParams[i]]) continue;
- double scanmiddlepoint = currentVals[params[i]];
+ double scanmiddlepoint = fCurVals[fParams[i]];
// Determine N points needed
- double limlow = minVals[params[i]];
- double limhigh = maxVals[params[i]];
- double step = stepVals[params[i]];
+ double limlow = fMinVals[fParams[i]];
+ double limhigh = fMaxVals[fParams[i]];
+ double step = fStepVals[fParams[i]];
int npoints = int( fabs(limhigh - limlow)/(step+0.) );
int count = 0;
double* xvals;
double* yvals;
xvals = new double[npoints];
yvals = new double[npoints];
// Set Start Point
- currentVals[params[i]] = limlow;
- updateRWEngine(currentVals, currentNorms);
- thisFCN->ReconfigureAllEvents();
+ fCurVals[fParams[i]] = limlow;
+ UpdateRWEngine(fCurVals);
+ fSampleFCN->ReconfigureAllEvents();
// Loop over scan points
- while (currentVals[params[i]] < limhigh){
+ while (fCurVals[fParams[i]] < limhigh){
// Update Prediction
- updateRWEngine(currentVals, currentNorms);
- thisFCN->ReconfigureAllEvents();
+ UpdateRWEngine(fCurVals);
+ fSampleFCN->ReconfigureAllEvents();
// Fill Graph Points
- yvals[count] = thisFCN->GetLikelihood();
- xvals[count] = currentVals[params[i]];
+ yvals[count] = fSampleFCN->GetLikelihood();
+ xvals[count] = fCurVals[fParams[i]];
- std::cout<<"Current Vals = "<<currentVals[params[i]]<<" = "<<yvals[count]<<std::endl;
+ std::cout<<"Current Vals = "<<fCurVals[fParams[i]]<<" = "<<yvals[count]<<std::endl;
// Get Next par set
- currentVals[params[i]] += step;
+ fCurVals[fParams[i]] += step;
count++;
}
// Save Graph
TGraph* scanGraph = new TGraph(count, xvals, yvals);
- scanGraph->Write(params[i].c_str());
+ scanGraph->Write(fParams[i].c_str());
// Reset Parameter
- currentVals[params[i]] = scanmiddlepoint;
+ fCurVals[fParams[i]] = scanmiddlepoint;
delete scanGraph;
delete xvals;
delete yvals;
}
return;
}
//*************************************
void minimizerRoutines::Chi2Scan2D(){
//*************************************
// Scan I
- for (UInt_t i = 0; i < params.size(); i++){
- if (fixVals[params[i]]) continue;
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ if (fFixVals[fParams[i]]) continue;
// Scan J
- for (UInt_t j = 0; j < params.size(); j++){
- if (fixVals[params[j]]) continue;
+ for (UInt_t j = 0; j < fParams.size(); j++){
+ if (fFixVals[fParams[j]]) continue;
- if (params[i] == params[j]) continue;
+ if (fParams[i] == fParams[j]) continue;
- double scanmid_i = currentVals[params[i]];
- double scanmid_j = currentVals[params[j]];
+ double scanmid_i = fCurVals[fParams[i]];
+ double scanmid_j = fCurVals[fParams[j]];
- double limlow_i = minVals[params[i]];
- double limhigh_i = maxVals[params[i]];
- double step_i = stepVals[params[i]];
+ double limlow_i = fMinVals[fParams[i]];
+ double limhigh_i = fMaxVals[fParams[i]];
+ double step_i = fStepVals[fParams[i]];
- double limlow_j = minVals[params[j]];
- double limhigh_j = maxVals[params[j]];
- double step_j = stepVals[params[j]];
+ double limlow_j = fMinVals[fParams[j]];
+ double limhigh_j = fMaxVals[fParams[j]];
+ double step_j = fStepVals[fParams[j]];
int npoints_i = int( fabs(limhigh_i - limlow_i)/(step_i+0.) ) + 1;
int npoints_j = int( fabs(limhigh_j - limlow_j)/(step_j+0.) ) + 1;
TH2D* contour = new TH2D("countour","countour",
npoints_i, limlow_i, limhigh_i,
npoints_j, limlow_j, limhigh_j );
- contour->GetXaxis()->SetTitle(params[i].c_str());
- contour->GetYaxis()->SetTitle(params[j].c_str());
+ contour->GetXaxis()->SetTitle(fParams[i].c_str());
+ contour->GetYaxis()->SetTitle(fParams[j].c_str());
- cout<<"Running scan for "<<params[i]<<" "<<params[j]<<endl;
+ cout<<"Running scan for "<<fParams[i]<<" "<<fParams[j]<<endl;
// Fill bins
for (int x = 0; x < contour->GetNbinsX(); x++){
// Set X Val
- currentVals[params[i]] = contour->GetXaxis()->GetBinCenter(x+1);
- cout<<"Set Value i "<<currentVals[params[i]]<<endl;
+ fCurVals[fParams[i]] = contour->GetXaxis()->GetBinCenter(x+1);
+ cout<<"Set Value i "<<fCurVals[fParams[i]]<<endl;
// Loop Y
for (int y = 0; y < contour->GetNbinsY(); y++){
// Set Y Val
- currentVals[params[j]] = contour->GetYaxis()->GetBinCenter(y+1);
- cout<<"Set Value j "<<currentVals[params[j]]<<endl;
+ fCurVals[fParams[j]] = contour->GetYaxis()->GetBinCenter(y+1);
+ cout<<"Set Value j "<<fCurVals[fParams[j]]<<endl;
// Reconfigure
- updateRWEngine(currentVals, currentNorms);
- thisFCN->ReconfigureAllEvents();
+ UpdateRWEngine(fCurVals);
+ fSampleFCN->ReconfigureAllEvents();
// Chi2
- double chi2 = thisFCN->GetLikelihood();
+ double chi2 = fSampleFCN->GetLikelihood();
// Fill Contour
contour->SetBinContent(x+1,y+1, chi2);
cout<<"Filling "<<x<<" "<<y<<" "<<chi2<<endl;
- currentVals[params[j]] = scanmid_j;
+ fCurVals[fParams[j]] = scanmid_j;
}
- currentVals[params[i]] = scanmid_i;
- currentVals[params[j]] = scanmid_j;
+ fCurVals[fParams[i]] = scanmid_i;
+ fCurVals[fParams[j]] = scanmid_j;
}
// Save contour
contour->Write();
}
}
return;
}
//*************************************
void minimizerRoutines::CreateContours(){
//*************************************
// Use MINUIT for this if possible
return;
}
//*************************************
void minimizerRoutines::FixAtLimit(){
//*************************************
- for (UInt_t i = 0; i < params.size(); i++){
- std::string systString = params.at(i);
- if (fixVals[systString]) continue;
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ std::string systString = fParams.at(i);
+ if (fFixVals[systString]) continue;
- double curVal = currentVals.at(systString);
- double minVal = minVals.at(systString);
- double maxVal = minVals.at(systString);
+ double curVal = fCurVals.at(systString);
+ double minVal = fMinVals.at(systString);
+ double maxVal = fMinVals.at(systString);
if (fabs(curVal - minVal) < 0.0001){
- currentVals.at(systString) = minVal;
+ fCurVals.at(systString) = minVal;
}
if (fabs(maxVal - curVal) < 0.0001){
- currentVals.at(systString) = maxVal;
+ fCurVals.at(systString) = maxVal;
}
}
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- std::string sampString = sampleDials.at(i);
- if (fixNorms[sampString]) continue;
-
- double curVal = currentNorms.at(sampString);
- double minVal = 0.3;
- double maxVal = 2.0;
-
- if (fabs(curVal - minVal) < 0.0001){
- currentVals.at(sampString) = minVal;
- }
-
- if (fabs(maxVal - curVal) < 0.0001){
- currentVals.at(sampString) = maxVal;
- }
- }
return;
}
/*
Write Functions
*/
//*************************************
-void minimizerRoutines::saveFitterOutput(std::string dir){
+void minimizerRoutines::SaveFitterOutput(std::string dir){
//*************************************
if (!dir.empty()){
- TDirectory* nominalDIR =(TDirectory*) outputFile->mkdir(dir.c_str());
+ TDirectory* nominalDIR =(TDirectory*) fOutputRootFile->mkdir(dir.c_str());
nominalDIR->cd();
}
- if (minimizerObj){
- saveMinimizerState();
+ if (fMinimizer){
+ SaveMinimizerState();
}
- saveCurrentState();
+ SaveCurrentState();
- outputFile->cd();
+ fOutputRootFile->cd();
return;
}
//*************************************
-void minimizerRoutines::saveMinimizerState(){
+void minimizerRoutines::SaveMinimizerState(){
//*************************************
- if (!minimizerObj) return;
+ if (!fMinimizer) return;
- thisFCN->WriteIterationTree();
+ fSampleFCN->WriteIterationTree();
- // Get Values and Errors
- getMinimizerState();
- outputFile->cd();
+ // Get Vals and Errors
+ GetMinimizerState();
+ fOutputRootFile->cd();
// Save tree with fit status
std::vector<std::string> nameVect;
std::vector<double> valVect;
std::vector<double> errVect;
std::vector<double> minVect;
std::vector<double> maxVect;
std::vector<double> startVect;
std::vector<int> endfixVect;
std::vector<int> startfixVect;
- // int NFREEPARS = minimizerObj->NFree();
- int NPARS = minimizerObj->NDim();
+ // int NFREEPARS = fMinimizer->NFree();
+ int NPARS = fMinimizer->NDim();
int ipar = 0;
- // Dial Values
- for (UInt_t i = 0; i < params.size(); i++){
- std::string name = params.at(i);
-
- nameVect .push_back(name);
- valVect .push_back(currentVals.at(name));
- errVect .push_back(errorVals.at(name));
- minVect .push_back(minVals.at(name));
- maxVect .push_back(maxVals.at(name));
- startVect .push_back(startVals.at(name));
- endfixVect .push_back(fixVals.at(name));
- startfixVect.push_back(startFixVals.at(name));
+ // Dial Vals
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ std::string name = fParams.at(i);
- ipar++;
- }
+ nameVect .push_back( name );
- // Sample Norms
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- std::string name = sampleDials.at(i);
+ cout << name << endl;
+ valVect .push_back( fCurVals.at(name) );
+ errVect .push_back( fErrorVals.at(name) );
+ minVect .push_back( fMinVals.at(name) );
+ maxVect .push_back( fMaxVals.at(name) );
- nameVect .push_back(name);
- valVect .push_back(currentNorms.at(name));
- errVect .push_back(errorNorms.at(name));
- minVect .push_back(0.3);
- maxVect .push_back(1.7);
- startVect .push_back(sampleNorms.at(name));
- endfixVect .push_back(fixNorms.at(name));
- startfixVect.push_back(startFixNorms.at(name));
+ cout << "MAX " << name << endl;
+ startVect .push_back( fStartVals.at(name) );
+ endfixVect .push_back( fFixVals.at(name) );
+ startfixVect.push_back( fStartFixVals.at(name) );
ipar++;
}
- std::cout << " Vectors " << std::endl;
- int NFREE = minimizerObj->NFree();
- int NDIM = minimizerObj->NDim();
+ int NFREE = fMinimizer->NFree();
+ int NDIM = fMinimizer->NDim();
- double CHI2 = thisFCN->GetLikelihood();
- int NBINS = thisFCN->GetNDOF();
+ double CHI2 = fSampleFCN->GetLikelihood();
+ int NBINS = fSampleFCN->GetNDOF();
int NDOF = NBINS - NFREE;
// Write fit results
TTree* fit_tree = new TTree("fit_result","fit_result");
fit_tree->Branch("parameter_names",&nameVect);
fit_tree->Branch("parameter_values",&valVect);
fit_tree->Branch("parameter_errors",&errVect);
fit_tree->Branch("parameter_min",&minVect);
fit_tree->Branch("parameter_max",&maxVect);
fit_tree->Branch("parameter_start",&startVect);
fit_tree->Branch("parameter_fix",&endfixVect);
fit_tree->Branch("parameter_startfix",&startfixVect);
fit_tree->Branch("CHI2",&CHI2,"CHI2/D");
fit_tree->Branch("NDOF",&NDOF,"NDOF/I");
fit_tree->Branch("NBINS",&NBINS,"NBINS/I");
fit_tree->Branch("NDIM",&NDIM,"NDIM/I");
fit_tree->Branch("NFREE",&NFREE,"NFREE/I");
fit_tree->Fill();
fit_tree->Write();
// Make dial variables
TH1D dialvar = TH1D("fit_dials","fit_dials",NPARS,0,NPARS);
TH1D startvar = TH1D("start_dials","start_dials",NPARS,0,NPARS);
TH1D minvar = TH1D("min_dials","min_dials",NPARS,0,NPARS);
TH1D maxvar = TH1D("max_dials","max_dials",NPARS,0,NPARS);
for (UInt_t i = 0; i < nameVect.size(); i++){
std::string name = nameVect.at(i);
dialvar.SetBinContent(i+1, valVect.at(i));
dialvar.SetBinError(i+1, errVect.at(i));
dialvar.GetXaxis()->SetBinLabel(i+1, name.c_str());
startvar.SetBinContent(i+1, startVect.at(i));
startvar.GetXaxis()->SetBinLabel(i+1, name.c_str());
minvar.SetBinContent(i+1, minVect.at(i));
minvar.GetXaxis()->SetBinLabel(i+1, name.c_str());
maxvar.SetBinContent(i+1, maxVect.at(i));
maxvar.GetXaxis()->SetBinLabel(i+1, name.c_str());
}
// Save Dial Plots
dialvar.Write();
startvar.Write();
minvar.Write();
maxvar.Write();
- // Save TString for cardFile
+ // Save TString for fCardFile
// Save fit_status plot
TH1D statusplot = TH1D("fit_status","fit_status",8,0,8);
std::string fit_labels[8] = {"status", "cov_status", \
"maxiter", "maxfunc", \
"iter", "func", \
"precision", "tolerance"};
double fit_vals[8];
- fit_vals[0] = minimizerObj->Status() + 0.;
- fit_vals[1] = minimizerObj->CovMatrixStatus() + 0.;
- fit_vals[2] = minimizerObj->MaxIterations() + 0.;
- fit_vals[3] = minimizerObj->MaxFunctionCalls()+ 0.;
- fit_vals[4] = minimizerObj->NIterations() + 0.;
- fit_vals[5] = minimizerObj->NCalls() + 0.;
- fit_vals[6] = minimizerObj->Precision() + 0.;
- fit_vals[7] = minimizerObj->Tolerance() + 0.;
+ fit_vals[0] = fMinimizer->Status() + 0.;
+ fit_vals[1] = fMinimizer->CovMatrixStatus() + 0.;
+ fit_vals[2] = fMinimizer->MaxIterations() + 0.;
+ fit_vals[3] = fMinimizer->MaxFunctionCalls()+ 0.;
+ fit_vals[4] = fMinimizer->NIterations() + 0.;
+ fit_vals[5] = fMinimizer->NCalls() + 0.;
+ fit_vals[6] = fMinimizer->Precision() + 0.;
+ fit_vals[7] = fMinimizer->Tolerance() + 0.;
for (int i = 0; i < 8; i++){
statusplot.SetBinContent(i+1, fit_vals[i]);
statusplot.GetXaxis()->SetBinLabel(i+1, fit_labels[i].c_str());
}
statusplot.Write();
- if (minimizerObj->NFree() == 0) return;
+ if (fMinimizer->NFree() == 0) return;
// Sort Covariances
SetupCovariance();
- if (minimizerObj->CovMatrixStatus() > 0){
+ if (fMinimizer->CovMatrixStatus() > 0){
- for (int i = 0; i < covarHist->GetNbinsX(); i++){
- for (int j = 0; j < covarHist->GetNbinsY(); j++){
- covarHist->SetBinContent(i+1,j+1, minimizerObj->CovMatrix(i,j));
+ for (int i = 0; i < fCovar->GetNbinsX(); i++){
+ for (int j = 0; j < fCovar->GetNbinsY(); j++){
+ fCovar->SetBinContent(i+1,j+1, fMinimizer->CovMatrix(i,j));
}
}
int freex = 0;
int freey = 0;
- for (int i = 0; i < covarHist->GetNbinsX(); i++){
+ for (int i = 0; i < fCovar->GetNbinsX(); i++){
freey = 0;
- if (minimizerObj->IsFixedVariable(i)) continue;
+ if (fMinimizer->IsFixedVariable(i)) continue;
- for (int j = 0; j < covarHist->GetNbinsY(); j++){
- if (minimizerObj->IsFixedVariable(j)) continue;
+ for (int j = 0; j < fCovar->GetNbinsY(); j++){
+ if (fMinimizer->IsFixedVariable(j)) continue;
- covarHist_Free->SetBinContent(freex+1,freey+1, minimizerObj->CovMatrix(i,j));
+ fCovarFree->SetBinContent(freex+1,freey+1, fMinimizer->CovMatrix(i,j));
freey++;
}
freex++;
}
}
- correlHist = PlotUtils::GetCorrelationPlot(covarHist,"correlation");
- decompHist = PlotUtils::GetDecompPlot(covarHist,"decomposition");
+ fCorrel = PlotUtils::GetCorrelationPlot(fCovar,"correlation");
+ fDecomp = PlotUtils::GetDecompPlot(fCovar,"decomposition");
- if (NFREE > 0)correlHist_Free = PlotUtils::GetCorrelationPlot(covarHist_Free, "correlation_free");
- if (NFREE > 0)decompHist_Free = PlotUtils::GetDecompPlot(covarHist_Free,"decomposition_free");
+ if (NFREE > 0)fCorrelFree = PlotUtils::GetCorrelationPlot(fCovarFree, "correlation_free");
+ if (NFREE > 0)fDecompFree = PlotUtils::GetDecompPlot(fCovarFree,"decomposition_free");
- if (covarHist) covarHist->Write();
- if (covarHist_Free) covarHist_Free->Write();
- if (correlHist) correlHist->Write();
- if (correlHist_Free) correlHist_Free->Write();
- if (decompHist) decompHist->Write();
- if (decompHist_Free) decompHist_Free->Write();
+ if (fCovar) fCovar->Write();
+ if (fCovarFree) fCovarFree->Write();
+ if (fCorrel) fCorrel->Write();
+ if (fCorrelFree) fCorrelFree->Write();
+ if (fDecomp) fDecomp->Write();
+ if (fDecompFree) fDecompFree->Write();
return;
}
//*************************************
-void minimizerRoutines::saveCurrentState(std::string subdir){
+void minimizerRoutines::SaveCurrentState(std::string subdir){
//*************************************
LOG(FIT)<<"Saving current FCN predictions" <<std::endl;
- outputFile->cd();
+ fOutputRootFile->cd();
FitBase::GetRW()->Reconfigure();
- thisFCN->ReconfigureAllEvents();
+ fSampleFCN->ReconfigureAllEvents();
if (!subdir.empty()){
- TDirectory* nominalDIR =(TDirectory*) outputFile->mkdir("nominal");
+ TDirectory* nominalDIR =(TDirectory*) fOutputRootFile->mkdir("nominal");
nominalDIR->cd();
}
- thisFCN->Write();
+ fSampleFCN->Write();
- outputFile->cd();
+ fOutputRootFile->cd();
return;
}
//*************************************
-void minimizerRoutines::saveNominal(){
+void minimizerRoutines::SaveNominal(){
//*************************************
LOG(FIT)<<"Saving Neut Nominal Predictions (be cautious with this)" <<std::endl;
-
- //rw->ResetAll();
FitBase::GetRW()->Reconfigure();
- saveCurrentState("nominal");
+ SaveCurrentState("nominal");
+
};
//*************************************
-void minimizerRoutines::savePrefit(){
+void minimizerRoutines::SavePrefit(){
//*************************************
LOG(FIT)<<"Saving Prefit Predictions"<<std::endl;
-
- updateRWEngine(startVals, sampleNorms);
- saveCurrentState("prefit");
- updateRWEngine(currentVals, currentNorms);
-
+ UpdateRWEngine(fStartVals);
+ SaveCurrentState("prefit");
+ UpdateRWEngine(fCurVals);
};
/*
MISC Functions
*/
//*************************************
int minimizerRoutines::GetStatus(){
//*************************************
return 0;
}
//*************************************
void minimizerRoutines::SetupCovariance(){
//*************************************
// Remove covares if they exist
- if (covarHist) delete covarHist;
- if (covarHist_Free) delete covarHist_Free;
- if (correlHist) delete correlHist;
- if (correlHist_Free) delete correlHist_Free;
- if (decompHist) delete decompHist;
- if (decompHist_Free) delete decompHist_Free;
+ if (fCovar) delete fCovar;
+ if (fCovarFree) delete fCovarFree;
+ if (fCorrel) delete fCorrel;
+ if (fCorrelFree) delete fCorrelFree;
+ if (fDecomp) delete fDecomp;
+ if (fDecompFree) delete fDecompFree;
int NFREE = 0;
int NDIM = 0;
// Get NFREE from min or from vals (for cases when doing throws)
- if (minimizerObj){
- NFREE = minimizerObj->NFree();
- NDIM = minimizerObj->NDim();
+ if (fMinimizer){
+ NFREE = fMinimizer->NFree();
+ NDIM = fMinimizer->NDim();
} else {
- NDIM = params.size() + sampleDials.size();
- for (UInt_t i = 0; i < params.size(); i++){
- if (!fixVals[params[i]]) NFREE++;
- }
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- if (!fixNorms[sampleDials[i]]) NFREE++;
+ NDIM = fParams.size();
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ if (!fFixVals[fParams[i]]) NFREE++;
}
}
if (NDIM == 0) return;
- covarHist = new TH2D("covariance","covariance",NDIM,0,NDIM,NDIM,0,NDIM);
+ fCovar = new TH2D("covariance","covariance",NDIM,0,NDIM,NDIM,0,NDIM);
if (NFREE > 0){
- covarHist_Free = new TH2D("covariance_free",
+ fCovarFree = new TH2D("covariance_free",
"covariance_free",
NFREE,0,NFREE,
NFREE,0,NFREE);
}
// Set Bin Labels
int countall = 0;
int countfree = 0;
- for (UInt_t i = 0; i < params.size(); i++){
-
- covarHist->GetXaxis()->SetBinLabel(countall+1,params[i].c_str());
- covarHist->GetYaxis()->SetBinLabel(countall+1,params[i].c_str());
- countall++;
-
- if (!fixVals[params[i]] and NFREE > 0){
- covarHist_Free->GetXaxis()->SetBinLabel(countfree+1,params[i].c_str());
- covarHist_Free->GetYaxis()->SetBinLabel(countfree+1,params[i].c_str());
- countfree++;
- }
- }
-
- for (UInt_t i = 0; i < sampleDials.size(); i++){
-
- covarHist->GetXaxis()->SetBinLabel(countall+1,sampleDials[i].c_str());
- covarHist->GetYaxis()->SetBinLabel(countall+1,sampleDials[i].c_str());
- countall++;
-
- if (!fixNorms[sampleDials[i]] and NFREE > 0){
- covarHist_Free->GetXaxis()->SetBinLabel(countfree+1,sampleDials[i].c_str());
- covarHist_Free->GetYaxis()->SetBinLabel(countfree+1,sampleDials[i].c_str());
- countfree++;
- }
- }
-
-
-
- // Fill Input Covariances
- for (UInt_t i = 0; i < input_covariances.size(); i++){
- TH2D covplot = input_covariances.at(i);
-
- for(Int_t i = 0; i < covplot.GetNbinsX(); i++){
- for (Int_t j = 0; j < covplot.GetNbinsY(); j++){
-
- std::string parx = covplot.GetXaxis()->GetBinLabel(i+1);
- std::string pary = covplot.GetYaxis()->GetBinLabel(j+1);
-
- for (Int_t k = 0; k < covarHist->GetNbinsX(); k++){
- for (Int_t l = 0; l < covarHist->GetNbinsY(); l++){
-
- if (!parx.compare(covarHist->GetXaxis()->GetBinLabel(k+1)) and
- !pary.compare(covarHist->GetYaxis()->GetBinLabel(l+1)))
-
- covarHist->SetBinContent(k+1,l+1, covarHist->GetBinContent(k+1,l+1) + covplot.GetBinContent(i+1,k+1));
-
- }
- }
-
- for (Int_t k = 0; k < covarHist_Free->GetNbinsX(); k++){
- for (Int_t l = 0; l < covarHist_Free->GetNbinsY(); l++){
-
- if (!parx.compare(covarHist_Free->GetXaxis()->GetBinLabel(k+1)) and
- !pary.compare(covarHist_Free->GetYaxis()->GetBinLabel(l+1))){
-
- covarHist_Free->SetBinContent(k+1,l+1, covarHist_Free->GetBinContent(k+1,l+1) + covplot.GetBinContent(i+1,j+1));
- }
- }
- }
- }
- }
- }
-
- // Setup Current Vals due to covariance inputs now as well
- for (UInt_t i = 0; i < input_dials.size(); i++){
- TH1D* plot = input_dials.at(i);
-
- for (Int_t j = 0; j < plot->GetNbinsX(); j++){
- std::string parname = std::string(plot->GetXaxis()->GetBinLabel(j+1));
-
- if (currentVals.find(parname) != currentVals.end()) currentVals[parname] = plot->GetBinContent(j+1);
- else if (currentNorms.find(parname) != currentNorms.end()) currentNorms[parname] = plot->GetBinContent(j+1);
-
- }
- }
-
- // Final Step Setting
- countall = 0;
- countfree = 0;
- for (UInt_t i = 0; i < params.size(); i++){
-
- double stepsq = stepVals[params[i]] * stepVals[params[i]];
-
- if (!fixVals[params[i]] and covarHist->GetBinContent(countall+1,countall+1) == 0.0)
- covarHist->SetBinContent(countall+1,countall+1,stepsq);
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ fCovar->GetXaxis()->SetBinLabel(countall+1,fParams[i].c_str());
+ fCovar->GetYaxis()->SetBinLabel(countall+1,fParams[i].c_str());
countall++;
- if (!fixVals[params[i]] and NFREE > 0){
- if (covarHist_Free->GetBinContent(countfree+1,countfree+1) == 0.0)
- covarHist_Free->SetBinContent(countfree+1,countfree+1,stepsq);
+ if (!fFixVals[fParams[i]] and NFREE > 0){
+ fCovarFree->GetXaxis()->SetBinLabel(countfree+1,fParams[i].c_str());
+ fCovarFree->GetYaxis()->SetBinLabel(countfree+1,fParams[i].c_str());
countfree++;
}
}
+ fCorrel = PlotUtils::GetCorrelationPlot(fCovar,"correlation");
+ fDecomp = PlotUtils::GetDecompPlot(fCovar,"decomposition");
- for (UInt_t i = 0; i < sampleDials.size(); i++){
-
- double stepsq = 0.1*0.1;
-
- if (!fixNorms[sampleDials[i]] and covarHist->GetBinContent(countall+1,countall+1) == 0.0)
- covarHist->SetBinContent(countall+1,countall+1,stepsq);
-
- countall++;
-
- if (!fixNorms[sampleDials[i]] and NFREE > 0){
-
- if (covarHist_Free->GetBinContent(countfree+1,countfree+1) == 0.0)
- covarHist_Free->SetBinContent(countfree+1,countfree+1,stepsq);
-
- countfree++;
- }
- }
-
- correlHist = PlotUtils::GetCorrelationPlot(covarHist,"correlation");
- decompHist = PlotUtils::GetDecompPlot(covarHist,"decomposition");
-
- if (NFREE > 0)correlHist_Free = PlotUtils::GetCorrelationPlot(covarHist_Free, "correlation_free");
- if (NFREE > 0)decompHist_Free = PlotUtils::GetDecompPlot(covarHist_Free,"decomposition_free");
+ if (NFREE > 0)fCorrelFree = PlotUtils::GetCorrelationPlot(fCovarFree, "correlation_free");
+ if (NFREE > 0)fDecompFree = PlotUtils::GetDecompPlot(fCovarFree,"decomposition_free");
return;
};
//*************************************
void minimizerRoutines::ThrowCovariance(bool uniformly){
//*************************************
std::vector<double> rands;
- if (!decompHist_Free) {
+ if (!fDecompFree) {
ERR(WRN) << "Trying to throw 0 free parameters"<<std::endl;
return;
}
- for (Int_t i = 0; i < decompHist_Free->GetNbinsX(); i++){
+ for (Int_t i = 0; i < fDecompFree->GetNbinsX(); i++){
rands.push_back(gRandom->Gaus(0.0,1.0));
}
- for (UInt_t i = 0; i < params.size(); i++){
- thrownVals[params[i]] = currentVals[params[i]];
- }
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- thrownNorms[sampleDials[i]] = currentNorms[sampleDials[i]];
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ fThrownVals[fParams[i]] = fCurVals[fParams[i]];
}
- for (Int_t i = 0; i < decompHist_Free->GetNbinsX(); i++){
+ for (Int_t i = 0; i < fDecompFree->GetNbinsX(); i++){
- std::string parname = std::string(decompHist_Free->GetXaxis()->GetBinLabel(i+1));
+ std::string parname = std::string(fDecompFree->GetXaxis()->GetBinLabel(i+1));
double mod = 0.0;
if (!uniformly){
- for (Int_t j = 0; j < decompHist_Free->GetNbinsY(); j++){
- mod += rands[j] * decompHist_Free->GetBinContent(j+1,i+1);
+ for (Int_t j = 0; j < fDecompFree->GetNbinsY(); j++){
+ mod += rands[j] * fDecompFree->GetBinContent(j+1,i+1);
}
}
- if (currentVals.find(parname) != currentVals.end()) {
-
- if (uniformly) thrownVals[parname] = gRandom->Uniform(minVals[parname],maxVals[parname]);
- else { thrownVals[parname] = currentVals[parname] + mod; }
-
- } else if (currentNorms.find(parname) != currentNorms.end()){
+ if (fCurVals.find(parname) != fCurVals.end()) {
- if (uniformly) thrownNorms[parname] = gRandom->Uniform(1.0, 0.7);
- else thrownNorms[parname] = currentNorms[parname]+ mod;
+ if (uniformly) fThrownVals[parname] = gRandom->Uniform(fMinVals[parname],fMaxVals[parname]);
+ else { fThrownVals[parname] = fCurVals[parname] + mod; }
}
}
- for (UInt_t i = 0; i < params.size(); i++){
- if (thrownVals[params[i]] < minVals[params[i]]) thrownVals[params[i]] = minVals[params[i]];
- if (thrownVals[params[i]] > maxVals[params[i]]) thrownVals[params[i]] = maxVals[params[i]];
- }
-
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- if (thrownNorms[sampleDials[i]] < 0.3) thrownNorms[sampleDials[i]] = 0.3;
- if (thrownNorms[sampleDials[i]] > 1.7) thrownNorms[sampleDials[i]] = 1.7;
+ for (UInt_t i = 0; i < fParams.size(); i++){
+ if (fThrownVals[fParams[i]] < fMinVals[fParams[i]]) fThrownVals[fParams[i]] = fMinVals[fParams[i]];
+ if (fThrownVals[fParams[i]] > fMaxVals[fParams[i]]) fThrownVals[fParams[i]] = fMaxVals[fParams[i]];
}
return;
};
//*************************************
void minimizerRoutines::GenerateErrorBands(){
//*************************************
- TDirectory* errorDIR = (TDirectory*) outputFile->mkdir("error_bands");
+ TDirectory* errorDIR = (TDirectory*) fOutputRootFile->mkdir("error_bands");
errorDIR->cd();
- TFile* tempfile = new TFile((outputFileName + ".throws.root").c_str(),"RECREATE");
+ TFile* tempfile = new TFile((fOutputFile + ".throws.root").c_str(),"RECREATE");
tempfile->cd();
int nthrows = FitPar::Config().GetParI("error_throws");
- updateRWEngine(currentVals, currentNorms);
- thisFCN->ReconfigureAllEvents();
+ UpdateRWEngine(fCurVals);
+ fSampleFCN->ReconfigureAllEvents();
TDirectory* nominal = (TDirectory*) tempfile->mkdir("nominal");
nominal->cd();
- thisFCN->Write();
+ fSampleFCN->Write();
- TDirectory* outnominal = (TDirectory*) outputFile->mkdir("nominal_throw");
+ TDirectory* outnominal = (TDirectory*) fOutputRootFile->mkdir("nominal_throw");
outnominal->cd();
- thisFCN->Write();
+ fSampleFCN->Write();
errorDIR->cd();
TTree* parameterTree = new TTree("throws","throws");
double chi2;
- for (UInt_t i = 0; i < params.size(); i++)
- parameterTree->Branch(params[i].c_str(), &thrownVals[params[i]], (params[i] + "/D").c_str());
- for (UInt_t i = 0; i < sampleDials.size(); i++)
- parameterTree->Branch(sampleDials[i].c_str(), &thrownNorms[sampleDials[i]], (sampleDials[i] + "/D").c_str());
+ for (UInt_t i = 0; i < fParams.size(); i++)
+ parameterTree->Branch(fParams[i].c_str(), &fThrownVals[fParams[i]], (fParams[i] + "/D").c_str());
parameterTree->Branch("chi2",&chi2,"chi2/D");
bool uniformly = FitPar::Config().GetParB("error_uniform");
// Run Throws and save
for (Int_t i = 0; i < nthrows; i++){
TDirectory* throwfolder = (TDirectory*)tempfile->mkdir(Form("throw_%i",i));
throwfolder->cd();
ThrowCovariance(uniformly);
- updateRWEngine(thrownVals, thrownNorms);
- thisFCN->ReconfigureAllEvents();
- thisFCN->Write();
- chi2 = thisFCN->GetLikelihood();
+ UpdateRWEngine(fThrownVals);
+ fSampleFCN->ReconfigureAllEvents();
+ fSampleFCN->Write();
+ chi2 = fSampleFCN->GetLikelihood();
parameterTree->Fill();
}
errorDIR->cd();
- decompHist_Free->Write();
- covarHist_Free->Write();
+ fDecompFree->Write();
+ fCovarFree->Write();
parameterTree->Write();
for (UInt_t i = 0; i < input_covariances.size(); i++){
input_covariances.at(i).Write();
}
delete parameterTree;
// Now go through the keys in the temporary file and look for TH1D, and TH2D plots
TIter next(nominal->GetListOfKeys());
TKey *key;
while ((key = (TKey*)next())) {
TClass *cl = gROOT->GetClass(key->GetClassName());
if (!cl->InheritsFrom("TH1D") and !cl->InheritsFrom("TH2D")) continue;
TH1D *baseplot = (TH1D*)key->ReadObj();
std::string plotname = std::string(baseplot->GetName());
int nbins = baseplot->GetNbinsX()*baseplot->GetNbinsY();
// Setup TProfile with RMS option
TProfile* tprof = new TProfile((plotname + "_prof").c_str(),(plotname + "_prof").c_str(),nbins, 0, nbins, "S");
// Setup The TTREE
double* bincontents;
bincontents = new double[nbins];
double* binlowest;
binlowest = new double[nbins];
double* binhighest;
binhighest = new double[nbins];
errorDIR->cd();
TTree* bintree = new TTree((plotname + "_tree").c_str(), (plotname + "_tree").c_str());
for (Int_t i = 0; i < nbins; i++){
bincontents[i] = 0.0;
binhighest[i] = 0.0;
binlowest[i] = 0.0;
bintree->Branch(Form("content_%i",i),&bincontents[i],Form("content_%i/D",i));
}
for (Int_t i = 0; i < nthrows; i++){
TH1* newplot = (TH1*)tempfile->Get(Form(("throw_%i/" + plotname).c_str(),i));
for (Int_t j = 0; j < nbins; j++){
tprof->Fill(j+0.5, newplot->GetBinContent(j+1));
bincontents[j] = newplot->GetBinContent(j+1);
if (bincontents[j] < binlowest[j] or i == 0) binlowest[j] = bincontents[j];
if (bincontents[j] > binhighest[j] or i == 0) binhighest[j] = bincontents[j];
}
errorDIR->cd();
bintree->Fill();
delete newplot;
}
errorDIR->cd();
for (Int_t j = 0; j < nbins; j++){
if (!uniformly){
baseplot->SetBinError(j+1,tprof->GetBinError(j+1));
} else {
baseplot->SetBinContent(j+1, (binlowest[j] + binhighest[j]) / 2.0);
baseplot->SetBinError(j+1, (binhighest[j] - binlowest[j])/2.0);
}
}
errorDIR->cd();
baseplot->Write();
tprof->Write();
bintree->Write();
delete baseplot;
delete tprof;
delete bintree;
delete [] bincontents;
}
return;
};
diff --git a/src/Routines/minimizerRoutines.h b/src/Routines/minimizerRoutines.h
index 0298160..1073c3c 100755
--- a/src/Routines/minimizerRoutines.h
+++ b/src/Routines/minimizerRoutines.h
@@ -1,347 +1,256 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#ifndef MINIMIZER_ROUTINES_H
#define MINIMIZER_ROUTINES_H
/*!
* \addtogroup Minimizer
* @{
*/
#include "TH1.h"
#include "TF1.h"
#include "TMatrixD.h"
#include "TVectorD.h"
#include "Minuit2/FCNBase.h"
#include "TFitterMinuit.h"
#include "TSystem.h"
#include "TFile.h"
#include "TProfile.h"
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <cstring>
#include "FitEvent.h"
#include "JointFCN.h"
#include "MinimizerFCN.h"
#include "FitParameters.h"
#include "Math/Minimizer.h"
#include "Math/Factory.h"
#include "Math/Functor.h"
#include "FitLogger.h"
//*************************************
//! Collects all possible fit routines into a single class to avoid repeated code
class minimizerRoutines{
//*************************************
public:
/*
Constructor/Destructor
*/
//! Constructor reads in arguments given at the command line for the fit here.
minimizerRoutines(int argc, char* argv[]);
//! Default destructor
~minimizerRoutines();
/*
Input Functions
*/
//! Splits the arguments ready for initial setup
- void parseArgs(int argc, char* argv[]);
+ void ParseArgs(int argc, char* argv[]);
//! Sorts out configuration and verbosity right at the very start.
//! Calls readCard to set everything else up.
- void initialSetup();
+ void InitialSetup();
//! Loops through each line of the card file and passes it to other read functions
- void readCard();
+ void ReadCard();
//! Check for parameter string in the line and assign the correct type.
//! Fills maps for each of the parameters
- void readParameters(std::string parstring);
+ void ReadParameters(std::string parstring);
//! Reads in fake parameters and assigns them (Requires the parameter to be included as a normal parameter as well)
- void readFakeDataPars(std::string parstring);
+ void ReadFakeDataPars(std::string parstring);
//! Read in the samples so we can set up the free normalisation dials if required
- void readSamples(std::string sampleString);
-
- //! If a previous input file is provided, eg to take the starting dial values, it is done here. NEEDS TESTING.
- void readInputFile();
-
- //! Check if previous result wasn't actually the final minimum incase we want to use fit continue functions. NEEDS TESTING
- bool checkPreviousResult();
+ void ReadSamples(std::string sampleString);
/*
Setup Functions
*/
-
//! Setup the configuration given the arguments passed at the commandline and card file
- void setupConfig();
+ void SetupConfig();
//! Setups up our custom RW engine with all the parameters passed in the card file
- void setupRWEngine();
+ void SetupRWEngine();
//! Setups up the jointFCN.
- void setupFCN();
+ void SetupFCN();
//! Sets up the minimizerObj for ROOT. there are cases where this is called repeatedly, e.g. If you are using a brute force scan before using Migrad.
- void setupFitter(std::string routine);
+ void SetupFitter(std::string routine);
//! Set the current data histograms in each sample to the fake data.
- void setFakeData();
+ void SetFakeData();
//! Setup the covariances with the correct dimensions. At the start this is either uncorrelated or merged given all the input covariances.
//! At the end of the fit this produces the blank covariances which can then be filled by the minimizerObj with best fit covariances.
void SetupCovariance();
/*
Fitting Functions
*/
//! Main function to actually start iterating over the different required fit routines
- void SelfFit();
+ void Run();
//! Given a new map change the values that the RW engine is currently set to
- void updateRWEngine(std::map<std::string,double>& updateVals, std::map<std::string,double>& updateNorms);
+ void UpdateRWEngine(std::map<std::string,double>& updateVals);
//! Given a single routine (see tutorial for options) run that fit routine now.
void RunFitRoutine(std::string routine);
//! Get the current state of minimizerObj and fill it into currentVals and currentNorms
- void getMinimizerState();
+ void GetMinimizerState();
//! Performs a fit routine where the MAXEVENTS is set to a much lower value to try and move closer to the best fit minimum.
void LowStatRoutine(std::string routine);
//! Perform a chi2 scan in 1D around the current point
void Create1DScans();
//! Perform a chi2 scan in 2D around the current point
void Chi2Scan2D();
//! Currently a placeholder NEEDS UPDATING
void CreateContours();
//! If any currentVals are close to the limits set them to the limit and fix them
void FixAtLimit();
//! Throw the current covariance of dial values we have, and fill the thrownVals and thrownNorms maps.
//! If uniformly is true parameters will be thrown uniformly between their upper and lower limits.
void ThrowCovariance(bool uniformly);
//! Step through each parameter one by one and create folders containing the MC predictions at each step.
//! Doesn't handle correlated parameters well
void PlotLimits();
//! Given the covariance we currently have generate error bands by throwing the covariance.
//! The FitPar config "error_uniform" defines whether to throw using the covariance or uniformly.
//! The FitPar config "error_throws" defines how many throws are needed.
//! Currently only supports TH1D plots.
void GenerateErrorBands();
/*
Write Functions
*/
//! Write plots and TTrees listing the minimizerObj result of the fit to file
- void saveMinimizerState();
+ void SaveMinimizerState();
//! Save the output of the fitter including sample plots.
//! dir if not empty forces plots to be saved in a subdirectory of outputfile
- void saveFitterOutput(std::string dir="");
+ void SaveFitterOutput(std::string dir="");
//! Save the sample plots for current MC
//! dir if not empty forces plots to be saved in a subdirectory of outputfile
- void saveCurrentState(std::string subdir="");
+ void SaveCurrentState(std::string subdir="");
//! Save starting predictions into a seperate folder
- void saveNominal();
+ void SaveNominal();
//! Save predictions before the fit is ran into a seperate folder
- void savePrefit();
+ void SavePrefit();
/*
MISC Functions
*/
//! Get previous fit status from a file
Int_t GetStatus();
protected:
//! Our Custom ReWeight Object
FitWeight* rw;
- // I/O
-
- std::string outputFileName;
- std::string inputFileName;
-
- //! Input file from previous fit
- TFile* inputFile;
+ std::string fOutputFile;
+ std::string fInputFile;
- //! Output file where the results are saved
- TFile* outputFile;
+ TFile* fInputRootFile;
+ TFile* fOutputRootFile;
//! Flag for whether the fit should be continued if an output file is already found.
bool fitContinue;
//! Minimizer Object for handling roots different minimizer methods
- ROOT::Math::Minimizer* minimizerObj;
+ ROOT::Math::Minimizer* fMinimizer;
- //! The actual chi2 Function from FCN module
- JointFCN* thisFCN;
- MinimizerFCN* MinFCN;
-
- //! A functor that root requires to pass to minimizerObj.
- //! Basically just a wrapper for thisFCN
- ROOT::Math::Functor* callFCN;
+ JointFCN* fSampleFCN;
+ MinimizerFCN* fMinimizerFCN;
+ ROOT::Math::Functor* fCallFunctor;
- //! Current number of free parameters. callFCN requires this when being setup.
int nfreepars;
- // Fit Options
-
- //! Input cardfile containing fit samples and dials
- std::string cardFile;
-
- //! comma seperated list of fit routines to be run
- std::string fitStrategy;
-
- //! fitStrategy is parsed into this vector of fit routines. Each one is run in sequence and current values updated.
- std::vector<std::string> fit_routines;
+ std::string fCardFile;
- //! Directory of a fake data MC file to use for this fit. If "MC" is provided the starting nominal MC and provided fake_parameters are used as fake data.
- std::string fakeDataFile;
+ std::string fStrategy;
+ std::vector<std::string> fRoutines;
- //! Current fit type.
- int type;
+ std::string fFakeDataInput;
- // Parameter Configs
- //! vector command line config overrides
std::vector<std::string> configCmdFix;
- // Input Dial Values
+ // Input Dial Vals
//! Vector of dial names
- std::vector<std::string> params;
-
- //! Map of dial names and dial types. 0 NEUT 1 NIWG 2 GENIE 3 NUWRO 4 CUSTOM
- std::map<std::string,int> params_type;
-
- //! Map of dial names and starting values given in the fit card
- std::map<std::string, double> startVals;
-
- //! Map of dial names and current values at this stage in the overall fitting routine
- std::map<std::string, double> currentVals;
-
- //! Map of dial names and current errors at this stage
- std::map<std::string, double> errorVals;
-
- //! Map of dial names and the minimum limits provided in the fit card
- std::map<std::string, double> minVals;
-
- //! Map of dial names and the maximum limits provided in the fit card
- std::map<std::string, double> maxVals;
-
- //! Map of dial names and the step values for this dial provided in the fit card.
- //! Minuit seems to ignore this anyway, but it is used in the PlotLimits routine.
- std::map<std::string, double> stepVals;
-
- //! Map of dial names and flags for whether the parmaeter is currently fixed.
- std::map<std::string, bool> fixVals;
-
- //! Map of dial names and flags for whether the parameter started fixed.
- std::map<std::string, bool> startFixVals;
-
- // Input Samples
-
- //! Vector of samples included in the fit
- std::vector<std::string> samples;
-
- //! Vector of sample normalisation dial names (sample + "_norm")
- std::vector<std::string> sampleDials;
-
- //! Map of norm dial names and the starting value given in the fit card
- std::map<std::string, double> sampleNorms;
-
- //! Map of norm dial names and the current value in the fit
- std::map<std::string, double> currentNorms;
-
- //! Map of norm dial names and the current error in the fit
- std::map<std::string, double> errorNorms;
-
- //! Map of norm dial names and whether it is currently fixed in the fit
- std::map<std::string, bool> fixNorms;
-
- //! Map of norm dial names and whether it started fixed
- std::map<std::string, bool> startFixNorms;
-
- //! Map of norm dial names and the files string input for those samples
- std::map<std::string, std::string> sampleFiles;
-
- //! Map of norm dial names and the type string for those samples
- std::map<std::string, std::string> sampleTypes;
-
- // Input Fake Data Sets
+ std::vector<std::string> fParams;
+ std::map<std::string, double> fStartVals;
+ std::map<std::string, double> fCurVals;
+ std::map<std::string, double> fErrorVals;
+ std::map<std::string, double> fMinVals;
+ std::map<std::string, double> fMaxVals;
+ std::map<std::string, double> fStepVals;
+ std::map<std::string, int> fTypeVals;
+ std::map<std::string, bool> fFixVals;
+ std::map<std::string, bool> fStartFixVals;
//! Vector of fake parameter names
- std::vector<std::string> fakeParams;
-
- //! Vector of fake parameter sample norms
- std::vector<std::string> fakeSamples;
-
- //! Map of fake dial names and their values
- std::map<std::string,double> fakeVals;
-
- //! Map of fake sample norm names and their values
- std::map<std::string,double> fakeNorms;
+ std::map<std::string,double> fFakeVals;
//! Map of thrown parameter names and values (After ThrowCovariance)
- std::map<std::string,double> thrownVals;
+ std::map<std::string,double> fThrownVals;
- //! Map of thrown parameter names and values (After ThrowCovariance)
- std::map<std::string,double> thrownNorms;
-
-
- TH2D* covarHist; //!< Covariance matrix for the fit. At the start this is uncorrelated unless input covars are provided.
- TH2D* covarHist_Free; //!< Covariance matrix for the free parameters fit. At the start this is uncorrelated unless input covars are provided.
- TH2D* correlHist; //!< Correlation matrix for the fit. At the start this is uncorrelated unless input covars are provided.
- TH2D* correlHist_Free; //!< Correlation matrix for the free parameters fit. At the start this is uncorrelated unless input covars are provided.
- TH2D* decompHist; //!< Decomposition matrix for the fit. At the start this is uncorrelated unless input covars are provided.
- TH2D* decompHist_Free; //!< Decomposition matrix for the free parameters fit. At the start this is uncorrelated unless input covars are provided.
+ TH2D* fCorrel;
+ TH2D* fDecomp;
+ TH2D* fCovar;
+
+ TH2D* fCorrelFree;
+ TH2D* fDecompFree;
+ TH2D* fCovarFree;
std::vector<TH1D*> input_dials; //!< Vector of histograms from parameter pull classes that give central values of the input pull terms
std::vector<TH2D> input_covariances; //!< vector of histograms from parameter pull classes that give covariance of the input pull terms
};
/*! @} */
#endif
diff --git a/src/Routines/systematicRoutines.cxx b/src/Routines/systematicRoutines.cxx
index 8f9ea58..052ceeb 100755
--- a/src/Routines/systematicRoutines.cxx
+++ b/src/Routines/systematicRoutines.cxx
@@ -1,1109 +1,970 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "StatusMessage.h"
#include "systematicRoutines.h"
/*
Constructor/Destructor
*/
//************************
systematicRoutines::systematicRoutines(int argc, char* argv[]){
//************************
// Set Defaults
inputFileName = "";
outputFileName = "";
covarHist = NULL;
covarHist_Free = NULL;
correlHist = NULL;
correlHist_Free = NULL;
decompHist = NULL;
decompHist_Free = NULL;
inputFile = NULL;
outputFile = NULL;
fitStrategy = "Migrad,FixAtLim";
fakeDataFile = "";
thisFCN = NULL;
- parseArgs(argc, argv);
-
+ ParseArgs(argc, argv);
};
//*************************************
systematicRoutines::~systematicRoutines(){
//*************************************
};
/*
Input Functions
*/
//*************************************
-void systematicRoutines::parseArgs(int argc, char* argv[]){
+void systematicRoutines::ParseArgs(int argc, char* argv[]){
//*************************************
std::string maxevents_flag = "";
int verbosity_flag = 0;
int error_flag = 0;
// If No Arguments print commands
for (int i = 1; i< argc; ++i){
if (i+1 != argc){
// Cardfile
if (!std::strcmp(argv[i], "-c")) { cardFile=argv[i+1]; ++i;}
else if (!std::strcmp(argv[i], "-o")) { outputFileName=argv[i+1]; ++i;}
else if (!std::strcmp(argv[i], "-f")) { fitStrategy=argv[i+1]; ++i;}
else if (!std::strcmp(argv[i], "-i")) { inputFileName=argv[i+1]; ++i;}
else if (!std::strcmp(argv[i], "-q")) { configCmdFix.push_back(argv[i+1]); ++i;}
else if (!std::strcmp(argv[i], "-n")) { maxevents_flag=argv[i+1]; ++i;}
else if (!std::strcmp(argv[i], "-v")) { verbosity_flag -= 1; }
else if (!std::strcmp(argv[i], "+v")) { verbosity_flag += 1; }
else if (!std::strcmp(argv[i], "-e")) { error_flag -= 1; }
else if (!std::strcmp(argv[i], "+e")) { error_flag += 1; }
} else std::cerr << "ERROR: unknown command line option given! - '" <<argv[i]<<" "<<argv[i+1]<<"'"<< std::endl;
}
if (outputFileName.empty()) std::cerr << "ERROR: output file not specified." << std::endl;
if (cardFile.empty()) std::cerr << "ERROR: card file not specified." << std::endl;
// Parse fit routine
std::string token;
std::istringstream stream(fitStrategy);
LOG(FIT)<< "Fit Routine = " << fitStrategy <<std::endl;
while(std::getline(stream, token, ',')){
fit_routines.push_back(token);
}
LOG(FIT) << " Config setup " << endl;
cout << "SETUP" << endl;
setupConfig();
- readCard();
+ ReadCard();
if (!maxevents_flag.empty()) FitPar::Config().SetParI("MAXEVENTS", atoi(maxevents_flag.c_str()));
if (verbosity_flag != 0) FitPar::Config().SetParI("VERBOSITY", FitPar::Config().GetParI("VERBOSITY") + verbosity_flag);
if (error_flag != 0) FitPar::Config().SetParI("ERROR", FitPar::Config().GetParI("ERROR") + error_flag);
-
return;
};
//*************************************
-void systematicRoutines::initialSetup(){
+void systematicRoutines::InitialSetup(){
//*************************************
- SetupCovariance();
-
// output file open
outputFile = new TFile(outputFileName.c_str(),"RECREATE");
FitPar::Config().Write();
// setup RW and FCN
setupRWEngine();
setupFCN();
-
+ GetCovarFromFCN();
+ SetupCovariance();
+
return;
}
//*************************************
-void systematicRoutines::readCard(){
+void systematicRoutines::ReadCard(){
//*************************************
std::string line;
std::ifstream card(this->cardFile.c_str(), ifstream::in);
while(std::getline(card, line, '\n')){
std::istringstream stream(line);
FitPar::Config().cardLines.push_back(line);
readParameters(line);
readFakeDataPars(line);
readSamples(line);
- readCovariance(line);
}
card.close();
- checkCovarianceDials(false);
-
return;
};
//*****************************************
-void systematicRoutines::checkCovarianceDials(bool printdials){
+void systematicRoutines::GetCovarFromFCN(){
//*****************************************
- bool baddial = false;
-
- cout << "N INputs = " << input_dials.size() << endl;
- // Loop over all input dials
- for (UInt_t i = 0; i < input_dials.size(); i++){
-
- for (UInt_t j = 0; j < input_dials.at(i)->GetNbinsX(); j++){
- std::string dialname = input_dials.at(i)->GetXaxis()->GetBinLabel(j+1);
-
- cout << dialname << " TICK? " << endl;
-
- // Check if we have input for this dial
- if (std::find(params.begin(), params.end(), dialname) != params.end()
- and !printdials){
- continue;
- }
-
- // Warn and add comment to card
- std::cerr << "No parameter type/limits specified for dial "
- << dialname << endl;
- std::cerr << "NUISANCE needs these to make sure throws are sensible!"
- << endl;
- std::cerr << "Added example lines to the card, please fill these in." << endl;
-
- // Add new line to card
- std::ofstream outtemp;
- outtemp.open(cardFile.c_str(), std::ios_base::app);
-
- outtemp << "[TYPE]_parameter " << dialname
- << input_dials.at(i)->GetBinContent(j+1) << " "
- << " -100.0 100.0 1.0 FREE " << endl;
- outtemp.close();
-
- baddial = true;
- }
- }
-
- if (baddial){
- sleep(10);
- exit(-1);
+ // Get Covariance Objects from FCN
+ std::list<ParamPull*> inputpulls = thisFCN->GetPullList();
+ for (PullListConstIter iter = inputpulls.begin();
+ iter != inputpulls.end(); iter++){
+
+ ParamPull* pull = (*iter);
+ fInputCovar.push_back(pull->GetFullCovarMatrix());
+ fInputDials.push_back(pull->GetDataHist());
+
}
-
+
return;
}
//*****************************************
void systematicRoutines::readParameters(std::string parstring){
//******************************************
cout << "PARSTRING = " << parstring << endl;
std::string token, parname;
std::istringstream stream(parstring); int val = 0;
double entry;
int partype;
std::string curparstate = "";
std::string partype_str = "";
if (parstring.c_str()[0] == '#') return;
while(std::getline(stream, token, ' ')){
stream >> std::ws;
std::istringstream stoken(token);
if (val > 1 and val < 6) stoken >> entry;
// Allow (parameter name val FIX)
if (val > 2 and val < 6 and token.find("FIX") != std::string::npos) {
startFixVals[parname] = true;
fixVals[parname] = true;
break;
}
if (val == 0 &&
token.compare("niwg_parameter") &&
token.compare("neut_parameter") &&
token.compare("genie_parameter") &&
token.compare("nuwro_parameter") &&
token.compare("custom_parameter") &&
token.compare("t2k_parameter")) {
return;
} else if (val == 0){
partype_str = token;
if (!token.compare("neut_parameter")) partype = kNEUT;
else if (!token.compare("niwg_parameter")) partype = kNIWG;
else if (!token.compare("genie_parameter")) partype = kGENIE;
else if (!token.compare("nuwro_parameter")) partype = kNUWRO;
else if (!token.compare("custom_parameter")) partype = kCUSTOM;
else if (!token.compare("t2k_parameter")) partype = kT2K;
} else if (val == 1) {
params.push_back(token);
parname = token;
// Set Type
params_type[parname] = partype;
// Defaults
startVals[parname] = 0.0;
currentVals[parname] = 0.0;
errorVals[parname] = 0.0;
minVals[parname] = -1.0;
maxVals[parname] = 1.0;
stepVals[parname] = 0.5;
startFixVals[parname] = true;
fixVals[parname] = true;
} else if (val == 2){ // Nominal
startVals[parname] = entry;
currentVals[parname] = entry;
errorVals[parname] = 0.0;
} else if (val == 3){ minVals[parname] = entry; // min
} else if (val == 4){ maxVals[parname] = entry; // max
} else if (val == 5){ stepVals[parname] = entry; // step
} else if (val == 6){ // type
startFixVals[parname] = ( token.find("FIX") != std::string::npos );
fixVals[parname] = ( token.find("FIX") != std::string::npos );
curparstate = token;
} else break;
val++;
}
// Run Dial Conversions
// ABSOLUTE CONVERSION
if (curparstate.find("ABS") != std::string::npos){
LOG(MIN)<<"Converting abs dial "<<parname<<" : "<<startVals[parname];
startVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, startVals[parname]);
currentVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, currentVals[parname]);
minVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, minVals[parname]);
maxVals[parname] = FitBase::RWAbsToSigma(partype_str, parname, maxVals[parname]);
stepVals[parname] = fabs((FitBase::RWAbsToSigma(partype_str, parname, startVals[parname] + stepVals[parname])
- FitBase::RWAbsToSigma(partype_str, parname, startVals[parname])));
LOG(MIN)<<" -> "<<startVals[parname]<<std::endl;
// FRACTION CONVERSION
} else if (curparstate.find("FRAC") != std::string::npos){
LOG(FIT)<<"Converting frac dial "<<parname<<" : "<<startVals[parname];
startVals[parname] = FitBase::RWFracToSigma(partype_str, parname, startVals[parname]);
currentVals[parname] = FitBase::RWFracToSigma(partype_str, parname, currentVals[parname]);
minVals[parname] = FitBase::RWFracToSigma(partype_str, parname, minVals[parname]);
maxVals[parname] = FitBase::RWFracToSigma(partype_str, parname, maxVals[parname]);
stepVals[parname] = (FitBase::RWFracToSigma(partype_str, parname, stepVals[parname]));
LOG(MIN)<<" -> "<<startVals[parname]<<std::endl;
}
return;
}
void systematicRoutines::PlotLimits(){
TDirectory* limfolder = (TDirectory*) outputFile->mkdir("Limits");
limfolder->cd();
// Set all parameters at their starting values
for (UInt_t i = 0; i < params.size(); i++){
currentVals[params[i]] = startVals[params[i]];
}
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- currentNorms[sampleDials[i]] = sampleNorms[sampleDials[i]];
- }
TDirectory* nomfolder = (TDirectory*) limfolder->mkdir("nominal");
nomfolder->cd();
- updateRWEngine(currentVals, currentNorms);
+ updateRWEngine(currentVals);
thisFCN->ReconfigureAllEvents();
thisFCN->Write();
limfolder->cd();
std::vector<std::string> allfolders;
// Loop through each parameter
for (UInt_t i = 0; i < params.size(); i++){
if (fixVals[params[i]]) continue;
while (currentVals[params[i]] > minVals[params[i]]){
currentVals[params[i]] = currentVals[params[i]] - stepVals[params[i]];
if (currentVals[params[i]] < minVals[params[i]])
currentVals[params[i]] = minVals[params[i]];
std::string curvalstring = std::string( Form( (params[i] + "_%f").c_str(), currentVals[params[i]] ) );
if (std::find(allfolders.begin(), allfolders.end(), curvalstring) != allfolders.end())
break;
TDirectory* minfolder = (TDirectory*) limfolder->mkdir(Form( (params[i] + "_%f").c_str(), currentVals[params[i]] ) );
minfolder->cd();
allfolders.push_back(curvalstring);
- updateRWEngine(currentVals, currentNorms);
+ updateRWEngine(currentVals);
thisFCN->ReconfigureAllEvents();
thisFCN->Write();
}
currentVals[params[i]] = startVals[params[i]];
while (currentVals[params[i]] < maxVals[params[i]]){
currentVals[params[i]] = currentVals[params[i]] + stepVals[params[i]];
if (currentVals[params[i]] > maxVals[params[i]])
currentVals[params[i]] = maxVals[params[i]];
std::string curvalstring = std::string( Form( (params[i] + "_%f").c_str(), currentVals[params[i]] ) );
if (std::find(allfolders.begin(), allfolders.end(), curvalstring) != allfolders.end())
break;
TDirectory* maxfolder = (TDirectory*) limfolder->mkdir(Form( (params[i] + "_%f").c_str(), currentVals[params[i]] ) );
maxfolder->cd();
allfolders.push_back(curvalstring);
- updateRWEngine(currentVals, currentNorms);
+ updateRWEngine(currentVals);
thisFCN->ReconfigureAllEvents();
thisFCN->Write();
}
currentVals[params[i]] = startVals[params[i]];
- updateRWEngine(currentVals, currentNorms);
+ updateRWEngine(currentVals);
}
}
//*******************************************
void systematicRoutines::readFakeDataPars(std::string parstring){
//******************************************
std::string token, parname;
std::istringstream stream(parstring);
int val = 0;
double entry;
if (parstring.c_str()[0] == '#') return;
while(std::getline(stream, token, ' ')){
stream >> std::ws; // strip whitespace
std::istringstream stoken(token);
if (val == 2) stoken >> entry;
if (val == 0){
if(token.compare("fake_parameter") != 0) return;
} else if (val == 1){
fakeParams.push_back(token);
parname = token;
} else if (val == 2){
fakeVals[parname] = entry;
} else {
break;
}
val++;
}
val = 0;
while(std::getline(stream, token, ' ')){
stream >> std::ws; // strip whitespace
std::istringstream stoken(token);
if (val == 2) stoken >> entry;
if (val == 0 && token.compare("fake_norm") != 0){ return; }
if (val == 1){
fakeSamples.push_back(token);
parname = token;
- } else if (val == 2) fakeNorms[parname] = entry;
+ } else if (val == 2) fakeVals[parname] = entry;
val++;
}
return;
}
//******************************************
void systematicRoutines::readSamples(std::string sampleString){
//******************************************
std::string token, samplename;
std::istringstream stream(sampleString); int val = 0;
double entry;
if (sampleString.c_str()[0] == '#') return;
while(std::getline(stream, token, ' ')){
stream >> std::ws; // strip whitespace
std::istringstream stoken(token);
stoken >> entry;
if (val == 0){
if (token.compare("sample") != 0){ return; }
} else if (val == 1){
samplename = token + "_norm";
samples.push_back(token);
- sampleDials.push_back(samplename);
+ params.push_back(samplename);
+
+ params_type[samplename] = kNORM;
- sampleNorms[samplename] = 1.0;
- currentNorms[samplename] = 1.0;
- errorNorms[samplename] = 1.0;
+ startVals[samplename] = 1.0;
+ currentVals[samplename] = 1.0;
+ errorVals[samplename] = 1.0;
} else if (val == 3) {
sampleTypes[samplename] = token;
bool fixed = (token.find("FREE") == std::string::npos);
- fixNorms[samplename] = fixed; //fixed;
- startFixNorms[samplename] = fixed; //fixed;
+ fixVals[samplename] = fixed; //fixed;
+ startFixVals[samplename] = fixed; //fixed;
// defaults
- sampleNorms[samplename] = 1.0;
- currentNorms[samplename] = 1.0;
- errorNorms[samplename] = 0.0;
+ startVals[samplename] = 1.0;
+ currentVals[samplename] = 1.0;
+ errorVals[samplename] = 0.0;
} else if (val == 2) { sampleFiles[samplename] = token;
} else if (val == 4){
if (entry > 0.3 and entry < 1.7) {
- sampleNorms[samplename] = entry;
- currentNorms[samplename] = entry;
- errorNorms[samplename] = entry;
+ startVals[samplename] = entry;
+ currentVals[samplename] = entry;
+ errorVals[samplename] = entry;
}
}
val++;
}
return;
}
/*
Setup Functions
*/
//*************************************
void systematicRoutines::setupConfig(){
//*************************************
std::string par_dir = std::string(std::getenv("EXT_FIT"))+"/parameters/";
cout << " Reading " << par_dir + "fitter.config.dat" << endl;
FitPar::Config().ReadParamFile( par_dir + "fitter.config.dat" );
cout << " Reading " << cardFile << endl;
FitPar::Config().ReadParamFile( cardFile );
for (unsigned int iter = 0; iter < configCmdFix.size(); iter++){
FitPar::Config().ForceParam(configCmdFix[iter]);
cout << " Par overridden " << configCmdFix[iter] << endl;
}
cout << " VERB = " << (FitPar::Config().GetParS("VERBOSITY")) << endl;
LOG_VERB(FitPar::Config().GetParS("VERBOSITY"));
ERR_VERB(FitPar::Config().GetParS("VERBOSITY"));
return;
};
//*************************************
void systematicRoutines::setupRWEngine(){
//*************************************
for (UInt_t i = 0; i < params.size(); i++){
std::string name = params[i];
std::cout << "Adding parameter " << name << std::endl;
FitBase::GetRW() -> IncludeDial(name, params_type.at(name) );
}
-
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- std::string name = sampleDials[i];
- FitBase::GetRW()->IncludeDial(name, kNORM);
- }
FitBase::GetRW()->Reconfigure();
- updateRWEngine(startVals, sampleNorms);
+ updateRWEngine(startVals);
std::cout<<"RW Engines updated"<<std::endl;
return;
}
//*************************************
void systematicRoutines::setupFCN(){
//*************************************
LOG(FIT)<<"Making the jointFCN"<<std::endl;
if (thisFCN) delete thisFCN;
thisFCN = new JointFCN(cardFile, outputFile);
setFakeData();
return;
}
//*************************************
void systematicRoutines::setFakeData(){
//*************************************
if (fakeDataFile.empty()) return;
if (fakeDataFile.compare("MC") == 0){
LOG(FIT)<<"Setting fake data from MC starting prediction." <<std::endl;
- updateRWEngine(fakeVals, fakeNorms);
+ updateRWEngine(fakeVals);
FitBase::GetRW()->Reconfigure();
thisFCN->ReconfigureAllEvents();
// thisFCN->SetFakeData("MC");
- updateRWEngine(currentVals, currentNorms);
+ updateRWEngine(currentVals);
LOG(FIT)<<"Set all data to fake MC predictions."<<std::endl;
} else {
// thisFCN->SetFakeData(fakeDataFile);
}
return;
}
/*
Fitting Functions
*/
//*************************************
-void systematicRoutines::updateRWEngine(std::map<std::string,double>& updateVals,
- std::map<std::string,double>& updateNorms){
+void systematicRoutines::updateRWEngine(std::map<std::string,double>& updateVals){
//*************************************
for (UInt_t i = 0; i < params.size(); i++){
std::string name = params[i];
if (updateVals.find(name) == updateVals.end()){
continue;
}
FitBase::GetRW()->SetDialValue(name,updateVals.at(name));
}
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- std::string name = sampleDials[i];
-
- if (updateNorms.find(name) == updateNorms.end()){
- FitBase::GetRW()->SetDialValue(name, 1.0);
- } else {
- FitBase::GetRW()->SetDialValue(name, updateNorms.at(name));
- }
- }
-
FitBase::GetRW()->Reconfigure();
return;
}
//**************
void systematicRoutines::SelfFit(){
//*************
for (UInt_t i = 0; i < fit_routines.size(); i++){
std::string routine = fit_routines.at(i);
LOG(FIT)<<"Running Routine: "<<routine<<std::endl;
if (routine.find("PlotLimits") != std::string::npos) PlotLimits();
else if (routine.find("ErrorBands") != std::string::npos) GenerateErrorBands();
}
return;
}
/*
Write Functions
*/
//*************************************
void systematicRoutines::saveCurrentState(std::string subdir){
//*************************************
LOG(FIT)<<"Saving current FCN predictions" <<std::endl;
outputFile->cd();
FitBase::GetRW()->Reconfigure();
thisFCN->ReconfigureAllEvents();
if (!subdir.empty()){
TDirectory* newDIR =(TDirectory*) outputFile->mkdir(subdir.c_str());
newDIR->cd();
}
thisFCN->Write();
outputFile->cd();
return;
}
//*************************************
void systematicRoutines::saveNominal(){
//*************************************
LOG(FIT)<<"Saving Neut Nominal Predictions (be cautious with this)" <<std::endl;
//rw->ResetAll();
FitBase::GetRW()->Reconfigure();
saveCurrentState("nominal");
};
//*************************************
void systematicRoutines::savePrefit(){
//*************************************
LOG(FIT)<<"Saving Prefit Predictions"<<std::endl;
- updateRWEngine(startVals, sampleNorms);
+ updateRWEngine(startVals);
saveCurrentState("prefit");
- updateRWEngine(currentVals, currentNorms);
+ updateRWEngine(currentVals);
};
/*
MISC Functions
*/
//*************************************
int systematicRoutines::GetStatus(){
//*************************************
return 0;
}
//*************************************
void systematicRoutines::SetupCovariance(){
//*************************************
- // Remove covares if they exist
- if (covarHist) delete covarHist;
- if (covarHist_Free) delete covarHist_Free;
- if (correlHist) delete correlHist;
- if (correlHist_Free) delete correlHist_Free;
- if (decompHist) delete decompHist;
- if (decompHist_Free) delete decompHist_Free;
+ // Clear Histograms
+ if (fCovar) delete fCovar;
+ if (fCorrel) delete fCorrel;
+ if (fDecomp) delete fDecomp;
+
+ if (fCovarFree) delete fCovarFree;
+ if (fCorrelFree) delete fCorrelFree;
+ if (fDecompFree) delete fDecompFree;
+
+
int NFREE = 0;
int NDIM = 0;
// Get NFREE from min or from vals (for cases when doing throws)
- NDIM = params.size() + sampleDials.size();
+ NDIM = params.size();
for (UInt_t i = 0; i < params.size(); i++){
if (!fixVals[params[i]]) NFREE++;
}
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- if (!fixNorms[sampleDials[i]]) NFREE++;
- }
if (NDIM == 0) return;
covarHist = new TH2D("covariance","covariance",NDIM,0,NDIM,NDIM,0,NDIM);
if (NFREE > 0){
covarHist_Free = new TH2D("covariance_free",
"covariance_free",
NFREE,0,NFREE,
NFREE,0,NFREE);
}
// Set Bin Labels
int countall = 0;
int countfree = 0;
for (UInt_t i = 0; i < params.size(); i++){
covarHist->GetXaxis()->SetBinLabel(countall+1,params[i].c_str());
covarHist->GetYaxis()->SetBinLabel(countall+1,params[i].c_str());
countall++;
if (!fixVals[params[i]] and NFREE > 0){
covarHist_Free->GetXaxis()->SetBinLabel(countfree+1,params[i].c_str());
covarHist_Free->GetYaxis()->SetBinLabel(countfree+1,params[i].c_str());
countfree++;
}
}
- for (UInt_t i = 0; i < sampleDials.size(); i++){
-
- covarHist->GetXaxis()->SetBinLabel(countall+1,sampleDials[i].c_str());
- covarHist->GetYaxis()->SetBinLabel(countall+1,sampleDials[i].c_str());
- countall++;
-
- if (!fixNorms[sampleDials[i]] and NFREE > 0){
- covarHist_Free->GetXaxis()->SetBinLabel(countfree+1,sampleDials[i].c_str());
- covarHist_Free->GetYaxis()->SetBinLabel(countfree+1,sampleDials[i].c_str());
- countfree++;
- }
- }
-
-
// Fill Input Covariances
for (UInt_t i = 0; i < input_covariances.size(); i++){
TH2D covplot = input_covariances.at(i);
for(Int_t i = 0; i < covplot.GetNbinsX(); i++){
for (Int_t j = 0; j < covplot.GetNbinsY(); j++){
std::string parx = covplot.GetXaxis()->GetBinLabel(i+1);
std::string pary = covplot.GetYaxis()->GetBinLabel(j+1);
for (Int_t k = 0; k < covarHist->GetNbinsX(); k++){
for (Int_t l = 0; l < covarHist->GetNbinsY(); l++){
if (!parx.compare(covarHist->GetXaxis()->GetBinLabel(k+1)) and
!pary.compare(covarHist->GetYaxis()->GetBinLabel(l+1)))
covarHist->SetBinContent(k+1,l+1, covarHist->GetBinContent(k+1,l+1) + covplot.GetBinContent(i+1,k+1));
}
}
for (Int_t k = 0; k < covarHist_Free->GetNbinsX(); k++){
for (Int_t l = 0; l < covarHist_Free->GetNbinsY(); l++){
if (!parx.compare(covarHist_Free->GetXaxis()->GetBinLabel(k+1)) and
!pary.compare(covarHist_Free->GetYaxis()->GetBinLabel(l+1))){
covarHist_Free->SetBinContent(k+1,l+1, covarHist_Free->GetBinContent(k+1,l+1) + covplot.GetBinContent(i+1,j+1));
}
}
}
}
}
}
// Setup Current Vals due to covariance inputs now as well
for (UInt_t i = 0; i < input_dials.size(); i++){
TH1D* plot = input_dials.at(i);
for (Int_t j = 0; j < plot->GetNbinsX(); j++){
std::string parname = std::string(plot->GetXaxis()->GetBinLabel(j+1));
if (currentVals.find(parname) != currentVals.end()) currentVals[parname] = plot->GetBinContent(j+1);
- else if (currentNorms.find(parname) != currentNorms.end()) currentNorms[parname] = plot->GetBinContent(j+1);
}
}
// Final Step Setting
countall = 0;
countfree = 0;
for (UInt_t i = 0; i < params.size(); i++){
double stepsq = stepVals[params[i]] * stepVals[params[i]];
if (!fixVals[params[i]] and covarHist->GetBinContent(countall+1,countall+1) == 0.0)
covarHist->SetBinContent(countall+1,countall+1,stepsq);
countall++;
if (!fixVals[params[i]] and NFREE > 0){
if (covarHist_Free->GetBinContent(countfree+1,countfree+1) == 0.0)
covarHist_Free->SetBinContent(countfree+1,countfree+1,stepsq);
countfree++;
}
}
-
- for (UInt_t i = 0; i < sampleDials.size(); i++){
-
- double stepsq = 0.1*0.1;
-
- if (!fixNorms[sampleDials[i]] and covarHist->GetBinContent(countall+1,countall+1) == 0.0)
- covarHist->SetBinContent(countall+1,countall+1,stepsq);
-
- countall++;
-
- if (!fixNorms[sampleDials[i]] and NFREE > 0){
-
- if (covarHist_Free->GetBinContent(countfree+1,countfree+1) == 0.0)
- covarHist_Free->SetBinContent(countfree+1,countfree+1,stepsq);
-
- countfree++;
- }
- }
-
correlHist = PlotUtils::GetCorrelationPlot(covarHist,"correlation");
decompHist = PlotUtils::GetDecompPlot(covarHist,"decomposition");
if (NFREE > 0)correlHist_Free = PlotUtils::GetCorrelationPlot(covarHist_Free, "correlation_free");
if (NFREE > 0)decompHist_Free = PlotUtils::GetDecompPlot(covarHist_Free,"decomposition_free");
return;
};
-//*************************************
-void systematicRoutines::readCovariance(std::string covarString){
-//*************************************
-
- std::string token, covarname, covartype;
- std::istringstream stream(covarString); int val = 0;
-
- if (covarString.c_str()[0] == '#') return;
-
- while(std::getline(stream, token, ' ')){
- stream >> std::ws; // strip whitespace
- std::istringstream stoken(token);
-
-
- if (val == 0 && token.compare("covar") != 0){ return; }
- else if (val == 1){ covarname = token; }
- else if (val == 2) { covartype = token; }
- else if (val == 3) {
-
- parameter_pulls* temp_pulls = new parameter_pulls(covarname, token, rw, covartype, "");
- this->input_covariances.push_back(temp_pulls->GetFullCovarMatrix());
- this->input_dials.push_back((TH1D*)temp_pulls->GetDataList().at(0)->Clone());
-
- delete temp_pulls;
- }
-
- val++;
- }
-
- return;
-};
//*************************************
void systematicRoutines::ThrowCovariance(bool uniformly){
//*************************************
std::vector<double> rands;
if (!decompHist_Free) {
ERR(WRN) << "Trying to throw 0 free parameters"<<std::endl;
return;
}
for (Int_t i = 0; i < decompHist_Free->GetNbinsX(); i++){
rands.push_back(gRandom->Gaus(0.0,1.0));
}
for (UInt_t i = 0; i < params.size(); i++){
thrownVals[params[i]] = currentVals[params[i]];
}
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- thrownNorms[sampleDials[i]] = currentNorms[sampleDials[i]];
- }
for (Int_t i = 0; i < decompHist_Free->GetNbinsX(); i++){
std::string parname = std::string(decompHist_Free->GetXaxis()->GetBinLabel(i+1));
double mod = 0.0;
if (!uniformly){
for (Int_t j = 0; j < decompHist_Free->GetNbinsY(); j++){
mod += rands[j] * decompHist_Free->GetBinContent(j+1,i+1);
}
}
if (currentVals.find(parname) != currentVals.end()) {
if (fixVals.at(parname)) continue;
if (uniformly) thrownVals[parname] = gRandom->Uniform(minVals[parname],maxVals[parname]);
else { thrownVals[parname] = currentVals[parname] + mod; }
- } else if (currentNorms.find(parname) != currentNorms.end()){
- if (fixNorms.at(parname)) continue;
-
- if (uniformly) thrownNorms[parname] = gRandom->Uniform(1.0, 0.7);
- else thrownNorms[parname] = currentNorms[parname]+ mod;
-
}
}
-
+
for (UInt_t i = 0; i < params.size(); i++){
if (fixVals.at(params[i])) continue;
if (thrownVals[params[i]] < minVals[params[i]]) thrownVals[params[i]] = minVals[params[i]];
if (thrownVals[params[i]] > maxVals[params[i]]) thrownVals[params[i]] = maxVals[params[i]];
}
- for (UInt_t i = 0; i < sampleDials.size(); i++){
- if (thrownNorms.at(sampleDials[i])) continue;
- if (thrownNorms[sampleDials[i]] < 0.3) thrownNorms[sampleDials[i]] = 0.3;
- if (thrownNorms[sampleDials[i]] > 1.7) thrownNorms[sampleDials[i]] = 1.7;
- }
-
return;
};
//*************************************
void systematicRoutines::GenerateErrorBands(){
//*************************************
TDirectory* errorDIR = (TDirectory*) outputFile->mkdir("error_bands");
errorDIR->cd();
TFile* tempfile = new TFile((outputFileName + ".throws.root").c_str(),"RECREATE");
tempfile->cd();
int nthrows = FitPar::Config().GetParI("error_throws");
- updateRWEngine(currentVals, currentNorms);
+ updateRWEngine(currentVals);
thisFCN->ReconfigureAllEvents();
TDirectory* nominal = (TDirectory*) tempfile->mkdir("nominal");
nominal->cd();
thisFCN->Write();
TDirectory* outnominal = (TDirectory*) outputFile->mkdir("nominal_throw");
outnominal->cd();
thisFCN->Write();
errorDIR->cd();
TTree* parameterTree = new TTree("throws","throws");
double chi2;
for (UInt_t i = 0; i < params.size(); i++)
parameterTree->Branch(params[i].c_str(), &thrownVals[params[i]], (params[i] + "/D").c_str());
- for (UInt_t i = 0; i < sampleDials.size(); i++)
- parameterTree->Branch(sampleDials[i].c_str(), &thrownNorms[sampleDials[i]], (sampleDials[i] + "/D").c_str());
parameterTree->Branch("chi2",&chi2,"chi2/D");
bool uniformly = FitPar::Config().GetParB("error_uniform");
// Run Throws and save
for (Int_t i = 0; i < nthrows; i++){
TDirectory* throwfolder = (TDirectory*)tempfile->mkdir(Form("throw_%i",i));
throwfolder->cd();
ThrowCovariance(uniformly);
-
- cout << " Throwing " <<i << endl;
- // updateRWEngine(currentVals, currentNorms);
- // thisFCN->ReconfigureAllEvents();
- updateRWEngine(thrownVals, thrownNorms);
+ updateRWEngine(thrownVals);
thisFCN->ReconfigureAllEvents();
thisFCN->Write();
chi2 = thisFCN->GetLikelihood();
parameterTree->Fill();
}
errorDIR->cd();
decompHist_Free->Write();
covarHist_Free->Write();
parameterTree->Write();
for (UInt_t i = 0; i < input_covariances.size(); i++){
input_covariances.at(i).Write();
}
delete parameterTree;
// Now go through the keys in the temporary file and look for TH1D, and TH2D plots
TIter next(nominal->GetListOfKeys());
TKey *key;
while ((key = (TKey*)next())) {
TClass *cl = gROOT->GetClass(key->GetClassName());
if (!cl->InheritsFrom("TH1D") and !cl->InheritsFrom("TH2D")) continue;
TH1D *baseplot = (TH1D*)key->ReadObj();
std::string plotname = std::string(baseplot->GetName());
int nbins = baseplot->GetNbinsX()*baseplot->GetNbinsY();
// Setup TProfile with RMS option
TProfile* tprof = new TProfile((plotname + "_prof").c_str(),(plotname + "_prof").c_str(),nbins, 0, nbins, "S");
// Setup The TTREE
double* bincontents;
bincontents = new double[nbins];
double* binlowest;
binlowest = new double[nbins];
double* binhighest;
binhighest = new double[nbins];
errorDIR->cd();
TTree* bintree = new TTree((plotname + "_tree").c_str(), (plotname + "_tree").c_str());
for (Int_t i = 0; i < nbins; i++){
bincontents[i] = 0.0;
binhighest[i] = 0.0;
binlowest[i] = 0.0;
bintree->Branch(Form("content_%i",i),&bincontents[i],Form("content_%i/D",i));
}
for (Int_t i = 0; i < nthrows; i++){
TH1D* newplot = (TH1D*)tempfile->Get(Form(("throw_%i/" + plotname).c_str(),i));
newplot->GetSumw2();
for (Int_t j = 0; j < nbins; j++){
tprof->Fill(j+0.5, newplot->GetBinContent(j+1));
bincontents[j] = newplot->GetBinContent(j+1);
if (bincontents[j] < binlowest[j] or i == 0) binlowest[j] = bincontents[j];
if (bincontents[j] > binhighest[j] or i == 0) binhighest[j] = bincontents[j];
}
errorDIR->cd();
bintree->Fill();
delete newplot;
}
errorDIR->cd();
for (Int_t j = 0; j < nbins; j++){
if (!uniformly){
if (tprof->GetBinContent(j+1) != 0.0){
baseplot->SetBinError(j+1,
tprof->GetBinError(j+1) * baseplot->GetBinContent(j+1) / tprof->GetBinContent(j+1));
}
} else {
cout << "Setting bin from uniformly" << endl;
baseplot->SetBinContent(j+1, (binlowest[j] + binhighest[j]) / 2.0);
baseplot->SetBinError(j+1, (binhighest[j] - binlowest[j])/2.0);
}
}
errorDIR->cd();
baseplot->Write();
tprof->Write();
bintree->Write();
delete baseplot;
delete tprof;
delete bintree;
delete [] bincontents;
}
return;
};
diff --git a/src/Routines/systematicRoutines.h b/src/Routines/systematicRoutines.h
index 8a0090b..b34b1d4 100755
--- a/src/Routines/systematicRoutines.h
+++ b/src/Routines/systematicRoutines.h
@@ -1,314 +1,327 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#ifndef SYSTEMATIC_ROUTINES_H
#define SYSTEMATIC_ROUTINES_H
/*!
* \addtogroup Minimizer
* @{
*/
#include "TH1.h"
#include "TF1.h"
#include "TMatrixD.h"
#include "TVectorD.h"
#include "Minuit2/FCNBase.h"
#include "TFitterMinuit.h"
#include "TSystem.h"
#include "TFile.h"
#include "TProfile.h"
-
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <cstring>
#include "FitEvent.h"
#include "JointFCN.h"
#include "FitParameters.h"
+#include "ParamPull.h"
#include "Math/Minimizer.h"
#include "Math/Factory.h"
#include "Math/Functor.h"
#include "FitLogger.h"
//*************************************
//! Collects all possible fit routines into a single class to avoid repeated code
class systematicRoutines{
//*************************************
public:
/*
Constructor/Destructor
*/
//! Constructor reads in arguments given at the command line for the fit here.
systematicRoutines(int argc, char* argv[]);
//! Default destructor
~systematicRoutines();
/*
Input Functions
*/
//! Splits the arguments ready for initial setup
- void parseArgs(int argc, char* argv[]);
+ void ParseArgs(int argc, char* argv[]);
//! Sorts out configuration and verbosity right at the very start.
//! Calls readCard to set everything else up.
- void initialSetup();
+ void InitialSetup();
//! Loops through each line of the card file and passes it to other read functions
- void readCard();
+ void ReadCard();
+ void GetCovarFromFCN();
+
//! Check for parameter string in the line and assign the correct type.
//! Fills maps for each of the parameters
void readParameters(std::string parstring);
//! Reads in fake parameters and assigns them (Requires the parameter to be included as a normal parameter as well)
void readFakeDataPars(std::string parstring);
//! Read in the samples so we can set up the free normalisation dials if required
void readSamples(std::string sampleString);
//! Read in a parameter pulls class as a covariance for the fit. Currently just used for throwing covariances but will change covariance pull
//! terms to use this method soon so it is a bit clearer.
void readCovariance(std::string covarString);
/*
Setup Functions
*/
//! Setup the configuration given the arguments passed at the commandline and card file
void setupConfig();
//! Setups up our custom RW engine with all the parameters passed in the card file
void setupRWEngine();
//! Setups up the jointFCN.
void setupFCN();
//! Set the current data histograms in each sample to the fake data.
void setFakeData();
//! Setup the covariances with the correct dimensions. At the start this is either uncorrelated or merged given all the input covariances.
//! At the end of the fit this produces the blank covariances which can then be filled by the minimizerObj with best fit covariances.
void SetupCovariance();
//! Check all dials have been added to the input card so we can grab the limits
void checkCovarianceDials(bool printdials);
/*
Fitting Functions
*/
//! Main function to actually start iterating over the different required fit routines
void SelfFit();
//! Given a new map change the values that the RW engine is currently set to
- void updateRWEngine(std::map<std::string,double>& updateVals, std::map<std::string,double>& updateNorms);
+ void updateRWEngine(std::map<std::string,double>& updateVals);
//! Given a single routine (see tutorial for options) run that fit routine now.
void RunFitRoutine(std::string routine);
//! Throw the current covariance of dial values we have, and fill the thrownVals and thrownNorms maps.
//! If uniformly is true parameters will be thrown uniformly between their upper and lower limits.
void ThrowCovariance(bool uniformly);
//! Step through each parameter one by one and create folders containing the MC predictions at each step.
//! Doesn't handle correlated parameters well
void PlotLimits();
//! Given the covariance we currently have generate error bands by throwing the covariance.
//! The FitPar config "error_uniform" defines whether to throw using the covariance or uniformly.
//! The FitPar config "error_throws" defines how many throws are needed.
//! Currently only supports TH1D plots.
void GenerateErrorBands();
/*
Write Functions
*/
//! Write plots and TTrees listing the minimizerObj result of the fit to file
void saveMinimizerState();
//! Save the sample plots for current MC
//! dir if not empty forces plots to be saved in a subdirectory of outputfile
void saveCurrentState(std::string subdir="");
//! Save starting predictions into a seperate folder
void saveNominal();
//! Save predictions before the fit is ran into a seperate folder
void savePrefit();
/*
MISC Functions
*/
//! Get previous fit status from a file
Int_t GetStatus();
protected:
//! Our Custom ReWeight Object
FitWeight* rw;
// I/O
-
std::string outputFileName;
std::string inputFileName;
//! Input file from previous fit
TFile* inputFile;
//! Output file where the results are saved
TFile* outputFile;
//! Flag for whether the fit should be continued if an output file is already found.
bool fitContinue;
//! The actual chi2 Function from FCN module
JointFCN* thisFCN;
//! Current number of free parameters. callFCN requires this when being setup.
int nfreepars;
// Fit Options
//! Input cardfile containing fit samples and dials
std::string cardFile;
//! comma seperated list of fit routines to be run
std::string fitStrategy;
//! fitStrategy is parsed into this vector of fit routines. Each one is run in sequence and current values updated.
std::vector<std::string> fit_routines;
//! Directory of a fake data MC file to use for this fit. If "MC" is provided the starting nominal MC and provided fake_parameters are used as fake data.
std::string fakeDataFile;
//! Current fit type.
int type;
// Parameter Configs
//! vector command line config overrides
std::vector<std::string> configCmdFix;
// Input Dial Values
//! Vector of dial names
std::vector<std::string> params;
//! Map of dial names and dial types. 0 NEUT 1 NIWG 2 GENIE 3 NUWRO 4 CUSTOM
std::map<std::string,int> params_type;
//! Map of dial names and starting values given in the fit card
std::map<std::string, double> startVals;
//! Map of dial names and current values at this stage in the overall fitting routine
std::map<std::string, double> currentVals;
//! Map of dial names and current errors at this stage
std::map<std::string, double> errorVals;
//! Map of dial names and the minimum limits provided in the fit card
std::map<std::string, double> minVals;
//! Map of dial names and the maximum limits provided in the fit card
std::map<std::string, double> maxVals;
//! Map of dial names and the step values for this dial provided in the fit card.
//! Minuit seems to ignore this anyway, but it is used in the PlotLimits routine.
std::map<std::string, double> stepVals;
//! Map of dial names and flags for whether the parmaeter is currently fixed.
std::map<std::string, bool> fixVals;
//! Map of dial names and flags for whether the parameter started fixed.
std::map<std::string, bool> startFixVals;
// Input Samples
//! Vector of samples included in the fit
std::vector<std::string> samples;
//! Vector of sample normalisation dial names (sample + "_norm")
std::vector<std::string> sampleDials;
//! Map of norm dial names and the starting value given in the fit card
std::map<std::string, double> sampleNorms;
//! Map of norm dial names and the current value in the fit
std::map<std::string, double> currentNorms;
//! Map of norm dial names and the current error in the fit
std::map<std::string, double> errorNorms;
//! Map of norm dial names and whether it is currently fixed in the fit
std::map<std::string, bool> fixNorms;
//! Map of norm dial names and whether it started fixed
std::map<std::string, bool> startFixNorms;
//! Map of norm dial names and the files string input for those samples
std::map<std::string, std::string> sampleFiles;
//! Map of norm dial names and the type string for those samples
std::map<std::string, std::string> sampleTypes;
// Input Fake Data Sets
//! Vector of fake parameter names
std::vector<std::string> fakeParams;
//! Vector of fake parameter sample norms
std::vector<std::string> fakeSamples;
//! Map of fake dial names and their values
std::map<std::string,double> fakeVals;
//! Map of fake sample norm names and their values
std::map<std::string,double> fakeNorms;
//! Map of thrown parameter names and values (After ThrowCovariance)
std::map<std::string,double> thrownVals;
//! Map of thrown parameter names and values (After ThrowCovariance)
std::map<std::string,double> thrownNorms;
TH2D* covarHist; //!< Covariance matrix for the fit. At the start this is uncorrelated unless input covars are provided.
TH2D* covarHist_Free; //!< Covariance matrix for the free parameters fit. At the start this is uncorrelated unless input covars are provided.
TH2D* correlHist; //!< Correlation matrix for the fit. At the start this is uncorrelated unless input covars are provided.
TH2D* correlHist_Free; //!< Correlation matrix for the free parameters fit. At the start this is uncorrelated unless input covars are provided.
TH2D* decompHist; //!< Decomposition matrix for the fit. At the start this is uncorrelated unless input covars are provided.
TH2D* decompHist_Free; //!< Decomposition matrix for the free parameters fit. At the start this is uncorrelated unless input covars are provided.
std::vector<TH1D*> input_dials; //!< Vector of histograms from parameter pull classes that give central values of the input pull terms
std::vector<TH2D> input_covariances; //!< vector of histograms from parameter pull classes that give covariance of the input pull terms
+
+ std::vector <TH1D> fInputDials; //!< Vector of Input Histograms
+ std::vector <TMatrixDSym> fInputCovar; //!< Vector of Input Covariances
+
+ TH2D* fCovar;
+ TH2D* fCorrel;
+ TH2D* fDecomp;
+
+ TH2D* fCovarFree;
+ TH2D* fCorrelFree;
+ TH2D* fDecompFree;
+
};
/*! @} */
#endif
diff --git a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu.cxx b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu.cxx
index db81a64..6138bbf 100644
--- a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu.cxx
+++ b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu.cxx
@@ -1,234 +1,234 @@
// 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
#include "T2K_CC0pi_XSec_2DPcos_nu.h"
// The constructor
T2K_CC0pi_XSec_2DPcos_nu::T2K_CC0pi_XSec_2DPcos_nu(std::string name,
std::string inputfile,
FitWeight *rw,
std::string type,
std::string fakeDataFile){
- measurementName = name;
- analysis = measurementName.find("_II") != std::string::npos ? 2 : 1;
+ fName = name;
+ analysis = fName.find("_II") != std::string::npos ? 2 : 1;
forwardgoing = (type.find("REST") != std::string::npos);
EnuMin = 0;
EnuMax = 10.0;
exp_distance = 0.280;
default_types = "DIAG/FIX";
allowed_types = "DIAG/FIX";
data_points_x = 12;
data_points_y = 10;
Measurement2D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
Double_t tempx[12] = {0.2, 0.35, 0.5, 0.65, 0.8, 0.95, 1.1, 1.25, 1.5, 2.0, 3.0, 5.0};
Double_t tempy[10] = {-1.0, 0.0, 0.6, 0.7, 0.8, 0.85, 0.9, 0.94, 0.98, 1.0};
xBins = tempx;
yBins = tempy;
plotTitles = "; P_{#mu} (GeV); cos#theta_{#mu}; d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)";
- dataHist = new TH2D((measurementName+"_data").c_str(),
- (measurementName+"_data"+plotTitles).c_str(),
+ dataHist = new TH2D((fName+"_data").c_str(),
+ (fName+"_data"+plotTitles).c_str(),
data_points_x-1, xBins,
data_points_y-1, yBins);
SetHistograms(FitPar::GetDataBase()+"/T2K/CC0pi/data_release.root");
SetupDefaultHist();
// Diagonal covar setup
if (!isShape) addNormPenalty = true;
normError = 0.089; // Set from covar mat instead...
cout << " Inputs = "<<this->GetInput()<<std::endl;
// Get Scaling
scaleFactor = (eventHist->Integral("width")/(nevents+0.))*13.0/6.0/TotalIntegratedFlux(); // NEUT
};
bool T2K_CC0pi_XSec_2DPcos_nu::isSignal(FitEvent *event){
return SignalDef::isT2K_CC0pi(event, EnuMin, EnuMax, forwardgoing);
};
void T2K_CC0pi_XSec_2DPcos_nu::FillEventVariables(FitEvent* event){
double pmu = -999.9;
double CosThetaMu = -999.9;
// Loop over all particles
for (UInt_t j = 2; j < event->Npart(); ++j){
// Muon section
if ((event->PartInfo(j))->fPID == 13){
// Now find the kinematic values and fill the histogram
pmu = (event->PartInfo(j))->fP.Vect().Mag()/1000;
CosThetaMu = cos(((event->PartInfo(0))->fP.Vect().Angle((event->PartInfo(j))->fP.Vect())));
continue;
}
}
this->X_VAR = pmu;
this->Y_VAR = CosThetaMu;
return;
};
// Modification is needed after the full reconfigure to move bins around
// Otherwise this would need to be replaced by a TH2Poly which is too awkward.
void T2K_CC0pi_XSec_2DPcos_nu::ConvertEventRates(){
// Do standard conversion.
Measurement2D::ConvertEventRates();
if (analysis == 1){
// Following code handles weird ND280 Binning
int nbins = this->mcHist->GetNbinsX() + 1;
double total = 0.0;
// Y = 1
total = 0.0;
for (int i = 3; i < nbins; i++){
double width = this->mcHist->GetXaxis()->GetBinWidth(i) * this->mcHist->GetYaxis()->GetBinWidth(1);
total += this->mcHist->GetBinContent(i, 1) * width;
this->mcHist->SetBinContent(i,1,0);
}
this->mcHist->SetBinContent(3, 1, total / (1.0 * 29.6));
// Y = 2
total = 0.0;
for (int i = 5; i < nbins; i++){
double width = this->mcHist->GetXaxis()->GetBinWidth(i) * this->mcHist->GetYaxis()->GetBinWidth(2);
total += this->mcHist->GetBinContent(i, 2)* width;
this->mcHist->SetBinContent(i,2,0);
}
this->mcHist->SetBinContent(5, 2, total / (0.6 *29.4));
// Y = 3
total = 0.0;
for (int i = 7; i < nbins; i++){
double width = this->mcHist->GetXaxis()->GetBinWidth(i) * this->mcHist->GetYaxis()->GetBinWidth(3);
total += this->mcHist->GetBinContent(i, 3)* width;
this->mcHist->SetBinContent(i, 3,0);
}
this->mcHist->SetBinContent(7, 3, total/ (0.1 * 29.2));
// Y = 4
total = 0.0;
for (int i = 7; i < nbins; i++){
double width = this->mcHist->GetXaxis()->GetBinWidth(i) * this->mcHist->GetYaxis()->GetBinWidth(4);
total += this->mcHist->GetBinContent(i, 4)* width;
this->mcHist->SetBinContent(i, 4,0);
}
this->mcHist->SetBinContent(7, 4, total / (0.1 * 29.2));
// Y = 5
total = 0.0;
for (int i = 8; i < nbins; i++){
double width = this->mcHist->GetXaxis()->GetBinWidth(i) * this->mcHist->GetYaxis()->GetBinWidth(5);
total += this->mcHist->GetBinContent(i, 5)* width;
this->mcHist->SetBinContent(i,5,0);
}
this->mcHist->SetBinContent(8, 5, total / (0.05 * 29.0));
// Y = 6
total = 0.0;
for (int i = 9; i < nbins; i++){
double width = this->mcHist->GetXaxis()->GetBinWidth(i) * this->mcHist->GetYaxis()->GetBinWidth(6);
total += this->mcHist->GetBinContent(i, 6)* width;
this->mcHist->SetBinContent(i, 6,0);
}
this->mcHist->SetBinContent(9, 6, total / (0.05 * 28.5));
// Y = 7
total = 0.0;
for (int i = 8; i < nbins; i++){
double width = this->mcHist->GetXaxis()->GetBinWidth(i) * this->mcHist->GetYaxis()->GetBinWidth(7);
total += this->mcHist->GetBinContent(i, 7)* width;
this->mcHist->SetBinContent(i, 7,0);
}
this->mcHist->SetBinContent(8, 7, total/ (0.04 * 28.0));
// Y = 8
total = 0.0;
for (int i = 11; i < nbins; i++){
double width = this->mcHist->GetXaxis()->GetBinWidth(i) * this->mcHist->GetYaxis()->GetBinWidth(8);
total += this->mcHist->GetBinContent(i, 8)* width;
this->mcHist->SetBinContent(i, 8,0);
}
this->mcHist->SetBinContent(11, 8, total / (0.4 * 27.0));
// Y = 9
total = 0.0;
for (int i = 9; i < nbins; i++){
double width = this->mcHist->GetXaxis()->GetBinWidth(i) * this->mcHist->GetYaxis()->GetBinWidth(9);
total += this->mcHist->GetBinContent(i, 9)* width;
this->mcHist->SetBinContent(i,9,0);
}
this->mcHist->SetBinContent(9, 9, total / (0.02 * 25.0));
}
return;
}
void T2K_CC0pi_XSec_2DPcos_nu::SetHistograms(std::string infile){
LOG(SAM)<<"Reading data from "<<infile<<std::endl;
TFile* rootfile = new TFile(infile.c_str(),"READ");
if (analysis == 1){
} else {
rootfile->ls();
- this->dataHist = (TH2D*) rootfile->Get("data_analysis2")->Clone((this->measurementName+"_data").c_str());
- this->mapHist = (TH2I*) rootfile->Get("map_analysis2")->Clone((this->measurementName+"_MAP").c_str());
+ this->dataHist = (TH2D*) rootfile->Get("data_analysis2")->Clone((this->fName+"_data").c_str());
+ this->mapHist = (TH2I*) rootfile->Get("map_analysis2")->Clone((this->fName+"_MAP").c_str());
TMatrixDSym* covmat_stat = (TMatrixDSym*) rootfile->Get("analysis2_statcov");
TMatrixDSym* covmat_flux = (TMatrixDSym*) rootfile->Get("analysis2_fluxcov");
TMatrixDSym* covmat_syst = (TMatrixDSym*) rootfile->Get("analysis2_systcov");
// Get flags
this->fullcovar = new TMatrixDSym(67);
for (int i = 0; i < 67; i++){
for (int j = 0; j < 67; j++){
(*fullcovar)(i,j) = (*fullcovar)(i,j) + (*covmat_stat)(i,j);
(*fullcovar)(i,j) = (*fullcovar)(i,j) + (*covmat_flux)(i,j);
(*fullcovar)(i,j) = (*fullcovar)(i,j) + (*covmat_syst)(i,j);
}
}
this->covar = StatUtils::GetInvert(fullcovar);
this->decomp = StatUtils::GetDecomp(covar);
}
return;
};
diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx
index 7a576f8..4e6c47e 100644
--- a/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx
+++ b/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx
@@ -1,208 +1,208 @@
#include "T2K_CC1pip_CH_XSec_1DQ2_nu.h"
#include <iomanip>
// The constructor
T2K_CC1pip_CH_XSec_1DQ2_nu::T2K_CC1pip_CH_XSec_1DQ2_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
EnuMin = 0.;
EnuMax = 10.;
isDiag = false;
// Here we can give either MB (kMB), extended MB (keMB) or Delta (kDelta)
if (type.find("eMB") != std::string::npos) {
fitType = keMB;
- measurementName = "T2K_CC1pip_CH_XSec_1DQ2eMB_nu";
+ fName = "T2K_CC1pip_CH_XSec_1DQ2eMB_nu";
plotTitles = "; Q^{2}_{eMB} (GeV^{2}); d#sigma/dQ^{2}_{eMB} (cm^{2}/GeV^{2}/nucleon)";
} else if (type.find("MB") != std::string::npos) {
fitType = kMB;
- measurementName = "T2K_CC1pip_CH_XSec_1DQ2MB_nu";
+ fName = "T2K_CC1pip_CH_XSec_1DQ2MB_nu";
plotTitles = "; Q^{2}_{MB} (GeV^{2}); d#sigma/dQ^{2}_{MB} (cm^{2}/GeV^{2}/nucleon)";
} else if (type.find("Delta") != std::string::npos) {
fitType = kDelta;
- measurementName = "T2K_CC1pip_CH_XSec_1DQ2delta_nu";
+ fName = "T2K_CC1pip_CH_XSec_1DQ2delta_nu";
plotTitles = "; Q^{2}_{#Delta} (GeV^{2}); d#sigma/dQ^{2}_{#Delta} (cm^{2}/GeV^{2}/nucleon)";
} else {
std::cout << "Found no specified type, using MiniBooNE E_nu/Q2 definition" << std::endl;
fitType = kMB;
- measurementName = "T2K_CC1pip_CH_XSec_1DQ2MB_nu";
+ fName = "T2K_CC1pip_CH_XSec_1DQ2MB_nu";
plotTitles = "; Q^{2}_{MB} (GeV^{2}); d#sigma/dQ^{2}_{MB} (cm^{2}/GeV^{2}/nucleon)";
}
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
//type = keMB;
//type = kDelta;
if (fitType == kMB) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Q2_MB.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Q2_MB.root");
} else if (fitType == keMB) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Q2_extendedMB.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Q2_extendedMB.root");
} else if (fitType == kDelta) {
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Q2_Delta.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Q2_Delta.root");
} else {
- std::cerr << "No data type set for " << measurementName << std::endl;
+ std::cerr << "No data type set for " << fName << std::endl;
std::cerr << __FILE__ << ":" << __LINE__ << std::endl;
exit(-1);
}
this->SetupDefaultHist();
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1DQ2_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
// Don't want the last bin of dataCopy
TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone();
const int nPoints = dataCopy->GetNbinsX()-6;
std::cout << nPoints << std::endl;
double *binEdges = new double[nPoints+1];
for (int i = 0; i < nPoints+1; i++) {
binEdges[i] = dataCopy->GetBinLowEdge(i+1);
}
for (int i = 0; i < nPoints+1; i++) {
std::cout << "binEdges[" << i << "] = " << binEdges[i] << std::endl;
}
- dataHist = new TH1D((measurementName+"_data").c_str(), (measurementName+"_data"+plotTitles).c_str(), nPoints, binEdges);
+ dataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+plotTitles).c_str(), nPoints, binEdges);
for (int i = 0; i < dataHist->GetNbinsX(); i++) {
dataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38);
dataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38);
std::cout << dataHist->GetBinLowEdge(i+1) << " " << dataHist->GetBinContent(i+1) << " " << dataHist->GetBinError(i+1) << std::endl;
}
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
- dataHist->SetNameTitle((measurementName+"_data").c_str(), (measurementName+"_MC"+plotTitles).c_str());
+ dataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+plotTitles).c_str());
dataFile->Close();
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1DQ2_nu::SetCovarMatrix(std::string fileLocation) {
std::cout << "Covariance: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone();
int nBinsX = covarMatrix->GetXaxis()->GetNbins();
int nBinsY = covarMatrix->GetYaxis()->GetNbins();
std::cout << nBinsX << std::endl;
std::cout << dataHist->GetNbinsX() << std::endl;
if ((nBinsX != nBinsY)) std::cerr << "covariance matrix not square!" << std::endl;
this->covar = new TMatrixDSym(nBinsX-7);
this->fullcovar = new TMatrixDSym(nBinsX-7);
// First two entries are BS
// Last entry is BS
for (int i = 0; i < nBinsX-7; i++) {
for (int j = 0; j < nBinsY-7; j++) {
(*this->covar)(i, j) = covarMatrix->GetBinContent(i+3, j+3); //adds syst+stat covariances
(*this->fullcovar)(i, j) = covarMatrix->GetBinContent(i+3, j+3); //adds syst+stat covariances
std::cout << "covar(" << i << ", " << j << ") = " << (*this->covar)(i,j) << std::endl;
}
} //should now have set covariance, I hope
TDecompChol tempMat = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), "");
*this->covar *= 1E-38*1E-38;
return;
};
void T2K_CC1pip_CH_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double q2 = -999;
switch(fitType) {
// First int refers to how we reconstruct Enu
// 0 uses true neutrino energy (not used here but common for other analyses when they unfold to true Enu from reconstructed Enu)
// 1 uses "extended MiniBooNE" method
// 2 uses "MiniBooNE reconstructed" method
// 3 uses Delta resonance mass for reconstruction
//
// The last bool refers to if pion directional information was used
//
// Use MiniBooNE reconstructed Enu; uses Michel tag so no pion direction information
case kMB:
q2 = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip, 2, false);
break;
// Use Extended MiniBooNE reconstructed Enu
// Needs pion information to reconstruct so bool is true (did not include Michel e tag)
case keMB:
q2 = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip, 1, true);
break;
// Use Delta resonance reconstructed Enu
// Uses Michel electron so don't have pion directional information
case kDelta:
q2 = FitUtils::Q2CC1piprec(Pnu, Pmu, Ppip, 3, false);
break;
}
this->X_VAR = q2;
return;
};
//********************************************************************
bool T2K_CC1pip_CH_XSec_1DQ2_nu::isSignal(FitEvent *event) {
//********************************************************************
// Warning: The CH analysis has different signal definition to the H2O analysis!
// Often to do with the Michel tag
switch(fitType) {
// Using MiniBooNE formula for Enu reconstruction on the Q2 variable
// Does have Michel e tag, set bool to true!
case kMB:
return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true);
break;
// Using extended MiniBooNE formula for Enu reconstruction on the Q2 variable
// Does not have Michel e tag because we need directional information to reconstruct Q2
case keMB:
return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, false);
break;
// Using Delta resonance for Enu reconstruction on the Q2 variable
// Does have Michel e tag, bool to true
case kDelta:
return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true);
break;
}
// Default to return false
return false;
}
diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1DWrec_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1DWrec_nu.cxx
index 5897cd6..8874e2e 100644
--- a/src/T2K/T2K_CC1pip_CH_XSec_1DWrec_nu.cxx
+++ b/src/T2K/T2K_CC1pip_CH_XSec_1DWrec_nu.cxx
@@ -1,122 +1,122 @@
#include "T2K_CC1pip_CH_XSec_1DWrec_nu.h"
#include <iomanip>
// The constructor
T2K_CC1pip_CH_XSec_1DWrec_nu::T2K_CC1pip_CH_XSec_1DWrec_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "T2K_CC1pip_CH_XSec_1DWrec_nu";
+ fName = "T2K_CC1pip_CH_XSec_1DWrec_nu";
plotTitles = "; W_{rec} (GeV/c); d#sigma/dW_{rec} (cm^{2}/(GeV/c^{2})/nucleon)";
EnuMin = 0.;
EnuMax = 10.;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/W.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/W.root");
this->SetupDefaultHist();
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1DWrec_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
// Don't want the first and last bin of dataCopy
TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone();
std::cout << dataCopy->GetNbinsX() << std::endl;
const int dataPoints = dataCopy->GetNbinsX()-2;
double *binEdges = new double[dataPoints+1];
// Want to skip the first bin here
for (int i = 0; i < dataPoints+1; i++) {
binEdges[i] = dataCopy->GetBinLowEdge(i+2);
}
for (int i = 0; i < dataPoints+1; i++) {
std::cout << "binEdges[" << i << "] = " << binEdges[i] << std::endl;
}
- dataHist = new TH1D((measurementName+"_data").c_str(), (measurementName+"_data"+plotTitles).c_str(), dataPoints, binEdges);
+ dataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+plotTitles).c_str(), dataPoints, binEdges);
for (int i = 0; i < dataHist->GetNbinsX(); i++) {
dataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+2)*1E-38);
dataHist->SetBinError(i+1, dataCopy->GetBinError(i+2)*1E-38);
std::cout << dataHist->GetBinLowEdge(i+1) << " " << dataHist->GetBinContent(i+1) << " " << dataHist->GetBinError(i+1) << std::endl;
}
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
- //dataHist->SetNameTitle((measurementName+"_data").c_str(), (measurementName+"_MC"+plotTitles).c_str());
+ //dataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+plotTitles).c_str());
dataFile->Close();
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1DWrec_nu::SetCovarMatrix(std::string fileLocation) {
std::cout << "Covariance: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone();
const int nBinsX = covarMatrix->GetXaxis()->GetNbins();
const int nBinsY = covarMatrix->GetYaxis()->GetNbins();
if ((nBinsX != nBinsY)) std::cerr << "covariance matrix not square!" << std::endl;
std::cout << nBinsX << std::endl;
std::cout << dataHist->GetNbinsX() << std::endl;
this->covar = new TMatrixDSym(nBinsX-3);
this->fullcovar = new TMatrixDSym(nBinsX-3);
for (int i = 0; i < nBinsX-3; i++) {
for (int j = 0; j < nBinsY-3; j++) {
(*this->covar)(i, j) = covarMatrix->GetBinContent(i+4, j+4); //adds syst+stat covariances
std::cout << "covar(" << i << ", " << j << ") = " << (*this->covar)(i,j) << std::endl;
}
} //should now have set covariance, I hope
TDecompChol tempMat = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), "");
*this->covar *= 1E-38*1E-38;
return;
};
void T2K_CC1pip_CH_XSec_1DWrec_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double Wrec = FitUtils::WrecCC1pip_T2K_MB(Pnu, Pmu, Ppip);
this->X_VAR = Wrec;
return;
};
//********************************************************************
bool T2K_CC1pip_CH_XSec_1DWrec_nu::isSignal(FitEvent *event) {
//********************************************************************
// This sample includes the Michel e tag so do not have to cut into the pion phase space
return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true);
}
diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dpmu_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dpmu_nu.cxx
index 6133fbf..bcf9ff1 100644
--- a/src/T2K/T2K_CC1pip_CH_XSec_1Dpmu_nu.cxx
+++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dpmu_nu.cxx
@@ -1,181 +1,181 @@
#include "T2K_CC1pip_CH_XSec_1Dpmu_nu.h"
#include <iomanip>
// The constructor
T2K_CC1pip_CH_XSec_1Dpmu_nu::T2K_CC1pip_CH_XSec_1Dpmu_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "T2K_CC1pip_CH_XSec_1Dpmu_nu";
+ fName = "T2K_CC1pip_CH_XSec_1Dpmu_nu";
plotTitles = "; p_{#mu} (GeV/c); d#sigma/dp_{#mu} (cm^{2}/(GeV/c)/nucleon)";
EnuMin = 0.;
EnuMax = 10.;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Pmu.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Pmu.root");
this->SetupDefaultHist();
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dpmu_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
// Don't want the last bin of dataCopy
TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone();
std::cout << dataCopy->GetNbinsX() << std::endl;
double *binEdges = new double[dataCopy->GetNbinsX()-1];
for (int i = 0; i < dataCopy->GetNbinsX()-1; i++) {
binEdges[i] = dataCopy->GetBinLowEdge(i+1);
}
binEdges[dataCopy->GetNbinsX()-1] = dataCopy->GetBinLowEdge(dataCopy->GetNbinsX());
for (int i = 0; i < dataCopy->GetNbinsX()+5; i++) {
std::cout << "binEdges[" << i << "] = " << binEdges[i] << std::endl;
}
- dataHist = new TH1D((measurementName+"_data").c_str(), (measurementName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX()-1, binEdges);
+ dataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX()-1, binEdges);
for (int i = 0; i < dataHist->GetNbinsX(); i++) {
dataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38);
dataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38);
std::cout << dataHist->GetBinLowEdge(i+1) << " " << dataHist->GetBinContent(i+1) << std::endl;
}
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
- dataHist->SetNameTitle((measurementName+"_data").c_str(), (measurementName+"_MC"+plotTitles).c_str());
+ dataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+plotTitles).c_str());
dataFile->Close();
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dpmu_nu::SetCovarMatrix(std::string fileLocation) {
std::cout << "Covariance: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone();
int nBinsX = covarMatrix->GetXaxis()->GetNbins();
int nBinsY = covarMatrix->GetYaxis()->GetNbins();
if ((nBinsX != nBinsY)) std::cerr << "covariance matrix not square!" << std::endl;
this->covar = new TMatrixDSym(nBinsX-2);
this->fullcovar = new TMatrixDSym(nBinsX-2);
// First two entries are BS
// Last entry is BS
for (int i = 1; i < nBinsX-1; i++) {
for (int j = 1; j < nBinsY-1; j++) {
(*this->covar)(i-1, j-1) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances
(*this->fullcovar)(i-1, j-1) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances
std::cout << "covar(" << i-1 << ", " << j-1 << ") = " << (*this->covar)(i-1,j-1) << std::endl;
}
} //should now have set covariance, I hope
TDecompChol tempMat = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), "");
*this->covar *= 1E-38*1E-38;
return;
};
void T2K_CC1pip_CH_XSec_1Dpmu_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double pmu = FitUtils::p(Pmu);
this->X_VAR = pmu;
return;
};
//********************************************************************
bool T2K_CC1pip_CH_XSec_1Dpmu_nu::isSignal(FitEvent *event) {
//********************************************************************
// Warning: The CH analysis has different signal definition to the H2O analysis!
//
// If Michel e- is used for pion PID we don't have directional info on pion; set the bool to true
// The bool is if we use Michel e- or not
// Also, for events binned in muon momentum/angle there's no cut on the pion kinematics
//
// Additionally, the 2D distribution uses 0.8 > cos th mu > 0 and no pion phase space reduction applied
// Also no muon momentum reduction applied
//
// This uses a slightly custom signal definition where a cut is only placed on the muon angle, not the momentum
//
// Pretty much a copy/paste of SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true), excluding the muon momentum requirement
if ((event->PartInfo(0))->fPID != 14) return false;
if (((event->PartInfo(0))->fP.E() < EnuMin*1000.) || ((event->PartInfo(0))->fP.E() > EnuMax*1000.)) return false;
if (((event->PartInfo(2))->fPID != 13) && ((event->PartInfo(3))->fPID != 13)) return false;
int pipCnt = 0; // counts number of pions
int lepCnt = 0;
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
for (unsigned int j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
// Ignore any non pi+ mesons
if ((abs(PID) >= 111 && abs(PID) <= 210) || (abs(PID) >= 212 && abs(PID) <= 557) || PID == -211) return false;
// Count leptons
else if (abs(PID) == 13) {
lepCnt++;
Pmu = (event->PartInfo(j))->fP;
}
else if (PID == 211) {
pipCnt++;
Ppip = (event->PartInfo(j))->fP;
}
}
if (pipCnt != 1) return false;
if (lepCnt != 1) return false;
// relatively generic CC1pi+ definition done
//
// now measurement specific depending on if we have Michel e- tag or not in measurement
double cos_th_mu = cos(FitUtils::th(Pnu,Pmu));
if (cos_th_mu <= 0.2) {
return false;
} else {
return true;
}
// Unnecssary default to false
return false;
}
diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx
index d0f8d1d..c97d90c 100644
--- a/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx
+++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx
@@ -1,165 +1,165 @@
#include "T2K_CC1pip_CH_XSec_1Dppi_nu.h"
#include <iomanip>
// The constructor
T2K_CC1pip_CH_XSec_1Dppi_nu::T2K_CC1pip_CH_XSec_1Dppi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "T2K_CC1pip_CH_XSec_1Dppi_nu";
+ fName = "T2K_CC1pip_CH_XSec_1Dppi_nu";
plotTitles = "; p_{#pi} (GeV/c); d#sigma/dW_{rec} (cm^{2}/(GeV/c)/nucleon)";
EnuMin = 0.;
EnuMax = 10.;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
if (type.find("Michel") != std::string::npos) {
useMichel = true;
- measurementName += "_Michel";
+ fName += "_Michel";
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Ppi.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Ppi.root");
} else {
useMichel = false;
- measurementName += "_kin";
+ fName += "_kin";
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Ppi_noME.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Ppi_noME.root");
}
this->SetupDefaultHist();
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dppi_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
// Don't want the last bin of dataCopy
TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone();
std::cout << dataCopy->GetNbinsX() << std::endl;
double *binEdges = new double[dataCopy->GetNbinsX()-1];
for (int i = 0; i < dataCopy->GetNbinsX()-1; i++) {
binEdges[i] = dataCopy->GetBinLowEdge(i+1);
}
binEdges[dataCopy->GetNbinsX()-1] = dataCopy->GetBinLowEdge(dataCopy->GetNbinsX());
- dataHist = new TH1D((measurementName+"_data").c_str(), (measurementName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX()-2, binEdges);
+ dataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX()-2, binEdges);
for (int i = 0; i < dataHist->GetNbinsX(); i++) {
dataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38);
dataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38);
std::cout << dataHist->GetBinLowEdge(i+1) << " " << dataHist->GetBinContent(i+1) << std::endl;
}
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
- dataHist->SetNameTitle((measurementName+"_data").c_str(), (measurementName+"_MC"+plotTitles).c_str());
+ dataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+plotTitles).c_str());
dataFile->Close();
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dppi_nu::SetCovarMatrix(std::string fileLocation) {
std::cout << "Covariance: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone();
int nBinsX = covarMatrix->GetXaxis()->GetNbins();
int nBinsY = covarMatrix->GetYaxis()->GetNbins();
if ((nBinsX != nBinsY)) std::cerr << "covariance matrix not square!" << std::endl;
this->covar = new TMatrixDSym(nBinsX-2);
this->fullcovar = new TMatrixDSym(nBinsX-2);
// First two entries are BS
// Last entry is BS
for (int i = 1; i < nBinsX-1; i++) {
for (int j = 1; j < nBinsY-1; j++) {
//std::cout << "(" << i << ", " << j << ") = " << covarMatrix->GetBinContent(i+1,j+1) << std::endl;
(*this->covar)(i-1, j-1) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances
(*this->fullcovar)(i-1, j-1) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances
}
} //should now have set covariance, I hope
TDecompChol tempMat = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), "");
*this->covar *= 1E-38*1E-38;
return;
};
void T2K_CC1pip_CH_XSec_1Dppi_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double ppip = FitUtils::p(Ppip);
this->X_VAR = ppip;
return;
};
//********************************************************************
bool T2K_CC1pip_CH_XSec_1Dppi_nu::isSignal(FitEvent *event) {
//********************************************************************
// This distribution uses a somewhat different signal definition so might as well implement it separately here
// If we use Michel tag sample we don't cut into the pion phase space, only the muon phase space
// The last bool refers to if we have Michel e or not
if (useMichel) {
return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true);
} else { // Custom signal definition if we aren't using Michel tag; cut on muon and cut only on pion angle
// does the event pass the muon cut?
bool muonPass = SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true);
// If the event doesn't pass the muon cut return false
if (!muonPass) {
return false;
}
// does the event pass the pion angle cut?
// we already know there's just one muon in the event if it passes muonPass so don't need to make an event loop rejection
// Need the neutrino four-vector to get the angle between pion and neutrino
TLorentzVector Pnu = event->PartInfo(0)->fP;
TLorentzVector Ppip;
for (unsigned int j = 2; j < event->Npart(); j++) {
if (!((event->PartInfo(j))->fIsAlive) && (event->PartInfo(j))->fStatus != 0) continue; //move on if NOT ALIVE and NOT NORMAL
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP; // Once the pion is found we can break
break;
}
}
double cos_th_pi = cos(FitUtils::th(Pnu, Ppip));
// Now check the angle of the pion
if (cos_th_pi <= 0.2) {
return false;
} else {
return true;
}
}
// Unnecessary default to false
return false;
}
diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dq3_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dq3_nu.cxx
index 13a6aab..79fee81 100644
--- a/src/T2K/T2K_CC1pip_CH_XSec_1Dq3_nu.cxx
+++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dq3_nu.cxx
@@ -1,123 +1,123 @@
#include "T2K_CC1pip_CH_XSec_1Dq3_nu.h"
#include <iomanip>
// The constructor
T2K_CC1pip_CH_XSec_1Dq3_nu::T2K_CC1pip_CH_XSec_1Dq3_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "T2K_CC1pip_CH_XSec_1Dq3_nu";
+ fName = "T2K_CC1pip_CH_XSec_1Dq3_nu";
plotTitles = "; q_{3} (GeV/c); d#sigma/dq_{3} (cm^{2}/(GeV/c)/nucleon)";
EnuMin = 0.;
EnuMax = 10.;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Q3.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Q3.root");
this->SetupDefaultHist();
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dq3_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
// Don't want the last bin of dataCopy
TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone();
double *binEdges = new double[dataCopy->GetNbinsX()-1];
std::cout << dataCopy->GetNbinsX() << std::endl;
for (int i = 1; i < dataCopy->GetNbinsX(); i++) {
binEdges[i-1] = dataCopy->GetBinLowEdge(i+1);
std::cout << i-1 << " " << binEdges[i-1] << " from binLowEdge " << i+1 << std::endl;
}
/*
for (int i = 0; i < dataCopy->GetNbinsX()+5; i++) {
std::cout << "binEdges[" << i << "] = " << binEdges[i] << std::endl;
}
*/
- dataHist = new TH1D((measurementName+"_data").c_str(), (measurementName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX()-2, binEdges);
+ dataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX()-2, binEdges);
for (int i = 0; i < dataHist->GetNbinsX(); i++) {
dataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+2)*1E-38);
dataHist->SetBinError(i+1, dataCopy->GetBinError(i+2)*1E-38);
std::cout << dataHist->GetBinLowEdge(i+1) << " " << dataHist->GetBinContent(i+1) << " " << dataHist->GetBinError(i+1) << std::endl;
}
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
- dataHist->SetNameTitle((measurementName+"_data").c_str(), (measurementName+"_MC"+plotTitles).c_str());
+ dataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+plotTitles).c_str());
dataFile->Close();
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dq3_nu::SetCovarMatrix(std::string fileLocation) {
std::cout << "Covariance: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone();
int nBinsX = covarMatrix->GetXaxis()->GetNbins();
int nBinsY = covarMatrix->GetYaxis()->GetNbins();
if ((nBinsX != nBinsY)) std::cerr << "covariance matrix not square!" << std::endl;
this->covar = new TMatrixDSym(nBinsX-2);
this->fullcovar = new TMatrixDSym(nBinsX-2);
// First two entries are BS
// Last entry is BS
for (int i = 2; i < nBinsX-1; i++) {
for (int j = 2; j < nBinsY-1; j++) {
(*this->covar)(i-2, j-2) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances
(*this->fullcovar)(i-2, j-2) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances
std::cout << "covar(" << i-2 << ", " << j-2 << ") = " << (*this->covar)(i-2,j-2) << std::endl;
}
} //should now have set covariance, I hope
TDecompChol tempMat = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), "");
*this->covar *= 1E-38*1E-38;
return;
};
void T2K_CC1pip_CH_XSec_1Dq3_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double q3 = FitUtils::q3_CC1pip_T2K(Pnu, Pmu, Ppip);
this->X_VAR = q3;
return;
};
//********************************************************************
bool T2K_CC1pip_CH_XSec_1Dq3_nu::isSignal(FitEvent *event) {
//********************************************************************
// Has a Michel e sample in so no phase space cut on pion required
return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, true);
}
diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx
index 89af24c..9374c58 100644
--- a/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx
+++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx
@@ -1,117 +1,117 @@
#include "T2K_CC1pip_CH_XSec_1Dthmupi_nu.h"
#include <iomanip>
// The constructor
T2K_CC1pip_CH_XSec_1Dthmupi_nu::T2K_CC1pip_CH_XSec_1Dthmupi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "T2K_CC1pip_CH_XSec_1Dthmupi_nu";
+ fName = "T2K_CC1pip_CH_XSec_1Dthmupi_nu";
plotTitles = "; #theta_{#pi,#mu} (radians); d#sigma/d#theta_{#pi} (cm^{2}/nucleon)";
EnuMin = 0.;
EnuMax = 10.;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Thetapimu.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Thetapimu.root");
this->SetupDefaultHist();
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dthmupi_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
// Don't want the first and last bin of dataCopy
TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone();
std::cout << "dataCopy->GetNbinsX() = " << dataCopy->GetNbinsX() << std::endl;
double *binEdges = new double[dataCopy->GetNbinsX()];
for (int i = 0; i < dataCopy->GetNbinsX(); i++) {
binEdges[i] = dataCopy->GetBinLowEdge(i+1);
}
binEdges[dataCopy->GetNbinsX()] = dataCopy->GetBinLowEdge(dataCopy->GetNbinsX()+1);
for (int i = 0; i < dataCopy->GetNbinsX()+5; i++) {
std::cout << "binEdges[" << i << "] = " << binEdges[i] << std::endl;
}
- dataHist = new TH1D((measurementName+"_data").c_str(), (measurementName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX(), binEdges);
+ dataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX(), binEdges);
for (int i = 0; i < dataHist->GetNbinsX()+1; i++) {
dataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38);
dataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38);
std::cout << dataHist->GetBinLowEdge(i+1) << " " << dataHist->GetBinContent(i+1) << " " << dataHist->GetBinError(i+1) << std::endl;
}
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
dataFile->Close();
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dthmupi_nu::SetCovarMatrix(std::string fileLocation) {
std::cout << "Covariance: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone();
int nBinsX = covarMatrix->GetXaxis()->GetNbins();
int nBinsY = covarMatrix->GetYaxis()->GetNbins();
if ((nBinsX != nBinsY)) std::cerr << "covariance matrix not square!" << std::endl;
this->covar = new TMatrixDSym(nBinsX-1);
this->fullcovar = new TMatrixDSym(nBinsX-1);
for (int i = 1; i < nBinsX; i++) {
for (int j = 1; j < nBinsY; j++) {
(*this->covar)(i-1, j-1) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances
(*this->fullcovar)(i-1, j-1) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances
std::cout << "covar(" << i-1 << ", " << j-1 << ") = " << (*this->covar)(i-1,j-1) << std::endl;
}
} //should now have set covariance, I hope
TDecompChol tempMat = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), "");
*this->covar *= 1E-38*1E-38;
dataFile->Close();
};
void T2K_CC1pip_CH_XSec_1Dthmupi_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double thmupi = FitUtils::th(Pmu, Ppip);
this->X_VAR = thmupi;
return;
};
//********************************************************************
bool T2K_CC1pip_CH_XSec_1Dthmupi_nu::isSignal(FitEvent *event) {
//********************************************************************
// This sample requires directional information on the pion so can't use Michel tag sample
return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, false);
}
diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx
index 0c82743..044717e 100644
--- a/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx
+++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx
@@ -1,119 +1,119 @@
#include "T2K_CC1pip_CH_XSec_1Dthpi_nu.h"
#include <iomanip>
// The constructor
T2K_CC1pip_CH_XSec_1Dthpi_nu::T2K_CC1pip_CH_XSec_1Dthpi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "T2K_CC1pip_CH_XSec_1Dthpi_nu";
+ fName = "T2K_CC1pip_CH_XSec_1Dthpi_nu";
plotTitles = "; #theta_{#pi} (radians); d#sigma/d#theta_{#pi} (cm^{2}/nucleon)";
EnuMin = 0.;
EnuMax = 10.;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Thetapi.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/Thetapi.root");
this->SetupDefaultHist();
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dthpi_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
// Don't want the first and last bin of dataCopy
TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone();
//std::cout << "dataCopy->GetNbinsX() = " << dataCopy->GetNbinsX() << std::endl;
double *binEdges = new double[dataCopy->GetNbinsX()-4];
for (int i = 0; i < dataCopy->GetNbinsX()-4; i++) {
binEdges[i] = dataCopy->GetBinLowEdge(i+1);
}
binEdges[dataCopy->GetNbinsX()-4] = dataCopy->GetBinLowEdge(dataCopy->GetNbinsX()-3);
for (int i = 0; i < dataCopy->GetNbinsX(); i++) {
//std::cout << "binEdges[" << i << "] = " << binEdges[i] << std::endl;
}
- dataHist = new TH1D((measurementName+"_data").c_str(), (measurementName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX()-4, binEdges);
+ dataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX()-4, binEdges);
for (int i = 0; i < dataHist->GetNbinsX(); i++) {
dataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38);
dataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38);
//std::cout << dataHist->GetBinLowEdge(i+1) << " " << dataHist->GetBinContent(i+1) << " " << dataHist->GetBinError(i+1) << std::endl;
}
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
dataFile->Close();
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dthpi_nu::SetCovarMatrix(std::string fileLocation) {
std::cout << "Covariance: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone();
int nBinsX = covarMatrix->GetXaxis()->GetNbins();
int nBinsY = covarMatrix->GetYaxis()->GetNbins();
if ((nBinsX != nBinsY)) std::cerr << "covariance matrix not square!" << std::endl;
this->covar = new TMatrixDSym(nBinsX-5);
this->fullcovar = new TMatrixDSym(nBinsX-5);
for (int i = 2; i < nBinsX-3; i++) {
for (int j = 2; j < nBinsY-3; j++) {
//std::cout << "(" << i << ", " << j << ") = " << covarMatrix->GetBinContent(i+1,j+1) << std::endl;
(*this->covar)(i-2, j-2) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances
(*this->fullcovar)(i-2, j-2) = covarMatrix->GetBinContent(i, j); //adds syst+stat covariances
//std::cout << "covar(" << i-2 << ", " << j-2 << ") = " << (*this->covar)(i-2,j-2) << std::endl;
}
} //should now have set covariance, I hope
TDecompChol tempMat = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), "");
*this->covar *= 1E-38*1E-38;
dataFile->Close();
};
void T2K_CC1pip_CH_XSec_1Dthpi_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double thpi = FitUtils::th(Pnu, Ppip);
this->X_VAR = thpi;
return;
};
//********************************************************************
bool T2K_CC1pip_CH_XSec_1Dthpi_nu::isSignal(FitEvent *event) {
//********************************************************************
// This sample uses directional info on the pion so Michel e tag sample can not be included
// i.e. we need reduce the pion variable phase space
return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, false);
}
diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dthq3pi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dthq3pi_nu.cxx
index 72a3f59..fcc6a0d 100644
--- a/src/T2K/T2K_CC1pip_CH_XSec_1Dthq3pi_nu.cxx
+++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dthq3pi_nu.cxx
@@ -1,123 +1,123 @@
#include "T2K_CC1pip_CH_XSec_1Dthq3pi_nu.h"
#include <iomanip>
// The constructor
T2K_CC1pip_CH_XSec_1Dthq3pi_nu::T2K_CC1pip_CH_XSec_1Dthq3pi_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile){
- measurementName = "T2K_CC1pip_CH_XSec_1Dthq3pi_nu";
+ fName = "T2K_CC1pip_CH_XSec_1Dthq3pi_nu";
plotTitles = "; #theta_{q_{3},#pi} (radians); d#sigma/d#theta_{q_{3},#pi} (cm^{2}/(radian)/nucleon)";
EnuMin = 0.;
EnuMax = 10.;
isDiag = false;
Measurement1D::SetupMeasurement(inputfile, type, rw, fakeDataFile);
this->SetDataValues(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/ThetaQ3Pi.root");
this->SetCovarMatrix(std::string(std::getenv("EXT_FIT"))+"/data/T2K/CC1pip/CH/ThetaQ3Pi.root");
this->SetupDefaultHist();
this->scaleFactor = (this->eventHist->Integral("width")*1E-38)/double(nevents)/TotalIntegratedFlux("width");
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dthq3pi_nu::SetDataValues(std::string fileLocation) {
- std::cout << "Reading: " << this->measurementName << "\nData: " << fileLocation.c_str() << std::endl;
+ std::cout << "Reading: " << this->fName << "\nData: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
// Don't want the last bin of dataCopy
TH1D *dataCopy = (TH1D*)(dataFile->Get("hResult_sliced_0_1"))->Clone();
double *binEdges = new double[dataCopy->GetNbinsX()-1];
std::cout << dataCopy->GetNbinsX() << std::endl;
for (int i = 1; i < dataCopy->GetNbinsX()+1; i++) {
binEdges[i-1] = dataCopy->GetBinLowEdge(i);
std::cout << i-1 << " " << binEdges[i-1] << std::endl;
}
for (int i = 0; i < dataCopy->GetNbinsX()+5; i++) {
std::cout << "binEdges[" << i << "] = " << binEdges[i] << std::endl;
}
- dataHist = new TH1D((measurementName+"_data").c_str(), (measurementName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX()-1, binEdges);
+ dataHist = new TH1D((fName+"_data").c_str(), (fName+"_data"+plotTitles).c_str(), dataCopy->GetNbinsX()-1, binEdges);
for (int i = 0; i < dataHist->GetNbinsX(); i++) {
dataHist->SetBinContent(i+1, dataCopy->GetBinContent(i+1)*1E-38);
dataHist->SetBinError(i+1, dataCopy->GetBinError(i+1)*1E-38);
std::cout << dataHist->GetBinLowEdge(i+1) << " " << dataHist->GetBinContent(i+1) << " " << dataHist->GetBinError(i+1) << std::endl;
}
dataHist->SetDirectory(0); //should disassociate dataHist with dataFile
- dataHist->SetNameTitle((measurementName+"_data").c_str(), (measurementName+"_MC"+plotTitles).c_str());
+ dataHist->SetNameTitle((fName+"_data").c_str(), (fName+"_MC"+plotTitles).c_str());
dataFile->Close();
};
// Override this for now
// Should really have Measurement1D do this properly though
void T2K_CC1pip_CH_XSec_1Dthq3pi_nu::SetCovarMatrix(std::string fileLocation) {
std::cout << "Covariance: " << fileLocation.c_str() << std::endl;
TFile *dataFile = new TFile(fileLocation.c_str()); //truly great .root file!
TH2D *covarMatrix = (TH2D*)(dataFile->Get("TMatrixDBase;1"))->Clone();
int nBinsX = covarMatrix->GetXaxis()->GetNbins();
int nBinsY = covarMatrix->GetYaxis()->GetNbins();
if ((nBinsX != nBinsY)) std::cerr << "covariance matrix not square!" << std::endl;
// First bin is underflow, last bin is overflow
this->covar = new TMatrixDSym(nBinsX-2);
this->fullcovar = new TMatrixDSym(nBinsX-2);
// First two entries are BS
// Last entry is BS
for (int i = 1; i < nBinsX-1; i++) {
for (int j = 1; j < nBinsY-1; j++) {
(*this->covar)(i-1, j-1) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances
(*this->fullcovar)(i-1, j-1) = covarMatrix->GetBinContent(i+1, j+1); //adds syst+stat covariances
std::cout << "covar(" << i-1 << ", " << j-1 << ") = " << (*this->covar)(i-1,j-1) << std::endl;
}
} //should now have set covariance, I hope
TDecompChol tempMat = TDecompChol(*this->covar);
this->covar = new TMatrixDSym(nBinsX, tempMat.Invert().GetMatrixArray(), "");
*this->covar *= 1E-38*1E-38;
return;
};
void T2K_CC1pip_CH_XSec_1Dthq3pi_nu::FillEventVariables(FitEvent *event) {
TLorentzVector Pnu = (event->PartInfo(0))->fP;
TLorentzVector Ppip;
TLorentzVector Pmu;
// Loop over the particle stack
for (unsigned int j = 2; j < event->Npart(); ++j) {
if (!(event->PartInfo(j))->fIsAlive && (event->PartInfo(j))->fStatus != 0) continue;
int PID = (event->PartInfo(j))->fPID;
if (PID == 211) {
Ppip = event->PartInfo(j)->fP;
} else if (PID == 13) {
Pmu = (event->PartInfo(j))->fP;
}
}
double th_q3_pi = FitUtils::thq3pi_CC1pip_T2K(Pnu, Pmu, Ppip);
this->X_VAR = th_q3_pi;
return;
};
//********************************************************************
bool T2K_CC1pip_CH_XSec_1Dthq3pi_nu::isSignal(FitEvent *event) {
//********************************************************************
// This sample requires pion directional information so can not include Michel tag sample
// i.e. will need to cut the pion phase space
return SignalDef::isCC1pip_T2K_CH(event, EnuMin, EnuMax, false);
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, May 14, 10:55 AM (20 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5087331
Default Alt Text
(922 KB)

Event Timeline