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

The hadron calorimeter sensitive detector. More...

#include <A01HadCalorimeterSD.h>

Inheritance diagram for A01HadCalorimeterSD:

Public Member Functions

 A01HadCalorimeterSD (const char *name)
 
 A01HadCalorimeterSD (const A01HadCalorimeterSD &origin)
 
 A01HadCalorimeterSD ()
 
virtual ~A01HadCalorimeterSD ()
 
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)
 
A01HadCalorHitGetHit (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 = 10
 
static const Int_t fgkNofRows = 2
 

Detailed Description

The hadron calorimeter sensitive detector.

Author
I. Hrivnacova; IPN, Orsay

Definition at line 30 of file A01HadCalorimeterSD.h.

Constructor & Destructor Documentation

◆ A01HadCalorimeterSD() [1/3]

A01HadCalorimeterSD::A01HadCalorimeterSD ( const char * name)

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

Parameters
nameThe calorimeter hits collection name

Definition at line 39 of file A01HadCalorimeterSD.cxx.

40 : TNamed(name, ""),
42 fVolId(0),
43 fWriteHits(true),
45{
46 /// Standard constructor.
47 /// Create hits collection and an empty hit for each layer.
48 /// \param name The calorimeter hits collection name
49
51 new TClonesArray("A01HadCalorHit", fgkNofColumns * fgkNofRows);
52 Int_t counter = 0;
53 for (Int_t iColumn = 0; iColumn < fgkNofColumns; ++iColumn) {
54 for (Int_t iRow = 0; iRow < fgkNofRows; ++iRow) {
55 new ((*fCalCollection)[counter++]) A01HadCalorHit();
56 }
57 }
58}
The hadron calorimeter hit.
static const Int_t fgkNofRows
Int_t fVerboseLevel
Verbosity level.
Int_t fVolId
The calorimeter volume Id.
static const Int_t fgkNofColumns
Bool_t fWriteHits
Option to write hits.
TClonesArray * fCalCollection
Hits collection.

◆ A01HadCalorimeterSD() [2/3]

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

62 : TNamed(origin),
64 fVolId(origin.fVolId),
65 fWriteHits(origin.fWriteHits),
67{
68 /// Copy constructor (for clonig on worker thread in MT mode).
69 /// Create hits collection and an empty hit for each layer.
70 /// \param origin The source object (on master).
71
73 new TClonesArray("A01HadCalorHit", fgkNofColumns * fgkNofRows);
74 Int_t counter = 0;
75 for (Int_t iColumn = 0; iColumn < fgkNofColumns; ++iColumn) {
76 for (Int_t iRow = 0; iRow < fgkNofRows; ++iRow) {
77 new ((*fCalCollection)[counter++]) A01HadCalorHit();
78 }
79 }
80}

◆ A01HadCalorimeterSD() [3/3]

A01HadCalorimeterSD::A01HadCalorimeterSD ( )

Default constructor

Definition at line 83 of file A01HadCalorimeterSD.cxx.

85{
86 /// Default constructor
87}

◆ ~A01HadCalorimeterSD()

A01HadCalorimeterSD::~A01HadCalorimeterSD ( )
virtual

Destructor

Definition at line 90 of file A01HadCalorimeterSD.cxx.

91{
92 /// Destructor
93
94 if (fCalCollection) fCalCollection->Delete();
95 delete fCalCollection;
96}

Member Function Documentation

◆ Initialize()

void A01HadCalorimeterSD::Initialize ( )

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

Definition at line 125 of file A01HadCalorimeterSD.cxx.

126{
127 /// Register hits collection in the Root manager;
128 /// set sensitive volumes.
129
130 if (TMCRootManager::Instance()) Register();
131
132 fVolId = gMC->VolId("HadCalScintiLogical");
133}

◆ ProcessHits()

Bool_t A01HadCalorimeterSD::ProcessHits ( )

Account energy deposit for each layer in its hit.

Definition at line 136 of file A01HadCalorimeterSD.cxx.

137{
138 /// Account energy deposit for each layer in its hit.
139
140 Int_t copyNo;
141 Int_t id = gMC->CurrentVolID(copyNo);
142 if (id != fVolId) return false;
143
144 Double_t edep = gMC->Edep();
145 if (edep == 0.) return false;
146
147 Int_t rowNo;
148 gMC->CurrentVolOffID(2, rowNo);
149 Int_t columnNo;
150 gMC->CurrentVolOffID(3, columnNo);
151 // VMC adopts Root numbering of divisions starting from 1
152 rowNo--;
153 columnNo--;
154 Int_t hitID = fgkNofRows * columnNo + rowNo;
155
156 A01HadCalorHit* hit = GetHit(hitID);
157 if (!hit) {
158 std::cerr << "No hit found for layer with "
159 << "rowNo = " << rowNo << " columnNo = " << columnNo << endl;
160 return false;
161 }
162
163 // check if it is the first touch
164 if (hit->GetColumnID() < 0) {
165 // Debug printing (to check hits indexing)
166 // cout << "HadCalorimeter: First Add in hit in (column, row): "
167 // << columnNo << ", " << rowNo << endl;
168 // cout << "gMC->CurrentVolOffName(2), gMC->CurrentVolOffName(3): "
169 // << gMC->CurrentVolOffName(2) << ", " << gMC->CurrentVolOffName(3) <<
170 // endl;
171
172 // fill volume information
173 hit->SetRowID(rowNo);
174 hit->SetColumnID(columnNo);
175
176 // get transformation
177 // add later
178 }
179
180 // add energy deposition
181 hit->AddEdep(edep);
182
183 return true;
184}
Int_t GetColumnID() const
void SetRowID(Int_t volId)
void SetColumnID(Int_t z)
void AddEdep(Double_t de)
A01HadCalorHit * GetHit(Int_t i) const

◆ EndOfEvent()

void A01HadCalorimeterSD::EndOfEvent ( )

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

Definition at line 187 of file A01HadCalorimeterSD.cxx.

188{
189 /// Print hits collection (if verbose) and reset hits afterwards.
190
191 if (fVerboseLevel > 0) PrintTotal();
192
193 // Reset hits collection
194 ResetHits();
195}

◆ Register()

void A01HadCalorimeterSD::Register ( )

Register the hits collection in Root manager.

Definition at line 198 of file A01HadCalorimeterSD.cxx.

199{
200 /// Register the hits collection in Root manager.
201
202 if (fWriteHits) {
203 TMCRootManager::Instance()->Register(
204 GetName(), "TClonesArray", &fCalCollection);
205 }
206}

◆ Print()

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

Print the hits collection.

Definition at line 209 of file A01HadCalorimeterSD.cxx.

210{
211 /// Print the hits collection.
212
213 Int_t nofHits = fCalCollection->GetEntriesFast();
214
215 cout << "\n-------->Hits Collection: in this event: " << endl;
216
217 if (fVerboseLevel > 1) {
218 for (Int_t i = 0; i < nofHits; i++) (*fCalCollection)[i]->Print();
219 }
220}

◆ PrintTotal()

void A01HadCalorimeterSD::PrintTotal ( ) const

Print the total values for all layers.

Definition at line 223 of file A01HadCalorimeterSD.cxx.

224{
225 /// Print the total values for all layers.
226
227 Int_t nofHits = 0;
228 Double_t totalEdep = 0.;
229 for (Int_t i = 0; i < fgkNofColumns * fgkNofRows; ++i) {
230 Double_t edep = GetHit(i)->GetEdep();
231 if (edep > 0.) {
232 nofHits++;
233 totalEdep += edep;
234 }
235 }
236 cout << GetName() << " has " << nofHits << " hits. Total Edep is "
237 << totalEdep * 1e03 << " (MeV)" << endl;
238}
Double_t GetEdep() const

◆ SetWriteHits()

void A01HadCalorimeterSD::SetWriteHits ( Bool_t writeHits)
inline

(In)Activate writing hits on file

Parameters
writeHitsThe new value of the option

Definition at line 72 of file A01HadCalorimeterSD.h.

73{
74 fWriteHits = writeHits;
75}

◆ SetVerboseLevel()

void A01HadCalorimeterSD::SetVerboseLevel ( Int_t level)
inline

Set verbose level

Parameters
levelThe new verbose level value

Definition at line 79 of file A01HadCalorimeterSD.h.

80{
81 fVerboseLevel = level;
82}

◆ GetHit()

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

Definition at line 103 of file A01HadCalorimeterSD.cxx.

104{
105 /// \return The hit for the specified layer.
106 /// \param i The layer number
107
108 return (A01HadCalorHit*)fCalCollection->At(i);
109}

◆ ResetHits()

void A01HadCalorimeterSD::ResetHits ( )
private

Reset all hits in the hits collection.

Definition at line 112 of file A01HadCalorimeterSD.cxx.

113{
114 /// Reset all hits in the hits collection.
115
116 for (Int_t i = 0; i < fCalCollection->GetEntriesFast(); i++)
117 GetHit(i)->Reset();
118}

Member Data Documentation

◆ fgkNofColumns

const Int_t A01HadCalorimeterSD::fgkNofColumns = 10
staticprivate

Definition at line 58 of file A01HadCalorimeterSD.h.

◆ fgkNofRows

const Int_t A01HadCalorimeterSD::fgkNofRows = 2
staticprivate

Definition at line 59 of file A01HadCalorimeterSD.h.

◆ fCalCollection

TClonesArray* A01HadCalorimeterSD::fCalCollection
private

Hits collection.

Definition at line 62 of file A01HadCalorimeterSD.h.

◆ fVolId

Int_t A01HadCalorimeterSD::fVolId
private

The calorimeter volume Id.

Definition at line 63 of file A01HadCalorimeterSD.h.

◆ fWriteHits

Bool_t A01HadCalorimeterSD::fWriteHits
private

Option to write hits.

Definition at line 64 of file A01HadCalorimeterSD.h.

◆ fVerboseLevel

Int_t A01HadCalorimeterSD::fVerboseLevel
private

Verbosity level.

Definition at line 65 of file A01HadCalorimeterSD.h.


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