TemplateAnalysisClass Class Reference

#include <TemplateAnalysisClass.h>

Inheritance diagram for TemplateAnalysisClass:
NuDSTAna NuBase

List of all members.

Public Member Functions

 TemplateAnalysisClass (NuXMLConfig *xmlConfig)
virtual ~TemplateAnalysisClass ()
virtual void MakePlots ()

Private Member Functions

virtual NuInputEventsGetEventListForLooping ()
virtual void PrepareEventForPlotting (NuEvent &event) const
virtual void Delete (TH1D *p)
virtual void CreateHistograms (const NuEvent &nu)
virtual void DeleteHistograms ()
virtual void FillPlots (NuEvent &event)
virtual void WritePlots ()

Private Attributes

Bool_t fHistogramsCreated
NuCuts::NuAnaVersion_t fAnaVersion
NuCutterfCutter
NuLibraryfLib
NuXMLConfigfxmlConfig
NuSystematicfsyst
TH1D * hRecoEnergyAll
TH1D * hRecoEnergyNQ
TH1D * hRecoEnergyPQ
std::vector< TH1D * > fvHistos

Detailed Description

Definition at line 25 of file TemplateAnalysisClass.h.


Constructor & Destructor Documentation

TemplateAnalysisClass::TemplateAnalysisClass ( NuXMLConfig xmlConfig  )  [explicit]

Definition at line 30 of file TemplateAnalysisClass.cxx.

References NuCutter::AnaVersion(), NuXMLConfig::AnaVersionString(), fAnaVersion, fCutter, fHistogramsCreated, fLib, fsyst, fxmlConfig, NuCutter::GetCut(), NuLibrary::Instance(), Msg::kWarning, MSG, NuSystematic::SetCCSelector(), and NuSystematic::SetNuBarSelector().

00031 {
00032   if (!xmlConfig){
00033     MSG("TemplateAnalysisClass",Msg::kWarning)
00034       << "Analysis object configured with a non-existent xml object."
00035       << endl
00036       << "Asserting now."
00037       << endl;
00038     assert(false);
00039   }
00040   fxmlConfig = xmlConfig;
00041 
00042   // Get the anaVersion and anaVersionNC from the XML config
00043   TString anaVer = fxmlConfig->AnaVersionString();
00044 
00045   fCutter = new NuCutter(anaVer);
00046 
00047   // Get NuAnaVersion_t from the cutter objects
00048   fAnaVersion = static_cast<NuCuts::NuAnaVersion_t>(fCutter->AnaVersion());
00049   
00050   //create NuSystematic object:
00051   fsyst = new NuSystematic(*xmlConfig);
00052   fsyst->SetNuBarSelector(fCutter->GetCut());
00053   fsyst->SetCCSelector(fCutter->GetCut());
00054   
00055   fLib = &NuLibrary::Instance();
00056   fHistogramsCreated = false;
00057 }

TemplateAnalysisClass::~TemplateAnalysisClass (  )  [virtual]

Definition at line 60 of file TemplateAnalysisClass.cxx.

References DeleteHistograms(), fCutter, and fLib.

00061 {
00062   if (fCutter) {
00063     delete fCutter;
00064     fCutter = 0;
00065   }
00066   fLib = 0; //I didn't create this, so don't have the right to delete it.
00067   this->DeleteHistograms();
00068 }


Member Function Documentation

void TemplateAnalysisClass::CreateHistograms ( const NuEvent nu  )  [private, virtual]

Definition at line 129 of file TemplateAnalysisClass.cxx.

References fHistogramsCreated, fvHistos, hRecoEnergyAll, hRecoEnergyNQ, hRecoEnergyPQ, SimFlag::kMC, and NuEvent::simFlag.

Referenced by MakePlots().

00130 {
00131 
00132   cout << "Creating histograms" << endl;
00133   hRecoEnergyAll = new TH1D("hRecoEnergyAll","",400,0,200);
00134   hRecoEnergyNQ = new TH1D("hRecoEnergyNQ","",400,0,200);
00135   hRecoEnergyPQ = new TH1D("hRecoEnergyPQ","",400,0,200);
00136 
00137   if (event.simFlag == SimFlag::kMC){
00138     //Create MC-only plots. You can similarly create ND-only plot, etc
00139   }
00140   
00141   fvHistos.push_back(hRecoEnergyAll);
00142   fvHistos.push_back(hRecoEnergyNQ);
00143   fvHistos.push_back(hRecoEnergyPQ);
00144 
00145   fHistogramsCreated = true;
00146 } // CreateHistograms()

void TemplateAnalysisClass::Delete ( TH1D *  p  )  [private, virtual]

Definition at line 159 of file TemplateAnalysisClass.cxx.

Referenced by DeleteHistograms().

00160 {
00161   if (p){delete p; p=0;}
00162 }

void TemplateAnalysisClass::DeleteHistograms (  )  [private, virtual]

Definition at line 149 of file TemplateAnalysisClass.cxx.

References Delete(), fvHistos, and it.

Referenced by ~TemplateAnalysisClass().

00150 {
00151   for (vector<TH1D*>::iterator it = fvHistos.begin();
00152        it != fvHistos.end();
00153        ++it){
00154     this->Delete(*it);
00155   }
00156 } // DeleteHistograms()

void TemplateAnalysisClass::FillPlots ( NuEvent event  )  [private, virtual]

Definition at line 165 of file TemplateAnalysisClass.cxx.

References NuEvent::charge, NuEvent::energy, hRecoEnergyAll, hRecoEnergyNQ, hRecoEnergyPQ, PrepareEventForPlotting(), and NuEvent::rw.

Referenced by MakePlots().

00166 {
00167   this->PrepareEventForPlotting(event);
00168 
00169   hRecoEnergyAll->Fill(event.energy, event.rw);
00170 
00171   if (-1 == event.charge){
00172     hRecoEnergyNQ->Fill(event.energy, event.rw);
00173   }
00174   if (1 == event.charge){
00175     hRecoEnergyPQ->Fill(event.energy, event.rw);
00176   }
00177 }

NuInputEvents & TemplateAnalysisClass::GetEventListForLooping (  )  [private, virtual]

Definition at line 71 of file TemplateAnalysisClass.cxx.

References NuDSTAna::DoIO(), fxmlConfig, and NuInputEvents::ResetNuEventLoopPositionToStart().

Referenced by MakePlots().

00072 {
00073   NuInputEvents& input = this->DoIO(0, "", "null");
00074   fxmlConfig->Write();
00075   input.ResetNuEventLoopPositionToStart();
00076   return input;
00077 }

void TemplateAnalysisClass::MakePlots (  )  [virtual]

Definition at line 80 of file TemplateAnalysisClass.cxx.

References CreateHistograms(), fCutter, fHistogramsCreated, FillPlots(), NuInputEvents::GetEntriesNuEvent(), GetEventListForLooping(), NuInputEvents::GetNextNuEvent(), Msg::kDebug, NuCutter::MakeCuts(), NuCutter::Passed(), PrepareEventForPlotting(), NuCutter::PrintSummary(), NuUtilities::ProgressBar(), and WritePlots().

00081 {
00082   NuInputEvents& input = this->GetEventListForLooping();
00083 
00084   for (Int_t i = 0; i < input.GetEntriesNuEvent(); ++i){
00085     NuUtilities::ProgressBar(i, input.GetEntriesNuEvent(), 5);
00086     NuEvent &nu = const_cast<NuEvent&>(input.GetNextNuEvent(Msg::kDebug));
00087     if (!fHistogramsCreated){this->CreateHistograms(nu);}
00088     
00089     this->PrepareEventForPlotting(nu);
00090     
00091     fCutter->MakeCuts(nu);
00092     
00093     if (fCutter->Passed()) {
00094       this->FillPlots(nu);
00095     }
00096   } // for
00097   
00098   this->WritePlots();
00099   
00100   fCutter->PrintSummary();
00101 }

void TemplateAnalysisClass::PrepareEventForPlotting ( NuEvent event  )  const [private, virtual]

Definition at line 104 of file TemplateAnalysisClass.cxx.

References NuReco::ApplyReweights(), NuReco::CalcResolution(), NuXMLConfig::ConfigureWeights(), fAnaVersion, fLib, fsyst, fxmlConfig, NuReco::GetEvtEnergy(), SimFlag::kData, NuCuts::kNCPRLNC, NuLibrary::reco, NuSystematic::Shift(), and NuEvent::simFlag.

Referenced by FillPlots(), and MakePlots().

00105 {
00106     event.anaVersion = fAnaVersion;
00107 
00108     fxmlConfig->ConfigureWeights(event);
00109 
00110     //RE-RECONSTRUCT the neutrino energy
00111     fLib->reco.GetEvtEnergy(event, false);
00112     fLib->reco.ApplyReweights(event);
00113     fLib->reco.CalcResolution(event);
00114    
00115     //apply systematics & oscillations
00116     if (event.simFlag!=SimFlag::kData) {
00117       fsyst->Shift(event);
00118       //Apply oscillations here if desired
00119     }
00120     
00121   //Used for NC selection comparisons 
00122     if(NuCuts::kNCPRLNC == fAnaVersion){
00123       //Do nothing for now
00124     }
00125     
00126 }

void TemplateAnalysisClass::WritePlots (  )  [private, virtual]

Definition at line 181 of file TemplateAnalysisClass.cxx.

References fvHistos, and it.

Referenced by MakePlots().

00182 {
00183   for (vector<TH1D*>::iterator it = fvHistos.begin();
00184        it != fvHistos.end();
00185        ++it){
00186     (*it)->Write();
00187   }
00188 }


Member Data Documentation

Definition at line 35 of file TemplateAnalysisClass.h.

Referenced by PrepareEventForPlotting(), and TemplateAnalysisClass().

Definition at line 34 of file TemplateAnalysisClass.h.

Referenced by CreateHistograms(), MakePlots(), and TemplateAnalysisClass().

Definition at line 39 of file TemplateAnalysisClass.h.

Referenced by PrepareEventForPlotting(), and TemplateAnalysisClass().

std::vector<TH1D*> TemplateAnalysisClass::fvHistos [private]

Definition at line 45 of file TemplateAnalysisClass.h.

Referenced by CreateHistograms(), DeleteHistograms(), and WritePlots().

Definition at line 41 of file TemplateAnalysisClass.h.

Referenced by CreateHistograms(), and FillPlots().

Definition at line 42 of file TemplateAnalysisClass.h.

Referenced by CreateHistograms(), and FillPlots().

Definition at line 43 of file TemplateAnalysisClass.h.

Referenced by CreateHistograms(), and FillPlots().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1