TENDER becomes Tender, removing .so
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliPrimaryPionCuts.cxx
CommitLineData
209b710e 1
2/**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Authors: Friederike Bock *
6 * Version 1.0 *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17////////////////////////////////////////////////
18//---------------------------------------------
19// Class handling all kinds of selection cuts for
20// Gamma Conversion analysis
21//---------------------------------------------
22////////////////////////////////////////////////
23
24
25#include "AliPrimaryPionCuts.h"
26#include "AliAODConversionPhoton.h"
27#include "AliKFVertex.h"
28#include "AliAODTrack.h"
29#include "AliESDtrack.h"
30#include "AliAnalysisManager.h"
31#include "AliInputEventHandler.h"
32#include "AliMCEventHandler.h"
33#include "AliAODHandler.h"
34#include "AliPIDResponse.h"
35#include "TH1.h"
36#include "TH2.h"
37#include "AliStack.h"
38#include "TObjString.h"
39#include "AliAODEvent.h"
40#include "AliESDEvent.h"
41#include "TList.h"
42class iostream;
43
44using namespace std;
45
46ClassImp(AliPrimaryPionCuts)
47
48
49const char* AliPrimaryPionCuts::fgkCutNames[AliPrimaryPionCuts::kNCuts] = {
42fe34e2 50 "kEtaCut", // 0
51 "kClsITSCut", // 1
52 "kClsTPCCut", // 2
53 "kDCAcut", // 3
54 "kPtCut", // 4
55 "kPiDedxSigmaITSCut", // 5
56 "kPiDedxSigmaTPCCut", // 6
57 "kPiTOFSigmaCut", // 7
58 "kMassCut" // 8
209b710e 59};
60
61//________________________________________________________________________
62AliPrimaryPionCuts::AliPrimaryPionCuts(const char *name,const char *title) : AliAnalysisCuts(name,title),
63 fHistograms(NULL),
64 fPIDResponse(NULL),
65 fEsdTrackCuts(NULL),
66 fEtaCut(0.9),
67 fEtaShift(0.0),
68 fDoEtaCut(kFALSE),
69 fPtCut(0.0),
70 fMinClsTPC(0), // minimum clusters in the TPC
71 fMinClsTPCToF(0), // minimum clusters to findable clusters
72 fDodEdxSigmaITSCut(kFALSE),
73 fDodEdxSigmaTPCCut(kTRUE),
74 fDoTOFsigmaCut(kFALSE), // RRnewTOF
75 fPIDnSigmaAbovePionLineITS(100),
76 fPIDnSigmaBelowPionLineITS(-100),
77 fPIDnSigmaAbovePionLineTPC(100),
78 fPIDnSigmaBelowPionLineTPC(-100),
79 fPIDnSigmaAbovePionLineTOF(100), // RRnewTOF
80 fPIDnSigmaBelowPionLineTOF(-100), // RRnewTOF
81 fUseCorrectedTPCClsInfo(kFALSE),
82 fUseTOFpid(kFALSE),
83 fRequireTOF(kFALSE),
d9d6352b 84 fDoMassCut(kFALSE),
85 fMassCut(10),
209b710e 86 fDoWeights(kFALSE),
87 fCutString(NULL),
88 fHistCutIndex(NULL),
89 fHistdEdxCuts(NULL),
90 fHistITSdEdxbefore(NULL),
91 fHistITSdEdxafter(NULL),
92 fHistTPCdEdxbefore(NULL),
93 fHistTPCdEdxafter(NULL),
94 fHistTPCdEdxSignalbefore(NULL),
95 fHistTPCdEdxSignalafter(NULL),
96 fHistTOFbefore(NULL),
97 fHistTOFafter(NULL),
98 fHistTrackDCAxyPtbefore(NULL),
99 fHistTrackDCAxyPtafter(NULL),
100 fHistTrackDCAzPtbefore(NULL),
101 fHistTrackDCAzPtafter(NULL),
102 fHistTrackNFindClsPtTPCbefore(NULL),
2c75809c 103 fHistTrackNFindClsPtTPCafter(NULL),
104 fStringITSClusterCut("")
209b710e 105{
106 InitPIDResponse();
107 for(Int_t jj=0;jj<kNCuts;jj++){ fCuts[jj]=0; }
108 fCutString=new TObjString((GetCutNumber()).Data());
109
110 // Using standard function for setting Cuts
111 Bool_t selectPrimaries=kFALSE;
358b4979 112 if (fEsdTrackCuts==NULL)fEsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
209b710e 113}
114
115//________________________________________________________________________
116AliPrimaryPionCuts::~AliPrimaryPionCuts() {
117 // Destructor
118 //Deleting fHistograms leads to seg fault it it's added to output collection of a task
119 // if(fHistograms)
120 // delete fHistograms;
121 // fHistograms = NULL;
122
123 if(fCutString != NULL){
124 delete fCutString;
125 fCutString = NULL;
126 }
127}
128
129//________________________________________________________________________
130void AliPrimaryPionCuts::InitCutHistograms(TString name, Bool_t preCut,TString cutNumber){
131
132 // Initialize Cut Histograms for QA (only initialized and filled if function is called)
133
134 TString cutName = "";
135
136 if( cutNumber==""){
137 cutName = GetCutNumber().Data();
138 }
139 else {
140 cutName = cutNumber.Data();
141 }
142
143 if(fHistograms != NULL){
144 delete fHistograms;
145 fHistograms=NULL;
146 }
147 if(fHistograms==NULL){
148 fHistograms=new TList();
149 if(name=="")fHistograms->SetName(Form("PionCuts_%s",cutName.Data()));
150 else fHistograms->SetName(Form("%s_%s",name.Data(),cutName.Data()));
151 }
152
153
154 fHistCutIndex=new TH1F(Form("IsPionSelected %s",cutName.Data()),"IsPionSelected",10,-0.5,9.5);
155 fHistCutIndex->GetXaxis()->SetBinLabel(kPionIn+1,"in");
156 fHistCutIndex->GetXaxis()->SetBinLabel(kNoTracks+1,"no tracks");
157 fHistCutIndex->GetXaxis()->SetBinLabel(kTrackCuts+1,"Track cuts");
158 fHistCutIndex->GetXaxis()->SetBinLabel(kdEdxCuts+1,"dEdx");
159 fHistCutIndex->GetXaxis()->SetBinLabel(kPionOut+1,"out");
160 fHistograms->Add(fHistCutIndex);
161
162 // dEdx Cuts
163 fHistdEdxCuts=new TH1F(Form("dEdxCuts %s",cutName.Data()),"dEdxCuts",5,-0.5,4.5);
164 fHistdEdxCuts->GetXaxis()->SetBinLabel(1,"in");
165 fHistdEdxCuts->GetXaxis()->SetBinLabel(2,"ITSpion");
166 fHistdEdxCuts->GetXaxis()->SetBinLabel(3,"TPCpion");
167 fHistdEdxCuts->GetXaxis()->SetBinLabel(4,"TOFpion");
168 fHistdEdxCuts->GetXaxis()->SetBinLabel(5,"out");
169 fHistograms->Add(fHistdEdxCuts);
170
171 TAxis *axisBeforeITS = NULL;
172 TAxis *axisBeforedEdx = NULL;
173 TAxis *axisBeforeTOF = NULL;
174 TAxis *axisBeforedEdxSignal = NULL;
175
176 if(preCut){
177 fHistITSdEdxbefore=new TH2F(Form("Pion_ITS_before %s",cutName.Data()),"ITS dEdx pion before" ,150,0.05,20,400,-10,10);
178 fHistograms->Add(fHistITSdEdxbefore);
179 axisBeforeITS = fHistITSdEdxbefore->GetXaxis();
180
181 fHistTPCdEdxbefore=new TH2F(Form("Pion_dEdx_before %s",cutName.Data()),"dEdx pion before" ,150,0.05,20,400,-10,10);
182 fHistograms->Add(fHistTPCdEdxbefore);
183 axisBeforedEdx = fHistTPCdEdxbefore->GetXaxis();
184
185 fHistTPCdEdxSignalbefore=new TH2F(Form("Pion_dEdxSignal_before %s",cutName.Data()),"dEdx pion signal before" ,150,0.05,20.0,800,0.0,200);
186 fHistograms->Add(fHistTPCdEdxSignalbefore);
187 axisBeforedEdxSignal = fHistTPCdEdxSignalbefore->GetXaxis();
188
189 fHistTOFbefore=new TH2F(Form("Pion_TOF_before %s",cutName.Data()),"TOF pion before" ,150,0.05,20,400,-6,10);
190 fHistograms->Add(fHistTOFbefore);
191 axisBeforeTOF = fHistTOFbefore->GetXaxis();
192
193 fHistTrackDCAxyPtbefore = new TH2F(Form("hTrack_DCAxy_Pt_before %s",cutName.Data()),"DCAxy Vs Pt of tracks before",800,-4.0,4.0,400,0.,10.);
194 fHistograms->Add(fHistTrackDCAxyPtbefore);
195
196 fHistTrackDCAzPtbefore = new TH2F(Form("hTrack_DCAz_Pt_before %s",cutName.Data()), "DCAz Vs Pt of tracks before",800,-4.0,4.0,400,0.,10.);
197 fHistograms->Add(fHistTrackDCAzPtbefore);
198
199 fHistTrackNFindClsPtTPCbefore = new TH2F(Form("hTrack_NFindCls_Pt_TPC_before %s",cutName.Data()),"Track: N Findable Cls TPC Vs Pt before",100,0,1,400,0.,10.);
200 fHistograms->Add(fHistTrackNFindClsPtTPCbefore);
201 }
202
203 fHistITSdEdxafter=new TH2F(Form("Pion_ITS_after %s",cutName.Data()),"ITS dEdx pion after" ,150,0.05,20,400, -10,10);
204 fHistograms->Add(fHistITSdEdxafter);
205
206 fHistTPCdEdxafter=new TH2F(Form("Pion_dEdx_after %s",cutName.Data()),"dEdx pion after" ,150,0.05,20,400, -10,10);
207 fHistograms->Add(fHistTPCdEdxafter);
208
209 fHistTPCdEdxSignalafter=new TH2F(Form("Pion_dEdxSignal_after %s",cutName.Data()),"dEdx pion signal after" ,150,0.05,20.0,800,0.0,200);
210 fHistograms->Add(fHistTPCdEdxSignalafter);
211
212 fHistTOFafter=new TH2F(Form("Pion_TOF_after %s",cutName.Data()),"TOF pion after" ,150,0.05,20,400,-6,10);
213 fHistograms->Add(fHistTOFafter);
214
215 fHistTrackDCAxyPtafter = new TH2F(Form("hTrack_DCAxy_Pt_after %s",cutName.Data()),"DCAxy Vs Pt of tracks after",800,-4.0,4.0,400,0.,10.);
216 fHistograms->Add(fHistTrackDCAxyPtafter);
217
218 fHistTrackDCAzPtafter = new TH2F(Form("hTrack_DCAz_Pt_after %s",cutName.Data()), "DCAz Vs Pt of tracks after",800,-4.0,4.0,400,0.,10.);
219 fHistograms->Add(fHistTrackDCAzPtafter);
220
221 fHistTrackNFindClsPtTPCafter = new TH2F(Form("hTrack_NFindCls_Pt_TPC_after %s",cutName.Data()),"Track: N Findable Cls TPC Vs Pt after",100,0,1,400,0.,10.);
222 fHistograms->Add(fHistTrackNFindClsPtTPCafter);
223
224 TAxis *AxisAfter = fHistTPCdEdxafter->GetXaxis();
225 Int_t bins = AxisAfter->GetNbins();
226 Double_t from = AxisAfter->GetXmin();
227 Double_t to = AxisAfter->GetXmax();
228 Double_t *newBins = new Double_t[bins+1];
229 newBins[0] = from;
230 Double_t factor = TMath::Power(to/from, 1./bins);
231 for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1];
232 AxisAfter->Set(bins, newBins);
233 AxisAfter = fHistTOFafter->GetXaxis();
234 AxisAfter->Set(bins, newBins);
235 AxisAfter = fHistITSdEdxafter->GetXaxis();
236 AxisAfter->Set(bins,newBins);
237 AxisAfter = fHistTPCdEdxSignalafter->GetXaxis();
238 AxisAfter->Set(bins,newBins);
239
240 if(preCut){
241 axisBeforeITS->Set(bins, newBins);
242 axisBeforedEdx->Set(bins, newBins);
243 axisBeforedEdxSignal->Set(bins,newBins);
244 axisBeforeTOF->Set(bins, newBins);
245
246 }
247 delete [] newBins;
248
249 // Event Cuts and Info
250}
251
252
253//________________________________________________________________________
254Bool_t AliPrimaryPionCuts::InitPIDResponse(){
255
256// Set Pointer to AliPIDResponse
257
258 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
259
260 if(man) {
261 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
262 fPIDResponse = (AliPIDResponse*)inputHandler->GetPIDResponse();
263 if(fPIDResponse)return kTRUE;
264
265 }
266
267 return kFALSE;
268}
269///________________________________________________________________________
270Bool_t AliPrimaryPionCuts::PionIsSelectedMC(Int_t labelParticle,AliStack *fMCStack){
271
272 if( labelParticle < 0 || labelParticle >= fMCStack->GetNtrack() ) return kFALSE;
273 if( fMCStack->IsPhysicalPrimary(labelParticle) == kFALSE ) return kFALSE;
274
275 TParticle* particle = fMCStack->Particle(labelParticle);
276
277 if( TMath::Abs( particle->GetPdgCode() ) != 211 ) return kFALSE;
278
279 if( fDoEtaCut ){
280 if( particle->Eta() > (fEtaCut + fEtaShift) || particle->Eta() < (-fEtaCut + fEtaShift) )
281 return kFALSE;
282 }
283
284 return kTRUE;
285}
286
287
288///________________________________________________________________________
289Bool_t AliPrimaryPionCuts::PionIsSelected(AliESDtrack* lTrack){
290 //Selection of Reconstructed electrons
291
292 Float_t b[2];
293 Float_t bCov[3];
294 lTrack->GetImpactParameters(b,bCov);
295
296 if (bCov[0]<=0 || bCov[2]<=0) {
297 AliDebug(1, "Estimated b resolution lower or equal zero!");
298 bCov[0]=0; bCov[2]=0;
299 }
300
301 Float_t dcaToVertexXY = b[0];
302 Float_t dcaToVertexZ = b[1];
303 Double_t clsToF = GetNFindableClustersTPC(lTrack);
304
209b710e 305
306 if (fHistCutIndex) fHistCutIndex->Fill(kPionIn);
307
308 if (lTrack == NULL){
309 if (fHistCutIndex) fHistCutIndex->Fill(kNoTracks);
310 return kFALSE;
311 }
85b56575 312 if (fHistTrackDCAxyPtbefore) fHistTrackDCAxyPtbefore->Fill(dcaToVertexXY,lTrack->Pt());
313 if (fHistTrackDCAzPtbefore) fHistTrackDCAzPtbefore->Fill( dcaToVertexZ, lTrack->Pt());
314 if (fHistTrackNFindClsPtTPCbefore) fHistTrackNFindClsPtTPCbefore->Fill( clsToF, lTrack->Pt());
315
209b710e 316
317 if ( ! lTrack->GetConstrainedParam() ){
318 return kFALSE;
319 }
320 AliVTrack * track = dynamic_cast<AliVTrack*>(lTrack);
321
322 // Track Cuts
323 if( !TrackIsSelected(lTrack) ){
324 if (fHistCutIndex) fHistCutIndex->Fill(kTrackCuts);
325 return kFALSE;
326 }
327
328 // dEdx Cuts
329 if( ! dEdxCuts( track ) ) {
330 if(fHistCutIndex)fHistCutIndex->Fill(kdEdxCuts);
331 return kFALSE;
332
333 }
334
335 //Pion passed the cuts
336 if (fHistCutIndex) fHistCutIndex->Fill(kPionOut);
337 if (fHistTrackDCAxyPtafter) fHistTrackDCAxyPtafter->Fill(dcaToVertexXY,lTrack->Pt());
338 if (fHistTrackDCAzPtafter) fHistTrackDCAzPtafter->Fill(dcaToVertexZ,lTrack->Pt());
339 if (fHistTrackNFindClsPtTPCafter) fHistTrackNFindClsPtTPCafter->Fill( clsToF, lTrack->Pt());
340
341 return kTRUE;
342}
343
344///________________________________________________________________________
345Bool_t AliPrimaryPionCuts::TrackIsSelected(AliESDtrack* lTrack) {
346 // Track Selection for Photon Reconstruction
347
348 Double_t clsToF = GetNFindableClustersTPC(lTrack);
349
350 if( ! fEsdTrackCuts->AcceptTrack(lTrack) ){
351 return kFALSE;
352 }
353
354 if( fDoEtaCut ) {
355 if( lTrack->Eta() > (fEtaCut + fEtaShift) || lTrack->Eta() < (-fEtaCut + fEtaShift) ) {
356 return kFALSE;
357 }
358 }
359
360 if( lTrack->Pt() < fPtCut ) {
361 return kFALSE;
362 }
363
364 if( clsToF < fMinClsTPCToF){
365 return kFALSE;
366 }
367
368 return kTRUE;
369}
370
371///________________________________________________________________________
372Bool_t AliPrimaryPionCuts::dEdxCuts(AliVTrack *fCurrentTrack){
373
374 // Pion Identification Cuts for Photon reconstruction
375
376 if(!fPIDResponse){ InitPIDResponse(); }// Try to reinitialize PID Response
377 if(!fPIDResponse){ AliError("No PID Response"); return kFALSE;}// if still missing fatal error
378
379 Int_t cutIndex=0;
380
381 if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
382 if(fHistITSdEdxbefore)fHistITSdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kPion));
383 if(fHistTPCdEdxbefore)fHistTPCdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kPion));
384 if(fHistTPCdEdxSignalbefore)fHistTPCdEdxSignalbefore->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal()));
385
386 cutIndex++;
387
388 if( fDodEdxSigmaITSCut == kTRUE ){
389 if( fPIDResponse->NumberOfSigmasITS(fCurrentTrack,AliPID::kPion)<fPIDnSigmaBelowPionLineITS ||
390 fPIDResponse->NumberOfSigmasITS(fCurrentTrack,AliPID::kPion)> fPIDnSigmaAbovePionLineITS ){
391 if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
392 return kFALSE;
393 }
394 }
395
396 if(fHistITSdEdxafter)fHistITSdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kPion));
397
398
399 cutIndex++;
400
401
402 if(fDodEdxSigmaTPCCut == kTRUE){
403 // TPC Pion Line
404 if( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)<fPIDnSigmaBelowPionLineTPC ||
405 fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)>fPIDnSigmaAbovePionLineTPC){
406 if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
407 return kFALSE;
408 }
409 cutIndex++;
410 } else { cutIndex+=1; }
411
412 if( ( fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid ) && ( !( fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch) ) ){
413 if(fHistTOFbefore) fHistTOFbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kPion));
414 if(fUseTOFpid){
415 if( fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kPion)>fPIDnSigmaAbovePionLineTOF ||
416 fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kPion)<fPIDnSigmaBelowPionLineTOF ){
417 if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
418 return kFALSE;
419 }
420 }
421 if(fHistTOFafter)fHistTOFafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kPion));
422 } else if ( fRequireTOF == kTRUE ) {
423 if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
424 return kFALSE;
425 }
426 cutIndex++;
427
428 if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
429 if(fHistTPCdEdxafter)fHistTPCdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kPion));
430 if(fHistTPCdEdxSignalafter)fHistTPCdEdxSignalafter->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal()));
431
432 return kTRUE;
433}
434
435///________________________________________________________________________
436AliVTrack *AliPrimaryPionCuts::GetTrack(AliVEvent * event, Int_t label){
437 //Returns pointer to the track with given ESD label
438 //(Important for AOD implementation, since Track array in AOD data is different
439 //from ESD array, but ESD tracklabels are stored in AOD Tracks)
440
441 AliESDEvent * esdEvent = dynamic_cast<AliESDEvent*>(event);
442 if(esdEvent) {
443 if(label > event->GetNumberOfTracks() ) return NULL;
444 AliESDtrack * track = esdEvent->GetTrack(label);
445 return track;
446 } else {
447 for(Int_t ii=0; ii<event->GetNumberOfTracks(); ii++) {
448 AliVTrack * track = dynamic_cast<AliVTrack*>(event->GetTrack(ii));
449 if(track) {
450 if(track->GetID() == label) {
451 return track;
452 }
453 }
454 }
455 }
456 cout << "track not found " << label << " " << event->GetNumberOfTracks() << endl;
457 return NULL;
458}
459
460///________________________________________________________________________
461Double_t AliPrimaryPionCuts::GetNFindableClustersTPC(AliESDtrack* lTrack){
462
463 Double_t clsToF=0;
464 if ( !fUseCorrectedTPCClsInfo ){
465 if(lTrack->GetTPCNclsF()!=0){
466 clsToF = (Double_t)lTrack->GetNcls(1)/(Double_t)lTrack->GetTPCNclsF();
467 }
468 } else {
469 clsToF = lTrack->GetTPCClusterInfo(2,0); //NOTE ask friederike
470 }
471 return clsToF;
472
473}
474
475///________________________________________________________________________
476Bool_t AliPrimaryPionCuts::UpdateCutString() {
477///Update the cut string (if it has been created yet)
478
479 if(fCutString && fCutString->GetString().Length() == kNCuts) {
480 fCutString->SetString(GetCutNumber());
481 } else {
482 return kFALSE;
483 }
484 return kTRUE;
485
486}
487
488///________________________________________________________________________
489Bool_t AliPrimaryPionCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) {
490 // Initialize Cuts from a given Cut string
491
492 AliInfo(Form("Set PionCuts Number: %s",analysisCutSelection.Data()));
493
494 if(analysisCutSelection.Length()!=kNCuts) {
495 AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
496 return kFALSE;
497 }
498 if(!analysisCutSelection.IsDigit()){
499 AliError("Cut selection contains characters");
500 return kFALSE;
501 }
502
503 const char *cutSelection = analysisCutSelection.Data();
504 #define ASSIGNARRAY(i) fCuts[i] = cutSelection[i] - '0'
505 for(Int_t ii=0;ii<kNCuts;ii++){
506 ASSIGNARRAY(ii);
507 }
508
509 // Set Individual Cuts
510 for(Int_t ii=0;ii<kNCuts;ii++){
511 if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
512 }
513
2c75809c 514 PrintCutsWithValues();
209b710e 515 return kTRUE;
516}
517///________________________________________________________________________
518Bool_t AliPrimaryPionCuts::SetCut(cutIds cutID, const Int_t value) {
519 ///Set individual cut ID
520
521 //cout << "Updating cut " << fgkCutNames[cutID] << " (" << cutID << ") to " << value << endl;
522
523 switch (cutID) {
524 case kEtaCut:
525 if( SetEtaCut(value)) {
526 fCuts[kEtaCut] = value;
527 UpdateCutString();
528 return kTRUE;
529 } else return kFALSE;
530 case kClsITSCut:
531 if( SetITSClusterCut(value) ) {
532 fCuts[kClsITSCut] = value;
533 UpdateCutString();
534 return kTRUE;
535 } else return kFALSE;
536 case kClsTPCCut:
537 if( SetTPCClusterCut(value)) {
538 fCuts[kClsTPCCut] = value;
539 UpdateCutString();
540 return kTRUE;
541 } else return kFALSE;
542 case kDCACut:
543 if( SetDCACut(value)) {
544 fCuts[kDCACut] = value;
545 UpdateCutString();
546 return kTRUE;
547 } else return kFALSE;
548 case kPtCut:
549 if( SetPtCut(value)) {
550 fCuts[kPtCut] = value;
551 UpdateCutString();
552 return kTRUE;
553 } else return kFALSE;
554 case kPidedxSigmaITSCut:
555 if( SetITSdEdxCutPionLine(value)) {
556 fCuts[kPidedxSigmaITSCut] = value;
557 UpdateCutString();
558 return kTRUE;
559 } else return kFALSE;
560 case kPidedxSigmaTPCCut:
561 if( SetTPCdEdxCutPionLine(value)) {
562 fCuts[kPidedxSigmaTPCCut] = value;
563 UpdateCutString();
564 return kTRUE;
565 } else return kFALSE;
566 case kPiTOFSigmaPID:
567 if( SetTOFPionPIDCut(value)) {
568 fCuts[kPiTOFSigmaPID] = value;
569 UpdateCutString();
570 return kTRUE;
571 } else return kFALSE;
d9d6352b 572 case kMassCut:
573 if( SetMassCut(value)) {
574 fCuts[kMassCut] = value;
575 UpdateCutString();
576 return kTRUE;
577 } else return kFALSE;
209b710e 578 case kNCuts:
579 cout << "Error:: Cut id out of range"<< endl;
580 return kFALSE;
581 }
582
583 cout << "Error:: Cut id " << cutID << " not recognized "<< endl;
584 return kFALSE;
585}
586
587///________________________________________________________________________
209b710e 588void AliPrimaryPionCuts::PrintCuts() {
589 // Print out current Cut Selection
590 for(Int_t ic = 0; ic < kNCuts; ic++) {
591 printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
592 }
593}
594
595///________________________________________________________________________
2c75809c 596void AliPrimaryPionCuts::PrintCutsWithValues() {
597 // Print out current Cut Selection with value
598 printf("\nCharged Pion cutnumber \n");
599 for(Int_t ic = 0; ic < kNCuts; ic++) {
600 printf("%d",fCuts[ic]);
601 }
602 printf("\n\n");
603
604 printf("Acceptance cuts \n");
605 if (fDoEtaCut) printf("\t |eta_{pi+-}| < %3.2f \n", fEtaCut);
606 else printf("\t none \n");
607 printf("Track cuts \n");
608 printf("\t %s \n", fStringITSClusterCut.Data());
609 printf("\t min N cluster TPC > %3.2f \n", fMinClsTPC);
610 printf("\t min N cluster TPC/ findable > %3.2f \n", fMinClsTPCToF);
611// printf("\t dca > %3.2f \n", fMinClsTPCToF);
612// "kDCAcut", // 3
613 printf("\t min pT > %3.2f \n", fPtCut);
614 printf("PID cuts \n");
615 if (fDodEdxSigmaITSCut)printf("\t %3.2f < ITS n_sigma pi < %3.2f \n", fPIDnSigmaBelowPionLineITS, fPIDnSigmaAbovePionLineITS );
616 if (fDodEdxSigmaTPCCut)printf("\t %3.2f < TPC n_sigma pi < %3.2f \n", fPIDnSigmaBelowPionLineTPC, fPIDnSigmaAbovePionLineTPC );
617 if (fDoTOFsigmaCut)printf("\t %3.2f < TOF n_sigma pi < %3.2f \n", fPIDnSigmaBelowPionLineTOF, fPIDnSigmaAbovePionLineTOF );
618 if (fDoMassCut) printf("two-pion mass cut < %3.2f \n", fMassCut);
619 printf("\n\n");
620}
621
622
623
624///________________________________________________________________________
209b710e 625Bool_t AliPrimaryPionCuts::SetITSdEdxCutPionLine(Int_t ededxSigmaCut){
626 switch(ededxSigmaCut){
627 case 0:
628 fDodEdxSigmaITSCut = kFALSE;
629 fPIDnSigmaBelowPionLineITS=-100;
630 fPIDnSigmaAbovePionLineITS= 100;
631 break;
632 case 1: // -10,10
633 fDodEdxSigmaITSCut = kTRUE;
634 fPIDnSigmaBelowPionLineITS=-10;
635 fPIDnSigmaAbovePionLineITS=10;
636 break;
637 case 2: // -6,7
638 fDodEdxSigmaITSCut = kTRUE;
639 fPIDnSigmaBelowPionLineITS=-6;
640 fPIDnSigmaAbovePionLineITS=7;
641 break;
642 case 3: // -5,5
643 fDodEdxSigmaITSCut = kTRUE;
644 fPIDnSigmaBelowPionLineITS=-5;
645 fPIDnSigmaAbovePionLineITS=5;
646 break;
647 case 4: // -4,5
648 fDodEdxSigmaITSCut = kTRUE;
649 fPIDnSigmaBelowPionLineITS=-4;
650 fPIDnSigmaAbovePionLineITS=5;
651 break;
652 case 5: // -3,5
653 fDodEdxSigmaITSCut = kTRUE;
654 fPIDnSigmaBelowPionLineITS=-3;
655 fPIDnSigmaAbovePionLineITS=5;
656 break;
657 case 6: // -4,4
658 fDodEdxSigmaITSCut = kTRUE;
659 fPIDnSigmaBelowPionLineITS=-4;
660 fPIDnSigmaAbovePionLineITS=4;
661 break;
662 case 7: // -2.5,4
663 fDodEdxSigmaITSCut = kTRUE;
664 fPIDnSigmaBelowPionLineITS=-2.5;
665 fPIDnSigmaAbovePionLineITS=4;
666 break;
667 case 8: // -2,3.5
668 fDodEdxSigmaITSCut = kTRUE;
669 fPIDnSigmaBelowPionLineITS=-2;
670 fPIDnSigmaAbovePionLineITS=3.5;
671 break;
672 default:
673 cout<<"Warning: ITSdEdxCutPionLine not defined"<<ededxSigmaCut<<endl;
674 return kFALSE;
675
676 }
677 return kTRUE;
678}
679
680///________________________________________________________________________
681Bool_t AliPrimaryPionCuts::SetTPCdEdxCutPionLine(Int_t ededxSigmaCut){
682 switch(ededxSigmaCut){
683 case 0:
684 fDodEdxSigmaTPCCut = kFALSE;
685 fPIDnSigmaBelowPionLineTPC=-10;
686 fPIDnSigmaAbovePionLineTPC=10;
687 break;
688 case 1: // -10,10
689 fDodEdxSigmaTPCCut = kTRUE;
690 fPIDnSigmaBelowPionLineTPC=-10;
691 fPIDnSigmaAbovePionLineTPC=10;
692 break;
693 case 2: // -6,7
694 fDodEdxSigmaTPCCut = kTRUE;
695 fPIDnSigmaBelowPionLineTPC=-6;
696 fPIDnSigmaAbovePionLineTPC=7;
697 break;
698 case 3: // -5,5
699 fDodEdxSigmaTPCCut = kTRUE;
700 fPIDnSigmaBelowPionLineTPC=-5;
701 fPIDnSigmaAbovePionLineTPC=5;
702 break;
703 case 4: // -4,5
704 fDodEdxSigmaTPCCut = kTRUE;
705 fPIDnSigmaBelowPionLineTPC=-4;
706 fPIDnSigmaAbovePionLineTPC=5;
707 break;
42fe34e2 708 case 5: // -4,4
209b710e 709 fDodEdxSigmaTPCCut = kTRUE;
710 fPIDnSigmaBelowPionLineTPC=-4;
711 fPIDnSigmaAbovePionLineTPC=4;
712 break;
42fe34e2 713 case 6: // -3,4
209b710e 714 fDodEdxSigmaTPCCut = kTRUE;
42fe34e2 715 fPIDnSigmaBelowPionLineTPC=-3;
209b710e 716 fPIDnSigmaAbovePionLineTPC=4;
717 break;
42fe34e2 718 case 7: // -3,3
719 fDodEdxSigmaTPCCut = kTRUE;
720 fPIDnSigmaBelowPionLineTPC=-3;
721 fPIDnSigmaAbovePionLineTPC=3;
722 break;
723 case 8: // -2,3.
209b710e 724 fDodEdxSigmaTPCCut = kTRUE;
725 fPIDnSigmaBelowPionLineTPC=-2;
42fe34e2 726 fPIDnSigmaAbovePionLineTPC=3.;
209b710e 727 break;
728 default:
729 cout<<"Warning: TPCdEdxCutPionLine not defined"<<ededxSigmaCut<<endl;
730 return kFALSE;
731 }
732 return kTRUE;
733}
734
735///________________________________________________________________________
736Bool_t AliPrimaryPionCuts::SetITSClusterCut(Int_t clsITSCut){
737 if( !fEsdTrackCuts ) {
738 cout<<"Warning: AliESDtrackCut is not initialized "<<endl;
739 return kFALSE;
740 }
741
742 switch(clsITSCut){
743 case 0:
744 fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
2c75809c 745 fStringITSClusterCut= "no SPD cluster requirement";
209b710e 746 break;
747 case 1:
748 fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst);
2c75809c 749 fStringITSClusterCut= "first SPD cluster required";
209b710e 750 break; //1 hit first layer of SPD
751 case 2:
752 fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
2c75809c 753 fStringITSClusterCut= "first or second SPD cluster required";
209b710e 754 break; //1 hit in any layer of SPD
755 case 3:
756 fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst);
757 fEsdTrackCuts->SetMinNClustersITS(4);
2c75809c 758 fStringITSClusterCut= "first SPD cluster required, min number of ITS clusters = 4";
209b710e 759 // 4 hits in total in the ITS. At least 1 hit in the first layer of SPD
760 break;
761 case 4:
762 fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
763 fEsdTrackCuts->SetMinNClustersITS(3);
2c75809c 764 fStringITSClusterCut= "first or second SPD cluster required, min number of ITS clusters = 3";
209b710e 765 // 3 hits in total in the ITS. At least 1 hit in any layer of SPD
766 break;
767 case 5:
768 fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
769 fEsdTrackCuts->SetMinNClustersITS(4);
2c75809c 770 fStringITSClusterCut= "first or second SPD cluster required, min number of ITS clusters = 4";
209b710e 771 // 4 hits in total in the ITS. At least 1 hit in any layer of SPD
772 break;
773 case 6:
774 fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
775 fEsdTrackCuts->SetMinNClustersITS(5);
2c75809c 776 fStringITSClusterCut= "first or second SPD cluster required, min number of ITS clusters = 5";
209b710e 777 // 5 hits in total in the ITS. At least 1 hit in any layer of SPD
778 break;
779 default:
780 cout<<"Warning: clsITSCut not defined "<<clsITSCut<<endl;
781 return kFALSE;
782 }
783 return kTRUE;
784}
785
786///________________________________________________________________________
787Bool_t AliPrimaryPionCuts::SetTPCClusterCut(Int_t clsTPCCut){
788 switch(clsTPCCut){
789 case 0: // 0
790 fMinClsTPC= 0.;
791 fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
792 break;
793 case 1: // 70
794 fMinClsTPC= 70.;
795 fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
796 break;
797 case 2: // 80
798 fMinClsTPC= 80.;
799 fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
800 break;
801 case 3: // 100
802 fMinClsTPC= 100.;
803 fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
804 break;
805 case 4: // 0% of findable clusters
806 fMinClsTPC= 70.;
807 fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
808 fMinClsTPCToF= 0.0;
809 fUseCorrectedTPCClsInfo=0;
810 break;
811 case 5: // 35% of findable clusters
812 fMinClsTPC = 70.;
813 fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
814 fMinClsTPCToF= 0.35;
815 fUseCorrectedTPCClsInfo=0;
816 break;
817 case 6: // 60% of findable clusters
818 fMinClsTPC= 70.;
819 fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
820 fMinClsTPCToF= 0.6;
821 fUseCorrectedTPCClsInfo=0;
822 break;
823 case 7: // 70% of findable clusters
824 fMinClsTPC= 70.;
825 fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
826 fMinClsTPCToF= 0.7;
827 fUseCorrectedTPCClsInfo=0;
828 break;
829 case 8: fMinClsTPC = 0.;
830 fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
831 fMinClsTPCToF= 0.35;
832 fUseCorrectedTPCClsInfo=0;
833 break;
834 case 9: // 35% of findable clusters
835 fMinClsTPC = 70.;
836 fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
837 fMinClsTPCToF= 0.35;
838 fUseCorrectedTPCClsInfo=1;
839 break;
840
841 default:
842 cout<<"Warning: clsTPCCut not defined "<<clsTPCCut<<endl;
843 return kFALSE;
844 }
845 return kTRUE;
846}
847
848///________________________________________________________________________
849Bool_t AliPrimaryPionCuts::SetEtaCut(Int_t etaCut){
850 // Set eta Cut
851 switch(etaCut){
852 case 0:
853 fEtaCut = 100.;
854 fDoEtaCut = kFALSE;
855 break;
856 case 1: // 1.4
857 fEtaCut = 1.4;
858 fDoEtaCut = kTRUE;
859 break;
860 case 2: // 1.2
861 fEtaCut = 1.2;
862 fDoEtaCut = kTRUE;
863 break;
864 case 3: // 0.9
865 fEtaCut = 0.9;
866 fDoEtaCut = kTRUE;
867 break;
868 case 4: // 0.8
869 fEtaCut = 0.8;
870 fDoEtaCut = kTRUE;
871 break;
872 case 5: // 0.75
873 fEtaCut = 0.75;
874 fDoEtaCut = kTRUE;
875 break;
876 case 6: //0.6
877 fEtaCut = 0.6; //changed from 0.4 to 0.6 2013.06.10
878 fDoEtaCut = kTRUE;
879 break;
880 case 7: //0.5
881 fEtaCut = 0.5; //changed from 0.3 to 0.5 2013.06.10
882 fDoEtaCut = kTRUE;
883 break;
884 case 8:
885 fEtaCut = 0.4;
886 fDoEtaCut = kTRUE;
887 break;
888 default:
889 cout<<"Warning: EtaCut not defined "<<etaCut<<endl;
890 return kFALSE;
891 }
892 return kTRUE;
893}
894
895///________________________________________________________________________
896Bool_t AliPrimaryPionCuts::SetPtCut(Int_t ptCut){
897 switch(ptCut){
898 case 0:
899 fPtCut = 0.075;
900 break;
901 case 1: // 0.1
902 fPtCut = 0.1;
903 break;
904 case 2: // 0.125 GeV
905 fPtCut = 0.125;
906 break;
907 case 3: // 0.15 GeV
908 fPtCut = 0.15;
909 break;
910 default:
911 cout<<"Warning: PtCut not defined "<<ptCut<<endl;
912 return kFALSE;
913 }
914 return kTRUE;
915}
916
917
918///________________________________________________________________________
919Bool_t AliPrimaryPionCuts::SetDCACut(Int_t dcaCut)
920{
921 // Set DCA Cut
922 if( !fEsdTrackCuts ) {
923 cout<<"Warning: AliESDtrackCut is not initialized "<<endl;
924 return kFALSE;
925 }
926
927 switch(dcaCut){
928 case 0:
929 //Open cuts//
930 fEsdTrackCuts->SetMaxDCAToVertexZ(1000);
931 fEsdTrackCuts->SetMaxDCAToVertexXY(1000);
932 fEsdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
933 break;
934 case 1:
935 fEsdTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
936 fEsdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
937 break;
2c75809c 938 case 2:
939 fEsdTrackCuts->SetMaxDCAToVertexZ(2);
209b710e 940 fEsdTrackCuts->SetMaxDCAToVertexXY(1);
941 fEsdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
942 break;
943 default:
944 cout<<"Warning: dcaCut not defined "<<dcaCut<<endl;
945 return kFALSE;
946 }
947 return kTRUE;
948}
949
950///________________________________________________________________________
951Bool_t AliPrimaryPionCuts::SetTOFPionPIDCut(Int_t TOFelectronPID){
952 // Set Cut
953 switch(TOFelectronPID){
954 case 0: // no cut
955 fRequireTOF = kFALSE;
956 fUseTOFpid = kFALSE;
957 fPIDnSigmaBelowPionLineTOF=-100;
958 fPIDnSigmaAbovePionLineTOF=100;
959 break;
960 case 1: // -7,7
961 fRequireTOF = kFALSE;
962 fUseTOFpid = kTRUE;
963 fPIDnSigmaBelowPionLineTOF=-7;
964 fPIDnSigmaAbovePionLineTOF=7;
965 break;
966 case 2: // -5,5
967 fRequireTOF = kFALSE;
968 fUseTOFpid = kTRUE;
969 fPIDnSigmaBelowPionLineTOF=-5;
970 fPIDnSigmaAbovePionLineTOF=5;
971 break;
972 case 3: // -3,5
973 fRequireTOF = kFALSE;
974 fUseTOFpid = kTRUE;
975 fPIDnSigmaBelowPionLineTOF=-3;
976 fPIDnSigmaAbovePionLineTOF=5;
977 break;
978 case 4: // -2,3
979 fRequireTOF = kFALSE;
980 fUseTOFpid = kTRUE;
981 fPIDnSigmaBelowPionLineTOF=-2;
982 fPIDnSigmaAbovePionLineTOF=3;
983 break;
984 case 5: // -3, 3 TOF mandatory
985 fRequireTOF = kTRUE;
986 fUseTOFpid = kTRUE;
987 fPIDnSigmaBelowPionLineTOF= -3;
988 fPIDnSigmaAbovePionLineTOF= 3;
989 break;
990 default:
991 cout<<"Warning: TOFPionCut not defined "<<TOFelectronPID<<endl;
992 return kFALSE;
993 }
994 return kTRUE;
995}
996
d9d6352b 997///________________________________________________________________________
998Bool_t AliPrimaryPionCuts::SetMassCut(Int_t massCut){
999 // Set Cut
1000 switch(massCut){
1001 case 0: // no cut
1002 fDoMassCut = kFALSE;
1003 fMassCut = 10;
1004 break;
1005 case 1: // cut at 1 GeV/c^2
1006 fDoMassCut = kTRUE;
1007 fMassCut = 1;
1008 break;
1009 case 2: // cut at 0.7 GeV/c^2
1010 fDoMassCut = kTRUE;
2c75809c 1011 fMassCut = 0.75;
d9d6352b 1012 break;
1013 case 3: // cut at 0.6 GeV/c^2
1014 fDoMassCut = kTRUE;
1015 fMassCut = 0.6;
1016 break;
1017 case 4: // cut at eta mass
1018 fDoMassCut = kTRUE;
1019 fMassCut = 0.547853;
1020 break;
1021 case 5: // cut at 0.5 GeV/c^2
1022 fDoMassCut = kTRUE;
1023 fMassCut = 0.5;
1024 break;
1025 default:
1026 cout<<"Warning: MassCut not defined "<<massCut<<endl;
1027 return kFALSE;
1028 }
1029 return kTRUE;
1030}
1031
209b710e 1032
1033///________________________________________________________________________
1034TString AliPrimaryPionCuts::GetCutNumber(){
1035 // returns TString with current cut number
1036 TString a(kNCuts);
1037 for(Int_t ii=0;ii<kNCuts;ii++){
1038 a.Append(Form("%d",fCuts[ii]));
1039 }
1040 return a;
1041}
1042
1043
1044///________________________________________________________________________
1045AliPrimaryPionCuts* AliPrimaryPionCuts::GetStandardCuts2010PbPb(){
1046 //Create and return standard 2010 PbPb cuts
1047 AliPrimaryPionCuts *cuts=new AliPrimaryPionCuts("StandardCuts2010PbPb","StandardCuts2010PbPb");
d9d6352b 1048 if(!cuts->InitializeCutsFromCutString("000000400")){
209b710e 1049 cout<<"Warning: Initialization of Standardcuts2010PbPb failed"<<endl;
1050 }
1051 return cuts;
1052}
1053
1054///________________________________________________________________________
1055AliPrimaryPionCuts* AliPrimaryPionCuts::GetStandardCuts2010pp(){
1056 //Create and return standard 2010 PbPb cuts
1057 AliPrimaryPionCuts *cuts=new AliPrimaryPionCuts("StandardCuts2010pp","StandardCuts2010pp");
1058
d9d6352b 1059 if(!cuts->InitializeCutsFromCutString("000000400")){
209b710e 1060 cout<<"Warning: Initialization of Standardcuts2010pp failed"<<endl;
1061 }
1062 return cuts;
1063}
1064