Geant4  10.02
CexmcRunManager.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 /*
27  * =============================================================================
28  *
29  * Filename: CexmcRunManager.hh
30  *
31  * Description: run manager
32  *
33  * Version: 1.0
34  * Created: 03.11.2009 20:17:20
35  * Revision: none
36  * Compiler: gcc
37  *
38  * Author: Alexey Radkov (),
39  * Company: PNPI
40  *
41  * =============================================================================
42  */
43 
44 #ifndef CEXMC_RUN_MANAGER_HH
45 #define CEXMC_RUN_MANAGER_HH
46 
47 #include <set>
48 #include <limits>
49 #ifdef CEXMC_USE_PERSISTENCY
50 #include <boost/archive/binary_oarchive.hpp>
51 #endif
52 #include <G4RunManager.hh>
53 #include "CexmcRunSObject.hh"
54 #include "CexmcException.hh"
55 #include "CexmcCommon.hh"
56 
59 class CexmcEventFastSObject;
60 #ifdef CEXMC_USE_CUSTOM_FILTER
61 class CexmcCustomFilterEval;
62 #endif
63 
64 
65 typedef std::set< CexmcOutputDataType > CexmcOutputDataTypeSet;
66 
67 
69 {
70  public:
71  explicit CexmcRunManager( const G4String & projectId = "",
72  const G4String & rProject = "",
73  G4bool overrideExistingProject = false );
74 
75  virtual ~CexmcRunManager();
76 
77  public:
78  void SetPhysicsManager( CexmcPhysicsManager * physicsManager_ );
79 
81  CexmcProductionModelType productionModelType_ );
82 
83  void SetGdmlFileName( const G4String & gdmlFileName_ );
84 
85  void SetGdmlFileValidation( G4bool on = true );
86 
87  void SetGuiMacroName( const G4String & guiMacroName_ );
88 
90 
92 
93  void RegisterScenePrimitives( void );
94 
95 #ifdef CEXMC_USE_PERSISTENCY
96  void ReadProject( void );
97 
98  void SaveProject( void );
99 
100  void PrintReadRunData( void ) const;
101 
102  void ReadAndPrintEventsData( void ) const;
103 
104  void PrintReadData( const CexmcOutputDataTypeSet & outputData ) const;
105 
106  void ReplayEvents( G4int nEvents = 0 );
107 
108  void SeekTo( G4int eventNmb = 1 );
109 
110  void SkipInteractionsWithoutEDTonWrite( G4bool on = true );
111 
112 #ifdef CEXMC_USE_CUSTOM_FILTER
113  void SetCustomFilter( const G4String & cfFileName_ );
114 #endif
115 #endif
116 
117  void BeamParticleChangeHook( void );
118 
119  void SetupConstructionHook( void );
120 
121  public:
123 
125 
126  G4String GetGdmlFileName( void ) const;
127 
128  G4bool ShouldGdmlFileBeValidated( void ) const;
129 
130  G4String GetGuiMacroName( void ) const;
131 
132  G4bool ProjectIsSaved( void ) const;
133 
134  G4bool ProjectIsRead( void ) const;
135 
136  G4String GetProjectsDir( void ) const;
137 
138  G4String GetProjectId( void ) const;
139 
140 #ifdef CEXMC_USE_PERSISTENCY
141  boost::archive::binary_oarchive * GetEventsArchive( void ) const;
142 
143  boost::archive::binary_oarchive * GetFastEventsArchive( void ) const;
144 #endif
145 
147 
148  protected:
149  void DoEventLoop( G4int nEvent, const char * macroFile,
150  G4int nSelect );
151 
152  private:
153  void DoCommonEventLoop( G4int nEvent, const G4String & cmd,
154  G4int nSelect );
155 
156 #ifdef CEXMC_USE_PERSISTENCY
157  void DoReadEventLoop( G4int nEvent );
158 
159  void SaveCurrentTPTEvent( const CexmcEventFastSObject & evFastSObject,
160  const CexmcAngularRangeList & angularRanges,
161  G4bool writeToDatabase );
162 #endif
163 
164  private:
165  void ReadPreinitProjectData( void );
166 
167  private:
169 
171 
173 
175 
177 
179 
181 
183 
185 
187 
189 
191 
193 
195 
196  private:
198 
200 
202 
203 #ifdef CEXMC_USE_PERSISTENCY
204  private:
205  boost::archive::binary_oarchive * eventsArchive;
206 
207  boost::archive::binary_oarchive * fastEventsArchive;
208 
209  CexmcRunSObject sObject;
210 
211 #ifdef CEXMC_USE_CUSTOM_FILTER
212  CexmcCustomFilterEval * customFilter;
213 #endif
214 #endif
215 
216  private:
218 
219  private:
221 };
222 
223 
225  CexmcPhysicsManager * physicsManager_ )
226 {
227  physicsManager = physicsManager_;
228 }
229 
230 
232  CexmcProductionModelType productionModelType_ )
233 {
234  if ( ProjectIsRead() )
236 
237  productionModelType = productionModelType_;
238 }
239 
240 
241 inline void CexmcRunManager::SetGdmlFileName( const G4String & gdmlFileName_ )
242 {
243  if ( ProjectIsRead() )
245 
246  gdmlFileName = gdmlFileName_;
247 }
248 
249 
251 {
253 }
254 
255 
256 inline void CexmcRunManager::SetGuiMacroName( const G4String & guiMacroName_ )
257 {
258  guiMacroName = guiMacroName_;
259 }
260 
261 
263  CexmcEventCountPolicy value )
264 {
265  if ( ProjectIsRead() )
267 
268  eventCountPolicy = value;
269 }
270 
271 
274 {
275  if ( ProjectIsRead() && value > rEvDataVerboseLevel )
277 
278  evDataVerboseLevel = value;
279 }
280 
281 
283 {
284  return physicsManager;
285 }
286 
287 
290 {
291  return productionModelType;
292 }
293 
294 
296 {
297  return gdmlFileName;
298 }
299 
300 
302 {
304 }
305 
306 
308 {
309  return guiMacroName;
310 }
311 
312 
314 {
315  return projectId != "";
316 }
317 
318 
320 {
321  return rProject != "";
322 }
323 
324 
326 {
327  return projectsDir;
328 }
329 
330 
332 {
333  return projectId;
334 }
335 
336 
337 #ifdef CEXMC_USE_PERSISTENCY
338 
339 inline boost::archive::binary_oarchive * CexmcRunManager::GetEventsArchive(
340  void ) const
341 {
342  return eventsArchive;
343 }
344 
345 
346 inline boost::archive::binary_oarchive * CexmcRunManager::GetFastEventsArchive(
347  void ) const
348 {
349  return fastEventsArchive;
350 }
351 
352 
353 inline void CexmcRunManager::ReplayEvents( G4int nEvents )
354 {
355  if ( ! ProjectIsRead() )
356  return;
357 
358  if ( nEvents == 0 )
360 
361  BeamOn( nEvents );
362 }
363 
364 
365 inline void CexmcRunManager::SeekTo( G4int eventNmb )
366 {
367  if ( ! ProjectIsRead() )
368  return;
369 
370  curEventRead = eventNmb;
371 }
372 
373 
374 inline void CexmcRunManager::SkipInteractionsWithoutEDTonWrite( G4bool on )
375 {
377 }
378 
379 #endif
380 
381 
383  void ) const
384 {
385  return evDataVerboseLevel;
386 }
387 
388 
389 #endif
390 
G4bool ShouldGdmlFileBeValidated(void) const
void SetPhysicsManager(CexmcPhysicsManager *physicsManager_)
G4String GetProjectsDir(void) const
G4bool shouldGdmlFileBeValidated
void SetupConstructionHook(void)
CexmcPhysicsManager * GetPhysicsManager(void)
void DoCommonEventLoop(G4int nEvent, const G4String &cmd, G4int nSelect)
virtual void BeamOn(G4int n_event, const char *macroFile=0, G4int n_select=-1)
void ReadPreinitProjectData(void)
int G4int
Definition: G4Types.hh:78
CexmcProductionModelType
Definition: CexmcCommon.hh:91
G4String GetGdmlFileName(void) const
CexmcBasePhysicsUsed
Definition: CexmcCommon.hh:82
void DoEventLoop(G4int nEvent, const char *macroFile, G4int nSelect)
virtual ~CexmcRunManager()
G4bool ProjectIsRead(void) const
CexmcProductionModelType productionModelType
CexmcEventDataVerboseLevel rEvDataVerboseLevel
CexmcEventDataVerboseLevel GetEventDataVerboseLevel(void) const
G4String GetGuiMacroName(void) const
CexmcEventCountPolicy eventCountPolicy
CexmcPhysicsManager * physicsManager
bool G4bool
Definition: G4Types.hh:79
void BeamParticleChangeHook(void)
void SetGdmlFileValidation(G4bool on=true)
void RegisterScenePrimitives(void)
CexmcEventCountPolicy
Definition: CexmcCommon.hh:107
G4String GetProjectId(void) const
void SetGdmlFileName(const G4String &gdmlFileName_)
void SetGuiMacroName(const G4String &guiMacroName_)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
CexmcEventDataVerboseLevel evDataVerboseLevel
CexmcProductionModelType GetProductionModelType(void) const
CexmcEventDataVerboseLevel
Definition: CexmcCommon.hh:184
std::vector< CexmcAngularRange > CexmcAngularRangeList
G4bool skipInteractionsWithoutEDTonWrite
G4int numberOfEventsProcessedEffective
CexmcBasePhysicsUsed basePhysicsUsed
CexmcRunManager(const G4String &projectId="", const G4String &rProject="", G4bool overrideExistingProject=false)
std::set< CexmcOutputDataType > CexmcOutputDataTypeSet
G4bool ProjectIsSaved(void) const
void SetProductionModelType(CexmcProductionModelType productionModelType_)
void SetEventCountPolicy(CexmcEventCountPolicy value)
void SetEventDataVerboseLevel(CexmcEventDataVerboseLevel value)
CexmcRunManagerMessenger * messenger