Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

NuTreeWrapper Class Reference

#include <NuTreeWrapper.h>

List of all members.

Public Member Functions

 NuTreeWrapper ()
 NuTreeWrapper (std::string filelist)
virtual ~NuTreeWrapper ()
virtual const Int_t Detector () const
virtual void FillTree ()
virtual const Int_t GetEntries () const
virtual const Int_t GetEntriesFast () const
virtual const NuEvent GetInfoObject (const Int_t event) const
virtual NuEventGetObjectToFill ()
virtual const Double_t GetPoT () const
virtual void Write (const std::string filename)

Private Member Functions

virtual void CalculatePoTs ()
virtual void LoadEvent (const Int_t event) const

Private Attributes

Bool_t IAmReadable
Int_t fcurrEntry
Double_t fTotPoT
TFile * fDummyFile
TTree * fNuTreeWrapper
TChain fInputChain
NuEventfNuEvent
NuEventfInputInfo


Constructor & Destructor Documentation

NuTreeWrapper::NuTreeWrapper  ) 
 

Definition at line 35 of file NuTreeWrapper.cxx.

00036   : IAmReadable(false),
00037     fcurrEntry(-1)
00038 {
00039   //Constructor to create a writable tree
00040   fNuTreeWrapper = new TTree("s","s");
00041   cout<<"NuTreeWrapper::Creating new NuEvent for output to tree"<<endl;
00042   fNuEvent = new NuEvent();
00043   fNuTreeWrapper->Branch("s","NuEvent",&fNuEvent,32000,2);
00044   fInputInfo = 0;
00045 }

NuTreeWrapper::NuTreeWrapper std::string  filelist  ) 
 

Definition at line 49 of file NuTreeWrapper.cxx.

References CalculatePoTs(), fInputChain, fInputInfo, and fTotPoT.

00051   : IAmReadable(true),
00052     fcurrEntry(-1),
00053     fInputChain("s")
00054 {
00055   //Constructor to read a tree(s) from file
00056   cout << "Running constructor." << endl;
00057   fInputInfo = 0;
00058   fInputChain.Add(filelist.c_str());
00059   fInputChain.SetBranchAddress("s",&fInputInfo);
00060   fTotPoT = 0.0;
00061 
00062   this->CalculatePoTs();
00063 }

NuTreeWrapper::~NuTreeWrapper  )  [virtual]
 

Definition at line 66 of file NuTreeWrapper.cxx.

00067 {
00068 }


Member Function Documentation

void NuTreeWrapper::CalculatePoTs  )  [private, virtual]
 

Definition at line 71 of file NuTreeWrapper.cxx.

References Detector(), fInputChain, fTotPoT, and MSG.

Referenced by NuTreeWrapper().

00072 {
00073   cout << "Running PoT function" << endl;
00074   TObjArray* fileList = fInputChain.GetListOfFiles();
00075   fTotPoT = 0.0;
00076   cout << "Starting fileLoop" << endl;
00077   Int_t detector = this->Detector();
00078   cout << "Got detector: " << detector << endl;
00079   for (Int_t counter=0; counter<fileList->GetEntries(); ++counter){
00080     TChainElement* chainElement =
00081       dynamic_cast<TChainElement*> (fileList->At(counter));
00082     if (chainElement){
00083       string fileName = chainElement->GetTitle();
00084       TFile f(fileName.c_str(),"READ");
00085       TH1F* hPottortgt = (TH1F*) f.Get("hPottortgt");
00086       TH1F* hRun = (TH1F*) f.Get("hRun");
00087       if (1==detector){
00088         fTotPoT += hPottortgt->GetMean()*hPottortgt->GetEntries()*1e12;
00089       }
00090       if (2==detector){
00091         fTotPoT += hPottortgt->GetMean()*hRun->GetEntries()*1e8*1e12;
00092       }
00093       fTotPoT += hPottortgt->Integral();
00094       f.Close();
00095     }
00096   }
00097     MSG("NuTreeWrapper.cxx",Msg::kInfo)
00098       << "PoT: " << fTotPoT << endl;
00099   return;
00100 }

const Int_t NuTreeWrapper::Detector  )  const [virtual]
 

Definition at line 103 of file NuTreeWrapper.cxx.

References NuEvent::detector, GetEntriesFast(), GetInfoObject(), and MSG.

Referenced by CalculatePoTs().

00104 {
00105   if (this->GetEntriesFast()){
00106     return this->GetInfoObject(0).detector;
00107   }
00108   else{
00109     MSG("NuTreeWrapper.cxx",Msg::kError)
00110       << "Trying to get PoT for empty NuTreeWrapper" << endl;
00111     return 0;
00112   }
00113 }

void NuTreeWrapper::FillTree  )  [virtual]
 

Definition at line 116 of file NuTreeWrapper.cxx.

References fNuTreeWrapper.

00117 {
00118   //fill the tree
00119   fNuTreeWrapper->Fill();
00120 }

const Int_t NuTreeWrapper::GetEntries  )  const [virtual]
 

Definition at line 123 of file NuTreeWrapper.cxx.

References fInputChain, and MSG.

Referenced by NuXFitAnalysis::CacheFDMCEvents(), NuCrossSectionFitter::CacheNDMCEvents(), NuXFitAnalysis::FillFDDataHistograms(), NuCrossSectionFitter::FillNDDataHistograms(), NuFluctuator::MakeCPTPDFs(), NuFluctuator::MakeShiftedCPTPDFs(), NuFluctuator::MakeShiftedTransitionPDFs(), and NuFluctuator::MakeTransitionPDFs().

00124 {
00125   if (!IAmReadable){
00126     MSG("NuTreeWrapper", Msg::kFatal)
00127       << "Trying to read from write-only NuTreeWrapper." << endl;
00128     return -1;
00129   }
00130   return fInputChain.GetEntries();
00131 }

const Int_t NuTreeWrapper::GetEntriesFast  )  const [virtual]
 

Definition at line 134 of file NuTreeWrapper.cxx.

References fInputChain, and MSG.

Referenced by Detector().

00135 {
00136   if (!IAmReadable){
00137     MSG("NuTreeWrapper", Msg::kFatal)
00138       << "Trying to read from write-only NuTreeWrapper." << endl;
00139     return -1;
00140   }
00141   return fInputChain.GetEntriesFast();
00142 }

const NuEvent NuTreeWrapper::GetInfoObject const Int_t  event  )  const [virtual]
 

Definition at line 145 of file NuTreeWrapper.cxx.

References LoadEvent(), and MSG.

Referenced by NuXFitAnalysis::CacheFDMCEvents(), NuCrossSectionFitter::CacheNDMCEvents(), Detector(), NuXFitAnalysis::FillFDDataHistograms(), NuCrossSectionFitter::FillNDDataHistograms(), NuFluctuator::MakeCPTPDFs(), NuFluctuator::MakeShiftedCPTPDFs(), NuFluctuator::MakeShiftedTransitionPDFs(), and NuFluctuator::MakeTransitionPDFs().

00146 {
00147   if (!IAmReadable){
00148     MSG("NuTreeWrapper", Msg::kFatal)
00149       << "Trying to read from write-only NuTreeWrapper." << endl;
00150     NuEvent dummy;
00151     return dummy;
00152   }
00153   this->LoadEvent(event);
00154   return *fInputInfo;
00155 }

NuEvent & NuTreeWrapper::GetObjectToFill  )  [virtual]
 

Definition at line 158 of file NuTreeWrapper.cxx.

References fNuEvent, and NuEvent::Reset().

00159 {
00160   fNuEvent->Reset();
00161   return *fNuEvent;
00162 }

virtual const Double_t NuTreeWrapper::GetPoT  )  const [inline, virtual]
 

Definition at line 25 of file NuTreeWrapper.h.

Referenced by NuXFitAnalysis::FDData(), NuXFitAnalysis::FDMC(), NuFluctuator::MonteCarlo(), NuCrossSectionFitter::NDData(), and NuCrossSectionFitter::NDMC().

00025 {return fTotPoT;}

void NuTreeWrapper::LoadEvent const Int_t  event  )  const [private, virtual]
 

Definition at line 165 of file NuTreeWrapper.cxx.

References fcurrEntry, and fInputChain.

Referenced by GetInfoObject().

00166 {
00167   if (event == fcurrEntry){return;}
00168   else{
00169     fInputChain.GetEvent(event);
00170     fcurrEntry = event;
00171   }
00172 }

void NuTreeWrapper::Write const std::string  filename  )  [virtual]
 

Definition at line 175 of file NuTreeWrapper.cxx.

References fNuTreeWrapper.

Referenced by NuXFitAnalysis::CPTAnalysis(), NuXFitAnalysis::FillFDDataHistograms(), and NuXFitAnalysis::TransitionAnalysis().

00176 {
00177   TFile f(filename.c_str(),"RECREATE");
00178   fNuTreeWrapper->Write();
00179   f.Close();
00180 }


Member Data Documentation

Int_t NuTreeWrapper::fcurrEntry [mutable, private]
 

Definition at line 34 of file NuTreeWrapper.h.

Referenced by LoadEvent().

TFile* NuTreeWrapper::fDummyFile [private]
 

Definition at line 36 of file NuTreeWrapper.h.

TChain NuTreeWrapper::fInputChain [mutable, private]
 

Definition at line 38 of file NuTreeWrapper.h.

Referenced by CalculatePoTs(), GetEntries(), GetEntriesFast(), LoadEvent(), and NuTreeWrapper().

NuEvent* NuTreeWrapper::fInputInfo [private]
 

Definition at line 40 of file NuTreeWrapper.h.

Referenced by NuTreeWrapper().

NuEvent* NuTreeWrapper::fNuEvent [private]
 

Definition at line 39 of file NuTreeWrapper.h.

Referenced by GetObjectToFill().

TTree* NuTreeWrapper::fNuTreeWrapper [private]
 

Definition at line 37 of file NuTreeWrapper.h.

Referenced by FillTree(), and Write().

Double_t NuTreeWrapper::fTotPoT [private]
 

Definition at line 35 of file NuTreeWrapper.h.

Referenced by CalculatePoTs(), and NuTreeWrapper().

Bool_t NuTreeWrapper::IAmReadable [private]
 

Definition at line 33 of file NuTreeWrapper.h.


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:09:58 2010 for loon by  doxygen 1.3.9.1