]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/GammaConv/AliCaloPhotonCuts.cxx
15ea53441ebe0129ace73c6d10f1d7ca41bdc6d7
[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(fHistDistanceTrackToClusterBeforeQA)fHistDistanceTrackToClusterBeforeQA->Fill(TMath::Sqrt(dR2));
822             if(fHistClusterdEtadPhiBeforeQA) fHistClusterdEtadPhiBeforeQA->Fill(dEta, dPhi);
823
824             Float_t clusM02 = (Float_t)cluster->GetM02();
825             Float_t clusM20 = (Float_t)cluster->GetM20();
826             if(fExtendedMatching){
827                 if(fHistClusterdEtadPhiPosTracksBeforeQA && inTrack->Charge() > 0) fHistClusterdEtadPhiPosTracksBeforeQA->Fill(dEta, dPhi);
828                 if(fHistClusterdEtadPhiNegTracksBeforeQA && inTrack->Charge() < 0) fHistClusterdEtadPhiNegTracksBeforeQA->Fill(dEta, dPhi);
829                 fHistClusterdEtadPtBeforeQA->Fill(dEta, inTrack->Pt());
830                 fHistClusterdPhidPtBeforeQA->Fill(dPhi, inTrack->Pt());
831                 if(abs(dPhi) > 0.05) fHistClusterM20Pt_dPhiBeforeQA->Fill(clusM20, inTrack->Pt());
832                 if(abs(dPhi) > 0.05) fHistClusterM02Pt_dPhiBeforeQA->Fill(clusM02, inTrack->Pt());
833                 fHistClusterM20M02BeforeQA->Fill(clusM20, clusM02);
834             }
835
836                         if(dR2 < fMinDistTrackToCluster*fMinDistTrackToCluster){
837                                 matched = kTRUE;
838                         } else {
839                 if(fHistDistanceTrackToClusterAfterQA)fHistDistanceTrackToClusterAfterQA->Fill(TMath::Sqrt(dR2));
840                 if(fHistClusterdEtadPhiAfterQA) fHistClusterdEtadPhiAfterQA->Fill(dEta, dPhi);
841                 if(fHistClusterRAfterQA) fHistClusterRAfterQA->Fill(clusterR);
842                 if(fExtendedMatching){
843                     fHistClusterM20M02AfterQA->Fill(clusM20, clusM02);
844                 }
845                         }       
846                 }
847                 delete trackParam;
848         }
849
850         return matched;
851
852 }
853
854 //____________________________________________________________________________________________
855
856
857 ///________________________________________________________________________
858 Bool_t AliCaloPhotonCuts::UpdateCutString() {
859    ///Update the cut string (if it has been created yet)
860
861    if(fCutString && fCutString->GetString().Length() == kNCuts) {
862       fCutString->SetString(GetCutNumber());
863    } else {
864       return kFALSE;
865    }
866    return kTRUE;
867 }
868
869 ///________________________________________________________________________
870 Bool_t AliCaloPhotonCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) {
871         // Initialize Cuts from a given Cut string
872         AliInfo(Form("Set CaloCut Number: %s",analysisCutSelection.Data()));
873         if(analysisCutSelection.Length()!=kNCuts) {
874                 AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
875                 return kFALSE;
876         }
877         if(!analysisCutSelection.IsDigit()){
878                 AliError("Cut selection contains characters");
879                 return kFALSE;
880         }
881
882         const char *cutSelection = analysisCutSelection.Data();
883         #define ASSIGNARRAY(i)  fCuts[i] = cutSelection[i] - '0'
884         for(Int_t ii=0;ii<kNCuts;ii++){
885                 ASSIGNARRAY(ii);
886         }
887
888         // Set Individual Cuts
889         for(Int_t ii=0;ii<kNCuts;ii++){
890                 if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
891         }
892         PrintCutsWithValues();
893         return kTRUE;
894 }
895
896 ///________________________________________________________________________
897 Bool_t AliCaloPhotonCuts::SetCut(cutIds cutID, const Int_t value) {
898         ///Set individual cut ID
899
900         switch (cutID) {                
901                 
902                 case kClusterType:
903                         if( SetClusterTypeCut(value)) {
904                                 fCuts[kClusterType] = value;
905                                 UpdateCutString();
906                                 return kTRUE;
907                         } else return kFALSE;
908                 
909                 case kEtaMin:
910                         if( SetMinEtaCut(value)) {
911                                 fCuts[kEtaMin] = value;
912                                 UpdateCutString();
913                                 return kTRUE;
914                         } else return kFALSE;
915
916                 case kEtaMax:
917                         if( SetMaxEtaCut(value)) {
918                                 fCuts[kEtaMax] = value;
919                                 UpdateCutString();
920                                 return kTRUE;
921                         } else return kFALSE;
922
923                 case kPhiMin:
924                         if( SetMinPhiCut(value)) {
925                                 fCuts[kPhiMin] = value;
926                                 UpdateCutString();
927                                 return kTRUE;
928                         } else return kFALSE;
929
930                 case kPhiMax:
931                         if( SetMaxPhiCut(value)) {
932                                 fCuts[kPhiMax] = value;
933                                 UpdateCutString();
934                                 return kTRUE;
935                         } else return kFALSE;
936
937                 case kDistanceToBadChannel:
938                         if( SetDistanceToBadChannelCut(value)) {
939                                 fCuts[kDistanceToBadChannel] = value;
940                                 UpdateCutString();
941                                 return kTRUE;
942                         } else return kFALSE;
943
944                 case kTiming:
945                         if( SetTimingCut(value)) {
946                                 fCuts[kTiming] = value;
947                                 UpdateCutString();
948                                 return kTRUE;
949                         } else return kFALSE;
950
951                 case kTrackMatching:
952                         if( SetTrackMatchingCut(value)) {
953                                 fCuts[kTrackMatching] = value;
954                                 UpdateCutString();
955                                 return kTRUE;
956                         } else return kFALSE;
957
958                 case kExoticCell:
959                         if( SetExoticCellCut(value)) {
960                                 fCuts[kExoticCell] = value;
961                                 UpdateCutString();
962                                 return kTRUE;
963                         } else return kFALSE;
964
965                 case kMinEnery:
966                         if( SetMinEnergyCut(value)) {
967                                 fCuts[kMinEnery] = value;
968                                 UpdateCutString();
969                                 return kTRUE;
970                         } else return kFALSE;
971
972                 case kNMinCells:
973                         if( SetMinNCellsCut(value)) {
974                                 fCuts[kNMinCells] = value;
975                                 UpdateCutString();
976                                 return kTRUE;
977                         } else return kFALSE;
978                         
979                 case kMinM02:
980                         if( SetMinM02(value)) {
981                                 fCuts[kMinM02] = value;
982                                 UpdateCutString();
983                                 return kTRUE;
984                         } else return kFALSE;
985
986                 case kMaxM02:
987                         if( SetMaxM02(value)) {
988                                 fCuts[kMaxM02] = value;
989                                 UpdateCutString();
990                                 return kTRUE;
991                         } else return kFALSE;
992                 
993                 case kMinM20:
994                         if( SetMinM20(value)) {
995                                 fCuts[kMinM20] = value;
996                                 UpdateCutString();
997                                 return kTRUE;
998                         } else return kFALSE;
999
1000                 case kMaxM20:
1001                         if( SetMaxM20(value)) {
1002                                 fCuts[kMaxM20] = value;
1003                                 UpdateCutString();
1004                                 return kTRUE;
1005                         } else return kFALSE;
1006
1007                 case kDispersion:
1008                         if( SetDispersion(value)) {
1009                                 fCuts[kDispersion] = value;
1010                                 UpdateCutString();
1011                                 return kTRUE;
1012                         } else return kFALSE;
1013
1014                 case kNLM:
1015                         if( SetNLM(value)) {
1016                                 fCuts[kNLM] = value;
1017                                 UpdateCutString();
1018                                 return kTRUE;
1019                         } else return kFALSE;
1020
1021                 case kNCuts:
1022                         AliError("Cut id out of range");
1023                         return kFALSE;
1024         }
1025
1026         AliError("Cut id %d not recognized");
1027         return kFALSE;
1028
1029
1030 }
1031 ///________________________________________________________________________
1032 void AliCaloPhotonCuts::PrintCuts() {
1033    // Print out current Cut Selection
1034    for(Int_t ic = 0; ic < kNCuts; ic++) {
1035       printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
1036    }
1037 }
1038
1039 void AliCaloPhotonCuts::PrintCutsWithValues() {
1040         // Print out current Cut Selection with value
1041         printf("\nCluster cutnumber \n");
1042         for(Int_t ic = 0; ic < kNCuts; ic++) {
1043                 printf("%d",fCuts[ic]);
1044         }
1045         printf("\n\n");
1046
1047         printf("Acceptance cuts: \n");
1048         if (fClusterType == 0) printf("\tall calorimeter clusters are used\n");
1049         if (fClusterType == 1) printf("\tEMCAL calorimeter clusters are used\n");
1050         if (fClusterType == 2) printf("\tPHOS calorimeter clusters are used\n");
1051         if (fUseEtaCut) printf("\t%3.2f < eta_{cluster} < %3.2f\n", fMinEtaCut, fMaxEtaCut );
1052         if (fUsePhiCut) printf("\t%3.2f < phi_{cluster} < %3.2f\n", fMinPhiCut, fMaxPhiCut );
1053         if (fUseDistanceToBadChannel) printf("\tcut on exotics applied \n");
1054         
1055         printf("Cluster Quality cuts: \n");
1056         if (fUseTimeDiff) printf("\t time difference < %3.2f\n", fMaxTimeDiff );
1057         if (fUseDistTrackToCluster) printf("\tmin distance to track > %3.2f\n", fMinDistTrackToCluster );
1058         if (fUseExoticCell)printf("\t min distance to track > %3.2f\n", fMinDistTrackToCluster );
1059     if (fUseMinEnergy)printf("\t E_{cluster} > %3.2f\n", fMinEnergy );
1060         if (fUseNCells) printf("\t number of cells per cluster >= %d\n", fMinNCells );
1061         if (fUseM02) printf("\t %3.2f < M02 < %3.2f\n", fMinM02, fMaxM02 );
1062         if (fUseM20) printf("\t %3.2f < M20 < %3.2f\n", fMinM20, fMaxM20 );
1063         if (fUseDispersion) printf("\t dispersion < %3.2f\n", fMaxDispersion );
1064         if (fUseNLM) printf("\t %d < NLM < %d\n", fMinNLM, fMaxNLM );
1065         
1066 }
1067
1068 // EMCAL acceptance 2011
1069 // 1.39626, 3.125 (phi)
1070 // -0.66687,,0.66465
1071
1072
1073 ///________________________________________________________________________
1074 Bool_t AliCaloPhotonCuts::SetClusterTypeCut(Int_t clusterType)
1075 {   // Set Cut
1076         switch(clusterType){
1077         case 0: // all clusters
1078                 fClusterType=0;
1079                 break;
1080         case 1: // EMCAL clusters
1081                 fClusterType=1;
1082                 break;
1083         case 2: // PHOS clusters
1084                 fClusterType=2;
1085                 break;
1086         default:
1087                 AliError(Form("ClusterTypeCut not defined %d",clusterType));
1088                 return kFALSE;
1089         }
1090         return kTRUE;
1091 }
1092
1093 //___________________________________________________________________
1094 Bool_t AliCaloPhotonCuts::SetMinEtaCut(Int_t minEta)
1095 {
1096         switch(minEta){
1097         case 0:
1098                 if (!fUseEtaCut) fUseEtaCut=0;
1099                 fMinEtaCut=-10.;
1100                 break;
1101         case 1:
1102                 if (!fUseEtaCut) fUseEtaCut=1;
1103                 fMinEtaCut=-0.6687;
1104                 break;
1105         case 2: 
1106                 if (!fUseEtaCut) fUseEtaCut=1;
1107                 fMinEtaCut=-0.5;
1108                 break;
1109         case 3: 
1110                 if (!fUseEtaCut) fUseEtaCut=1;
1111                 fMinEtaCut=-2;
1112                 break;
1113         default:
1114                 AliError(Form("MinEta Cut not defined %d",minEta));
1115                 return kFALSE;
1116         }
1117         return kTRUE;
1118 }
1119
1120
1121 //___________________________________________________________________
1122 Bool_t AliCaloPhotonCuts::SetMaxEtaCut(Int_t maxEta)
1123 {
1124         switch(maxEta){
1125         case 0: 
1126                 if (!fUseEtaCut) fUseEtaCut=0;
1127                 fMaxEtaCut=10;
1128                 break;          
1129         case 1:
1130                 if (!fUseEtaCut) fUseEtaCut=1;
1131                 fMaxEtaCut=0.66465;
1132                 break;
1133         case 2: 
1134                 if (!fUseEtaCut) fUseEtaCut=1;
1135                 fMaxEtaCut=0.5;
1136                 break;
1137         case 3: 
1138                 if (!fUseEtaCut) fUseEtaCut=1;
1139                 fMaxEtaCut=2;
1140                 break;
1141         default:
1142                 AliError(Form("MaxEta Cut not defined %d",maxEta));
1143                 return kFALSE;
1144         }
1145         return kTRUE;
1146 }
1147
1148 //___________________________________________________________________
1149 Bool_t AliCaloPhotonCuts::SetMinPhiCut(Int_t minPhi)
1150 {
1151         switch(minPhi){
1152         case 0: 
1153                 if (!fUsePhiCut) fUsePhiCut=0;
1154                 fMinPhiCut=-10000;
1155                 break;
1156         case 1: 
1157                 if (!fUsePhiCut) fUsePhiCut=1;
1158                 fMinPhiCut=1.39626;
1159                 break;
1160         default:
1161                 AliError(Form("MinPhi Cut not defined %d",minPhi));
1162                 return kFALSE;
1163         }
1164         return kTRUE;
1165 }
1166
1167 //___________________________________________________________________
1168 Bool_t AliCaloPhotonCuts::SetMaxPhiCut(Int_t maxPhi)
1169 {
1170         switch(maxPhi){
1171         case 0: 
1172                 if (!fUsePhiCut) fUsePhiCut=0;
1173                 fMaxPhiCut=10000;
1174                 break;
1175         case 1: 
1176                 if (!fUsePhiCut) fUsePhiCut=1;
1177                 fMaxPhiCut=3.125;
1178                 break;
1179         default:
1180                 AliError(Form("Max Phi Cut not defined %d",maxPhi));
1181                 return kFALSE;
1182         }
1183         return kTRUE;
1184 }
1185
1186 //___________________________________________________________________
1187 Bool_t AliCaloPhotonCuts::SetDistanceToBadChannelCut(Int_t distanceToBadChannel)
1188 {
1189         switch(distanceToBadChannel){
1190         case 0: 
1191                 fUseDistanceToBadChannel=0;
1192                 fMinDistanceToBadChannel=0;
1193                 break;
1194         case 1: 
1195                 if (!fUseDistanceToBadChannel) fUseDistanceToBadChannel=1;
1196                 fMinDistanceToBadChannel=5;
1197                 break;
1198         default:
1199                 AliError(Form("minimum distance to bad channel Cut not defined %d",distanceToBadChannel));
1200                 return kFALSE;
1201         }
1202         return kTRUE;
1203 }
1204
1205 //___________________________________________________________________
1206 Bool_t AliCaloPhotonCuts::SetTimingCut(Int_t timing)
1207 {
1208         switch(timing){
1209         case 0: 
1210                 fUseTimeDiff=0;
1211                 fMaxTimeDiff=500;
1212                 break;
1213         case 1: 
1214                 if (!fUseTimeDiff) fUseTimeDiff=1;
1215                 fMaxTimeDiff=10e-7; //1000ns
1216                 break;
1217         case 2: 
1218                 if (!fUseTimeDiff) fUseTimeDiff=1;
1219                 fMaxTimeDiff=50e-8; //500ns
1220                 break;
1221         case 3: 
1222                 if (!fUseTimeDiff) fUseTimeDiff=1;
1223                 fMaxTimeDiff=20e-8; //200ns
1224                 break;
1225         case 4: 
1226                 if (!fUseTimeDiff) fUseTimeDiff=1;
1227                 fMaxTimeDiff=10e-8; //100ns
1228                 break;
1229         case 5: 
1230                 if (!fUseTimeDiff) fUseTimeDiff=1;
1231                 fMaxTimeDiff=50e-9; //50ns
1232                 break;
1233
1234         default:
1235                 AliError(Form("Timing Cut not defined %d",timing));
1236                 return kFALSE;
1237         }
1238         return kTRUE;
1239 }
1240
1241 //___________________________________________________________________
1242 Bool_t AliCaloPhotonCuts::SetTrackMatchingCut(Int_t trackMatching)
1243 {
1244         switch(trackMatching){
1245         case 0: 
1246                 fUseDistTrackToCluster=0;
1247                 fMinDistTrackToCluster=0;
1248                 break;
1249         case 1: 
1250                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1251                 fMinDistTrackToCluster= 0.03;   //0.04;  
1252                 break;
1253         case 2: 
1254                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1255                 fMinDistTrackToCluster= 0.035;  //0.05; 
1256                 break;
1257         case 3: 
1258                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1259                 fMinDistTrackToCluster= 0.04;   //0.1;  
1260                 break;
1261         case 4: 
1262                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1263                 fMinDistTrackToCluster= 0.045;  //0.13; 
1264                 break;
1265         case 5: 
1266                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1267                 fMinDistTrackToCluster= 0.05;   //0.15 
1268                 break;
1269         case 6: 
1270                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1271                 fMinDistTrackToCluster= 0.055;  //0.2; 
1272                 break;
1273         case 7: 
1274                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1275                 fMinDistTrackToCluster= 0.06;   //0.3; 
1276                 break;
1277         case 8: 
1278                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1279                 fMinDistTrackToCluster= 0.07;   //0.4; 
1280                 break;
1281         case 9: 
1282                 if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
1283                 fMinDistTrackToCluster= 0.1;    //0.5; 
1284                 break;
1285
1286         default:
1287                 AliError(Form("Track Matching Cut not defined %d",trackMatching));
1288                 return kFALSE;
1289         }
1290         return kTRUE;
1291 }
1292
1293 //___________________________________________________________________
1294 Bool_t AliCaloPhotonCuts::SetExoticCellCut(Int_t exoticCell)
1295 {
1296         switch(exoticCell){
1297         case 0: 
1298                 fUseExoticCell=0;
1299                 fExoticCell=0;
1300                 break;
1301         case 1: 
1302                 if (!fUseExoticCell) fUseExoticCell=1;
1303                 fExoticCell=5; 
1304                 break;
1305         default:
1306                 AliError(Form("Exotic cell Cut not defined %d",exoticCell));
1307                 return kFALSE;
1308         }
1309         return kTRUE;
1310 }
1311                 
1312 //___________________________________________________________________
1313 Bool_t AliCaloPhotonCuts::SetMinEnergyCut(Int_t minEnergy)
1314 {
1315         switch(minEnergy){
1316         case 0: 
1317                 if (!fUseMinEnergy) fUseMinEnergy=0;
1318                 fMinEnergy=0;
1319                 break;
1320         case 1: 
1321                 if (!fUseMinEnergy) fUseMinEnergy=1;
1322                 fMinEnergy=0.05; 
1323                 break;
1324         case 2: 
1325                 if (!fUseMinEnergy) fUseMinEnergy=1;
1326                 fMinEnergy=0.1; 
1327                 break;
1328         case 3: 
1329                 if (!fUseMinEnergy) fUseMinEnergy=1;
1330                 fMinEnergy=0.15; 
1331                 break;
1332         case 4: 
1333                 if (!fUseMinEnergy) fUseMinEnergy=1;
1334                 fMinEnergy=0.2; 
1335                 break;
1336         case 5: 
1337                 if (!fUseMinEnergy) fUseMinEnergy=1;
1338                 fMinEnergy=0.3; 
1339                 break;
1340         case 6: 
1341                 if (!fUseMinEnergy) fUseMinEnergy=1;
1342                 fMinEnergy=0.4; 
1343                 break;
1344         case 7: 
1345                 if (!fUseMinEnergy) fUseMinEnergy=1;
1346                 fMinEnergy=0.5; 
1347                 break;
1348         case 8: 
1349                 if (!fUseMinEnergy) fUseMinEnergy=1;
1350                 fMinEnergy=0.75; 
1351                 break;
1352         case 9: 
1353                 if (!fUseMinEnergy) fUseMinEnergy=1;
1354                 fMinEnergy=1.; 
1355                 break;
1356         default:
1357                 AliError(Form("Minimum Energy Cut not defined %d",minEnergy));
1358                 return kFALSE;
1359         }
1360         return kTRUE;
1361 }
1362                 
1363 //___________________________________________________________________
1364 Bool_t AliCaloPhotonCuts::SetMinNCellsCut(Int_t minNCells)
1365 {
1366         switch(minNCells){
1367         case 0:
1368                 if (!fUseNCells) fUseNCells=0;
1369                 fMinNCells=0;
1370                 break;
1371         case 1: 
1372                 if (!fUseNCells) fUseNCells=1;
1373                 fMinNCells=1; 
1374                 break;
1375         case 2: 
1376                 if (!fUseNCells) fUseNCells=1;
1377                 fMinNCells=2; 
1378                 break;
1379         case 3: 
1380                 if (!fUseNCells) fUseNCells=1;
1381                 fMinNCells=3; 
1382                 break;
1383         case 4: 
1384                 if (!fUseNCells) fUseNCells=1;
1385                 fMinNCells=4; 
1386                 break;
1387         case 5: 
1388                 if (!fUseNCells) fUseNCells=1;
1389                 fMinNCells=5; 
1390                 break;
1391         case 6: 
1392                 if (!fUseNCells) fUseNCells=1;
1393                 fMinNCells=6; 
1394                 break;
1395
1396         default:
1397                 AliError(Form("Min N cells Cut not defined %d",minNCells));
1398                 return kFALSE;
1399         }
1400         return kTRUE;
1401 }
1402
1403 //___________________________________________________________________
1404 Bool_t AliCaloPhotonCuts::SetMaxM02(Int_t maxM02)
1405 {
1406         switch(maxM02){
1407         case 0: 
1408                 if (!fUseM02) fUseM02=0;
1409                 fMaxM02=100;
1410                 break;
1411         case 1: 
1412                 if (!fUseM02) fUseM02=1;
1413                 fMaxM02=1.; 
1414                 break;
1415         case 2: 
1416                 if (!fUseM02) fUseM02=1;
1417                 fMaxM02=0.7; 
1418                 break;
1419         case 3: 
1420                 if (!fUseM02) fUseM02=1;
1421                 fMaxM02=0.5; 
1422                 break;
1423         case 4: 
1424                 if (!fUseM02) fUseM02=1;
1425                 fMaxM02=0.4; 
1426                 break;
1427         default:
1428                 AliError(Form("Max M02 Cut not defined %d",maxM02));
1429                 return kFALSE;
1430         }
1431         return kTRUE;
1432 }
1433
1434 //___________________________________________________________________
1435 Bool_t AliCaloPhotonCuts::SetMinM02(Int_t minM02)
1436 {
1437         switch(minM02){
1438         case 0: 
1439                 if (!fUseM02) fUseM02=0;
1440                 fMinM02=0;
1441                 break;
1442         case 1: 
1443                 if (!fUseM02) fUseM02=1;
1444                 fMinM02=0.002; 
1445                 break;
1446         default:
1447                 AliError(Form("Min M02 not defined %d",minM02));
1448                 return kFALSE;
1449         }
1450         return kTRUE;
1451 }
1452
1453 //___________________________________________________________________
1454 Bool_t AliCaloPhotonCuts::SetMaxM20(Int_t maxM20)
1455 {
1456         switch(maxM20){
1457         case 0: 
1458                 if (!fUseM20) fUseM20=0;
1459                 fMaxM20=100;
1460                 break;
1461         case 1: 
1462                 if (!fUseM20) fUseM20=1;
1463                 fMaxM20=0.5; 
1464                 break;
1465         default:
1466                 AliError(Form("Max M20 Cut not defined %d",maxM20));
1467                 return kFALSE;
1468         }
1469         return kTRUE;
1470 }
1471
1472 //___________________________________________________________________
1473 Bool_t AliCaloPhotonCuts::SetMinM20(Int_t minM20)
1474 {
1475         switch(minM20){
1476         case 0: 
1477                 if (!fUseM20) fUseM20=0;
1478                 fMinM20=0;
1479                 break;
1480         case 1: 
1481                 if (!fUseM20) fUseM20=1;
1482                 fMinM20=0.002; 
1483                 break;
1484         default:
1485                 AliError(Form("Min M20 Cut not defined %d",minM20));
1486                 return kFALSE;
1487         }
1488         return kTRUE;
1489 }
1490
1491 //___________________________________________________________________
1492 Bool_t AliCaloPhotonCuts::SetDispersion(Int_t dispersion)
1493 {
1494         switch(dispersion){
1495         case 0: 
1496                 if (!fUseDispersion) fUseDispersion=0;
1497                 fMaxDispersion =100;
1498                 break;
1499         case 1: 
1500                 if (!fUseDispersion) fUseDispersion=1;
1501                 fMaxDispersion=2.; 
1502                 break;
1503         default:
1504                 AliError(Form("Maximum Dispersion Cut not defined %d",dispersion));
1505                 return kFALSE;
1506         }
1507         return kTRUE;
1508 }
1509
1510 //___________________________________________________________________
1511 Bool_t AliCaloPhotonCuts::SetNLM(Int_t nlm)
1512 {
1513         switch(nlm){
1514         case 0: 
1515                 if (!fUseNLM) fUseNLM=0;
1516                 fMinNLM =0;
1517                 fMaxNLM =100;
1518                 break;
1519         case 1: 
1520                 if (!fUseNLM) fUseNLM=1;
1521                 fMinNLM =0;
1522                 fMaxNLM =1;
1523                 break;
1524         default:
1525                 AliError(Form("NLM Cut not defined %d",nlm));
1526                 return kFALSE;
1527         }
1528         return kTRUE;
1529 }
1530         
1531 ///________________________________________________________________________
1532 TString AliCaloPhotonCuts::GetCutNumber(){
1533    // returns TString with current cut number
1534    TString a(kNCuts);
1535    for(Int_t ii=0;ii<kNCuts;ii++){
1536       a.Append(Form("%d",fCuts[ii]));
1537    }
1538    return a;
1539 }
1540         
1541