Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B5EmCalorimeterSD.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: B5EmCalorimeterSD.cc 101036 2016-11-04 09:00:23Z gcosmo $
27 //
30 
31 #include "B5EmCalorimeterSD.hh"
32 #include "B5EmCalorimeterHit.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("EMcalorimeterColl");
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 i=0;i<kNofEmCells;i++) {
69  fHitsCollection->insert(new B5EmCalorimeterHit(i));
70  }
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 {
77  auto edep = step->GetTotalEnergyDeposit();
78  if (edep==0.) return true;
79 
80  auto touchable = step->GetPreStepPoint()->GetTouchable();
81  auto physical = touchable->GetVolume();
82  auto copyNo = physical->GetCopyNo();
83 
84  auto hit = (*fHitsCollection)[copyNo];
85  // check if it is first touch
86  if (!(hit->GetLogV())) {
87  // fill volume information
88  hit->SetLogV(physical->GetLogicalVolume());
89  G4AffineTransform transform = touchable->GetHistory()->GetTopTransform();
90  transform.Invert();
91  hit->SetRot(transform.NetRotation());
92  hit->SetPos(transform.NetTranslation());
93  }
94  // add energy deposition
95  hit->AddEdep(edep);
96 
97  return true;
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const XML_Char * name
Definition: expat.h:151
virtual void Initialize(G4HCofThisEvent *HCE)
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
G4ThreeVector NetTranslation() const
Definition of the B5EmCalorimeterSD class.
G4int insert(T *aHit)
const G4VTouchable * GetTouchable() const
G4StepPoint * GetPreStepPoint() const
Definition of the B5EmCalorimeterHit class.
G4AffineTransform & Invert()
bool G4bool
Definition: G4Types.hh:79
Definition: G4Step.hh:76
G4double GetTotalEnergyDeposit() const
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
G4RotationMatrix NetRotation() const
Definition of constants.
B5EmCalorimeterSD(G4String name)
virtual G4VPhysicalVolume * GetVolume(G4int depth=0) const
Definition: G4VTouchable.cc:44
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
virtual G4int GetCopyNo() const =0
virtual ~B5EmCalorimeterSD()
G4CollectionNameVector collectionName
constexpr G4int kNofEmCells
Definition: B5Constants.hh:41
G4THitsCollection< B5EmCalorimeterHit > B5EmCalorimeterHitsCollection