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