VMC Examples Version 6.8
Loading...
Searching...
No Matches
Ex03dCalorimeterSD Class Reference

The calorimeter sensitive detector. More...

#include <Ex03dCalorimeterSD.h>

Inheritance diagram for Ex03dCalorimeterSD:

Public Member Functions

 Ex03dCalorimeterSD (const char *name, Ex03DetectorConstruction *detector)
 Ex03dCalorimeterSD (const Ex03dCalorimeterSD &origin, Ex03DetectorConstruction *detector)
 Ex03dCalorimeterSD ()
virtual ~Ex03dCalorimeterSD ()
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

Static Public Member Functions

static void PrintTotal (std::vector< Ex03CalorHit > *collection)

Private Member Functions

void ResetHits ()

Private Attributes

TVirtualMC * fMC
 The VMC implementation.
Ex03DetectorConstructionfDetector
 Detector construction.
std::vector< Ex03CalorHit > * fCalCollection
Int_t fAbsorberVolId
 < The vector of particle (persistent)
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 RNTuple output.

Date
07/07/2026
Author
Radoslaw Karabowicz; GSI

Definition at line 39 of file Ex03dCalorimeterSD.h.

Constructor & Destructor Documentation

◆ Ex03dCalorimeterSD() [1/3]

Ex03dCalorimeterSD::Ex03dCalorimeterSD ( const char * name,
Ex03DetectorConstruction * 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 65 of file Ex03dCalorimeterSD.cxx.

67 : TNamed(name, ""),
68 fMC(0),
69 fDetector(detector),
71 fGapVolId(0),
73{
74 /// Standard constructor.
75 /// Create hits collection and an empty hit for each layer
76 /// As the copy numbers may start from 0 or 1 (depending on
77 /// geometry model, we create one more layer for this case.)
78 /// \param name The calorimeter hits collection name
79 /// \param detector The detector construction
80
81 for (Int_t i = 0; i < fDetector->GetNbOfLayers() + 1; i++)
82 fCalCollection->push_back(Ex03CalorHit());
83}
Int_t fGapVolId
The gap volume Id.
TVirtualMC * fMC
The VMC implementation.
Int_t fAbsorberVolId
< The vector of particle (persistent)
Int_t fVerboseLevel
Verbosity level.
Ex03DetectorConstruction * fDetector
Detector construction.
std::vector< Ex03CalorHit > * fCalCollection

◆ Ex03dCalorimeterSD() [2/3]

Ex03dCalorimeterSD::Ex03dCalorimeterSD ( const Ex03dCalorimeterSD & origin,
Ex03DetectorConstruction * 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 86 of file Ex03dCalorimeterSD.cxx.

88 : TNamed(origin),
89 fMC(0),
90 fDetector(detector),
92 fGapVolId(origin.fGapVolId),
94{
95 /// Copy constructor (for clonig on worker thread in MT mode).
96 /// Create hits collection and an empty hit for each layer
97 /// As the copy numbers may start from 0 or 1 (depending on
98 /// geometry model, we create one more layer for this case.)
99 /// \param origin The source object (on master).
100 /// \param detector The detector construction
101
102 for (Int_t i = 0; i < fDetector->GetNbOfLayers() + 1; i++)
103 fCalCollection->push_back(Ex03CalorHit());
104}

◆ Ex03dCalorimeterSD() [3/3]

Ex03dCalorimeterSD::Ex03dCalorimeterSD ( )

Default constructor

Definition at line 107 of file Ex03dCalorimeterSD.cxx.

108 : TNamed(), fDetector(0), fAbsorberVolId(0), fGapVolId(0), fVerboseLevel(1)
109{
110 /// Default constructor
111}

◆ ~Ex03dCalorimeterSD()

Ex03dCalorimeterSD::~Ex03dCalorimeterSD ( )
virtual

Destructor

Definition at line 114 of file Ex03dCalorimeterSD.cxx.

115{
116 /// Destructor
117
118 delete fCalCollection;
119}

Member Function Documentation

◆ PrintTotal() [1/2]

void Ex03dCalorimeterSD::PrintTotal ( std::vector< Ex03CalorHit > * collection)
static

Print the total values for all layers for the given collection

Definition at line 39 of file Ex03dCalorimeterSD.cxx.

40{
41 /// Print the total values for all layers for the given collection
42
43 Double_t totEAbs = 0.;
44 Double_t totLAbs = 0.;
45 Double_t totEGap = 0.;
46 Double_t totLGap = 0.;
47
48 Int_t nofHits = collection->size();
49 for (auto& hit : *collection) {
50 totEAbs += hit.GetEdepAbs();
51 totLAbs += hit.GetTrakAbs();
52 totEGap += hit.GetEdepGap();
53 totLGap += hit.GetTrakGap();
54 }
55
56 cout << " Absorber: total energy (MeV): " << setw(7) << totEAbs * 1.0e03
57 << " total track length (cm): " << setw(7) << totLAbs << endl
58 << " Gap: total energy (MeV): " << setw(7) << totEGap * 1.0e03
59 << " total track length (cm): " << setw(7) << totLGap << endl;
60}

◆ Initialize()

void Ex03dCalorimeterSD::Initialize ( )

Definition at line 147 of file Ex03dCalorimeterSD.cxx.

148{
149 // Keep the pointer to TVirtualMC object as a data member
150 // to avoid a possible performance penalty due to a frequent retrieval
151 // from the thread-local storage
152 fMC = gMC;
153
154 fAbsorberVolId = fMC->VolId("ABSO");
155 fGapVolId = fMC->VolId("GAPX");
156}

◆ ProcessHits()

Bool_t Ex03dCalorimeterSD::ProcessHits ( )

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

Definition at line 159 of file Ex03dCalorimeterSD.cxx.

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

◆ EndOfEvent()

void Ex03dCalorimeterSD::EndOfEvent ( )

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

Definition at line 193 of file Ex03dCalorimeterSD.cxx.

194{
195 /// Print hits collection (if verbose) and reset hits afterwards.
196
197 if (fVerboseLevel > 1) Print();
198
199 // Reset hits collection
200 ResetHits();
201}
virtual void Print(Option_t *option="") const

◆ Register()

void Ex03dCalorimeterSD::Register ( )

Register the hits collection in Root manager.

Definition at line 204 of file Ex03dCalorimeterSD.cxx.

205{
206 /// Register the hits collection in Root manager.
207 TMCRootManager::Instance()->Register("hits", fCalCollection);
208}

◆ Print()

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

Print the hits collection.

Definition at line 211 of file Ex03dCalorimeterSD.cxx.

212{
213 /// Print the hits collection.
214
215 Int_t nofHits = fCalCollection->size();
216
217 cout << "\n-------->Hits Collection: in this event: " << endl;
218
219 for (Int_t i = 0; i < nofHits; i++) (*fCalCollection)[i].Print();
220}

◆ PrintTotal() [2/2]

void Ex03dCalorimeterSD::PrintTotal ( ) const

Print the total values for all layers.

Definition at line 223 of file Ex03dCalorimeterSD.cxx.

224{
225 /// Print the total values for all layers.
226
228}

◆ SetVerboseLevel()

void Ex03dCalorimeterSD::SetVerboseLevel ( Int_t level)
inline

Set verbose level

Parameters
levelThe new verbose level value

Definition at line 84 of file Ex03dCalorimeterSD.h.

85{
86 fVerboseLevel = level;
87}

◆ GetHit()

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

Definition at line 126 of file Ex03dCalorimeterSD.cxx.

127{
128 /// \return The hit for the specified layer.
129 /// \param i The layer number
130
131 return &(*fCalCollection)[i];
132}

◆ ResetHits()

void Ex03dCalorimeterSD::ResetHits ( )
private

Reset all hits in the hits collection.

Definition at line 135 of file Ex03dCalorimeterSD.cxx.

136{
137 /// Reset all hits in the hits collection.
138
139 for (Int_t i = 0; i < fCalCollection->size(); i++) GetHit(i)->Reset();
140}

Member Data Documentation

◆ fMC

TVirtualMC* Ex03dCalorimeterSD::fMC
private

The VMC implementation.

Definition at line 70 of file Ex03dCalorimeterSD.h.

◆ fDetector

Ex03DetectorConstruction* Ex03dCalorimeterSD::fDetector
private

Detector construction.

Definition at line 71 of file Ex03dCalorimeterSD.h.

◆ fCalCollection

std::vector<Ex03CalorHit>* Ex03dCalorimeterSD::fCalCollection
private
Initial value:
{
new std::vector<Ex03CalorHit>
}

Definition at line 72 of file Ex03dCalorimeterSD.h.

72 {
73 new std::vector<Ex03CalorHit>
74 }; //! < The vector of particle (persistent)

◆ fAbsorberVolId

Int_t Ex03dCalorimeterSD::fAbsorberVolId
private

< The vector of particle (persistent)

The absorber volume Id

Definition at line 75 of file Ex03dCalorimeterSD.h.

◆ fGapVolId

Int_t Ex03dCalorimeterSD::fGapVolId
private

The gap volume Id.

Definition at line 76 of file Ex03dCalorimeterSD.h.

◆ fVerboseLevel

Int_t Ex03dCalorimeterSD::fVerboseLevel
private

Verbosity level.

Definition at line 77 of file Ex03dCalorimeterSD.h.


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