[1199] | 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: F02EventAction.cc,v 1.6 2006/06/29 18:27:55 gunter Exp $ |
---|
| 28 | // GEANT4 tag $Name: HEAD $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | |
---|
| 32 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 33 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 34 | |
---|
| 35 | #include "F02EventAction.hh" |
---|
| 36 | |
---|
| 37 | #include "F02RunAction.hh" |
---|
| 38 | |
---|
| 39 | #include "F02CalorHit.hh" |
---|
| 40 | #include "F02EventActionMessenger.hh" |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | #include "G4Event.hh" |
---|
| 44 | #include "G4EventManager.hh" |
---|
| 45 | #include "G4HCofThisEvent.hh" |
---|
| 46 | #include "G4VHitsCollection.hh" |
---|
| 47 | #include "G4SDManager.hh" |
---|
| 48 | #include "G4UImanager.hh" |
---|
| 49 | #include "G4TrajectoryContainer.hh" |
---|
| 50 | #include "G4Trajectory.hh" |
---|
| 51 | #include "G4VVisManager.hh" |
---|
| 52 | #include "G4ios.hh" |
---|
| 53 | #include "G4UnitsTable.hh" |
---|
| 54 | #include "Randomize.hh" |
---|
| 55 | |
---|
| 56 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 57 | |
---|
| 58 | F02EventAction::F02EventAction(F02RunAction* F02RA) |
---|
| 59 | :calorimeterCollID(-1),eventMessenger(NULL), |
---|
| 60 | verboselevel(0),runaction(F02RA),drawFlag("all"),printModulo(10000) |
---|
| 61 | { |
---|
| 62 | eventMessenger = new F02EventActionMessenger(this); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 66 | |
---|
| 67 | F02EventAction::~F02EventAction() |
---|
| 68 | { |
---|
| 69 | delete eventMessenger; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 73 | |
---|
| 74 | void F02EventAction::BeginOfEventAction(const G4Event* evt) |
---|
| 75 | { |
---|
| 76 | G4int evtNb = evt->GetEventID(); |
---|
| 77 | if (evtNb%printModulo == 0) |
---|
| 78 | G4cout << "\n---> Begin of Event: " << evtNb << G4endl; |
---|
| 79 | |
---|
| 80 | if(verboselevel>1) |
---|
| 81 | G4cout << "<<< Event " << evtNb << " started." << G4endl; |
---|
| 82 | |
---|
| 83 | if (calorimeterCollID==-1) |
---|
| 84 | { |
---|
| 85 | G4SDManager * SDman = G4SDManager::GetSDMpointer(); |
---|
| 86 | calorimeterCollID = SDman->GetCollectionID("CalCollection"); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | nstep = 0. ; |
---|
| 90 | nstepCharged = 0. ; |
---|
| 91 | nstepNeutral = 0. ; |
---|
| 92 | Nch = 0. ; |
---|
| 93 | Nne = 0. ; |
---|
| 94 | NE=0.; |
---|
| 95 | NP=0.; |
---|
| 96 | Transmitted=0.; |
---|
| 97 | Reflected =0.; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 101 | |
---|
| 102 | void F02EventAction::EndOfEventAction(const G4Event* evt) |
---|
| 103 | { |
---|
| 104 | G4HCofThisEvent* HCE = evt->GetHCofThisEvent(); |
---|
| 105 | F02CalorHitsCollection* CHC = NULL; |
---|
| 106 | |
---|
| 107 | if (HCE) CHC = (F02CalorHitsCollection*)(HCE->GetHC(calorimeterCollID)); |
---|
| 108 | |
---|
| 109 | if (CHC) |
---|
| 110 | { |
---|
| 111 | int n_hit = CHC->entries(); |
---|
| 112 | // if(verboselevel==2) |
---|
| 113 | // G4cout << " " << n_hit |
---|
| 114 | // << " hits are stored in F02CalorHitsCollection." << G4endl; |
---|
| 115 | |
---|
| 116 | G4double totEAbs=0, totLAbs=0; |
---|
| 117 | |
---|
| 118 | for (int i=0;i<n_hit;i++) |
---|
| 119 | { |
---|
| 120 | totEAbs += (*CHC)[i]->GetEdepAbs(); |
---|
| 121 | totLAbs += (*CHC)[i]->GetTrakAbs(); |
---|
| 122 | } |
---|
| 123 | if(verboselevel==2) |
---|
| 124 | { |
---|
| 125 | G4cout << " Absorber: total energy: " << std::setw(7) |
---|
| 126 | << G4BestUnit(totEAbs,"Energy") |
---|
| 127 | << " total track length: " << std::setw(7) |
---|
| 128 | << G4BestUnit(totLAbs,"Length") << G4endl; |
---|
| 129 | } |
---|
| 130 | // count event, add deposits to the sum ... |
---|
| 131 | |
---|
| 132 | runaction->CountEvent() ; |
---|
| 133 | runaction->AddTrackLength(totLAbs) ; |
---|
| 134 | runaction->AddnStepsCharged(nstepCharged) ; |
---|
| 135 | runaction->AddnStepsNeutral(nstepNeutral) ; |
---|
| 136 | |
---|
| 137 | if(verboselevel==2) |
---|
| 138 | { |
---|
| 139 | G4cout << " Ncharged=" << Nch << " , Nneutral=" << Nne << G4endl; |
---|
| 140 | } |
---|
| 141 | runaction->CountParticles(Nch,Nne); |
---|
| 142 | runaction->AddEP(NE,NP); |
---|
| 143 | runaction->AddTrRef(Transmitted,Reflected) ; |
---|
| 144 | runaction->AddEdeps(totEAbs) ; |
---|
| 145 | runaction->FillEn(totEAbs) ; |
---|
| 146 | |
---|
| 147 | nstep=nstepCharged+nstepNeutral ; |
---|
| 148 | runaction->FillNbOfSteps(nstep); |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance(); |
---|
| 152 | |
---|
| 153 | if(pVVisManager) |
---|
| 154 | { |
---|
| 155 | G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer(); |
---|
| 156 | G4int n_trajectories = 0; |
---|
| 157 | |
---|
| 158 | if (trajectoryContainer) n_trajectories = trajectoryContainer->entries(); |
---|
| 159 | |
---|
| 160 | for(G4int i=0; i<n_trajectories; i++) |
---|
| 161 | { |
---|
| 162 | G4Trajectory* trj = (G4Trajectory *)((*(evt->GetTrajectoryContainer()))[i]); |
---|
| 163 | |
---|
| 164 | if (drawFlag == "all") |
---|
| 165 | { |
---|
| 166 | trj->DrawTrajectory(50); |
---|
| 167 | } |
---|
| 168 | else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.)) |
---|
| 169 | { |
---|
| 170 | trj->DrawTrajectory(50); |
---|
| 171 | } |
---|
| 172 | } |
---|
| 173 | } |
---|
| 174 | if(verboselevel>0) |
---|
| 175 | { |
---|
| 176 | G4cout << "<<< Event " << evt->GetEventID() << " ended." << G4endl; |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | //save rndm status |
---|
| 180 | if (runaction->GetRndmFreq() == 2) |
---|
| 181 | { |
---|
| 182 | HepRandom::saveEngineStatus("endOfEvent.rndm"); |
---|
| 183 | G4int evtNb = evt->GetEventID(); |
---|
| 184 | |
---|
| 185 | if (evtNb%printModulo == 0) |
---|
| 186 | { |
---|
| 187 | G4cout << "\n---> End of Event: " << evtNb << G4endl; |
---|
| 188 | HepRandom::showEngineStatus(); |
---|
| 189 | } |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 194 | |
---|
| 195 | G4int F02EventAction::GetEventno() |
---|
| 196 | { |
---|
| 197 | G4int evno = fpEventManager->GetConstCurrentEvent()->GetEventID() ; |
---|
| 198 | return evno ; |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 202 | |
---|
| 203 | void F02EventAction::setEventVerbose(G4int level) |
---|
| 204 | { |
---|
| 205 | verboselevel = level ; |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 209 | |
---|
| 210 | void F02EventAction::CountStepsCharged() |
---|
| 211 | { |
---|
| 212 | nstepCharged += 1. ; |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 216 | |
---|
| 217 | void F02EventAction::CountStepsNeutral() |
---|
| 218 | { |
---|
| 219 | nstepNeutral += 1. ; |
---|
| 220 | } |
---|
| 221 | |
---|
| 222 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 223 | |
---|
| 224 | void F02EventAction::AddCharged() |
---|
| 225 | { |
---|
| 226 | Nch += 1.; |
---|
| 227 | } |
---|
| 228 | |
---|
| 229 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 230 | |
---|
| 231 | void F02EventAction::AddNeutral() |
---|
| 232 | { |
---|
| 233 | Nne += 1.; |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 237 | |
---|
| 238 | void F02EventAction::AddE() |
---|
| 239 | { |
---|
| 240 | NE += 1.; |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 244 | |
---|
| 245 | void F02EventAction::AddP() |
---|
| 246 | { |
---|
| 247 | NP += 1.; |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 251 | |
---|
| 252 | void F02EventAction::SetTr() |
---|
| 253 | { |
---|
| 254 | Transmitted = 1.; |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 258 | |
---|
| 259 | void F02EventAction::SetRef() |
---|
| 260 | { |
---|
| 261 | Reflected = 1.; |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 265 | |
---|
| 266 | |
---|
| 267 | |
---|
| 268 | |
---|
| 269 | |
---|
| 270 | |
---|
| 271 | |
---|
| 272 | |
---|
| 273 | |
---|
| 274 | |
---|
| 275 | |
---|
| 276 | |
---|