update to master versions
[u/mrichter/AliRoot.git] / PWGCF / Correlations / JCORRAN / AliJPhoton.cxx
CommitLineData
66be7134 1/**************************************************************************
2 * Copyright(c) 1998-2014, 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 **************************************************************************/
15
16// Comment describing what this class does needed!
17
37dde34e 18// $Id: AliJPhoton.cxx,v 1.4 2008/05/08 13:44:45 djkim Exp $
19
20////////////////////////////////////////////////////
21/*!
22 \file AliJPhoton.cxx
23 \brief
24 \author J. Rak, D.J.Kim, R.Diaz (University of Jyvaskyla)
25 \email: djkim@jyu.fi
26 \version $Revision: 1.4 $
27 \date $Date: 2008/05/08 13:44:45 $
28 */
29////////////////////////////////////////////////////
30
31#include "AliJBaseTrack.h"
32#include "AliJPhoton.h"
66be7134 33#include <TF1.h>
37dde34e 34
35ClassImp(AliJPhoton);
36//______________________________________________________________________________
37AliJPhoton::AliJPhoton() :
38 AliJBaseTrack(),
39 fChi2(-999),
40 fTof(-999),
41 fX(-999),
42 fY(-999),
43 fZ(-999),
44 fProbPhot(-999),
45 fTrackDx(-1),
46 fTrackDz(-1),
47 fCaloType(kUndef),
48 fDistToBadChannel(-999),
49 fDispersion(-999),
50 fM20(-999),
51 fM02(-999),
52 fEmcCpvDist(-999),
66be7134 53 fNCells(-999),
54 fNTracksMatched(-999),
37dde34e 55 fSuperModuleId(-999),
56 fCellsAbsId(0x0),
66be7134 57 fCellsAmpFraction(0x0),
58 fNEMCLabel(0),
59 fEMCLabel(0x0),
60 fEMax(-999),
61 fECross(-999),
62 fECore(-999),
63 fNLM(-999),
64 fCellsIndex(0x0)
65// fCellsAmp(0x0)
37dde34e 66
67{
68 // default constructor
69 for(Int_t i=0;i<kUnknownAli+1;i++) fCaloPID[i]=-1;
70
71 SetPID((Double_t*)NULL);
72}
73
74//_____________________________________________________________________________
75AliJPhoton::AliJPhoton(const AliJPhoton& a) :
76 AliJBaseTrack(a),
77 fChi2(a.fChi2),
78 fTof(a.fTof),
79 fX(a.fX),
80 fY(a.fY),
81 fZ(a.fZ),
82 fProbPhot(a.fProbPhot),
83 fTrackDx(a.fTrackDx),
84 fTrackDz(a.fTrackDz),
85 fCaloType(a.fCaloType),
86 fDistToBadChannel(a.fDistToBadChannel),
87 fDispersion(a.fDispersion),
88 fM20(a.fM20),
89 fM02(a.fM02),
90 fEmcCpvDist(a.fEmcCpvDist),
91 fNCells(a.fNCells),
66be7134 92 fNTracksMatched(a.fNTracksMatched),
37dde34e 93 fSuperModuleId(a.fSuperModuleId),
94 fCellsAbsId(NULL),
66be7134 95 fCellsAmpFraction(NULL),
96 fNEMCLabel(a.fNEMCLabel),
97 fEMCLabel(NULL),
98 fEMax(a.fEMax),
99 fECross(a.fECross),
100 fECore(a.fECore),
101 fNLM(a.fNLM),
102 fCellsIndex(NULL)
103// fCellsAmp(NULL)
37dde34e 104
105{
106 //copy constructor
107 for(Int_t i=0;i<kUnknownAli+1;i++) fCaloPID[i] = a.fCaloPID[i];
108 SetCellsAbsId( a.fCellsAbsId );
109 SetCellsAmplitudeFraction( a.fCellsAmpFraction );
66be7134 110 SetCellsIndex( a.fCellsIndex );
111 SetEMCLabel( a.fEMCLabel );
112// SetCellsAmplitude( a.fCellsAmp );
113}
114
115
116//_____________________________________________________________________________
117AliJPhoton::~AliJPhoton(){
118 // destructor
119 Clear("");
120}
121
122//_____________________________________________________________________________
123void AliJPhoton::Clear( Option_t * /* option */ ){
124 // cleaner
125 if(fCellsAbsId) delete [] fCellsAbsId;
126 if(fCellsAmpFraction) delete [] fCellsAmpFraction;
127 if( fEMCLabel ) delete [] fEMCLabel;
128 if( fCellsIndex ) delete [] fCellsIndex;
129 fCellsAbsId = 0;
130 fCellsAmpFraction = 0;
131 fEMCLabel = 0;
132 fCellsIndex = 0;
133// if(fCellsAmp) delete [] fCellsAmp;
37dde34e 134}
135
136//_____________________________________________________________________________
137AliJPhoton& AliJPhoton::operator=(const AliJPhoton& photon){
138 //operator=
139 if(this != &photon){
140 AliJBaseTrack::operator=(photon);
141 fChi2 = photon.fChi2;
142 fTof = photon.fTof;
143 fX = photon.fX;
144 fY = photon.fY;
145 fZ = photon.fZ;
146 fProbPhot = photon.fProbPhot;
147 fTrackDx = photon.fTrackDx;
148 fTrackDz = photon.fTrackDz;
89e21aee 149 fCaloType = photon.fCaloType;
37dde34e 150 for(Int_t i=0; i<kUnknownAli+1; i++){
151 fCaloPID[i] = photon.fCaloPID[i];
152 }
153 fDistToBadChannel = photon.fDistToBadChannel;
154 fDispersion = photon.fDispersion;
155 fM20 = photon.fM20;
156 fM02 = photon.fM02;
157 fEmcCpvDist = photon.fEmcCpvDist;
158 fNCells = photon.fNCells;
66be7134 159 fNTracksMatched = photon.fNTracksMatched;
37dde34e 160 fSuperModuleId = photon.fSuperModuleId;
89e21aee 161 SetCellsAbsId( photon.fCellsAbsId );
162 SetCellsAmplitudeFraction( photon.fCellsAmpFraction );
66be7134 163 SetEMCLabel( photon.fEMCLabel );
164// SetCellsAmplitude( photon.fCellsAmp );
165 fEMax = photon.fEMax;
166 fECross = photon.fECross;
167 fECore = photon.fECore;
168 fNLM = photon.fNLM;
169 SetCellsIndex( photon.fCellsIndex );
37dde34e 170
171 }
172
173 return *this;
174}
175//______________________________________________________________________________
176void AliJPhoton::SetCellsAbsId(const UShort_t *array)
177{
178 // Set the array of cell absId numbers
179 if (fNCells) {
180 if(fCellsAbsId){ delete [] fCellsAbsId; fCellsAbsId = NULL; }
66be7134 181 fCellsAbsId = new UShort_t[fNCells];
182 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
37dde34e 183 }
184}
185
186//_______________________________________________________________________
187void AliJPhoton::SetCellsAmplitudeFraction(const Double32_t *array)
188{
189 // Set the array of cell amplitude fraction
190 if (fNCells) {
66be7134 191 if(fCellsAmpFraction){ delete [] fCellsAmpFraction; fCellsAmpFraction = NULL;}
192 fCellsAmpFraction = new Double32_t[fNCells];
193 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];
194 }
195}
196
197//______________________________________________________________________________
198void AliJPhoton::SetEMCLabel(const Int_t *array)
199{
200 // Set the array of cell absId numbers
201 if (fNEMCLabel) {
202 if(fEMCLabel){ delete [] fEMCLabel; fEMCLabel = NULL; }
203 fEMCLabel = new Int_t[fNEMCLabel];
204 for (Int_t i = 0; i < fNEMCLabel; i++) fEMCLabel[i] = array[i];
205 }
206}
207
208//______________________________________________________________________________
209void AliJPhoton::SetCellsIndex(const Int_t *array)
210{
211 // Set the array of cell absId numbers
212 if( !array ){
213 if( fCellsIndex ){
214 delete [] fCellsIndex;
215 fCellsIndex = NULL;
216 }
217 }
218 else if (fNCells) {
219 if( fCellsIndex ){
220 delete [] fCellsIndex;
221 fCellsIndex = NULL;
37dde34e 222 }
66be7134 223
224 fCellsIndex = new Int_t[fNCells];
225 for (Int_t i = 0; i < fNCells; i++)
226 fCellsIndex[i] = array[i];
227 }
37dde34e 228}
229
230//______________________________________________________________________________
66be7134 231void AliJPhoton::SetCellIndex(const Int_t pos, const Int_t ind)
232{
233 // Set the array of cell absId numbers
234
235 Int_t i;
236 if (fNCells) {
237 if( ! fCellsIndex ){
238 fCellsIndex = new Int_t[fNCells];
239 for( i = 0; i < fNCells; i++ )
240 fCellsIndex[i] = -1;
241 }
242 }
243
244 fCellsIndex[pos] = ind;
245}
246
247//______________________________________________________________________________
248void AliJPhoton::ClearCellsIndex()
249{
250 // Clears the array of cell absId numbers
251 if(fCellsIndex){
252 delete [] fCellsIndex;
253 fCellsIndex = NULL;
254 }
255}
256
257// //_______________________________________________________________________
258// void AliJPhoton::SetCellsAmplitude(const Double32_t *array)
259// {
260// // Set the array of cell amplitude fraction
261// if (fNCells) {
262// if(fCellsAmp){ delete [] fCellsAmp; fCellsAmp = NULL;}
263// fCellsAmp = new Double_t[fNCells];
264// for (Int_t i = 0; i < fNCells; i++) fCellsAmp[i] = array[i];
265// }
266// }
267
268//______________________________________________________________________________
269void AliJPhoton::SetPID(const Double32_t *pid) {
37dde34e 270 //set pid
271 if(pid){
66be7134 272 for(Int_t i=0; i<kUnknownAli; ++i) fCaloPID[i]=pid[i];
37dde34e 273 SetProbPhot(fCaloPID[kPhotonAli]);
274 }else{
66be7134 275 for(Int_t i=0; i<kUnknownAli; fCaloPID[i++]=0.){}
37dde34e 276 fCaloPID[kUnknownAli]=1.;
277 }
278}
279
280
281//______________________________________________________________________________
66be7134 282particleType AliJPhoton::GetParticleType() {
37dde34e 283
284 // return the most problable particle type
285 // Note: following the AliCaloPID implementation
286
287 //Init default weights
288 Float_t wPhoton = 0.75 ;
289 Float_t wPi0 = 0.8 ;
290 Float_t wElectron = 0.5 ;
291 Float_t wCharged = 0.5 ;
292 Float_t wNeutral = 0.5 ;
293
294 Bool_t usePHOSweightFormula = kTRUE;
295 //Formula to set the PID weight threshold for photon or pizero
296 // ALICE-INT-2005-016 (2007)
297 TFormula* wPhotonPHOSFormula =
298 new TFormula("photonWeight","0.75*(x<40)+ 0.68*(x>=100)+(x>=40 && x<100)*(0.98+x*(6e-3)-x*x*(2e-04)+x*x*x*(1.1e-06))");
299 TFormula* wPi0PHOSFormula =
300 new TFormula("pi0Weight","0.80*(x<65)+ 0.915*(x>=100)+(x>=65 && x-x*(1.95e-3)-x*x*(4.31e-05)+x*x*x*(3.61e-07))");
301
302 if(fCaloType == kPHOSCalo && usePHOSweightFormula){
303 wPhoton = wPhotonPHOSFormula->Eval(E()) ;
304 wPi0 = wPi0PHOSFormula->Eval(E());
305 // cout << "wPhotonF " << wPhoton << " wphoton " << fCaloPID[kPhotonAli] << " wPi0F " << wPi0 << " wpi0 " << fCaloPID[kPi0Ali] << endl;
306 }
307
308 if(fCaloType == kEMCALCalo){
309 wPhoton = 0.8 ;
310 wPi0 = 0.5 ;
311 wElectron = 0.8 ;
312 wCharged = 0.5 ;
313 wNeutral = 0.5 ;
314 }
315
316
5ca97880 317 particleType pdg = kJHadron;
37dde34e 318
319 //Select most probable ID
320 if(fCaloType == kPHOSCalo){
5ca97880 321 if(fCaloPID[kPhotonAli] > wPhoton) pdg = kJPhoton ;
322 else if(fCaloPID[kPi0Ali] > wPi0) pdg = kJPizero ;
37dde34e 323 //else if(fCaloPID[kElectronAli] > wElectron) pdg = electron ;
324 //else if(fCaloPID[kEleConAli] > wElectron) pdg = electronCon ;
325 //else if(chargedHadronWeight > wCharged) pdg = chargedHadron ;
326 //else if(neutralHadronWeight > wNeutral) pdg = neutralHadron ;
327 //else if(allChargedWeight > allNeutralWeight)
328 // pdg = chargedUnknown ;
329 //else
330 // pdg = neutralUnknown ;
331 }
332 else{//EMCAL
333 //Temporal solution, electrons and photons not differenciated
5ca97880 334 if(fCaloPID[kPhotonAli] + fCaloPID[kElectronAli] > wPhoton) pdg = kJPhoton ;
335 else if(fCaloPID[kPi0Ali] > wPi0) pdg = kJPizero ;
37dde34e 336 //else if(chargedHadronWeight + neutralHadronWeight > wCharged) pdg = chargedHadron ;
337 //else if(neutralHadronWeight + chargedHadronWeight > wNeutral) pdg = neutralHadron ;
338 //else pdg = neutralUnknown ;
339
340 }
341
342 delete wPhotonPHOSFormula;
343 delete wPi0PHOSFormula;
344
345 //if(fCaloType == kPHOSCalo) cout << "pdg " << pdg << endl;
346
347 return pdg ;
348
349}
350
351