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

The calorimeter sensitive detector. More...

#include <Ex03bCalorimeterSD.h>

Inheritance diagram for Ex03bCalorimeterSD:

Public Member Functions

 Ex03bCalorimeterSD (const char *name, Ex03DetectorConstruction *detector)
 Ex03bCalorimeterSD (const Ex03bCalorimeterSD &origin, Ex03DetectorConstruction *detector)
 Ex03bCalorimeterSD ()
virtual ~Ex03bCalorimeterSD ()
void Initialize ()
virtual void ProcessHits ()
void EndOfEvent ()
void Register ()
virtual void Print (Option_t *option="") const
void PrintTotal () const
void SetVerboseLevel (Int_t level)
void SetPrintModulo (Int_t value)
Ex03CalorHit * GetHit (Int_t i) const

Private Member Functions

void ResetHits ()

Private Attributes

TVirtualMC * fMC
 The VMC implementation.
Ex03DetectorConstruction * fDetector
 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.
Int_t fPrintModulo
 The event modulus number to be printed.
Ex03CalorHit fReflectedHit
 Reflected contribution to the layer hits.

Detailed Description

The calorimeter sensitive detector.

A variant of the Ex03CalorimeterSD: a sensitive detector class derived fron the new TVirtualMCSensitiveDetector interface

Author
I. Hrivnacova; IPN, Orsay

Definition at line 39 of file Ex03bCalorimeterSD.h.

Constructor & Destructor Documentation

◆ Ex03bCalorimeterSD() [1/3]

Ex03bCalorimeterSD::Ex03bCalorimeterSD ( 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 Ex03bCalorimeterSD.cxx.

39 : TVirtualMCSensitiveDetector(name, ""),
40 fMC(0),
41 fDetector(detector),
44 fGapVolId(0),
46 fPrintModulo(1),
48{
49 /// Standard constructor.
50 /// Create hits collection and an empty hit for each layer
51 /// As the copy numbers may start from 0 or 1 (depending on
52 /// geometry model, we create one more layer for this case.)
53 /// \param name The calorimeter hits collection name
54 /// \param detector The detector construction
55
56 fCalCollection = new TClonesArray("Ex03CalorHit", 500);
57 for (Int_t i = 0; i < fDetector->GetNbOfLayers() + 1; i++)
58 new ((*fCalCollection)[i]) Ex03CalorHit();
59}
Ex03CalorHit fReflectedHit
Reflected contribution to the layer hits.
TVirtualMC * fMC
The VMC implementation.
Int_t fPrintModulo
The event modulus number to be printed.
Ex03DetectorConstruction * fDetector
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.

◆ Ex03bCalorimeterSD() [2/3]

Ex03bCalorimeterSD::Ex03bCalorimeterSD ( const Ex03bCalorimeterSD & 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 62 of file Ex03bCalorimeterSD.cxx.

64 : TVirtualMCSensitiveDetector(origin),
65 fMC(0),
66 fDetector(detector),
69 fGapVolId(origin.fGapVolId),
73{
74 /// Copy constructor (for clonig on worker thread in MT mode).
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 origin The source object (on master).
79 /// \param detector The detector construction
80
81 fCalCollection = new TClonesArray("Ex03CalorHit", 500);
82 for (Int_t i = 0; i < fDetector->GetNbOfLayers() + 1; i++)
83 new ((*fCalCollection)[i]) Ex03CalorHit();
84}

◆ Ex03bCalorimeterSD() [3/3]

Ex03bCalorimeterSD::Ex03bCalorimeterSD ( )

Default constructor

Definition at line 87 of file Ex03bCalorimeterSD.cxx.

88 : TVirtualMCSensitiveDetector(),
89 fDetector(0),
92 fGapVolId(0),
95{
96 /// Default constructor
97}

◆ ~Ex03bCalorimeterSD()

Ex03bCalorimeterSD::~Ex03bCalorimeterSD ( )
virtual

Destructor

Definition at line 100 of file Ex03bCalorimeterSD.cxx.

101{
102 /// Destructor
103
104 if (fCalCollection) fCalCollection->Delete();
105 delete fCalCollection;
106}

Member Function Documentation

◆ Initialize()

void Ex03bCalorimeterSD::Initialize ( )

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

Definition at line 135 of file Ex03bCalorimeterSD.cxx.

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

◆ ProcessHits()

void Ex03bCalorimeterSD::ProcessHits ( )
virtual

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

Definition at line 152 of file Ex03bCalorimeterSD.cxx.

153{
154 /// Account energy deposit and track lengths for each layer in its hit.
155
156 Int_t copyNo;
157 Int_t id = fMC->CurrentVolID(copyNo);
158
159 if (id != fAbsorberVolId && id != fGapVolId) return;
160
161 const Bool_t reflected = fDetector->GetUseReflection() && copyNo == 2;
162 fMC->CurrentVolOffID(2, copyNo);
163
164 Double_t edep = fMC->Edep();
165
166 Double_t step = 0.;
167 if (fMC->TrackCharge() != 0.) step = fMC->TrackStep();
168
169 if (!GetHit(copyNo)) {
170 return;
171 }
172
173 if (id == fAbsorberVolId) {
174 GetHit(copyNo)->AddAbs(edep, step);
175 if (reflected) fReflectedHit.AddAbs(edep, step);
176 }
177
178 if (id == fGapVolId) {
179 GetHit(copyNo)->AddGap(edep, step);
180 if (reflected) fReflectedHit.AddGap(edep, step);
181 }
182}
void AddAbs(Double_t de, Double_t dl)
void AddGap(Double_t de, Double_t dl)
Ex03CalorHit * GetHit(Int_t i) const

◆ EndOfEvent()

void Ex03bCalorimeterSD::EndOfEvent ( )

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

Definition at line 185 of file Ex03bCalorimeterSD.cxx.

186{
187 /// Print hits collection (if verbose) and reset hits afterwards.
188
189 if (gMC->CurrentEvent() % fPrintModulo == 0) {
190 PrintTotal();
191 }
192
193 if (fVerboseLevel > 1) Print();
194
195 if (fDetector->GetUseReflection()) {
196 cout << " Reflected placements (included in layer totals):" << endl;
197 fReflectedHit.Print();
198 }
199 if (fDetector->GetRequireReflectedHits()) {
200 if (fReflectedHit.GetEdepAbs() <= 0. || fReflectedHit.GetTrakAbs() <= 0. ||
201 fReflectedHit.GetEdepGap() <= 0. || fReflectedHit.GetTrakGap() <= 0.) {
202 Fatal("EndOfEvent", "Missing hits in reflected absorber or gap");
203 }
204 cout << " Reflected hits test passed" << endl;
205 }
206 fReflectedHit.Reset();
207
208 // Reset hits collection
209 ResetHits();
210}
virtual void Print(Option_t *option="") const

◆ Register()

void Ex03bCalorimeterSD::Register ( )

Register the hits collection in Root manager.

Definition at line 213 of file Ex03bCalorimeterSD.cxx.

214{
215 /// Register the hits collection in Root manager.
216
217 TMCRootManager::Instance()->Register("hits", "TClonesArray", &fCalCollection);
218}

◆ Print()

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

Print the hits collection.

Definition at line 221 of file Ex03bCalorimeterSD.cxx.

222{
223 /// Print the hits collection.
224
225 Int_t nofHits = fCalCollection->GetEntriesFast();
226
227 cout << "\n-------->Hits Collection: in this event: " << endl;
228
229 for (Int_t i = 0; i < nofHits; i++) (*fCalCollection)[i]->Print();
230}

◆ PrintTotal()

void Ex03bCalorimeterSD::PrintTotal ( ) const

Print the total values for all layers.

Definition at line 233 of file Ex03bCalorimeterSD.cxx.

234{
235 /// Print the total values for all layers.
236
237 Double_t totEAbs = 0.;
238 Double_t totLAbs = 0.;
239 Double_t totEGap = 0.;
240 Double_t totLGap = 0.;
241
242 Int_t nofHits = fCalCollection->GetEntriesFast();
243 for (Int_t i = 0; i < nofHits; i++) {
244 totEAbs += GetHit(i)->GetEdepAbs();
245 totLAbs += GetHit(i)->GetTrakAbs();
246 totEGap += GetHit(i)->GetEdepGap();
247 totLGap += GetHit(i)->GetTrakGap();
248 }
249
250 cout << " Absorber: total energy (MeV): " << setw(7) << totEAbs * 1.0e03
251 << " total track length (cm): " << setw(7) << totLAbs << endl
252 << " Gap: total energy (MeV): " << setw(7) << totEGap * 1.0e03
253 << " total track length (cm): " << setw(7) << totLGap << endl;
254}
Double_t GetEdepGap()
Double_t GetTrakGap()
Double_t GetEdepAbs()
Double_t GetTrakAbs()

◆ SetVerboseLevel()

void Ex03bCalorimeterSD::SetVerboseLevel ( Int_t level)
inline

Set verbose level

Parameters
levelThe new verbose level value

Definition at line 83 of file Ex03bCalorimeterSD.h.

84{
85 fVerboseLevel = level;
86}

◆ SetPrintModulo()

void Ex03bCalorimeterSD::SetPrintModulo ( Int_t value)
inline

Set the event modulus number to be printed

Parameters
valueThe new event modulus number value

Definition at line 90 of file Ex03bCalorimeterSD.h.

91{
92 fPrintModulo = value;
93}

◆ GetHit()

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

Definition at line 113 of file Ex03bCalorimeterSD.cxx.

114{
115 /// \return The hit for the specified layer.
116 /// \param i The layer number
117
118 return (Ex03CalorHit*)fCalCollection->At(i);
119}

◆ ResetHits()

void Ex03bCalorimeterSD::ResetHits ( )
private

Reset all hits in the hits collection.

Definition at line 122 of file Ex03bCalorimeterSD.cxx.

123{
124 /// Reset all hits in the hits collection.
125
126 for (Int_t i = 0; i < fCalCollection->GetEntriesFast(); i++)
127 GetHit(i)->Reset();
128}

Member Data Documentation

◆ fMC

TVirtualMC* Ex03bCalorimeterSD::fMC
private

The VMC implementation.

Definition at line 68 of file Ex03bCalorimeterSD.h.

◆ fDetector

Ex03DetectorConstruction* Ex03bCalorimeterSD::fDetector
private

Detector construction.

Definition at line 69 of file Ex03bCalorimeterSD.h.

◆ fCalCollection

TClonesArray* Ex03bCalorimeterSD::fCalCollection
private

Hits collection.

Definition at line 70 of file Ex03bCalorimeterSD.h.

◆ fAbsorberVolId

Int_t Ex03bCalorimeterSD::fAbsorberVolId
private

The absorber volume Id.

Definition at line 71 of file Ex03bCalorimeterSD.h.

◆ fGapVolId

Int_t Ex03bCalorimeterSD::fGapVolId
private

The gap volume Id.

Definition at line 72 of file Ex03bCalorimeterSD.h.

◆ fVerboseLevel

Int_t Ex03bCalorimeterSD::fVerboseLevel
private

Verbosity level.

Definition at line 73 of file Ex03bCalorimeterSD.h.

◆ fPrintModulo

Int_t Ex03bCalorimeterSD::fPrintModulo
private

The event modulus number to be printed.

Definition at line 74 of file Ex03bCalorimeterSD.h.

◆ fReflectedHit

Ex03CalorHit Ex03bCalorimeterSD::fReflectedHit
private

Reflected contribution to the layer hits.

Definition at line 76 of file Ex03bCalorimeterSD.h.


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