]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITShit.cxx
added mono-cathods removal in real Pb-Pb settings
[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
88cb7938 16/* $Id$ */
4c039060 17
4ae5bbc4 18#include <Riostream.h>
58005f18 19
012f0f4c 20#include <TLorentzVector.h>
21#include <TParticle.h>
58005f18 22
b2340bbf 23#include "AliRun.h"
58005f18 24#include "AliITS.h"
4fc5ed2d 25#include "AliITSgeom.h"
58005f18 26#include "AliITShit.h"
5d12ce38 27#include "AliMC.h"
5bf6eb16 28#include "AliStack.h"
58005f18 29
fe7d86eb 30using std::ios;
58005f18 31ClassImp(AliITShit)
32////////////////////////////////////////////////////////////////////////
33// Version: 0
34// Written by Rene Brun, Federico Carminati, and Roberto Barbera
35//
36// Version: 1
37// Modified and documented by Bjorn S. Nilsen
38// July 11 1999
39//
40// AliITShit is the hit class for the ITS. Hits are the information
41// that comes from a Monte Carlo at each step as a particle mass through
42// sensitive detector elements as particles are transported through a
43// detector.
44//
45//Begin_Html
46/*
a92b2b7d 47<img src="picts/ITS/AliITShit_Class_Diagram.gif">
58005f18 48</pre>
49<br clear=left>
50<font size=+2 color=red>
51<p>This show the relasionships between the ITS hit class and the rest of Aliroot.
52</font>
53<pre>
54*/
55//End_Html
b2340bbf 56////////////////////////////////////////////////////////////////////////
57// Inline Member functions:
58//
59// AliITShit()
60// The default creator of the AliITShit class.
61//
62// ~AliITShit()
63// The default destructor of the AliITShit class.
64//
65// int GetTrack()
66// See AliHit for a full description. Returns the track number fTrack
67// for this hit.
68//
69// SetTrack(int track)
70// See AliHit for a full description. Sets the track number fTrack
71// for this hit.
72//
73// Int_t GetTrackStatus()
74// Returns the value of the track status flag fStatus. This flag
75// indicates the track status at the time of creating this hit. It is
76// made up of the following 8 status bits from highest order to lowest
77// order bits
78// 0 : IsTrackAlive(): IsTrackStop():IsTrackDisappeared():
79// IsTrackOut():IsTrackExiting():IsTrackEntering():IsTrackInside() .
80// See AliMC for a description of these functions. If the function is
81// true then the bit is set to one, otherwise it is zero.
82//
83// Bool_t StatusInside()
84// Returns kTRUE if the particle producing this hit is still inside
85// the present volume. Returns kFalse if this particle will be in another
86// volume. {bit IsTrackInside is set or not}
87//
88// Bool_t StatusEntering()
89// Returns kTRUE if the particle producing this hit is has just enterd
90// the present volume. Returns kFalse otherwise. {bit IsTrackEntering is
91// set or not}
92//
93// Bool_t StatusExiting()
94// Returns kTRUE if the particle producing this hit is will exit
95// the present volume. Returns kFalse otherwise. {bit IsTrackExiting is set
96// or not}
97//
98// Bool_t StatusOut()
99// Returns kTRUE if the particle producing this hit is goint exit the
100// simulation. Returns kFalse otherwise. {bit IsTrackOut is set or not}
101//
102// Bool_t StatusDisappeared()
103// Returns kTRUE if the particle producing this hit is going to "disappear"
104// for example it has interacted producing some other particles. Returns
105// kFalse otherwise. {bit IsTrackOut is set or not}
106//
107// Bool_t StatusStop()
108// Returns kTRUE if the particle producing this hit is has dropped below
109// its energy cut off producing some other particles. Returns kFalse otherwise.
110// {bit IsTrackOut is set or not}
111//
112// Bool_t StatuAlives()
113// Returns kTRUE if the particle producing this hit is going to continue
114// to be transported. Returns kFalse otherwise. {bit IsTrackOut is set or not}
115//
116// Int_t GetLayer()
117// Returns the layer number, fLayer, for this hit.
118//
119// Int_t GetLadder()
120// Returns the ladder number, fLadder, for this hit.
121//
122// Int_t GetDetector()
123// Returns the detector number, fDet, for this hit.
124//
125// GetDetectorID(Int_t &layer, Int_t &ladder, Int_t &detector)
126// Returns the layer, ladder, and detector numbers, fLayer fLadder fDet,
127// in one call.
128//
129// Float_t GetIonization()
130// Returns the energy lost, fDestep, by the particle creating this hit,
131// in the units defined by the Monte Carlo.
132//
133// GetPositionG(Float_t &x, Float_t &y, Float_t &z)
134// Returns the global position, fX fY fZ, of this hit, in the units
135// define by the Monte Carlo.
136//
137// GetPositionG(Double_t &x, Double_t &y, Double_t &z)
138// Returns the global position, fX fY fZ, of this hit, in the units
139// define by the Monte Carlo.
140//
141// GetPositionG(Float_t &x, Float_t &y, Float_t &z, Float_t &tof)
142// Returns the global position and time of flight, fX fY fZ fTof, of
143// this hit, in the units define by the Monte Carlo.
144//
145// GetPositionG(Double_t &x,Double_t &y,Double_t &z,Double_t &tof)
146// Returns the global position and time of flight, fX fY fZ fTof, of
147// this hit, in the units define by the Monte Carlo.
148//
149// GetPositionL(Double_t &x,Double_t &y,Double_t &z)
150// Returns the local position, fX fY fZ, of this hit in the coordiante
151// of this module, in the units define by the Monte Carlo.
152//
153// GetPositionG(Double_t &x,Double_t &y,Double_t &z,Double_t &tof)
154// Returns the local position and time of flight, fX fY fZ fTof, of
155// this hit in the coordinates of this module, in the units define by the
156// Monte Carlo.
157//
158// Float_t GetXG()
159// Returns the global x position in the units defined by the Monte Carlo.
160//
161// Float_t GetYG()
162// Returns the global y position in the units defined by the Monte Carlo.
163//
164// Float_t GetYG()
165// Returns the global z position in the units defined by the Monte Carlo.
166//
167// Float_t GetTOF()
168// Returns the time of flight, fTof, of this hit, in the units defined
169// by the Monte Carlo.
170//
171// GetMomentumG(Float_t &px, Float_t &py, Float_t &pz)
172// Returns the global momentum, fPx fPy fPz, of the particle that made
173// this hit, in the units define by the Monte Carlo.
174//
175// GetMomentumG(Double_t &px,Double_t &py,Double_t &pz)
176// Returns the global momentum, fPx fPy fPz, of the particle that made
177// this hit, in the units define by the Monte Carlo.
178//
179// GetMomentumL(Double_t &px,Double_t &py,Double_t &pz)
180// Returns the momentum, fPx fPy fPz in coordinate appropreate for this
181// specific module, in the units define by the Monte Carlo.
182//
183// Float_t GetPXG()
184// Returns the global X momentum in the units defined by the Monte Carlo.
185//
186// Float_t GetPYG()
187// Returns the global Y momentum in the units defined by the Monte Carlo.
188//
189// Float_t GetPZG()
190// Returns the global Z momentum in the units defined by the Monte Carlo.
191//
192////////////////////////////////////////////////////////////////////////
58005f18 193//_____________________________________________________________________________
7537d03c 194AliITShit::AliITShit():AliHit(),
012f0f4c 195fStatus(0), // Track Status
196fModule(0), // Module number
197fPx(0.0), // PX of particle at the point of the hit
198fPy(0.0), // PY of particle at the point of the hit
199fPz(0.0), // PZ of particle at the point of the hit
200fDestep(0.0), // Energy deposited in the current step
201fTof(0.0), // Time of flight at the point of the hit
202fStatus0(0),// Track Status of Starting point
203fx0(0.0), // Starting point of this step
204fy0(0.0), // Starting point of this step
205fz0(0.0), // Starting point of this step
206ft0(0.0) // Starting point of this step
207{
7e3ded1b 208 // Default Constructor
209 // Zero data member just to be safe.
210 // Intputs:
211 // none.
212 // Outputs:
213 // none.
214 // Return:
215 // A default created AliITShit class.
216
7e3ded1b 217}
012f0f4c 218//----------------------------------------------------------------------
7e3ded1b 219AliITShit::AliITShit(Int_t shunt,Int_t track,Int_t *vol,Float_t edep,
012f0f4c 220 Float_t tof,TLorentzVector &x,TLorentzVector &x0,
221 TLorentzVector &p) :
222AliHit(shunt, track), // AliHit
223fStatus(vol[3]), // Track Status
224fModule(vol[0]), // Module number
225fPx(p.Px()), // PX of particle at the point of the hit
226fPy(p.Py()), // PY of particle at the point of the hit
227fPz(p.Pz()), // PZ of particle at the point of the hit
228fDestep(edep), // Energy deposited in the current step
229fTof(tof), // Time of flight at the point of the hit
230fStatus0(vol[4]),// Track Status of Starting point
231fx0(x0.X()), // Starting point of this step
232fy0(x0.Y()), // Starting point of this step
233fz0(x0.Z()), // Starting point of this step
234ft0(x0.T()) // Starting point of this step
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. In the units of the Monte Carlo
240 // Inputs:
7e3ded1b 241 // Int_t shunt See AliHit
242 // Int_t track Track number, see AliHit
243 // Int_t *vol Array of integer hit data,
012f0f4c 244 // vol[0] module
245 // vol[1] not used
246 // vol[2] not used
7e3ded1b 247 // vol[3] Set of status bits
248 // vol[4] Set of status bits at start
012f0f4c 249 // Float_t edep The energy deposited GeV during the transport
250 // of this step
251 // Float_t tof The time of flight of this particle at this step
252 // TLorenzVector &x The Global position of this step [cm]
253 // TLorenzVector &x0 The Global position of where this step
254 // started from [cm]
255 // TLorenzVector &p The Global momentum of the particle at this
256 // step [GeV/c]
7e3ded1b 257 // Outputs:
258 // none.
259 // Return:
260 // A default created AliITShit class.
261
012f0f4c 262 SetPosition(x);
7e3ded1b 263}
264//______________________________________________________________________
58005f18 265AliITShit::AliITShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
012f0f4c 266 AliHit(shunt, track), // AliHit
267fStatus(vol[3]), // Track Status
268fModule(vol[0]), // Module number
269fPx(hits[3]), // PX of particle at the point of the hit
270fPy(hits[4]), // PY of particle at the point of the hit
271fPz(hits[5]), // PZ of particle at the point of the hit
272fDestep(hits[6]), // Energy deposited in the current step
273fTof(hits[7]), // Time of flight at the point of the hit
274fStatus0(vol[4]),// Track Status of Starting point
275fx0(hits[8]), // Starting point of this step
276fy0(hits[9]), // Starting point of this step
277fz0(hits[10]), // Starting point of this step
278ft0(hits[11]) // Starting point of this step
279{
280 // Create ITS hit
281 // The creator of the AliITShit class. The variables shunt and
282 // track are passed to the creator of the AliHit class. See the AliHit
283 // class for a full description. the integer array *vol contains, in order,
284 // fLayer = vol[0], fDet = vol[1], fLadder = vol[2], fStatus = vol[3].
285 // The array *hits contains, in order, fX = hits[0], fY = hits[1],
286 // fZ = hits[2], fPx = hits[3], fPy = hits[4], fPz = hits[5],
287 // fDestep = hits[6], and fTof = hits[7]. In the units of the Monte Carlo
7e3ded1b 288 // Intputs:
289 // Int_t shunt See AliHit
290 // Int_t track Track number, see AliHit
291 // Int_t *vol Array of integer hit data,
012f0f4c 292 // vol[0] module number
293 // vol[1] not used
294 // vol[2] not used
7e3ded1b 295 // vol[3] Set of status bits
012f0f4c 296 // vol[4] Set of status bits at start
7e3ded1b 297 // Float_t *hits Array of hit information
298 // hits[0] X global position of this hit
299 // hits[1] Y global position of this hit
300 // hits[2] Z global position of this hit
301 // hits[3] Px global position of this hit
302 // hits[4] Py global position of this hit
303 // hits[5] Pz global position of this hit
304 // hits[6] Energy deposited by this step
305 // hits[7] Time of flight of this particle at this step
012f0f4c 306 // hits[8] X0 global position of start of step
307 // hits[9] Y0 global position of start of step
308 // hits[10] Z0 global position of start of step
309 // hits[11] Time of flight of this particle before step
7e3ded1b 310 // Outputs:
311 // none.
312 // Return:
313 // A standard created AliITShit class.
012f0f4c 314
315 fX = hits[0]; // Track X global position
316 fY = hits[1]; // Track Y global position
317 fZ = hits[2]; // Track Z global position
58005f18 318}
b2340bbf 319//______________________________________________________________________
012f0f4c 320AliITShit::AliITShit(const AliITShit &h):
321AliHit(h), // AliHit
322fStatus(h.fStatus), // Track Status
323fModule(h.fModule), // Module number
324fPx(h.fPx), // PX of particle at the point of the hit
325fPy(h.fPy), // PY of particle at the point of the hit
326fPz(h.fPz), // PZ of particle at the point of the hit
327fDestep(h.fDestep), // Energy deposited in the current step
328fTof(h.fTof), // Time of flight at the point of the hit
329fStatus0(h.fStatus0),// Track Status of Starting point
330fx0(h.fx0), // Starting point of this step
331fy0(h.fy0), // Starting point of this step
332fz0(h.fz0), // Starting point of this step
333ft0(h.ft0) // Starting point of this step
334{
335 // The standard copy constructor
336 // Inputs:
337 // AliITShit &h the sourse of this copy
338 // Outputs:
339 // none.
340 // Return:
341 // A copy of the sourse hit h
58005f18 342
012f0f4c 343 //Info("CopyConstructor","Coping hit");
344
345 if(this == &h) return;
58005f18 346 return;
347}
b2340bbf 348//______________________________________________________________________
012f0f4c 349AliITShit& AliITShit::operator=(const AliITShit &h){
350 // The standard = operator
351 // Inputs:
352 // AliITShit &h the sourse of this copy
353 // Outputs:
354 // none.
355 // Return:
356 // A copy of the sourse hit h
357
358 if(this == &h) return *this;
359 this->fStatus = h.fStatus;
360 this->fModule = h.fModule;
361 this->fPx = h.fPx;
362 this->fPy = h.fPy;
363 this->fPz = h.fPz;
364 this->fDestep = h.fDestep;
365 this->fTof = h.fTof;
366 this->fStatus0 = h.fStatus0;
367 this->fx0 = h.fx0;
368 this->fy0 = h.fy0;
369 this->fz0 = h.fz0;
370 this->ft0 = h.ft0;
371 return *this;
372}
373//______________________________________________________________________
374void AliITShit::SetShunt(Int_t shunt){
375 // Sets track flag based on shunt value. Code copied from
376 // AliHit standar constructor.
377 // Inputs:
378 // Int_t shunt A flag to indecate what to do with track numbers
379 // Outputs:
380 // none.
381 // Return:
382 // none.
383 Int_t primary,track,current,parent;
384 TParticle *part;
385
386 track = fTrack;
387 if(shunt == 1) {
388 primary = gAlice->GetMCApp()->GetPrimary(track);
389 gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
390 fTrack=primary;
391 }else if (shunt == 2) {
392 // the "primary" particle associated to the hit is
393 // the last track that has been flagged in the StepManager
394 // used by PHOS to associate the hit with the decay gamma
395 // rather than with the original pi0
396 parent=track;
397 while (1) {
398 current=parent;
399 part = gAlice->GetMCApp()->Particle(current);
400 parent=part->GetFirstMother();
401 if(parent<0 || part->TestBit(kKeepBit))
402 break;
403 }
404 fTrack=current;
405 }else {
406 fTrack=track;
407 gAlice->GetMCApp()->FlagTrack(fTrack);
408 } // end if shunt
409}
410//______________________________________________________________________
58005f18 411void AliITShit::GetPositionL(Float_t &x,Float_t &y,Float_t &z,Float_t &tof){
012f0f4c 412 // Returns the position and time of flight of this hit in the local
413 // coordinates of this module, and in the units of the Monte Carlo.
414 // Inputs:
415 // none.
416 // Outputs:
417 // Float_t x Global position of this hit [cm]
418 // Float_t y Global position of this hit [cm]
419 // Float_t z Global poistion of this hit [cm]
420 // Float_t tof Time of flight of particle at this hit
421 // Return:
422 // none.
58005f18 423 AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
424 Float_t g[3],l[3];
425
426 g[0] = fX;
427 g[1] = fY;
428 g[2] = fZ;
4fc5ed2d 429 if(gm) {
012f0f4c 430 gm->GtoL(fModule,g,l);
431 x = l[0];
432 y = l[1];
433 z = l[2];
4fc5ed2d 434 } else {
a5a317a9 435 Error("AliITShit","NULL pointer to the geometry! return smth else");
012f0f4c 436 // AliITSv7 - SDD case
437 x=fX;
438 y=fY;
439 z=fZ;
440 } // end if
58005f18 441 tof = fTof;
442 return;
443}
b2340bbf 444//______________________________________________________________________
d2ace6e6 445void AliITShit::GetPositionL0(Double_t &x,Double_t &y,Double_t &z,
012f0f4c 446 Double_t &tof){
447 // Returns the initial position and time of flight of this hit
448 // in the local coordinates of this module, and in the units of the
449 // Monte Carlo.
450 // Inputs:
451 // none.
452 // Outputs:
453 // Double_t x Global position of this hit [cm]
454 // Double_t y Global position of this hit [cm]
455 // Double_t z Global poistion of this hit [cm]
456 // Double_t tof Time of flight of particle at this hit
457 // Return:
458 // none.
d2ace6e6 459 AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
460 Float_t g[3],l[3];
461
462 g[0] = fx0;
463 g[1] = fy0;
464 g[2] = fz0;
465 if(gm) {
012f0f4c 466 gm->GtoL(fModule,g,l);
467 x = l[0];
468 y = l[1];
469 z = l[2];
d2ace6e6 470 } else {
a5a317a9 471 Error("AliITShit","NULL pointer to the geometry! return smth else");
012f0f4c 472 x=fx0;
473 y=fy0;
474 z=fz0;
d2ace6e6 475 }
476 tof = ft0;
477 return;
478}
58005f18 479
b2340bbf 480//______________________________________________________________________
012f0f4c 481TParticle * AliITShit::GetParticle() const {
482 // Returns the pointer to the TParticle for the particle that created
483 // this hit. From the TParticle all kinds of information about this
484 // particle can be found. See the TParticle class.
485 // Inputs:
486 // none.
487 // Outputs:
488 // none.
489 // Return:
490 // The TParticle of the track that created this hit.
4fc5ed2d 491
012f0f4c 492 return gAlice->GetMCApp()->Particle(GetTrack());
b2340bbf 493}
012f0f4c 494//----------------------------------------------------------------------
495void AliITShit::GetDetectorID(Int_t &layer,Int_t &ladder,Int_t &det)const{
496 // Returns the layer ladder and detector number lables for this
497 // ITS module. The use of layer, ladder and detector number for
498 // discribing the ITS is obsoleate.
499 // Inputs:
500 // none.
501 // Outputs:
502 // Int_t &layer Layer lable
503 // Int_t &ladder Ladder lable
504 // Int_t &det Detector lable
505 // Return:
506 // none.
b2340bbf 507 AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
508
012f0f4c 509 gm->GetModuleId(fModule,layer,ladder,det);
510 return;
3dbb2c95 511}
512//----------------------------------------------------------------------
33da2552 513void AliITShit::Print(ostream *os) const {
012f0f4c 514 // Standard output format for this class.
515 // Inputs:
516 // ostream *os The output stream
517 // Outputs:
518 // none.
519 // Return:
520 // none.
521
3dbb2c95 522#if defined __GNUC__
523#if __GNUC__ > 2
524 ios::fmtflags fmt;
525#else
526 Int_t fmt;
527#endif
94831058 528#else
9f69211c 529#if defined __ICC || defined __ECC || defined __xlC__
94831058 530 ios::fmtflags fmt;
3dbb2c95 531#else
532 Int_t fmt;
94831058 533#endif
3dbb2c95 534#endif
535
536 fmt = os->setf(ios::scientific); // set scientific floating point output
e11d9a3a 537 *os << fTrack << " " << fX << " " << fY << " " << fZ << " ";
3dbb2c95 538 fmt = os->setf(ios::hex); // set hex for fStatus only.
539 *os << fStatus << " ";
540 fmt = os->setf(ios::dec); // every thing else decimel.
012f0f4c 541 *os << fModule << " ";
3dbb2c95 542 *os << fPx << " " << fPy << " " << fPz << " ";
543 *os << fDestep << " " << fTof;
000d397e 544 *os << " " << fx0 << " " << fy0 << " " << fz0;
545// *os << " " << endl;
3dbb2c95 546 os->flags(fmt); // reset back to old formating.
547 return;
548}
549//----------------------------------------------------------------------
33da2552 550void AliITShit::Read(istream *is) {
012f0f4c 551 // Standard input format for this class.
552 // Inputs:
553 // istream *is the input stream
554 // Outputs:
555 // none.
556 // Return:
557 // none.
e11d9a3a 558
559 *is >> fTrack >> fX >> fY >> fZ;
012f0f4c 560 *is >> fStatus >> fModule >> fPx >> fPy >> fPz >> fDestep >> fTof;
7e3ded1b 561 *is >> fx0 >> fy0 >> fz0;
3dbb2c95 562 return;
563}
564//----------------------------------------------------------------------
565ostream &operator<<(ostream &os,AliITShit &p){
012f0f4c 566 // Standard output streaming function.
567 // Inputs:
568 // ostream os The output stream
569 // AliITShit p The his to be printed out
570 // Outputs:
571 // none.
572 // Return:
573 // The input stream
574
3dbb2c95 575 p.Print(&os);
576 return os;
577}
578//----------------------------------------------------------------------
579istream &operator>>(istream &is,AliITShit &r){
012f0f4c 580 // Standard input streaming function.
581 // Inputs:
582 // istream is The input stream
583 // AliITShit p The AliITShit class to be filled from this input stream
584 // Outputs:
585 // none.
586 // Return:
587 // The input stream
588
3dbb2c95 589 r.Read(&is);
590 return is;
b2340bbf 591}
3dbb2c95 592//----------------------------------------------------------------------