Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:50

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /*
0027  * =============================================================================
0028  *
0029  *       Filename:  CexmcRunManager.hh
0030  *
0031  *    Description:  run manager
0032  *
0033  *        Version:  1.0
0034  *        Created:  03.11.2009 20:17:20
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * =============================================================================
0042  */
0043 
0044 #ifndef CEXMC_RUN_MANAGER_HH
0045 #define CEXMC_RUN_MANAGER_HH
0046 
0047 #include <set>
0048 #include <limits>
0049 #ifdef CEXMC_USE_PERSISTENCY
0050 #include <boost/archive/binary_oarchive.hpp>
0051 #endif
0052 #include <G4RunManager.hh>
0053 #include "CexmcRunSObject.hh"
0054 #include "CexmcException.hh"
0055 #include "CexmcCommon.hh"
0056 
0057 class  CexmcRunManagerMessenger;
0058 class  CexmcPhysicsManager;
0059 class  CexmcEventFastSObject;
0060 #ifdef CEXMC_USE_CUSTOM_FILTER
0061 class  CexmcCustomFilterEval;
0062 #endif
0063 
0064 
0065 typedef std::set< CexmcOutputDataType >  CexmcOutputDataTypeSet;
0066 
0067 
0068 class  CexmcRunManager : public G4RunManager
0069 {
0070     public:
0071         explicit CexmcRunManager( const G4String &  projectId = "",
0072                                   const G4String &  rProject = "",
0073                                   G4bool  overrideExistingProject = false );
0074 
0075         virtual ~CexmcRunManager();
0076 
0077     public:
0078         void  SetPhysicsManager( CexmcPhysicsManager *  physicsManager_ );
0079 
0080         void  SetProductionModelType(
0081                             CexmcProductionModelType  productionModelType_ );
0082 
0083         void  SetGdmlFileName( const G4String &  gdmlFileName_ );
0084 
0085         void  SetGdmlFileValidation( G4bool  on = true );
0086 
0087         void  SetGuiMacroName( const G4String &  guiMacroName_ );
0088 
0089         void  SetEventCountPolicy( CexmcEventCountPolicy  value );
0090 
0091         void  SetEventDataVerboseLevel( CexmcEventDataVerboseLevel  value );
0092 
0093         void  RegisterScenePrimitives( void );
0094 
0095 #ifdef CEXMC_USE_PERSISTENCY
0096         void  ReadProject( void );
0097 
0098         void  SaveProject( void );
0099 
0100         void  PrintReadRunData( void ) const;
0101 
0102         void  ReadAndPrintEventsData( void ) const;
0103 
0104         void  PrintReadData( const CexmcOutputDataTypeSet &  outputData ) const;
0105 
0106         void  ReplayEvents( G4int  nEvents = 0 );
0107 
0108         void  SeekTo( G4int  eventNmb = 1 );
0109 
0110         void  SkipInteractionsWithoutEDTonWrite( G4bool  on = true );
0111 
0112 #ifdef CEXMC_USE_CUSTOM_FILTER
0113         void  SetCustomFilter( const G4String &  cfFileName_ );
0114 #endif
0115 #endif
0116 
0117         void  BeamParticleChangeHook( void );
0118 
0119         void  SetupConstructionHook( void );
0120 
0121     public:
0122         CexmcPhysicsManager *     GetPhysicsManager( void );
0123 
0124         CexmcProductionModelType  GetProductionModelType( void ) const;
0125 
0126         G4String                  GetGdmlFileName( void ) const;
0127 
0128         G4bool                    ShouldGdmlFileBeValidated( void ) const;
0129 
0130         G4String                  GetGuiMacroName( void ) const;
0131 
0132         G4bool                    ProjectIsSaved( void ) const;
0133 
0134         G4bool                    ProjectIsRead( void ) const;
0135 
0136         G4String                  GetProjectsDir( void ) const;
0137 
0138         G4String                  GetProjectId( void ) const;
0139 
0140 #ifdef CEXMC_USE_PERSISTENCY
0141         boost::archive::binary_oarchive *  GetEventsArchive( void ) const;
0142 
0143         boost::archive::binary_oarchive *  GetFastEventsArchive( void ) const;
0144 #endif
0145 
0146         CexmcEventDataVerboseLevel  GetEventDataVerboseLevel( void ) const;
0147 
0148     protected:
0149         void  DoEventLoop( G4int  nEvent, const char *  macroFile,
0150                            G4int  nSelect );
0151 
0152     private:
0153         void  DoCommonEventLoop( G4int  nEvent, const G4String &  cmd,
0154                                  G4int  nSelect );
0155 
0156 #ifdef CEXMC_USE_PERSISTENCY
0157         void  DoReadEventLoop( G4int  nEvent );
0158 
0159         void  SaveCurrentTPTEvent( const CexmcEventFastSObject &  evFastSObject,
0160                                    const CexmcAngularRangeList &  angularRanges,
0161                                    G4bool  writeToDatabase );
0162 #endif
0163 
0164     private:
0165         void  ReadPreinitProjectData( void );
0166 
0167     private:
0168         CexmcBasePhysicsUsed        basePhysicsUsed;
0169 
0170         CexmcProductionModelType    productionModelType;
0171 
0172         G4String                    gdmlFileName;
0173 
0174         G4bool                      shouldGdmlFileBeValidated;
0175 
0176         G4bool                      zipGdmlFile;
0177 
0178         G4String                    projectsDir;
0179 
0180         G4String                    projectId;
0181 
0182         G4String                    rProject;
0183 
0184         G4String                    guiMacroName;
0185 
0186         G4String                    cfFileName;
0187 
0188         CexmcEventCountPolicy       eventCountPolicy;
0189 
0190         G4bool                      skipInteractionsWithoutEDTonWrite;
0191 
0192         CexmcEventDataVerboseLevel  evDataVerboseLevel;
0193 
0194         CexmcEventDataVerboseLevel  rEvDataVerboseLevel;
0195 
0196     private:
0197         G4int                       numberOfEventsProcessed;
0198 
0199         G4int                       numberOfEventsProcessedEffective;
0200 
0201         G4int                       curEventRead;
0202 
0203 #ifdef CEXMC_USE_PERSISTENCY
0204     private:
0205         boost::archive::binary_oarchive *  eventsArchive;
0206 
0207         boost::archive::binary_oarchive *  fastEventsArchive;
0208 
0209         CexmcRunSObject             sObject;
0210 
0211 #ifdef CEXMC_USE_CUSTOM_FILTER
0212         CexmcCustomFilterEval *     customFilter;
0213 #endif
0214 #endif
0215 
0216     private:
0217         CexmcPhysicsManager *       physicsManager;
0218 
0219     private:
0220         CexmcRunManagerMessenger *  messenger;
0221 };
0222 
0223 
0224 inline void  CexmcRunManager::SetPhysicsManager(
0225                                         CexmcPhysicsManager *  physicsManager_ )
0226 {
0227     physicsManager = physicsManager_;
0228 }
0229 
0230 
0231 inline void  CexmcRunManager::SetProductionModelType(
0232                                 CexmcProductionModelType  productionModelType_ )
0233 {
0234     if ( ProjectIsRead() )
0235         throw CexmcException( CexmcCmdIsNotAllowed );
0236 
0237     productionModelType = productionModelType_;
0238 }
0239 
0240 
0241 inline void  CexmcRunManager::SetGdmlFileName( const G4String &  gdmlFileName_ )
0242 {
0243     if ( ProjectIsRead() )
0244         throw CexmcException( CexmcCmdIsNotAllowed );
0245 
0246     gdmlFileName = gdmlFileName_;
0247 }
0248 
0249 
0250 inline void  CexmcRunManager::SetGdmlFileValidation( G4bool  on )
0251 {
0252     shouldGdmlFileBeValidated = on;
0253 }
0254 
0255 
0256 inline void  CexmcRunManager::SetGuiMacroName( const G4String &  guiMacroName_ )
0257 {
0258     guiMacroName = guiMacroName_;
0259 }
0260 
0261 
0262 inline void  CexmcRunManager::SetEventCountPolicy(
0263                                             CexmcEventCountPolicy  value )
0264 {
0265     if ( ProjectIsRead() )
0266         throw CexmcException( CexmcCmdIsNotAllowed );
0267 
0268     eventCountPolicy = value;
0269 }
0270 
0271 
0272 inline void  CexmcRunManager::SetEventDataVerboseLevel(
0273                                             CexmcEventDataVerboseLevel  value )
0274 {
0275     if ( ProjectIsRead() && value > rEvDataVerboseLevel )
0276         throw CexmcException( CexmcPoorEventData );
0277 
0278     evDataVerboseLevel = value;
0279 }
0280 
0281 
0282 inline CexmcPhysicsManager *  CexmcRunManager::GetPhysicsManager( void )
0283 {
0284     return physicsManager;
0285 }
0286 
0287 
0288 inline CexmcProductionModelType
0289                         CexmcRunManager::GetProductionModelType( void ) const
0290 {
0291     return productionModelType;
0292 }
0293 
0294 
0295 inline G4String  CexmcRunManager::GetGdmlFileName( void ) const
0296 {
0297     return gdmlFileName;
0298 }
0299 
0300 
0301 inline G4bool  CexmcRunManager::ShouldGdmlFileBeValidated( void ) const
0302 {
0303     return shouldGdmlFileBeValidated;
0304 }
0305 
0306 
0307 inline G4String  CexmcRunManager::GetGuiMacroName( void ) const
0308 {
0309     return guiMacroName;
0310 }
0311 
0312 
0313 inline G4bool  CexmcRunManager::ProjectIsSaved( void ) const
0314 {
0315     return projectId != "";
0316 }
0317 
0318 
0319 inline G4bool  CexmcRunManager::ProjectIsRead( void ) const
0320 {
0321     return rProject != "";
0322 }
0323 
0324 
0325 inline G4String  CexmcRunManager::GetProjectsDir( void ) const
0326 {
0327     return projectsDir;
0328 }
0329 
0330 
0331 inline G4String  CexmcRunManager::GetProjectId( void ) const
0332 {
0333     return projectId;
0334 }
0335 
0336 
0337 #ifdef CEXMC_USE_PERSISTENCY
0338 
0339 inline boost::archive::binary_oarchive *  CexmcRunManager::GetEventsArchive(
0340                                                                     void ) const
0341 {
0342     return eventsArchive;
0343 }
0344 
0345 
0346 inline boost::archive::binary_oarchive *  CexmcRunManager::GetFastEventsArchive(
0347                                                                     void ) const
0348 {
0349     return fastEventsArchive;
0350 }
0351 
0352 
0353 inline void  CexmcRunManager::ReplayEvents( G4int  nEvents )
0354 {
0355     if ( ! ProjectIsRead() )
0356         return;
0357 
0358     if ( nEvents == 0 )
0359         nEvents = std::numeric_limits< G4int >::max();
0360 
0361     BeamOn( nEvents );
0362 }
0363 
0364 
0365 inline void  CexmcRunManager::SeekTo( G4int  eventNmb )
0366 {
0367     if ( ! ProjectIsRead() )
0368         return;
0369 
0370     curEventRead = eventNmb;
0371 }
0372 
0373 
0374 inline void  CexmcRunManager::SkipInteractionsWithoutEDTonWrite( G4bool  on )
0375 {
0376     skipInteractionsWithoutEDTonWrite = on;
0377 }
0378 
0379 #endif
0380 
0381 
0382 inline CexmcEventDataVerboseLevel  CexmcRunManager::GetEventDataVerboseLevel(
0383                                                                     void ) const
0384 {
0385     return evDataVerboseLevel;
0386 }
0387 
0388 
0389 #endif
0390