]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSRecParticle.cxx
Added reference from vertex to candidate (Andrea)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRecParticle.cxx
CommitLineData
6ad0bfa0 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
b2a60966 15/* $Id$ */
6ad0bfa0 16//_________________________________________________________________________
b2a60966 17// A Reconstructed Particle in PHOS
2f04ed65 18// To become a general class of AliRoot ?
19// Why should I put meaningless comments
20// just to satisfy
21// the code checker
b2a60966 22//
23//*-- Author: Yves Schutz (SUBATECH)
24
6ad0bfa0 25
26// --- ROOT system ---
27
28// --- Standard library ---
29
ed4205d8 30
6ad0bfa0 31// --- AliRoot header files ---
6ad0bfa0 32#include "AliPHOSRecParticle.h"
8f3968d8 33#include "AliPHOSGetter.h"
c81ced2d 34#include "AliPHOSGeometry.h"
1212b8da 35#include "AliLog.h"
6ad0bfa0 36
0272607d 37//____________________________________________________________________________
43fbaae1 38AliPHOSRecParticle::AliPHOSRecParticle():
39 fPHOSTrackSegment(0),
40 fDebug(kFALSE),
41 fPos()
0272607d 42{
43 // ctor
304864ab 44 const Int_t nSPECIES = AliPID::kSPECIESN;
88340ded 45 for(Int_t i = 0; i<nSPECIES ; i++)
0272607d 46 fPID[i]=0.;
47}
6ad0bfa0 48
49
a73f33f0 50//____________________________________________________________________________
43fbaae1 51AliPHOSRecParticle::AliPHOSRecParticle(const AliPHOSRecParticle & rp):
52 AliPHOSFastRecParticle(rp),
53 fPHOSTrackSegment(rp.fPHOSTrackSegment),
54 fDebug(kFALSE),
55 fPos()
a73f33f0 56{
b2a60966 57 // copy ctor
a73f33f0 58 fType = rp.fType ;
83974468 59 fIndexInList = rp.fIndexInList ;
b2a60966 60
cafda784 61 fPdgCode = rp.fPdgCode;
62 fStatusCode = rp.fStatusCode;
63 fMother[0] = rp.fMother[0];
64 fMother[1] = rp.fMother[1];
65 fDaughter[0] = rp.fDaughter[0];
66 fDaughter[1] = rp.fDaughter[1];
67 fWeight = rp.fWeight;
68 fCalcMass = rp.fCalcMass;
69 fPx = rp.fPx;
70 fPy = rp.fPy;
71 fPz = rp.fPz;
72 fE = rp.fE;
73 fVx = rp.fVx;
74 fVy = rp.fVy;
75 fVz = rp.fVz;
76 fVt = rp.fVt;
77 fPolarTheta = rp.fPolarTheta;
78 fPolarPhi = rp.fPolarPhi;
79 fParticlePDG = rp.fParticlePDG;
304864ab 80 const Int_t nSPECIES = AliPID::kSPECIESN;
88340ded 81 for(Int_t i = 0; i<nSPECIES ; i++)
0272607d 82 fPID[i]=rp.fPID[i];
b2a60966 83}
83974468 84
8f3968d8 85//____________________________________________________________________________
17323043 86Int_t AliPHOSRecParticle::GetNPrimaries() const
88cb7938 87{
88 return -1;
a278df55 89}
90
91//____________________________________________________________________________
17323043 92Int_t AliPHOSRecParticle::GetNPrimariesToRecParticles() const
8f3968d8 93{
e957fea8 94 // Get the number of primaries at the origine of the RecParticle
8f3968d8 95 Int_t rv = 0 ;
88cb7938 96 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
97 Int_t emcRPindex = dynamic_cast<AliPHOSTrackSegment*>(gime->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex();
98 dynamic_cast<AliPHOSEmcRecPoint*>(gime->EmcRecPoints()->At(emcRPindex))->GetPrimaries(rv) ;
8f3968d8 99 return rv ;
100}
83974468 101
c81ced2d 102//____________________________________________________________________________
103const TParticle * AliPHOSRecParticle::GetPrimary() const
104{
105 // Get the primary particle at the origine of the RecParticle and
106 // which has deposited the largest energy in SDigits
107 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
108 if (!gime)
109 Error("GetPrimary", "Getter not yet instantiated") ;
110 gime->Event(gime->EventNumber(), "SRTPX") ;
111 if(GetNPrimaries() == 0)
112 return 0 ;
113 if(GetNPrimaries() == 1)
114 return GetPrimary(0) ;
115 Int_t AbsId = 0;
116 Int_t module ;
6c8cd883 117
118 // Get PHOS Geometry object
119 AliPHOSGeometry *geom;
120 if (!(geom = AliPHOSGeometry::GetInstance()))
121 geom = AliPHOSGeometry::GetInstance("IHEP","");
122 Double_t x,z ;
5a9ecaeb 123//DP to be fixed: Why do we use this method here??? M.B. use RecPoint???
124 Double_t vtx[3]={0.,0.,0.} ;
125 geom->ImpactOnEmc(vtx,static_cast<double>(Theta()),static_cast<double>(Phi()), module,z,x);
c81ced2d 126 Int_t amp = 0 ;
127 Int_t iPrim=-1 ;
128 if(module != 0){
129 geom->RelPosToAbsId(module,x,z,AbsId) ;
130 TClonesArray * sdigits = gime->SDigits() ;
131 AliPHOSDigit * sdig ;
132
133 for(Int_t i = 0 ; i < sdigits->GetEntriesFast() ; i++){
134 sdig = static_cast<AliPHOSDigit *>(sdigits->At(i)) ;
135 if((sdig->GetId() == AbsId)){
136 if((sdig->GetAmp() > amp) && (sdig->GetNprimary())){
137 amp = sdig->GetAmp() ;
138 iPrim = sdig->GetPrimary(1) ;
139 }
140 // do not scan rest of list
141 if(sdig->GetId() > AbsId)
142 continue ;
143 }
144 }
145 }
146 if(iPrim >= 0)
147 return gime->Primary(iPrim) ;
148 else
149 return 0 ;
150}
151
09286392 152//____________________________________________________________________________
eb0b1051 153Int_t AliPHOSRecParticle::GetPrimaryIndex() const
09286392 154{
155 // Get the primary track index in TreeK which deposits the most energy
156 // in Digits which forms EmcRecPoint, which produces TrackSegment,
157 // which the RecParticle is created from
158
1212b8da 159
09286392 160 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
161 if (!gime)
1212b8da 162 AliError(Form("Getter not yet instantiated")) ;
eb0b1051 163 //PH gime->Event(gime->EventNumber(), "DRTX") ;
84294dcd 164 gime->Event(gime->EventNumber(), "DRT") ;
1212b8da 165
09286392 166 // Get TrackSegment corresponding to this RecParticle
167 AliPHOSTrackSegment *ts = gime->TrackSegment(fPHOSTrackSegment);
168
169 // Get EmcRecPoint corresponding to this TrackSegment
170 Int_t emcRecPointIndex = ts->GetEmcIndex();
1212b8da 171
09286392 172 AliPHOSEmcRecPoint *emcRecPoint = gime->EmcRecPoint(emcRecPointIndex);
173
174 // Get the list of digits forming this EmcRecParticle
175 Int_t nDigits = emcRecPoint->GetDigitsMultiplicity();
176 Int_t *digitList = emcRecPoint->GetDigitsList();
e4ca05c3 177
09286392 178 // Find the digit with maximum amplitude
179 AliPHOSDigit *digit = 0;
180 Int_t maxAmp = 0;
181 Int_t bestDigitIndex = -1;
182 for (Int_t iDigit=0; iDigit<nDigits; iDigit++) {
1212b8da 183 digit = gime->Digit(digitList[iDigit]);
09286392 184 if (digit->GetAmp() > maxAmp) {
185 maxAmp = digit->GetAmp();
186 bestDigitIndex = iDigit;
187 }
188 }
ff309466 189 if (bestDigitIndex>-1)
190 digit = gime->Digit(digitList[bestDigitIndex]);
31804400 191 if (digit==0) return -12345;
192
c48a7283 193
09286392 194 // Get the list of primary tracks producing this digit
195 // and find which track has more track energy.
c48a7283 196 //Int_t nPrimary = digit->GetNprimary();
197 //TParticle *track = 0;
198 //Double_t energyEM = 0;
199 //Double_t energyHadron = 0;
200 //Int_t trackEM = -1;
201 //Int_t trackHadron = -1;
202 //for (Int_t iPrim=0; iPrim<nPrimary; iPrim++) {
203 // Int_t iPrimary = digit->GetPrimary(iPrim+1);
204 // if (iPrimary == -1 || TMath::Abs(iPrimary)>10000000)
205 // continue ; //PH 10000000 is the shift of the track
206 // //PH indexes in the underlying event
207 // track = gime->Primary(iPrimary);
208 // Int_t pdgCode = track->GetPdgCode();
209 // Double_t energy = track->Energy();
210 // if (pdgCode==22 || TMath::Abs(pdgCode)==11) {
211 // if (energy > energyEM) {
212 // energyEM = energy;
213 // trackEM = iPrimary;
214 // }
215 // }
216 // else {
217 // if (energy > energyHadron) {
218 // energyHadron = energy;
219 // trackHadron = iPrimary;
220 // }
221 // }
222 //}
223 // Preferences are given to electromagnetic tracks
224 //if (trackEM != -1) return trackEM; // track is gamma or e+-
225 //if (trackHadron != -1) return trackHadron; // track is hadron
226 //return -12345; // no track found :(
227
228
229 // Get the list of hits producing this digit,
230 // find which hit has deposited more energy
231 // and find the primary track.
232
233 AliPHOSHit *hit = 0;
234 TClonesArray *hits = gime->Hits();
25ed816e 235 if (hits==0) return -12345;
236
c48a7283 237 Double_t maxedep = 0;
238 Int_t maxtrack = -1;
239 Int_t nHits = hits ->GetEntries();
240 Int_t id = digit->GetId();
241
242 for (Int_t iHit=0; iHit<nHits; iHit++) {
243 hit = gime->Hit(iHit);
244 if(hit->GetId() == id){
245 Double_t edep = hit->GetEnergy();
246 Int_t track = hit->GetPrimary();
247 if(edep > maxedep){
248 maxedep = edep;
249 maxtrack = track;
09286392 250 }
251 }
252 }
c48a7283 253
254 if (maxtrack != -1) return maxtrack; // track is hadron
255 return -12345; // no track found :(
09286392 256}
257
8f3968d8 258//____________________________________________________________________________
259const TParticle * AliPHOSRecParticle::GetPrimary(Int_t index) const
260{
c81ced2d 261 // Get one of the primary particles at the origine of the RecParticle
a278df55 262 if ( index > GetNPrimariesToRecParticles() ) {
51d189f4 263 if (fDebug)
88cb7938 264 Warning("GetPrimary", "AliPHOSRecParticle::GetPrimary -> %d is larger that the number of primaries %d",
265 index, GetNPrimaries()) ;
266 return 0 ;
51d189f4 267 }
88cb7938 268 else {
269 Int_t dummy ;
270 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
271
272 Int_t emcRPindex = dynamic_cast<AliPHOSTrackSegment*>(gime->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex();
273 Int_t primaryindex = dynamic_cast<AliPHOSEmcRecPoint*>(gime->EmcRecPoints()->At(emcRPindex))->GetPrimaries(dummy)[index] ;
274 return gime->Primary(primaryindex) ;
275 }
fc7e2f43 276 // return 0 ;
8f3968d8 277}
948a4b24 278
06e774ed 279//____________________________________________________________________________
85c60a8e 280void AliPHOSRecParticle::SetPID(Int_t type, Float_t weight)
06e774ed 281{
cc1fe362 282 // Set the probability densities that this reconstructed particle
06e774ed 283 // has a type of i:
284 // i particle types
285 // ----------------------
286 // 0 electron
287 // 1 muon
288 // 2 pi+-
289 // 3 K+-
290 // 4 p/pbar
291 // 5 photon
292 // 6 pi0 at high pt
293 // 7 neutron
294 // 8 K0L
cc1fe362 295 // 9 Conversion electron
296
297 fPID[type] = weight ;
06e774ed 298}