HighLAND
Public Member Functions | Protected Attributes | List of all members
InputConverter Class Referenceabstract

#include <InputConverter.hxx>

Inheritance diagram for InputConverter:
MiniTreeConverter oaAnalysisTreeConverter RedoTreeConverter HighlandMiniTreeConverter FlatTreeConverter

Public Member Functions

 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 bool Initialize ()=0
 
virtual Int_t GetSpill (Long64_t &entry, AnaSpillC *&spill)=0
 
virtual Int_t GetEvent (Long64_t &entry, AnaEventC *&event)=0
 
virtual void IncrementPOTBySpill ()=0
 
virtual bool AddFileToTChain (const std::string &inputString)=0
 Add the file specified to fChain, and any friend chains that were set up.
 
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 Int_t GetNEvents (Int_t entries=-1)
 Return the total number of events for a given number of entries in the tree.
 
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

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

This base class specifies the interface that all input converters should implement.

An input converter takes an input file and converts the information into the AnaSpillB format used in the framework. For example, the oaAnalysisTreeConverter class converts an oaAnalysis file to the AnaSpillB format.

The converters themselves are found in the highLevelAnalysisIO package.

Definition at line 24 of file InputConverter.hxx.

Member Function Documentation

§ AddChain()

void InputConverter::AddChain ( const std::string &  name,
const std::string &  name_path = "" 
)
inline

Add a chain with the given name to the map of chains the converter uses. When two names are given the first is the one we will use in the map, while the second is the actual path in the root file. If only one name is given, the path is used as name in the map

Definition at line 99 of file InputConverter.hxx.

99  {
100  if (!HasChain(name)) {
101  if (name_path=="")
102  _chain_map[name] = new TChain(name.c_str());
103  else
104  _chain_map[name] = new TChain(name_path.c_str());
105  } else {
106  std::cout << "TChain " << name << " already exists. Not added !!!" << std::endl;
107  }
108  }
bool HasChain(const std::string &name)
std::map< std::string, TChain * > _chain_map

§ GetChain()

TChain* InputConverter::GetChain ( const std::string &  name = "")
inline

Get the chain with the given name, if it has been added to the map of chains the converter uses. If no name is specified, the 'main' chain fChain is returned. If no chain with the given name is in the map of chains, then NULL is returned.

Definition at line 114 of file InputConverter.hxx.

114  {
115  if (name == "") {
116  return fChain;
117  } else if (HasChain(name)) {
118  return _chain_map[name];
119  } else {
120  return NULL;
121  }
122  }
bool HasChain(const std::string &name)
std::map< std::string, TChain * > _chain_map
TChain * fChain
The main TChain used to read events from the input file.

§ GetEvent()

virtual Int_t InputConverter::GetEvent ( Long64_t &  entry,
AnaEventC *&  event 
)
pure 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.

Implemented in oaAnalysisTreeConverter, RedoTreeConverter, and MiniTreeConverter.

§ GetSpill()

virtual Int_t InputConverter::GetSpill ( Long64_t &  entry,
AnaSpillC *&  spill 
)
pure 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.

Implemented in oaAnalysisTreeConverter, RedoTreeConverter, FlatTreeConverter, and MiniTreeConverter.

§ HasChain()

bool InputConverter::HasChain ( const std::string &  name)
inline

Whether the converter has added a chain with the given name to its map of chains.

Definition at line 91 of file InputConverter.hxx.

91  {
92  return (_chain_map.find(name) != _chain_map.end());
93  }
std::map< std::string, TChain * > _chain_map

§ IncrementPOTBySpill()

virtual void InputConverter::IncrementPOTBySpill ( )
pure virtual

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

Implemented in oaAnalysisTreeConverter, RedoTreeConverter, and MiniTreeConverter.

§ Initialize()

virtual bool InputConverter::Initialize ( )
pure virtual

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

Implemented in oaAnalysisTreeConverter, FlatTreeConverter, RedoTreeConverter, and MiniTreeConverter.

§ SetCosmicMode()

virtual void InputConverter::SetCosmicMode ( const bool  cosmic)
inlinevirtual

Specify whether we're running in "cosmic" mode or not. Some converters don't care about this, but others do and can override this function.

Reimplemented in oaAnalysisTreeConverter.

Definition at line 87 of file InputConverter.hxx.

87 {(void)cosmic;};

Member Data Documentation

§ _chain_map

std::map<std::string, TChain*> InputConverter::_chain_map
protected

Map of all the chains the converter uses. Access with AddChain(), HasChain() and GetChain() functions.

Definition at line 152 of file InputConverter.hxx.


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