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