Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Par04ParallelFullSensitiveDetector Class Reference

Sensitive detector. More...

#include <Par04ParallelFullSensitiveDetector.hh>

Inheritance diagram for Par04ParallelFullSensitiveDetector:
G4VSensitiveDetector

Public Member Functions

 Par04ParallelFullSensitiveDetector (G4String aName)
 
 Par04ParallelFullSensitiveDetector (G4String aName, G4int aNbOfLayers, G4int aNbOfSlices, G4int aNbOfRows)
 
virtual ~Par04ParallelFullSensitiveDetector ()
 
virtual void Initialize (G4HCofThisEvent *HCE) final
 Create hit collection.
 
virtual G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *aROhist) final
 Process energy deposit from the full simulation.
 
virtual void EndOfEvent (G4HCofThisEvent *aHC) final
 

Private Attributes

Par04HitsCollectionfHitsCollection = nullptr
 Collection of hits.
 
std::unordered_map< G4int, std::unique_ptr< Par04Hit > > fHitsMap
 
G4int fHitCollectionID = -1
 ID of collection of hits.
 
G4int fNbOfLayers = 1
 Number of readout cells.
 
G4int fNbOfSlices = 1
 
G4int fNbOfRows = 1
 

Detailed Description

Sensitive detector.

Definition at line 48 of file Par04ParallelFullSensitiveDetector.hh.

Constructor & Destructor Documentation

◆ Par04ParallelFullSensitiveDetector() [1/2]

Par04ParallelFullSensitiveDetector::Par04ParallelFullSensitiveDetector ( G4String  aName)

Definition at line 52 of file Par04ParallelFullSensitiveDetector.cc.

54{
55 collectionName.insert("physicalCellsFullSim");
56}

◆ Par04ParallelFullSensitiveDetector() [2/2]

Par04ParallelFullSensitiveDetector::Par04ParallelFullSensitiveDetector ( G4String  aName,
G4int  aNbOfLayers,
G4int  aNbOfSlices,
G4int  aNbOfRows 
)

Definition at line 59 of file Par04ParallelFullSensitiveDetector.cc.

64 , fNbOfLayers(aNbOfLayers)
65 , fNbOfSlices(aNbOfSlices)
66 , fNbOfRows(aNbOfRows)
67{
68 collectionName.insert("physicalCellsFullSim");
69}

◆ ~Par04ParallelFullSensitiveDetector()

Par04ParallelFullSensitiveDetector::~Par04ParallelFullSensitiveDetector ( )
virtualdefault

Member Function Documentation

◆ Initialize()

void Par04ParallelFullSensitiveDetector::Initialize ( G4HCofThisEvent HCE)
finalvirtual

Create hit collection.

Definition at line 77 of file Par04ParallelFullSensitiveDetector.cc.

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}
G4THitsCollection< Par04Hit > Par04HitsCollection
Definition Par04Hit.hh:145
Par04HitsCollection * fHitsCollection
Collection of hits.

◆ ProcessHits()

G4bool Par04ParallelFullSensitiveDetector::ProcessHits ( G4Step aStep,
G4TouchableHistory aROhist 
)
finalvirtual

Process energy deposit from the full simulation.

Definition at line 89 of file Par04ParallelFullSensitiveDetector.cc.

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}
Hit class to store energy deposited in the sensitive detector.
std::unordered_map< G4int, std::unique_ptr< Par04Hit > > fHitsMap

◆ EndOfEvent()

void Par04ParallelFullSensitiveDetector::EndOfEvent ( G4HCofThisEvent aHC)
finalvirtual

Definition at line 141 of file Par04ParallelFullSensitiveDetector.cc.

142{
143 for(const auto& hits: fHitsMap){
144 fHitsCollection->insert(new Par04Hit(*hits.second.get()));
145 }
146 fHitsMap.clear();
147}

Member Data Documentation

◆ fHitsCollection

Par04HitsCollection* Par04ParallelFullSensitiveDetector::fHitsCollection = nullptr
private

Collection of hits.

Definition at line 64 of file Par04ParallelFullSensitiveDetector.hh.

◆ fHitsMap

std::unordered_map<G4int, std::unique_ptr<Par04Hit> > Par04ParallelFullSensitiveDetector::fHitsMap
private

Definition at line 65 of file Par04ParallelFullSensitiveDetector.hh.

◆ fHitCollectionID

G4int Par04ParallelFullSensitiveDetector::fHitCollectionID = -1
private

ID of collection of hits.

Definition at line 67 of file Par04ParallelFullSensitiveDetector.hh.

◆ fNbOfLayers

G4int Par04ParallelFullSensitiveDetector::fNbOfLayers = 1
private

Number of readout cells.

Definition at line 69 of file Par04ParallelFullSensitiveDetector.hh.

◆ fNbOfSlices

G4int Par04ParallelFullSensitiveDetector::fNbOfSlices = 1
private

Definition at line 70 of file Par04ParallelFullSensitiveDetector.hh.

◆ fNbOfRows

G4int Par04ParallelFullSensitiveDetector::fNbOfRows = 1
private

Definition at line 71 of file Par04ParallelFullSensitiveDetector.hh.


The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration