VMC Examples Version 6.6
Loading...
Searching...
No Matches
A01EmCalorimeterSD Class Reference

The EM calorimeter sensitive detector. More...

#include <A01EmCalorimeterSD.h>

Inheritance diagram for A01EmCalorimeterSD:

Public Member Functions

 A01EmCalorimeterSD (const char *name)
 
 A01EmCalorimeterSD (const A01EmCalorimeterSD &origin)
 
 A01EmCalorimeterSD ()
 
virtual ~A01EmCalorimeterSD ()
 
void Initialize ()
 
Bool_t ProcessHits ()
 
void EndOfEvent ()
 
void Register ()
 
virtual void Print (Option_t *option="") const
 
void PrintTotal () const
 
void SetWriteHits (Bool_t writeHits)
 
void SetVerboseLevel (Int_t level)
 
A01EmCalorHitGetHit (Int_t i) const
 

Private Member Functions

void ResetHits ()
 

Private Attributes

TClonesArray * fCalCollection
 Hits collection.
 
Int_t fVolId
 The calorimeter volume Id.
 
Bool_t fWriteHits
 Option to write hits.
 
Int_t fVerboseLevel
 Verbosity level.
 

Static Private Attributes

static const Int_t fgkNofColumns = 20
 
static const Int_t fgkNofRows = 4
 

Detailed Description

The EM calorimeter sensitive detector.

Author
I. Hrivnacova; IPN, Orsay

Definition at line 30 of file A01EmCalorimeterSD.h.

Constructor & Destructor Documentation

◆ A01EmCalorimeterSD() [1/3]

A01EmCalorimeterSD::A01EmCalorimeterSD ( const char * name)

Standard constructor. Create hits collection and an empty hit for each layer.

Parameters
nameThe calorimeter hits collection name

Definition at line 37 of file A01EmCalorimeterSD.cxx.

38 : TNamed(name, ""),
40 fVolId(0),
41 fWriteHits(true),
43{
44 /// Standard constructor.
45 /// Create hits collection and an empty hit for each layer.
46 /// \param name The calorimeter hits collection name
47
49 new TClonesArray("A01EmCalorHit", fgkNofColumns * fgkNofRows);
50 for (Int_t i = 0; i < fgkNofColumns * fgkNofRows; i++)
51 new ((*fCalCollection)[i]) A01EmCalorHit();
52}
The EM calorimeter hit.
Int_t fVolId
The calorimeter volume Id.
static const Int_t fgkNofRows
Bool_t fWriteHits
Option to write hits.
Int_t fVerboseLevel
Verbosity level.
TClonesArray * fCalCollection
Hits collection.
static const Int_t fgkNofColumns

◆ A01EmCalorimeterSD() [2/3]

A01EmCalorimeterSD::A01EmCalorimeterSD ( const A01EmCalorimeterSD & origin)

Copy constructor (for clonig on worker thread in MT mode). Create hits collection and an empty hit for each layer

Parameters
originThe source object (on master).

Definition at line 55 of file A01EmCalorimeterSD.cxx.

56 : TNamed(origin),
58 fVolId(origin.fVolId),
59 fWriteHits(origin.fWriteHits),
61{
62 /// Copy constructor (for clonig on worker thread in MT mode).
63 /// Create hits collection and an empty hit for each layer
64 /// \param origin The source object (on master).
65
67 new TClonesArray("A01EmCalorHit", fgkNofColumns * fgkNofRows);
68 for (Int_t i = 0; i < fgkNofColumns * fgkNofRows; i++)
69 new ((*fCalCollection)[i]) A01EmCalorHit();
70}

◆ A01EmCalorimeterSD() [3/3]

A01EmCalorimeterSD::A01EmCalorimeterSD ( )

Default constructor

Definition at line 73 of file A01EmCalorimeterSD.cxx.

75{
76 /// Default constructor
77}

◆ ~A01EmCalorimeterSD()

A01EmCalorimeterSD::~A01EmCalorimeterSD ( )
virtual

Destructor

Definition at line 80 of file A01EmCalorimeterSD.cxx.

81{
82 /// Destructor
83
84 if (fCalCollection) fCalCollection->Delete();
85 delete fCalCollection;
86}

Member Function Documentation

◆ Initialize()

void A01EmCalorimeterSD::Initialize ( )

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

Definition at line 106 of file A01EmCalorimeterSD.cxx.

107{
108 /// Register hits collection in the Root manager;
109 /// set sensitive volumes.
110
111 if (TMCRootManager::Instance()) Register();
112
113 fVolId = gMC->VolId("cellLogical");
114}

◆ ProcessHits()

Bool_t A01EmCalorimeterSD::ProcessHits ( )

Account energy deposit for each layer in its hit.

Definition at line 117 of file A01EmCalorimeterSD.cxx.

118{
119 /// Account energy deposit for each layer in its hit.
120
121 Int_t copyNo;
122 Int_t id = gMC->CurrentVolID(copyNo);
123 if (id != fVolId) return false;
124
125 Double_t edep = gMC->Edep();
126 if (edep == 0.) return false;
127
128 Int_t rowNo = copyNo;
129 Int_t columnNo;
130 gMC->CurrentVolOffID(1, columnNo);
131 // VMC adopts Root numbering of divisions starting from 1
132 rowNo--;
133 columnNo--;
134 Int_t hitID = fgkNofRows * columnNo + rowNo;
135
136 A01EmCalorHit* hit = GetHit(hitID);
137 if (!hit) {
138 std::cerr << "No hit found for layer with copyNo = " << copyNo << endl;
139 return false;
140 }
141
142 // check if it is the first touch
143 if (hit->GetVolId() < 0) {
144 // Debug printing (to check hits indexing)
145 // cout << "EmCalorimeter: First Add in hit in (column, row): "
146 // << columnNo << ", " << rowNo << endl;
147 // cout << "gMC->CurrentVolName(), gMC->CurrentVolOffName(1): "
148 // << gMC->CurrentVolName() << ", " << gMC->CurrentVolOffName(1) <<
149 // endl;
150
151 // fill volume information
152 hit->SetVolId(fVolId);
153 // get transformation
154 // add later
155 }
156
157 // cout << "Adding edep [MeV]" << edep*1e03 << " in copyNo " << copyNo <<
158 // endl;
159
160 // add energy deposition
161 hit->AddEdep(edep);
162
163 return true;
164}
void AddEdep(Double_t de)
Int_t GetVolId() const
void SetVolId(Int_t volId)
A01EmCalorHit * GetHit(Int_t i) const

◆ EndOfEvent()

void A01EmCalorimeterSD::EndOfEvent ( )

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

Definition at line 167 of file A01EmCalorimeterSD.cxx.

168{
169 /// Print hits collection (if verbose) and reset hits afterwards.
170
171 if (fVerboseLevel > 0) PrintTotal();
172
173 // Reset hits collection
174 ResetHits();
175}

◆ Register()

void A01EmCalorimeterSD::Register ( )

Register the hits collection in Root manager.

Definition at line 178 of file A01EmCalorimeterSD.cxx.

179{
180 /// Register the hits collection in Root manager.
181
182 if (fWriteHits) {
183 TMCRootManager::Instance()->Register(
184 GetName(), "TClonesArray", &fCalCollection);
185 }
186}

◆ Print()

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

Print the hits collection.

Definition at line 189 of file A01EmCalorimeterSD.cxx.

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

◆ PrintTotal()

void A01EmCalorimeterSD::PrintTotal ( ) const

Print the total values for all layers.

Definition at line 203 of file A01EmCalorimeterSD.cxx.

204{
205 /// Print the total values for all layers.
206
207 Int_t nofHits = 0;
208 Double_t totalEdep = 0.;
209 for (Int_t i = 0; i < fgkNofColumns * fgkNofRows; ++i) {
210 Double_t edep = GetHit(i)->GetEdep();
211 if (edep > 0.) {
212 nofHits++;
213 totalEdep += edep;
214 }
215 }
216 cout << GetName() << " has " << nofHits << " hits. Total Edep is "
217 << totalEdep * 1e03 << " (MeV)" << endl;
218}
Double_t GetEdep() const

◆ SetWriteHits()

void A01EmCalorimeterSD::SetWriteHits ( Bool_t writeHits)
inline

(In)Activate writing hits on file

Parameters
writeHitsThe new value of the option

Definition at line 72 of file A01EmCalorimeterSD.h.

73{
74 fWriteHits = writeHits;
75}

◆ SetVerboseLevel()

void A01EmCalorimeterSD::SetVerboseLevel ( Int_t level)
inline

Set verbose level

Parameters
levelThe new verbose level value

Definition at line 79 of file A01EmCalorimeterSD.h.

80{
81 fVerboseLevel = level;
82}

◆ GetHit()

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

Definition at line 221 of file A01EmCalorimeterSD.cxx.

222{
223 /// \return The hit for the specified layer.
224 /// \param i The layer number
225
226 return (A01EmCalorHit*)fCalCollection->At(i);
227}

◆ ResetHits()

void A01EmCalorimeterSD::ResetHits ( )
private

Reset all hits in the hits collection.

Definition at line 93 of file A01EmCalorimeterSD.cxx.

94{
95 /// Reset all hits in the hits collection.
96
97 for (Int_t i = 0; i < fCalCollection->GetEntriesFast(); i++)
98 GetHit(i)->Reset();
99}

Member Data Documentation

◆ fgkNofColumns

const Int_t A01EmCalorimeterSD::fgkNofColumns = 20
staticprivate

Definition at line 58 of file A01EmCalorimeterSD.h.

◆ fgkNofRows

const Int_t A01EmCalorimeterSD::fgkNofRows = 4
staticprivate

Definition at line 59 of file A01EmCalorimeterSD.h.

◆ fCalCollection

TClonesArray* A01EmCalorimeterSD::fCalCollection
private

Hits collection.

Definition at line 62 of file A01EmCalorimeterSD.h.

◆ fVolId

Int_t A01EmCalorimeterSD::fVolId
private

The calorimeter volume Id.

Definition at line 63 of file A01EmCalorimeterSD.h.

◆ fWriteHits

Bool_t A01EmCalorimeterSD::fWriteHits
private

Option to write hits.

Definition at line 64 of file A01EmCalorimeterSD.h.

◆ fVerboseLevel

Int_t A01EmCalorimeterSD::fVerboseLevel
private

Verbosity level.

Definition at line 65 of file A01EmCalorimeterSD.h.


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