[807] | 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 | // $Id: F03EventAction.cc,v 1.6 2006/06/29 17:19:28 gunter Exp $ |
---|
| 28 | // GEANT4 tag $Name: $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | |
---|
| 32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 33 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 34 | |
---|
| 35 | #include "F03EventAction.hh" |
---|
| 36 | |
---|
| 37 | #include "F03RunAction.hh" |
---|
| 38 | |
---|
| 39 | #include "F03CalorHit.hh" |
---|
| 40 | #include "F03EventActionMessenger.hh" |
---|
| 41 | |
---|
| 42 | #include "G4Event.hh" |
---|
| 43 | #include "G4EventManager.hh" |
---|
| 44 | #include "G4HCofThisEvent.hh" |
---|
| 45 | #include "G4VHitsCollection.hh" |
---|
| 46 | #include "G4SDManager.hh" |
---|
| 47 | #include "G4TrajectoryContainer.hh" |
---|
| 48 | #include "G4Trajectory.hh" |
---|
| 49 | #include "G4VVisManager.hh" |
---|
| 50 | #include "G4ios.hh" |
---|
| 51 | #include "G4UnitsTable.hh" |
---|
| 52 | #include "Randomize.hh" |
---|
| 53 | |
---|
| 54 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 55 | |
---|
| 56 | F03EventAction::F03EventAction(F03RunAction* F03RA) |
---|
| 57 | : calorimeterCollID(-1), eventMessenger(0), |
---|
| 58 | runaction(F03RA), verboselevel(0), |
---|
| 59 | drawFlag("all"), printModulo(10000) |
---|
| 60 | { |
---|
| 61 | eventMessenger = new F03EventActionMessenger(this); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 65 | |
---|
| 66 | F03EventAction::~F03EventAction() |
---|
| 67 | { |
---|
| 68 | delete eventMessenger; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 72 | |
---|
| 73 | void F03EventAction::BeginOfEventAction(const G4Event* evt) |
---|
| 74 | { |
---|
| 75 | G4int evtNb = evt->GetEventID(); |
---|
| 76 | if (evtNb%printModulo == 0) |
---|
| 77 | G4cout << "\n---> Begin of Event: " << evtNb << G4endl; |
---|
| 78 | |
---|
| 79 | if(verboselevel>1) |
---|
| 80 | G4cout << "<<< Event " << evtNb << " started." << G4endl; |
---|
| 81 | |
---|
| 82 | if (calorimeterCollID==-1) |
---|
| 83 | { |
---|
| 84 | G4SDManager * SDman = G4SDManager::GetSDMpointer(); |
---|
| 85 | calorimeterCollID = SDman->GetCollectionID("CalCollection"); |
---|
| 86 | } |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 90 | |
---|
| 91 | void F03EventAction::EndOfEventAction(const G4Event* evt) |
---|
| 92 | { |
---|
| 93 | G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); |
---|
| 94 | |
---|
| 95 | if(pVVisManager) |
---|
| 96 | { |
---|
| 97 | G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer(); |
---|
| 98 | G4int n_trajectories = 0; |
---|
| 99 | if (trajectoryContainer) n_trajectories = trajectoryContainer->entries(); |
---|
| 100 | for(G4int i=0; i<n_trajectories; i++) |
---|
| 101 | { G4Trajectory* trj = (G4Trajectory *)((*(evt->GetTrajectoryContainer()))[i]); |
---|
| 102 | if (drawFlag == "all") trj->DrawTrajectory(50); |
---|
| 103 | else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.)) |
---|
| 104 | trj->DrawTrajectory(50); |
---|
| 105 | } |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | if(verboselevel>0) |
---|
| 109 | G4cout << "<<< Event " << evt->GetEventID() << " ended." << G4endl; |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | //save rndm status |
---|
| 113 | if (runaction->GetRndmFreq() == 2) |
---|
| 114 | { |
---|
| 115 | CLHEP::HepRandom::saveEngineStatus("endOfEvent.rndm"); |
---|
| 116 | G4int evtNb = evt->GetEventID(); |
---|
| 117 | if (evtNb%printModulo == 0) |
---|
| 118 | { |
---|
| 119 | G4cout << "\n---> End of Event: " << evtNb << G4endl; |
---|
| 120 | CLHEP::HepRandom::showEngineStatus(); |
---|
| 121 | } |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 126 | |
---|
| 127 | G4int F03EventAction::GetEventno() |
---|
| 128 | { |
---|
| 129 | G4int evno = fpEventManager->GetConstCurrentEvent()->GetEventID() ; |
---|
| 130 | return evno ; |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 134 | |
---|
| 135 | void F03EventAction::setEventVerbose(G4int level) |
---|
| 136 | { |
---|
| 137 | verboselevel = level ; |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|