]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/GammaConv/AliCaloPhotonCuts.cxx
- modified selection in PHOS according to suggestions by Yuri Kharlov
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliCaloPhotonCuts.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                                                                *
4  * Authors: Friederike Bock, Baldo Sahlmueller                                *
5  * Version 1.0                                                                                    *
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 ////////////////////////////////////////////////
17 //---------------------------------------------
18 // Class handling all kinds of selection cuts for
19 // Photon from EMCAL clusters
20 //---------------------------------------------
21 ////////////////////////////////////////////////
22
23 #include "AliCaloPhotonCuts.h"
24 #include "AliAnalysisManager.h"
25 #include "AliInputEventHandler.h"
26 #include "AliMCEventHandler.h"
27 #include "AliAODHandler.h"
28 #include "TH1.h"
29 #include "TH2.h"
30 #include "TF1.h"
31 #include "AliStack.h"
32 #include "AliAODConversionMother.h"
33 #include "AliAODConversionPhoton.h"
34 #include "TObjString.h"
35 #include "AliAODEvent.h"
36 #include "AliESDEvent.h"
37 #include "AliCentrality.h"
38 #include "TList.h"
39 #include "TFile.h"
40 #include "AliLog.h"
41 #include "AliV0ReaderV1.h"
42 #include "AliAODMCParticle.h"
43 #include "AliAODMCHeader.h"
44 #include "AliPicoTrack.h"
45 #include "AliEMCALRecoUtils.h"
46 #include "AliTrackerBase.h"
47
48 class iostream;
49
50 using namespace std;
51
52 ClassImp(AliCaloPhotonCuts)
53
54
55 const char* AliCaloPhotonCuts::fgkCutNames[AliCaloPhotonCuts::kNCuts] = {
56         "ClusterType",          //0   0: all,    1: EMCAL,   2: PHOS
57         "EtaMin",               //1   0: -10,    1: -0.6687, 2: -0,5, 3: -2
58         "EtaMax",               //2   0: 10,     1: 0.66465, 2: 0.5,  3: 2
59         "PhiMin",               //3   0: -10000, 1: 1.39626
60         "PhiMax",               //4   0: 10000, 1: 3.125
61         "DistanceToBadChannel", //5   0: 0,      1: 5
62         "Timing",               //6   0: no cut
63         "TrackMatching",        //7   0: 0,      1: 5
64         "ExoticCell",           //8   0: no cut
65         "MinEnergy",            //9   0: no cut, 1: 0.05,    2: 0.1,  3: 0.15, 4: 0.2, 5: 0.3, 6: 0.5, 7: 0.75, 8: 1, 9: 1.25 (all GeV)
66         "MinNCells",            //10  0: no cut, 1: 1,       2: 2,    3: 3,    4: 4,   5: 5,   6: 6
67         "MinM02",                               //11
68         "MaxM02",                               //12
69         "MinM20",                               //13
70         "MaxM20",                               //14
71         "MaximumDispersion",    //15
72         "NLM"                                   //16
73 };
74
75
76 //________________________________________________________________________
77 AliCaloPhotonCuts::AliCaloPhotonCuts(const char *name,const char *title) :
78         AliAnalysisCuts(name,title),
79         fHistograms(NULL),      
80         fClusterType(0),
81         fMinEtaCut(-10),
82         fMaxEtaCut(10),
83         fUseEtaCut(0),
84         fMinPhiCut(-10000),
85         fMaxPhiCut(-10000),
86         fUsePhiCut(0),
87         fMinDistanceToBadChannel(0),
88         fUseDistanceToBadChannel(0),
89         fMaxTimeDiff(10e10),
90         fUseTimeDiff(0),
91         fMinDistTrackToCluster(0),
92         fUseDistTrackToCluster(0),
93     fExtendedMatching(kFALSE),
94         fExoticCell(0),
95         fUseExoticCell(0),
96         fMinEnergy(0),
97         fUseMinEnergy(0),
98         fMinNCells(0),
99         fUseNCells(0),
100         fMaxM02(1000),
101         fMinM02(0),
102         fUseM02(0),
103         fMaxM20(1000),
104         fMinM20(0),
105         fUseM20(0),
106         fMaxDispersion(1000),
107         fUseDispersion(0),
108         fMinNLM(0),
109         fMaxNLM(1000),
110         fUseNLM(0),
111         fCutString(NULL),
112         fHistCutIndex(NULL),
113         fHistAcceptanceCuts(NULL),
114         fHistClusterIdentificationCuts(NULL),
115         fHistClusterEtavsPhiBeforeAcc(NULL),
116         fHistClusterEtavsPhiAfterAcc(NULL),
117         fHistClusterEtavsPhiAfterQA(NULL),
118     //fHistDistanceToBadChannelBeforeAcc(NULL),
119     //fHistDistanceToBadChannelAfterAcc(NULL),
120         fHistClusterTimevsEBeforeQA(NULL),
121         fHistClusterTimevsEAfterQA(NULL),
122     //fHistExoticCellBeforeQA(NULL),
123     //fHistExoticCellAfterQA(NULL),
124     //fHistNMatchedTracks(NULL),
125         fHistEnergyOfClusterBeforeQA(NULL),
126         fHistEnergyOfClusterAfterQA(NULL),
127         fHistNCellsBeforeQA(NULL),
128         fHistNCellsAfterQA(NULL),
129         fHistM02BeforeQA(NULL),
130         fHistM02AfterQA(NULL),
131         fHistM20BeforeQA(NULL),
132         fHistM20AfterQA(NULL),
133         fHistDispersionBeforeQA(NULL),
134     fHistDispersionAfterQA(NULL),
135     //fHistNLMBeforeQA(NULL),
136     //fHistNLMAfterQA(NULL),
137     fHistClusterRBeforeQA(NULL),
138     fHistClusterRAfterQA(NULL),
139     fHistClusterdEtadPhiBeforeQA(NULL),
140     fHistClusterdEtadPhiAfterQA(NULL),
141     fHistDistanceTrackToClusterBeforeQA(NULL),
142     fHistDistanceTrackToClusterAfterQA(NULL),
143     fHistClusterdEtadPhiPosTracksBeforeQA(NULL),
144     fHistClusterdEtadPhiNegTracksBeforeQA(NULL),
145     fHistClusterdEtadPtBeforeQA(NULL),
146     fHistClusterdPhidPtBeforeQA(NULL),
147     fHistClusterM20Pt_dPhiBeforeQA(NULL),
148     fHistClusterM02Pt_dPhiBeforeQA(NULL),
149     fHistClusterM20M02BeforeQA(NULL),
150     fHistClusterM20M02AfterQA(NULL)
151 {
152    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
153    fCutString=new TObjString((GetCutNumber()).Data());
154 }
155
156 //________________________________________________________________________
157 AliCaloPhotonCuts::AliCaloPhotonCuts(const AliCaloPhotonCuts &ref) :
158    AliAnalysisCuts(ref),
159         fHistograms(NULL),      
160         fClusterType(ref.fClusterType),
161         fMinEtaCut(ref.fMinEtaCut),
162         fMaxEtaCut(ref.fMaxEtaCut),
163         fUseEtaCut(ref.fUseEtaCut),
164         fMinPhiCut(ref.fMinPhiCut),
165         fMaxPhiCut(ref.fMaxPhiCut),
166         fUsePhiCut(ref.fUsePhiCut),
167         fMinDistanceToBadChannel(ref.fMinDistanceToBadChannel),
168         fUseDistanceToBadChannel(ref.fUseDistanceToBadChannel),
169         fMaxTimeDiff(ref.fMaxTimeDiff),
170         fUseTimeDiff(ref.fUseTimeDiff),
171         fMinDistTrackToCluster(ref.fMinDistTrackToCluster),
172         fUseDistTrackToCluster(ref.fUseDistTrackToCluster),
173     fExtendedMatching(ref.fExtendedMatching),
174         fExoticCell(ref.fExoticCell),
175         fUseExoticCell(ref.fUseExoticCell),
176         fMinEnergy(ref.fMinEnergy),
177         fUseMinEnergy(ref.fUseMinEnergy),
178         fMinNCells(ref.fMinNCells),
179         fUseNCells(ref.fUseNCells),
180         fMaxM02(ref.fMaxM02),
181         fMinM02(ref.fMinM02),
182         fUseM02(ref.fUseM02),
183         fMaxM20(ref.fMaxM20),
184         fMinM20(ref.fMinM20),
185         fUseM20(ref.fUseDispersion),
186         fMaxDispersion(ref.fMaxDispersion),
187         fUseDispersion(ref.fUseDispersion),
188         fMinNLM(ref.fMinNLM),
189         fMaxNLM(ref.fMaxNLM),
190         fUseNLM(ref.fUseNLM),
191         fCutString(NULL),
192         fHistCutIndex(NULL),
193         fHistAcceptanceCuts(NULL),
194         fHistClusterIdentificationCuts(NULL),
195         fHistClusterEtavsPhiBeforeAcc(NULL),
196         fHistClusterEtavsPhiAfterAcc(NULL),
197         fHistClusterEtavsPhiAfterQA(NULL),
198     //fHistDistanceToBadChannelBeforeAcc(NULL),
199     //fHistDistanceToBadChannelAfterAcc(NULL),
200         fHistClusterTimevsEBeforeQA(NULL),
201         fHistClusterTimevsEAfterQA(NULL),
202     //fHistExoticCellBeforeQA(NULL),
203     //fHistExoticCellAfterQA(NULL),
204     //fHistNMatchedTracks(NULL),
205         fHistEnergyOfClusterBeforeQA(NULL),
206         fHistEnergyOfClusterAfterQA(NULL),
207         fHistNCellsBeforeQA(NULL),
208         fHistNCellsAfterQA(NULL),
209         fHistM02BeforeQA(NULL),
210         fHistM02AfterQA(NULL),
211         fHistM20BeforeQA(NULL),
212         fHistM20AfterQA(NULL),
213         fHistDispersionBeforeQA(NULL),
214     fHistDispersionAfterQA(NULL),
215     //fHistNLMBeforeQA(NULL),
216     //fHistNLMAfterQA(NULL),
217     fHistClusterRBeforeQA(NULL),
218     fHistClusterRAfterQA(NULL),
219     fHistClusterdEtadPhiBeforeQA(NULL),
220     fHistClusterdEtadPhiAfterQA(NULL),
221     fHistDistanceTrackToClusterBeforeQA(NULL),
222     fHistDistanceTrackToClusterAfterQA(NULL),
223     fHistClusterdEtadPhiPosTracksBeforeQA(NULL),
224     fHistClusterdEtadPhiNegTracksBeforeQA(NULL),
225     fHistClusterdEtadPtBeforeQA(NULL),
226     fHistClusterdPhidPtBeforeQA(NULL),
227     fHistClusterM20Pt_dPhiBeforeQA(NULL),
228     fHistClusterM02Pt_dPhiBeforeQA(NULL),
229     fHistClusterM20M02BeforeQA(NULL),
230     fHistClusterM20M02AfterQA(NULL)
231 {
232    // Copy Constructor
233    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=ref.fCuts[jj];}
234    fCutString=new TObjString((GetCutNumber()).Data());
235
236 }
237
238
239 //________________________________________________________________________
240 AliCaloPhotonCuts::~AliCaloPhotonCuts() {
241    // Destructor
242    //Deleting fHistograms leads to seg fault it it's added to output collection of a task
243    // if(fHistograms)
244    //    delete fHistograms;
245    // fHistograms = NULL;
246    if(fCutString != NULL){
247       delete fCutString;
248       fCutString = NULL;
249    }
250 }
251
252 //________________________________________________________________________
253 void AliCaloPhotonCuts::InitCutHistograms(TString name){
254
255         // Initialize Cut Histograms for QA (only initialized and filled if function is called)
256         TH1::AddDirectory(kFALSE);
257
258         if(fHistograms != NULL){
259                 delete fHistograms;
260                 fHistograms=NULL;
261         }
262         if(fHistograms==NULL){
263                 fHistograms=new TList();
264                 fHistograms->SetOwner(kTRUE);
265                 if(name=="")fHistograms->SetName(Form("CaloCuts_%s",GetCutNumber().Data()));
266                 else fHistograms->SetName(Form("%s_%s",name.Data(),GetCutNumber().Data()));
267         }
268
269         // IsPhotonSelected
270         fHistCutIndex=new TH1F(Form("IsPhotonSelected %s",GetCutNumber().Data()),"IsPhotonSelected",5,-0.5,4.5);
271         fHistCutIndex->GetXaxis()->SetBinLabel(kPhotonIn+1,"in");
272         fHistCutIndex->GetXaxis()->SetBinLabel(kDetector+1,"detector");
273         fHistCutIndex->GetXaxis()->SetBinLabel(kAcceptance+1,"acceptance");
274         fHistCutIndex->GetXaxis()->SetBinLabel(kClusterQuality+1,"cluster QA");
275         fHistCutIndex->GetXaxis()->SetBinLabel(kPhotonOut+1,"out");
276         fHistograms->Add(fHistCutIndex);
277
278         // Acceptance Cuts
279         fHistAcceptanceCuts=new TH1F(Form("AcceptanceCuts %s",GetCutNumber().Data()),"AcceptanceCuts",5,-0.5,4.5);
280         fHistAcceptanceCuts->GetXaxis()->SetBinLabel(1,"in");
281         fHistAcceptanceCuts->GetXaxis()->SetBinLabel(2,"eta");
282         fHistAcceptanceCuts->GetXaxis()->SetBinLabel(3,"phi");
283         fHistAcceptanceCuts->GetXaxis()->SetBinLabel(4,"distance to bad channel");
284         fHistAcceptanceCuts->GetXaxis()->SetBinLabel(5,"out");
285         fHistograms->Add(fHistAcceptanceCuts);
286
287         // Cluster Cuts
288         fHistClusterIdentificationCuts =new TH1F(Form("ClusterQualityCuts %s",GetCutNumber().Data()),"ClusterQualityCuts",11,-0.5,10.5);
289         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(1,"in");
290         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(2,"timing");
291         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(3,"track matching");
292         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(4,"Exotics");
293         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(5,"minimum energy");
294         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(6,"minimum NCells");
295         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(7,"M02");
296         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(8,"M20");
297         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(9,"dispersion");
298         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(10,"NLM");
299         fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(11,"out");
300         fHistograms->Add(fHistClusterIdentificationCuts);
301
302         // Acceptance related histogramms
303     fHistClusterEtavsPhiBeforeAcc=new TH2F(Form("EtaPhi_beforeAcceptance %s",GetCutNumber().Data()),"EtaPhi_beforeAcceptance",430,-TMath::Pi(),TMath::Pi(),96,-0.7,0.7); // 462->430, 110->96
304         fHistograms->Add(fHistClusterEtavsPhiBeforeAcc);
305     fHistClusterEtavsPhiAfterAcc=new TH2F(Form("EtaPhi_afterAcceptance %s",GetCutNumber().Data()),"EtaPhi_afterAcceptance",430,-TMath::Pi(),TMath::Pi(),96,-0.7,0.7); // 462->430, 110->96
306         fHistograms->Add(fHistClusterEtavsPhiAfterAcc);
307     fHistClusterEtavsPhiAfterQA=new TH2F(Form("EtaPhi_afterClusterQA %s",GetCutNumber().Data()),"EtaPhi_afterClusterQA",430,-TMath::Pi(),TMath::Pi(),96,-0.7,0.7); // 462->430, 110->96
308         fHistograms->Add(fHistClusterEtavsPhiAfterQA);
309     //fHistDistanceToBadChannelBeforeAcc = new TH1F(Form("DistanceToBadChannel_beforeAcceptance %s",GetCutNumber().Data()),"DistanceToBadChannel_beforeAcceptance",200,0,40);
310     //fHistograms->Add(fHistDistanceToBadChannelBeforeAcc);
311     //fHistDistanceToBadChannelAfterAcc = new TH1F(Form("DistanceToBadChannel_afterAcceptance %s",GetCutNumber().Data()),"DistanceToBadChannel_afterAcceptance",200,0,40);
312     //fHistograms->Add(fHistDistanceToBadChannelAfterAcc);
313         
314         // Cluster quality related histograms
315         Double_t timeMin = -10e-6;
316         Double_t timeMax = 10e-6;
317         fHistClusterTimevsEBeforeQA=new TH2F(Form("ClusterTimeVsE_beforeClusterQA %s",GetCutNumber().Data()),"ClusterTimeVsE_beforeClusterQA",400,timeMin,timeMax,100,0.,40);
318         fHistograms->Add(fHistClusterTimevsEBeforeQA);
319         fHistClusterTimevsEAfterQA=new TH2F(Form("ClusterTimeVsE_afterClusterQA %s",GetCutNumber().Data()),"ClusterTimeVsE_afterClusterQA",400,timeMin,timeMax,100,0.,40);
320         fHistograms->Add(fHistClusterTimevsEAfterQA);
321     //fHistExoticCellBeforeQA=new TH2F(Form("ExoticCell_beforeClusterQA %s",GetCutNumber().Data()),"ExoticCell_beforeClusterQA",400,0,40,50,0.75,1);
322     //fHistograms->Add(fHistExoticCellBeforeQA);
323     //fHistExoticCellAfterQA=new TH2F(Form("ExoticCell_afterClusterQA %s",GetCutNumber().Data()),"ExoticCell_afterClusterQA",400,0,40,50,0.75,1);
324     //fHistograms->Add(fHistExoticCellAfterQA);
325     //fHistNMatchedTracks = new TH1F(Form("NMatchedTracks_%s",GetCutNumber().Data()),"NMatchedTracks",22,-1.5,20.5);
326     //fHistograms->Add(fHistNMatchedTracks);
327         fHistEnergyOfClusterBeforeQA = new TH1F(Form("EnergyOfCluster_beforeClusterQA %s",GetCutNumber().Data()),"EnergyOfCluster_beforeClusterQA",300,0,30);
328         fHistograms->Add(fHistEnergyOfClusterBeforeQA);
329         fHistEnergyOfClusterAfterQA = new TH1F(Form("EnergyOfCluster_afterClusterQA %s",GetCutNumber().Data()),"EnergyOfCluster_afterClusterQA",300,0,30);
330         fHistograms->Add(fHistEnergyOfClusterAfterQA);
331         fHistNCellsBeforeQA = new TH1F(Form("NCellPerCluster_beforeClusterQA %s",GetCutNumber().Data()),"NCellPerCluster_beforeClusterQA",50,0,50);
332         fHistograms->Add(fHistNCellsBeforeQA);
333         fHistNCellsAfterQA = new TH1F(Form("NCellPerCluster_afterClusterQA %s",GetCutNumber().Data()),"NCellPerCluster_afterClusterQA",50,0,50);
334         fHistograms->Add(fHistNCellsAfterQA);
335         fHistM02BeforeQA = new TH1F(Form("M02_beforeClusterQA %s",GetCutNumber().Data()),"M02_beforeClusterQA",400,0,5);
336         fHistograms->Add(fHistM02BeforeQA);
337         fHistM02AfterQA = new TH1F(Form("M02_afterClusterQA %s",GetCutNumber().Data()),"M02_afterClusterQA",400,0,5);
338         fHistograms->Add(fHistM02AfterQA);
339         fHistM20BeforeQA = new TH1F(Form("M20_beforeClusterQA %s",GetCutNumber().Data()),"M20_beforeClusterQA",400,0,2.5);
340         fHistograms->Add(fHistM20BeforeQA);
341         fHistM20AfterQA = new TH1F(Form("M20_afterClusterQA %s",GetCutNumber().Data()),"M20_afterClusterQA",400,0,2.5);
342         fHistograms->Add(fHistM20AfterQA);
343         fHistDispersionBeforeQA = new TH1F(Form("Dispersion_beforeClusterQA %s",GetCutNumber().Data()),"Dispersion_beforeClusterQA",100,0,4);
344         fHistograms->Add(fHistDispersionBeforeQA);
345         fHistDispersionAfterQA = new TH1F(Form("Dispersion_afterClusterQA %s",GetCutNumber().Data()),"Dispersion_afterClusterQA",100,0,4);
346         fHistograms->Add(fHistDispersionAfterQA);
347     //fHistNLMBeforeQA = new TH1F(Form("NLM_beforeClusterQA %s",GetCutNumber().Data()),"NLM_beforeClusterQA",10,0,10);
348     //fHistograms->Add(fHistNLMBeforeQA);
349     //fHistNLMAfterQA = new TH1F(Form("NLM_afterClusterQA %s",GetCutNumber().Data()),"NLM_afterClusterQA",10,0,10);
350     //fHistograms->Add(fHistNLMAfterQA);
351
352     //TrackMatching histograms
353     if(fUseDistTrackToCluster) {
354         fHistClusterRBeforeQA = new TH1F(Form("R_Cluster_beforeClusterQA %s",GetCutNumber().Data()),"R of cluster",200,400,500);
355         fHistograms->Add(fHistClusterRBeforeQA);
356         fHistClusterRAfterQA = new TH1F(Form("R_Cluster_afterClusterQA %s",GetCutNumber().Data()),"R of cluster_matched",200,400,500);
357         fHistograms->Add(fHistClusterRAfterQA);
358         fHistClusterdEtadPhiBeforeQA=new TH2F(Form("dEtaVsdPhi_beforeClusterQA %s",GetCutNumber().Data()),"dEtaVsdPhi_beforeClusterQA",240,-0.3,0.3,240,-0.3,0.3);
359         fHistograms->Add(fHistClusterdEtadPhiBeforeQA);
360         fHistClusterdEtadPhiAfterQA=new TH2F(Form("dEtaVsdPhi_afterClusterQA %s",GetCutNumber().Data()),"dEtaVsdPhi_afterClusterQA",240,-0.3,0.3,240,-0.3,0.3);
361         fHistograms->Add(fHistClusterdEtadPhiAfterQA);
362         fHistDistanceTrackToClusterBeforeQA = new TH1F(Form("DistanceToTrack_beforeClusterQA %s",GetCutNumber().Data()),"DistanceToTrack_beforeClusterQA",200,0,2);
363         fHistograms->Add(fHistDistanceTrackToClusterBeforeQA);
364         fHistDistanceTrackToClusterAfterQA = new TH1F(Form("DistanceToTrack_afterClusterQA %s",GetCutNumber().Data()),"DistanceToTrack_afterClusterQA",200,0,2);
365         fHistograms->Add(fHistDistanceTrackToClusterAfterQA);
366         
367         if(fExtendedMatching){
368             fHistClusterdEtadPhiPosTracksBeforeQA = new TH2F(Form("dEtaVsdPhi_posTracks_beforeClusterQA %s",GetCutNumber().Data()),"dEtaVsdPhi_posTracks_beforeClusterQA",240,-0.3,0.3,240,-0.3,0.3);
369             fHistograms->Add(fHistClusterdEtadPhiPosTracksBeforeQA);
370             fHistClusterdEtadPhiNegTracksBeforeQA = new TH2F(Form("dEtaVsdPhi_negTracks_beforeClusterQA %s",GetCutNumber().Data()),"dEtaVsdPhi_negTracks_beforeClusterQA",240,-0.3,0.3,240,-0.3,0.3);
371             fHistograms->Add(fHistClusterdEtadPhiNegTracksBeforeQA);
372             fHistClusterdEtadPtBeforeQA = new TH2F(Form("dEtaVsPt_beforeClusterQA %s",GetCutNumber().Data()),"dEtaVsPt_beforeClusterQA",240,-0.3,0.3,250,0,25);
373             fHistograms->Add(fHistClusterdEtadPtBeforeQA);
374             fHistClusterdPhidPtBeforeQA = new TH2F(Form("dPhiVsPt_beforeClusterQA %s",GetCutNumber().Data()),"dPhiVsPt_beforeClusterQA",480,-0.6,0.6,250,0,25);
375             fHistograms->Add(fHistClusterdPhidPtBeforeQA);
376             fHistClusterM20Pt_dPhiBeforeQA = new TH2F(Form("M20VsPt_dPhi_beforeClusterQA %s",GetCutNumber().Data()),"M20VsPt_dPhi_beforeClusterQA",200,0,2.5,250,0,25);
377             fHistograms->Add(fHistClusterM20Pt_dPhiBeforeQA);
378             fHistClusterM02Pt_dPhiBeforeQA = new TH2F(Form("M02VsPt_dPhi_beforeClusterQA %s",GetCutNumber().Data()),"M20VsPt_dPhi_beforeClusterQA",400,0,5,250,0,25);
379             fHistograms->Add(fHistClusterM02Pt_dPhiBeforeQA);
380             fHistClusterM20M02BeforeQA = new TH2F(Form("M20VsM02_beforeClusterQA %s",GetCutNumber().Data()),"M20VsM02_beforeClusterQA",200,0,2.5,400,0,5);
381             fHistograms->Add(fHistClusterM20M02BeforeQA);
382             fHistClusterM20M02AfterQA = new TH2F(Form("M20VsM02_afterClusterQA %s",GetCutNumber().Data()),"M20VsM02_afterClusterQA",200,0,2.5,400,0,5);
383             fHistograms->Add(fHistClusterM20M02AfterQA);
384         }
385     }
386         TH1::AddDirectory(kTRUE);
387 }
388
389
390 ///________________________________________________________________________
391 Bool_t AliCaloPhotonCuts::ClusterIsSelectedMC(TParticle *particle,AliStack *fMCStack){
392    // MonteCarlo Photon Selection
393
394         if(!fMCStack)return kFALSE;
395
396         if (particle->GetPdgCode() == 22){
397
398                 if ( particle->Eta() < fMinEtaCut || particle->Eta() > fMaxEtaCut ) return kFALSE;
399                 if ( particle->Phi() < fMinPhiCut || particle->Phi() > fMaxPhiCut ) return kFALSE;
400                 
401                 if(particle->GetMother(0) >-1 && fMCStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
402                         return kFALSE; // no photon as mothers!
403                 }
404                 if(particle->GetMother(0) >= fMCStack->GetNprimary()){
405                         return kFALSE; // the gamma has a mother, and it is not a primary particle
406                 }
407                 return kTRUE;
408         }
409         return kFALSE;
410 }
411 ///________________________________________________________________________
412 Bool_t AliCaloPhotonCuts::ClusterIsSelectedAODMC(AliAODMCParticle *particle,TClonesArray *aodmcArray){
413         // MonteCarlo Photon Selection
414
415         if(!aodmcArray)return kFALSE;
416         if (particle->GetPdgCode() == 22){
417                 if ( particle->Eta() < fMinEtaCut || particle->Eta() > fMaxEtaCut ) return kFALSE;
418                 if ( particle->Phi() < fMinPhiCut || particle->Phi() > fMaxPhiCut ) return kFALSE;
419                 if(particle->GetMother() > -1){
420                         if((static_cast<AliAODMCParticle*>(aodmcArray->At(particle->GetMother())))->GetPdgCode() == 22){
421                                 return kFALSE; // no photon as mothers!
422                         }
423                         if(!(static_cast<AliAODMCParticle*>(aodmcArray->At(particle->GetMother()))->IsPrimary())){
424                                 return kFALSE; // the gamma has a mother, and it is not a primary particle
425                         }
426                 }
427                 return kTRUE; // return in case of accepted gamma
428         }
429         return kFALSE;
430 }
431
432
433
434 ///________________________________________________________________________
435 // This function selects the clusters based on their quality criteria
436 ///________________________________________________________________________
437 Bool_t AliCaloPhotonCuts::ClusterQualityCuts(AliVCluster* cluster, AliVEvent *event, Bool_t isMC)
438 {   // Specific Photon Cuts
439
440         Int_t cutIndex = 0;
441         if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex);
442         cutIndex++;
443
444 //      Double_t minR = 999.0;
445         // get the minimum radius of tracks to cluster
446 //      if(fHistDistanceTrackToClusterBeforeQA || fHistDistanceTrackToClusterAfterQA){
447 //              Float_t pos[3];
448 //              cluster->GetPosition(pos);  // Get cluster position
449 //              
450 //              TVector3 cp(pos);
451 //              int NtrMatched = 0;
452 //              NtrMatched = cluster->GetNTracksMatched();
453 //              fHistNMatchedTracks->Fill(NtrMatched);
454 //              //loop over tracks for Jet QA
455 //              TList *l = event->GetList();
456 //              TClonesArray *tracks = dynamic_cast<TClonesArray*>(l->FindObject("Tracks"));
457 //              for(int itrack = 0; itrack < NtrMatched; itrack++){
458 //                      AliVTrack *trackcluster = static_cast<AliVTrack*>(tracks->At(itrack));
459 //                      if (! trackcluster) {
460 //                              AliError(Form("Couldn't get ESD track %d\n", itrack));
461 //                              continue;
462 //                      }
463 //                      Double_t dphi = -999.0;
464 //                      Double_t deta = -999.0;
465 //                      AliPicoTrack::GetEtaPhiDiff(trackcluster, cluster, dphi, deta);
466 //                      cout << "here" << endl;
467 //                      Double_t dr = sqrt(dphi*dphi + deta+deta);
468 //                      if(dr < minR)
469 //                              minR = dr;
470 //              }//loop over tracks
471 //      }
472         
473         // Fill Histos before Cuts
474         if(fHistClusterTimevsEBeforeQA) fHistClusterTimevsEBeforeQA->Fill(cluster->GetTOF(), cluster->E());
475 //      if(fHistExoticCellBeforeQA) fHistExoticCellBeforeQA->Fill(cluster->E(), );
476 //      if(fHistDistanceTrackToClusterBeforeQA) fHistDistanceTrackToClusterBeforeQA->Fill(minR);
477         if(fHistEnergyOfClusterBeforeQA) fHistEnergyOfClusterBeforeQA->Fill(cluster->E());
478         if(fHistNCellsBeforeQA) fHistNCellsBeforeQA->Fill(cluster->GetNCells());
479         if(fHistM02BeforeQA) fHistM02BeforeQA->Fill(cluster->GetM02());
480         if(fHistM20BeforeQA) fHistM20BeforeQA->Fill(cluster->GetM20());
481         if(fHistDispersionBeforeQA) fHistDispersionBeforeQA->Fill(cluster->GetDispersion());
482 //      if(fHistNLMBeforeQA) fHistNLMBeforeQA->Fill(cluster->GetNExMax());
483         
484         // Check wether timing is ok
485         if (fUseTimeDiff){
486                 if(abs(cluster->GetTOF()) > fMaxTimeDiff && !isMC){
487                         if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //1
488                         return kFALSE;
489                 }
490         }       
491         cutIndex++; //2, next cut
492
493         // Minimum distance to track
494 //      if (fUseDistTrackToCluster){
495 //              Float_t pos[3];
496 //              cluster->GetPosition(pos);  // Get cluster position
497 //              TVector3 cp(pos);
498 //              int NtrMatched = 0;
499 //              NtrMatched = cluster->GetNTracksMatched();
500 //              fHistNMatchedTracks->Fill(NtrMatched);
501 //              if(NtrMatched > 0){
502 //                      //loop over tracks for QA
503 //                      TList *l = event->GetList();
504 //                      TClonesArray *tracks = dynamic_cast<TClonesArray*>(l->FindObject("Tracks"));
505 //                      
506 //                      Double_t dphi = 999.0;
507 //                      Double_t deta = 999.0;
508 //                      Double_t dr2 = 999.0;
509 // 
510 //                      for(int itrack = 0; itrack < NtrMatched; itrack++){
511 //                              AliVTrack *trackcluster = NULL;
512 //                              trackcluster = static_cast<AliVTrack*>(tracks->At(itrack));
513 //                              if (! trackcluster) {
514 //                              AliError(Form("Couldn't get ESD track %d\n", itrack));
515 //                              continue;
516 //                              }
517 //                              AliPicoTrack::GetEtaPhiDiff(trackcluster, cluster, dphi, deta);
518 //                              dr2 = dphi*dphi + deta+deta;
519 //                              //cout << dr << endl;
520 //                              if(dr2 < fMinDistTrackToCluster*fMinDistTrackToCluster){
521 //              //        if(dphi < fMinDistTrackToCluster || deta < fMinDistTrackToCluster){
522 //                              if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //2
523 //                              return kFALSE;
524 //                              }
525 //                              
526 //                      }//loop over tracks
527 //              }
528 // //           if(cluster->GetEmcCpvDistance() < fMinDistTrackToCluster){
529 // //                   if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //2
530 // //                   return kFALSE;
531 // //           }
532 //      }
533         cutIndex++;//3, next cut
534
535         // exotic cell cut --IMPLEMENT LATER---
536 //      if(!AcceptanceCuts(photon)){
537 //              if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //3
538 //              return kFALSE;
539 //      }
540         cutIndex++; //4, next cut
541         
542         // minimum cell energy cut
543         if (fUseMinEnergy){
544                 if(cluster->E() < fMinEnergy){
545                         if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //4
546                         return kFALSE;
547                 }
548         }       
549         cutIndex++; //5, next cut
550         
551         // minimum number of cells
552         if (fUseNCells){
553                 if(cluster->GetNCells() < fMinNCells) {
554                         if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //5
555                         return kFALSE;
556                 }
557         }       
558         cutIndex++; //6, next cut
559         
560         // M02 cut
561         if (fUseM02){
562                 if( cluster->GetM02()< fMinM02 || cluster->GetM02() > fMaxM02 ) {
563                         if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //6
564                         return kFALSE;
565                 }
566         }       
567         cutIndex++; //7, next cut
568         
569         // M20 cut
570         if (fUseM20){
571                 if( cluster->GetM20()< fMinM20 || cluster->GetM20() > fMaxM20 ) {
572                         if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //7
573                         return kFALSE;
574                 }
575         }       
576         cutIndex++; //8, next cut
577         
578         // dispersion cut
579         if (fUseDispersion){
580                 if( cluster->GetDispersion()> fMaxDispersion) {
581                         if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //8
582                         return kFALSE;
583                 }
584         }       
585         cutIndex++; //9, next cut
586         
587         // NLM cut --IMPLEMENT LATER---
588 //      if (fUseNLM){
589 //              if( cluster->GetDispersion()> fMaxDispersion) {
590 //                      if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //9
591 //                      return kFALSE;
592 //              }
593 //      }       
594         cutIndex++; //9, next cut
595         
596         // DONE with selecting photons
597         if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //10
598
599         // Histos after Cuts
600     Double_t vertex[3] = {0,0,0};
601 //      event->GetPrimaryVertex()->GetXYZ(vertex);
602         // TLorentzvector with cluster
603         TLorentzVector clusterVector;
604         cluster->GetMomentum(clusterVector,vertex);
605         Double_t etaCluster = clusterVector.Eta();
606         Double_t phiCluster = clusterVector.Phi();
607         
608         if(fHistClusterEtavsPhiAfterQA) fHistClusterEtavsPhiAfterQA->Fill(phiCluster,etaCluster);
609         if(fHistClusterTimevsEAfterQA) fHistClusterTimevsEAfterQA->Fill(cluster->GetTOF(), cluster->E());
610 //      if(fHistExoticCellAfterQA) fHistExoticCellAfterQA->Fill(cluster->E(), );
611 //      if(fHistDistanceTrackToClusterAfterQA) fHistDistanceTrackToClusterAfterQA->Fill(minR);
612         if(fHistEnergyOfClusterAfterQA) fHistEnergyOfClusterAfterQA->Fill(cluster->E());
613         if(fHistNCellsAfterQA) fHistNCellsAfterQA->Fill(cluster->GetNCells());
614         if(fHistM02AfterQA) fHistM02AfterQA->Fill(cluster->GetM02());
615         if(fHistM20AfterQA) fHistM20AfterQA->Fill(cluster->GetM20());
616         if(fHistDispersionAfterQA) fHistDispersionAfterQA->Fill(cluster->GetDispersion());
617 //      if(fHistNLMBeforeQA) fHistNLMAfterQA->Fill(cluster->GetNExMax());
618
619         return kTRUE;
620
621 }
622
623
624 ///________________________________________________________________________
625 Bool_t AliCaloPhotonCuts::ClusterIsSelected(AliVCluster *cluster, AliVEvent * event, Bool_t isMC)
626 {
627         //Selection of Reconstructed photon clusters with Calorimeters
628
629         FillClusterCutIndex(kPhotonIn);
630
631     Double_t vertex[3] = {0,0,0};
632 //      event->GetPrimaryVertex()->GetXYZ(vertex);
633         // TLorentzvector with cluster
634         TLorentzVector clusterVector;
635         cluster->GetMomentum(clusterVector,vertex);
636         Double_t etaCluster = clusterVector.Eta();
637         Double_t phiCluster = clusterVector.Phi();
638
639         // Histos before cuts
640         if(fHistClusterEtavsPhiBeforeAcc) fHistClusterEtavsPhiBeforeAcc->Fill(phiCluster,etaCluster);
641         
642         // Cluster Selection - 0= accept any calo cluster
643         if (fClusterType > 0){
644                 //Select EMCAL cluster
645                 if (fClusterType == 1 && !cluster->IsEMCAL()){
646                         FillClusterCutIndex(kDetector);
647                         return kFALSE;
648                 }
649                 //Select PHOS cluster
650                 if (fClusterType == 2 && !cluster->IsPHOS()){
651                         FillClusterCutIndex(kDetector);
652                         return kFALSE;
653                 }
654         }
655         
656         // Acceptance Cuts
657         if(!AcceptanceCuts(cluster,event)){
658                 FillClusterCutIndex(kAcceptance);
659                 return kFALSE;
660         }
661         // Cluster Quality Cuts
662         if(!ClusterQualityCuts(cluster,event,isMC)){
663                 FillClusterCutIndex(kClusterQuality);
664                 return kFALSE;
665         }
666
667         // Photon passed cuts
668         FillClusterCutIndex(kPhotonOut);
669         return kTRUE;
670 }
671
672
673 ///________________________________________________________________________
674 Bool_t AliCaloPhotonCuts::AcceptanceCuts(AliVCluster *cluster, AliVEvent* event) 
675 {
676    // Exclude certain areas for photon reconstruction
677
678         Int_t cutIndex=0;
679         if(fHistAcceptanceCuts)fHistAcceptanceCuts->Fill(cutIndex);
680         cutIndex++;
681
682         
683         Double_t vertex[3] = {0,0,0};
684 //      event->GetPrimaryVertex()->GetXYZ(vertex);
685         // TLorentzvector with cluster
686         TLorentzVector clusterVector;
687         cluster->GetMomentum(clusterVector,vertex);
688         Double_t etaCluster = clusterVector.Eta();
689         Double_t phiCluster = clusterVector.Phi();
690         
691         // check eta range
692         if (fUseEtaCut){
693                 if (etaCluster < fMinEtaCut || etaCluster > fMaxEtaCut){
694                         if(fHistAcceptanceCuts)fHistAcceptanceCuts->Fill(cutIndex);
695                         return kFALSE;
696                 }
697         }
698         cutIndex++;
699         
700         // check phi range
701         if (fUsePhiCut ){
702         if (phiCluster < fMinPhiCut || phiCluster > fMaxPhiCut){
703                         if(fHistAcceptanceCuts)fHistAcceptanceCuts->Fill(cutIndex);
704                         return kFALSE;
705                 }
706         }
707         cutIndex++;
708         
709         // check distance to bad channel
710         if (fUseDistanceToBadChannel){
711                 if (cluster->GetDistanceToBadChannel() < fMinDistanceToBadChannel){
712                         if(fHistAcceptanceCuts)fHistAcceptanceCuts->Fill(cutIndex);
713                         return kFALSE;
714                 }       
715         }
716         cutIndex++;
717         if(fHistAcceptanceCuts)fHistAcceptanceCuts->Fill(cutIndex);
718
719         // Histos after cuts
720         if(fHistClusterEtavsPhiAfterAcc) fHistClusterEtavsPhiAfterAcc->Fill(phiCluster,etaCluster);
721         
722         return kTRUE;
723 }
724
725 Bool_t AliCaloPhotonCuts::MatchConvPhotonToCluster(AliAODConversionPhoton* convPhoton, AliVCluster* cluster, AliVEvent* event ){
726
727         if (!fUseDistTrackToCluster) return kFALSE;
728         
729         AliESDEvent *esdev = dynamic_cast<AliESDEvent*>(event);
730         AliAODEvent *aodev = 0;
731         if (!esdev) {
732                 aodev = dynamic_cast<AliAODEvent*>(event);
733                 if (!aodev) {
734                         AliError("Task needs AOD or ESD event, returning");
735                         return kFALSE;
736                 }
737         }
738
739 //    Double_t vertex[3] = {0,0,0};
740 //      event->GetPrimaryVertex()->GetXYZ(vertex);
741
742     if(!cluster->IsEMCAL() && !cluster->IsPHOS()){AliError("Cluster is neither EMCAL nor PHOS, returning"); return kFALSE;}
743
744     Float_t clusterPosition[3] = {0,0,0};
745     cluster->GetPosition(clusterPosition);
746     Double_t clusterR = TMath::Sqrt( clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1] );
747     if(fHistClusterRBeforeQA) fHistClusterRBeforeQA->Fill(clusterR);
748
749 //cout << "+++++++++ Cluster: x, y, z, R" << clusterPosition[0] << ", " << clusterPosition[1] << ", " << clusterPosition[2] << ", " << clusterR << "+++++++++" << endl;
750
751         Bool_t matched = kFALSE;
752         for (Int_t i = 0; i < 2; i++){
753                 Int_t tracklabel = convPhoton->GetLabel(i);
754                 AliVTrack *inTrack = 0x0;       
755                 if(esdev) {
756                         if(tracklabel > event->GetNumberOfTracks() ) continue;
757                         inTrack = esdev->GetTrack(tracklabel);
758                 } else {
759                         if(((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1"))->AreAODsRelabeled()){
760                                 inTrack = dynamic_cast<AliVTrack*>(event->GetTrack(tracklabel));        
761                         } else {
762                                 for(Int_t ii=0; ii<event->GetNumberOfTracks(); ii++) {
763                                         inTrack = dynamic_cast<AliVTrack*>(event->GetTrack(ii));
764                                         if(inTrack){
765                                                 if(inTrack->GetID() == tracklabel) {
766                                                         continue;
767                                                 }
768                                         }
769                                 }
770                         }
771                 }
772
773                 AliESDtrack *esdt = dynamic_cast<AliESDtrack*>(inTrack);
774                 AliAODTrack *aodt = 0;
775                 if (!esdt) {
776                         aodt = dynamic_cast<AliAODTrack*>(inTrack);
777                         if (!aodt){AliError("Track is neither ESD nor AOD, continue"); continue;}
778                 }
779
780                 AliExternalTrackParam *trackParam = 0;
781                 if (esdt) {
782                         const AliExternalTrackParam *in = esdt->GetInnerParam();
783                         if (!in){AliError("Could not get InnerParam of Track, continue"); continue;}
784                         trackParam = new AliExternalTrackParam(*in);
785                 } else {
786                         Double_t xyz[3] = {0}, pxpypz[3] = {0}, cv[21] = {0};
787                         aodt->PxPyPz(pxpypz);
788                         aodt->XvYvZv(xyz);
789                         aodt->GetCovarianceXYZPxPyPz(cv);
790                         trackParam = new AliExternalTrackParam(xyz,pxpypz,cv,aodt->Charge());
791                 }
792                 if (!trackParam){AliError("Could not get TrackParameters, continue"); continue;}
793                 
794                 Bool_t propagated = kFALSE;
795                 AliExternalTrackParam emcParam(*trackParam);
796                 Float_t dPhi = 0;
797                 Float_t dEta = 0;
798
799                 if(cluster->IsEMCAL()){
800                         Float_t eta = 0; Float_t phi = 0; Float_t pt = 0;
801                         propagated = AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&emcParam, 430, 0.000510999, 20, eta, phi, pt);
802                         if(propagated){
803                                 propagated = AliEMCALRecoUtils::ExtrapolateTrackToCluster(&emcParam, cluster, 0.000510999, 5, dEta, dPhi);
804                         }
805                 }
806                 if(cluster->IsPHOS()){
807                         propagated = AliTrackerBase::PropagateTrackToBxByBz(&emcParam, clusterR, 0.000510999, 20, kTRUE, 0.8, -1);
808                         if (propagated){
809                                 Double_t trkPos[3] = {0,0,0};
810                                 emcParam.GetXYZ(trkPos);
811                                 TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
812                                 TVector3 clsPosVec(clusterPosition);
813                                 dPhi = clsPosVec.DeltaPhi(trkPosVec);
814                                 dEta = clsPosVec.Eta()-trkPosVec.Eta();
815                         }
816                 }
817
818                 if (propagated){
819                         Float_t dR2 = dPhi*dPhi + dEta*dEta;
820             if(fHistDistanceTrackToClusterBeforeQA)fHistDistanceTrackToClusterBeforeQA->Fill(TMath::Sqrt(dR2));
821             if(fHistClusterdEtadPhiBeforeQA) fHistClusterdEtadPhiBeforeQA->Fill(dEta, dPhi);
822
823             Float_t clusM02 = (Float_t)cluster->GetM02();
824             Float_t clusM20 = (Float_t)cluster->GetM20();
825             if(fExtendedMatching){
826                 if(inTrack->Charge() > 0) fHistClusterdEtadPhiPosTracksBeforeQA->Fill(dEta, dPhi);
827                 if(inTrack->Charge() < 0) fHistClusterdEtadPhiNegTracksBeforeQA->Fill(dEta, dPhi);
828                 fHistClusterdEtadPtBeforeQA->Fill(dEta, inTrack->Pt());
829                 fHistClusterdPhidPtBeforeQA->Fill(dPhi, inTrack->Pt());
830                 if(abs(dPhi) > 0.05) fHistClusterM20Pt_dPhiBeforeQA->Fill(clusM20, inTrack->Pt());
831                 if(abs(dPhi) > 0.05) fHistClusterM02Pt_dPhiBeforeQA->Fill(clusM02, inTrack->Pt());
832                 fHistClusterM20M02BeforeQA->Fill(clusM20, clusM02);
833             }
834
835                         if(dR2 < fMinDistTrackToCluster*fMinDistTrackToCluster){
836                                 matched = kTRUE;
837                         } else {
838                 if(fHistDistanceTrackToClusterAfterQA)fHistDistanceTrackToClusterAfterQA->Fill(TMath::Sqrt(dR2));
839                 if(fHistClusterdEtadPhiAfterQA) fHistClusterdEtadPhiAfterQA->Fill(dEta, dPhi);
840                 if(fHistClusterRAfterQA) fHistClusterRAfterQA->Fill(clusterR);
841                 if(fExtendedMatching){
842                     fHistClusterM20M02AfterQA->Fill(clusM20, clusM02);
843                 }
844                         }       
845                 }
846                 delete trackParam;
847         }
848
849         return matched;
850
851 }
852
853 //____________________________________________________________________________________________
854
855
856 ///________________________________________________________________________
857 Bool_t AliCaloPhotonCuts::UpdateCutString() {
858    ///Update the cut string (if it has been created yet)
859
860    if(fCutString && fCutString->GetString().Length() == kNCuts) {
861       fCutString->SetString(GetCutNumber());
862    } else {
863       return kFALSE;
864    }
865    return kTRUE;
866 }
867
868 ///________________________________________________________________________
869 Bool_t AliCaloPhotonCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) {
870         // Initialize Cuts from a given Cut string
871         AliInfo(Form("Set CaloCut Number: %s",analysisCutSelection.Data()));
872         if(analysisCutSelection.Length()!=kNCuts) {
873                 AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
874                 return kFALSE;
875         }
876         if(!analysisCutSelection.IsDigit()){
877                 AliError("Cut selection contains characters");
878                 return kFALSE;
879         }
880
881         const char *cutSelection = analysisCutSelection.Data();
882         #define ASSIGNARRAY(i)  fCuts[i] = cutSelection[i] - '0'
883         for(Int_t ii=0;ii<kNCuts;ii++){
884                 ASSIGNARRAY(ii);
885         }
886
887         // Set Individual Cuts
888         for(Int_t ii=0;ii<kNCuts;ii++){
889                 if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
890         }
891         PrintCutsWithValues();
892         return kTRUE;
893 }
894
895 ///________________________________________________________________________
896 Bool_t AliCaloPhotonCuts::SetCut(cutIds cutID, const Int_t value) {
897         ///Set individual cut ID
898
899         switch (cutID) {                
900                 
901                 case kClusterType:
902                         if( SetClusterTypeCut(value)) {
903                                 fCuts[kClusterType] = value;
904                                 UpdateCutString();
905                                 return kTRUE;
906                         } else return kFALSE;
907                 
908                 case kEtaMin:
909                         if( SetMinEtaCut(value)) {
910                                 fCuts[kEtaMin] = value;
911                                 UpdateCutString();
912                                 return kTRUE;
913                         } else return kFALSE;
914
915                 case kEtaMax:
916                         if( SetMaxEtaCut(value)) {
917                                 fCuts[kEtaMax] = value;
918                                 UpdateCutString();
919                                 return kTRUE;
920                         } else return kFALSE;
921
922                 case kPhiMin:
923                         if( SetMinPhiCut(value)) {
924                                 fCuts[kPhiMin] = value;
925                                 UpdateCutString();
926                                 return kTRUE;
927                         } else return kFALSE;
928
929                 case kPhiMax:
930                         if( SetMaxPhiCut(value)) {
931                                 fCuts[kPhiMax] = value;
932                                 UpdateCutString();
933                                 return kTRUE;
934                         } else return kFALSE;
935
936                 case kDistanceToBadChannel:
937                         if( SetDistanceToBadChannelCut(value)) {
938                                 fCuts[kDistanceToBadChannel] = value;
939                                 UpdateCutString();
940                                 return kTRUE;
941                         } else return kFALSE;
942
943                 case kTiming:
944                         if( SetTimingCut(value)) {
945                                 fCuts[kTiming] = value;
946                                 UpdateCutString();
947                                 return kTRUE;
948                         } else return kFALSE;
949
950                 case kTrackMatching:
951                         if( SetTrackMatchingCut(value)) {
952                                 fCuts[kTrackMatching] = value;
953                                 UpdateCutString();
954                                 return kTRUE;
955                         } else return kFALSE;
956
957                 case kExoticCell:
958                         if( SetExoticCellCut(value)) {
959                                 fCuts[kExoticCell] = value;
960                                 UpdateCutString();
961                                 return kTRUE;
962                         } else return kFALSE;
963
964                 case kMinEnery:
965                         if( SetMinEnergyCut(value)) {
966                                 fCuts[kMinEnery] = value;
967                                 UpdateCutString();
968                                 return kTRUE;
969                         } else return kFALSE;
970
971                 case kNMinCells:
972                         if( SetMinNCellsCut(value)) {
973                                 fCuts[kNMinCells] = value;
974                                 UpdateCutString();
975                                 return kTRUE;
976                         } else return kFALSE;
977                         
978                 case kMinM02:
979                         if( SetMinM02(value)) {
980                                 fCuts[kMinM02] = value;
981                                 UpdateCutString();
982                                 return kTRUE;
983                         } else return kFALSE;
984
985                 case kMaxM02:
986                         if( SetMaxM02(value)) {
987                                 fCuts[kMaxM02] = value;
988                                 UpdateCutString();
989                                 return kTRUE;
990                         } else return kFALSE;
991                 
992                 case kMinM20:
993                         if( SetMinM20(value)) {
994                                 fCuts[kMinM20] = value;
995                                 UpdateCutString();
996                                 return kTRUE;
997                         } else return kFALSE;
998
999                 case kMaxM20:
1000                         if( SetMaxM20(value)) {
1001                                 fCuts[kMaxM20] = value;
1002                                 UpdateCutString();
1003                                 return kTRUE;
1004                         } else return kFALSE;
1005
1006                 case kDispersion:
1007                         if( SetDispersion(value)) {
1008                                 fCuts[kDispersion] = value;
1009                                 UpdateCutString();
1010                                 return kTRUE;
1011                         } else return kFALSE;
1012
1013                 case kNLM:
1014                         if( SetNLM(value)) {
1015                                 fCuts[kNLM] = value;
1016                                 UpdateCutString();
1017                                 return kTRUE;
1018                         } else return kFALSE;
1019
1020                 case kNCuts:
1021                         AliError("Cut id out of range");
1022                         return kFALSE;
1023         }
1024
1025         AliError("Cut id %d not recognized");
1026         return kFALSE;
1027
1028
1029 }
1030 ///________________________________________________________________________
1031 void AliCaloPhotonCuts::PrintCuts() {
1032    // Print out current Cut Selection
1033    for(Int_t ic = 0; ic < kNCuts; ic++) {
1034       printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
1035    }
1036 }
1037
1038 void AliCaloPhotonCuts::PrintCutsWithValues() {
1039         // Print out current Cut Selection with value
1040         printf("\nCluster cutnumber \n");
1041         for(Int_t ic = 0; ic < kNCuts; ic++) {
1042                 printf("%d",fCuts[ic]);
1043         }
1044         printf("\n\n");
1045
1046         printf("Acceptance cuts: \n");
1047         if (fClusterType == 0) printf("\tall calorimeter clusters are used\n");
1048         if (fClusterType == 1) printf("\tEMCAL calorimeter clusters are used\n");
1049         if (fClusterType == 2) printf("\tPHOS calorimeter clusters are used\n");
1050         if (fUseEtaCut) printf("\t%3.2f < eta_{cluster} < %3.2f\n", fMinEtaCut, fMaxEtaCut );
1051         if (fUsePhiCut) printf("\t%3.2f < phi_{cluster} < %3.2f\n", fMinPhiCut, fMaxPhiCut );
1052         if (fUseDistanceToBadChannel) printf("\tcut on exotics applied \n");
1053         
1054         printf("Cluster Quality cuts: \n");
1055         if (fUseTimeDiff) printf("\t time difference < %3.2f\n", fMaxTimeDiff );
1056         if (fUseDistTrackToCluster) printf("\tmin distance to track > %3.2f\n", fMinDistTrackToCluster );
1057         if (fUseExoticCell)printf("\t min distance to track > %3.2f\n", fMinDistTrackToCluster );
1058     if (fUseMinEnergy)printf("\t E_{cluster} > %3.2f\n", fMinEnergy );
1059         if (fUseNCells) printf("\t number of cells per cluster >= %d\n", fMinNCells );
1060         if (fUseM02) printf("\t %3.2f < M02 < %3.2f\n", fMinM02, fMaxM02 );
1061         if (fUseM20) printf("\t %3.2f < M20 < %3.2f\n", fMinM20, fMaxM20 );
1062         if (fUseDispersion) printf("\t dispersion < %3.2f\n", fMaxDispersion );
1063         if (fUseNLM) printf("\t %d < NLM < %d\n", fMinNLM, fMaxNLM );
1064         
1065 }
1066
1067 // EMCAL acceptance 2011
1068 // 1.39626, 3.125 (phi)
1069 // -0.66687,,0.66465
1070
1071
1072 ///________________________________________________________________________
1073 Bool_t AliCaloPhotonCuts::SetClusterTypeCut(Int_t clusterType)
1074 {   // Set Cut
1075         switch(clusterType){
1076         case 0: // all clusters
1077                 fClusterType=0;
1078                 break;
1079         case 1: // EMCAL clusters
1080                 fClusterType=1;
1081                 break;
1082         case 2: // PHOS clusters
1083                 fClusterType=2;
1084                 break;
1085         default:
1086                 AliError(Form("ClusterTypeCut not defined %d",clusterType));
1087                 return kFALSE;
1088         }
1089         return kTRUE;
1090 }
1091
1092 //___________________________________________________________________
1093 Bool_t AliCaloPhotonCuts::SetMinEtaCut(Int_t minEta)
1094 {
1095         switch(minEta){
1096         case 0:
1097                 if (!fUseEtaCut) fUseEtaCut=0;
1098                 fMinEtaCut=-10.;
1099                 break;
1100         case 1:
1101                 if (!fUseEtaCut) fUseEtaCut=1;
1102                 fMinEtaCut=-0.6687;
1103                 break;
1104         case 2: 
1105                 if (!fUseEtaCut) fUseEtaCut=1;
1106                 fMinEtaCut=-0.5;
1107                 break;
1108         case 3: 
1109                 if (!fUseEtaCut) fUseEtaCut=1;
1110                 fMinEtaCut=-2;
1111                 break;
1112         default:
1113                 AliError(Form("MinEta Cut not defined %d",minEta));
1114                 return kFALSE;
1115         }
1116         return kTRUE;
1117 }
1118
1119
1120 //___________________________________________________________________
1121 Bool_t AliCaloPhotonCuts::SetMaxEtaCut(Int_t maxEta)
1122 {
1123         switch(maxEta){
1124         case 0: 
1125                 if (!fUseEtaCut) fUseEtaCut=0;
1126                 fMaxEtaCut=10;
1127                 break;          
1128         case 1:
1129                 if (!fUseEtaCut) fUseEtaCut=1;
1130                 fMaxEtaCut=0.66465;
1131                 break;
1132         case 2: 
1133                 if (!fUseEtaCut) fUseEtaCut=1;
1134                 fMaxEtaCut=0.5;
1135                 break;
1136         case 3: 
1137                 if (!fUseEtaCut) fUseEtaCut=1;
1138                 fMaxEtaCut=2;
1139                 break;
1140         default:
1141                 AliError(Form("MaxEta Cut not defined %d",maxEta));
1142                 return kFALSE;
1143         }
1144         return kTRUE;
1145 }
1146
1147 //___________________________________________________________________
1148 Bool_t AliCaloPhotonCuts::SetMinPhiCut(Int_t minPhi)
1149 {
1150         switch(minPhi){
1151         case 0: 
1152                 if (!fUsePhiCut) fUsePhiCut=0;
1153                 fMinPhiCut=-10000;
1154                 break;
1155         case 1: 
1156                 if (!fUsePhiCut) fUsePhiCut=1;
1157                 fMinPhiCut=1.39626;
1158                 break;
1159         default:
1160                 AliError(Form("MinPhi Cut not defined %d",minPhi));
1161                 return kFALSE;
1162         }
1163         return kTRUE;
1164 }
1165
1166 //___________________________________________________________________
1167 Bool_t AliCaloPhotonCuts::SetMaxPhiCut(Int_t maxPhi)
1168 {
1169         switch(maxPhi){
1170         case 0: 
1171                 if (!fUsePhiCut) fUsePhiCut=0;
1172                 fMaxPhiCut=10000;
1173                 break;
1174         case 1: 
1175                 if (!fUsePhiCut) fUsePhiCut=1;
1176                 fMaxPhiCut=3.125;
1177                 break;
1178         default:
1179                 AliError(Form("Max Phi Cut not defined %d",maxPhi));
1180                 return kFALSE;
1181         }
1182         return kTRUE;
1183 }
1184
1185 //___________________________________________________________________
1186 Bool_t AliCaloPhotonCuts::SetDistanceToBadChannelCut(Int_t distanceToBadChannel)
1187 {
1188         switch(distanceToBadChannel){
1189         case 0: 
1190                 fUseDistanceToBadChannel=0;
1191                 fMinDistanceToBadChannel=0;
1192                 break;
1193         case 1: 
1194                 if (!fUseDistanceToBadChannel) fUseDistanceToBadChannel=1;
1195                 fMinDistanceToBadChannel=5;
1196                 break;
1197         default:
1198                 AliError(Form("minimum distance to bad channel Cut not defined %d",distanceToBadChannel));
1199                 return kFALSE;
1200         }
1201         return kTRUE;
1202 }
1203
1204 //___________________________________________________________________
1205 Bool_t AliCaloPhotonCuts::SetTimingCut(Int_t timing)
1206 {
1207         switch(timing){
1208         case 0: 
1209                 fUseTimeDiff=0;
1210                 fMaxTimeDiff=500;
1211                 break;
1212         case 1: 
1213                 if (!fUseTimeDiff) fUseTimeDiff=1;
1214                 fMaxTimeDiff=10e-7; //1000ns
1215                 break;
1216         case 2: 
1217                 if (!fUseTimeDiff) fUseTimeDiff=1;
1218                 fMaxTimeDiff=50e-8; //500ns
1219                 break;
1220         case 3: 
1221                 if (!fUseTimeDiff) fUseTimeDiff=1;
1222                 fMaxTimeDiff=20e-8; //200ns
1223                 break;
1224         case 4: 
1225                 if (!fUseTimeDiff) fUseTimeDiff=1;
1226                 fMaxTimeDiff=10e-8; //100ns
1227                 break;
1228         case 5: 
1229                 if (!fUseTimeDiff) fUseTimeDiff=1;
1230                 fMaxTimeDiff=50e-9; //50ns
1231                 break;
1232
1233         default:
1234                 AliError(Form("Timing Cut not defined %d",timing));
1235                 return kFALSE;
1236         }
1237         return kTRUE;
1238 }
1239
1240 //___________________________________________________________________
1241 Bool_t AliCaloPhotonCuts::SetTrackMatchingCut(Int_t trackMatching)
1242 {
1243         switch(trackMatching){
1244         case 0: 
1245                 fUseDistTrackToCluster=0;
1246                 fMinDistTrackToCluster=0;
1247                 break;
1248         case 1: 
1249                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1250                 fMinDistTrackToCluster= 0.03;   //0.04;  
1251                 break;
1252         case 2: 
1253                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1254                 fMinDistTrackToCluster= 0.035;  //0.05; 
1255                 break;
1256         case 3: 
1257                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1258                 fMinDistTrackToCluster= 0.04;   //0.1;  
1259                 break;
1260         case 4: 
1261                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1262                 fMinDistTrackToCluster= 0.045;  //0.13; 
1263                 break;
1264         case 5: 
1265                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1266                 fMinDistTrackToCluster= 0.05;   //0.15 
1267                 break;
1268         case 6: 
1269                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1270                 fMinDistTrackToCluster= 0.055;  //0.2; 
1271                 break;
1272         case 7: 
1273                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1274                 fMinDistTrackToCluster= 0.06;   //0.3; 
1275                 break;
1276         case 8: 
1277                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1278                 fMinDistTrackToCluster= 0.07;   //0.4; 
1279                 break;
1280         case 9: 
1281                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1282                 fMinDistTrackToCluster= 0.1;    //0.5; 
1283                 break;
1284
1285         default:
1286                 AliError(Form("Track Matching Cut not defined %d",trackMatching));
1287                 return kFALSE;
1288         }
1289         return kTRUE;
1290 }
1291
1292 //___________________________________________________________________
1293 Bool_t AliCaloPhotonCuts::SetExoticCellCut(Int_t exoticCell)
1294 {
1295         switch(exoticCell){
1296         case 0: 
1297                 fUseExoticCell=0;
1298                 fExoticCell=0;
1299                 break;
1300         case 1: 
1301                 if (!fUseExoticCell) fUseExoticCell=1;
1302                 fExoticCell=5; 
1303                 break;
1304         default:
1305                 AliError(Form("Exotic cell Cut not defined %d",exoticCell));
1306                 return kFALSE;
1307         }
1308         return kTRUE;
1309 }
1310                 
1311 //___________________________________________________________________
1312 Bool_t AliCaloPhotonCuts::SetMinEnergyCut(Int_t minEnergy)
1313 {
1314         switch(minEnergy){
1315         case 0: 
1316                 if (!fUseMinEnergy) fUseMinEnergy=0;
1317                 fMinEnergy=0;
1318                 break;
1319         case 1: 
1320                 if (!fUseMinEnergy) fUseMinEnergy=1;
1321                 fMinEnergy=0.05; 
1322                 break;
1323         case 2: 
1324                 if (!fUseMinEnergy) fUseMinEnergy=1;
1325                 fMinEnergy=0.1; 
1326                 break;
1327         case 3: 
1328                 if (!fUseMinEnergy) fUseMinEnergy=1;
1329                 fMinEnergy=0.15; 
1330                 break;
1331         case 4: 
1332                 if (!fUseMinEnergy) fUseMinEnergy=1;
1333                 fMinEnergy=0.2; 
1334                 break;
1335         case 5: 
1336                 if (!fUseMinEnergy) fUseMinEnergy=1;
1337                 fMinEnergy=0.3; 
1338                 break;
1339         case 6: 
1340                 if (!fUseMinEnergy) fUseMinEnergy=1;
1341                 fMinEnergy=0.4; 
1342                 break;
1343         case 7: 
1344                 if (!fUseMinEnergy) fUseMinEnergy=1;
1345                 fMinEnergy=0.5; 
1346                 break;
1347         case 8: 
1348                 if (!fUseMinEnergy) fUseMinEnergy=1;
1349                 fMinEnergy=0.75; 
1350                 break;
1351         case 9: 
1352                 if (!fUseMinEnergy) fUseMinEnergy=1;
1353                 fMinEnergy=1.; 
1354                 break;
1355         default:
1356                 AliError(Form("Minimum Energy Cut not defined %d",minEnergy));
1357                 return kFALSE;
1358         }
1359         return kTRUE;
1360 }
1361                 
1362 //___________________________________________________________________
1363 Bool_t AliCaloPhotonCuts::SetMinNCellsCut(Int_t minNCells)
1364 {
1365         switch(minNCells){
1366         case 0:
1367                 if (!fUseNCells) fUseNCells=0;
1368                 fMinNCells=0;
1369                 break;
1370         case 1: 
1371                 if (!fUseNCells) fUseNCells=1;
1372                 fMinNCells=1; 
1373                 break;
1374         case 2: 
1375                 if (!fUseNCells) fUseNCells=1;
1376                 fMinNCells=2; 
1377                 break;
1378         case 3: 
1379                 if (!fUseNCells) fUseNCells=1;
1380                 fMinNCells=3; 
1381                 break;
1382         case 4: 
1383                 if (!fUseNCells) fUseNCells=1;
1384                 fMinNCells=4; 
1385                 break;
1386         case 5: 
1387                 if (!fUseNCells) fUseNCells=1;
1388                 fMinNCells=5; 
1389                 break;
1390         case 6: 
1391                 if (!fUseNCells) fUseNCells=1;
1392                 fMinNCells=6; 
1393                 break;
1394
1395         default:
1396                 AliError(Form("Min N cells Cut not defined %d",minNCells));
1397                 return kFALSE;
1398         }
1399         return kTRUE;
1400 }
1401
1402 //___________________________________________________________________
1403 Bool_t AliCaloPhotonCuts::SetMaxM02(Int_t maxM02)
1404 {
1405         switch(maxM02){
1406         case 0: 
1407                 if (!fUseM02) fUseM02=0;
1408                 fMaxM02=100;
1409                 break;
1410         case 1: 
1411                 if (!fUseM02) fUseM02=1;
1412                 fMaxM02=1.; 
1413                 break;
1414         case 2: 
1415                 if (!fUseM02) fUseM02=1;
1416                 fMaxM02=0.7; 
1417                 break;
1418         case 3: 
1419                 if (!fUseM02) fUseM02=1;
1420                 fMaxM02=0.5; 
1421                 break;
1422         case 4: 
1423                 if (!fUseM02) fUseM02=1;
1424                 fMaxM02=0.4; 
1425                 break;
1426         default:
1427                 AliError(Form("Max M02 Cut not defined %d",maxM02));
1428                 return kFALSE;
1429         }
1430         return kTRUE;
1431 }
1432
1433 //___________________________________________________________________
1434 Bool_t AliCaloPhotonCuts::SetMinM02(Int_t minM02)
1435 {
1436         switch(minM02){
1437         case 0: 
1438                 if (!fUseM02) fUseM02=0;
1439                 fMinM02=0;
1440                 break;
1441         case 1: 
1442                 if (!fUseM02) fUseM02=1;
1443                 fMinM02=0.002; 
1444                 break;
1445         case 2: 
1446                 if (!fUseM02) fUseM02=1;
1447                 fMinM02=0.2; 
1448                 break;
1449
1450         default:
1451                 AliError(Form("Min M02 not defined %d",minM02));
1452                 return kFALSE;
1453         }
1454         return kTRUE;
1455 }
1456
1457 //___________________________________________________________________
1458 Bool_t AliCaloPhotonCuts::SetMaxM20(Int_t maxM20)
1459 {
1460         switch(maxM20){
1461         case 0: 
1462                 if (!fUseM20) fUseM20=0;
1463                 fMaxM20=100;
1464                 break;
1465         case 1: 
1466                 if (!fUseM20) fUseM20=1;
1467                 fMaxM20=0.5; 
1468                 break;
1469         default:
1470                 AliError(Form("Max M20 Cut not defined %d",maxM20));
1471                 return kFALSE;
1472         }
1473         return kTRUE;
1474 }
1475
1476 //___________________________________________________________________
1477 Bool_t AliCaloPhotonCuts::SetMinM20(Int_t minM20)
1478 {
1479         switch(minM20){
1480         case 0: 
1481                 if (!fUseM20) fUseM20=0;
1482                 fMinM20=0;
1483                 break;
1484         case 1: 
1485                 if (!fUseM20) fUseM20=1;
1486                 fMinM20=0.002; 
1487                 break;
1488         default:
1489                 AliError(Form("Min M20 Cut not defined %d",minM20));
1490                 return kFALSE;
1491         }
1492         return kTRUE;
1493 }
1494
1495 //___________________________________________________________________
1496 Bool_t AliCaloPhotonCuts::SetDispersion(Int_t dispersion)
1497 {
1498         switch(dispersion){
1499         case 0: 
1500                 if (!fUseDispersion) fUseDispersion=0;
1501                 fMaxDispersion =100;
1502                 break;
1503         case 1: 
1504                 if (!fUseDispersion) fUseDispersion=1;
1505                 fMaxDispersion=2.; 
1506                 break;
1507         default:
1508                 AliError(Form("Maximum Dispersion Cut not defined %d",dispersion));
1509                 return kFALSE;
1510         }
1511         return kTRUE;
1512 }
1513
1514 //___________________________________________________________________
1515 Bool_t AliCaloPhotonCuts::SetNLM(Int_t nlm)
1516 {
1517         switch(nlm){
1518         case 0: 
1519                 if (!fUseNLM) fUseNLM=0;
1520                 fMinNLM =0;
1521                 fMaxNLM =100;
1522                 break;
1523         case 1: 
1524                 if (!fUseNLM) fUseNLM=1;
1525                 fMinNLM =0;
1526                 fMaxNLM =1;
1527                 break;
1528         default:
1529                 AliError(Form("NLM Cut not defined %d",nlm));
1530                 return kFALSE;
1531         }
1532         return kTRUE;
1533 }
1534         
1535 ///________________________________________________________________________
1536 TString AliCaloPhotonCuts::GetCutNumber(){
1537    // returns TString with current cut number
1538    TString a(kNCuts);
1539    for(Int_t ii=0;ii<kNCuts;ii++){
1540       a.Append(Form("%d",fCuts[ii]));
1541    }
1542    return a;
1543 }
1544         
1545