]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITShit.cxx
fix warnings
[u/mrichter/AliRoot.git] / ITS / AliITShit.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
18 #include <Riostream.h>
19
20 #include <TLorentzVector.h>
21 #include <TParticle.h>
22
23 #include "AliRun.h"
24 #include "AliITS.h"
25 #include "AliITSgeom.h"
26 #include "AliITShit.h"
27 #include "AliMC.h"
28 #include "AliStack.h"
29
30
31 ClassImp(AliITShit)
32 ////////////////////////////////////////////////////////////////////////
33 // Version: 0
34 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
35 //
36 // Version: 1
37 // Modified and documented by Bjorn S. Nilsen
38 // July 11 1999
39 //
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
43 // detector.
44 //
45 //Begin_Html
46 /*
47 <img src="picts/ITS/AliITShit_Class_Diagram.gif">
48 </pre>
49 <br clear=left>
50 <font size=+2 color=red>
51 <p>This show the relasionships between the ITS hit class and the rest of Aliroot.
52 </font>
53 <pre>
54 */
55 //End_Html
56 ////////////////////////////////////////////////////////////////////////
57 // Inline Member functions:
58 //
59 // AliITShit()
60 //     The default creator of the AliITShit class.
61 //
62 // ~AliITShit()
63 //     The default destructor of the AliITShit class.
64 //
65 // int GetTrack()
66 //     See AliHit for a full description. Returns the track number fTrack
67 // for this hit.
68 //
69 // SetTrack(int track)
70 //     See AliHit for a full description. Sets the track number fTrack
71 // for this hit.
72 //
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
77 // order bits
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.
82 //
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}
87 //
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
91 // set or not}
92 //
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
96 // or not}
97 //
98 // Bool_t StatusOut()
99 //     Returns kTRUE if the particle producing this hit is goint exit the
100 // simulation. Returns kFalse otherwise. {bit IsTrackOut is set or not}
101 //
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}
106 //
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}
111 //
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}
115 //
116 // Int_t GetLayer()
117 //     Returns the layer number, fLayer, for this hit.
118 //
119 // Int_t GetLadder()
120 //     Returns the ladder number, fLadder, for this hit.
121 //
122 // Int_t GetDetector()
123 //     Returns the detector number, fDet, for this hit.
124 //
125 // GetDetectorID(Int_t &layer, Int_t &ladder, Int_t &detector)
126 //     Returns the layer, ladder, and detector numbers, fLayer fLadder fDet,
127 // in one call.
128 //
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.
132 //
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.
136 //
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.
140 //
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.
144 //
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.
148 //
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.
152 //
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
156 //  Monte Carlo.
157 //
158 // Float_t GetXG()
159 //     Returns the global x position in the units defined by the Monte Carlo.
160 //
161 // Float_t GetYG()
162 //     Returns the global y position in the units defined by the Monte Carlo.
163 //
164 // Float_t GetYG()
165 //     Returns the global z position in the units defined by the Monte Carlo.
166 //
167 // Float_t GetTOF()
168 //     Returns the time of flight, fTof, of this hit, in the units defined
169 // by the Monte Carlo.
170 //
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.
174 //
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.
178 //
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.
182 //
183 // Float_t GetPXG()
184 //     Returns the global X momentum in the units defined by the Monte Carlo.
185 //
186 // Float_t GetPYG()
187 //     Returns the global Y momentum in the units defined by the Monte Carlo.
188 //
189 // Float_t GetPZG()
190 //     Returns the global Z momentum in the units defined by the Monte Carlo.
191 //
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
207 {
208     // Default Constructor
209     // Zero data member just to be safe.
210     // Intputs:
211     //    none.
212     // Outputs:
213     //    none.
214     // Return:
215     //    A default created AliITShit class.
216
217 }
218 //----------------------------------------------------------------------
219 AliITShit::AliITShit(Int_t shunt,Int_t track,Int_t *vol,Float_t edep,
220                      Float_t tof,TLorentzVector &x,TLorentzVector &x0,
221                      TLorentzVector &p) :
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
235 {
236     // Create ITS hit
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
240     // Inputs:
241     //    Int_t shunt   See AliHit
242     //    Int_t track   Track number, see AliHit
243     //    Int_t *vol     Array of integer hit data,
244     //                     vol[0] module
245     //                     vol[1] not used
246     //                     vol[2] not used
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
250     //                       of this step
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 
254     //                       started from [cm]
255     //    TLorenzVector &p   The Global momentum of the particle at this
256     //                       step [GeV/c]
257     // Outputs:
258     //    none.
259     // Return:
260     //    A default created AliITShit class.
261
262     SetPosition(x);
263 }
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
279 {
280     // Create ITS hit
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
288     // Intputs:
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
293     //                     vol[1] not used
294     //                     vol[2] not used
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
310     // Outputs:
311     //    none.
312     // Return:
313     //    A standard created AliITShit class.
314
315     fX          = hits[0];  // Track X global position
316     fY          = hits[1];  // Track Y global position
317     fZ          = hits[2];  // Track Z global position
318 }
319 //______________________________________________________________________
320 AliITShit::AliITShit(const AliITShit &h):
321 AliHit(h), // AliHit
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
334 {
335     // The standard copy constructor
336     // Inputs:
337     //   AliITShit   &h the sourse of this copy
338     // Outputs:
339     //   none.
340     // Return:
341     //  A copy of the sourse hit h
342
343     //Info("CopyConstructor","Coping hit");
344
345     if(this == &h) return;
346     return;
347 }
348 //______________________________________________________________________
349 AliITShit& AliITShit::operator=(const AliITShit &h){
350     // The standard = operator
351     // Inputs:
352     //   AliITShit   &h the sourse of this copy
353     // Outputs:
354     //   none.
355     // Return:
356     //  A copy of the sourse hit h
357
358     if(this == &h) return *this;
359     this->fStatus  = h.fStatus;
360     this->fModule  = h.fModule;
361     this->fPx      = h.fPx;
362     this->fPy      = h.fPy;
363     this->fPz      = h.fPz;
364     this->fDestep  = h.fDestep;
365     this->fTof     = h.fTof;
366     this->fStatus0 = h.fStatus0;
367     this->fx0      = h.fx0;
368     this->fy0      = h.fy0;
369     this->fz0      = h.fz0;
370     this->ft0      = h.ft0;
371     return *this;
372 }
373 //______________________________________________________________________
374 void AliITShit::SetShunt(Int_t shunt){
375     // Sets track flag based on shunt value. Code copied from
376     // AliHit standar constructor.
377     // Inputs:
378     //   Int_t shunt    A flag to indecate what to do with track numbers
379     // Outputs:
380     //   none.
381     // Return:
382     //   none.
383     Int_t primary,track,current,parent;
384     TParticle *part;
385
386     track = fTrack;
387     if(shunt == 1) {
388         primary = gAlice->GetMCApp()->GetPrimary(track);
389         gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
390         fTrack=primary;
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
396         parent=track;
397         while (1) {
398             current=parent;
399             part = gAlice->GetMCApp()->Particle(current);
400             parent=part->GetFirstMother();
401             if(parent<0 || part->TestBit(kKeepBit))
402                 break;
403         }
404         fTrack=current;
405     }else {
406         fTrack=track;
407         gAlice->GetMCApp()->FlagTrack(fTrack);
408     } // end if shunt
409 }
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.
414     // Inputs:
415     //   none.
416     // Outputs:
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
421     // Return:
422     //   none.
423     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
424     Float_t g[3],l[3];
425
426     g[0] = fX;
427     g[1] = fY;
428     g[2] = fZ;
429     if(gm) {
430         gm->GtoL(fModule,g,l);
431         x = l[0];
432         y = l[1];
433         z = l[2];
434     } else {
435         Error("AliITShit","NULL pointer to the geometry! return smth else");
436         // AliITSv7 - SDD case
437         x=fX;
438         y=fY;
439         z=fZ;
440     } // end if
441     tof = fTof;
442     return;
443 }
444 //______________________________________________________________________
445 void AliITShit::GetPositionL0(Double_t &x,Double_t &y,Double_t &z,
446                               Double_t &tof){
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 
449     // Monte Carlo.
450     // Inputs:
451     //   none.
452     // Outputs:
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
457     // Return:
458     //   none.
459     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
460     Float_t g[3],l[3];
461
462     g[0] = fx0;
463     g[1] = fy0;
464     g[2] = fz0;
465     if(gm) {
466         gm->GtoL(fModule,g,l);
467         x = l[0];
468         y = l[1];
469         z = l[2];
470     } else {
471         Error("AliITShit","NULL pointer to the geometry! return smth else");
472         x=fx0;
473         y=fy0;
474         z=fz0;
475     }
476     tof = ft0;
477     return;
478 }
479 //______________________________________________________________________
480 void AliITShit::GetMomentumL(Float_t &px,Float_t &py,Float_t &pz){
481     //     Returns the momentum of this hit in the local coordinates of this
482     // module, and in the units of the Monte Carlo.
483     // Inputs:
484     //   none.
485     // Outputs:
486     //   Float_t px   Track x momentum at this hit [GeV/c]
487     //   Float_t py   Track y momentum at this hit [GeV/c]
488     //   Float_t pz   Track z momentum at this hit [GeV/c]
489     // Return:
490     //   none.
491     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
492     Float_t g[3],l[3];
493
494     g[0] = fPx;
495     g[1] = fPy;
496     g[2] = fPz;
497     if (gm) {
498         gm->GtoLMomentum(fModule,g,l);
499         px = l[0];
500         py = l[1];
501         pz = l[2];
502     } else {
503         Error("AliITShit","NULL pointer to the geometry! return smth else");
504         px=fPx;
505         py=fPy;
506         pz=fPz;
507     } // end if
508     return;
509 }
510 //______________________________________________________________________
511 TParticle * AliITShit::GetParticle() const {
512     //     Returns the pointer to the TParticle for the particle that created
513     // this hit. From the TParticle all kinds of information about this 
514     // particle can be found. See the TParticle class.
515     // Inputs:
516     //   none.
517     // Outputs:
518     //   none.
519     // Return:
520     //   The TParticle of the track that created this hit.
521
522     return gAlice->GetMCApp()->Particle(GetTrack());
523 }
524 //----------------------------------------------------------------------
525 void AliITShit::GetDetectorID(Int_t &layer,Int_t &ladder,Int_t &det)const{
526     // Returns the layer ladder and detector number lables for this
527     // ITS module. The use of layer, ladder and detector number for
528     // discribing the ITS is obsoleate.
529     // Inputs:
530     //   none.
531     // Outputs:
532     //   Int_t   &layer   Layer lable
533     //   Int_t   &ladder  Ladder lable
534     //   Int_t   &det     Detector lable
535     // Return:
536     //    none.
537     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
538
539     gm->GetModuleId(fModule,layer,ladder,det);
540     return;
541 }  
542 //----------------------------------------------------------------------
543 void AliITShit::Print(ostream *os) const {
544     // Standard output format for this class.
545     // Inputs:
546     //   ostream *os   The output stream
547     // Outputs:
548     //   none.
549     // Return:
550     //   none.
551
552 #if defined __GNUC__
553 #if __GNUC__ > 2
554     ios::fmtflags fmt;
555 #else
556     Int_t fmt;
557 #endif
558 #else
559 #if defined __ICC || defined __ECC || defined __xlC__
560     ios::fmtflags fmt;
561 #else
562     Int_t fmt;
563 #endif
564 #endif
565  
566     fmt = os->setf(ios::scientific);  // set scientific floating point output
567     *os << fTrack << " " << fX << " " << fY << " " << fZ << " ";
568     fmt = os->setf(ios::hex); // set hex for fStatus only.
569     *os << fStatus << " ";
570     fmt = os->setf(ios::dec); // every thing else decimel.
571     *os << fModule << " ";
572     *os << fPx << " " << fPy << " " << fPz << " ";
573     *os << fDestep << " " << fTof;
574     *os << " " << fx0 << " " << fy0 << " " << fz0;
575 //    *os << " " << endl;
576     os->flags(fmt); // reset back to old formating.
577     return;
578 }
579 //----------------------------------------------------------------------
580 void AliITShit::Read(istream *is) {
581     // Standard input format for this class.
582     // Inputs:
583     //   istream *is  the input stream
584     // Outputs:
585     //   none.
586     // Return:
587     //   none.
588
589     *is >> fTrack >> fX >> fY >> fZ;
590     *is >> fStatus >> fModule >> fPx >> fPy >> fPz >> fDestep >> fTof;
591     *is >> fx0 >> fy0 >> fz0;
592     return;
593 }
594 //----------------------------------------------------------------------
595 ostream &operator<<(ostream &os,AliITShit &p){
596     // Standard output streaming function.
597     // Inputs:
598     //   ostream os  The output stream
599     //   AliITShit p The his to be printed out
600     // Outputs:
601     //   none.
602     // Return:
603     //   The input stream
604
605     p.Print(&os);
606     return os;
607 }
608 //----------------------------------------------------------------------
609 istream &operator>>(istream &is,AliITShit &r){
610     // Standard input streaming function.
611     // Inputs:
612     //   istream is  The input stream
613     //   AliITShit p The AliITShit class to be filled from this input stream
614     // Outputs:
615     //   none.
616     // Return:
617     //   The input stream
618
619     r.Read(&is);
620     return is;
621 }
622 //----------------------------------------------------------------------