]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGDQ/dielectron/AliDielectronEventCuts.cxx
- user updates
[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
39#include "AliDielectronEventCuts.h"
40
41ClassImp(AliDielectronEventCuts)
42
1bb1fef1 43const char* AliDielectronEventCuts::fgkVtxNames[AliDielectronEventCuts::kVtxTracksOrSPD+1] = {"Tracks", "SPD", "TPC", "Any", "TracksOrSPD"};
44
2a14a7b1 45AliDielectronEventCuts::AliDielectronEventCuts() :
46 AliAnalysisCuts(),
47 fVtxZmin(0.),
48 fVtxZmax(0.),
49 fRequireVtx(kFALSE),
50 fMinVtxContributors(0),
ffbede40 51 fMultITSTPC(kFALSE),
ba15fdfb 52 fCentMin(1.),
53 fCentMax(0.),
2a14a7b1 54 fVtxType(kVtxTracks),
55 fRequireV0and(0),
56 fTriggerAnalysis(0x0),
d327d9cd 57 fkVertex(0x0),
90c1ae2d 58 fkVertexAOD(0x0),
59 fparMean(0x0),
60 fparSigma(0x0),
61 fcutSigma(3.)
2a14a7b1 62{
63 //
64 // Default Constructor
65 //
66
67}
68
69//______________________________________________
70AliDielectronEventCuts::AliDielectronEventCuts(const char* name, const char* title) :
71 AliAnalysisCuts(name, title),
72 fVtxZmin(0.),
73 fVtxZmax(0.),
74 fRequireVtx(kFALSE),
75 fMinVtxContributors(0),
ffbede40 76 fMultITSTPC(kFALSE),
ba15fdfb 77 fCentMin(1.),
78 fCentMax(0.),
2a14a7b1 79 fVtxType(kVtxTracks),
80 fRequireV0and(0),
81 fTriggerAnalysis(0x0),
d327d9cd 82 fkVertex(0x0),
90c1ae2d 83 fkVertexAOD(0x0),
84 fparMean(0x0),
85 fparSigma(0x0),
86 fcutSigma(3.)
2a14a7b1 87{
88 //
89 // Named Constructor
90 //
91}
92
93//______________________________________________
94AliDielectronEventCuts::~AliDielectronEventCuts()
95{
96 //
97 // Default Destructor
98 //
99 if (fTriggerAnalysis) delete fTriggerAnalysis;
100}
101
102//______________________________________________
103Bool_t AliDielectronEventCuts::IsSelected(TObject* event)
104{
105 //
106 // check the cuts
107 //
108
d327d9cd 109 if(event->IsA() == AliESDEvent::Class()) return IsSelectedESD(event);
110 else if(event->IsA() == AliAODEvent::Class()) return IsSelectedAOD(event);
111 else return kFALSE;
112}
113//____________________________________________________________________
114Bool_t AliDielectronEventCuts::IsSelectedESD(TObject* event)
115{
116 //
117 // check the cuts
118 //
119
2a14a7b1 120 AliESDEvent *ev=dynamic_cast<AliESDEvent*>(event);
121 if (!ev) return kFALSE;
122
ba15fdfb 123 if (fCentMin<fCentMax){
124 AliCentrality *centrality=ev->GetCentrality();
125 Double_t centralityF=-1;
126 if (centrality) centralityF = centrality->GetCentralityPercentile("V0M");
127 if (centralityF<fCentMin || centralityF>=fCentMax) return kFALSE;
128 }
129
2a14a7b1 130 fkVertex=0x0;
5720c765 131
2a14a7b1 132 switch(fVtxType){
1201a1a9 133 case kVtxTracks:
134 case kVtxTracksOrSPD:
135 fkVertex=ev->GetPrimaryVertexTracks();
136 break;
2a14a7b1 137 case kVtxSPD: fkVertex=ev->GetPrimaryVertexSPD(); break;
138 case kVtxTPC: fkVertex=ev->GetPrimaryVertexTPC(); break;
139 case kVtxAny: fkVertex=ev->GetPrimaryVertex(); break;
140 }
141
142 if ((fRequireVtx||fVtxZmin<fVtxZmax||fMinVtxContributors>0)&&!fkVertex) return kFALSE;
143
2a14a7b1 144
145 if (fMinVtxContributors>0){
146 Int_t nCtrb = fkVertex->GetNContributors();
ba15fdfb 147 if (nCtrb<fMinVtxContributors){
148 if (fVtxType==kVtxTracksOrSPD){
149 fkVertex=ev->GetPrimaryVertexSPD();
150 nCtrb = fkVertex->GetNContributors();
151 if (nCtrb<fMinVtxContributors) return kFALSE;
152 } else {
153 return kFALSE;
154 }
155 }
2a14a7b1 156 }
157
ba15fdfb 158 if (fVtxZmin<fVtxZmax){
159 Double_t zvtx=fkVertex->GetZv();
160 if (zvtx<fVtxZmin||zvtx>fVtxZmax) return kFALSE;
161 }
162
2a14a7b1 163 if (fRequireV0and){
164 if (!fTriggerAnalysis) fTriggerAnalysis=new AliTriggerAnalysis;
165 Bool_t v0AND = kFALSE;
166 if (fRequireV0and==1){
167 Bool_t v0A = fTriggerAnalysis->IsOfflineTriggerFired(ev, AliTriggerAnalysis::kV0A);
168 Bool_t v0C = fTriggerAnalysis->IsOfflineTriggerFired(ev, AliTriggerAnalysis::kV0C);
169 v0AND = v0A && v0C;
170 }
171
172 if (fRequireV0and==2){
173 Bool_t v0AHW = (fTriggerAnalysis->V0Trigger(ev, AliTriggerAnalysis::kASide, kTRUE) == AliTriggerAnalysis::kV0BB);
174 Bool_t v0CHW = (fTriggerAnalysis->V0Trigger(ev, AliTriggerAnalysis::kCSide, kTRUE) == AliTriggerAnalysis::kV0BB);
175 v0AND = v0AHW && v0CHW;
176 }
177
178 if (!v0AND) return kFALSE;
179 }
ffbede40 180
181 if (fMultITSTPC){
182 const AliESDVertex *vtxESDTPC=ev->GetPrimaryVertexTPC();
183 const AliMultiplicity *multESD = ev->GetMultiplicity();
184 if ( vtxESDTPC && multESD && vtxESDTPC->GetNContributors() < (-10.+0.25*multESD->GetNumberOfITSClusters(0)) )
185 return kFALSE;
186 }
ba15fdfb 187
90c1ae2d 188 if(fparMean && fparSigma) {
189 Double_t nTrks = ev->GetNumberOfTracks();
190 Double_t multV0 = 0.0;
191 for(Int_t j=0; j<64; j++) multV0 += ev->GetVZEROData()->GetMultiplicity(j);
192 Double_t mV0 = fparMean->Eval(nTrks);
193 Double_t sV0 = fparSigma->Eval(nTrks);
77e2c705 194 if(multV0 > mV0+fcutSigma*sV0 || multV0 < mV0-fcutSigma*sV0) return kFALSE;
90c1ae2d 195 }
196
d327d9cd 197 return kTRUE;
198}
199//______________________________________________
200Bool_t AliDielectronEventCuts::IsSelectedAOD(TObject* event)
201{
202 //
203 // check the cuts
204 //
205
206 AliAODEvent *ev=dynamic_cast<AliAODEvent*>(event);
207 if (!ev) return kFALSE;
208
209 if (fCentMin<fCentMax){
210 AliCentrality *centrality=ev->GetCentrality();
211 Double_t centralityF=-1;
212 if (centrality) centralityF = centrality->GetCentralityPercentile("V0M");
213 if (centralityF<fCentMin || centralityF>=fCentMax) return kFALSE;
214 }
215
216 fkVertexAOD=0x0;
217
218 switch(fVtxType){
e4339752 219 case kVtxTracks: fkVertexAOD=0x0; break;
0df6826e 220 case kVtxTPC: fkVertexAOD=ev->GetVertex(AliAODVertex::kMainTPC); break;
d327d9cd 221 case kVtxSPD:
e4339752 222 case kVtxTracksOrSPD: fkVertexAOD=ev->GetPrimaryVertexSPD(); break;
223 case kVtxAny: fkVertexAOD=ev->GetPrimaryVertex(); break;
d327d9cd 224 }
225
226 if ((fRequireVtx||fVtxZmin<fVtxZmax||fMinVtxContributors>0)&&!fkVertexAOD) return kFALSE;
227
228 if (fMinVtxContributors>0){
229 Int_t nCtrb = fkVertexAOD->GetNContributors();
230 if (nCtrb<fMinVtxContributors){
a823f01b 231 // if (fVtxType==kVtxTracksOrSPD){
232 // fkVertexAOD=ev->GetVertex(AliAODVertex::kPrimary);
233 // nCtrb = fkVertexAOD->GetNContributors();
234 // if (nCtrb<fMinVtxContributors) return kFALSE;
235 // } else {
236 return kFALSE;
237 //}
d327d9cd 238 }
239 }
a823f01b 240
d327d9cd 241
242 if (fVtxZmin<fVtxZmax){
243 Double_t zvtx=fkVertexAOD->GetZ();
244 if (zvtx<fVtxZmin||zvtx>fVtxZmax) return kFALSE;
245 }
a823f01b 246
d327d9cd 247 /*
248 if (fRequireV0and){
249 // if (!fTriggerAnalysis) fTriggerAnalysis=new AliTriggerAnalysis;
250 Bool_t v0AND = kFALSE;
251 if (fRequireV0and==1){
252 Bool_t v0A = fTriggerAnalysis->IsOfflineTriggerFired(ev, AliTriggerAnalysis::kV0A);
253 Bool_t v0A = header->GetOfflineTrigger(); //TODO
254 Bool_t v0C = fTriggerAnalysis->IsOfflineTriggerFired(ev, AliTriggerAnalysis::kV0C);
255 v0AND = v0A && v0C;
256 }
257
258 if (fRequireV0and==2){
259 Bool_t v0AHW = (fTriggerAnalysis->V0Trigger(ev, AliTriggerAnalysis::kASide, kTRUE) == AliTriggerAnalysis::kV0BB);
260 Bool_t v0CHW = (fTriggerAnalysis->V0Trigger(ev, AliTriggerAnalysis::kCSide, kTRUE) == AliTriggerAnalysis::kV0BB);
261 v0AND = v0AHW && v0CHW;
262 }
263
264 if (!v0AND) return kFALSE;
265 }
266 */
267 /* if (fMultITSTPC){
268 const AliESDVertex *vtxESDTPC=ev->GetPrimaryVertexTPC();
269 const AliMultiplicity *multESD = ev->GetMultiplicity();
270 if ( vtxESDTPC && multESD && vtxESDTPC->GetNContributors() < (-10.+0.25*multESD->GetNumberOfITSClusters(0)) )
271 return kFALSE;
272 }
273 */
90c1ae2d 274
275 if(fparMean && fparSigma) {
276 Double_t nTrks = ev->GetNumberOfTracks();
277 Double_t multV0 = 0.0;
278 for(Int_t j=0; j<64; j++) multV0 += ev->GetVZEROData()->GetMultiplicity(j);
279 Double_t mV0 = fparMean->Eval(nTrks);
280 Double_t sV0 = fparSigma->Eval(nTrks);
281 if(multV0 > mV0+fcutSigma*sV0 || multV0 < mV0-fcutSigma*sV0) return kFALSE;
282 }
283
2a14a7b1 284 return kTRUE;
285}
286
1bb1fef1 287//________________________________________________________________________
288void AliDielectronEventCuts::Print(const Option_t* /*option*/) const
289{
290 //
291 // Print cuts and the range
292 //
293 printf("cut ranges for '%s'\n",GetTitle());
294 printf("All Cuts have to be fulfilled\n");
295
296 Int_t iCut=0;
297 if(fRequireVtx) {
298 printf("Cut %02d: vertex required \n",iCut); iCut++; }
299 printf("Cut %02d: vertex type: %s \n", iCut, fgkVtxNames[fVtxType]); iCut++;
300 if(fMinVtxContributors) {
301 printf("Cut %02d: vertex contributors >= %d \n", iCut, fMinVtxContributors); iCut++; }
302 if(fVtxZmin<fVtxZmax) {
90c1ae2d 303 printf("Cut %02d: %f < %s < %f\n", iCut, fVtxZmin, "Zvtx", fVtxZmax); iCut++; }
1bb1fef1 304 if(fCentMin<fCentMax) {
305 printf("Cut %02d: %f < %s < %f\n", iCut, fCentMin, "V0centrality", fCentMax);iCut++; }
306 if(fMultITSTPC) {
307 printf("Cut %02d: cut on multiplcity ITS vs. TPC \n", iCut); iCut++; }
90c1ae2d 308 if(fparMean&&fparSigma) {
309 printf("Cut %02d: multplicity vs. #tracks correlation +-%.1f sigma inclusion \n", iCut, fcutSigma); iCut++; }
1bb1fef1 310 if(fRequireV0and) {
311 printf("Cut %02d: require V0and type: %c \n", iCut, fRequireV0and); iCut++; }
312
313}
314