]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - STEER/STEERBase/AliMCParticle.cxx
Moving the classes that belong to the following libraries: STEERBase, ESD, CDB, AOD...
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliMCParticle.cxx
... / ...
CommitLineData
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 <TRefArray.h>
25
26#include "AliMCParticle.h"
27#include "AliExternalTrackParam.h"
28
29
30ClassImp(AliMCParticle)
31
32AliMCParticle::AliMCParticle():
33 AliVParticle(),
34 fParticle(0),
35 fTrackReferences(0),
36 fNTrackRef(0),
37 fLabel(-1),
38 fMother(-1),
39 fFirstDaughter(-1),
40 fLastDaughter(-1)
41{
42 // Constructor
43}
44
45
46AliMCParticle::AliMCParticle(TParticle* part, TRefArray* rarray, Int_t index):
47 AliVParticle(),
48 fParticle(part),
49 fTrackReferences(rarray),
50 fNTrackRef(0),
51 fLabel(index),
52 fMother(-1),
53 fFirstDaughter(-1),
54 fLastDaughter(-1)
55{
56 // Constructor
57 if (rarray != 0) {
58 fNTrackRef = fTrackReferences->GetEntriesFast();
59 }
60}
61
62
63AliMCParticle::AliMCParticle(const AliMCParticle& mcPart) :
64 AliVParticle(mcPart),
65 fParticle(0),
66 fTrackReferences(0),
67 fNTrackRef(0),
68 fLabel(-1),
69 fMother(-1),
70 fFirstDaughter(-1),
71 fLastDaughter(-1)
72{
73// Copy constructor
74}
75
76AliMCParticle& AliMCParticle::operator=(const AliMCParticle& mcPart)
77{
78// Copy constructor
79 if (this!=&mcPart) {
80 AliVParticle::operator=(mcPart);
81 }
82
83 return *this;
84}
85
86AliMCParticle::~AliMCParticle()
87{
88 // delete the track references passed externally
89 // fParticle should be handled by the user
90 // AliStack in case of AliMCEventHandler
91 if(fTrackReferences){
92 fTrackReferences->Delete();
93 delete fTrackReferences;
94 fTrackReferences = 0;
95 }
96}
97
98
99
100Float_t AliMCParticle::GetTPCTrackLength(Float_t bz, Float_t ptmin, Int_t &counter, Float_t deadWidth){
101 //
102 // return track length in geometrically active volume of TPC.
103 // z nad rphi acceptance is included
104 // doesn't take into account dead channel and ExB
105 // Intput:
106 // trackRefs
107 // bz - magnetic field
108 // deadWidth - dead zone in r-phi
109 // Additional output:
110 // counter - number of circles
111
112 if (fNTrackRef == 0) return 0.;
113
114 const Float_t kRMin = 90;
115 const Float_t kRMax = 245;
116 const Float_t kZMax = 250;
117 const Float_t kMinPt= ptmin;
118
119 Float_t length =0;
120 Int_t nrefs = fNTrackRef;
121
122
123 AliExternalTrackParam param;
124 Double_t cv[21];
125 for (Int_t i = 0; i < 21; i++) cv[i]=0;
126 counter=0;
127 //
128 //
129
130 AliTrackReference *ref0 = (AliTrackReference*) (fTrackReferences->At(0));
131 Float_t direction = 0;
132 //
133 for (Int_t iref = 1; iref < nrefs; iref++){
134 AliTrackReference *ref = (AliTrackReference*) (fTrackReferences->At(iref));
135 if (!ref) continue;
136 if (!ref0 || ref0->DetectorId()!= AliTrackReference::kTPC){
137 ref0 = ref;
138 direction = ((ref0->X() * ref0->Px() + ref0->Y() * ref0->Py()) > 0)? 1. : -1.;
139 continue;
140 }
141
142 Float_t newdirection = ((ref->X() * ref->Px() + ref->Y() * ref->Py()) > 0)? 1. : -1.;
143 if (newdirection*direction<0) {
144 counter++; //circle counter
145 direction = newdirection;
146 continue;
147 }
148 if (counter>0) continue;
149 if (ref0->Pt() < kMinPt) break;
150 Float_t radius0 = TMath::Max(TMath::Min(ref0->R(),kRMax),kRMin);;
151 Float_t radius1 = TMath::Max(TMath::Min(ref->R(),kRMax),kRMin);
152 Double_t xyz[3] = {ref0->X(), ref0->Y(), ref0->Z()};
153 Double_t pxyz[3]= {ref0->Px(), ref0->Py(), ref0->Pz()};
154 Double_t alpha;
155 param.Set(xyz,pxyz,cv,TMath::Nint(fParticle->GetPDG()->Charge()/3.));
156
157 for (Float_t radius = radius0; radius < radius1; radius+=1){
158 param.GetXYZAt(radius, bz, xyz);
159 if (TMath::Abs(xyz[2]) > kZMax) continue;
160 Float_t gradius = TMath::Sqrt(xyz[1] * xyz[1] + xyz[0] * xyz[0]);
161 if (gradius > kRMax) continue;
162 alpha = TMath::ATan2(xyz[1],xyz[0]);
163 if (alpha<0) alpha += TMath::TwoPi();
164 //
165 Int_t sector = Int_t(9 * alpha / TMath::Pi());
166 Float_t lalpha = alpha - ((sector + 0.5) * TMath::Pi() / 9.);
167 Float_t dedge = (TMath::Tan(TMath::Pi() / 18.) - TMath::Abs(TMath::Tan(lalpha))) * gradius;
168 if (dedge>deadWidth) length++;
169 }
170 if (ref->DetectorId()!= AliTrackReference::kTPC) break;
171 ref0 = ref;
172 }
173 return length;
174}