added copyright, updated class description
[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$
a8a6107b 18Revision 1.10 2001/01/26 20:01:19 hristov
19Major upgrade of AliRoot code
20
2ab0c725 21Revision 1.9 2000/10/02 16:32:51 barbera
22Automatic streamer used and forward declarations added
23
339150e6 24Revision 1.3.4.7 2000/10/02 15:54:49 barbera
25Automatic streamer used and forward declarations added
26
27Revision 1.8 2000/09/22 12:35:21 nilsen
28Traps placed incase it is used without a properly initilized AliITSgeom class.
29
4fc5ed2d 30Revision 1.7 2000/07/10 16:07:18 fca
31Release version of ITS code
32
b2340bbf 33Revision 1.3.4.2 2000/03/04 23:43:57 nilsen
34Fixed up the comments/documentation.
35
36Revision 1.3.4.1 2000/01/12 19:03:32 nilsen
37This is the version of the files after the merging done in December 1999.
38See the ReadMe110100.txt file for details
39
40Revision 1.3 1999/09/29 09:24:20 fca
41Introduction of the Copyright and cvs Log
42
4c039060 43*/
44
58005f18 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>
4fc5ed2d 52#include "TParticle.h"
58005f18 53
b2340bbf 54#include "AliRun.h"
58005f18 55#include "AliITS.h"
4fc5ed2d 56#include "AliITSgeom.h"
58005f18 57#include "AliITShit.h"
58005f18 58
59
60ClassImp(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/*
a92b2b7d 76<img src="picts/ITS/AliITShit_Class_Diagram.gif">
58005f18 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
b2340bbf 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////////////////////////////////////////////////////////////////////////
58005f18 222//_____________________________________________________________________________
223AliITShit::AliITShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
b2340bbf 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////////////////////////////////////////////////////////////////////////
58005f18 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}
b2340bbf 248//______________________________________________________________________
58005f18 249void AliITShit::GetPositionL(Float_t &x,Float_t &y,Float_t &z){
b2340bbf 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////////////////////////////////////////////////////////////////////////
58005f18 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;
4fc5ed2d 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 }
58005f18 272 return;
273}
b2340bbf 274//______________________________________________________________________
58005f18 275void AliITShit::GetPositionL(Float_t &x,Float_t &y,Float_t &z,Float_t &tof){
b2340bbf 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////////////////////////////////////////////////////////////////////////
58005f18 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;
4fc5ed2d 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 }
58005f18 298 tof = fTof;
299 return;
300}
b2340bbf 301//______________________________________________________________________
58005f18 302Float_t AliITShit::GetXL(){
b2340bbf 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////////////////////////////////////////////////////////////////////////
58005f18 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;
4fc5ed2d 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 }
58005f18 320}
b2340bbf 321//______________________________________________________________________
58005f18 322Float_t AliITShit::GetYL(){
b2340bbf 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////////////////////////////////////////////////////////////////////////
58005f18 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;
4fc5ed2d 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 }
58005f18 340}
b2340bbf 341//______________________________________________________________________
58005f18 342Float_t AliITShit::GetZL(){
b2340bbf 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////////////////////////////////////////////////////////////////////////
58005f18 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;
4fc5ed2d 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 }
58005f18 360}
b2340bbf 361//______________________________________________________________________
58005f18 362void AliITShit::GetMomentumL(Float_t &px,Float_t &py,Float_t &pz){
b2340bbf 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////////////////////////////////////////////////////////////////////////
58005f18 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;
4fc5ed2d 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 }
58005f18 384 return;
385}
b2340bbf 386//______________________________________________________________________
387Float_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;
4fc5ed2d 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 }
b2340bbf 405}
406//______________________________________________________________________
407Float_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;
4fc5ed2d 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
b2340bbf 426}
427//______________________________________________________________________
428Float_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;
4fc5ed2d 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
b2340bbf 447}
448//___________________________________________________________________________;
449Int_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
4fc5ed2d 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 }
b2340bbf 460}
461//______________________________________________________________________
462TParticle * 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////////////////////////////////////////////////////////////////////////
2ab0c725 468 return gAlice->Particle(GetTrack());
b2340bbf 469}