ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B3bRun.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file B3bRun.cc
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 //
29 
30 #include "B3bRun.hh"
31 
32 #include "G4RunManager.hh"
33 #include "G4Event.hh"
34 
35 #include "G4SDManager.hh"
36 #include "G4HCofThisEvent.hh"
37 #include "G4THitsMap.hh"
38 #include "G4SystemOfUnits.hh"
39 
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41 
43  : G4Run(),
44  fCollID_cryst(-1),
45  fCollID_patient(-1),
46  fPrintModulo(10000),
47  fGoodEvents(0),
48  fSumDose(0.),
49  fStatDose()
50 { }
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 { }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
59 void B3bRun::RecordEvent(const G4Event* event)
60 {
61  if ( fCollID_cryst < 0 ) {
63  = G4SDManager::GetSDMpointer()->GetCollectionID("crystal/edep");
64  //G4cout << " fCollID_cryst: " << fCollID_cryst << G4endl;
65  }
66 
67  if ( fCollID_patient < 0 ) {
69  = G4SDManager::GetSDMpointer()->GetCollectionID("patient/dose");
70  //G4cout << " fCollID_patient: " << fCollID_patient << G4endl;
71  }
72 
73  G4int evtNb = event->GetEventID();
74 
75  if (evtNb%fPrintModulo == 0) {
76  G4cout << G4endl << "---> end of event: " << evtNb << G4endl;
77  }
78 
79  //Hits collections
80  //
81  G4HCofThisEvent* HCE = event->GetHCofThisEvent();
82  if(!HCE) return;
83 
84  //Energy in crystals : identify 'good events'
85  //
86  const G4double eThreshold = 500*keV;
87  G4int nbOfFired = 0;
88 
89  G4THitsMap<G4double>* evtMap =
90  static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID_cryst));
91 
92  std::map<G4int,G4double*>::iterator itr;
93  for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
94  G4double edep = *(itr->second);
95  if (edep > eThreshold) nbOfFired++;
98  }
99  if (nbOfFired == 2) fGoodEvents++;
100 
101  //Dose deposit in patient
102  //
103  G4double dose = 0.;
104 
105  evtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID_patient));
106 
107  for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
109  dose = *(itr->second);
110  }
111  fSumDose += dose;
112  fStatDose += dose;
113 
114  G4Run::RecordEvent(event);
115 }
116 
117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118 
119 void B3bRun::Merge(const G4Run* aRun)
120 {
121  const B3bRun* localRun = static_cast<const B3bRun*>(aRun);
122  fGoodEvents += localRun->fGoodEvents;
123  fSumDose += localRun->fSumDose;
124  fStatDose += localRun->fStatDose;
125  G4Run::Merge(aRun);
126 }
127 
128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......