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

The tracker sensitive detector. More...

#include <Ex02TrackerSD.h>

Inheritance diagram for Ex02TrackerSD:

Public Member Functions

 Ex02TrackerSD (const char *name)
 
 Ex02TrackerSD (const Ex02TrackerSD &origin)
 
 Ex02TrackerSD ()
 
virtual ~Ex02TrackerSD ()
 
void Initialize ()
 
Bool_t ProcessHits ()
 
void EndOfEvent ()
 
void Register ()
 
virtual void Print (const Option_t *option=0) const
 
void SetVerboseLevel (Int_t level)
 

Private Member Functions

Ex02TrackerHitAddHit ()
 

Private Attributes

TClonesArray * fTrackerCollection
 Hits collection.
 
Int_t fSensitiveVolumeID
 Sensitive volume Id.
 
Int_t fVerboseLevel
 Verbosity level.
 

Detailed Description

The tracker sensitive detector.

Date
21/04/2002
Author
I. Hrivnacova; IPN, Orsay

Definition at line 33 of file Ex02TrackerSD.h.

Constructor & Destructor Documentation

◆ Ex02TrackerSD() [1/3]

Ex02TrackerSD::Ex02TrackerSD ( const char * name)

Standard constructor

Parameters
nameThe tracker hits collection name

Definition at line 37 of file Ex02TrackerSD.cxx.

38 : TNamed(name, ""),
42{
43 /// Standard constructor
44 /// \param name The tracker hits collection name
45}
Int_t fVerboseLevel
Verbosity level.
Int_t fSensitiveVolumeID
Sensitive volume Id.
TClonesArray * fTrackerCollection
Hits collection.

◆ Ex02TrackerSD() [2/3]

Ex02TrackerSD::Ex02TrackerSD ( const Ex02TrackerSD & origin)

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

Parameters
originThe source object (on master).

Definition at line 48 of file Ex02TrackerSD.cxx.

49 : TNamed(origin.GetName(), origin.GetTitle()),
53{
54 /// Copy constructor (for clonig on worker thread in MT mode).
55 /// \param origin The source object (on master).
56}

◆ Ex02TrackerSD() [3/3]

Ex02TrackerSD::Ex02TrackerSD ( )

Default constructor

Definition at line 59 of file Ex02TrackerSD.cxx.

61{
62 /// Default constructor
63}

◆ ~Ex02TrackerSD()

Ex02TrackerSD::~Ex02TrackerSD ( )
virtual

Destructor

Definition at line 66 of file Ex02TrackerSD.cxx.

67{
68 /// Destructor
69}

Member Function Documentation

◆ Initialize()

void Ex02TrackerSD::Initialize ( )

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

Definition at line 92 of file Ex02TrackerSD.cxx.

93{
94 /// Register hits collection in the Root manager;
95 /// set sensitive volumes.
96
97 static __thread Bool_t registered = false;
98 if (!registered) {
99 // cout << "... creating TClonesArray" << endl;
100
101 // Lock Root when creating data - seems not to be needed ?
102 fTrackerCollection = new TClonesArray("Ex02TrackerHit");
103
104 // Register to Root IO only if RootManager is instantiated
105 if (TMCRootManager::Instance()) Register();
106 registered = true;
107 }
108
109 fSensitiveVolumeID = gMC->VolId("CHMB");
110}

◆ ProcessHits()

Bool_t Ex02TrackerSD::ProcessHits ( )

Create hits (in stepping).

Definition at line 113 of file Ex02TrackerSD.cxx.

114{
115 /// Create hits (in stepping).
116
117 Int_t copyNo;
118 Int_t id = gMC->CurrentVolID(copyNo);
119
120 if (id != fSensitiveVolumeID) return false;
121
122 Double_t edep = gMC->Edep();
123
124 if (edep == 0.) return false;
125
126 Ex02TrackerHit* newHit = AddHit();
127
128 // Track ID
129 newHit->SetTrackID(gMC->GetStack()->GetCurrentTrackNumber());
130
131 // Chamber no
132 newHit->SetChamberNb(copyNo);
133
134 // Energy deposit
135 newHit->SetEdep(edep);
136
137 // Position
138 TLorentzVector pos;
139 gMC->TrackPosition(pos);
140 newHit->SetPos(TVector3(pos.X(), pos.Y(), pos.Z()));
141
142 // newHit->Print();
143 // newHit->Draw();
144
145 return true;
146}
The tracker hit.
void SetChamberNb(Int_t chamb)
void SetTrackID(Int_t track)
void SetPos(TVector3 xyz)
void SetEdep(Double_t de)
Ex02TrackerHit * AddHit()

◆ EndOfEvent()

void Ex02TrackerSD::EndOfEvent ( )

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

Definition at line 149 of file Ex02TrackerSD.cxx.

150{
151 /// Print hits collection (if verbose)
152 /// and delete hits afterwards.
153
154 if (fVerboseLevel > 0) Print();
155
156 // Reset hits collection
157 fTrackerCollection->Clear();
158}
virtual void Print(const Option_t *option=0) const

◆ Register()

void Ex02TrackerSD::Register ( )

Register the hits collection in the Root manager.

Definition at line 161 of file Ex02TrackerSD.cxx.

162{
163 /// Register the hits collection in the Root manager.
164
165 TMCRootManager::Instance()->Register(
166 "hits", "TClonesArray", &fTrackerCollection);
167}

◆ Print()

void Ex02TrackerSD::Print ( const Option_t * option = 0) const
virtual

Print the hits collection.

Definition at line 170 of file Ex02TrackerSD.cxx.

171{
172 /// Print the hits collection.
173
174 Int_t nofHits = fTrackerCollection->GetEntriesFast();
175
176 cout << "\n-------->Hits Collection: in this event they are " << nofHits
177 << " hits in the tracker chambers: " << endl;
178
179 for (Int_t i = 0; i < nofHits; i++) (*fTrackerCollection)[i]->Print();
180}

◆ SetVerboseLevel()

void Ex02TrackerSD::SetVerboseLevel ( Int_t level)
inline

Set verbose level

Parameters
levelThe new verbose level value

Definition at line 65 of file Ex02TrackerSD.h.

66{
67 fVerboseLevel = level;
68}

◆ AddHit()

Ex02TrackerHit * Ex02TrackerSD::AddHit ( )
private

Create a new hit in the TClonesArray.

Returns
The new hit

Definition at line 76 of file Ex02TrackerSD.cxx.

77{
78 /// Create a new hit in the TClonesArray.
79 /// \return The new hit
80
81 TClonesArray& ref = *fTrackerCollection;
82 Int_t size = ref.GetEntriesFast();
83
84 return new (ref[size]) Ex02TrackerHit();
85}

Member Data Documentation

◆ fTrackerCollection

TClonesArray* Ex02TrackerSD::fTrackerCollection
private

Hits collection.

Definition at line 56 of file Ex02TrackerSD.h.

◆ fSensitiveVolumeID

Int_t Ex02TrackerSD::fSensitiveVolumeID
private

Sensitive volume Id.

Definition at line 57 of file Ex02TrackerSD.h.

◆ fVerboseLevel

Int_t Ex02TrackerSD::fVerboseLevel
private

Verbosity level.

Definition at line 58 of file Ex02TrackerSD.h.


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