AliRoot Core  3dc7879 (3dc7879)
AliMCParticle.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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 //-------------------------------------------------------------------------
19 // Realisation of AliVParticle for MC Particles
20 // Implementation wraps a TParticle and delegates the methods
21 // Author: Andreas Morsch, CERN
22 //-------------------------------------------------------------------------
23 
24 #include <TObjArray.h>
25 
26 #include "AliMCParticle.h"
27 #include "AliExternalTrackParam.h"
28 
29 
30 ClassImp(AliMCParticle)
31 
33  AliVParticle(),
34  fParticle(0),
35  fTrackReferences(0),
36  fNTrackRef(0),
37  fLabel(-1),
38  fMother(-1),
39  fFirstDaughter(-1),
40  fLastDaughter(-1),
41  fGeneratorIndex(-1),
42  fStack(0)
43 {
44  // Constructor
45 }
46 
47 
48 AliMCParticle::AliMCParticle(TParticle* part, TObjArray* rarray, Int_t index):
49  AliVParticle(),
50  fParticle(part),
51  fTrackReferences(rarray),
52  fNTrackRef(0),
53  fLabel(index),
54  fMother(-1),
55  fFirstDaughter(-1),
56  fLastDaughter(-1),
57  fGeneratorIndex(-1),
58  fStack(0)
59 {
60  // Constructor
61  if (rarray != 0) {
62  fNTrackRef = fTrackReferences->GetEntriesFast();
63  }
64 }
65 
66 
68  AliVParticle(mcPart),
69  fParticle(0),
71  fNTrackRef(0),
72  fLabel(-1),
73  fMother(-1),
74  fFirstDaughter(-1),
75  fLastDaughter(-1),
76  fGeneratorIndex(-1),
77  fStack(0)
78 {
79 // Copy constructor
80 }
81 
83 {
84 // Copy constructor
85  if (this!=&mcPart) {
87  }
88 
89  return *this;
90 }
91 
93 {
94  // delete the track references passed externally
95  // fParticle should be handled by the user
96  // AliStack in case of AliMCEventHandler
97  if(fTrackReferences){
98  fTrackReferences->Clear();
99  delete fTrackReferences;
100  fTrackReferences = 0;
101  }
102 }
103 
104 
105 
106 Float_t AliMCParticle::GetTPCTrackLength(Float_t bz, Float_t ptmin, Int_t &counter, Float_t deadWidth, Float_t zMax){
107  //
108  // return track length in geometrically active volume of TPC.
109  // z nad rphi acceptance is included
110  // doesn't take into account dead channel and ExB
111  // 25/04/2013 --> zMax as a parameter with default value 230 cm to take into account L1 shift introduced in AliTPC.cxx
112  // Intput:
113  // trackRefs
114  // bz - magnetic field
115  // deadWidth - dead zone in r-phi
116  // Additional output:
117  // counter - number of circles
118 
119  if (fNTrackRef == 0) return 0.;
120 
121  const Float_t kRMin = 90;
122  const Float_t kRMax = 245;
123 // const Float_t kZMax = 250;
124  const Float_t kMinPt= ptmin;
125 
126  Float_t length =0;
127  Int_t nrefs = fNTrackRef;
128 
129 
130  AliExternalTrackParam param;
131  Double_t cv[21];
132  for (Int_t i = 0; i < 21; i++) cv[i]=0;
133  counter=0;
134  //
135  //
136 
138  Float_t direction = 0;
139  //
140  for (Int_t iref = 1; iref < nrefs; iref++){
142  if (!ref) continue;
143  if (!ref0 || ref0->DetectorId()!= AliTrackReference::kTPC){
144  ref0 = ref;
145  direction = ((ref0->X() * ref0->Px() + ref0->Y() * ref0->Py()) > 0)? 1. : -1.;
146  continue;
147  }
148 
149  Float_t newdirection = ((ref->X() * ref->Px() + ref->Y() * ref->Py()) > 0)? 1. : -1.;
150  if (newdirection*direction<0) {
151  counter++; //circle counter
152  direction = newdirection;
153  continue;
154  }
155  if (counter>0) continue;
156  if (ref0->Pt() < kMinPt) break;
157  Float_t radius0 = TMath::Max(TMath::Min(ref0->R(),kRMax),kRMin);;
158  Float_t radius1 = TMath::Max(TMath::Min(ref->R(),kRMax),kRMin);
159  Double_t xyz[3] = {ref0->X(), ref0->Y(), ref0->Z()};
160  Double_t pxyz[3]= {ref0->Px(), ref0->Py(), ref0->Pz()};
161  Double_t alpha;
162  param.Set(xyz,pxyz,cv,TMath::Nint(fParticle->GetPDG()->Charge()/3.));
163 
164  for (Float_t radius = radius0; radius < radius1; radius+=1){
165  param.GetXYZAt(radius, bz, xyz);
166 // if (TMath::Abs(xyz[2]) > kZMax) continue;
167  if (TMath::Abs(xyz[2]) > zMax) continue;
168  Float_t gradius = TMath::Sqrt(xyz[1] * xyz[1] + xyz[0] * xyz[0]);
169  if (gradius > kRMax) continue;
170  alpha = TMath::ATan2(xyz[1],xyz[0]);
171  if (alpha<0) alpha += TMath::TwoPi();
172  //
173  Int_t sector = Int_t(9 * alpha / TMath::Pi());
174  Float_t lalpha = alpha - ((sector + 0.5) * TMath::Pi() / 9.);
175  Float_t dedge = (TMath::Tan(TMath::Pi() / 18.) - TMath::Abs(TMath::Tan(lalpha))) * gradius;
176  if (dedge>deadWidth) length++;
177  }
178  if (ref->DetectorId()!= AliTrackReference::kTPC) break;
179  ref0 = ref;
180  }
181  return length;
182 }
virtual Float_t R() const
AliMCParticle & operator=(const AliMCParticle &mcPart)
Int_t fFirstDaughter
void Set(T x, T alpha, const T param[5], const T covar[15])
#define TObjArray
TParticle * fParticle
Definition: AliMCParticle.h:96
AliVParticle & operator=(const AliVParticle &vPart)
Float_t GetTPCTrackLength(Float_t bz, Float_t ptmin, Int_t &counter, Float_t deadWidth, Float_t zMax=230.)
virtual Float_t Px() const
virtual Float_t Pz() const
virtual Float_t Pt() const
virtual ~AliMCParticle()
virtual Float_t Py() const
virtual Float_t Y() const
TObjArray * fTrackReferences
Definition: AliMCParticle.h:97
Short_t fGeneratorIndex
virtual Float_t Z() const
AliStack * fStack
virtual Float_t X() const
Bool_t GetXYZAt(Double_t x, Double_t b, Double_t r[3]) const
virtual Int_t DetectorId() const