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

The calorimeter sensitive detector. More...

#include <Ex03CalorimeterSD.h>

Inheritance diagram for Ex03CalorimeterSD:

Public Member Functions

 Ex03CalorimeterSD (const char *name, Ex03DetectorConstruction *detector)
 Ex03CalorimeterSD (const Ex03CalorimeterSD &origin, Ex03DetectorConstruction *detector)
 Ex03CalorimeterSD ()
virtual ~Ex03CalorimeterSD ()
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.
TClonesArray * fCalCollection
 Hits collection.
Int_t fAbsorberVolId
 The absorber volume Id.
Int_t fGapVolId
 The gap volume Id.
Bool_t fAssemblyHierarchyPrinted
 Whether assembly levels were printed.
Int_t fVerboseLevel
 Verbosity level.

Detailed Description

The calorimeter sensitive detector.

Date
06/03/2003
Author
I. Hrivnacova; IPN, Orsay

Definition at line 35 of file Ex03CalorimeterSD.h.

Constructor & Destructor Documentation

◆ Ex03CalorimeterSD() [1/3]

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

39 : TNamed(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}
Ex03DetectorConstruction * fDetector
Detector construction.
TClonesArray * fCalCollection
Hits collection.
Int_t fVerboseLevel
Verbosity level.
Bool_t fAssemblyHierarchyPrinted
Whether assembly levels were printed.
Int_t fGapVolId
The gap volume Id.
Int_t fAbsorberVolId
The absorber volume Id.
TVirtualMC * fMC
The VMC implementation.

◆ Ex03CalorimeterSD() [2/3]

Ex03CalorimeterSD::Ex03CalorimeterSD ( const Ex03CalorimeterSD & 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 Ex03CalorimeterSD.cxx.

63 : TNamed(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}

◆ Ex03CalorimeterSD() [3/3]

Ex03CalorimeterSD::Ex03CalorimeterSD ( )

Default constructor

Definition at line 85 of file Ex03CalorimeterSD.cxx.

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

◆ ~Ex03CalorimeterSD()

Ex03CalorimeterSD::~Ex03CalorimeterSD ( )
virtual

Destructor

Definition at line 98 of file Ex03CalorimeterSD.cxx.

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

Member Function Documentation

◆ Initialize()

void Ex03CalorimeterSD::Initialize ( )

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

Definition at line 133 of file Ex03CalorimeterSD.cxx.

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

◆ ProcessHits()

Bool_t Ex03CalorimeterSD::ProcessHits ( )

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

Definition at line 150 of file Ex03CalorimeterSD.cxx.

151{
152 /// Account energy deposit and track lengths for each layer in its hit.
153
154 Int_t copyNo;
155 Int_t id = fMC->CurrentVolID(copyNo);
156
157 if (id != fAbsorberVolId && id != fGapVolId) return false;
158
159 if (fDetector->GetUseAssemblies() && !fAssemblyHierarchyPrinted) {
161 cout << "Assembly volume hierarchy:" << endl;
162 for (Int_t off = 0; off <= 6; ++off) {
163 Int_t offCopyNo = -1;
164 TString offName = fMC->CurrentVolOffName(off);
165 Int_t offId = fMC->CurrentVolOffID(off, offCopyNo);
166 cout << " off=" << off << " name=" << offName << " id=" << offId
167 << " copyNo=" << offCopyNo << endl;
168 }
169 }
170
171 fMC->CurrentVolOffID(2, copyNo);
172 // cout << "Got copyNo "<< copyNo << " " << fMC->CurrentVolPath() << endl;
173
174 Double_t edep = fMC->Edep();
175
176 Double_t step = 0.;
177 if (fMC->TrackCharge() != 0.) step = fMC->TrackStep();
178
179 if (!GetHit(copyNo)) {
180 std::cerr << "No hit found for layer with copyNo = " << copyNo << endl;
181 return false;
182 }
183
184 if (id == fAbsorberVolId) {
185 GetHit(copyNo)->AddAbs(edep, step);
186 }
187
188 if (id == fGapVolId) {
189 GetHit(copyNo)->AddGap(edep, step);
190 }
191
192 return true;
193}
void AddAbs(Double_t de, Double_t dl)
void AddGap(Double_t de, Double_t dl)
Ex03CalorHit * GetHit(Int_t i) const

◆ EndOfEvent()

void Ex03CalorimeterSD::EndOfEvent ( )

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

Definition at line 196 of file Ex03CalorimeterSD.cxx.

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

◆ Register()

void Ex03CalorimeterSD::Register ( )

Register the hits collection in Root manager.

Definition at line 207 of file Ex03CalorimeterSD.cxx.

208{
209 /// Register the hits collection in Root manager.
210
211 TMCRootManager::Instance()->Register("hits", "TClonesArray", &fCalCollection);
212}

◆ Print()

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

Print the hits collection.

Definition at line 215 of file Ex03CalorimeterSD.cxx.

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

◆ PrintTotal()

void Ex03CalorimeterSD::PrintTotal ( ) const

Print the total values for all layers.

Definition at line 227 of file Ex03CalorimeterSD.cxx.

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

◆ SetVerboseLevel()

void Ex03CalorimeterSD::SetVerboseLevel ( Int_t level)
inline

Set verbose level

Parameters
levelThe new verbose level value

Definition at line 76 of file Ex03CalorimeterSD.h.

77{
78 fVerboseLevel = level;
79}

◆ GetHit()

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

Definition at line 111 of file Ex03CalorimeterSD.cxx.

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

◆ ResetHits()

void Ex03CalorimeterSD::ResetHits ( )
private

Reset all hits in the hits collection.

Definition at line 120 of file Ex03CalorimeterSD.cxx.

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

Member Data Documentation

◆ fMC

TVirtualMC* Ex03CalorimeterSD::fMC
private

The VMC implementation.

Definition at line 63 of file Ex03CalorimeterSD.h.

◆ fDetector

Ex03DetectorConstruction* Ex03CalorimeterSD::fDetector
private

Detector construction.

Definition at line 64 of file Ex03CalorimeterSD.h.

◆ fCalCollection

TClonesArray* Ex03CalorimeterSD::fCalCollection
private

Hits collection.

Definition at line 65 of file Ex03CalorimeterSD.h.

◆ fAbsorberVolId

Int_t Ex03CalorimeterSD::fAbsorberVolId
private

The absorber volume Id.

Definition at line 66 of file Ex03CalorimeterSD.h.

◆ fGapVolId

Int_t Ex03CalorimeterSD::fGapVolId
private

The gap volume Id.

Definition at line 67 of file Ex03CalorimeterSD.h.

◆ fAssemblyHierarchyPrinted

Bool_t Ex03CalorimeterSD::fAssemblyHierarchyPrinted
private

Whether assembly levels were printed.

Definition at line 68 of file Ex03CalorimeterSD.h.

◆ fVerboseLevel

Int_t Ex03CalorimeterSD::fVerboseLevel
private

Verbosity level.

Definition at line 69 of file Ex03CalorimeterSD.h.


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