Change Mult binning scheme
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliDielectronEventCuts.cxx
CommitLineData
2a14a7b1 1/*************************************************************************
2* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
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// Dielectron EventCuts //
18// //
19// //
20/*
21Detailed description
22
23
24*/
25// //
26///////////////////////////////////////////////////////////////////////////
27
5720c765 28
2a14a7b1 29#include <AliTriggerAnalysis.h>
30#include <AliESDVertex.h>
d327d9cd 31#include <AliAODVertex.h>
2a14a7b1 32#include <AliESDEvent.h>
d327d9cd 33#include <AliAODEvent.h>
ffbede40 34#include <AliMultiplicity.h>
ba15fdfb 35#include <AliCentrality.h>
90c1ae2d 36#include <AliESDVZERO.h>
37#include <AliAODVZERO.h>
2a14a7b1 38
99345a64 39#include "AliDielectronVarManager.h"
2a14a7b1 40#include "AliDielectronEventCuts.h"
41
42ClassImp(AliDielectronEventCuts)
43
1bb1fef1 44const char* AliDielectronEventCuts::fgkVtxNames[AliDielectronEventCuts::kVtxTracksOrSPD+1] = {"Tracks", "SPD", "TPC", "Any", "TracksOrSPD"};
45
2a14a7b1 46AliDielectronEventCuts::AliDielectronEventCuts() :
47 AliAnalysisCuts(),
48 fVtxZmin(0.),
49 fVtxZmax(0.),
50 fRequireVtx(kFALSE),
51 fMinVtxContributors(0),
ffbede40 52 fMultITSTPC(kFALSE),
ba15fdfb 53 fCentMin(1.),
54 fCentMax(0.),
2a14a7b1 55 fVtxType(kVtxTracks),
b2ad74d0 56 fRequire13sel(kFALSE),
57 fUtils(),
2a14a7b1 58 fRequireV0and(0),
59 fTriggerAnalysis(0x0),
d327d9cd 60 fkVertex(0x0),
90c1ae2d 61 fkVertexAOD(0x0),
62 fparMean(0x0),
63 fparSigma(0x0),
6bd73568 64 fcutSigma(3.),
65 fparMinVtxContributors(0x0),
66 fparMaxVtxContributors(0x0)
2a14a7b1 67{
68 //
69 // Default Constructor
70 //
71
72}
73
74//______________________________________________
75AliDielectronEventCuts::AliDielectronEventCuts(const char* name, const char* title) :
76 AliAnalysisCuts(name, title),
77 fVtxZmin(0.),
78 fVtxZmax(0.),
79 fRequireVtx(kFALSE),
80 fMinVtxContributors(0),
ffbede40 81 fMultITSTPC(kFALSE),
ba15fdfb 82 fCentMin(1.),
83 fCentMax(0.),
2a14a7b1 84 fVtxType(kVtxTracks),
b2ad74d0 85 fRequire13sel(kFALSE),
86 fUtils(),
2a14a7b1 87 fRequireV0and(0),
88 fTriggerAnalysis(0x0),
d327d9cd 89 fkVertex(0x0),
90c1ae2d 90 fkVertexAOD(0x0),
91 fparMean(0x0),
92 fparSigma(0x0),
6bd73568 93 fcutSigma(3.),
94 fparMinVtxContributors(0x0),
95 fparMaxVtxContributors(0x0)
2a14a7b1 96{
97 //
98 // Named Constructor
99 //
100}
101
102//______________________________________________
103AliDielectronEventCuts::~AliDielectronEventCuts()
104{
105 //
106 // Default Destructor
107 //
108 if (fTriggerAnalysis) delete fTriggerAnalysis;
109}
110
111//______________________________________________
112Bool_t AliDielectronEventCuts::IsSelected(TObject* event)
113{
114 //
115 // check the cuts
116 //
117
d327d9cd 118 if(event->IsA() == AliESDEvent::Class()) return IsSelectedESD(event);
119 else if(event->IsA() == AliAODEvent::Class()) return IsSelectedAOD(event);
120 else return kFALSE;
121}
122//____________________________________________________________________
123Bool_t AliDielectronEventCuts::IsSelectedESD(TObject* event)
124{
125 //
126 // check the cuts
127 //
128
2a14a7b1 129 AliESDEvent *ev=dynamic_cast<AliESDEvent*>(event);
130 if (!ev) return kFALSE;
131
ba15fdfb 132 if (fCentMin<fCentMax){
133 AliCentrality *centrality=ev->GetCentrality();
134 Double_t centralityF=-1;
135 if (centrality) centralityF = centrality->GetCentralityPercentile("V0M");
136 if (centralityF<fCentMin || centralityF>=fCentMax) return kFALSE;
137 }
138
2a14a7b1 139 fkVertex=0x0;
5720c765 140
2a14a7b1 141 switch(fVtxType){
1201a1a9 142 case kVtxTracks:
143 case kVtxTracksOrSPD:
144 fkVertex=ev->GetPrimaryVertexTracks();
145 break;
2a14a7b1 146 case kVtxSPD: fkVertex=ev->GetPrimaryVertexSPD(); break;
147 case kVtxTPC: fkVertex=ev->GetPrimaryVertexTPC(); break;
148 case kVtxAny: fkVertex=ev->GetPrimaryVertex(); break;
149 }
150
151 if ((fRequireVtx||fVtxZmin<fVtxZmax||fMinVtxContributors>0)&&!fkVertex) return kFALSE;
152
2a14a7b1 153
154 if (fMinVtxContributors>0){
155 Int_t nCtrb = fkVertex->GetNContributors();
ba15fdfb 156 if (nCtrb<fMinVtxContributors){
157 if (fVtxType==kVtxTracksOrSPD){
158 fkVertex=ev->GetPrimaryVertexSPD();
159 nCtrb = fkVertex->GetNContributors();
160 if (nCtrb<fMinVtxContributors) return kFALSE;
161 } else {
162 return kFALSE;
163 }
164 }
2a14a7b1 165 }
166
ba15fdfb 167 if (fVtxZmin<fVtxZmax){
168 Double_t zvtx=fkVertex->GetZv();
169 if (zvtx<fVtxZmin||zvtx>fVtxZmax) return kFALSE;
170 }
b2ad74d0 171
172 if(fRequire13sel){
173 if(!fUtils.IsVertexSelected2013pA(ev)) return kFALSE;
174 if(fUtils.IsFirstEventInChunk(ev)) return kFALSE;
175 }
176
2a14a7b1 177 if (fRequireV0and){
178 if (!fTriggerAnalysis) fTriggerAnalysis=new AliTriggerAnalysis;
179 Bool_t v0AND = kFALSE;
180 if (fRequireV0and==1){
181 Bool_t v0A = fTriggerAnalysis->IsOfflineTriggerFired(ev, AliTriggerAnalysis::kV0A);
182 Bool_t v0C = fTriggerAnalysis->IsOfflineTriggerFired(ev, AliTriggerAnalysis::kV0C);
183 v0AND = v0A && v0C;
184 }
185
186 if (fRequireV0and==2){
187 Bool_t v0AHW = (fTriggerAnalysis->V0Trigger(ev, AliTriggerAnalysis::kASide, kTRUE) == AliTriggerAnalysis::kV0BB);
188 Bool_t v0CHW = (fTriggerAnalysis->V0Trigger(ev, AliTriggerAnalysis::kCSide, kTRUE) == AliTriggerAnalysis::kV0BB);
189 v0AND = v0AHW && v0CHW;
190 }
191
192 if (!v0AND) return kFALSE;
193 }
ffbede40 194
195 if (fMultITSTPC){
196 const AliESDVertex *vtxESDTPC=ev->GetPrimaryVertexTPC();
197 const AliMultiplicity *multESD = ev->GetMultiplicity();
198 if ( vtxESDTPC && multESD && vtxESDTPC->GetNContributors() < (-10.+0.25*multESD->GetNumberOfITSClusters(0)) )
199 return kFALSE;
200 }
ba15fdfb 201
90c1ae2d 202 if(fparMean && fparSigma) {
203 Double_t nTrks = ev->GetNumberOfTracks();
204 Double_t multV0 = 0.0;
205 for(Int_t j=0; j<64; j++) multV0 += ev->GetVZEROData()->GetMultiplicity(j);
206 Double_t mV0 = fparMean->Eval(nTrks);
207 Double_t sV0 = fparSigma->Eval(nTrks);
77e2c705 208 if(multV0 > mV0+fcutSigma*sV0 || multV0 < mV0-fcutSigma*sV0) return kFALSE;
90c1ae2d 209 }
210
6bd73568 211 // cut on the number of vertex contributors using TPC versus global vertex
212 if(fparMinVtxContributors && fparMaxVtxContributors) {
213 const AliESDVertex *vtxTPC = ev->GetPrimaryVertexTPC();
214 const AliESDVertex *vtxGbl = ev->GetPrimaryVertex();
215 Double_t nContribTPC = (vtxTPC ? vtxTPC->GetNContributors() : 0);
216 Double_t nContribGbl = (vtxGbl ? vtxGbl->GetNContributors() : 0);
217 Double_t minCut = fparMinVtxContributors->Eval(nContribGbl);
218 Double_t maxCut = fparMaxVtxContributors->Eval(nContribGbl);
219 if(nContribTPC > maxCut || nContribTPC < minCut) return kFALSE;
220 }
221
222
2a14a7b1 223 return kTRUE;
224}
d327d9cd 225//______________________________________________
226Bool_t AliDielectronEventCuts::IsSelectedAOD(TObject* event)
227{
228 //
229 // check the cuts
230 //
231
232 AliAODEvent *ev=dynamic_cast<AliAODEvent*>(event);
233 if (!ev) return kFALSE;
234
235 if (fCentMin<fCentMax){
236 AliCentrality *centrality=ev->GetCentrality();
237 Double_t centralityF=-1;
238 if (centrality) centralityF = centrality->GetCentralityPercentile("V0M");
239 if (centralityF<fCentMin || centralityF>=fCentMax) return kFALSE;
240 }
241
242 fkVertexAOD=0x0;
243
244 switch(fVtxType){
e4339752 245 case kVtxTracks: fkVertexAOD=0x0; break;
99345a64 246 case kVtxTPC: fkVertexAOD=AliDielectronVarManager::GetVertex(ev, AliAODVertex::kMainTPC); break;
d327d9cd 247 case kVtxSPD:
e4339752 248 case kVtxTracksOrSPD: fkVertexAOD=ev->GetPrimaryVertexSPD(); break;
249 case kVtxAny: fkVertexAOD=ev->GetPrimaryVertex(); break;
d327d9cd 250 }
251
252 if ((fRequireVtx||fVtxZmin<fVtxZmax||fMinVtxContributors>0)&&!fkVertexAOD) return kFALSE;
253
254 if (fMinVtxContributors>0){
255 Int_t nCtrb = fkVertexAOD->GetNContributors();
256 if (nCtrb<fMinVtxContributors){
a823f01b 257 // if (fVtxType==kVtxTracksOrSPD){
258 // fkVertexAOD=ev->GetVertex(AliAODVertex::kPrimary);
259 // nCtrb = fkVertexAOD->GetNContributors();
260 // if (nCtrb<fMinVtxContributors) return kFALSE;
261 // } else {
262 return kFALSE;
263 //}
d327d9cd 264 }
265 }
a823f01b 266
d327d9cd 267
268 if (fVtxZmin<fVtxZmax){
269 Double_t zvtx=fkVertexAOD->GetZ();
270 if (zvtx<fVtxZmin||zvtx>fVtxZmax) return kFALSE;
271 }
a823f01b 272
b2ad74d0 273 if(fRequire13sel){
274 if(!fUtils.IsVertexSelected2013pA(ev)) return kFALSE;
275 if(fUtils.IsFirstEventInChunk(ev)) return kFALSE;
276 }
277
d327d9cd 278 /*
279 if (fRequireV0and){
280 // if (!fTriggerAnalysis) fTriggerAnalysis=new AliTriggerAnalysis;
281 Bool_t v0AND = kFALSE;
282 if (fRequireV0and==1){
283 Bool_t v0A = fTriggerAnalysis->IsOfflineTriggerFired(ev, AliTriggerAnalysis::kV0A);
284 Bool_t v0A = header->GetOfflineTrigger(); //TODO
285 Bool_t v0C = fTriggerAnalysis->IsOfflineTriggerFired(ev, AliTriggerAnalysis::kV0C);
286 v0AND = v0A && v0C;
287 }
288
289 if (fRequireV0and==2){
290 Bool_t v0AHW = (fTriggerAnalysis->V0Trigger(ev, AliTriggerAnalysis::kASide, kTRUE) == AliTriggerAnalysis::kV0BB);
291 Bool_t v0CHW = (fTriggerAnalysis->V0Trigger(ev, AliTriggerAnalysis::kCSide, kTRUE) == AliTriggerAnalysis::kV0BB);
292 v0AND = v0AHW && v0CHW;
293 }
294
295 if (!v0AND) return kFALSE;
296 }
297 */
298 /* if (fMultITSTPC){
299 const AliESDVertex *vtxESDTPC=ev->GetPrimaryVertexTPC();
300 const AliMultiplicity *multESD = ev->GetMultiplicity();
301 if ( vtxESDTPC && multESD && vtxESDTPC->GetNContributors() < (-10.+0.25*multESD->GetNumberOfITSClusters(0)) )
302 return kFALSE;
303 }
304 */
6bd73568 305
306 // correlation cut Ntrks vs. multV0
90c1ae2d 307 if(fparMean && fparSigma) {
308 Double_t nTrks = ev->GetNumberOfTracks();
309 Double_t multV0 = 0.0;
310 for(Int_t j=0; j<64; j++) multV0 += ev->GetVZEROData()->GetMultiplicity(j);
311 Double_t mV0 = fparMean->Eval(nTrks);
312 Double_t sV0 = fparSigma->Eval(nTrks);
313 if(multV0 > mV0+fcutSigma*sV0 || multV0 < mV0-fcutSigma*sV0) return kFALSE;
314 }
315
6bd73568 316 // cut on the number of vertex contributors using TPC versus global vertex
317 if(fparMinVtxContributors && fparMaxVtxContributors) {
318 const AliAODVertex *vtxTPC = ev->GetVertex(AliAODVertex::kMainTPC);
319 const AliAODVertex *vtxGbl = ev->GetPrimaryVertex();
320 Double_t nContribTPC = (vtxTPC ? vtxTPC->GetNContributors() : 0);
321 Double_t nContribGbl = (vtxGbl ? vtxGbl->GetNContributors() : 0);
322 Double_t minCut = fparMinVtxContributors->Eval(nContribGbl);
323 Double_t maxCut = fparMaxVtxContributors->Eval(nContribGbl);
324 if(nContribTPC > maxCut || nContribTPC < minCut) return kFALSE;
325 }
326
d327d9cd 327 return kTRUE;
328}
2a14a7b1 329
1bb1fef1 330//________________________________________________________________________
331void AliDielectronEventCuts::Print(const Option_t* /*option*/) const
332{
333 //
334 // Print cuts and the range
335 //
336 printf("cut ranges for '%s'\n",GetTitle());
337 printf("All Cuts have to be fulfilled\n");
338
339 Int_t iCut=0;
340 if(fRequireVtx) {
341 printf("Cut %02d: vertex required \n",iCut); iCut++; }
342 printf("Cut %02d: vertex type: %s \n", iCut, fgkVtxNames[fVtxType]); iCut++;
343 if(fMinVtxContributors) {
344 printf("Cut %02d: vertex contributors >= %d \n", iCut, fMinVtxContributors); iCut++; }
345 if(fVtxZmin<fVtxZmax) {
90c1ae2d 346 printf("Cut %02d: %f < %s < %f\n", iCut, fVtxZmin, "Zvtx", fVtxZmax); iCut++; }
1bb1fef1 347 if(fCentMin<fCentMax) {
348 printf("Cut %02d: %f < %s < %f\n", iCut, fCentMin, "V0centrality", fCentMax);iCut++; }
349 if(fMultITSTPC) {
350 printf("Cut %02d: cut on multiplcity ITS vs. TPC \n", iCut); iCut++; }
90c1ae2d 351 if(fparMean&&fparSigma) {
352 printf("Cut %02d: multplicity vs. #tracks correlation +-%.1f sigma inclusion \n", iCut, fcutSigma); iCut++; }
b2ad74d0 353 if(fRequire13sel){
354 printf("Cut %02d: vertex and event selection for 2013 pPb data taking required \n",iCut); iCut++; }
1bb1fef1 355 if(fRequireV0and) {
356 printf("Cut %02d: require V0and type: %c \n", iCut, fRequireV0and); iCut++; }
357
358}
359