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 // $Id$ 29 // 30 // 30 ////////////////////////////////////////////// 31 ///////////////////////////////////////////////////////////////////////// 31 // 32 // 32 // EventAction 33 // EventAction 33 // 34 // 34 // Created: 31.04.2006 V.Ivanchenko 35 // Created: 31.04.2006 V.Ivanchenko 35 // 36 // 36 // Modified: 37 // Modified: 37 // 04.06.2006 Adoptation of hadr01 (V.Ivanchen 38 // 04.06.2006 Adoptation of hadr01 (V.Ivanchenko) 38 // 39 // 39 ////////////////////////////////////////////// 40 //////////////////////////////////////////////////////////////////////// 40 // << 41 // 41 42 42 #include "EventAction.hh" 43 #include "EventAction.hh" 43 << 44 #include "G4Event.hh" 44 #include "EventActionMessenger.hh" << 45 #include "HistoManager.hh" 45 #include "HistoManager.hh" >> 46 #include "EventActionMessenger.hh" 46 47 47 #include "G4Event.hh" << 48 #include "G4PhysicalConstants.hh" << 49 #include "G4SystemOfUnits.hh" << 50 #include "G4UImanager.hh" 48 #include "G4UImanager.hh" 51 #include "G4ios.hh" 49 #include "G4ios.hh" 52 50 53 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 54 52 55 EventAction::EventAction() << 53 EventAction::EventAction(): 56 : G4UserEventAction(), fEventMessenger(0), f << 54 printModulo(100), >> 55 nSelected(0), >> 56 drawFlag("all"), >> 57 debugStarted(false) 57 { 58 { 58 fEventMessenger = new EventActionMessenger(t << 59 eventMessenger = new EventActionMessenger(this); >> 60 UI = G4UImanager::GetUIpointer(); >> 61 selectedEvents.clear(); 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 eventMessenger; 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(nSelected>0) { 76 for (G4int i = 0; i < fNSelected; i++) { << 79 for(G4int i=0; i<nSelected; i++) { 77 if (nEvt == fSelectedEvents[i]) { << 80 if(nEvt == selectedEvents[i]) { 78 G4UImanager::GetUIpointer()->ApplyComm << 81 UI->ApplyCommand("/random/saveThisEvent"); 79 G4UImanager::GetUIpointer()->ApplyComm << 82 UI->ApplyCommand("/tracking/verbose 2"); 80 fDebugStarted = true; << 83 debugStarted = 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 || G4int(nEvt/printModulo)*printModulo == nEvt) 90 G4cout << "EventAction: Event # " << nEvt << 93 G4cout << "EventAction: Event # " 91 } << 94 << nEvt << " started" << G4endl; >> 95 92 } 96 } 93 97 94 //....oooOO0OOooo........oooOO0OOooo........oo 98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 95 99 96 void EventAction::EndOfEventAction(const G4Eve 100 void EventAction::EndOfEventAction(const G4Event*) 97 { 101 { 98 if (fDebugStarted) { << 102 if(debugStarted) { 99 G4UImanager::GetUIpointer()->ApplyCommand( << 103 UI->ApplyCommand("/tracking/verbose 0"); 100 fDebugStarted = false; << 104 debugStarted = false; 101 } 105 } 102 106 103 HistoManager* man = HistoManager::GetPointer 107 HistoManager* man = HistoManager::GetPointer(); 104 man->EndOfEvent(); << 108 man->EndOfEvent(); 105 if (man->GetVerbose() > 1) G4cout << "EventA << 109 if(man->GetVerbose() > 1) 106 } << 110 G4cout << "EventAction: Event ended" << G4endl; 107 << 108 //....oooOO0OOooo........oooOO0OOooo........oo << 109 << 110 void EventAction::AddEventToDebug(G4int val) << 111 { << 112 fSelectedEvents.push_back(val); << 113 fNSelected++; << 114 } 111 } 115 112 116 //....oooOO0OOooo........oooOO0OOooo........oo 113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 117 114