Loading...
Searching...
No Matches
Run.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//
27/// \file B3/B3b/src/Run.cc
28/// \brief Implementation of the B3b::Run class
29
30#include "Run.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
40namespace B3b
41{
42
43//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
45void Run::RecordEvent(const G4Event* event)
46{
47 if ( fCollID_cryst < 0 ) {
49 = G4SDManager::GetSDMpointer()->GetCollectionID("crystal/edep");
50 //G4cout << " fCollID_cryst: " << fCollID_cryst << G4endl;
51 }
52
53 if ( fCollID_patient < 0 ) {
55 = G4SDManager::GetSDMpointer()->GetCollectionID("patient/dose");
56 //G4cout << " fCollID_patient: " << fCollID_patient << G4endl;
57 }
58
59 G4int evtNb = event->GetEventID();
60
61 if (evtNb%fPrintModulo == 0) {
62 G4cout << G4endl << "---> end of event: " << evtNb << G4endl;
63 }
64
65 //Hits collections
66 //
67 G4HCofThisEvent* HCE = event->GetHCofThisEvent();
68 if(!HCE) return;
69
70 //Energy in crystals : identify 'good events'
71 //
72 const G4double eThreshold = 500*keV;
73 G4int nbOfFired = 0;
74
75 auto evtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID_cryst));
76
77 std::map<G4int,G4double*>::iterator itr;
78 for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
79 G4double edep = *(itr->second);
80 if (edep > eThreshold) nbOfFired++;
81 ///G4int copyNb = (itr->first);
82 ///G4cout << G4endl << " cryst" << copyNb << ": " << edep/keV << " keV ";
83 }
84 if (nbOfFired == 2) fGoodEvents++;
85
86 //Dose deposit in patient
87 //
88 G4double dose = 0.;
89
90 evtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID_patient));
91
92 for (itr = evtMap->GetMap()->begin(); itr != evtMap->GetMap()->end(); itr++) {
93 ///G4int copyNb = (itr->first);
94 dose = *(itr->second);
95 }
96 fSumDose += dose;
97 fStatDose += dose;
98
99 G4Run::RecordEvent(event);
100}
101
102//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103
104void Run::Merge(const G4Run* aRun)
105{
106 const Run* localRun = static_cast<const Run*>(aRun);
107 fGoodEvents += localRun->fGoodEvents;
108 fSumDose += localRun->fSumDose;
109 fStatDose += localRun->fStatDose;
110 G4Run::Merge(aRun);
111}
112
113//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114
115}
116
Run class.
G4StatAnalysis fStatDose
Definition Run.hh:65
G4int fCollID_cryst
Definition Run.hh:60
G4int fGoodEvents
Definition Run.hh:63
void Merge(const G4Run *) override
Definition Run.cc:104
G4double fSumDose
Definition Run.hh:64
G4int fPrintModulo
Definition Run.hh:62
void RecordEvent(const G4Event *) override
Definition Run.cc:45
G4int fCollID_patient
Definition Run.hh:61

Applications | User Support | Publications | Collaboration