SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
LcioManager Class Reference

Singleton manager class of LCIO configuration and output file operations. More...

#include <LcioManager.hh>

Inheritance diagram for LcioManager:
Module Singleton< LcioManager >

Public Types

enum  EFileExistsAction { eInvalid = -1 , eFail = 0 , eDelete = 1 , eAppend = 2 }
 
- Public Types inherited from Module
enum  ModuleStatus { eOkay = 0 , eNotInitialized = 1 , eBadState = 2 , eFatalError = 3 }
 

Public Member Functions

 LcioManager ()
 
virtual ~LcioManager ()
 
void addCollection (EVENT::LCCollection *collection, const std::string &name)
 
void addCollection (EVENT::LCEvent *lcevent, EVENT::LCCollection *collection, const std::string &name)
 
void beginRun (const G4Run *run)
 
IMPL::LCEventImpl * createLCEvent ()
 
IMPL::LCEventImpl * createLCEvent (const G4Event *anEvent)
 
void enableDumpEvent (bool p=true)
 
void endEvent (const G4Event *anEvent)
 
void endRun (const G4Run *run)
 
IMPL::LCEventImpl * getCurrentLCEvent ()
 
EFileExistsAction getFileExistsAction ()
 
LcioFileNamer * getFileNamer ()
 
std::string getFullOutputPath (bool withExtension=false)
 
LcioHitsCollectionBuilder * getHitsCollectionBuilder ()
 
G4bool getWriteCompleteEvent ()
 
void openLcioFile ()
 
void setAutonameFields (const std::vector< std::string > &fields)
 
void setCurrentLCEvent (IMPL::LCEventImpl *anLCEvent)
 
void setFileExistsAction (EFileExistsAction fea)
 
void setFilename (const std::string &filename)
 
void setPath (const std::string &path)
 
void setRunNumber (int runNumber)
 
void setStoreMomentum (bool s=true)
 
void setWriteCompleteEvent (G4bool writeCompleteEvent)
 
- Public Member Functions inherited from Module
virtual ~Module ()
 
virtual void beginEvent (const G4Event *)
 
virtual void cleanup ()
 
bool deleteOnExit ()
 
const std::string & getName () const
 
ModuleStatus getStatus () const
 
virtual void initialize ()
 
LogStream & log ()
 
virtual void postTracking (const G4Track *)
 
virtual void preTracking (const G4Track *)
 
virtual void reset ()
 
virtual void stepping (const G4Step *)
 
- Public Member Functions inherited from Singleton< LcioManager >
 Singleton ()
 
 ~Singleton ()
 
void release ()
 

Static Public Member Functions

static EFileExistsAction getFileExistsActionFromString (const std::string &fileExists)
 
- Static Public Member Functions inherited from Singleton< LcioManager >
static LcioManager * instance ()
 

Private Member Functions

void addActiveSubdetectors ()
 
void createHitsCollections ()
 
void createRunHeader (const G4Run *run)
 
void createWriter ()
 
void deleteRunHeader ()
 
void deleteWriter ()
 
void makeAutoname ()
 
void setDetectorName ()
 
void setEventTimeStamp ()
 

Private Attributes

bool _writeCompleteEvent
 
std::vector< std::string > m_currentAutonameFields
 
IMPL::LCEventImpl * m_currentLCEvent
 
bool m_enableDumpEvent
 
EFileExistsAction m_fileExistsAction
 
std::string m_filename
 
LcioHitsCollectionBuilder * m_HCBuilder
 
LcioMessenger * m_messenger
 
LcioFileNamer * m_namer
 
std::string m_path
 
IMPL::LCRunHeaderImpl * m_runHdr
 
int m_runNumber
 
bool m_usingAutoname
 
IO::LCWriter * m_writer
 
bool m_writerIsOpen
 

Static Private Attributes

static std::string m_defaultFileName = "slicEvents"
 

Additional Inherited Members

- Public Attributes inherited from Module
bool m_deleteOnExit
 
LogStream * m_log
 
std::string m_name
 
ModuleStatus m_status
 
- Protected Member Functions inherited from Module
 Module (const std::string &name, bool deleteOnExit=true, bool autoRegister=true)
 

Detailed Description

Singleton manager class of LCIO configuration and output file operations.

Note
This class is the top-level instantiator of most other LCIO-related managers and helper classes.

Definition at line 45 of file LcioManager.hh.

Member Enumeration Documentation

◆ EFileExistsAction

Enum for setting what action to take when an output LCIO file already exists.

Enumerator
eInvalid 
eFail 
eDelete 
eAppend 

Definition at line 52 of file LcioManager.hh.

Constructor & Destructor Documentation

◆ LcioManager()

◆ ~LcioManager()

~LcioManager ( )
virtual

Class destructor.

Definition at line 72 of file LcioManager.cc.

References LcioManager::deleteWriter(), and LcioManager::m_messenger.

Member Function Documentation

◆ addActiveSubdetectors()

void addActiveSubdetectors ( )
private

Add the list of active subdetectors into the event header.

Definition at line 270 of file LcioManager.cc.

References LcioManager::m_runHdr.

Referenced by LcioManager::createRunHeader().

◆ addCollection() [1/2]

void addCollection ( EVENT::LCCollection *  collection,
const std::string &  name 
)

Add a collection the current LCEvent.

Parameters
[in]Thecollection.

Definition at line 393 of file LcioManager.cc.

References LcioManager::getCurrentLCEvent().

◆ addCollection() [2/2]

void addCollection ( EVENT::LCEvent *  lcevent,
EVENT::LCCollection *  collection,
const std::string &  name 
)

Add a collection to the LCEvent.

Parameters
[in]lcseventThe LCEvent.
[in]collectionThe collection.
[in]nameThe name of the collection.

Definition at line 389 of file LcioManager.cc.

◆ beginRun()

void beginRun ( const G4Run *  run)
virtual

◆ createHitsCollections()

void createHitsCollections ( )
private

Create the hits collections using the current set of objects.

Definition at line 385 of file LcioManager.cc.

References LcioHitsCollectionBuilder::createHitCollectionsFromEvent(), LcioManager::m_currentLCEvent, and LcioManager::m_HCBuilder.

Referenced by LcioManager::endEvent().

◆ createLCEvent() [1/2]

LCEventImpl * createLCEvent ( )

Create the LCEvent from the current G4Event.

Returns
The LCEvent.

Definition at line 353 of file LcioManager.cc.

◆ createLCEvent() [2/2]

LCEventImpl * createLCEvent ( const G4Event *  anEvent)

Create the LCEvent from the G4Event.

Parameters
[in]anEventThe input G4Event.
Returns
The output LCEvent.

Definition at line 317 of file LcioManager.cc.

References Singleton< MCParticleManager >::instance(), LcioManager::m_runHdr, and LcioManager::setCurrentLCEvent().

◆ createRunHeader()

void createRunHeader ( const G4Run *  run)
private

Create the run header from the Geant4 run.

Parameters
[in]runThe Geant4 run.

Definition at line 240 of file LcioManager.cc.

References LcioManager::addActiveSubdetectors(), LcioManager::m_runHdr, LcioManager::m_runNumber, and LcioManager::setDetectorName().

Referenced by LcioManager::beginRun().

◆ createWriter()

void createWriter ( )
private

Create the output LCWriter.

Definition at line 149 of file LcioManager.cc.

References LcioManager::m_writer.

Referenced by LcioManager::LcioManager().

◆ deleteRunHeader()

void deleteRunHeader ( )
private

Delete the current run header.

Definition at line 263 of file LcioManager.cc.

References LcioManager::m_runHdr.

Referenced by LcioManager::endRun().

◆ deleteWriter()

void deleteWriter ( )
private

Delete the current LCWriter.

Definition at line 153 of file LcioManager.cc.

References LcioManager::m_writer, and LcioManager::m_writerIsOpen.

Referenced by LcioManager::~LcioManager().

◆ enableDumpEvent()

void enableDumpEvent ( bool  p = true)
inline

Enable dump event output for debugging.

Parameters
[in]Thedump event setting.

Definition at line 222 of file LcioManager.hh.

References LcioManager::m_enableDumpEvent.

Referenced by LcioMessenger::SetNewValue().

◆ endEvent()

void endEvent ( const G4Event *  anEvent)
virtual

End of event hook to write out an LCIO file.

Parameters
[in]Thephysics event.

Reimplemented from Module.

Definition at line 357 of file LcioManager.cc.

References LcioManager::createHitsCollections(), LcioManager::m_currentLCEvent, LcioManager::m_enableDumpEvent, LcioManager::m_writer, and LcioManager::setEventTimeStamp().

◆ endRun()

void endRun ( const G4Run *  run)
virtual

◆ getCurrentLCEvent()

IMPL::LCEventImpl* getCurrentLCEvent ( )
inline

Get the current LCEvent.

Returns
The current LCEvent.

Definition at line 167 of file LcioManager.hh.

References LcioManager::m_currentLCEvent.

Referenced by LcioManager::addCollection(), and LcioManager::setEventTimeStamp().

◆ getFileExistsAction()

EFileExistsAction getFileExistsAction ( )
inline

Get the file exists action.

Returns
The file exists action.

Definition at line 198 of file LcioManager.hh.

References LcioManager::m_fileExistsAction.

◆ getFileExistsActionFromString()

LcioManager::EFileExistsAction getFileExistsActionFromString ( const std::string &  fileExists)
static

Get the FileExists enum value from a string.

Parameters
[in]fileExistsThe file exists string.
Returns
The file exists action from the string.

Definition at line 130 of file LcioManager.cc.

References LcioManager::eAppend, LcioManager::eDelete, LcioManager::eFail, and LcioManager::eInvalid.

Referenced by LcioMessenger::SetNewValue().

◆ getFileNamer()

LcioFileNamer* getFileNamer ( )
inline

Get the LcioFileNamer for automatically naming output files.

Returns
The LcioFileNamer for naming output files.

Definition at line 214 of file LcioManager.hh.

References LcioManager::m_namer.

◆ getFullOutputPath()

string getFullOutputPath ( bool  withExtension = false)

Get the path plus the filename and optionally include the extension.

Parameters
[in]withExtensionWhether or not to include the file extension.
Returns
The full output file path.

Definition at line 167 of file LcioManager.cc.

References LcioManager::m_filename, and LcioManager::m_path.

Referenced by LcioManager::openLcioFile().

◆ getHitsCollectionBuilder()

LcioHitsCollectionBuilder* getHitsCollectionBuilder ( )
inline

Get the LcioHitsCollectionBuilder for creating output hit collections.

Returns
The LcioHitsCollectionBuilder.

Definition at line 206 of file LcioManager.hh.

References LcioManager::m_HCBuilder.

Referenced by LcioMessenger::SetNewValue().

◆ getWriteCompleteEvent()

G4bool getWriteCompleteEvent ( )
inline

Definition at line 234 of file LcioManager.hh.

References LcioManager::_writeCompleteEvent.

◆ makeAutoname()

void makeAutoname ( )
private

◆ openLcioFile()

void openLcioFile ( )

◆ setAutonameFields()

void setAutonameFields ( const std::vector< std::string > &  fields)

Set the list of fields to use for output file autonaming.

Definition at line 298 of file LcioManager.cc.

References LcioManager::m_currentAutonameFields, and LcioManager::m_usingAutoname.

Referenced by LcioMessenger::SetNewValue().

◆ setCurrentLCEvent()

void setCurrentLCEvent ( IMPL::LCEventImpl *  anLCEvent)
inline

Set the current output LCIO event.

Parameters
[in]anLCEventThe LCIO event.

Definition at line 159 of file LcioManager.hh.

References LcioManager::m_currentLCEvent.

Referenced by LcioManager::createLCEvent().

◆ setDetectorName()

void setDetectorName ( )
private

Set the detector name in the current run header.

Definition at line 257 of file LcioManager.cc.

References Module::log(), LcioManager::m_runHdr, and LogStream::okay().

Referenced by LcioManager::createRunHeader().

◆ setEventTimeStamp()

void setEventTimeStamp ( )
private

Set the time stamp in the current event header.

Definition at line 381 of file LcioManager.cc.

References LcioManager::getCurrentLCEvent(), and TimeUtil::getTimeNS().

Referenced by LcioManager::endEvent().

◆ setFileExistsAction()

void setFileExistsAction ( EFileExistsAction  fea)
inline

Set the file exists action.

Parameters
[in]feaThe file exists action.

Definition at line 183 of file LcioManager.hh.

References LOG::done, LcioManager::eInvalid, LOG::error, Module::log(), and LcioManager::m_fileExistsAction.

Referenced by LcioMessenger::SetNewValue().

◆ setFilename()

void setFilename ( const std::string &  filename)

Set the output file name, which will be appended to the path.

Definition at line 285 of file LcioManager.cc.

References Module::log(), LcioManager::m_filename, and LogStream::okay().

Referenced by LcioManager::makeAutoname(), and LcioMessenger::SetNewValue().

◆ setPath()

void setPath ( const std::string &  path)

Set the output path.

Definition at line 279 of file LcioManager.cc.

References Module::log(), LcioManager::m_path, and LogStream::okay().

Referenced by LcioMessenger::SetNewValue().

◆ setRunNumber()

void setRunNumber ( int  runNumber)

Set the current run number.

Parameters
[in]runNumberThe run number.

Definition at line 144 of file LcioManager.cc.

References Module::log(), LcioManager::m_runNumber, and LogStream::verbose().

Referenced by LcioMessenger::SetNewValue().

◆ setStoreMomentum()

void setStoreMomentum ( bool  s = true)
inline

Set whether to store momentum in output hits.

Parameters
[in]sSetting for storing momentum in output hits.

Definition at line 175 of file LcioManager.hh.

References LcioManager::m_HCBuilder, and LcioHitsCollectionBuilder::setStoreMomentum().

◆ setWriteCompleteEvent()

void setWriteCompleteEvent ( G4bool  writeCompleteEvent)
inline

Enable writing complete event to MCParticle collection.

Parameters
[in]writeCompleteEventSet to true to write complete event.

Definition at line 230 of file LcioManager.hh.

References LcioManager::_writeCompleteEvent.

Member Data Documentation

◆ _writeCompleteEvent

bool _writeCompleteEvent
private

◆ m_currentAutonameFields

std::vector<std::string> m_currentAutonameFields
private

Definition at line 320 of file LcioManager.hh.

Referenced by LcioManager::makeAutoname(), and LcioManager::setAutonameFields().

◆ m_currentLCEvent

IMPL::LCEventImpl* m_currentLCEvent
private

◆ m_defaultFileName

string m_defaultFileName = "slicEvents"
staticprivate

Definition at line 319 of file LcioManager.hh.

Referenced by LcioManager::LcioManager(), and LcioManager::makeAutoname().

◆ m_enableDumpEvent

bool m_enableDumpEvent
private

Definition at line 322 of file LcioManager.hh.

Referenced by LcioManager::enableDumpEvent(), and LcioManager::endEvent().

◆ m_fileExistsAction

EFileExistsAction m_fileExistsAction
private

◆ m_filename

std::string m_filename
private

file info – filename

Definition at line 295 of file LcioManager.hh.

Referenced by LcioManager::LcioManager(), LcioManager::getFullOutputPath(), and LcioManager::setFilename().

◆ m_HCBuilder

LcioHitsCollectionBuilder* m_HCBuilder
private

◆ m_messenger

LcioMessenger* m_messenger
private

Definition at line 309 of file LcioManager.hh.

Referenced by LcioManager::LcioManager(), and LcioManager::~LcioManager().

◆ m_namer

LcioFileNamer* m_namer
private

◆ m_path

std::string m_path
private

file info – path

Definition at line 297 of file LcioManager.hh.

Referenced by LcioManager::getFullOutputPath(), and LcioManager::setPath().

◆ m_runHdr

IMPL::LCRunHeaderImpl* m_runHdr
private

◆ m_runNumber

int m_runNumber
private

starting run number

Definition at line 315 of file LcioManager.hh.

Referenced by LcioManager::beginRun(), LcioManager::createRunHeader(), and LcioManager::setRunNumber().

◆ m_usingAutoname

bool m_usingAutoname
private

Definition at line 324 of file LcioManager.hh.

Referenced by LcioManager::beginRun(), and LcioManager::setAutonameFields().

◆ m_writer

IO::LCWriter* m_writer
private

◆ m_writerIsOpen

bool m_writerIsOpen
private

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