a5bc90a1ee73b6476629310d91dda97f7ab01aa6
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / macrosJPSI / ConfigJpsi_nano_PbPb.C
1 void InitHistograms(AliDielectron *die, Int_t cutDefinition);
2
3 void SetupEventCuts(AliDielectron *die, Int_t cutDefinition);
4 void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition);
5 void SetupV0Cuts(   AliDielectron *die, Int_t cutDefinition);
6 void SetupPairCuts( AliDielectron *die, Int_t cutDefinition);
7
8 void ConfigEvtPlane(AliDielectron *die, Int_t cutDefinition);
9 void SetEtaCorrection(AliDielectron *die);
10
11 TString names=("NANO");
12 enum { kNANO=0 };
13
14 TObjArray *arrNames=names.Tokenize(";");
15 const Int_t nDie=arrNames->GetEntries();
16
17 Bool_t  isESD     = kTRUE;
18 TString periodLHC = "";
19 TString list  = gSystem->Getenv("LIST");
20
21
22 AliDielectron* ConfigJpsi_nano_PbPb(Int_t cutDefinition, Bool_t hasMC=kFALSE, TString period="")
23 {
24   //
25   // Setup the instance of AliDielectron
26   //
27
28   periodLHC = period;
29   printf("this is -%s- filtering \n",periodLHC.Data());
30
31   //ESD handler?
32   isESD=(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->IsA()==AliESDInputHandler::Class());
33
34   // task name
35   TString name=Form("%02d",cutDefinition);
36   if (cutDefinition<arrNames->GetEntriesFast())  name=arrNames->At(cutDefinition)->GetName();
37   printf(" Adding %s%s config %s for %s \n",(isESD?"ESD":"AOD"),(hasMC?" MC":""),name.Data(),list.Data());
38
39   // init AliDielectron
40   AliDielectron *die = new AliDielectron(Form("%s",name.Data()), Form("%s",name.Data()));
41   die->SetHasMC(hasMC);
42
43   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
44   SetupEventCuts(die,cutDefinition);
45   SetupTrackCuts(die,cutDefinition);
46   // SetupV0Cuts(die,cutDefinition);   // switch off for nanoAODs??
47   // SetupPairCuts(die,cutDefinition);
48
49   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv MISC vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
50   // PID eta correction
51   //SetEtaCorrection(die); //no eta corrction
52   // prefilter settings
53   //  if(hasMC)
54   die->SetNoPairing();
55   //  else die->SetPreFilterUnlikeOnly();
56   //die->SetPreFilterAllSigns();
57
58   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv OUTPUT vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
59   // histogram setup
60   InitHistograms(die,cutDefinition);
61
62   // cut QA
63   die->SetCutQA();
64
65   return die;
66 }
67
68 //______________________________________________________________________________________
69 void SetupEventCuts(AliDielectron *die, Int_t cutDefinition)
70 {
71   //
72   // Setup the event cuts
73   //
74
75   AliDielectronEventCuts *eventCuts=new AliDielectronEventCuts("eventCuts","eventCuts");
76   if(!isESD) eventCuts->SetVertexType(AliDielectronEventCuts::kVtxAny);
77   eventCuts->SetRequireVertex();
78   eventCuts->SetMinVtxContributors(1);
79   //  eventCuts->SetVertexZ(-10.,+10.);
80   eventCuts->SetCentralityRange(0., 90.);
81   eventCuts->Print();
82   die->GetEventFilter().AddCuts(eventCuts);
83
84 }
85
86 //______________________________________________________________________________________
87 void SetupTrackCuts(AliDielectron *die, Int_t cutDefinition)
88 {
89   //
90   // Setup the track cuts
91   //
92
93   Bool_t hasMC=die->GetHasMC();
94
95   // Quality cuts
96   AliDielectronCutGroup* cuts = new AliDielectronCutGroup("cuts","cuts",AliDielectronCutGroup::kCompAND);
97   die->GetTrackFilter().AddCuts(cuts);
98
99   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv FILTER CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
100   // AOD track filter (needs to be first cut to speed up)
101   AliDielectronTrackCuts *trkFilter = new AliDielectronTrackCuts("TrkFilter","TrkFilter");
102   trkFilter->SetAODFilterBit(AliDielectronTrackCuts::kTPCqual);
103   //  trkFilter->SetAODFilterBit(AliDielectronTrackCuts::kTPCqualSPDany);
104   //  trkFilter->SetMinNCrossedRowsOverFindable(0.6);
105
106   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv TRACK CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
107   AliDielectronVarCuts *varCuts   = new AliDielectronVarCuts("VarCuts","VarCuts");
108   AliDielectronTrackCuts *trkCuts = new AliDielectronTrackCuts("TrkCuts","TrkCuts");
109   // specific cuts
110   varCuts->AddCut(AliDielectronVarManager::kPt,           0.85, 1e30);
111   varCuts->AddCut(AliDielectronVarManager::kEta,         -0.9,   0.9);
112   if(periodLHC.Contains("LHC11h"))
113     varCuts->AddCut(AliDielectronVarManager::kTPCclsSegments,7.,   8.0);
114   varCuts->AddCut(AliDielectronVarManager::kNclsTPC,     70.0, 160.0);
115   //  trkCuts->SetITSclusterCut(AliDielectronTrackCuts::kOneOf, 3); // SPD any
116
117   // standard cuts
118   varCuts->AddCut(AliDielectronVarManager::kImpactParXY, -1.0,   1.0);
119   varCuts->AddCut(AliDielectronVarManager::kImpactParZ,  -3.0,   3.0);
120   varCuts->AddCut(AliDielectronVarManager::kTPCchi2Cl,    0.0,   4.0);
121   varCuts->AddCut(AliDielectronVarManager::kKinkIndex0,   0.);
122   trkCuts->SetRequireITSRefit(kTRUE);
123   trkCuts->SetRequireTPCRefit(kTRUE);
124
125   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv PID CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
126   //  AliDielectronVarCuts *pidVarCuts = new AliDielectronVarCuts("varPIDCuts","varPIDCuts");
127   AliDielectronPID *pidCuts        = new AliDielectronPID("PIDCuts","PIDCuts");
128   // TOF inclusion
129   //  pidVarCuts->AddCut(AliDielectronVarManager::kTOFbeta,      0.2,   0.9, kTRUE);
130   //  pidCuts->AddCut(AliDielectronPID::kTOF,AliPID::kElectron,-3,3.,0.,0.,kFALSE, AliDielectronPID::kIfAvailable);
131   // TPC inclusion
132   if(periodLHC.Contains("LHC10h"))
133     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-4.0,4.7); // when eta correction OFF (LHC10h) [/*-2.0*/,+3.]
134   else
135     pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kElectron,-3.0,4.3); // when eta correction OFF (LHC11h) [-1.5,+3.]
136   //  pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kPion,-100.,4.0,0.,0.,kTRUE);
137   //  pidCuts->AddCut(AliDielectronPID::kTPC,AliPID::kProton,-100.,3.5,0.,0.,kTRUE);
138
139   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv MC PID CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
140   AliDielectronVarCuts *pidCutsMC = new AliDielectronVarCuts("PIDCutsMC","PIDCutsMC");
141   pidCutsMC->SetCutType(AliDielectronVarCuts::kAny);
142   pidCutsMC->SetCutOnMCtruth(kTRUE);
143   pidCutsMC->AddCut(AliDielectronVarManager::kPdgCode, -11., -11.);
144   pidCutsMC->AddCut(AliDielectronVarManager::kPdgCode, +11., +11.);
145
146   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv TENDER CUTS vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
147   // exclude conversion electrons selected by the tender
148   AliDielectronTrackCuts *noconv=new AliDielectronTrackCuts("noConv","noConv");
149   noconv->SetV0DaughterCut(AliPID::kElectron,kTRUE);
150
151   // activate the cut sets (order might be CPU timewise important)
152   if(hasMC) {
153     //    cuts->AddCut(pidCutsMC);
154   }
155   else {
156     if(!isESD) cuts->AddCut(trkFilter);
157     cuts->AddCut(varCuts);
158     cuts->AddCut(trkCuts);
159     cuts->AddCut(pidCuts);
160     //cuts->AddCut(pidVarCuts);
161     //cuts->AddCut(noconv);
162   }
163   cuts->Print();
164
165 }
166
167 //______________________________________________________________________________________
168 void SetupV0Cuts(AliDielectron *die, Int_t cutDefinition)
169 {
170   //
171   // Setup the V0 cuts
172   //
173
174   // Quality cuts (add the gamma filter to the cut group)
175   TIter next(die->GetTrackFilter().GetCuts());
176   AliAnalysisCuts *cuts;
177   while((cuts = (AliAnalysisCuts*)next())) {
178     if(cuts->IsA() == AliDielectronCutGroup::Class())  break;
179   }
180
181   AliDielectronV0Cuts *gammaV0Cuts = new AliDielectronV0Cuts("IsGamma","IsGamma");
182   gammaV0Cuts->SetPdgCodes(22,11,11);
183   gammaV0Cuts->SetDefaultPID(16);
184   gammaV0Cuts->AddCut(AliDielectronVarManager::kCosPointingAngle, TMath::Cos(0.02),   1.0, kFALSE);
185   gammaV0Cuts->AddCut(AliDielectronVarManager::kChi2NDF,                       0.0,  10.0, kFALSE);
186   gammaV0Cuts->AddCut(AliDielectronVarManager::kLegDist,                       0.0,   0.25, kFALSE);
187   gammaV0Cuts->AddCut(AliDielectronVarManager::kR,                             3.0,  90.0, kFALSE);
188   gammaV0Cuts->AddCut(AliDielectronVarManager::kPsiPair,                       0.0,   0.05, kFALSE);
189   gammaV0Cuts->AddCut(AliDielectronVarManager::kM,                             0.0,   0.05, kFALSE);
190   //  gammaV0Cuts->AddCut(AliDielectronVarManager::kOpeningAngle,              0.0,   0.1, kFALSE);
191   gammaV0Cuts->AddCut(AliDielectronVarManager::kArmPt,                         0.0,   0.05, kFALSE);
192   //  gammaV0Cuts->AddCut(AliDielectronVarManager::kArmAlpha,                     -0.35,  0.35, kFALSE); // not sure if it works as expected
193   gammaV0Cuts->SetExcludeTracks(kTRUE);
194   gammaV0Cuts->Print();
195
196  //  const Double_t |cutAlphaG| < 0.35; &&  const Double_t cutQTG < 0.05;
197  //  const Double_t |cutAlphaG2|[2] = {0.6, 0.8}; &&  const Double_t cutQTG2 < 0.04;
198
199   if(cuts)
200     ((AliDielectronCutGroup*)cuts)->AddCut(gammaV0Cuts);
201   else
202     die->GetTrackFilter().AddCuts(gammaV0Cuts);
203 }
204
205 //______________________________________________________________________________________
206 void SetupPairCuts(AliDielectron *die, Int_t cutDefinition)
207 {
208   //
209   // Setup the pair cuts
210   //
211
212   // conversion rejection
213   Double_t gCut=0.05;
214   AliDielectronVarCuts *gammaCuts = new AliDielectronVarCuts("GammaCuts","GammaCuts");
215   gammaCuts->AddCut(AliDielectronVarManager::kM,            0.0,   gCut);
216   //  die->GetPairPreFilter().AddCuts(gammaCuts);
217
218   // rapidity selection
219   Double_t yCut=0.9;
220   AliDielectronVarCuts *rapCut=new AliDielectronVarCuts(Form("|Y|<%.1f",yCut),Form("|Y|<%.1f",yCut));
221   rapCut->AddCut(AliDielectronVarManager::kY,-1.*yCut,yCut);
222   die->GetPairFilter().AddCuts(rapCut);
223
224 }
225
226 //______________________________________________________________________________________
227 void InitHistograms(AliDielectron *die, Int_t cutDefinition)
228 {
229   //
230   // Initialise the histograms
231   //
232   Bool_t hasMC=die->GetHasMC();
233
234   //Setup histogram Manager
235   AliDielectronHistos *histos=new AliDielectronHistos(die->GetName(),die->GetTitle());
236
237   //add histograms to event class
238   histos->AddClass("Event");
239   histos->UserHistogram("Event","","", 100, 0.0, 100.0,   AliDielectronVarManager::kCentrality);
240   histos->UserHistogram("Event","","", 300,-15., +15.0,   AliDielectronVarManager::kZvPrim);
241   // candidates monitoring
242   histos->UserProfile("Event","","", AliDielectronVarManager::kTracks, 100,0,100., AliDielectronVarManager::kCentrality);
243   histos->UserProfile("Event","","", AliDielectronVarManager::kPairs,  100,0,100., AliDielectronVarManager::kCentrality);
244
245   die->SetHistogramManager(histos);
246 }
247
248 //______________________________________________________________________________________
249 void SetEtaCorrection(AliDielectron *die) {
250
251   if (AliDielectronPID::GetCentroidCorrFunction()) return;
252
253   TF2 *fCntrdCorr=0x0;
254   TF1 *fWdthCorr=0x0;
255   /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv DATA vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
256   if( !die->GetHasMC() ) {
257     // 2-dimensional eta correction for the centroid of electron sigmas
258     fCntrdCorr = new TF2("fCntrdCorr", "[0] + [1]*y + [2]*y*y + [3]*TMath::Power(y,3) + [4]*TMath::Power(y,4) + [5]*TMath::Power(y,5) + [6]*TMath::Power(y,6) + [7]*x",
259                          //0.0, 3000.0, -0.9, +0.9); // Nacc
260                          0.0,   90.0, -0.9, +0.9); // centrality
261     //  fCntrdCorr->SetParameters(0.723106, 0.23958, -6.31221, -0.687976, 15.912, 0.579609, -11.6901, -0.000354381); // Nacc
262     fCntrdCorr->SetParameters(+0.149002, +0.214644 , -6.034930, -0.529588, +14.97902, +0.402640, -10.890027, +0.011248); // centrality
263     // 1-dimensional eta correction for the width of electron sigmas
264     // fWdthCorr = new TF1("fWdthCorr", "pol2", 0.0, 3000.0);     // Nacc
265     // fWdthCorr->SetParameters(1.06108, 0.000217804,-5.80291e-08);
266     fWdthCorr = new TF1("fWdthCorr", "pol2", 0.0, 90.0);       // centrality
267     fWdthCorr->SetParameters(+1.290755, -0.005261, +0.000021);
268   }
269   else  {
270     /* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv MONTE CARLO vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */
271     // 2-dimensional eta correction for the centroid of electron sigmas
272     fCntrdCorr = new TF2("fCntrdCorr", "[0] + [1]*y + [2]*y*y + [3]*TMath::Power(y,3) + [4]*TMath::Power(y,4) + [5]*TMath::Power(y,5) + [6]*TMath::Power(y,6) + [7]*x",
273                               0.0, 3000.0, -0.9, +0.9);
274     fCntrdCorr->SetParameters(+0.378611, -0.070831, -3.076778, +0.121977, +8.576097, +0.113009, -5.001368, -0.000181);
275
276     // 1-dimensional eta correction for the width of electron sigmas
277     fWdthCorr = new TF1("fWdthCorr", "pol1", 0.0, 3000.0);
278     fWdthCorr->SetParameters(+0.881894, +0.000053);
279   }
280
281   // apply corrections
282   // AliDielectronPID::SetCentroidCorrFunction(fCntrdCorr,AliDielectronVarManager::kNacc,AliDielectronVarManager::kEta);
283   // AliDielectronPID::SetWidthCorrFunction(fWdthCorr,AliDielectronVarManager::kNacc);
284   AliDielectronPID::SetCentroidCorrFunction(fCntrdCorr,AliDielectronVarManager::kCentrality,AliDielectronVarManager::kEta);
285   AliDielectronPID::SetWidthCorrFunction(fWdthCorr,AliDielectronVarManager::kCentrality);
286
287 }