1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include <Riostream.h>
20 #include <TLorentzVector.h>
21 #include <TParticle.h>
25 #include "AliITSgeom.h"
26 #include "AliITShit.h"
32 ////////////////////////////////////////////////////////////////////////
34 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
37 // Modified and documented by Bjorn S. Nilsen
40 // AliITShit is the hit class for the ITS. Hits are the information
41 // that comes from a Monte Carlo at each step as a particle mass through
42 // sensitive detector elements as particles are transported through a
47 <img src="picts/ITS/AliITShit_Class_Diagram.gif">
50 <font size=+2 color=red>
51 <p>This show the relasionships between the ITS hit class and the rest of Aliroot.
56 ////////////////////////////////////////////////////////////////////////
57 // Inline Member functions:
60 // The default creator of the AliITShit class.
63 // The default destructor of the AliITShit class.
66 // See AliHit for a full description. Returns the track number fTrack
69 // SetTrack(int track)
70 // See AliHit for a full description. Sets the track number fTrack
73 // Int_t GetTrackStatus()
74 // Returns the value of the track status flag fStatus. This flag
75 // indicates the track status at the time of creating this hit. It is
76 // made up of the following 8 status bits from highest order to lowest
78 // 0 : IsTrackAlive(): IsTrackStop():IsTrackDisappeared():
79 // IsTrackOut():IsTrackExiting():IsTrackEntering():IsTrackInside() .
80 // See AliMC for a description of these functions. If the function is
81 // true then the bit is set to one, otherwise it is zero.
83 // Bool_t StatusInside()
84 // Returns kTRUE if the particle producing this hit is still inside
85 // the present volume. Returns kFalse if this particle will be in another
86 // volume. {bit IsTrackInside is set or not}
88 // Bool_t StatusEntering()
89 // Returns kTRUE if the particle producing this hit is has just enterd
90 // the present volume. Returns kFalse otherwise. {bit IsTrackEntering is
93 // Bool_t StatusExiting()
94 // Returns kTRUE if the particle producing this hit is will exit
95 // the present volume. Returns kFalse otherwise. {bit IsTrackExiting is set
99 // Returns kTRUE if the particle producing this hit is goint exit the
100 // simulation. Returns kFalse otherwise. {bit IsTrackOut is set or not}
102 // Bool_t StatusDisappeared()
103 // Returns kTRUE if the particle producing this hit is going to "disappear"
104 // for example it has interacted producing some other particles. Returns
105 // kFalse otherwise. {bit IsTrackOut is set or not}
107 // Bool_t StatusStop()
108 // Returns kTRUE if the particle producing this hit is has dropped below
109 // its energy cut off producing some other particles. Returns kFalse otherwise.
110 // {bit IsTrackOut is set or not}
112 // Bool_t StatuAlives()
113 // Returns kTRUE if the particle producing this hit is going to continue
114 // to be transported. Returns kFalse otherwise. {bit IsTrackOut is set or not}
117 // Returns the layer number, fLayer, for this hit.
120 // Returns the ladder number, fLadder, for this hit.
122 // Int_t GetDetector()
123 // Returns the detector number, fDet, for this hit.
125 // GetDetectorID(Int_t &layer, Int_t &ladder, Int_t &detector)
126 // Returns the layer, ladder, and detector numbers, fLayer fLadder fDet,
129 // Float_t GetIonization()
130 // Returns the energy lost, fDestep, by the particle creating this hit,
131 // in the units defined by the Monte Carlo.
133 // GetPositionG(Float_t &x, Float_t &y, Float_t &z)
134 // Returns the global position, fX fY fZ, of this hit, in the units
135 // define by the Monte Carlo.
137 // GetPositionG(Double_t &x, Double_t &y, Double_t &z)
138 // Returns the global position, fX fY fZ, of this hit, in the units
139 // define by the Monte Carlo.
141 // GetPositionG(Float_t &x, Float_t &y, Float_t &z, Float_t &tof)
142 // Returns the global position and time of flight, fX fY fZ fTof, of
143 // this hit, in the units define by the Monte Carlo.
145 // GetPositionG(Double_t &x,Double_t &y,Double_t &z,Double_t &tof)
146 // Returns the global position and time of flight, fX fY fZ fTof, of
147 // this hit, in the units define by the Monte Carlo.
149 // GetPositionL(Double_t &x,Double_t &y,Double_t &z)
150 // Returns the local position, fX fY fZ, of this hit in the coordiante
151 // of this module, in the units define by the Monte Carlo.
153 // GetPositionG(Double_t &x,Double_t &y,Double_t &z,Double_t &tof)
154 // Returns the local position and time of flight, fX fY fZ fTof, of
155 // this hit in the coordinates of this module, in the units define by the
159 // Returns the global x position in the units defined by the Monte Carlo.
162 // Returns the global y position in the units defined by the Monte Carlo.
165 // Returns the global z position in the units defined by the Monte Carlo.
168 // Returns the time of flight, fTof, of this hit, in the units defined
169 // by the Monte Carlo.
171 // GetMomentumG(Float_t &px, Float_t &py, Float_t &pz)
172 // Returns the global momentum, fPx fPy fPz, of the particle that made
173 // this hit, in the units define by the Monte Carlo.
175 // GetMomentumG(Double_t &px,Double_t &py,Double_t &pz)
176 // Returns the global momentum, fPx fPy fPz, of the particle that made
177 // this hit, in the units define by the Monte Carlo.
179 // GetMomentumL(Double_t &px,Double_t &py,Double_t &pz)
180 // Returns the momentum, fPx fPy fPz in coordinate appropreate for this
181 // specific module, in the units define by the Monte Carlo.
184 // Returns the global X momentum in the units defined by the Monte Carlo.
187 // Returns the global Y momentum in the units defined by the Monte Carlo.
190 // Returns the global Z momentum in the units defined by the Monte Carlo.
192 ////////////////////////////////////////////////////////////////////////
193 //_____________________________________________________________________________
194 AliITShit::AliITShit():AliHit(),
195 fStatus(0), // Track Status
196 fModule(0), // Module number
197 fPx(0.0), // PX of particle at the point of the hit
198 fPy(0.0), // PY of particle at the point of the hit
199 fPz(0.0), // PZ of particle at the point of the hit
200 fDestep(0.0), // Energy deposited in the current step
201 fTof(0.0), // Time of flight at the point of the hit
202 fStatus0(0),// Track Status of Starting point
203 fx0(0.0), // Starting point of this step
204 fy0(0.0), // Starting point of this step
205 fz0(0.0), // Starting point of this step
206 ft0(0.0) // Starting point of this step
208 // Default Constructor
209 // Zero data member just to be safe.
215 // A default created AliITShit class.
218 //----------------------------------------------------------------------
219 AliITShit::AliITShit(Int_t shunt,Int_t track,Int_t *vol,Float_t edep,
220 Float_t tof,TLorentzVector &x,TLorentzVector &x0,
222 AliHit(shunt, track), // AliHit
223 fStatus(vol[3]), // Track Status
224 fModule(vol[0]), // Module number
225 fPx(p.Px()), // PX of particle at the point of the hit
226 fPy(p.Py()), // PY of particle at the point of the hit
227 fPz(p.Pz()), // PZ of particle at the point of the hit
228 fDestep(edep), // Energy deposited in the current step
229 fTof(tof), // Time of flight at the point of the hit
230 fStatus0(vol[4]),// Track Status of Starting point
231 fx0(x0.X()), // Starting point of this step
232 fy0(x0.Y()), // Starting point of this step
233 fz0(x0.Z()), // Starting point of this step
234 ft0(x0.T()) // Starting point of this step
237 // The creator of the AliITShit class. The variables shunt and
238 // track are passed to the creator of the AliHit class. See the AliHit
239 // class for a full description. In the units of the Monte Carlo
241 // Int_t shunt See AliHit
242 // Int_t track Track number, see AliHit
243 // Int_t *vol Array of integer hit data,
247 // vol[3] Set of status bits
248 // vol[4] Set of status bits at start
249 // Float_t edep The energy deposited GeV during the transport
251 // Float_t tof The time of flight of this particle at this step
252 // TLorenzVector &x The Global position of this step [cm]
253 // TLorenzVector &x0 The Global position of where this step
255 // TLorenzVector &p The Global momentum of the particle at this
260 // A default created AliITShit class.
264 //______________________________________________________________________
265 AliITShit::AliITShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
266 AliHit(shunt, track), // AliHit
267 fStatus(vol[3]), // Track Status
268 fModule(vol[0]), // Module number
269 fPx(hits[3]), // PX of particle at the point of the hit
270 fPy(hits[4]), // PY of particle at the point of the hit
271 fPz(hits[5]), // PZ of particle at the point of the hit
272 fDestep(hits[6]), // Energy deposited in the current step
273 fTof(hits[7]), // Time of flight at the point of the hit
274 fStatus0(vol[4]),// Track Status of Starting point
275 fx0(hits[8]), // Starting point of this step
276 fy0(hits[9]), // Starting point of this step
277 fz0(hits[10]), // Starting point of this step
278 ft0(hits[11]) // Starting point of this step
281 // The creator of the AliITShit class. The variables shunt and
282 // track are passed to the creator of the AliHit class. See the AliHit
283 // class for a full description. the integer array *vol contains, in order,
284 // fLayer = vol[0], fDet = vol[1], fLadder = vol[2], fStatus = vol[3].
285 // The array *hits contains, in order, fX = hits[0], fY = hits[1],
286 // fZ = hits[2], fPx = hits[3], fPy = hits[4], fPz = hits[5],
287 // fDestep = hits[6], and fTof = hits[7]. In the units of the Monte Carlo
289 // Int_t shunt See AliHit
290 // Int_t track Track number, see AliHit
291 // Int_t *vol Array of integer hit data,
292 // vol[0] module number
295 // vol[3] Set of status bits
296 // vol[4] Set of status bits at start
297 // Float_t *hits Array of hit information
298 // hits[0] X global position of this hit
299 // hits[1] Y global position of this hit
300 // hits[2] Z global position of this hit
301 // hits[3] Px global position of this hit
302 // hits[4] Py global position of this hit
303 // hits[5] Pz global position of this hit
304 // hits[6] Energy deposited by this step
305 // hits[7] Time of flight of this particle at this step
306 // hits[8] X0 global position of start of step
307 // hits[9] Y0 global position of start of step
308 // hits[10] Z0 global position of start of step
309 // hits[11] Time of flight of this particle before step
313 // A standard created AliITShit class.
315 fX = hits[0]; // Track X global position
316 fY = hits[1]; // Track Y global position
317 fZ = hits[2]; // Track Z global position
319 //______________________________________________________________________
320 AliITShit::AliITShit(const AliITShit &h):
322 fStatus(h.fStatus), // Track Status
323 fModule(h.fModule), // Module number
324 fPx(h.fPx), // PX of particle at the point of the hit
325 fPy(h.fPy), // PY of particle at the point of the hit
326 fPz(h.fPz), // PZ of particle at the point of the hit
327 fDestep(h.fDestep), // Energy deposited in the current step
328 fTof(h.fTof), // Time of flight at the point of the hit
329 fStatus0(h.fStatus0),// Track Status of Starting point
330 fx0(h.fx0), // Starting point of this step
331 fy0(h.fy0), // Starting point of this step
332 fz0(h.fz0), // Starting point of this step
333 ft0(h.ft0) // Starting point of this step
335 // The standard copy constructor
337 // AliITShit &h the sourse of this copy
341 // A copy of the sourse hit h
343 //Info("CopyConstructor","Coping hit");
345 if(this == &h) return;
348 //______________________________________________________________________
349 AliITShit& AliITShit::operator=(const AliITShit &h){
350 // The standard = operator
352 // AliITShit &h the sourse of this copy
356 // A copy of the sourse hit h
358 if(this == &h) return *this;
359 this->fStatus = h.fStatus;
360 this->fModule = h.fModule;
364 this->fDestep = h.fDestep;
366 this->fStatus0 = h.fStatus0;
373 //______________________________________________________________________
374 void AliITShit::SetShunt(Int_t shunt){
375 // Sets track flag based on shunt value. Code copied from
376 // AliHit standar constructor.
378 // Int_t shunt A flag to indecate what to do with track numbers
383 Int_t primary,track,current,parent;
388 primary = gAlice->GetMCApp()->GetPrimary(track);
389 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
391 }else if (shunt == 2) {
392 // the "primary" particle associated to the hit is
393 // the last track that has been flagged in the StepManager
394 // used by PHOS to associate the hit with the decay gamma
395 // rather than with the original pi0
399 part = gAlice->GetMCApp()->Particle(current);
400 parent=part->GetFirstMother();
401 if(parent<0 || part->TestBit(kKeepBit))
407 gAlice->GetMCApp()->FlagTrack(fTrack);
410 //______________________________________________________________________
411 void AliITShit::GetPositionL(Float_t &x,Float_t &y,Float_t &z,Float_t &tof){
412 // Returns the position and time of flight of this hit in the local
413 // coordinates of this module, and in the units of the Monte Carlo.
417 // Float_t x Global position of this hit [cm]
418 // Float_t y Global position of this hit [cm]
419 // Float_t z Global poistion of this hit [cm]
420 // Float_t tof Time of flight of particle at this hit
423 AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
430 gm->GtoL(fModule,g,l);
435 Error("AliITShit","NULL pointer to the geometry! return smth else");
436 // AliITSv7 - SDD case
444 //______________________________________________________________________
445 void AliITShit::GetPositionL0(Double_t &x,Double_t &y,Double_t &z,
447 // Returns the initial position and time of flight of this hit
448 // in the local coordinates of this module, and in the units of the
453 // Double_t x Global position of this hit [cm]
454 // Double_t y Global position of this hit [cm]
455 // Double_t z Global poistion of this hit [cm]
456 // Double_t tof Time of flight of particle at this hit
459 AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
466 gm->GtoL(fModule,g,l);
471 Error("AliITShit","NULL pointer to the geometry! return smth else");
480 //______________________________________________________________________
481 TParticle * AliITShit::GetParticle() const {
482 // Returns the pointer to the TParticle for the particle that created
483 // this hit. From the TParticle all kinds of information about this
484 // particle can be found. See the TParticle class.
490 // The TParticle of the track that created this hit.
492 return gAlice->GetMCApp()->Particle(GetTrack());
494 //----------------------------------------------------------------------
495 void AliITShit::GetDetectorID(Int_t &layer,Int_t &ladder,Int_t &det)const{
496 // Returns the layer ladder and detector number lables for this
497 // ITS module. The use of layer, ladder and detector number for
498 // discribing the ITS is obsoleate.
502 // Int_t &layer Layer lable
503 // Int_t &ladder Ladder lable
504 // Int_t &det Detector lable
507 AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
509 gm->GetModuleId(fModule,layer,ladder,det);
512 //----------------------------------------------------------------------
513 void AliITShit::Print(ostream *os) const {
514 // Standard output format for this class.
516 // ostream *os The output stream
529 #if defined __ICC || defined __ECC || defined __xlC__
536 fmt = os->setf(ios::scientific); // set scientific floating point output
537 *os << fTrack << " " << fX << " " << fY << " " << fZ << " ";
538 fmt = os->setf(ios::hex); // set hex for fStatus only.
539 *os << fStatus << " ";
540 fmt = os->setf(ios::dec); // every thing else decimel.
541 *os << fModule << " ";
542 *os << fPx << " " << fPy << " " << fPz << " ";
543 *os << fDestep << " " << fTof;
544 *os << " " << fx0 << " " << fy0 << " " << fz0;
545 // *os << " " << endl;
546 os->flags(fmt); // reset back to old formating.
549 //----------------------------------------------------------------------
550 void AliITShit::Read(istream *is) {
551 // Standard input format for this class.
553 // istream *is the input stream
559 *is >> fTrack >> fX >> fY >> fZ;
560 *is >> fStatus >> fModule >> fPx >> fPy >> fPz >> fDestep >> fTof;
561 *is >> fx0 >> fy0 >> fz0;
564 //----------------------------------------------------------------------
565 ostream &operator<<(ostream &os,AliITShit &p){
566 // Standard output streaming function.
568 // ostream os The output stream
569 // AliITShit p The his to be printed out
578 //----------------------------------------------------------------------
579 istream &operator>>(istream &is,AliITShit &r){
580 // Standard input streaming function.
582 // istream is The input stream
583 // AliITShit p The AliITShit class to be filled from this input stream
592 //----------------------------------------------------------------------