Geant4 Cross Reference |
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: CexmcRunManagerMessenger.cc 30 * 31 * Description: init parameters (production model, gdml file etc.) 32 * 33 * Version: 1.0 34 * Created: 03.11.2009 20:45:11 35 * Revision: none 36 * Compiler: gcc 37 * 38 * Author: Alexey Radkov (), 39 * Company: PNPI 40 * 41 * ============================================================================ 42 */ 43 44 #include <G4UIcmdWithAString.hh> 45 #include <G4UIcmdWithAnInteger.hh> 46 #include <G4UIcmdWithABool.hh> 47 #include <G4UIcmdWithoutParameter.hh> 48 #include "CexmcRunManager.hh" 49 #include "CexmcRunManagerMessenger.hh" 50 #include "CexmcMessenger.hh" 51 52 53 CexmcRunManagerMessenger::CexmcRunManagerMessenger( 54 CexmcRunManager * runManager_ ) : 55 runManager( runManager_ ), setProductionModel( NULL ), setGdmlFile( NULL ), 56 setGuiMacro( NULL ), setEventCountPolicy( NULL ), 57 setEventDataVerboseLevel( NULL ), 58 #ifdef CEXMC_USE_PERSISTENCY 59 replayEvents( NULL ), seekTo( NULL ), skipInteractionsWithoutEDT( NULL ), 60 #endif 61 registerScenePrimitives( NULL ), validateGdmlFile( NULL ) 62 { 63 setProductionModel = new G4UIcmdWithAString( 64 ( CexmcMessenger::physicsDirName + "productionModel" ).c_str(), this ); 65 setProductionModel->SetGuidance( "Set production model (e.g. pi0 or eta)" ); 66 setProductionModel->SetParameterName( "ProductionModel", false ); 67 setProductionModel->SetCandidates( "pi0 eta" ); 68 setProductionModel->AvailableForStates( G4State_PreInit ); 69 70 setGdmlFile = new G4UIcmdWithAString( 71 ( CexmcMessenger::geometryDirName + "gdmlFile" ).c_str(), this ); 72 setGdmlFile->SetGuidance( "GDML file to read geometry from" ); 73 setGdmlFile->SetParameterName( "GdmlFile", false ); 74 setGdmlFile->AvailableForStates( G4State_PreInit ); 75 76 setGuiMacro = new G4UIcmdWithAString( 77 ( CexmcMessenger::runDirName + "guiMacro" ).c_str(), this ); 78 setGuiMacro->SetGuidance( "Set Gui macro file" ); 79 setGuiMacro->SetParameterName( "GuiMacro", false ); 80 setGuiMacro->AvailableForStates( G4State_PreInit, G4State_Idle ); 81 82 setEventCountPolicy = new G4UIcmdWithAString( 83 ( CexmcMessenger::runDirName + "eventCountPolicy" ).c_str(), this ); 84 setEventCountPolicy->SetGuidance( "How number of events is interpreted.\n" 85 " all - all events are accounted,\n" 86 " interaction - events with studied interaction triggered,\n" 87 " trigger - only events with trigger" ); 88 setEventCountPolicy->SetParameterName( "EventCountPolicy", false ); 89 setEventCountPolicy->SetCandidates( "all interaction trigger" ); 90 setEventCountPolicy->SetDefaultValue( "all" ); 91 setEventCountPolicy->AvailableForStates( G4State_PreInit, G4State_Idle ); 92 93 setEventDataVerboseLevel = new G4UIcmdWithAString( 94 ( CexmcMessenger::runDirName + "eventDataVerboseLevel" ).c_str(), 95 this ); 96 setEventDataVerboseLevel->SetGuidance( "When events will be saved.\n" 97 " nosave - never,\n" 98 " trigger - when energy deposit triggered (EDT),\n" 99 " interaction - when studied interaction triggered (TPT)" ); 100 setEventDataVerboseLevel->SetParameterName( "EventDataVerboseLevel", 101 false ); 102 setEventDataVerboseLevel->SetCandidates( "nosave trigger interaction" ); 103 setEventDataVerboseLevel->SetDefaultValue( "trigger" ); 104 setEventDataVerboseLevel->AvailableForStates( G4State_PreInit, 105 G4State_Idle ); 106 107 #ifdef CEXMC_USE_PERSISTENCY 108 replayEvents = new G4UIcmdWithAnInteger( 109 ( CexmcMessenger::runDirName + "replay" ).c_str(), this ); 110 replayEvents->SetGuidance( "Replay specified number of events " 111 "\n (available only if a project is read)." 112 "\n If number of events is 0 (or not specified) then all" 113 "\n run will be replayed" ); 114 replayEvents->SetParameterName( "ReplayEvents", true ); 115 replayEvents->SetRange( "ReplayEvents >= 0" ); 116 replayEvents->SetDefaultValue( 0 ); 117 replayEvents->AvailableForStates( G4State_PreInit, G4State_Idle ); 118 119 seekTo = new G4UIcmdWithAnInteger( 120 ( CexmcMessenger::runDirName + "seekto" ).c_str(), this ); 121 seekTo->SetGuidance( "Seek to specified event id " 122 "(available only if a project is read)." 123 "\n 'seekto 0' brings to the start of run, 'seekto 4' - to the" 124 "\n first recorded event with interaction after fourth recorded" 125 "\n event with trigger" ); 126 seekTo->SetParameterName( "SeekTo", false ); 127 seekTo->SetRange( "SeekTo >= 0" ); 128 seekTo->SetDefaultValue( 0 ); 129 seekTo->AvailableForStates( G4State_PreInit, G4State_Idle ); 130 131 skipInteractionsWithoutEDT = new G4UIcmdWithABool( 132 ( CexmcMessenger::runDirName + "skipInteractionsWithoutEDT" ).c_str(), 133 this ); 134 skipInteractionsWithoutEDT->SetGuidance( "Do not write interactions into " 135 ".fdb file\n if event was not triggered (effective only when a " 136 "project is read and then\n written to another project and only if " 137 "event data verbose level is\n 'trigger')" ); 138 skipInteractionsWithoutEDT->SetParameterName( "skipInteractionsWithoutEDT", 139 true ); 140 skipInteractionsWithoutEDT->SetDefaultValue( true ); 141 skipInteractionsWithoutEDT->AvailableForStates( G4State_PreInit, 142 G4State_Idle ); 143 #endif 144 145 registerScenePrimitives = new G4UIcmdWithoutParameter( 146 ( CexmcMessenger::visDirName + "registerScenePrimitives" ).c_str(), 147 this ); 148 registerScenePrimitives->SetGuidance( "Register custom scene primitives " 149 "(radial lines,\n inner crystals highlights etc.)" ); 150 registerScenePrimitives->AvailableForStates( G4State_PreInit, 151 G4State_Idle ); 152 153 validateGdmlFile = new G4UIcmdWithABool( 154 ( CexmcMessenger::geometryDirName + "validateGdmlFile" ).c_str(), 155 this ); 156 validateGdmlFile->SetGuidance( "If GDML file will be validated or not" ); 157 validateGdmlFile->SetParameterName( "ValidateGdmlFile", false ); 158 validateGdmlFile->SetDefaultValue( false ); 159 validateGdmlFile->AvailableForStates( G4State_PreInit ); 160 } 161 162 163 CexmcRunManagerMessenger::~CexmcRunManagerMessenger() 164 { 165 delete setProductionModel; 166 delete setGdmlFile; 167 delete setGuiMacro; 168 delete setEventCountPolicy; 169 delete setEventDataVerboseLevel; 170 #ifdef CEXMC_USE_PERSISTENCY 171 delete replayEvents; 172 delete seekTo; 173 delete skipInteractionsWithoutEDT; 174 #endif 175 delete registerScenePrimitives; 176 delete validateGdmlFile; 177 } 178 179 180 void CexmcRunManagerMessenger::SetNewValue( G4UIcommand * cmd, 181 G4String value ) 182 { 183 do 184 { 185 if ( cmd == setProductionModel ) 186 { 187 CexmcProductionModelType productionModelType( 188 CexmcUnknownProductionModel ); 189 do 190 { 191 if ( value == "pi0" ) 192 { 193 productionModelType = CexmcPionZeroProduction; 194 break; 195 } 196 if ( value == "eta" ) 197 { 198 productionModelType = CexmcEtaProduction; 199 break; 200 } 201 } while ( false ); 202 runManager->SetProductionModelType( productionModelType ); 203 break; 204 } 205 if ( cmd == setGdmlFile ) 206 { 207 runManager->SetGdmlFileName( value ); 208 break; 209 } 210 if ( cmd == setGuiMacro ) 211 { 212 runManager->SetGuiMacroName( value ); 213 break; 214 } 215 if ( cmd == setEventCountPolicy ) 216 { 217 CexmcEventCountPolicy eventCountPolicy( CexmcCountAllEvents ); 218 do 219 { 220 if ( value == "interaction" ) 221 { 222 eventCountPolicy = CexmcCountEventsWithInteraction; 223 break; 224 } 225 if ( value == "trigger" ) 226 { 227 eventCountPolicy = CexmcCountEventsWithTrigger; 228 break; 229 } 230 } while ( false ); 231 runManager->SetEventCountPolicy( eventCountPolicy ); 232 break; 233 } 234 if ( cmd == setEventDataVerboseLevel ) 235 { 236 CexmcEventDataVerboseLevel eventDataVerboseLevel( 237 CexmcWriteEventDataOnEveryEDT ); 238 do 239 { 240 if ( value == "nosave" ) 241 { 242 eventDataVerboseLevel = CexmcWriteNoEventData; 243 break; 244 } 245 if ( value == "trigger" ) 246 { 247 eventDataVerboseLevel = CexmcWriteEventDataOnEveryEDT; 248 break; 249 } 250 if ( value == "interaction" ) 251 { 252 eventDataVerboseLevel = CexmcWriteEventDataOnEveryTPT; 253 break; 254 } 255 } while ( false ); 256 runManager->SetEventDataVerboseLevel( eventDataVerboseLevel ); 257 break; 258 } 259 #ifdef CEXMC_USE_PERSISTENCY 260 if ( cmd == replayEvents ) 261 { 262 runManager->ReplayEvents( 263 G4UIcmdWithAnInteger::GetNewIntValue( value ) ); 264 break; 265 } 266 if ( cmd == seekTo ) 267 { 268 runManager->SeekTo( G4UIcmdWithAnInteger::GetNewIntValue( value ) ); 269 break; 270 } 271 if ( cmd == skipInteractionsWithoutEDT ) 272 { 273 runManager->SkipInteractionsWithoutEDTonWrite( 274 G4UIcmdWithABool::GetNewBoolValue( value ) ); 275 break; 276 } 277 #endif 278 if ( cmd == registerScenePrimitives ) 279 { 280 runManager->RegisterScenePrimitives(); 281 break; 282 } 283 if ( cmd == validateGdmlFile ) 284 { 285 runManager->SetGdmlFileValidation( 286 G4UIcmdWithABool::GetNewBoolValue( value ) ); 287 break; 288 } 289 } while ( false ); 290 } 291 292