Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /* 26 /* 27 * =========================================== 27 * ============================================================================ 28 * 28 * 29 * Filename: CexmcRunManagerMessenger.c 29 * Filename: CexmcRunManagerMessenger.cc 30 * 30 * 31 * Description: init parameters (productio 31 * Description: init parameters (production model, gdml file etc.) 32 * 32 * 33 * Version: 1.0 33 * Version: 1.0 34 * Created: 03.11.2009 20:45:11 34 * Created: 03.11.2009 20:45:11 35 * Revision: none 35 * Revision: none 36 * Compiler: gcc 36 * Compiler: gcc 37 * 37 * 38 * Author: Alexey Radkov (), 38 * Author: Alexey Radkov (), 39 * Company: PNPI 39 * Company: PNPI 40 * 40 * 41 * =========================================== 41 * ============================================================================ 42 */ 42 */ 43 43 44 #include <G4UIcmdWithAString.hh> 44 #include <G4UIcmdWithAString.hh> 45 #include <G4UIcmdWithAnInteger.hh> 45 #include <G4UIcmdWithAnInteger.hh> 46 #include <G4UIcmdWithABool.hh> 46 #include <G4UIcmdWithABool.hh> 47 #include <G4UIcmdWithoutParameter.hh> 47 #include <G4UIcmdWithoutParameter.hh> 48 #include "CexmcRunManager.hh" 48 #include "CexmcRunManager.hh" 49 #include "CexmcRunManagerMessenger.hh" 49 #include "CexmcRunManagerMessenger.hh" 50 #include "CexmcMessenger.hh" 50 #include "CexmcMessenger.hh" 51 51 52 52 53 CexmcRunManagerMessenger::CexmcRunManagerMesse 53 CexmcRunManagerMessenger::CexmcRunManagerMessenger( 54 CexmcRunManage 54 CexmcRunManager * runManager_ ) : 55 runManager( runManager_ ), setProductionMo 55 runManager( runManager_ ), setProductionModel( NULL ), setGdmlFile( NULL ), 56 setGuiMacro( NULL ), setEventCountPolicy( 56 setGuiMacro( NULL ), setEventCountPolicy( NULL ), 57 setEventDataVerboseLevel( NULL ), 57 setEventDataVerboseLevel( NULL ), 58 #ifdef CEXMC_USE_PERSISTENCY 58 #ifdef CEXMC_USE_PERSISTENCY 59 replayEvents( NULL ), seekTo( NULL ), skip 59 replayEvents( NULL ), seekTo( NULL ), skipInteractionsWithoutEDT( NULL ), 60 #endif 60 #endif 61 registerScenePrimitives( NULL ), validateG 61 registerScenePrimitives( NULL ), validateGdmlFile( NULL ) 62 { 62 { 63 setProductionModel = new G4UIcmdWithAStrin 63 setProductionModel = new G4UIcmdWithAString( 64 ( CexmcMessenger::physicsDirName + "pr 64 ( CexmcMessenger::physicsDirName + "productionModel" ).c_str(), this ); 65 setProductionModel->SetGuidance( "Set prod 65 setProductionModel->SetGuidance( "Set production model (e.g. pi0 or eta)" ); 66 setProductionModel->SetParameterName( "Pro 66 setProductionModel->SetParameterName( "ProductionModel", false ); 67 setProductionModel->SetCandidates( "pi0 et 67 setProductionModel->SetCandidates( "pi0 eta" ); 68 setProductionModel->AvailableForStates( G4 68 setProductionModel->AvailableForStates( G4State_PreInit ); 69 69 70 setGdmlFile = new G4UIcmdWithAString( 70 setGdmlFile = new G4UIcmdWithAString( 71 ( CexmcMessenger::geometryDirName + "g 71 ( CexmcMessenger::geometryDirName + "gdmlFile" ).c_str(), this ); 72 setGdmlFile->SetGuidance( "GDML file to re 72 setGdmlFile->SetGuidance( "GDML file to read geometry from" ); 73 setGdmlFile->SetParameterName( "GdmlFile", 73 setGdmlFile->SetParameterName( "GdmlFile", false ); 74 setGdmlFile->AvailableForStates( G4State_P 74 setGdmlFile->AvailableForStates( G4State_PreInit ); 75 75 76 setGuiMacro = new G4UIcmdWithAString( 76 setGuiMacro = new G4UIcmdWithAString( 77 ( CexmcMessenger::runDirName + "guiMac 77 ( CexmcMessenger::runDirName + "guiMacro" ).c_str(), this ); 78 setGuiMacro->SetGuidance( "Set Gui macro f 78 setGuiMacro->SetGuidance( "Set Gui macro file" ); 79 setGuiMacro->SetParameterName( "GuiMacro", 79 setGuiMacro->SetParameterName( "GuiMacro", false ); 80 setGuiMacro->AvailableForStates( G4State_P 80 setGuiMacro->AvailableForStates( G4State_PreInit, G4State_Idle ); 81 81 82 setEventCountPolicy = new G4UIcmdWithAStri 82 setEventCountPolicy = new G4UIcmdWithAString( 83 ( CexmcMessenger::runDirName + "eventC 83 ( CexmcMessenger::runDirName + "eventCountPolicy" ).c_str(), this ); 84 setEventCountPolicy->SetGuidance( "How num 84 setEventCountPolicy->SetGuidance( "How number of events is interpreted.\n" 85 " all - all events are accounte 85 " all - all events are accounted,\n" 86 " interaction - events with stu 86 " interaction - events with studied interaction triggered,\n" 87 " trigger - only events with tr 87 " trigger - only events with trigger" ); 88 setEventCountPolicy->SetParameterName( "Ev 88 setEventCountPolicy->SetParameterName( "EventCountPolicy", false ); 89 setEventCountPolicy->SetCandidates( "all i 89 setEventCountPolicy->SetCandidates( "all interaction trigger" ); 90 setEventCountPolicy->SetDefaultValue( "all 90 setEventCountPolicy->SetDefaultValue( "all" ); 91 setEventCountPolicy->AvailableForStates( G 91 setEventCountPolicy->AvailableForStates( G4State_PreInit, G4State_Idle ); 92 92 93 setEventDataVerboseLevel = new G4UIcmdWith 93 setEventDataVerboseLevel = new G4UIcmdWithAString( 94 ( CexmcMessenger::runDirName + "eventD 94 ( CexmcMessenger::runDirName + "eventDataVerboseLevel" ).c_str(), 95 this ); 95 this ); 96 setEventDataVerboseLevel->SetGuidance( "Wh 96 setEventDataVerboseLevel->SetGuidance( "When events will be saved.\n" 97 " nosave - never,\n" 97 " nosave - never,\n" 98 " trigger - when energy deposit 98 " trigger - when energy deposit triggered (EDT),\n" 99 " interaction - when studied in 99 " interaction - when studied interaction triggered (TPT)" ); 100 setEventDataVerboseLevel->SetParameterName 100 setEventDataVerboseLevel->SetParameterName( "EventDataVerboseLevel", 101 101 false ); 102 setEventDataVerboseLevel->SetCandidates( " 102 setEventDataVerboseLevel->SetCandidates( "nosave trigger interaction" ); 103 setEventDataVerboseLevel->SetDefaultValue( 103 setEventDataVerboseLevel->SetDefaultValue( "trigger" ); 104 setEventDataVerboseLevel->AvailableForStat 104 setEventDataVerboseLevel->AvailableForStates( G4State_PreInit, 105 105 G4State_Idle ); 106 106 107 #ifdef CEXMC_USE_PERSISTENCY 107 #ifdef CEXMC_USE_PERSISTENCY 108 replayEvents = new G4UIcmdWithAnInteger( 108 replayEvents = new G4UIcmdWithAnInteger( 109 ( CexmcMessenger::runDirName + "replay 109 ( CexmcMessenger::runDirName + "replay" ).c_str(), this ); 110 replayEvents->SetGuidance( "Replay specifi 110 replayEvents->SetGuidance( "Replay specified number of events " 111 "\n (available only if a project 111 "\n (available only if a project is read)." 112 "\n If number of events is 0 (or 112 "\n If number of events is 0 (or not specified) then all" 113 "\n run will be replayed" ); 113 "\n run will be replayed" ); 114 replayEvents->SetParameterName( "ReplayEve 114 replayEvents->SetParameterName( "ReplayEvents", true ); 115 replayEvents->SetRange( "ReplayEvents >= 0 115 replayEvents->SetRange( "ReplayEvents >= 0" ); 116 replayEvents->SetDefaultValue( 0 ); 116 replayEvents->SetDefaultValue( 0 ); 117 replayEvents->AvailableForStates( G4State_ 117 replayEvents->AvailableForStates( G4State_PreInit, G4State_Idle ); 118 118 119 seekTo = new G4UIcmdWithAnInteger( 119 seekTo = new G4UIcmdWithAnInteger( 120 ( CexmcMessenger::runDirName + "seekto 120 ( CexmcMessenger::runDirName + "seekto" ).c_str(), this ); 121 seekTo->SetGuidance( "Seek to specified ev 121 seekTo->SetGuidance( "Seek to specified event id " 122 "(available only if a project is re 122 "(available only if a project is read)." 123 "\n 'seekto 0' brings to the sta 123 "\n 'seekto 0' brings to the start of run, 'seekto 4' - to the" 124 "\n first recorded event with in 124 "\n first recorded event with interaction after fourth recorded" 125 "\n event with trigger" ); 125 "\n event with trigger" ); 126 seekTo->SetParameterName( "SeekTo", false 126 seekTo->SetParameterName( "SeekTo", false ); 127 seekTo->SetRange( "SeekTo >= 0" ); 127 seekTo->SetRange( "SeekTo >= 0" ); 128 seekTo->SetDefaultValue( 0 ); 128 seekTo->SetDefaultValue( 0 ); 129 seekTo->AvailableForStates( G4State_PreIni 129 seekTo->AvailableForStates( G4State_PreInit, G4State_Idle ); 130 130 131 skipInteractionsWithoutEDT = new G4UIcmdWi 131 skipInteractionsWithoutEDT = new G4UIcmdWithABool( 132 ( CexmcMessenger::runDirName + "skipIn 132 ( CexmcMessenger::runDirName + "skipInteractionsWithoutEDT" ).c_str(), 133 this ); 133 this ); 134 skipInteractionsWithoutEDT->SetGuidance( " 134 skipInteractionsWithoutEDT->SetGuidance( "Do not write interactions into " 135 ".fdb file\n if event was not trigg 135 ".fdb file\n if event was not triggered (effective only when a " 136 "project is read and then\n written 136 "project is read and then\n written to another project and only if " 137 "event data verbose level is\n 'tri 137 "event data verbose level is\n 'trigger')" ); 138 skipInteractionsWithoutEDT->SetParameterNa 138 skipInteractionsWithoutEDT->SetParameterName( "skipInteractionsWithoutEDT", 139 139 true ); 140 skipInteractionsWithoutEDT->SetDefaultValu 140 skipInteractionsWithoutEDT->SetDefaultValue( true ); 141 skipInteractionsWithoutEDT->AvailableForSt 141 skipInteractionsWithoutEDT->AvailableForStates( G4State_PreInit, 142 142 G4State_Idle ); 143 #endif 143 #endif 144 144 145 registerScenePrimitives = new G4UIcmdWitho 145 registerScenePrimitives = new G4UIcmdWithoutParameter( 146 ( CexmcMessenger::visDirName + "regist 146 ( CexmcMessenger::visDirName + "registerScenePrimitives" ).c_str(), 147 this ); 147 this ); 148 registerScenePrimitives->SetGuidance( "Reg 148 registerScenePrimitives->SetGuidance( "Register custom scene primitives " 149 "(radial lines,\n inner crystals hi 149 "(radial lines,\n inner crystals highlights etc.)" ); 150 registerScenePrimitives->AvailableForState 150 registerScenePrimitives->AvailableForStates( G4State_PreInit, 151 151 G4State_Idle ); 152 152 153 validateGdmlFile = new G4UIcmdWithABool( 153 validateGdmlFile = new G4UIcmdWithABool( 154 ( CexmcMessenger::geometryDirName + "v 154 ( CexmcMessenger::geometryDirName + "validateGdmlFile" ).c_str(), 155 this ); 155 this ); 156 validateGdmlFile->SetGuidance( "If GDML fi 156 validateGdmlFile->SetGuidance( "If GDML file will be validated or not" ); 157 validateGdmlFile->SetParameterName( "Valid << 157 validateGdmlFile->SetParameterName( "ValidateGdmlFile", true ); 158 validateGdmlFile->SetDefaultValue( false ) << 158 validateGdmlFile->SetDefaultValue( true ); 159 validateGdmlFile->AvailableForStates( G4St 159 validateGdmlFile->AvailableForStates( G4State_PreInit ); 160 } 160 } 161 161 162 162 163 CexmcRunManagerMessenger::~CexmcRunManagerMess 163 CexmcRunManagerMessenger::~CexmcRunManagerMessenger() 164 { 164 { 165 delete setProductionModel; 165 delete setProductionModel; 166 delete setGdmlFile; 166 delete setGdmlFile; 167 delete setGuiMacro; 167 delete setGuiMacro; 168 delete setEventCountPolicy; 168 delete setEventCountPolicy; 169 delete setEventDataVerboseLevel; 169 delete setEventDataVerboseLevel; 170 #ifdef CEXMC_USE_PERSISTENCY 170 #ifdef CEXMC_USE_PERSISTENCY 171 delete replayEvents; 171 delete replayEvents; 172 delete seekTo; 172 delete seekTo; 173 delete skipInteractionsWithoutEDT; 173 delete skipInteractionsWithoutEDT; 174 #endif 174 #endif 175 delete registerScenePrimitives; 175 delete registerScenePrimitives; 176 delete validateGdmlFile; 176 delete validateGdmlFile; 177 } 177 } 178 178 179 179 180 void CexmcRunManagerMessenger::SetNewValue( G 180 void CexmcRunManagerMessenger::SetNewValue( G4UIcommand * cmd, 181 G 181 G4String value ) 182 { 182 { 183 do 183 do 184 { 184 { 185 if ( cmd == setProductionModel ) 185 if ( cmd == setProductionModel ) 186 { 186 { 187 CexmcProductionModelType producti 187 CexmcProductionModelType productionModelType( 188 188 CexmcUnknownProductionModel ); 189 do 189 do 190 { 190 { 191 if ( value == "pi0" ) 191 if ( value == "pi0" ) 192 { 192 { 193 productionModelType = Cexm 193 productionModelType = CexmcPionZeroProduction; 194 break; 194 break; 195 } 195 } 196 if ( value == "eta" ) 196 if ( value == "eta" ) 197 { 197 { 198 productionModelType = Cexm 198 productionModelType = CexmcEtaProduction; 199 break; 199 break; 200 } 200 } 201 } while ( false ); 201 } while ( false ); 202 runManager->SetProductionModelType 202 runManager->SetProductionModelType( productionModelType ); 203 break; 203 break; 204 } 204 } 205 if ( cmd == setGdmlFile ) 205 if ( cmd == setGdmlFile ) 206 { 206 { 207 runManager->SetGdmlFileName( value 207 runManager->SetGdmlFileName( value ); 208 break; 208 break; 209 } 209 } 210 if ( cmd == setGuiMacro ) 210 if ( cmd == setGuiMacro ) 211 { 211 { 212 runManager->SetGuiMacroName( value 212 runManager->SetGuiMacroName( value ); 213 break; 213 break; 214 } 214 } 215 if ( cmd == setEventCountPolicy ) 215 if ( cmd == setEventCountPolicy ) 216 { 216 { 217 CexmcEventCountPolicy eventCountP 217 CexmcEventCountPolicy eventCountPolicy( CexmcCountAllEvents ); 218 do 218 do 219 { 219 { 220 if ( value == "interaction" ) 220 if ( value == "interaction" ) 221 { 221 { 222 eventCountPolicy = CexmcCo 222 eventCountPolicy = CexmcCountEventsWithInteraction; 223 break; 223 break; 224 } 224 } 225 if ( value == "trigger" ) 225 if ( value == "trigger" ) 226 { 226 { 227 eventCountPolicy = CexmcCo 227 eventCountPolicy = CexmcCountEventsWithTrigger; 228 break; 228 break; 229 } 229 } 230 } while ( false ); 230 } while ( false ); 231 runManager->SetEventCountPolicy( e 231 runManager->SetEventCountPolicy( eventCountPolicy ); 232 break; 232 break; 233 } 233 } 234 if ( cmd == setEventDataVerboseLevel ) 234 if ( cmd == setEventDataVerboseLevel ) 235 { 235 { 236 CexmcEventDataVerboseLevel eventD 236 CexmcEventDataVerboseLevel eventDataVerboseLevel( 237 237 CexmcWriteEventDataOnEveryEDT ); 238 do 238 do 239 { 239 { 240 if ( value == "nosave" ) 240 if ( value == "nosave" ) 241 { 241 { 242 eventDataVerboseLevel = Ce 242 eventDataVerboseLevel = CexmcWriteNoEventData; 243 break; 243 break; 244 } 244 } 245 if ( value == "trigger" ) 245 if ( value == "trigger" ) 246 { 246 { 247 eventDataVerboseLevel = Ce 247 eventDataVerboseLevel = CexmcWriteEventDataOnEveryEDT; 248 break; 248 break; 249 } 249 } 250 if ( value == "interaction" ) 250 if ( value == "interaction" ) 251 { 251 { 252 eventDataVerboseLevel = Ce 252 eventDataVerboseLevel = CexmcWriteEventDataOnEveryTPT; 253 break; 253 break; 254 } 254 } 255 } while ( false ); 255 } while ( false ); 256 runManager->SetEventDataVerboseLev 256 runManager->SetEventDataVerboseLevel( eventDataVerboseLevel ); 257 break; 257 break; 258 } 258 } 259 #ifdef CEXMC_USE_PERSISTENCY 259 #ifdef CEXMC_USE_PERSISTENCY 260 if ( cmd == replayEvents ) 260 if ( cmd == replayEvents ) 261 { 261 { 262 runManager->ReplayEvents( 262 runManager->ReplayEvents( 263 G4UIcmdWithAnI 263 G4UIcmdWithAnInteger::GetNewIntValue( value ) ); 264 break; 264 break; 265 } 265 } 266 if ( cmd == seekTo ) 266 if ( cmd == seekTo ) 267 { 267 { 268 runManager->SeekTo( G4UIcmdWithAnI 268 runManager->SeekTo( G4UIcmdWithAnInteger::GetNewIntValue( value ) ); 269 break; 269 break; 270 } 270 } 271 if ( cmd == skipInteractionsWithoutEDT 271 if ( cmd == skipInteractionsWithoutEDT ) 272 { 272 { 273 runManager->SkipInteractionsWithou 273 runManager->SkipInteractionsWithoutEDTonWrite( 274 G4UIcmdWithABo 274 G4UIcmdWithABool::GetNewBoolValue( value ) ); 275 break; 275 break; 276 } 276 } 277 #endif 277 #endif 278 if ( cmd == registerScenePrimitives ) 278 if ( cmd == registerScenePrimitives ) 279 { 279 { 280 runManager->RegisterScenePrimitive 280 runManager->RegisterScenePrimitives(); 281 break; 281 break; 282 } 282 } 283 if ( cmd == validateGdmlFile ) 283 if ( cmd == validateGdmlFile ) 284 { 284 { 285 runManager->SetGdmlFileValidation( 285 runManager->SetGdmlFileValidation( 286 G4UIcmdWithABo 286 G4UIcmdWithABool::GetNewBoolValue( value ) ); 287 break; 287 break; 288 } 288 } 289 } while ( false ); 289 } while ( false ); 290 } 290 } 291 291 292 292