Update monitoring executable in order to make it compatible with the tracking in...
[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"
6ad0bfa0 35
0272607d 36//____________________________________________________________________________
37 AliPHOSRecParticle::AliPHOSRecParticle(): fPHOSTrackSegment(0) , fDebug( kFALSE )
38{
39 // ctor
304864ab 40 const Int_t nSPECIES = AliPID::kSPECIESN;
88340ded 41 for(Int_t i = 0; i<nSPECIES ; i++)
0272607d 42 fPID[i]=0.;
43}
6ad0bfa0 44
45
46//____________________________________________________________________________
a73f33f0 47 AliPHOSRecParticle::AliPHOSRecParticle(const AliPHOSRecParticle & rp)
a8c47ab6 48 : AliPHOSFastRecParticle(rp)
a73f33f0 49{
b2a60966 50 // copy ctor
51
83974468 52 fPHOSTrackSegment = rp.fPHOSTrackSegment ;
51d189f4 53 fDebug = kFALSE ;
a73f33f0 54 fType = rp.fType ;
83974468 55 fIndexInList = rp.fIndexInList ;
b2a60966 56
cafda784 57 fPdgCode = rp.fPdgCode;
58 fStatusCode = rp.fStatusCode;
59 fMother[0] = rp.fMother[0];
60 fMother[1] = rp.fMother[1];
61 fDaughter[0] = rp.fDaughter[0];
62 fDaughter[1] = rp.fDaughter[1];
63 fWeight = rp.fWeight;
64 fCalcMass = rp.fCalcMass;
65 fPx = rp.fPx;
66 fPy = rp.fPy;
67 fPz = rp.fPz;
68 fE = rp.fE;
69 fVx = rp.fVx;
70 fVy = rp.fVy;
71 fVz = rp.fVz;
72 fVt = rp.fVt;
73 fPolarTheta = rp.fPolarTheta;
74 fPolarPhi = rp.fPolarPhi;
75 fParticlePDG = rp.fParticlePDG;
304864ab 76 const Int_t nSPECIES = AliPID::kSPECIESN;
88340ded 77 for(Int_t i = 0; i<nSPECIES ; i++)
0272607d 78 fPID[i]=rp.fPID[i];
b2a60966 79}
83974468 80
8f3968d8 81//____________________________________________________________________________
17323043 82Int_t AliPHOSRecParticle::GetNPrimaries() const
88cb7938 83{
84 return -1;
a278df55 85}
86
87//____________________________________________________________________________
17323043 88Int_t AliPHOSRecParticle::GetNPrimariesToRecParticles() const
8f3968d8 89{
e957fea8 90 // Get the number of primaries at the origine of the RecParticle
8f3968d8 91 Int_t rv = 0 ;
88cb7938 92 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
93 Int_t emcRPindex = dynamic_cast<AliPHOSTrackSegment*>(gime->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex();
94 dynamic_cast<AliPHOSEmcRecPoint*>(gime->EmcRecPoints()->At(emcRPindex))->GetPrimaries(rv) ;
8f3968d8 95 return rv ;
96}
83974468 97
8f3968d8 98//____________________________________________________________________________
c81ced2d 99const TParticle * AliPHOSRecParticle::GetPrimary() const
100{
101 // Get the primary particle at the origine of the RecParticle and
102 // which has deposited the largest energy in SDigits
103 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
104 if (!gime)
105 Error("GetPrimary", "Getter not yet instantiated") ;
106 gime->Event(gime->EventNumber(), "SRTPX") ;
107 if(GetNPrimaries() == 0)
108 return 0 ;
109 if(GetNPrimaries() == 1)
110 return GetPrimary(0) ;
111 Int_t AbsId = 0;
112 Int_t module ;
113 const AliPHOSGeometry * geom = gime->PHOSGeometry() ;
114 Double_t x,z ;
115 geom->ImpactOnEmc(static_cast<double>(Theta()),static_cast<double>(Phi()), module,z,x);
116 Int_t amp = 0 ;
117 Int_t iPrim=-1 ;
118 if(module != 0){
119 geom->RelPosToAbsId(module,x,z,AbsId) ;
120 TClonesArray * sdigits = gime->SDigits() ;
121 AliPHOSDigit * sdig ;
122
123 for(Int_t i = 0 ; i < sdigits->GetEntriesFast() ; i++){
124 sdig = static_cast<AliPHOSDigit *>(sdigits->At(i)) ;
125 if((sdig->GetId() == AbsId)){
126 if((sdig->GetAmp() > amp) && (sdig->GetNprimary())){
127 amp = sdig->GetAmp() ;
128 iPrim = sdig->GetPrimary(1) ;
129 }
130 // do not scan rest of list
131 if(sdig->GetId() > AbsId)
132 continue ;
133 }
134 }
135 }
136 if(iPrim >= 0)
137 return gime->Primary(iPrim) ;
138 else
139 return 0 ;
140}
141
142//____________________________________________________________________________
8f3968d8 143const TParticle * AliPHOSRecParticle::GetPrimary(Int_t index) const
144{
c81ced2d 145 // Get one of the primary particles at the origine of the RecParticle
a278df55 146 if ( index > GetNPrimariesToRecParticles() ) {
51d189f4 147 if (fDebug)
88cb7938 148 Warning("GetPrimary", "AliPHOSRecParticle::GetPrimary -> %d is larger that the number of primaries %d",
149 index, GetNPrimaries()) ;
150 return 0 ;
51d189f4 151 }
88cb7938 152 else {
153 Int_t dummy ;
154 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
155
156 Int_t emcRPindex = dynamic_cast<AliPHOSTrackSegment*>(gime->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex();
157 Int_t primaryindex = dynamic_cast<AliPHOSEmcRecPoint*>(gime->EmcRecPoints()->At(emcRPindex))->GetPrimaries(dummy)[index] ;
158 return gime->Primary(primaryindex) ;
159 }
fc7e2f43 160 // return 0 ;
8f3968d8 161}
948a4b24 162
06e774ed 163//____________________________________________________________________________
cc1fe362 164void AliPHOSRecParticle::SetPID(Int_t type, Double_t weight)
06e774ed 165{
cc1fe362 166 // Set the probability densities that this reconstructed particle
06e774ed 167 // has a type of i:
168 // i particle types
169 // ----------------------
170 // 0 electron
171 // 1 muon
172 // 2 pi+-
173 // 3 K+-
174 // 4 p/pbar
175 // 5 photon
176 // 6 pi0 at high pt
177 // 7 neutron
178 // 8 K0L
cc1fe362 179 // 9 Conversion electron
180
181 fPID[type] = weight ;
06e774ed 182}