SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
LcioManager.hh
Go to the documentation of this file.
1 #ifndef SLIC_LCIOMANAGER_HH_
2 #define SLIC_LCIOMANAGER_HH_ 1
3 
4 // lcdd
5 #include "lcdd/detectors/SensitiveDetector.hh"
6 #include "lcdd/hits/CalorimeterHit.hh"
7 #include "lcdd/hits/TrackerHit.hh"
8 
9 // slic
11 #include "LcioFileNamer.hh"
12 #include "Singleton.hh"
13 
14 // lcio
15 #include "IO/LCWriter.h"
16 #include "EVENT/MCParticle.h"
17 #include "IMPL/SimCalorimeterHitImpl.h"
18 #include "IMPL/SimTrackerHitImpl.h"
19 #include "IMPL/LCCollectionVec.h"
20 #include "IMPL/LCEventImpl.h"
21 #include "IMPL/LCRunHeaderImpl.h"
22 #include "IMPL/MCParticleImpl.h"
23 
24 // geant4
25 #include "G4Event.hh"
26 #include "G4PrimaryParticle.hh"
27 
28 // std
29 #include <string>
30 #include <map>
31 
32 class G4Run;
33 class G4VHitsCollection;
34 
35 namespace slic {
36 
37 class LcioMessenger;
38 
45 class LcioManager: public Module, public Singleton<LcioManager> {
46 
47  public:
48 
53  eInvalid = -1, eFail = 0, eDelete = 1, eAppend = 2
54  };
55 
56  public:
57 
61  LcioManager();
62 
66  virtual ~LcioManager();
67 
68  public:
69 
73  void openLcioFile();
74 
78  void setPath(const std::string& path);
79 
83  void setFilename(const std::string& filename);
84 
88  void setAutonameFields(const std::vector<std::string>& fields);
89 
95  std::string getFullOutputPath(bool withExtension = false);
96 
102  static EFileExistsAction getFileExistsActionFromString(const std::string& fileExists);
103 
108  void setRunNumber(int runNumber);
109 
114  void beginRun(const G4Run* run);
115 
120  void endRun(const G4Run* run);
121 
127  IMPL::LCEventImpl* createLCEvent(const G4Event* anEvent);
128 
133  IMPL::LCEventImpl* createLCEvent();
134 
141  void addCollection(EVENT::LCEvent* lcevent, EVENT::LCCollection* collection, const std::string& name);
142 
147  void addCollection(EVENT::LCCollection* collection, const std::string& name);
148 
153  void endEvent(const G4Event* anEvent);
154 
159  void setCurrentLCEvent(IMPL::LCEventImpl* anLCEvent) {
160  m_currentLCEvent = anLCEvent;
161  }
162 
167  IMPL::LCEventImpl* getCurrentLCEvent() {
168  return m_currentLCEvent;
169  }
170 
175  void setStoreMomentum(bool s = true) {
177  }
178 
184  if (fea == eInvalid) {
185 #ifdef SLIC_LOG
186  log() << LOG::error << "Invalid setting for FileExistsAction." << LOG::done;
187 #endif
188  return;
189  }
190 
191  m_fileExistsAction = fea;
192  }
193 
199  return m_fileExistsAction;
200  }
201 
207  return m_HCBuilder;
208  }
209 
215  return m_namer;
216  }
217 
222  void enableDumpEvent(bool p = true) {
223  m_enableDumpEvent = p;
224  }
225 
230  void setWriteCompleteEvent(G4bool writeCompleteEvent) {
231  _writeCompleteEvent = writeCompleteEvent;
232  }
233 
235  return _writeCompleteEvent;
236  }
237 
238  private:
239 
243  void makeAutoname();
244 
248  void createHitsCollections();
249 
253  void createWriter();
254 
258  void deleteWriter();
259 
264  void createRunHeader(const G4Run* run);
265 
269  void deleteRunHeader();
270 
274  void setDetectorName();
275 
279  void setEventTimeStamp();
280 
284  void addActiveSubdetectors();
285 
286  private:
287 
289  IO::LCWriter* m_writer;
290 
292  IMPL::LCRunHeaderImpl* m_runHdr;
293 
295  std::string m_filename;
297  std::string m_path;
298 
299  // event generator from MCP Coll
300  //LcioPrimaryGenerator* m_eventGenerator;
301 
304 
306  IMPL::LCEventImpl* m_currentLCEvent;
307 
308  // messenger
310 
313 
316 
318 
319  static std::string m_defaultFileName;
320  std::vector<std::string> m_currentAutonameFields;
321 
326 };
327 }
328 
329 #endif
Automatically name LCIO output files according to input settings.
Builds Lcio hits collections from G4/SLIC event data.
void setStoreMomentum(bool storeMomentum=true)
Singleton manager class of LCIO configuration and output file operations.
Definition: LcioManager.hh:45
std::vector< std::string > m_currentAutonameFields
Definition: LcioManager.hh:320
IO::LCWriter * m_writer
Definition: LcioManager.hh:289
LcioHitsCollectionBuilder * getHitsCollectionBuilder()
Definition: LcioManager.hh:206
void endRun(const G4Run *run)
Definition: LcioManager.cc:221
void setCurrentLCEvent(IMPL::LCEventImpl *anLCEvent)
Definition: LcioManager.hh:159
LcioFileNamer * m_namer
Definition: LcioManager.hh:317
void setFileExistsAction(EFileExistsAction fea)
Definition: LcioManager.hh:183
LcioFileNamer * getFileNamer()
Definition: LcioManager.hh:214
LcioHitsCollectionBuilder * m_HCBuilder
Definition: LcioManager.hh:303
std::string getFullOutputPath(bool withExtension=false)
Definition: LcioManager.cc:167
void enableDumpEvent(bool p=true)
Definition: LcioManager.hh:222
void setRunNumber(int runNumber)
Definition: LcioManager.cc:144
void createHitsCollections()
Definition: LcioManager.cc:385
static EFileExistsAction getFileExistsActionFromString(const std::string &fileExists)
Definition: LcioManager.cc:130
void setFilename(const std::string &filename)
Definition: LcioManager.cc:285
LcioMessenger * m_messenger
Definition: LcioManager.hh:309
void addActiveSubdetectors()
Definition: LcioManager.cc:270
std::string m_path
Definition: LcioManager.hh:297
void setEventTimeStamp()
Definition: LcioManager.cc:381
void setAutonameFields(const std::vector< std::string > &fields)
Definition: LcioManager.cc:298
IMPL::LCEventImpl * getCurrentLCEvent()
Definition: LcioManager.hh:167
void setPath(const std::string &path)
Definition: LcioManager.cc:279
EFileExistsAction getFileExistsAction()
Definition: LcioManager.hh:198
void setWriteCompleteEvent(G4bool writeCompleteEvent)
Definition: LcioManager.hh:230
void endEvent(const G4Event *anEvent)
Definition: LcioManager.cc:357
virtual ~LcioManager()
Definition: LcioManager.cc:72
void setStoreMomentum(bool s=true)
Definition: LcioManager.hh:175
void beginRun(const G4Run *run)
Definition: LcioManager.cc:189
static std::string m_defaultFileName
Definition: LcioManager.hh:319
G4bool getWriteCompleteEvent()
Definition: LcioManager.hh:234
std::string m_filename
Definition: LcioManager.hh:295
IMPL::LCEventImpl * m_currentLCEvent
Definition: LcioManager.hh:306
void addCollection(EVENT::LCEvent *lcevent, EVENT::LCCollection *collection, const std::string &name)
Definition: LcioManager.cc:389
EFileExistsAction m_fileExistsAction
Definition: LcioManager.hh:312
IMPL::LCEventImpl * createLCEvent()
Definition: LcioManager.cc:353
void createRunHeader(const G4Run *run)
Definition: LcioManager.cc:240
IMPL::LCRunHeaderImpl * m_runHdr
Definition: LcioManager.hh:292
G4UIcommand class for LCIO commands.
Base class for slic code modules that provides common functionality, such as logging to an output str...
Definition: Module.hh:25
LogStream & log()
Definition: Module.hh:99
@ error
Definition: LogStream.hh:33
@ name
Definition: LogStream.hh:26
@ done
Definition: LogStream.hh:26