Geant4  10.00.p01
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 EnableLiveHistograms( G4bool on = true );
118 
119  void BeamParticleChangeHook( void );
120 
121  void SetupConstructionHook( void );
122 
123  public:
125 
127 
128  G4String GetGdmlFileName( void ) const;
129 
130  G4bool ShouldGdmlFileBeValidated( void ) const;
131 
132  G4String GetGuiMacroName( void ) const;
133 
134  G4bool ProjectIsSaved( void ) const;
135 
136  G4bool ProjectIsRead( void ) const;
137 
138  G4String GetProjectsDir( void ) const;
139 
140  G4String GetProjectId( void ) const;
141 
142 #ifdef CEXMC_USE_PERSISTENCY
143  boost::archive::binary_oarchive * GetEventsArchive( void ) const;
144 
145  boost::archive::binary_oarchive * GetFastEventsArchive( void ) const;
146 #endif
147 
148  G4bool AreLiveHistogramsEnabled( void ) const;
149 
151 
152  protected:
153  void DoEventLoop( G4int nEvent, const char * macroFile,
154  G4int nSelect );
155 
156  private:
157  void DoCommonEventLoop( G4int nEvent, const G4String & cmd,
158  G4int nSelect );
159 
160 #ifdef CEXMC_USE_PERSISTENCY
161  void DoReadEventLoop( G4int nEvent );
162 
163  void SaveCurrentTPTEvent( const CexmcEventFastSObject & evFastSObject,
164  const CexmcAngularRangeList & angularRanges,
165  G4bool writeToDatabase );
166 #endif
167 
168  private:
169  void ReadPreinitProjectData( void );
170 
171  private:
173 
175 
177 
179 
181 
183 
185 
187 
189 
191 
193 
195 
197 
199 
201 
202  private:
204 
206 
208 
209 #ifdef CEXMC_USE_PERSISTENCY
210  private:
211  boost::archive::binary_oarchive * eventsArchive;
212 
213  boost::archive::binary_oarchive * fastEventsArchive;
214 
215  CexmcRunSObject sObject;
216 
217 #ifdef CEXMC_USE_CUSTOM_FILTER
218  CexmcCustomFilterEval * customFilter;
219 #endif
220 #endif
221 
222  private:
224 
225  private:
227 };
228 
229 
231  CexmcPhysicsManager * physicsManager_ )
232 {
233  physicsManager = physicsManager_;
234 }
235 
236 
238  CexmcProductionModelType productionModelType_ )
239 {
240  if ( ProjectIsRead() )
242 
243  productionModelType = productionModelType_;
244 }
245 
246 
247 inline void CexmcRunManager::SetGdmlFileName( const G4String & gdmlFileName_ )
248 {
249  if ( ProjectIsRead() )
251 
252  gdmlFileName = gdmlFileName_;
253 }
254 
255 
257 {
259 }
260 
261 
262 inline void CexmcRunManager::SetGuiMacroName( const G4String & guiMacroName_ )
263 {
264  guiMacroName = guiMacroName_;
265 }
266 
267 
269  CexmcEventCountPolicy value )
270 {
271  if ( ProjectIsRead() )
273 
274  eventCountPolicy = value;
275 }
276 
277 
280 {
281  if ( ProjectIsRead() && value > rEvDataVerboseLevel )
283 
284  evDataVerboseLevel = value;
285 }
286 
287 
289 {
290  return physicsManager;
291 }
292 
293 
296 {
297  return productionModelType;
298 }
299 
300 
302 {
303  return gdmlFileName;
304 }
305 
306 
308 {
310 }
311 
312 
314 {
315  return guiMacroName;
316 }
317 
318 
320 {
321  return projectId != "";
322 }
323 
324 
326 {
327  return rProject != "";
328 }
329 
330 
332 {
333  return projectsDir;
334 }
335 
336 
338 {
339  return projectId;
340 }
341 
342 
343 #ifdef CEXMC_USE_PERSISTENCY
344 
345 inline boost::archive::binary_oarchive * CexmcRunManager::GetEventsArchive(
346  void ) const
347 {
348  return eventsArchive;
349 }
350 
351 
352 inline boost::archive::binary_oarchive * CexmcRunManager::GetFastEventsArchive(
353  void ) const
354 {
355  return fastEventsArchive;
356 }
357 
358 
359 inline void CexmcRunManager::ReplayEvents( G4int nEvents )
360 {
361  if ( ! ProjectIsRead() )
362  return;
363 
364  if ( nEvents == 0 )
366 
367  BeamOn( nEvents );
368 }
369 
370 
371 inline void CexmcRunManager::SeekTo( G4int eventNmb )
372 {
373  if ( ! ProjectIsRead() )
374  return;
375 
376  curEventRead = eventNmb;
377 }
378 
379 
380 inline void CexmcRunManager::SkipInteractionsWithoutEDTonWrite( G4bool on )
381 {
383 }
384 
385 #endif
386 
387 
389 {
391 }
392 
393 
395 {
397 }
398 
399 
401  void ) const
402 {
403  return evDataVerboseLevel;
404 }
405 
406 
407 #endif
408 
void EnableLiveHistograms(G4bool on=true)
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)
G4bool areLiveHistogramsEnabled
void SetGdmlFileValidation(G4bool on=true)
void RegisterScenePrimitives(void)
CexmcEventCountPolicy
Definition: CexmcCommon.hh:107
G4String GetProjectId(void) const
G4bool AreLiveHistogramsEnabled(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