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