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

The calorimeter sensitive detector. More...

#include <A01HodoscopeSD.h>

Inheritance diagram for A01HodoscopeSD:

Public Member Functions

 A01HodoscopeSD (const char *name, const char *volName)
 
 A01HodoscopeSD (const A01HodoscopeSD &origin)
 
 A01HodoscopeSD ()
 
virtual ~A01HodoscopeSD ()
 
void Initialize ()
 
Bool_t ProcessHits ()
 
void EndOfEvent ()
 
void Register ()
 
virtual void Print (Option_t *option="") const
 
void SetWriteHits (Bool_t writeHits)
 
void SetVerboseLevel (Int_t level)
 
A01HodoscopeHitGetHit (Int_t i) const
 

Private Attributes

TClonesArray * fHitsCollection
 Hits collection.
 
TString fVolName
 The sensitive volume Name.
 
Int_t fVolId
 The calorimeter volume Id.
 
Bool_t fWriteHits
 Option to write hits.
 
Int_t fVerboseLevel
 Verbosity level.
 

Detailed Description

The calorimeter sensitive detector.

Author
I. Hrivnacova; IPN, Orsay

Definition at line 30 of file A01HodoscopeSD.h.

Constructor & Destructor Documentation

◆ A01HodoscopeSD() [1/3]

A01HodoscopeSD::A01HodoscopeSD ( const char * name,
const char * volName )

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

Parameters
nameThe calorimeter hits collection name
volNameThe sensitive volume name

Definition at line 36 of file A01HodoscopeSD.cxx.

37 : TNamed(name, ""),
39 fVolName(volName),
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 /// \param volName The sensitive volume name
48
49 // Create hits collection and an empty hit for each layer
50 fHitsCollection = new TClonesArray("A01HodoscopeHit", 500);
51 // cout << "Hodoscope nofHits: " << fHitsCollection->GetEntriesFast() << endl;
52}
TString fVolName
The sensitive volume Name.
Bool_t fWriteHits
Option to write hits.
Int_t fVolId
The calorimeter volume Id.
TClonesArray * fHitsCollection
Hits collection.
Int_t fVerboseLevel
Verbosity level.

◆ A01HodoscopeSD() [2/3]

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

56 : TNamed(origin),
58 fVolName(origin.fVolName),
59 fVolId(origin.fVolId),
60 fWriteHits(origin.fWriteHits),
62{
63 /// Copy constructor (for clonig on worker thread in MT mode).
64 /// Create hits collection and an empty hit for each layer.
65 /// \param origin The source object (on master).
66
67 fHitsCollection = new TClonesArray("A01HodoscopeHit", 500);
68 // cout << "Hodoscope nofHits: " << fHitsCollection->GetEntriesFast() << endl;
69}

◆ A01HodoscopeSD() [3/3]

A01HodoscopeSD::A01HodoscopeSD ( )

Default constructor

Definition at line 72 of file A01HodoscopeSD.cxx.

73 : TNamed(),
75 fVolName(),
76 fVolId(0),
77 fWriteHits(true),
79{
80 /// Default constructor
81}

◆ ~A01HodoscopeSD()

A01HodoscopeSD::~A01HodoscopeSD ( )
virtual

Destructor

Definition at line 84 of file A01HodoscopeSD.cxx.

85{
86 /// Destructor
87
88 if (fHitsCollection) fHitsCollection->Delete();
89 delete fHitsCollection;
90}

Member Function Documentation

◆ Initialize()

void A01HodoscopeSD::Initialize ( )

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

Definition at line 110 of file A01HodoscopeSD.cxx.

111{
112 /// Register hits collection in the Root manager;
113 /// set sensitive volumes.
114
115 if (TMCRootManager::Instance()) Register();
116
117 fVolId = gMC->VolId(fVolName.Data());
118}

◆ ProcessHits()

Bool_t A01HodoscopeSD::ProcessHits ( )

Account hit time; create a new hit per detector cell if it does not yet exist

Definition at line 121 of file A01HodoscopeSD.cxx.

122{
123 /// Account hit time; create a new hit per detector cell if it does not yet
124 /// exist
125
126 Int_t copyNo;
127 Int_t id = gMC->CurrentVolID(copyNo);
128 if (id != fVolId) return false;
129
130 Double_t edep = gMC->Edep();
131 if (edep == 0.) return false;
132
133 Double_t hitTime = gMC->TrackTime();
134
135 // check if this finger already has a hit
136 Int_t ix = -1;
137 Int_t nofHits = fHitsCollection->GetEntriesFast();
138 for (Int_t i = 0; i < nofHits; i++) {
139 A01HodoscopeHit* hit = GetHit(i);
140 if (hit->GetID() == copyNo) {
141 ix = i;
142 break;
143 }
144 }
145
146 if (ix >= 0) {
147 // if it has, then take the earlier time
148 A01HodoscopeHit* hit = GetHit(ix);
149 if (hit->GetTime() > hitTime) {
150 hit->SetTime(hitTime);
151 }
152 }
153 else {
154 // Debug printing
155 // cout << "** Hodoscope: Create hit in nofHits, copyNo, hitTime[s] "
156 // << nofHits << ", " << copyNo << ", " << hitTime << endl;
157 // cout << "gMC->CurrentVolName(): " << gMC->CurrentVolName() << endl;
158
159 // if not, create a new hit and set it to the collection
160 A01HodoscopeHit* hit =
161 new ((*fHitsCollection)[nofHits]) A01HodoscopeHit(copyNo, hitTime);
162 hit->SetVolId(id);
163
164 // get transformation
165 // add later
166 }
167
168 return true;
169}
The hodoscope hit.
Double_t GetTime() const
void SetVolId(Int_t volId)
void SetTime(Double_t t)
Int_t GetID() const
A01HodoscopeHit * GetHit(Int_t i) const

◆ EndOfEvent()

void A01HodoscopeSD::EndOfEvent ( )

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

Definition at line 172 of file A01HodoscopeSD.cxx.

173{
174 /// Print hits collection (if verbose) and reset hits afterwards.
175
176 if (fVerboseLevel > 0) Print();
177
178 // Reset hits collection
179 fHitsCollection->Clear();
180}
virtual void Print(Option_t *option="") const

◆ Register()

void A01HodoscopeSD::Register ( )

Register the hits collection in Root manager.

Definition at line 183 of file A01HodoscopeSD.cxx.

184{
185 /// Register the hits collection in Root manager.
186
187 if (fWriteHits) {
188 TMCRootManager::Instance()->Register(
189 GetName(), "TClonesArray", &fHitsCollection);
190 }
191}

◆ Print()

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

Print the hits collection.

Definition at line 194 of file A01HodoscopeSD.cxx.

195{
196 /// Print the hits collection.
197
198 Int_t nofHits = fHitsCollection->GetEntriesFast();
199 cout << GetName() << " has " << nofHits << " hits." << endl;
200
201 if (fVerboseLevel > 1) {
202 for (Int_t i = 0; i < nofHits; i++) (*fHitsCollection)[i]->Print();
203 }
204}

◆ SetWriteHits()

void A01HodoscopeSD::SetWriteHits ( Bool_t writeHits)
inline

(In)Activate writing hits on file

Parameters
writeHitsThe new value of the option

Definition at line 66 of file A01HodoscopeSD.h.

67{
68 fWriteHits = writeHits;
69}

◆ SetVerboseLevel()

void A01HodoscopeSD::SetVerboseLevel ( Int_t level)
inline

Set verbose level

Parameters
levelThe new verbose level value

Definition at line 73 of file A01HodoscopeSD.h.

74{
75 fVerboseLevel = level;
76}

◆ GetHit()

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

Definition at line 97 of file A01HodoscopeSD.cxx.

98{
99 /// \return The hit for the specified layer.
100 /// \param i The layer number
101
102 return (A01HodoscopeHit*)fHitsCollection->At(i);
103}

Member Data Documentation

◆ fHitsCollection

TClonesArray* A01HodoscopeSD::fHitsCollection
private

Hits collection.

Definition at line 55 of file A01HodoscopeSD.h.

◆ fVolName

TString A01HodoscopeSD::fVolName
private

The sensitive volume Name.

Definition at line 56 of file A01HodoscopeSD.h.

◆ fVolId

Int_t A01HodoscopeSD::fVolId
private

The calorimeter volume Id.

Definition at line 57 of file A01HodoscopeSD.h.

◆ fWriteHits

Bool_t A01HodoscopeSD::fWriteHits
private

Option to write hits.

Definition at line 58 of file A01HodoscopeSD.h.

◆ fVerboseLevel

Int_t A01HodoscopeSD::fVerboseLevel
private

Verbosity level.

Definition at line 59 of file A01HodoscopeSD.h.


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