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 "AliCFEventRecCuts.h"
32 ClassImp(AliCFEventRecCuts)
33 //____________________________________________________________________
34 AliCFEventRecCuts::AliCFEventRecCuts() :
38 fRequireVtxCuts(kFALSE),
49 fVtxNCtrbMax((Int_t)1.e9),
60 //____________________________________________________________________
61 AliCFEventRecCuts::AliCFEventRecCuts(Char_t* name, Char_t* title) :
62 AliCFCutBase(name,title),
65 fRequireVtxCuts(kFALSE),
76 fVtxNCtrbMax((Int_t)1.e9),
87 //____________________________________________________________________
88 AliCFEventRecCuts::AliCFEventRecCuts(const AliCFEventRecCuts& c) :
90 fNTracksMin(c.fNTracksMin),
91 fNTracksMax(c.fNTracksMax),
92 fRequireVtxCuts(c.fRequireVtxCuts),
99 fVtxXResMax(c.fVtxXResMax),
100 fVtxYResMax(c.fVtxYResMax),
101 fVtxZResMax(c.fVtxZResMax),
102 fVtxNCtrbMin(c.fVtxNCtrbMin),
103 fVtxNCtrbMax(c.fVtxNCtrbMax),
110 for (Int_t i=0; i<c.kNCuts; i++){
111 for (Int_t j=0; j<c.kNStepQA; j++){
112 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
118 //____________________________________________________________________
119 AliCFEventRecCuts::~AliCFEventRecCuts() {
124 for (Int_t i=0; i<kNCuts; i++){
125 for (Int_t j=0; j<kNStepQA; j++){
126 if(fhQA[i][j]) delete fhQA[i][j];
130 if(fBitMap)delete fBitMap;
133 //_____________________________________________________________________________
134 void AliCFEventRecCuts::Initialise()
142 // sets pointers to histos to zero
145 for(Int_t i=0; i<kNCuts; i++){
146 for(Int_t j =0; j<kNStepQA; j++){
152 //____________________________________________________________________
153 AliCFEventRecCuts& AliCFEventRecCuts::operator=(const AliCFEventRecCuts& c)
156 // Assignment operator
159 AliCFCutBase::operator=(c) ;
160 fNTracksMin=c.fNTracksMin;
161 fNTracksMax=c.fNTracksMax;
162 fRequireVtxCuts=c.fRequireVtxCuts;
169 fVtxXResMax=c.fVtxXResMax;
170 fVtxYResMax=c.fVtxYResMax;
171 fVtxZResMax=c.fVtxZResMax;
172 fVtxNCtrbMin=c.fVtxNCtrbMin;
173 fVtxNCtrbMax=c.fVtxNCtrbMax;
178 for (Int_t i=0; i<c.kNCuts; i++){
179 for (Int_t j=0; j<c.kNStepQA; j++){
180 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
188 //____________________________________________________________________
189 Bool_t AliCFEventRecCuts::IsSelected(TObject* obj) {
191 //Check if the requested cuts are passed
195 SelectionBitMap(obj);
197 if (fIsQAOn) FillHistograms(obj,0);
198 Bool_t isSelected = kTRUE;
200 for (UInt_t icut=0; icut<fBitMap->GetNbits();icut++)
201 if(!fBitMap->TestBitNumber(icut)) isSelected = kFALSE;
203 if (!isSelected) return kFALSE ;
204 if (fIsQAOn) FillHistograms(obj,1);
208 //____________________________________________________________________
209 void AliCFEventRecCuts::SelectionBitMap(TObject* obj) {
211 //cut on the number of charged tracks and on the event vertex.
212 //so far specific to AliESDEvents
215 //Check if the requested cuts are passed and return a bitmap
216 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
217 AliESDEvent* esd = dynamic_cast<AliESDEvent *>(obj);
220 //now start checking the cuts,
221 //first assume the event will be accepted:
222 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE);
224 //Number of charged tracks:
225 Int_t nTracks = esd->GetNumberOfTracks();
226 if(nTracks<fNTracksMin || nTracks>fNTracksMax)
227 fBitMap->SetBitNumber(0,kFALSE);
230 const AliESDVertex* vtxESD = fVtxTPC ? esd->GetPrimaryVertexTPC() : esd->GetPrimaryVertexSPD() ;
232 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
233 AliWarning("Cannot get vertex, skipping event");
236 // Require the vertex to have been reconstructed successfully
237 if (strcmp(vtxESD->GetName(), "default")==0){
238 AliWarning(Form(" No reconstructed vertex found, skipping event"));
239 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
242 // Pick up the position and uncertainties
245 vtxPos[0] = vtxESD->GetXv();
246 vtxPos[1] = vtxESD->GetYv();
247 vtxPos[2] = vtxESD->GetZv();
250 vtxRes[0] = vtxESD->GetXRes();
251 vtxRes[1] = vtxESD->GetYRes();
252 vtxRes[2] = vtxESD->GetZRes();
254 Int_t nCtrb = vtxESD->GetNContributors();
258 if (vtxPos[0]>fVtxXMax || vtxPos[0]<fVtxXMin)
259 fBitMap->SetBitNumber(1,kFALSE);
260 if (vtxPos[1]>fVtxYMax || vtxPos[1]<fVtxYMin)
261 fBitMap->SetBitNumber(2,kFALSE);
262 if (vtxPos[2]>fVtxZMax || vtxPos[2]<fVtxZMin)
263 fBitMap->SetBitNumber(3,kFALSE);
264 if (vtxRes[0]==0 || vtxRes[0]>fVtxXResMax)
265 fBitMap->SetBitNumber(4,kFALSE);
266 if (vtxRes[1]==0 || vtxRes[1]>fVtxYResMax)
267 fBitMap->SetBitNumber(5,kFALSE);
268 if (vtxRes[2]==0 || vtxRes[2]>fVtxZResMax)
269 fBitMap->SetBitNumber(6,kFALSE);
270 if (nCtrb<fVtxNCtrbMin || nCtrb>fVtxNCtrbMax)
271 fBitMap->SetBitNumber(7,kFALSE);
277 //_____________________________________________________________________________
278 void AliCFEventRecCuts::FillHistograms(TObject* obj, Bool_t b)
281 // fill the QA histograms
285 // cast TObject into VParticle
286 AliESDEvent* esd = dynamic_cast<AliESDEvent *>(obj);
289 // index = 0: fill histograms before cuts
290 // index = 1: fill histograms after cuts
292 index = ((b) ? 1 : 0);
295 //number of charged tracks:
296 Int_t nTracks = esd->GetNumberOfTracks();
297 fhQA[kNTracks][index]->Fill(nTracks);
299 //look at vertex parameters:
300 const AliESDVertex* vtxESD = fVtxTPC ? esd->GetPrimaryVertexTPC() : esd->GetPrimaryVertexSPD();
302 // Require the vertex to have been reconstructed successfully
303 if (strcmp(vtxESD->GetName(), "default")==0)return;
304 // vertex position and uncertainties
305 fhQA[kVtxPosX] [index]->Fill(vtxESD->GetXv());
306 fhQA[kVtxPosY] [index]->Fill(vtxESD->GetYv());
307 fhQA[kVtxPosZ] [index]->Fill(vtxESD->GetZv());
308 fhQA[kVtxResX] [index]->Fill(vtxESD->GetXRes());
309 fhQA[kVtxResY] [index]->Fill(vtxESD->GetYRes());
310 fhQA[kVtxResZ] [index]->Fill(vtxESD->GetZRes());
311 fhQA[kVtxNCtrb][index]->Fill(vtxESD->GetNContributors());
315 //____________________________________________________________________
316 void AliCFEventRecCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bins)
319 //setting x-axis bin limits of QA histogram fhQA[index]
322 for(Int_t i=0;i<kNStepQA;i++){
323 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
326 fhQA[index][i]->GetXaxis()->Set(nbins,bins);
329 //____________________________________________________________________
330 void AliCFEventRecCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin, Double_t xmax)
333 //setting x-axis bins and range of QA histogram fhQA[index]
336 for(Int_t i=0;i<kNStepQA;i++){
337 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
340 fhQA[index][i]->GetXaxis()->Set(nbins,xmin,xmax);
344 //_____________________________________________________________________________
345 void AliCFEventRecCuts::DefineHistograms() {
347 // histograms for cut variables
352 AliInfo(Form("No QA histos requested, Please first set the QA flag on!"));
356 // book QA histograms
359 for (Int_t i=0; i<kNStepQA; i++) {
360 if (i==0) sprintf(str," ");
361 else sprintf(str,"_cut");
363 fhQA[kNTracks][i] = new TH1F(Form("%s_NTracks%s",GetName(),str), "",501,-0.5,500.5);
364 fhQA[kVtxPosX][i] = new TH1F(Form("%s_Vtx_Pos_X%s",GetName(),str), "",100,-5.,5.);
365 fhQA[kVtxPosY][i] = new TH1F(Form("%s_Vtx_Pos_Y%s",GetName(),str), "",100,-5.,5.);
366 fhQA[kVtxPosZ][i] = new TH1F(Form("%s_Vtx_Pos_Z%s",GetName(),str), "",200,-50.,50.);
367 fhQA[kVtxResX][i] = new TH1F(Form("%s_Vtx_Res_X%s",GetName(),str), "",100,-1.,1.);
368 fhQA[kVtxResY][i] = new TH1F(Form("%s_Vtx_Res_Y%s",GetName(),str), "",100,-1.,1.);
369 fhQA[kVtxResZ][i] = new TH1F(Form("%s_Vtx_Res_Z%s",GetName(),str), "",100,-1.,1.);
370 fhQA[kVtxNCtrb][i] = new TH1F(Form("%s_Vtx_N_Ctrb%s",GetName(),str), "",1000,0.,1000.);
372 fhQA[kNTracks][i] ->SetXTitle("Number of ESD tracks");
373 fhQA[kVtxPosX][i] ->SetXTitle("Vertex Position X (cm)");
374 fhQA[kVtxPosY][i] ->SetXTitle("Vertex Position Y (cm)");
375 fhQA[kVtxPosZ][i] ->SetXTitle("Vertex Position Z (cm)");
376 fhQA[kVtxResX][i] ->SetXTitle("Vertex Resolution X (cm)");
377 fhQA[kVtxResY][i] ->SetXTitle("Vertex Resolution Y (cm)");
378 fhQA[kVtxResZ][i] ->SetXTitle("Vertex Resolution Z (cm)");
379 fhQA[kVtxNCtrb][i] ->SetXTitle("Number of contributors");
382 for(Int_t i=0; i<kNCuts; i++) fhQA[i][1]->SetLineColor(color);
386 //_____________________________________________________________________________
387 void AliCFEventRecCuts::AddQAHistograms(TList *qaList) {
389 // saves the histograms in a TList
394 for (Int_t j=0; j<kNStepQA; j++) {
395 for(Int_t i=0; i<kNCuts; i++)
396 qaList->Add(fhQA[i][j]);