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