eic-smear  1.0.3
A collection of ROOT classes for Monte Carlo events and a fast-smearing code simulating detector effects for the Electron-Ion Collider task force
erhic::Forester Class Reference

Manages the creation of trees from plain-text Monte Carlo files. More...

#include <Forester.h>

Inheritance diagram for erhic::Forester:

Classes

class  Status
 Stores summary information about the last call to Forester::Plant(). More...
 

Public Member Functions

 Forester ()
 Default constructor. More...
 
virtual ~Forester ()
 Destructor. More...
 
Long64_t Plant ()
 Processes a text file into a ROOT file. More...
 
void SetInputFileName (const std::string &)
 Sets the name of the input text file containing Monte Carlo data. More...
 
void SetOutputFileName (const std::string &)
 Sets the name of the ROOT tree file to create. More...
 
void SetTreeName (const std::string &="EICTree")
 Sets the name of the TTree to write to the file named by SetOutputFileName(). More...
 
void SetBranchName (const std::string &="event")
 Sets the name of the TBranch containing event objects. More...
 
std::string GetInputFileName () const
 Returns the name of the input text file containing Monte Carlo data. More...
 
std::string GetOutputFileName () const
 Returns the name of the ROOT tree file to create. More...
 
std::string GetTreeName () const
 Returns the name of the TTree to write to the file named by SetOutputFileName(). More...
 
std::string GetBranchName () const
 Returns the name of the TBranch containing event objects. More...
 
void SetMaxNEvents (Long64_t=0)
 Sets the maximum number of events to process. More...
 
Long64_t GetMaxNEvents () const
 Returns the maximum number of events to process. More...
 
void SetMessageInterval (Long64_t=10000)
 Sets the event count interval at which to print a status message. More...
 
void Print (std::ostream &stream) const
 Prints the current configuration to the requested output stream. More...
 
void Print (Option_t *="not used") const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.To avoid hiding TObject::Print() More...
 
void SetBeVerbose (bool=false)
 If set to true, prints messages during running. More...
 
bool BeVerbose () const
 Returns the verbosity i.e. More...
 
const erhic::FileTypeGetFileType () const
 Returns the file type information for the last processed file. More...
 

Protected Member Functions

const StatusGetGetStatus () const
 Prints a summary of the last call to Plant() to the requested output stream. More...
 
bool OpenInput ()
 Opens the input file and checks that it was produced by a supported Monte Carlo generator. More...
 
bool SetupOutput ()
 Opens the output ROOT file and creates the TTree ready for filling. More...
 
void Finish ()
 Writes output and takes end-of-file actions. More...
 
bool AllocateEvent ()
 Allocate an event buffer for the TTree based on the generator type. More...
 
bool FindFirstEvent ()
 Aligns the input text file on the first line of the first event. More...
 
void PrintStatus () const
 Prints the status of the current Plant() call to the standard output. More...
 
bool MustQuit () const
 Prints the quit flag status. More...
 
void SetMustQuit (bool quit)
 Set the quit flag. More...
 

Protected Attributes

Bool_t mQuit
 Quit status. Set to true once EoF or max events reached. More...
 
Bool_t mVerbose
 Verbosity flag. More...
 
TTree * mTree
 
VirtualEventmEvent
 < Output TTree, owned by mRootFile More...
 
const erhic::FileTypemFile
 < Stores event branch address More...
 
TFile * mRootFile
 < File type information More...
 
Long64_t mMaxNEvents
 < Pointer to output ROOT file More...
 
Long64_t mInterval
 Event interval between printing status messages. More...
 
std::ifstream * mTextFile
 
std::string mInputName
 < Input text file More...
 
std::string mOutputName
 Name of the output ROOT file. More...
 
std::string mTreeName
 Name of the output TTree. More...
 
std::string mBranchName
 Name of the event TBranch. More...
 
std::string mLine
 Stores the latest text line read from the input file. More...
 
Status mStatus
 Forester status information. More...
 
VirtualEventFactorymFactory
 

Detailed Description

Manages the creation of trees from plain-text Monte Carlo files.

Bad pun, I know, but the ROOT guys started it.

Definition at line 40 of file Forester.h.

Constructor & Destructor Documentation

◆ Forester()

erhic::Forester::Forester ( )

Default constructor.

Definition at line 25 of file Forester.cxx.

◆ ~Forester()

erhic::Forester::~Forester ( )
virtual

Destructor.

Definition at line 42 of file Forester.cxx.

Member Function Documentation

◆ AllocateEvent()

bool erhic::Forester::AllocateEvent ( )
protected

Allocate an event buffer for the TTree based on the generator type.

Returns false if the generator has not yet been successfully determined.

Definition at line 213 of file Forester.cxx.

◆ BeVerbose()

bool erhic::Forester::BeVerbose ( ) const
inline

Returns the verbosity i.e.

whether to print status messages.

Definition at line 317 of file Forester.h.

◆ FindFirstEvent()

bool erhic::Forester::FindFirstEvent ( )
protected

Aligns the input text file on the first line of the first event.

After a successful call, mLine stores the first line of the event and true is returned. If unsuccessful, mLine is blank and false is returned.

Definition at line 228 of file Forester.cxx.

◆ Finish()

void erhic::Forester::Finish ( )
protected

Writes output and takes end-of-file actions.

Definition at line 191 of file Forester.cxx.

◆ GetBranchName()

std::string erhic::Forester::GetBranchName ( ) const
inline

Returns the name of the TBranch containing event objects.

Definition at line 289 of file Forester.h.

◆ GetFileType()

const FileType * erhic::Forester::GetFileType ( ) const
inline

Returns the file type information for the last processed file.

Returns NULL if no input has been processed. Do not delete the returned object.

Definition at line 321 of file Forester.h.

◆ GetGetStatus()

const Status& erhic::Forester::GetGetStatus ( ) const
inlineprotected

Prints a summary of the last call to Plant() to the requested output stream.

Definition at line 184 of file Forester.h.

◆ GetInputFileName()

std::string erhic::Forester::GetInputFileName ( ) const
inline

Returns the name of the input text file containing Monte Carlo data.

Definition at line 277 of file Forester.h.

◆ GetMaxNEvents()

Long64_t erhic::Forester::GetMaxNEvents ( ) const
inline

Returns the maximum number of events to process.

Definition at line 297 of file Forester.h.

◆ GetOutputFileName()

std::string erhic::Forester::GetOutputFileName ( ) const
inline

Returns the name of the ROOT tree file to create.

Definition at line 281 of file Forester.h.

◆ GetTreeName()

std::string erhic::Forester::GetTreeName ( ) const
inline

Returns the name of the TTree to write to the file named by SetOutputFileName().

Definition at line 285 of file Forester.h.

◆ MustQuit()

bool erhic::Forester::MustQuit ( ) const
inlineprotected

Prints the quit flag status.

A return value of true indicates that the input file has ended or the mMaxNEvents has been reached. Processing the file will quit after the end of the next call to FinishEvent().

Definition at line 305 of file Forester.h.

◆ OpenInput()

bool erhic::Forester::OpenInput ( )
protected

Opens the input file and checks that it was produced by a supported Monte Carlo generator.

Returns true upon success or false upon and I/O error or if the Monte Carlo generator is unsupported or cannot be determined.

Definition at line 130 of file Forester.cxx.

◆ Plant()

Long64_t erhic::Forester::Plant ( )

Processes a text file into a ROOT file.

Returns the number of events processed.

Todo:
Get rid of the static counter. Replace with a member that is reset every time Plant() is called.

Definition at line 67 of file Forester.cxx.

◆ Print() [1/2]

void erhic::Forester::Print ( Option_t *  = "not used") const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.To avoid hiding TObject::Print()

Definition at line 252 of file Forester.cxx.

◆ Print() [2/2]

void erhic::Forester::Print ( std::ostream &  stream) const

Prints the current configuration to the requested output stream.

Definition at line 241 of file Forester.cxx.

◆ PrintStatus()

void erhic::Forester::PrintStatus ( ) const
protected

Prints the status of the current Plant() call to the standard output.

◆ SetBeVerbose()

void erhic::Forester::SetBeVerbose ( bool  flag = false)
inline

If set to true, prints messages during running.

If set to false, runs silently except in the case of critical errors.

Definition at line 313 of file Forester.h.

◆ SetBranchName()

void erhic::Forester::SetBranchName ( const std::string &  name = "event")
inline

Sets the name of the TBranch containing event objects.

This is the only branch written to the TTree named by SetTreeName().

Definition at line 273 of file Forester.h.

◆ SetInputFileName()

void erhic::Forester::SetInputFileName ( const std::string &  name)
inline

Sets the name of the input text file containing Monte Carlo data.

Definition at line 261 of file Forester.h.

◆ SetMaxNEvents()

void erhic::Forester::SetMaxNEvents ( Long64_t  number = 0)
inline

Sets the maximum number of events to process.

Processing will terminate when this number of events or the end of the input file is reached, whichever occurs first. A value <= 0 indicates to process all events in the input file (this is the default).

Definition at line 293 of file Forester.h.

◆ SetMessageInterval()

void erhic::Forester::SetMessageInterval ( Long64_t  number = 10000)
inline

Sets the event count interval at which to print a status message.

A value <= 0 suppresses messages.

Definition at line 301 of file Forester.h.

◆ SetMustQuit()

void erhic::Forester::SetMustQuit ( bool  quit)
inlineprotected

Set the quit flag.

Definition at line 309 of file Forester.h.

◆ SetOutputFileName()

void erhic::Forester::SetOutputFileName ( const std::string &  name)
inline

Sets the name of the ROOT tree file to create.

Definition at line 265 of file Forester.h.

◆ SetTreeName()

void erhic::Forester::SetTreeName ( const std::string &  name = "EICTree")
inline

Sets the name of the TTree to write to the file named by SetOutputFileName().

Definition at line 269 of file Forester.h.

◆ SetupOutput()

bool erhic::Forester::SetupOutput ( )
protected

Opens the output ROOT file and creates the TTree ready for filling.

Definition at line 158 of file Forester.cxx.

Member Data Documentation

◆ mBranchName

std::string erhic::Forester::mBranchName
protected

Name of the event TBranch.

Definition at line 253 of file Forester.h.

◆ mEvent

VirtualEvent* erhic::Forester::mEvent
protected

< Output TTree, owned by mRootFile

Definition at line 243 of file Forester.h.

◆ mFactory

VirtualEventFactory* erhic::Forester::mFactory
protected

Definition at line 256 of file Forester.h.

◆ mFile

const erhic::FileType* erhic::Forester::mFile
protected

< Stores event branch address

Definition at line 244 of file Forester.h.

◆ mInputName

std::string erhic::Forester::mInputName
protected

< Input text file

Name of the input text file

Definition at line 250 of file Forester.h.

◆ mInterval

Long64_t erhic::Forester::mInterval
protected

Event interval between printing status messages.

Definition at line 247 of file Forester.h.

◆ mLine

std::string erhic::Forester::mLine
protected

Stores the latest text line read from the input file.

Definition at line 254 of file Forester.h.

◆ mMaxNEvents

Long64_t erhic::Forester::mMaxNEvents
protected

< Pointer to output ROOT file

Maximum number of events to process

Definition at line 246 of file Forester.h.

◆ mOutputName

std::string erhic::Forester::mOutputName
protected

Name of the output ROOT file.

Definition at line 251 of file Forester.h.

◆ mQuit

Bool_t erhic::Forester::mQuit
protected

Quit status. Set to true once EoF or max events reached.

Definition at line 240 of file Forester.h.

◆ mRootFile

TFile* erhic::Forester::mRootFile
protected

< File type information

Definition at line 245 of file Forester.h.

◆ mStatus

Status erhic::Forester::mStatus
protected

Forester status information.

Definition at line 255 of file Forester.h.

◆ mTextFile

std::ifstream* erhic::Forester::mTextFile
protected

Definition at line 249 of file Forester.h.

◆ mTree

TTree* erhic::Forester::mTree
protected

Definition at line 242 of file Forester.h.

◆ mTreeName

std::string erhic::Forester::mTreeName
protected

Name of the output TTree.

Definition at line 252 of file Forester.h.

◆ mVerbose

Bool_t erhic::Forester::mVerbose
protected

Verbosity flag.

Definition at line 241 of file Forester.h.


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