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