VMC Examples Version 6.6
Loading...
Searching...
No Matches
Ex03cCalorimeterSD Class Reference

The calorimeter sensitive detector. More...

#include <Ex03cCalorimeterSD.h>

Inheritance diagram for Ex03cCalorimeterSD:

Public Member Functions

 Ex03cCalorimeterSD (const char *name, Ex03cDetectorConstruction *detector)
 
 Ex03cCalorimeterSD (const Ex03cCalorimeterSD &origin, Ex03cDetectorConstruction *detector)
 
 Ex03cCalorimeterSD ()
 
virtual ~Ex03cCalorimeterSD ()
 
void Initialize ()
 
Bool_t ProcessHits ()
 
void EndOfEvent ()
 
void Register ()
 
virtual void Print (Option_t *option="") const
 
void PrintTotal () const
 
void SetVerboseLevel (Int_t level)
 
Ex03CalorHitGetHit (Int_t i) const
 

Private Member Functions

void ResetHits ()
 

Private Attributes

TVirtualMC * fMC
 The VMC implementation.
 
Ex03cDetectorConstructionfDetector
 Detector construction.
 
TClonesArray * fCalCollection
 Hits collection.
 
Int_t fAbsorberVolId
 The absorber volume Id.
 
Int_t fGapVolId
 The gap volume Id.
 
Int_t fVerboseLevel
 Verbosity level.
 

Detailed Description

The calorimeter sensitive detector.

A variant of the Ex03CalorimeterSD class updated for multiple engine runs.

Date
21/08/2019
Author
Benedikt Volkel, CERN

Definition at line 38 of file Ex03cCalorimeterSD.h.

Constructor & Destructor Documentation

◆ Ex03cCalorimeterSD() [1/3]

Ex03cCalorimeterSD::Ex03cCalorimeterSD ( const char * name,
Ex03cDetectorConstruction * detector )

Standard constructor. Create hits collection and an empty hit for each layer As the copy numbers may start from 0 or 1 (depending on geometry model, we create one more layer for this case.)

Parameters
nameThe calorimeter hits collection name
detectorThe detector construction

Definition at line 38 of file Ex03cCalorimeterSD.cxx.

40 : TNamed(name, ""),
41 fMC(0),
42 fDetector(detector),
45 fGapVolId(0),
47{
48 /// Standard constructor.
49 /// Create hits collection and an empty hit for each layer
50 /// As the copy numbers may start from 0 or 1 (depending on
51 /// geometry model, we create one more layer for this case.)
52 /// \param name The calorimeter hits collection name
53 /// \param detector The detector construction
54
55 fCalCollection = new TClonesArray("Ex03CalorHit", 500);
56 for (Int_t i = 0; i < fDetector->GetNbOfLayers() + 1; i++)
57 new ((*fCalCollection)[i]) Ex03CalorHit();
58}
The calorimeter hit.
Int_t fAbsorberVolId
The absorber volume Id.
Int_t fVerboseLevel
Verbosity level.
Int_t fGapVolId
The gap volume Id.
TVirtualMC * fMC
The VMC implementation.
Ex03cDetectorConstruction * fDetector
Detector construction.
TClonesArray * fCalCollection
Hits collection.

◆ Ex03cCalorimeterSD() [2/3]

Ex03cCalorimeterSD::Ex03cCalorimeterSD ( const Ex03cCalorimeterSD & origin,
Ex03cDetectorConstruction * detector )

Copy constructor (for clonig on worker thread in MT mode). Create hits collection and an empty hit for each layer As the copy numbers may start from 0 or 1 (depending on geometry model, we create one more layer for this case.)

Parameters
originThe source object (on master).
detectorThe detector construction

Definition at line 61 of file Ex03cCalorimeterSD.cxx.

63 : TNamed(origin),
64 fMC(0),
65 fDetector(detector),
68 fGapVolId(origin.fGapVolId),
70{
71 /// Copy constructor (for clonig on worker thread in MT mode).
72 /// Create hits collection and an empty hit for each layer
73 /// As the copy numbers may start from 0 or 1 (depending on
74 /// geometry model, we create one more layer for this case.)
75 /// \param origin The source object (on master).
76 /// \param detector The detector construction
77
78 fCalCollection = new TClonesArray("Ex03CalorHit", 500);
79 for (Int_t i = 0; i < fDetector->GetNbOfLayers() + 1; i++)
80 new ((*fCalCollection)[i]) Ex03CalorHit();
81}

◆ Ex03cCalorimeterSD() [3/3]

Ex03cCalorimeterSD::Ex03cCalorimeterSD ( )

Default constructor

Definition at line 84 of file Ex03cCalorimeterSD.cxx.

85 : TNamed(),
86 fDetector(0),
89 fGapVolId(0),
91{
92 /// Default constructor
93}

◆ ~Ex03cCalorimeterSD()

Ex03cCalorimeterSD::~Ex03cCalorimeterSD ( )
virtual

Destructor

Definition at line 96 of file Ex03cCalorimeterSD.cxx.

97{
98 /// Destructor
99
100 if (fCalCollection) fCalCollection->Delete();
101 delete fCalCollection;
102}

Member Function Documentation

◆ Initialize()

void Ex03cCalorimeterSD::Initialize ( )

Register hits collection in the Root manager; set sensitive volumes.

Definition at line 131 of file Ex03cCalorimeterSD.cxx.

132{
133 /// Register hits collection in the Root manager;
134 /// set sensitive volumes.
135
136 if (TMCRootManager::Instance()) Register();
137
138 // Keep the pointer to TVirtualMC object as a data member
139 // to avoid a possible performance penalty due to a frequent retrieval
140 // from the thread-local storage
141 if (TMCManager::Instance()) {
142 TMCManager::Instance()->ConnectEnginePointer(fMC);
143 }
144 else {
145 fMC = gMC;
146 }
147
148 fAbsorberVolId = fMC->VolId("ABSO");
149 fGapVolId = fMC->VolId("GAPX");
150}

◆ ProcessHits()

Bool_t Ex03cCalorimeterSD::ProcessHits ( )

Account energy deposit and track lengths for each layer in its hit.

Definition at line 153 of file Ex03cCalorimeterSD.cxx.

154{
155 /// Account energy deposit and track lengths for each layer in its hit.
156
157 Int_t copyNo;
158 Int_t id = fMC->CurrentVolID(copyNo);
159
160 if (id != fAbsorberVolId && id != fGapVolId) return false;
161
162 fMC->CurrentVolOffID(2, copyNo);
163 // cout << "Got copyNo "<< copyNo << " " << fMC->CurrentVolPath() << endl;
164
165 Double_t edep = fMC->Edep();
166
167 Double_t step = 0.;
168 if (fMC->TrackCharge() != 0.) step = fMC->TrackStep();
169
170 if (!GetHit(copyNo)) {
171 std::cerr << "No hit found for layer with copyNo = " << copyNo << endl;
172 return false;
173 }
174
175 if (id == fAbsorberVolId) {
176 GetHit(copyNo)->AddAbs(edep, step);
177 }
178
179 if (id == fGapVolId) {
180 GetHit(copyNo)->AddGap(edep, step);
181 }
182
183 return true;
184}
void AddAbs(Double_t de, Double_t dl)
void AddGap(Double_t de, Double_t dl)
Ex03CalorHit * GetHit(Int_t i) const

◆ EndOfEvent()

void Ex03cCalorimeterSD::EndOfEvent ( )

Print hits collection (if verbose) and reset hits afterwards.

Definition at line 187 of file Ex03cCalorimeterSD.cxx.

188{
189 /// Print hits collection (if verbose) and reset hits afterwards.
190
191 if (fVerboseLevel > 1) Print();
192
193 // Reset hits collection
194 ResetHits();
195}
virtual void Print(Option_t *option="") const

◆ Register()

void Ex03cCalorimeterSD::Register ( )

Register the hits collection in Root manager.

Definition at line 198 of file Ex03cCalorimeterSD.cxx.

199{
200 /// Register the hits collection in Root manager.
201
202 TMCRootManager::Instance()->Register("hits", "TClonesArray", &fCalCollection);
203}

◆ Print()

void Ex03cCalorimeterSD::Print ( Option_t * option = "") const
virtual

Print the hits collection.

Definition at line 206 of file Ex03cCalorimeterSD.cxx.

207{
208 /// Print the hits collection.
209
210 Int_t nofHits = fCalCollection->GetEntriesFast();
211
212 cout << "\n-------->Hits Collection: in this event: " << endl;
213
214 for (Int_t i = 0; i < nofHits; i++) (*fCalCollection)[i]->Print();
215}

◆ PrintTotal()

void Ex03cCalorimeterSD::PrintTotal ( ) const

Print the total values for all layers.

Definition at line 218 of file Ex03cCalorimeterSD.cxx.

219{
220 /// Print the total values for all layers.
221
222 Double_t totEAbs = 0.;
223 Double_t totLAbs = 0.;
224 Double_t totEGap = 0.;
225 Double_t totLGap = 0.;
226
227 Int_t nofHits = fCalCollection->GetEntriesFast();
228 for (Int_t i = 0; i < nofHits; i++) {
229 totEAbs += GetHit(i)->GetEdepAbs();
230 totLAbs += GetHit(i)->GetTrakAbs();
231 totEGap += GetHit(i)->GetEdepGap();
232 totLGap += GetHit(i)->GetTrakGap();
233 }
234
235 cout << " Absorber: total energy (MeV): " << setw(7) << totEAbs * 1.0e03
236 << " total track length (cm): " << setw(7) << totLAbs << endl
237 << " Gap: total energy (MeV): " << setw(7) << totEGap * 1.0e03
238 << " total track length (cm): " << setw(7) << totLGap << endl;
239}
Double_t GetEdepGap()
Double_t GetTrakGap()
Double_t GetEdepAbs()
Double_t GetTrakAbs()

◆ SetVerboseLevel()

void Ex03cCalorimeterSD::SetVerboseLevel ( Int_t level)
inline

Set verbose level

Parameters
levelThe new verbose level value

Definition at line 78 of file Ex03cCalorimeterSD.h.

79{
80 fVerboseLevel = level;
81}

◆ GetHit()

Ex03CalorHit * Ex03cCalorimeterSD::GetHit ( Int_t i) const
Returns
The hit for the specified layer.
Parameters
iThe layer number

Definition at line 109 of file Ex03cCalorimeterSD.cxx.

110{
111 /// \return The hit for the specified layer.
112 /// \param i The layer number
113
114 return (Ex03CalorHit*)fCalCollection->At(i);
115}

◆ ResetHits()

void Ex03cCalorimeterSD::ResetHits ( )
private

Reset all hits in the hits collection.

Definition at line 118 of file Ex03cCalorimeterSD.cxx.

119{
120 /// Reset all hits in the hits collection.
121
122 for (Int_t i = 0; i < fCalCollection->GetEntriesFast(); i++)
123 GetHit(i)->Reset();
124}

Member Data Documentation

◆ fMC

TVirtualMC* Ex03cCalorimeterSD::fMC
private

The VMC implementation.

Definition at line 66 of file Ex03cCalorimeterSD.h.

◆ fDetector

Ex03cDetectorConstruction* Ex03cCalorimeterSD::fDetector
private

Detector construction.

Definition at line 67 of file Ex03cCalorimeterSD.h.

◆ fCalCollection

TClonesArray* Ex03cCalorimeterSD::fCalCollection
private

Hits collection.

Definition at line 68 of file Ex03cCalorimeterSD.h.

◆ fAbsorberVolId

Int_t Ex03cCalorimeterSD::fAbsorberVolId
private

The absorber volume Id.

Definition at line 69 of file Ex03cCalorimeterSD.h.

◆ fGapVolId

Int_t Ex03cCalorimeterSD::fGapVolId
private

The gap volume Id.

Definition at line 70 of file Ex03cCalorimeterSD.h.

◆ fVerboseLevel

Int_t Ex03cCalorimeterSD::fVerboseLevel
private

Verbosity level.

Definition at line 71 of file Ex03cCalorimeterSD.h.


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