NuTreeWrapper Class Reference

#include <NuTreeWrapper.h>

List of all members.

Public Member Functions

 NuTreeWrapper ()
 NuTreeWrapper (std::string filelist)
virtual ~NuTreeWrapper ()
virtual Int_t Detector () const
virtual void FillTree ()
virtual Int_t GetEntries () const
virtual Int_t GetEntriesFast () const
virtual const NuEvent GetInfoObject (const Int_t event) const
virtual NuEventGetObjectToFill ()
virtual 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

Detailed Description

Definition at line 13 of file NuTreeWrapper.h.


Constructor & Destructor Documentation

NuTreeWrapper::NuTreeWrapper (  ) 

Definition at line 43 of file NuTreeWrapper.cxx.

00044   : IAmReadable(false),
00045     fcurrEntry(-1)
00046 {
00047   //Constructor to create a writable tree
00048   fNuTreeWrapper = new TTree("s","s");
00049   cout<<"NuTreeWrapper::Creating new NuEvent for output to tree"<<endl;
00050   fNuEvent = new NuEvent();
00051   fNuTreeWrapper->Branch("s","NuEvent",&fNuEvent,32000,2);
00052   fInputInfo = 0;
00053 }

NuTreeWrapper::NuTreeWrapper ( std::string  filelist  ) 
NuTreeWrapper::~NuTreeWrapper (  )  [virtual]

Definition at line 74 of file NuTreeWrapper.cxx.

00075 {
00076 }


Member Function Documentation

void NuTreeWrapper::CalculatePoTs (  )  [private, virtual]

Definition at line 79 of file NuTreeWrapper.cxx.

References Detector(), fInputChain, fTotPoT, Msg::kInfo, and MSG.

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

Int_t NuTreeWrapper::Detector ( void   )  const [virtual]

Definition at line 104 of file NuTreeWrapper.cxx.

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

Referenced by CalculatePoTs().

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

void NuTreeWrapper::FillTree (  )  [virtual]

Definition at line 117 of file NuTreeWrapper.cxx.

References fNuTreeWrapper.

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

Int_t NuTreeWrapper::GetEntries (  )  const [virtual]

Definition at line 124 of file NuTreeWrapper.cxx.

References fInputChain, IAmReadable, Msg::kFatal, and MSG.

Referenced by NuFluctuator::MakeCPTPDFs(), NuFluctuator::MakeShiftedCPTPDFs(), NuFluctuator::MakeShiftedTransitionPDFs(), and NuFluctuator::MakeTransitionPDFs().

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

Int_t NuTreeWrapper::GetEntriesFast (  )  const [virtual]

Definition at line 135 of file NuTreeWrapper.cxx.

References fInputChain, IAmReadable, Msg::kFatal, and MSG.

Referenced by Detector().

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

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

Definition at line 146 of file NuTreeWrapper.cxx.

References fInputInfo, IAmReadable, Msg::kFatal, LoadEvent(), and MSG.

Referenced by Detector(), NuFluctuator::MakeCPTPDFs(), NuFluctuator::MakeShiftedCPTPDFs(), NuFluctuator::MakeShiftedTransitionPDFs(), and NuFluctuator::MakeTransitionPDFs().

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

NuEvent & NuTreeWrapper::GetObjectToFill (  )  [virtual]

Definition at line 159 of file NuTreeWrapper.cxx.

References fNuEvent, and NuEvent::Reset().

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

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

Definition at line 25 of file NuTreeWrapper.h.

References fTotPoT.

00025 {return fTotPoT;}

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

Definition at line 166 of file NuTreeWrapper.cxx.

References fcurrEntry, and fInputChain.

Referenced by GetInfoObject().

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

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

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(), and LoadEvent().

Definition at line 40 of file NuTreeWrapper.h.

Referenced by GetInfoObject().

Definition at line 39 of file NuTreeWrapper.h.

Referenced by GetObjectToFill().

Definition at line 37 of file NuTreeWrapper.h.

Referenced by FillTree().

Double_t NuTreeWrapper::fTotPoT [private]

Definition at line 35 of file NuTreeWrapper.h.

Referenced by CalculatePoTs(), and GetPoT().

Bool_t NuTreeWrapper::IAmReadable [private]

Definition at line 33 of file NuTreeWrapper.h.

Referenced by GetEntries(), GetEntriesFast(), and GetInfoObject().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1