Loading...
Searching...
No Matches
Par04ParallelFullSensitiveDetector.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//
27#include <CLHEP/Vector/Rotation.h> // for HepRotation
28#include <CLHEP/Vector/ThreeVector.h> // for Hep3Vector
29#include <cmath> // for floor
30#include <G4CollectionNameVector.hh> // for G4CollectionNameVector
31#include <G4FastHit.hh> // for G4FastHit
32#include <G4FastTrack.hh> // for G4FastTrack
33#include <G4RotationMatrix.hh> // for G4RotationMatrix
34#include <G4StepPoint.hh> // for G4StepPoint
35#include <G4THitsCollection.hh> // for G4THitsCollection
36#include <G4ThreeVector.hh> // for G4ThreeVector
37#include <G4VSensitiveDetector.hh> // for G4VSensitiveDetector
38#include <G4VUserEventInformation.hh> // for G4VUserEventInformation
39#include <cstddef> // for size_t
40#include <vector> // for vector
41#include "G4Event.hh" // for G4Event
42#include "G4EventManager.hh" // for G4EventManager
43#include "G4HCofThisEvent.hh" // for G4HCofThisEvent
44#include "G4SDManager.hh" // for G4SDManager
45#include "G4Step.hh" // for G4Step
46#include "G4Track.hh" // for G4Track
47#include "Par04EventInformation.hh" // for Par04EventInformation
48#include "Par04Hit.hh" // for Par04Hit, Par04HitsCollection
49
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51
54{
55 collectionName.insert("physicalCellsFullSim");
56}
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58
60 G4int aNbOfLayers,
61 G4int aNbOfSlices,
62 G4int aNbOfRows)
64 , fNbOfLayers(aNbOfLayers)
65 , fNbOfSlices(aNbOfSlices)
66 , fNbOfRows(aNbOfRows)
67{
68 collectionName.insert("physicalCellsFullSim");
69}
70
71//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72
74
75//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76
78{
79 fHitsCollection = new Par04HitsCollection(SensitiveDetectorName, collectionName[0]);
80 if(fHitCollectionID < 0)
81 {
82 fHitCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
83 }
84 aHCE->AddHitsCollection(fHitCollectionID, fHitsCollection);
85}
86
87//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88
90{
91 G4double edep = aStep->GetTotalEnergyDeposit();
92 if(edep == 0.)
93 return true;
94
95 auto touchable = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
96
97 G4int layerNo = touchable->GetCopyNumber(0);
98 G4int sliceNo = touchable->GetCopyNumber(1);
99 G4int rowNo = touchable->GetCopyNumber(2);
100
101 G4int hitID = fNbOfLayers*fNbOfSlices*rowNo+fNbOfLayers*sliceNo+layerNo;
102 if (layerNo >= fNbOfLayers) {
103 G4cout << "ERROR, problem with Layer IDs: " << layerNo << " > " << fNbOfLayers << G4endl;
104 return false;
105 }
106 if (sliceNo >= fNbOfSlices) {
107 G4cout << "ERROR, problem with Slice IDs: " << sliceNo << " >= " << fNbOfSlices << G4endl;
108 return false;
109 }
110 if (rowNo >= fNbOfRows) {
111 G4cout << "ERROR, problem with Row IDs: " << rowNo << " >= " << fNbOfRows << G4endl;
112 return false;
113 }
114 auto hit = fHitsMap[hitID].get();
115 if (hit==nullptr) {
116 fHitsMap[hitID] = std::unique_ptr<Par04Hit>(new Par04Hit());
117 hit = fHitsMap[hitID].get();
118 hit->SetPhiId(sliceNo);
119 hit->SetRhoId(layerNo);
120 hit->SetZid(rowNo);
121 }
122
123 // Add energy deposit from G4Step
124 hit->AddEdep(edep);
125 // Increment the counter
126 hit->AddNdep(1);
127
128 // Fill time information from G4Step
129 // If it's already filled, choose hit with earliest global time
130 if(hit->GetTime() == -1 || hit->GetTime() > aStep->GetTrack()->GetGlobalTime())
131 hit->SetTime(aStep->GetTrack()->GetGlobalTime());
132
133 // Set type to parallel world full hit
134 hit->SetType(2);
135
136 return true;
137}
138
139
140//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
142{
143 for(const auto& hits: fHitsMap){
144 fHitsCollection->insert(new Par04Hit(*hits.second.get()));
145 }
146 fHitsMap.clear();
147}
G4THitsCollection< Par04Hit > Par04HitsCollection
Definition Par04Hit.hh:145
Hit class to store energy deposited in the sensitive detector.
std::unordered_map< G4int, std::unique_ptr< Par04Hit > > fHitsMap
virtual void EndOfEvent(G4HCofThisEvent *aHC) final
virtual void Initialize(G4HCofThisEvent *HCE) final
Create hit collection.
Par04HitsCollection * fHitsCollection
Collection of hits.
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *aROhist) final
Process energy deposit from the full simulation.

Applications | User Support | Publications | Collaboration