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 /// \file hadronic/Hadr02/src/EventAction.cc 26 /// \file hadronic/Hadr02/src/EventAction.cc 27 /// \brief Implementation of the EventAction c 27 /// \brief Implementation of the EventAction class 28 // 28 // 29 // 29 // 30 ////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////// 31 // 31 // 32 // EventAction 32 // EventAction 33 // 33 // 34 // Created: 31.04.2006 V.Ivanchenko 34 // Created: 31.04.2006 V.Ivanchenko 35 // 35 // 36 // Modified: 36 // Modified: 37 // 04.06.2006 Adoptation of hadr01 (V.Ivanchen 37 // 04.06.2006 Adoptation of hadr01 (V.Ivanchenko) 38 // 38 // 39 ////////////////////////////////////////////// 39 //////////////////////////////////////////////////////////////////////// 40 // << 40 // 41 41 42 #include "EventAction.hh" 42 #include "EventAction.hh" 43 << 44 #include "EventActionMessenger.hh" << 45 #include "HistoManager.hh" << 46 << 47 #include "G4Event.hh" 43 #include "G4Event.hh" >> 44 #include "HistoManager.hh" >> 45 #include "EventActionMessenger.hh" 48 #include "G4PhysicalConstants.hh" 46 #include "G4PhysicalConstants.hh" 49 #include "G4SystemOfUnits.hh" 47 #include "G4SystemOfUnits.hh" >> 48 50 #include "G4UImanager.hh" 49 #include "G4UImanager.hh" 51 #include "G4ios.hh" 50 #include "G4ios.hh" 52 51 53 //....oooOO0OOooo........oooOO0OOooo........oo 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 54 53 55 EventAction::EventAction() 54 EventAction::EventAction() 56 : G4UserEventAction(), fEventMessenger(0), f << 55 : G4UserEventAction(), >> 56 fEventMessenger(0), >> 57 fSelectedEvents(), >> 58 fNSelected(0), >> 59 fDebugStarted(false) 57 { 60 { 58 fEventMessenger = new EventActionMessenger(t 61 fEventMessenger = new EventActionMessenger(this); 59 } 62 } 60 63 61 //....oooOO0OOooo........oooOO0OOooo........oo 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 62 65 63 EventAction::~EventAction() 66 EventAction::~EventAction() 64 { 67 { 65 delete fEventMessenger; 68 delete fEventMessenger; 66 } 69 } 67 70 68 //....oooOO0OOooo........oooOO0OOooo........oo 71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 69 72 70 void EventAction::BeginOfEventAction(const G4E 73 void EventAction::BeginOfEventAction(const G4Event* evt) 71 { 74 { 72 // New event 75 // New event 73 G4int nEvt = evt->GetEventID(); 76 G4int nEvt = evt->GetEventID(); 74 77 75 if (fNSelected > 0) { << 78 if (fNSelected>0) { 76 for (G4int i = 0; i < fNSelected; i++) { << 79 for(G4int i=0; i<fNSelected; i++) { 77 if (nEvt == fSelectedEvents[i]) { 80 if (nEvt == fSelectedEvents[i]) { 78 G4UImanager::GetUIpointer()->ApplyComm 81 G4UImanager::GetUIpointer()->ApplyCommand("/random/saveThisEvent"); 79 G4UImanager::GetUIpointer()->ApplyComm 82 G4UImanager::GetUIpointer()->ApplyCommand("/tracking/verbose 2"); 80 fDebugStarted = true; 83 fDebugStarted = true; 81 break; 84 break; 82 } 85 } 83 } 86 } 84 } 87 } 85 88 86 // Initialize user actions 89 // Initialize user actions 87 HistoManager* man = HistoManager::GetPointer 90 HistoManager* man = HistoManager::GetPointer(); 88 man->BeginOfEvent(); << 91 man->BeginOfEvent(); 89 if (man->GetVerbose() > 0) { << 92 if ( man->GetVerbose() > 0 ) { 90 G4cout << "EventAction: Event # " << nEvt 93 G4cout << "EventAction: Event # " << nEvt << " started" << G4endl; 91 } << 94 } 92 } 95 } 93 96 94 //....oooOO0OOooo........oooOO0OOooo........oo 97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 95 98 96 void EventAction::EndOfEventAction(const G4Eve 99 void EventAction::EndOfEventAction(const G4Event*) 97 { 100 { 98 if (fDebugStarted) { 101 if (fDebugStarted) { 99 G4UImanager::GetUIpointer()->ApplyCommand( 102 G4UImanager::GetUIpointer()->ApplyCommand("/tracking/verbose 0"); 100 fDebugStarted = false; 103 fDebugStarted = false; 101 } 104 } 102 105 103 HistoManager* man = HistoManager::GetPointer 106 HistoManager* man = HistoManager::GetPointer(); 104 man->EndOfEvent(); << 107 man->EndOfEvent(); 105 if (man->GetVerbose() > 1) G4cout << "EventA << 108 if(man->GetVerbose() > 1) >> 109 G4cout << "EventAction: Event ended" << G4endl; 106 } 110 } 107 111 108 //....oooOO0OOooo........oooOO0OOooo........oo 112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 109 113 110 void EventAction::AddEventToDebug(G4int val) << 114 void EventAction::AddEventToDebug(G4int val) 111 { 115 { 112 fSelectedEvents.push_back(val); 116 fSelectedEvents.push_back(val); 113 fNSelected++; 117 fNSelected++; 114 } 118 } 115 119 116 //....oooOO0OOooo........oooOO0OOooo........oo 120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 117 121