1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // Realisation of AliVParticle for MC Particles
20 // Implementation wraps a TParticle and delegates the methods
21 // Author: Andreas Morsch, CERN
22 //-------------------------------------------------------------------------
24 #include <TObjArray.h>
26 #include "AliMCParticle.h"
27 #include "AliExternalTrackParam.h"
30 ClassImp(AliMCParticle)
32 AliMCParticle::AliMCParticle():
46 AliMCParticle::AliMCParticle(TParticle* part, TObjArray* rarray, Int_t index):
49 fTrackReferences(rarray),
58 fNTrackRef = fTrackReferences->GetEntriesFast();
63 AliMCParticle::AliMCParticle(const AliMCParticle& mcPart) :
76 AliMCParticle& AliMCParticle::operator=(const AliMCParticle& mcPart)
80 AliVParticle::operator=(mcPart);
86 AliMCParticle::~AliMCParticle()
88 // delete the track references passed externally
89 // fParticle should be handled by the user
90 // AliStack in case of AliMCEventHandler
92 fTrackReferences->Clear();
93 delete fTrackReferences;
100 Float_t AliMCParticle::GetTPCTrackLength(Float_t bz, Float_t ptmin, Int_t &counter, Float_t deadWidth, Float_t zMax){
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 // 25/04/2013 --> zMax as a parameter with default value 230 cm to take into account L1 shift introduced in AliTPC.cxx
108 // bz - magnetic field
109 // deadWidth - dead zone in r-phi
110 // Additional output:
111 // counter - number of circles
113 if (fNTrackRef == 0) return 0.;
115 const Float_t kRMin = 90;
116 const Float_t kRMax = 245;
117 // const Float_t kZMax = 250;
118 const Float_t kMinPt= ptmin;
121 Int_t nrefs = fNTrackRef;
124 AliExternalTrackParam param;
126 for (Int_t i = 0; i < 21; i++) cv[i]=0;
131 AliTrackReference *ref0 = (AliTrackReference*) (fTrackReferences->At(0));
132 Float_t direction = 0;
134 for (Int_t iref = 1; iref < nrefs; iref++){
135 AliTrackReference *ref = (AliTrackReference*) (fTrackReferences->At(iref));
137 if (!ref0 || ref0->DetectorId()!= AliTrackReference::kTPC){
139 direction = ((ref0->X() * ref0->Px() + ref0->Y() * ref0->Py()) > 0)? 1. : -1.;
143 Float_t newdirection = ((ref->X() * ref->Px() + ref->Y() * ref->Py()) > 0)? 1. : -1.;
144 if (newdirection*direction<0) {
145 counter++; //circle counter
146 direction = newdirection;
149 if (counter>0) continue;
150 if (ref0->Pt() < kMinPt) break;
151 Float_t radius0 = TMath::Max(TMath::Min(ref0->R(),kRMax),kRMin);;
152 Float_t radius1 = TMath::Max(TMath::Min(ref->R(),kRMax),kRMin);
153 Double_t xyz[3] = {ref0->X(), ref0->Y(), ref0->Z()};
154 Double_t pxyz[3]= {ref0->Px(), ref0->Py(), ref0->Pz()};
156 param.Set(xyz,pxyz,cv,TMath::Nint(fParticle->GetPDG()->Charge()/3.));
158 for (Float_t radius = radius0; radius < radius1; radius+=1){
159 param.GetXYZAt(radius, bz, xyz);
160 // if (TMath::Abs(xyz[2]) > kZMax) continue;
161 if (TMath::Abs(xyz[2]) > zMax) continue;
162 Float_t gradius = TMath::Sqrt(xyz[1] * xyz[1] + xyz[0] * xyz[0]);
163 if (gradius > kRMax) continue;
164 alpha = TMath::ATan2(xyz[1],xyz[0]);
165 if (alpha<0) alpha += TMath::TwoPi();
167 Int_t sector = Int_t(9 * alpha / TMath::Pi());
168 Float_t lalpha = alpha - ((sector + 0.5) * TMath::Pi() / 9.);
169 Float_t dedge = (TMath::Tan(TMath::Pi() / 18.) - TMath::Abs(TMath::Tan(lalpha))) * gradius;
170 if (dedge>deadWidth) length++;
172 if (ref->DetectorId()!= AliTrackReference::kTPC) break;