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(): fPHOSTrackSegment(0) , fDebug( kFALSE )
41 const Int_t nSPECIES = AliPID::kSPECIESN;
42 for(Int_t i = 0; i<nSPECIES ; i++)
47 //____________________________________________________________________________
48 AliPHOSRecParticle::AliPHOSRecParticle(const AliPHOSRecParticle & rp)
49 : AliPHOSFastRecParticle(rp)
53 fPHOSTrackSegment = rp.fPHOSTrackSegment ;
56 fIndexInList = rp.fIndexInList ;
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];
65 fCalcMass = rp.fCalcMass;
74 fPolarTheta = rp.fPolarTheta;
75 fPolarPhi = rp.fPolarPhi;
76 fParticlePDG = rp.fParticlePDG;
77 const Int_t nSPECIES = AliPID::kSPECIESN;
78 for(Int_t i = 0; i<nSPECIES ; i++)
82 //____________________________________________________________________________
83 Int_t AliPHOSRecParticle::GetNPrimaries() const
88 //____________________________________________________________________________
89 Int_t AliPHOSRecParticle::GetNPrimariesToRecParticles() const
91 // Get the number of primaries at the origine of the RecParticle
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) ;
99 //____________________________________________________________________________
100 const TParticle * AliPHOSRecParticle::GetPrimary() const
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() ;
106 Error("GetPrimary", "Getter not yet instantiated") ;
107 gime->Event(gime->EventNumber(), "SRTPX") ;
108 if(GetNPrimaries() == 0)
110 if(GetNPrimaries() == 1)
111 return GetPrimary(0) ;
114 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
116 geom->ImpactOnEmc(static_cast<double>(Theta()),static_cast<double>(Phi()), module,z,x);
120 geom->RelPosToAbsId(module,x,z,AbsId) ;
121 TClonesArray * sdigits = gime->SDigits() ;
122 AliPHOSDigit * sdig ;
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) ;
131 // do not scan rest of list
132 if(sdig->GetId() > AbsId)
138 return gime->Primary(iPrim) ;
143 //____________________________________________________________________________
144 Int_t AliPHOSRecParticle::GetPrimaryIndex() const
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
151 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
153 AliError(Form("Getter not yet instantiated")) ;
154 //PH gime->Event(gime->EventNumber(), "DRTX") ;
155 gime->Event(gime->EventNumber(), "DRT") ;
157 // Get TrackSegment corresponding to this RecParticle
158 AliPHOSTrackSegment *ts = gime->TrackSegment(fPHOSTrackSegment);
160 // Get EmcRecPoint corresponding to this TrackSegment
161 Int_t emcRecPointIndex = ts->GetEmcIndex();
163 AliPHOSEmcRecPoint *emcRecPoint = gime->EmcRecPoint(emcRecPointIndex);
165 // Get the list of digits forming this EmcRecParticle
166 Int_t nDigits = emcRecPoint->GetDigitsMultiplicity();
167 Int_t *digitList = emcRecPoint->GetDigitsList();
169 // Find the digit with maximum amplitude
170 AliPHOSDigit *digit = 0;
172 Int_t bestDigitIndex = -1;
173 for (Int_t iDigit=0; iDigit<nDigits; iDigit++) {
174 digit = gime->Digit(digitList[iDigit]);
175 if (digit->GetAmp() > maxAmp) {
176 maxAmp = digit->GetAmp();
177 bestDigitIndex = iDigit;
180 digit = gime->Digit(digitList[bestDigitIndex]);
181 if (digit==0) return -12345;
184 // Get the list of primary tracks producing this digit
185 // and find which track has more track energy.
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;
207 // if (energy > energyHadron) {
208 // energyHadron = energy;
209 // trackHadron = iPrimary;
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 :(
219 // Get the list of hits producing this digit,
220 // find which hit has deposited more energy
221 // and find the primary track.
224 TClonesArray *hits = gime->Hits();
225 if (hits==0) return -12345;
227 Double_t maxedep = 0;
229 Int_t nHits = hits ->GetEntries();
230 Int_t id = digit->GetId();
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();
244 if (maxtrack != -1) return maxtrack; // track is hadron
245 return -12345; // no track found :(
248 //____________________________________________________________________________
249 const TParticle * AliPHOSRecParticle::GetPrimary(Int_t index) const
251 // Get one of the primary particles at the origine of the RecParticle
252 if ( index > GetNPrimariesToRecParticles() ) {
254 Warning("GetPrimary", "AliPHOSRecParticle::GetPrimary -> %d is larger that the number of primaries %d",
255 index, GetNPrimaries()) ;
260 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
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) ;
269 //____________________________________________________________________________
270 void AliPHOSRecParticle::SetPID(Int_t type, Float_t weight)
272 // Set the probability densities that this reconstructed particle
275 // ----------------------
285 // 9 Conversion electron
287 fPID[type] = weight ;