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

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 37 of file Ex03dCalorimeterSD.cxx.

39 : TNamed(name, ""),
40 fMC(0),
41 fDetector(detector),
43 fGapVolId(0),
45{
46 /// Standard constructor.
47 /// Create hits collection and an empty hit for each layer
48 /// As the copy numbers may start from 0 or 1 (depending on
49 /// geometry model, we create one more layer for this case.)
50 /// \param name The calorimeter hits collection name
51 /// \param detector The detector construction
52
53 for (Int_t i = 0; i < fDetector->GetNbOfLayers() + 1; i++)
54 fCalCollection->push_back(Ex03CalorHit());
55}
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 58 of file Ex03dCalorimeterSD.cxx.

60 : TNamed(origin),
61 fMC(0),
62 fDetector(detector),
64 fGapVolId(origin.fGapVolId),
66{
67 /// Copy constructor (for clonig on worker thread in MT mode).
68 /// Create hits collection and an empty hit for each layer
69 /// As the copy numbers may start from 0 or 1 (depending on
70 /// geometry model, we create one more layer for this case.)
71 /// \param origin The source object (on master).
72 /// \param detector The detector construction
73
74 for (Int_t i = 0; i < fDetector->GetNbOfLayers() + 1; i++)
75 fCalCollection->push_back(Ex03CalorHit());
76}

◆ Ex03dCalorimeterSD() [3/3]

Ex03dCalorimeterSD::Ex03dCalorimeterSD ( )

Default constructor

Definition at line 79 of file Ex03dCalorimeterSD.cxx.

80 : TNamed(), fDetector(0), fAbsorberVolId(0), fGapVolId(0), fVerboseLevel(1)
81{
82 /// Default constructor
83}

◆ ~Ex03dCalorimeterSD()

Ex03dCalorimeterSD::~Ex03dCalorimeterSD ( )
virtual

Destructor

Definition at line 86 of file Ex03dCalorimeterSD.cxx.

87{
88 /// Destructor
89
90 delete fCalCollection;
91}

Member Function Documentation

◆ Initialize()

void Ex03dCalorimeterSD::Initialize ( )

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

Definition at line 119 of file Ex03dCalorimeterSD.cxx.

120{
121 /// Register hits collection in the Root manager;
122 /// set sensitive volumes.
123 if (TMCRootManager::Instance()) Register();
124
125 // Keep the pointer to TVirtualMC object as a data member
126 // to avoid a possible performance penalty due to a frequent retrieval
127 // from the thread-local storage
128 fMC = gMC;
129
130 fAbsorberVolId = fMC->VolId("ABSO");
131 fGapVolId = fMC->VolId("GAPX");
132}

◆ ProcessHits()

Bool_t Ex03dCalorimeterSD::ProcessHits ( )

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

Definition at line 135 of file Ex03dCalorimeterSD.cxx.

136{
137 /// Account energy deposit and track lengths for each layer in its hit.
138
139 Int_t copyNo;
140 Int_t id = fMC->CurrentVolID(copyNo);
141
142 if (id != fAbsorberVolId && id != fGapVolId) return false;
143
144 fMC->CurrentVolOffID(2, copyNo);
145 // cout << "Got copyNo "<< copyNo << " " << fMC->CurrentVolPath() << endl;
146
147 Double_t edep = fMC->Edep();
148
149 Double_t step = 0.;
150 if (fMC->TrackCharge() != 0.) step = fMC->TrackStep();
151
152 if (!GetHit(copyNo)) {
153 std::cerr << "No hit found for layer with copyNo = " << copyNo << endl;
154 return false;
155 }
156
157 if (id == fAbsorberVolId) {
158 GetHit(copyNo)->AddAbs(edep, step);
159 }
160
161 if (id == fGapVolId) {
162 GetHit(copyNo)->AddGap(edep, step);
163 }
164
165 return true;
166}
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 169 of file Ex03dCalorimeterSD.cxx.

170{
171 /// Print hits collection (if verbose) and reset hits afterwards.
172
173 if (fVerboseLevel > 1) Print();
174
175 // Reset hits collection
176 ResetHits();
177}
virtual void Print(Option_t *option="") const

◆ Register()

void Ex03dCalorimeterSD::Register ( )

Register the hits collection in Root manager.

Definition at line 180 of file Ex03dCalorimeterSD.cxx.

181{
182 /// Register the hits collection in Root manager.
183 TMCRootManager::Instance()->Register("hits", fCalCollection);
184 // TMCRootManager::Instance()->Register("hits", "std::vector<Ex03CalorHit>",
185 // &fCalCollection);
186}

◆ Print()

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

Print the hits collection.

Definition at line 189 of file Ex03dCalorimeterSD.cxx.

190{
191 /// Print the hits collection.
192
193 Int_t nofHits = fCalCollection->size();
194
195 cout << "\n-------->Hits Collection: in this event: " << endl;
196
197 for (Int_t i = 0; i < nofHits; i++) (*fCalCollection)[i].Print();
198}

◆ PrintTotal()

void Ex03dCalorimeterSD::PrintTotal ( ) const

Print the total values for all layers.

Definition at line 201 of file Ex03dCalorimeterSD.cxx.

202{
203 /// Print the total values for all layers.
204
205 Double_t totEAbs = 0.;
206 Double_t totLAbs = 0.;
207 Double_t totEGap = 0.;
208 Double_t totLGap = 0.;
209
210 Int_t nofHits = fCalCollection->size();
211 for (Int_t i = 0; i < nofHits; i++) {
212 totEAbs += GetHit(i)->GetEdepAbs();
213 totLAbs += GetHit(i)->GetTrakAbs();
214 totEGap += GetHit(i)->GetEdepGap();
215 totLGap += GetHit(i)->GetTrakGap();
216 }
217
218 cout << " Absorber: total energy (MeV): " << setw(7) << totEAbs * 1.0e03
219 << " total track length (cm): " << setw(7) << totLAbs << endl
220 << " Gap: total energy (MeV): " << setw(7) << totEGap * 1.0e03
221 << " total track length (cm): " << setw(7) << totLGap << endl;
222}
Double_t GetEdepGap()
Double_t GetTrakGap()
Double_t GetEdepAbs()
Double_t GetTrakAbs()

◆ SetVerboseLevel()

void Ex03dCalorimeterSD::SetVerboseLevel ( Int_t level)
inline

Set verbose level

Parameters
levelThe new verbose level value

Definition at line 81 of file Ex03dCalorimeterSD.h.

82{
83 fVerboseLevel = level;
84}

◆ GetHit()

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

Definition at line 98 of file Ex03dCalorimeterSD.cxx.

99{
100 /// \return The hit for the specified layer.
101 /// \param i The layer number
102
103 return &(*fCalCollection)[i];
104}

◆ ResetHits()

void Ex03dCalorimeterSD::ResetHits ( )
private

Reset all hits in the hits collection.

Definition at line 107 of file Ex03dCalorimeterSD.cxx.

108{
109 /// Reset all hits in the hits collection.
110
111 for (Int_t i = 0; i < fCalCollection->size(); i++) GetHit(i)->Reset();
112}

Member Data Documentation

◆ fMC

TVirtualMC* Ex03dCalorimeterSD::fMC
private

The VMC implementation.

Definition at line 67 of file Ex03dCalorimeterSD.h.

◆ fDetector

Ex03DetectorConstruction* Ex03dCalorimeterSD::fDetector
private

Detector construction.

Definition at line 68 of file Ex03dCalorimeterSD.h.

◆ fCalCollection

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

Definition at line 69 of file Ex03dCalorimeterSD.h.

69 {
70 new std::vector<Ex03CalorHit>
71 }; //! < The vector of particle (persistent)

◆ fAbsorberVolId

Int_t Ex03dCalorimeterSD::fAbsorberVolId
private

< The vector of particle (persistent)

The absorber volume Id

Definition at line 72 of file Ex03dCalorimeterSD.h.

◆ fGapVolId

Int_t Ex03dCalorimeterSD::fGapVolId
private

The gap volume Id.

Definition at line 73 of file Ex03dCalorimeterSD.h.

◆ fVerboseLevel

Int_t Ex03dCalorimeterSD::fVerboseLevel
private

Verbosity level.

Definition at line 74 of file Ex03dCalorimeterSD.h.


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