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"
31 ////////////////////////////////////////////////////////////////////////
33 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
36 // Modified and documented by Bjorn S. Nilsen
39 // AliITShit is the hit class for the ITS. Hits are the information
40 // that comes from a Monte Carlo at each step as a particle mass through
41 // sensitive detector elements as particles are transported through a
46 <img src="picts/ITS/AliITShit_Class_Diagram.gif">
49 <font size=+2 color=red>
50 <p>This show the relasionships between the ITS hit class and the rest of Aliroot.
55 ////////////////////////////////////////////////////////////////////////
56 // Inline Member functions:
59 // The default creator of the AliITShit class.
62 // The default destructor of the AliITShit class.
65 // See AliHit for a full description. Returns the track number fTrack
68 // SetTrack(int track)
69 // See AliHit for a full description. Sets the track number fTrack
72 // Int_t GetTrackStatus()
73 // Returns the value of the track status flag fStatus. This flag
74 // indicates the track status at the time of creating this hit. It is
75 // made up of the following 8 status bits from highest order to lowest
77 // 0 : IsTrackAlive(): IsTrackStop():IsTrackDisappeared():
78 // IsTrackOut():IsTrackExiting():IsTrackEntering():IsTrackInside() .
79 // See AliMC for a description of these functions. If the function is
80 // true then the bit is set to one, otherwise it is zero.
82 // Bool_t StatusInside()
83 // Returns kTRUE if the particle producing this hit is still inside
84 // the present volume. Returns kFalse if this particle will be in another
85 // volume. {bit IsTrackInside is set or not}
87 // Bool_t StatusEntering()
88 // Returns kTRUE if the particle producing this hit is has just enterd
89 // the present volume. Returns kFalse otherwise. {bit IsTrackEntering is
92 // Bool_t StatusExiting()
93 // Returns kTRUE if the particle producing this hit is will exit
94 // the present volume. Returns kFalse otherwise. {bit IsTrackExiting is set
98 // Returns kTRUE if the particle producing this hit is goint exit the
99 // simulation. Returns kFalse otherwise. {bit IsTrackOut is set or not}
101 // Bool_t StatusDisappeared()
102 // Returns kTRUE if the particle producing this hit is going to "disappear"
103 // for example it has interacted producing some other particles. Returns
104 // kFalse otherwise. {bit IsTrackOut is set or not}
106 // Bool_t StatusStop()
107 // Returns kTRUE if the particle producing this hit is has dropped below
108 // its energy cut off producing some other particles. Returns kFalse otherwise.
109 // {bit IsTrackOut is set or not}
111 // Bool_t StatuAlives()
112 // Returns kTRUE if the particle producing this hit is going to continue
113 // to be transported. Returns kFalse otherwise. {bit IsTrackOut is set or not}
116 // Returns the layer number, fLayer, for this hit.
119 // Returns the ladder number, fLadder, for this hit.
121 // Int_t GetDetector()
122 // Returns the detector number, fDet, for this hit.
124 // GetDetectorID(Int_t &layer, Int_t &ladder, Int_t &detector)
125 // Returns the layer, ladder, and detector numbers, fLayer fLadder fDet,
128 // Float_t GetIonization()
129 // Returns the energy lost, fDestep, by the particle creating this hit,
130 // in the units defined by the Monte Carlo.
132 // GetPositionG(Float_t &x, Float_t &y, Float_t &z)
133 // Returns the global position, fX fY fZ, of this hit, in the units
134 // define by the Monte Carlo.
136 // GetPositionG(Double_t &x, Double_t &y, Double_t &z)
137 // Returns the global position, fX fY fZ, of this hit, in the units
138 // define by the Monte Carlo.
140 // GetPositionG(Float_t &x, Float_t &y, Float_t &z, Float_t &tof)
141 // Returns the global position and time of flight, fX fY fZ fTof, of
142 // this hit, in the units define by the Monte Carlo.
144 // GetPositionG(Double_t &x,Double_t &y,Double_t &z,Double_t &tof)
145 // Returns the global position and time of flight, fX fY fZ fTof, of
146 // this hit, in the units define by the Monte Carlo.
148 // GetPositionL(Double_t &x,Double_t &y,Double_t &z)
149 // Returns the local position, fX fY fZ, of this hit in the coordiante
150 // of this module, in the units define by the Monte Carlo.
152 // GetPositionG(Double_t &x,Double_t &y,Double_t &z,Double_t &tof)
153 // Returns the local position and time of flight, fX fY fZ fTof, of
154 // this hit in the coordinates of this module, in the units define by the
158 // Returns the global x position in the units defined by the Monte Carlo.
161 // Returns the global y position in the units defined by the Monte Carlo.
164 // Returns the global z position in the units defined by the Monte Carlo.
167 // Returns the time of flight, fTof, of this hit, in the units defined
168 // by the Monte Carlo.
170 // GetMomentumG(Float_t &px, Float_t &py, Float_t &pz)
171 // Returns the global momentum, fPx fPy fPz, of the particle that made
172 // this hit, in the units define by the Monte Carlo.
174 // GetMomentumG(Double_t &px,Double_t &py,Double_t &pz)
175 // Returns the global momentum, fPx fPy fPz, of the particle that made
176 // this hit, in the units define by the Monte Carlo.
178 // GetMomentumL(Double_t &px,Double_t &py,Double_t &pz)
179 // Returns the momentum, fPx fPy fPz in coordinate appropreate for this
180 // specific module, in the units define by the Monte Carlo.
183 // Returns the global X momentum in the units defined by the Monte Carlo.
186 // Returns the global Y momentum in the units defined by the Monte Carlo.
189 // Returns the global Z momentum in the units defined by the Monte Carlo.
191 ////////////////////////////////////////////////////////////////////////
192 //_____________________________________________________________________________
193 AliITShit::AliITShit():AliHit(),
194 fStatus(0), // Track Status
195 fModule(0), // Module number
196 fPx(0.0), // PX of particle at the point of the hit
197 fPy(0.0), // PY of particle at the point of the hit
198 fPz(0.0), // PZ of particle at the point of the hit
199 fDestep(0.0), // Energy deposited in the current step
200 fTof(0.0), // Time of flight at the point of the hit
201 fStatus0(0),// Track Status of Starting point
202 fx0(0.0), // Starting point of this step
203 fy0(0.0), // Starting point of this step
204 fz0(0.0), // Starting point of this step
205 ft0(0.0) // Starting point of this step
207 // Default Constructor
208 // Zero data member just to be safe.
214 // A default created AliITShit class.
217 //----------------------------------------------------------------------
218 AliITShit::AliITShit(Int_t shunt,Int_t track,Int_t *vol,Float_t edep,
219 Float_t tof,TLorentzVector &x,TLorentzVector &x0,
221 AliHit(shunt, track), // AliHit
222 fStatus(vol[3]), // Track Status
223 fModule(vol[0]), // Module number
224 fPx(p.Px()), // PX of particle at the point of the hit
225 fPy(p.Py()), // PY of particle at the point of the hit
226 fPz(p.Pz()), // PZ of particle at the point of the hit
227 fDestep(edep), // Energy deposited in the current step
228 fTof(tof), // Time of flight at the point of the hit
229 fStatus0(vol[4]),// Track Status of Starting point
230 fx0(x0.X()), // Starting point of this step
231 fy0(x0.Y()), // Starting point of this step
232 fz0(x0.Z()), // Starting point of this step
233 ft0(x0.T()) // Starting point of this step
236 // The creator of the AliITShit class. The variables shunt and
237 // track are passed to the creator of the AliHit class. See the AliHit
238 // class for a full description. In the units of the Monte Carlo
240 // Int_t shunt See AliHit
241 // Int_t track Track number, see AliHit
242 // Int_t *vol Array of integer hit data,
246 // vol[3] Set of status bits
247 // vol[4] Set of status bits at start
248 // Float_t edep The energy deposited GeV during the transport
250 // Float_t tof The time of flight of this particle at this step
251 // TLorenzVector &x The Global position of this step [cm]
252 // TLorenzVector &x0 The Global position of where this step
254 // TLorenzVector &p The Global momentum of the particle at this
259 // A default created AliITShit class.
263 //______________________________________________________________________
264 AliITShit::AliITShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
265 AliHit(shunt, track), // AliHit
266 fStatus(vol[3]), // Track Status
267 fModule(vol[0]), // Module number
268 fPx(hits[3]), // PX of particle at the point of the hit
269 fPy(hits[4]), // PY of particle at the point of the hit
270 fPz(hits[5]), // PZ of particle at the point of the hit
271 fDestep(hits[6]), // Energy deposited in the current step
272 fTof(hits[7]), // Time of flight at the point of the hit
273 fStatus0(vol[4]),// Track Status of Starting point
274 fx0(hits[8]), // Starting point of this step
275 fy0(hits[9]), // Starting point of this step
276 fz0(hits[10]), // Starting point of this step
277 ft0(hits[11]) // Starting point of this step
280 // The creator of the AliITShit class. The variables shunt and
281 // track are passed to the creator of the AliHit class. See the AliHit
282 // class for a full description. the integer array *vol contains, in order,
283 // fLayer = vol[0], fDet = vol[1], fLadder = vol[2], fStatus = vol[3].
284 // The array *hits contains, in order, fX = hits[0], fY = hits[1],
285 // fZ = hits[2], fPx = hits[3], fPy = hits[4], fPz = hits[5],
286 // fDestep = hits[6], and fTof = hits[7]. In the units of the Monte Carlo
288 // Int_t shunt See AliHit
289 // Int_t track Track number, see AliHit
290 // Int_t *vol Array of integer hit data,
291 // vol[0] module number
294 // vol[3] Set of status bits
295 // vol[4] Set of status bits at start
296 // Float_t *hits Array of hit information
297 // hits[0] X global position of this hit
298 // hits[1] Y global position of this hit
299 // hits[2] Z global position of this hit
300 // hits[3] Px global position of this hit
301 // hits[4] Py global position of this hit
302 // hits[5] Pz global position of this hit
303 // hits[6] Energy deposited by this step
304 // hits[7] Time of flight of this particle at this step
305 // hits[8] X0 global position of start of step
306 // hits[9] Y0 global position of start of step
307 // hits[10] Z0 global position of start of step
308 // hits[11] Time of flight of this particle before step
312 // A standard created AliITShit class.
314 fX = hits[0]; // Track X global position
315 fY = hits[1]; // Track Y global position
316 fZ = hits[2]; // Track Z global position
318 //______________________________________________________________________
319 AliITShit::AliITShit(const AliITShit &h):
321 fStatus(h.fStatus), // Track Status
322 fModule(h.fModule), // Module number
323 fPx(h.fPx), // PX of particle at the point of the hit
324 fPy(h.fPy), // PY of particle at the point of the hit
325 fPz(h.fPz), // PZ of particle at the point of the hit
326 fDestep(h.fDestep), // Energy deposited in the current step
327 fTof(h.fTof), // Time of flight at the point of the hit
328 fStatus0(h.fStatus0),// Track Status of Starting point
329 fx0(h.fx0), // Starting point of this step
330 fy0(h.fy0), // Starting point of this step
331 fz0(h.fz0), // Starting point of this step
332 ft0(h.ft0) // Starting point of this step
334 // The standard copy constructor
336 // AliITShit &h the sourse of this copy
340 // A copy of the sourse hit h
342 //Info("CopyConstructor","Coping hit");
344 if(this == &h) return;
347 //______________________________________________________________________
348 AliITShit& AliITShit::operator=(const AliITShit &h){
349 // The standard = operator
351 // AliITShit &h the sourse of this copy
355 // A copy of the sourse hit h
357 if(this == &h) return *this;
358 this->fStatus = h.fStatus;
359 this->fModule = h.fModule;
363 this->fDestep = h.fDestep;
365 this->fStatus0 = h.fStatus0;
372 //______________________________________________________________________
373 void AliITShit::SetShunt(Int_t shunt){
374 // Sets track flag based on shunt value. Code copied from
375 // AliHit standar constructor.
377 // Int_t shunt A flag to indecate what to do with track numbers
382 Int_t primary,track,current,parent;
387 primary = gAlice->GetMCApp()->GetPrimary(track);
388 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
390 }else if (shunt == 2) {
391 // the "primary" particle associated to the hit is
392 // the last track that has been flagged in the StepManager
393 // used by PHOS to associate the hit with the decay gamma
394 // rather than with the original pi0
398 part = gAlice->GetMCApp()->Particle(current);
399 parent=part->GetFirstMother();
400 if(parent<0 || part->TestBit(kKeepBit))
406 gAlice->GetMCApp()->FlagTrack(fTrack);
409 //______________________________________________________________________
410 void AliITShit::GetPositionL(Float_t &x,Float_t &y,Float_t &z,Float_t &tof){
411 // Returns the position and time of flight of this hit in the local
412 // coordinates of this module, and in the units of the Monte Carlo.
416 // Float_t x Global position of this hit [cm]
417 // Float_t y Global position of this hit [cm]
418 // Float_t z Global poistion of this hit [cm]
419 // Float_t tof Time of flight of particle at this hit
422 AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
429 gm->GtoL(fModule,g,l);
434 Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
435 // AliITSv7 - SDD case
443 //______________________________________________________________________
444 void AliITShit::GetPositionL0(Double_t &x,Double_t &y,Double_t &z,
446 // Returns the initial position and time of flight of this hit
447 // in the local coordinates of this module, and in the units of the
452 // Double_t x Global position of this hit [cm]
453 // Double_t y Global position of this hit [cm]
454 // Double_t z Global poistion of this hit [cm]
455 // Double_t tof Time of flight of particle at this hit
458 AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
465 gm->GtoL(fModule,g,l);
470 Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
478 //______________________________________________________________________
479 void AliITShit::GetMomentumL(Float_t &px,Float_t &py,Float_t &pz){
480 // Returns the momentum of this hit in the local coordinates of this
481 // module, and in the units of the Monte Carlo.
485 // Float_t px Track x momentum at this hit [GeV/c]
486 // Float_t py Track y momentum at this hit [GeV/c]
487 // Float_t pz Track z momentum at this hit [GeV/c]
490 AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
497 gm->GtoLMomentum(fModule,g,l);
502 Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
509 //______________________________________________________________________
510 TParticle * AliITShit::GetParticle() const {
511 // Returns the pointer to the TParticle for the particle that created
512 // this hit. From the TParticle all kinds of information about this
513 // particle can be found. See the TParticle class.
519 // The TParticle of the track that created this hit.
521 return gAlice->GetMCApp()->Particle(GetTrack());
523 //----------------------------------------------------------------------
524 void AliITShit::GetDetectorID(Int_t &layer,Int_t &ladder,Int_t &det)const{
525 // Returns the layer ladder and detector number lables for this
526 // ITS module. The use of layer, ladder and detector number for
527 // discribing the ITS is obsoleate.
531 // Int_t &layer Layer lable
532 // Int_t &ladder Ladder lable
533 // Int_t &det Detector lable
536 AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
538 gm->GetModuleId(fModule,layer,ladder,det);
541 //----------------------------------------------------------------------
542 void AliITShit::Print(ostream *os) const {
543 // Standard output format for this class.
545 // ostream *os The output stream
558 #if defined __ICC || defined __ECC || defined __xlC__
565 fmt = os->setf(ios::scientific); // set scientific floating point output
566 *os << fTrack << " " << fX << " " << fY << " " << fZ << " ";
567 fmt = os->setf(ios::hex); // set hex for fStatus only.
568 *os << fStatus << " ";
569 fmt = os->setf(ios::dec); // every thing else decimel.
570 *os << fModule << " ";
571 *os << fPx << " " << fPy << " " << fPz << " ";
572 *os << fDestep << " " << fTof;
573 *os << " " << fx0 << " " << fy0 << " " << fz0;
574 // *os << " " << endl;
575 os->flags(fmt); // reset back to old formating.
578 //----------------------------------------------------------------------
579 void AliITShit::Read(istream *is) {
580 // Standard input format for this class.
582 // istream *is the input stream
588 *is >> fTrack >> fX >> fY >> fZ;
589 *is >> fStatus >> fModule >> fPx >> fPy >> fPz >> fDestep >> fTof;
590 *is >> fx0 >> fy0 >> fz0;
593 //----------------------------------------------------------------------
594 ostream &operator<<(ostream &os,AliITShit &p){
595 // Standard output streaming function.
597 // ostream os The output stream
598 // AliITShit p The his to be printed out
607 //----------------------------------------------------------------------
608 istream &operator>>(istream &is,AliITShit &r){
609 // Standard input streaming function.
611 // istream is The input stream
612 // AliITShit p The AliITShit class to be filled from this input stream
621 //----------------------------------------------------------------------