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

Event action class for hits' analysis. More...

#include <Doxymodules_parameterisations.h>

Inheritance diagram for Par04EventAction:
G4UserEventAction

Public Member Functions

 Par04EventAction (Par04DetectorConstruction *aDetector, Par04ParallelFullWorld *aParallel)
 
virtual ~Par04EventAction ()
 
virtual void BeginOfEventAction (const G4Event *aEvent) final
 Timer is started.
 
virtual void EndOfEventAction (const G4Event *aEvent) final
 Hits collection is retrieved, analysed, and histograms are filled.
 
std::vector< G4double > & GetCalEdep ()
 
std::vector< G4int > & GetCalRho ()
 
std::vector< G4int > & GetCalPhi ()
 
std::vector< G4int > & GetCalZ ()
 
std::vector< G4double > & GetPhysicalCalEdep ()
 
std::vector< G4int > & GetPhysicalCalLayer ()
 
std::vector< G4int > & GetPhysicalCalSlice ()
 
std::vector< G4int > & GetPhysicalCalRow ()
 
void StartTimer ()
 
void StopTimer ()
 

Private Attributes

G4int fHitCollectionID = -1
 ID of a hit collection to analyse.
 
G4int fPhysicalFullHitCollectionID = -1
 
G4int fPhysicalFastHitCollectionID = -1
 
G4Timer fTimer
 Timer measurement from Geant4.
 
Par04DetectorConstructionfDetector = nullptr
 Pointer to detector construction to retrieve (once) the detector dimensions and size of readout.
 
Par04ParallelFullWorldfParallel = nullptr
 
G4double fCellSizeZ = 0
 Size of cell along Z axis.
 
G4double fCellSizeRho = 0
 Size of cell along radius of cylinder.
 
G4double fCellSizePhi = 0
 Size of cell in azimuthal angle.
 
G4int fCellNbRho = 0
 Number of readout cells along radius.
 
G4int fCellNbPhi = 0
 Number of readout cells in azimuthal angle.
 
G4int fCellNbZ = 0
 Number of readout cells along z axis.
 
G4int fPhysicalNbLayers = 0
 Number of physical readout layers.
 
G4int fPhysicalNbSlices = 0
 Number of physical readout slices.
 
G4int fPhysicalNbRows = 0
 Number of physical readout rows.
 
std::vector< G4double > fCalEdep
 Cell energy deposits to be stored in ntuple.
 
std::vector< G4int > fCalRho
 Cell ID of radius to be stored in ntuple.
 
std::vector< G4int > fCalPhi
 Cell ID of azimuthal angle to be stored in ntuple.
 
std::vector< G4int > fCalZ
 Cell ID of z axis to be stored in ntuple.
 
std::vector< G4double > fCalPhysicalEdep
 Physical cell energy deposits to be stored in ntuple.
 
std::vector< G4int > fCalPhysicalLayer
 Physical layer ID to be stored in ntuple.
 
std::vector< G4int > fCalPhysicalSlice
 Physical slice ID to be stored in ntuple.
 
std::vector< G4int > fCalPhysicalRow
 Physical row ID to be stored in ntuple.
 

Detailed Description

Event action class for hits' analysis.

Analysis of single-particle events and developed showers in the detector. At the end of the event basic variables are calculated and saved in the histograms. Additionally ntuple with cell energies and IDs (in cylindrical coordinates) is stored.

Definition at line 81 of file Doxymodules_parameterisations.h.

Constructor & Destructor Documentation

◆ Par04EventAction()

Par04EventAction::Par04EventAction ( Par04DetectorConstruction aDetector,
Par04ParallelFullWorld aParallel 
)

Definition at line 57 of file Par04EventAction.cc.

63 , fTimer()
64 , fDetector(aDetector)
65 , fParallel(aParallel)
66{
67 fCellNbRho = aDetector->GetMeshNbOfCells().x();
68 fCellNbPhi = aDetector->GetMeshNbOfCells().y();
69 fCellNbZ = aDetector->GetMeshNbOfCells().z();
78}
G4ThreeVector GetMeshNbOfCells() const
Get number of Mesh cells in cylindrical coordinates (r, phi, z)
std::vector< G4int > fCalZ
Cell ID of z axis to be stored in ntuple.
G4int fHitCollectionID
ID of a hit collection to analyse.
std::vector< G4int > fCalPhi
Cell ID of azimuthal angle to be stored in ntuple.
G4int fCellNbRho
Number of readout cells along radius.
std::vector< G4int > fCalPhysicalRow
Physical row ID to be stored in ntuple.
G4int fCellNbZ
Number of readout cells along z axis.
G4int fPhysicalNbRows
Number of physical readout rows.
std::vector< G4double > fCalPhysicalEdep
Physical cell energy deposits to be stored in ntuple.
Par04DetectorConstruction * fDetector
Pointer to detector construction to retrieve (once) the detector dimensions and size of readout.
G4int fPhysicalNbLayers
Number of physical readout layers.
std::vector< G4int > fCalRho
Cell ID of radius to be stored in ntuple.
G4Timer fTimer
Timer measurement from Geant4.
G4int fPhysicalNbSlices
Number of physical readout slices.
std::vector< G4double > fCalEdep
Cell energy deposits to be stored in ntuple.
std::vector< G4int > fCalPhysicalLayer
Physical layer ID to be stored in ntuple.
std::vector< G4int > fCalPhysicalSlice
Physical slice ID to be stored in ntuple.
G4int fCellNbPhi
Number of readout cells in azimuthal angle.
Par04ParallelFullWorld * fParallel

◆ ~Par04EventAction()

Par04EventAction::~Par04EventAction ( )
virtualdefault

Member Function Documentation

◆ BeginOfEventAction()

void Par04EventAction::BeginOfEventAction ( const G4Event aEvent)
finalvirtual

Timer is started.

Definition at line 86 of file Par04EventAction.cc.

86 {
87 StartTimer();
88}

◆ EndOfEventAction()

void Par04EventAction::EndOfEventAction ( const G4Event aEvent)
finalvirtual

Hits collection is retrieved, analysed, and histograms are filled.

Definition at line 104 of file Par04EventAction.cc.

105{
106 G4SDManager::GetSDMpointer()->GetHCtable();
107 StopTimer();
108
109 // Get hits collection ID (only once)
110 if(fHitCollectionID == -1)
111 {
112 fHitCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("hits");
113 }
115 {
117 G4SDManager::GetSDMpointer()->GetCollectionID("physicalCellsFullSim");
118 }
120 {
122 G4SDManager::GetSDMpointer()->GetCollectionID("physicalCellsFastSim");
123 }
124 // Get hits collection
125 auto hitsCollection =
126 static_cast<Par04HitsCollection*>(aEvent->GetHCofThisEvent()->GetHC(fHitCollectionID));
127 auto physicalFullHitsCollection =
128 static_cast<Par04HitsCollection*>(aEvent->GetHCofThisEvent()
130 auto physicalFastHitsCollection =
131 static_cast<Par04HitsCollection*>(aEvent->GetHCofThisEvent()
133
134 if(hitsCollection == nullptr)
135 {
136 G4ExceptionDescription msg;
137 msg << "Cannot access hitsCollection ID " << fHitCollectionID;
138 G4Exception("Par04EventAction::GetHitsCollection()", "MyCode0001", FatalException, msg);
139 }
140 if(physicalFullHitsCollection == nullptr)
141 {
142 G4ExceptionDescription msg;
143 msg << "Cannot access physical full sim hitsCollection ID " << fPhysicalFullHitCollectionID;
144 G4Exception("Par04EventAction::GetHitsCollection()", "MyCode0001", FatalException, msg);
145 }
146 if(physicalFastHitsCollection == nullptr)
147 {
148 G4ExceptionDescription msg;
149 msg << "Cannot access physical fast sim hitsCollection ID " << fPhysicalFastHitCollectionID;
150 G4Exception("Par04EventAction::GetHitsCollection()", "MyCode0001", FatalException, msg);
151 }
152 // Get analysis manager
153 auto analysisManager = G4AnalysisManager::Instance();
154 // Retrieve only once detector dimensions
155 if(fCellSizeZ == 0)
156 {
163 }
164 if(fPhysicalNbLayers == 0)
165 {
169 }
170
171 // Retrieve information from primary vertex and primary particle
172 // To calculate shower axis and entry point to the detector
173 auto primaryVertex =
174 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetPrimaryVertex();
175 auto primaryParticle = primaryVertex->GetPrimary(0);
176 G4double primaryEnergy = primaryParticle->GetTotalEnergy();
177 // Estimate from vertex and particle direction the entry point to the detector
178 // Calculate entrance point to the detector located at z = 0
179 auto primaryDirection = primaryParticle->GetMomentumDirection();
180 auto primaryEntrance =
181 primaryVertex->GetPosition() - primaryVertex->GetPosition().z() * primaryDirection;
182
183 // Resize back to initial mesh size
187 fCalZ.resize(fCellNbRho * fCellNbPhi * fCellNbZ,0);
192
193 // Fill histograms
194 Par04Hit* hit = nullptr;
195 G4double hitEn = 0;
196 G4double totalEnergy = 0;
197 G4int hitNum = 0;
198 G4int totalNum = 0;
199 G4int hitZ = -1;
200 G4int hitRho = -1;
201 G4int hitPhi = -1;
202 G4int hitType = -1;
203 G4int numNonZeroThresholdCells = 0;
204 G4double tDistance = 0., rDistance = 0., phiDistance = 0.;
205 G4double tFirstMoment = 0., tSecondMoment = 0.;
206 G4double rFirstMoment = 0., rSecondMoment = 0.;
207 G4double phiMean = 0.;
208 for(size_t iHit = 0; iHit < hitsCollection->entries(); iHit++)
209 {
210 hit = static_cast<Par04Hit*>(hitsCollection->GetHit(iHit));
211 hitZ = hit->GetZid();
212 hitRho = hit->GetRhoId();
213 hitPhi = hit->GetPhiId();
214 hitEn = hit->GetEdep();
215 hitNum = hit->GetNdep();
216 hitType = hit->GetType();
217 if(hitEn > 0)
218 {
219 totalEnergy += hitEn;
220 totalNum += hitNum;
221 tDistance = hitZ * fCellSizeZ;
222 rDistance = hitRho * fCellSizeRho;
223 phiDistance = hitPhi * fCellSizePhi;
224 tFirstMoment += hitEn * tDistance;
225 rFirstMoment += hitEn * rDistance;
226 phiMean += hitEn * phiDistance;
227 analysisManager->FillH1(4, tDistance, hitEn);
228 analysisManager->FillH1(5, rDistance, hitEn);
229 analysisManager->FillH1(10, hitType);
230 if(hitEn > 0.0005)
231 { // e > 0.5 keV
232 fCalEdep[numNonZeroThresholdCells] = hitEn;
233 fCalRho[numNonZeroThresholdCells] = hitRho;
234 fCalPhi[numNonZeroThresholdCells] = hitPhi;
235 fCalZ[numNonZeroThresholdCells] = hitZ;
236 numNonZeroThresholdCells++;
237 analysisManager->FillH1(13, std::log10(hitEn));
238 analysisManager->FillH1(15, hitNum);
239 }
240 }
241 }
242 tFirstMoment /= totalEnergy;
243 rFirstMoment /= totalEnergy;
244 phiMean /= totalEnergy;
245 analysisManager->FillH1(0, primaryEnergy / GeV);
246 analysisManager->FillH1(1, totalEnergy / GeV);
247 analysisManager->FillH1(2, totalEnergy / primaryEnergy);
248 analysisManager->FillH1(3, fTimer.GetRealElapsed());
249 analysisManager->FillH1(6, tFirstMoment);
250 analysisManager->FillH1(7, rFirstMoment);
251 analysisManager->FillH1(12, numNonZeroThresholdCells);
252 analysisManager->FillH1(14, totalNum);
253 // Resize to store only energy hits above threshold
254 fCalEdep.resize(numNonZeroThresholdCells);
255 fCalRho.resize(numNonZeroThresholdCells);
256 fCalPhi.resize(numNonZeroThresholdCells);
257 fCalZ.resize(numNonZeroThresholdCells);
258 analysisManager->FillNtupleDColumn(0, 0, primaryEnergy);
259 analysisManager->FillNtupleDColumn(0, 1, fTimer.GetRealElapsed());
260 // Second loop over hits to calculate second moments
261 for(size_t iHit = 0; iHit < hitsCollection->entries(); iHit++)
262 {
263 hit = static_cast<Par04Hit*>(hitsCollection->GetHit(iHit));
264 hitEn = hit->GetEdep();
265 hitZ = hit->GetZid();
266 hitRho = hit->GetRhoId();
267 hitPhi = hit->GetPhiId();
268 if(hitEn > 0)
269 {
270 tDistance = hitZ * fCellSizeZ;
271 rDistance = hitRho * fCellSizeRho;
272 phiDistance = hitPhi * fCellSizePhi;
273 tSecondMoment += hitEn * std::pow(tDistance - tFirstMoment, 2);
274 rSecondMoment += hitEn * std::pow(rDistance - rFirstMoment, 2);
275 analysisManager->FillH1(11, phiDistance - phiMean, hitEn);
276 }
277 }
278 tSecondMoment /= totalEnergy;
279 rSecondMoment /= totalEnergy;
280 analysisManager->FillH1(8, tSecondMoment);
281 analysisManager->FillH1(9, rSecondMoment);
282
283 // Fill ntuple with physical readout data
284 G4double totalPhysicalEnergy = 0;
285 totalNum = 0;
286 hitEn = 0;
287 hitNum = 0;
288 G4int hitLayer = -1;
289 G4int hitRow = -1;
290 G4int hitSlice = -1;
291 numNonZeroThresholdCells = 0;
292 for(size_t iHit = 0; iHit < physicalFullHitsCollection->entries(); iHit++)
293 {
294 hit = static_cast<Par04Hit*>(physicalFullHitsCollection->GetHit(iHit));
295 hitLayer = hit->GetRhoId();
296 hitRow = hit->GetZid();
297 hitSlice = hit->GetPhiId();
298 hitEn = hit->GetEdep();
299 hitNum = hit->GetNdep();
300 if(hitEn > 0)
301 {
302 totalPhysicalEnergy += hitEn;
303 totalNum += hitNum;
304 if(hitEn > 0.0005)
305 { // e > 0.5 keV
306 fCalPhysicalEdep[numNonZeroThresholdCells] = hitEn;
307 fCalPhysicalLayer[numNonZeroThresholdCells] = hitLayer;
308 fCalPhysicalRow[numNonZeroThresholdCells] = hitRow;
309 fCalPhysicalSlice[numNonZeroThresholdCells] = hitSlice;
310 numNonZeroThresholdCells++;
311 analysisManager->FillH1(19, std::log10(hitEn));
312 analysisManager->FillH1(21, hitNum);
313 }
314 }
315 }for(size_t iHit = 0; iHit < physicalFastHitsCollection->entries(); iHit++)
316 {
317 hit = static_cast<Par04Hit*>(physicalFastHitsCollection->GetHit(iHit));
318 hitLayer = hit->GetRhoId();
319 hitRow = hit->GetZid();
320 hitSlice = hit->GetPhiId();
321 hitEn = hit->GetEdep();
322 hitNum = hit->GetNdep();
323 if(hitEn > 0)
324 {
325 totalPhysicalEnergy += hitEn;
326 totalNum += hitNum;
327 if(hitEn > 0.0005)
328 { // e > 0.5 keV
329 fCalPhysicalEdep[numNonZeroThresholdCells] = hitEn;
330 fCalPhysicalLayer[numNonZeroThresholdCells] = hitLayer;
331 fCalPhysicalRow[numNonZeroThresholdCells] = hitRow;
332 fCalPhysicalSlice[numNonZeroThresholdCells] = hitSlice;
333 numNonZeroThresholdCells++;
334 analysisManager->FillH1(19, std::log10(hitEn));
335 analysisManager->FillH1(21, hitNum);
336 }
337 }
338 }
339 analysisManager->FillH1(16, totalPhysicalEnergy / GeV);
340 analysisManager->FillH1(17, totalPhysicalEnergy / primaryEnergy);
341 analysisManager->FillH1(18, numNonZeroThresholdCells);
342 analysisManager->FillH1(20, totalNum);
343 fCalPhysicalEdep.resize(numNonZeroThresholdCells);
344 fCalPhysicalLayer.resize(numNonZeroThresholdCells);
345 fCalPhysicalSlice.resize(numNonZeroThresholdCells);
346 fCalPhysicalRow.resize(numNonZeroThresholdCells);
347 analysisManager->AddNtupleRow(0);
348 analysisManager->AddNtupleRow(1);
349 analysisManager->AddNtupleRow(2);
350}
G4THitsCollection< Par04Hit > Par04HitsCollection
Definition Par04Hit.hh:145
G4ThreeVector GetMeshSizeOfCells() const
Get size of Mesh cells in cylindrical coordinates (r, phi, z)
G4double fCellSizePhi
Size of cell in azimuthal angle.
G4double fCellSizeRho
Size of cell along radius of cylinder.
G4double fCellSizeZ
Size of cell along Z axis.
Hit class to store energy deposited in the sensitive detector.
G4int GetZid() const
Get Z id of the cell in the readout segmentation.
Definition Par04Hit.hh:100
G4double GetEdep() const
Get energy.
Definition Par04Hit.hh:90
G4int GetType() const
Get type (0 = full sim, 1 = fast sim)
Definition Par04Hit.hh:116
G4int GetRhoId() const
Get rho id of the cell in the readout segmentation.
Definition Par04Hit.hh:104
G4int GetNdep() const
Get number of deposits per hit/cell.
Definition Par04Hit.hh:96
G4int GetPhiId() const
Get phi id of the cell in the readout segmentation.
Definition Par04Hit.hh:108
G4int GetNbOfRows() const
Get number of rows.
G4int GetNbOfLayers() const
Get number of layers.
G4int GetNbOfSlices() const
Get number of slices.

◆ GetCalEdep()

std::vector< G4double > & Par04EventAction::GetCalEdep ( )
inline

Definition at line 57 of file Par04EventAction.hh.

57{ return fCalEdep; }

◆ GetCalRho()

std::vector< G4int > & Par04EventAction::GetCalRho ( )
inline

Definition at line 58 of file Par04EventAction.hh.

58{ return fCalRho; }

◆ GetCalPhi()

std::vector< G4int > & Par04EventAction::GetCalPhi ( )
inline

Definition at line 59 of file Par04EventAction.hh.

59{ return fCalPhi; }

◆ GetCalZ()

std::vector< G4int > & Par04EventAction::GetCalZ ( )
inline

Definition at line 60 of file Par04EventAction.hh.

60{ return fCalZ; }

◆ GetPhysicalCalEdep()

std::vector< G4double > & Par04EventAction::GetPhysicalCalEdep ( )
inline

Definition at line 61 of file Par04EventAction.hh.

61{ return fCalPhysicalEdep; }

◆ GetPhysicalCalLayer()

std::vector< G4int > & Par04EventAction::GetPhysicalCalLayer ( )
inline

Definition at line 62 of file Par04EventAction.hh.

62{ return fCalPhysicalLayer; }

◆ GetPhysicalCalSlice()

std::vector< G4int > & Par04EventAction::GetPhysicalCalSlice ( )
inline

Definition at line 63 of file Par04EventAction.hh.

63{ return fCalPhysicalSlice; }

◆ GetPhysicalCalRow()

std::vector< G4int > & Par04EventAction::GetPhysicalCalRow ( )
inline

Definition at line 64 of file Par04EventAction.hh.

64{ return fCalPhysicalRow; }

◆ StartTimer()

void Par04EventAction::StartTimer ( )

Definition at line 92 of file Par04EventAction.cc.

92 {
93 fTimer.Start();
94}

◆ StopTimer()

void Par04EventAction::StopTimer ( )

Definition at line 98 of file Par04EventAction.cc.

98 {
99 fTimer.Stop();
100}

Member Data Documentation

◆ fHitCollectionID

G4int Par04EventAction::fHitCollectionID = -1
private

ID of a hit collection to analyse.

Definition at line 69 of file Par04EventAction.hh.

◆ fPhysicalFullHitCollectionID

G4int Par04EventAction::fPhysicalFullHitCollectionID = -1
private

Definition at line 70 of file Par04EventAction.hh.

◆ fPhysicalFastHitCollectionID

G4int Par04EventAction::fPhysicalFastHitCollectionID = -1
private

Definition at line 71 of file Par04EventAction.hh.

◆ fTimer

G4Timer Par04EventAction::fTimer
private

Timer measurement from Geant4.

Definition at line 73 of file Par04EventAction.hh.

◆ fDetector

Par04DetectorConstruction* Par04EventAction::fDetector = nullptr
private

Pointer to detector construction to retrieve (once) the detector dimensions and size of readout.

Definition at line 76 of file Par04EventAction.hh.

◆ fParallel

Par04ParallelFullWorld* Par04EventAction::fParallel = nullptr
private

Definition at line 77 of file Par04EventAction.hh.

◆ fCellSizeZ

G4double Par04EventAction::fCellSizeZ = 0
private

Size of cell along Z axis.

Definition at line 79 of file Par04EventAction.hh.

◆ fCellSizeRho

G4double Par04EventAction::fCellSizeRho = 0
private

Size of cell along radius of cylinder.

Definition at line 81 of file Par04EventAction.hh.

◆ fCellSizePhi

G4double Par04EventAction::fCellSizePhi = 0
private

Size of cell in azimuthal angle.

Definition at line 83 of file Par04EventAction.hh.

◆ fCellNbRho

G4int Par04EventAction::fCellNbRho = 0
private

Number of readout cells along radius.

Definition at line 85 of file Par04EventAction.hh.

◆ fCellNbPhi

G4int Par04EventAction::fCellNbPhi = 0
private

Number of readout cells in azimuthal angle.

Definition at line 87 of file Par04EventAction.hh.

◆ fCellNbZ

G4int Par04EventAction::fCellNbZ = 0
private

Number of readout cells along z axis.

Definition at line 89 of file Par04EventAction.hh.

◆ fPhysicalNbLayers

G4int Par04EventAction::fPhysicalNbLayers = 0
private

Number of physical readout layers.

Definition at line 91 of file Par04EventAction.hh.

◆ fPhysicalNbSlices

G4int Par04EventAction::fPhysicalNbSlices = 0
private

Number of physical readout slices.

Definition at line 93 of file Par04EventAction.hh.

◆ fPhysicalNbRows

G4int Par04EventAction::fPhysicalNbRows = 0
private

Number of physical readout rows.

Definition at line 95 of file Par04EventAction.hh.

◆ fCalEdep

std::vector<G4double> Par04EventAction::fCalEdep
private

Cell energy deposits to be stored in ntuple.

Definition at line 97 of file Par04EventAction.hh.

◆ fCalRho

std::vector<G4int> Par04EventAction::fCalRho
private

Cell ID of radius to be stored in ntuple.

Definition at line 99 of file Par04EventAction.hh.

◆ fCalPhi

std::vector<G4int> Par04EventAction::fCalPhi
private

Cell ID of azimuthal angle to be stored in ntuple.

Definition at line 101 of file Par04EventAction.hh.

◆ fCalZ

std::vector<G4int> Par04EventAction::fCalZ
private

Cell ID of z axis to be stored in ntuple.

Definition at line 103 of file Par04EventAction.hh.

◆ fCalPhysicalEdep

std::vector<G4double> Par04EventAction::fCalPhysicalEdep
private

Physical cell energy deposits to be stored in ntuple.

Definition at line 105 of file Par04EventAction.hh.

◆ fCalPhysicalLayer

std::vector<G4int> Par04EventAction::fCalPhysicalLayer
private

Physical layer ID to be stored in ntuple.

Definition at line 107 of file Par04EventAction.hh.

◆ fCalPhysicalSlice

std::vector<G4int> Par04EventAction::fCalPhysicalSlice
private

Physical slice ID to be stored in ntuple.

Definition at line 109 of file Par04EventAction.hh.

◆ fCalPhysicalRow

std::vector<G4int> Par04EventAction::fCalPhysicalRow
private

Physical row ID to be stored in ntuple.

Definition at line 111 of file Par04EventAction.hh.


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

Applications | User Support | Publications | Collaboration