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