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