Adding histogram of Z veretx for all events passing all selection without z veretx...
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliConversionMesonCuts.cxx
CommitLineData
2bb2434e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Authors: Svein Lindal, Daniel Lohner *
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// Gamma Conversion analysis
20//---------------------------------------------
21////////////////////////////////////////////////
22
23#include "AliConversionMesonCuts.h"
24
25#include "AliKFVertex.h"
26#include "AliAODTrack.h"
27#include "AliESDtrack.h"
28#include "AliAnalysisManager.h"
29#include "AliInputEventHandler.h"
30#include "AliMCEventHandler.h"
31#include "AliAODHandler.h"
32#include "AliPIDResponse.h"
33#include "TH1.h"
34#include "TH2.h"
35#include "AliStack.h"
36#include "AliAODConversionMother.h"
37#include "TObjString.h"
38#include "AliAODEvent.h"
39#include "AliESDEvent.h"
40#include "AliCentrality.h"
41#include "TList.h"
42class iostream;
43
44using namespace std;
45
46ClassImp(AliConversionMesonCuts)
47
48
49const char* AliConversionMesonCuts::fgkCutNames[AliConversionMesonCuts::kNCuts] = {
e5b6e8a6 50 "MesonKind",
51 "BackgroundScheme",
52 "NumberOfBGEvents",
53 "DegreesForRotationMethod",
54 "RapidityMesonCut",
55 "RCut",
56 "AlphaMesonCut",
57 "Chi2MesonCut",
58 "SharedElectronCuts",
59 "RejectToCloseV0s",
60 "UseMCPSmearing",
2bb2434e 61};
62
63
64//________________________________________________________________________
e5b6e8a6 65AliConversionMesonCuts::AliConversionMesonCuts(const char *name,const char *title) :
66 AliAnalysisCuts(name,title),
67 fHistograms(NULL),
68 fMesonKind(0),
69 fMaxR(200),
70 fChi2CutMeson(1000),
71 fAlphaMinCutMeson(0),
72 fAlphaCutMeson(1),
73 fRapidityCutMeson(1),
74 fUseRotationMethodInBG(kFALSE),
75 fDoBG(kTRUE),
76 fdoBGProbability(kFALSE),
77 fUseTrackMultiplicityForBG(kFALSE),
78 fnDegreeRotationPMForBG(0),
79 fNumberOfBGEvents(0),
80 fOpeningAngle(0.005),
81 fDoToCloseV0sCut(kFALSE),
82 fminV0Dist(200.),
83 fDoSharedElecCut(kFALSE),
84 fUseMCPSmearing(kFALSE),
85 fPBremSmearing(0),
86 fPSigSmearing(0),
87 fPSigSmearingCte(0),
88 fBrem(NULL),
89 fRandom(0),
90 fElectronLabelArray(NULL),
91 fBackgroundHandler(0),
92 fCutString(NULL),
93 hMesonCuts(NULL),
94 hMesonBGCuts(NULL)
95
2bb2434e 96{
e5b6e8a6 97 for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
98 fCutString=new TObjString((GetCutNumber()).Data());
99 fElectronLabelArray = new Int_t[500];
100 if (fBrem == NULL){
101 fBrem = new TF1("fBrem","pow(-log(x),[0]/log(2.0)-1.0)/TMath::Gamma([0]/log(2.0))",0.00001,0.999999999);
102 // tests done with 1.0e-14
103 fBrem->SetParameter(0,fPBremSmearing);
104 fBrem->SetNpx(100000);
105 }
ca91a3e1 106
2bb2434e 107}
108
109//________________________________________________________________________
110AliConversionMesonCuts::~AliConversionMesonCuts() {
e5b6e8a6 111 // Destructor
112 //Deleting fHistograms leads to seg fault it it's added to output collection of a task
113 // if(fHistograms)
114 // delete fHistograms;
115 // fHistograms = NULL;
2bb2434e 116 if(fCutString != NULL){
117 delete fCutString;
118 fCutString = NULL;
119 }
120 if(fElectronLabelArray){
121 delete fElectronLabelArray;
122 fElectronLabelArray = NULL;
123 }
124
125}
126
127//________________________________________________________________________
e5b6e8a6 128void AliConversionMesonCuts::InitCutHistograms(TString name){
129
130 // Initialize Cut Histograms for QA (only initialized and filled if function is called)
131
132 if(fHistograms != NULL){
133 delete fHistograms;
134 fHistograms=NULL;
135 }
136 if(fHistograms==NULL){
137 fHistograms=new TList();
138 if(name=="")fHistograms->SetName(Form("ConvMesonCuts_%s",GetCutNumber().Data()));
139 else fHistograms->SetName(Form("%s_%s",name.Data(),GetCutNumber().Data()));
140 }
141
142 // Meson Cuts
143 hMesonCuts=new TH1F(Form("MesonCuts %s",GetCutNumber().Data()),"MesonCuts",10,-0.5,9.5);
144 hMesonCuts->GetXaxis()->SetBinLabel(1,"in");
145 hMesonCuts->GetXaxis()->SetBinLabel(2,"undef rapidity");
146 hMesonCuts->GetXaxis()->SetBinLabel(3,"rapidity cut");
147 hMesonCuts->GetXaxis()->SetBinLabel(4,"opening angle");
148 hMesonCuts->GetXaxis()->SetBinLabel(5,"alpha max");
149 hMesonCuts->GetXaxis()->SetBinLabel(6,"alpha min");
150 hMesonCuts->GetXaxis()->SetBinLabel(7,"out");
151 fHistograms->Add(hMesonCuts);
152
153 hMesonBGCuts=new TH1F(Form("MesonBGCuts %s",GetCutNumber().Data()),"MesonBGCuts",10,-0.5,9.5);
154 hMesonBGCuts->GetXaxis()->SetBinLabel(1,"in");
155 hMesonBGCuts->GetXaxis()->SetBinLabel(2,"undef rapidity");
156 hMesonBGCuts->GetXaxis()->SetBinLabel(3,"rapidity cut");
157 hMesonBGCuts->GetXaxis()->SetBinLabel(4,"opening angle");
158 hMesonBGCuts->GetXaxis()->SetBinLabel(5,"alpha max");
159 hMesonBGCuts->GetXaxis()->SetBinLabel(6,"alpha min");
160 hMesonBGCuts->GetXaxis()->SetBinLabel(7,"out");
161 fHistograms->Add(hMesonBGCuts);
2bb2434e 162}
163
164
165//________________________________________________________________________
e5b6e8a6 166Bool_t AliConversionMesonCuts::MesonIsSelectedMC(TParticle *fMCMother,AliStack *fMCStack){
167 // Returns true for all pions within acceptance cuts for decay into 2 photons
168 // If bMCDaughtersInAcceptance is selected, it requires in addition that both daughter photons are within acceptance cuts
169
170 if(!fMCStack)return kFALSE;
171
172 if(fMCMother->GetPdgCode()==111 || fMCMother->GetPdgCode()==221){
173 if(fMCMother->R()>fMaxR) return kFALSE; // cuts on distance from collision point
174
175 Double_t rapidity = 10.;
176 if(fMCMother->Energy() - fMCMother->Pz() == 0 || fMCMother->Energy() + fMCMother->Pz() == 0){
177 rapidity=8.;
178 } else{
179 rapidity = 0.5*(TMath::Log((fMCMother->Energy()+fMCMother->Pz()) / (fMCMother->Energy()-fMCMother->Pz())));
180 }
181
182 // Rapidity Cut
183 if(abs(rapidity)>fRapidityCutMeson)return kFALSE;
184
185 // Select only -> 2y decay channel
186 if(fMCMother->GetNDaughters()!=2)return kFALSE;
187
188 for(Int_t i=0;i<2;i++){
189 TParticle *MDaughter=fMCStack->Particle(fMCMother->GetDaughter(i));
190 // Is Daughter a Photon?
191 if(MDaughter->GetPdgCode()!=22)return kFALSE;
192 // Is Photon in Acceptance?
193 // if(bMCDaughtersInAcceptance){
194 // if(!PhotonIsSelectedMC(MDaughter,fMCStack)){return kFALSE;}
195 // }
196 }
197 return kTRUE;
198 }
199 return kFALSE;
2bb2434e 200}
201
202//________________________________________________________________________
203Bool_t AliConversionMesonCuts::MesonIsSelectedMCDalitz(TParticle *fMCMother,AliStack *fMCStack){
e5b6e8a6 204 // Returns true for all pions within acceptance cuts for decay into 2 photons
205 // If bMCDaughtersInAcceptance is selected, it requires in addition that both daughter photons are within acceptance cuts
2bb2434e 206
e5b6e8a6 207 if(!fMCStack)return kFALSE;
2bb2434e 208
e5b6e8a6 209 if(fMCMother->GetPdgCode()==111 || fMCMother->GetPdgCode()==221){
2bb2434e 210
e5b6e8a6 211 if(fMCMother->R()>fMaxR) return kFALSE; // cuts on distance from collision point
212
213 Double_t rapidity = 10.;
214 if(fMCMother->Energy() - fMCMother->Pz() == 0 || fMCMother->Energy() + fMCMother->Pz() == 0){
215 rapidity=8.;
216 }
217 else{
218 rapidity = 0.5*(TMath::Log((fMCMother->Energy()+fMCMother->Pz()) / (fMCMother->Energy()-fMCMother->Pz())));
219 }
2bb2434e 220
e5b6e8a6 221 // Rapidity Cut
222 if(abs(rapidity)>fRapidityCutMeson)return kFALSE;
223
224 // Select only -> Dalitz decay channel
225 if(fMCMother->GetNDaughters()!=3)return kFALSE;
226
227 Int_t daughterPDGs[3] = {0,0,0};
228 Int_t index = 0;
229
230 // iParticle->GetFirstDaughter(); idxPi0 <= iParticle->GetLastDaughter()
231
232 for(Int_t i=fMCMother->GetFirstDaughter(); i<= fMCMother->GetLastDaughter();i++){
233 TParticle *MDaughter=fMCStack->Particle(i);
234 // Is Daughter a Photon or an electron?
235 daughterPDGs[index]=MDaughter->GetPdgCode();
236 index++;
237 }
238 for (Int_t j=0;j<2;j++){
239
240 for (Int_t i=0;i<2;i++){
241 if (daughterPDGs[i] > daughterPDGs[i+1]){
242 Int_t interMed = daughterPDGs[i] ;
243 daughterPDGs[i] = daughterPDGs[i+1];
244 daughterPDGs[i+1] = interMed;
245 }
246 }
247 }
248 if (daughterPDGs[0] == -11 && daughterPDGs[1] == 11 && daughterPDGs[2] == 22) return kTRUE;
249 }
250 return kFALSE;
2bb2434e 251}
252
253
254///________________________________________________________________________
255Bool_t AliConversionMesonCuts::MesonIsSelected(AliAODConversionMother *pi0,Bool_t IsSignal)
256{
e5b6e8a6 257 // Selection of reconstructed Meson candidates
258 // Use flag IsSignal in order to fill Fill different
259 // histograms for Signal and Background
260 TH1 *hist=0x0;
261
262 if(IsSignal){hist=hMesonCuts;}
263 else{hist=hMesonBGCuts;}
264
265 Int_t cutIndex=0;
266
267 if(hist)hist->Fill(cutIndex);
268 cutIndex++;
269
270 // Undefined Rapidity -> Floating Point exception
271 if((pi0->E()+pi0->Pz())/(pi0->E()-pi0->Pz())<=0){
272 if(hist)hist->Fill(cutIndex);
273 cutIndex++;
274 return kFALSE;
275 }
276 else{
277 // PseudoRapidity Cut --> But we cut on Rapidity !!!
278 cutIndex++;
279 if(abs(pi0->Rapidity())>fRapidityCutMeson){
280 if(hist)hist->Fill(cutIndex);
281 return kFALSE;
282 }
283 }
284 cutIndex++;
285
286 // Opening Angle Cut
287 //fOpeningAngle=2*TMath::ATan(0.134/pi0->P());// physical minimum opening angle
288 if( pi0->GetOpeningAngle() < fOpeningAngle){
289 if(hist)hist->Fill(cutIndex);
290 return kFALSE;
291 }
292 cutIndex++;
293
294 // Alpha Max Cut
295 if(pi0->GetAlpha()>fAlphaCutMeson){
296 if(hist)hist->Fill(cutIndex);
297 return kFALSE;
298 }
299 cutIndex++;
300
301 // Alpha Min Cut
302 if(pi0->GetAlpha()<fAlphaMinCutMeson){
303 if(hist)hist->Fill(cutIndex);
304 return kFALSE;
305 }
306 cutIndex++;
307
308 if(hist)hist->Fill(cutIndex);
309 return kTRUE;
2bb2434e 310}
311
312
313
314///________________________________________________________________________
315///________________________________________________________________________
e5b6e8a6 316Bool_t AliConversionMesonCuts::UpdateCutString() {
317 ///Update the cut string (if it has been created yet)
318
319 if(fCutString && fCutString->GetString().Length() == kNCuts) {
320 // cout << "Updating cut id in spot number " << cutID << " to " << value << endl;
321 fCutString->SetString(GetCutNumber());
322 } else {
323 // cout << "fCutString not yet initialized, will not be updated" << endl;
324 return kFALSE;
325 }
326 // cout << fCutString->GetString().Data() << endl;
327 return kTRUE;
2bb2434e 328}
329
330///________________________________________________________________________
331Bool_t AliConversionMesonCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) {
e5b6e8a6 332 // Initialize Cuts from a given Cut string
333 AliInfo(Form("Set Meson Cutnumber: %s",analysisCutSelection.Data()));
334 if(analysisCutSelection.Length()!=kNCuts) {
335 AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
336 return kFALSE;
337 }
338 if(!analysisCutSelection.IsDigit()){
339 AliError("Cut selection contains characters");
340 return kFALSE;
341 }
2bb2434e 342
e5b6e8a6 343 const char *cutSelection = analysisCutSelection.Data();
344#define ASSIGNARRAY(i) fCuts[i] = cutSelection[i] - '0'
345 for(Int_t ii=0;ii<kNCuts;ii++){
346 ASSIGNARRAY(ii);
347 }
348
349 // Set Individual Cuts
350 for(Int_t ii=0;ii<kNCuts;ii++){
2bb2434e 351 if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
e5b6e8a6 352 }
2bb2434e 353
e5b6e8a6 354 //PrintCuts();
355 return kTRUE;
2bb2434e 356}
357///________________________________________________________________________
358Bool_t AliConversionMesonCuts::SetCut(cutIds cutID, const Int_t value) {
e5b6e8a6 359 ///Set individual cut ID
360
361 //cout << "Updating cut " << fgkCutNames[cutID] << " (" << cutID << ") to " << value << endl;
362 switch (cutID) {
363 case kMesonKind:
364 if( SetMesonKind(value)) {
365 fCuts[kMesonKind] = value;
366 UpdateCutString();
367 return kTRUE;
368 } else return kFALSE;
369 case kchi2MesonCut:
370 if( SetChi2MesonCut(value)) {
371 fCuts[kchi2MesonCut] = value;
372 UpdateCutString();
373 return kTRUE;
374 } else return kFALSE;
375 case kalphaMesonCut:
376 if( SetAlphaMesonCut(value)) {
377 fCuts[kalphaMesonCut] = value;
378 UpdateCutString();
379 return kTRUE;
380 } else return kFALSE;
381 case kRCut:
382 if( SetRCut(value)) {
383 fCuts[kRCut] = value;
384 UpdateCutString();
385 return kTRUE;
386 } else return kFALSE;
387
388 case kRapidityMesonCut:
389 if( SetRapidityMesonCut(value)) {
390 fCuts[kRapidityMesonCut] = value;
391 UpdateCutString();
392 return kTRUE;
393 } else return kFALSE;
394
395 case kBackgroundScheme:
396 if( SetBackgroundScheme(value)) {
397 fCuts[kBackgroundScheme] = value;
398 UpdateCutString();
399 return kTRUE;
400 } else return kFALSE;
401
402 case kDegreesForRotationMethod:
403 if( SetNDegreesForRotationMethod(value)) {
404 fCuts[kDegreesForRotationMethod] = value;
405 UpdateCutString();
406 return kTRUE;
407 } else return kFALSE;
408
409 case kNumberOfBGEvents:
410 if( SetNumberOfBGEvents(value)) {
411 fCuts[kNumberOfBGEvents] = value;
412 UpdateCutString();
413 return kTRUE;
414 } else return kFALSE;
415
416 case kuseMCPSmearing:
417 if( SetMCPSmearing(value)) {
418 fCuts[kuseMCPSmearing] = value;
419 UpdateCutString();
420 return kTRUE;
421 } else return kFALSE;
422 case kElecShare:
423 if( SetSharedElectronCut(value)) {
424 fCuts[kElecShare] = value;
425 UpdateCutString();
426 return kTRUE;
427 } else return kFALSE;
428 case kToCloseV0s:
429 if( SetToCloseV0sCut(value)) {
430 fCuts[kToCloseV0s] = value;
431 UpdateCutString();
432 return kTRUE;
433 } else return kFALSE;
434
435 case kNCuts:
436 cout << "Error:: Cut id out of range"<< endl;
437 return kFALSE;
438 }
2bb2434e 439
e5b6e8a6 440 cout << "Error:: Cut id " << cutID << " not recognized "<< endl;
441 return kFALSE;
2bb2434e 442
443}
444
445
446///________________________________________________________________________
447void AliConversionMesonCuts::PrintCuts() {
e5b6e8a6 448 // Print out current Cut Selection
449 for(Int_t ic = 0; ic < kNCuts; ic++) {
450 printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
451 }
2bb2434e 452}
453
454///________________________________________________________________________
455Bool_t AliConversionMesonCuts::SetMesonKind(Int_t mesonKind){
e5b6e8a6 456 // Set Cut
457 switch(mesonKind){
458 case 0:
459 fMesonKind=0;
460 break;
461 case 1:
462 fMesonKind=1;;
463 break;
464 default:
465 cout<<"Warning: Meson kind not defined"<<mesonKind<<endl;
466 return kFALSE;
467 }
468 return kTRUE;
2bb2434e 469}
470
471///________________________________________________________________________
472Bool_t AliConversionMesonCuts::SetRCut(Int_t rCut){
e5b6e8a6 473 // Set Cut
474 switch(rCut){
475 case 0:
476 fMaxR = 180.;
477 break;
478 case 1:
479 fMaxR = 180.;
480 break;
481 case 2:
482 fMaxR = 180.;
483 break;
484 case 3:
485 fMaxR = 70.;
486 break;
487 case 4:
488 fMaxR = 70.;
489 break;
490 case 5:
491 fMaxR = 180.;
492 break;
493 // High purity cuts for PbPb
494 case 9:
495 fMaxR = 180.;
496 break;
497 default:
498 cout<<"Warning: rCut not defined"<<rCut<<endl;
499 return kFALSE;
500 }
501 return kTRUE;
2bb2434e 502}
503
504///________________________________________________________________________
505Bool_t AliConversionMesonCuts::SetChi2MesonCut(Int_t chi2MesonCut){
e5b6e8a6 506 // Set Cut
507 switch(chi2MesonCut){
508 case 0: // 100.
509 fChi2CutMeson = 100.;
510 break;
511 case 1: // 50.
512 fChi2CutMeson = 50.;
513 break;
514 case 2: // 30.
515 fChi2CutMeson = 30.;
516 break;
517 case 3:
518 fChi2CutMeson = 200.;
519 break;
520 case 4:
521 fChi2CutMeson = 500.;
522 break;
523 case 5:
524 fChi2CutMeson = 1000.;
525 break;
526 default:
527 cout<<"Warning: Chi2MesonCut not defined "<<chi2MesonCut<<endl;
528 return kFALSE;
529 }
530 return kTRUE;
2bb2434e 531}
532
533
534///________________________________________________________________________
535Bool_t AliConversionMesonCuts::SetAlphaMesonCut(Int_t alphaMesonCut)
536{ // Set Cut
e5b6e8a6 537 switch(alphaMesonCut){
538 case 0: // 0- 0.7
539 fAlphaMinCutMeson = 0.0;
540 fAlphaCutMeson = 0.7;
541 break;
542 case 1: // 0-0.5
543 fAlphaMinCutMeson = 0.0;
544 fAlphaCutMeson = 0.5;
545 break;
546 case 2: // 0.5-1
547 fAlphaMinCutMeson = 0.5;
548 fAlphaCutMeson = 1.;
549 break;
550 case 3: // 0.0-1
551 fAlphaMinCutMeson = 0.0;
552 fAlphaCutMeson = 1.;
553 break;
554 case 4: // 0-0.65
555 fAlphaMinCutMeson = 0.0;
556 fAlphaCutMeson = 0.65;
557 break;
558 case 5: // 0-0.75
559 fAlphaMinCutMeson = 0.0;
560 fAlphaCutMeson = 0.75;
561 break;
562 case 6: // 0-0.8
563 fAlphaMinCutMeson = 0.0;
564 fAlphaCutMeson = 0.8;
565 break;
566 case 7: // 0.0-0.85
567 fAlphaMinCutMeson = 0.0;
568 fAlphaCutMeson = 0.85;
569 break;
570 case 8: // 0.0-0.6
571 fAlphaMinCutMeson = 0.0;
572 fAlphaCutMeson = 0.6;
573 break;
574 case 9: // 0.0-0.3
575 fAlphaMinCutMeson = 0.0;
576 fAlphaCutMeson = 0.3;
577 break;
578 default:
579 cout<<"Warning: AlphaMesonCut not defined "<<alphaMesonCut<<endl;
580 return kFALSE;
581 }
582 return kTRUE;
2bb2434e 583}
584
585///________________________________________________________________________
586Bool_t AliConversionMesonCuts::SetRapidityMesonCut(Int_t RapidityMesonCut){
e5b6e8a6 587 // Set Cut
588 switch(RapidityMesonCut){
589 case 0: //
590 fRapidityCutMeson = 0.9;
591 break;
592 case 1: //
593 fRapidityCutMeson = 0.8;
594 break;
595 case 2: //
596 fRapidityCutMeson = 0.7;
597 break;
598 case 3: //
599 fRapidityCutMeson = 0.6;
600 break;
601 case 4: //
602 fRapidityCutMeson = 0.5;
603 break;
604 case 5: //
605 fRapidityCutMeson = 0.85;
606 break;
607 case 6: //
608 fRapidityCutMeson = 0.75;
609 break;
610
611 default:
612 cout<<"Warning: RapidityMesonCut not defined "<<RapidityMesonCut<<endl;
613 return kFALSE;
614 }
615 return kTRUE;
2bb2434e 616}
617
618
619///________________________________________________________________________
620Bool_t AliConversionMesonCuts::SetBackgroundScheme(Int_t BackgroundScheme){
e5b6e8a6 621 // Set Cut
622 switch(BackgroundScheme){
623 case 0: //Rotation
624 fUseRotationMethodInBG=kTRUE;
625 fdoBGProbability=kFALSE;
626 break;
627 case 1: // mixed event with V0 multiplicity
628 fUseRotationMethodInBG=kFALSE;
629 fUseTrackMultiplicityForBG=kFALSE;
630 fdoBGProbability=kFALSE;
631 break;
632 case 2: // mixed event with track multiplicity
633 fUseRotationMethodInBG=kFALSE;
634 fUseTrackMultiplicityForBG=kTRUE;
635 fdoBGProbability=kFALSE;
636 break;
637 case 3: //Rotation
638 fUseRotationMethodInBG=kTRUE;
639 fdoBGProbability=kTRUE;
640 break;
641 case 4: //No BG calculation
642 cout << "no BG calculation should be done" << endl;
643 fUseRotationMethodInBG=kFALSE;
644 fdoBGProbability=kFALSE;
645 fDoBG=kFALSE;
646 break;
647 case 5: //Rotation
648 fUseRotationMethodInBG=kTRUE;
649 fdoBGProbability=kFALSE;
650 fBackgroundHandler = 1;
651 break;
652 case 6: // mixed event with V0 multiplicity
653 fUseRotationMethodInBG=kFALSE;
654 fUseTrackMultiplicityForBG=kFALSE;
655 fdoBGProbability=kFALSE;
656 fBackgroundHandler = 1;
657 break;
658 case 7: // mixed event with track multiplicity
659 fUseRotationMethodInBG=kFALSE;
660 fUseTrackMultiplicityForBG=kTRUE;
661 fdoBGProbability=kFALSE;
662 fBackgroundHandler = 1;
663 break;
664 case 8: //Rotation
665 fUseRotationMethodInBG=kTRUE;
666 fdoBGProbability=kTRUE;
667 fBackgroundHandler = 1;
668 break;
669 default:
670 cout<<"Warning: BackgroundScheme not defined "<<BackgroundScheme<<endl;
671 return kFALSE;
672 }
673 return kTRUE;
2bb2434e 674}
675
ca91a3e1 676
2bb2434e 677///________________________________________________________________________
678Bool_t AliConversionMesonCuts::SetNDegreesForRotationMethod(Int_t DegreesForRotationMethod){
e5b6e8a6 679 // Set Cut
680 switch(DegreesForRotationMethod){
681 case 0:
682 fnDegreeRotationPMForBG = 5;
683 break;
684 case 1:
685 fnDegreeRotationPMForBG = 10;
686 break;
687 case 2:
688 fnDegreeRotationPMForBG = 15;
689 break;
690 case 3:
691 fnDegreeRotationPMForBG = 20;
692 break;
693 default:
694 cout<<"Warning: DegreesForRotationMethod not defined "<<DegreesForRotationMethod<<endl;
695 return kFALSE;
696 }
697 fCuts[kDegreesForRotationMethod]=DegreesForRotationMethod;
698 return kTRUE;
2bb2434e 699}
700
701///________________________________________________________________________
ca91a3e1 702Bool_t AliConversionMesonCuts::SetNumberOfBGEvents(Int_t NumberOfBGEvents){
e5b6e8a6 703 // Set Cut
704 switch(NumberOfBGEvents){
705 case 0:
706 fNumberOfBGEvents = 5;
707 break;
708 case 1:
709 fNumberOfBGEvents = 10;
710 break;
711 case 2:
712 fNumberOfBGEvents = 15;
713 break;
714 case 3:
715 fNumberOfBGEvents = 20;
716 break;
717 case 4:
718 fNumberOfBGEvents = 2;
719 break;
720 case 5:
721 fNumberOfBGEvents = 50;
722 break;
723 case 6:
724 fNumberOfBGEvents = 80;
725 break;
726 case 7:
727 fNumberOfBGEvents = 100;
728 break;
729 default:
730 cout<<"Warning: NumberOfBGEvents not defined "<<NumberOfBGEvents<<endl;
731 return kFALSE;
732 }
733 return kTRUE;
2bb2434e 734}
2bb2434e 735///________________________________________________________________________
736Bool_t AliConversionMesonCuts::SetSharedElectronCut(Int_t sharedElec) {
737
e5b6e8a6 738 switch(sharedElec){
739 case 0:
740 fDoSharedElecCut = kFALSE;
741 break;
742 case 1:
743 fDoSharedElecCut = kTRUE;
744 break;
745 default:
746 cout<<"Warning: Shared Electron Cut not defined "<<sharedElec<<endl;
747 return kFALSE;
748 }
2bb2434e 749
e5b6e8a6 750 return kTRUE;
2bb2434e 751}
752
753///________________________________________________________________________
754Bool_t AliConversionMesonCuts::SetToCloseV0sCut(Int_t toClose) {
755
e5b6e8a6 756 switch(toClose){
757 case 0:
758 fDoToCloseV0sCut = kFALSE;
759 fminV0Dist = 250;
760 break;
761 case 1:
762 fDoToCloseV0sCut = kTRUE;
763 fminV0Dist = 1;
764 break;
765 case 2:
766 fDoToCloseV0sCut = kTRUE;
767 fminV0Dist = 2;
768 break;
769 case 3:
770 fDoToCloseV0sCut = kTRUE;
771 fminV0Dist = 3;
772 break;
773 default:
774 cout<<"Warning: Shared Electron Cut not defined "<<toClose<<endl;
775 return kFALSE;
776 }
777 return kTRUE;
2bb2434e 778}
779
ca91a3e1 780///________________________________________________________________________
781Bool_t AliConversionMesonCuts::SetMCPSmearing(Int_t useMCPSmearing)
782{// Set Cut
e5b6e8a6 783 switch(useMCPSmearing){
784 case 0:
785 fUseMCPSmearing=0;
786 fPBremSmearing=1.;
787 fPSigSmearing=0.;
788 fPSigSmearingCte=0.;
789 break;
790 case 1:
791 fUseMCPSmearing=1;
792 fPBremSmearing=1.0e-14;
793 fPSigSmearing=0.;
794 fPSigSmearingCte=0.;
795 break;
796 case 2:
797 fUseMCPSmearing=1;
798 fPBremSmearing=1.0e-15;
799 fPSigSmearing=0.0;
800 fPSigSmearingCte=0.;
801 break;
802 case 3:
803 fUseMCPSmearing=1;
804 fPBremSmearing=1.;
805 fPSigSmearing=0.003;
806 fPSigSmearingCte=0.002;
807 break;
808 case 4:
809 fUseMCPSmearing=1;
810 fPBremSmearing=1.;
811 fPSigSmearing=0.003;
812 fPSigSmearingCte=0.007;
813 break;
814 case 5:
815 fUseMCPSmearing=1;
816 fPBremSmearing=1.;
817 fPSigSmearing=0.003;
818 fPSigSmearingCte=0.016;
819 break;
820 case 6:
821 fUseMCPSmearing=1;
822 fPBremSmearing=1.;
823 fPSigSmearing=0.007;
824 fPSigSmearingCte=0.016;
825 break;
826 case 7:
827 fUseMCPSmearing=1;
828 fPBremSmearing=1.0e-16;
829 fPSigSmearing=0.0;
830 fPSigSmearingCte=0.;
831 break;
832 case 8:
833 fUseMCPSmearing=1;
834 fPBremSmearing=1.;
835 fPSigSmearing=0.007;
836 fPSigSmearingCte=0.014;
837 break;
838 case 9:
839 fUseMCPSmearing=1;
840 fPBremSmearing=1.;
841 fPSigSmearing=0.007;
842 fPSigSmearingCte=0.011;
843 break;
844
845 default:
846 AliError("Warning: UseMCPSmearing not defined");
847 return kFALSE;
848 }
849 return kTRUE;
ca91a3e1 850}
2bb2434e 851///________________________________________________________________________
852TString AliConversionMesonCuts::GetCutNumber(){
e5b6e8a6 853 // returns TString with current cut number
854 TString a(kNCuts);
855 for(Int_t ii=0;ii<kNCuts;ii++){
856 a.Append(Form("%d",fCuts[ii]));
857 }
858 return a;
2bb2434e 859}
860
861///________________________________________________________________________
862void AliConversionMesonCuts::FillElectonLabelArray(AliAODConversionPhoton* photon, Int_t nV0){
863
e5b6e8a6 864 Int_t posLabel = photon->GetTrackLabelPositive();
865 Int_t negLabel = photon->GetTrackLabelNegative();
2bb2434e 866
e5b6e8a6 867 fElectronLabelArray[nV0*2] = posLabel;
868 fElectronLabelArray[(nV0*2)+1] = negLabel;
2bb2434e 869}
870
871///________________________________________________________________________
872Bool_t AliConversionMesonCuts::RejectSharedElectronV0s(AliAODConversionPhoton* photon, Int_t nV0, Int_t nV0s){
873
e5b6e8a6 874 Int_t posLabel = photon->GetTrackLabelPositive();
875 Int_t negLabel = photon->GetTrackLabelNegative();
2bb2434e 876
e5b6e8a6 877 for(Int_t i = 0; i<nV0s*2;i++){
878 if(i==nV0*2) continue;
879 if(i==(nV0*2)+1) continue;
880 if(fElectronLabelArray[i] == posLabel){
881 return kFALSE;}
882 if(fElectronLabelArray[i] == negLabel){
883 return kFALSE;}
884 }
2bb2434e 885
e5b6e8a6 886 return kTRUE;
2bb2434e 887}
888///________________________________________________________________________
889Bool_t AliConversionMesonCuts::RejectToCloseV0s(AliAODConversionPhoton* photon, TList *photons, Int_t nV0){
e5b6e8a6 890 Double_t posX = photon->GetConversionX();
891 Double_t posY = photon->GetConversionY();
892 Double_t posZ = photon->GetConversionZ();
893
894 for(Int_t i = 0;i<photons->GetEntries();i++){
895 if(nV0 == i) continue;
896 AliAODConversionPhoton *photonComp = (AliAODConversionPhoton*) photons->At(i);
897 Double_t posCompX = photonComp->GetConversionX();
898 Double_t posCompY = photonComp->GetConversionY();
899 Double_t posCompZ = photonComp->GetConversionZ();
2bb2434e 900
e5b6e8a6 901 Double_t dist = pow((posX - posCompX),2)+pow((posY - posCompY),2)+pow((posZ - posCompZ),2);
2bb2434e 902
e5b6e8a6 903 if(dist < fminV0Dist*fminV0Dist){
904 if(photon->GetChi2perNDF() < photonComp->GetChi2perNDF()) return kTRUE;
905 else {
906 return kFALSE;}
907 }
2bb2434e 908
e5b6e8a6 909 }
910 return kTRUE;
2bb2434e 911}
ca91a3e1 912
913///________________________________________________________________________
914void AliConversionMesonCuts::SmearParticle(AliAODConversionPhoton* photon)
915{
916 Double_t facPBrem = 1.;
917 Double_t facPSig = 0.;
918
919 Double_t phi=0.;
920 Double_t theta=0.;
921 Double_t P=0.;
922
923
924 P=photon->P();
925 phi=photon->Phi();
926 if( photon->P()!=0){
927 theta=acos( photon->Pz()/ photon->P());
928 }
929
930 if( fPSigSmearing != 0. || fPSigSmearingCte!=0. ){
931 facPSig = TMath::Sqrt(fPSigSmearingCte*fPSigSmearingCte+fPSigSmearing*fPSigSmearing*P*P)*fRandom.Gaus(0.,1.);
932 }
933
934 if( fPBremSmearing != 1.){
935 if(fBrem!=NULL){
936 facPBrem = fBrem->GetRandom();
937 }
938 }
939
940 photon->SetPx(facPBrem* (1+facPSig)* P*sin(theta)*cos(phi)) ;
941 photon->SetPy(facPBrem* (1+facPSig)* P*sin(theta)*sin(phi)) ;
942 photon->SetPz(facPBrem* (1+facPSig)* P*cos(theta)) ;
943 photon->SetE(photon->P());
944}