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