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