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

The calorimeter sensitive detector. More...

#include <A01DriftChamberSD.h>

Inheritance diagram for A01DriftChamberSD:

Public Member Functions

 A01DriftChamberSD (const char *name, const char *volName)
 
 A01DriftChamberSD (const A01DriftChamberSD &origin)
 
 A01DriftChamberSD ()
 
virtual ~A01DriftChamberSD ()
 
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)
 
A01DriftChamberHitGetHit (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 A01DriftChamberSD.h.

Constructor & Destructor Documentation

◆ A01DriftChamberSD() [1/3]

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

Standard constructor. Creates hits collection.

Parameters
nameThe calorimeter hits collection name
volNameThe sensitive volume name

Definition at line 36 of file A01DriftChamberSD.cxx.

37 : TNamed(name, ""),
39 fVolName(volName),
40 fVolId(0),
41 fWriteHits(true),
43{
44 /// Standard constructor.
45 /// Creates hits collection.
46 /// \param name The calorimeter hits collection name
47 /// \param volName The sensitive volume name
48
49 fHitsCollection = new TClonesArray("A01DriftChamberHit", 500);
50}
Bool_t fWriteHits
Option to write hits.
Int_t fVolId
The calorimeter volume Id.
TClonesArray * fHitsCollection
Hits collection.
Int_t fVerboseLevel
Verbosity level.
TString fVolName
The sensitive volume name.

◆ A01DriftChamberSD() [2/3]

A01DriftChamberSD::A01DriftChamberSD ( const A01DriftChamberSD & origin)

Copy constructor (for clonig on worker thread in MT mode). Creates hits collection.

Parameters
originThe source object (on master).

Definition at line 53 of file A01DriftChamberSD.cxx.

54 : TNamed(origin),
56 fVolName(origin.fVolName),
57 fVolId(origin.fVolId),
58 fWriteHits(origin.fWriteHits),
60{
61 /// Copy constructor (for clonig on worker thread in MT mode).
62 /// Creates hits collection.
63 /// \param origin The source object (on master).
64
65 fHitsCollection = new TClonesArray("A01DriftChamberHit", 500);
66}

◆ A01DriftChamberSD() [3/3]

A01DriftChamberSD::A01DriftChamberSD ( )

Default constructor

Definition at line 69 of file A01DriftChamberSD.cxx.

70 : TNamed(),
72 fVolName(),
73 fVolId(0),
74 fWriteHits(true),
76{
77 /// Default constructor
78}

◆ ~A01DriftChamberSD()

A01DriftChamberSD::~A01DriftChamberSD ( )
virtual

Destructor

Definition at line 81 of file A01DriftChamberSD.cxx.

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

Member Function Documentation

◆ Initialize()

void A01DriftChamberSD::Initialize ( )

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

Definition at line 107 of file A01DriftChamberSD.cxx.

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

◆ ProcessHits()

Bool_t A01DriftChamberSD::ProcessHits ( )

Account the hit time, local and global position for each layer in its hit.

Definition at line 118 of file A01DriftChamberSD.cxx.

119{
120 /// Account the hit time, local and global position for each layer in its hit.
121
122 Int_t copyNo;
123 Int_t id = gMC->CurrentVolID(copyNo);
124 if (id != fVolId) return false;
125
126 Double_t charge = gMC->TrackCharge();
127 if (charge == 0.) return false;
128
129 if (!gMC->IsTrackEntering()) return false;
130
131 // get copyNo in mother
132 gMC->CurrentVolOffID(1, copyNo);
133
134 // global and local hit position
135 Double_t globalPos[3];
136 Double_t localPos[3];
137 gMC->TrackPosition(globalPos[0], globalPos[1], globalPos[2]);
138 gMC->Gmtod(globalPos, localPos, 1);
139
140 // Debug printing
141 // cout << "** Drift Chamber: Create hit in DriftChamber copyNo, worldPos[cm]
142 // "
143 // << copyNo << ", "
144 // << globalPos[0] << ", " << globalPos[1] << ", " << globalPos[2] <<
145 // endl;
146 // cout << "gMC->CurrentVolOffName(1): " << gMC->CurrentVolOffName(1) << endl;
147 // cout << "localPos[cm] "
148 // << localPos[0] << ", " << localPos[1] << ", " << localPos[2] << endl;
149
150 Int_t nofHits = fHitsCollection->GetEntriesFast();
151 A01DriftChamberHit* hit =
152 new ((*fHitsCollection)[nofHits]) A01DriftChamberHit(copyNo);
153
154 hit->SetWorldPos(TVector3(globalPos[0], globalPos[1], globalPos[2]));
155 hit->SetLocalPos(TVector3(localPos[0], localPos[1], localPos[2]));
156 hit->SetTime(gMC->TrackTime());
157
158 return true;
159}
The drift chamber hit.
void SetLocalPos(const TVector3 &pos)
void SetTime(Double_t t)
void SetWorldPos(const TVector3 &pos)

◆ EndOfEvent()

void A01DriftChamberSD::EndOfEvent ( )

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

Definition at line 162 of file A01DriftChamberSD.cxx.

163{
164 /// Print hits collection (if verbose) and reset hits afterwards.
165
166 if (fVerboseLevel > 0) Print();
167
168 // Reset hits collection
169 fHitsCollection->Clear();
170}
virtual void Print(Option_t *option="") const

◆ Register()

void A01DriftChamberSD::Register ( )

Register the hits collection in Root manager.

Definition at line 173 of file A01DriftChamberSD.cxx.

174{
175 /// Register the hits collection in Root manager.
176
177 if (fWriteHits) {
178 TMCRootManager::Instance()->Register(
179 GetName(), "TClonesArray", &fHitsCollection);
180 }
181}

◆ Print()

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

Print the hits collection.

Definition at line 184 of file A01DriftChamberSD.cxx.

185{
186 /// Print the hits collection.
187
188 Int_t nofHits = fHitsCollection->GetEntriesFast();
189 cout << GetName() << " has " << nofHits << " hits." << endl;
190 if (fVerboseLevel > 1) {
191 for (Int_t i2 = 0; i2 < 5; ++i2) {
192 for (Int_t i = 0; i < nofHits; ++i) {
193 A01DriftChamberHit* hit = GetHit(i);
194 if (hit->GetLayerID() == i2) hit->Print();
195 }
196 }
197 }
198}
virtual void Print(Option_t *option="") const
A01DriftChamberHit * GetHit(Int_t i) const

◆ SetWriteHits()

void A01DriftChamberSD::SetWriteHits ( Bool_t writeHits)
inline

(In)Activate writing hits on file

Parameters
writeHitsThe new value of the option

Definition at line 66 of file A01DriftChamberSD.h.

67{
68 fWriteHits = writeHits;
69}

◆ SetVerboseLevel()

void A01DriftChamberSD::SetVerboseLevel ( Int_t level)
inline

Set verbose level

Parameters
levelThe new verbose level value

Definition at line 73 of file A01DriftChamberSD.h.

74{
75 fVerboseLevel = level;
76}

◆ GetHit()

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

Definition at line 94 of file A01DriftChamberSD.cxx.

95{
96 /// \return The hit for the specified layer.
97 /// \param i The layer number
98
99 return (A01DriftChamberHit*)fHitsCollection->At(i);
100}

Member Data Documentation

◆ fHitsCollection

TClonesArray* A01DriftChamberSD::fHitsCollection
private

Hits collection.

Definition at line 55 of file A01DriftChamberSD.h.

◆ fVolName

TString A01DriftChamberSD::fVolName
private

The sensitive volume name.

Definition at line 56 of file A01DriftChamberSD.h.

◆ fVolId

Int_t A01DriftChamberSD::fVolId
private

The calorimeter volume Id.

Definition at line 57 of file A01DriftChamberSD.h.

◆ fWriteHits

Bool_t A01DriftChamberSD::fWriteHits
private

Option to write hits.

Definition at line 58 of file A01DriftChamberSD.h.

◆ fVerboseLevel

Int_t A01DriftChamberSD::fVerboseLevel
private

Verbosity level.

Definition at line 59 of file A01DriftChamberSD.h.


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