]>
Commit | Line | Data |
---|---|---|
c2690925 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | // Cut on the Event at reconstructed level: for the moment | |
16 | // the requirements on the number of charged tracks and on | |
17 | // the vertex position and resolution are implemented | |
18 | // The argument of IsSelected member function (passed object) is cast into | |
19 | // an AliESDEvent. In the future may be modified to use AliVEvent interface | |
20 | // and include more cut variables. | |
21 | // The class derives from AliCFCutBase | |
22 | // Author:S.Arcelli Silvia.Arcelli@cern.ch | |
23 | // | |
24 | // | |
25 | #include "TH1F.h" | |
26 | #include "TList.h" | |
27 | #include "TBits.h" | |
28 | #include "AliLog.h" | |
4437a0d2 | 29 | #include "AliAnalysisUtils.h" |
c2690925 | 30 | #include "AliESDEvent.h" |
31 | #include "AliESDVertex.h" | |
11ff28c5 | 32 | #include "AliAODEvent.h" |
33 | #include "AliAODVertex.h" | |
c2690925 | 34 | #include "AliHFEextraEventCuts.h" |
35 | ClassImp(AliHFEextraEventCuts) | |
36 | //____________________________________________________________________ | |
37 | AliHFEextraEventCuts::AliHFEextraEventCuts() : | |
38 | AliCFCutBase(), | |
4437a0d2 | 39 | fAnalysisUtils(NULL), |
c2690925 | 40 | fRequireVtxCuts(kFALSE), |
41 | fVtxZMax(1.e99), | |
42 | fVtxZMin(-1.e99), | |
43 | fVtxNCtrbMin(0), | |
44 | fVtxMixed(0), | |
63bdf450 | 45 | fVtxSPD(0), |
46 | fCheckCorrelationSPDVtx(0), | |
d87a9d29 | 47 | fVtxResolution(kFALSE), |
4437a0d2 | 48 | fPApileupCut(kFALSE), |
c2690925 | 49 | fBitMap(0x0) |
50 | { | |
51 | // | |
52 | //ctor | |
53 | // | |
54 | } | |
55 | ||
56 | //____________________________________________________________________ | |
57 | AliHFEextraEventCuts::AliHFEextraEventCuts(Char_t* name, Char_t* title) : | |
58 | AliCFCutBase(name,title), | |
59 | fRequireVtxCuts(kFALSE), | |
60 | fVtxZMax(1.e99), | |
61 | fVtxZMin(-1.e99), | |
62 | fVtxNCtrbMin(0), | |
63 | fVtxMixed(0), | |
63bdf450 | 64 | fVtxSPD(0), |
65 | fCheckCorrelationSPDVtx(0), | |
d87a9d29 | 66 | fVtxResolution(kFALSE), |
4437a0d2 | 67 | fPApileupCut(kFALSE), |
c2690925 | 68 | fBitMap(0x0) |
69 | { | |
70 | // | |
71 | //ctor | |
72 | // | |
73 | fBitMap=new TBits(0); | |
74 | Initialise(); | |
4437a0d2 | 75 | fAnalysisUtils = new AliAnalysisUtils; |
c2690925 | 76 | } |
77 | ||
78 | //____________________________________________________________________ | |
79 | AliHFEextraEventCuts::AliHFEextraEventCuts(const AliHFEextraEventCuts& c) : | |
80 | AliCFCutBase(c), | |
4437a0d2 | 81 | fAnalysisUtils(NULL), |
c2690925 | 82 | fRequireVtxCuts(c.fRequireVtxCuts), |
83 | fVtxZMax(c.fVtxZMax), | |
84 | fVtxZMin(c.fVtxZMin), | |
85 | fVtxNCtrbMin(c.fVtxNCtrbMin), | |
86 | fVtxMixed(c.fVtxMixed), | |
63bdf450 | 87 | fVtxSPD(c.fVtxSPD), |
88 | fCheckCorrelationSPDVtx(c.fCheckCorrelationSPDVtx), | |
d87a9d29 | 89 | fVtxResolution(c.fVtxResolution), |
4437a0d2 | 90 | fPApileupCut(c.fPApileupCut), |
c2690925 | 91 | fBitMap(c.fBitMap) |
92 | { | |
93 | // | |
94 | //copy constructor | |
95 | // | |
96 | for (Int_t i=0; i<c.kNCuts; i++){ | |
97 | for (Int_t j=0; j<c.kNStepQA; j++){ | |
98 | if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone(); | |
99 | } | |
100 | } | |
4437a0d2 | 101 | fAnalysisUtils = new AliAnalysisUtils; |
c2690925 | 102 | } |
103 | ||
104 | //____________________________________________________________________ | |
105 | AliHFEextraEventCuts::~AliHFEextraEventCuts() { | |
106 | // | |
107 | //dtor | |
108 | // | |
109 | ||
110 | for (Int_t i=0; i<kNCuts; i++){ | |
111 | for (Int_t j=0; j<kNStepQA; j++){ | |
112 | if(fhQA[i][j]) delete fhQA[i][j]; | |
113 | } | |
114 | } | |
115 | ||
4437a0d2 | 116 | if(fBitMap) delete fBitMap; |
117 | if(fAnalysisUtils) delete fAnalysisUtils; | |
c2690925 | 118 | } |
119 | //_____________________________________________________________________________ | |
120 | void AliHFEextraEventCuts::Initialise() | |
121 | { | |
122 | ||
123 | // | |
124 | //initialization | |
125 | // | |
126 | ||
127 | // | |
128 | // sets pointers to histos to zero | |
129 | // | |
130 | ||
131 | for(Int_t i=0; i<kNCuts; i++){ | |
132 | for(Int_t j =0; j<kNStepQA; j++){ | |
133 | fhQA[i][j]=0x0; | |
134 | } | |
135 | } | |
136 | } | |
137 | ||
138 | //____________________________________________________________________ | |
139 | AliHFEextraEventCuts& AliHFEextraEventCuts::operator=(const AliHFEextraEventCuts& c) | |
140 | { | |
141 | // | |
142 | // Assignment operator | |
143 | // | |
144 | if (this != &c) { | |
145 | AliCFCutBase::operator=(c) ; | |
146 | fRequireVtxCuts=c.fRequireVtxCuts; | |
147 | fVtxZMax=c.fVtxZMax; | |
148 | fVtxZMin=c.fVtxZMin; | |
149 | fVtxNCtrbMin=c.fVtxNCtrbMin; | |
150 | fVtxMixed=c.fVtxMixed; | |
63bdf450 | 151 | fVtxSPD=c.fVtxSPD; |
152 | fCheckCorrelationSPDVtx=c.fCheckCorrelationSPDVtx; | |
d87a9d29 | 153 | fVtxResolution = c.fVtxResolution; |
c2690925 | 154 | fBitMap=c.fBitMap; |
4437a0d2 | 155 | if(!fAnalysisUtils) fAnalysisUtils = new AliAnalysisUtils; |
156 | fPApileupCut = c.fPApileupCut; | |
c2690925 | 157 | } |
158 | ||
159 | for (Int_t i=0; i<c.kNCuts; i++){ | |
160 | for (Int_t j=0; j<c.kNStepQA; j++){ | |
161 | if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone(); | |
162 | } | |
163 | } | |
164 | ||
165 | ||
166 | return *this ; | |
167 | } | |
168 | ||
169 | //____________________________________________________________________ | |
170 | Bool_t AliHFEextraEventCuts::IsSelected(TObject* obj) { | |
171 | // | |
172 | //Check if the requested cuts are passed | |
173 | // | |
174 | ||
175 | ||
176 | SelectionBitMap(obj); | |
177 | ||
178 | if (fIsQAOn) FillHistograms(obj,0); | |
179 | Bool_t isSelected = kTRUE; | |
180 | ||
181 | for (UInt_t icut=0; icut<fBitMap->GetNbits();icut++) | |
182 | if(!fBitMap->TestBitNumber(icut)) isSelected = kFALSE; | |
183 | ||
184 | if (!isSelected) return kFALSE ; | |
185 | if (fIsQAOn) FillHistograms(obj,1); | |
186 | return kTRUE; | |
187 | ||
188 | } | |
189 | //____________________________________________________________________ | |
190 | void AliHFEextraEventCuts::SelectionBitMap(TObject* obj) { | |
191 | // | |
192 | //cut on the number of charged tracks and on the event vertex. | |
193 | //so far specific to AliESDEvents | |
194 | // | |
195 | ||
196 | //Check if the requested cuts are passed and return a bitmap | |
c2690925 | 197 | |
d87a9d29 | 198 | AliVEvent *inputEvent = dynamic_cast<AliVEvent *>(obj); |
199 | if(!inputEvent){ | |
200 | AliDebug(1, "Not a virtual event"); | |
201 | for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE); | |
11ff28c5 | 202 | return; |
11ff28c5 | 203 | } |
d87a9d29 | 204 | const AliVVertex *vtxTracks = GetPrimaryVertexTracks(inputEvent), |
205 | *vtxSPD = GetPrimaryVertexSPD(inputEvent), | |
206 | *vtxPrim(NULL); | |
11ff28c5 | 207 | |
d87a9d29 | 208 | //first assume the event will be accepted: |
209 | for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE); | |
210 | ||
211 | if(fVtxMixed){ | |
212 | // Use mixed vertex: Prefer vertex with tracks, in case not available use SPD vertex | |
213 | if(vtxTracks && vtxTracks->GetNContributors() > 0) vtxPrim = vtxTracks; | |
214 | else if(vtxSPD && vtxSPD->GetNContributors() > 0) vtxPrim = vtxSPD; | |
215 | } else if(fVtxSPD){ | |
216 | if(vtxSPD && vtxSPD->GetNContributors () > 0) vtxPrim = vtxSPD; | |
217 | } else { | |
218 | if(vtxTracks && vtxTracks->GetNContributors() > 0) vtxPrim = vtxTracks; | |
219 | } | |
220 | if(!vtxPrim){ | |
221 | // No primary vertex: Reject event | |
222 | for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE); | |
223 | AliWarning("Cannot get vertex, skipping event"); | |
224 | return; | |
225 | } | |
226 | // Check standard vertex cuts using the primary vertex | |
227 | if(fVtxZMin > - 1000. && fVtxZMax < 1000.){ | |
228 | // Primary vertex z cut required | |
229 | // Pick up the position and uncertainties | |
230 | Double_t vtxPos[3]; | |
231 | vtxPos[0] = vtxPrim->GetX(); | |
232 | vtxPos[1] = vtxPrim->GetY(); | |
233 | vtxPos[2] = vtxPrim->GetZ(); | |
234 | if (vtxPos[2]>fVtxZMax || vtxPos[2]<fVtxZMin) | |
235 | fBitMap->SetBitNumber(kVtxPosZ,kFALSE); | |
236 | } | |
237 | if(fVtxNCtrbMin > 0){ | |
238 | // cut required if the cut value is set to something larger than 0 | |
239 | // same effect as setting the min. cut value to 0 | |
240 | Int_t nCtrb = vtxPrim->GetNContributors(); | |
241 | if (nCtrb<fVtxNCtrbMin) | |
242 | fBitMap->SetBitNumber(kVtxNCtrb,kFALSE); | |
243 | } | |
244 | ||
245 | // check vertex correlation cut | |
246 | if(fCheckCorrelationSPDVtx){ | |
247 | if(vtxTracks && vtxTracks->GetNContributors() && vtxSPD && vtxSPD->GetNContributors()){ | |
248 | // Both vertices available, check correlation | |
249 | if(TMath::Abs(vtxTracks->GetZ() - vtxSPD->GetZ()) >= 0.5) fBitMap->SetBitNumber(kCorrelation, kFALSE); | |
250 | } else { | |
251 | // No correlation available: set the cut to false | |
252 | fBitMap->SetBitNumber(kCorrelation, kFALSE); | |
253 | } | |
254 | } | |
255 | // check cut on the SPD vertex resolution | |
256 | if(fVtxResolution){ | |
257 | if(vtxSPD){ | |
258 | TString vtxTyp = vtxSPD->GetTitle(); | |
259 | Double_t cov[6]={0}; | |
260 | vtxSPD->GetCovarianceMatrix(cov); | |
261 | Double_t zRes = TMath::Sqrt(cov[5]); | |
262 | if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) fBitMap->SetBitNumber(kResolution, kFALSE); | |
263 | } else{ | |
264 | fBitMap->SetBitNumber(kResolution, kFALSE); | |
265 | } | |
266 | } | |
4437a0d2 | 267 | // check pA pileup cut |
268 | if(fPApileupCut){ | |
269 | if(fAnalysisUtils->IsPileUpEvent(inputEvent)) fBitMap->SetBitNumber(kpApileup,kFALSE); | |
270 | } | |
c2690925 | 271 | } |
272 | ||
273 | //_____________________________________________________________________________ | |
274 | void AliHFEextraEventCuts::FillHistograms(TObject* obj, Bool_t b) | |
275 | { | |
276 | // | |
277 | // fill the QA histograms | |
278 | // | |
279 | ||
280 | if(!fIsQAOn) return; | |
d87a9d29 | 281 | // cast TObject into VEvent |
282 | AliVEvent* inputEvent = dynamic_cast<AliESDEvent *>(obj); | |
283 | if (!inputEvent) return; | |
c2690925 | 284 | |
285 | // index = 0: fill histograms before cuts | |
286 | // index = 1: fill histograms after cuts | |
287 | Int_t index = -1; | |
288 | index = ((b) ? 1 : 0); | |
289 | ||
d87a9d29 | 290 | // Obtain vertices |
291 | const AliVVertex *vtxTracks = GetPrimaryVertexTracks(inputEvent), | |
292 | *vtxSPD = GetPrimaryVertexSPD(inputEvent), | |
293 | *vtxPrim(NULL); | |
c2690925 | 294 | |
295 | //look at vertex parameters: | |
d87a9d29 | 296 | if(fVtxMixed){ |
808d3d3b | 297 | if(vtxTracks && vtxTracks->GetNContributors() > 0) vtxPrim = vtxTracks; |
298 | else if(vtxSPD && vtxSPD->GetNContributors()) vtxPrim = vtxSPD; | |
c2690925 | 299 | } |
300 | else { | |
d87a9d29 | 301 | vtxPrim = vtxTracks; |
c2690925 | 302 | } |
d87a9d29 | 303 | if(!vtxPrim)return; |
c2690925 | 304 | // vertex position and uncertainties |
d87a9d29 | 305 | fhQA[kVtxPosZ] [index]->Fill(vtxPrim->GetZ()); |
306 | fhQA[kVtxNCtrb][index]->Fill(vtxPrim->GetNContributors()); | |
307 | // SPD Vertex Position Correlation | |
308 | if(vtxTracks && vtxSPD){ | |
309 | fhQA[kCorrelation][index]->Fill(vtxTracks->GetZ()-vtxSPD->GetZ()); | |
310 | } | |
311 | if(vtxSPD){ | |
312 | Double_t cov[6]={0}; | |
313 | vtxSPD->GetCovarianceMatrix(cov); | |
314 | fhQA[kResolution][index]->Fill(TMath::Sqrt(cov[5])); | |
315 | } | |
4437a0d2 | 316 | double isPileup =0 ; |
317 | if(fAnalysisUtils->IsPileUpEvent(inputEvent)) isPileup = 1, | |
318 | fhQA[kpApileup][index]->Fill(isPileup); | |
c2690925 | 319 | } |
320 | ||
321 | //____________________________________________________________________ | |
322 | void AliHFEextraEventCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bins) | |
323 | { | |
324 | // | |
325 | //setting x-axis bin limits of QA histogram fhQA[index] | |
326 | // | |
327 | ||
328 | for(Int_t i=0;i<kNStepQA;i++){ | |
329 | if(!fhQA[index][i]){AliWarning("non-existing histogram!"); | |
330 | return; | |
331 | } | |
332 | fhQA[index][i]->GetXaxis()->Set(nbins,bins); | |
333 | } | |
334 | } | |
335 | //____________________________________________________________________ | |
336 | void AliHFEextraEventCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin, Double_t xmax) | |
337 | { | |
338 | // | |
339 | //setting x-axis bins and range of QA histogram fhQA[index] | |
340 | // | |
341 | ||
342 | for(Int_t i=0;i<kNStepQA;i++){ | |
343 | if(!fhQA[index][i]){AliWarning("non-existing histogram!"); | |
344 | return; | |
345 | } | |
346 | fhQA[index][i]->GetXaxis()->Set(nbins,xmin,xmax); | |
347 | } | |
348 | } | |
349 | ||
350 | //_____________________________________________________________________________ | |
351 | void AliHFEextraEventCuts::DefineHistograms() { | |
352 | // | |
353 | // histograms for cut variables | |
354 | // | |
355 | Int_t color = 2; | |
356 | ||
357 | if(!fIsQAOn) { | |
358 | AliInfo(Form("No QA histos requested, Please first set the QA flag on!")); | |
359 | return; | |
360 | } | |
361 | ||
362 | // book QA histograms | |
c2690925 | 363 | Char_t str[5]; |
364 | for (Int_t i=0; i<kNStepQA; i++) { | |
365 | if (i==0) snprintf(str,5," "); | |
366 | else snprintf(str,5,"_cut"); | |
367 | ||
368 | fhQA[kVtxPosZ][i] = new TH1F(Form("%s_Vtx_Pos_Z%s",GetName(),str), "",200,-50.,50.); | |
369 | fhQA[kVtxNCtrb][i] = new TH1F(Form("%s_Vtx_N_Ctrb%s",GetName(),str), "",1000,0.,1000.); | |
d87a9d29 | 370 | fhQA[kCorrelation][i] = new TH1F(Form("%s_SPDCorrelation_%s",GetName(),str), "",200, -10., 10); |
371 | fhQA[kResolution][i] = new TH1F(Form("%s_SPDResolution_%s",GetName(), str), "", 100, 0., 1.); | |
4437a0d2 | 372 | fhQA[kpApileup][i] = new TH1F(Form("%s_pApileup_%s",GetName(),str), "", 2, 0., 2.); |
c2690925 | 373 | |
374 | fhQA[kVtxPosZ][i] ->SetXTitle("Vertex Position Z (cm)"); | |
375 | fhQA[kVtxNCtrb][i] ->SetXTitle("Number of contributors"); | |
376 | } | |
377 | ||
378 | for(Int_t i=0; i<kNCuts; i++) fhQA[i][1]->SetLineColor(color); | |
379 | ||
380 | } | |
381 | ||
382 | //_____________________________________________________________________________ | |
383 | void AliHFEextraEventCuts::AddQAHistograms(TList *qaList) { | |
384 | // | |
385 | // saves the histograms in a TList | |
386 | // | |
387 | ||
388 | DefineHistograms(); | |
389 | ||
390 | for (Int_t j=0; j<kNStepQA; j++) { | |
391 | for(Int_t i=0; i<kNCuts; i++) | |
392 | qaList->Add(fhQA[i][j]); | |
393 | } | |
394 | } | |
d87a9d29 | 395 | |
396 | //_____________________________________________________________________________ | |
397 | const AliVVertex *AliHFEextraEventCuts::GetPrimaryVertexSPD(const AliVEvent * const inputEvent){ | |
398 | // | |
399 | // Get SPD vertex from event | |
400 | // | |
401 | const AliVVertex *spdvtx(NULL); | |
402 | const AliESDEvent *esd(NULL); | |
403 | const AliAODEvent *aod(NULL); | |
404 | if((esd = dynamic_cast<const AliESDEvent *>(inputEvent))){ | |
405 | spdvtx = esd->GetPrimaryVertexSPD(); | |
406 | } else if((aod = dynamic_cast<const AliAODEvent *>(inputEvent))){ | |
407 | spdvtx = aod->GetPrimaryVertexSPD(); | |
408 | } | |
409 | return spdvtx; | |
410 | } | |
411 | ||
412 | //_____________________________________________________________________________ | |
413 | const AliVVertex *AliHFEextraEventCuts::GetPrimaryVertexTracks(const AliVEvent *const inputEvent){ | |
414 | // | |
415 | // Get Primary Vertex from tracks | |
416 | // | |
417 | const AliVVertex *trkvtx(NULL); | |
418 | const AliESDEvent *esd(NULL); | |
419 | const AliAODEvent *aod(NULL); | |
420 | if((esd = dynamic_cast<const AliESDEvent *>(inputEvent))){ | |
421 | trkvtx = esd->GetPrimaryVertexTracks(); | |
422 | } else if((aod = dynamic_cast<const AliAODEvent *>(inputEvent))){ | |
423 | const AliVVertex *vtxTmp = aod->GetPrimaryVertex(); | |
424 | // check whether the primary vertex is the vertex from tracks | |
425 | TString vtxTtl = vtxTmp->GetTitle(); | |
426 | if(vtxTtl.Contains("VertexerTracks")){ | |
427 | trkvtx = vtxTmp; | |
428 | } | |
429 | } | |
430 | return trkvtx; | |
431 | } | |
432 |