NuDSTAna Class Reference

#include <NuDSTAna.h>

Inheritance diagram for NuDSTAna:
NuBase DataMCPlots DataStabilityAnalysisClass FitTree FoverNHistos TemplateAnalysisClass ToFPlotter

List of all members.

Public Member Functions

 NuDSTAna ()
 ~NuDSTAna ()
void StdCCAna ()
void StdNMBAna (TString xmlFileName="")
void MMAna (std::string sOutputFileName="")
virtual void DoSystematicShifts (NuEvent &event, const NuXMLConfig *xmlConfig) const
void MMRereco (std::string sOutputFileName, TString xmlFileName)
void MMRereco (std::string sOutputFileName, const NuXMLConfig *xmlConfig)
void MMTransition (std::string sOutputFileName="", TString xmlFileName="")
void MMTransSME (std::string sOutputFileName, const NuXMLConfig *xmlConfig)
void MakeMicroDST (TString anaVersion, const TString xmlfile="")
 Make a microDST, optionally processing from the XML file.
void MakeMicroDstForCSSSystematics ()
void MakeMicroDstWithStdCCRecoAndCuts ()
void MakeMicroDstJJEPresel (int run=-1)
void MakeMicroDst2010 (bool redoRw=false)
void MakeMicroDstNC2012 (bool redoRw=false)
void MakeMicroDst2014 (bool redoRw=false)
void MakeMicroDstHe (bool forceRHC=false)
void MakeFCTree (TString xmlFileName)
void MakeSelMicroDST (Int_t Selector)
void MakeMicroDstFakeData (bool presel=true)
void MakeDstPQ ()
void ConcatenateDSTs ()
void MakeCuts (TString selection, Int_t charge)
void DPSystematic ()
void FluxComponents (TString xmlFileName)
void Contamination (TString xmlFileName)
void ContaminationNQ (TString xmlFileName)
void MakeShwEnkNNTrainingSet (TString xmlFileName)
void MakeShwEnkNNTestingSet (TString xmlFileName)
void MakeRoIDTrainingSet (TString xmlFileName)
void MakePurityEfficiencyPlotsCCNC (TString ccSelector, TString ncSelector)
void MakekNNTrainTestSet (TString xmlFileName)
void NewFieldAna (std::string sOutputFileName="")
void NDOsc ()
void RHCTest ()
void SelectorTable ()
void QPStudy ()
void YStudy (TString xmlFileName)
void NDQPRB (bool cedar)
void BRevAna ()
void CoilHoleAna ()
void CSSAna ()
void CSSAnaRashid ()
void FDTestAna ()
void JeffsTestAna ()
void NDTestAna ()
void NMBAna ()
void VsTime ()
void TestNuSyst ()
void MakeResolutionBins (TString xmlfilename, bool chargecut, TString runStr)

Protected Member Functions

Float_t Baseline () const
void CopyAcrossHistos (TDirectory *dirInput, TDirectory *dirOutput) const
void UpdatePotSinceLastEvt (NuEvent &nu, Bool_t newEvt) const
NuConfig GetNuConfig (const NuEvent &nu) const
Bool_t IsGoodPreSelectionCuts (const NuPlots *plots, const NuEvent &nu) const
Bool_t IsGoodStdCuts (const NuPlots *plots, const NuEvent &nu) const
void MakeFinalPlots (const NuPlots *plots, const NuEvent &nu) const
void MakePostPreSelectionPlots (const NuPlots *plots, const NuEvent &nu) const
void Oscillate (NuEvent &nu, const NuXMLConfig *xmlConfig) const
void Oscillate (NuMCEvent &nu, const NuXMLConfig *xmlConfig) const
void OscillateOrTransition (NuEvent &nu, const NuXMLConfig *xmlConfig, NuTransition *transition) const
Float_t OscillationWeight (const Float_t energy, const Int_t inu, const NuXMLConfig *xmlConfig) const
void OscillateTrans (NuEvent &nu, const NuXMLConfig *xmlConfig) const
void OscillateTrans (NuMCEvent &nu, const NuXMLConfig *xmlConfig) const
Float_t OscillationWeightTrans (const Float_t energy, const Int_t inu, const NuXMLConfig *xmlConfig) const
void OverwriteSntpBeamDataInNtuple (NuEvent &nu)
void OverwriteCoilDataInNtuple (NuEvent &nu)
void SanityCheckAnaVersionSameAsPrevious (Int_t anaVersion) const
Int_t SanityCheckedAnaVersion (Int_t anaVersion, Int_t overrideAnaVersion) const
virtual void SanityCheckFourFlavourProbabilities (const NuXMLConfig *xmlConfig) const
const NuEventGetEvent (const NuEvent &nu)
const NuEventGetEventND (const NuEvent &nu)
NuInputEventsDoIO (NuOutputWriter *poutput=0, std::string sFilePrefix="", std::string sFullFileName="")
NuInputEventsDoIOSimple (std::string sFilePrefix="")

Detailed Description

Definition at line 27 of file NuDSTAna.h.


Constructor & Destructor Documentation

NuDSTAna::NuDSTAna (  ) 

Definition at line 71 of file NuDSTAna.cxx.

References Msg::kDebug, and MSG.

00072 {
00073   MSG("NuDSTAna",Msg::kDebug)
00074     <<"Running NuDSTAna Constructor..."<<endl;
00075 
00076 
00077   MSG("NuDSTAna",Msg::kDebug)
00078     <<"Finished NuDSTAna Constructor"<<endl;
00079 }

NuDSTAna::~NuDSTAna (  ) 

Definition at line 83 of file NuDSTAna.cxx.

References Msg::kDebug, and MSG.

00084 {
00085   MSG("NuDSTAna",Msg::kDebug)
00086     <<"Running NuDSTAna Destructor..."<<endl;
00087 
00088 
00089   MSG("NuDSTAna",Msg::kDebug)
00090     <<"Finished NuDSTAna Destructor"<<endl;
00091 }


Member Function Documentation

Float_t NuDSTAna::Baseline (  )  const [inline, protected]

Definition at line 101 of file NuDSTAna.h.

00101 {return 735.0;};

void NuDSTAna::BRevAna (  ) 

Definition at line 9213 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, NuConfig::detector, DoIO(), NuCounter::evtCounter, NuPlots::FillBRev(), NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuLibrary::Instance(), IsGoodPreSelectionCuts(), IsGoodStdCuts(), NuCuts::IsInFidVolTrueEvt(), Msg::kDebug, Msg::kError, Detector::kFar, Msg::kInfo, SimFlag::kMC, NuCuts::kNMB0325Bravo, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuConfig::run, and SanityCheckedAnaVersion().

09214 {
09215   NuInputEvents& input=this->DoIO(0,"","");
09216 
09217   //use config object to store info
09218   NuConfig config;
09219   config.detector=Detector::kFar;
09220   config.run=100;
09221 
09222   TString post;
09223 
09224   //get an instance of the code library
09225   NuLibrary& lib=NuLibrary::Instance();
09226 
09227   //get an object to fill plots
09228   const NuPlots* plots=0;
09229 
09230   //version to do reco/cuts with
09231   NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kNMB0325Bravo;
09232   //NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kRM2;
09233 
09234   input.ResetNuEventLoopPositionToStart();
09235   TH1::AddDirectory(true);
09236 
09240 
09241   cout<<endl
09242       <<"************************************************"<<endl
09243       <<"***      Starting main loop over snarls      ***"<<endl
09244       <<"************************************************"<<endl;
09245 
09246   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
09247     lib.cnt.evtCounter++;
09248 
09249     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
09250 
09251     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
09252 
09253     //OVERRIDE
09254     //Selection
09255     nu.anaVersion=this->SanityCheckedAnaVersion(nu.anaVersion,overrideAnaVersion);
09256 
09257     // Set RunII Weighting
09258     nu.applyBeamWeight = true;
09259 
09260     MSG("NuDSTAna", Msg::kError) << "Can't apply RunII weights which no longer exist" << endl;
09261 
09262     //RE-RECONSTRUCT the neutrino energy
09263     lib.reco.GetEvtEnergy(nu, false);
09264     lib.reco.ApplyReweights(nu);
09265 
09267     // Fill Truth Histos before cuts
09269 
09270     if (!this->IsGoodPreSelectionCuts(plots,nu)) continue;
09271 
09272     if (nu.simFlag == SimFlag::kMC) {
09273       if (nu.iaction != 1) {
09274         post = "NC";
09275       }
09276       else {
09277         if (lib.cuts.IsInFidVolTrueEvt(nu)) {
09278           plots->FillBRev(nu,"True",true);
09279         }
09280         if ( (nu.charge > 0 && nu.inu != -14) || (nu.charge < 0 && nu.inu != 14) ) {
09281           post = "WrSn";
09282         } else {
09283           post = "Sig";
09284         }
09285       }
09286     }
09287     else {
09288       post = "Data";
09289     }
09290 
09291     //make all the std cuts
09292     if (!this->IsGoodStdCuts(plots,nu)) continue;
09293 
09295     //END OF STD CUTS
09297 
09298     if (nu.charge==-1) lib.cnt.nuNQCounter++;
09299     else if (nu.charge==+1) lib.cnt.nuPQCounter++;
09300     else cout<<"ahhh, bad charge(12)"<<endl;
09301 
09302 
09303     plots->FillBRev(nu,post);
09304     if (nu.simFlag == SimFlag::kMC) {
09305       plots->FillBRev(nu,"All");
09306     }
09307 
09308   }//end of loop over summary tree
09309 
09310   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
09311 
09315 
09316   //print out the numbers of events
09317   lib.cnt.PrintMicroDST();
09318 
09319   MSG("NuAnalysis",Msg::kInfo)
09320     <<" ** Finished BRevAna method **"<<endl;
09321 }

void NuDSTAna::CoilHoleAna (  ) 

Definition at line 9325 of file NuDSTAna.cxx.

References NuConfig::detector, DoIO(), NuPlots::FillCoilHole(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), NuCuts::kCC0250Std, Msg::kDebug, Detector::kFar, Msg::kInfo, MSG, plots(), NuBase::PrintLoopProgress(), NuInputEvents::ResetNuEventLoopPositionToStart(), and NuConfig::run.

09326 {
09327   NuInputEvents& input=this->DoIO(0,"","null");
09328 
09329   //use config object to store info
09330   NuConfig config;
09331   config.detector=Detector::kFar;
09332   config.run=100;
09333 
09334 
09335   //get an object to fill plots
09336   const NuPlots* plots=0;
09337 
09338   //version to do reco/cuts with
09339   //NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kNMB0325Bravo;
09340 
09341   input.ResetNuEventLoopPositionToStart();
09342 
09346 
09347   cout<<endl
09348       <<"************************************************"<<endl
09349       <<"***      Starting main loop over snarls      ***"<<endl
09350       <<"************************************************"<<endl;
09351 
09352   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
09353     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
09354 
09355     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
09356 
09357     nu.anaVersion=NuCuts::kCC0250Std;
09358 
09359     //make the preselection cuts
09360     //if (!this->IsGoodPreSelectionCuts(plots,nu)) continue;
09361     plots->FillCoilHole(nu);
09362 
09363   } //end of loop over summary tree
09364 
09365   MSG("NuDSTAna",Msg::kInfo)<<"Finished main loop"<<endl;
09366 
09370 
09371   MSG("NuDSTAna",Msg::kInfo)
09372     <<" ** Finished BRevAna method **"<<endl;
09373 }

void NuDSTAna::ConcatenateDSTs (  ) 

This function concatenates DSTs no cuts are made whatsoever, although the anaVersion is checked to ensure all input files use the same version Use with care!

Definition at line 3488 of file NuDSTAna.cxx.

References NuLibrary::cnt, DoIO(), NuCounter::evtCounter, NuOutputWriter::FillNuEventTree(), NuOutputWriter::FillNuMCEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuOutputWriter::GetNuEventToFill(), NuOutputWriter::GetNuMCEventToFill(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, MAXMSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuCounter::PrintFullDST(), NuBase::PrintLoopProgress(), NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), and SanityCheckAnaVersionSameAsPrevious().

03489 {
03494 
03495   //do the histogram IO
03496   NuOutputWriter* poutput=new NuOutputWriter();
03497   NuInputEvents& input=this->DoIO(poutput,"NuDSTConcat");
03498 
03499   //get a reference
03500   NuOutputWriter& output=(*poutput);
03501 
03502   //get an instance of the code library
03503   NuLibrary& lib=NuLibrary::Instance();
03504 
03505   // This can be put back in as necessary. At the moment all it does
03506   // Is throw up an annoying compiler warning.
03507   // static const NuPlots* plots;
03508 
03512 
03513   //prepare for next loop
03514   input.ResetNuEventLoopPositionToStart();
03515 
03516   cout<<endl
03517       <<"************************************************"<<endl
03518       <<"***      Starting main loop over snarls      ***"<<endl
03519       <<"************************************************"<<endl;
03520 
03521   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
03522     lib.cnt.evtCounter++;
03523 
03524     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
03525 
03526     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
03527 
03528     //make sanity check to avoid erroneous use
03529     this->SanityCheckAnaVersionSameAsPrevious(nu.anaVersion);
03530 
03532     //NO CUTS WHATSOEVER
03534 
03535     //count the events to print to screen after loop
03536     if (nu.charge==-1) lib.cnt.nuNQCounter++;
03537     else if (nu.charge==+1) lib.cnt.nuPQCounter++;
03538 
03539     //get the output nu to fill, copy nu to the output nu, fill tree
03540     NuEvent& nuOutput=output.GetNuEventToFill();
03541     nuOutput=nu;
03542     output.FillNuEventTree();
03543   }
03544 
03548 
03549   input.InitialiseNuMCEventBranch();
03550   input.ResetNuMCEventLoopPositionToStart();
03551 
03552   cout<<endl
03553       <<"************************************************"<<endl
03554       <<"***       Starting loop over truth info      ***"<<endl
03555       <<"************************************************"<<endl;
03556 
03557   for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
03558     lib.cnt.evtCounter++;
03559 
03560     this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
03561 
03562     NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
03563                                          (Msg::kDebug));
03564 
03565     //make sanity check to avoid erroneous use
03566     this->SanityCheckAnaVersionSameAsPrevious(mc.anaVersion);
03567 
03568     MAXMSG("NuDSTAna",Msg::kInfo,5)
03569       <<"energyMC="<<mc.energyMC<<endl;
03570 
03572     //NO CUTS WHATSOEVER
03574 
03575     //get the output nu to fill,copy mc to the output mc, fill tree
03576     NuMCEvent& mcOutput=output.GetNuMCEventToFill();
03577     mcOutput=mc;
03578     output.FillNuMCEventTree();
03579   }
03580 
03581   //print out the numbers of events
03582   lib.cnt.PrintFullDST();
03583 
03584   //close the file and write out everything
03585   output.Finish();
03586 }

void NuDSTAna::Contamination ( TString  xmlFileName  ) 

Definition at line 6850 of file NuDSTAna.cxx.

References NuXMLConfig::AnaVersionString(), NuReco::ApplyReweights(), NuXMLConfig::BinningScheme(), NuLibrary::cnt, NuXMLConfig::ConfigureWeights(), DoIO(), NuCounter::evtCounter, NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::InitialiseNuEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, MSG, NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuUtilities::RecoBins(), NuInputEvents::ResetNuEventLoopPositionToStart(), and SanityCheckedAnaVersion().

06851 {
06852   NuInputEvents& input=this->DoIO(0,"","null");
06853 
06854   //get an instance of the code library
06855   NuLibrary& lib = NuLibrary::Instance();
06856 
06857   MSG("NuDSTAna",Msg::kInfo) << "Using xml file " << xmlFileName << endl;
06858   const NuXMLConfig* xmlConfig = new NuXMLConfig(xmlFileName);
06859   xmlConfig->Write();
06860 
06861   // Create the cutter objects
06862   NuCutter cutter(xmlConfig->AnaVersionString(), 0);
06863   cutter.PrintSummary();
06864 
06865   //version to do reco/cuts with
06866   NuCuts::NuAnaVersion_t overrideAnaVersion =
06867   static_cast<NuCuts::NuAnaVersion_t>(cutter.AnaVersion());
06868 
06869   //Binning scheme
06870   NuBinningScheme::NuBinningScheme_t binningScheme =
06871   static_cast<NuBinningScheme::NuBinningScheme_t>(xmlConfig->BinningScheme());
06872   std::vector<Double_t> vReco = NuUtilities::RecoBins(binningScheme);
06873   int numRecoBins = vReco.size() - 1;
06874 
06875   TH1::AddDirectory(true);
06876   TH1D * hEffDenom = new TH1D("hEffDenom","True NuBars in fid with a track",numRecoBins,&(vReco[0]));
06877 
06878   TH1D * hSignal = new TH1D("hSignal","PQ Signal before Selection",numRecoBins,&(vReco[0]));
06879   TH1D * hNC = new TH1D("hNC","PQ NC Events before Selection",numRecoBins,&(vReco[0]));
06880   TH1D * hWS = new TH1D("hWS","PQ Wrong Sign Events before Selection",numRecoBins,&(vReco[0]));
06881   TH1D * hTau = new TH1D("hTau","PQ Tau Events before Selection",numRecoBins,&(vReco[0]));
06882   TH1D * hBkgd = new TH1D("hBkgd","All PQ Background before Selection",numRecoBins,&(vReco[0]));
06883   TH1D * hAllEvents = new TH1D("hAllEvents","All PQ Events before Selection",numRecoBins,&(vReco[0]));
06884 
06885   TH1D * hSignal_sel = new TH1D("hSignal_sel","PQ Signal after Selection",numRecoBins,&(vReco[0]));
06886   TH1D * hNC_sel = new TH1D("hNC_sel","PQ NC Events after Selection",numRecoBins,&(vReco[0]));
06887   TH1D * hWS_sel = new TH1D("hWS_sel","PQ Wrong Sign Events after Selection",numRecoBins,&(vReco[0]));
06888   TH1D * hTau_sel = new TH1D("hTau_sel","PQ Tau Events before Selection",numRecoBins,&(vReco[0]));
06889   TH1D * hBkgd_sel = new TH1D("hBkgd_sel","All PQ Background after Selection",numRecoBins,&(vReco[0]));
06890   TH1D * hAllEvents_sel = new TH1D("hAllEvents_sel","All PQ Events after Selection",numRecoBins,&(vReco[0]));
06891 
06892   input.InitialiseNuEventBranch();
06893   input.ResetNuEventLoopPositionToStart();
06894 
06895   cout<<endl
06896       <<"************************************************"<<endl
06897       <<"***      Starting main loop over snarls      ***"<<endl
06898       <<"************************************************"<<endl;
06899   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
06900     //for (Int_t i=0;i<0;++i) {
06901     lib.cnt.evtCounter++;
06902 
06903     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
06904 
06905     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
06906 
06907     //OVERRIDE
06908     //Selection
06909     nu.anaVersion=this->SanityCheckedAnaVersion
06910       (nu.anaVersion,overrideAnaVersion);
06911 
06912     // Configure reweighting based on the XML file
06913     xmlConfig->ConfigureWeights(nu);
06914 
06915     // Force new SKZP weights (to get the new error band)
06916     //lib.zBeamReweight.ExtractZBeamReweight(nu);
06917 
06918 
06919     //RE-RECONSTRUCT the neutrino energy
06920     lib.reco.GetEvtEnergy(nu, false);
06921 
06922     // Force the correct kNN shower energy to be used
06923     //nu.energy = nu.trkEn+nu.shwEnkNN;
06924     // Force non-kNN Shower energy
06925     //nu.energy = nu.trkEn+nu.shwEnLinCCCor;
06926 
06927     lib.reco.ApplyReweights(nu);
06928 
06929 
06930     cutter.ResetStatus();
06931     cutter.MakePreselectionCuts(nu);
06932 
06933     // Pre-pre selection (Ntracks and fid vol)
06934     if (cutter.Failed("GoodNumberofTracks")) continue;
06935     if (cutter.Failed("FidVol")) continue;
06936 
06937     if (nu.inu == -14 && nu.iaction != 0)
06938       hEffDenom->Fill(nu.energy, nu.rw);
06939 
06940 
06941     if (cutter.Failed()) continue;
06942     if (nu.charge == -1) continue; // Only interested in PQ events
06943 
06944 
06945     hAllEvents->Fill(nu.energy, nu.rw);
06946     if (nu.inu == 16 || nu.inu == -16) { // Taus
06947       if (nu.iaction == 1) {
06948         hTau->Fill(nu.energy, nu.rw);
06949         hBkgd->Fill(nu.energy, nu.rw);
06950       }
06951     }
06952     else if (nu.iaction == 0) {    // NC Background
06953       hNC->Fill(nu.energy, nu.rw);
06954       hBkgd->Fill(nu.energy, nu.rw);
06955     }
06956     else if (nu.inu == 14) { // Wrong Sign Background
06957       hWS->Fill(nu.energy, nu.rw);
06958       hBkgd->Fill(nu.energy, nu.rw);
06959     }
06960     else if (nu.inu == -14) {  // Signal
06961       hSignal->Fill(nu.energy, nu.rw);
06962     }
06963     else { // Other?
06964       hBkgd->Fill(nu.energy, nu.rw);
06965     }
06966 
06967     cutter.MakeCuts(nu);
06968     if (cutter.Failed()) continue;
06969 
06970     hAllEvents_sel->Fill(nu.energy, nu.rw);
06971     if (nu.inu == 16 || nu.inu == -16) { // Taus
06972       if (nu.iaction == 1) {
06973         hTau_sel->Fill(nu.energy, nu.rw);
06974         hBkgd_sel->Fill(nu.energy, nu.rw);
06975       }
06976     }
06977     else if (nu.iaction == 0) {    // NC Background
06978       hNC_sel->Fill(nu.energy, nu.rw);
06979       hBkgd_sel->Fill(nu.energy, nu.rw);
06980     }
06981     else if (nu.inu == 14) { // Wrong Sign Background
06982       hWS_sel->Fill(nu.energy, nu.rw);
06983       hBkgd_sel->Fill(nu.energy, nu.rw);
06984     }
06985     else if (nu.inu == -14) {  // Signal
06986       hSignal_sel->Fill(nu.energy, nu.rw);
06987     }
06988     else { // Other?
06989       hBkgd_sel->Fill(nu.energy, nu.rw);
06990     }
06991 
06992   }
06993 
06994   cout<<endl;
06995 
06996   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06997 
07001 
07002   cutter.PrintSummary();
07003 
07004   //print out the numbers of events
07005   lib.cnt.PrintMicroDST();
07006 
07007   MSG("NuAnalysis",Msg::kInfo)
07008     <<" ** Finished Contamination() method **"<<endl;
07009 }

void NuDSTAna::ContaminationNQ ( TString  xmlFileName  ) 

Definition at line 7012 of file NuDSTAna.cxx.

References NuXMLConfig::AnaVersionString(), NuReco::ApplyReweights(), NuXMLConfig::BinningScheme(), NuLibrary::cnt, NuXMLConfig::ConfigureWeights(), DoIO(), NuCounter::evtCounter, NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::InitialiseNuEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, MSG, NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuUtilities::RecoBins(), NuInputEvents::ResetNuEventLoopPositionToStart(), and SanityCheckedAnaVersion().

07013 {
07014   NuInputEvents& input=this->DoIO(0,"","null");
07015 
07016   //get an instance of the code library
07017   NuLibrary& lib = NuLibrary::Instance();
07018 
07019   MSG("NuDSTAna",Msg::kInfo) << "Using xml file " << xmlFileName << endl;
07020   const NuXMLConfig* xmlConfig = new NuXMLConfig(xmlFileName);
07021   xmlConfig->Write();
07022 
07023   // Create the cutter objects
07024   NuCutter cutter(xmlConfig->AnaVersionString(), 0);
07025   cutter.PrintSummary();
07026 
07027   //version to do reco/cuts with
07028   NuCuts::NuAnaVersion_t overrideAnaVersion =
07029   static_cast<NuCuts::NuAnaVersion_t>(cutter.AnaVersion());
07030 
07031   //Binning scheme
07032   NuBinningScheme::NuBinningScheme_t binningScheme =
07033   static_cast<NuBinningScheme::NuBinningScheme_t>(xmlConfig->BinningScheme());
07034   std::vector<Double_t> vReco = NuUtilities::RecoBins(binningScheme);
07035   int numRecoBins = vReco.size() - 1;
07036 
07037   TH1::AddDirectory(true);
07038   TH1D * hEffDenom = new TH1D("hEffDenom","True Nus in fid with a track",numRecoBins,&(vReco[0]));
07039 
07040   TH1D * hSignal = new TH1D("hSignal","NQ Signal before Selection",numRecoBins,&(vReco[0]));
07041   TH1D * hNC = new TH1D("hNC","NQ NC Events before Selection",numRecoBins,&(vReco[0]));
07042   TH1D * hWS = new TH1D("hWS","NQ Wrong Sign Events before Selection",numRecoBins,&(vReco[0]));
07043   TH1D * hTau = new TH1D("hTau","NQ Tau Events before Selection",numRecoBins,&(vReco[0]));
07044   TH1D * hBkgd = new TH1D("hBkgd","All NQ Background before Selection",numRecoBins,&(vReco[0]));
07045   TH1D * hAllEvents = new TH1D("hAllEvents","All NQ Events before Selection",numRecoBins,&(vReco[0]));
07046 
07047   TH1D * hSignal_sel = new TH1D("hSignal_sel","NQ Signal after Selection",numRecoBins,&(vReco[0]));
07048   TH1D * hNC_sel = new TH1D("hNC_sel","NQ NC Events after Selection",numRecoBins,&(vReco[0]));
07049   TH1D * hWS_sel = new TH1D("hWS_sel","NQ Wrong Sign Events after Selection",numRecoBins,&(vReco[0]));
07050   TH1D * hTau_sel = new TH1D("hTau_sel","NQ Tau Events before Selection",numRecoBins,&(vReco[0]));
07051   TH1D * hBkgd_sel = new TH1D("hBkgd_sel","All NQ Background after Selection",numRecoBins,&(vReco[0]));
07052   TH1D * hAllEvents_sel = new TH1D("hAllEvents_sel","All NQ Events after Selection",numRecoBins,&(vReco[0]));
07053 
07054   input.InitialiseNuEventBranch();
07055   input.ResetNuEventLoopPositionToStart();
07056 
07057   cout<<endl
07058       <<"************************************************"<<endl
07059       <<"***      Starting main loop over snarls      ***"<<endl
07060       <<"************************************************"<<endl;
07061   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
07062     //for (Int_t i=0;i<0;++i) {
07063     lib.cnt.evtCounter++;
07064 
07065     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
07066 
07067     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
07068 
07069     //OVERRIDE
07070     //Selection
07071     nu.anaVersion=this->SanityCheckedAnaVersion
07072       (nu.anaVersion,overrideAnaVersion);
07073 
07074     // Configure reweighting based on the XML file
07075     xmlConfig->ConfigureWeights(nu);
07076 
07077     // Force new SKZP weights (to get the new error band)
07078     //lib.zBeamReweight.ExtractZBeamReweight(nu);
07079 
07080 
07081     //RE-RECONSTRUCT the neutrino energy
07082     lib.reco.GetEvtEnergy(nu, false);
07083 
07084     // Force the correct kNN shower energy to be used
07085     //nu.energy = nu.trkEn+nu.shwEnkNN;
07086     // Force non-kNN Shower energy
07087     //nu.energy = nu.trkEn+nu.shwEnLinCCCor;
07088 
07089     lib.reco.ApplyReweights(nu);
07090 
07091 
07092     cutter.ResetStatus();
07093     cutter.MakePreselectionCuts(nu);
07094 
07095     // Pre-pre selection (Ntracks and fid vol)
07096     if (cutter.Failed("GoodNumberofTracks")) continue;
07097     if (cutter.Failed("FidVol")) continue;
07098 
07099     if (nu.inu == 14 && nu.iaction != 0)
07100       hEffDenom->Fill(nu.energy, nu.rw);
07101 
07102 
07103     if (cutter.Failed()) continue;
07104     if (nu.charge == 1) continue; // Only interested in NQ events
07105 
07106 
07107     hAllEvents->Fill(nu.energy, nu.rw);
07108     if (nu.inu == 16 || nu.inu == -16) { // Taus
07109       if (nu.iaction == 1) {
07110         hTau->Fill(nu.energy, nu.rw);
07111         hBkgd->Fill(nu.energy, nu.rw);
07112       }
07113     }
07114     else if (nu.iaction == 0) {    // NC Background
07115       hNC->Fill(nu.energy, nu.rw);
07116       hBkgd->Fill(nu.energy, nu.rw);
07117     }
07118     else if (nu.inu == -14) { // Wrong Sign Background
07119       hWS->Fill(nu.energy, nu.rw);
07120       hBkgd->Fill(nu.energy, nu.rw);
07121     }
07122     else if (nu.inu == 14) {  // Signal
07123       hSignal->Fill(nu.energy, nu.rw);
07124     }
07125     else { // Other?
07126       hBkgd->Fill(nu.energy, nu.rw);
07127     }
07128 
07129     cutter.MakeCuts(nu);
07130     if (cutter.Failed()) continue;
07131 
07132     hAllEvents_sel->Fill(nu.energy, nu.rw);
07133     if (nu.inu == 16 || nu.inu == -16) { // Taus
07134       if (nu.iaction == 1) {
07135         hTau_sel->Fill(nu.energy, nu.rw);
07136         hBkgd_sel->Fill(nu.energy, nu.rw);
07137       }
07138     }
07139     else if (nu.iaction == 0) {    // NC Background
07140       hNC_sel->Fill(nu.energy, nu.rw);
07141       hBkgd_sel->Fill(nu.energy, nu.rw);
07142     }
07143     else if (nu.inu == -14) { // Wrong Sign Background
07144       hWS_sel->Fill(nu.energy, nu.rw);
07145       hBkgd_sel->Fill(nu.energy, nu.rw);
07146     }
07147     else if (nu.inu == 14) {  // Signal
07148       hSignal_sel->Fill(nu.energy, nu.rw);
07149     }
07150     else { // Other?
07151       hBkgd_sel->Fill(nu.energy, nu.rw);
07152     }
07153 
07154   }
07155 
07156   cout<<endl;
07157 
07158   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
07159 
07163 
07164   cutter.PrintSummary();
07165 
07166   //print out the numbers of events
07167   lib.cnt.PrintMicroDST();
07168 
07169   MSG("NuAnalysis",Msg::kInfo)
07170     <<" ** Finished ContaminationNQ() method **"<<endl;
07171 }

void NuDSTAna::CopyAcrossHistos ( TDirectory *  dirInput,
TDirectory *  dirOutput 
) const [protected]

Definition at line 936 of file NuDSTAna.cxx.

References NuGeneral::CopyAcrossObjects().

Referenced by DoIOSimple(), FDTestAna(), and NMBAna().

00938 {
00939   //vector to store the names of the histograms to copy across
00940   vector<string> vObjectNames;
00941   vObjectNames.push_back("hDetector");
00942   vObjectNames.push_back("hSimFlag");
00943   vObjectNames.push_back("hTrigSrc");
00944   vObjectNames.push_back("hSpillsPerFile");
00945 
00946   //these were commented out
00947   vObjectNames.push_back("hRun");
00948   vObjectNames.push_back("hPottortgt");
00949   vObjectNames.push_back("hPotBadtortgt");
00950   vObjectNames.push_back("hPottrtgtd");
00951   vObjectNames.push_back("hPotBadtrtgtd");
00952   vObjectNames.push_back("hPottor101");
00953   vObjectNames.push_back("hPotBadtor101");
00954   vObjectNames.push_back("hPottr101d");
00955   vObjectNames.push_back("hPotBadtr101d");
00956 
00957   //these are new
00958   vObjectNames.push_back("hTotalPot");
00959   vObjectNames.push_back("hNtupleEarliestTime");
00960   vObjectNames.push_back("hNtupleLatestTime");
00961 
00962   NuGeneral general;
00963   general.CopyAcrossObjects(dirInput,dirOutput,vObjectNames);
00964 }

void NuDSTAna::CSSAna (  ) 

Definition at line 9444 of file NuDSTAna.cxx.

References DoIO(), NuPlots::FillEffPur(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), Msg::kDebug, Msg::kInfo, MSG, plots(), NuBase::PrintLoopProgress(), and NuInputEvents::ResetNuEventLoopPositionToStart().

09445 {
09446   NuInputEvents& input=this->DoIO();
09447 
09448   //get an object to fill plots
09449   const NuPlots* plots=0;
09450 
09451   input.ResetNuEventLoopPositionToStart();
09452 
09456 
09457   cout<<endl
09458       <<"************************************************"<<endl
09459       <<"***      Starting main loop over snarls      ***"<<endl
09460       <<"************************************************"<<endl;
09461 
09462   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
09463     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
09464 
09465     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
09466 
09467     //speed up cut for looking at nmb only
09468     if (nu.charge==-1) continue;
09469 
09470     plots->FillEffPur(nu, nu.prob > 0.1);
09471   }//end of loop over summary tree
09472 
09473   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
09474 
09478 
09479   MSG("NuAnalysis",Msg::kInfo)
09480     <<" ** Finished CSSAna method **"<<endl;
09481 }

void NuDSTAna::CSSAnaRashid (  ) 

Definition at line 9377 of file NuDSTAna.cxx.

References DoIO(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), Msg::kDebug, Msg::kInfo, MakeFinalPlots(), MakePostPreSelectionPlots(), MSG, plots(), NuBase::PrintLoopProgress(), and NuInputEvents::ResetNuEventLoopPositionToStart().

09378 {
09379   NuInputEvents& input=this->DoIO();
09380 
09381   //get an object to fill plots
09382   const NuPlots* plots=0;
09383 
09384   input.ResetNuEventLoopPositionToStart();
09385 
09389 
09390   cout<<endl
09391       <<"************************************************"<<endl
09392       <<"***      Starting main loop over snarls      ***"<<endl
09393       <<"************************************************"<<endl;
09394 
09395   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
09396     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
09397 
09398     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
09399 
09400     //make the post-preselection plots (do this first)
09401     this->MakePostPreSelectionPlots(plots,nu);
09402 
09404     //NOW MAKE THE CUTS THAT YOU ARE INVESTIGATING THE EFFECT OF
09405     //THE SYSTEMATICS ON
09407 
09408     //speed up cut for looking at nmb only
09409     if (nu.charge==-1) {
09410       //neutrino-like event
09411       if (nu.dpID<-0.1) continue;
09412     }
09413     else if (nu.charge==+1) {
09414       //anti-neutrino-like event
09415 
09416       //EXAMPLE CUTS:
09417 
09418       if (nu.dpID<+0.4) continue;
09419 
09420       //if (nu.prob<0.1) continue;
09421 
09422       //if (roID<0.3) continue;//WHAT VALUE TO USE???
09423 
09424       //OTHER CUTS INVESTIGATED HERE...
09425     }
09426 
09427     //now fill the plots after the selection has been applied
09428     this->MakeFinalPlots(plots,nu);
09429 
09430   }//end of loop over summary tree
09431 
09432   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
09433 
09437 
09438   MSG("NuAnalysis",Msg::kInfo)
09439     <<" ** Finished CSSAnaRashid method **"<<endl;
09440 }

NuInputEvents & NuDSTAna::DoIO ( NuOutputWriter poutput = 0,
std::string  sFilePrefix = "",
std::string  sFullFileName = "" 
) [protected]

Definition at line 997 of file NuDSTAna.cxx.

References NuHistos::CalcPOTsFromHistos(), det, NuBase::fOutFile, NuInputEvents::GetFirstRunNumberNuEvent(), NuBase::GetInputFileName(), NuInputEvents::GetNextNuEvent(), GetNuConfig(), NuLibrary::hist, NuInputEvents::InitialiseChains(), NuInputEvents::InitialiseNuEventBranch(), NuInputEvents::InputFileName(), NuLibrary::Instance(), Msg::kDebug, Msg::kError, Msg::kFatal, Msg::kInfo, ENCTruth::kNumTruths, Msg::kWarning, MAXMSG, MSG, NuBase::OpenFile(), NuBase::OpenFileRECREATE(), NuInputEvents::OpenNextInputFile(), NuOutputWriter::SetupFile(), and ENCTruth::truthNames.

Referenced by BRevAna(), CoilHoleAna(), ConcatenateDSTs(), Contamination(), ContaminationNQ(), CSSAna(), CSSAnaRashid(), DPSystematic(), FluxComponents(), FoverNHistos::GetEventListForLooping(), FitTree::GetEventListForLooping(), DataStabilityAnalysisClass::GetEventListForLooping(), TemplateAnalysisClass::GetEventListForLooping(), ToFPlotter::GetEventListForLooping(), DataMCPlots::GetEventListForLooping(), JeffsTestAna(), MakeCuts(), MakeDstPQ(), MakeFCTree(), MakekNNTrainTestSet(), MakeMicroDST(), MakeMicroDst2010(), MakeMicroDst2014(), MakeMicroDstFakeData(), MakeMicroDstForCSSSystematics(), MakeMicroDstHe(), MakeMicroDstJJEPresel(), MakeMicroDstNC2012(), MakeMicroDstWithStdCCRecoAndCuts(), MakePurityEfficiencyPlotsCCNC(), MakeResolutionBins(), MakeRoIDTrainingSet(), MakeSelMicroDST(), MakeShwEnkNNTestingSet(), MakeShwEnkNNTrainingSet(), MMAna(), MMRereco(), MMTransition(), MMTransSME(), NDOsc(), NDQPRB(), NDTestAna(), NewFieldAna(), QPStudy(), RHCTest(), SelectorTable(), StdCCAna(), StdNMBAna(), TestNuSyst(), VsTime(), and YStudy().

01000 {
01001   //open the input file with the tree in it
01002   string inputFileName=this->GetInputFileName();
01003   NuInputEvents* fpInput=new NuInputEvents();
01004   NuInputEvents& input=*fpInput;
01005   input.InputFileName(inputFileName);
01006   input.InitialiseChains();
01007   input.InitialiseNuEventBranch();
01008 
01009   TDirectory* dirInput=0;
01010 
01011   //formatting string for times
01012   MsgFormat ffmt("%9.f");
01013 
01014   NuXMLConfig *xmlConfigClone=0;
01015   TH1F* hDetectorClone=0;
01016   TH1F* hSimFlagClone=0;
01017   TH1F* hTrigSrcClone=0;
01018   TH1F* hSpillsPerFileClone=0;
01019 
01020   TH1F* hTotalPotClone=0;
01021 
01022   TH1F* hPottortgtClone=0;
01023   TH1F* hPotBadtortgtClone=0;
01024   TH1F* hPottrtgtdClone=0;
01025   TH1F* hPotBadtrtgtdClone=0;
01026   TH1F* hPottor101Clone=0;
01027   TH1F* hPotBadtor101Clone=0;
01028   TH1F* hPottr101dClone=0;
01029   TH1F* hPotBadtr101dClone=0;
01030   TH1F* hRunClone=0;
01031 
01032   TH1F* hNtupleEarliestTimeClone=0;
01033   TH1F* hNtupleLatestTimeClone=0;
01034 
01035   // F/N method histograms
01036   TH2D *hRecoVsTrueEnergyUnnormNQ_ND = 0;
01037   TH2D *hRecoVsTrueEnergyUnnormNQ_FD = 0;
01038   TH2D *hRecoVsTrueEnergyUnnormPQ_ND = 0;
01039   TH2D *hRecoVsTrueEnergyUnnormPQ_FD = 0;
01040   TH2D *hRecoVsTrueEnergyUnnormAll_ND = 0;
01041   TH2D *hRecoVsTrueEnergyUnnormAll_FD = 0;
01042 
01043   //Matrix method histograms (numu CC):
01044   TH2D *hRecoVsTrueEnergy_NDClone = 0;
01045   TH2D *hRecoVsTrueEnergy_FDClone = 0;
01046   TH1D *hEfficiency_NDClone = 0;
01047   TH1D *hEfficiency_FDClone = 0;
01048   TH1D *hPurity_NDClone = 0;
01049   TH1D *hPurity_FDClone = 0;
01050   TH1D *hRecoEnergyAllEvents_NDClone = 0;
01051   TH1D *hRecoEnergyCCOnlyEvents_NDClone = 0;
01052   TH1D *hTrueEnergyCCOnlyEvents_NDClone = 0;
01053   TH1D *hTrueEnergyTrueCCFidEvents_NDClone = 0;
01054   TH1D *hTrueEnergyTrueCCFidEvents_FDClone = 0;
01055   TH1D *hTrueEnergyCCOnlyEvents_FDClone = 0;
01056   TH1D *hRecoEnergyCCOnlyEvents_FDClone = 0;
01057   TH1D *hRecoEnergyAllEvents_FDClone = 0;
01058   TH1D* hRecoEnergy_NDClone = 0;
01059   TH1D* hRecoEnergy_FDClone = 0;
01060   TH1D* hRecoEnergy_ND_NCClone = 0;
01061   TH1D* hRecoEnergy_FD_NCClone = 0;
01062   TH2D* hRecoVsTrueEnergy_ND_NCClone = 0;
01063   TH2D* hRecoVsTrueEnergy_FD_NCClone = 0;
01064 
01065   TH2D* hRecoVsTrueEnergy_NCClone_truly[ENCTruth::kNumTruths][2] = {{0,},};
01066 
01067   TH1D* hCCContamination_FDClone = 0;
01068   TH1D* hCCContamination_NDClone = 0;
01069   TH2D* hCCContaminationRecoVsTrue_FDClone = 0;
01070   TH1D* hNCContamination_FDClone = 0;
01071   TH1D* hNCContamination_NDClone = 0;
01072   //Matrix method histograms (numubar CC):
01073   TH2D *hRecoVsTrueEnergyPQ_NDClone = 0;
01074   TH2D *hRecoVsTrueEnergyPQ_FDClone = 0;
01075   TH1D *hEfficiencyPQ_NDClone = 0;
01076   TH1D *hEfficiencyPQ_FDClone = 0;
01077   TH1D *hPurityPQ_NDClone = 0;
01078   TH1D *hPurityPQ_FDClone = 0;
01079   TH1D *hRecoEnergyAllEventsPQ_NDClone = 0;
01080   TH1D *hRecoEnergyCCOnlyEventsPQ_NDClone = 0;
01081   TH1D *hTrueEnergyCCOnlyEventsPQ_NDClone = 0;
01082   TH1D *hTrueEnergyTrueCCFidEventsPQ_NDClone = 0;
01083   TH1D *hTrueEnergyTrueCCFidEventsPQ_FDClone = 0;
01084   TH1D *hTrueEnergyCCOnlyEventsPQ_FDClone = 0;
01085   TH1D *hRecoEnergyCCOnlyEventsPQ_FDClone = 0;
01086   TH1D *hRecoEnergyAllEventsPQ_FDClone = 0;
01087   TH1D* hRecoEnergyPQ_NDClone = 0;
01088   TH1D* hRecoEnergyPQ_FDClone = 0;
01089   TH1D* hCCContaminationPQ_FDClone = 0;
01090   TH1D* hCCContaminationPQ_NDClone = 0;
01091   TH2D* hCCContaminationRecoVsTruePQ_FDClone = 0;
01092   TH1D* hNCContaminationPQ_FDClone = 0;
01093   TH1D* hNCContaminationPQ_NDClone = 0;
01094   //Matrix method Decay Pipe histograms
01095   TH1D* hTrueEnergyAllEventsPQ_NDClone = 0;
01096   TH1D* hTrueEnergyAllEventsPQ_FDClone = 0;
01097   TH1D* hTrueEnergyDecayPipePQ_NDClone = 0;
01098   TH1D* hTrueEnergyDecayPipePQ_FDClone = 0;
01099   //Matrix method histograms (numu + numubar CC):
01100   TH2D *hRecoVsTrueEnergyAll_NDClone = 0;
01101   TH2D *hRecoVsTrueEnergyAll_FDClone = 0;
01102   TH1D *hEfficiencyAll_NDClone = 0;
01103   TH1D *hEfficiencyAll_FDClone = 0;
01104   TH1D *hPurityAll_NDClone = 0;
01105   TH1D *hPurityAll_FDClone = 0;
01106   TH1D *hRecoEnergyAllEventsAll_NDClone = 0;
01107   TH1D *hRecoEnergyCCOnlyEventsAll_NDClone = 0;
01108   TH1D *hTrueEnergyCCOnlyEventsAll_NDClone = 0;
01109   TH1D *hTrueEnergyTrueCCFidEventsAll_NDClone = 0;
01110   TH1D *hTrueEnergyTrueCCFidEventsAll_FDClone = 0;
01111   TH1D *hTrueEnergyCCOnlyEventsAll_FDClone = 0;
01112   TH1D *hRecoEnergyCCOnlyEventsAll_FDClone = 0;
01113   TH1D *hRecoEnergyAllEventsAll_FDClone = 0;
01114   TH1D* hRecoEnergyAll_NDClone = 0;
01115   TH1D* hRecoEnergyAll_FDClone = 0;
01116   //Matrix method histograms (nutau CC):
01117   TH2D* hRecoVsTrueEnergyTau_FDClone = 0;
01118   TH1D* hEfficiencyTau_FDClone = 0;
01119   TH1D* hTrueEnergyTrueCCFidEventsTau_FDClone = 0;
01120   TH1D* hTrueEnergyCCOnlyEventsTau_FDClone = 0;
01121   //Matrix method histograms (nutaubar CC):
01122   TH2D* hRecoVsTrueEnergyTauPQ_FDClone = 0;
01123   TH1D* hEfficiencyTauPQ_FDClone = 0;
01124   TH1D* hTrueEnergyTrueCCFidEventsTauPQ_FDClone = 0;
01125   TH1D* hTrueEnergyCCOnlyEventsTauPQ_FDClone = 0;
01126   //Matrix method histograms (nutau + nutaubar CC):
01127   TH2D* hRecoVsTrueEnergyTauAll_FDClone = 0;
01128   TH1D* hEfficiencyTauAll_FDClone = 0;
01129   TH1D* hTrueEnergyTrueCCFidEventsTauAll_FDClone = 0;
01130   TH1D* hTrueEnergyCCOnlyEventsTauAll_FDClone = 0;
01131 
01132 
01133   for (Int_t i=0;i<10000;i++){
01134 
01135     //get the next file
01136     TDirectory* tmpDirInput=input.OpenNextInputFile();
01137 
01138     //check file exists
01139     if (!tmpDirInput) continue;
01140 
01141     //store input file directory
01142     dirInput=tmpDirInput;
01143     gDirectory=dirInput;
01144     dirInput->Print();
01145 
01146     NuXMLConfig *xmlConfig = (NuXMLConfig*)gROOT->FindObject("NuXMLConfig");
01147 
01148     //get the histograms
01149     TH1F* hDetector=(TH1F*)gROOT->FindObject("hDetector");
01150     TH1F* hSimFlag=(TH1F*)gROOT->FindObject("hSimFlag");
01151     TH1F* hTrigSrc=(TH1F*)gROOT->FindObject("hTrigSrc");
01152     TH1F* hSpillsPerFile=(TH1F*)gROOT->FindObject("hSpillsPerFile");
01153 
01154     TH1F* hTotalPot=(TH1F*)gROOT->FindObject("hTotalPot");
01155 
01156     TH1F* hPottortgt=(TH1F*)gROOT->FindObject("hPottortgt");
01157     TH1F* hPotBadtortgt=(TH1F*)gROOT->FindObject("hPotBadtortgt");
01158     TH1F* hPottrtgtd=(TH1F*)gROOT->FindObject("hPottrtgtd");
01159     TH1F* hPotBadtrtgtd=(TH1F*)gROOT->FindObject("hPotBadtrtgtd");
01160     TH1F* hPottor101=(TH1F*)gROOT->FindObject("hPottor101");
01161     TH1F* hPotBadtor101=(TH1F*)gROOT->FindObject("hPotBadtor101");
01162     TH1F* hPottr101d=(TH1F*)gROOT->FindObject("hPottr101d");
01163     TH1F* hPotBadtr101d=(TH1F*)gROOT->FindObject("hPotBadtr101d");
01164     TH1F* hRun=(TH1F*)gROOT->FindObject("hRun");
01165 
01166     TH1F* hNtupleEarliestTime=(TH1F*)gROOT->FindObject("hNtupleEarliestTime");
01167     TH1F* hNtupleLatestTime=(TH1F*)gROOT->FindObject("hNtupleLatestTime");
01168 
01169     //get Matrix Method histograms (numu CC):
01170     TH2D *hRecoVsTrueEnergy_ND = (TH2D*) gROOT->FindObject("RecoVsTrueEnergy_ND");
01171     TH2D *hRecoVsTrueEnergy_FD = (TH2D*) gROOT->FindObject("RecoVsTrueEnergy_FD");
01172     TH1D *hEfficiency_ND = (TH1D*) gROOT->FindObject("Efficiency_ND");
01173     TH1D *hEfficiency_FD = (TH1D*) gROOT->FindObject("Efficiency_FD");
01174     TH1D *hPurity_ND = (TH1D*) gROOT->FindObject("Purity_ND");
01175     TH1D *hPurity_FD = (TH1D*) gROOT->FindObject("Purity_FD");
01176     TH1D *hRecoEnergyAllEvents_ND = (TH1D*) gROOT->FindObject("RecoEnergyAllEvents_ND");
01177     TH1D *hRecoEnergyCCOnlyEvents_ND = (TH1D*) gROOT->FindObject("RecoEnergyCCOnlyEvents_ND");
01178     TH1D *hTrueEnergyCCOnlyEvents_ND = (TH1D*) gROOT->FindObject("TrueEnergyCCOnlyEvents_ND");
01179     TH1D *hTrueEnergyTrueCCFidEvents_ND = (TH1D*) gROOT->FindObject("TrueEnergyTrueCCFidEvents_ND");
01180     TH1D *hTrueEnergyTrueCCFidEvents_FD = (TH1D*) gROOT->FindObject("TrueEnergyTrueCCFidEvents_FD");
01181     TH1D *hTrueEnergyCCOnlyEvents_FD = (TH1D*) gROOT->FindObject("TrueEnergyCCOnlyEvents_FD");
01182     TH1D *hRecoEnergyCCOnlyEvents_FD = (TH1D*) gROOT->FindObject("RecoEnergyCCOnlyEvents_FD");
01183     TH1D *hRecoEnergyAllEvents_FD = (TH1D*) gROOT->FindObject("RecoEnergyAllEvents_FD");
01184     TH1D *hRecoEnergy_ND = (TH1D*) gROOT->FindObject("RecoEnergy_ND");
01185 
01186     TH1D *hRecoEnergy_FD = (TH1D*) gROOT->FindObject("RecoEnergy_FD");
01187     TH1D *hRecoEnergy_ND_NC = (TH1D*) gROOT->FindObject("RecoEnergy_ND_NC");
01188     TH1D *hRecoEnergy_FD_NC = (TH1D*) gROOT->FindObject("RecoEnergy_FD_NC");
01189     TH2D *hRecoVsTrueEnergy_ND_NC = (TH2D*) gROOT->FindObject("RecoVsTrueEnergy_ND_NC");
01190     TH2D *hRecoVsTrueEnergy_FD_NC = (TH2D*) gROOT->FindObject("RecoVsTrueEnergy_FD_NC");
01191 
01192     TH2D* RecoVsTrueEnergy_NC_truly[ENCTruth::kNumTruths][2];
01193     for(int truth = 0; truth < ENCTruth::kNumTruths; ++truth){
01194       for(int det = 0; det <= 1; ++det){
01195         const TString detstr = det ? "FD" : "ND";
01196         const TString name = "RecoVsTrueEnergy_truly"+ENCTruth::truthNames[truth]+"_"+detstr+"_NC";
01197         RecoVsTrueEnergy_NC_truly[truth][det] = (TH2D*)gROOT->FindObject(name);
01198       }
01199     }
01200 
01201 
01202     TH1D* hCCContamination_FD =(TH1D*) gROOT->FindObject("CCContamination_FD");
01203     TH1D* hCCContamination_ND =(TH1D*) gROOT->FindObject("CCContamination_ND");
01204     TH2D* hCCContaminationRecoVsTrue_FD =(TH2D*) gROOT->FindObject("CCContaminationRecoVsTrue_FD");
01205     TH1D* hNCContamination_FD =(TH1D*) gROOT->FindObject("NCContamination_FD");
01206     TH1D* hNCContamination_ND =(TH1D*) gROOT->FindObject("NCContamination_ND");
01207     //get Matrix Method histograms (numubar CC):
01208     TH2D *hRecoVsTrueEnergyPQ_ND = (TH2D*) gROOT->FindObject("RecoVsTrueEnergyPQ_ND");
01209     TH2D *hRecoVsTrueEnergyPQ_FD = (TH2D*) gROOT->FindObject("RecoVsTrueEnergyPQ_FD");
01210     TH1D *hEfficiencyPQ_ND = (TH1D*) gROOT->FindObject("EfficiencyPQ_ND");
01211     TH1D *hEfficiencyPQ_FD = (TH1D*) gROOT->FindObject("EfficiencyPQ_FD");
01212     TH1D *hPurityPQ_ND = (TH1D*) gROOT->FindObject("PurityPQ_ND");
01213     TH1D *hPurityPQ_FD = (TH1D*) gROOT->FindObject("PurityPQ_FD");
01214     TH1D *hRecoEnergyAllEventsPQ_ND = (TH1D*) gROOT->FindObject("RecoEnergyAllEventsPQ_ND");
01215     TH1D *hRecoEnergyCCOnlyEventsPQ_ND = (TH1D*) gROOT->FindObject("RecoEnergyCCOnlyEventsPQ_ND");
01216     TH1D *hTrueEnergyCCOnlyEventsPQ_ND = (TH1D*) gROOT->FindObject("TrueEnergyCCOnlyEventsPQ_ND");
01217     TH1D *hTrueEnergyTrueCCFidEventsPQ_ND = (TH1D*) gROOT->FindObject("TrueEnergyTrueCCFidEventsPQ_ND");
01218     TH1D *hTrueEnergyTrueCCFidEventsPQ_FD = (TH1D*) gROOT->FindObject("TrueEnergyTrueCCFidEventsPQ_FD");
01219     TH1D *hTrueEnergyCCOnlyEventsPQ_FD = (TH1D*) gROOT->FindObject("TrueEnergyCCOnlyEventsPQ_FD");
01220     TH1D *hRecoEnergyCCOnlyEventsPQ_FD = (TH1D*) gROOT->FindObject("RecoEnergyCCOnlyEventsPQ_FD");
01221     TH1D *hRecoEnergyAllEventsPQ_FD = (TH1D*) gROOT->FindObject("RecoEnergyAllEventsPQ_FD");
01222     TH1D *hRecoEnergyPQ_ND = (TH1D*) gROOT->FindObject("RecoEnergyPQ_ND");
01223     TH1D *hRecoEnergyPQ_FD = (TH1D*) gROOT->FindObject("RecoEnergyPQ_FD");
01224     TH1D* hCCContaminationPQ_FD =(TH1D*) gROOT->FindObject("CCContaminationPQ_FD");
01225     TH1D* hCCContaminationPQ_ND =(TH1D*) gROOT->FindObject("CCContaminationPQ_ND");
01226     TH2D* hCCContaminationRecoVsTruePQ_FD =(TH2D*) gROOT->FindObject("CCContaminationRecoVsTruePQ_FD");
01227     TH1D* hNCContaminationPQ_FD =(TH1D*) gROOT->FindObject("NCContaminationPQ_FD");
01228     TH1D* hNCContaminationPQ_ND =(TH1D*) gROOT->FindObject("NCContaminationPQ_ND");
01229     //get Matrix Method histograms (Decay Pipe)
01230     TH1D* hTrueEnergyAllEventsPQ_ND =(TH1D*) gROOT->FindObject("TrueEnergyAllEventsPQ_ND");
01231     TH1D* hTrueEnergyAllEventsPQ_FD =(TH1D*) gROOT->FindObject("TrueEnergyAllEventsPQ_FD");
01232     TH1D* hTrueEnergyDecayPipePQ_ND =(TH1D*) gROOT->FindObject("TrueEnergyDecayPipePQ_ND");
01233     TH1D* hTrueEnergyDecayPipePQ_FD =(TH1D*) gROOT->FindObject("TrueEnergyDecayPipePQ_FD");
01234     //get Matrix Method histograms (numu + numubar CC):
01235     TH2D *hRecoVsTrueEnergyAll_ND = (TH2D*) gROOT->FindObject("RecoVsTrueEnergyAll_ND");
01236     TH2D *hRecoVsTrueEnergyAll_FD = (TH2D*) gROOT->FindObject("RecoVsTrueEnergyAll_FD");
01237     TH1D *hEfficiencyAll_ND = (TH1D*) gROOT->FindObject("EfficiencyAll_ND");
01238     TH1D *hEfficiencyAll_FD = (TH1D*) gROOT->FindObject("EfficiencyAll_FD");
01239     TH1D *hPurityAll_ND = (TH1D*) gROOT->FindObject("PurityAll_ND");
01240     TH1D *hPurityAll_FD = (TH1D*) gROOT->FindObject("PurityAll_FD");
01241     TH1D *hRecoEnergyAllEventsAll_ND = (TH1D*) gROOT->FindObject("RecoEnergyAllEventsAll_ND");
01242     TH1D *hRecoEnergyCCOnlyEventsAll_ND = (TH1D*) gROOT->FindObject("RecoEnergyCCOnlyEventsAll_ND");
01243     TH1D *hTrueEnergyCCOnlyEventsAll_ND = (TH1D*) gROOT->FindObject("TrueEnergyCCOnlyEventsAll_ND");
01244     TH1D *hTrueEnergyTrueCCFidEventsAll_ND = (TH1D*) gROOT->FindObject("TrueEnergyTrueCCFidEventsAll_ND");
01245     TH1D *hTrueEnergyTrueCCFidEventsAll_FD = (TH1D*) gROOT->FindObject("TrueEnergyTrueCCFidEventsAll_FD");
01246     TH1D *hTrueEnergyCCOnlyEventsAll_FD = (TH1D*) gROOT->FindObject("TrueEnergyCCOnlyEventsAll_FD");
01247     TH1D *hRecoEnergyCCOnlyEventsAll_FD = (TH1D*) gROOT->FindObject("RecoEnergyCCOnlyEventsAll_FD");
01248     TH1D *hRecoEnergyAllEventsAll_FD = (TH1D*) gROOT->FindObject("RecoEnergyAllEventsAll_FD");
01249     TH1D *hRecoEnergyAll_ND = (TH1D*) gROOT->FindObject("RecoEnergyAll_ND");
01250     TH1D *hRecoEnergyAll_FD = (TH1D*) gROOT->FindObject("RecoEnergyAll_FD");
01251     //get Matrix Method histograms (nutau CC):
01252     TH2D* hRecoVsTrueEnergyTau_FD = (TH2D*) gROOT->FindObject("RecoVsTrueEnergyTau_FD");
01253     TH1D* hEfficiencyTau_FD = (TH1D*) gROOT->FindObject("EfficiencyTau_FD");
01254     TH1D* hTrueEnergyTrueCCFidEventsTau_FD = (TH1D*) gROOT->FindObject("TrueEnergyTrueCCFidEventsTau_FD");
01255     TH1D* hTrueEnergyCCOnlyEventsTau_FD = (TH1D*) gROOT->FindObject("TrueEnergyCCOnlyEventsTau_FD");
01256     //get Matrix Method histograms (nutaubar CC):
01257     TH2D* hRecoVsTrueEnergyTauPQ_FD = (TH2D*) gROOT->FindObject("RecoVsTrueEnergyTauPQ_FD");
01258     TH1D* hEfficiencyTauPQ_FD = (TH1D*) gROOT->FindObject("EfficiencyTauPQ_FD");
01259     TH1D* hTrueEnergyTrueCCFidEventsTauPQ_FD = (TH1D*) gROOT->FindObject("TrueEnergyTrueCCFidEventsTauPQ_FD");
01260     TH1D* hTrueEnergyCCOnlyEventsTauPQ_FD = (TH1D*) gROOT->FindObject("TrueEnergyCCOnlyEventsTauPQ_FD");
01261     //get Matrix Method histograms (nutau CC):
01262     TH2D* hRecoVsTrueEnergyTauAll_FD = (TH2D*) gROOT->FindObject("RecoVsTrueEnergyTauAll_FD");
01263     TH1D* hEfficiencyTauAll_FD = (TH1D*) gROOT->FindObject("EfficiencyTauAll_FD");
01264     TH1D* hTrueEnergyTrueCCFidEventsTauAll_FD = (TH1D*) gROOT->FindObject("TrueEnergyTrueCCFidEventsTauAll_FD");
01265     TH1D* hTrueEnergyCCOnlyEventsTauAll_FD = (TH1D*) gROOT->FindObject("TrueEnergyCCOnlyEventsTauAll_FD");
01266 
01267     //check if histo found
01268     if (!hPottortgt) {
01269       MSG("NuDSTAna",Msg::kWarning) <<"hPottortgt does not exist in file:"<<endl;
01270       dirInput->Print();
01271       // There is not always an hPottortgt
01272       //continue;
01273     }
01274 
01275     //clone the histos for the first file
01276     if (!hPottortgtClone) {
01277       MSG("NuDSTAna",Msg::kInfo) << "Clone the histos for the first file" << endl;
01278 
01279       if (xmlConfig) {
01280         MSG("NuDSTAna",Msg::kInfo)<< "NuXMLConfig cloned from input file" << endl;
01281         xmlConfigClone = (NuXMLConfig*)xmlConfig->Clone("NuXMLConfigClone");
01282       }
01283       else {
01284         MSG("NuDSTAna",Msg::kInfo)
01285           <<"No NuXMLConfig object found in input"
01286           <<" file (not necessarily unexpected)" << endl;
01287 
01288       }
01289 
01290 
01291       hDetectorClone=(TH1F*)hDetector->Clone("hDetectorClone");
01292       hSimFlagClone=(TH1F*)hSimFlag->Clone("hSimFlagClone");
01293       hTrigSrcClone=(TH1F*)hTrigSrc->Clone("hTrigSrcClone");
01294       hSpillsPerFileClone=(TH1F*)hSpillsPerFile->Clone("hSpillsPerFileClone");
01295 
01296       if (hTotalPot) {
01297         hTotalPotClone=(TH1F*)hTotalPot->Clone("hTotalPotClone");
01298       }
01299 
01300       hPottortgtClone=(TH1F*)hPottortgt->Clone("hPottortgtClone");
01301       hPotBadtortgtClone=(TH1F*)hPotBadtortgt->Clone("hPotBadtortgtClone");
01302       hPottrtgtdClone=(TH1F*)hPottrtgtd->Clone("hPottrtgtdClone");
01303       hPotBadtrtgtdClone=(TH1F*)hPotBadtrtgtd->Clone("hPotBadtrtgtdClone");
01304       hPottor101Clone=(TH1F*)hPottor101->Clone("hPottor101Clone");
01305       hPotBadtor101Clone=(TH1F*)hPotBadtor101->Clone("hPotBadtor101Clone");
01306       hPottr101dClone=(TH1F*)hPottr101d->Clone("hPottr101dClone");
01307       hPotBadtr101dClone=(TH1F*)hPotBadtr101d->Clone("hPotBadtr101dClone");
01308       hRunClone=(TH1F*)hRun->Clone("hRunClone");
01309 
01310       Double_t earliestTime=2000000000;
01311       Double_t latestTime=0;
01312       if (hNtupleLatestTime) {
01313         hNtupleLatestTimeClone=(TH1F*)hNtupleLatestTime->Clone("hNtupleLatestTimeClone");
01314         hNtupleEarliestTimeClone=(TH1F*)hNtupleEarliestTime->Clone("hNtupleEarliestTimeClone");
01315 
01316         //get the times
01317         earliestTime=hNtupleEarliestTimeClone->Integral();
01318         latestTime=hNtupleLatestTimeClone->Integral();
01319         MSG("NuDSTAna",Msg::kInfo) <<"First histo: earliestTime="<<ffmt(earliestTime)
01320                                    <<", latestTime="<<ffmt(latestTime)<<endl;
01321       }
01322       else {//only run once
01323         MSG("NuDSTAna",Msg::kInfo) <<"DoIO: hNtupleLatestTime not found"<<endl;
01324 
01325       }
01326 
01327       //after and before are the same for the first file
01328       Float_t potBefore=hPottortgtClone->GetMean()*
01329         hPottortgtClone->GetEntries();
01330       Float_t potAfter=hPottortgtClone->GetMean()*
01331         hPottortgtClone->GetEntries();
01332       Float_t runBefore=hRunClone->GetEntries();
01333       Float_t runAfter=hRunClone->GetEntries();
01334       MSG("NuDSTAna",Msg::kInfo) <<"First histo: potBefore="<<potBefore*1e12
01335                                  <<", potAfter="<<potAfter*1e12<<endl;
01336       MSG("NuDSTAna",Msg::kInfo) <<"First histo: runBefore="<<runBefore
01337                                  <<", runAfter="<<runAfter<<endl;
01338 
01339 
01340       // check that F/N histos exist
01341       if (!hRecoVsTrueEnergy_ND) {
01342         MSG("NuDSTAna",Msg::kInfo) << "F/N Histos not gettting cloned" << endl;
01343       } else {
01344         MSG("NuDSTAna",Msg::kInfo) << "F/N Histos gettting cloned" << endl;
01345         hRecoVsTrueEnergyUnnormNQ_ND = 
01346           (TH2D*) hRecoVsTrueEnergy_ND->Clone("RecoVsTrueEnergyUnnormNQ_ND");
01347         hRecoVsTrueEnergyUnnormNQ_FD = 
01348           (TH2D*) hRecoVsTrueEnergy_FD->Clone("RecoVsTrueEnergyUnnormNQ_FD");
01349 
01350         hRecoVsTrueEnergyUnnormPQ_ND = 
01351           (TH2D*) hRecoVsTrueEnergyPQ_ND->Clone("RecoVsTrueEnergyUnnormPQ_ND");
01352         hRecoVsTrueEnergyUnnormPQ_FD = 
01353           (TH2D*) hRecoVsTrueEnergyPQ_FD->Clone("RecoVsTrueEnergyUnnormPQ_FD");
01354 
01355         hRecoVsTrueEnergyUnnormAll_ND = 
01356           (TH2D*) hRecoVsTrueEnergyAll_ND->Clone("RecoVsTrueEnergyUnnormAll_ND");
01357         hRecoVsTrueEnergyUnnormAll_FD = 
01358           (TH2D*) hRecoVsTrueEnergyAll_FD->Clone("RecoVsTrueEnergyUnnormAll_FD");
01359 
01360 
01361       }
01362 
01363       //check that MM histos exist
01364       if (!hRecoVsTrueEnergyPQ_FD) {
01365         MSG("NuDSTAna",Msg::kInfo) << "MM Histos not gettting cloned" << endl;
01366       } else {
01367         MSG("NuDSTAna",Msg::kInfo) << "Cloning MM histos" << endl;
01368         //clone the MM histograms (numu CC):
01369         hRecoVsTrueEnergy_NDClone = (TH2D*) hRecoVsTrueEnergy_ND->Clone("hRecoVsTrueEnergy_NDClone");
01370         hRecoVsTrueEnergy_FDClone = (TH2D*) hRecoVsTrueEnergy_FD->Clone("hRecoVsTrueEnergy_FDClone");
01371         hEfficiency_NDClone = (TH1D*) hEfficiency_ND->Clone("hEfficiency_NDClone");
01372         hEfficiency_FDClone = (TH1D*) hEfficiency_FD->Clone("hEfficiency_FDClone");
01373         hPurity_NDClone = (TH1D*) hPurity_ND->Clone("hPurity_NDClone");
01374         hPurity_FDClone = (TH1D*) hPurity_FD->Clone("hPurity_FDClone");
01375         hRecoEnergyAllEvents_NDClone = (TH1D*) hRecoEnergyAllEvents_ND->Clone("hRecoEnergyAllEvents_NDClone");
01376         hRecoEnergyCCOnlyEvents_NDClone = (TH1D*) hRecoEnergyCCOnlyEvents_ND->Clone("hRecoEnergyCCOnlyEvents_NDClone");
01377         hTrueEnergyCCOnlyEvents_NDClone = (TH1D*) hTrueEnergyCCOnlyEvents_ND->Clone("hTrueEnergyCCOnlyEvents_NDClone");
01378 
01379         if (hTrueEnergyTrueCCFidEvents_ND){
01380           hTrueEnergyTrueCCFidEvents_NDClone =
01381             (TH1D*) hTrueEnergyTrueCCFidEvents_ND->
01382             Clone("hTrueEnergyTrueCCFidEvents_NDClone");
01383         }
01384 
01385         if (hTrueEnergyTrueCCFidEvents_FD){
01386           hTrueEnergyTrueCCFidEvents_FDClone = (TH1D*) hTrueEnergyTrueCCFidEvents_FD->Clone("hTrueEnergyTrueCCFidEvents_FDClone");
01387         }
01388 
01389         hTrueEnergyCCOnlyEvents_FDClone = (TH1D*) hTrueEnergyCCOnlyEvents_FD->Clone("hTrueEnergyCCOnlyEvents_FDClone");
01390         hRecoEnergyCCOnlyEvents_FDClone = (TH1D*) hRecoEnergyCCOnlyEvents_FD->Clone("hRecoEnergyCCOnlyEvents_FDClone");
01391         hRecoEnergyAllEvents_FDClone = (TH1D*) hRecoEnergyAllEvents_FD->Clone("hRecoEnergyAllEvents_FDClone");
01392         hRecoEnergy_NDClone = (TH1D*) hRecoEnergy_ND->Clone("hRecoEnergy_NDClone");
01393         hRecoEnergy_FDClone = (TH1D*) hRecoEnergy_FD->Clone("hRecoEnergy_FDClone");
01394         if (hRecoEnergy_ND_NC){
01395           hRecoEnergy_ND_NCClone = (TH1D*) hRecoEnergy_ND_NC->Clone("hRecoEnergy_ND_NCClone");
01396         }
01397         if (hRecoEnergy_FD_NC){
01398           hRecoEnergy_FD_NCClone = (TH1D*) hRecoEnergy_FD_NC->Clone("hRecoEnergy_FD_NCClone");
01399         }
01400         if (hRecoVsTrueEnergy_ND_NC){
01401           hRecoVsTrueEnergy_ND_NCClone= (TH2D*) hRecoVsTrueEnergy_ND_NC->Clone("hRecoVsTrueEnergy_ND_NCClone");
01402         }
01403         if (hRecoVsTrueEnergy_FD_NC){
01404           hRecoVsTrueEnergy_FD_NCClone= (TH2D*) hRecoVsTrueEnergy_FD_NC->Clone("hRecoVsTrueEnergy_FD_NCClone");
01405         }
01406 
01407         for(int truth = 0; truth < ENCTruth::kNumTruths; ++truth){
01408           for(int det = 0; det <= 1; ++det){
01409             const TString detstr = det ? "FD" : "ND";
01410             if (RecoVsTrueEnergy_NC_truly[truth][det]){
01411               hRecoVsTrueEnergy_NCClone_truly[truth][det] = (TH2D*)RecoVsTrueEnergy_NC_truly[truth][det]->Clone("RecoVsTrueEnergy_truly"+ENCTruth::truthNames[truth]+"_"+detstr+"_NC");
01412             }
01413           }
01414         }
01415 
01416         if (hCCContamination_FD){
01417           hCCContamination_FDClone = (TH1D*) hCCContamination_FD->Clone("hCCContamination_FDClone");
01418           if (hCCContaminationRecoVsTrue_FD){
01419             hCCContaminationRecoVsTrue_FDClone = (TH2D*) hCCContaminationRecoVsTrue_FD->Clone("hCCContaminationRecoVsTrue_FDClone");
01420           }
01421           hNCContamination_FDClone = (TH1D*) hNCContamination_FD->Clone("hNCContamination_FDClone");
01422         }
01423 
01424         if (hCCContamination_ND){
01425           hCCContamination_NDClone = (TH1D*) hCCContamination_ND->Clone("hCCContamination_NDClone");
01426         }
01427         if (hNCContamination_ND){
01428           hNCContamination_NDClone = (TH1D*) hNCContamination_ND->Clone("hNCContamination_NDClone");
01429         }
01430 
01431         //clone the MM histograms (numubar CC):
01432         hRecoVsTrueEnergyPQ_NDClone = (TH2D*) hRecoVsTrueEnergyPQ_ND->Clone("hRecoVsTrueEnergyPQ_NDClone");
01433         hRecoVsTrueEnergyPQ_FDClone = (TH2D*) hRecoVsTrueEnergyPQ_FD->Clone("hRecoVsTrueEnergyPQ_FDClone");
01434         hEfficiencyPQ_NDClone = (TH1D*) hEfficiencyPQ_ND->Clone("hEfficiencyPQ_NDClone");
01435         hEfficiencyPQ_FDClone = (TH1D*) hEfficiencyPQ_FD->Clone("hEfficiencyPQ_FDClone");
01436         hPurityPQ_NDClone = (TH1D*) hPurityPQ_ND->Clone("hPurityPQ_NDClone");
01437         hPurityPQ_FDClone = (TH1D*) hPurityPQ_FD->Clone("hPurityPQ_FDClone");
01438         hRecoEnergyAllEventsPQ_NDClone = (TH1D*) hRecoEnergyAllEventsPQ_ND->Clone("hRecoEnergyAllEventsPQ_NDClone");
01439         hRecoEnergyCCOnlyEventsPQ_NDClone = (TH1D*) hRecoEnergyCCOnlyEventsPQ_ND->Clone("hRecoEnergyCCOnlyEventsPQ_NDClone");
01440         hTrueEnergyCCOnlyEventsPQ_NDClone = (TH1D*) hTrueEnergyCCOnlyEventsPQ_ND->Clone("hTrueEnergyCCOnlyEventsPQ_NDClone");
01441 
01442         if (hTrueEnergyTrueCCFidEventsPQ_ND){
01443           hTrueEnergyTrueCCFidEventsPQ_NDClone = (TH1D*) hTrueEnergyTrueCCFidEventsPQ_ND->Clone("hTrueEnergyTrueCCFidEventsPQ_NDClone");
01444         }
01445         if (hTrueEnergyTrueCCFidEventsPQ_FD){
01446           hTrueEnergyTrueCCFidEventsPQ_FDClone = (TH1D*) hTrueEnergyTrueCCFidEventsPQ_FD->Clone("hTrueEnergyTrueCCFidEventsPQ_FDClone");
01447         }
01448 
01449         hTrueEnergyCCOnlyEventsPQ_FDClone = (TH1D*) hTrueEnergyCCOnlyEventsPQ_FD->Clone("hTrueEnergyCCOnlyEventsPQ_FDClone");
01450         hRecoEnergyCCOnlyEventsPQ_FDClone = (TH1D*) hRecoEnergyCCOnlyEventsPQ_FD->Clone("hRecoEnergyCCOnlyEventsPQ_FDClone");
01451         hRecoEnergyAllEventsPQ_FDClone = (TH1D*) hRecoEnergyAllEventsPQ_FD->Clone("hRecoEnergyAllEventsPQ_FDClone");
01452         hRecoEnergyPQ_NDClone = (TH1D*) hRecoEnergyPQ_ND->Clone("hRecoEnergyPQ_NDClone");
01453         hRecoEnergyPQ_FDClone = (TH1D*) hRecoEnergyPQ_FD->Clone("hRecoEnergyPQ_FDClone");
01454         if (hCCContaminationPQ_FD){
01455           hCCContaminationPQ_FDClone =
01456             (TH1D*) hCCContaminationPQ_FD->        Clone("hCCContaminationPQ_FDClone");
01457           if (hCCContaminationRecoVsTruePQ_FD){
01458             hCCContaminationRecoVsTruePQ_FDClone =
01459 
01460               (TH2D*) hCCContaminationRecoVsTruePQ_FD->Clone("hCCContaminationRecoVsTruePQ_FDClone");
01461           }
01462           hNCContaminationPQ_FDClone =(TH1D*) hNCContaminationPQ_FD->Clone("hNCContaminationPQ_FDClone");
01463         }
01464         if (hCCContaminationPQ_ND){
01465           hCCContaminationPQ_NDClone = (TH1D*) hCCContaminationPQ_ND->Clone("hCCContaminationPQ_NDClone");
01466         }
01467         if (hNCContaminationPQ_ND){
01468           hNCContaminationPQ_NDClone = (TH1D*) hNCContaminationPQ_ND->Clone("hNCContaminationPQ_NDClone");
01469         }
01470         //clone the MM histograms (Decay Pipe)
01471         if (hTrueEnergyAllEventsPQ_ND){
01472           hTrueEnergyAllEventsPQ_NDClone = (TH1D*) hTrueEnergyAllEventsPQ_ND->Clone("hTrueEnergyAllEventsPQ_NDClone");
01473         }
01474         if (hTrueEnergyAllEventsPQ_FD){
01475           hTrueEnergyAllEventsPQ_FDClone = (TH1D*) hTrueEnergyAllEventsPQ_FD->Clone("hTrueEnergyAllEventsPQ_FDClone");
01476         }
01477         if (hTrueEnergyDecayPipePQ_ND){
01478           hTrueEnergyDecayPipePQ_NDClone = (TH1D*) hTrueEnergyDecayPipePQ_ND->Clone("hTrueEnergyDecayPipePQ_NDClone");
01479         }
01480         if (hTrueEnergyDecayPipePQ_FD){
01481           hTrueEnergyDecayPipePQ_FDClone = (TH1D*) hTrueEnergyDecayPipePQ_FD->Clone("hTrueEnergyDecayPipePQ_FDClone");
01482         }
01483         //clone the MM histograms (numu + numubar CC):
01484         hRecoVsTrueEnergyAll_NDClone = (TH2D*) hRecoVsTrueEnergyAll_ND->Clone("hRecoVsTrueEnergyAll_NDClone");
01485         hRecoVsTrueEnergyAll_FDClone = (TH2D*) hRecoVsTrueEnergyAll_FD->Clone("hRecoVsTrueEnergyAll_FDClone");
01486         hEfficiencyAll_NDClone = (TH1D*) hEfficiencyAll_ND->Clone("hEfficiencyAll_NDClone");
01487         hEfficiencyAll_FDClone = (TH1D*) hEfficiencyAll_FD->Clone("hEfficiencyAll_FDClone");
01488         hPurityAll_NDClone = (TH1D*) hPurityAll_ND->Clone("hPurityAll_NDClone");
01489         hPurityAll_FDClone = (TH1D*) hPurityAll_FD->Clone("hPurityAll_FDClone");
01490         hRecoEnergyAllEventsAll_NDClone = (TH1D*) hRecoEnergyAllEventsAll_ND->Clone("hRecoEnergyAllEventsAll_NDClone");
01491         hRecoEnergyCCOnlyEventsAll_NDClone = (TH1D*) hRecoEnergyCCOnlyEventsAll_ND->Clone("hRecoEnergyCCOnlyEventsAll_NDClone");
01492         hTrueEnergyCCOnlyEventsAll_NDClone = (TH1D*) hTrueEnergyCCOnlyEventsAll_ND->Clone("hTrueEnergyCCOnlyEventsAll_NDClone");
01493 
01494         if (hTrueEnergyTrueCCFidEventsAll_ND){
01495           hTrueEnergyTrueCCFidEventsAll_NDClone = (TH1D*) hTrueEnergyTrueCCFidEventsAll_ND->Clone("hTrueEnergyTrueCCFidEventsAll_NDClone");
01496         }
01497         if (hTrueEnergyTrueCCFidEventsAll_FD){
01498           hTrueEnergyTrueCCFidEventsAll_FDClone = (TH1D*) hTrueEnergyTrueCCFidEventsAll_FD->Clone("hTrueEnergyTrueCCFidEventsAll_FDClone");
01499         }
01500 
01501         hTrueEnergyCCOnlyEventsAll_FDClone = (TH1D*) hTrueEnergyCCOnlyEventsAll_FD->Clone("hTrueEnergyCCOnlyEventsAll_FDClone");
01502         hRecoEnergyCCOnlyEventsAll_FDClone = (TH1D*) hRecoEnergyCCOnlyEventsAll_FD->Clone("hRecoEnergyCCOnlyEventsAll_FDClone");
01503         hRecoEnergyAllEventsAll_FDClone = (TH1D*) hRecoEnergyAllEventsAll_FD->Clone("hRecoEnergyAllEventsAll_FDClone");
01504         hRecoEnergyAll_NDClone = (TH1D*) hRecoEnergyAll_ND->Clone("hRecoEnergyAll_NDClone");
01505         hRecoEnergyAll_FDClone = (TH1D*) hRecoEnergyAll_FD->Clone("hRecoEnergyAll_FDClone");
01506         //Clone the taus:
01507         if (hEfficiencyTau_FD){
01508           hEfficiencyTau_FDClone = (TH1D*) hEfficiencyTau_FD->Clone("hEfficiencyTau_FDClone");
01509         }
01510         if (hRecoVsTrueEnergyTau_FD){
01511           hRecoVsTrueEnergyTau_FDClone = (TH2D*) hRecoVsTrueEnergyTau_FD->Clone("hRecoVsTrueEnergyTau_FDClone");
01512         }
01513         if (hTrueEnergyTrueCCFidEventsTau_FD){
01514           hTrueEnergyTrueCCFidEventsTau_FDClone = (TH1D*) hTrueEnergyTrueCCFidEventsTau_FD->Clone("hTrueEnergyTrueCCFidEventsTau_FDClone");
01515         }
01516         if (hTrueEnergyCCOnlyEventsTau_FD){
01517           hTrueEnergyCCOnlyEventsTau_FDClone = (TH1D*) hTrueEnergyCCOnlyEventsTau_FD->Clone("hTrueEnergyCCOnlyEventsTau_FDClone");
01518         }
01519         //Clone the taubars:
01520         if (hEfficiencyTauPQ_FD){
01521           hEfficiencyTauPQ_FDClone = (TH1D*) hEfficiencyTauPQ_FD->Clone("hEfficiencyTauPQ_FDClone");
01522         }
01523         if (hRecoVsTrueEnergyTauPQ_FD){
01524           hRecoVsTrueEnergyTauPQ_FDClone = (TH2D*) hRecoVsTrueEnergyTauPQ_FD->Clone("hRecoVsTrueEnergyTauPQ_FDClone");
01525         }
01526         if (hTrueEnergyTrueCCFidEventsTauPQ_FD){
01527           hTrueEnergyTrueCCFidEventsTauPQ_FDClone = (TH1D*) hTrueEnergyTrueCCFidEventsTauPQ_FD->Clone("hTrueEnergyTrueCCFidEventsTauPQ_FDClone");
01528         }
01529         if (hTrueEnergyCCOnlyEventsTauPQ_FD){
01530           hTrueEnergyCCOnlyEventsTauPQ_FDClone = (TH1D*) hTrueEnergyCCOnlyEventsTauPQ_FD->Clone("hTrueEnergyCCOnlyEventsTauPQ_FDClone");
01531         }
01532         //Clone the taus + taubars:
01533         if (hEfficiencyTauAll_FD){
01534           hEfficiencyTauAll_FDClone = (TH1D*) hEfficiencyTauAll_FD->Clone("hEfficiencyTauAll_FDClone");
01535         }
01536         if (hRecoVsTrueEnergyTauAll_FD){
01537           hRecoVsTrueEnergyTauAll_FDClone = (TH2D*) hRecoVsTrueEnergyTauAll_FD->Clone("hRecoVsTrueEnergyTauAll_FDClone");
01538         }
01539         if (hTrueEnergyTrueCCFidEventsTauAll_FD){
01540           hTrueEnergyTrueCCFidEventsTauAll_FDClone = (TH1D*) hTrueEnergyTrueCCFidEventsTauAll_FD->Clone("hTrueEnergyTrueCCFidEventsTauAll_FDClone");
01541         }
01542         if (hTrueEnergyCCOnlyEventsTauAll_FD){
01543           hTrueEnergyCCOnlyEventsTauAll_FDClone = (TH1D*) hTrueEnergyCCOnlyEventsTauAll_FD->Clone("hTrueEnergyCCOnlyEventsTauAll_FDClone");
01544         }
01545       }
01546     }
01547     else { //for second file onwards add the new histo to the clone
01548       MSG("NuDSTAna",Msg::kInfo) << "Adding up pots for later files" << endl;
01549       Float_t potBefore=hPottortgtClone->GetMean()*
01550         hPottortgtClone->GetEntries();
01551       Float_t potNew=hPottortgt->GetMean()*hPottortgt->GetEntries();
01552       Float_t runBefore=hRunClone->GetEntries();
01553 
01554       if (hNtupleLatestTime && hNtupleLatestTimeClone) {
01555         Double_t earliestTime=2000000000;
01556         Double_t latestTime=0;
01557         Double_t newEarliestTime=2000000000;
01558         Double_t newLatestTime=0;
01559         //get the times from clone
01560         earliestTime=hNtupleEarliestTimeClone->Integral();
01561         latestTime=hNtupleLatestTimeClone->Integral();
01562 
01563         //get the next set of times
01564         newEarliestTime=hNtupleEarliestTime->Integral();
01565         newLatestTime=hNtupleLatestTime->Integral();
01566 
01567         MAXMSG("NuDSTAna",Msg::kInfo,5)
01568           <<"Previous file(s): earliestTime="<<ffmt(earliestTime)
01569           <<", latestTime="<<ffmt(latestTime)<<endl
01570           <<"This file:        earliestTime="<<ffmt(newEarliestTime)
01571           <<", latestTime="<<ffmt(newLatestTime)<<endl;
01572 
01573         //work out which time is the earliest/latest
01574         if (newEarliestTime<earliestTime) {
01575           Float_t oldT=earliestTime;
01576           earliestTime=newEarliestTime;
01577           hNtupleEarliestTimeClone->Reset("ICE");
01578           hNtupleEarliestTimeClone->Fill(1,earliestTime);
01579           MSG("NuDSTAna",Msg::kInfo)
01580             <<"Using new earliestTime="<<ffmt(earliestTime)
01581             <<" (was "<<ffmt(oldT)<<")"<<endl;
01582         }
01583         if (newLatestTime>latestTime) {
01584           Float_t oldT=latestTime;
01585           latestTime=newLatestTime;
01586           hNtupleLatestTimeClone->Reset("ICE");
01587           hNtupleLatestTimeClone->Fill(1,latestTime);
01588           MSG("NuDSTAna",Msg::kInfo)
01589             <<"Using new latestTime="<<ffmt(latestTime)
01590             <<" (was "<<ffmt(oldT)<<")"<<endl;
01591         }
01592       }
01593       else {
01594         MAXMSG("NuDSTAna",Msg::kInfo,3)
01595           <<"DoIO: Next file hNtupleLatestTime not found"<<endl;
01596       }
01597 
01599       //add the histos up
01600 
01601       //don't need to do this for
01602       //hDetectorClone
01603       //hSimFlagClone
01604       //hTrigSrcClone
01605       //hSpillsPerFileClone
01606 
01607       if (hTotalPotClone) hTotalPotClone->Add(hTotalPot);
01608 
01609       hPottortgtClone->Add(hPottortgt);
01610       hPotBadtortgtClone->Add(hPotBadtortgt);
01611       hPottrtgtdClone->Add(hPottrtgtd);
01612       hPotBadtrtgtdClone->Add(hPotBadtrtgtd);
01613       hPottor101Clone->Add(hPottor101);
01614       hPotBadtor101Clone->Add(hPotBadtor101);
01615       hPottr101dClone->Add(hPottr101d);
01616       hPotBadtr101dClone->Add(hPotBadtr101d);
01617       hRunClone->Add(hRun);
01618 
01619       Float_t potAfter=hPottortgtClone->GetMean()*
01620         hPottortgtClone->GetEntries();
01621       Float_t runAfter=hRunClone->GetEntries();
01622 
01623       MSG("NuDSTAna",Msg::kInfo)
01624         <<"Adding histos: potBefore="<<potBefore*1e12
01625         <<", potAfter="<<potAfter*1e12
01626         <<", potNew="<<potNew*1e12<<endl;
01627       MSG("NuDSTAna",Msg::kInfo)
01628         <<"Adding histos: runsBefore="<<runBefore
01629         <<", runsAfter="<<runAfter<<endl;
01630 
01631       //Add the MM histograms up (if they exist) (numu CC):
01632       if (hRecoVsTrueEnergyPQ_FDClone) {
01633         MSG("NuDSTAna",Msg::kInfo) << "Adding to MM histos" << endl;
01634 
01635         hRecoVsTrueEnergyUnnormNQ_ND->Add(hRecoVsTrueEnergy_ND);
01636         hRecoVsTrueEnergyUnnormNQ_FD->Add(hRecoVsTrueEnergy_FD);
01637         hRecoVsTrueEnergyUnnormPQ_ND->Add(hRecoVsTrueEnergyPQ_ND);
01638         hRecoVsTrueEnergyUnnormPQ_FD->Add(hRecoVsTrueEnergyPQ_FD);
01639         hRecoVsTrueEnergyUnnormAll_ND->Add(hRecoVsTrueEnergyAll_ND);
01640         hRecoVsTrueEnergyUnnormAll_FD->Add(hRecoVsTrueEnergyAll_FD);
01641 
01642         hRecoVsTrueEnergy_NDClone->Add(hRecoVsTrueEnergy_ND);
01643         hRecoVsTrueEnergy_FDClone->Add(hRecoVsTrueEnergy_FD);
01644         hEfficiency_NDClone->Add(hEfficiency_ND);
01645         hEfficiency_FDClone->Add(hEfficiency_FD);
01646         hPurity_NDClone->Add(hPurity_ND);
01647         hPurity_FDClone->Add(hPurity_FD);
01648         hRecoEnergyAllEvents_NDClone->Add(hRecoEnergyAllEvents_ND);
01649         hRecoEnergyCCOnlyEvents_NDClone->Add(hRecoEnergyCCOnlyEvents_ND);
01650         hTrueEnergyCCOnlyEvents_NDClone->Add(hTrueEnergyCCOnlyEvents_ND);
01651 
01652         if (hTrueEnergyTrueCCFidEvents_NDClone){
01653           hTrueEnergyTrueCCFidEvents_NDClone->Add(hTrueEnergyTrueCCFidEvents_ND);
01654         }
01655         if (hTrueEnergyTrueCCFidEvents_FDClone){
01656           hTrueEnergyTrueCCFidEvents_FDClone->Add(hTrueEnergyTrueCCFidEvents_FD);
01657         }
01658 
01659         hTrueEnergyCCOnlyEvents_FDClone->Add(hTrueEnergyCCOnlyEvents_FD);
01660         hRecoEnergyCCOnlyEvents_FDClone->Add(hRecoEnergyCCOnlyEvents_FD);
01661         hRecoEnergyAllEvents_FDClone->Add(hRecoEnergyAllEvents_FD);
01662         hRecoEnergy_NDClone->Add(hRecoEnergy_ND);
01663         hRecoEnergy_FDClone->Add(hRecoEnergy_FD);
01664         if (hRecoEnergy_ND_NCClone){
01665           hRecoEnergy_ND_NCClone->Add(hRecoEnergy_ND_NC);
01666         }
01667         if (hRecoEnergy_FD_NCClone){
01668           hRecoEnergy_FD_NCClone->Add(hRecoEnergy_FD_NC);
01669         }
01670         if (hRecoVsTrueEnergy_ND_NCClone){
01671           hRecoVsTrueEnergy_ND_NCClone->Add(hRecoVsTrueEnergy_ND_NC);
01672         }
01673         if (hRecoVsTrueEnergy_ND_NCClone){
01674           hRecoVsTrueEnergy_FD_NCClone->Add(hRecoVsTrueEnergy_FD_NC);
01675         }
01676 
01677         for(int truth = 0; truth < ENCTruth::kNumTruths; ++truth){
01678           for(int det = 0; det <= 1; ++det){
01679             if (hRecoVsTrueEnergy_NCClone_truly[truth][det]){
01680               hRecoVsTrueEnergy_NCClone_truly[truth][det]->
01681                 Add(RecoVsTrueEnergy_NC_truly[truth][det]);
01682             }
01683           }
01684         }
01685 
01686         if (hCCContamination_FDClone){
01687           hCCContamination_FDClone->Add(hCCContamination_FD);
01688           if (hCCContaminationRecoVsTrue_FDClone){
01689             hCCContaminationRecoVsTrue_FDClone->Add(hCCContaminationRecoVsTrue_FD);
01690           }
01691           hNCContamination_FDClone->Add(hNCContamination_FD);
01692           if (hCCContamination_NDClone){
01693             hCCContamination_NDClone->Add(hCCContamination_ND);
01694           }
01695           if (hNCContamination_NDClone){
01696             hNCContamination_NDClone->Add(hNCContamination_ND);
01697           }
01698         }
01699         //Add the MM histograms up (Decay Pipe):
01700         if(hTrueEnergyAllEventsPQ_NDClone) {
01701           hTrueEnergyAllEventsPQ_NDClone->Add(hTrueEnergyAllEventsPQ_ND);
01702         }
01703         if(hTrueEnergyAllEventsPQ_FDClone) {
01704           hTrueEnergyAllEventsPQ_FDClone->Add(hTrueEnergyAllEventsPQ_FD);
01705         }
01706         if(hTrueEnergyDecayPipePQ_NDClone) {
01707           hTrueEnergyDecayPipePQ_NDClone->Add(hTrueEnergyDecayPipePQ_ND);
01708         }
01709         if(hTrueEnergyDecayPipePQ_FDClone) {
01710           hTrueEnergyDecayPipePQ_FDClone->Add(hTrueEnergyDecayPipePQ_FD);
01711         }
01712         //Add the MM histograms up (numubar CC):
01713         hRecoVsTrueEnergyPQ_NDClone->Add(hRecoVsTrueEnergyPQ_ND);
01714         hRecoVsTrueEnergyPQ_FDClone->Add(hRecoVsTrueEnergyPQ_FD);
01715         hEfficiencyPQ_NDClone->Add(hEfficiencyPQ_ND);
01716         hEfficiencyPQ_FDClone->Add(hEfficiencyPQ_FD);
01717         hPurityPQ_NDClone->Add(hPurityPQ_ND);
01718         hPurityPQ_FDClone->Add(hPurityPQ_FD);
01719         hRecoEnergyAllEventsPQ_NDClone->Add(hRecoEnergyAllEventsPQ_ND);
01720         hRecoEnergyCCOnlyEventsPQ_NDClone->Add(hRecoEnergyCCOnlyEventsPQ_ND);
01721         hTrueEnergyCCOnlyEventsPQ_NDClone->Add(hTrueEnergyCCOnlyEventsPQ_ND);
01722 
01723         if (hTrueEnergyTrueCCFidEventsPQ_NDClone){
01724           hTrueEnergyTrueCCFidEventsPQ_NDClone->Add(hTrueEnergyTrueCCFidEventsPQ_ND);
01725         }
01726         if (hTrueEnergyTrueCCFidEventsPQ_FDClone){
01727           hTrueEnergyTrueCCFidEventsPQ_FDClone->Add(hTrueEnergyTrueCCFidEventsPQ_FD);
01728         }
01729 
01730         hTrueEnergyCCOnlyEventsPQ_FDClone->Add(hTrueEnergyCCOnlyEventsPQ_FD);
01731         hRecoEnergyCCOnlyEventsPQ_FDClone->Add(hRecoEnergyCCOnlyEventsPQ_FD);
01732         hRecoEnergyAllEventsPQ_FDClone->Add(hRecoEnergyAllEventsPQ_FD);
01733         hRecoEnergyPQ_NDClone->Add(hRecoEnergyPQ_ND);
01734         hRecoEnergyPQ_FDClone->Add(hRecoEnergyPQ_FD);
01735         if (hCCContaminationPQ_FDClone){
01736           hCCContaminationPQ_FDClone->Add(hCCContaminationPQ_FD);
01737           if (hCCContaminationRecoVsTruePQ_FDClone){
01738             hCCContaminationRecoVsTruePQ_FDClone->Add(hCCContaminationRecoVsTruePQ_FD);
01739           }
01740           hNCContaminationPQ_FDClone->Add(hNCContaminationPQ_FD);
01741           if (hCCContaminationPQ_NDClone){
01742             hCCContaminationPQ_NDClone->
01743               Add(hCCContaminationPQ_ND);
01744           }
01745           if (hNCContaminationPQ_NDClone){
01746             hNCContaminationPQ_NDClone->
01747               Add(hNCContaminationPQ_ND);
01748           }
01749         }
01750         //Add the MM histograms up (numu + numubar CC):
01751         hRecoVsTrueEnergyAll_NDClone->Add(hRecoVsTrueEnergyAll_ND);
01752         hRecoVsTrueEnergyAll_FDClone->Add(hRecoVsTrueEnergyAll_FD);
01753         hEfficiencyAll_NDClone->Add(hEfficiencyAll_ND);
01754         hEfficiencyAll_FDClone->Add(hEfficiencyAll_FD);
01755         hPurityAll_NDClone->Add(hPurityAll_ND);
01756         hPurityAll_FDClone->Add(hPurityAll_FD);
01757         hRecoEnergyAllEventsAll_NDClone->Add(hRecoEnergyAllEventsAll_ND);
01758         hRecoEnergyCCOnlyEventsAll_NDClone->Add(hRecoEnergyCCOnlyEventsAll_ND);
01759         hTrueEnergyCCOnlyEventsAll_NDClone->Add(hTrueEnergyCCOnlyEventsAll_ND);
01760 
01761         if (hTrueEnergyTrueCCFidEventsAll_NDClone){
01762           hTrueEnergyTrueCCFidEventsAll_NDClone->Add(hTrueEnergyTrueCCFidEventsAll_ND);
01763         }
01764         if (hTrueEnergyTrueCCFidEventsAll_FDClone){
01765           hTrueEnergyTrueCCFidEventsAll_FDClone->Add(hTrueEnergyTrueCCFidEventsAll_FD);
01766         }
01767 
01768         hTrueEnergyCCOnlyEventsAll_FDClone->Add(hTrueEnergyCCOnlyEventsAll_FD);
01769         hRecoEnergyCCOnlyEventsAll_FDClone->Add(hRecoEnergyCCOnlyEventsAll_FD);
01770         hRecoEnergyAllEventsAll_FDClone->Add(hRecoEnergyAllEventsAll_FD);
01771         hRecoEnergyAll_NDClone->Add(hRecoEnergyAll_ND);
01772         hRecoEnergyAll_FDClone->Add(hRecoEnergyAll_FD);
01773         //Add the MM histograms up (nutau CC):
01774         if (hRecoVsTrueEnergyTau_FDClone){
01775           hRecoVsTrueEnergyTau_FDClone->Add(hRecoVsTrueEnergyTau_FD);
01776         }
01777         if (hEfficiencyTau_FDClone){
01778           hEfficiencyTau_FDClone->Add(hEfficiencyTau_FD);
01779         }
01780         if (hTrueEnergyTrueCCFidEventsTau_FDClone){
01781           hTrueEnergyTrueCCFidEventsTau_FDClone->Add(hTrueEnergyTrueCCFidEventsTau_FD);
01782         }
01783         if (hTrueEnergyCCOnlyEventsTau_FDClone){
01784           hTrueEnergyCCOnlyEventsTau_FDClone->Add(hTrueEnergyCCOnlyEventsTau_FD);
01785         }
01786         //Add the MM histograms up (nutaubar CC):
01787         if (hRecoVsTrueEnergyTauPQ_FDClone){
01788           hRecoVsTrueEnergyTauPQ_FDClone->Add(hRecoVsTrueEnergyTauPQ_FD);
01789         }
01790         if (hEfficiencyTauPQ_FDClone){
01791           hEfficiencyTauPQ_FDClone->Add(hEfficiencyTauPQ_FD);
01792         }
01793         if (hTrueEnergyTrueCCFidEventsTauPQ_FDClone){
01794           hTrueEnergyTrueCCFidEventsTauPQ_FDClone->Add(hTrueEnergyTrueCCFidEventsTauPQ_FD);
01795         }
01796         if (hTrueEnergyCCOnlyEventsTauPQ_FDClone){
01797           hTrueEnergyCCOnlyEventsTauPQ_FDClone->Add(hTrueEnergyCCOnlyEventsTauPQ_FD);
01798         }
01799         //Add the MM histograms up (nutau + nutaubar CC):
01800         if (hRecoVsTrueEnergyTauAll_FDClone){
01801           hRecoVsTrueEnergyTauAll_FDClone->Add(hRecoVsTrueEnergyTauAll_FD);
01802         }
01803         if (hEfficiencyTauAll_FDClone){
01804           hEfficiencyTauAll_FDClone->Add(hEfficiencyTauAll_FD);
01805         }
01806         if (hTrueEnergyTrueCCFidEventsTauAll_FDClone){
01807           hTrueEnergyTrueCCFidEventsTauAll_FDClone->Add(hTrueEnergyTrueCCFidEventsTauAll_FD);
01808         }
01809         if (hTrueEnergyCCOnlyEventsTauAll_FDClone){
01810           hTrueEnergyCCOnlyEventsTauAll_FDClone->Add(hTrueEnergyCCOnlyEventsTauAll_FD);
01811         }
01812       }
01813     }
01814   }
01815   //Normalise the ND reco v. true CC matrix (if exists)
01816   if (hRecoVsTrueEnergyPQ_FDClone) {
01817     MSG("NuDSTAna",Msg::kInfo) << "Doing MM Normalization" << endl;
01818     for(int i=1;i<=hRecoVsTrueEnergy_NDClone->GetNbinsX();i++){
01819       //loop over true bins
01820       for(int j=1;j<=hRecoVsTrueEnergy_NDClone->GetNbinsY()+1;j++){
01821         //loop over reco bins
01822         if(hRecoEnergyCCOnlyEvents_NDClone->GetBinContent(j)>0 &&
01823            hRecoVsTrueEnergy_NDClone->GetBinContent(i,j)>0) {
01824           Float_t error=(hRecoVsTrueEnergy_NDClone->GetBinError(i,j)/
01825                          hRecoVsTrueEnergy_NDClone->GetBinContent(i,j));
01826 
01827           hRecoVsTrueEnergy_NDClone->SetBinContent
01828             (i,j,hRecoVsTrueEnergy_NDClone->GetBinContent(i,j)/
01829              hRecoEnergyCCOnlyEvents_NDClone->GetBinContent(j));
01830 
01831           hRecoVsTrueEnergy_NDClone->SetBinError
01832             (i,j,error*hRecoVsTrueEnergy_NDClone->GetBinContent(i,j));
01833         }
01834         else {
01835           hRecoVsTrueEnergy_NDClone->SetBinContent(i,j,0);
01836           hRecoVsTrueEnergy_NDClone->SetBinError(i,j,0);
01837         }
01838       }
01839     }
01840     //(numubar CC):
01841     for(int i=1;i<=hRecoVsTrueEnergyPQ_NDClone->GetNbinsX();i++){
01842       //loop over true bins
01843       for(int j=1;j<=hRecoVsTrueEnergyPQ_NDClone->GetNbinsY()+1;j++){
01844         //loop over reco bins
01845         if(hRecoEnergyCCOnlyEventsPQ_NDClone->GetBinContent(j)>0 &&
01846            hRecoVsTrueEnergyPQ_NDClone->GetBinContent(i,j)>0) {
01847           Float_t error=(hRecoVsTrueEnergyPQ_NDClone->GetBinError(i,j)/
01848                          hRecoVsTrueEnergyPQ_NDClone->GetBinContent(i,j));
01849 
01850           hRecoVsTrueEnergyPQ_NDClone->SetBinContent
01851             (i,j,hRecoVsTrueEnergyPQ_NDClone->GetBinContent(i,j)/
01852              hRecoEnergyCCOnlyEventsPQ_NDClone->GetBinContent(j));
01853 
01854           hRecoVsTrueEnergyPQ_NDClone->SetBinError
01855             (i,j,error*hRecoVsTrueEnergyPQ_NDClone->GetBinContent(i,j));
01856         }
01857         else {
01858           hRecoVsTrueEnergyPQ_NDClone->SetBinContent(i,j,0);
01859           hRecoVsTrueEnergyPQ_NDClone->SetBinError(i,j,0);
01860         }
01861       }
01862     }
01863     //(numu + numubar CC):
01864     for(int i=1;i<=hRecoVsTrueEnergyAll_NDClone->GetNbinsX();i++){
01865       //loop over true bins
01866       for(int j=1;j<=hRecoVsTrueEnergyAll_NDClone->GetNbinsY()+1;j++){
01867         //loop over reco bins
01868         if(hRecoEnergyCCOnlyEventsAll_NDClone->GetBinContent(j)>0 &&
01869            hRecoVsTrueEnergyAll_NDClone->GetBinContent(i,j)>0) {
01870           Float_t error=(hRecoVsTrueEnergyAll_NDClone->GetBinError(i,j)/
01871                          hRecoVsTrueEnergyAll_NDClone->GetBinContent(i,j));
01872 
01873           hRecoVsTrueEnergyAll_NDClone->SetBinContent
01874             (i,j,hRecoVsTrueEnergyAll_NDClone->GetBinContent(i,j)/
01875              hRecoEnergyCCOnlyEventsAll_NDClone->GetBinContent(j));
01876 
01877           hRecoVsTrueEnergyAll_NDClone->SetBinError
01878             (i,j,error*hRecoVsTrueEnergyAll_NDClone->GetBinContent(i,j));
01879         }
01880         else {
01881           hRecoVsTrueEnergyAll_NDClone->SetBinContent(i,j,0);
01882           hRecoVsTrueEnergyAll_NDClone->SetBinError(i,j,0);
01883         }
01884       }
01885     }
01886 
01887     //Normalise the FD reco v. true CC matrix (numu CC):
01888     for(int i=1;i<=hRecoVsTrueEnergy_FDClone->GetNbinsX();i++){
01889       //loop over true bins
01890       for(int j=1;j<=hRecoVsTrueEnergy_FDClone->GetNbinsY()+1;j++){
01891         //loop over reco bins
01892         if( hTrueEnergyCCOnlyEvents_FDClone->GetBinContent(i)>0 &&
01893             hRecoVsTrueEnergy_FDClone->GetBinContent(i,j)>0 ) {
01894           Float_t error=(hRecoVsTrueEnergy_FDClone->GetBinError(i,j)/
01895                          hRecoVsTrueEnergy_FDClone->GetBinContent(i,j));
01896 
01897           hRecoVsTrueEnergy_FDClone->SetBinContent
01898             (i,j,hRecoVsTrueEnergy_FDClone->GetBinContent(i,j)/
01899              hTrueEnergyCCOnlyEvents_FDClone->GetBinContent(i));
01900 
01901           hRecoVsTrueEnergy_FDClone->SetBinError
01902             (i,j,error*hRecoVsTrueEnergy_FDClone->GetBinContent(i,j));
01903         }
01904         else {
01905           hRecoVsTrueEnergy_FDClone->SetBinContent(i,j,0);
01906           hRecoVsTrueEnergy_FDClone->SetBinError(i,j,0);
01907         }
01908       }
01909     }
01910 
01911     // The NC histograms are normalized (to 1 POT) in CombineMMHelpers.C
01912 
01913     //Normalise the FD reco v. true CC matrix (numubar CC):
01914     for(int i=1;i<=hRecoVsTrueEnergyPQ_FDClone->GetNbinsX();i++){
01915       //loop over true bins
01916       for(int j=1;j<=hRecoVsTrueEnergyPQ_FDClone->GetNbinsY()+1;j++){
01917         //loop over reco bins
01918         if( hTrueEnergyCCOnlyEventsPQ_FDClone->GetBinContent(i)>0 &&
01919             hRecoVsTrueEnergyPQ_FDClone->GetBinContent(i,j)>0 ) {
01920           Float_t error=(hRecoVsTrueEnergyPQ_FDClone->GetBinError(i,j)/
01921                          hRecoVsTrueEnergyPQ_FDClone->GetBinContent(i,j));
01922 
01923           hRecoVsTrueEnergyPQ_FDClone->SetBinContent
01924             (i,j,hRecoVsTrueEnergyPQ_FDClone->GetBinContent(i,j)/
01925              hTrueEnergyCCOnlyEventsPQ_FDClone->GetBinContent(i));
01926 
01927           hRecoVsTrueEnergyPQ_FDClone->SetBinError
01928             (i,j,error*hRecoVsTrueEnergyPQ_FDClone->GetBinContent(i,j));
01929         }
01930         else {
01931           hRecoVsTrueEnergyPQ_FDClone->SetBinContent(i,j,0);
01932           hRecoVsTrueEnergyPQ_FDClone->SetBinError(i,j,0);
01933         }
01934       }
01935     }
01936     //Normalise the FD reco v. true CC matrix (numu + numubar CC):
01937     for(int i=1;i<=hRecoVsTrueEnergyAll_FDClone->GetNbinsX();i++){
01938       //loop over true bins
01939       for(int j=1;j<=hRecoVsTrueEnergyAll_FDClone->GetNbinsY()+1;j++){
01940         //loop over reco bins
01941         if( hTrueEnergyCCOnlyEventsAll_FDClone->GetBinContent(i)>0 &&
01942             hRecoVsTrueEnergyAll_FDClone->GetBinContent(i,j)>0 ) {
01943           Float_t error=(hRecoVsTrueEnergyAll_FDClone->GetBinError(i,j)/
01944                          hRecoVsTrueEnergyAll_FDClone->GetBinContent(i,j));
01945 
01946           hRecoVsTrueEnergyAll_FDClone->SetBinContent
01947             (i,j,hRecoVsTrueEnergyAll_FDClone->GetBinContent(i,j)/
01948              hTrueEnergyCCOnlyEventsAll_FDClone->GetBinContent(i));
01949 
01950           hRecoVsTrueEnergyAll_FDClone->SetBinError
01951             (i,j,error*hRecoVsTrueEnergyAll_FDClone->GetBinContent(i,j));
01952         }
01953         else {
01954           hRecoVsTrueEnergyAll_FDClone->SetBinContent(i,j,0);
01955           hRecoVsTrueEnergyAll_FDClone->SetBinError(i,j,0);
01956         }
01957       }
01958     }
01959 
01960     //Normalise the FD reco v. true CC matrix (nutau CC):
01961     for(int i=1;i<=hRecoVsTrueEnergyTau_FDClone->GetNbinsX();i++){
01962       //loop over true bins
01963       for(int j=1;j<=hRecoVsTrueEnergyTau_FDClone->GetNbinsY()+1;j++){
01964         //loop over reco bins
01965         if( hTrueEnergyCCOnlyEventsTau_FDClone->GetBinContent(i)>0 &&
01966             hRecoVsTrueEnergyTau_FDClone->GetBinContent(i,j)>0 ) {
01967           Float_t error=(hRecoVsTrueEnergyTau_FDClone->GetBinError(i,j)/
01968                          hRecoVsTrueEnergyTau_FDClone->GetBinContent(i,j));
01969 
01970           hRecoVsTrueEnergyTau_FDClone->SetBinContent
01971             (i,j,hRecoVsTrueEnergyTau_FDClone->GetBinContent(i,j)/
01972              hTrueEnergyCCOnlyEventsTau_FDClone->GetBinContent(i));
01973 
01974           hRecoVsTrueEnergyTau_FDClone->SetBinError
01975             (i,j,error*hRecoVsTrueEnergyTau_FDClone->GetBinContent(i,j));
01976         }
01977         else {
01978           hRecoVsTrueEnergyTau_FDClone->SetBinContent(i,j,0);
01979           hRecoVsTrueEnergyTau_FDClone->SetBinError(i,j,0);
01980         }
01981       }
01982     }
01983     //Normalise the FD reco v. true CC matrix (nutaubar CC):
01984     for(int i=1;i<=hRecoVsTrueEnergyTauPQ_FDClone->GetNbinsX();i++){
01985       //loop over true bins
01986       for(int j=1;j<=hRecoVsTrueEnergyTauPQ_FDClone->GetNbinsY()+1;j++){
01987         //loop over reco bins
01988         if( hTrueEnergyCCOnlyEventsTauPQ_FDClone->GetBinContent(i)>0 &&
01989             hRecoVsTrueEnergyTauPQ_FDClone->GetBinContent(i,j)>0 ) {
01990           Float_t error=(hRecoVsTrueEnergyTauPQ_FDClone->GetBinError(i,j)/
01991                          hRecoVsTrueEnergyTauPQ_FDClone->GetBinContent(i,j));
01992 
01993           hRecoVsTrueEnergyTauPQ_FDClone->SetBinContent
01994             (i,j,hRecoVsTrueEnergyTauPQ_FDClone->GetBinContent(i,j)/
01995              hTrueEnergyCCOnlyEventsTauPQ_FDClone->GetBinContent(i));
01996 
01997           hRecoVsTrueEnergyTauPQ_FDClone->SetBinError
01998             (i,j,error*hRecoVsTrueEnergyTauPQ_FDClone->GetBinContent(i,j));
01999         }
02000         else {
02001           hRecoVsTrueEnergyTauPQ_FDClone->SetBinContent(i,j,0);
02002           hRecoVsTrueEnergyTauPQ_FDClone->SetBinError(i,j,0);
02003         }
02004       }
02005     }
02006     //Normalise the FD reco v. true CC matrix (nutau + nutaubar CC):
02007     for(int i=1;i<=hRecoVsTrueEnergyTauAll_FDClone->GetNbinsX();i++){
02008       //loop over true bins
02009       for(int j=1;j<=hRecoVsTrueEnergyTauAll_FDClone->GetNbinsY()+1;j++){
02010         //loop over reco bins
02011         if( hTrueEnergyCCOnlyEventsTauAll_FDClone->GetBinContent(i)>0 &&
02012             hRecoVsTrueEnergyTauAll_FDClone->GetBinContent(i,j)>0 ) {
02013           Float_t error=(hRecoVsTrueEnergyTauAll_FDClone->GetBinError(i,j)/
02014                          hRecoVsTrueEnergyTauAll_FDClone->GetBinContent(i,j));
02015 
02016           hRecoVsTrueEnergyTauAll_FDClone->SetBinContent
02017             (i,j,hRecoVsTrueEnergyTauAll_FDClone->GetBinContent(i,j)/
02018              hTrueEnergyCCOnlyEventsTauAll_FDClone->GetBinContent(i));
02019 
02020           hRecoVsTrueEnergyTauAll_FDClone->SetBinError
02021             (i,j,error*hRecoVsTrueEnergyTauAll_FDClone->GetBinContent(i,j));
02022         }
02023         else {
02024           hRecoVsTrueEnergyTauAll_FDClone->SetBinContent(i,j,0);
02025           hRecoVsTrueEnergyTauAll_FDClone->SetBinError(i,j,0);
02026         }
02027       }
02028     }
02029   }
02030 
02031 
02033   //POT section
02035   if (!hTotalPotClone) {
02036     MSG("NuDSTAna",Msg::kInfo)
02037       <<"No hTotalPot histo so recalculating..."<<endl;
02038 
02039     //get an instance of the code library
02040     const NuLibrary& lib=NuLibrary::Instance();
02041 
02042     //calc pot histograms (hPotTotal gets written by default)
02043     lib.hist.CalcPOTsFromHistos("Clone");
02044 
02045     //set the clone pointer to the newly created histo
02046     //it will then get written out below
02047     hTotalPotClone=(TH1F*)gROOT->FindObject("hTotalPot");
02048   }
02049   else {
02050     MAXMSG("NuDSTAna",Msg::kInfo,1)
02051       <<"hTotalPot histo(s) exist(s) so they were summed"<<endl;
02052     MAXMSG("NuDSTAna",Msg::kInfo,1)
02053       <<"Total POT (from hTotalPot)="<<hTotalPotClone->Integral()<<endl;
02054   }
02055 
02057   //section to open output file
02059 
02060   //variable to store the output directory
02061   TDirectory* dirOutput=0;
02062 
02063   //open the output file for histos if not given etc
02064   if (poutput==0) {
02065     if (sFullFileName!="" && sFullFileName != "null") {
02066       fOutFile=this->OpenFileRECREATE(sFullFileName);
02067     }
02068     else if (fOutFile) {
02069       if (fOutFile->IsOpen())
02070         fOutFile->cd();
02071       else {
02072         MSG("NuDSTAna",Msg::kError) << "fOutFile was closed somehow." << endl;
02073         MSG("NuDSTAna",Msg::kFatal) << "fOutFile was closed somehow." << endl;
02074       }
02075     }
02076     else {
02077       Int_t firstRunNumber=input.GetFirstRunNumberNuEvent();
02078       if (sFilePrefix=="") sFilePrefix="NMBSumAna";
02079       fOutFile=this->OpenFile(firstRunNumber,sFilePrefix);
02080     }
02081     dirOutput=gDirectory;
02082     MSG("NuDSTAna",Msg::kInfo)<<"After opening output file:"<<endl;
02083     dirOutput->Print();
02084   }
02085   else {
02086     //get config object
02087     NuConfig config=this->GetNuConfig(input.GetNextNuEvent(Msg::kDebug));
02088     if (sFilePrefix=="") string sFilePrefix="NuDSTMicro";
02089     poutput->SetupFile(config,sFilePrefix);
02090 
02091     //get the directory of the new file
02092     dirOutput=gDirectory;
02093     MSG("NuDSTAna",Msg::kInfo)<<"Set up tree for NuOutputWriter"<<endl;
02094     //dirOutput->Print();//too verbose
02095   }
02096 
02097   //get rid of Clone in the name
02098   hDetectorClone->SetName("hDetector");
02099   hSimFlagClone->SetName("hSimFlag");
02100   hTrigSrcClone->SetName("hTrigSrc");
02101   hSpillsPerFileClone->SetName("hSpillsPerFile");
02102 
02103   if (hTotalPotClone) hTotalPotClone->SetName("hTotalPot");
02104 
02105   hPottortgtClone->SetName("hPottortgt");
02106   hPotBadtortgtClone->SetName("hPotBadtortgt");
02107   hPottrtgtdClone->SetName("hPottrtgtd");
02108   hPotBadtrtgtdClone->SetName("hPotBadtrtgtd");
02109   hPottor101Clone->SetName("hPottor101");
02110   hPotBadtor101Clone->SetName("hPotBadtor101");
02111   hPottr101dClone->SetName("hPottr101d");
02112   hPotBadtr101dClone->SetName("hPotBadtr101d");
02113   hRunClone->SetName("hRun");
02114 
02115   if (hNtupleEarliestTimeClone) {
02116     hNtupleEarliestTimeClone->SetName("hNtupleEarliestTime");
02117     hNtupleLatestTimeClone->SetName("hNtupleLatestTime");
02118   }
02119 
02120   //Rename MM histograms
02121   if (hRecoVsTrueEnergyPQ_FDClone) {
02122     MSG("NuDSTAna",Msg::kInfo) << "Renaming MM histos" << endl;
02123     //Numu CC:
02124     hRecoVsTrueEnergy_NDClone->SetName("RecoVsTrueEnergy_ND");
02125     hRecoVsTrueEnergy_FDClone->SetName("RecoVsTrueEnergy_FD");
02126     hEfficiency_NDClone->SetName("Efficiency_ND");
02127     hEfficiency_FDClone->SetName("Efficiency_FD");
02128     hPurity_NDClone->SetName("Purity_ND");
02129     hPurity_FDClone->SetName("Purity_FD");
02130     hRecoEnergyAllEvents_NDClone->SetName("RecoEnergyAllEvents_ND");
02131     hRecoEnergyCCOnlyEvents_NDClone->SetName("RecoEnergyCCOnlyEvents_ND");
02132     hTrueEnergyCCOnlyEvents_NDClone->SetName("TrueEnergyCCOnlyEvents_ND");
02133 
02134     if (hTrueEnergyTrueCCFidEvents_NDClone){
02135       hTrueEnergyTrueCCFidEvents_NDClone->SetName("TrueEnergyTrueCCFidEvents_ND");
02136     }
02137     if (hTrueEnergyTrueCCFidEvents_FDClone){
02138       hTrueEnergyTrueCCFidEvents_FDClone->SetName("TrueEnergyTrueCCFidEvents_FD");
02139     }
02140 
02141     hTrueEnergyCCOnlyEvents_FDClone->SetName("TrueEnergyCCOnlyEvents_FD");
02142     hRecoEnergyCCOnlyEvents_FDClone->SetName("RecoEnergyCCOnlyEvents_FD");
02143     hRecoEnergyAllEvents_FDClone->SetName("RecoEnergyAllEvents_FD");
02144     hRecoEnergy_NDClone->SetName("RecoEnergy_ND");
02145     hRecoEnergy_FDClone->SetName("RecoEnergy_FD");
02146     if (hRecoEnergy_ND_NCClone){
02147       hRecoEnergy_ND_NCClone->SetName("RecoEnergy_ND_NC");
02148     }
02149     if (hRecoEnergy_FD_NCClone){
02150       hRecoEnergy_FD_NCClone->SetName("RecoEnergy_FD_NC");
02151     }
02152     if (hRecoVsTrueEnergy_ND_NCClone){
02153       hRecoVsTrueEnergy_ND_NCClone->SetName("RecoVsTrueEnergy_ND_NC");
02154     }
02155     if (hRecoVsTrueEnergy_FD_NCClone){
02156       hRecoVsTrueEnergy_FD_NCClone->SetName("RecoVsTrueEnergy_FD_NC");
02157     }
02158 
02159     for(int truth = 0; truth < ENCTruth::kNumTruths; ++truth){
02160       for(int det = 0; det <= 1; ++det){
02161         const TString detstr = det ? "FD" : "ND";
02162         const TString name = "RecoVsTrueEnergy_truly"+ENCTruth::truthNames[truth]+"_"+detstr+"_NC";
02163         if (hRecoVsTrueEnergy_NCClone_truly[truth][det]){
02164           hRecoVsTrueEnergy_NCClone_truly[truth][det]->SetName(name);
02165         }
02166       }
02167     }
02168 
02169     if (hCCContamination_FDClone){
02170       hCCContamination_FDClone->SetName("CCContamination_FD");
02171       if (hCCContaminationRecoVsTrue_FDClone){
02172         hCCContaminationRecoVsTrue_FDClone->SetName("CCContaminationRecoVsTrue_FD");
02173       }
02174       hNCContamination_FDClone->SetName("NCContamination_FD");
02175     }
02176     if (hCCContamination_NDClone){
02177       hCCContamination_NDClone->SetName("CCContamination_ND");
02178     }
02179     if (hNCContamination_NDClone){
02180       hNCContamination_NDClone->SetName("NCContamination_ND");
02181     }
02182     //Decay Pipe:
02183     if(hTrueEnergyAllEventsPQ_NDClone) {
02184       hTrueEnergyAllEventsPQ_NDClone->SetName("TrueEnergyAllEventsPQ_ND");
02185     }
02186     if(hTrueEnergyAllEventsPQ_FDClone) {
02187       hTrueEnergyAllEventsPQ_FDClone->SetName("TrueEnergyAllEventsPQ_FD");
02188     }
02189     if(hTrueEnergyDecayPipePQ_NDClone) {
02190       hTrueEnergyDecayPipePQ_NDClone->SetName("TrueEnergyDecayPipePQ_ND");
02191     }
02192     if(hTrueEnergyDecayPipePQ_FDClone) {
02193       hTrueEnergyDecayPipePQ_FDClone->SetName("TrueEnergyDecayPipePQ_FD");
02194     }
02195     //Numubar CC:
02196     hRecoVsTrueEnergyPQ_NDClone->SetName("RecoVsTrueEnergyPQ_ND");
02197     hRecoVsTrueEnergyPQ_FDClone->SetName("RecoVsTrueEnergyPQ_FD");
02198     hEfficiencyPQ_NDClone->SetName("EfficiencyPQ_ND");
02199     hEfficiencyPQ_FDClone->SetName("EfficiencyPQ_FD");
02200     hPurityPQ_NDClone->SetName("PurityPQ_ND");
02201     hPurityPQ_FDClone->SetName("PurityPQ_FD");
02202     hRecoEnergyAllEventsPQ_NDClone->SetName("RecoEnergyAllEventsPQ_ND");
02203     hRecoEnergyCCOnlyEventsPQ_NDClone->SetName("RecoEnergyCCOnlyEventsPQ_ND");
02204     hTrueEnergyCCOnlyEventsPQ_NDClone->SetName("TrueEnergyCCOnlyEventsPQ_ND");
02205 
02206     if (hTrueEnergyTrueCCFidEventsPQ_NDClone){
02207       hTrueEnergyTrueCCFidEventsPQ_NDClone->SetName("TrueEnergyTrueCCFidEventsPQ_ND");
02208     }
02209     if (hTrueEnergyTrueCCFidEventsPQ_FDClone){
02210       hTrueEnergyTrueCCFidEventsPQ_FDClone->SetName("TrueEnergyTrueCCFidEventsPQ_FD");
02211     }
02212 
02213     hTrueEnergyCCOnlyEventsPQ_FDClone->SetName("TrueEnergyCCOnlyEventsPQ_FD");
02214     hRecoEnergyCCOnlyEventsPQ_FDClone->SetName("RecoEnergyCCOnlyEventsPQ_FD");
02215     hRecoEnergyAllEventsPQ_FDClone->SetName("RecoEnergyAllEventsPQ_FD");
02216     hRecoEnergyPQ_NDClone->SetName("RecoEnergyPQ_ND");
02217     hRecoEnergyPQ_FDClone->SetName("RecoEnergyPQ_FD");
02218     if (hCCContaminationPQ_FDClone){
02219       hCCContaminationPQ_FDClone->SetName("CCContaminationPQ_FD");
02220       if (hCCContaminationRecoVsTruePQ_FDClone){
02221         hCCContaminationRecoVsTruePQ_FDClone->SetName("CCContaminationRecoVsTruePQ_FD");
02222       }
02223       hNCContaminationPQ_FDClone->SetName("NCContaminationPQ_FD");
02224     }
02225     if (hCCContaminationPQ_NDClone){
02226       hCCContaminationPQ_NDClone->SetName("CCContaminationPQ_ND");
02227     }
02228     if (hNCContaminationPQ_NDClone){
02229       hNCContaminationPQ_NDClone->SetName("NCContaminationPQ_ND");
02230     }
02231     //Numu + numubar CC:
02232     hRecoVsTrueEnergyAll_NDClone->SetName("RecoVsTrueEnergyAll_ND");
02233     hRecoVsTrueEnergyAll_FDClone->SetName("RecoVsTrueEnergyAll_FD");
02234     hEfficiencyAll_NDClone->SetName("EfficiencyAll_ND");
02235     hEfficiencyAll_FDClone->SetName("EfficiencyAll_FD");
02236     hPurityAll_NDClone->SetName("PurityAll_ND");
02237     hPurityAll_FDClone->SetName("PurityAll_FD");
02238     hRecoEnergyAllEventsAll_NDClone->SetName("RecoEnergyAllEventsAll_ND");
02239     hRecoEnergyCCOnlyEventsAll_NDClone->SetName("RecoEnergyCCOnlyEventsAll_ND");
02240     hTrueEnergyCCOnlyEventsAll_NDClone->SetName("TrueEnergyCCOnlyEventsAll_ND");
02241 
02242     if (hTrueEnergyTrueCCFidEventsAll_NDClone){
02243       hTrueEnergyTrueCCFidEventsAll_NDClone->SetName("TrueEnergyTrueCCFidEventsAll_ND");
02244       hTrueEnergyTrueCCFidEventsAll_FDClone->SetName("TrueEnergyTrueCCFidEventsAll_FD");
02245     }
02246 
02247     hTrueEnergyCCOnlyEventsAll_FDClone->SetName("TrueEnergyCCOnlyEventsAll_FD");
02248     hRecoEnergyCCOnlyEventsAll_FDClone->SetName("RecoEnergyCCOnlyEventsAll_FD");
02249     hRecoEnergyAllEventsAll_FDClone->SetName("RecoEnergyAllEventsAll_FD");
02250     hRecoEnergyAll_NDClone->SetName("RecoEnergyAll_ND");
02251     hRecoEnergyAll_FDClone->SetName("RecoEnergyAll_FD");
02252   }
02253   //nutau CC:
02254   if (hRecoVsTrueEnergyTau_FDClone){
02255     hRecoVsTrueEnergyTau_FDClone->SetName("RecoVsTrueEnergyTau_FD");
02256   }
02257   if (hEfficiencyTau_FDClone){
02258     hEfficiencyTau_FDClone->SetName("EfficiencyTau_FD");
02259   }
02260   if (hTrueEnergyTrueCCFidEventsTau_FDClone){
02261     hTrueEnergyTrueCCFidEventsTau_FDClone->SetName("TrueEnergyTrueCCFidEventsTau_FD");
02262   }
02263   if (hTrueEnergyTrueCCFidEventsTau_FDClone){
02264     hTrueEnergyCCOnlyEventsTau_FDClone->SetName("TrueEnergyCCOnlyEventsTau_FD");
02265   }
02266   //nutaubar CC:
02267   if (hRecoVsTrueEnergyTauPQ_FDClone){
02268     hRecoVsTrueEnergyTauPQ_FDClone->SetName("RecoVsTrueEnergyTauPQ_FD");
02269   }
02270   if (hEfficiencyTauPQ_FDClone){
02271     hEfficiencyTauPQ_FDClone->SetName("EfficiencyTauPQ_FD");
02272   }
02273   if (hTrueEnergyTrueCCFidEventsTauPQ_FDClone){
02274     hTrueEnergyTrueCCFidEventsTauPQ_FDClone->SetName("TrueEnergyTrueCCFidEventsTauPQ_FD");
02275   }
02276   if (hTrueEnergyTrueCCFidEventsTauPQ_FDClone){
02277     hTrueEnergyCCOnlyEventsTauPQ_FDClone->SetName("TrueEnergyCCOnlyEventsTauPQ_FD");
02278   }
02279   //nutau + nutaubar CC:
02280   if (hRecoVsTrueEnergyTauAll_FDClone){
02281     hRecoVsTrueEnergyTauAll_FDClone->SetName("RecoVsTrueEnergyTauAll_FD");
02282   }
02283   if (hEfficiencyTauAll_FDClone){
02284     hEfficiencyTauAll_FDClone->SetName("EfficiencyTauAll_FD");
02285   }
02286   if (hTrueEnergyTrueCCFidEventsTauAll_FDClone){
02287     hTrueEnergyTrueCCFidEventsTauAll_FDClone->SetName("TrueEnergyTrueCCFidEventsTauAll_FD");
02288   }
02289   if (hTrueEnergyTrueCCFidEventsTauAll_FDClone){
02290     hTrueEnergyCCOnlyEventsTauAll_FDClone->SetName("TrueEnergyCCOnlyEventsTauAll_FD");
02291   }
02292 
02293   // F/N histos
02294   if (hRecoVsTrueEnergyUnnormNQ_ND) {
02295     hRecoVsTrueEnergyUnnormNQ_ND->SetName("RecoVsTrueEnergyUnnormNQ_ND");
02296     hRecoVsTrueEnergyUnnormNQ_FD->SetName("RecoVsTrueEnergyUnnormNQ_FD");
02297 
02298     hRecoVsTrueEnergyUnnormPQ_ND->SetName("RecoVsTrueEnergyUnnormPQ_ND");
02299     hRecoVsTrueEnergyUnnormPQ_FD->SetName("RecoVsTrueEnergyUnnormPQ_FD");
02300 
02301     hRecoVsTrueEnergyUnnormAll_ND->SetName("RecoVsTrueEnergyUnnormAll_ND");
02302     hRecoVsTrueEnergyUnnormAll_FD->SetName("RecoVsTrueEnergyUnnormAll_FD");
02303   }
02304 
02305 
02307   //now write to file
02309   hDetectorClone->Write();
02310   hSimFlagClone->Write();
02311   hTrigSrcClone->Write();
02312   hSpillsPerFileClone->Write();
02313 
02314   if (hTotalPotClone) {
02315     if (hTotalPotClone->Integral() < 0) {
02316       MSG("NuDSTAna",Msg::kWarning) << "Warning: Negative total POT = " << hTotalPotClone->Integral() << endl;
02317       if (hDetectorClone->GetMean() == 2 && hSimFlagClone->GetMean() == 4) {
02318         double pot = hTotalPotClone->Integral();
02319         pot /= hPottortgtClone->GetMean();
02320         pot *= 6.5; // 6.5 (e20) should replace whatever negative value of spills per file was used.  All else is unchanged
02321         MSG("NuDSTAna",Msg::kWarning) << "This appears to be FD MC.  Setting POTs to default dogwood value, which for this file is " << pot << endl;
02322         hTotalPotClone->SetBinContent(1, pot);
02323       }
02324     }
02325 
02326 
02327     hTotalPotClone->Write();
02328   }
02329 
02330   if (xmlConfigClone) {
02331     cout << "NuXMLConfig Transfered" << endl;
02332     xmlConfigClone->Write("NuXMLConfig");
02333   }
02334 
02335   hPottortgtClone->Write();
02336   hPotBadtortgtClone->Write();
02337   hPottrtgtdClone->Write();
02338   hPotBadtrtgtdClone->Write();
02339   hPottor101Clone->Write();
02340   hPotBadtor101Clone->Write();
02341   hPottr101dClone->Write();
02342   hPotBadtr101dClone->Write();
02343   hRunClone->Write();
02344 
02345   if (hNtupleEarliestTimeClone) hNtupleEarliestTimeClone->Write();
02346   if (hNtupleLatestTimeClone) hNtupleLatestTimeClone->Write();
02347 
02348   // Write F/N histograms
02349   if (hRecoVsTrueEnergyUnnormNQ_FD) {
02350     MSG("NuDSTAna",Msg::kInfo) << "Writing F/N histos to file" << endl;
02351     
02352     hRecoVsTrueEnergyUnnormNQ_ND->Write();
02353     hRecoVsTrueEnergyUnnormNQ_FD->Write();
02354 
02355     hRecoVsTrueEnergyUnnormPQ_ND->Write();
02356     hRecoVsTrueEnergyUnnormPQ_FD->Write();
02357 
02358     hRecoVsTrueEnergyUnnormAll_ND->Write();
02359     hRecoVsTrueEnergyUnnormAll_FD->Write();
02360   }
02361 
02362   //Write the MM histograms
02363   if (hRecoVsTrueEnergyPQ_FDClone) {
02364     MSG("NuDSTAna",Msg::kInfo) << "Writing MM histos to file" << endl;
02365     //Numu CC:
02366     hRecoVsTrueEnergy_NDClone->Write();
02367     hRecoVsTrueEnergy_FDClone->Write();
02368     hEfficiency_NDClone->Write();
02369     hEfficiency_FDClone->Write();
02370     hPurity_NDClone->Write();
02371     hPurity_FDClone->Write();
02372     hRecoEnergyAllEvents_NDClone->Write();
02373     hRecoEnergyCCOnlyEvents_NDClone->Write();
02374     hTrueEnergyCCOnlyEvents_NDClone->Write();
02375 
02376     if (hTrueEnergyTrueCCFidEvents_NDClone){
02377       hTrueEnergyTrueCCFidEvents_NDClone->Write();
02378     }
02379     if (hTrueEnergyTrueCCFidEvents_FDClone){
02380       hTrueEnergyTrueCCFidEvents_FDClone->Write();
02381     }
02382 
02383     hTrueEnergyCCOnlyEvents_FDClone->Write();
02384     hRecoEnergyCCOnlyEvents_FDClone->Write();
02385     hRecoEnergyAllEvents_FDClone->Write();
02386     hRecoEnergy_NDClone->Write();
02387     hRecoEnergy_FDClone->Write();
02388 
02389     if (hRecoEnergy_ND_NCClone){
02390       hRecoEnergy_ND_NCClone->Write();
02391     }
02392     if (hRecoEnergy_FD_NCClone){
02393       hRecoEnergy_FD_NCClone->Write();
02394     }
02395     if (hRecoVsTrueEnergy_ND_NCClone){
02396       hRecoVsTrueEnergy_ND_NCClone->Write();
02397     }
02398     if (hRecoVsTrueEnergy_FD_NCClone){
02399       hRecoVsTrueEnergy_FD_NCClone->Write();
02400     }
02401 
02402     for(int truth = 0; truth < ENCTruth::kNumTruths; ++truth){
02403       for(int det = 0; det <= 1; ++det){
02404         if (hRecoVsTrueEnergy_NCClone_truly[truth][det]){
02405           hRecoVsTrueEnergy_NCClone_truly[truth][det]->Write();
02406         }
02407       }
02408     }
02409 
02410     if (hCCContamination_FDClone){
02411       hCCContamination_FDClone->Write();
02412       if (hCCContaminationRecoVsTrue_FDClone){
02413         hCCContaminationRecoVsTrue_FDClone->Write();
02414       }
02415       hNCContamination_FDClone->Write();
02416     }
02417     if (hCCContamination_NDClone){
02418       hCCContamination_NDClone->Write();
02419     }
02420     if (hNCContamination_NDClone){
02421       hNCContamination_NDClone->Write();
02422     }
02423     //Decay Pipe:
02424     if(hTrueEnergyAllEventsPQ_NDClone) {
02425       hTrueEnergyAllEventsPQ_NDClone->Write();
02426     }
02427     if(hTrueEnergyAllEventsPQ_FDClone) {
02428       hTrueEnergyAllEventsPQ_FDClone->Write();
02429     }
02430     if(hTrueEnergyDecayPipePQ_NDClone) {
02431       hTrueEnergyDecayPipePQ_NDClone->Write();
02432     }
02433     if(hTrueEnergyDecayPipePQ_FDClone) {
02434       hTrueEnergyDecayPipePQ_FDClone->Write();
02435     }
02436     //Numubar CC:
02437     hRecoVsTrueEnergyPQ_NDClone->Write();
02438     hRecoVsTrueEnergyPQ_FDClone->Write();
02439     hEfficiencyPQ_NDClone->Write();
02440     hEfficiencyPQ_FDClone->Write();
02441     hPurityPQ_NDClone->Write();
02442     hPurityPQ_FDClone->Write();
02443     hRecoEnergyAllEventsPQ_NDClone->Write();
02444     hRecoEnergyCCOnlyEventsPQ_NDClone->Write();
02445     hTrueEnergyCCOnlyEventsPQ_NDClone->Write();
02446 
02447     if (hTrueEnergyTrueCCFidEventsPQ_NDClone){
02448       hTrueEnergyTrueCCFidEventsPQ_NDClone->Write();
02449     }
02450     if (hTrueEnergyTrueCCFidEventsPQ_FDClone){
02451       hTrueEnergyTrueCCFidEventsPQ_FDClone->Write();
02452     }
02453 
02454     hTrueEnergyCCOnlyEventsPQ_FDClone->Write();
02455     hRecoEnergyCCOnlyEventsPQ_FDClone->Write();
02456     hRecoEnergyAllEventsPQ_FDClone->Write();
02457     hRecoEnergyPQ_NDClone->Write();
02458     hRecoEnergyPQ_FDClone->Write();
02459     if (hCCContaminationPQ_FDClone){
02460       hCCContaminationPQ_FDClone->Write();
02461       if (hCCContaminationRecoVsTruePQ_FDClone){
02462         hCCContaminationRecoVsTruePQ_FDClone->Write();
02463       }
02464       hNCContaminationPQ_FDClone->Write();
02465     }
02466     if (hCCContaminationPQ_NDClone){
02467       hCCContaminationPQ_NDClone->Write();
02468     }
02469     if (hNCContaminationPQ_NDClone){
02470       hNCContaminationPQ_NDClone->Write();
02471     }
02472     //Numu + numubar CC:
02473     hRecoVsTrueEnergyAll_NDClone->Write();
02474     hRecoVsTrueEnergyAll_FDClone->Write();
02475     hEfficiencyAll_NDClone->Write();
02476     hEfficiencyAll_FDClone->Write();
02477     hPurityAll_NDClone->Write();
02478     hPurityAll_FDClone->Write();
02479     hRecoEnergyAllEventsAll_NDClone->Write();
02480     hRecoEnergyCCOnlyEventsAll_NDClone->Write();
02481     hTrueEnergyCCOnlyEventsAll_NDClone->Write();
02482 
02483     if (hTrueEnergyTrueCCFidEventsAll_NDClone){
02484       hTrueEnergyTrueCCFidEventsAll_NDClone->Write();
02485     }
02486     if (hTrueEnergyTrueCCFidEventsAll_FDClone){
02487       hTrueEnergyTrueCCFidEventsAll_FDClone->Write();
02488     }
02489 
02490     hTrueEnergyCCOnlyEventsAll_FDClone->Write();
02491     hRecoEnergyCCOnlyEventsAll_FDClone->Write();
02492     hRecoEnergyAllEventsAll_FDClone->Write();
02493     hRecoEnergyAll_NDClone->Write();
02494     hRecoEnergyAll_FDClone->Write();
02495     //nutau CC:
02496     if (hRecoVsTrueEnergyTau_FDClone){
02497       hRecoVsTrueEnergyTau_FDClone->Write();
02498     }
02499     if (hEfficiencyTau_FDClone){
02500       hEfficiencyTau_FDClone->Write();
02501     }
02502     if (hTrueEnergyTrueCCFidEventsTau_FDClone){
02503       hTrueEnergyTrueCCFidEventsTau_FDClone->Write();
02504     }
02505     if (hTrueEnergyTrueCCFidEventsTau_FDClone){
02506       hTrueEnergyCCOnlyEventsTau_FDClone->Write();
02507     }
02508     //nutaubar CC:
02509     if (hRecoVsTrueEnergyTauPQ_FDClone){
02510       hRecoVsTrueEnergyTauPQ_FDClone->Write();
02511     }
02512     if (hEfficiencyTauPQ_FDClone){
02513       hEfficiencyTauPQ_FDClone->Write();
02514     }
02515     if (hTrueEnergyTrueCCFidEventsTauPQ_FDClone){
02516       hTrueEnergyTrueCCFidEventsTauPQ_FDClone->Write();
02517     }
02518     if (hTrueEnergyTrueCCFidEventsTauPQ_FDClone){
02519       hTrueEnergyCCOnlyEventsTauPQ_FDClone->Write();
02520     }
02521     //nutau _ nutaubar CC:
02522     if (hRecoVsTrueEnergyTauAll_FDClone){
02523       hRecoVsTrueEnergyTauAll_FDClone->Write();
02524     }
02525     if (hEfficiencyTauAll_FDClone){
02526       hEfficiencyTauAll_FDClone->Write();
02527     }
02528     if (hTrueEnergyTrueCCFidEventsTauAll_FDClone){
02529       hTrueEnergyTrueCCFidEventsTauAll_FDClone->Write();
02530     }
02531     if (hTrueEnergyTrueCCFidEventsTauAll_FDClone){
02532       hTrueEnergyCCOnlyEventsTauAll_FDClone->Write();
02533     }
02534   }
02535 
02536   //copy across histos such hDetector, hSimFlag, and POT ones
02537   //do this above now
02538   //this->CopyAcrossHistos(dirInput,dirOutput);
02539 
02540   return input;
02541 }

NuInputEvents & NuDSTAna::DoIOSimple ( std::string  sFilePrefix = ""  )  [protected]

Definition at line 968 of file NuDSTAna.cxx.

References CopyAcrossHistos(), NuBase::fOutFile, NuInputEvents::GetFirstRunNumberNuEvent(), NuBase::GetInputFileName(), NuInputEvents::InitialiseChains(), NuInputEvents::InitialiseNuEventBranch(), NuInputEvents::InputFileName(), NuBase::OpenFile(), and NuInputEvents::OpenInputFile().

00969 {
00970   //open the input file with the tree in it
00971   string inputFileName=this->GetInputFileName();
00972   NuInputEvents* fpInput=new NuInputEvents();
00973   NuInputEvents& input=*fpInput;
00974   input.InputFileName(inputFileName);
00975   input.InitialiseChains();
00976   input.InitialiseNuEventBranch();
00977   TDirectory* dirInput=input.OpenInputFile();
00978   Int_t firstRunNumber=input.GetFirstRunNumberNuEvent();
00979 
00980   //open the output file for histos etc
00981   if (sFilePrefix!="") {
00982     fOutFile=this->OpenFile(firstRunNumber,sFilePrefix.c_str());
00983     TDirectory* dirOutput=gDirectory;
00984     cout<<"After opening output file:"<<endl;
00985     dirOutput->Print();
00986 
00987     //copy across histos such hDetector, hSimFlag, and POT ones
00988     this->CopyAcrossHistos(dirInput,dirOutput);
00989   }
00990   else cout<<"Not opening an output file"<<endl;
00991 
00992   return input;
00993 }

void NuDSTAna::DoSystematicShifts ( NuEvent event,
const NuXMLConfig xmlConfig 
) const [virtual]

Definition at line 5695 of file NuDSTAna.cxx.

References NuXMLConfig::FullTitle(), Msg::kInfo, MAXMSG, NuXMLConfig::Name(), and NuSystematic::Shift().

Referenced by FluxComponents(), and MakeMicroDST().

05697 {
05698   if (!xmlConfig){
05699     MAXMSG("NuDSTAna",Msg::kInfo,5)
05700       << "No NuXMLConfig object supplied: "
05701       << "performing no systematic shifts."
05702       << endl;
05703     return;
05704   } else if (xmlConfig->Name().IsNull()) {
05705     MAXMSG("NuDSTAna",Msg::kInfo,5)
05706       << "No Shift supplied in XML. Not doing shifts."
05707       << endl;
05708     return;
05709   } else {
05710     MAXMSG("NuDSTAna",Msg::kInfo,5)
05711       << "Performing systematic shift "
05712       << xmlConfig->FullTitle()
05713       << endl;
05714     static NuSystematic nuSyst(*xmlConfig);
05715     nuSyst.Shift(event);
05716     return;
05717   }
05718 }

void NuDSTAna::DPSystematic (  ) 

Definition at line 6608 of file NuDSTAna.cxx.

References NuCut::AnaVersion(), NuReco::ApplyReweights(), NuLibrary::cnt, DoIO(), NuCounter::evtCounter, NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::InitialiseNuEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, NuCut::MakeCuts(), MSG, NuCut::Passed(), NuBase::PrintLoopProgress(), NuCut::PrintSummary(), NuLibrary::reco, NuUtilities::RecoBins(), NuInputEvents::ResetNuEventLoopPositionToStart(), and SanityCheckedAnaVersion().

06609 {
06610   NuInputEvents& input=this->DoIO(0,"","null");
06611 
06612   //get an instance of the code library
06613   NuLibrary& lib = NuLibrary::Instance();
06614 
06615   NuCutImps::Bravo0720 bravoCut;
06616 
06617   
06618   //version to do reco/cuts with
06619   NuCuts::NuAnaVersion_t overrideAnaVersion = static_cast<NuCuts::NuAnaVersion_t>(bravoCut.AnaVersion());
06620 
06621   //Binning scheme
06622   const NuUtilities cuts;
06623   NuBinningScheme::NuBinningScheme_t binningScheme =
06624     static_cast<NuBinningScheme::NuBinningScheme_t>(4);
06625   std::vector<Double_t> vReco = cuts.RecoBins(binningScheme);
06626   int numRecoBins = vReco.size() - 1;
06627 
06628   TH1::AddDirectory(true);
06629   TH1D *hUp  = new TH1D("hUp",  "Upstream #bar{#nu}",    numRecoBins, &(vReco[0]));
06630   TH1D *hDn  = new TH1D("hDn",  "Downstream #bar{#nu}",  numRecoBins, &(vReco[0]));
06631 
06632 
06633 
06637 
06638   bool dp;
06639 
06640   input.InitialiseNuEventBranch();
06641   input.ResetNuEventLoopPositionToStart();
06642 
06643   cout<<endl
06644       <<"************************************************"<<endl
06645       <<"***      Starting main loop over snarls      ***"<<endl
06646       <<"************************************************"<<endl;
06647   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
06648     //for (Int_t i=0;i<0;++i) {
06649     lib.cnt.evtCounter++;
06650 
06651     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
06652 
06653     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
06654     //OVERRIDE
06655     //Selection
06656     nu.anaVersion=this->SanityCheckedAnaVersion
06657       (nu.anaVersion,overrideAnaVersion);
06658 
06659     if (nu.charge < 0) continue;  // Only care about numubars
06660 
06661     bravoCut.MakeCuts(nu);
06662     if (!bravoCut.Passed()) continue;
06663 
06664     dp = nu.ppvz > 4500 && nu.ptype != 13 && nu.ptype != -13;
06665 
06666     nu.applyBeamWeight = true;
06667 
06668     //nu.reweightVersion = 1; // Force numu-only SKZP
06669     //lib.zBeamReweight.ExtractZBeamReweight(nu);
06670     // Use custom set of weights (no NuMuBar spectrum in fit)
06671     //lib.zBeamReweight.ExtractZBeamReweightCustom(nu);
06672 
06673     
06674 
06675     //RE-RECONSTRUCT the neutrino energy
06676     lib.reco.GetEvtEnergy(nu, false);
06677     lib.reco.ApplyReweights(nu);
06678 
06679     if (dp) {
06680       hDn->Fill(nu.energy, nu.rw);
06681     }
06682     else {
06683       hUp->Fill(nu.energy, nu.rw);
06684     }
06685   }
06686 
06687   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06688 
06692 
06693   //print out the numbers of events
06694   bravoCut.PrintSummary();
06695 
06696 
06697   MSG("NuAnalysis",Msg::kInfo)
06698     <<" ** Finished DPSystematic method **"<<endl;
06699 }

void NuDSTAna::FDTestAna (  ) 

Definition at line 308 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuEvent::charge, CopyAcrossHistos(), NuConfig::detector, NuEvent::energy, NuCounter::evtCounter, NuBase::fOutFile, NuInputEvents::GetEntriesNuEvent(), GetEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetFirstRunNumberNuEvent(), NuBase::GetInputFileName(), NuInputEvents::GetNextNuEvent(), NuReco::GetShowerEnergyCC(), NuReco::GetShowerEnergyCor(), Munits::GeV, NuInputEvents::InitialiseChains(), NuInputEvents::InitialiseNuEventBranch(), NuInputEvents::InputFileName(), IsGoodStdCuts(), CandShowerHandle::kCC, NuCuts::kCC0250Std, Msg::kDebug, Detector::kFar, Msg::kInfo, MakeFinalPlots(), MAXMSG, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuBase::OpenFile(), NuInputEvents::OpenInputFile(), NuBase::OpenTxtFile(), plots(), NuPlots::PrintEventInfo(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuInputEvents::ResetNuEventLoopPositionToStart(), NuConfig::run, and SanityCheckedAnaVersion().

00309 {
00310   //open the input file with the tree in it
00311   string inputFileName=this->GetInputFileName();
00312   NuInputEvents* fpInput=new NuInputEvents();
00313   NuInputEvents& input=*fpInput;
00314   input.InputFileName(inputFileName);
00315   input.InitialiseChains();
00316   input.InitialiseNuEventBranch();
00317   TDirectory* dirInput=input.OpenInputFile();
00318   Int_t firstRunNumber=input.GetFirstRunNumberNuEvent();
00319 
00320   //open the output file for histos etc
00321   string sFilePrefix="NMBSumAna";
00322   fOutFile=this->OpenFile(firstRunNumber,sFilePrefix.c_str());
00323   TDirectory* dirOutput=gDirectory;
00324   cout<<"After opening output file:"<<endl;
00325   dirOutput->Print();
00326 
00327   //copy across histos such hDetector, hSimFlag, and POT ones
00328   this->CopyAcrossHistos(dirInput,dirOutput);
00329 
00330   //use config object to store info
00331   NuConfig config;
00332   config.detector=Detector::kFar;
00333   config.run=100;
00334 
00335   string sTxt="nmb";
00336   ofstream& nmbTxt=*(this->OpenTxtFile(config,sTxt.c_str()));
00337   string sTxtNM="nm";
00338   ofstream& nmTxt=*(this->OpenTxtFile(config,sTxtNM.c_str()));
00339   //string sTxtLINM="nmLI";
00340   //ofstream& nmLITxt=*(this->OpenTxtFile(config,sTxtLINM.c_str()));
00341 
00342   //object to count events
00343   NuCounter cnt;
00344 
00345   static NuGeneral general;
00346   static NuPlots* plots=0;
00347   static NuCuts cuts;
00348   static NuReco reco;
00349 
00350   TH1F* hRecoEnDiff=new TH1F("hRecoEnDiff","hRecoEnDiff",
00351                              200000,-100,100);
00352   hRecoEnDiff->SetTitle("Reconstructed Energy Difference (GeV)");
00353   hRecoEnDiff->GetXaxis()->
00354     SetTitle("Reconstructed Energy Difference (GeV)");
00355   hRecoEnDiff->GetXaxis()->CenterTitle();
00356   hRecoEnDiff->GetYaxis()->SetTitle("");
00357   hRecoEnDiff->GetYaxis()->CenterTitle();
00358   hRecoEnDiff->SetFillColor(0);
00359   hRecoEnDiff->SetLineColor(1);
00360   //hRecoEnDiff->SetBit(TH1::kCanRebin);
00361 
00362   TH1F* hRecoEnDiffCurv=new TH1F("hRecoEnDiffCurv","hRecoEnDiffCurv",
00363                                  200000,-100,100);
00364   hRecoEnDiffCurv->SetTitle("Reconstructed Energy Difference (GeV)");
00365   hRecoEnDiffCurv->GetXaxis()->
00366     SetTitle("Reconstructed Energy Difference (GeV)");
00367   hRecoEnDiffCurv->GetXaxis()->CenterTitle();
00368   hRecoEnDiffCurv->GetYaxis()->SetTitle("");
00369   hRecoEnDiffCurv->GetYaxis()->CenterTitle();
00370   hRecoEnDiffCurv->SetFillColor(0);
00371   hRecoEnDiffCurv->SetLineColor(1);
00372   //hRecoEnDiffCurv->SetBit(TH1::kCanRebin);
00373 
00374   TH1F* hRecoEnDiffRange=new TH1F("hRecoEnDiffRange","hRecoEnDiffRange",
00375                                   200000,-100,100);
00376   hRecoEnDiffRange->SetTitle("Reconstructed Energy Difference (GeV)");
00377   hRecoEnDiffRange->GetXaxis()->
00378     SetTitle("Reconstructed Energy Difference (GeV)");
00379   hRecoEnDiffRange->GetXaxis()->CenterTitle();
00380   hRecoEnDiffRange->GetYaxis()->SetTitle("");
00381   hRecoEnDiffRange->GetYaxis()->CenterTitle();
00382   hRecoEnDiffRange->SetFillColor(0);
00383   hRecoEnDiffRange->SetLineColor(1);
00384   //hRecoEnDiffRange->SetBit(TH1::kCanRebin);
00385 
00386 
00387   TH1F* hRecoTrkEnDiff=new TH1F("hRecoTrkEnDiff","hRecoTrkEnDiff",
00388                                 200000,-100,100);
00389   hRecoTrkEnDiff->SetTitle("Reconstructed Trk Energy Difference (GeV)");
00390   hRecoTrkEnDiff->GetXaxis()->
00391     SetTitle("Reconstructed Trk Energy Difference (GeV)");
00392   hRecoTrkEnDiff->GetXaxis()->CenterTitle();
00393   hRecoTrkEnDiff->GetYaxis()->SetTitle("");
00394   hRecoTrkEnDiff->GetYaxis()->CenterTitle();
00395   hRecoTrkEnDiff->SetFillColor(0);
00396   hRecoTrkEnDiff->SetLineColor(1);
00397   //hRecoTrkEnDiff->SetBit(TH1::kCanRebin);
00398 
00399   TH1F* hRecoTrkEnDiffCurv=new TH1F("hRecoTrkEnDiffCurv","hRecoTrkEnDiffCurv",
00400                                     200000,-100,100);
00401   hRecoTrkEnDiffCurv->SetTitle("Reconstructed Trk Energy Difference (GeV)");
00402   hRecoTrkEnDiffCurv->GetXaxis()->
00403     SetTitle("Reconstructed Trk Energy Difference (GeV)");
00404   hRecoTrkEnDiffCurv->GetXaxis()->CenterTitle();
00405   hRecoTrkEnDiffCurv->GetYaxis()->SetTitle("");
00406   hRecoTrkEnDiffCurv->GetYaxis()->CenterTitle();
00407   hRecoTrkEnDiffCurv->SetFillColor(0);
00408   hRecoTrkEnDiffCurv->SetLineColor(1);
00409   //hRecoTrkEnDiffCurv->SetBit(TH1::kCanRebin);
00410 
00411   TH1F* hRecoTrkEnDiffRange=new TH1F("hRecoTrkEnDiffRange","hRecoTrkEnDiffRange",
00412                                      200000,-100,100);
00413   hRecoTrkEnDiffRange->SetTitle("Reconstructed Trk Energy Difference (GeV)");
00414   hRecoTrkEnDiffRange->GetXaxis()->
00415     SetTitle("Reconstructed Trk Energy Difference (GeV)");
00416   hRecoTrkEnDiffRange->GetXaxis()->CenterTitle();
00417   hRecoTrkEnDiffRange->GetYaxis()->SetTitle("");
00418   hRecoTrkEnDiffRange->GetYaxis()->CenterTitle();
00419   hRecoTrkEnDiffRange->SetFillColor(0);
00420   hRecoTrkEnDiffRange->SetLineColor(1);
00421   //hRecoTrkEnDiffRange->SetBit(TH1::kCanRebin);
00422 
00423 
00424 
00425 
00426   TH1F* hRecoShwEnDiff=new TH1F("hRecoShwEnDiff","hRecoShwEnDiff",
00427                                 200000,-100,100);
00428   hRecoShwEnDiff->SetTitle("Reconstructed Shw Energy Difference (GeV)");
00429   hRecoShwEnDiff->GetXaxis()->
00430     SetTitle("Reconstructed Shw Energy Difference (GeV)");
00431   hRecoShwEnDiff->GetXaxis()->CenterTitle();
00432   hRecoShwEnDiff->GetYaxis()->SetTitle("");
00433   hRecoShwEnDiff->GetYaxis()->CenterTitle();
00434   hRecoShwEnDiff->SetFillColor(0);
00435   hRecoShwEnDiff->SetLineColor(1);
00436   //hRecoShwEnDiff->SetBit(TH1::kCanRebin);
00437 
00438   TH1F* hRecoShwEnDiffCurv=new TH1F("hRecoShwEnDiffCurv","hRecoShwEnDiffCurv",
00439                                     200000,-100,100);
00440   hRecoShwEnDiffCurv->SetTitle("Reconstructed Shw Energy Difference (GeV)");
00441   hRecoShwEnDiffCurv->GetXaxis()->
00442     SetTitle("Reconstructed Shw Energy Difference (GeV)");
00443   hRecoShwEnDiffCurv->GetXaxis()->CenterTitle();
00444   hRecoShwEnDiffCurv->GetYaxis()->SetTitle("");
00445   hRecoShwEnDiffCurv->GetYaxis()->CenterTitle();
00446   hRecoShwEnDiffCurv->SetFillColor(0);
00447   hRecoShwEnDiffCurv->SetLineColor(1);
00448   //hRecoShwEnDiffCurv->SetBit(TH1::kCanRebin);
00449 
00450   TH1F* hRecoShwEnDiffRange=new TH1F("hRecoShwEnDiffRange","hRecoShwEnDiffRange",
00451                                      200000,-100,100);
00452   hRecoShwEnDiffRange->SetTitle("Reconstructed Shw Energy Difference (GeV)");
00453   hRecoShwEnDiffRange->GetXaxis()->
00454     SetTitle("Reconstructed Shw Energy Difference (GeV)");
00455   hRecoShwEnDiffRange->GetXaxis()->CenterTitle();
00456   hRecoShwEnDiffRange->GetYaxis()->SetTitle("");
00457   hRecoShwEnDiffRange->GetYaxis()->CenterTitle();
00458   hRecoShwEnDiffRange->SetFillColor(0);
00459   hRecoShwEnDiffRange->SetLineColor(1);
00460   //hRecoShwEnDiffRange->SetBit(TH1::kCanRebin);
00461 
00462 
00463 
00464 
00465   TH1F* hRecoEnOfDiff=new TH1F("hRecoEnOfDiff","hRecoEnOfDiff",
00466                                400,-100,100);
00467   hRecoEnOfDiff->SetTitle("Reconstructed Energy (GeV)");
00468   hRecoEnOfDiff->GetXaxis()->
00469     SetTitle("Reconstructed Energy (GeV)");
00470   hRecoEnOfDiff->GetXaxis()->CenterTitle();
00471   hRecoEnOfDiff->GetYaxis()->SetTitle("");
00472   hRecoEnOfDiff->GetYaxis()->CenterTitle();
00473   hRecoEnOfDiff->SetFillColor(0);
00474   hRecoEnOfDiff->SetLineColor(1);
00475   //hRecoEnOfDiff->SetBit(TH1::kCanRebin);
00476 
00477   TH1F* hRecoTrkEnOfDiff=new TH1F("hRecoTrkEnOfDiff","hRecoTrkEnOfDiff",
00478                                   400,-100,100);
00479   hRecoTrkEnOfDiff->SetTitle("Reconstructed Trk Energy (GeV)");
00480   hRecoTrkEnOfDiff->GetXaxis()->
00481     SetTitle("Reconstructed Trk Energy (GeV)");
00482   hRecoTrkEnOfDiff->GetXaxis()->CenterTitle();
00483   hRecoTrkEnOfDiff->GetYaxis()->SetTitle("");
00484   hRecoTrkEnOfDiff->GetYaxis()->CenterTitle();
00485   hRecoTrkEnOfDiff->SetFillColor(0);
00486   hRecoTrkEnOfDiff->SetLineColor(1);
00487   //hRecoTrkEnOfDiff->SetBit(TH1::kCanRebin);
00488 
00489   TH1F* hRecoShwEnOfDiff=new TH1F("hRecoShwEnOfDiff","hRecoShwEnOfDiff",
00490                                   400,-100,100);
00491   hRecoShwEnOfDiff->SetTitle("Reconstructed Shw Energy (GeV)");
00492   hRecoShwEnOfDiff->GetXaxis()->
00493     SetTitle("Reconstructed Shw Energy (GeV)");
00494   hRecoShwEnOfDiff->GetXaxis()->CenterTitle();
00495   hRecoShwEnOfDiff->GetYaxis()->SetTitle("");
00496   hRecoShwEnOfDiff->GetYaxis()->CenterTitle();
00497   hRecoShwEnOfDiff->SetFillColor(0);
00498   hRecoShwEnOfDiff->SetLineColor(1);
00499   //hRecoShwEnOfDiff->SetBit(TH1::kCanRebin);
00500 
00501   //version to do reco/cuts with
00502   NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kCC0250Std;
00503 
00504   input.ResetNuEventLoopPositionToStart();
00505 
00506   cout<<endl
00507       <<"************************************************"<<endl
00508       <<"***      Starting main loop over snarls      ***"<<endl
00509       <<"************************************************"<<endl;
00510 
00511   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
00512     cnt.evtCounter++;
00513 
00514     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
00515 
00516     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
00517 
00518     //OVERRIDE
00519     nu.releaseType=8240;
00520     //set the analysis version (could be kFullDST)
00521     nu.anaVersion=this->SanityCheckedAnaVersion
00522       (nu.anaVersion,overrideAnaVersion);
00523 
00524     //RE-RECONSTRUCT the neutrino energy
00525     reco.GetEvtEnergy(nu, false);
00526     reco.ApplyReweights(nu);
00527 
00528     //make all the std cuts
00529     if (!this->IsGoodStdCuts(plots,nu)) continue;
00530 
00531     if (nu.charge==-1) {
00532       plots->PrintEventInfo(nmTxt,nu);
00533       cnt.nuNQCounter++;
00534     }
00535     else if (nu.charge==+1) {
00536       plots->PrintEventInfo(nmbTxt,nu);
00537       cnt.nuPQCounter++;
00538     }
00539     else cout<<"ahhh, bad charge (1)"<<endl;
00540 
00541     Float_t energyDiff=-999;
00542 
00543     Bool_t printToScreen=false;
00544     const NuEvent* pnu=0;
00545     if (printToScreen) pnu=this->GetEvent(nu);
00546 
00547     if (printToScreen && pnu && nu.charge==-1) {
00548       const NuEvent& nui=*pnu;
00549 
00550       static NuReco reco;
00551       reco.GetShowerEnergyCC(nu);
00552 
00553       energyDiff=nu.energy-nui.energy;
00554       Float_t rangeCurvDiff=nu.trkEnRange-nu.trkEnCurv;
00555 
00556       if (TMath::Abs(energyDiff)>0.005*(Munits::GeV)) {
00557         MAXMSG("NuDSTAna",Msg::kInfo,500)
00558           <<endl<<"************************"<<endl
00559           <<endl<<"************************"<<endl
00560           <<endl<<"************************"<<endl
00561           <<endl<<"************************"<<endl
00562           <<endl<<"************************"<<endl
00563           <<endl<<"************************"<<endl
00564           <<endl<<"************************"<<endl
00565           <<endl<<"************************"<<endl
00566           <<endl<<"************************"<<endl
00567           <<endl<<"************************"<<endl
00568           <<endl<<"************************"<<endl
00569           <<endl<<"************************"<<endl
00570           <<endl<<"************************"<<endl
00571           <<"run="<<nu.run<<", snarl="<<nu.snarl<<", evt="<<nu.evt
00572           <<endl
00573           <<"My energy="<<nu.energy<<", CC std energy="<<nui.energy
00574           <<", Ediff="<<energyDiff
00575           <<endl
00576           <<"shwEn="<<nu.shwEn
00577           <<", shwEnCor="<<nu.shwEnCor
00578           <<", shwEnNoCor="<<nu.shwEnNoCor
00579           <<", primshw="<<nu.primshw
00580           <<", nshw="<<nu.nshw
00581           <<endl
00582           <<"shwEnNoCor1="<<nu.shwEnNoCor1
00583           <<", shwEnNoCor2="<<nu.shwEnNoCor2
00584           <<", shwEnNOCor3="<<nu.shwEnNoCor3
00585           <<", shwEnNoCor4="<<nu.shwEnNoCor4
00586           <<endl
00587           <<"shower1 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor1,CandShowerHandle::kCC,nu)
00588           <<" : x,y,z="<<nu.xShwVtx1
00589           <<","<<nu.yShwVtx1
00590           <<","<<nu.zShwVtx1
00591           <<endl
00592           <<"shower2 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor2,CandShowerHandle::kCC,nu)
00593           <<" : x,y,z="<<nu.xShwVtx2
00594           <<","<<nu.yShwVtx2
00595           <<","<<nu.zShwVtx2
00596           <<endl
00597           <<"shower3 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor3,CandShowerHandle::kCC,nu)
00598           <<" : x,y,z="<<nu.xShwVtx3
00599           <<","<<nu.yShwVtx3
00600           <<","<<nu.zShwVtx3
00601           <<endl
00602           <<"shower4 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor4,CandShowerHandle::kCC,nu)
00603           <<" : x,y,z="<<nu.xShwVtx4
00604           <<","<<nu.yShwVtx4
00605           <<","<<nu.zShwVtx4
00606           <<endl
00607           <<"track  x,y,z="<<nu.xTrkVtx
00608           <<","<<nu.yTrkVtx
00609           <<","<<nu.zTrkVtx
00610           <<endl
00611           <<"trkEnRange="<<nu.trkEnRange
00612           <<", trkEnCurv="<<nu.trkEnCurv
00613           <<", rng-crv="<<rangeCurvDiff
00614           <<endl
00615           <<"trkEnCorRange1="<<nu.trkEnCorRange1
00616           <<", trkEnCorRange2="<<nu.trkEnCorRange2
00617           <<", trkEnCorRange3="<<nu.trkEnCorRange3
00618           <<endl
00619           <<"trkEnCorCurv1="<<nu.trkEnCorCurv1
00620           <<", trkEnCorCurv2="<<nu.trkEnCorCurv2
00621           <<", trkEnCorCurv3="<<nu.trkEnCorCurv3
00622           <<endl;
00623       }
00624     }
00625 
00626     if (printToScreen && ((!pnu && nu.charge==-1) || nu.energy>200)) {
00627       Float_t p=-1;
00628       if (nu.qp) p=1./nu.qp;
00629 
00630       MAXMSG("NuDSTAna",Msg::kInfo,500)
00631         <<endl<<"************************"<<endl
00632         <<"run="<<nu.run<<", snarl="<<nu.snarl<<", evt="<<nu.evt
00633         <<", entry="<<nu.entry
00634         <<endl
00635         <<"My energy="<<nu.energy<<", trkEn="<<nu.trkEn
00636         <<", shwEn="<<nu.shwEn
00637         <<endl
00638         <<"shwEnCor="<<nu.shwEnCor
00639         <<", shwEnNoCor="<<nu.shwEnNoCor
00640         <<", primshw="<<nu.primshw
00641         <<", nshw="<<nu.nshw
00642         <<", ntrk="<<nu.ntrk<<", nevt="<<nu.nevt
00643         <<endl
00644         <<"shwEnNoCor1="<<nu.shwEnNoCor1
00645         <<", shwEnNoCor2="<<nu.shwEnNoCor2
00646         <<", shwEnNOCor3="<<nu.shwEnNoCor3
00647         <<", shwEnNoCor4="<<nu.shwEnNoCor4
00648         <<endl
00649         <<"shower1 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor1,CandShowerHandle::kCC,nu)
00650         <<" : x,y,z="<<nu.xShwVtx1
00651         <<","<<nu.yShwVtx1
00652         <<","<<nu.zShwVtx1
00653         <<endl
00654         <<"shower2 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor2,CandShowerHandle::kCC,nu)
00655         <<" : x,y,z="<<nu.xShwVtx2
00656         <<","<<nu.yShwVtx2
00657         <<","<<nu.zShwVtx2
00658         <<endl
00659         <<"shower3 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor3,CandShowerHandle::kCC,nu)
00660         <<" : x,y,z="<<nu.xShwVtx3
00661         <<","<<nu.yShwVtx3
00662         <<","<<nu.zShwVtx3
00663         <<endl
00664         <<"shower4 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor4,CandShowerHandle::kCC,nu)
00665         <<" : x,y,z="<<nu.xShwVtx4
00666         <<","<<nu.yShwVtx4
00667         <<","<<nu.zShwVtx4
00668         <<endl
00669         <<"track  x,y,z="<<nu.xTrkVtx
00670         <<","<<nu.yTrkVtx
00671         <<","<<nu.zTrkVtx
00672         <<endl
00673         <<"trkEnRange="<<nu.trkEnRange
00674         <<", trkEnCurv="<<nu.trkEnCurv
00675         <<", fitpass="<<nu.trkfitpass
00676         <<endl
00677         <<"rangeNoCor="<<nu.trkMomentumRange
00678         <<", curvNoCor="<<p
00679         <<endl
00680         <<"trkEnCorRange1="<<nu.trkEnCorRange1
00681         <<", trkEnCorRange2="<<nu.trkEnCorRange2
00682         <<", trkEnCorRange3="<<nu.trkEnCorRange3
00683         <<endl
00684         <<"trkEnCorCurv1="<<nu.trkEnCorCurv1
00685         <<", trkEnCorCurv2="<<nu.trkEnCorCurv2
00686         <<", trkEnCorCurv3="<<nu.trkEnCorCurv3
00687         <<endl
00688         <<"nshw="<<nu.nshw
00689         <<", rawPhEvt="<<nu.rawPhEvt
00690         <<", planeEvtHdrBeg="<<nu.planeEvtHdrBeg
00691         <<", planeEvtHdrEnd="<<nu.planeEvtHdrEnd
00692         <<endl;
00693 
00694       hRecoEnOfDiff->Fill(nu.energy);
00695       hRecoEnDiff->Fill(nu.energy);
00696       if (nu.containmentFlag==1) hRecoEnDiffRange->Fill(nu.energy);
00697       else if (nu.containmentFlag==2) hRecoEnDiffCurv->Fill(nu.energy);
00698       else cout<<"Ahhhhh"<<endl;
00699     }
00700 
00701     //if (pnu) continue;
00702     //if (energyDiff==-999) continue;
00703     //if (TMath::Abs(energyDiff)<0.005) continue;
00704 
00705     //make the final plots
00706     this->MakeFinalPlots(plots,nu);
00707 
00708     MAXMSG("NuDSTAna",Msg::kInfo,5)
00709       <<"Passed: index="<<nu.index
00710       <<", energy="<<nu.energy<<", energyMC="<<nu.energyMC<<endl;
00711   }//end of loop over summary tree
00712 
00713   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
00714 
00718 
00719   //print out the numbers of events
00720   cnt.PrintMicroDST();
00721 
00722   MSG("NuAnalysis",Msg::kInfo)
00723     <<" ** Finished StdAna method **"<<endl;
00724 }

void NuDSTAna::FluxComponents ( TString  xmlFileName  ) 

Definition at line 6704 of file NuDSTAna.cxx.

References NuXMLConfig::AnaVersion(), NuXMLConfig::AnaVersionString(), NuReco::ApplyReweights(), NuXMLConfig::BinningScheme(), NuLibrary::cnt, NuXMLConfig::ConfigureWeights(), DoIO(), DoSystematicShifts(), NuCounter::evtCounter, NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, SimFlag::kMC, MSG, NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), and SanityCheckedAnaVersion().

06705 {
06706   NuInputEvents& input=this->DoIO(0,"","null");
06707 
06708   //get an instance of the code library
06709   NuLibrary& lib = NuLibrary::Instance();
06710 
06711 
06712   //Get the NuXMLConfig object for configuration.
06713   NuXMLConfig* xmlConfig = 0;
06714   if (xmlFileName.IsNull()) {
06715     xmlConfig = new NuXMLConfig();
06716     xmlConfig->Write();
06717   }
06718   else {
06719     xmlConfig = new NuXMLConfig(xmlFileName);
06720     xmlConfig->Write();
06721   }
06722 
06723   // Selection
06724   NuCuts::NuAnaVersion_t overrideAnaVersion =
06725     static_cast<NuCuts::NuAnaVersion_t>(xmlConfig->AnaVersion());
06726   NuCutter cutter(xmlConfig->AnaVersionString());
06727 
06728   // Binning scheme
06729   const NuUtilities cuts;
06730   NuBinningScheme::NuBinningScheme_t binningScheme =
06731     static_cast<NuBinningScheme::NuBinningScheme_t>(xmlConfig->BinningScheme());
06732   std::vector<Double_t> vReco = cuts.RecoBins(binningScheme);
06733   int numRecoBins = vReco.size() - 1;
06734 
06735 
06736   TH1::AddDirectory(true);
06737   TString names[] = {"hTotal", "hUpPi", "hUpK", "hDecayPipe"};
06738   TString titles[] = {"Total", "Upstream Pions", "Upstream Kaons", "Decay Pipe"};
06739 
06740 
06741   TH1D *hPQ[5];
06742   TH1D *hNQ[5];
06743   TH1D *hVzPQ[5];
06744   TH1D *hVzNQ[5];
06745 
06746   for (int i = 0; i < 4; i++) {
06747     hPQ[i]   = new TH1D(names[i],        titles[i],          numRecoBins, &(vReco[0]));
06748     hNQ[i]   = new TH1D(names[i]+"NQ",   titles[i]+" NQ",    numRecoBins, &(vReco[0]));
06749     hVzPQ[i] = new TH1D(names[i]+"Vz",   titles[i]+" Vz",    500,0,800);
06750     hVzNQ[i] = new TH1D(names[i]+"VzNQ", titles[i]+" Vz NQ", 500,0,800);
06751   }
06752 
06756 
06757   input.ResetNuEventLoopPositionToStart();
06758 
06759   cout<<endl
06760       <<"************************************************"<<endl
06761       <<"***      Starting main loop over snarls      ***"<<endl
06762       <<"************************************************"<<endl;
06763   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
06764     //for (Int_t i=0;i<0;++i) {
06765     lib.cnt.evtCounter++;
06766 
06767     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
06768 
06769     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
06770 
06771     nu.anaVersion=this->SanityCheckedAnaVersion
06772       (nu.anaVersion,overrideAnaVersion);
06773 
06774     // Configure reweighting based on the XML file
06775     xmlConfig->ConfigureWeights(nu);
06776 
06777     //RE-RECONSTRUCT the neutrino energy
06778     lib.reco.GetEvtEnergy(nu, false);
06779     lib.reco.ApplyReweights(nu);
06780 
06781     this->DoSystematicShifts(nu,xmlConfig);
06782 
06783     cutter.MakeCuts(nu);
06784     if (cutter.Failed()) continue;
06785 
06786     int plotNo = 0;
06787 
06788     if (nu.simFlag == SimFlag::kMC) {
06789       bool isDP = nu.ppvz > 4500;
06790 
06791       int type = nu.ptype;
06792       if (type == -1) {
06793         cout << "Using old files.  Bailing now." << endl;
06794         assert(false);
06795       }
06796       if (type == -13 || type == 13) {
06797         type = nu.tptype;
06798         isDP = false;
06799       }
06800 
06801 
06802       if (isDP) {// Decay Pipe
06803         plotNo = 3;
06804       }
06805       else if (type == -311 || type == 311 ||
06806                type == -321 || type == 321 ||
06807                type == 130  || type == 310) {// Kaons
06808         plotNo = 2;
06809       }
06810       else {// Pions
06811         plotNo = 1;
06812       }
06813 
06814       if (nu.charge == 1) {
06815         hPQ[plotNo]->Fill(nu.energy, nu.rw);
06816         if (nu.Vz > -900) hVzPQ[plotNo]->Fill(nu.Vz/100., nu.rw);
06817       }
06818       else {
06819         hNQ[plotNo]->Fill(nu.energy, nu.rw);
06820         if (nu.Vz > -900) hVzNQ[plotNo]->Fill(nu.Vz/100., nu.rw);
06821       }
06822     }
06823     if (nu.charge == 1) {
06824       hPQ[0]->Fill(nu.energy, nu.rw);
06825       if (nu.Vz > -900) hVzPQ[0]->Fill(nu.Vz/100., nu.rw);
06826     }
06827     else {
06828       hNQ[0]->Fill(nu.energy, nu.rw);
06829       if (nu.Vz > -900) hVzNQ[0]->Fill(nu.Vz/100., nu.rw);
06830     }
06831   }
06832   cout<<endl;
06833 
06834   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06835 
06836   cutter.PrintSummary();
06837 
06841 
06842   //print out the numbers of events
06843   lib.cnt.PrintMicroDST();
06844 
06845   MSG("NuAnalysis",Msg::kInfo)
06846     <<" ** Finished NewFieldAna method **"<<endl;
06847 }

const NuEvent * NuDSTAna::GetEvent ( const NuEvent nu  )  [protected]

Definition at line 854 of file NuDSTAna.cxx.

References NuEvent::energy, NuEvent::evt, it, run(), NuEvent::run, and NuEvent::snarl.

Referenced by FDTestAna().

00855 {
00856   static map<Int_t,map<Int_t,NuEvent> > mymap;
00857   static Bool_t firstTime=true;
00858 
00859   //check if file exists
00860   if (firstTime){
00861     firstTime=false;
00862 
00863     string sFileName="fdlist-allevents.txt";
00864 
00865     //open the file
00866     cout<<"Opening file "<<sFileName<<"..."<<endl;
00867     ifstream file(sFileName.c_str());
00868 
00869     if (file){
00870       cout<<"File exists"<<endl;
00871       //variables to hold input from file
00872       Int_t index=-1;
00873       Int_t run=-1;
00874       Int_t snarl=-1;
00875       Int_t evt=-1;
00876       Float_t energy=-1;
00877 
00878 
00879       string s;
00880       Int_t counter=0;
00881 
00882       //read in from the text file, have to deal with all the *'s
00883       while (file>>s>>index>>s>>run>>s>>snarl>>s>>evt>>s>>energy>>s) {
00884         //cout<<"index="<<index<<", run="<<run<<", snarl="<<snarl
00885         //  <<", evt="<<evt<<", energy="<<energy<<endl;
00886 
00887         NuEvent& nui=*new NuEvent();
00888         nui.run=run;
00889         nui.snarl=snarl;
00890         nui.evt=evt;
00891         nui.energy=energy;
00892 
00893         mymap[run][snarl]=nui;
00894 
00895         counter++;
00896       }
00897       cout<<"Total events found in txt file="<<counter<<endl;
00898     }
00899     else cout<<"No file"<<endl;
00900 
00901     Int_t counter=0;
00902     for (map<Int_t,map<Int_t,NuEvent> >::iterator it=mymap.begin();
00903          it!=mymap.end();++it) {
00904 
00905       for (map<Int_t,NuEvent>::iterator it2=it->second.begin();
00906            it2!=it->second.end();++it2) {
00907         //NuEvent& n=it2->second;
00908         //cout<<"run="<<n.run<<", snarl="<<n.snarl<<", energy="<<n.energy
00909         //<<endl;
00910         counter++;
00911       }
00912     }
00913     cout<<"Total events in map="<<counter<<endl;
00914   }
00915 
00916   //look up the run and snarl in the map
00917   //return the NuEvent if found
00918   map<Int_t,map<Int_t,NuEvent> >::iterator it=mymap.find(nu.run);
00919   if (it==mymap.end()) {
00920     cout<<"No such run in map="<<nu.run<<endl;
00921     return NULL;
00922   }
00923   else {
00924     map<Int_t,NuEvent>::iterator it2=it->second.find(nu.snarl);
00925     if (it2==it->second.end()) {
00926       cout<<"No such snarl in map for run="<<nu.run
00927           <<", snarl="<<nu.snarl<<endl;
00928       return NULL;
00929     }
00930     else return &(it2->second);
00931   }
00932 }

const NuEvent * NuDSTAna::GetEventND ( const NuEvent nu  )  [protected]

Definition at line 728 of file NuDSTAna.cxx.

References NuEvent::abID, NuEvent::energy, NuEvent::evt, it, Msg::kInfo, MAXMSG, n, run(), NuEvent::run, NuEvent::shwEn, NuEvent::snarl, and NuEvent::trkEn.

Referenced by NDTestAna().

00729 {
00730   static map<Int_t,map<Int_t,map<Int_t,NuEvent> > > mymap;
00731   static Bool_t firstTime=true;
00732 
00733   //check if file exists
00734   if (firstTime){
00735     firstTime=false;
00736 
00737     //string sFileName="fdlist-allevents.txt";
00738     //string sFileName="eventsFDDataTrish-sorted.txt";
00739     string sFileName="eventsNDDataTrish-sorted.txt";
00740 
00741     //open the file
00742     cout<<"Opening file "<<sFileName<<"..."<<endl;
00743     ifstream file(sFileName.c_str());
00744 
00745     if (file){
00746       cout<<"File exists..."<<endl;
00747       //variables to hold input from file
00748       //Int_t index=-1;
00749       Int_t run=-1;
00750       Int_t subrun=-1;
00751       Int_t snarl=-1;
00752       Int_t evt=-1;
00753       Float_t energy=-1;
00754       Float_t trkEn=-1;
00755       Float_t shwEn=-1;
00756       Float_t abID=-1;
00757 
00758 
00759       string s;
00760       Int_t counter=0;
00761 
00762       //read in from the text file, have to deal with all the *'s
00763       while (file>>run>>subrun>>snarl>>evt
00764              >>energy>>trkEn>>shwEn>>abID) {
00765         MAXMSG("NuDSTAna",Msg::kInfo,100)
00766           <<"run="<<run<<", snarl="<<snarl<<", evt="<<evt
00767           <<", energy="<<energy<<", trkEn="<<trkEn
00768           <<", shwEn="<<shwEn<<", abID="<<abID<<endl;
00769 
00770         if (run<9200 || run>9300) continue;
00771 
00772         NuEvent& nui=*new NuEvent();
00773         nui.run=run;
00774         nui.snarl=snarl;
00775         nui.evt=evt;
00776         nui.energy=energy;
00777         nui.trkEn=trkEn;
00778         nui.shwEn=shwEn;
00779         nui.abID=abID;
00780 
00781         mymap[run][snarl][evt]=nui;
00782 
00783         counter++;
00784       }
00785       cout<<"Total events found in txt file="<<counter<<endl;
00786     }
00787     else cout<<"No file"<<endl;
00788 
00789     Int_t counter=0;
00790     for (map<Int_t,map<Int_t,map<Int_t,NuEvent> > >::iterator it=
00791            mymap.begin();
00792          it!=mymap.end();++it) {
00793 
00794       for (map<Int_t,map<Int_t,NuEvent> >::iterator it2=
00795              it->second.begin();
00796            it2!=it->second.end();++it2) {
00797 
00798         for (map<Int_t,NuEvent>::iterator it3=it2->second.begin();
00799              it3!=it2->second.end();++it3) {
00800 
00801           NuEvent& n=it3->second;
00802           MAXMSG("NuDSTAna",Msg::kInfo,100)
00803             <<"Map: run="<<n.run<<", snarl="<<n.snarl<<", evt="<<n.evt
00804             <<", energy="<<n.energy<<endl;
00805 
00806           if (n.run==9259) {
00807             if (n.snarl<56595) {//140344
00808               MAXMSG("NuDSTAna",Msg::kInfo,100)
00809                 <<"Map: run="<<n.run
00810                 <<", snarl="<<n.snarl<<", evt="<<n.evt
00811                 <<", energy="<<n.energy<<endl;
00812               counter++;
00813             }
00814           }
00815 
00816         }
00817       }
00818     }
00819     cout<<"Total events in map="<<counter<<endl;
00820   }
00821 
00822   //look up the run and snarl in the map
00823   //return the NuEvent if found
00824   map<Int_t,map<Int_t,map<Int_t,NuEvent> > >::iterator it=
00825     mymap.find(nu.run);
00826   if (it==mymap.end()) {
00827     cout<<"No such run in map="<<nu.run<<endl;
00828     return NULL;
00829   }
00830   else {
00831     map<Int_t,map<Int_t,NuEvent> >::iterator it2=
00832       it->second.find(nu.snarl);
00833     if (it2==it->second.end()) {
00834       cout<<"No such snarl in map for run="<<nu.run
00835           <<", snarl="<<nu.snarl<<endl;
00836       return NULL;
00837     }
00838     else {
00839       map<Int_t,NuEvent>::iterator it3=it2->second.find(nu.evt);
00840       if (it3==it2->second.end()) {
00841         cout<<"No such evt in map for run="<<nu.run
00842             <<", snarl="<<nu.snarl<<", evt="<<nu.evt<<endl;
00843         return NULL;
00844       }
00845       else {
00846         return &(it3->second);
00847       }
00848     }
00849   }
00850 }

NuConfig NuDSTAna::GetNuConfig ( const NuEvent nu  )  const [protected]

Definition at line 3136 of file NuDSTAna.cxx.

References NuEvent::anaVersion, NuConfig::anaVersion, NuEvent::beamType, NuConfig::beamType, NuEvent::cutOnBeamInfo, NuConfig::cutOnBeamInfo, NuConfig::cutOnDataQuality, NuEvent::cutOnDataQuality, NuConfig::cutOnSpillTiming, NuEvent::cutOnSpillTiming, NuEvent::detector, NuConfig::detector, NuEvent::intensity, NuConfig::intensity, NuConfig::mcVersion, NuEvent::mcVersion, NuConfig::recoVersion, NuEvent::recoVersion, NuConfig::releaseType, NuEvent::releaseType, NuEvent::reweightVersion, NuConfig::reweightVersion, NuConfig::run, NuEvent::run, NuConfig::runPeriod, NuEvent::runPeriod, NuEvent::simFlag, NuConfig::simFlag, NuConfig::subRun, NuEvent::subRun, NuEvent::useDBForBeamInfo, NuConfig::useDBForBeamInfo, NuEvent::useDBForDataQuality, NuConfig::useDBForDataQuality, NuConfig::useDBForSpillTiming, NuEvent::useDBForSpillTiming, NuEvent::useGeneratorReweight, and NuConfig::useGeneratorReweight.

Referenced by DoIO().

03137 {
03138   //create a config object
03139   NuConfig config;
03140 
03141   //copy all the info across
03142   config.run=nu.run;
03143   config.subRun = nu.subRun;
03144   config.detector=nu.detector;
03145   config.simFlag=nu.simFlag;
03146 
03147   config.runPeriod=nu.runPeriod;
03148   config.intensity = (Int_t) nu.intensity;
03149 
03150   config.anaVersion=nu.anaVersion;
03151   config.useGeneratorReweight=nu.useGeneratorReweight;
03152   config.reweightVersion=nu.reweightVersion;
03153   config.mcVersion=nu.mcVersion;
03154   config.recoVersion=nu.recoVersion;
03155   config.releaseType=nu.releaseType;
03156   config.beamType=nu.beamType;
03157   config.useDBForDataQuality=nu.useDBForDataQuality;
03158   config.useDBForSpillTiming=nu.useDBForSpillTiming;
03159   config.useDBForBeamInfo=nu.useDBForBeamInfo;
03160   config.cutOnDataQuality=nu.cutOnDataQuality;
03161   config.cutOnSpillTiming=nu.cutOnSpillTiming;
03162   config.cutOnBeamInfo=nu.cutOnBeamInfo;
03163 
03164   return config;
03165 }

Bool_t NuDSTAna::IsGoodPreSelectionCuts ( const NuPlots plots,
const NuEvent nu 
) const [protected]

Definition at line 5626 of file NuDSTAna.cxx.

References NuEvent::anaVersion, and NuCut::MakePreselectionCuts().

Referenced by BRevAna(), MakeMicroDstFakeData(), MakeMicroDstForCSSSystematics(), MakeMicroDstHe(), MakeMicroDstJJEPresel(), MakeMicroDstWithStdCCRecoAndCuts(), MakeSelMicroDST(), NDQPRB(), QPStudy(), SelectorTable(), and YStudy().

05628 {
05629   // In order to move over to the new cuts system, the cutting logic
05630   // has been moved. See NuCutsSelection.cxx for the implementation of
05631   // this function
05632   NuCutImps::NuCutsSelection cut(nu.anaVersion, plots);
05633   return cut.MakePreselectionCuts(nu);
05634 }

Bool_t NuDSTAna::IsGoodStdCuts ( const NuPlots plots,
const NuEvent nu 
) const [protected]

Definition at line 5638 of file NuDSTAna.cxx.

References NuEvent::anaVersion, and NuCut::MakeCuts().

Referenced by BRevAna(), FDTestAna(), JeffsTestAna(), MakeSelMicroDST(), MMTransition(), NDOsc(), NDTestAna(), NewFieldAna(), RHCTest(), StdCCAna(), and VsTime().

05640 {
05641   // In order to move over to the new cuts system, the cutting logic
05642   // has been moved. See NuCutsSelection.cxx for the implementation of
05643   // this function
05644   NuCutImps::NuCutsSelection cut(nu.anaVersion, plots);
05645   return cut.MakeCuts(nu);
05646 }

void NuDSTAna::JeffsTestAna (  ) 

Definition at line 5137 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, NuConfig::detector, DoIO(), NuCounter::evtCounter, NuPlots::FillDPIdSigmaQPFailDpIDCutPlots(), NuPlots::FillDPIdSigmaQPFailProbCutPlots(), NuPlots::FillDPIdSigmaQPFailSigQPCutPlots(), NuPlots::FillDPIdSigmaQPPassDpIDCutPlots(), NuPlots::FillDPIdSigmaQPPassSigQPCutPlots(), NuHistos::FillMatrixMethodHistos(), NuPlots::FillTrueFidEnergySpect(), NuPlots::FillTrueFidEnergySpectSpecial(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuCounter::goodFitProbCounter, NuCounter::goodFitSigQPCounter, NuCounter::goodPIDCounter, NuLibrary::hist, NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), NuCuts::IsGoodFitProb(), NuCuts::IsGoodPID(), NuCuts::IsGoodSigmaQP_QP(), IsGoodStdCuts(), NuCuts::IsInCylindricalVolume(), NuCuts::IsInFidVolTrueEvt(), NuCuts::kCC0250Std, Msg::kDebug, Detector::kFar, Msg::kInfo, NuCuts::kNMB0325Bravo, Munits::m, MakeFinalPlots(), MAXMSG, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuBase::OpenTxtFile(), plots(), NuPlots::PrintEventInfo(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), NuConfig::run, and SanityCheckedAnaVersion().

05138 {
05139   NuInputEvents& input=this->DoIO();
05140 
05141   //use config object to store info
05142   NuConfig config;
05143   config.detector=Detector::kFar;
05144   config.run=100;
05145 
05146   //text files to store info for evts passing cuts
05147   string sTxt="nmb";//nubars
05148   ofstream& nmbTxt=*(this->OpenTxtFile(config,sTxt.c_str()));
05149   string sTxtNM="nm";//neutrinos
05150   ofstream& nmTxt=*(this->OpenTxtFile(config,sTxtNM.c_str()));
05151 
05152   //get an instance of the code library
05153   NuLibrary& lib=NuLibrary::Instance();
05154 
05155   //get an object to fill plots
05156   const NuPlots* plots=new NuPlots();
05157 
05158   //version to do reco/cuts with
05159   NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kCC0250Std;
05160 
05164 
05165   input.ResetNuEventLoopPositionToStart();
05166 
05167   cout<<endl
05168       <<"************************************************"<<endl
05169       <<"***      Starting main loop over snarls      ***"<<endl
05170       <<"************************************************"<<endl;
05171 
05172   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
05173     lib.cnt.evtCounter++;
05174 
05175     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
05176 
05177     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
05178 
05179     //OVERRIDE
05180     nu.anaVersion=this->SanityCheckedAnaVersion
05181       (nu.anaVersion,overrideAnaVersion);
05182 
05183     //cut on new 0.8m radius
05184     const Float_t beamzerox=1.4828*(Munits::m);//new for 2.5 analysis
05185     const Float_t beamzeroy=0.2384*(Munits::m);//new for 2.5 analysis
05186     Bool_t inFid=lib.cuts.IsInCylindricalVolume
05187       (nu.xTrkVtx,nu.yTrkVtx,nu.zTrkVtx,beamzerox,beamzeroy,
05188        1*(Munits::m),5*(Munits::m),0.8*(Munits::m));
05189     if (!inFid) continue;
05190 
05191     //RE-RECONSTRUCT the neutrino energy
05192     lib.reco.GetEvtEnergy(nu, false);
05193     lib.reco.ApplyReweights(nu);
05194 
05195     //make all the std cuts
05196     if (!this->IsGoodStdCuts(plots,nu)) continue;
05197 
05198     if (nu.charge==-1) {
05199       plots->PrintEventInfo(nmTxt,nu);
05200       lib.cnt.nuNQCounter++;
05201     }
05202     else if (nu.charge==+1) {
05203       plots->PrintEventInfo(nmbTxt,nu);
05204       lib.cnt.nuPQCounter++;
05205     }
05206     else cout<<"ahhh, bad charge(6)"<<endl;
05207 
05208 
05209 
05210 
05211     //OVERRIDE
05212     nu.anaVersion=NuCuts::kNMB0325Bravo;
05213 
05214 
05215     //cut on the PID
05216     if (!lib.cuts.IsGoodPID(nu)) {
05217       plots->FillDPIdSigmaQPFailDpIDCutPlots(nu);
05218       continue;
05219     }
05220     lib.cnt.goodPIDCounter++;
05221     plots->FillDPIdSigmaQPPassDpIDCutPlots(nu);
05222 
05223     //cut on the fractional track momentum and sign error
05224     if (!lib.cuts.IsGoodSigmaQP_QP(nu)) {
05225       plots->FillDPIdSigmaQPFailSigQPCutPlots(nu);
05226       continue;
05227     }
05228     lib.cnt.goodFitSigQPCounter++;
05229     plots->FillDPIdSigmaQPPassSigQPCutPlots(nu);
05230 
05231     //cut on the track fit probability
05232     if (!lib.cuts.IsGoodFitProb(nu)) {
05233       plots->FillDPIdSigmaQPFailProbCutPlots(nu);
05234       continue;
05235     }
05236     lib.cnt.goodFitProbCounter++;
05237 
05238 
05239 
05240 
05241 
05242 
05243     //make the final plots
05244     this->MakeFinalPlots(plots,nu);
05245 
05246     //fill matrix method histos
05247     lib.hist.FillMatrixMethodHistos(nu);
05248 
05249     MAXMSG("NuDSTAna",Msg::kInfo,5)
05250       <<"Passed: index="<<nu.index
05251       <<", energy="<<nu.energy<<", energyMC="<<nu.energyMC<<endl;
05252   }
05253 
05254   //print out the numbers of events
05255   lib.cnt.PrintMicroDST();
05256 
05257 
05258   /*
05259     for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
05260     //for (Int_t i=0;i<0;++i) {
05261     lib.cnt.evtCounter++;
05262 
05263     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
05264 
05265     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
05266 
05267     //speed up cut for looking at nmb only
05268     //if (nu.charge==-1) continue;
05269 
05270     //OVERRIDE
05271     nu.anaVersion=NuCuts::kCC0250Std;
05272     //nu.applyEnergyShifts=false;
05273     //nu.applyBeamWeight=true;
05274     //nu.applyDetectorWeight=false;
05275     //nu.applyGeneratorWeight=false;
05276     //nu.cutOnDataQuality=false;
05277 
05278     nu.anaVersion=NuCuts::kNMB0325Bravo;
05279 
05280     //RE-RECONSTRUCT the neutrino energy
05281     lib.reco.GetEvtEnergy(nu);
05282     lib.reco.ApplyReweights(nu);
05283 
05284     nu.anaVersion=NuCuts::kCC0250Std;
05285 
05286     //Bool_t passFid=lib.cuts.IsInFidVolOffset(nu);
05287     //if (!passFid) continue;
05288     //if (passFid) continue;//for Anti-FV
05289 
05290     //if (nu.ntrk==1) continue;
05291     //if (nu.ntrk>=2) continue;
05292 
05293     //select specific true events
05294     //if (nu.charge==-1) continue;//remove NQ events
05295     //if (nu.inu==-14) continue;//remove the true nubars
05296     //if (nu.iaction==1) continue;//remove the CC events
05297 
05299     //START OF STD CUTS
05301 
05302     //cut on the sntp good beam and that coil is on
05303     if (!lib.cuts.IsGoodBeamDetPOTCountingStage(nu)) continue;
05304     lib.cnt.goodBeamDetPOTCountingStage++;
05305 
05306     //ensure good number of tracks in the event
05307     if (!lib.cuts.IsGoodNumberOfTracks(nu)) continue;
05308     lib.cnt.evtWithTrkCounter++;
05309 
05310     //check if the trk is in the fiducial volume
05311     if (!lib.cuts.IsInFidVolTrk(nu)) continue;
05312     lib.cnt.trkInFidVolCounter++;
05313 
05314     //cut on LI
05315     if (lib.cuts.IsLI(nu)) continue;
05316     lib.cnt.evtNotIsLI++;
05317 
05318     //cut on the data quality
05319     if (!lib.cuts.IsGoodDataQuality(nu)) continue;
05320     lib.cnt.goodDataQualityCounter++;
05321 
05322     //cut on the spill time
05323     plots->FillEvtAndSpillTimingPlots(nu);
05324     if (!lib.cuts.IsGoodTimeToNearestSpill(nu)) continue;
05325     lib.cnt.goodTimeToNearestSpillCounter++;
05326 
05327     //cut on the beam
05328     if (!lib.cuts.IsGoodBeam(nu)) continue;
05329     lib.cnt.goodBeamInfoDBCounter++;
05330 
05331     //require a good trk fit
05332     if (!lib.cuts.IsGoodTrackFitPass(nu)) continue;
05333     lib.cnt.goodTrkPassCounter++;
05334 
05335     //require a forward going neutrino about beam direction
05336     if (!lib.cuts.IsGoodDirCos(nu)) continue;
05337     lib.cnt.goodDirectionCosineCounter++;
05338 
05339     //make the post-preselection plots
05340     this->MakePostPreSelectionPlots(plots,nu);
05341 
05342 
05343     //OVERRIDE
05344     nu.anaVersion=NuCuts::kNMB0325Bravo;
05345 
05349     //Float_t r=pow(nu.xTrkEnd,2)+pow(nu.yTrkEnd,2);
05350     //if (r) r=sqrt(r);
05351     //if (r<0.5) continue;
05352     //if (nu.planeTrkEnd-nu.planeTrkBeg<50) continue;
05353 
05354     //cut on the PID
05355     if (!lib.cuts.IsGoodPID(nu)) {
05356     plots->FillDPIdSigmaQPFailDpIDCutPlots(nu);
05357     continue;
05358     }
05359     lib.cnt.goodPIDCounter++;
05360     plots->FillDPIdSigmaQPPassDpIDCutPlots(nu);
05361 
05362     //cut on the fractional track momentum and sign error
05363     if (!lib.cuts.IsGoodSigmaQP_QP(nu)) {
05364     plots->FillDPIdSigmaQPFailSigQPCutPlots(nu);
05365     continue;
05366     }
05367     lib.cnt.goodFitSigQPCounter++;
05368     plots->FillDPIdSigmaQPPassSigQPCutPlots(nu);
05369 
05370     //cut on the track fit probability
05371     if (!lib.cuts.IsGoodFitProb(nu)) {
05372     plots->FillDPIdSigmaQPFailProbCutPlots(nu);
05373     continue;
05374     }
05375     lib.cnt.goodFitProbCounter++;
05376 
05378     //END OF STD CUTS
05380 
05381     if (nu.charge==-1) {
05382     plots->PrintEventInfo(nmTxt,nu);
05383     lib.cnt.nuNQCounter++;
05384     }
05385     else if (nu.charge==+1) {
05386     plots->PrintEventInfo(nmbTxt,nu);
05387     lib.cnt.nuPQCounter++;
05388     }
05389     else cout<<"ahhh, bad charge"<<endl;
05390 
05391     //make the final plots
05392     this->MakeFinalPlots(plots,nu);
05393 
05394     //fill matrix method histos
05395     lib.hist.FillMatrixMethodHistos(nu);
05396 
05397     MAXMSG("NuDSTAna",Msg::kInfo,5)
05398     <<"Passed: index="<<nu.index
05399     <<", energy="<<nu.energy<<", energyMC="<<nu.energyMC<<endl;
05400     }//end of loop over summary tree
05401   */
05402 
05403 
05407 
05408   input.InitialiseNuMCEventBranch();
05409   input.ResetNuMCEventLoopPositionToStart();
05410 
05411   cout<<endl
05412       <<"************************************************"<<endl
05413       <<"***       Starting loop over truth info      ***"<<endl
05414       <<"************************************************"<<endl;
05415 
05416   //for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
05417   for (Int_t i=0;i<0;++i) {
05418     lib.cnt.evtCounter++;
05419 
05420     this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
05421 
05422     NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
05423                                          (Msg::kDebug));
05424 
05425     //OVERRIDE
05426     mc.anaVersion=this->SanityCheckedAnaVersion
05427       (mc.anaVersion,overrideAnaVersion);
05428 
05429     MAXMSG("NuDSTAna",Msg::kInfo,5)
05430       <<"energyMC="<<mc.energyMC<<endl;
05431 
05432     //make fid vol cut
05433     if (!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
05434 
05435     //fill plots
05436     plots->FillTrueFidEnergySpect(mc);
05437     plots->FillTrueFidEnergySpectSpecial(mc);
05438   }
05439 
05440   MSG("NuAnalysis",Msg::kInfo)
05441     <<" ** Finished JeffsTestAna method **"<<endl;
05442 }

void NuDSTAna::MakeCuts ( TString  selection,
Int_t  charge 
)

Definition at line 10478 of file NuDSTAna.cxx.

References NuLibrary::cnt, DoIO(), NuCounter::evtCounter, NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuOutputWriter::GetNuEventToFill(), NuLibrary::Instance(), Msg::kDebug, NuCutter::MakePreselectionCuts(), NuCutter::MakeSelectionCuts(), NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuCutter::Passed(), plots(), NuBase::PrintLoopProgress(), NuCutter::PrintSummary(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuCutter::ResetStatus(), and UpdatePotSinceLastEvt().

10478                                                       {
10479 
10480   //do the histogram IO
10481   NuOutputWriter* poutput=new NuOutputWriter();
10482   string rootFileName("NuDST_beamfits_"); rootFileName.append(selection.Data()); rootFileName.append("_");
10483   //TString tmp(selection); tmp+=charge;
10484   //string rootFileName("NuDST_ji_"); rootFileName.append(tmp.Data()); rootFileName.append("_");
10485   NuInputEvents& input=this->DoIO(poutput,rootFileName);
10486 
10487   //get a reference
10488   NuOutputWriter& output=(*poutput);
10489 
10490   //get an instance of the code library
10491   NuLibrary& lib = NuLibrary::Instance();
10492 
10493   //interface for the pids, plots
10494   NuPIDInterface pid;
10495   const NuPlots* plots = 0;
10496 
10497   //preselection & selection
10498 
10499   NuCutter preSelectionCutter(selection);
10500   NuCutter selectionCutter(selection);
10501   //prepare for loop
10502   input.ResetNuEventLoopPositionToStart();
10503 
10504   for(int i = 0; i < input.GetEntriesNuEvent(); ++i){
10505     ++lib.cnt.evtCounter;
10506 
10507     PrintLoopProgress(i, input.GetEntriesNuEvent(), 1);
10508 
10509     NuEvent& nu = const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
10510 
10511     //RE-RECONSTRUCT the neutrino energy
10512     lib.reco.GetEvtEnergy(nu, false);//this re-reconstructs the neutrino energy
10513   
10514     //count up the pots
10515     UpdatePotSinceLastEvt(nu, false);
10516 
10517     // Need to reset otherwise previous event failing will fail this one
10518     preSelectionCutter.ResetStatus();
10519     selectionCutter.ResetStatus();
10520     
10521     //PRESELECTION
10522     //make the preselection cuts
10523     preSelectionCutter.MakePreselectionCuts(nu);
10524     // If the event passes preselection then we apply selection
10525     if(!preSelectionCutter.Passed()) continue;
10526     
10527     //selection
10528     //make the selection cuts
10529     selectionCutter.MakeSelectionCuts(nu);
10530     // If the event passes selection then we keep it
10531     if(!selectionCutter.Passed()) continue;
10532     if(nu.charge != charge) continue;
10533     
10534     //figure out the first and last time in the whole ntuple
10535     //this is very useful for making plots of quantities vs time
10536     plots->FillNtupleEarliestLatestTime(nu);
10537 
10538     //count the events to print to screen
10539     if(nu.charge == -1) ++lib.cnt.nuNQCounter;
10540     if(nu.charge == +1) ++lib.cnt.nuPQCounter;
10541 
10542     //copy pots since last event to ntuple for this new evt
10543     UpdatePotSinceLastEvt(nu, true);
10544 
10545     //get the output nu to fill, copy nu to the output nu, fill tree
10546     output.GetNuEventToFill() = nu;
10547     output.FillNuEventTree();
10548   } // end for i
10549 
10550 
10551   preSelectionCutter.PrintSummary();
10552   selectionCutter.PrintSummary();
10553   //close the file and write out everything
10554   output.Finish();
10555 }

void NuDSTAna::MakeDstPQ (  ) 

this function makes a micro DST with just the PQ events

Definition at line 4892 of file NuDSTAna.cxx.

References NuLibrary::cnt, DoIO(), NuCounter::evtCounter, NuOutputWriter::FillNuEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), NuOutputWriter::GetNuEventToFill(), NuLibrary::Instance(), Msg::kDebug, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuInputEvents::ResetNuEventLoopPositionToStart(), and UpdatePotSinceLastEvt().

04893 {
04895 
04896   //do the histogram IO
04897   NuOutputWriter* poutput=new NuOutputWriter();
04898   NuInputEvents& input=this->DoIO(poutput,"NuDSTMicroPQ");
04899 
04900   //get a reference
04901   NuOutputWriter& output=(*poutput);
04902 
04903   //get an instance of the code library
04904   NuLibrary& lib=NuLibrary::Instance();
04905 
04906   input.ResetNuEventLoopPositionToStart();
04907 
04911 
04912   cout<<endl
04913       <<"************************************************"<<endl
04914       <<"***      Starting main loop over snarls      ***"<<endl
04915       <<"************************************************"<<endl;
04916 
04917   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
04918     lib.cnt.evtCounter++;
04919 
04920     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
04921 
04922     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
04923 
04924     //count up the pots
04925     Bool_t newEvt=false;
04926     this->UpdatePotSinceLastEvt(nu,newEvt);
04927 
04928     //speed up cut for looking at nmb only
04929     if (nu.charge==-1) {
04930       lib.cnt.nuNQCounter++;
04931       if (nu.inu < 0) {//need the mis-id ones for eff/pur plots
04932         //keep these
04933       }
04934       else {
04935         continue;
04936       }
04937     }
04938 
04939     if (nu.charge==+1) {
04940       lib.cnt.nuPQCounter++;
04941     }
04942 
04943     //copy pots since last event to ntuple for this new evt
04944     newEvt=true;
04945     this->UpdatePotSinceLastEvt(nu,newEvt);
04946 
04947     //get the output nu to fill, copy across and fill tree
04948     NuEvent& nuOutput=output.GetNuEventToFill();
04949     nuOutput=nu;
04950     output.FillNuEventTree();
04951   }
04952 
04953   //print out the numbers of events
04954   lib.cnt.PrintMicroDST();
04955 
04956   //close the file and write out everything
04957   output.Finish();
04958 }

void NuDSTAna::MakeFCTree ( TString  xmlFileName  ) 

Definition at line 4745 of file NuDSTAna.cxx.

References NuEvent::anaVersion, NuXMLConfig::AnaVersionString(), NuReco::ApplyReweights(), NuEvent::charge, NuLibrary::cnt, NuXMLConfig::ConfigureWeights(), NuFCEvent::detector, DoIO(), NuFCEvent::energy, NuEvent::energy, NuEvent::energyMC, NuCounter::evtCounter, NuFCEvent::Extract(), NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuEvent::index, NuLibrary::Instance(), Msg::kInfo, MAXMSG, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, plots(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuFCEvent::Reset(), NuInputEvents::ResetNuEventLoopPositionToStart(), and SanityCheckedAnaVersion().

04746 {
04747   NuInputEvents& input=this->DoIO(0,"","null");
04748   //get an instance of the code library
04749   NuLibrary& lib=NuLibrary::Instance();
04750   //get an object to fill plots
04751   const NuPlots* plots=0;
04752   //Get the NuXMLConfig object for configuration.
04753   NuXMLConfig* xmlConfig = 0;
04754   if (xmlFileName.IsNull()) {
04755     xmlConfig = new NuXMLConfig();
04756     xmlConfig->Write();
04757   }
04758   else {
04759     xmlConfig = new NuXMLConfig(xmlFileName);
04760     xmlConfig->Write();
04761   }
04762 
04763   NuCutter cutter(xmlConfig->AnaVersionString(), plots);
04764 
04765   //version to do reco/cuts with
04766   NuCuts::NuAnaVersion_t overrideAnaVersion =
04767     static_cast<NuCuts::NuAnaVersion_t>(cutter.AnaVersion());
04768 
04769   TDirectory *save = gDirectory;
04770   gDirectory->pwd();
04771 
04772   const char* type = "FCTree";
04773 
04774   cout << "Create the dummy event" << endl;
04775   NuFCEvent *dummy_nu = new NuFCEvent();
04776   cout << "Create tree type " << type << endl;
04777   TTree *tree = new TTree(type,type);
04778   cout << "Create branch" << endl;
04779   tree->Branch("NuFCEvent","NuFCEvent",&dummy_nu,32000,2);
04780   cout<<"Tree initialized."<<endl;
04781 
04785 
04786   input.ResetNuEventLoopPositionToStart();
04787 
04788   cout<<endl
04789       <<"************************************************"<<endl
04790       <<"***      Starting main loop over snarls      ***"<<endl
04791       <<"************************************************"<<endl;
04792 
04793   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
04794 
04795     lib.cnt.evtCounter++;
04796     //this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
04797 
04798     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kInfo));
04799 
04800     //OVERRIDE
04801     //Selection
04802     nu.anaVersion=this->SanityCheckedAnaVersion
04803       (nu.anaVersion,overrideAnaVersion);
04804 
04805     // Configure reweighting based on the XML file
04806     xmlConfig->ConfigureWeights(nu);
04807 
04808     // Force new SKZP weights (to get the new error band)
04809     //lib.zBeamReweight.ExtractZBeamReweight(nu);
04810 
04811 
04812     //RE-RECONSTRUCT the neutrino energy
04813     lib.reco.GetEvtEnergy(nu, false);
04814     lib.reco.ApplyReweights(nu);
04815 
04816     // No Systematics
04817     //this->DoSystematicShifts(nu,xmlConfig);
04818 
04819     //Get NuMuBars only
04820     cutter.MakeCuts(nu);
04821 
04822     // Explicit hack to get only NuBars
04823     // This will break for non NuBar analyses
04824 //    MAXMSG("NuDSTAna.cxx",Msg::kWarning,100) << "Explicitly cutting "
04825 //    << "nu.charge < 0 -- Horrible Hack, works for NUBAR ONLY!!!" << endl;
04826 //    if (nu.charge < 0) continue;
04827 
04828     //if (!lib.cuts.IsGoodQP(nu)) continue;
04829 
04830     // If neither of these passed, continue
04831     if (cutter.Failed()) continue;
04832 
04833     // No oscillations
04834     //this->Oscillate(nu,xmlConfig);
04835 
04836     if (nu.charge==-1) lib.cnt.nuNQCounter++;
04837     else if (nu.charge==+1) lib.cnt.nuPQCounter++;
04838     else cout<<"ahhh, bad charge (4)"<<endl;
04839 
04840     //cout << "About to extract" << endl;
04841     dummy_nu->Extract(nu);
04842     //cout << "Extracted. Going to fill acceptance weight" << endl;
04843 
04844     TH1D* result;
04845     double accwt = 0.0; // default value means no shift
04846     
04847     //cout << "Getting the RHC- Acceptance shift" << endl;
04848     
04849     TFile rhc_ratio_file("/minos/app/mmathis/fcRHC0350/Final_RHC_plus_minus_ratio.root");
04850     
04851     rhc_ratio_file.GetObject("fdPred", result);
04852     
04853     // if the histogram couldn't be opened, return a unit histogram
04854     // so nothing is shifted
04855     if (!result) {
04856       cout << "Oh no, couldn't get the histogram!" << endl;
04857     } else if (2 == dummy_nu->detector) { // only apply to FD
04858       result->GetXaxis()->SetRangeUser(0, 200);
04859       accwt = 
04860         result->GetBinContent(result->GetXaxis()->FindFixBin(dummy_nu->energy));
04861       //cout << "Weight is " << accwt << endl;
04862     }
04863     
04864     //cout << "Integral() of result is " << result->Integral() << endl;
04865     
04866 
04867     //cout << "Extracted.  About to fill." << endl;
04868     tree->Fill();
04869     //cout << "Filled.  About to reset." << endl;
04870     dummy_nu->Reset();
04871 
04872     MAXMSG("NuFarNear",Msg::kInfo,5)
04873       <<"Passed: index="<<nu.index
04874       <<", energy="<<nu.energy<<", energyMC="<<nu.energyMC<<endl;
04875   }//end of loop over summary tree
04876 
04877   save->cd();
04878   tree->Write();
04879 
04883   //print out the numbers of events
04884   lib.cnt.PrintMicroDST();
04885 
04886   MSG("NuDSTAna",Msg::kInfo)
04887     <<" ** Finished MakeFCTree method **"<<endl;
04888 }

void NuDSTAna::MakeFinalPlots ( const NuPlots plots,
const NuEvent nu 
) const [protected]

Definition at line 5662 of file NuDSTAna.cxx.

References NuPlots::FillContainmentHistos(), NuPlots::FillDPIdSigmaQPPlotsN(), NuPlots::FillEvtAndSpillTimingPlots(), NuPlots::FillKinematicsHistos(), NuPlots::FillMiscHists(), NuPlots::FillRecoEnYHistosN(), NuPlots::FillRelativeAngleHistos(), NuPlots::FillSigmaQPPlots(), NuPlots::FillTrueJmIDHistosPQNQ(), NuPlots::FillTruePIDHistos(), NuPlots::FillTrueRoIDHistosPQNQ(), NuPlots::FillUVHistos(), and NuPlots::FillXYZHistos().

Referenced by CSSAnaRashid(), FDTestAna(), JeffsTestAna(), NDTestAna(), NewFieldAna(), NMBAna(), StdCCAna(), and StdNMBAna().

05664 {
05665   //same list as in NuAnalysis, but with trk/evt ones commented out
05666   plots->FillRecoEnYHistosN(nu);
05667   plots->FillDPIdSigmaQPPlotsN(nu);
05668   //   plots->FillEnergyBinHistos(nu);
05669 
05670   //plots->FillShwHistos(ntp,evt,nu);
05671   plots->FillUVHistos(nu);
05672   plots->FillXYZHistos(nu);
05673   plots->FillContainmentHistos(nu);
05674   plots->FillRelativeAngleHistos(nu);
05675   plots->FillTruePIDHistos(nu);
05676   plots->FillTrueRoIDHistosPQNQ(nu);
05677   plots->FillTrueJmIDHistosPQNQ(nu);
05678   plots->FillSigmaQPPlots(nu);
05679   //plots->FillTrackResponseHistos(ntp,trk,nu);
05680   //plots->FillRangeCurvCompHistos(nu);
05681   plots->FillKinematicsHistos(nu);
05682   plots->FillEvtAndSpillTimingPlots(nu);
05683   plots->FillMiscHists(nu);
05684 
05685 }

void NuDSTAna::MakekNNTrainTestSet ( TString  xmlFileName  ) 

< 0

< 1

< 2

< 3

< 4

< 5

< 6

< 7

< 8

< 9

< 10

< 11

< 12

< 13

< 14

< 15

< 16

< 17

< 18

< 19

Definition at line 7590 of file NuDSTAna.cxx.

References NuXMLConfig::AnaVersionString(), NuReco::ApplyReweights(), NuLibrary::cnt, NuXMLConfig::ConfigureWeights(), DoIO(), MuELoss::e, NuCounter::evtCounter, NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), NuInputEvents::InitialiseNuEventBranch(), NuLibrary::Instance(), NuCuts::kCC1070Std, Msg::kDebug, Msg::kInfo, MSG, NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, and NuInputEvents::ResetNuEventLoopPositionToStart().

07591 {
07592   NuInputEvents& input=this->DoIO(0,"","null");
07593 
07594   //get an instance of the code library
07595   NuLibrary& lib = NuLibrary::Instance();
07596 
07597   MSG("NuDSTAna",Msg::kInfo) << "Using xml file " << xmlFileName << endl;
07598   const NuXMLConfig* xmlConfig = new NuXMLConfig(xmlFileName);
07599   xmlConfig->Write();
07600 
07601   // Create the cutter objects
07602   NuCutter cutter(xmlConfig->AnaVersionString(), 0);
07603   TH1::AddDirectory(true);
07604 
07605   // output trees
07606   bool newDST = true;
07607   // roID
07608   Float_t testID;
07609   Float_t knn01TrkActivePlanes;
07610   Float_t knn10TrkMeanPh;
07611   Float_t knn20LowHighPh;
07612   Float_t knn40TrkPhFrac;
07613   Float_t roID;           
07614   Float_t jmID;    
07615   // truth info
07616   Bool_t roSignalMC;
07617   Bool_t signalMC;
07618   // for making energy spectra
07619   Float_t rw;
07620   Float_t energyMC;
07621   Float_t energy;     
07622 
07623   // shws
07624   // Chris variables
07625   Float_t trkShwEnNearDW, nplaneShw, sum2Shw;
07626   Float_t sum2ShwNoCor;
07627   Float_t shwEnLinCCCor;
07628   Float_t shwEnLinCCNoCor;
07629   Float_t shwEnLinCCNoCor2;
07630   Float_t shwEnWtCCCor;
07631   Float_t nstripShw;
07632   Float_t planeShwMax;
07633   Float_t transverseRMS;
07634   // others
07635   Int_t   nshw;
07636   Float_t shwEnkNN;
07637   Float_t shwEnkNNNoCor;
07638   Float_t sumShws;
07639   Float_t sumShwsWt;
07640   Float_t nstripAllShws;
07641   Float_t trkEn;
07642   Float_t shwEnMC;
07643   Float_t trkEnMC;
07644   Float_t neuEnMC;
07645   // unique to newDST
07646   Float_t shwRmsT;
07647   Float_t shwPctWidth;
07648   Float_t shwPctLength;
07649   Float_t avgShwHitMip;
07650   Float_t trkVtxSinz;
07651   Float_t shwSumHitLength;
07652   Float_t shwSumHitWidth;
07653   Float_t maxShwPlaneMip;
07654   Float_t maxShwHitMip;
07655   // all shws
07656   Float_t shwRmsTAllShws;
07657   Float_t shwPctWidthAllShws;
07658   Float_t shwPctLengthAllShws;
07659   Float_t avgShwHitMipAllShws;
07660   Float_t shwSumHitLengthAllShws;
07661   Float_t shwSumHitWidthAllShws;
07662   Float_t maxShwPlaneMipAllShws;
07663   Float_t maxShwHitMipAllShws;
07664   Float_t nplaneAllShws;
07665   Float_t planeAllShwMax;
07666   // test variables
07667   Float_t testShwEn1;
07668   Float_t testShwEn2;
07669   Float_t testShwEn3;              
07670 
07671   // shower energy sys
07672   Float_t InukePiCExchgP;   
07673   Float_t InukePiCExchgN;   
07674   Float_t InukePiEScatP;    
07675   Float_t InukePiEScatN;    
07676   Float_t InukePiInEScatP;  
07677   Float_t InukePiInEScatN;  
07678   Float_t InukePiAbsorbP;   
07679   Float_t InukePiAbsorbN;   
07680   Float_t InukePi2PiP;      
07681   Float_t InukePi2PiN;      
07682   Float_t InukeNknockP;     
07683   Float_t InukeNknockN;     
07684   Float_t InukeNNPiP;       
07685   Float_t InukeNNPiN;       
07686   Float_t InukeFormTP;      
07687   Float_t InukeFormTN;      
07688   Float_t InukePiXsecP;     
07689   Float_t InukePiXsecN;     
07690   Float_t InukeNXsecP;      
07691   Float_t InukeNXsecN;      
07692 
07693   // test tree
07694   TTree* testTree = new TTree("test", "test"); 
07695 
07696   // pid
07697   testTree->Branch("testID", &testID);
07698   testTree->Branch("knn01TrkActivePlanes", &knn01TrkActivePlanes);
07699   testTree->Branch("knn10TrkMeanPh", &knn10TrkMeanPh);
07700   testTree->Branch("knn20LowHighPh", &knn20LowHighPh);
07701   testTree->Branch("knn40TrkPhFrac", &knn40TrkPhFrac);
07702   testTree->Branch("roID", &roID);   
07703   testTree->Branch("jmID", &jmID);
07704   testTree->Branch("roSignalMC", &roSignalMC);
07705   testTree->Branch("signalMC", &signalMC);
07706   testTree->Branch("rw", &rw);
07707   testTree->Branch("energyMC", &energyMC);
07708   testTree->Branch("energy", &energy);
07709 
07710   // shw
07711   testTree->Branch("trkShwEnNearDW", &trkShwEnNearDW);
07712   testTree->Branch("nplaneShw", &nplaneShw);
07713   testTree->Branch("sum2Shw", &sum2Shw);
07714   testTree->Branch("sum2ShwNoCor", &sum2ShwNoCor);
07715   testTree->Branch("shwEnLinCCCor", &shwEnLinCCCor);
07716   testTree->Branch("shwEnLinCCNoCor", &shwEnLinCCNoCor);
07717   testTree->Branch("shwEnLinCCNoCor2", &shwEnLinCCNoCor2);
07718   testTree->Branch("shwEnWtCCCor", &shwEnWtCCCor);
07719   testTree->Branch("nstripShw", &nstripShw);
07720   testTree->Branch("planeShwMax", &planeShwMax);
07721   testTree->Branch("transverseRMS", &transverseRMS);
07722   testTree->Branch("nshw", &nshw);
07723   testTree->Branch("shwEnkNN", &shwEnkNN);
07724   testTree->Branch("shwEnkNNNoCor", &shwEnkNNNoCor);
07725   testTree->Branch("sumShws", &sumShws);
07726   testTree->Branch("sumShwsWt", &sumShwsWt);
07727   testTree->Branch("nstripAllShws", &nstripAllShws);
07728   testTree->Branch("trkEn", &trkEn);
07729   testTree->Branch("shwEnMC", &shwEnMC);
07730   testTree->Branch("trkEnMC", &trkEnMC);
07731   testTree->Branch("neuEnMC", &neuEnMC);
07732   testTree->Branch("shwRmsT", &shwRmsT);
07733   testTree->Branch("shwPctWidth", &shwPctWidth);
07734   testTree->Branch("shwPctLength", &shwPctLength);
07735   testTree->Branch("avgShwHitMip", &avgShwHitMip);
07736   testTree->Branch("trkVtxSinz", &trkVtxSinz);
07737   testTree->Branch("shwSumHitLength", &shwSumHitLength);
07738   testTree->Branch("shwSumHitWidth", &shwSumHitWidth);
07739   testTree->Branch("maxShwPlaneMip", &maxShwPlaneMip);
07740   testTree->Branch("maxShwHitMip", &maxShwHitMip);
07741   testTree->Branch("shwRmsTAllShws", &shwRmsTAllShws);
07742   testTree->Branch("shwPctWidthAllShws", &shwPctWidthAllShws);
07743   testTree->Branch("shwPctLengthAllShws", &shwPctLengthAllShws);
07744   testTree->Branch("avgShwHitMipAllShws", &avgShwHitMipAllShws);
07745   testTree->Branch("shwSumHitLengthAllShws", &shwSumHitLengthAllShws);
07746   testTree->Branch("shwSumHitWidthAllShws", &shwSumHitWidthAllShws);
07747   testTree->Branch("maxShwPlaneMipAllShws", &maxShwPlaneMipAllShws);
07748   testTree->Branch("maxShwHitMipAllShws", &maxShwHitMipAllShws);
07749   testTree->Branch("nplaneAllShws", &nplaneAllShws);
07750   testTree->Branch("planeAllShwMax", &planeAllShwMax);
07751   testTree->Branch("testShwEn1", &testShwEn1);
07752   testTree->Branch("testShwEn2", &testShwEn2);
07753   testTree->Branch("testShwEn3", &testShwEn3);
07754   // shw sys
07755   testTree->Branch("InukePiCExchgP", &InukePiCExchgP);
07756   testTree->Branch("InukePiCExchgN", &InukePiCExchgN);
07757   testTree->Branch("InukePiEScatP", &InukePiEScatP);
07758   testTree->Branch("InukePiEScatN", &InukePiEScatN);
07759   testTree->Branch("InukePiInEScatP", &InukePiInEScatP);
07760   testTree->Branch("InukePiInEScatN", &InukePiInEScatN);
07761   testTree->Branch("InukePiAbsorbP", &InukePiAbsorbP);
07762   testTree->Branch("InukePiAbsorbN", &InukePiAbsorbN);
07763   testTree->Branch("InukePi2PiP", &InukePi2PiP);
07764   testTree->Branch("InukePi2PiN", &InukePi2PiN);
07765   testTree->Branch("InukeNknockP", &InukeNknockP);
07766   testTree->Branch("InukeNknockN", &InukeNknockN);
07767   testTree->Branch("InukeNNPiP", &InukeNNPiP);
07768   testTree->Branch("InukeNNPiN", &InukeNNPiN);
07769   testTree->Branch("InukeFormTP", &InukeFormTP);
07770   testTree->Branch("InukeFormTN", &InukeFormTN);
07771   testTree->Branch("InukePiXsecP", &InukePiXsecP);
07772   testTree->Branch("InukePiXsecN", &InukePiXsecN);
07773   testTree->Branch("InukeNXsecP", &InukeNXsecP);
07774   testTree->Branch("InukeNXsecN", &InukeNXsecN); 
07775 
07776   // train tree
07777   // PID
07778   TTree* trainTreePID = new TTree("trainPID", "trainPID"); 
07779   trainTreePID->Branch("knn01TrkActivePlanes", &knn01TrkActivePlanes);
07780   trainTreePID->Branch("knn10TrkMeanPh", &knn10TrkMeanPh);
07781   trainTreePID->Branch("knn20LowHighPh", &knn20LowHighPh);
07782   trainTreePID->Branch("knn40TrkPhFrac", &knn40TrkPhFrac);
07783   trainTreePID->Branch("roSignalMC", &roSignalMC);
07784   trainTreePID->Branch("signalMC", &signalMC);
07785   trainTreePID->Branch("rw", &rw);
07786 
07787   // shws
07788   TTree* trainTreeShw = new TTree("trainShw", "trainShw"); 
07789   trainTreeShw->Branch("shwEnMC", &shwEnMC);  
07790   trainTreeShw->Branch("rw", &rw); 
07791   trainTreeShw->Branch("trkShwEnNearDW", &trkShwEnNearDW);
07792   trainTreeShw->Branch("nplaneShw", &nplaneShw);
07793   trainTreeShw->Branch("sum2Shw", &sum2Shw);
07794   trainTreeShw->Branch("sum2ShwNoCor", &sum2ShwNoCor);
07795   trainTreeShw->Branch("shwEnLinCCCor", &shwEnLinCCCor);
07796   trainTreeShw->Branch("shwEnLinCCNoCor", &shwEnLinCCNoCor);
07797   trainTreeShw->Branch("shwEnLinCCNoCor2", &shwEnLinCCNoCor2);
07798   trainTreeShw->Branch("shwEnWtCCCor", &shwEnWtCCCor);
07799   trainTreeShw->Branch("nstripShw", &nstripShw);
07800   trainTreeShw->Branch("planeShwMax", &planeShwMax);
07801   trainTreeShw->Branch("transverseRMS", &transverseRMS);
07802   trainTreeShw->Branch("sumShws", &sumShws);
07803   trainTreeShw->Branch("sumShwsWt", &sumShwsWt);
07804   trainTreeShw->Branch("nstripAllShws", &nstripAllShws);
07805   trainTreeShw->Branch("shwRmsT", &shwRmsT);
07806   trainTreeShw->Branch("shwPctWidth", &shwPctWidth);
07807   trainTreeShw->Branch("shwPctLength", &shwPctLength);
07808   trainTreeShw->Branch("avgShwHitMip", &avgShwHitMip);
07809   trainTreeShw->Branch("trkVtxSinz", &trkVtxSinz);
07810   trainTreeShw->Branch("shwSumHitLength", &shwSumHitLength);
07811   trainTreeShw->Branch("shwSumHitWidth", &shwSumHitWidth);
07812   trainTreeShw->Branch("maxShwPlaneMip", &maxShwPlaneMip);
07813   trainTreeShw->Branch("maxShwHitMip", &maxShwHitMip);
07814   trainTreeShw->Branch("shwRmsTAllShws", &shwRmsTAllShws);
07815   trainTreeShw->Branch("shwPctWidthAllShws", &shwPctWidthAllShws);
07816   trainTreeShw->Branch("shwPctLengthAllShws", &shwPctLengthAllShws);
07817   trainTreeShw->Branch("avgShwHitMipAllShws", &avgShwHitMipAllShws);
07818   trainTreeShw->Branch("shwSumHitLengthAllShws", &shwSumHitLengthAllShws);
07819   trainTreeShw->Branch("shwSumHitWidthAllShws", &shwSumHitWidthAllShws);
07820   trainTreeShw->Branch("maxShwPlaneMipAllShws", &maxShwPlaneMipAllShws);
07821   trainTreeShw->Branch("maxShwHitMipAllShws", &maxShwHitMipAllShws);
07822   trainTreeShw->Branch("nplaneAllShws", &nplaneAllShws);
07823   trainTreeShw->Branch("planeAllShwMax", &planeAllShwMax); 
07824 
07825   // efficiency denomenator
07826   TTree * effdTree = new TTree("effd", "effd");
07827   effdTree->Branch("energy", &energy);
07828   effdTree->Branch("energyMC", &energyMC);
07829   effdTree->Branch("rw", &rw);
07830 
07831   // for TMVA PID test tree
07832   TTree* testTreeS = new TTree("testS", "testS");
07833   testTreeS->Branch("knn01TrkActivePlanes", &knn01TrkActivePlanes);
07834   testTreeS->Branch("knn10TrkMeanPh", &knn10TrkMeanPh);
07835   testTreeS->Branch("knn20LowHighPh", &knn20LowHighPh);
07836   testTreeS->Branch("knn40TrkPhFrac", &knn40TrkPhFrac);        
07837   TTree* testTreeB = new TTree("testB", "testB");
07838   testTreeB->Branch("knn01TrkActivePlanes", &knn01TrkActivePlanes);
07839   testTreeB->Branch("knn10TrkMeanPh", &knn10TrkMeanPh);
07840   testTreeB->Branch("knn20LowHighPh", &knn20LowHighPh);
07841   testTreeB->Branch("knn40TrkPhFrac", &knn40TrkPhFrac);        
07842 
07843   // for TMVA PID train tree
07844   TTree* trainTreeS = new TTree("trainS", "trainS"); 
07845   trainTreeS->Branch("knn01TrkActivePlanes", &knn01TrkActivePlanes);
07846   trainTreeS->Branch("knn10TrkMeanPh", &knn10TrkMeanPh);
07847   trainTreeS->Branch("knn20LowHighPh", &knn20LowHighPh);
07848   trainTreeS->Branch("knn40TrkPhFrac", &knn40TrkPhFrac);       
07849   TTree* trainTreeB = new TTree("trainB", "trainB"); 
07850   trainTreeB->Branch("knn01TrkActivePlanes", &knn01TrkActivePlanes);
07851   trainTreeB->Branch("knn10TrkMeanPh", &knn10TrkMeanPh);
07852   trainTreeB->Branch("knn20LowHighPh", &knn20LowHighPh);
07853   trainTreeB->Branch("knn40TrkPhFrac", &knn40TrkPhFrac);       
07854 
07855   TRandom3 randomNumber(1); 
07856 
07857   // loop over evts
07858   input.InitialiseNuEventBranch();
07859   input.ResetNuEventLoopPositionToStart();
07860   cout<<endl
07861       <<"************************************************"<<endl
07862       <<"***      Starting main loop over snarls      ***"<<endl
07863       <<"************************************************"<<endl;
07864   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
07865     lib.cnt.evtCounter++;
07866 
07867     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
07868 
07869     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
07870 
07871     nu.anaVersion = NuCuts::kCC1070Std;
07872 
07873     // Configure reweighting based on the XML file
07874     xmlConfig->ConfigureWeights(nu);
07875     lib.reco.ApplyReweights(nu);
07876 
07877     // getting values for output
07878     testID = nu.roIDPlus;
07879     knn01TrkActivePlanes = nu.knn01TrkActivePlanes;
07880     knn10TrkMeanPh = nu.knn10TrkMeanPh;
07881     knn20LowHighPh = nu.knn20LowHighPh;
07882     knn40TrkPhFrac = nu.knn40TrkPhFrac;
07883     roID = nu.roID;      
07884     //roID = nu.roIDPlus;      
07885     jmID = nu.jmID;
07886     roSignalMC = (abs(nu.trkIdMC) == 13); 
07887     signalMC = (abs(nu.inu) == 14 && nu.iaction != 0 );
07888     rw = nu.rw;
07889     energyMC = nu.energyMC;
07890     energy = nu.energy; 
07891 
07892     trkShwEnNearDW = nu.trkShwEnNearDW;
07893     nplaneShw = nu.nplaneShw;
07894     sum2Shw = nu.shwEnLinCCCor;
07895     sum2ShwNoCor = nu.shwEnLinCCNoCor;
07896     shwEnLinCCCor = nu.shwEnLinCCCor;
07897     shwEnLinCCNoCor = nu.shwEnLinCCNoCor;
07898     shwEnLinCCNoCor2 = nu.shwEnLinCCNoCor2;
07899     shwEnWtCCCor = nu.shwEnWtCCCor;
07900     nstripShw = nu.nstripShw;
07901     planeShwMax = nu.planeShwMax - nu.planeShwBeg;
07902     transverseRMS = nu.transverseRMSU + nu.transverseRMSV;
07903     nshw = nu.nshw;
07904     shwEnkNN = nu.shwEnkNN;
07905     shwEnkNNNoCor = nu.shwEnkNNNoCor;
07906     
07907     sumShws = 0.;
07908     sumShwsWt = 0.;
07909     nstripAllShws = 0.;
07910 
07911     trkEn = nu.trkEn;
07912     shwEnMC = nu.shwEnMC;
07913     trkEnMC = nu.trkEnMC;
07914     neuEnMC = nu.neuEnMC;
07915     if(newDST){
07916       shwRmsT = nu.shwRmsT;
07917       shwPctWidth = nu.shwPctWidth;
07918       shwPctLength = nu.shwPctLength;
07919       avgShwHitMip = nu.avgShwHitMip;
07920       trkVtxSinz = (abs(nu.trkvtxdcosz) <= 1) ? sqrt(1. - pow(nu.trkvtxdcosz, 2)) : -1.;
07921       shwSumHitLength = nu.shwSumHitLength;
07922       shwSumHitWidth = nu.shwSumHitWidth;
07923       maxShwPlaneMip = nu.maxShwPlaneMip;
07924       maxShwHitMip = nu.maxShwHitMip;
07925       shwRmsTAllShws = nu.shwRmsTAllShws;
07926       shwPctWidthAllShws = nu.shwPctWidthAllShws;
07927       shwPctLengthAllShws = nu.shwPctLengthAllShws;
07928       avgShwHitMipAllShws = nu.avgShwHitMipAllShws;
07929       shwSumHitLengthAllShws = nu.shwSumHitLengthAllShws;
07930       shwSumHitWidthAllShws = nu.shwSumHitWidthAllShws;
07931       maxShwPlaneMipAllShws = nu.maxShwPlaneMipAllShws;
07932       maxShwHitMipAllShws = nu.maxShwHitMipAllShws;
07933       nplaneAllShws = nu.nplaneAllShws;
07934       planeAllShwMax = nu.planeAllShwMax;
07935     }
07936     else{
07937       shwRmsT = -1.;
07938       shwPctWidth = -1.;
07939       shwPctLength = -1.;
07940       avgShwHitMip = -1.;
07941       trkVtxSinz = -1.;
07942       shwSumHitLength = -1.;
07943       shwSumHitWidth = -1.;
07944       maxShwPlaneMip = -1.;
07945       maxShwHitMip = -1.;
07946       shwRmsTAllShws = -1.;
07947       shwPctWidthAllShws = -1.;
07948       shwPctLengthAllShws = -1.;
07949       avgShwHitMipAllShws = -1.;
07950       shwSumHitLengthAllShws = -1.;
07951       shwSumHitWidthAllShws = -1.;
07952       maxShwPlaneMipAllShws = -1.;
07953       maxShwHitMipAllShws = -1.;
07954       nplaneAllShws = -1.;
07955       planeAllShwMax = -1.; 
07956     }
07957     testShwEn1 = 0.;
07958     testShwEn2 = 0.;
07959     //testShwEn3 = 0.;
07960     testShwEn3 = nu.shwEnkNNPlus;
07961     // shw sys
07962     InukePiCExchgP = nu.InukePiCExchgP;
07963     InukePiCExchgN = nu.InukePiCExchgN;
07964     InukePiEScatP = nu.InukePiEScatP;
07965     InukePiEScatN = nu.InukePiEScatN;
07966     InukePiInEScatP = nu.InukePiInEScatP;
07967     InukePiInEScatN = nu.InukePiInEScatN;
07968     InukePiAbsorbP = nu.InukePiAbsorbP;
07969     InukePiAbsorbN = nu.InukePiAbsorbN;
07970     InukePi2PiP = nu.InukePi2PiP;
07971     InukePi2PiN = nu.InukePi2PiN;
07972     InukeNknockP = nu.InukeNknockP;
07973     InukeNknockN = nu.InukeNknockN;
07974     InukeNNPiP = nu.InukeNNPiP;
07975     InukeNNPiN = nu.InukeNNPiN;
07976     InukeFormTP = nu.InukeFormTP;
07977     InukeFormTN = nu.InukeFormTN;
07978     InukePiXsecP = nu.InukePiXsecP;
07979     InukePiXsecN = nu.InukePiXsecN;
07980     InukeNXsecP = nu.InukeNXsecP;
07981     InukeNXsecN = nu.InukeNXsecN; 
07982 
07983     // taking sums
07984     if(nshw > 1){
07985       sum2Shw = nu.shwEnLinCCCor + nu.shwEnLinCCCor2;
07986       sum2ShwNoCor = nu.shwEnLinCCNoCor + nu.shwEnLinCCNoCor2;
07987     }
07988 
07989     if(nu.shwExists1){
07990       sumShws       += nu.shwEnLinCCCor1;
07991       sumShwsWt     += nu.shwEnWtCCCor1;
07992       nstripAllShws += nu.nstripShw1;
07993     }
07994     if(nu.shwExists2){
07995       sumShws       += nu.shwEnLinCCCor2;
07996       sumShwsWt     += nu.shwEnWtCCCor2;
07997       nstripAllShws += nu.nstripShw2;
07998     }
07999     if(nu.shwExists3){
08000       sumShws       += nu.shwEnLinCCCor3;
08001       sumShwsWt     += nu.shwEnWtCCCor3;
08002       nstripAllShws += nu.nstripShw3;
08003     }
08004     if(nu.shwExists4){
08005       sumShws       += nu.shwEnLinCCCor4;
08006       sumShwsWt     += nu.shwEnWtCCCor4;
08007       nstripAllShws += nu.nstripShw4;
08008     }
08009     if(nu.shwExists5){
08010       sumShws       += nu.shwEnLinCCCor5;
08011       sumShwsWt     += nu.shwEnWtCCCor5;
08012       nstripAllShws += nu.nstripShw5;
08013     }                    
08014 
08015     // add some randomness to integer variables or variables for the best shower
08016     // integer variables
08017     nplaneShw       += randomNumber.Gaus(0, 1e-5);
08018     nstripShw       += randomNumber.Gaus(0, 1e-5);
08019     planeShwMax     += randomNumber.Gaus(0, 1e-5);
08020     nplaneAllShws   += randomNumber.Gaus(0, 1e-5);
08021     nstripAllShws   += randomNumber.Gaus(0, 1e-5);
08022     planeAllShwMax  += randomNumber.Gaus(0, 1e-5);
08023     // variables for best shower
08024     trkShwEnNearDW  += randomNumber.Gaus(0, 1e-5);
08025     sum2Shw         += randomNumber.Gaus(0, 1e-5);
08026     shwEnLinCCCor   += randomNumber.Gaus(0, 1e-5);
08027     shwEnWtCCCor    += randomNumber.Gaus(0, 1e-5);
08028     transverseRMS   += randomNumber.Gaus(0, 1e-5);
08029     shwRmsT         += randomNumber.Gaus(0, 1e-5);
08030     shwPctWidth     += randomNumber.Gaus(0, 1e-5);
08031     shwPctLength    += randomNumber.Gaus(0, 1e-5);
08032     avgShwHitMip    += randomNumber.Gaus(0, 1e-5);
08033     shwSumHitLength += randomNumber.Gaus(0, 1e-5);
08034     shwSumHitWidth  += randomNumber.Gaus(0, 1e-5);
08035     maxShwPlaneMip  += randomNumber.Gaus(0, 1e-5);
08036     maxShwHitMip    += randomNumber.Gaus(0, 1e-5);
08037     
08038     // for test
08039     signalMC = roSignalMC;
08040 
08041     // setup selection
08042     cutter.ResetStatus();
08043     cutter.MakeCuts(nu);
08044 
08045     // pre-pre selection (Ntracks and fid vol)
08046     if (cutter.Failed("GoodNumberofTracks")) continue;
08047     if (cutter.Failed("FidVol")) continue;
08048 
08049     if (nu.inu == 14 && nu.iaction != 0)
08050       effdTree->Fill();
08051 
08052     // fill the train tree for PID
08053     if(knn01TrkActivePlanes < 0 || knn10TrkMeanPh < 0 || knn20LowHighPh < 0 || knn40TrkPhFrac < 0) continue;
08054     trainTreePID->Fill();
08055     if(signalMC)
08056       trainTreeS->Fill();
08057     else
08058       trainTreeB->Fill();
08059 
08060     // apply selection with PID cut removed
08061     if (nu.charge == 1) continue;
08062     if(!cutter.PassedExcept("pid")) continue;
08063 
08064     // fill the train tree for shw
08065     if((roID > 0.25 || jmID > 0.5) && nshw > 0)
08066       trainTreeShw->Fill(); 
08067 
08068     // fill the test tree
08069     testTree->Fill();
08070 
08071     if(signalMC)
08072       testTreeS->Fill();
08073     else
08074       testTreeB->Fill();
08075 
08076   }
08077 
08078   cout<<endl;
08079 
08080   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
08081 
08085 
08086   cutter.PrintSummary();
08087 
08088   //print out the numbers of events
08089   lib.cnt.PrintMicroDST();
08090 
08091   MSG("NuAnalysis",Msg::kInfo)
08092     <<" ** Finished MakekNNTrainTestSet() method **"<<endl;
08093 }

void NuDSTAna::MakeMicroDST ( TString  anaVersion,
const TString  xmlfile = "" 
)

Make a microDST, optionally processing from the XML file.

Definition at line 3208 of file NuDSTAna.cxx.

References NuCutter::AnaVersion(), NuReco::ApplyReweights(), NuLibrary::cnt, DoIO(), DoSystematicShifts(), NuCounter::evtCounter, NuOutputWriter::FillNuEventTree(), NuOutputWriter::FillNuMCEventTree(), NuOutputWriter::Finish(), NuCutter::GetCut(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuOutputWriter::GetNuEventToFill(), NuOutputWriter::GetNuMCEventToFill(), NuCut::InFidVolTrueEvt(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, NuCutter::MakeCuts(), MAXMSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, Oscillate(), plots(), NuBase::PrintLoopProgress(), NuCutter::PrintSummary(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), SanityCheckedAnaVersion(), and UpdatePotSinceLastEvt().

03210 {
03211   //do the histogram IO
03212   NuOutputWriter output;
03213   NuInputEvents& input = this->DoIO(&output,("NuDSTMicro" + anaVersionStr).Data());
03214 
03215   // Set up useful and needed instances
03216   NuLibrary& lib=NuLibrary::Instance();
03217   const NuPlots* plots = 0;
03218 
03219   // Initialise the XML object
03220   auto_ptr<NuXMLConfig> xmlConfig;
03221   if (xmlFilename.IsNull()) {
03222     xmlConfig.reset(new NuXMLConfig());
03223   } else {
03224     xmlConfig.reset(new NuXMLConfig(xmlFilename));
03225   }
03226 
03227   // Sync function argument and xml with each other. Function argument takes
03228   // priority if it's set.
03229   if(!anaVersionStr.IsNull()) xmlConfig->SetAnaVersionString(anaVersionStr);
03230   anaVersionStr = xmlConfig->AnaVersionString();
03231 
03232   // Save a copy to the output file
03233   xmlConfig->Write();
03234 
03235   // Build the cutter object
03236   NuCutter cutter(anaVersionStr, plots);
03237 
03241 
03242   cout<<endl
03243       <<"************************************************"<<endl
03244       <<"***      Starting main loop over snarls      ***"<<endl
03245       <<"************************************************"<<endl;
03246 
03247   input.ResetNuEventLoopPositionToStart();
03248 
03249   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
03250     lib.cnt.evtCounter++;
03251 
03252     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
03253 
03254     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
03255 
03256     //OVERRIDE the analysis version
03257     nu.anaVersion = SanityCheckedAnaVersion(nu.anaVersion,
03258                                             cutter.AnaVersion());
03259 
03260     // Stop cutting on data quality for now
03261     //nu.useDBForDataQuality = false;
03262 
03263     // Record the POTs as they go past, so that when we get an event
03264     // that passes, it has the correct POT
03265     this->UpdatePotSinceLastEvt(nu,false);
03266 
03267     // Configure reweighting based on the XML file
03268     xmlConfig->ConfigureWeights(nu);
03269 
03270     //RE-RECONSTRUCT the neutrino energy including kNN, reweight
03271     lib.reco.GetEvtEnergy(nu, true);
03272     lib.reco.ApplyReweights(nu);
03273 
03274     // Apply the systematic shift if required according to xmlConfig
03275     this->DoSystematicShifts(nu,xmlConfig.get());
03276 
03277     // Make the cuts!
03278     if (!cutter.MakeCuts(nu)) continue;
03279 
03280     // Oscillate if desired (to make fake data)
03281     this->Oscillate(nu,xmlConfig.get());
03282 
03283     // figure out the first and last time in the whole ntuple
03284     // this is very useful for making plots of quantities vs time
03285     // plots->FillNtupleEarliestLatestTime(nu);
03286 
03287     // Count the events to print to screen
03288     if      (nu.charge==-1) lib.cnt.nuNQCounter++;
03289     else if (nu.charge==+1) lib.cnt.nuPQCounter++;
03290     // else MSG("NuDSTAna",Msg::kWarning) << "Bad charge (" << nu.charge
03291     //         << ") found!" << endl;
03292 
03293 
03294     // Copy pots since last event to ntuple for this new evt
03295     this->UpdatePotSinceLastEvt(nu,true);
03296 
03297     //get the output nu to fill, copy nu to the output nu, fill tree
03298     NuEvent& nuOutput=output.GetNuEventToFill();
03299     nuOutput=nu;
03300     output.FillNuEventTree();
03301   }
03302 
03306 
03307   input.InitialiseNuMCEventBranch();
03308   input.ResetNuMCEventLoopPositionToStart();
03309 
03310   cout<<endl
03311       <<"************************************************"<<endl
03312       <<"***       Starting loop over truth info      ***"<<endl
03313       <<"************************************************"<<endl;
03314 
03315   for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
03316     lib.cnt.evtCounter++;
03317 
03318     this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
03319 
03320     NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
03321                                          (Msg::kDebug));
03322 
03323     //OVERRIDE
03324     mc.anaVersion = SanityCheckedAnaVersion(mc.anaVersion,
03325                                             cutter.AnaVersion());
03326 
03327     MAXMSG("NuDSTAna",Msg::kInfo,5)
03328       <<"energyMC="<<mc.energyMC<<endl;
03329 
03330     // Make fid vol cut
03331     if (!cutter.GetCut()->InFidVolTrueEvt(mc)) continue;
03332 
03333     xmlConfig->ConfigureWeights(mc);
03334 
03335     this->Oscillate(mc,xmlConfig.get());
03336 
03337     //get the output nu to fill,copy mc to the output mc, fill tree
03338     NuMCEvent& mcOutput=output.GetNuMCEventToFill();
03339     mcOutput=mc;
03340     output.FillNuMCEventTree();
03341   }
03342 
03343   cutter.PrintSummary();
03344 
03345   //close the file and write out everything
03346   output.Finish();
03347 }

void NuDSTAna::MakeMicroDst2010 ( bool  redoRw = false  ) 

Definition at line 4006 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuZBeamReweight::ExtractZBeamReweight(), NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuOutputWriter::FillNuMCEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuOutputWriter::GetNuEventToFill(), NuOutputWriter::GetNuMCEventToFill(), NuPIDInterface::GetRoIDPlus(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), NuCuts::IsInFidVolTrueEvt(), NuCuts::kCC0720Std, Msg::kDebug, Msg::kInfo, Msg::kWarning, NuCutter::MakePreselectionCuts(), MAXMSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuCutter::Passed(), plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuCutter::PrintSummary(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), NuCutter::ResetStatus(), SanityCheckedAnaVersion(), UpdatePotSinceLastEvt(), and NuLibrary::zBeamReweight.

04007 {
04008   //do the histogram IO
04009   NuOutputWriter* poutput = new NuOutputWriter;
04010   NuInputEvents& input = DoIO(poutput, "NuDSTMicro2010");
04011 
04012   //get a reference
04013   NuOutputWriter& output=(*poutput);
04014 
04015   //get an instance of the code library
04016   NuLibrary& lib = NuLibrary::Instance();
04017 
04018   //interface for the pids, plots
04019   NuPIDInterface pid;
04020   const NuPlots* plots = 0;
04021 
04022   //just use the bare bones preselection for the microDSTs
04023   //can't use the NC/CC preselections since they remove RAF events
04024   NuCutter preSelection2010Cutter("Preselection2010");
04025 
04029 
04030   //prepare for loop
04031   input.ResetNuEventLoopPositionToStart();
04032 
04033   cout<<endl
04034       <<"************************************************"<<endl
04035       <<"***      Starting main loop over snarls      ***"<<endl
04036       <<"************************************************"<<endl;
04037 
04038   for(int i = 0; i < input.GetEntriesNuEvent(); ++i){
04039     ++lib.cnt.evtCounter;
04040 
04041     PrintLoopProgress(i, input.GetEntriesNuEvent(), 1);
04042 
04043     NuEvent& nu = const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
04044 
04045     //OVERRIDE the analysis version
04046     nu.anaVersion=SanityCheckedAnaVersion(nu.anaVersion,
04047                                           NuCuts::kCC0720Std);
04048 
04049     //count up the pots
04050     UpdatePotSinceLastEvt(nu, false);
04051 
04052     if (redoRw) {
04053       //Recalculate the SKZP weights
04054 //    nu.reweightVersion=SKZPWeightCalculator::kDogwood5_Daikon07_2012;
04055       lib.zBeamReweight.ExtractZBeamReweight(nu);
04056       nu.applyBeamWeight = true;
04057     }
04058 
04059     //RE-RECONSTRUCT the neutrino energy including kNN, reweight
04060     lib.reco.GetEvtEnergy(nu, true);
04061     lib.reco.ApplyReweights(nu);
04062 
04063     //Recalculate roID in making microDSTs
04064     pid.GetRoIDPlus(nu);
04065 
04066     if(nu.coilIsReverse != nu.hornIsReverse){
04067       MAXMSG("NuDSTAna", Msg::kWarning, 50)
04068         << "Found a " << (nu.coilIsReverse ? "reversed" : "forward")
04069         << " coil event in a " << (nu.hornIsReverse ? "reversed" : "forward")
04070         << " horn run.  The event is being kept, but there may be a problem!"
04071         << " This warning is expected for RHC MC." << endl;
04072     }
04073 
04074     // Need to reset otherwise previous event failing will fail this one
04075     preSelection2010Cutter.ResetStatus();
04076 
04077     //make the preselection cuts
04078     preSelection2010Cutter.MakePreselectionCuts(nu);
04079 
04080     // If the event passes preselection then we keep it
04081     if(!preSelection2010Cutter.Passed()) continue;
04082 
04083     //figure out the first and last time in the whole ntuple
04084     //this is very useful for making plots of quantities vs time
04085     plots->FillNtupleEarliestLatestTime(nu);
04086 
04087     //count the events to print to screen
04088     if(nu.charge == -1) ++lib.cnt.nuNQCounter;
04089     if(nu.charge == +1) ++lib.cnt.nuPQCounter;
04090 
04091     //copy pots since last event to ntuple for this new evt
04092     UpdatePotSinceLastEvt(nu, true);
04093 
04094     //get the output nu to fill, copy nu to the output nu, fill tree
04095     output.GetNuEventToFill() = nu;
04096     output.FillNuEventTree();
04097   } // end for i
04098 
04102 
04103   input.InitialiseNuMCEventBranch();
04104   input.ResetNuMCEventLoopPositionToStart();
04105 
04106   cout<<endl
04107       <<"************************************************"<<endl
04108       <<"***       Starting loop over truth info      ***"<<endl
04109       <<"************************************************"<<endl;
04110 
04111   for(int i = 0; i < input.GetEntriesNuMCEvent(); ++i){
04112     ++lib.cnt.evtCounter;
04113 
04114     PrintLoopProgress(i, input.GetEntriesNuMCEvent(), 1);
04115 
04116     NuMCEvent& mc = const_cast<NuMCEvent&>(input.GetNextNuMCEvent(Msg::kDebug));
04117 
04118     //OVERRIDE
04119     mc.anaVersion = SanityCheckedAnaVersion(mc.anaVersion, NuCuts::kCC0720Std);
04120 
04121     MAXMSG("NuDSTAna", Msg::kInfo,5) << "energyMC=" << mc.energyMC << endl;
04122 
04123     //make fid vol cut
04124     if(!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
04125 
04126     if (redoRw) {
04127       lib.zBeamReweight.ExtractZBeamReweight(mc);
04128     }
04129 
04130     //get the output nu to fill,copy mc to the output mc, fill tree
04131     output.GetNuMCEventToFill() = mc;
04132     output.FillNuMCEventTree();
04133   } // end for i
04134 
04135   preSelection2010Cutter.PrintSummary();
04136 
04137   //print out the numbers of events
04138   lib.cnt.PrintMicroDST();
04139 
04140   //close the file and write out everything
04141   output.Finish();
04142 }

void NuDSTAna::MakeMicroDst2014 ( bool  redoRw = false  ) 

Definition at line 4282 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuZBeamReweight::ExtractZBeamReweight(), NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuOutputWriter::FillNuMCEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuOutputWriter::GetNuEventToFill(), NuOutputWriter::GetNuMCEventToFill(), NuPIDInterface::GetRoIDPlus(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), NuCuts::IsInFidVolTrueEvt(), NuCuts::kCC2014, Msg::kDebug, Msg::kInfo, Msg::kWarning, NuCutter::MakePreselectionCuts(), MAXMSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuCutter::Passed(), plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuCutter::PrintSummary(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), NuCutter::ResetStatus(), SanityCheckedAnaVersion(), UpdatePotSinceLastEvt(), and NuLibrary::zBeamReweight.

04283 {
04284   //do the histogram IO
04285   NuOutputWriter* poutput = new NuOutputWriter;
04286   NuInputEvents& input = DoIO(poutput, "NuDSTMicro2014");
04287 
04288   //get a reference
04289   NuOutputWriter& output=(*poutput);
04290 
04291   //get an instance of the code library
04292   NuLibrary& lib = NuLibrary::Instance();
04293 
04294   //interface for the pids, plots
04295   NuPIDInterface pid;
04296   const NuPlots* plots = 0;
04297 
04298   //just use the bare bones preselection for the microDSTs
04299   //can't use the NC/CC preselections since they remove RAF events
04300   NuCutter preSelection2014Cutter("Preselection2014");
04301 
04305 
04306   //prepare for loop
04307   input.ResetNuEventLoopPositionToStart();
04308 
04309   cout<<endl
04310       <<"************************************************"<<endl
04311       <<"***      Starting main loop over snarls      ***"<<endl
04312       <<"************************************************"<<endl;
04313 
04314   for(int i = 0; i < input.GetEntriesNuEvent(); ++i){
04315     ++lib.cnt.evtCounter;
04316 
04317     PrintLoopProgress(i, input.GetEntriesNuEvent(), 1);
04318 
04319     NuEvent& nu = const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
04320 
04321     //OVERRIDE the analysis version
04322     nu.anaVersion=SanityCheckedAnaVersion(nu.anaVersion,
04323                                           NuCuts::kCC2014);//kPreselection2014);
04324 
04325     //count up the pots
04326     UpdatePotSinceLastEvt(nu, false);
04327 
04328     if (redoRw) {
04329       //Recalculate the SKZP weights
04330 //    nu.reweightVersion=SKZPWeightCalculator::kDogwood5_Daikon07_2012;
04331       lib.zBeamReweight.ExtractZBeamReweight(nu);
04332       nu.applyBeamWeight = true;
04333     }
04334 
04335     //RE-RECONSTRUCT the neutrino energy including kNN, reweight
04336     lib.reco.GetEvtEnergy(nu, true);
04337     lib.reco.ApplyReweights(nu);
04338 
04339     //Recalculate roID in making microDSTs
04340     pid.GetRoIDPlus(nu);
04341 
04342     if(nu.coilIsReverse != nu.hornIsReverse){
04343       MAXMSG("NuDSTAna", Msg::kWarning, 50)
04344         << "Found a " << (nu.coilIsReverse ? "reversed" : "forward")
04345         << " coil event in a " << (nu.hornIsReverse ? "reversed" : "forward")
04346         << " horn run.  The event is being kept, but there may be a problem!"
04347         << " This warning is expected for RHC MC." << endl;
04348     }
04349 
04350     // Need to reset otherwise previous event failing will fail this one
04351     preSelection2014Cutter.ResetStatus();
04352 
04353     //make the preselection cuts
04354     preSelection2014Cutter.MakePreselectionCuts(nu);
04355 
04356     // If the event passes preselection then we keep it
04357     if(!preSelection2014Cutter.Passed()) continue;
04358 
04359     //figure out the first and last time in the whole ntuple
04360     //this is very useful for making plots of quantities vs time
04361     plots->FillNtupleEarliestLatestTime(nu);
04362 
04363     //count the events to print to screen
04364     if(nu.charge == -1) ++lib.cnt.nuNQCounter;
04365     if(nu.charge == +1) ++lib.cnt.nuPQCounter;
04366 
04367     //copy pots since last event to ntuple for this new evt
04368     UpdatePotSinceLastEvt(nu, true);
04369 
04370     //get the output nu to fill, copy nu to the output nu, fill tree
04371     output.GetNuEventToFill() = nu;
04372     output.FillNuEventTree();
04373   } // end for i
04374 
04378 
04379   input.InitialiseNuMCEventBranch();
04380   input.ResetNuMCEventLoopPositionToStart();
04381 
04382   cout<<endl
04383       <<"************************************************"<<endl
04384       <<"***       Starting loop over truth info      ***"<<endl
04385       <<"************************************************"<<endl;
04386 
04387   for(int i = 0; i < input.GetEntriesNuMCEvent(); ++i){
04388     ++lib.cnt.evtCounter;
04389 
04390     PrintLoopProgress(i, input.GetEntriesNuMCEvent(), 1);
04391 
04392     NuMCEvent& mc = const_cast<NuMCEvent&>(input.GetNextNuMCEvent(Msg::kDebug));
04393 
04394     //OVERRIDE
04395     mc.anaVersion = SanityCheckedAnaVersion(mc.anaVersion, NuCuts::kCC2014);//kPreselection2014);
04396 
04397     MAXMSG("NuDSTAna", Msg::kInfo,5) << "energyMC=" << mc.energyMC << endl;
04398 
04399     //make fid vol cut
04400     if(!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
04401 
04402     if (redoRw) {
04403       lib.zBeamReweight.ExtractZBeamReweight(mc);
04404     }
04405 
04406     //get the output nu to fill,copy mc to the output mc, fill tree
04407     output.GetNuMCEventToFill() = mc;
04408     output.FillNuMCEventTree();
04409   } // end for i
04410 
04411   preSelection2014Cutter.PrintSummary();
04412 
04413   //print out the numbers of events
04414   lib.cnt.PrintMicroDST();
04415 
04416   //close the file and write out everything
04417   output.Finish();
04418 }

void NuDSTAna::MakeMicroDstFakeData ( bool  presel = true  ) 

this function makes a micro DST with std CC reco and cuts

Definition at line 4587 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuPlots::FillNtupleEarliestLatestTime(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), IsGoodPreSelectionCuts(), NuCuts::IsInFidVolTrueEvt(), Msg::kDebug, Msg::kError, Msg::kInfo, NuCuts::kJJE1, MAXMSG, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, Oscillate(), plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), SanityCheckedAnaVersion(), NuXMLConfig::SetCPT(), and UpdatePotSinceLastEvt().

04588 {
04590 
04591   //do the histogram IO
04592   NuOutputWriter* poutput=new NuOutputWriter();
04593   TString name;
04594   if (presel) name = "NuDSTMicroFakeData";
04595   else        name = "NuDSTFullFakeData";
04596   NuInputEvents& input=this->DoIO(poutput,name.Data());
04597 
04598   //get a reference
04599   NuOutputWriter& output=(*poutput);
04600 
04601   //get an instance of the code library
04602   NuLibrary& lib=NuLibrary::Instance();
04603 
04604   //interface for the pids, plots
04605   NuPIDInterface pid;
04606   const NuPlots* plots=0;
04607 
04608   //version to do reco/cuts with
04609   NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kJJE1;
04610 
04611   // Make an xmlConfig object for oscilaltions
04612   NuXMLConfig *xmlConfig = new NuXMLConfig();
04613   xmlConfig->SetCPT();
04614   xmlConfig->Write("NuXMLConfig");
04615 
04619 
04620   //prepare for loop
04621   input.ResetNuEventLoopPositionToStart();
04622 
04623   cout<<endl
04624       <<"************************************************"<<endl
04625       <<"***      Starting main loop over snarls      ***"<<endl
04626       <<"************************************************"<<endl;
04627 
04628 
04629   int RunIPart = static_cast<Int_t>(input.GetEntriesNuEvent() *
04630                                     1.27 / 3.21);
04631 
04632   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
04633     lib.cnt.evtCounter++;
04634 
04635     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
04636 
04637     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
04638 
04639     //OVERRIDE
04640     nu.anaVersion=this->SanityCheckedAnaVersion
04641       (nu.anaVersion,overrideAnaVersion);
04642 
04643     //count up the pots
04644     Bool_t newEvt=false;
04645     this->UpdatePotSinceLastEvt(nu,newEvt);
04646 
04647     //OVERRIDE
04648     //Selection
04649     nu.anaVersion=this->SanityCheckedAnaVersion
04650       (nu.anaVersion,overrideAnaVersion);
04651 
04652     MSG("NuDSTAna", Msg::kError) << "Not applying SKZP weights in RunI/RunII as previously" << endl;
04653 
04654     //RE-RECONSTRUCT the neutrino energy, including kNN
04655     lib.reco.GetEvtEnergy(nu, true);
04656     lib.reco.ApplyReweights(nu);
04657 
04658     //Oscillate if desired (to make fake data)
04659     this->Oscillate(nu,xmlConfig);
04660 
04661     // PoID Officially depracated
04662     // Add in Pedro's pid's
04663     // pid.GetPoID(nu);
04664 
04665     //make the preselection cuts
04666     if (presel) {
04667       if (!this->IsGoodPreSelectionCuts(plots,nu)) continue;
04668     }
04669 
04670     //figure out the first and last time in the whole ntuple
04671     //this is very useful for making plots of quantities vs time
04672     plots->FillNtupleEarliestLatestTime(nu);
04673 
04674     //count the events to print to screen
04675     if (nu.charge==-1) {
04676       lib.cnt.nuNQCounter++;
04677     }
04678     else if (nu.charge==+1) {
04679       lib.cnt.nuPQCounter++;
04680     }
04681 
04682     //copy pots since last event to ntuple for this new evt
04683     newEvt=true;
04684     this->UpdatePotSinceLastEvt(nu,newEvt);
04685 
04686     //get the output nu to fill, copy nu to the output nu, fill tree
04687     NuEvent& nuOutput=output.GetNuEventToFill();
04688     nuOutput=nu;
04689     output.FillNuEventTree();
04690   }
04691 
04695 
04696   input.InitialiseNuMCEventBranch();
04697   input.ResetNuMCEventLoopPositionToStart();
04698 
04699   cout<<endl
04700       <<"************************************************"<<endl
04701       <<"***       Starting loop over truth info      ***"<<endl
04702       <<"************************************************"<<endl;
04703 
04704   RunIPart = static_cast<Int_t>(input.GetEntriesNuMCEvent() *
04705                                 1.27 / 3.21);
04706 
04707   for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
04708     lib.cnt.evtCounter++;
04709 
04710     this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
04711 
04712     NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
04713                                          (Msg::kDebug));
04714 
04715     //OVERRIDE
04716     mc.anaVersion=this->SanityCheckedAnaVersion
04717       (mc.anaVersion,overrideAnaVersion);
04718 
04719     MAXMSG("NuDSTAna",Msg::kInfo,5)
04720       <<"energyMC="<<mc.energyMC<<endl;
04721 
04722     //make fid vol cut
04723     if (!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
04724 
04725     MSG("NuDSTAna", Msg::kError) << "Can't apply RunI/RunII weights which no longer exist" << endl;
04726 
04727     //Oscillate if desired (to make fake data)
04728     this->Oscillate(mc,xmlConfig);
04729 
04730     //get the output nu to fill,copy mc to the output mc, fill tree
04731     NuMCEvent& mcOutput=output.GetNuMCEventToFill();
04732     mcOutput=mc;
04733     output.FillNuMCEventTree();
04734   }
04735 
04736   //print out the numbers of events
04737   lib.cnt.PrintMicroDST();
04738 
04739   //close the file and write out everything
04740   output.Finish();
04741 }

void NuDSTAna::MakeMicroDstForCSSSystematics (  ) 

this function makes a micro DST with just events for CSS study

Definition at line 3351 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuOutputWriter::FillNuMCEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuOutputWriter::GetNuEventToFill(), NuOutputWriter::GetNuMCEventToFill(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), IsGoodPreSelectionCuts(), NuCuts::IsInFidVolTrueEvt(), Msg::kDebug, Msg::kError, Msg::kInfo, NuCuts::kNMB0325Bravo, Msg::kWarning, MAXMSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), SanityCheckedAnaVersion(), and UpdatePotSinceLastEvt().

03352 {
03354 
03355   //do the histogram IO
03356   NuOutputWriter* poutput=new NuOutputWriter();
03357   NuInputEvents& input=this->DoIO(poutput,"NuDSTMicroCSS");
03358 
03359   //get a reference
03360   NuOutputWriter& output=(*poutput);
03361 
03362   //get an instance of the code library
03363   NuLibrary& lib=NuLibrary::Instance();
03364 
03365   //get plots object
03366   const NuPlots* plots=0;
03367 
03368   //version to do reco/cuts with
03369   NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kNMB0325Bravo;
03370 
03374 
03375   //prepare for loop
03376   input.ResetNuEventLoopPositionToStart();
03377 
03378   cout<<endl
03379       <<"************************************************"<<endl
03380       <<"***      Starting main loop over snarls      ***"<<endl
03381       <<"************************************************"<<endl;
03382 
03383   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
03384     lib.cnt.evtCounter++;
03385 
03386     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
03387 
03388     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
03389 
03390     //OVERRIDE
03391     nu.anaVersion=this->SanityCheckedAnaVersion
03392       (nu.anaVersion,overrideAnaVersion);
03393 
03394     //count up the pots
03395     Bool_t newEvt=false;
03396     this->UpdatePotSinceLastEvt(nu,newEvt);
03397 
03398     //RE-RECONSTRUCT the neutrino energy, including kNN
03399     lib.reco.GetEvtEnergy(nu, true);
03400     lib.reco.ApplyReweights(nu);
03401 
03402     MAXMSG("NuDSTAna",Msg::kWarning,5)
03403       <<"Note: setting rw variable to use SKZP RunI beam weight"<<endl;
03404     MAXMSG("NuDSTAna",Msg::kError,5)
03405       <<"No I'm not - why would you do that?"<<endl;
03406     nu.rw=nu.beamWeight;
03407 
03408     //make the preselection cuts
03409     if (!this->IsGoodPreSelectionCuts(plots,nu)) continue;
03410 
03411     //NC PID taken out due to the fact that Andy's PID uses the charge
03412     //and the effect of this is not yet understood.
03413     //cut on the PID
03414     //if (!lib.cuts.IsGoodPID(nu)) {
03415     //continue;
03416     //}
03417     //lib.cnt.goodPIDCounter++;
03418 
03419     //figure out the first and last time in the whole ntuple
03420     //this is very useful for making plots of quantities vs time
03421     plots->FillNtupleEarliestLatestTime(nu);
03422 
03423     //count the events to print to screen
03424     if (nu.charge==-1) lib.cnt.nuNQCounter++;
03425     else if (nu.charge==+1) lib.cnt.nuPQCounter++;
03426 
03427     //copy pots since last event to ntuple for this new evt
03428     newEvt=true;
03429     this->UpdatePotSinceLastEvt(nu,newEvt);
03430 
03431     //get the output nu to fill, copy nu to the output nu, fill tree
03432     NuEvent& nuOutput=output.GetNuEventToFill();
03433     nuOutput=nu;
03434     output.FillNuEventTree();
03435   }
03436 
03440 
03441   input.InitialiseNuMCEventBranch();
03442   input.ResetNuMCEventLoopPositionToStart();
03443 
03444   cout<<endl
03445       <<"************************************************"<<endl
03446       <<"***       Starting loop over truth info      ***"<<endl
03447       <<"************************************************"<<endl;
03448 
03449   for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
03450     lib.cnt.evtCounter++;
03451 
03452     this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
03453 
03454     NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
03455                                          (Msg::kDebug));
03456 
03457     //OVERRIDE
03458     mc.anaVersion=this->SanityCheckedAnaVersion
03459       (mc.anaVersion,overrideAnaVersion);
03460 
03461     MAXMSG("NuDSTAna",Msg::kInfo,5)
03462       <<"energyMC="<<mc.energyMC<<endl;
03463 
03464     //make fid vol cut
03465     if (!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
03466 
03467     MAXMSG("NuDSTAna",Msg::kWarning,5)
03468       <<"Note: setting rw variable to use SKZP RunI beam weight"<<endl;
03469     MAXMSG("NuDSTAna",Msg::kError,5)
03470       <<"No I'm not. Why would you do that?"<<endl;
03471     mc.rw=mc.beamWeight;
03472 
03473     //get the output nu to fill,copy mc to the output mc, fill tree
03474     NuMCEvent& mcOutput=output.GetNuMCEventToFill();
03475     mcOutput=mc;
03476     output.FillNuMCEventTree();
03477   }
03478 
03479   //print out the numbers of events
03480   lib.cnt.PrintMicroDST();
03481 
03482   //close the file and write out everything
03483   output.Finish();
03484 }

void NuDSTAna::MakeMicroDstHe ( bool  forceRHC = false  ) 

this function makes a micro DST with std CC reco and cuts It also applies the He reweighting appropriate to the horn current configuration

Definition at line 4421 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuZBeamReweight::ExtractZBeamReweight(), NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuOutputWriter::FillNuMCEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), ReleaseType::GetMCSubVersion(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuOutputWriter::GetNuEventToFill(), NuOutputWriter::GetNuMCEventToFill(), NuZBeamReweight::GetWeightHelium(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), ReleaseType::IsDaikon(), IsGoodPreSelectionCuts(), NuCuts::IsInFidVolTrueEvt(), Msg::kDebug, Msg::kError, Msg::kInfo, NuCuts::kJJE1, BeamType::kL010z185i_rev, SimFlag::kMC, Msg::kWarning, MAXMSG, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuUtilities::PrintRelease(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), SanityCheckedAnaVersion(), UpdatePotSinceLastEvt(), and NuLibrary::zBeamReweight.

04422 {
04425 
04426   //do the histogram IO
04427   NuOutputWriter* poutput=new NuOutputWriter();
04428   NuInputEvents& input=this->DoIO(poutput,"NuDSTPreselHe");
04429 
04430   //get a reference
04431   NuOutputWriter& output=(*poutput);
04432 
04433   //get an instance of the code library
04434   NuLibrary& lib=NuLibrary::Instance();
04435 
04436   //interface for the pids, plots
04437   NuPIDInterface pid;
04438   const NuPlots* plots=0;
04439 
04440   //version to do reco/cuts with
04441   NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kJJE1;
04442 
04446 
04447   //prepare for loop
04448   input.ResetNuEventLoopPositionToStart();
04449 
04450   cout<<endl
04451       <<"************************************************"<<endl
04452       <<"***      Starting main loop over snarls      ***"<<endl
04453       <<"************************************************"<<endl;
04454 
04455   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
04456     lib.cnt.evtCounter++;
04457 
04458     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
04459 
04460     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
04461 
04462     if (nu.simFlag != SimFlag::kMC) {
04463       MSG("NuDSTAna",Msg::kError) << "Cout this is not an MC file -- He reweighting is inappropriate.  Bailing." << endl;
04464       assert(false);
04465     }
04466 
04467     if (ReleaseType::IsDaikon(nu.releaseType) &&
04468         ReleaseType::GetMCSubVersion(nu.releaseType) > 4) {
04469       MSG("NuDSTAna",Msg::kError) << "Trying to make an NuDSTPreselHe for releaseType = "
04470                                   << NuUtilities::PrintRelease(nu.releaseType)
04471                                   << " -- He should already be accounted for.  Use MakeMicroDstJJEPresel().  Bailing." << endl;
04472       assert(false);
04473     }
04474 
04475 
04476     if (forceRHC) {
04477       if (nu.runPeriod == 4) {
04478         MAXMSG("NuDSTAna",Msg::kWarning, 10) << "This file already seems to be RHC -- no forcing need, but done anyways." << endl;
04479       }
04480       else if (nu.runPeriod != 0) {
04481         MAXMSG("NuDSTAna",Msg::kWarning, 10) << "This file has runPeriod=" << nu.runPeriod
04482                                              << " so it should know if it is RHC.  Forcing anyways but you've been warned." << endl;
04483       }
04484 
04485       // Force some parameters:
04486       nu.runPeriod = 4;
04487       nu.hornIsReverse = true;
04488       nu.beamType = BeamType::kL010z185i_rev;
04489 
04490       // Redo the beam weights
04491       lib.zBeamReweight.ExtractZBeamReweight(nu);
04492 
04493       //Reweighting
04494       nu.applyBeamWeight = true;
04495     }
04496 
04497 
04498     //OVERRIDE
04499     nu.anaVersion=this->SanityCheckedAnaVersion
04500       (nu.anaVersion,overrideAnaVersion);
04501 
04502     //count up the pots
04503     Bool_t newEvt=false;
04504     this->UpdatePotSinceLastEvt(nu,newEvt);
04505 
04506 
04507     //RE-RECONSTRUCT the neutrino energy including kNN, reweight
04508     lib.reco.GetEvtEnergy(nu, true);
04509     lib.reco.ApplyReweights(nu);
04510     nu.rw *= lib.zBeamReweight.GetWeightHelium(nu);
04511 
04512     if (nu.coilIsReverse != nu.hornIsReverse) {
04513       MAXMSG("NuDSTAna",Msg::kWarning,50) << "Found a reversed coil event.  Skipping it, but POT counting will be off!" << endl;
04514       continue;
04515     }
04516 
04517     //make the preselection cuts
04518     if (!this->IsGoodPreSelectionCuts(plots,nu)) continue;
04519 
04520     //figure out the first and last time in the whole ntuple
04521     //this is very useful for making plots of quantities vs time
04522     plots->FillNtupleEarliestLatestTime(nu);
04523 
04524     //count the events to print to screen
04525     if (nu.charge==-1) {
04526       lib.cnt.nuNQCounter++;
04527     }
04528     else if (nu.charge==+1) {
04529       lib.cnt.nuPQCounter++;
04530     }
04531 
04532     //copy pots since last event to ntuple for this new evt
04533     newEvt=true;
04534     this->UpdatePotSinceLastEvt(nu,newEvt);
04535 
04536     //get the output nu to fill, copy nu to the output nu, fill tree
04537     NuEvent& nuOutput=output.GetNuEventToFill();
04538     nuOutput=nu;
04539     output.FillNuEventTree();
04540   }
04541 
04545 
04546   input.InitialiseNuMCEventBranch();
04547   input.ResetNuMCEventLoopPositionToStart();
04548 
04549   cout<<endl
04550       <<"************************************************"<<endl
04551       <<"***       Starting loop over truth info      ***"<<endl
04552       <<"************************************************"<<endl;
04553 
04554   for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
04555     lib.cnt.evtCounter++;
04556 
04557     this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
04558 
04559     NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
04560                                          (Msg::kDebug));
04561 
04562     //OVERRIDE
04563     mc.anaVersion=this->SanityCheckedAnaVersion
04564       (mc.anaVersion,overrideAnaVersion);
04565 
04566     MAXMSG("NuDSTAna",Msg::kInfo,5)
04567       <<"energyMC="<<mc.energyMC<<endl;
04568 
04569     //make fid vol cut
04570     if (!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
04571 
04572     //get the output nu to fill,copy mc to the output mc, fill tree
04573     NuMCEvent& mcOutput=output.GetNuMCEventToFill();
04574     mcOutput=mc;
04575     output.FillNuMCEventTree();
04576   }
04577 
04578   //print out the numbers of events
04579   lib.cnt.PrintMicroDST();
04580 
04581   //close the file and write out everything
04582   output.Finish();
04583 }

void NuDSTAna::MakeMicroDstJJEPresel ( int  run = -1  ) 

this function makes a micro DST with std CC reco and cuts

Definition at line 3833 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuOutputWriter::FillNuMCEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuOutputWriter::GetNuEventToFill(), NuOutputWriter::GetNuMCEventToFill(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), IsGoodPreSelectionCuts(), NuCuts::IsInFidVolTrueEvt(), Msg::kDebug, Msg::kInfo, NuCuts::kJJE1, Msg::kWarning, MAXMSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), SanityCheckedAnaVersion(), and UpdatePotSinceLastEvt().

03834 {
03836 
03837   //do the histogram IO
03838   NuOutputWriter* poutput=new NuOutputWriter();
03839   NuInputEvents& input=this->DoIO(poutput,"NuDSTMicroJJEPresel");
03840 
03841 
03842   //get a reference
03843   NuOutputWriter& output=(*poutput);
03844 
03845   //get an instance of the code library
03846   NuLibrary& lib=NuLibrary::Instance();
03847 
03848   //interface for the pids, plots
03849   NuPIDInterface pid;
03850   const NuPlots* plots=0;
03851 
03852   //version to do reco/cuts with
03853   NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kJJE1;
03854 
03858 
03859   //prepare for loop
03860   input.ResetNuEventLoopPositionToStart();
03861 
03862   cout<<endl
03863       <<"************************************************"<<endl
03864       <<"***      Starting main loop over snarls      ***"<<endl
03865       <<"************************************************"<<endl;
03866 
03867   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
03868     lib.cnt.evtCounter++;
03869 
03870     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
03871 
03872     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
03873 
03874     // Stop cutting on data quality for now
03875     //nu.useDBForDataQuality = false;
03876 
03877     //OVERRIDE
03878     nu.anaVersion=this->SanityCheckedAnaVersion
03879       (nu.anaVersion,overrideAnaVersion);
03880 
03881     //count up the pots
03882     Bool_t newEvt=false;
03883     this->UpdatePotSinceLastEvt(nu,newEvt);
03884 
03885     if (run >= 0) {
03886       // LE Times
03887       int startRunI  = 1116619345; // 2005-05-20 20:02:25
03888       int endRunI    = 1140934189; // 2006-02-26 06:09:49
03889       int startRunII = 1158043200; // 2006-09-12 00:06:40
03890       int endRunII   = 1184352157; // 2007-07-13 18:42:37
03891 
03892       bool RunILE =  (nu.timeSec >= startRunI  && nu.timeSec <= endRunI);
03893       bool RunIILE = (nu.timeSec >= startRunII && nu.timeSec <= endRunII);
03894 
03895       if (run == 1 && !RunILE) continue;
03896       if (run == 2 && !RunIILE) continue;
03897       if (!RunILE && !RunIILE) continue;
03898     }
03899 
03900 
03901 
03902 
03903     //RE-RECONSTRUCT the neutrino energy including kNN, reweight
03904     lib.reco.GetEvtEnergy(nu, true);
03905     lib.reco.ApplyReweights(nu);
03906 
03907     if (nu.coilIsReverse != nu.hornIsReverse) {
03908       MAXMSG("NuDSTAna",Msg::kWarning,50) << "Found a " << (nu.coilIsReverse?"reversed":"forward") << " coil event in a " << (nu.hornIsReverse?"reversed":"forward")
03909                                           << " horn run.  The event is being kept, but there may be a problem!  This warning is expected for RHC MC." << endl;
03910     }
03911 
03912 
03913     //    // Hack to fix misreconstructed FD RHC MC
03914     //    if (nu.detector == Detector::kFar && nu.simFlag == SimFlag::kMC && (nu.runPeriod == 4 || nu.runPeriod == 7)) {
03915     //      MAXMSG("NuDSTAna",Msg::kWarning,50) << "Reversing the charge for " << NuUtilities::PrintRelease(nu.releaseType)
03916     //      << " events from RunPeriod 4 and 7.  This is because the first round of FD RHC Daikon07 MC was reconstructed with the wrong field." << endl
03917     //      << "Pleae confirm that results from these files make sense." << endl;
03918     //
03919     //      nu.charge *= -1;
03920     //      nu.sigqp_qp *= -1;
03921     //
03922     //      nu.qp *= -1;
03923     //      nu.qp_rangebiased *= -1;
03924     //      nu.qp_sigqp *= -1;
03925     //      nu.qp1 *= -1;
03926     //      nu.qp_rangebiased1 *= -1;
03927     //      nu.qp_sigqp1 *= -1;
03928     //      nu.qp2 *= -1;
03929     //      nu.qp_rangebiased2 *= -1;
03930     //      nu.qp_sigqp2 *= -1;
03931     //      nu.qp3 *= -1;
03932     //      nu.qp_rangebiased3 *= -1;
03933     //      nu.qp_sigqp3 *= -1;
03934     //    }
03935 
03936     //make the preselection cuts
03937     if (!this->IsGoodPreSelectionCuts(plots,nu)) continue;
03938 
03939     //figure out the first and last time in the whole ntuple
03940     //this is very useful for making plots of quantities vs time
03941     plots->FillNtupleEarliestLatestTime(nu);
03942 
03943     //count the events to print to screen
03944     if (nu.charge==-1) {
03945       lib.cnt.nuNQCounter++;
03946     }
03947     else if (nu.charge==+1) {
03948       lib.cnt.nuPQCounter++;
03949     }
03950 
03951     //copy pots since last event to ntuple for this new evt
03952     newEvt=true;
03953     this->UpdatePotSinceLastEvt(nu,newEvt);
03954 
03955     //get the output nu to fill, copy nu to the output nu, fill tree
03956     NuEvent& nuOutput=output.GetNuEventToFill();
03957     nuOutput=nu;
03958     output.FillNuEventTree();
03959   }
03960 
03964 
03965   input.InitialiseNuMCEventBranch();
03966   input.ResetNuMCEventLoopPositionToStart();
03967 
03968   cout<<endl
03969       <<"************************************************"<<endl
03970       <<"***       Starting loop over truth info      ***"<<endl
03971       <<"************************************************"<<endl;
03972 
03973   for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
03974     lib.cnt.evtCounter++;
03975 
03976     this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
03977 
03978     NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
03979                                          (Msg::kDebug));
03980 
03981     //OVERRIDE
03982     mc.anaVersion=this->SanityCheckedAnaVersion
03983       (mc.anaVersion,overrideAnaVersion);
03984 
03985     MAXMSG("NuDSTAna",Msg::kInfo,5)
03986       <<"energyMC="<<mc.energyMC<<endl;
03987 
03988     //make fid vol cut
03989     if (!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
03990 
03991     //get the output nu to fill,copy mc to the output mc, fill tree
03992     NuMCEvent& mcOutput=output.GetNuMCEventToFill();
03993     mcOutput=mc;
03994     output.FillNuMCEventTree();
03995   }
03996 
03997   //print out the numbers of events
03998   lib.cnt.PrintMicroDST();
03999 
04000   //close the file and write out everything
04001   output.Finish();
04002 }

void NuDSTAna::MakeMicroDstNC2012 ( bool  redoRw = false  ) 

Definition at line 4145 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuZBeamReweight::ExtractZBeamReweight(), NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuOutputWriter::FillNuMCEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuOutputWriter::GetNuEventToFill(), NuOutputWriter::GetNuMCEventToFill(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), NuCuts::IsInFidVolTrueEvt(), NuCuts::kCC0720Std, Msg::kDebug, Msg::kInfo, NuCuts::kPreselectionNC2012, Msg::kWarning, NuCutter::MakePreselectionCuts(), MAXMSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuCutter::Passed(), plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuCutter::PrintSummary(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), NuCutter::ResetStatus(), SanityCheckedAnaVersion(), UpdatePotSinceLastEvt(), and NuLibrary::zBeamReweight.

04146 {
04147   //do the histogram IO
04148   NuOutputWriter* poutput = new NuOutputWriter;
04149   NuInputEvents& input = DoIO(poutput, "NuDSTMicroNC2012");
04150 
04151   //get a reference
04152   NuOutputWriter& output=(*poutput);
04153 
04154   //get an instance of the code library
04155   NuLibrary& lib = NuLibrary::Instance();
04156 
04157   //interface for the pids, plots
04158   NuPIDInterface pid;
04159   const NuPlots* plots = 0;
04160 
04161   //just use the bare bones preselection for the microDSTs
04162   //can't use the NC/CC preselections since they remove RAF events
04163   NuCutter preSelection2012Cutter("PreselectionNC2012");
04164 
04168 
04169   //prepare for loop
04170   input.ResetNuEventLoopPositionToStart();
04171 
04172   cout<<endl
04173       <<"************************************************"<<endl
04174       <<"***      Starting main loop over snarls      ***"<<endl
04175       <<"************************************************"<<endl;
04176 
04177   for(int i = 0; i < input.GetEntriesNuEvent(); ++i){
04178     ++lib.cnt.evtCounter;
04179 
04180     PrintLoopProgress(i, input.GetEntriesNuEvent(), 1);
04181 
04182     NuEvent& nu = const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
04183 
04184     //OVERRIDE the analysis version
04185     nu.anaVersion=SanityCheckedAnaVersion(nu.anaVersion,
04186                                           NuCuts::kPreselectionNC2012);
04187 
04188     //count up the pots
04189     UpdatePotSinceLastEvt(nu, false);
04190 
04191     if (redoRw) {
04192       //Recalculate the SKZP weights
04193 //    nu.reweightVersion=SKZPWeightCalculator::kDogwood5_Daikon07_2012;
04194       lib.zBeamReweight.ExtractZBeamReweight(nu);
04195       nu.applyBeamWeight = true;
04196     }
04197 
04198     //RE-RECONSTRUCT the neutrino energy including kNN, reweight
04199     lib.reco.GetEvtEnergy(nu, true);
04200     lib.reco.ApplyReweights(nu);
04201 
04202     if(nu.coilIsReverse != nu.hornIsReverse){
04203       MAXMSG("NuDSTAna", Msg::kWarning, 50)
04204         << "Found a " << (nu.coilIsReverse ? "reversed" : "forward")
04205         << " coil event in a " << (nu.hornIsReverse ? "reversed" : "forward")
04206         << " horn run.  The event is being kept, but there may be a problem!"
04207         << " This warning is expected for RHC MC." << endl;
04208     }
04209 
04210     // Need to reset otherwise previous event failing will fail this one
04211     preSelection2012Cutter.ResetStatus();
04212 
04213     //make the preselection cuts
04214     preSelection2012Cutter.MakePreselectionCuts(nu);
04215 
04216     // If the event passes preselection then we keep it
04217     if(!preSelection2012Cutter.Passed()) continue;
04218 
04219     //figure out the first and last time in the whole ntuple
04220     //this is very useful for making plots of quantities vs time
04221     plots->FillNtupleEarliestLatestTime(nu);
04222 
04223     //count the events to print to screen
04224     if(nu.charge == -1) ++lib.cnt.nuNQCounter;
04225     if(nu.charge == +1) ++lib.cnt.nuPQCounter;
04226 
04227     //copy pots since last event to ntuple for this new evt
04228     UpdatePotSinceLastEvt(nu, true);
04229 
04230     //get the output nu to fill, copy nu to the output nu, fill tree
04231     output.GetNuEventToFill() = nu;
04232     output.FillNuEventTree();
04233   } // end for i
04234 
04238 
04239   input.InitialiseNuMCEventBranch();
04240   input.ResetNuMCEventLoopPositionToStart();
04241 
04242   cout<<endl
04243       <<"************************************************"<<endl
04244       <<"***       Starting loop over truth info      ***"<<endl
04245       <<"************************************************"<<endl;
04246 
04247   for(int i = 0; i < input.GetEntriesNuMCEvent(); ++i){
04248     ++lib.cnt.evtCounter;
04249 
04250     PrintLoopProgress(i, input.GetEntriesNuMCEvent(), 1);
04251 
04252     NuMCEvent& mc = const_cast<NuMCEvent&>(input.GetNextNuMCEvent(Msg::kDebug));
04253 
04254     //OVERRIDE
04255     mc.anaVersion = SanityCheckedAnaVersion(mc.anaVersion, NuCuts::kCC0720Std);
04256 
04257     MAXMSG("NuDSTAna", Msg::kInfo,5) << "energyMC=" << mc.energyMC << endl;
04258 
04259     //make fid vol cut
04260     if(!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
04261 
04262     if (redoRw) {
04263       lib.zBeamReweight.ExtractZBeamReweight(mc);
04264     }
04265 
04266     //get the output nu to fill,copy mc to the output mc, fill tree
04267     output.GetNuMCEventToFill() = mc;
04268     output.FillNuMCEventTree();
04269   } // end for i
04270 
04271   preSelection2012Cutter.PrintSummary();
04272 
04273   //print out the numbers of events
04274   lib.cnt.PrintMicroDST();
04275 
04276   //close the file and write out everything
04277   output.Finish();
04278 } // MakeMicroDstNC2012

void NuDSTAna::MakeMicroDstWithStdCCRecoAndCuts (  ) 

this function makes a micro DST with std CC reco and cuts

Definition at line 3714 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuOutputWriter::FillNuMCEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuOutputWriter::GetNuEventToFill(), NuOutputWriter::GetNuMCEventToFill(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), IsGoodPreSelectionCuts(), NuCuts::IsInFidVolTrueEvt(), NuCuts::kCC0325Std, Msg::kDebug, Msg::kInfo, MAXMSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), SanityCheckedAnaVersion(), and UpdatePotSinceLastEvt().

03715 {
03717 
03718   //do the histogram IO
03719   NuOutputWriter* poutput=new NuOutputWriter();
03720   NuInputEvents& input=this->DoIO(poutput,"NuDSTMicroStdCC");
03721 
03722   //get a reference
03723   NuOutputWriter& output=(*poutput);
03724 
03725   //get an instance of the code library
03726   NuLibrary& lib=NuLibrary::Instance();
03727   const NuPlots* plots=0;
03728 
03729   //version to do reco/cuts with
03730   NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kCC0325Std;
03731 
03735 
03736   //prepare for loop
03737   input.ResetNuEventLoopPositionToStart();
03738 
03739   cout<<endl
03740       <<"************************************************"<<endl
03741       <<"***      Starting main loop over snarls      ***"<<endl
03742       <<"************************************************"<<endl;
03743 
03744   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
03745     lib.cnt.evtCounter++;
03746 
03747     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
03748 
03749     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
03750 
03751     //OVERRIDE
03752     nu.anaVersion=this->SanityCheckedAnaVersion
03753       (nu.anaVersion,overrideAnaVersion);
03754 
03755     //count up the pots
03756     Bool_t newEvt=false;
03757     this->UpdatePotSinceLastEvt(nu,newEvt);
03758 
03759     //RE-RECONSTRUCT the neutrino energy, including kNN
03760     lib.reco.GetEvtEnergy(nu, true);
03761     lib.reco.ApplyReweights(nu);
03762 
03763     //make the preselection cuts
03764     if (!this->IsGoodPreSelectionCuts(plots,nu)) continue;
03765 
03766     //figure out the first and last time in the whole ntuple
03767     //this is very useful for making plots of quantities vs time
03768     plots->FillNtupleEarliestLatestTime(nu);
03769 
03770     //count the events to print to screen
03771     if (nu.charge==-1) {
03772       lib.cnt.nuNQCounter++;
03773     }
03774     else if (nu.charge==+1) {
03775       lib.cnt.nuPQCounter++;
03776     }
03777 
03778     //copy pots since last event to ntuple for this new evt
03779     newEvt=true;
03780     this->UpdatePotSinceLastEvt(nu,newEvt);
03781 
03782     //get the output nu to fill, copy nu to the output nu, fill tree
03783     NuEvent& nuOutput=output.GetNuEventToFill();
03784     nuOutput=nu;
03785     output.FillNuEventTree();
03786   }
03787 
03791 
03792   input.InitialiseNuMCEventBranch();
03793   input.ResetNuMCEventLoopPositionToStart();
03794 
03795   cout<<endl
03796       <<"************************************************"<<endl
03797       <<"***       Starting loop over truth info      ***"<<endl
03798       <<"************************************************"<<endl;
03799 
03800   for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
03801     lib.cnt.evtCounter++;
03802 
03803     this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
03804 
03805     NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
03806                                          (Msg::kDebug));
03807 
03808     //OVERRIDE
03809     mc.anaVersion=this->SanityCheckedAnaVersion
03810       (mc.anaVersion,overrideAnaVersion);
03811 
03812     MAXMSG("NuDSTAna",Msg::kInfo,5)
03813       <<"energyMC="<<mc.energyMC<<endl;
03814 
03815     //make fid vol cut
03816     if (!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
03817 
03818     //get the output nu to fill,copy mc to the output mc, fill tree
03819     NuMCEvent& mcOutput=output.GetNuMCEventToFill();
03820     mcOutput=mc;
03821     output.FillNuMCEventTree();
03822   }
03823 
03824   //print out the numbers of events
03825   lib.cnt.PrintMicroDST();
03826 
03827   //close the file and write out everything
03828   output.Finish();
03829 }

void NuDSTAna::MakePostPreSelectionPlots ( const NuPlots plots,
const NuEvent nu 
) const [protected]

Definition at line 5650 of file NuDSTAna.cxx.

References NuCutImps::NuCutsSelection::MakePostPreSelectionPlots().

Referenced by CSSAnaRashid(), and NMBAna().

05652 {
05653   // In order to move over to the new cuts system, the cutting logic
05654   // has been moved. See NuCutsSelection.cxx for the implementation of
05655   // this function
05656   NuCutImps::NuCutsSelection cut(plots);
05657   cut.MakePostPreSelectionPlots(nu);
05658 }

void NuDSTAna::MakePurityEfficiencyPlotsCCNC ( TString  ccSelector,
TString  ncSelector 
)

Definition at line 7508 of file NuDSTAna.cxx.

References NuLibrary::cnt, DoIO(), NuCounter::evtCounter, NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), NuInputEvents::InitialiseNuEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, NuCutter::MakeCuts(), MSG, NuCutter::Passed(), NuCutter::PassedUpTo(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuCutter::PrintSummary(), NuInputEvents::ResetNuEventLoopPositionToStart(), and NuCutter::ResetStatus().

07508                                                                                   {
07509 
07510   NuInputEvents& input=this->DoIO(0,"","null");
07511   NuLibrary& lib = NuLibrary::Instance();
07512   NuCutter cutterCC(ccSelector);
07513   NuCutter cutterNC(ncSelector);
07514   TH1::AddDirectory(true);
07515 
07516   // histograms                                                                                                                                                                                    
07517   TH1D * hEfficiencyDenominator_NC   = new TH1D("hEfficiencyDenominator_NC",  "hEfficiencyDenominator_NC", 200, 0, 40);
07518   TH1D * hSelectedEventsAll_NC       = new TH1D("hSelectedEventsAll_NC",      "hSelectedEventsAll_NC",     200, 0, 40);
07519   TH1D * hSelectedEventsSignal_NC    = new TH1D("hSelectedEventsSignal_NC",   "hSelectedEventsSignal_NC",  200, 0, 40);
07520 
07521   TH1D * hEfficiencyDenominator_CC   = new TH1D("hEfficiencyDenominator_CC",  "hEfficiencyDenominator_CC", 200, 0, 40);
07522   TH1D * hSelectedEventsAll_CC       = new TH1D("hSelectedEventsAll_CC",      "hSelectedEventsAll_CC",     200, 0, 40);
07523   TH1D * hSelectedEventsSignal_CC    = new TH1D("hSelectedEventsSignal_CC",   "hSelectedEventsSignal_CC",  200, 0, 40);
07524 
07525   // loop over evts
07526   input.InitialiseNuEventBranch();
07527   input.ResetNuEventLoopPositionToStart();
07528   cout<<endl
07529       <<"************************************************"<<endl
07530       <<"***      Starting main loop over snarls      ***"<<endl
07531       <<"************************************************"<<endl;
07532   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
07533     lib.cnt.evtCounter++;
07534 
07535     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
07536 
07537     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
07538 
07539     // NC                                                                                                                                                                                          
07540     cutterNC.ResetStatus();
07541     cutterNC.MakeCuts(nu);
07542 
07543     if(cutterNC.PassedUpTo("evtLength") && nu.iaction == 0)
07544       hEfficiencyDenominator_NC->Fill(nu.energyNC, nu.rw);
07545 
07546     if(cutterNC.Passed())
07547       hSelectedEventsAll_NC->Fill(nu.energyNC, nu.rw);
07548 
07549     if(cutterNC.Passed() && nu.iaction == 0)
07550       hSelectedEventsSignal_NC->Fill(nu.energyNC, nu.rw);
07551 
07552     // CC
07553     cutterCC.ResetStatus();
07554     cutterCC.MakeCuts(nu);
07555     if (cutterCC.Passed("GoodNumberofTracks")
07556         && cutterCC.Passed("FidVol")
07557         && fabs(nu.inu) == 14
07558         && nu.iaction != 0)
07559       hEfficiencyDenominator_CC->Fill(nu.energyCC, nu.rw);
07560 
07561     if (cutterCC.Passed())
07562       hSelectedEventsAll_CC->Fill(nu.energyCC, nu.rw);
07563 
07564     if (cutterCC.Passed()
07565         && fabs(nu.inu) == 14
07566         && nu.iaction != 0)
07567       hSelectedEventsSignal_CC->Fill(nu.energyCC, nu.rw);
07568 
07569   } //end of looping over snarls
07570 
07571   cout << endl;
07572 
07573   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
07574   cutterNC.PrintSummary();
07575   cutterCC.PrintSummary();
07576 
07577   //print out the numbers of events
07578   lib.cnt.PrintMicroDST();
07579 
07580   MSG("NuAnalysis",Msg::kInfo)
07581     <<" ** Finished MakePurityEfficiencyPlotsCCNC() method **"<<endl;
07582 }

void NuDSTAna::MakeResolutionBins ( TString  xmlfilename,
bool  chargecut,
TString  runStr 
)

Definition at line 10317 of file NuDSTAna.cxx.

References NuXMLConfig::AnaVersionString(), NuReco::ApplyReweights(), NuXMLConfig::BinningScheme(), NuReco::CalcResolution(), NuXMLConfig::ConfigureWeights(), DoIO(), ResInfo::frac_res, NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), info, NuLibrary::Instance(), it, Msg::kDebug, Msg::kInfo, MSG, n, NuBase::PrintLoopProgress(), NuLibrary::reco, NuUtilities::RecoBins(), NuInputEvents::ResetNuEventLoopPositionToStart(), ResInfoFracResLT(), ResInfoRwLT(), ResInfo::rw, and SanityCheckedAnaVersion().

10319 {
10320   NuInputEvents& input = this->DoIO();
10321 
10322   NuXMLConfig* xmlConfig = new NuXMLConfig(xmlfilename);
10323 
10324   //get an instance of the code library
10325   NuLibrary& lib = NuLibrary::Instance();
10326 
10327   //Binning scheme
10328   NuBinningScheme::NuBinningScheme_t binningScheme =
10329     NuBinningScheme::NuBinningScheme_t(xmlConfig->BinningScheme());
10330 
10331   // Create the cutter object
10332   NuCutter cutter(xmlConfig->AnaVersionString(), 0);
10333 
10334   //version to do reco/cuts with
10335   NuCuts::NuAnaVersion_t overrideAnaVersion =
10336     static_cast<NuCuts::NuAnaVersion_t>(cutter.AnaVersion());
10337 
10338   vector<Double_t> recoBins = NuUtilities::RecoBins(binningScheme);
10339 
10340   // This is the structure we will be filling. One vector of events for each
10341   // energy bin.
10342   vector<vector<ResInfo> > infos;
10343   infos.resize(recoBins.size());
10344 
10345 
10346   input.ResetNuEventLoopPositionToStart();
10347 
10348   cout<<endl
10349       <<"************************************************"<<endl
10350       <<"***      Starting main loop over snarls      ***"<<endl
10351       <<"************************************************"<<endl;
10352   for(Int_t j = 0; j < input.GetEntriesNuEvent(); ++j){
10353     this->PrintLoopProgress(j, input.GetEntriesNuEvent(), 1);
10354 
10355     NuEvent& nu = const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
10356 
10357     //OVERRIDE
10358     nu.anaVersion = this->SanityCheckedAnaVersion
10359       (nu.anaVersion, overrideAnaVersion);
10360 
10361     // Configure reweighting based on the XML file
10362     xmlConfig->ConfigureWeights(nu);
10363 
10364     //RE-RECONSTRUCT the neutrino energy
10365     //We shouldn't have to do this off of MicroDST's
10366     lib.reco.GetEvtEnergy(nu, false);
10367     lib.reco.ApplyReweights(nu);
10368     lib.reco.CalcResolution(nu);
10369 
10370     //If we're training on numu's, make sure charge < 0
10371     if(chargecut && nu.charge > 0) continue;
10372 
10373     // Do the cuts:
10374     cutter.MakeCuts(nu);
10375     // did we pass the (CC) selection?
10376     if (cutter.Failed()) continue;
10377 
10378     // The information we'll be saving
10379     ResInfo info;
10380     info.frac_res = nu.resolution/nu.energy;
10381     info.rw = nu.rw;
10382     // Work out what energy bin it's in
10383     unsigned int binIdx = std::lower_bound(recoBins.begin(), recoBins.end(), nu.energy)-recoBins.begin()-1;
10384     assert(binIdx >= infos.size()-1 || (recoBins[binIdx] < nu.energy && recoBins[binIdx+1] >= nu.energy));
10385     // Events with energy >200GeV apparently exist...
10386     if(binIdx >= infos.size()) binIdx = infos.size()-1;
10387     infos[binIdx].push_back(info);
10388   } // End of loop over summary tree
10389 
10390   cutter.PrintSummary();
10391 
10392   // Now we make a tree to store the cut information in
10393 
10394   //Variables to stores in cut tree
10395   double cut_position[6];  // array to contain the quantiles
10396   // Description of which energy bin we're in
10397   Double_t low_res_bin_edge;
10398   Double_t high_res_bin_edge;
10399 
10400   //Valid runStr:  r1, r2, r3, phe
10401   TString cutfilename = chargecut ? "cuts_numu_"+runStr+".root" : "cuts_numubar_"+runStr+".root";
10402 
10403   TFile* cuttree = new TFile(cutfilename, "RECREATE");
10404   TTree* cuts;
10405   if(runStr=="r1")cuts = new TTree("cuts_r1", "cuts_r1");
10406   else if(runStr=="r2")cuts = new TTree("cuts_r2", "cuts_r2");
10407   else if(runStr=="r3")cuts = new TTree("cuts_r3", "cuts_r3");
10408   else if(runStr=="pHE")cuts = new TTree("cuts_phe", "cuts_phe");
10409     else {
10410     cout<<"Uh oh! Consider adding a new run period to the resolution function!"<<endl;
10411     cuts = new TTree("cuts","cuts");
10412   }
10413 
10414   cuts->Branch("lowedge", &low_res_bin_edge, "lowedge/D");
10415   cuts->Branch("highedge", &high_res_bin_edge, "highedge/D");
10416   cuts->Branch("quantiles", cut_position, "quantiles[6]/D");
10417 
10418   // Go over all the energy bins we have
10419   for(unsigned int binIdx = 0; binIdx < infos.size(); ++binIdx){
10420     vector<ResInfo>& is = infos[binIdx];
10421 
10422     low_res_bin_edge = recoBins[binIdx];
10423     high_res_bin_edge = recoBins[binIdx+1];
10424 
10425     // Sort the list of resolutions
10426     std::sort(is.begin(), is.end(), ResInfoFracResLT);
10427 
10428 //     cout << "Events in this bin:" << endl;
10429 //     for(unsigned int n = 0; n < is.size(); ++n) cout << is[n].frac_res << " ";
10430 //     cout << endl;
10431 
10432     // And integrate the weights up
10433     const int N = is.size();
10434     for(int n = 1; n < N; ++n){
10435       is[n].rw += is[n-1].rw;
10436     }
10437 
10438     const double totWeight = is[N-1].rw;
10439 
10440     // Make sure to get all the events (1e10 ~ infinity)
10441     cut_position[0] = 0;
10442     cut_position[5] = 1e10;
10443     // For the remaining internal edges
10444     for(int edge = 1; edge < 5; ++edge){
10445       const double target = (edge/5.0)*totWeight;
10446       ResInfo targetInfo;
10447       targetInfo.rw = target;
10448       // Get an iterator to where this edge goes
10449       vector<ResInfo>::iterator it =
10450         std::lower_bound(is.begin(), is.end(), targetInfo, ResInfoRwLT);
10451       if(it == is.end() || it+1 == is.end()){
10452         // If it's at the end then it might as well be infinity
10453         cut_position[edge] = 1e10;
10454       }
10455       else{
10456         // Otherwise we go halfway between the neighbouring events.
10457         // ROOT actually does a linear interpolation here.
10458             cut_position[edge] = (it->frac_res + (it+1)->frac_res)/2;
10459       }
10460     } // end for edge
10461 
10462 //     cout << "Bin edges:" << endl;
10463 //     for(int n = 0; n < 6; ++n) cout << cut_position[n] << " ";
10464 //     cout << endl;
10465 
10466     cuts->Fill();
10467   } // end for binIdx
10468 
10469   cuttree->cd();
10470   cuts->Write();
10471   cuttree->Close();
10472 
10473   MSG("NuAnalysis",Msg::kInfo)
10474     <<" ** Finished making resolution cuts **"<<endl;
10475 }

void NuDSTAna::MakeRoIDTrainingSet ( TString  xmlFileName  ) 

Definition at line 7430 of file NuDSTAna.cxx.

References NuXMLConfig::AnaVersionString(), NuLibrary::cnt, DoIO(), NuCounter::evtCounter, NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), NuInputEvents::InitialiseNuEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, MSG, NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), and NuInputEvents::ResetNuEventLoopPositionToStart().

07430                                                      {
07431 
07432   NuInputEvents& input=this->DoIO(0,"","null");
07433 
07434   //get an instance of the code library
07435   NuLibrary& lib = NuLibrary::Instance();
07436 
07437   MSG("NuDSTAna",Msg::kInfo) << "Using xml file " << xmlFileName << endl;
07438   const NuXMLConfig* xmlConfig = new NuXMLConfig(xmlFileName);
07439   xmlConfig->Write();
07440 
07441   // Create the cutter objects
07442   NuCutter cutter(xmlConfig->AnaVersionString(), 0);
07443   TH1::AddDirectory(true);
07444 
07445   // roID
07446   Float_t knn01TrkActivePlanes;
07447   Float_t knn10TrkMeanPh;
07448   Float_t knn20LowHighPh;
07449   Float_t knn40TrkPhFrac;
07450   Bool_t signalMC;
07451 
07452   // PID training tree
07453   TTree* trainTreePID = new TTree("trainPID", "trainPID"); 
07454   trainTreePID->Branch("knn01TrkActivePlanes", &knn01TrkActivePlanes);
07455   trainTreePID->Branch("knn10TrkMeanPh", &knn10TrkMeanPh);
07456   trainTreePID->Branch("knn20LowHighPh", &knn20LowHighPh);
07457   trainTreePID->Branch("knn40TrkPhFrac", &knn40TrkPhFrac);
07458   trainTreePID->Branch("signalMC", &signalMC);
07459 
07460   // loop over evts
07461   input.InitialiseNuEventBranch();
07462   input.ResetNuEventLoopPositionToStart();
07463   cout<<endl
07464       <<"************************************************"<<endl
07465       <<"***      Starting main loop over snarls      ***"<<endl
07466       <<"************************************************"<<endl;
07467   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
07468     lib.cnt.evtCounter++;
07469 
07470     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
07471 
07472     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
07473 
07474     knn01TrkActivePlanes = nu.knn01TrkActivePlanes;
07475     knn10TrkMeanPh = nu.knn10TrkMeanPh;
07476     knn20LowHighPh = nu.knn20LowHighPh;
07477     knn40TrkPhFrac = nu.knn40TrkPhFrac;
07478     signalMC = (abs(nu.trkIdMC) == 13); 
07479 
07480     // setup selection
07481     cutter.ResetStatus();
07482     cutter.MakeCuts(nu);
07483 
07484     // pre-pre selection (Ntracks and fid vol)
07485     if (cutter.Failed("GoodNumberofTracks")) continue;
07486     if (cutter.Failed("FidVol")) continue;
07487 
07488     // fill the train tree for PID
07489     if(knn01TrkActivePlanes < 0 || knn10TrkMeanPh < 0 || knn20LowHighPh < 0 || knn40TrkPhFrac < 0) continue;
07490 
07491     trainTreePID->Fill();
07492 
07493   } // end of looping over snarls
07494 
07495   cout<<endl;
07496   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
07497   cutter.PrintSummary();
07498 
07499   //print out the numbers of events
07500   lib.cnt.PrintMicroDST();
07501 
07502   MSG("NuAnalysis",Msg::kInfo)
07503     <<" ** Finished MakeRoIDTrainingSet() method **"<<endl;
07504 
07505 }

void NuDSTAna::MakeSelMicroDST ( Int_t  Selector  ) 

this function makes a micro DST with selector 11 cuts

Definition at line 3590 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuPlots::FillNtupleEarliestLatestTime(), NuOutputWriter::FillNuEventTree(), NuOutputWriter::FillNuMCEventTree(), NuOutputWriter::Finish(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuOutputWriter::GetNuEventToFill(), NuOutputWriter::GetNuMCEventToFill(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), IsGoodPreSelectionCuts(), IsGoodStdCuts(), NuCuts::IsInFidVolTrueEvt(), Msg::kDebug, Msg::kInfo, MAXMSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), SanityCheckedAnaVersion(), and UpdatePotSinceLastEvt().

03591 {
03592 
03594 
03595   //do the histogram IO
03596   NuOutputWriter* poutput=new NuOutputWriter();
03597   NuInputEvents& input=this->DoIO(poutput,"NuDSTMicroNMB11");
03598 
03599   //get a reference
03600   NuOutputWriter& output=(*poutput);
03601 
03602   //get an instance of the code library
03603   NuLibrary& lib=NuLibrary::Instance();
03604   const NuPlots* plots=0;
03605 
03606   //version to do reco/cuts with
03607   NuCuts::NuAnaVersion_t overrideAnaVersion=
03608     (NuCuts::NuAnaVersion_t)selector;
03609 
03613 
03614   //prepare for loop
03615   input.ResetNuEventLoopPositionToStart();
03616 
03617   cout<<endl
03618       <<"************************************************"<<endl
03619       <<"***      Starting main loop over snarls      ***"<<endl
03620       <<"************************************************"<<endl;
03621 
03622   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
03623     lib.cnt.evtCounter++;
03624 
03625     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
03626 
03627     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
03628 
03629     //OVERRIDE
03630     nu.anaVersion=this->SanityCheckedAnaVersion
03631       (nu.anaVersion,overrideAnaVersion);
03632 
03633     //count up the pots
03634     Bool_t newEvt=false;
03635     this->UpdatePotSinceLastEvt(nu,newEvt);
03636 
03637     //RE-RECONSTRUCT the neutrino energy, including kNN
03638     lib.reco.GetEvtEnergy(nu, true);
03639     lib.reco.ApplyReweights(nu);
03640 
03641     //make the preselection cuts
03642     if (!this->IsGoodPreSelectionCuts(plots,nu)) continue;
03643 
03644     // Make the advanced cuts
03645     if (!this->IsGoodStdCuts(plots,nu)) continue;
03646 
03647     //figure out the first and last time in the whole ntuple
03648     //this is very useful for making plots of quantities vs time
03649     plots->FillNtupleEarliestLatestTime(nu);
03650 
03651     //count the events to print to screen
03652     if (nu.charge==-1) {
03653       lib.cnt.nuNQCounter++;
03654     }
03655     else if (nu.charge==+1) {
03656       lib.cnt.nuPQCounter++;
03657     }
03658 
03659     //copy pots since last event to ntuple for this new evt
03660     newEvt=true;
03661     this->UpdatePotSinceLastEvt(nu,newEvt);
03662 
03663     //get the output nu to fill, copy nu to the output nu, fill tree
03664     NuEvent& nuOutput=output.GetNuEventToFill();
03665     nuOutput=nu;
03666     output.FillNuEventTree();
03667   }
03668 
03672 
03673   input.InitialiseNuMCEventBranch();
03674   input.ResetNuMCEventLoopPositionToStart();
03675 
03676   cout<<endl
03677       <<"************************************************"<<endl
03678       <<"***       Starting loop over truth info      ***"<<endl
03679       <<"************************************************"<<endl;
03680 
03681   for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
03682     lib.cnt.evtCounter++;
03683 
03684     this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
03685 
03686     NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
03687                                          (Msg::kDebug));
03688 
03689     //OVERRIDE
03690     mc.anaVersion=this->SanityCheckedAnaVersion
03691       (mc.anaVersion,overrideAnaVersion);
03692 
03693     MAXMSG("NuDSTAna",Msg::kInfo,5)
03694       <<"energyMC="<<mc.energyMC<<endl;
03695 
03696     //make fid vol cut
03697     if (!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
03698 
03699     //get the output nu to fill,copy mc to the output mc, fill tree
03700     NuMCEvent& mcOutput=output.GetNuMCEventToFill();
03701     mcOutput=mc;
03702     output.FillNuMCEventTree();
03703   }
03704 
03705   //print out the numbers of events
03706   lib.cnt.PrintMicroDST();
03707 
03708   //close the file and write out everything
03709   output.Finish();
03710 }

void NuDSTAna::MakeShwEnkNNTestingSet ( TString  xmlFileName  ) 

Definition at line 7296 of file NuDSTAna.cxx.

References NuXMLConfig::AnaVersionString(), NuLibrary::cnt, DoIO(), MuELoss::e, NuCounter::evtCounter, NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), NuInputEvents::InitialiseNuEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, Detector::kNear, MSG, NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), and NuInputEvents::ResetNuEventLoopPositionToStart().

07296                                                         {
07297 
07298   NuInputEvents& input=this->DoIO(0,"","null");
07299 
07300   //get an instance of the code library
07301   NuLibrary& lib = NuLibrary::Instance();
07302 
07303   MSG("NuDSTAna",Msg::kInfo) << "Using xml file " << xmlFileName << endl;
07304   const NuXMLConfig* xmlConfig = new NuXMLConfig(xmlFileName);
07305   xmlConfig->Write();
07306 
07307   // Create the cutter objects
07308   NuCutter cutter(xmlConfig->AnaVersionString(), 0);
07309   TH1::AddDirectory(true);
07310 
07311   Float_t trkShwEnNearDW;
07312   Float_t nplaneShw;
07313   Float_t sum2Shw;
07314   Float_t shwEnMC;
07315 
07316   Float_t sumShws;
07317   Float_t nplaneAllShws;
07318   Float_t nstripAllShws;
07319   Float_t shwSumHitLengthAllShws;
07320 
07321   Float_t shwEnLinCCCor;
07322   Float_t shwEnkNN;
07323   Float_t shwEnkNNPlus;
07324   Float_t shwEnkNNNoCor;
07325   Float_t shwEnkNNPlusNoCor;
07326   Float_t rw;
07327 
07328   // shws
07329   TTree* testTreeShw = new  TTree("testShw", "testShw"); 
07330   testTreeShw->Branch("trkShwEnNearDW", &trkShwEnNearDW);
07331   testTreeShw->Branch("nplaneShw", &nplaneShw);
07332   testTreeShw->Branch("sum2Shw", &sum2Shw);
07333   testTreeShw->Branch("shwEnMC", &shwEnMC);  
07334 
07335   testTreeShw->Branch("sumShws",       &sumShws);  
07336   testTreeShw->Branch("nplaneAllShws", &nplaneAllShws);  
07337   testTreeShw->Branch("nstripAllShws", &nstripAllShws);  
07338   testTreeShw->Branch("shwSumHitLengthAllShws", &shwSumHitLengthAllShws);  
07339 
07340   testTreeShw->Branch("shwEnLinCCCor", &shwEnLinCCCor);  
07341   testTreeShw->Branch("shwEnkNN", &shwEnkNN);  
07342   testTreeShw->Branch("shwEnkNNPlus", &shwEnkNNPlus);  
07343   testTreeShw->Branch("shwEnkNNNoCor", &shwEnkNNNoCor);  
07344   testTreeShw->Branch("shwEnkNNPlusNoCor", &shwEnkNNPlusNoCor);  
07345   testTreeShw->Branch("rw", &rw);  
07346 
07347   TRandom3 randomNumber(1); 
07348 
07349   // loop over evts
07350   input.InitialiseNuEventBranch();
07351   input.ResetNuEventLoopPositionToStart();
07352   cout<<endl
07353       <<"************************************************"<<endl
07354       <<"***      Starting main loop over snarls      ***"<<endl
07355       <<"************************************************"<<endl;
07356   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
07357     lib.cnt.evtCounter++;
07358 
07359     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
07360 
07361     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
07362 
07363     trkShwEnNearDW = nu.trkShwEnNearDW;
07364     nplaneShw = nu.nplaneShw;
07365     sum2Shw = nu.shwEnLinCCCor;
07366     shwEnMC = nu.shwEnMC;
07367     if(nu.nshw > 1)
07368       sum2Shw += nu.shwEnLinCCCor2;
07369 
07370     nplaneShw      += randomNumber.Gaus(0, 1e-5);
07371     sum2Shw        += randomNumber.Gaus(0, 1e-5);
07372     trkShwEnNearDW += randomNumber.Gaus(0, 1e-5);
07373 
07374     nplaneAllShws          = nu.nplaneAllShws; 
07375     shwSumHitLengthAllShws = nu.shwSumHitLengthAllShws;
07376     sumShws = 
07377       (nu.shwExists1) ? nu.shwEnLinCCCor1 : 0. + 
07378       (nu.shwExists2) ? nu.shwEnLinCCCor2 : 0. + 
07379       (nu.shwExists3) ? nu.shwEnLinCCCor3 : 0. + 
07380       (nu.shwExists4) ? nu.shwEnLinCCCor4 : 0. + 
07381       (nu.shwExists5) ? nu.shwEnLinCCCor5 : 0.;
07382 
07383     nstripAllShws = 
07384       (nu.shwExists1) ? nu.nstripShw1 : 0. + 
07385       (nu.shwExists2) ? nu.nstripShw2 : 0. + 
07386       (nu.shwExists3) ? nu.nstripShw3 : 0. + 
07387       (nu.shwExists4) ? nu.nstripShw4 : 0. + 
07388       (nu.shwExists5) ? nu.nstripShw5 : 0.;
07389 
07390     shwEnLinCCCor = nu.shwEnLinCCCor;
07391     shwEnkNN = nu.shwEnkNN;
07392     shwEnkNNPlus = nu.shwEnkNNPlus;
07393     shwEnkNNNoCor = nu.shwEnkNNNoCor;
07394     shwEnkNNPlusNoCor = nu.shwEnkNNPlusNoCor;
07395     rw = nu.rw;
07396     
07397     // setup selection
07398     cutter.ResetStatus();
07399     cutter.MakeCuts(nu);
07400 
07401     // apply selection
07402     if(Detector::Detector_t(nu.detector) == Detector::kNear && cutter.Failed("InFidVolCCOrNC")) continue;
07403     if(cutter.Failed("FidVol")) continue;
07404     if(cutter.Failed("pid")) continue;    
07405 
07406     if(nu.charge == 1) continue;
07407     if(nu.nshw < 1) continue;
07408 
07409     // fill the train tree for shw    
07410     testTreeShw->Fill(); 
07411 
07412   } // end of looping over snarls
07413 
07414   cout<<endl;
07415   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
07416   cutter.PrintSummary();
07417 
07418   //print out the numbers of events
07419   lib.cnt.PrintMicroDST();
07420 
07421   MSG("NuAnalysis",Msg::kInfo)
07422     <<" ** Finished MakeShwEnkNNTrainingSet() method **"<<endl;
07423 
07424 }

void NuDSTAna::MakeShwEnkNNTrainingSet ( TString  xmlFileName  ) 

Definition at line 7177 of file NuDSTAna.cxx.

References NuXMLConfig::AnaVersionString(), NuLibrary::cnt, DoIO(), MuELoss::e, NuCounter::evtCounter, NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetNextNuEvent(), NuInputEvents::InitialiseNuEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kInfo, Detector::kNear, MSG, NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), and NuInputEvents::ResetNuEventLoopPositionToStart().

07177                                                          {
07178 
07179   NuInputEvents& input=this->DoIO(0,"","null");
07180 
07181   //get an instance of the code library
07182   NuLibrary& lib = NuLibrary::Instance();
07183 
07184   MSG("NuDSTAna",Msg::kInfo) << "Using xml file " << xmlFileName << endl;
07185   const NuXMLConfig* xmlConfig = new NuXMLConfig(xmlFileName);
07186   xmlConfig->Write();
07187 
07188   // Create the cutter objects
07189   NuCutter cutter(xmlConfig->AnaVersionString(), 0);
07190   TH1::AddDirectory(true);
07191 
07192   Float_t trkShwEnNearDW;
07193   Float_t nplaneShw;
07194   Float_t sum2Shw;
07195   Float_t shwEnMC;
07196 
07197   Float_t sumShws;
07198   Float_t nplaneAllShws;
07199   Float_t nstripAllShws;
07200   Float_t shwSumHitLengthAllShws;
07201 
07202   // shws
07203   TTree* trainTreeShw = new  TTree("trainShw", "trainShw"); 
07204   trainTreeShw->Branch("trkShwEnNearDW", &trkShwEnNearDW);
07205   trainTreeShw->Branch("nplaneShw", &nplaneShw);
07206   trainTreeShw->Branch("sum2Shw", &sum2Shw);
07207   trainTreeShw->Branch("shwEnMC", &shwEnMC);  
07208 
07209   trainTreeShw->Branch("sumShws", &sumShws);  
07210   trainTreeShw->Branch("nplaneAllShws", &nplaneAllShws);  
07211   trainTreeShw->Branch("nstripAllShws", &nstripAllShws);  
07212   trainTreeShw->Branch("shwSumHitLengthAllShws", &shwSumHitLengthAllShws);  
07213 
07214   TRandom3 randomNumber(1); 
07215 
07216   // loop over evts
07217   input.InitialiseNuEventBranch();
07218   input.ResetNuEventLoopPositionToStart();
07219   cout<<endl
07220       <<"************************************************"<<endl
07221       <<"***      Starting main loop over snarls      ***"<<endl
07222       <<"************************************************"<<endl;
07223   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
07224     lib.cnt.evtCounter++;
07225 
07226     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
07227 
07228     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
07229 
07230     trkShwEnNearDW = nu.trkShwEnNearDW;
07231     nplaneShw = nu.nplaneShw;
07232     sum2Shw = nu.shwEnLinCCCor;
07233     shwEnMC = nu.shwEnMC;
07234     if(nu.nshw > 1)
07235       sum2Shw += nu.shwEnLinCCCor2;
07236 
07237     nplaneShw      += randomNumber.Gaus(0, 1e-5);
07238     sum2Shw        += randomNumber.Gaus(0, 1e-5);
07239     trkShwEnNearDW += randomNumber.Gaus(0, 1e-5);
07240 
07241 
07242     nplaneAllShws          = nu.nplaneAllShws; 
07243     shwSumHitLengthAllShws = nu.shwSumHitLengthAllShws;
07244     sumShws = 
07245       (nu.shwExists1) ? nu.shwEnLinCCCor1 : 0. + 
07246       (nu.shwExists2) ? nu.shwEnLinCCCor2 : 0. + 
07247       (nu.shwExists3) ? nu.shwEnLinCCCor3 : 0. + 
07248       (nu.shwExists4) ? nu.shwEnLinCCCor4 : 0. + 
07249       (nu.shwExists5) ? nu.shwEnLinCCCor5 : 0.;
07250 
07251     nstripAllShws = 
07252       (nu.shwExists1) ? nu.nstripShw1 : 0. + 
07253       (nu.shwExists2) ? nu.nstripShw2 : 0. + 
07254       (nu.shwExists3) ? nu.nstripShw3 : 0. + 
07255       (nu.shwExists4) ? nu.nstripShw4 : 0. + 
07256       (nu.shwExists5) ? nu.nstripShw5 : 0.;
07257 
07258     sumShws                += randomNumber.Gaus(0, 1e-5);
07259     nplaneAllShws          += randomNumber.Gaus(0, 1e-5);
07260     nstripAllShws          += randomNumber.Gaus(0, 1e-5);
07261     shwSumHitLengthAllShws += randomNumber.Gaus(0, 1e-5);
07262 
07263     // setup selection
07264     cutter.ResetStatus();
07265     cutter.MakeCuts(nu);
07266 
07267     // apply selection
07268     if(Detector::Detector_t(nu.detector) == Detector::kNear && cutter.Failed("InFidVolCCOrNC")) continue;
07269     if(cutter.Failed("FidVol")) continue;
07270     if(cutter.Failed("pid")) continue;
07271 
07272     if(nu.qp > 1) continue;
07273     if(nu.nshw < 1) continue;
07274 
07275     // fill the train tree for shw    
07276     trainTreeShw->Fill(); 
07277 
07278   } // end of looping over snarls
07279 
07280   cout<<endl;
07281   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
07282   cutter.PrintSummary();
07283 
07284   //print out the numbers of events
07285   lib.cnt.PrintMicroDST();
07286 
07287   MSG("NuAnalysis",Msg::kInfo)
07288     <<" ** Finished MakeShwEnkNNTrainingSet() method **"<<endl;
07289 
07290 }

void NuDSTAna::MMAna ( std::string  sOutputFileName = ""  ) 

Definition at line 5689 of file NuDSTAna.cxx.

References DoIO().

05690 {
05691   this->DoIO(0,"",sOutputFileName);
05692 }

void NuDSTAna::MMRereco ( std::string  sOutputFileName,
const NuXMLConfig xmlConfig 
)

Definition at line 5733 of file NuDSTAna.cxx.

References NuXMLConfig::AnaVersionString(), NuReco::ApplyReweights(), NuXMLConfig::BinningScheme(), NuReco::CalcResolution(), NuLibrary::cnt, NuXMLConfig::ConfigureWeights(), NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuHistos::FillMatrixMethodHistos(), NuHistos::FillMatrixMethodNCHistos(), NuPlots::FillTrueFidEnergySpect(), NuCuts::FreeCuts(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuXMLConfig::GetUnknownKey(), NuLibrary::hist, NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kError, Msg::kInfo, NuCuts::kNMBFree, Msg::kWarning, MAXMSG, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, Oscillate(), plots(), NuBase::PrintLoopProgress(), NuSystematic::PrintState(), NuUtilities::ProgressBar(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), SanityCheckedAnaVersion(), NuSystematic::SetCCSelector(), NuSystematic::SetNCSelector(), NuSystematic::SetNuBarSelector(), and NuSystematic::Shift().

05735 {
05736   NuInputEvents& input=this->DoIO(0,"",sOutputFileName);
05737 
05738   //get an instance of the code library
05739   NuLibrary& lib=NuLibrary::Instance();
05740 
05741   //get an object to fill plots
05742   const NuPlots* plots=new NuPlots();
05743 
05744     xmlConfig->Write();
05745 
05746   //Binning scheme
05747   NuBinningScheme::NuBinningScheme_t binningScheme =
05748     static_cast<NuBinningScheme::NuBinningScheme_t>(xmlConfig->BinningScheme());
05749 
05750   // Create the cutter objects
05751   NuCutter cutter(xmlConfig->AnaVersionString(), plots);
05752   NuCutter NCcutter;
05753 
05754   //version to do reco/cuts with
05755   NuCuts::NuAnaVersion_t overrideAnaVersion =
05756     static_cast<NuCuts::NuAnaVersion_t>(cutter.AnaVersion());
05757 
05758   NuSystematic syst(*xmlConfig);
05759   syst.SetNuBarSelector(cutter.GetCut());
05760   syst.SetCCSelector(cutter.GetCut());
05761 
05762 
05763 
05764   // Check to see if the user wants to do an NC cut along with the CC one
05765   if (! xmlConfig->GetUnknownKey("anaVersionNC").IsNull()) {
05766     MSG("NuDSTAna",Msg::kInfo) << "Found anaVersionNC in configuration... Doing additional NC cuts" << endl;
05767     NCcutter.SetCut(xmlConfig->GetUnknownKey("anaVersionNC"));
05768     syst.SetNCSelector(NCcutter.GetCut());
05769   }
05770   else{
05771     MSG("NuDSTAna",Msg::kInfo) << "Didn't find anaVersionNC key in configuration. No NC histograms will be produced." << endl;
05772   }
05773 
05774   int zBin = -1;
05775   int boundaries[] = {0, 20, 30, 40, 50, 60, 80};
05776   // Check to see if the user wants to do an NC cut along with the CC one
05777   if (! xmlConfig->GetUnknownKey("zVtxBin").IsNull()) {
05778     TString sBin = xmlConfig->GetUnknownKey("zVtxBin");
05779     cout << "zVtxBin = " << sBin << endl;
05780     zBin = sBin.Atoi();
05781     MSG("NuDSTAna",Msg::kInfo) << "Found z vertex bin in configuration... using bin "
05782     << zBin << " which includes planes " << boundaries[zBin] << " to " << boundaries[zBin+1] << endl;
05783   }
05784 
05785   int rBin = -1;
05786   double Rboundaries[] = {0.7, 1.1, 1.5, 1.9, 2.3};
05787   // Check to see if the user wants to do an NC cut along with the CC one
05788   if (! xmlConfig->GetUnknownKey("rVtxBin").IsNull()) {
05789     TString sBin = xmlConfig->GetUnknownKey("rVtxBin");
05790     cout << "rVtxBin = " << sBin << endl;
05791     rBin = sBin.Atoi();
05792     MSG("NuDSTAna",Msg::kInfo) << "Found r vertex bin in configuration... using bin "
05793     << rBin << " which includes " << Rboundaries[rBin] << " to " << Rboundaries[rBin+1] << endl;
05794   }
05795 
05796 
05797   int qBin = -1;
05798   // Check to see if the user wants to do an NC cut along with the CC one
05799   if (! xmlConfig->GetUnknownKey("quadBin").IsNull()) {
05800     TString sBin = xmlConfig->GetUnknownKey("quadBin");
05801     cout << "quadBin = " << sBin << endl;
05802     qBin = sBin.Atoi();
05803     MSG("NuDSTAna",Msg::kInfo) << "Found quadrant bin in configuration... using bin "
05804     << qBin << endl;
05805   }
05806 
05807 
05808   int forcekNN = 0;
05809   TString tmp = xmlConfig->GetUnknownKey("kNNShowerEnergy");
05810   tmp.ToLower();
05811   if (! tmp.IsNull()) {
05812     if (tmp == "yes") {
05813       MSG("NuDSTAna",Msg::kInfo) << "Forcing kNN shower energy" << endl;
05814       forcekNN = 1;
05815     }
05816     else if (tmp == "no") {
05817       MSG("NuDSTAna",Msg::kInfo) << "Forcing calo. shower energy" << endl;
05818       forcekNN = -1;
05819     }
05820     else {
05821       MSG("NuDSTAna",Msg::kInfo) << "Not forcing shower energy -- yes or no required (got "
05822       << xmlConfig->GetUnknownKey("kNNShowerEnergy") << ")" << endl;
05823     }
05824   }
05825 
05826 
05827   double qpsqpCut = 0;
05828   if (! xmlConfig->GetUnknownKey("qpsqp").IsNull()) {
05829     TString sCut = xmlConfig->GetUnknownKey("qpsqp");
05830     cout << "qpsqp = " << sCut << endl;
05831     qpsqpCut = sCut.Atof();
05832     MSG("NuDSTAna",Msg::kInfo) << "Found extra qpsqp cut of "
05833     << qpsqpCut << endl;
05834   }
05835 
05836 
05837   double relangCut = 0;
05838   if (! xmlConfig->GetUnknownKey("relang").IsNull()) {
05839     TString sCut = xmlConfig->GetUnknownKey("relang");
05840     cout << "relang = " << sCut << endl;
05841     relangCut = sCut.Atof();
05842     MSG("NuDSTAna",Msg::kInfo) << "Found extra relang cut of "
05843     << relangCut << endl;
05844   }
05845 
05846   syst.PrintState();
05847 
05851 
05852   input.ResetNuEventLoopPositionToStart();
05853 
05854   cout<<endl
05855       <<"************************************************"<<endl
05856       <<"***      Starting main loop over snarls      ***"<<endl
05857       <<"************************************************"<<endl;
05858   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
05859 
05860     lib.cnt.evtCounter++;
05861 
05862     NuUtilities::ProgressBar(i,input.GetEntriesNuEvent(),5);
05863 
05864     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
05865 
05866     //OVERRIDE
05867     //Selection
05868     nu.anaVersion=this->SanityCheckedAnaVersion
05869       (nu.anaVersion,overrideAnaVersion);
05870 
05871     if (nu.hornIsReverse && nu.beamType == 3) {
05872       nu.beamType = 41;
05873       nu.beamTypeDB = 41;
05874       MAXMSG("NuDSTAna",Msg::kError,30) << "Horrible hack to fix RHC beamtype." << endl;
05875       //assert(false);
05876     }
05877 
05878     // Configure reweighting based on the XML file
05879     xmlConfig->ConfigureWeights(nu);
05880 
05881     // Force new SKZP weights (to get the new error band)
05882     //lib.zBeamReweight.ExtractZBeamReweight(nu);
05883 
05884     if (zBin >= 0) {
05885       if (nu.planeEvtVtx < boundaries[zBin]) continue;
05886       if (nu.planeEvtVtx >= boundaries[zBin+1]) continue;
05887     }
05888 
05889     if (rBin >= 0) {
05890       if (nu.rTrkVtx < Rboundaries[rBin]) continue;
05891       if (nu.rTrkVtx >= Rboundaries[rBin+1]) continue;
05892     }
05893 
05894 //      /--------\    */
05895 //     /     |    \   */
05896 //    /   3  |  0  \  */
05897 //    |------------|  */
05898 //    \   2  |  1  /  */
05899 //     \     |    /   */
05900 //      \--------/    */
05901 
05902     if (qBin >= 0) {
05903       double xmid = 1.5;
05904       double ymid = 0.25;
05905       if (qBin == 0) {
05906         if (nu.xTrkVtx <= xmid) continue;
05907         if (nu.yTrkVtx <= ymid) continue;
05908       }
05909       if (qBin == 1) {
05910         if (nu.xTrkVtx <= xmid) continue;
05911         if (nu.yTrkVtx > ymid) continue;
05912       }
05913       if (qBin == 2) {
05914         if (nu.xTrkVtx > xmid) continue;
05915         if (nu.yTrkVtx > ymid) continue;
05916       }
05917       if (qBin == 3) {
05918         if (nu.xTrkVtx > xmid) continue;
05919         if (nu.yTrkVtx <= ymid) continue;
05920       }
05921     }
05922 
05923 
05924     if (qpsqpCut > 0 && nu.charge == 1) {
05925       if (nu.qp_sigqp < qpsqpCut) continue;
05926     }
05927 
05928 
05929     if (relangCut > 0 && nu.charge == 1) {
05930       if (TMath::Abs(nu.relativeAngle - TMath::Pi()) > relangCut) continue;
05931     }
05932 
05933 
05934     //RE-RECONSTRUCT the neutrino energy
05935     lib.reco.GetEvtEnergy(nu, false);
05936 
05937     // Force Curvature for coil hole events
05938     //if (nu.rTrkEnd < 0.5) {
05939     //  nu.usedRange = false;
05940     //  nu.usedCurv = !nu.usedRange;
05941     //  nu.trkEn = nu.trkEnCurv;
05942     //  nu.energyCC=nu.trkEn+nu.shwEnCC;
05943     //  nu.energy=nu.energyCC;
05944     //  lib.reco.CalcKinematicVariables(nu);
05945     //}
05946 
05947 
05948     // Force the correct kNN shower energy to be used
05949     if (forcekNN == 1) nu.energy = nu.trkEn+nu.shwEnkNN;
05950     // Force non-kNN Shower energy
05951     if (forcekNN == -1) nu.energy = nu.trkEn+nu.shwEnLinCCCor;
05952 
05953     lib.reco.ApplyReweights(nu);
05954     lib.reco.CalcResolution(nu);
05955     //apply the systematic shift if required according to xmlConfig
05956     //this->DoSystematicShifts(nu,xmlConfig);
05957     syst.Shift(nu);
05958 
05959     // Do the cuts:
05960     cutter.MakeCuts(nu);
05961     NCcutter.MakeCuts(nu);
05962 
05963     // If neither of these passed, continue
05964     if (cutter.Failed() && NCcutter.Failed()) continue;
05965 
05966     // For now, print a warning if the event passes both cuts. If we care, we can
05967     // print more information out here
05968     if (cutter.Passed() && NCcutter.Passed()) {
05969       MAXMSG("NuDSTAna",Msg::kWarning, 10) << "Event passed multiple cuts!" << endl;
05970     }
05971     // Oscillate if desired (to make fake data)
05972     this->Oscillate(nu,xmlConfig);
05973 
05974 
05975     // did we pass the (CC?) selection?
05976     if (cutter.Passed()) {
05977       // making the cuts via the xml
05978       MAXMSG("NuDSTAna",Msg::kInfo,5)
05979         <<"xmlcut: "  << xmlConfig->AnaVersionString()
05980         <<" charge: " << nu.charge << endl;
05981 
05982       // Process dave's free cuts stuff
05983       if (cutter.AnaVersion() == NuCuts::kNMBFree && nu.charge>0){
05984         if(!lib.cuts.FreeCuts(nu,xmlConfig))continue;
05985       }
05986       //make the final plots
05987       //if (plots) this->MakeFinalPlots(plots,nu);
05988 
05989       if (nu.charge==-1) lib.cnt.nuNQCounter++;
05990       else if (nu.charge==+1) lib.cnt.nuPQCounter++;
05991       else cout<<"ahhh, bad charge (8)"<<endl;
05992 
05993       //fill matrix method histos
05994       lib.hist.FillMatrixMethodHistos(nu, binningScheme);
05995 
05996       MAXMSG("NuDSTAna",Msg::kInfo,5)
05997         <<"Passed: index="<<nu.index
05998         <<", energy="<<nu.energy<<", energyMC="<<nu.energyMC<<endl;
05999     }
06000 
06001     // Now, if we selected NC:
06002     if (NCcutter.Passed()) {
06003       lib.hist.FillMatrixMethodNCHistos(nu, binningScheme);
06004     }
06005 
06006   }//end of loop over summary tree
06007 
06008 
06009   input.InitialiseNuMCEventBranch();
06010   input.ResetNuMCEventLoopPositionToStart();
06011 
06015 
06016   input.InitialiseNuMCEventBranch();
06017   input.ResetNuMCEventLoopPositionToStart();
06018 
06019   cout<<endl
06020       <<"************************************************"<<endl
06021       <<"***       Starting loop over truth info      ***"<<endl
06022       <<"************************************************"<<endl;
06023 
06024   for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
06025     lib.cnt.evtCounter++;
06026 
06027     this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
06028 
06029     NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
06030                                          (Msg::kDebug));
06031 
06032     //OVERRIDE
06033     //Selection
06034     mc.anaVersion=this->SanityCheckedAnaVersion
06035       (mc.anaVersion,overrideAnaVersion);
06036 
06037     MAXMSG("NuDSTAna",Msg::kInfo,5)
06038       <<"energyMC="<<mc.energyMC<<endl;
06039 
06040 
06041     //make fid vol cut
06042     //if (!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
06043     if (!cutter.GetCut()->InFidVolTrueEvt(mc)) continue;
06044 
06045     // Configure reweighting based on the XML file
06046     xmlConfig->ConfigureWeights(mc);
06047 
06048     // Force new SKZP weights (to get the new error band)
06049     //lib.zBeamReweight.ExtractZBeamReweight(mc);
06050 
06051 
06052     this->Oscillate(mc,xmlConfig);
06053 
06054     //fill plots
06055     if (plots) plots->FillTrueFidEnergySpect(mc,binningScheme);
06056   }
06057 
06058   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06059 
06063 
06064   cutter.PrintSummary();
06065   cutter.PrintNMinusOneSummary();
06066 
06067   // If the NC cutter is valid, print for that too
06068   if (NCcutter.IsValid()) {
06069     MSG("NuDSTAna",Msg::kInfo) << "Cutting statistics for NC cut:" << endl;
06070     NCcutter.PrintSummary();
06071     NCcutter.PrintNMinusOneSummary();
06072   }
06073 
06074   MSG("NuAnalysis",Msg::kInfo)
06075     <<" ** Finished MMRereco method **"<<endl;
06076 }

void NuDSTAna::MMRereco ( std::string  sOutputFileName,
TString  xmlFileName 
)

Definition at line 5722 of file NuDSTAna.cxx.

05724 {
05725   if(xmlFileName.IsNull())
05726     MMRereco(sOutputFileName, new NuXMLConfig);
05727   else
05728     MMRereco(sOutputFileName, new NuXMLConfig(xmlFileName));
05729 }

void NuDSTAna::MMTransition ( std::string  sOutputFileName = "",
TString  xmlFileName = "" 
)

Definition at line 6080 of file NuDSTAna.cxx.

References NuMCEvent::anaVersion, NuXMLConfig::AnaVersion(), NuReco::ApplyReweights(), NuXMLConfig::BinningScheme(), NuLibrary::cnt, NuXMLConfig::ConfigureWeights(), NuLibrary::cuts, NuMCEvent::detector, DoIO(), NuCounter::evtCounter, NuTransition::Fill(), NuHistos::FillMatrixMethodHistos(), NuPlots::FillTrueFidEnergySpect(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuLibrary::hist, NuInputEvents::InitialiseNuEventBranch(), NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), IsGoodStdCuts(), NuCuts::IsInFidVolTrueEvt(), Msg::kDebug, Detector::kFar, Msg::kInfo, MAXMSG, MSG, Oscillate(), plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), NuTransition::Reweight(), SanityCheckedAnaVersion(), and NuXMLConfig::TransitionProb().

06082 {
06083   NuInputEvents& input=this->DoIO(0,"",sOutputFileName);
06084 
06085   //get an instance of the code library
06086   NuLibrary& lib = NuLibrary::Instance();
06087 
06088   //get an object to fill plots
06089   const NuPlots* plots=0;
06090 
06091   //Get the NuXMLConfig object for configuration.
06092   NuXMLConfig* xmlConfig = 0;
06093   if (xmlFileName.IsNull()) {
06094     xmlConfig = new NuXMLConfig();
06095     xmlConfig->Write();
06096   }
06097   else {
06098     xmlConfig = new NuXMLConfig(xmlFileName);
06099     xmlConfig->Write();
06100   }
06101 
06102   //version to do reco/cuts with
06103   NuCuts::NuAnaVersion_t overrideAnaVersion =
06104     static_cast<NuCuts::NuAnaVersion_t>(xmlConfig->AnaVersion());
06105 
06106   //Binning scheme
06107   NuBinningScheme::NuBinningScheme_t binningScheme =
06108     static_cast<NuBinningScheme::NuBinningScheme_t>(xmlConfig->BinningScheme());
06109 
06110   NuTransition * transition = new NuTransition(xmlConfig);
06111 
06115 
06116   input.InitialiseNuMCEventBranch();
06117   input.ResetNuMCEventLoopPositionToStart();
06118 
06119   NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent(Msg::kDebug));
06120 
06121   if (xmlConfig->TransitionProb() > 0 && mc.detector == Detector::kFar) {
06122 
06123     input.ResetNuMCEventLoopPositionToStart();
06124 
06125     cout<<endl
06126         <<"************************************************"<<endl
06127         <<"***       Starting loop over truth info      ***"<<endl
06128         <<"************************************************"<<endl;
06129 
06130     for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
06131       lib.cnt.evtCounter++;
06132 
06133       this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
06134 
06135       NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
06136                                            (Msg::kDebug));
06137 
06138       //OVERRIDE
06139       //Selection
06140       mc.anaVersion=this->SanityCheckedAnaVersion
06141         (mc.anaVersion,overrideAnaVersion);
06142 
06143       MAXMSG("NuDSTAna",Msg::kInfo,5)
06144         <<"energyMC="<<mc.energyMC<<endl;
06145 
06146 
06147       //make fid vol cut
06148       if (!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
06149 
06150       // Configure reweighting based on the XML file
06151       xmlConfig->ConfigureWeights(mc);
06152 
06153       transition->Fill(mc);
06154 
06155       this->Oscillate(mc,xmlConfig);
06156 
06157       //fill plots
06158       plots->FillTrueFidEnergySpect(mc,binningScheme);
06159     }
06160 
06161   }
06162 
06166 
06167 
06168   input.InitialiseNuEventBranch();
06169   input.ResetNuEventLoopPositionToStart();
06170 
06171   cout<<endl
06172       <<"************************************************"<<endl
06173       <<"***      Starting main loop over snarls      ***"<<endl
06174       <<"************************************************"<<endl;
06175   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
06176     //for (Int_t i=0;i<0;++i) {
06177     lib.cnt.evtCounter++;
06178 
06179     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
06180 
06181     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
06182     //OVERRIDE
06183     //Selection
06184     nu.anaVersion=this->SanityCheckedAnaVersion
06185       (nu.anaVersion,overrideAnaVersion);
06186 
06187 
06188     // Configure reweighting based on the XML file
06189     xmlConfig->ConfigureWeights(nu);
06190 
06191 
06192     //RE-RECONSTRUCT the neutrino energy
06193     lib.reco.GetEvtEnergy(nu, false);
06194     lib.reco.ApplyReweights(nu);
06195 
06196 
06197 
06198     if (!this->IsGoodStdCuts(plots,nu)) continue;
06199 
06200     //NuEvent *nuOsc = (NuEvent*)nu.Clone();
06201     //NuEvent *nuTrans = transition->GetTransitionEvent(nu);
06202 
06203 
06204     // Reweight for systematics, oscillations and transitions
06205     transition->Reweight(nu);
06206 
06207     // apply the systematic shift if required according to xmlConfig
06208     // but only to the normal, not the appeared event
06209     //this->DoSystematicShifts(*nuOsc,xmlConfig);
06210 
06211     // Oscillate if desired (to make fake data)
06212 
06213     //this->Oscillate(*nuOsc,xmlConfig);
06214 
06215     // Reduce taus corresponding to transitions
06216 
06217     //if (nuOsc->inu == 16 || nuOsc->inu == -16) {
06218     //  MAXMSG("NuDSTAna",Msg::kInfo,1)
06219     //  << "Weighting down appeared NuTaus IN NUDSTANA for transitions by "
06220     //  << (1.0 - xmlConfig->TransitionProb()) << endl;
06221     //  nuOsc->rw *= (1.0 - xmlConfig->TransitionProb());
06222     //}
06223 
06224     //double oldWeight = nuOsc->rw;
06225     //delete nuOsc;
06226 
06227     //if (nuTrans) {
06228     //  oldWeight += nuTrans->rw;
06229     //  delete nuTrans;
06230     //}
06231 
06232 
06233     //if (TMath::Abs(oldWeight - nu.rw) < 1e-5) {
06234     //  MAXMSG("NuDSTAna",Msg::kInfo,5) << "===> Weights OK!" << endl;
06235     //}
06236     //else {
06237     //  MSG("NuDSTAna",Msg::kInfo) << "===> Weights disagree: old = " << oldWeight << ", new = " << nu.rw << endl;
06238     //}
06239 
06240     // fill matrix method histos
06241     // for the original oscillated event, nu or nubar
06242     lib.hist.FillMatrixMethodHistos(nu, binningScheme);
06243   }
06244 
06245   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06246 
06250 
06251   //print out the numbers of events
06252   lib.cnt.PrintMicroDST();
06253 
06254   MSG("NuAnalysis",Msg::kInfo)
06255     <<" ** Finished MMTransition method **"<<endl;
06256 }

void NuDSTAna::MMTransSME ( std::string  sOutputFileName,
const NuXMLConfig xmlConfig 
)

Definition at line 6260 of file NuDSTAna.cxx.

References NuXMLConfig::AnaVersion(), NuXMLConfig::AnaVersionString(), NuReco::ApplyReweights(), NuXMLConfig::BinningScheme(), NuReco::CalcResolution(), NuLibrary::cnt, NuXMLConfig::ConfigureWeights(), NuLibrary::cuts, DoIO(), NuCounter::evtCounter, NuTransSME::Fill(), NuHistos::FillMatrixMethodHistos(), NuHistos::FillMatrixMethodNCHistos(), NuPlots::FillTrueFidEnergySpect(), NuCuts::FreeCuts(), NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetEntriesNuMCEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuInputEvents::GetNextNuMCEvent(), NuXMLConfig::GetUnknownKey(), NuLibrary::hist, NuInputEvents::InitialiseNuMCEventBranch(), NuLibrary::Instance(), Msg::kDebug, Msg::kError, Msg::kInfo, NuCuts::kNMBFree, Msg::kWarning, MAXMSG, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, OscillateTrans(), plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuSystematic::PrintState(), NuUtilities::ProgressBar(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuInputEvents::ResetNuMCEventLoopPositionToStart(), NuTransSME::Reweight(), SanityCheckedAnaVersion(), NuSystematic::SetCCSelector(), NuSystematic::SetNCSelector(), and NuSystematic::SetNuBarSelector().

06262 {
06263   NuInputEvents& input=this->DoIO(0,"",sOutputFileName);
06264 
06265   //get an instance of the code library
06266   NuLibrary& lib = NuLibrary::Instance();
06267 
06268   //get an object to fill plots
06269   const NuPlots* plots=0;
06270 
06271   //Get the NuXMLConfig object for configuration.
06272     xmlConfig->Write();
06273 
06274   NuCutter cutter(xmlConfig->AnaVersionString(), plots);
06275   NuCutter NCcutter;
06276 
06277   //version to do reco/cuts with
06278   NuCuts::NuAnaVersion_t overrideAnaVersion =
06279     static_cast<NuCuts::NuAnaVersion_t>(xmlConfig->AnaVersion());
06280 
06281   NuSystematic syst(*xmlConfig);
06282    syst.SetNuBarSelector(cutter.GetCut());
06283    syst.SetCCSelector(cutter.GetCut());
06284 
06285   //Binning scheme
06286   NuBinningScheme::NuBinningScheme_t binningScheme =
06287     static_cast<NuBinningScheme::NuBinningScheme_t>(xmlConfig->BinningScheme());
06288 
06289   NuTransSME * transition = new NuTransSME(xmlConfig);
06290 
06291   // Check to see if the user wants to do an NC cut along with the CC one
06292   if (! xmlConfig->GetUnknownKey("anaVersionNC").IsNull()) {
06293     MSG("NuDSTAna",Msg::kInfo) << "Found anaVersionNC in configuration... Doing additional NC cuts" << endl;
06294     NCcutter.SetCut(xmlConfig->GetUnknownKey("anaVersionNC"));
06295     syst.SetNCSelector(NCcutter.GetCut()); 
06296   }
06297   else{
06298     MSG("NuDSTAna",Msg::kInfo) << "Didn't find anaVersionNC key in configuration. No NC histograms will be produced." << endl;
06299   }
06300 
06301   int zBin = -1;
06302   int boundaries[] = {0, 20, 30, 40, 50, 60, 80};
06303   // Check to see if the user wants to do an NC cut along with the CC one
06304   if (! xmlConfig->GetUnknownKey("zVtxBin").IsNull()) {
06305     TString sBin = xmlConfig->GetUnknownKey("zVtxBin");
06306     cout << "zVtxBin = " << sBin << endl;
06307     zBin = sBin.Atoi();
06308     MSG("NuDSTAna",Msg::kInfo) << "Found z vertex bin in configuration... using bin "
06309     << zBin << " which includes planes " << boundaries[zBin] << " to " << boundaries[zBin+1] << endl;
06310   }
06311 
06312   int rBin = -1;
06313   double Rboundaries[] = {0.7, 1.1, 1.5, 1.9, 2.3};
06314   // Check to see if the user wants to do an NC cut along with the CC one
06315   if (! xmlConfig->GetUnknownKey("rVtxBin").IsNull()) {
06316     TString sBin = xmlConfig->GetUnknownKey("rVtxBin");
06317     cout << "rVtxBin = " << sBin << endl;
06318     rBin = sBin.Atoi();
06319     MSG("NuDSTAna",Msg::kInfo) << "Found r vertex bin in configuration... using bin "
06320     << rBin << " which includes " << Rboundaries[rBin] << " to " << Rboundaries[rBin+1] << endl;
06321   }
06322 
06323   int qBin = -1;
06324   // Check to see if the user wants to do an NC cut along with the CC one
06325   if (! xmlConfig->GetUnknownKey("quadBin").IsNull()) {
06326     TString sBin = xmlConfig->GetUnknownKey("quadBin");
06327     cout << "quadBin = " << sBin << endl;
06328     qBin = sBin.Atoi();
06329     MSG("NuDSTAna",Msg::kInfo) << "Found quadrant bin in configuration... using bin "
06330     << qBin << endl;
06331   }
06332 
06333 
06334   int forcekNN = 0;
06335    TString tmp = xmlConfig->GetUnknownKey("kNNShowerEnergy");
06336    tmp.ToLower();
06337    if (! tmp.IsNull()) {
06338      if (tmp == "yes") {
06339        MSG("NuDSTAna",Msg::kInfo) << "Forcing kNN shower energy" << endl;
06340        forcekNN = 1;
06341      }
06342      else if (tmp == "no") {
06343        MSG("NuDSTAna",Msg::kInfo) << "Forcing calo. shower energy" << endl;
06344        forcekNN = -1;
06345      }
06346      else {
06347        MSG("NuDSTAna",Msg::kInfo) << "Not forcing shower energy -- yes or no required (got "
06348        << xmlConfig->GetUnknownKey("kNNShowerEnergy") << ")" << endl;
06349      }
06350    }
06351 
06352   double qpsqpCut = 0;
06353   if (! xmlConfig->GetUnknownKey("qpsqp").IsNull()) {
06354     TString sCut = xmlConfig->GetUnknownKey("qpsqp");
06355     cout << "qpsqp = " << sCut << endl;
06356     qpsqpCut = sCut.Atof();
06357     MSG("NuDSTAna",Msg::kInfo) << "Found extra qpsqp cut of "
06358     << qpsqpCut << endl;
06359   }
06360 
06361 
06362   double relangCut = 0;
06363   if (! xmlConfig->GetUnknownKey("relang").IsNull()) {
06364     TString sCut = xmlConfig->GetUnknownKey("relang");
06365     cout << "relang = " << sCut << endl;
06366     relangCut = sCut.Atof();
06367     MSG("NuDSTAna",Msg::kInfo) << "Found extra relang cut of "
06368     << relangCut << endl;
06369   }
06370 
06371   syst.PrintState();
06372 
06376 
06377   input.InitialiseNuMCEventBranch();
06378   input.ResetNuMCEventLoopPositionToStart();
06379 
06380   //NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent(Msg::kDebug));
06381 
06382     input.ResetNuMCEventLoopPositionToStart();
06383 
06384     cout<<endl
06385         <<"************************************************"<<endl
06386         <<"***       Starting loop over truth info      ***"<<endl
06387         <<"************************************************"<<endl;
06388 
06389     for (Int_t i=0;i<input.GetEntriesNuMCEvent();++i) {
06390       lib.cnt.evtCounter++;
06391 
06392       this->PrintLoopProgress(i,input.GetEntriesNuMCEvent(),1);
06393 
06394       NuMCEvent& mc=const_cast<NuMCEvent&>(input.GetNextNuMCEvent
06395                                            (Msg::kDebug));
06396 
06397       //OVERRIDE
06398       //Selection
06399       mc.anaVersion=this->SanityCheckedAnaVersion
06400         (mc.anaVersion,overrideAnaVersion);
06401 
06402       MAXMSG("NuDSTAna",Msg::kInfo,5)
06403         <<"energyMC="<<mc.energyMC<<endl;
06404 
06405 
06406       //make fid vol cut
06407   //    if (!lib.cuts.IsInFidVolTrueEvt(mc)) continue;
06408       if (!cutter.GetCut()->InFidVolTrueEvt(mc)) continue;
06409 
06410 
06411       // Configure reweighting based on the XML file
06412       xmlConfig->ConfigureWeights(mc);
06413 
06414       transition->Fill(mc);
06415 
06416       this->OscillateTrans(mc,xmlConfig);
06417 
06418       //fill plots
06419       plots->FillTrueFidEnergySpect(mc,binningScheme);
06420     
06421 
06422   }
06423 
06427 
06428 
06429 //  input.InitialiseNuEventBranch();
06430   input.ResetNuEventLoopPositionToStart();
06431 
06432   cout<<endl
06433       <<"************************************************"<<endl
06434       <<"***      Starting main loop over snarls      ***"<<endl
06435       <<"************************************************"<<endl;
06436   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
06437     lib.cnt.evtCounter++;
06438 
06439     //  this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
06440     NuUtilities::ProgressBar(i,input.GetEntriesNuEvent(),5);
06441 
06442     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
06443     //OVERRIDE
06444     //Selection
06445     nu.anaVersion=this->SanityCheckedAnaVersion
06446       (nu.anaVersion,overrideAnaVersion);
06447 
06448     if (nu.hornIsReverse && nu.beamType == 3) {
06449       nu.beamType = 41;
06450       nu.beamTypeDB = 41;
06451       MAXMSG("NuDSTAna",Msg::kError,30) << "Horrible hack to fix RHC beamtype." << endl;
06452       //assert(false);
06453     }
06454 
06455     // Configure reweighting based on the XML file
06456     xmlConfig->ConfigureWeights(nu);
06457 
06458     // Force new SKZP weights (to get the new error band)
06459     //lib.zBeamReweight.ExtractZBeamReweight(nu);
06460 
06461     if (zBin >= 0) {
06462       if (nu.planeEvtVtx < boundaries[zBin]) continue;
06463       if (nu.planeEvtVtx >= boundaries[zBin+1]) continue;
06464     }
06465 
06466     if (rBin >= 0) {
06467       if (nu.rTrkVtx < Rboundaries[rBin]) continue;
06468       if (nu.rTrkVtx >= Rboundaries[rBin+1]) continue;
06469     }
06470 
06471 //      /--------\    */
06472 //     /     |    \   */
06473 //    /   3  |  0  \  */
06474 //    |------------|  */
06475 //    \   2  |  1  /  */
06476 //     \     |    /   */
06477 //      \--------/    */
06478 
06479     if (qBin >= 0) {
06480       double xmid = 1.5;
06481       double ymid = 0.25;
06482       if (qBin == 0) {
06483         if (nu.xTrkVtx <= xmid) continue;
06484         if (nu.yTrkVtx <= ymid) continue;
06485       }
06486       if (qBin == 1) {
06487         if (nu.xTrkVtx <= xmid) continue;
06488         if (nu.yTrkVtx > ymid) continue;
06489       }
06490       if (qBin == 2) {
06491         if (nu.xTrkVtx > xmid) continue;
06492         if (nu.yTrkVtx > ymid) continue;
06493       }
06494       if (qBin == 3) {
06495         if (nu.xTrkVtx > xmid) continue;
06496         if (nu.yTrkVtx <= ymid) continue;
06497       }
06498     }
06499 
06500 
06501     if (qpsqpCut > 0 && nu.charge == 1) {
06502       if (nu.qp_sigqp < qpsqpCut) continue;
06503     }
06504 
06505 
06506     if (relangCut > 0 && nu.charge == 1) {
06507       if (TMath::Abs(nu.relativeAngle - TMath::Pi()) > relangCut) continue;
06508     }
06509 
06510 
06511     //RE-RECONSTRUCT the neutrino energy
06512     lib.reco.GetEvtEnergy(nu, false);
06513 
06514     // Force Curvature for coil hole events
06515     //if (nu.rTrkEnd < 0.5) {
06516     //  nu.usedRange = false;
06517     //  nu.usedCurv = !nu.usedRange;
06518     //  nu.trkEn = nu.trkEnCurv;
06519     //  nu.energyCC=nu.trkEn+nu.shwEnCC;
06520     //  nu.energy=nu.energyCC;
06521     //  lib.reco.CalcKinematicVariables(nu);
06522     //}
06523 
06524 
06525     // Force the correct kNN shower energy to be used
06526      if (forcekNN == 1) nu.energy = nu.trkEn+nu.shwEnkNN;
06527      // Force non-kNN Shower energy
06528      if (forcekNN == -1) nu.energy = nu.trkEn+nu.shwEnLinCCCor;
06529 
06530 
06531     //RE-RECONSTRUCT the neutrino energy
06532     lib.reco.ApplyReweights(nu);
06533     lib.reco.CalcResolution(nu);
06534 
06535 
06536     // Reweight for systematics, oscillations and transitions
06537     // Do the cuts
06538     cutter.MakeCuts(nu);
06539     NCcutter.MakeCuts(nu);
06540 
06541     // If neither of these passed, continue
06542     if (cutter.Failed() && NCcutter.Failed()) continue;
06543 
06544     // For now, print a warning if the event passes both cuts. If we care, we can
06545     // print more information out here
06546     if (cutter.Passed() && NCcutter.Passed()) {
06547       MAXMSG("NuDSTAna",Msg::kWarning, 10) << "Event passed multiple cuts!" << endl;
06548     }
06549 
06550 
06551     transition->Reweight(nu);
06552 
06553     // fill matrix method histos
06554     
06555     // did we pass the (CC?) selection?
06556     if (cutter.Passed()) {
06557       // making the cuts via the xml
06558       MAXMSG("NuDSTAna",Msg::kInfo,5)
06559         <<"xmlcut: "  << xmlConfig->AnaVersionString()
06560         <<" charge: " << nu.charge << endl;
06561 
06562       // Process dave's free cuts stuff
06563       if (cutter.AnaVersion() == NuCuts::kNMBFree && nu.charge>0){
06564         if(!lib.cuts.FreeCuts(nu,xmlConfig))continue;
06565       }
06566       //make the final plots
06567       //if (plots) this->MakeFinalPlots(plots,nu);
06568 
06569       if (nu.charge==-1) lib.cnt.nuNQCounter++;
06570       else if (nu.charge==+1) lib.cnt.nuPQCounter++;
06571       else cout<<"ahhh, bad charge (8)"<<endl;
06572 
06573       //fill matrix method histos
06574     lib.hist.FillMatrixMethodHistos(nu, binningScheme);
06575 
06576 
06577     MAXMSG("NuDSTAna",Msg::kInfo,5)
06578          <<"Passed: index="<<nu.index
06579          <<", energy="<<nu.energy<<", energyMC="<<nu.energyMC<<endl;
06580     }
06581 
06582     // Now, if we selected NC:
06583     if (NCcutter.Passed()) {
06584       lib.hist.FillMatrixMethodNCHistos(nu, binningScheme);
06585     }
06586 
06587   }//end of loop over summary tree
06588   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06589 
06590   cutter.PrintSummary();
06591   cutter.PrintNMinusOneSummary();
06592 
06596 
06597   //print out the numbers of events
06598   lib.cnt.PrintMicroDST();
06599 
06600   MSG("NuAnalysis",Msg::kInfo)
06601     <<" ** Finished MMTransSME method **"<<endl;
06602 }

void NuDSTAna::NDOsc (  ) 

Definition at line 8205 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, DoIO(), MuELoss::e, NuCounter::evtCounter, Munits::g, NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuLibrary::Instance(), IsGoodStdCuts(), Msg::kDebug, Msg::kError, Msg::kInfo, NuCuts::kNMB0325Bravo, NuBinningScheme::kNuMuBar0325Std2, MAXMSG, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, OscillationWeight(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuUtilities::RecoBins(), NuInputEvents::ResetNuEventLoopPositionToStart(), and SanityCheckedAnaVersion().

08206 {
08207   NuInputEvents& input=this->DoIO(0,"","");
08208 
08209   //get an instance of the code library
08210   NuLibrary& lib=NuLibrary::Instance();
08211 
08212   //get an object to fill plots
08213   //const NuPlots* plots=0;
08214 
08215   //version to do reco/cuts with
08216   NuCuts::NuAnaVersion_t overrideAnaVersion  = NuCuts::kNMB0325Bravo;
08217 
08218   //Binning scheme
08219   NuBinningScheme::NuBinningScheme_t binningScheme = NuBinningScheme::kNuMuBar0325Std2;
08220 
08221   const NuUtilities cuts;
08222 
08223   std::vector<Double_t> vReco = cuts.RecoBins(binningScheme);
08224   int nbins = vReco.size() - 1;
08225   Double_t *bins = &(vReco[0]);
08226 
08227 
08228   // Initialize the plots
08229   TH1D *gdist = new TH1D("gdist","#nu_{#mu} Distance Traveled",1000,0,2);
08230   TH1D *hdist = new TH1D("hdist","#bar{#nu}_{#mu} Distance Traveled",1000,0,2);
08231   TH1D *h[100];
08232   TH1D *g[100];
08233   TString num;
08234   for (int i = 0; i < 100; i++) {
08235     num.Form("%04i",i*20);
08236     h[i] = new TH1D("h"+num,"#Delta #bar{m}^{2} = "+num+"e-3 eV^{2}",nbins, bins);
08237     g[i] = new TH1D("g"+num,"#Delta m^{2} = "+num+"e-3 eV^{2}",nbins, bins);
08238   }
08239 
08240   double osc = 1.;
08241   double sn2 = 1.;
08242   double dm2 = 0;
08243   double dist = 0;
08244   double cm2km = 1./(100.*1000.);
08245   double m2km = 1./(1000.);
08246 
08250 
08251   input.ResetNuEventLoopPositionToStart();
08252 
08253   cout<<endl
08254       <<"************************************************"<<endl
08255       <<"***      Starting main loop over snarls      ***"<<endl
08256       <<"************************************************"<<endl;
08257   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
08258     //for (Int_t i=0;i<0;++i) {
08259     lib.cnt.evtCounter++;
08260 
08261     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
08262 
08263     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
08264 
08265     //OVERRIDE
08266     //Selection
08267     nu.anaVersion=this->SanityCheckedAnaVersion
08268       (nu.anaVersion,overrideAnaVersion);
08269     //Reweighting
08270     nu.applyBeamWeight = true;
08271 
08272     MSG("NuDSTAna", Msg::kError) << "Can't apply RunI weights which no longer exist" << endl;
08273 
08274     //RE-RECONSTRUCT the neutrino energy
08275     lib.reco.GetEvtEnergy(nu, false);
08276     lib.reco.ApplyReweights(nu);
08277 
08278     //make all the std cuts
08279     if (!this->IsGoodStdCuts(0,nu)) continue;
08280 
08281     osc = 1;
08282 
08283     for (int i = 0; i < 100; i++) {
08284       //check for CC nubars
08285       if (1 == nu.iaction && abs(nu.inu) == 14) {
08286         dm2 = i;
08287         dm2 *= 20.*1e-3;
08288         dist = (104000.0 - nu.Vz)*cm2km + (nu.zTrkVtx - 13.5)*m2km;
08289         osc = NuOscProbCalc::OscillationWeight(nu.neuEnMC, dm2, sn2);
08290       }
08291 
08292       if (nu.charge == 1) {
08293         h[i]->Fill(nu.energy, nu.rw*osc);
08294       }
08295       else {
08296         g[i]->Fill(nu.energy, nu.rw*osc);
08297       }
08298 
08299     }
08300 
08301     if (nu.charge == 1) {
08302       hdist->Fill(dist, nu.rw);
08303     }
08304     else {
08305       gdist->Fill(dist, nu.rw);
08306     }
08307 
08308 
08309     if (nu.charge==-1) lib.cnt.nuNQCounter++;
08310     else if (nu.charge==+1) lib.cnt.nuPQCounter++;
08311     else cout<<"ahhh, bad charge (11)"<<endl;
08312 
08313 
08314     MAXMSG("NuDSTAna",Msg::kInfo,5)
08315       <<"Passed: index="<<nu.index
08316       <<", energy="<<nu.energy<<", energyMC="<<nu.energyMC<<endl;
08317   }//end of loop over summary tree
08318 
08319   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
08320 
08324 
08325   //print out the numbers of events
08326   lib.cnt.PrintMicroDST();
08327 
08328   MSG("NuAnalysis",Msg::kInfo)
08329     <<" ** Finished NDOsc method **"<<endl;
08330 }

void NuDSTAna::NDQPRB ( bool  cedar  ) 

Definition at line 9033 of file NuDSTAna.cxx.

References NuEvent::anaVersion, NuEvent::applyBeamWeight, NuEvent::applyEnergyShifts, NuReco::ApplyReweights(), NuEvent::charge, NuLibrary::cnt, NuEvent::containmentFlag, DoIO(), NuCounter::evtCounter, NuZBeamReweight::ExtractZBeamReweight(), NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuLibrary::Instance(), IsGoodPreSelectionCuts(), Msg::kInfo, SimFlag::kMC, NuCuts::kNMB0325Bravo, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuEvent::planeTrkVtx, plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuEvent::qp, NuEvent::qp_rangebiased, NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuEvent::runPeriod, NuEvent::rw, NuEvent::simFlag, NuEvent::trkEnMC, NuEvent::trkLength, NuEvent::xTrkEnd, NuEvent::xTrkVtx, NuEvent::yTrkEnd, NuEvent::yTrkVtx, NuLibrary::zBeamReweight, NuEvent::zTrkEnd, and NuEvent::zTrkVtx.

09034 {
09035   cout<<endl
09036       <<"***********************************************"<<endl
09037       <<"***            Starting NDQPRB()            ***"<<endl
09038       <<"***********************************************"<<endl << endl;;
09039 
09040   NuInputEvents& input=this->DoIO(0,"","");
09041 
09042   //get an instance of the code library
09043   NuLibrary& lib=NuLibrary::Instance();
09044 
09045   input.ResetNuEventLoopPositionToStart();
09046 
09047   const int Ncont = 4;
09048 
09049   TString contNames[] = {"cont1","cont2","cont3","cont4"};
09050   TString varNames[99];
09051   double varMin[99];
09052   double varMax[99];
09053   double vals[99];
09054 
09055   int v = 0;
09056   varNames[0] = "trkEnMC";
09057   varMin[v]   = 0;
09058   varMax[v]   = 50;
09059   v = 1;
09060   varNames[v] = "xTrkVtx";
09061   varMin[v]   = 0.5;
09062   varMax[v]   = 2.5;
09063   v = 2;
09064   varNames[v] = "yTrkVtx";
09065   varMin[v]   = -0.75;
09066   varMax[v]   = 1.25;
09067   v = 3;
09068   varNames[v] = "zTrkVtx";
09069   varMin[v]   = 0.5;
09070   varMax[v]   = 4.5;
09071   v = 4;
09072   varNames[v] = "xTrkEnd";
09073   varMin[v]   = -2;
09074   varMax[v]   = 3;
09075   v = 5;
09076   varNames[v] = "yTrkEnd";
09077   varMin[v]   = -2.5;
09078   varMax[v]   = 2.5;
09079   v = 6;
09080   varNames[v] = "zTrkEnd";
09081   varMin[v]   = 7;
09082   varMax[v]   = 17;
09083   v = 7;
09084   varNames[v] = "trkLength";
09085   varMin[v]   = 40;
09086   varMax[v]   = 280;
09087   v = 8;
09088   varNames[v] = "qp";
09089   varMin[v]   = -1;
09090   varMax[v]   = 1;
09091   v = 9;
09092   varNames[v] = "invqp";
09093   varMin[v]   = -200;
09094   varMax[v]   = 200;
09095 
09096   v = 10;
09097   varNames[v] = "specLength";
09098   varMin[v]   = 0;
09099   varMax[v]   = 180;
09100 
09101   const int Nvars = 11;
09102 
09103   int nbinsX = 250;
09104   int nbinsY = 500;
09105   double minY = -1;
09106   double maxY = 9;
09107   double valy;
09108 
09109   TH2D *plots[Nvars][Ncont];
09110 
09111   for (int v = 0; v < Nvars; v++) {
09112     for (int c = 0; c < Ncont; c++) {
09113       plots[v][c] = new TH2D("h"+varNames[v]+"_"+contNames[c],
09114                              contNames[c]+";"+varNames[v]+";Reco-True/True",
09115                              nbinsX, varMin[v], varMax[v],
09116                              nbinsY, minY, maxY);
09117     }
09118   }
09119 
09120   cout<<endl
09121       <<"************************************************"<<endl
09122       <<"***      Starting main loop over snarls      ***"<<endl
09123       <<"************************************************"<<endl;
09124   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
09125     lib.cnt.evtCounter++;
09126 
09127     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
09128     if (i < 200) cout << "Debug: i=" << i << "/" << input.GetEntriesNuEvent() << endl;;
09129 
09130 
09131     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kInfo));
09132 
09133     if (nu.trkEnMC == 0) continue; // Only events with real track energy
09134     if (!cedar && nu.qp_rangebiased == 0) continue; // Only events with passed track
09135     if (cedar && nu.qp == 0) continue; // Only events with passed track
09136 
09137     // Only care about preselected nubars here
09138     nu.anaVersion = NuCuts::kNMB0325Bravo;
09139     if (!this->IsGoodPreSelectionCuts(0,nu)) continue;
09140 
09141     //OVERRIDE
09142 
09143     //RE-RECONSTRUCT the neutrino energy
09144     // Redo the beam weights
09145     if (nu.simFlag==SimFlag::kMC) {
09146       nu.runPeriod = 0;
09147       lib.zBeamReweight.ExtractZBeamReweight(nu);
09148 
09149       //Reweighting
09150       nu.applyBeamWeight = true;
09151       nu.applyEnergyShifts = false;
09152       nu.rw = 1;
09153       lib.reco.ApplyReweights(nu);
09154     }
09155 
09156     // First do nominal qp, nominal SKZP
09157     lib.reco.GetEvtEnergy(nu, false);
09158 
09159     int c = nu.containmentFlag - 1;
09160     vals[0] = nu.trkEnMC;
09161     vals[1] = nu.xTrkVtx;
09162     vals[2] = nu.yTrkVtx;
09163     vals[3] = nu.zTrkVtx;
09164     vals[4] = nu.xTrkEnd;
09165     vals[5] = nu.yTrkEnd;
09166     vals[6] = nu.zTrkEnd;
09167     vals[7] = nu.trkLength;
09168     if (cedar) {
09169       if (nu.qp == 0 || nu.trkEnMC == 0) continue;
09170       vals[8] = nu.qp;
09171       vals[9] = 1./nu.qp;
09172       valy = TMath::Abs(nu.qp*nu.trkEnMC) - 1.;
09173     }
09174     else {
09175       if (nu.qp_rangebiased == 0 || nu.trkEnMC == 0) continue;
09176       vals[8] = nu.qp_rangebiased;
09177       vals[9] = 1./nu.qp_rangebiased;
09178       valy = TMath::Abs(nu.qp_rangebiased*nu.trkEnMC) - 1.;
09179     }
09180     vals[10] = nu.trkLength - (118-nu.planeTrkVtx);
09181 
09182 
09183     for (int v = 0; v < Nvars; v++) {
09184       plots[v][c]->Fill(vals[v], valy, nu.rw);
09185     }
09186 
09187 
09188     if (nu.charge==-1) lib.cnt.nuNQCounter++;
09189     else if (nu.charge==+1) lib.cnt.nuPQCounter++;
09190     else cout<<"ahhh, bad charge (11)"<<endl;
09191 
09192   }//end of loop over summary tree
09193 
09194   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
09195 
09199 
09200   //print out the numbers of events
09201   lib.cnt.PrintMicroDST();
09202 
09203   cout<<endl
09204       <<"***********************************************"<<endl
09205       <<"***             Ending NDQPRB()             ***"<<endl
09206       <<"***********************************************"<<endl << endl;;
09207 
09208 }

void NuDSTAna::NDTestAna (  ) 

Definition at line 2545 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuEvent::charge, NuConfig::detector, DoIO(), NuEvent::energy, NuCounter::evtCounter, NuInputEvents::GetEntriesNuEvent(), GetEventND(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuReco::GetShowerEnergyCor(), Munits::GeV, NuLibrary::Instance(), IsGoodStdCuts(), CandShowerHandle::kCC, NuCuts::kCC0325Std, Msg::kDebug, Detector::kFar, Msg::kInfo, MakeFinalPlots(), MAXMSG, MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, NuBase::OpenTxtFile(), plots(), NuPlots::PrintEventInfo(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuInputEvents::ResetNuEventLoopPositionToStart(), NuConfig::run, SanityCheckedAnaVersion(), NuEvent::shwEn, and NuEvent::trkEn.

02546 {
02547   NuInputEvents& input=this->DoIO();
02548 
02549   //use config object to store info
02550   NuConfig config;
02551   config.detector=Detector::kFar;
02552   config.run=100;
02553 
02554   string sTxt="nmb";
02555   ofstream& nmbTxt=*(this->OpenTxtFile(config,sTxt.c_str()));
02556   string sTxtNM="nm";
02557   ofstream& nmTxt=*(this->OpenTxtFile(config,sTxtNM.c_str()));
02558   //string sTxtLINM="nmLI";
02559   //ofstream& nmLITxt=*(this->OpenTxtFile(config,sTxtLINM.c_str()));
02560 
02561   //object to count events
02562   NuCounter cnt;
02563 
02564   static NuGeneral general;
02565   const NuPlots* plots=0;
02566   static NuCuts cuts;
02567   //static NuReco reco;//make a local one
02568 
02569   TH1F* hRecoEnDiff=new TH1F("hRecoEnDiff","hRecoEnDiff",
02570                              200000,-100,100);
02571   hRecoEnDiff->SetTitle("Reconstructed Energy Difference (GeV)");
02572   hRecoEnDiff->GetXaxis()->
02573     SetTitle("Reconstructed Energy Difference (GeV)");
02574   hRecoEnDiff->GetXaxis()->CenterTitle();
02575   hRecoEnDiff->GetYaxis()->SetTitle("");
02576   hRecoEnDiff->GetYaxis()->CenterTitle();
02577   hRecoEnDiff->SetFillColor(0);
02578   hRecoEnDiff->SetLineColor(1);
02579   //hRecoEnDiff->SetBit(TH1::kCanRebin);
02580 
02581   TH1F* hRecoEnDiffCurv=new TH1F("hRecoEnDiffCurv","hRecoEnDiffCurv",
02582                                  200000,-100,100);
02583   hRecoEnDiffCurv->SetTitle("Reconstructed Energy Difference (GeV)");
02584   hRecoEnDiffCurv->GetXaxis()->
02585     SetTitle("Reconstructed Energy Difference (GeV)");
02586   hRecoEnDiffCurv->GetXaxis()->CenterTitle();
02587   hRecoEnDiffCurv->GetYaxis()->SetTitle("");
02588   hRecoEnDiffCurv->GetYaxis()->CenterTitle();
02589   hRecoEnDiffCurv->SetFillColor(0);
02590   hRecoEnDiffCurv->SetLineColor(1);
02591   //hRecoEnDiffCurv->SetBit(TH1::kCanRebin);
02592 
02593   TH1F* hRecoEnDiffRange=new TH1F("hRecoEnDiffRange","hRecoEnDiffRange",
02594                                   200000,-100,100);
02595   hRecoEnDiffRange->SetTitle("Reconstructed Energy Difference (GeV)");
02596   hRecoEnDiffRange->GetXaxis()->
02597     SetTitle("Reconstructed Energy Difference (GeV)");
02598   hRecoEnDiffRange->GetXaxis()->CenterTitle();
02599   hRecoEnDiffRange->GetYaxis()->SetTitle("");
02600   hRecoEnDiffRange->GetYaxis()->CenterTitle();
02601   hRecoEnDiffRange->SetFillColor(0);
02602   hRecoEnDiffRange->SetLineColor(1);
02603   //hRecoEnDiffRange->SetBit(TH1::kCanRebin);
02604 
02605 
02606   TH1F* hRecoTrkEnDiff=new TH1F("hRecoTrkEnDiff","hRecoTrkEnDiff",
02607                                 200000,-100,100);
02608   hRecoTrkEnDiff->SetTitle("Reconstructed Trk Energy Difference (GeV)");
02609   hRecoTrkEnDiff->GetXaxis()->
02610     SetTitle("Reconstructed Trk Energy Difference (GeV)");
02611   hRecoTrkEnDiff->GetXaxis()->CenterTitle();
02612   hRecoTrkEnDiff->GetYaxis()->SetTitle("");
02613   hRecoTrkEnDiff->GetYaxis()->CenterTitle();
02614   hRecoTrkEnDiff->SetFillColor(0);
02615   hRecoTrkEnDiff->SetLineColor(1);
02616   //hRecoTrkEnDiff->SetBit(TH1::kCanRebin);
02617 
02618   TH1F* hRecoTrkEnDiffCurv=new TH1F("hRecoTrkEnDiffCurv","hRecoTrkEnDiffCurv",
02619                                     200000,-100,100);
02620   hRecoTrkEnDiffCurv->SetTitle("Reconstructed Trk Energy Difference (GeV)");
02621   hRecoTrkEnDiffCurv->GetXaxis()->
02622     SetTitle("Reconstructed Trk Energy Difference (GeV)");
02623   hRecoTrkEnDiffCurv->GetXaxis()->CenterTitle();
02624   hRecoTrkEnDiffCurv->GetYaxis()->SetTitle("");
02625   hRecoTrkEnDiffCurv->GetYaxis()->CenterTitle();
02626   hRecoTrkEnDiffCurv->SetFillColor(0);
02627   hRecoTrkEnDiffCurv->SetLineColor(1);
02628   //hRecoTrkEnDiffCurv->SetBit(TH1::kCanRebin);
02629 
02630   TH1F* hRecoTrkEnDiffRange=new TH1F("hRecoTrkEnDiffRange","hRecoTrkEnDiffRange",
02631                                      200000,-100,100);
02632   hRecoTrkEnDiffRange->SetTitle("Reconstructed Trk Energy Difference (GeV)");
02633   hRecoTrkEnDiffRange->GetXaxis()->
02634     SetTitle("Reconstructed Trk Energy Difference (GeV)");
02635   hRecoTrkEnDiffRange->GetXaxis()->CenterTitle();
02636   hRecoTrkEnDiffRange->GetYaxis()->SetTitle("");
02637   hRecoTrkEnDiffRange->GetYaxis()->CenterTitle();
02638   hRecoTrkEnDiffRange->SetFillColor(0);
02639   hRecoTrkEnDiffRange->SetLineColor(1);
02640   //hRecoTrkEnDiffRange->SetBit(TH1::kCanRebin);
02641 
02642 
02643 
02644 
02645   TH1F* hRecoShwEnDiff=new TH1F("hRecoShwEnDiff","hRecoShwEnDiff",
02646                                 200000,-100,100);
02647   hRecoShwEnDiff->SetTitle("Reconstructed Shw Energy Difference (GeV)");
02648   hRecoShwEnDiff->GetXaxis()->
02649     SetTitle("Reconstructed Shw Energy Difference (GeV)");
02650   hRecoShwEnDiff->GetXaxis()->CenterTitle();
02651   hRecoShwEnDiff->GetYaxis()->SetTitle("");
02652   hRecoShwEnDiff->GetYaxis()->CenterTitle();
02653   hRecoShwEnDiff->SetFillColor(0);
02654   hRecoShwEnDiff->SetLineColor(1);
02655   //hRecoShwEnDiff->SetBit(TH1::kCanRebin);
02656 
02657   TH1F* hRecoShwEnDiffCurv=new TH1F("hRecoShwEnDiffCurv","hRecoShwEnDiffCurv",
02658                                     200000,-100,100);
02659   hRecoShwEnDiffCurv->SetTitle("Reconstructed Shw Energy Difference (GeV)");
02660   hRecoShwEnDiffCurv->GetXaxis()->
02661     SetTitle("Reconstructed Shw Energy Difference (GeV)");
02662   hRecoShwEnDiffCurv->GetXaxis()->CenterTitle();
02663   hRecoShwEnDiffCurv->GetYaxis()->SetTitle("");
02664   hRecoShwEnDiffCurv->GetYaxis()->CenterTitle();
02665   hRecoShwEnDiffCurv->SetFillColor(0);
02666   hRecoShwEnDiffCurv->SetLineColor(1);
02667   //hRecoShwEnDiffCurv->SetBit(TH1::kCanRebin);
02668 
02669   TH1F* hRecoShwEnDiffRange=new TH1F("hRecoShwEnDiffRange","hRecoShwEnDiffRange",
02670                                      200000,-100,100);
02671   hRecoShwEnDiffRange->SetTitle("Reconstructed Shw Energy Difference (GeV)");
02672   hRecoShwEnDiffRange->GetXaxis()->
02673     SetTitle("Reconstructed Shw Energy Difference (GeV)");
02674   hRecoShwEnDiffRange->GetXaxis()->CenterTitle();
02675   hRecoShwEnDiffRange->GetYaxis()->SetTitle("");
02676   hRecoShwEnDiffRange->GetYaxis()->CenterTitle();
02677   hRecoShwEnDiffRange->SetFillColor(0);
02678   hRecoShwEnDiffRange->SetLineColor(1);
02679   //hRecoShwEnDiffRange->SetBit(TH1::kCanRebin);
02680 
02681 
02682 
02683 
02684   TH1F* hRecoEnOfDiff=new TH1F("hRecoEnOfDiff","hRecoEnOfDiff",
02685                                400,-100,100);
02686   hRecoEnOfDiff->SetTitle("Reconstructed Energy (GeV)");
02687   hRecoEnOfDiff->GetXaxis()->
02688     SetTitle("Reconstructed Energy (GeV)");
02689   hRecoEnOfDiff->GetXaxis()->CenterTitle();
02690   hRecoEnOfDiff->GetYaxis()->SetTitle("");
02691   hRecoEnOfDiff->GetYaxis()->CenterTitle();
02692   hRecoEnOfDiff->SetFillColor(0);
02693   hRecoEnOfDiff->SetLineColor(1);
02694   //hRecoEnOfDiff->SetBit(TH1::kCanRebin);
02695 
02696   TH1F* hRecoTrkEnOfDiff=new TH1F("hRecoTrkEnOfDiff","hRecoTrkEnOfDiff",
02697                                   400,-100,100);
02698   hRecoTrkEnOfDiff->SetTitle("Reconstructed Trk Energy (GeV)");
02699   hRecoTrkEnOfDiff->GetXaxis()->
02700     SetTitle("Reconstructed Trk Energy (GeV)");
02701   hRecoTrkEnOfDiff->GetXaxis()->CenterTitle();
02702   hRecoTrkEnOfDiff->GetYaxis()->SetTitle("");
02703   hRecoTrkEnOfDiff->GetYaxis()->CenterTitle();
02704   hRecoTrkEnOfDiff->SetFillColor(0);
02705   hRecoTrkEnOfDiff->SetLineColor(1);
02706   //hRecoTrkEnOfDiff->SetBit(TH1::kCanRebin);
02707 
02708   TH1F* hRecoShwEnOfDiff=new TH1F("hRecoShwEnOfDiff","hRecoShwEnOfDiff",
02709                                   400,-100,100);
02710   hRecoShwEnOfDiff->SetTitle("Reconstructed Shw Energy (GeV)");
02711   hRecoShwEnOfDiff->GetXaxis()->
02712     SetTitle("Reconstructed Shw Energy (GeV)");
02713   hRecoShwEnOfDiff->GetXaxis()->CenterTitle();
02714   hRecoShwEnOfDiff->GetYaxis()->SetTitle("");
02715   hRecoShwEnOfDiff->GetYaxis()->CenterTitle();
02716   hRecoShwEnOfDiff->SetFillColor(0);
02717   hRecoShwEnOfDiff->SetLineColor(1);
02718   //hRecoShwEnOfDiff->SetBit(TH1::kCanRebin);
02719 
02720   //get an instance of the code library
02721   const NuLibrary& lib=NuLibrary::Instance();
02722 
02723   //version to do reco/cuts with
02724   NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kCC0325Std;
02725 
02726   input.ResetNuEventLoopPositionToStart();
02727 
02731 
02732   cout<<endl
02733       <<"************************************************"<<endl
02734       <<"***      Starting main loop over snarls      ***"<<endl
02735       <<"************************************************"<<endl;
02736 
02737   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
02738     cnt.evtCounter++;
02739 
02740     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
02741 
02742     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
02743 
02744     //OVERRIDE
02745     //set the analysis version (could be kFullDST)
02746     nu.anaVersion=this->SanityCheckedAnaVersion
02747       (nu.anaVersion,overrideAnaVersion);
02748 
02749     nu.applyEnergyShifts=false;
02750     nu.applyBeamWeight=true;
02751     nu.applyDetectorWeight=false;
02752     nu.applyGeneratorWeight=false;
02753     nu.cutOnDataQuality=false;
02754 
02755     //RE-RECONSTRUCT the neutrino energy
02756     lib.reco.GetEvtEnergy(nu, false);
02757     lib.reco.ApplyReweights(nu);
02758 
02759     //make all the std cuts
02760     if (!this->IsGoodStdCuts(plots,nu)) continue;
02761 
02762     Bool_t printToScreen=true;
02763     const NuEvent* pnu=0;
02764     if (printToScreen && nu.charge==-1) pnu=this->GetEventND(nu);
02765     Float_t energyDiff=-1;
02766     Float_t trkEnDiff=-1;
02767     Float_t shwEnDiff=-1;
02768 
02769     if (printToScreen && pnu && nu.charge==-1) {
02770       const NuEvent& nui=*pnu;
02771 
02772       static NuReco reco;
02773       //reco.GetShowerEnergy(nu);
02774 
02775       energyDiff=nu.energy-nui.energy;
02776       trkEnDiff=nu.trkEn-nui.trkEn;
02777       shwEnDiff=nu.shwEn-nui.shwEn;
02778       Float_t rangeCurvDiff=nu.trkEnRange-nu.trkEnCurv;
02779 
02780       MAXMSG("NuDSTAna",Msg::kInfo,50)
02781         <<endl<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl
02782         <<"Exists in map: run="<<nu.run
02783         <<", snarl="<<nu.snarl<<", evt="<<nu.evt
02784         <<endl
02785         <<"My energy="<<nu.energy<<", CC std energy="<<nui.energy
02786         <<", Ediff="<<energyDiff
02787         <<endl
02788         <<"My trkEn="<<nu.trkEn<<", CC std trkEn="<<nui.trkEn
02789         <<", trkEnDiff="<<trkEnDiff
02790         <<endl
02791         <<"My shwEn="<<nu.shwEn<<", CC std shwEn="<<nui.shwEn
02792         <<", shwEnDiff="<<shwEnDiff
02793         <<endl;
02794 
02795 
02796       if (TMath::Abs(energyDiff)>0.005*(Munits::GeV)) {
02797         Float_t p=-1;
02798         if (nu.qp) p=1./nu.qp;
02799 
02800         MAXMSG("NuDSTAna",Msg::kInfo,50)
02801           <<endl<<"************************"<<endl
02802           <<endl<<"************************"<<endl
02803           <<endl<<"************************"<<endl
02804           <<endl<<"************************"<<endl
02805           <<"run="<<nu.run<<", snarl="<<nu.snarl<<", evt="<<nu.evt
02806           <<endl
02807           <<"My energy="<<nu.energy<<", CC std energy="<<nui.energy
02808           <<", Ediff="<<energyDiff
02809           <<endl
02810           <<"My trkEn="<<nu.trkEn<<", CC std trkEn="<<nui.trkEn
02811           <<", trkEnDiff="<<trkEnDiff
02812           <<endl
02813           <<"My shwEn="<<nu.shwEn<<", CC std shwEn="<<nui.shwEn
02814           <<", shwEnDiff="<<shwEnDiff
02815           <<endl
02816           <<"shwEn="<<nu.shwEn
02817           <<", shwEnCor="<<nu.shwEnCor
02818           <<", shwEnNoCor="<<nu.shwEnNoCor
02819           <<", primshw="<<nu.primshw
02820           <<", nshw="<<nu.nshw
02821           <<endl
02822           <<"shwEnNoCor1="<<nu.shwEnNoCor1
02823           <<", shwEnNoCor2="<<nu.shwEnNoCor2
02824           <<", shwEnNOCor3="<<nu.shwEnNoCor3
02825           <<", shwEnNoCor4="<<nu.shwEnNoCor4
02826           <<endl
02827           <<"shower1 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor1,CandShowerHandle::kCC,nu)
02828           <<" : x,y,z="<<nu.xShwVtx1
02829           <<","<<nu.yShwVtx1
02830           <<","<<nu.zShwVtx1
02831           <<endl
02832           <<"shower2 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor2,CandShowerHandle::kCC,nu)
02833           <<" : x,y,z="<<nu.xShwVtx2
02834           <<","<<nu.yShwVtx2
02835           <<","<<nu.zShwVtx2
02836           <<endl
02837           <<"shower3 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor3,CandShowerHandle::kCC,nu)
02838           <<" : x,y,z="<<nu.xShwVtx3
02839           <<","<<nu.yShwVtx3
02840           <<","<<nu.zShwVtx3
02841           <<endl
02842           <<"shower4 E="<<reco.GetShowerEnergyCor(nu.shwEnNoCor4,CandShowerHandle::kCC,nu)
02843           <<" : x,y,z="<<nu.xShwVtx4
02844           <<","<<nu.yShwVtx4
02845           <<","<<nu.zShwVtx4
02846           <<endl
02847           <<"track  x,y,z="<<nu.xTrkVtx
02848           <<","<<nu.yTrkVtx
02849           <<","<<nu.zTrkVtx
02850           <<endl
02851           <<"trkEnRange="<<nu.trkEnRange
02852           <<", trkEnCurv="<<nu.trkEnCurv
02853           <<", rng-crv="<<rangeCurvDiff
02854           <<endl
02855           <<"rangeNoCor="<<nu.trkMomentumRange
02856           <<", curvNoCor="<<p
02857           <<endl
02858           <<"trkEnCorRange1="<<nu.trkEnCorRange1
02859           <<", trkEnCorRange2="<<nu.trkEnCorRange2
02860           <<", trkEnCorRange3="<<nu.trkEnCorRange3
02861           <<endl
02862           <<"trkEnCorCurv1="<<nu.trkEnCorCurv1
02863           <<", trkEnCorCurv2="<<nu.trkEnCorCurv2
02864           <<", trkEnCorCurv3="<<nu.trkEnCorCurv3
02865           <<endl;
02866 
02867         hRecoEnOfDiff->Fill(nu.energy);
02868         hRecoTrkEnOfDiff->Fill(nu.trkEn);
02869         hRecoShwEnOfDiff->Fill(nu.shwEn);
02870 
02871       }
02872 
02873       hRecoEnDiff->Fill(energyDiff);
02874       hRecoTrkEnDiff->Fill(trkEnDiff);
02875       hRecoShwEnDiff->Fill(shwEnDiff);
02876       if (nu.containmentFlag==1 || nu.containmentFlag==3) {
02877         hRecoEnDiffRange->Fill(energyDiff);
02878         hRecoTrkEnDiffRange->Fill(trkEnDiff);
02879         hRecoShwEnDiffRange->Fill(shwEnDiff);
02880       }
02881       else if (nu.containmentFlag==2 || nu.containmentFlag==4) {
02882         hRecoEnDiffCurv->Fill(energyDiff);
02883         hRecoTrkEnDiffCurv->Fill(trkEnDiff);
02884         hRecoShwEnDiffCurv->Fill(shwEnDiff);
02885       }
02886       else cout<<"Ahhhhh"<<endl;
02887     }
02888 
02889     //only pass the ones that aren't in trish's sample
02890     //if (pnu) continue;
02891     //if (nu.snarl>=140344) continue;
02892     if (nu.snarl>=56595) continue;
02893 
02894     if (nu.charge==-1) {
02895       plots->PrintEventInfo(nmTxt,nu);
02896       cnt.nuNQCounter++;
02897     }
02898     else if (nu.charge==+1) {
02899       plots->PrintEventInfo(nmbTxt,nu);
02900       cnt.nuPQCounter++;
02901     }
02902     else cout<<"ahhh, bad charge (2)"<<endl;
02903 
02904 
02905     MAXMSG("NuDSTAna",Msg::kInfo,50)
02906       <<"Weights before: beam="<<nu.beamWeight
02907       <<", det="<<nu.detectorWeight
02908       <<", trk="<<nu.trkEnWeight
02909       <<", shw="<<nu.shwEnWeight
02910       <<endl;
02911     Float_t beamWeightBefore=nu.beamWeight;
02912 
02913     //lib.zBeamReweight.ExtractZBeamReweight(nu);
02914 
02915 
02916     Float_t beamDiff=nu.beamWeight-beamWeightBefore;
02917     MAXMSG("NuDSTAna",Msg::kInfo,50)
02918       <<"Weights after:  beam="<<nu.beamWeight
02919       <<", det="<<nu.detectorWeight
02920       <<", trk="<<nu.trkEnWeight
02921       <<", shw="<<nu.shwEnWeight
02922       <<", bdiff="<<beamDiff
02923       <<endl;
02924 
02925     //make the final plots
02926     this->MakeFinalPlots(plots,nu);
02927 
02928     MAXMSG("NuDSTAna",Msg::kInfo,5)
02929       <<"Passed: index="<<nu.index
02930       <<", energy="<<nu.energy<<", energyMC="<<nu.energyMC<<endl;
02931   }//end of loop over summary tree
02932 
02933   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
02934 
02938 
02939   //print out the numbers of events
02940   cnt.PrintMicroDST();
02941 
02942   MSG("NuAnalysis",Msg::kInfo)
02943     <<" ** Finished FDTestAna method **"<<endl;
02944 }

void NuDSTAna::NewFieldAna ( std::string  sOutputFileName = ""  ) 

Definition at line 8097 of file NuDSTAna.cxx.

References NuReco::ApplyReweights(), NuLibrary::cnt, DoIO(), NuCounter::evtCounter, NuHistos::FillMatrixMethodHistos(), NuInputEvents::GetEntriesNuEvent(), NuReco::GetEvtEnergy(), NuInputEvents::GetNextNuEvent(), NuLibrary::hist, NuInputEvents::InitialiseNuEventBranch(), NuLibrary::Instance(), IsGoodStdCuts(), Msg::kDebug, Msg::kError, Detector::kFar, Msg::kInfo, NuCuts::kJJE2, Detector::kNear, MakeFinalPlots(), MSG, NuCounter::nuNQCounter, NuCounter::nuPQCounter, plots(), NuBase::PrintLoopProgress(), NuCounter::PrintMicroDST(), NuLibrary::reco, NuUtilities::RecoBins(), NuInputEvents::ResetNuEventLoopPositionToStart(), SanityCheckedAnaVersion(), and NuUtilities::TrueBins().

08098 {
08099   NuInputEvents& input=this->DoIO(0,"",sOutputFileName);
08100 
08101   //get an instance of the code library
08102   NuLibrary& lib = NuLibrary::Instance();
08103 
08104   //get an object to fill plots
08105   const NuPlots* plots=0;
08106 
08107   //version to do reco/cuts with
08108   NuCuts::NuAnaVersion_t overrideAnaVersion =
08109     static_cast<NuCuts::NuAnaVersion_t>(NuCuts::kJJE2);
08110 
08111   //Binning scheme
08112   NuBinningScheme::NuBinningScheme_t binningScheme =
08113     static_cast<NuBinningScheme::NuBinningScheme_t>(3);
08114 
08115   const NuUtilities cuts;
08116 
08117   std::vector<Double_t> vReco = cuts.RecoBins(binningScheme);
08118   std::vector<Double_t> vTrue = cuts.TrueBins(binningScheme);
08119 
08120   TH1::AddDirectory(true);
08121   TH1D * hqp_numu = new TH1D("hqp_numu","qp for NuMus", 200, -5, 5);
08122   TH1D * hqp_nubar = new TH1D("hqp_nubar","qp for NuBars", 200, -5, 5);
08123   TH1D * htrken_numu = new TH1D("htrken_numu","Track Energy for NuMus", 200, 0, 20);
08124   TH1D * htrken_nubar = new TH1D("htrken_nubar","Track Energy for NuBars", 200, 0, 20);
08125 
08126 
08127   input.InitialiseNuEventBranch();
08128   input.ResetNuEventLoopPositionToStart();
08129 
08130   cout<<endl
08131       <<"************************************************"<<endl
08132       <<"***      Starting main loop over snarls      ***"<<endl
08133       <<"************************************************"<<endl;
08134   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
08135     //for (Int_t i=0;i<0;++i) {
08136     lib.cnt.evtCounter++;
08137 
08138     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
08139 
08140     NuEvent &nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
08141 
08142     // Select only the right runs
08143     if (nu.detector == Detector::kFar && nu.run > 21037019)
08144       continue;
08145     if (nu.detector == Detector::kNear && nu.run > 13037009)
08146       continue;
08147 
08148 
08149     //OVERRIDE
08150     //Selection
08151     nu.anaVersion=this->SanityCheckedAnaVersion
08152       (nu.anaVersion,overrideAnaVersion);
08153     //Reweighting
08154     nu.applyBeamWeight = true;
08155 
08156     MSG("NuDSTAna", Msg::kError) << "Can't apply RunI weights which no longer exist" << endl;
08157 
08158     //RE-RECONSTRUCT the neutrino energy
08159     lib.reco.GetEvtEnergy(nu, false);
08160     lib.reco.ApplyReweights(nu);
08161 
08162     // CC-only
08163     if (nu.iaction==1) {
08164 
08165       if (nu.inu == -14) {
08166         hqp_nubar->Fill(nu.qp, nu.rw);
08167         htrken_nubar->Fill(nu.trkEnCurv, nu.rw);
08168       }
08169       else if (nu.inu == 14) {
08170         hqp_numu->Fill(nu.qp, nu.rw);
08171         htrken_numu->Fill(nu.trkEnCurv, nu.rw);
08172       }
08173     }
08174 
08175     if (!this->IsGoodStdCuts(plots,nu)) continue;
08176 
08177     if (nu.charge==-1) lib.cnt.nuNQCounter++;
08178     else if (nu.charge==+1) lib.cnt.nuPQCounter++;
08179     else cout<<"ahhh, bad charge (10)"<<endl;
08180 
08181 
08182     //make the final plots
08183     this->MakeFinalPlots(plots,nu);
08184 
08185     //fill matrix method histos
08186     lib.hist.FillMatrixMethodHistos(nu, binningScheme);
08187   }
08188 
08189   MSG("NuAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
08190 
08194 
08195   //print out the numbers of events
08196   lib.cnt.PrintMicroDST();
08197 
08198   MSG("NuAnalysis",Msg::kInfo)
08199     <<" ** Finished NewFieldAna method **"<<endl;
08200 }

void NuDSTAna::NMBAna (  ) 

Definition at line 95 of file NuDSTAna.cxx.

References CopyAcrossHistos(), NuPlots::FillDPIdSigmaQPFailDpIDCutPlots(), NuPlots::FillDPIdSigmaQPFailProbCutPlots(), NuPlots::FillDPIdSigmaQPFailSigQPCutPlots(), NuPlots::FillDPIdSigmaQPPassDpIDCutPlots(), NuPlots::FillDPIdSigmaQPPassSigQPCutPlots(), NuPlots::FillEnergyBinHistos(), NuBase::fOutFile, NuInputEvents::GetEntriesNuEvent(), NuInputEvents::GetFirstRunNumberNuEvent(), NuBase::GetInputFileName(), NuInputEvents::GetNextNuEvent(), NuInputEvents::InitialiseChains(), NuInputEvents::InitialiseNuEventBranch(), NuInputEvents::InputFileName(), NuCuts::IsGoodAbID(), NuCuts::IsGoodFitChi2PerNdof(), NuCuts::IsGoodFitProb(), NuCuts::IsGoodSigmaQP_QP(), NuCuts::IsGoodTrackFitPass(), NuCuts::IsInCylindricalVolume(), NuCuts::IsInFidVolTrk(), Msg::kDebug, Msg::kInfo, NuCuts::kNMB0325Bravo, Munits::m, MakeFinalPlots(), MakePostPreSelectionPlots(), MAXMSG, NuBase::OpenFile(), NuInputEvents::OpenInputFile(), NuGeneral::OscWeight(), plots(), NuBase::PrintLoopProgress(), NuInputEvents::ResetNuEventLoopPositionToStart(), and SanityCheckedAnaVersion().

00096 {
00097   //open the input file with the tree in it
00098   string inputFileName=this->GetInputFileName();
00099   NuInputEvents* fpInput=new NuInputEvents();
00100   NuInputEvents& input=*fpInput;
00101   input.InputFileName(inputFileName);
00102   input.InitialiseChains();
00103   input.InitialiseNuEventBranch();
00104   TDirectory* dirInput=input.OpenInputFile();
00105   Int_t firstRunNumber=input.GetFirstRunNumberNuEvent();
00106 
00107   //open the output file for histos etc
00108   string sFilePrefix="NMBSumAna";
00109   fOutFile=this->OpenFile(firstRunNumber,sFilePrefix.c_str());
00110   TDirectory* dirOutput=gDirectory;
00111   cout<<"After opening output file:"<<endl;
00112   dirOutput->Print();
00113 
00114   //copy across histos such hDetector, hSimFlag, and POT ones
00115   this->CopyAcrossHistos(dirInput,dirOutput);
00116 
00117   cout<<"Before creating histos output file:"<<endl;
00118   gDirectory->Print();
00119 
00120   static NuGeneral general;
00121   static NuPlots* plots;
00122   static NuCuts cuts;
00123 
00124   //version to do reco/cuts with
00125   NuCuts::NuAnaVersion_t overrideAnaVersion=NuCuts::kNMB0325Bravo;
00126 
00127   //draw detailed distance to edge plot
00128   //static NuReco reco;
00129   //reco.TestGetSmallestDeepDistToEdge();
00130 
00131   input.ResetNuEventLoopPositionToStart();
00132 
00133   for (Int_t i=0;i<input.GetEntriesNuEvent();++i) {
00134 
00135     this->PrintLoopProgress(i,input.GetEntriesNuEvent(),1);
00136 
00137     NuEvent& nu=const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
00138 
00139     //set the analysis version (could be kFullDST)
00140     nu.anaVersion=this->SanityCheckedAnaVersion
00141       (nu.anaVersion,overrideAnaVersion);
00142 
00143     //OVERRIDE
00144     nu.rw=nu.beamWeight*nu.detectorWeight*nu.generatorWeight;
00145     nu.trkEn=nu.trkEnRw;
00146     nu.shwEn=nu.shwEnRw;
00147     nu.energy=nu.energyRw;
00148 
00149     //const Float_t beamzerox=1.4885*(Munits::m);
00150     const Float_t beamzerox=1.4828*(Munits::m);//new for 2.5 analysis
00151     //const Float_t beamzerox=1.2*(Munits::m);
00152     //const Float_t beamzeroy=0.1397*(Munits::m);
00153     const Float_t beamzeroy=0.2384*(Munits::m);//new for 2.5 analysis
00154     //const Float_t beamzeroy=0.0*(Munits::m);
00155     const Float_t minZ=1.0*(Munits::m);
00156     const Float_t maxZ=4.0*(Munits::m);
00157     const Float_t maxR=0.5*(Munits::m);
00158     //additional cut on x position to remove coil hole
00159     //if (nu.xTrkVtx<0.7) continue;
00160 
00161     Bool_t passFid=cuts.IsInCylindricalVolume(nu.xTrkVtx,nu.yTrkVtx,
00162                                               nu.zTrkVtx,
00163                                               beamzerox,beamzeroy,
00164                                               minZ,maxZ,maxR);
00165 
00166     if (!passFid) continue;
00167     //if (nu.containmentFlagPitt>=3) continue;//got to downstream
00168     //if (nu.containmentFlagPitt<=2) continue;//only got to upstream
00169 
00170     //override the anaVersion
00171     //nu.anaVersion=NuCuts::kNMB0325Bravo;
00172 
00173     //check if the trk is in the fiducial volume
00174     if (!cuts.IsInFidVolTrk(nu)) continue;
00175 
00176     //require a good trk fit
00177     if (!cuts.IsGoodTrackFitPass(nu)) continue;
00178 
00179     //make the post-preselection plots
00180     this->MakePostPreSelectionPlots(plots,nu);
00181 
00182     //cut on the PID
00183     //if (!cuts.IsGoodDpID(nu)) {
00184     if (!cuts.IsGoodAbID(nu)) {
00185       plots->FillDPIdSigmaQPFailDpIDCutPlots(nu);
00186       continue;
00187     }
00188     plots->FillDPIdSigmaQPPassDpIDCutPlots(nu);
00189 
00190     plots->FillEnergyBinHistos(nu);//just PID cut
00191 
00192     //cut on the fractional track momentum and sign error
00193     if (!cuts.IsGoodSigmaQP_QP(nu)) {
00194       plots->FillDPIdSigmaQPFailSigQPCutPlots(nu);
00195       continue;
00196     }
00197     plots->FillDPIdSigmaQPPassSigQPCutPlots(nu);
00198 
00199     //cut on the chi2
00200     if (!cuts.IsGoodFitChi2PerNdof(nu)) continue;
00201 
00202     //was here
00203     //plots->FillEnergyBinHistos(nu);
00204 
00205     //cut on the track fit probability
00206     if (!cuts.IsGoodFitProb(nu)) {
00207       plots->FillDPIdSigmaQPFailProbCutPlots(nu);
00208       continue;
00209     }
00210 
00211     if (nu.trkEn<0.5) {
00212       Float_t momCurv=-1;
00213       if (nu.qp!=0) momCurv=1./nu.qp;
00214       MAXMSG("NuReco",Msg::kInfo,10)
00215         <<endl
00216         <<"DST:"
00217         <<" nshw="<<nu.nshw
00218         <<", ntrk="<<nu.ntrk
00219         <<", primshw="<<nu.primshw
00220         <<", primtrk="<<nu.primtrk
00221         <<", shwExists="<<nu.shwExists<<","
00222         <<", trkExists="<<nu.trkExists<<","
00223         <<endl
00224         <<"shwExists1,2,3="<<nu.shwExists1<<","
00225         <<nu.shwExists2<<","<<nu.shwExists3
00226         <<",  trkExists1,2,3="<<nu.trkExists1<<","
00227         <<nu.trkExists2<<","<<nu.trkExists3<<endl
00228         <<"E="<<nu.energy<<", trkEn="<<nu.trkEn<<", shwEn="<<nu.shwEn
00229         <<endl
00230         <<"trkMomentumRange="<<nu.trkMomentumRange
00231         <<", momCurv="<<momCurv
00232         <<", usedCurv="<<nu.usedCurv<<", fitpass="<<nu.trkfitpass
00233         <<endl
00234         <<"dircosnu="<<nu.dirCosNu
00235         <<", y="<<nu.y<<", q2="<<nu.q2
00236         <<", w2="<<nu.w2<<", x="<<nu.x
00237         <<endl
00238         <<"shwEn1="<<nu.shwEnCor1
00239         <<", shw2="<<nu.shwEnCor2
00240         <<", shw3="<<nu.shwEnCor3
00241         <<", shw4="<<nu.shwEnCor4
00242         <<", shw5="<<nu.shwEnCor5
00243         //<<", shw6="<<nu.shwEnCor6
00244         //<<", shw7="<<nu.shwEnCor7
00245         <<endl
00246         <<"trkCv1="<<nu.trkEnCorCurv1
00247         <<", trkCv2="<<nu.trkEnCorCurv2
00248         <<", trkCv3="<<nu.trkEnCorCurv3
00249         <<endl
00250         <<"trkRg1="<<nu.trkEnCorRange1
00251         <<", trkRg2="<<nu.trkEnCorRange2
00252         <<", trkRg3="<<nu.trkEnCorRange3
00253         <<endl;
00254     }
00255 
00256     //extra cuts to test
00257     //if (nu.dpID<+0.1) continue;
00258     //if (nu.dpID<+0.4) continue;
00259     //if (nu.dpID<+0.4 && nu.charge>0) continue;
00260     //if (nu.prob<0.1) continue;
00261     //if (nu.sigqp_qp>0.3) continue;
00262 
00263     //Bool_t weightForOsc=true;
00264     Bool_t weightForOsc=false;
00265     if (weightForOsc){
00266       //get the weight for the event
00267       Double_t weight=nu.rw;
00268       //apply the oscillation weight to CC events
00269       if (nu.iaction==1) {
00270         Float_t dm2=2.7e-3;
00271         Double_t oscWeight=general.OscWeight(dm2,1,
00272                                              nu.energyMC);
00273         weight*=oscWeight;
00274       }
00275       nu.rw=weight;
00276     }
00277 
00278     //if (nu.containedTrk && nu.rTrkEnd<0.3) {
00279     //MAXMSG("NuDSTAna",Msg::kInfo,200)
00280     //<<"nu.rTrkEnd="<<nu.rTrkEnd<<endl;
00281     //}
00282 
00284     //if (nu.rTrkEnd>0.3) continue;
00285 
00286     //if (nu.xTrkEnd<-0.2 && nu.planeTrkEnd<=120 && nu.containmentFlag==1) {
00287     //MAXMSG("NuDSTAna",Msg::kInfo,200)
00288     //<<"xTrkEnd="<<nu.xTrkEnd
00289     //<<", y="<<nu.yTrkEnd
00290     //<<", r="<<nu.rTrkEnd
00291     //<<", plTrkEnd"<<nu.planeTrkEnd
00292     //<<", con="<<nu.containedTrk
00293     //<<", flag="<<nu.containmentFlag
00294     //<<endl;
00295     //}
00296 
00297     //make the final plots
00298     this->MakeFinalPlots(plots,nu);
00299 
00300     MAXMSG("NuDSTAna",Msg::kInfo,5)
00301       <<"NMBSummaryTreeAna: NuEvent: index="<<nu.index
00302       <<", energy="<<nu.energy<<", energyMC="<<nu.energyMC<<endl;
00303   }//end of loop over summary tree
00304 }

void NuDSTAna::Oscillate ( NuMCEvent nu,
const NuXMLConfig xmlConfig 
) const [protected]

Reimplemented in FoverNHistos.

Definition at line 9740 of file NuDSTAna.cxx.

References NuXMLConfig::ALPHA(), NuOscProbCalc::DecayWeightCC(), NuOscProbCalc::DecayWeightMuToTau(), NuOscProbCalc::DecayWeightNC(), NuOscProbCalc::DecoherenceWeight(), NuMCEvent::detector, NuXMLConfig::DM2Bar(), NuXMLConfig::DM2Nu(), NuXMLConfig::EPSILON(), NuMCEvent::iaction, NuMCEvent::inu, NuMCEvent::inunoosc, SimFlag::kData, Detector::kFar, Msg::kInfo, MAXMSG, NuXMLConfig::MU2Nu(), NuMCEvent::neuEnMC, NuOscProbCalc::NSIWeight(), NuXMLConfig::OscillationModel(), OscillationWeight(), NuMCEvent::rw, NuMCEvent::simFlag, NuXMLConfig::SN2Bar(), and NuXMLConfig::SN2Nu().

09742 {
09743   if (!xmlConfig){return;}
09744   if (SimFlag::kData == mc.simFlag){
09745     MAXMSG("NuDSTAna",Msg::kInfo,1)
09746       << "Not applying fake oscillations to data" << endl;
09747     return;
09748   }
09749   if (Detector::kFar != mc.detector){
09750     MAXMSG("NuDSTAna",Msg::kInfo,1)
09751       << "Not applying fake oscillations to ND MC" << endl;
09752     return;
09753   }
09754   if (xmlConfig->DM2Nu() < 0.0 ||
09755       xmlConfig->SN2Nu() < 0.0 ||
09756       xmlConfig->DM2Bar() < 0.0 ||
09757       xmlConfig->SN2Bar() < 0.0){
09758     MAXMSG("NuDSTAna",Msg::kInfo,1)
09759       << "Not applying fake oscillations due to xml configuration"
09760       << endl;
09761     return;
09762   }
09763   if (1 != mc.iaction && (16 == mc.inu || -16 == mc.inu)){
09764     mc.rw=0;
09765     MAXMSG("NuDSTAna",Msg::kInfo,1)
09766       <<"Removing MC NC from Tau file"<<endl;
09767     return;
09768   }
09769 
09770   if(xmlConfig->OscillationModel() == 1){
09771     switch(mc.iaction){
09772     case 0:
09773       mc.rw *= NuOscProbCalc::DecayWeightNC(mc.neuEnMC,
09774                                           xmlConfig->ALPHA(),
09775                                           xmlConfig->SN2Nu());
09776     return;
09777     case 1:
09778       if(abs(mc.inu) == 14){
09779         mc.rw *= NuOscProbCalc::DecayWeightCC(mc.neuEnMC,
09780                                             xmlConfig->ALPHA(),
09781                                             xmlConfig->SN2Nu(),
09782                                             xmlConfig->DM2Nu());
09783         return;
09784       }
09785       if(abs(mc.inu == 16)){
09786         mc.rw *= NuOscProbCalc::DecayWeightMuToTau(mc.neuEnMC,
09787                                                  xmlConfig->ALPHA(),
09788                                                  xmlConfig->SN2Nu(),
09789                                                  xmlConfig->DM2Nu());
09790         return;
09791       }
09792       // An electron maybe? Ignore it
09793       return;
09794     default:
09795       assert(0 && "Unknown iaction");
09796     }
09797   }
09798 
09799   if(xmlConfig->OscillationModel() == 2){
09800     if(mc.iaction == 1){
09801       mc.rw *= NuOscProbCalc::DecoherenceWeight(mc.neuEnMC,
09802                                               xmlConfig->MU2Nu(),
09803