VMC Examples Version 6.7
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
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)
 
Ex03CalorHitGetHit (Int_t i) const
 

Private Member Functions

void ResetHits ()
 

Private Attributes

TVirtualMC * fMC
 The VMC implementation.
 
Ex03DetectorConstructionfDetector
 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.
 

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 38 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),
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}
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 61 of file Ex03bCalorimeterSD.cxx.

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

◆ Ex03bCalorimeterSD() [3/3]

Ex03bCalorimeterSD::Ex03bCalorimeterSD ( )

Default constructor

Definition at line 85 of file Ex03bCalorimeterSD.cxx.

86 : TVirtualMCSensitiveDetector(),
87 fDetector(0),
90 fGapVolId(0),
92{
93 /// Default constructor
94}

◆ ~Ex03bCalorimeterSD()

Ex03bCalorimeterSD::~Ex03bCalorimeterSD ( )
virtual

Destructor

Definition at line 97 of file Ex03bCalorimeterSD.cxx.

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

Member Function Documentation

◆ Initialize()

void Ex03bCalorimeterSD::Initialize ( )

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

Definition at line 132 of file Ex03bCalorimeterSD.cxx.

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

◆ ProcessHits()

void Ex03bCalorimeterSD::ProcessHits ( )
virtual

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

Definition at line 149 of file Ex03bCalorimeterSD.cxx.

150{
151 /// Account energy deposit and track lengths for each layer in its hit.
152
153 Int_t copyNo;
154 Int_t id = fMC->CurrentVolID(copyNo);
155
156 if (id != fAbsorberVolId && id != fGapVolId) return;
157
158 fMC->CurrentVolOffID(2, copyNo);
159
160 Double_t edep = fMC->Edep();
161
162 Double_t step = 0.;
163 if (fMC->TrackCharge() != 0.) step = fMC->TrackStep();
164
165 if (!GetHit(copyNo)) {
166 return;
167 }
168
169 if (id == fAbsorberVolId) {
170 GetHit(copyNo)->AddAbs(edep, step);
171 }
172
173 if (id == fGapVolId) {
174 GetHit(copyNo)->AddGap(edep, step);
175 }
176}
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 179 of file Ex03bCalorimeterSD.cxx.

180{
181 /// Print hits collection (if verbose) and reset hits afterwards.
182
183 if (gMC->CurrentEvent() % fPrintModulo == 0) {
184 PrintTotal();
185 }
186
187 if (fVerboseLevel > 1) Print();
188
189 // Reset hits collection
190 ResetHits();
191}
virtual void Print(Option_t *option="") const

◆ Register()

void Ex03bCalorimeterSD::Register ( )

Register the hits collection in Root manager.

Definition at line 194 of file Ex03bCalorimeterSD.cxx.

195{
196 /// Register the hits collection in Root manager.
197
198 TMCRootManager::Instance()->Register("hits", "TClonesArray", &fCalCollection);
199}

◆ Print()

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

Print the hits collection.

Definition at line 202 of file Ex03bCalorimeterSD.cxx.

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

◆ PrintTotal()

void Ex03bCalorimeterSD::PrintTotal ( ) const

Print the total values for all layers.

Definition at line 214 of file Ex03bCalorimeterSD.cxx.

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

81{
82 fVerboseLevel = level;
83}

◆ 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 87 of file Ex03bCalorimeterSD.h.

88{
89 fPrintModulo = value;
90}

◆ GetHit()

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

Definition at line 110 of file Ex03bCalorimeterSD.cxx.

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

◆ ResetHits()

void Ex03bCalorimeterSD::ResetHits ( )
private

Reset all hits in the hits collection.

Definition at line 119 of file Ex03bCalorimeterSD.cxx.

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

Member Data Documentation

◆ fMC

TVirtualMC* Ex03bCalorimeterSD::fMC
private

The VMC implementation.

Definition at line 67 of file Ex03bCalorimeterSD.h.

◆ fDetector

Ex03DetectorConstruction* Ex03bCalorimeterSD::fDetector
private

Detector construction.

Definition at line 68 of file Ex03bCalorimeterSD.h.

◆ fCalCollection

TClonesArray* Ex03bCalorimeterSD::fCalCollection
private

Hits collection.

Definition at line 69 of file Ex03bCalorimeterSD.h.

◆ fAbsorberVolId

Int_t Ex03bCalorimeterSD::fAbsorberVolId
private

The absorber volume Id.

Definition at line 70 of file Ex03bCalorimeterSD.h.

◆ fGapVolId

Int_t Ex03bCalorimeterSD::fGapVolId
private

The gap volume Id.

Definition at line 71 of file Ex03bCalorimeterSD.h.

◆ fVerboseLevel

Int_t Ex03bCalorimeterSD::fVerboseLevel
private

Verbosity level.

Definition at line 72 of file Ex03bCalorimeterSD.h.

◆ fPrintModulo

Int_t Ex03bCalorimeterSD::fPrintModulo
private

The event modulus number to be printed.

Definition at line 73 of file Ex03bCalorimeterSD.h.


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