Line data Source code
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 : /* $Id$ */
17 :
18 : #include <Riostream.h>
19 :
20 : #include <TLorentzVector.h>
21 : #include <TParticle.h>
22 :
23 : #include "AliRun.h"
24 : #include "AliITS.h"
25 : #include "AliITSgeom.h"
26 : #include "AliITShit.h"
27 : #include "AliMC.h"
28 : #include "AliStack.h"
29 :
30 : using std::ios;
31 116 : ClassImp(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 : /*
47 : <img src="picts/ITS/AliITShit_Class_Diagram.gif">
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
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 : ////////////////////////////////////////////////////////////////////////
193 : //_____________________________________________________________________________
194 732 : AliITShit::AliITShit():AliHit(),
195 732 : fStatus(0), // Track Status
196 732 : fModule(0), // Module number
197 732 : fPx(0.0), // PX of particle at the point of the hit
198 732 : fPy(0.0), // PY of particle at the point of the hit
199 732 : fPz(0.0), // PZ of particle at the point of the hit
200 732 : fDestep(0.0), // Energy deposited in the current step
201 732 : fTof(0.0), // Time of flight at the point of the hit
202 732 : fStatus0(0),// Track Status of Starting point
203 732 : fx0(0.0), // Starting point of this step
204 732 : fy0(0.0), // Starting point of this step
205 732 : fz0(0.0), // Starting point of this step
206 732 : ft0(0.0) // Starting point of this step
207 3660 : {
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 :
217 1464 : }
218 : //----------------------------------------------------------------------
219 : AliITShit::AliITShit(Int_t shunt,Int_t track,Int_t *vol,Float_t edep,
220 : Float_t tof,TLorentzVector &x,TLorentzVector &x0,
221 : TLorentzVector &p) :
222 0 : AliHit(shunt, track), // AliHit
223 0 : fStatus(vol[3]), // Track Status
224 0 : fModule(vol[0]), // Module number
225 0 : fPx(p.Px()), // PX of particle at the point of the hit
226 0 : fPy(p.Py()), // PY of particle at the point of the hit
227 0 : fPz(p.Pz()), // PZ of particle at the point of the hit
228 0 : fDestep(edep), // Energy deposited in the current step
229 0 : fTof(tof), // Time of flight at the point of the hit
230 0 : fStatus0(vol[4]),// Track Status of Starting point
231 0 : fx0(x0.X()), // Starting point of this step
232 0 : fy0(x0.Y()), // Starting point of this step
233 0 : fz0(x0.Z()), // Starting point of this step
234 0 : ft0(x0.T()) // Starting point of this step
235 0 : {
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:
241 : // Int_t shunt See AliHit
242 : // Int_t track Track number, see AliHit
243 : // Int_t *vol Array of integer hit data,
244 : // vol[0] module
245 : // vol[1] not used
246 : // vol[2] not used
247 : // vol[3] Set of status bits
248 : // vol[4] Set of status bits at start
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]
257 : // Outputs:
258 : // none.
259 : // Return:
260 : // A default created AliITShit class.
261 :
262 0 : SetPosition(x);
263 0 : }
264 : //______________________________________________________________________
265 : AliITShit::AliITShit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
266 0 : AliHit(shunt, track), // AliHit
267 0 : fStatus(vol[3]), // Track Status
268 0 : fModule(vol[0]), // Module number
269 0 : fPx(hits[3]), // PX of particle at the point of the hit
270 0 : fPy(hits[4]), // PY of particle at the point of the hit
271 0 : fPz(hits[5]), // PZ of particle at the point of the hit
272 0 : fDestep(hits[6]), // Energy deposited in the current step
273 0 : fTof(hits[7]), // Time of flight at the point of the hit
274 0 : fStatus0(vol[4]),// Track Status of Starting point
275 0 : fx0(hits[8]), // Starting point of this step
276 0 : fy0(hits[9]), // Starting point of this step
277 0 : fz0(hits[10]), // Starting point of this step
278 0 : ft0(hits[11]) // Starting point of this step
279 0 : {
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
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,
292 : // vol[0] module number
293 : // vol[1] not used
294 : // vol[2] not used
295 : // vol[3] Set of status bits
296 : // vol[4] Set of status bits at start
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
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
310 : // Outputs:
311 : // none.
312 : // Return:
313 : // A standard created AliITShit class.
314 :
315 0 : fX = hits[0]; // Track X global position
316 0 : fY = hits[1]; // Track Y global position
317 0 : fZ = hits[2]; // Track Z global position
318 0 : }
319 : //______________________________________________________________________
320 : AliITShit::AliITShit(const AliITShit &h):
321 4405 : AliHit(h), // AliHit
322 4405 : fStatus(h.fStatus), // Track Status
323 4405 : fModule(h.fModule), // Module number
324 4405 : fPx(h.fPx), // PX of particle at the point of the hit
325 4405 : fPy(h.fPy), // PY of particle at the point of the hit
326 4405 : fPz(h.fPz), // PZ of particle at the point of the hit
327 4405 : fDestep(h.fDestep), // Energy deposited in the current step
328 4405 : fTof(h.fTof), // Time of flight at the point of the hit
329 4405 : fStatus0(h.fStatus0),// Track Status of Starting point
330 4405 : fx0(h.fx0), // Starting point of this step
331 4405 : fy0(h.fy0), // Starting point of this step
332 4405 : fz0(h.fz0), // Starting point of this step
333 4405 : ft0(h.ft0) // Starting point of this step
334 22025 : {
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
342 :
343 : //Info("CopyConstructor","Coping hit");
344 :
345 : if(this == &h) return;
346 : return;
347 8810 : }
348 : //______________________________________________________________________
349 : AliITShit& 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 0 : if(this == &h) return *this;
359 0 : this->fStatus = h.fStatus;
360 0 : this->fModule = h.fModule;
361 0 : this->fPx = h.fPx;
362 0 : this->fPy = h.fPy;
363 0 : this->fPz = h.fPz;
364 0 : this->fDestep = h.fDestep;
365 0 : this->fTof = h.fTof;
366 0 : this->fStatus0 = h.fStatus0;
367 0 : this->fx0 = h.fx0;
368 0 : this->fy0 = h.fy0;
369 0 : this->fz0 = h.fz0;
370 0 : this->ft0 = h.ft0;
371 0 : return *this;
372 0 : }
373 : //______________________________________________________________________
374 : void 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 2714 : track = fTrack;
387 1357 : if(shunt == 1) {
388 0 : primary = gAlice->GetMCApp()->GetPrimary(track);
389 0 : gAlice->GetMCApp()->Particle(primary)->SetBit(kKeepBit);
390 0 : fTrack=primary;
391 1357 : }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 0 : while (1) {
398 : current=parent;
399 0 : part = gAlice->GetMCApp()->Particle(current);
400 0 : parent=part->GetFirstMother();
401 0 : if(parent<0 || part->TestBit(kKeepBit))
402 : break;
403 : }
404 0 : fTrack=current;
405 0 : }else {
406 1357 : fTrack=track;
407 1357 : gAlice->GetMCApp()->FlagTrack(fTrack);
408 : } // end if shunt
409 1357 : }
410 : //______________________________________________________________________
411 : void AliITShit::GetPositionL(Float_t &x,Float_t &y,Float_t &z,Float_t &tof){
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.
423 5416 : AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
424 2708 : Float_t g[3],l[3];
425 :
426 2708 : g[0] = fX;
427 2708 : g[1] = fY;
428 2708 : g[2] = fZ;
429 2708 : if(gm) {
430 2708 : gm->GtoL(fModule,g,l);
431 2708 : x = l[0];
432 2708 : y = l[1];
433 2708 : z = l[2];
434 2708 : } else {
435 0 : Error("AliITShit","NULL pointer to the geometry! return smth else");
436 : // AliITSv7 - SDD case
437 0 : x=fX;
438 0 : y=fY;
439 0 : z=fZ;
440 : } // end if
441 2708 : tof = fTof;
442 : return;
443 2708 : }
444 : //______________________________________________________________________
445 : void AliITShit::GetPositionL0(Double_t &x,Double_t &y,Double_t &z,
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.
459 2578 : AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
460 1289 : Float_t g[3],l[3];
461 :
462 1289 : g[0] = fx0;
463 1289 : g[1] = fy0;
464 1289 : g[2] = fz0;
465 1289 : if(gm) {
466 1289 : gm->GtoL(fModule,g,l);
467 1289 : x = l[0];
468 1289 : y = l[1];
469 1289 : z = l[2];
470 1289 : } else {
471 0 : Error("AliITShit","NULL pointer to the geometry! return smth else");
472 0 : x=fx0;
473 0 : y=fy0;
474 0 : z=fz0;
475 : }
476 1289 : tof = ft0;
477 : return;
478 1289 : }
479 :
480 : //______________________________________________________________________
481 : TParticle * 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.
491 :
492 0 : return gAlice->GetMCApp()->Particle(GetTrack());
493 : }
494 : //----------------------------------------------------------------------
495 : void 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.
507 7048 : AliITSgeom *gm = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
508 :
509 3524 : gm->GetModuleId(fModule,layer,ladder,det);
510 : return;
511 3524 : }
512 : //----------------------------------------------------------------------
513 : void AliITShit::Print(ostream *os) const {
514 : // Standard output format for this class.
515 : // Inputs:
516 : // ostream *os The output stream
517 : // Outputs:
518 : // none.
519 : // Return:
520 : // none.
521 :
522 : #if defined __GNUC__
523 : #if __GNUC__ > 2
524 : ios::fmtflags fmt;
525 : #else
526 : Int_t fmt;
527 : #endif
528 : #else
529 : #if defined __ICC || defined __ECC || defined __xlC__
530 : ios::fmtflags fmt;
531 : #else
532 : Int_t fmt;
533 : #endif
534 : #endif
535 :
536 0 : fmt = os->setf(ios::scientific); // set scientific floating point output
537 0 : *os << fTrack << " " << fX << " " << fY << " " << fZ << " ";
538 0 : fmt = os->setf(ios::hex); // set hex for fStatus only.
539 0 : *os << fStatus << " ";
540 0 : fmt = os->setf(ios::dec); // every thing else decimel.
541 0 : *os << fModule << " ";
542 0 : *os << fPx << " " << fPy << " " << fPz << " ";
543 0 : *os << fDestep << " " << fTof;
544 0 : *os << " " << fx0 << " " << fy0 << " " << fz0;
545 : // *os << " " << endl;
546 0 : os->flags(fmt); // reset back to old formating.
547 : return;
548 0 : }
549 : //----------------------------------------------------------------------
550 : void AliITShit::Read(istream *is) {
551 : // Standard input format for this class.
552 : // Inputs:
553 : // istream *is the input stream
554 : // Outputs:
555 : // none.
556 : // Return:
557 : // none.
558 :
559 0 : *is >> fTrack >> fX >> fY >> fZ;
560 0 : *is >> fStatus >> fModule >> fPx >> fPy >> fPz >> fDestep >> fTof;
561 0 : *is >> fx0 >> fy0 >> fz0;
562 0 : return;
563 : }
564 : //----------------------------------------------------------------------
565 : ostream &operator<<(ostream &os,AliITShit &p){
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 :
575 0 : p.Print(&os);
576 0 : return os;
577 : }
578 : //----------------------------------------------------------------------
579 : istream &operator>>(istream &is,AliITShit &r){
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 :
589 0 : r.Read(&is);
590 0 : return is;
591 : }
592 : //----------------------------------------------------------------------
|