Geant4  10.02
B3bRun.cc
Go to the documentation of this file.
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 // $Id: B3bRun.cc 68058 2013-03-13 14:47:43Z gcosmo $
27 //
30 
31 #include "B3bRun.hh"
32 
33 #include "G4RunManager.hh"
34 #include "G4Event.hh"
35 
36 #include "G4SDManager.hh"
37 #include "G4HCofThisEvent.hh"
38 #include "G4THitsMap.hh"
39 #include "G4SystemOfUnits.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
44  : G4Run(),
45  fCollID_cryst(-1),
46  fCollID_patient(-1),
47  fPrintModulo(10000),
48  fGoodEvents(0),
49  fSumDose(0.)
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 
113  G4Run::RecordEvent(event);
114 }
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117 
118 void B3bRun::Merge(const G4Run* aRun)
119 {
120  const B3bRun* localRun = static_cast<const B3bRun*>(aRun);
121  fGoodEvents += localRun->fGoodEvents;
122  fSumDose += localRun->fSumDose;
123 
124  G4Run::Merge(aRun);
125 }
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int fGoodEvents
Definition: B3bRun.hh:59
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
G4int fCollID_cryst
Definition: B3bRun.hh:56
G4VHitsCollection * GetHC(G4int i)
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
G4int fPrintModulo
Definition: B3bRun.hh:58
virtual ~B3bRun()
Definition: B3bRun.cc:54
int G4int
Definition: G4Types.hh:78
B3bRun()
Definition: B3bRun.cc:43
Run class.
Definition: B3bRun.hh:42
G4GLOB_DLL std::ostream G4cout
Definition: G4Run.hh:46
Definition of the B3bRun class.
virtual void Merge(const G4Run *)
Definition: B3bRun.cc:118
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
virtual void RecordEvent(const G4Event *)
Definition: G4Run.cc:51
std::map< G4int, T * > * GetMap() const
Definition: G4THitsMap.hh:68
#define G4endl
Definition: G4ios.hh:61
G4double fSumDose
Definition: B3bRun.hh:60
static const double keV
Definition: G4SIunits.hh:213
double G4double
Definition: G4Types.hh:76
virtual void RecordEvent(const G4Event *)
Definition: B3bRun.cc:59
G4int fCollID_patient
Definition: B3bRun.hh:57