HighLAND
Public Member Functions | Protected Attributes | List of all members
MiniTreeConverter Class Reference
Inheritance diagram for MiniTreeConverter:
InputConverter HighlandMiniTreeConverter

Public Member Functions

 MiniTreeConverter (bool readRooTrackerVtx=false)
 
virtual bool Initialize ()
 
Int_t GetSpill (Long64_t &entry, AnaSpillC *&spill)
 
Int_t GetEvent (Long64_t &entry, AnaEventC *&event)
 
virtual AnaSpillBMakeSpill ()
 
AnaEventBMakeEvent (AnaSpillB &spill, AnaBunchB &bunch)
 
void IncrementPOTBySpill ()
 
bool AddFileToTChain (const std::string &inputString)
 Add the file specified to fChain, and any friend chains that were set up.
 
Int_t GetNEvents (Int_t entries=-1)
 Return the total number of events for a given number of entries in the tree.
 
- Public Member Functions inherited from InputConverter
 InputConverter (const std::string &name)
 Constrctor provided a name.
 
virtual ~InputConverter ()
 Everyone should have a destructor...
 
const std::string & GetTreeName ()
 returns the name of the tree to convert
 
const std::string & Name () const
 Return the name of this converter.
 
void SetName (const std::string &name)
 Set the name of this converter, which is used internally by the InputManager.
 
virtual void Reset ()
 Reset the trees in the TChain and the number of entries. Also the header (POT, etc)
 
virtual Long64_t LoadTree (Long64_t entry)
 Handle loading the correct entry from fChain.
 
virtual Long64_t GetEntries ()
 Return the total number of entries in the chain.
 
virtual bool IsCorrectType (const std::string &inputString)
 Whether the implementation can handle the specified file.
 
virtual void SetCosmicMode (const bool cosmic)
 
bool HasChain (const std::string &name)
 
void AddChain (const std::string &name, const std::string &name_path="")
 
TChain * GetChain (const std::string &name="")
 
Headerheader ()
 Returns the Header manager.
 

Protected Attributes

bool _useCorrectedValues
 
bool _readRooTrackerVtx
 
bool _firstFile
 
std::string _currentfilename
 
Int_t _currentBunch
 
AnaSpillB_spill
 
Double_t _POTSincePreviousSavedSpill
 The accumulated POT.
 
TChain * minitree
 
TChain * GRooTrackerVTX
 
TChain * NRooTrackerVTX
 
bool fGenie
 
bool fNeut
 
Long64_t _entry_roo
 
Int_t RunID
 
Int_t SubrunID
 
Int_t EventID
 
Int_t NNVtx
 
TClonesArray * NVtx
 
Int_t NGVtx
 
TClonesArray * GVtx
 
- Protected Attributes inherited from InputConverter
std::string _name
 The name of the converter.
 
std::string _treeName
 The name of the tree to convert.
 
int _nentries
 The number of entries in the chain. To be set by the implementation.
 
TChain * fChain
 The main TChain used to read events from the input file.
 
Int_t fCurrent
 current Tree number in a TChain
 
Int_t _currentFileIndex
 
std::string _currentFileName
 
std::map< std::string, TChain * > _chain_map
 
Header _header
 The header manager.
 

Detailed Description

Definition at line 15 of file MiniTreeConverter.hxx.

Member Function Documentation

§ GetEvent()

Int_t MiniTreeConverter::GetEvent ( Long64_t &  entry,
AnaEventC *&  event 
)
virtual

Read the specified entry from the file, and fill the event. The entry number must be incremented inside this function 0 should be returned on error.

Implements InputConverter.

Definition at line 153 of file MiniTreeConverter.cxx.

153  {
154 //*****************************************************************************
155 
156 // static AnaSpillB* RawSpill = 0;
157  Int_t entry_temp=1;
158 
159  AnaSpillB* RawSpill = static_cast<AnaSpillB*>(RawSpillC);
160 
161  if (RawSpill && _currentBunch < (Int_t)(RawSpill->Bunches.size()-1)){
162  _currentBunch++;
163  }
164  else{
165  if (RawSpill) delete RawSpill;
166  entry_temp = GetSpill(entry,RawSpillC);
167  if (entry_temp<=0 || !RawSpill || RawSpill->Bunches.size()==0) return 0;
168  _currentBunch=0;
169  }
170 
171  // Create a new event from the RawSpill and the current bunch
172  event = MakeEvent(*RawSpill,*static_cast<AnaBunchB*>((RawSpill->Bunches[_currentBunch])));
173 
174  return entry_temp;
175 }
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
Int_t GetSpill(Long64_t &entry, AnaSpillC *&spill)

§ GetSpill()

Int_t MiniTreeConverter::GetSpill ( Long64_t &  entry,
AnaSpillC *&  spill 
)
virtual

Read the specified entry from the file, and fill the spill. The entry number must be incremented as part of this function, and the new entry number returned. 0 should be returned on error.

Implements InputConverter.

Definition at line 178 of file MiniTreeConverter.cxx.

178  {
179 //*****************************************************************************
180 
181  // Read contents of entry.
182  if (!fChain) return 0;
183 
184  // Create the appropriate instance of Spill
185  spill = MakeSpill();
186 
187  // cast to AnaSpillB
188  _spill = static_cast<AnaSpillB*>(spill);
189 
190  // Set the branch address
191  fChain->SetBranchAddress("Spill", &spill);
192 
193  // Print the current file
194  std::string filename =minitree->GetFile()->GetName();
195  if( filename != _currentfilename ) {
196  std::cout << " Running on file: " << filename << std::endl;
197  _currentfilename = filename;
198  }
199 
200  // get a new entry from the flat tree. entry_temp >0 when succesfull
201  Int_t entry_temp = minitree->GetEntry(entry);
202 
203  // If this is not one of the events to skim just go to the next entry (and don't process that event --> return <=0)
204  if (!anaUtils::CheckSkimmedEvent(_spill->EventInfo->Run,_spill->EventInfo->SubRun,_spill->EventInfo->Event)){
205  entry++;
206  return 0;
207  }
208 
209  if (_spill->EventInfo){
210  if (_readRooTrackerVtx){
211  bool sIsMC = _spill->EventInfo->IsMC;
212  Int_t sEvt = _spill->EventInfo->Event;
213  Int_t sSubrun = _spill->EventInfo->SubRun;
214  Int_t sRun = _spill->EventInfo->Run;
215 
216  // sEvt should be positive since sEvt=-999 is used for the last flatree entry
217  if (entry_temp>0 && sIsMC && (fGenie || fNeut) && sEvt>=0) {
218  // Loop over RooTrackerVtx entries until we get the same run, subrun and event numbers
219  // In general we will get the right entry in the first iteration, but just in case
220  do{
221  if (NRooTrackerVTX) NRooTrackerVTX->GetEntry(_entry_roo);
222  else if (GRooTrackerVTX) GRooTrackerVTX->GetEntry(_entry_roo);
223  if ((RunID> sRun ) ||
224  (RunID==sRun && SubrunID> sSubrun ) ||
225  (RunID==sRun && SubrunID==sSubrun && EventID>sEvt ))
226  _entry_roo--;
227  else
228  _entry_roo++;
229  }while(EventID!=sEvt || RunID!=sRun || SubrunID!=sSubrun);
230  }
231  }
232 
233  // Copy vectors into arrays
234  _spill->CopyVectorsIntoArrays();
235  // Redo reco-reco and reco-truth links (many not pressent in MiniTree)
236  _spill->RedoLinks();
237  }
238  else
239  entry_temp=0;
240 
241 
242  // Increment entry number
243  entry++;
244 
245  // Load the geometry for this spill(999 is the default value in BaseDataClasses)
246  if (_spill->GeomID!=999)
247  ND::hgman().LoadGeometry(filename,(Int_t)_spill->GeomID,"geom");
248 
249  return entry_temp;
250 }
AnaEventInfoB * EventInfo
Run, sunrun, event, time stamp, etc.
virtual void CopyVectorsIntoArrays()
Copy the vectore into the arrays, needed after FlatTree reading.
Int_t SubRun
The subrun number.
UInt_t GeomID
Is this the original Spill or a clone.
Int_t Event
The ND280 event number.
virtual void RedoLinks()
Redo reco-reco and reco-truth after cloning or reading MiniTree.
TChain * fChain
The main TChain used to read events from the input file.
bool IsMC
Says if the event is MC or data.
bool LoadGeometry(const std::string &file="", Int_t geomID=-1, const std::string &geomDir="")
Load the TGeoManager from the input root file. Returns true when the new geometry was loaded...
Int_t Run
The ND280 run number.

§ IncrementPOTBySpill()

void MiniTreeConverter::IncrementPOTBySpill ( )
virtual

Record the POT for the current spill, based on information in the AnaBeam member of the current AnaSpill.

Implements InputConverter.

Definition at line 253 of file MiniTreeConverter.cxx.

253  {
254 //********************************************************************
255 
256  anaUtils::IncrementPOTBySpill(*_spill,header());
257  // header().IncrementPOTBySpill(*_spill);
258 }
Header & header()
Returns the Header manager.

§ Initialize()

bool MiniTreeConverter::Initialize ( )
virtual

Any initialization that must be done. Called before the input file is read.

Implements InputConverter.

Definition at line 37 of file MiniTreeConverter.cxx.

37  {
38 //********************************************************************
39 
40  // Set branch addresses and branch pointers
41  if (!fChain) return false;
42 
43  // Check the existence of the "minitree" tree
44  if (!gDirectory->FindObjectAny(_treeName.c_str())) return false;
45 
46  fCurrent = -1;
47  fChain->SetMakeClass(1);
48 
49  return true;
50 }
std::string _treeName
The name of the tree to convert.
Int_t fCurrent
current Tree number in a TChain
TChain * fChain
The main TChain used to read events from the input file.

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