Loading...
Searching...
No Matches
Par04ParallelFastSensitiveDetector.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("physicalCellsFastSim");
56}
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58
60 G4int aNbOfLayers,
61 G4int aNbOfSlices)
63 , fNbOfLayers(aNbOfLayers)
64 , fNbOfSlices(aNbOfSlices)
65{
66 collectionName.insert("physicalCellsFastSim");
67}
68
69//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70
72
73//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74
76{
77 fHitsCollection = new Par04HitsCollection(SensitiveDetectorName, collectionName[0]);
78 if(fHitCollectionID < 0)
79 {
80 fHitCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
81 }
82 aHCE->AddHitsCollection(fHitCollectionID, fHitsCollection);
83}
84
85//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90
91//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93 const G4FastTrack*,
94 G4TouchableHistory* aTouchable)
95{
96 G4double edep = aHit->GetEnergy();
97 if(edep == 0.)
98 return true;
99
100 G4int layerNo = aTouchable->GetCopyNumber(0);
101 G4int sliceNo = aTouchable->GetCopyNumber(1);
102 G4int rowNo = aTouchable->GetCopyNumber(2);
103
104 G4int hitID = fNbOfLayers*fNbOfSlices*rowNo+fNbOfLayers*sliceNo+layerNo;
105 auto hit = fHitsMap[hitID].get();
106 if (hit==nullptr) {
107 fHitsMap[hitID] = std::unique_ptr<Par04Hit>(new Par04Hit());
108 hit = fHitsMap[hitID].get();
109 hit->SetPhiId(sliceNo);
110 hit->SetRhoId(layerNo);
111 hit->SetZid(rowNo);
112 }
113 if (layerNo != hit->GetRhoId()) {
114 G4cout << "ERROR, problem with Layer IDs: " << layerNo << " != " << hit->GetRhoId() << G4endl;
115 return false;
116 }
117 if (sliceNo != hit->GetPhiId()) {
118 G4cout << "ERROR, problem with Slice IDs: " << sliceNo << " != " << hit->GetPhiId() << G4endl;
119 return false;
120 }
121 if (rowNo != hit->GetZid()) {
122 G4cout << "ERROR, problem with Row IDs: " << rowNo << " != " << hit->GetZid() << G4endl;
123 return false;
124 }
125
126 // Add energy deposit from G4Step
127 hit->AddEdep(edep);
128 // Increment the counter
129 hit->AddNdep(1);
130 // Set hit type to parallel world fast simulation (even if hit was already marked as full
131 // sim, overwrite it)
132 hit->SetType(3);
133
134 return true;
135}
136
137//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139{
140 for(const auto& hits: fHitsMap){
141 fHitsCollection->insert(new Par04Hit(*hits.second.get()));
142 }
143 fHitsMap.clear();
144}
G4THitsCollection< Par04Hit > Par04HitsCollection
Definition Par04Hit.hh:145
G4double GetEnergy() const
Hit class to store energy deposited in the sensitive detector.
virtual void Initialize(G4HCofThisEvent *HCE) final
Create hit collection.
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *aROhist) final
Process energy deposit from the full simulation.
Par04HitsCollection * fHitsCollection
Collection of hits.
std::unordered_map< G4int, std::unique_ptr< Par04Hit > > fHitsMap
virtual void EndOfEvent(G4HCofThisEvent *aHC) final

Applications | User Support | Publications | Collaboration