1 #include "AnalysisManager.hxx" 2 #include "Parameters.hxx" 3 #include "ND280AnalysisUtils.hxx" 4 #include "VersioningUtils.hxx" 5 #include "SystematicUtils.hxx" 7 #include "RedoTreeConverter.hxx" 8 #include "MiniTreeConverter.hxx" 11 #include "BFieldDistortionSystematics.hxx" 12 #include "MomentumScaleSystematics.hxx" 13 #include "MomentumResolSystematics.hxx" 14 #include "ToFResolSystematics.hxx" 15 #include "ECalEMEnergyResolSystematics.hxx" 16 #include "ECalEMEnergyScaleSystematics.hxx" 19 #include "ChargeIDEffSystematics.hxx" 20 #include "TPCTrackEffSystematics.hxx" 21 #include "FGDTrackEffSystematics.hxx" 22 #include "FGDHybridTrackEffSystematics.hxx" 23 #include "TPCClusterEffSystematics.hxx" 24 #include "MichelElectronEffSystematics.hxx" 27 #include "TPCFGDMatchEffSystematics.hxx" 28 #include "TPCECalMatchEffSystematics.hxx" 31 #include "TPCPIDSystematics.hxx" 32 #include "FGDPIDSystematics.hxx" 33 #include "ECalEmHipPIDSystematics.hxx" 34 #include "ECalPIDSystematics.hxx" 37 #include "PileUpSystematics.hxx" 38 #include "FGDMassSystematics.hxx" 39 #include "OOFVSystematics.hxx" 40 #include "SandMuonsSystematics.hxx" 41 #include "SIPionSystematics.hxx" 42 #include "SIProtonSystematics.hxx" 43 #include "FluxWeightSystematics.hxx" 46 #include "FGD2ShowerSystematics.hxx" 47 #include "nueECalPileUpSystematics.hxx" 48 #include "nueOOFVSystematics.hxx" 49 #include "nueP0DPileUpSystematics.hxx" 50 #include "nueTPCPileUpSystematics.hxx" 54 #include "numuCCSelection.hxx" 55 #include "numuCC4piSelection.hxx" 56 #include "numuCCMultiPiSelection.hxx" 57 #include "numuCC4piMultiPiSelection.hxx" 61 #include "numuCCFGD2Selection.hxx" 62 #include "numuCC4piFGD2Selection.hxx" 63 #include "numuCCMultiPiFGD2Selection.hxx" 64 #include "numuCC4piMultiPiFGD2Selection.hxx" 67 #include "numuBkgInAntiNuModeCCSelection.hxx" 68 #include "numuBkgInAntiNuModeCCMultiTrackSelection.hxx" 69 #include "numuBkgInAntiNuModeCCMultiPiSelection.hxx" 72 #include "numuBkgInAntiNuModeCCFGD2Selection.hxx" 73 #include "numuBkgInAntiNuModeCCMultiTrackFGD2Selection.hxx" 74 #include "numuBkgInAntiNuModeCCMultiPiFGD2Selection.hxx" 77 #include "antiNumuCCSelection.hxx" 78 #include "antiNumuCCMultiTrackSelection.hxx" 79 #include "antiNumuCCMultiPiSelection.hxx" 82 #include "antiNumuCCFGD2Selection.hxx" 83 #include "antiNumuCCMultiTrackFGD2Selection.hxx" 84 #include "antiNumuCCMultiPiFGD2Selection.hxx" 87 #include "nueCCSelection.hxx" 90 #include "nueCCFGD2Selection.hxx" 93 #include "gammaSelection.hxx" 96 #include "gammaFGD2Selection.hxx" 99 #include "antiNueCCSelection.hxx" 102 #include "antiNueCCFGD2Selection.hxx" 106 AnalysisManager::AnalysisManager(){
112 DefineInputConverters();
120 _applyEventVariations = (bool)ND::params().GetParameterI(
"psycheSteering.Systematics.ApplyVariationSystematics");
121 _applyEventWeights = (bool)ND::params().GetParameterI(
"psycheSteering.Systematics.ApplyWeightSystematics");
131 _fluxVersion = ND::params().
GetParameterS(
"psycheSteering.FluxWeighting.Version");
132 _fluxTuning = ND::params().
GetParameterS(
"psycheSteering.FluxWeighting.Tuning");
142 _currentSampleGroup = NULL;
157 void AnalysisManager::DefineInputConverters(){
166 void AnalysisManager::DefineProduction(){
170 if (ND::params().GetParameterI(
"psycheSteering.POT.Production")==6){
171 versionUtils::prod6_POT =
true;
172 std::cout <<
"WARNING: production has been overwritten by parameter psycheSteering.POT.Production == 6" << std::endl;
174 else if (ND::params().GetParameterI(
"psycheSteering.POT.Production")==5){
175 versionUtils::prod6_POT =
false;
176 std::cout <<
"WARNING: production has been overwritten by parameter psycheSteering.POT.Production == 5" << std::endl;
180 if (ND::params().GetParameterI(
"psycheSteering.Bunching.Production")==6){
181 versionUtils::prod6_bunching =
true;
182 std::cout <<
"WARNING: production has been overwritten by parameter psycheSteering.Bunching.Production == 6" << std::endl;
184 else if (ND::params().GetParameterI(
"psycheSteering.Bunching.Production")==5){
185 versionUtils::prod6_bunching =
false;
186 std::cout <<
"WARNING: production has been overwritten by parameter psycheSteering.Bunching.Production == 5" << std::endl;
190 if (ND::params().GetParameterI(
"psycheSteering.Corrections.Production")==6){
191 versionUtils::prod6_corrections =
true;
192 std::cout <<
"WARNING: production has been overwritten by parameter psycheSteering.Corrections.Production == 6" << std::endl;
194 else if (ND::params().GetParameterI(
"psycheSteering.Corrections.Production")==5){
195 versionUtils::prod6_corrections =
false;
196 std::cout <<
"WARNING: production has been overwritten by parameter psycheSteering.Corrections.Production == 5" << std::endl;
200 if (ND::params().GetParameterI(
"psycheSteering.Systematics.Production")==6){
201 versionUtils::prod6_systematics =
true;
202 std::cout <<
"WARNING: production has been overwritten by parameter psycheSteering.Systematics.Production == 6" << std::endl;
204 else if (ND::params().GetParameterI(
"psycheSteering.Systematics.Production")==5){
205 versionUtils::prod6_systematics =
false;
206 std::cout <<
"WARNING: production has been overwritten by parameter psycheSteering.Systematics.Production == 5" << std::endl;
212 void AnalysisManager::DefineSelections(){
259 sel().
SetValidRunPeriods(
"kTrackerNumuCC", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuCC.ValidRunPeriods"));
260 sel().
SetValidRunPeriods(
"kTrackerNumuCC4piMultiPi", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuCC4piMultiPi.ValidRunPeriods"));
261 sel().
SetValidRunPeriods(
"kTrackerNumuCC4pi", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuCC4pi.ValidRunPeriods"));
262 sel().
SetValidRunPeriods(
"kTrackerNumuCCMultiPi", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuCCMultiPi.ValidRunPeriods"));
265 sel().
SetValidRunPeriods(
"kTrackerAntiNumuCC", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerAntiNumuCC.ValidRunPeriods"));
266 sel().
SetValidRunPeriods(
"kTrackerAntiNumuCCMultiTrack", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerAntiNumuCCMultiTrack.ValidRunPeriods"));
267 sel().
SetValidRunPeriods(
"kTrackerAntiNumuCCMultiPi", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerAntiNumuCCMultiPi.ValidRunPeriods"));
270 sel().
SetValidRunPeriods(
"kTrackerNumuInAntiNuModeCC", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuInAntiNuModeCC.ValidRunPeriods"));
271 sel().
SetValidRunPeriods(
"kTrackerNumuInAntiNuModeCCMultiTrack", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuInAntiNuModeCCMultiTrack.ValidRunPeriods"));
272 sel().
SetValidRunPeriods(
"kTrackerNumuInAntiNuModeCCMultiPi", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuInAntiNuModeCCMultiPi.ValidRunPeriods"));
277 sel().
SetValidRunPeriods(
"kTrackerNumuCCFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuCC.ValidRunPeriods"));
278 sel().
SetValidRunPeriods(
"kTrackerNumuCCMultiPiFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuCCMultiPi.ValidRunPeriods"));
279 sel().
SetValidRunPeriods(
"kTrackerNumuCC4piFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuCC4pi.ValidRunPeriods"));
280 sel().
SetValidRunPeriods(
"kTrackerNumuCC4piMultiPiFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuCC4piMultiPi.ValidRunPeriods"));
283 sel().
SetValidRunPeriods(
"kTrackerAntiNumuCCFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerAntiNumuCC.ValidRunPeriods"));
284 sel().
SetValidRunPeriods(
"kTrackerAntiNumuCCMultiTrackFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerAntiNumuCCMultiTrack.ValidRunPeriods"));
285 sel().
SetValidRunPeriods(
"kTrackerAntiNumuCCMultiPiFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerAntiNumuCCMultiPi.ValidRunPeriods"));
288 sel().
SetValidRunPeriods(
"kTrackerNumuInAntiNuModeCCFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuInAntiNuModeCC.ValidRunPeriods"));
289 sel().
SetValidRunPeriods(
"kTrackerNumuInAntiNuModeCCMultiTrackFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuInAntiNuModeCCMultiTrack.ValidRunPeriods"));
290 sel().
SetValidRunPeriods(
"kTrackerNumuInAntiNuModeCCMultiPiFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNumuInAntiNuModeCCMultiPi.ValidRunPeriods"));
293 sel().
SetValidRunPeriods(
"kTrackerNuECC", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNuECC.ValidRunPeriods"));
294 sel().
SetValidRunPeriods(
"kTrackerAntiNuECC", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerAntiNuECC.ValidRunPeriods"));
295 sel().
SetValidRunPeriods(
"kTrackerGamma", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerGamma.ValidRunPeriods"));
298 sel().
SetValidRunPeriods(
"kTrackerNuECCFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerNuECC.ValidRunPeriods"));
299 sel().
SetValidRunPeriods(
"kTrackerAntiNuECCFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerAntiNuECC.ValidRunPeriods"));
300 sel().
SetValidRunPeriods(
"kTrackerGammaFGD2", ND::params().GetParameterS(
"psycheSteering.Selections.TrackerGamma.ValidRunPeriods"));
303 if (!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuCC"))
306 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuCCMultiPi"))
309 if (!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuCC4pi"))
312 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuCC4piMultiPi"))
316 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerAntiNumuCC"))
319 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerAntiNumuCCMultiTrack"))
322 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerAntiNumuCCMultiPi"))
326 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuInAntiNuModeCC"))
329 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuInAntiNuModeCCMultiTrack"))
332 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuInAntiNuModeCCMultiPi"))
337 if (!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuCCFGD2"))
340 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuCCMultiPiFGD2"))
343 if (!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuCC4piFGD2"))
346 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuCC4piMultiPiFGD2"))
351 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerAntiNumuCCFGD2"))
354 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerAntiNumuCCMultiTrackFGD2"))
357 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerAntiNumuCCMultiPiFGD2"))
361 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuInAntiNuModeCCFGD2"))
364 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuInAntiNuModeCCMultiTrackFGD2"))
367 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNumuInAntiNuModeCCMultiPiFGD2"))
371 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNuECC"))
374 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerAntiNuECC"))
377 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerGamma"))
381 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerNuECCFGD2"))
384 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerAntiNuECCFGD2"))
387 if(!ND::params().GetParameterI(
"psycheSteering.Selections.EnableTrackerGammaFGD2"))
393 void AnalysisManager::DefineSystematics(){
443 if(ND::params().GetParameterI(
"psycheSteering.Variations.EnableBFieldDist"))
evar().
EnableEventVariation(SystId::kBFieldDist);
444 if(ND::params().GetParameterI(
"psycheSteering.Variations.EnableMomScale"))
evar().
EnableEventVariation(SystId::kMomScale);
445 if(ND::params().GetParameterI(
"psycheSteering.Variations.EnableMomResol"))
evar().
EnableEventVariation(SystId::kMomResol);
446 if(ND::params().GetParameterI(
"psycheSteering.Variations.EnableTpcPid"))
evar().
EnableEventVariation(SystId::kTpcPid);
447 if(ND::params().GetParameterI(
"psycheSteering.Variations.EnableFgdPid"))
evar().
EnableEventVariation(SystId::kFgdPid);
448 if(ND::params().GetParameterI(
"psycheSteering.Variations.EnableToFResol"))
evar().
EnableEventVariation(SystId::kToFResol);
449 if(ND::params().GetParameterI(
"psycheSteering.Variations.EnableECalMomScale"))
evar().
EnableEventVariation(SystId::kECalEMScale);
450 if(ND::params().GetParameterI(
"psycheSteering.Variations.EnableECalMomResol"))
evar().
EnableEventVariation(SystId::kECalEMResol);
452 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableChargeConf"))
eweight().
EnableEventWeight(SystId::kChargeIDEff);
453 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableTpcClusterEff"))
eweight().
EnableEventWeight(SystId::kTpcClusterEff);
454 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableTpcTrackEff"))
eweight().
EnableEventWeight(SystId::kTpcTrackEff);
455 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableTpcFgdMatchEff"))
eweight().
EnableEventWeight(SystId::kTpcFgdMatchEff);
456 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableFgdTrackEff"))
eweight().
EnableEventWeight(SystId::kFgdTrackEff);
457 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableFgdHybridTrackEff"))
eweight().
EnableEventWeight(SystId::kFgdHybridTrackEff);
458 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableMichelEleEff"))
eweight().
EnableEventWeight(SystId::kMichelEleEff);
460 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableFgdMass"))
eweight().
EnableEventWeight(SystId::kFgdMass);
463 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableSIProton"))
eweight().
EnableEventWeight(SystId::kSIProton);
464 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableSandMuons"))
eweight().
EnableEventWeight(SystId::kSandMu);
465 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableECalPID"))
eweight().
EnableEventWeight(SystId::kECalPID);
466 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableTpcECalMatchEff"))
eweight().
EnableEventWeight(SystId::kTpcECalMatchEff);
468 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableECalEmHipPID"))
eweight().
EnableEventWeight(SystId::kECalEmHipPID);
469 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableFGD2Shower"))
eweight().
EnableEventWeight(SystId::kFGD2Shower);
470 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableNuETPCPileUp"))
eweight().
EnableEventWeight(SystId::kNuETPCPileUp);
471 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableNuEP0DPileUp"))
eweight().
EnableEventWeight(SystId::kNuEP0DPileUp);
472 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableNuEECalPileUp"))
eweight().
EnableEventWeight(SystId::kNuEECalPileUp);
473 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableNuEOOFV"))
eweight().
EnableEventWeight(SystId::kNuEOOFV);
475 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableFluxNeutrino"))
syst().
EnableSystematic(SystId::kFluxWeightNu);
476 if(ND::params().GetParameterI(
"psycheSteering.Weights.EnableFluxAntiNeutrino"))
syst().
EnableSystematic(SystId::kFluxWeightAntiNu);
499 return ProcessEvent(toy,event,totalWeightSystVector,fluxWeightSystVector,POTweight);
541 anaUtils::CreateArray(weightSystDummy, nWeightSyst);
544 totalWeightSystVector.clear();
545 fluxWeightSystVector.clear();
565 if (!selec.IsEnabled())
continue;
575 bool passed_temp = selec.
Apply(event,redo);
577 if (passed_temp && event.
GetIsMC()){
598 totalWeightSystVector.push_back(totalWeightSyst);
599 fluxWeightSystVector.push_back(fluxWeightSyst);
602 if (passed_temp) passed=
true;
606 if (_currentSampleGroup){
610 _currentSampleGroup->
GetPOT(POTdata, POTmc, POTsand);
611 POTweight = POTdata/POTmc;
614 delete [] weightSystDummy;
661 anaUtils::CreateArray(weightSystDummy, nWeightSyst);
664 for (std::vector<SelectionBase*>::iterator it=
sel().GetSelections().begin();it!=
sel().
GetSelections().end();it++){
668 if (!selec.IsEnabled())
continue;
679 bool passed_temp = selec.
Apply(event,redo);
681 if(passed_temp && passed) std::cout <<
"DOUBLE EVENT SELECTION ON selec.GetSampleId() = " << selec.
GetSampleId() << std::endl;
682 if(passed_temp) passed = 1;
684 if (passed_temp && event.
GetIsMC()){
688 if (static_cast<AnaEventSummaryB*>(event.
Summary)->TrueVertex[selec.
GetSampleId()] && !
event.GetIsSandMC())
706 if (passed_temp)
return true;
740 if (!selec.IsEnabled())
continue;
745 if (selec.
Apply(event, redo)) passed=
true;
749 if (_currentSampleGroup){
753 _currentSampleGroup->
GetPOT(POTdata, POTmc, POTsand);
754 POTweight = POTdata/POTmc;
765 if(event==NULL)
return false;
770 bool AnalysisManager::Initialize(Int_t nmax_events){
781 evar().Initialize(nmax_events);
790 if (_samples.size() == 0){
792 std::map< std::string, SampleGroup >::iterator sit;
793 for (sit = sampleGroups.begin(); sit != sampleGroups.end(); sit++) {
796 std::vector<DataSample*>& dataSamples = sampleGroup.
GetDataSamples();
797 std::vector<DataSample*>::iterator it;
798 for (it = dataSamples.begin(); it != dataSamples.end(); it++) {
800 _samples.push_back(sample);
803 std::map< std::string, DataSample*>& mcSamples = sampleGroup.
GetMCSamples();
804 std::map< std::string, DataSample*>::iterator it2;
805 for (it2 = mcSamples.begin(); it2 != mcSamples.end(); it2++) {
806 std::string name = it2->first;
808 _samples.push_back(sample);
811 _currentSample = _samples.begin();
820 return ReadEvents(*_currentSample, nmax_events);
844 std::cout <<
"AnalysisManager::ReadEvents(). Reading file " << inputFile << std::endl;
856 if (nmax_events !=-1)
859 nmax_events = nEventsInTree;
861 std::cout <<
"AnalysisManager::ReadEvents(). Preload " << nmax_events <<
" events" << std::endl;
863 Initialize(nmax_events);
872 if (entry%10000==0 || entry == nentries)
873 std::cout <<
"entry: " << entry <<
" of " << nentries <<
" (" << (100*entry/nentries) <<
"%)" << std::endl;
889 std::cout <<
"AnalysisManager::ReadEvents(). Preloading done of " <<
_nEventsInArray <<
" events"<< std::endl;
985 void AnalysisManager::PreloadEvents(
bool preloadData,
bool preloadMC){
989 std::cout <<
"There is no Experiment associated with this AnalysisManager, cannot preload events this way. Use ReadEvents(int nevents) method instead." << std::endl;
995 std::map< std::string, SampleGroup >::iterator sit;
996 for (sit = sampleGroups.begin(); sit != sampleGroups.end(); sit++) {
1003 sampleGroup.
GetPOT(POTdata, POTmc, POTsand);
1005 float POT_weight = POTdata/POTmc;
1006 float POT_weight_sand = POTdata/POTsand;
1008 std::map< std::string, DataSample*>& mcSamples = sampleGroup.
GetMCSamples();
1009 std::map< std::string, DataSample*>::iterator it2;
1010 for (it2 = mcSamples.begin(); it2 != mcSamples.end(); it2++) {
1011 if((it2->first).find(
"and")!=std::string::npos){
1025 bool AnalysisManager::PreloadMCEvents(std::vector<std::string> inputFiles, std::vector<float> POT_weights){
1029 int nmax_events = 0;
1031 for(std::vector<std::string>::iterator it = inputFiles.begin(); it != inputFiles.end(); ++it){
1033 std::string inputFile = *it;
1047 CreateMCEventArray(nmax_events);
1055 evar().Initialize(nmax_events);
1059 for(
int i = 0; i < (int)inputFiles.size(); ++i){
1060 std::string inputFile = inputFiles[i];
1061 float POT_weight = POT_weights[i];
1064 std::cout <<
"AnalysisManager::PreloadMCEvents(). Reading file " << inputFile << std::endl;
1073 while((
int)entry < nmax_entries){
1079 if (entry%10000==0 || entry == nmax_entries)
1080 std::cout <<
"entry: " << entry <<
" of " << nmax_entries <<
" (" << (100*entry/nmax_entries) <<
"%)" << std::endl;
1092 event->POTWeight = POT_weight;
1098 std::cout <<
"AnalysisManager::PreloadMCEvents(). Preloading done" << std::endl;
1103 bool AnalysisManager::PreloadDataEvents(std::vector<std::string> inputFiles){
1107 int nmax_events = 0;
1109 for(std::vector<std::string>::iterator it = inputFiles.begin(); it != inputFiles.end(); ++it){
1111 std::string inputFile = *it;
1125 CreateDataEventArray(nmax_events);
1129 for(std::vector<std::string>::iterator it = inputFiles.begin(); it != inputFiles.end(); ++it){
1131 std::string inputFile = *it;
1134 std::cout <<
"AnalysisManager::PreloadDataEvents(). Reading file " << inputFile << std::endl;
1143 while((
int)entry < nmax_entries){
1149 if (entry%10000==0 || entry == nmax_entries)
1150 std::cout <<
"entry: " << entry <<
" of " << nmax_entries <<
" (" << (100*entry/nmax_entries) <<
"%)" << std::endl;
1160 std::cout <<
"AnalysisManager::PreloadDataEvents(). Preloading done" << std::endl;
1165 void AnalysisManager::InitialiseMCTChain(){
1173 std::map< std::string, SampleGroup >::iterator sit;
1174 for (sit = sampleGroups.begin(); sit != sampleGroups.end(); sit++) {
1177 std::map< std::string, DataSample*>& mcSamples = sampleGroup.
GetMCSamples();
1178 std::map< std::string, DataSample*>::iterator it2;
1179 for (it2 = mcSamples.begin(); it2 != mcSamples.end(); it2++){
1184 std::cout <<
"AnalysisManager::InitialiseMCTChain(). TChain has all MC files added." << std::endl;
1189 void AnalysisManager::InitialiseDataTChain(){
1191 std::vector<std::string> inputFiles;
1198 for(std::vector<std::string>::iterator it = inputFiles.begin(); it != inputFiles.end(); ++it){
1199 std::string inputFile = *it;
1204 std::cout <<
"AnalysisManager::InitialiseDataTChain(). TChain has all data files added." << std::endl;
1209 AnaSuperEventB* AnalysisManager::GetPreloadedMCSuperEvent(
int i){
1212 std::cout <<
"Requesting event " << i <<
" when the MC preloaded event array only has " << _nEventsInMCArray <<
" entries." << std::endl;
1219 AnaSuperEventB* AnalysisManager::GetPreloadedDataSuperEvent(
int i){
1222 std::cout <<
"Requesting event " << i <<
" when the Data preloaded event array only has " << _nEventsInDataArray <<
" entries." << std::endl;
1230 void AnalysisManager::CreateMCEventArray(Int_t nmax){
1248 void AnalysisManager::CreateDataEventArray(Int_t nmax){
1265 void AnalysisManager::ResetEventsProcessed(){
bool ReadEvents(const std::string &inputFile, Int_t nmax=-1)
Read the specified number of events from the file and save them into an array. Default(-1) is all eve...
void AddWeightSystematic(Int_t index, EventWeightBase *sys)
Register an SystematicBase as a weight systematic.
const std::string & GetFilePath()
returns the filePath
Int_t GetIndex() const
Return the index of this systematic.
int GetParameterI(std::string)
Get parameter. Value is returned as integer.
UInt_t GetNEnabledEventWeights()
Returns the number of enabled EventWeights.
bool _applyEventVariations
whether to apply detector event variation or not
AnaEventC * Event
The modified event.
void CreateToyBoxArray(Int_t nevents)
Create the array of PreviousToyBox for all enabled selections.
TN-152 for a longer explanaition.
UInt_t GetNEventVariations() const
Returns the number of EventVariations.
bool GetIsSandMC() const
Return whether this event is from Sand Monte Carlo or not.
std::vector< EventVariationBase * > & GetEventVariations()
Get the vector of EventVariations.
InputManager _input
An instance of the input manager.
std::vector< Float_t > _POT_weights
The POT weight for each MC file loaded into the Analysis Manager.
bool _applyFluxWeightSystematic
whether to apply Flux weight systematic or not
virtual SampleId_h GetSampleId()
Return the sample type, needed by fitters.
std::vector< DataSample * > & GetDataSamples()
Get all MC samples in a group.
UInt_t GetNEventWeights() const
Returns the number of EventWeights.
void InitializeEvent(SelectionManager &sel, AnaEventC &event)
Fill the SystBox for the enabled EventWeights.
bool CheckSelectionAgainstRunPeriod(SelectionBase *selec, int RunPeriod)
void EnableSystematic(Int_t index)
Enable the systematic registered with the given index.
void AddFluxSystematic(Int_t index, EventWeightBase *sys)
Register an SystematicBase as a flux systematic.
UInt_t _nEventsInArray
the number of events in the array
const ToyBoxB & GetPreviousToyBox(const AnaEventC &event) const
Get the ToyBox of the last processed toy for a particular event.
void GetPOT(Float_t &POTdata, Float_t &POTmc)
Get the good data and MC POT for this sample group.
std::vector< SelectionBase * > & GetSelections()
Return the map of selections.
InputManager & input()
Returns the input manager.
bool _applyFluxWeight
Flag to enable/disable flux weight.
std::string GetParameterS(std::string)
Get parameter. Value is returned as string.
AnaEventB * GetNextEvent()
Returns The next Event.
void InitializeEvent(SelectionManager &sel, AnaEventC &event)
Fill the SystBox for the enabled EventVariations.
Weight_h ApplyFluxSystematics(const ToyExperiment &toy, const AnaEventC &event, const ToyBoxB &ToyBox)
Apply all fluxSystematics. Returns the total event Weight.
AnaSuperEventB ** _dataEventArray
The array of preloaded Data events.
SampleGroup & GetSampleGroup(const std::string &name)
Get a single sample group by name.
bool LoadEvent(Long64_t &entry)
std::map< std::string, DataSample * > & GetMCSamples()
Get all MC samples in a group.
UInt_t _nEventsInMCArray
the number of events in the preloaded MC array
SelectionManager & sel()
Returns the selection manager.
void ConstructCovarianceMatrix()
Make the covariance.
int GetRunPeriod(int run, int subrun=-1)
Returns the run period (sequentially: 0,1,2,3,4,5 ...)
Experiment * _exp
The Experiment.
void DisableAllSystematics()
Disable all Systematics.
EventVariationManager & evar()
Returns the EventVariation manager.
std::vector< std::string > GetDataFileVector()
Return pointer to vector of data files.
This is a normalization systematic. It takes into account the uncertainty on the FGD mass introduced ...
bool ProcessEvent(const ToyExperiment &toy, AnaEventB &event, std::vector< Weight_h > &totalWeightSystVector, std::vector< Weight_h > &fluxWeightSystVector)
Float_t GetWeight(AnaTrueVertexB *vertex, int RunPeriod)
bool Apply(AnaEventC &event, bool &redo)
Apply all steps in the selection.
This systematic evaluates the oofv systematic for nue analysis. At the moment a 30% rate unceratinty ...
AnaSuperEventB * LoadSuperEvent(Long64_t &evtIndex)
AnaSuperEventB * GetNextSuperEvent()
Returns The next SuperEvent.
bool GetIsMC() const
Return whether this event is from Monte Carlo or not.
void AddEventVariation(Int_t index, EventVariationBase *sys)
Add a new Event Variation provided its index in the manager and a pointer to it.
AnaSuperEventB ** _eventArray
The array of events.
void AddEventWeight(Int_t index, EventWeightBase *sys)
Add a new Event Weight provided its index in the manager and a pointer to it.
void SetNEntries(Int_t en)
Set and Get the special normalisation to be used for this sample.
AnaEventC * RawEvent
The Raw event.
bool _initialisePionSystematics
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
AnaEventB * GetEvent(Int_t eventIndex)
Returns The Event with a given index from the array.
void CreateEventArray(Int_t nmax)
Create the evevt array for preloading events.
void AddSelection(const std::string &name, const std::string &title, SelectionBase *sel, Int_t presel=-1)
Add a user selection to the selection manager.
UInt_t GetEntries()
Returns the number of entries in the input tree.
Int_t _nEventsProcessed
the number of events processed so far
void ApplyEventVariations(const ToyExperiment &toy, AnaEventC &event)
Apply all EventVariations.
TN-152 for a longer explanaition.
Charge confusion systematic. This is treated as an efficiency systematic, applying a weight to the ev...
Int_t _currentEvent
The current event in the event array.
UInt_t _nEventsInDataArray
the number of events in the preloaded Data array
This systematic smears the pull of each FGD track segment.
bool IsValidRun(int runPeriod) const
Method to see whether this selection should be applied to the given run period.
std::vector< EventWeightBase * > & GetEventWeights()
Get the vector of EventWeights.
void EnableEventWeight(Int_t index)
Enable the EventWeight registered with the given index.
void DisableSelection(const std::string &sel)
Disable a selection.
std::string _fluxFile
Flux file and option.
AnaSuperEventB ** _mcEventArray
The array of preloaded MC events.
FluxWeighting * _flux
Access to the flux weighting.
Weight_h ComputeEventWeights(const ToyExperiment &toy, const AnaEventC &event, const ToyBoxB &ToyBox)
Compute all eventWeights. Returns the total event normalization weight.
void AddVariationSystematic(Int_t index, EventVariationBase *sys)
Register an EventVariationBase as a variation systematic.
std::vector< std::string > GetMCFileVector()
Return pointer to vector of mc files.
std::map< std::string, SampleGroup > & GetSampleGroups()
Returns all sample groups.
void EnableEventVariation(Int_t index)
Enable the EventVariation registered with the given index.
SystematicManager & syst()
Returns the systematic manager.
This systematic smears the CT of each TPC track segment.
EventWeightManager & eweight()
Returns the EventWeight manager.
Michel electron effciency systematic.
virtual const char * GetName() const
Return the name of this systematic. This overrides the TObject::GetName() interface.
Int_t _nEventsToProcess
the maximum number of events to process
void SetValidRunPeriods(const std::string &ssel1, const std::string validRunPeriods)
Method to set the valid run periods for this selection (e.g. Anti-neutrino selections should only be ...
AnaSuperEventB * GetSuperEvent(Int_t eventIndex)
Returns The SuperEvent with a given index from the array.
void InitializeEvent(AnaEventC &event)
Initialize the EventBox for all enabled selections.
bool _applyEventWeights
whether to apply detector event weight or not