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