Back to home page

EIC code displayed by LXR

 
 

    


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

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:  CexmcRunManagerMessenger.cc
0030  *
0031  *    Description:  init parameters (production model, gdml file etc.)
0032  *
0033  *        Version:  1.0
0034  *        Created:  03.11.2009 20:45:11
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * ============================================================================
0042  */
0043 
0044 #include <G4UIcmdWithAString.hh>
0045 #include <G4UIcmdWithAnInteger.hh>
0046 #include <G4UIcmdWithABool.hh>
0047 #include <G4UIcmdWithoutParameter.hh>
0048 #include "CexmcRunManager.hh"
0049 #include "CexmcRunManagerMessenger.hh"
0050 #include "CexmcMessenger.hh"
0051 
0052 
0053 CexmcRunManagerMessenger::CexmcRunManagerMessenger(
0054                                 CexmcRunManager *  runManager_ ) :
0055     runManager( runManager_ ), setProductionModel( NULL ), setGdmlFile( NULL ),
0056     setGuiMacro( NULL ), setEventCountPolicy( NULL ),
0057     setEventDataVerboseLevel( NULL ),
0058 #ifdef CEXMC_USE_PERSISTENCY
0059     replayEvents( NULL ), seekTo( NULL ), skipInteractionsWithoutEDT( NULL ), 
0060 #endif
0061     registerScenePrimitives( NULL ), validateGdmlFile( NULL )
0062 {
0063     setProductionModel = new G4UIcmdWithAString(
0064         ( CexmcMessenger::physicsDirName + "productionModel" ).c_str(), this );
0065     setProductionModel->SetGuidance( "Set production model (e.g. pi0 or eta)" );
0066     setProductionModel->SetParameterName( "ProductionModel", false );
0067     setProductionModel->SetCandidates( "pi0 eta" );
0068     setProductionModel->AvailableForStates( G4State_PreInit );
0069 
0070     setGdmlFile = new G4UIcmdWithAString(
0071         ( CexmcMessenger::geometryDirName + "gdmlFile" ).c_str(), this );
0072     setGdmlFile->SetGuidance( "GDML file to read geometry from" );
0073     setGdmlFile->SetParameterName( "GdmlFile", false );
0074     setGdmlFile->AvailableForStates( G4State_PreInit );
0075 
0076     setGuiMacro = new G4UIcmdWithAString(
0077         ( CexmcMessenger::runDirName + "guiMacro" ).c_str(), this );
0078     setGuiMacro->SetGuidance( "Set Gui macro file" );
0079     setGuiMacro->SetParameterName( "GuiMacro", false );
0080     setGuiMacro->AvailableForStates( G4State_PreInit, G4State_Idle );
0081 
0082     setEventCountPolicy = new G4UIcmdWithAString(
0083         ( CexmcMessenger::runDirName + "eventCountPolicy" ).c_str(), this );
0084     setEventCountPolicy->SetGuidance( "How number of events is interpreted.\n"
0085             "    all - all events are accounted,\n"
0086             "    interaction - events with studied interaction triggered,\n"
0087             "    trigger - only events with trigger" );
0088     setEventCountPolicy->SetParameterName( "EventCountPolicy", false );
0089     setEventCountPolicy->SetCandidates( "all interaction trigger" );
0090     setEventCountPolicy->SetDefaultValue( "all" );
0091     setEventCountPolicy->AvailableForStates( G4State_PreInit, G4State_Idle );
0092 
0093     setEventDataVerboseLevel = new G4UIcmdWithAString(
0094         ( CexmcMessenger::runDirName + "eventDataVerboseLevel" ).c_str(),
0095         this );
0096     setEventDataVerboseLevel->SetGuidance( "When events will be saved.\n"
0097             "    nosave - never,\n"
0098             "    trigger - when energy deposit triggered (EDT),\n"
0099             "    interaction - when studied interaction triggered (TPT)" );
0100     setEventDataVerboseLevel->SetParameterName( "EventDataVerboseLevel",
0101                                                 false );
0102     setEventDataVerboseLevel->SetCandidates( "nosave trigger interaction" );
0103     setEventDataVerboseLevel->SetDefaultValue( "trigger" );
0104     setEventDataVerboseLevel->AvailableForStates( G4State_PreInit,
0105                                                   G4State_Idle );
0106 
0107 #ifdef CEXMC_USE_PERSISTENCY
0108     replayEvents = new G4UIcmdWithAnInteger(
0109         ( CexmcMessenger::runDirName + "replay" ).c_str(), this );
0110     replayEvents->SetGuidance( "Replay specified number of events "
0111            "\n    (available only if a project is read)."
0112            "\n    If number of events is 0 (or not specified) then all"
0113            "\n    run will be replayed" );
0114     replayEvents->SetParameterName( "ReplayEvents", true );
0115     replayEvents->SetRange( "ReplayEvents >= 0" );
0116     replayEvents->SetDefaultValue( 0 );
0117     replayEvents->AvailableForStates( G4State_PreInit, G4State_Idle );
0118 
0119     seekTo = new G4UIcmdWithAnInteger(
0120         ( CexmcMessenger::runDirName + "seekto" ).c_str(), this );
0121     seekTo->SetGuidance( "Seek to specified event id "
0122            "(available only if a project is read)."
0123            "\n    'seekto 0' brings to the start of run, 'seekto 4' - to the"
0124            "\n    first recorded event with interaction after fourth recorded"
0125            "\n    event with trigger" );
0126     seekTo->SetParameterName( "SeekTo", false );
0127     seekTo->SetRange( "SeekTo >= 0" );
0128     seekTo->SetDefaultValue( 0 );
0129     seekTo->AvailableForStates( G4State_PreInit, G4State_Idle );
0130 
0131     skipInteractionsWithoutEDT = new G4UIcmdWithABool(
0132         ( CexmcMessenger::runDirName + "skipInteractionsWithoutEDT" ).c_str(),
0133         this );
0134     skipInteractionsWithoutEDT->SetGuidance( "Do not write interactions into "
0135         ".fdb file\n    if event was not triggered (effective only when a "
0136         "project is read and then\n    written to another project and only if "
0137         "event data verbose level is\n    'trigger')" );
0138     skipInteractionsWithoutEDT->SetParameterName( "skipInteractionsWithoutEDT",
0139                                                   true );
0140     skipInteractionsWithoutEDT->SetDefaultValue( true );
0141     skipInteractionsWithoutEDT->AvailableForStates( G4State_PreInit,
0142                                                     G4State_Idle );
0143 #endif
0144 
0145     registerScenePrimitives = new G4UIcmdWithoutParameter(
0146         ( CexmcMessenger::visDirName + "registerScenePrimitives" ).c_str(),
0147         this );
0148     registerScenePrimitives->SetGuidance( "Register custom scene primitives "
0149         "(radial lines,\n    inner crystals highlights etc.)" );
0150     registerScenePrimitives->AvailableForStates( G4State_PreInit,
0151                                                  G4State_Idle );
0152 
0153     validateGdmlFile = new G4UIcmdWithABool(
0154         ( CexmcMessenger::geometryDirName + "validateGdmlFile" ).c_str(),
0155         this );
0156     validateGdmlFile->SetGuidance( "If GDML file will be validated or not" );
0157     validateGdmlFile->SetParameterName( "ValidateGdmlFile", false );
0158     validateGdmlFile->SetDefaultValue( false );
0159     validateGdmlFile->AvailableForStates( G4State_PreInit );
0160 }
0161 
0162 
0163 CexmcRunManagerMessenger::~CexmcRunManagerMessenger()
0164 {
0165     delete setProductionModel;
0166     delete setGdmlFile;
0167     delete setGuiMacro;
0168     delete setEventCountPolicy;
0169     delete setEventDataVerboseLevel;
0170 #ifdef CEXMC_USE_PERSISTENCY
0171     delete replayEvents;
0172     delete seekTo;
0173     delete skipInteractionsWithoutEDT;
0174 #endif
0175     delete registerScenePrimitives;
0176     delete validateGdmlFile;
0177 }
0178 
0179 
0180 void  CexmcRunManagerMessenger::SetNewValue( G4UIcommand *  cmd,
0181                                              G4String  value )
0182 {
0183     do
0184     {
0185         if ( cmd == setProductionModel )
0186         {
0187             CexmcProductionModelType  productionModelType(
0188                                                 CexmcUnknownProductionModel );
0189             do
0190             {
0191                 if ( value == "pi0" )
0192                 {
0193                     productionModelType = CexmcPionZeroProduction;
0194                     break;
0195                 }
0196                 if ( value == "eta" )
0197                 {
0198                     productionModelType = CexmcEtaProduction;
0199                     break;
0200                 }
0201             } while ( false );
0202             runManager->SetProductionModelType( productionModelType );
0203             break;
0204         }
0205         if ( cmd == setGdmlFile )
0206         {
0207             runManager->SetGdmlFileName( value );
0208             break;
0209         }
0210         if ( cmd == setGuiMacro )
0211         {
0212             runManager->SetGuiMacroName( value );
0213             break;
0214         }
0215         if ( cmd == setEventCountPolicy )
0216         {
0217             CexmcEventCountPolicy  eventCountPolicy( CexmcCountAllEvents );
0218             do
0219             {
0220                 if ( value == "interaction" )
0221                 {
0222                     eventCountPolicy = CexmcCountEventsWithInteraction;
0223                     break;
0224                 }
0225                 if ( value == "trigger" )
0226                 {
0227                     eventCountPolicy = CexmcCountEventsWithTrigger;
0228                     break;
0229                 }
0230             } while ( false );
0231             runManager->SetEventCountPolicy( eventCountPolicy );
0232             break;
0233         }
0234         if ( cmd == setEventDataVerboseLevel )
0235         {
0236             CexmcEventDataVerboseLevel  eventDataVerboseLevel(
0237                                                 CexmcWriteEventDataOnEveryEDT );
0238             do
0239             {
0240                 if ( value == "nosave" )
0241                 {
0242                     eventDataVerboseLevel = CexmcWriteNoEventData;
0243                     break;
0244                 }
0245                 if ( value == "trigger" )
0246                 {
0247                     eventDataVerboseLevel = CexmcWriteEventDataOnEveryEDT;
0248                     break;
0249                 }
0250                 if ( value == "interaction" )
0251                 {
0252                     eventDataVerboseLevel = CexmcWriteEventDataOnEveryTPT;
0253                     break;
0254                 }
0255             } while ( false );
0256             runManager->SetEventDataVerboseLevel( eventDataVerboseLevel );
0257             break;
0258         }
0259 #ifdef CEXMC_USE_PERSISTENCY
0260         if ( cmd == replayEvents )
0261         {
0262             runManager->ReplayEvents(
0263                                 G4UIcmdWithAnInteger::GetNewIntValue( value ) );
0264             break;
0265         }
0266         if ( cmd == seekTo )
0267         {
0268             runManager->SeekTo( G4UIcmdWithAnInteger::GetNewIntValue( value ) );
0269             break;
0270         }
0271         if ( cmd == skipInteractionsWithoutEDT )
0272         {
0273             runManager->SkipInteractionsWithoutEDTonWrite(
0274                                 G4UIcmdWithABool::GetNewBoolValue( value ) );
0275             break;
0276         }
0277 #endif
0278         if ( cmd == registerScenePrimitives )
0279         {
0280             runManager->RegisterScenePrimitives();
0281             break;
0282         }
0283         if ( cmd == validateGdmlFile )
0284         {
0285             runManager->SetGdmlFileValidation(
0286                                 G4UIcmdWithABool::GetNewBoolValue( value ) );
0287             break;
0288         }
0289     } while ( false );
0290 }
0291