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