Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B5HadCalorimeterSD.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: B5HadCalorimeterSD.cc 101036 2016-11-04 09:00:23Z gcosmo $
27 //
30 
31 #include "B5HadCalorimeterSD.hh"
32 #include "B5HadCalorimeterHit.hh"
33 #include "B5Constants.hh"
34 
35 #include "G4HCofThisEvent.hh"
36 #include "G4TouchableHistory.hh"
37 #include "G4Track.hh"
38 #include "G4Step.hh"
39 #include "G4SDManager.hh"
40 #include "G4ios.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
45 : G4VSensitiveDetector(name),
46  fHitsCollection(nullptr), fHCID(-1)
47 {
48  collectionName.insert("HadCalorimeterColl");
49 }
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 {}
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 {
60  fHitsCollection
62  if (fHCID<0) {
63  fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
64  }
65  hce->AddHitsCollection(fHCID,fHitsCollection);
66 
67  // fill calorimeter hits with zero energy deposition
68  for (auto column=0;column<kNofHadColumns;column++) {
69  for (auto row=0;row<kNofHadRows;row++) {
70  fHitsCollection->insert(new B5HadCalorimeterHit());
71  }
72  }
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79  auto edep = step->GetTotalEnergyDeposit();
80  if (edep==0.) return true;
81 
82  auto touchable = step->GetPreStepPoint()->GetTouchable();
83  auto rowNo = touchable->GetCopyNumber(2);
84  auto columnNo = touchable->GetCopyNumber(3);
85  auto hitID = kNofHadRows*columnNo+rowNo;
86  auto hit = (*fHitsCollection)[hitID];
87 
88  // check if it is first touch
89  if (hit->GetColumnID()<0) {
90  hit->SetColumnID(columnNo);
91  hit->SetRowID(rowNo);
92  auto depth = touchable->GetHistory()->GetDepth();
93  auto transform = touchable->GetHistory()->GetTransform(depth-2);
94  transform.Invert();
95  hit->SetRot(transform.NetRotation());
96  hit->SetPos(transform.NetTranslation());
97  }
98  // add energy deposition
99  hit->AddEdep(edep);
100 
101  return true;
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Definition of the B5HadCalorimeterSD class.
const XML_Char * name
Definition: expat.h:151
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
virtual void Initialize(G4HCofThisEvent *HCE)
G4int insert(T *aHit)
const G4VTouchable * GetTouchable() const
G4int GetCopyNumber(G4int depth=0) const
G4StepPoint * GetPreStepPoint() const
constexpr G4int kNofHadRows
Definition: B5Constants.hh:43
bool G4bool
Definition: G4Types.hh:79
B5HadCalorimeterSD(G4String name)
constexpr G4int kNofHadColumns
Definition: B5Constants.hh:42
Definition: G4Step.hh:76
G4THitsCollection< B5HadCalorimeterHit > B5HadCalorimeterHitsCollection
G4double GetTotalEnergyDeposit() const
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
Definition of constants.
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
G4CollectionNameVector collectionName
Definition of the B5HadCalorimeterHit class.