Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B3Run.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: B3Run.cc 68058 2013-03-13 14:47:43Z gcosmo $
27 //
28 /// \file B3Run.cc
29 /// \brief Implementation of the B3Run class
30 
31 #include "B3Run.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 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56 { }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
60 void B3Run::RecordEvent(const G4Event* event)
61 {
62  if ( fCollID_cryst < 0 ) {
63  fCollID_cryst
64  = G4SDManager::GetSDMpointer()->GetCollectionID("crystal/edep");
65  //G4cout << " fCollID_cryst: " << fCollID_cryst << G4endl;
66  }
67 
68  if ( fCollID_patient < 0 ) {
69  fCollID_patient
70  = G4SDManager::GetSDMpointer()->GetCollectionID("patient/dose");
71  //G4cout << " fCollID_patient: " << fCollID_patient << G4endl;
72  }
73 
74  G4int evtNb = event->GetEventID();
75 
76  if (evtNb%fPrintModulo == 0) {
77  G4cout << "\n---> end of event: " << evtNb << G4endl;
78  }
79 
80  //Hits collections
81  //
82  G4HCofThisEvent* HCE = event->GetHCofThisEvent();
83  if(!HCE) return;
84 
85  //Energy in crystals : identify 'good events'
86  //
87  const G4double eThreshold = 500*keV;
88  G4int nbOfFired = 0;
89 
90  G4THitsMap<G4double>* evtMap =
91  static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID_cryst));
92 
93  std::map<G4int,G4double*>::iterator itr;
94  for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
95  G4double edep = *(itr->second);
96  if (edep > eThreshold) nbOfFired++;
97  ///G4int copyNb = (itr->first);
98  ///G4cout << "\n cryst" << copyNb << ": " << edep/keV << " keV ";
99  }
100  if (nbOfFired == 2) fGoodEvents++;
101 
102  //Dose deposit in patient
103  //
104  G4double dose = 0.;
105 
106  evtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID_patient));
107 
108  for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
109  ///G4int copyNb = (itr->first);
110  dose = *(itr->second);
111  }
112  fSumDose += dose;
113 
114  G4Run::RecordEvent(event);
115 }
116 
117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118 
119 void B3Run::Merge(const G4Run* aRun)
120 {
121  const B3Run* localRun = static_cast<const B3Run*>(aRun);
122  fGoodEvents += localRun->fGoodEvents;
123  fSumDose += localRun->fSumDose;
124 
125  G4Run::Merge(aRun);
126 }
127 
128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
virtual void Merge(const G4Run *)
Definition: G4Run.cc:54
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
B3Run()
Definition: B3Run.cc:43
Definition: G4Run.hh:46
virtual void Merge(const G4Run *)
Definition: B3Run.cc:119
Definition: B3Run.hh:42
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
virtual ~B3Run()
Definition: B3Run.cc:55
double G4double
Definition: G4Types.hh:76
virtual void RecordEvent(const G4Event *)
Definition: B3Run.cc:60
Definition of the B3Run class.