]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITShit.cxx
5e10b5a9317068ca40eafdbdcd433c0ccbe6a1c4
[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 /*
17 $Log$
18 Revision 1.13  2002/03/09 18:35:35  nilsen
19 Added functions to print out Hit data members.
20
21 Revision 1.12  2002/03/08 16:05:05  nilsen
22 Standeard io streamers added to make debugging et al. easier.
23
24 Revision 1.11  2001/01/30 09:23:13  hristov
25 Streamers removed (R.Brun)
26
27 Revision 1.10  2001/01/26 20:01:19  hristov
28 Major upgrade of AliRoot code
29
30 Revision 1.9  2000/10/02 16:32:51  barbera
31 Automatic streamer used and forward declarations added
32
33 Revision 1.3.4.7  2000/10/02 15:54:49  barbera
34 Automatic streamer used and forward declarations added
35
36 Revision 1.8  2000/09/22 12:35:21  nilsen
37 Traps placed incase it is used without a properly initilized AliITSgeom class.
38
39 Revision 1.7  2000/07/10 16:07:18  fca
40 Release version of ITS code
41
42 Revision 1.3.4.2  2000/03/04 23:43:57  nilsen
43 Fixed up the comments/documentation.
44
45 Revision 1.3.4.1  2000/01/12 19:03:32  nilsen
46 This is the version of the files after the merging done in December 1999.
47 See the ReadMe110100.txt file for details
48
49 Revision 1.3  1999/09/29 09:24:20  fca
50 Introduction of the Copyright and cvs Log
51
52 */
53
54 #include <iostream.h>
55
56 #include <TMath.h>
57 #include <TRandom.h>
58 #include <TVector.h>
59 #include <TGeometry.h>
60 #include <TNode.h>
61 #include <TTUBE.h>
62 #include "TParticle.h"
63
64 #include "AliRun.h"
65 #include "AliITS.h"
66 #include "AliITSgeom.h"
67 #include "AliITShit.h"
68
69
70 ClassImp(AliITShit)
71 ////////////////////////////////////////////////////////////////////////
72 // Version: 0
73 // Written by Rene Brun, Federico Carminati, and Roberto Barbera
74 //
75 // Version: 1
76 // Modified and documented by Bjorn S. Nilsen
77 // July 11 1999
78 //
79 // AliITShit is the hit class for the ITS. Hits are the information
80 // that comes from a Monte Carlo at each step as a particle mass through
81 // sensitive detector elements as particles are transported through a
82 // detector.
83 //
84 //Begin_Html
85 /*
86 <img src="picts/ITS/AliITShit_Class_Diagram.gif">
87 </pre>
88 <br clear=left>
89 <font size=+2 color=red>
90 <p>This show the relasionships between the ITS hit class and the rest of Aliroot.
91 </font>
92 <pre>
93 */
94 //End_Html
95 ////////////////////////////////////////////////////////////////////////
96 // Inline Member functions:
97 //
98 // AliITShit()
99 //     The default creator of the AliITShit class.
100 //
101 // ~AliITShit()
102 //     The default destructor of the AliITShit class.
103 //
104 // int GetTrack()
105 //     See AliHit for a full description. Returns the track number fTrack
106 // for this hit.
107 //
108 // SetTrack(int track)
109 //     See AliHit for a full description. Sets the track number fTrack
110 // for this hit.
111 //
112 // Int_t GetTrackStatus()
113 //     Returns the value of the track status flag fStatus. This flag
114 // indicates the track status at the time of creating this hit. It is
115 // made up of the following 8 status bits from highest order to lowest
116 // order bits
117 // 0           :  IsTrackAlive():    IsTrackStop():IsTrackDisappeared():
118 // IsTrackOut():IsTrackExiting():IsTrackEntering():IsTrackInside()     .
119 // See AliMC for a description of these functions. If the function is
120 // true then the bit is set to one, otherwise it is zero.
121 //
122 // Bool_t StatusInside()
123 //     Returns kTRUE if the particle producing this hit is still inside
124 // the present volume. Returns kFalse if this particle will be in another
125 // volume. {bit IsTrackInside is set or not}
126 //
127 // Bool_t StatusEntering()
128 //     Returns kTRUE if the particle producing this hit is has just enterd
129 // the present volume. Returns kFalse otherwise.  {bit IsTrackEntering is
130 // set or not}
131 //
132 // Bool_t StatusExiting()
133 //     Returns kTRUE if the particle producing this hit is will exit
134 // the present volume. Returns kFalse otherwise. {bit IsTrackExiting is set
135 // or not}
136 //
137 // Bool_t StatusOut()
138 //     Returns kTRUE if the particle producing this hit is goint exit the
139 // simulation. Returns kFalse otherwise. {bit IsTrackOut is set or not}
140 //
141 // Bool_t StatusDisappeared()
142 //     Returns kTRUE if the particle producing this hit is going to "disappear"
143 // for example it has interacted producing some other particles. Returns
144 //  kFalse otherwise. {bit IsTrackOut is set or not}
145 //
146 // Bool_t StatusStop()
147 //     Returns kTRUE if the particle producing this hit is has dropped below
148 // its energy cut off producing some other particles. Returns kFalse otherwise.
149 // {bit IsTrackOut is set or not}
150 //
151 // Bool_t StatuAlives()
152 //     Returns kTRUE if the particle producing this hit is going to continue
153 // to be transported. Returns kFalse otherwise. {bit IsTrackOut is set or not}
154 //
155 // Int_t GetLayer()
156 //     Returns the layer number, fLayer, for this hit.
157 //
158 // Int_t GetLadder()
159 //     Returns the ladder number, fLadder, for this hit.
160 //
161 // Int_t GetDetector()
162 //     Returns the detector number, fDet, for this hit.
163 //
164 // GetDetectorID(Int_t &layer, Int_t &ladder, Int_t &detector)
165 //     Returns the layer, ladder, and detector numbers, fLayer fLadder fDet,
166 // in one call.
167 //
168 // Float_t GetIonization()
169 //     Returns the energy lost, fDestep, by the particle creating this hit,
170 // in the units defined by the Monte Carlo.
171 //
172 // GetPositionG(Float_t &x, Float_t &y, Float_t &z)
173 //     Returns the global position, fX fY fZ, of this hit, in the units
174 // define by the Monte Carlo.
175 //
176 // GetPositionG(Double_t &x, Double_t &y, Double_t &z)
177 //     Returns the global position, fX fY fZ, of this hit, in the units
178 // define by the Monte Carlo.
179 //
180 // GetPositionG(Float_t &x, Float_t &y, Float_t &z, Float_t &tof)
181 //     Returns the global position and time of flight, fX fY fZ fTof, of
182 // this hit, in the units define by the Monte Carlo.
183 //
184 // GetPositionG(Double_t &x,Double_t &y,Double_t &z,Double_t &tof)
185 //     Returns the global position and time of flight, fX fY fZ fTof, of
186 // this hit, in the units define by the Monte Carlo.
187 //
188 // GetPositionL(Double_t &x,Double_t &y,Double_t &z)
189 //     Returns the local position, fX fY fZ, of this hit in the coordiante
190 // of this module, in the units define by the Monte Carlo.
191 //
192 // GetPositionG(Double_t &x,Double_t &y,Double_t &z,Double_t &tof)
193 //     Returns the local position and time of flight, fX fY fZ fTof, of
194 // this hit in the coordinates of this module, in the units define by the
195 //  Monte Carlo.
196 //
197 // Float_t GetXG()
198 //     Returns the global x position in the units defined by the Monte Carlo.
199 //
200 // Float_t GetYG()
201 //     Returns the global y position in the units defined by the Monte Carlo.
202 //
203 // Float_t GetYG()
204 //     Returns the global z position in the units defined by the Monte Carlo.
205 //
206 // Float_t GetTOF()
207 //     Returns the time of flight, fTof, of this hit, in the units defined
208 // by the Monte Carlo.
209 //
210 // GetMomentumG(Float_t &px, Float_t &py, Float_t &pz)
211 //     Returns the global momentum, fPx fPy fPz, of the particle that made
212 // this hit, in the units define by the Monte Carlo.
213 //
214 // GetMomentumG(Double_t &px,Double_t &py,Double_t &pz)
215 //     Returns the global momentum, fPx fPy fPz, of the particle that made
216 // this hit, in the units define by the Monte Carlo.
217 //
218 // GetMomentumL(Double_t &px,Double_t &py,Double_t &pz)
219 //     Returns the momentum, fPx fPy fPz in coordinate appropreate for this
220 // specific module, in the units define by the Monte Carlo.
221 //
222 // Float_t GetPXG()
223 //     Returns the global X momentum in the units defined by the Monte Carlo.
224 //
225 // Float_t GetPYG()
226 //     Returns the global Y momentum in the units defined by the Monte Carlo.
227 //
228 // Float_t GetPZG()
229 //     Returns the global Z momentum in the units defined by the Monte Carlo.
230 //
231 ////////////////////////////////////////////////////////////////////////
232 //_____________________________________________________________________________
233 AliITShit::AliITShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
234     AliHit(shunt, track){
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. the integer array *vol contains, in order,
240 // fLayer = vol[0], fDet = vol[1], fLadder = vol[2], fStatus = vol[3].
241 // The array *hits contains, in order, fX = hits[0], fY = hits[1],
242 // fZ = hits[2], fPx = hits[3], fPy = hits[4], fPz = hits[5],
243 // fDestep = hits[6], and fTof = hits[7]. In the units of the Monte Carlo
244 ////////////////////////////////////////////////////////////////////////
245   fLayer      = vol[0];   // Layer number
246   fLadder     = vol[2];   // Ladder number
247   fDet        = vol[1];   // Detector number
248   fStatus     = vol[3];   // Track status flags
249   fX          = hits[0];  // Track X position
250   fY          = hits[1];  // Track Y position
251   fZ          = hits[2];  // Track Z position
252   fPx         = hits[3];  // Track X Momentum
253   fPy         = hits[4];  // Track Y Momentum
254   fPz         = hits[5];  // Track Z Momentum
255   fDestep     = hits[6];  // Track dE/dx for this step
256   fTof        = hits[7];  // Track Time of Flight for this step
257 }
258 //______________________________________________________________________
259 void AliITShit::GetPositionL(Float_t &x,Float_t &y,Float_t &z){
260 ////////////////////////////////////////////////////////////////////////
261 //     Returns the position of this hit in the local coordinates of this
262 // module, and in the units of the Monte Carlo.
263 ////////////////////////////////////////////////////////////////////////
264     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
265     Float_t g[3],l[3];
266
267     g[0] = fX;
268     g[1] = fY;
269     g[2] = fZ;
270     if(gm) {
271       gm->GtoL(fLayer,fLadder,fDet,g,l);
272       x = l[0];
273       y = l[1];
274       z = l[2];
275     } else {
276       Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
277       // AliITSv7 - SDD case
278       x=fX;
279       y=fZ;
280       z=fY;
281     }
282     return;
283 }
284 //______________________________________________________________________
285 void AliITShit::GetPositionL(Float_t &x,Float_t &y,Float_t &z,Float_t &tof){
286 ////////////////////////////////////////////////////////////////////////
287 //     Returns the position and time of flight of this hit in the local
288 // coordinates of this module, and in the units of the Monte Carlo.
289 ////////////////////////////////////////////////////////////////////////
290     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
291     Float_t g[3],l[3];
292
293     g[0] = fX;
294     g[1] = fY;
295     g[2] = fZ;
296     if(gm) {
297       gm->GtoL(fLayer,fLadder,fDet,g,l);
298       x = l[0];
299       y = l[1];
300       z = l[2];
301     } else {
302       Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
303       // AliITSv7 - SDD case
304       x=fX;
305       y=fZ;
306       z=fY;
307     }
308     tof = fTof;
309     return;
310 }
311 //______________________________________________________________________
312 Float_t AliITShit::GetXL(){
313 ////////////////////////////////////////////////////////////////////////
314 //     Returns the x position of this hit in the local coordinates of this
315 // module, and in the units of the Monte Carlo.
316 ////////////////////////////////////////////////////////////////////////
317     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
318     Float_t g[3],l[3];
319
320     g[0] = fX;
321     g[1] = fY;
322     g[2] = fZ;
323     if(gm) {
324       gm->GtoL(fLayer,fLadder,fDet,g,l);
325       return l[0];
326     } else {
327       Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
328       return fX;
329     }
330 }
331 //______________________________________________________________________
332 Float_t AliITShit::GetYL(){
333 ////////////////////////////////////////////////////////////////////////
334 //     Returns the y position of this hit in the local coordinates of this
335 // module, and in the units of the Monte Carlo.
336 ////////////////////////////////////////////////////////////////////////
337     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
338     Float_t g[3],l[3];
339
340     g[0] = fX;
341     g[1] = fY;
342     g[2] = fZ;
343     if (gm) {
344       gm->GtoL(fLayer,fLadder,fDet,g,l);
345       return l[1];
346     } else {
347       Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
348       return fZ;
349     }
350 }
351 //______________________________________________________________________
352 Float_t AliITShit::GetZL(){
353 ////////////////////////////////////////////////////////////////////////
354 //     Returns the z position of this hit in the local coordinates of this
355 // module, and in the units of the Monte Carlo.
356 ////////////////////////////////////////////////////////////////////////
357     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
358     Float_t g[3],l[3];
359
360     g[0] = fX;
361     g[1] = fY;
362     g[2] = fZ;
363     if(gm) {
364       gm->GtoL(fLayer,fLadder,fDet,g,l);
365       return l[2];
366     } else {
367       Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
368       return fY;
369     }
370 }
371 //______________________________________________________________________
372 void AliITShit::GetMomentumL(Float_t &px,Float_t &py,Float_t &pz){
373 ////////////////////////////////////////////////////////////////////////
374 //     Returns the momentum of this hit in the local coordinates of this
375 // module, and in the units of the Monte Carlo.
376 ////////////////////////////////////////////////////////////////////////
377     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
378     Float_t g[3],l[3];
379
380     g[0] = fPx;
381     g[1] = fPy;
382     g[2] = fPz;
383     if (gm) {
384       gm->GtoLMomentum(fLayer,fLadder,fDet,g,l);
385       px = l[0];
386       py = l[1];
387       pz = l[2];
388     } else {
389       Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
390       px=fPx;
391       py=fPy;
392       pz=fPz;
393     }
394     return;
395 }
396 //______________________________________________________________________
397 Float_t AliITShit::GetPXL(){
398 ////////////////////////////////////////////////////////////////////////
399 //     Returns the X momentum of this hit in the local coordinates of this
400 // module, and in the units of the Monte Carlo.
401 ////////////////////////////////////////////////////////////////////////
402     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
403     Float_t g[3],l[3];
404
405     g[0] = fPx;
406     g[1] = fPy;
407     g[2] = fPz;
408     if (gm) {
409       gm->GtoLMomentum(fLayer,fLadder,fDet,g,l);
410       return l[0];
411     } else {
412       Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
413       return fPx;
414     }
415 }
416 //______________________________________________________________________
417 Float_t AliITShit::GetPYL(){
418 ////////////////////////////////////////////////////////////////////////
419 //     Returns the Y momentum of this hit in the local coordinates of this
420 // module, and in the units of the Monte Carlo.
421 ////////////////////////////////////////////////////////////////////////
422     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
423     Float_t g[3],l[3];
424
425     g[0] = fPx;
426     g[1] = fPy;
427     g[2] = fPz;
428     if (gm) {
429       gm->GtoLMomentum(fLayer,fLadder,fDet,g,l);
430       return l[1];
431     } else {
432       Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
433       return fPy;
434     }
435
436 }
437 //______________________________________________________________________
438 Float_t AliITShit::GetPZL(){
439 ////////////////////////////////////////////////////////////////////////
440 //     Returns the Z momentum of this hit in the local coordinates of this
441 // module, and in the units of the Monte Carlo.
442 ////////////////////////////////////////////////////////////////////////
443     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
444     Float_t g[3],l[3];
445
446     g[0] = fPx;
447     g[1] = fPy;
448     g[2] = fPz;
449     if (gm) {
450       gm->GtoLMomentum(fLayer,fLadder,fDet,g,l);
451       return l[2];
452     } else {
453       Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
454       return fPz;
455     }
456
457 }
458 //___________________________________________________________________________;
459 Int_t AliITShit::GetModule(){
460 ////////////////////////////////////////////////////////////////////////
461 //     Returns the module index number of the module where this hit was in.
462 ////////////////////////////////////////////////////////////////////////
463     AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
464
465     if (gm) return gm->GetModuleIndex(fLayer,fLadder,fDet);
466     else {
467       Error("AliITShit","NULL pointer to the geometry! return smth else",gm);
468       return 0;
469     }
470 }
471 //______________________________________________________________________
472 TParticle * AliITShit::GetParticle(){
473 ////////////////////////////////////////////////////////////////////////
474 //     Returns the pointer to the TParticle for the particle that created
475 // this hit. From the TParticle all kinds of information about this 
476 // particle can be found. See the TParticle class.
477 ////////////////////////////////////////////////////////////////////////
478     return gAlice->Particle(GetTrack());
479 }  
480 //----------------------------------------------------------------------
481 void AliITShit::Print(ostream *os){
482 ////////////////////////////////////////////////////////////////////////
483 // Standard output format for this class.
484 ////////////////////////////////////////////////////////////////////////
485 #if defined __GNUC__
486 #if __GNUC__ > 2
487     ios::fmtflags fmt;
488 #else
489     Int_t fmt;
490 #endif
491 #else
492 #if defined __ICC
493     ios::fmtflags fmt;
494 #else
495     Int_t fmt;
496 #endif
497 #endif
498  
499     fmt = os->setf(ios::scientific);  // set scientific floating point output
500     *os << fTrack << " " << fX << " " << fY << " " << fZ << " ";
501     fmt = os->setf(ios::hex); // set hex for fStatus only.
502     *os << fStatus << " ";
503     fmt = os->setf(ios::dec); // every thing else decimel.
504     *os << fLayer << " " << fLadder << " " << fDet << " ";;
505     *os << fPx << " " << fPy << " " << fPz << " ";
506     *os << fDestep << " " << fTof;
507     *os << endl;
508     os->flags(fmt); // reset back to old formating.
509     return;
510 }
511 //----------------------------------------------------------------------
512 void AliITShit::Read(istream *is){
513 ////////////////////////////////////////////////////////////////////////
514 // Standard input format for this class.
515 ////////////////////////////////////////////////////////////////////////
516  
517
518     *is >> fTrack >> fX >> fY >> fZ;
519     *is >> fStatus >> fLayer >> fLadder >> fDet >> fPx >> fPy >> fPz >>
520            fDestep >> fTof;
521     return;
522 }
523 //----------------------------------------------------------------------
524 ostream &operator<<(ostream &os,AliITShit &p){
525 ////////////////////////////////////////////////////////////////////////
526 // Standard output streaming function.
527 ////////////////////////////////////////////////////////////////////////
528  
529     p.Print(&os);
530     return os;
531 }
532 //----------------------------------------------------------------------
533 istream &operator>>(istream &is,AliITShit &r){
534 ////////////////////////////////////////////////////////////////////////
535 // Standard input streaming function.
536 ////////////////////////////////////////////////////////////////////////
537  
538     r.Read(&is);
539     return is;
540 }
541 //----------------------------------------------------------------------