]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITShit.cxx
First version of the SDD DA calibration classes. AliITSOnlineSDDBase - for measuremen...
[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
29
30 ClassImp(AliITShit)
31 ////////////////////////////////////////////////////////////////////////
32 // Version: 0
33 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
34 //
35 // Version: 1
36 // Modified and documented by Bjorn S. Nilsen
37 // July 11 1999
38 //
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
42 // detector.
43 //
44 //Begin_Html
45 /*
46 <img src="picts/ITS/AliITShit_Class_Diagram.gif">
47 </pre>
48 <br clear=left>
49 <font size=+2 color=red>
50 <p>This show the relasionships between the ITS hit class and the rest of Aliroot.
51 </font>
52 <pre>
53 */
54 //End_Html
55 ////////////////////////////////////////////////////////////////////////
56 // Inline Member functions:
57 //
58 // AliITShit()
59 //     The default creator of the AliITShit class.
60 //
61 // ~AliITShit()
62 //     The default destructor of the AliITShit class.
63 //
64 // int GetTrack()
65 //     See AliHit for a full description. Returns the track number fTrack
66 // for this hit.
67 //
68 // SetTrack(int track)
69 //     See AliHit for a full description. Sets the track number fTrack
70 // for this hit.
71 //
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
76 // order bits
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.
81 //
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}
86 //
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
90 // set or not}
91 //
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
95 // or not}
96 //
97 // Bool_t StatusOut()
98 //     Returns kTRUE if the particle producing this hit is goint exit the
99 // simulation. Returns kFalse otherwise. {bit IsTrackOut is set or not}
100 //
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}
105 //
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}
110 //
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}
114 //
115 // Int_t GetLayer()
116 //     Returns the layer number, fLayer, for this hit.
117 //
118 // Int_t GetLadder()
119 //     Returns the ladder number, fLadder, for this hit.
120 //
121 // Int_t GetDetector()
122 //     Returns the detector number, fDet, for this hit.
123 //
124 // GetDetectorID(Int_t &layer, Int_t &ladder, Int_t &detector)
125 //     Returns the layer, ladder, and detector numbers, fLayer fLadder fDet,
126 // in one call.
127 //
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.
131 //
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.
135 //
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.
139 //
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.
143 //
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.
147 //
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.
151 //
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
155 //  Monte Carlo.
156 //
157 // Float_t GetXG()
158 //     Returns the global x position in the units defined by the Monte Carlo.
159 //
160 // Float_t GetYG()
161 //     Returns the global y position in the units defined by the Monte Carlo.
162 //
163 // Float_t GetYG()
164 //     Returns the global z position in the units defined by the Monte Carlo.
165 //
166 // Float_t GetTOF()
167 //     Returns the time of flight, fTof, of this hit, in the units defined
168 // by the Monte Carlo.
169 //
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.
173 //
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.
177 //
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.
181 //
182 // Float_t GetPXG()
183 //     Returns the global X momentum in the units defined by the Monte Carlo.
184 //
185 // Float_t GetPYG()
186 //     Returns the global Y momentum in the units defined by the Monte Carlo.
187 //
188 // Float_t GetPZG()
189 //     Returns the global Z momentum in the units defined by the Monte Carlo.
190 //
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
206 {
207     // Default Constructor
208     // Zero data member just to be safe.
209     // Intputs:
210     //    none.
211     // Outputs:
212     //    none.
213     // Return:
214     //    A default created AliITShit class.
215
216 }
217 //----------------------------------------------------------------------
218 AliITShit::AliITShit(Int_t shunt,Int_t track,Int_t *vol,Float_t edep,
219                      Float_t tof,TLorentzVector &x,TLorentzVector &x0,
220                      TLorentzVector &p) :
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
234 {
235     // Create ITS hit
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
239     // Inputs:
240     //    Int_t shunt   See AliHit
241     //    Int_t track   Track number, see AliHit
242     //    Int_t *vol     Array of integer hit data,
243     //                     vol[0] module
244     //                     vol[1] not used
245     //                     vol[2] not used
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
249     //                       of this step
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 
253     //                       started from [cm]
254     //    TLorenzVector &p   The Global momentum of the particle at this
255     //                       step [GeV/c]
256     // Outputs:
257     //    none.
258     // Return:
259     //    A default created AliITShit class.
260
261     SetPosition(x);
262 }
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
278 {
279     // Create ITS hit
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
287     // Intputs:
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
292     //                     vol[1] not used
293     //                     vol[2] not used
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
309     // Outputs:
310     //    none.
311     // Return:
312     //    A standard created AliITShit class.
313
314     fX          = hits[0];  // Track X global position
315     fY          = hits[1];  // Track Y global position
316     fZ          = hits[2];  // Track Z global position
317 }
318 //______________________________________________________________________
319 AliITShit::AliITShit(const AliITShit &h):
320 AliHit(h), // AliHit
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
333 {
334     // The standard copy constructor
335     // Inputs:
336     //   AliITShit   &h the sourse of this copy
337     // Outputs:
338     //   none.
339     // Return:
340     //  A copy of the sourse hit h
341
342     //Info("CopyConstructor","Coping hit");
343
344     if(this == &h) return;
345     return;
346 }
347 //______________________________________________________________________
348 AliITShit& AliITShit::operator=(const AliITShit &h){
349     // The standard = operator
350     // Inputs:
351     //   AliITShit   &h the sourse of this copy
352     // Outputs:
353     //   none.
354     // Return:
355     //  A copy of the sourse hit h
356
357     if(this == &h) return *this;
358     this->fStatus  = h.fStatus;
359     this->fModule  = h.fModule;
360     this->fPx      = h.fPx;
361     this->fPy      = h.fPy;
362     this->fPz      = h.fPz;
363     this->fDestep  = h.fDestep;
364     this->fTof     = h.fTof;
365     this->fStatus0 = h.fStatus0;
366     this->fx0      = h.fx0;
367     this->fy0      = h.fy0;
368     this->fz0      = h.fz0;
369     this->ft0      = h.ft0;
370     return *this;
371 }
372 //______________________________________________________________________
373 void AliITShit::SetShunt(Int_t shunt){
374     // Sets track flag based on shunt value. Code copied from
375     // AliHit standar constructor.
376     // Inputs:
377     //   Int_t shunt    A flag to indecate what to do with track numbers
378     // Outputs:
379     //   none.
380     // Return:
381     //   none.
382     Int_t primary,track,current,parent;
383     TParticle *part;
384
385     track = fTrack;
386     if(shunt == 1) {
387         primary = gAlice->GetMCApp()->GetPrimary(track);
388         gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
389         fTrack=primary;
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
395         parent=track;
396         while (1) {
397             current=parent;
398             part = gAlice->GetMCApp()->Particle(current);
399             parent=part->GetFirstMother();
400             if(parent<0 || part->TestBit(kKeepBit))
401                 break;
402         }
403         fTrack=current;
404     }else {
405         fTrack=track;
406         gAlice->GetMCApp()->FlagTrack(fTrack);
407     } // end if shunt
408 }
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.
413     // Inputs:
414     //   none.
415     // Outputs:
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
420     // Return:
421     //   none.
422     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
423     Float_t g[3],l[3];
424
425     g[0] = fX;
426     g[1] = fY;
427     g[2] = fZ;
428     if(gm) {
429         gm->GtoL(fModule,g,l);
430         x = l[0];
431         y = l[1];
432         z = l[2];
433     } else {
434         Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
435         // AliITSv7 - SDD case
436         x=fX;
437         y=fY;
438         z=fZ;
439     } // end if
440     tof = fTof;
441     return;
442 }
443 //______________________________________________________________________
444 void AliITShit::GetPositionL0(Double_t &x,Double_t &y,Double_t &z,
445                               Double_t &tof){
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 
448     // Monte Carlo.
449     // Inputs:
450     //   none.
451     // Outputs:
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
456     // Return:
457     //   none.
458     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
459     Float_t g[3],l[3];
460
461     g[0] = fx0;
462     g[1] = fy0;
463     g[2] = fz0;
464     if(gm) {
465         gm->GtoL(fModule,g,l);
466         x = l[0];
467         y = l[1];
468         z = l[2];
469     } else {
470         Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
471         x=fx0;
472         y=fy0;
473         z=fz0;
474     }
475     tof = ft0;
476     return;
477 }
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.
482     // Inputs:
483     //   none.
484     // Outputs:
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]
488     // Return:
489     //   none.
490     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
491     Float_t g[3],l[3];
492
493     g[0] = fPx;
494     g[1] = fPy;
495     g[2] = fPz;
496     if (gm) {
497         gm->GtoLMomentum(fModule,g,l);
498         px = l[0];
499         py = l[1];
500         pz = l[2];
501     } else {
502         Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
503         px=fPx;
504         py=fPy;
505         pz=fPz;
506     } // end if
507     return;
508 }
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.
514     // Inputs:
515     //   none.
516     // Outputs:
517     //   none.
518     // Return:
519     //   The TParticle of the track that created this hit.
520
521     return gAlice->GetMCApp()->Particle(GetTrack());
522 }
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.
528     // Inputs:
529     //   none.
530     // Outputs:
531     //   Int_t   &layer   Layer lable
532     //   Int_t   &ladder  Ladder lable
533     //   Int_t   &det     Detector lable
534     // Return:
535     //    none.
536     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
537
538     gm->GetModuleId(fModule,layer,ladder,det);
539     return;
540 }  
541 //----------------------------------------------------------------------
542 void AliITShit::Print(ostream *os) const {
543     // Standard output format for this class.
544     // Inputs:
545     //   ostream *os   The output stream
546     // Outputs:
547     //   none.
548     // Return:
549     //   none.
550
551 #if defined __GNUC__
552 #if __GNUC__ > 2
553     ios::fmtflags fmt;
554 #else
555     Int_t fmt;
556 #endif
557 #else
558 #if defined __ICC || defined __ECC || defined __xlC__
559     ios::fmtflags fmt;
560 #else
561     Int_t fmt;
562 #endif
563 #endif
564  
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.
576     return;
577 }
578 //----------------------------------------------------------------------
579 void AliITShit::Read(istream *is) {
580     // Standard input format for this class.
581     // Inputs:
582     //   istream *is  the input stream
583     // Outputs:
584     //   none.
585     // Return:
586     //   none.
587
588     *is >> fTrack >> fX >> fY >> fZ;
589     *is >> fStatus >> fModule >> fPx >> fPy >> fPz >> fDestep >> fTof;
590     *is >> fx0 >> fy0 >> fz0;
591     return;
592 }
593 //----------------------------------------------------------------------
594 ostream &operator<<(ostream &os,AliITShit &p){
595     // Standard output streaming function.
596     // Inputs:
597     //   ostream os  The output stream
598     //   AliITShit p The his to be printed out
599     // Outputs:
600     //   none.
601     // Return:
602     //   The input stream
603
604     p.Print(&os);
605     return os;
606 }
607 //----------------------------------------------------------------------
608 istream &operator>>(istream &is,AliITShit &r){
609     // Standard input streaming function.
610     // Inputs:
611     //   istream is  The input stream
612     //   AliITShit p The AliITShit class to be filled from this input stream
613     // Outputs:
614     //   none.
615     // Return:
616     //   The input stream
617
618     r.Read(&is);
619     return is;
620 }
621 //----------------------------------------------------------------------