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),
61 //____________________________________________________________________
62 AliCFEventRecCuts::AliCFEventRecCuts(Char_t* name, Char_t* title) :
63 AliCFCutBase(name,title),
66 fRequireVtxCuts(kFALSE),
77 fVtxNCtrbMax((Int_t)1.e9),
89 //____________________________________________________________________
90 AliCFEventRecCuts::AliCFEventRecCuts(const AliCFEventRecCuts& c) :
92 fNTracksMin(c.fNTracksMin),
93 fNTracksMax(c.fNTracksMax),
94 fRequireVtxCuts(c.fRequireVtxCuts),
100 fVtxZMin(c.fVtxZMin),
101 fVtxXResMax(c.fVtxXResMax),
102 fVtxYResMax(c.fVtxYResMax),
103 fVtxZResMax(c.fVtxZResMax),
104 fVtxNCtrbMin(c.fVtxNCtrbMin),
105 fVtxNCtrbMax(c.fVtxNCtrbMax),
113 for (Int_t i=0; i<c.kNCuts; i++){
114 for (Int_t j=0; j<c.kNStepQA; j++){
115 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
121 //____________________________________________________________________
122 AliCFEventRecCuts::~AliCFEventRecCuts() {
127 for (Int_t i=0; i<kNCuts; i++){
128 for (Int_t j=0; j<kNStepQA; j++){
129 if(fhQA[i][j]) delete fhQA[i][j];
133 if(fBitMap)delete fBitMap;
136 //_____________________________________________________________________________
137 void AliCFEventRecCuts::Initialise()
145 // sets pointers to histos to zero
148 for(Int_t i=0; i<kNCuts; i++){
149 for(Int_t j =0; j<kNStepQA; j++){
155 //____________________________________________________________________
156 AliCFEventRecCuts& AliCFEventRecCuts::operator=(const AliCFEventRecCuts& c)
159 // Assignment operator
162 AliCFCutBase::operator=(c) ;
163 fNTracksMin=c.fNTracksMin;
164 fNTracksMax=c.fNTracksMax;
165 fRequireVtxCuts=c.fRequireVtxCuts;
172 fVtxXResMax=c.fVtxXResMax;
173 fVtxYResMax=c.fVtxYResMax;
174 fVtxZResMax=c.fVtxZResMax;
175 fVtxNCtrbMin=c.fVtxNCtrbMin;
176 fVtxNCtrbMax=c.fVtxNCtrbMax;
182 for (Int_t i=0; i<c.kNCuts; i++){
183 for (Int_t j=0; j<c.kNStepQA; j++){
184 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
192 //____________________________________________________________________
193 Bool_t AliCFEventRecCuts::IsSelected(TObject* obj) {
195 //Check if the requested cuts are passed
199 SelectionBitMap(obj);
201 if (fIsQAOn) FillHistograms(obj,0);
202 Bool_t isSelected = kTRUE;
204 for (UInt_t icut=0; icut<fBitMap->GetNbits();icut++)
205 if(!fBitMap->TestBitNumber(icut)) isSelected = kFALSE;
207 if (!isSelected) return kFALSE ;
208 if (fIsQAOn) FillHistograms(obj,1);
212 //____________________________________________________________________
213 void AliCFEventRecCuts::SelectionBitMap(TObject* obj) {
215 //cut on the number of charged tracks and on the event vertex.
216 //so far specific to AliESDEvents
219 //Check if the requested cuts are passed and return a bitmap
220 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
221 AliESDEvent* esd = dynamic_cast<AliESDEvent *>(obj);
224 //now start checking the cuts,
225 //first assume the event will be accepted:
226 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE);
228 //Number of charged tracks:
229 Int_t nTracks = esd->GetNumberOfTracks();
230 if(nTracks<fNTracksMin || nTracks>fNTracksMax)
231 fBitMap->SetBitNumber(0,kFALSE);
234 const AliESDVertex* vtxESD = 0x0;
235 if (fVtxTPC) vtxESD = esd->GetPrimaryVertexTPC() ;
236 else if (fVtxSPD) vtxESD = esd->GetPrimaryVertexSPD() ;
237 else vtxESD = esd->GetPrimaryVertexTracks() ;
239 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
240 AliWarning("Cannot get vertex, skipping event");
243 // Require the vertex to have been reconstructed successfully
244 if (strcmp(vtxESD->GetName(), "default")==0){
245 AliWarning(Form(" No reconstructed vertex found, skipping event"));
246 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
249 // Pick up the position and uncertainties
252 vtxPos[0] = vtxESD->GetXv();
253 vtxPos[1] = vtxESD->GetYv();
254 vtxPos[2] = vtxESD->GetZv();
257 vtxRes[0] = vtxESD->GetXRes();
258 vtxRes[1] = vtxESD->GetYRes();
259 vtxRes[2] = vtxESD->GetZRes();
261 Int_t nCtrb = vtxESD->GetNContributors();
265 if (vtxPos[0]>fVtxXMax || vtxPos[0]<fVtxXMin)
266 fBitMap->SetBitNumber(1,kFALSE);
267 if (vtxPos[1]>fVtxYMax || vtxPos[1]<fVtxYMin)
268 fBitMap->SetBitNumber(2,kFALSE);
269 if (vtxPos[2]>fVtxZMax || vtxPos[2]<fVtxZMin)
270 fBitMap->SetBitNumber(3,kFALSE);
271 if (vtxRes[0]==0 || vtxRes[0]>fVtxXResMax)
272 fBitMap->SetBitNumber(4,kFALSE);
273 if (vtxRes[1]==0 || vtxRes[1]>fVtxYResMax)
274 fBitMap->SetBitNumber(5,kFALSE);
275 if (vtxRes[2]==0 || vtxRes[2]>fVtxZResMax)
276 fBitMap->SetBitNumber(6,kFALSE);
277 if (nCtrb<fVtxNCtrbMin || nCtrb>fVtxNCtrbMax)
278 fBitMap->SetBitNumber(7,kFALSE);
284 //_____________________________________________________________________________
285 void AliCFEventRecCuts::FillHistograms(TObject* obj, Bool_t b)
288 // fill the QA histograms
292 // cast TObject into VParticle
293 AliESDEvent* esd = dynamic_cast<AliESDEvent *>(obj);
296 // index = 0: fill histograms before cuts
297 // index = 1: fill histograms after cuts
299 index = ((b) ? 1 : 0);
302 //number of charged tracks:
303 Int_t nTracks = esd->GetNumberOfTracks();
304 fhQA[kNTracks][index]->Fill(nTracks);
306 //look at vertex parameters:
307 const AliESDVertex* vtxESD = 0x0;
308 if (fVtxTPC) vtxESD = esd->GetPrimaryVertexTPC() ;
309 else if (fVtxSPD) vtxESD = esd->GetPrimaryVertexSPD() ;
310 else vtxESD = esd->GetPrimaryVertexTracks() ;
312 // Require the vertex to have been reconstructed successfully
313 if (strcmp(vtxESD->GetName(), "default")==0)return;
314 // vertex position and uncertainties
315 fhQA[kVtxPosX] [index]->Fill(vtxESD->GetXv());
316 fhQA[kVtxPosY] [index]->Fill(vtxESD->GetYv());
317 fhQA[kVtxPosZ] [index]->Fill(vtxESD->GetZv());
318 fhQA[kVtxResX] [index]->Fill(vtxESD->GetXRes());
319 fhQA[kVtxResY] [index]->Fill(vtxESD->GetYRes());
320 fhQA[kVtxResZ] [index]->Fill(vtxESD->GetZRes());
321 fhQA[kVtxNCtrb][index]->Fill(vtxESD->GetNContributors());
325 //____________________________________________________________________
326 void AliCFEventRecCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bins)
329 //setting x-axis bin limits of QA histogram fhQA[index]
332 for(Int_t i=0;i<kNStepQA;i++){
333 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
336 fhQA[index][i]->GetXaxis()->Set(nbins,bins);
339 //____________________________________________________________________
340 void AliCFEventRecCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin, Double_t xmax)
343 //setting x-axis bins and range of QA histogram fhQA[index]
346 for(Int_t i=0;i<kNStepQA;i++){
347 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
350 fhQA[index][i]->GetXaxis()->Set(nbins,xmin,xmax);
354 //_____________________________________________________________________________
355 void AliCFEventRecCuts::DefineHistograms() {
357 // histograms for cut variables
362 AliInfo(Form("No QA histos requested, Please first set the QA flag on!"));
366 // book QA histograms
369 for (Int_t i=0; i<kNStepQA; i++) {
370 if (i==0) snprintf(str,5," ");
371 else snprintf(str,5,"_cut");
373 fhQA[kNTracks][i] = new TH1F(Form("%s_NTracks%s",GetName(),str), "",501,-0.5,500.5);
374 fhQA[kVtxPosX][i] = new TH1F(Form("%s_Vtx_Pos_X%s",GetName(),str), "",100,-5.,5.);
375 fhQA[kVtxPosY][i] = new TH1F(Form("%s_Vtx_Pos_Y%s",GetName(),str), "",100,-5.,5.);
376 fhQA[kVtxPosZ][i] = new TH1F(Form("%s_Vtx_Pos_Z%s",GetName(),str), "",200,-50.,50.);
377 fhQA[kVtxResX][i] = new TH1F(Form("%s_Vtx_Res_X%s",GetName(),str), "",100,-1.,1.);
378 fhQA[kVtxResY][i] = new TH1F(Form("%s_Vtx_Res_Y%s",GetName(),str), "",100,-1.,1.);
379 fhQA[kVtxResZ][i] = new TH1F(Form("%s_Vtx_Res_Z%s",GetName(),str), "",100,-1.,1.);
380 fhQA[kVtxNCtrb][i] = new TH1F(Form("%s_Vtx_N_Ctrb%s",GetName(),str), "",1000,0.,1000.);
382 fhQA[kNTracks][i] ->SetXTitle("Number of ESD tracks");
383 fhQA[kVtxPosX][i] ->SetXTitle("Vertex Position X (cm)");
384 fhQA[kVtxPosY][i] ->SetXTitle("Vertex Position Y (cm)");
385 fhQA[kVtxPosZ][i] ->SetXTitle("Vertex Position Z (cm)");
386 fhQA[kVtxResX][i] ->SetXTitle("Vertex Resolution X (cm)");
387 fhQA[kVtxResY][i] ->SetXTitle("Vertex Resolution Y (cm)");
388 fhQA[kVtxResZ][i] ->SetXTitle("Vertex Resolution Z (cm)");
389 fhQA[kVtxNCtrb][i] ->SetXTitle("Number of contributors");
392 for(Int_t i=0; i<kNCuts; i++) fhQA[i][1]->SetLineColor(color);
396 //_____________________________________________________________________________
397 void AliCFEventRecCuts::AddQAHistograms(TList *qaList) {
399 // saves the histograms in a TList
404 for (Int_t j=0; j<kNStepQA; j++) {
405 for(Int_t i=0; i<kNCuts; i++)
406 qaList->Add(fhQA[i][j]);