1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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
29 #include "AliESDEvent.h"
30 #include "AliESDVertex.h"
31 #include "AliAODEvent.h"
32 #include "AliAODVertex.h"
33 #include "AliHFEextraEventCuts.h"
34 ClassImp(AliHFEextraEventCuts)
35 //____________________________________________________________________
36 AliHFEextraEventCuts::AliHFEextraEventCuts() :
38 fRequireVtxCuts(kFALSE),
44 fCheckCorrelationSPDVtx(0),
52 //____________________________________________________________________
53 AliHFEextraEventCuts::AliHFEextraEventCuts(Char_t* name, Char_t* title) :
54 AliCFCutBase(name,title),
55 fRequireVtxCuts(kFALSE),
61 fCheckCorrelationSPDVtx(0),
71 //____________________________________________________________________
72 AliHFEextraEventCuts::AliHFEextraEventCuts(const AliHFEextraEventCuts& c) :
74 fRequireVtxCuts(c.fRequireVtxCuts),
77 fVtxNCtrbMin(c.fVtxNCtrbMin),
78 fVtxMixed(c.fVtxMixed),
80 fCheckCorrelationSPDVtx(c.fCheckCorrelationSPDVtx),
86 for (Int_t i=0; i<c.kNCuts; i++){
87 for (Int_t j=0; j<c.kNStepQA; j++){
88 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
94 //____________________________________________________________________
95 AliHFEextraEventCuts::~AliHFEextraEventCuts() {
100 for (Int_t i=0; i<kNCuts; i++){
101 for (Int_t j=0; j<kNStepQA; j++){
102 if(fhQA[i][j]) delete fhQA[i][j];
106 if(fBitMap)delete fBitMap;
109 //_____________________________________________________________________________
110 void AliHFEextraEventCuts::Initialise()
118 // sets pointers to histos to zero
121 for(Int_t i=0; i<kNCuts; i++){
122 for(Int_t j =0; j<kNStepQA; j++){
128 //____________________________________________________________________
129 AliHFEextraEventCuts& AliHFEextraEventCuts::operator=(const AliHFEextraEventCuts& c)
132 // Assignment operator
135 AliCFCutBase::operator=(c) ;
136 fRequireVtxCuts=c.fRequireVtxCuts;
139 fVtxNCtrbMin=c.fVtxNCtrbMin;
140 fVtxMixed=c.fVtxMixed;
142 fCheckCorrelationSPDVtx=c.fCheckCorrelationSPDVtx;
146 for (Int_t i=0; i<c.kNCuts; i++){
147 for (Int_t j=0; j<c.kNStepQA; j++){
148 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
156 //____________________________________________________________________
157 Bool_t AliHFEextraEventCuts::IsSelected(TObject* obj) {
159 //Check if the requested cuts are passed
163 SelectionBitMap(obj);
165 if (fIsQAOn) FillHistograms(obj,0);
166 Bool_t isSelected = kTRUE;
168 for (UInt_t icut=0; icut<fBitMap->GetNbits();icut++)
169 if(!fBitMap->TestBitNumber(icut)) isSelected = kFALSE;
171 if (!isSelected) return kFALSE ;
172 if (fIsQAOn) FillHistograms(obj,1);
176 //____________________________________________________________________
177 void AliHFEextraEventCuts::SelectionBitMap(TObject* obj) {
179 //cut on the number of charged tracks and on the event vertex.
180 //so far specific to AliESDEvents
183 //Check if the requested cuts are passed and return a bitmap
184 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
188 AliESDEvent* esd = dynamic_cast<AliESDEvent *>(obj);
189 AliAODEvent* aod = dynamic_cast<AliAODEvent *>(obj);
196 //now start checking the cuts,
197 //first assume the event will be accepted:
198 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE);
203 const AliESDVertex* vtxESD = 0x0;
205 vtxESD = esd->GetPrimaryVertexTracks() ;
206 if((!vtxESD) || (vtxESD->GetNContributors() <= 0)) {
207 vtxESD = esd->GetPrimaryVertexSPD() ;
208 if((!vtxESD) || (vtxESD->GetNContributors() <= 0)) {
209 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
210 AliWarning("Cannot get vertex, skipping event");
216 vtxESD = esd->GetPrimaryVertexSPD() ;
217 if(fCheckCorrelationSPDVtx) {
218 const AliESDVertex* vtxESDtr = esd->GetPrimaryVertexTracks();
219 if((vtxESD) && (vtxESD->GetNContributors() > 0) && (vtxESDtr) && (vtxESDtr->GetNContributors() > 0)) {
220 if(TMath::Abs(vtxESD->GetZv()-vtxESDtr->GetZv())>0.5) return;
226 vtxESD = esd->GetPrimaryVertexTracks() ;
230 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
231 AliWarning("Cannot get vertex, skipping event");
235 // Pick up the position and uncertainties
237 vtxPos[0] = vtxESD->GetXv();
238 vtxPos[1] = vtxESD->GetYv();
239 vtxPos[2] = vtxESD->GetZv();
241 Int_t nCtrb = vtxESD->GetNContributors();
245 if (vtxPos[2]>fVtxZMax || vtxPos[2]<fVtxZMin)
246 fBitMap->SetBitNumber(0,kFALSE);
247 if (nCtrb<fVtxNCtrbMin)
248 fBitMap->SetBitNumber(1,kFALSE);
262 //now start checking the cuts,
263 //first assume the event will be accepted:
264 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE);
269 const AliAODVertex* vtxAOD = 0x0;
271 vtxAOD = aod->GetPrimaryVertex();
272 if((!vtxAOD) || (vtxAOD->GetNContributors() <= 0)) {
273 vtxAOD = aod->GetPrimaryVertexSPD() ;
274 if((!vtxAOD) || (vtxAOD->GetNContributors() <= 0)) {
275 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
276 AliWarning("Cannot get vertex, skipping event");
282 vtxAOD = aod->GetPrimaryVertexSPD() ;
283 if(fCheckCorrelationSPDVtx) {
284 const AliAODVertex* vtxAODtr = aod->GetPrimaryVertex();
285 if((vtxAOD) && (vtxAOD->GetNContributors() > 0) && (vtxAODtr) && (vtxAODtr->GetNContributors() > 0)) {
286 if(TMath::Abs(vtxAOD->GetZ()-vtxAODtr->GetZ())>0.5) return;
292 vtxAOD = aod->GetPrimaryVertex() ;
296 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
297 AliWarning("Cannot get vertex, skipping event");
301 // Pick up the position and uncertainties
303 vtxPos[0] = vtxAOD->GetX();
304 vtxPos[1] = vtxAOD->GetY();
305 vtxPos[2] = vtxAOD->GetZ();
307 Int_t nCtrb = vtxAOD->GetNContributors();
308 //printf("AliHFEextraCuts:: %d, %f, %f, %f\n",nCtrb,vtxPos[0],vtxPos[1],vtxPos[2]);
312 if (vtxPos[2]>fVtxZMax || vtxPos[2]<fVtxZMin)
313 fBitMap->SetBitNumber(0,kFALSE);
314 if (nCtrb<fVtxNCtrbMin)
315 fBitMap->SetBitNumber(1,kFALSE);
327 //_____________________________________________________________________________
328 void AliHFEextraEventCuts::FillHistograms(TObject* obj, Bool_t b)
331 // fill the QA histograms
335 // cast TObject into VParticle
336 AliESDEvent* esd = dynamic_cast<AliESDEvent *>(obj);
339 // index = 0: fill histograms before cuts
340 // index = 1: fill histograms after cuts
342 index = ((b) ? 1 : 0);
345 //look at vertex parameters:
346 const AliESDVertex* vtxESD = 0x0;
348 vtxESD = esd->GetPrimaryVertexTracks() ;
349 if((!vtxESD) || (vtxESD->GetNContributors() <= 0)) {
350 vtxESD = esd->GetPrimaryVertexSPD() ;
351 if((!vtxESD) || (vtxESD->GetNContributors() <= 0)) {
357 vtxESD = esd->GetPrimaryVertexTracks() ;
360 // vertex position and uncertainties
361 fhQA[kVtxPosZ] [index]->Fill(vtxESD->GetZv());
362 fhQA[kVtxNCtrb][index]->Fill(vtxESD->GetNContributors());
366 //____________________________________________________________________
367 void AliHFEextraEventCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bins)
370 //setting x-axis bin limits of QA histogram fhQA[index]
373 for(Int_t i=0;i<kNStepQA;i++){
374 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
377 fhQA[index][i]->GetXaxis()->Set(nbins,bins);
380 //____________________________________________________________________
381 void AliHFEextraEventCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin, Double_t xmax)
384 //setting x-axis bins and range of QA histogram fhQA[index]
387 for(Int_t i=0;i<kNStepQA;i++){
388 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
391 fhQA[index][i]->GetXaxis()->Set(nbins,xmin,xmax);
395 //_____________________________________________________________________________
396 void AliHFEextraEventCuts::DefineHistograms() {
398 // histograms for cut variables
403 AliInfo(Form("No QA histos requested, Please first set the QA flag on!"));
407 // book QA histograms
410 for (Int_t i=0; i<kNStepQA; i++) {
411 if (i==0) snprintf(str,5," ");
412 else snprintf(str,5,"_cut");
414 fhQA[kVtxPosZ][i] = new TH1F(Form("%s_Vtx_Pos_Z%s",GetName(),str), "",200,-50.,50.);
415 fhQA[kVtxNCtrb][i] = new TH1F(Form("%s_Vtx_N_Ctrb%s",GetName(),str), "",1000,0.,1000.);
417 fhQA[kVtxPosZ][i] ->SetXTitle("Vertex Position Z (cm)");
418 fhQA[kVtxNCtrb][i] ->SetXTitle("Number of contributors");
421 for(Int_t i=0; i<kNCuts; i++) fhQA[i][1]->SetLineColor(color);
425 //_____________________________________________________________________________
426 void AliHFEextraEventCuts::AddQAHistograms(TList *qaList) {
428 // saves the histograms in a TList
433 for (Int_t j=0; j<kNStepQA; j++) {
434 for(Int_t i=0; i<kNCuts; i++)
435 qaList->Add(fhQA[i][j]);