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

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

#include <Doxymodules_parameterisations.h>

Inheritance diagram for Par03EventAction:
G4UserEventAction

Public Member Functions

 Par03EventAction (Par03DetectorConstruction *aDetector)
 
virtual ~Par03EventAction ()
 
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.
 

Private Attributes

G4int fHitCollectionID
 ID of a hit collection to analyse.
 
G4Timer fTimer
 Timer measurement.
 
Par03DetectorConstructionfDetector
 Pointer to detector construction to retrieve (once) the detector dimensions.
 
G4double fCellSizeZ = 0
 Size of cell along Z axis.
 
G4double fCellSizeRho = 0
 Size of cell along radius of cylinder.
 

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.

Definition at line 64 of file Doxymodules_parameterisations.h.

Constructor & Destructor Documentation

◆ Par03EventAction()

Par03EventAction::Par03EventAction ( Par03DetectorConstruction aDetector)

Definition at line 36 of file Par03EventAction.cc.

39 , fTimer()
40 , fDetector(aDetector)
41{}
Par03DetectorConstruction * fDetector
Pointer to detector construction to retrieve (once) the detector dimensions.
G4int fHitCollectionID
ID of a hit collection to analyse.
G4Timer fTimer
Timer measurement.

◆ ~Par03EventAction()

Par03EventAction::~Par03EventAction ( )
virtualdefault

Member Function Documentation

◆ BeginOfEventAction()

void Par03EventAction::BeginOfEventAction ( const G4Event aEvent)
finalvirtual

Timer is started.

Definition at line 49 of file Par03EventAction.cc.

49{ fTimer.Start(); }

◆ EndOfEventAction()

void Par03EventAction::EndOfEventAction ( const G4Event aEvent)
finalvirtual

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

Definition at line 53 of file Par03EventAction.cc.

54{
55 fTimer.Stop();
56 // Get hits collection ID (only once)
57 if(fHitCollectionID == -1)
58 {
59 fHitCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("hits");
60 }
61 // Get hits collection
62 auto hitsCollection = static_cast<Par03HitsCollection*>(
63 aEvent->GetHCofThisEvent()->GetHC(fHitCollectionID));
64
65 if(hitsCollection == nullptr)
66 {
67 G4ExceptionDescription msg;
68 msg << "Cannot access hitsCollection ID " << fHitCollectionID;
69 G4Exception("Par03EventAction::GetHitsCollection()", "MyCode0001",
70 FatalException, msg);
71 }
72 // Get analysis manager
73 auto analysisManager = G4AnalysisManager::Instance();
74 // Retrieve only once detector dimensions
75 if(fCellSizeZ == 0)
76 {
79 }
80
81 // Retrieve information from primary vertex and primary particle
82 // To calculate shower axis and entry point to the detector
83 auto primaryVertex = G4EventManager::GetEventManager()
84 ->GetConstCurrentEvent()
85 ->GetPrimaryVertex();
86 auto primaryParticle = primaryVertex->GetPrimary(0);
87 G4double primaryEnergy = primaryParticle->GetTotalEnergy();
88 // Estimate from vertex and particle direction the entry point to the detector
89 // Calculate entrance point to the detector located at z = 0
90 auto primaryDirection = primaryParticle->GetMomentumDirection();
91 auto primaryEntrance = primaryVertex->GetPosition() -
92 primaryVertex->GetPosition().z() * primaryDirection;
93 G4double cosDirection = std::cos(primaryDirection.theta());
94 G4double sinDirection = std::sin(primaryDirection.theta());
95
96 // Fill histograms
97 Par03Hit* hit = nullptr;
98 G4double hitEn = 0;
99 G4double totalEnergy = 0;
100 G4int hitZ = -1;
101 G4int hitRho = -1;
102 G4int hitType = -1;
103 G4double tDistance = 0., rDistance = 0.;
104 G4double tFirstMoment = 0., tSecondMoment = 0.;
105 G4double rFirstMoment = 0., rSecondMoment = 0.;
106 for(size_t iHit = 0; iHit < hitsCollection->entries(); iHit++)
107 {
108 hit = static_cast<Par03Hit*>(hitsCollection->GetHit(iHit));
109 hitZ = hit->GetZid();
110 hitRho = hit->GetRhoId();
111 hitEn = hit->GetEdep();
112 hitType = hit->GetType();
113 if(hitEn > 0)
114 {
115 totalEnergy += hitEn;
116 tDistance =
117 hitZ * fCellSizeZ * cosDirection +
118 (hitRho * fCellSizeRho - primaryEntrance.perp()) * sinDirection;
119 rDistance =
120 hitZ * fCellSizeZ * (-sinDirection) +
121 (hitRho * fCellSizeRho - primaryEntrance.perp()) * cosDirection;
122 tFirstMoment += hitEn * tDistance;
123 rFirstMoment += hitEn * rDistance;
124 analysisManager->FillH1(4, tDistance, hitEn);
125 analysisManager->FillH1(5, rDistance, hitEn);
126 analysisManager->FillH1(10, hitType);
127 }
128 }
129 tFirstMoment /= totalEnergy;
130 rFirstMoment /= totalEnergy;
131 analysisManager->FillH1(0, primaryEnergy / GeV);
132 analysisManager->FillH1(1, totalEnergy / GeV);
133 analysisManager->FillH1(2, totalEnergy / primaryEnergy);
134 analysisManager->FillH1(3, fTimer.GetRealElapsed());
135 analysisManager->FillH1(6, tFirstMoment);
136 analysisManager->FillH1(7, rFirstMoment);
137
138 // Second loop over hits to calculate second moments
139 for(size_t iHit = 0; iHit < hitsCollection->entries(); iHit++)
140 {
141 hit = static_cast<Par03Hit*>(hitsCollection->GetHit(iHit));
142 hitEn = hit->GetEdep();
143 hitZ = hit->GetZid();
144 hitRho = hit->GetRhoId();
145 if(hitEn > 0)
146 {
147 tDistance = hitZ * fCellSizeZ * cosDirection +
148 (hitRho * fCellSizeRho - primaryEntrance.r()) * sinDirection;
149 rDistance = hitZ * fCellSizeZ * (-sinDirection) +
150 (hitRho * fCellSizeRho - primaryEntrance.r()) * cosDirection;
151 tSecondMoment += hitEn * std::pow(tDistance - tFirstMoment, 2);
152 rSecondMoment += hitEn * std::pow(rDistance - rFirstMoment, 2);
153 }
154 }
155 tSecondMoment /= totalEnergy;
156 rSecondMoment /= totalEnergy;
157 analysisManager->FillH1(8, tSecondMoment);
158 analysisManager->FillH1(9, rSecondMoment);
159}
G4THitsCollection< Par03Hit > Par03HitsCollection
Definition Par03Hit.hh:132
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 GetRhoId() const
Get rho id of the cell in the readout segmentation.
Definition Par03Hit.hh:93
G4int GetZid() const
Get Z id of the cell in the readout segmentation.
Definition Par03Hit.hh:89
G4int GetType() const
Get type (0 = full sim, 1 = fast sim)
Definition Par03Hit.hh:105
G4double GetEdep() const
Get energy.
Definition Par03Hit.hh:85

Member Data Documentation

◆ fHitCollectionID

G4int Par03EventAction::fHitCollectionID
private

ID of a hit collection to analyse.

Definition at line 56 of file Par03EventAction.hh.

◆ fTimer

G4Timer Par03EventAction::fTimer
private

Timer measurement.

Definition at line 58 of file Par03EventAction.hh.

◆ fDetector

Par03DetectorConstruction* Par03EventAction::fDetector
private

Pointer to detector construction to retrieve (once) the detector dimensions.

Definition at line 61 of file Par03EventAction.hh.

◆ fCellSizeZ

G4double Par03EventAction::fCellSizeZ = 0
private

Size of cell along Z axis.

Definition at line 63 of file Par03EventAction.hh.

◆ fCellSizeRho

G4double Par03EventAction::fCellSizeRho = 0
private

Size of cell along radius of cylinder.

Definition at line 65 of file Par03EventAction.hh.


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

Applications | User Support | Publications | Collaboration