1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
16 //_________________________________________________________________________
17 // A Reconstructed Particle in PHOS
18 // To become a general class of AliRoot ?
19 // Why should I put meaningless comments
23 //*-- Author: Yves Schutz (SUBATECH)
26 // --- ROOT system ---
28 // --- Standard library ---
31 // --- AliRoot header files ---
32 #include "AliPHOSRecParticle.h"
33 #include "AliPHOSGetter.h"
34 #include "AliPHOSGeometry.h"
37 //____________________________________________________________________________
38 AliPHOSRecParticle::AliPHOSRecParticle():
44 const Int_t nSPECIES = AliPID::kSPECIESN;
45 for(Int_t i = 0; i<nSPECIES ; i++)
50 //____________________________________________________________________________
51 AliPHOSRecParticle::AliPHOSRecParticle(const AliPHOSRecParticle & rp):
52 AliPHOSFastRecParticle(rp),
53 fPHOSTrackSegment(rp.fPHOSTrackSegment),
59 fIndexInList = rp.fIndexInList ;
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];
68 fCalcMass = rp.fCalcMass;
77 fPolarTheta = rp.fPolarTheta;
78 fPolarPhi = rp.fPolarPhi;
79 fParticlePDG = rp.fParticlePDG;
80 const Int_t nSPECIES = AliPID::kSPECIESN;
81 for(Int_t i = 0; i<nSPECIES ; i++)
85 //____________________________________________________________________________
86 Int_t AliPHOSRecParticle::GetNPrimaries() const
91 //____________________________________________________________________________
92 Int_t AliPHOSRecParticle::GetNPrimariesToRecParticles() const
94 // Get the number of primaries at the origine of the RecParticle
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) ;
102 //____________________________________________________________________________
103 const TParticle * AliPHOSRecParticle::GetPrimary() const
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() ;
109 Error("GetPrimary", "Getter not yet instantiated") ;
110 gime->Event(gime->EventNumber(), "SRTPX") ;
111 if(GetNPrimaries() == 0)
113 if(GetNPrimaries() == 1)
114 return GetPrimary(0) ;
118 // Get PHOS Geometry object
119 AliPHOSGeometry *geom;
120 if (!(geom = AliPHOSGeometry::GetInstance()))
121 geom = AliPHOSGeometry::GetInstance("IHEP","");
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);
129 geom->RelPosToAbsId(module,x,z,AbsId) ;
130 TClonesArray * sdigits = gime->SDigits() ;
131 AliPHOSDigit * sdig ;
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) ;
140 // do not scan rest of list
141 if(sdig->GetId() > AbsId)
147 return gime->Primary(iPrim) ;
152 //____________________________________________________________________________
153 Int_t AliPHOSRecParticle::GetPrimaryIndex() const
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
160 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
162 AliError(Form("Getter not yet instantiated")) ;
163 //PH gime->Event(gime->EventNumber(), "DRTX") ;
164 gime->Event(gime->EventNumber(), "DRT") ;
166 // Get TrackSegment corresponding to this RecParticle
167 AliPHOSTrackSegment *ts = gime->TrackSegment(fPHOSTrackSegment);
169 // Get EmcRecPoint corresponding to this TrackSegment
170 Int_t emcRecPointIndex = ts->GetEmcIndex();
172 AliPHOSEmcRecPoint *emcRecPoint = gime->EmcRecPoint(emcRecPointIndex);
174 // Get the list of digits forming this EmcRecParticle
175 Int_t nDigits = emcRecPoint->GetDigitsMultiplicity();
176 Int_t *digitList = emcRecPoint->GetDigitsList();
178 // Find the digit with maximum amplitude
179 AliPHOSDigit *digit = 0;
181 Int_t bestDigitIndex = -1;
182 for (Int_t iDigit=0; iDigit<nDigits; iDigit++) {
183 digit = gime->Digit(digitList[iDigit]);
184 if (digit->GetAmp() > maxAmp) {
185 maxAmp = digit->GetAmp();
186 bestDigitIndex = iDigit;
189 if (bestDigitIndex>-1)
190 digit = gime->Digit(digitList[bestDigitIndex]);
191 if (digit==0) return -12345;
194 // Get the list of primary tracks producing this digit
195 // and find which track has more track energy.
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;
217 // if (energy > energyHadron) {
218 // energyHadron = energy;
219 // trackHadron = iPrimary;
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 :(
229 // Get the list of hits producing this digit,
230 // find which hit has deposited more energy
231 // and find the primary track.
234 TClonesArray *hits = gime->Hits();
235 if (hits==0) return -12345;
237 Double_t maxedep = 0;
239 Int_t nHits = hits ->GetEntries();
240 Int_t id = digit->GetId();
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();
254 if (maxtrack != -1) return maxtrack; // track is hadron
255 return -12345; // no track found :(
258 //____________________________________________________________________________
259 const TParticle * AliPHOSRecParticle::GetPrimary(Int_t index) const
261 // Get one of the primary particles at the origine of the RecParticle
262 if ( index > GetNPrimariesToRecParticles() ) {
264 Warning("GetPrimary", "AliPHOSRecParticle::GetPrimary -> %d is larger that the number of primaries %d",
265 index, GetNPrimaries()) ;
270 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
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) ;
279 //____________________________________________________________________________
280 void AliPHOSRecParticle::SetPID(Int_t type, Float_t weight)
282 // Set the probability densities that this reconstructed particle
285 // ----------------------
295 // 9 Conversion electron
297 fPID[type] = weight ;