Loading...
Searching...
No Matches
F01CalorimeterSD.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/// \file field/field01/src/F01CalorimeterSD.cc
27/// \brief Implementation of the F01CalorimeterSD class
28//
29//
30//
31//
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34
35#include "F01CalorimeterSD.hh"
36
37#include "F01CalorHit.hh"
39
40#include "G4VPhysicalVolume.hh"
41#include "G4Step.hh"
42#include "G4VTouchable.hh"
43#include "G4TouchableHistory.hh"
44#include "G4SDManager.hh"
45
46//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47
51 fDetector(det),
52 fHitID(new G4int[500])
53{
54 collectionName.insert("CalCollection");
55}
56
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58
63
64//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65
67{
69 (SensitiveDetectorName,collectionName[0]);
70 for (G4int j=0;j<1; j++) {fHitID[j] = -1;};
71}
72
73//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74
76{
77 G4double edep = step->GetTotalEnergyDeposit();
78 G4double stepl = 0.;
79
80 stepl = step->GetStepLength();
81
82 if ((edep == 0.) && (stepl == 0.) ) return false;
83
84 auto theTouchable
85 = (G4TouchableHistory*)(step->GetPreStepPoint()->GetTouchable());
86
87 G4VPhysicalVolume* physVol = theTouchable->GetVolume();
88
89 G4int number = 0;
90 if (fHitID[number]==-1)
91 {
92 auto calHit = new F01CalorHit();
93 if (physVol == fDetector->GetAbsorber()) calHit->AddAbs(edep,stepl);
94 fHitID[number] = fCalCollection->insert(calHit) - 1;
95 if (verboseLevel>0)
96 G4cout << " New Calorimeter Hit on F01: " << number << G4endl;
97 }
98 else
99 {
100 if (physVol == fDetector->GetAbsorber())
101 (*fCalCollection)[fHitID[number]]->AddAbs(edep,stepl);
102 if (verboseLevel>0)
103 G4cout << " Energy added to F01: " << number << G4endl;
104 }
105 return true;
106}
107
108//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109
111{
112 static G4int hcID = -1;
113 if (hcID<0)
114 { hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
115 hce->AddHitsCollection(hcID,fCalCollection);
116}
117
118//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Definition of the F01CalorHit class.
G4THitsCollection< F01CalorHit > F01CalorHitsCollection
Definition of the F01CalorimeterSD class.
Definition of the F01DetectorConstruction class.
F01CalorHitsCollection * fCalCollection
void Initialize(G4HCofThisEvent *) override
G4bool ProcessHits(G4Step *, G4TouchableHistory *) override
~F01CalorimeterSD() override
F01CalorimeterSD(G4String, F01DetectorConstruction *)
void EndOfEvent(G4HCofThisEvent *) override
F01DetectorConstruction * fDetector
const G4VPhysicalVolume * GetAbsorber()

Applications | User Support | Publications | Collaboration