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),
50 //____________________________________________________________________
51 AliHFEextraEventCuts::AliHFEextraEventCuts(Char_t* name, Char_t* title) :
52 AliCFCutBase(name,title),
53 fRequireVtxCuts(kFALSE),
67 //____________________________________________________________________
68 AliHFEextraEventCuts::AliHFEextraEventCuts(const AliHFEextraEventCuts& c) :
70 fRequireVtxCuts(c.fRequireVtxCuts),
73 fVtxNCtrbMin(c.fVtxNCtrbMin),
74 fVtxMixed(c.fVtxMixed),
80 for (Int_t i=0; i<c.kNCuts; i++){
81 for (Int_t j=0; j<c.kNStepQA; j++){
82 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
88 //____________________________________________________________________
89 AliHFEextraEventCuts::~AliHFEextraEventCuts() {
94 for (Int_t i=0; i<kNCuts; i++){
95 for (Int_t j=0; j<kNStepQA; j++){
96 if(fhQA[i][j]) delete fhQA[i][j];
100 if(fBitMap)delete fBitMap;
103 //_____________________________________________________________________________
104 void AliHFEextraEventCuts::Initialise()
112 // sets pointers to histos to zero
115 for(Int_t i=0; i<kNCuts; i++){
116 for(Int_t j =0; j<kNStepQA; j++){
122 //____________________________________________________________________
123 AliHFEextraEventCuts& AliHFEextraEventCuts::operator=(const AliHFEextraEventCuts& c)
126 // Assignment operator
129 AliCFCutBase::operator=(c) ;
130 fRequireVtxCuts=c.fRequireVtxCuts;
133 fVtxNCtrbMin=c.fVtxNCtrbMin;
134 fVtxMixed=c.fVtxMixed;
138 for (Int_t i=0; i<c.kNCuts; i++){
139 for (Int_t j=0; j<c.kNStepQA; j++){
140 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
148 //____________________________________________________________________
149 Bool_t AliHFEextraEventCuts::IsSelected(TObject* obj) {
151 //Check if the requested cuts are passed
155 SelectionBitMap(obj);
157 if (fIsQAOn) FillHistograms(obj,0);
158 Bool_t isSelected = kTRUE;
160 for (UInt_t icut=0; icut<fBitMap->GetNbits();icut++)
161 if(!fBitMap->TestBitNumber(icut)) isSelected = kFALSE;
163 if (!isSelected) return kFALSE ;
164 if (fIsQAOn) FillHistograms(obj,1);
168 //____________________________________________________________________
169 void AliHFEextraEventCuts::SelectionBitMap(TObject* obj) {
171 //cut on the number of charged tracks and on the event vertex.
172 //so far specific to AliESDEvents
175 //Check if the requested cuts are passed and return a bitmap
176 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
180 AliESDEvent* esd = dynamic_cast<AliESDEvent *>(obj);
181 AliAODEvent* aod = dynamic_cast<AliAODEvent *>(obj);
188 //now start checking the cuts,
189 //first assume the event will be accepted:
190 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE);
195 const AliESDVertex* vtxESD = 0x0;
197 vtxESD = esd->GetPrimaryVertexTracks() ;
198 if((!vtxESD) || (vtxESD->GetNContributors() <= 0)) {
199 vtxESD = esd->GetPrimaryVertexSPD() ;
200 if((!vtxESD) || (vtxESD->GetNContributors() <= 0)) {
201 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
202 AliWarning("Cannot get vertex, skipping event");
208 vtxESD = esd->GetPrimaryVertexTracks() ;
212 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
213 AliWarning("Cannot get vertex, skipping event");
217 // Pick up the position and uncertainties
218 vtxESD = esd->GetPrimaryVertex();
220 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
221 AliWarning("Cannot get vertex, skipping event");
225 vtxPos[0] = vtxESD->GetXv();
226 vtxPos[1] = vtxESD->GetYv();
227 vtxPos[2] = vtxESD->GetZv();
229 Int_t nCtrb = vtxESD->GetNContributors();
233 if (vtxPos[2]>fVtxZMax || vtxPos[2]<fVtxZMin)
234 fBitMap->SetBitNumber(0,kFALSE);
235 if (nCtrb<fVtxNCtrbMin)
236 fBitMap->SetBitNumber(1,kFALSE);
250 //now start checking the cuts,
251 //first assume the event will be accepted:
252 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE);
257 const AliAODVertex* vtxAOD = 0x0;
259 vtxAOD = aod->GetPrimaryVertex();
260 if((!vtxAOD) || (vtxAOD->GetNContributors() <= 0)) {
261 vtxAOD = aod->GetPrimaryVertexSPD() ;
262 if((!vtxAOD) || (vtxAOD->GetNContributors() <= 0)) {
263 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
264 AliWarning("Cannot get vertex, skipping event");
270 vtxAOD = aod->GetPrimaryVertex() ;
274 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
275 AliWarning("Cannot get vertex, skipping event");
279 // Pick up the position and uncertainties
280 vtxAOD = aod->GetPrimaryVertex();
282 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
283 AliWarning("Cannot get vertex, skipping event");
287 vtxPos[0] = vtxAOD->GetX();
288 vtxPos[1] = vtxAOD->GetY();
289 vtxPos[2] = vtxAOD->GetZ();
291 Int_t nCtrb = vtxAOD->GetNContributors();
292 //printf("AliHFEextraCuts:: %d, %f, %f, %f\n",nCtrb,vtxPos[0],vtxPos[1],vtxPos[2]);
296 if (vtxPos[2]>fVtxZMax || vtxPos[2]<fVtxZMin)
297 fBitMap->SetBitNumber(0,kFALSE);
298 if (nCtrb<fVtxNCtrbMin)
299 fBitMap->SetBitNumber(1,kFALSE);
311 //_____________________________________________________________________________
312 void AliHFEextraEventCuts::FillHistograms(TObject* obj, Bool_t b)
315 // fill the QA histograms
319 // cast TObject into VParticle
320 AliESDEvent* esd = dynamic_cast<AliESDEvent *>(obj);
323 // index = 0: fill histograms before cuts
324 // index = 1: fill histograms after cuts
326 index = ((b) ? 1 : 0);
329 //look at vertex parameters:
330 const AliESDVertex* vtxESD = 0x0;
332 vtxESD = esd->GetPrimaryVertexTracks() ;
333 if((!vtxESD) || (vtxESD->GetNContributors() <= 0)) {
334 vtxESD = esd->GetPrimaryVertexSPD() ;
335 if((!vtxESD) || (vtxESD->GetNContributors() <= 0)) {
341 vtxESD = esd->GetPrimaryVertexTracks() ;
344 // vertex position and uncertainties
345 fhQA[kVtxPosZ] [index]->Fill(vtxESD->GetZv());
346 fhQA[kVtxNCtrb][index]->Fill(vtxESD->GetNContributors());
350 //____________________________________________________________________
351 void AliHFEextraEventCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bins)
354 //setting x-axis bin limits of QA histogram fhQA[index]
357 for(Int_t i=0;i<kNStepQA;i++){
358 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
361 fhQA[index][i]->GetXaxis()->Set(nbins,bins);
364 //____________________________________________________________________
365 void AliHFEextraEventCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin, Double_t xmax)
368 //setting x-axis bins and range of QA histogram fhQA[index]
371 for(Int_t i=0;i<kNStepQA;i++){
372 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
375 fhQA[index][i]->GetXaxis()->Set(nbins,xmin,xmax);
379 //_____________________________________________________________________________
380 void AliHFEextraEventCuts::DefineHistograms() {
382 // histograms for cut variables
387 AliInfo(Form("No QA histos requested, Please first set the QA flag on!"));
391 // book QA histograms
394 for (Int_t i=0; i<kNStepQA; i++) {
395 if (i==0) snprintf(str,5," ");
396 else snprintf(str,5,"_cut");
398 fhQA[kVtxPosZ][i] = new TH1F(Form("%s_Vtx_Pos_Z%s",GetName(),str), "",200,-50.,50.);
399 fhQA[kVtxNCtrb][i] = new TH1F(Form("%s_Vtx_N_Ctrb%s",GetName(),str), "",1000,0.,1000.);
401 fhQA[kVtxPosZ][i] ->SetXTitle("Vertex Position Z (cm)");
402 fhQA[kVtxNCtrb][i] ->SetXTitle("Number of contributors");
405 for(Int_t i=0; i<kNCuts; i++) fhQA[i][1]->SetLineColor(color);
409 //_____________________________________________________________________________
410 void AliHFEextraEventCuts::AddQAHistograms(TList *qaList) {
412 // saves the histograms in a TList
417 for (Int_t j=0; j<kNStepQA; j++) {
418 for(Int_t i=0; i<kNCuts; i++)
419 qaList->Add(fhQA[i][j]);