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/Hadr01/src/EventAction.cc << 26 // $Id: EventAction.cc,v 1.6 2010-06-07 05:40:46 perl Exp $ 27 /// \brief Implementation of the EventAction c << 27 // GEANT4 tag $Name: not supported by cvs2svn $ 28 // << 29 // 28 // 30 ////////////////////////////////////////////// 29 ///////////////////////////////////////////////////////////////////////// 31 // 30 // 32 // EventAction 31 // EventAction 33 // 32 // 34 // Created: 21.06.2008 V.Ivanchenko << 33 // Created: 31.04.2006 V.Ivanchenko 35 // 34 // 36 // Modified: 35 // Modified: >> 36 // 04.06.2006 Adoptation of hadr01 (V.Ivanchenko) 37 // 37 // 38 ////////////////////////////////////////////// 38 //////////////////////////////////////////////////////////////////////// 39 // << 39 // 40 40 41 #include "EventAction.hh" 41 #include "EventAction.hh" 42 << 42 #include "G4Event.hh" 43 #include "EventActionMessenger.hh" << 44 #include "HistoManager.hh" 43 #include "HistoManager.hh" >> 44 #include "EventActionMessenger.hh" 45 45 46 #include "G4Event.hh" << 47 #include "G4UImanager.hh" 46 #include "G4UImanager.hh" 48 #include "G4ios.hh" 47 #include "G4ios.hh" 49 48 50 //....oooOO0OOooo........oooOO0OOooo........oo << 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 51 50 52 EventAction::EventAction() : G4UserEventAction << 51 EventAction::EventAction(): >> 52 printModulo(100), >> 53 nSelected(0), >> 54 drawFlag("all"), >> 55 debugStarted(false) 53 { 56 { 54 fEventMessenger = new EventActionMessenger(t << 57 eventMessenger = new EventActionMessenger(this); 55 fUI = G4UImanager::GetUIpointer(); << 58 UI = G4UImanager::GetUIpointer(); >> 59 selectedEvents.clear(); 56 } 60 } 57 61 58 //....oooOO0OOooo........oooOO0OOooo........oo << 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 59 63 60 EventAction::~EventAction() 64 EventAction::~EventAction() 61 { 65 { 62 delete fEventMessenger; << 66 delete eventMessenger; 63 } 67 } 64 68 65 //....oooOO0OOooo........oooOO0OOooo........oo << 69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 66 70 67 void EventAction::BeginOfEventAction(const G4E 71 void EventAction::BeginOfEventAction(const G4Event* evt) 68 { 72 { 69 // New event 73 // New event 70 G4int nEvt = evt->GetEventID(); 74 G4int nEvt = evt->GetEventID(); 71 75 72 if (!fSelectedEvents.empty()) { << 76 if(nSelected>0) { 73 for (auto const& n : fSelectedEvents) { << 77 for(G4int i=0; i<nSelected; i++) { 74 if (nEvt == n) { << 78 if(nEvt == selectedEvents[i]) { 75 fUI->ApplyCommand("/random/saveThisEve << 79 UI->ApplyCommand("/random/saveThisEvent"); 76 fUI->ApplyCommand("/tracking/verbose 2 << 80 UI->ApplyCommand("/tracking/verbose 2"); 77 fDebugStarted = true; << 81 debugStarted = true; 78 break; 82 break; 79 } 83 } 80 } 84 } 81 } 85 } 82 86 83 // Initialize user actions 87 // Initialize user actions 84 if (G4int(nEvt / fPrintModulo) * fPrintModul << 88 HistoManager* man = HistoManager::GetPointer(); 85 G4cout << "EventAction: Event #" << nEvt < << 89 man->BeginOfEvent(); 86 } << 90 if(man->GetVerbose() > 0 || G4int(nEvt/printModulo)*printModulo == nEvt) 87 HistoManager::GetPointer()->BeginOfEvent(); << 91 G4cout << "EventAction: Event # " >> 92 << nEvt << " started" << G4endl; >> 93 88 } 94 } 89 95 90 //....oooOO0OOooo........oooOO0OOooo........oo << 96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 91 97 92 void EventAction::EndOfEventAction(const G4Eve << 98 void EventAction::EndOfEventAction(const G4Event*) 93 { 99 { 94 if (fDebugStarted) { << 100 if(debugStarted) { 95 fUI->ApplyCommand("/tracking/verbose 0"); << 101 UI->ApplyCommand("/tracking/verbose 0"); 96 fDebugStarted = false; << 102 debugStarted = false; 97 G4cout << "EventAction: Event #" << evt->G << 98 } 103 } >> 104 99 HistoManager* man = HistoManager::GetPointer 105 HistoManager* man = HistoManager::GetPointer(); 100 man->EndOfEvent(); << 106 man->EndOfEvent(); 101 if (man->GetVerbose() > 1) { << 107 if(man->GetVerbose() > 1) 102 G4cout << "EventAction: Event #" << evt->G << 108 G4cout << "EventAction: Event ended" << G4endl; 103 } << 104 } 109 } 105 110 106 //....oooOO0OOooo........oooOO0OOooo........oo << 111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 107 112