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),
45 fVtxResolution(kFALSE),
53 //____________________________________________________________________
54 AliHFEextraEventCuts::AliHFEextraEventCuts(Char_t* name, Char_t* title) :
55 AliCFCutBase(name,title),
56 fRequireVtxCuts(kFALSE),
62 fCheckCorrelationSPDVtx(0),
63 fVtxResolution(kFALSE),
73 //____________________________________________________________________
74 AliHFEextraEventCuts::AliHFEextraEventCuts(const AliHFEextraEventCuts& c) :
76 fRequireVtxCuts(c.fRequireVtxCuts),
79 fVtxNCtrbMin(c.fVtxNCtrbMin),
80 fVtxMixed(c.fVtxMixed),
82 fCheckCorrelationSPDVtx(c.fCheckCorrelationSPDVtx),
83 fVtxResolution(c.fVtxResolution),
89 for (Int_t i=0; i<c.kNCuts; i++){
90 for (Int_t j=0; j<c.kNStepQA; j++){
91 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
97 //____________________________________________________________________
98 AliHFEextraEventCuts::~AliHFEextraEventCuts() {
103 for (Int_t i=0; i<kNCuts; i++){
104 for (Int_t j=0; j<kNStepQA; j++){
105 if(fhQA[i][j]) delete fhQA[i][j];
109 if(fBitMap)delete fBitMap;
112 //_____________________________________________________________________________
113 void AliHFEextraEventCuts::Initialise()
121 // sets pointers to histos to zero
124 for(Int_t i=0; i<kNCuts; i++){
125 for(Int_t j =0; j<kNStepQA; j++){
131 //____________________________________________________________________
132 AliHFEextraEventCuts& AliHFEextraEventCuts::operator=(const AliHFEextraEventCuts& c)
135 // Assignment operator
138 AliCFCutBase::operator=(c) ;
139 fRequireVtxCuts=c.fRequireVtxCuts;
142 fVtxNCtrbMin=c.fVtxNCtrbMin;
143 fVtxMixed=c.fVtxMixed;
145 fCheckCorrelationSPDVtx=c.fCheckCorrelationSPDVtx;
146 fVtxResolution = c.fVtxResolution;
150 for (Int_t i=0; i<c.kNCuts; i++){
151 for (Int_t j=0; j<c.kNStepQA; j++){
152 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
160 //____________________________________________________________________
161 Bool_t AliHFEextraEventCuts::IsSelected(TObject* obj) {
163 //Check if the requested cuts are passed
167 SelectionBitMap(obj);
169 if (fIsQAOn) FillHistograms(obj,0);
170 Bool_t isSelected = kTRUE;
172 for (UInt_t icut=0; icut<fBitMap->GetNbits();icut++)
173 if(!fBitMap->TestBitNumber(icut)) isSelected = kFALSE;
175 if (!isSelected) return kFALSE ;
176 if (fIsQAOn) FillHistograms(obj,1);
180 //____________________________________________________________________
181 void AliHFEextraEventCuts::SelectionBitMap(TObject* obj) {
183 //cut on the number of charged tracks and on the event vertex.
184 //so far specific to AliESDEvents
187 //Check if the requested cuts are passed and return a bitmap
189 AliVEvent *inputEvent = dynamic_cast<AliVEvent *>(obj);
191 AliDebug(1, "Not a virtual event");
192 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
195 const AliVVertex *vtxTracks = GetPrimaryVertexTracks(inputEvent),
196 *vtxSPD = GetPrimaryVertexSPD(inputEvent),
199 //first assume the event will be accepted:
200 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE);
203 // Use mixed vertex: Prefer vertex with tracks, in case not available use SPD vertex
204 if(vtxTracks && vtxTracks->GetNContributors() > 0) vtxPrim = vtxTracks;
205 else if(vtxSPD && vtxSPD->GetNContributors() > 0) vtxPrim = vtxSPD;
207 if(vtxSPD && vtxSPD->GetNContributors () > 0) vtxPrim = vtxSPD;
209 if(vtxTracks && vtxTracks->GetNContributors() > 0) vtxPrim = vtxTracks;
212 // No primary vertex: Reject event
213 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
214 AliWarning("Cannot get vertex, skipping event");
217 // Check standard vertex cuts using the primary vertex
218 if(fVtxZMin > - 1000. && fVtxZMax < 1000.){
219 // Primary vertex z cut required
220 // Pick up the position and uncertainties
222 vtxPos[0] = vtxPrim->GetX();
223 vtxPos[1] = vtxPrim->GetY();
224 vtxPos[2] = vtxPrim->GetZ();
225 if (vtxPos[2]>fVtxZMax || vtxPos[2]<fVtxZMin)
226 fBitMap->SetBitNumber(kVtxPosZ,kFALSE);
228 if(fVtxNCtrbMin > 0){
229 // cut required if the cut value is set to something larger than 0
230 // same effect as setting the min. cut value to 0
231 Int_t nCtrb = vtxPrim->GetNContributors();
232 if (nCtrb<fVtxNCtrbMin)
233 fBitMap->SetBitNumber(kVtxNCtrb,kFALSE);
236 // check vertex correlation cut
237 if(fCheckCorrelationSPDVtx){
238 if(vtxTracks && vtxTracks->GetNContributors() && vtxSPD && vtxSPD->GetNContributors()){
239 // Both vertices available, check correlation
240 if(TMath::Abs(vtxTracks->GetZ() - vtxSPD->GetZ()) >= 0.5) fBitMap->SetBitNumber(kCorrelation, kFALSE);
242 // No correlation available: set the cut to false
243 fBitMap->SetBitNumber(kCorrelation, kFALSE);
246 // check cut on the SPD vertex resolution
249 TString vtxTyp = vtxSPD->GetTitle();
251 vtxSPD->GetCovarianceMatrix(cov);
252 Double_t zRes = TMath::Sqrt(cov[5]);
253 if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) fBitMap->SetBitNumber(kResolution, kFALSE);
255 fBitMap->SetBitNumber(kResolution, kFALSE);
260 //_____________________________________________________________________________
261 void AliHFEextraEventCuts::FillHistograms(TObject* obj, Bool_t b)
264 // fill the QA histograms
268 // cast TObject into VEvent
269 AliVEvent* inputEvent = dynamic_cast<AliESDEvent *>(obj);
270 if (!inputEvent) return;
272 // index = 0: fill histograms before cuts
273 // index = 1: fill histograms after cuts
275 index = ((b) ? 1 : 0);
278 const AliVVertex *vtxTracks = GetPrimaryVertexTracks(inputEvent),
279 *vtxSPD = GetPrimaryVertexSPD(inputEvent),
282 //look at vertex parameters:
284 if(vtxTracks && vtxTracks->GetNContributors() > 0) vtxPrim = vtxTracks;
285 else if(vtxSPD && vtxSPD->GetNContributors()) vtxPrim = vtxSPD;
291 // vertex position and uncertainties
292 fhQA[kVtxPosZ] [index]->Fill(vtxPrim->GetZ());
293 fhQA[kVtxNCtrb][index]->Fill(vtxPrim->GetNContributors());
294 // SPD Vertex Position Correlation
295 if(vtxTracks && vtxSPD){
296 fhQA[kCorrelation][index]->Fill(vtxTracks->GetZ()-vtxSPD->GetZ());
300 vtxSPD->GetCovarianceMatrix(cov);
301 fhQA[kResolution][index]->Fill(TMath::Sqrt(cov[5]));
305 //____________________________________________________________________
306 void AliHFEextraEventCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bins)
309 //setting x-axis bin limits of QA histogram fhQA[index]
312 for(Int_t i=0;i<kNStepQA;i++){
313 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
316 fhQA[index][i]->GetXaxis()->Set(nbins,bins);
319 //____________________________________________________________________
320 void AliHFEextraEventCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin, Double_t xmax)
323 //setting x-axis bins and range of QA histogram fhQA[index]
326 for(Int_t i=0;i<kNStepQA;i++){
327 if(!fhQA[index][i]){AliWarning("non-existing histogram!");
330 fhQA[index][i]->GetXaxis()->Set(nbins,xmin,xmax);
334 //_____________________________________________________________________________
335 void AliHFEextraEventCuts::DefineHistograms() {
337 // histograms for cut variables
342 AliInfo(Form("No QA histos requested, Please first set the QA flag on!"));
346 // book QA histograms
348 for (Int_t i=0; i<kNStepQA; i++) {
349 if (i==0) snprintf(str,5," ");
350 else snprintf(str,5,"_cut");
352 fhQA[kVtxPosZ][i] = new TH1F(Form("%s_Vtx_Pos_Z%s",GetName(),str), "",200,-50.,50.);
353 fhQA[kVtxNCtrb][i] = new TH1F(Form("%s_Vtx_N_Ctrb%s",GetName(),str), "",1000,0.,1000.);
354 fhQA[kCorrelation][i] = new TH1F(Form("%s_SPDCorrelation_%s",GetName(),str), "",200, -10., 10);
355 fhQA[kResolution][i] = new TH1F(Form("%s_SPDResolution_%s",GetName(), str), "", 100, 0., 1.);
357 fhQA[kVtxPosZ][i] ->SetXTitle("Vertex Position Z (cm)");
358 fhQA[kVtxNCtrb][i] ->SetXTitle("Number of contributors");
361 for(Int_t i=0; i<kNCuts; i++) fhQA[i][1]->SetLineColor(color);
365 //_____________________________________________________________________________
366 void AliHFEextraEventCuts::AddQAHistograms(TList *qaList) {
368 // saves the histograms in a TList
373 for (Int_t j=0; j<kNStepQA; j++) {
374 for(Int_t i=0; i<kNCuts; i++)
375 qaList->Add(fhQA[i][j]);
379 //_____________________________________________________________________________
380 const AliVVertex *AliHFEextraEventCuts::GetPrimaryVertexSPD(const AliVEvent * const inputEvent){
382 // Get SPD vertex from event
384 const AliVVertex *spdvtx(NULL);
385 const AliESDEvent *esd(NULL);
386 const AliAODEvent *aod(NULL);
387 if((esd = dynamic_cast<const AliESDEvent *>(inputEvent))){
388 spdvtx = esd->GetPrimaryVertexSPD();
389 } else if((aod = dynamic_cast<const AliAODEvent *>(inputEvent))){
390 spdvtx = aod->GetPrimaryVertexSPD();
395 //_____________________________________________________________________________
396 const AliVVertex *AliHFEextraEventCuts::GetPrimaryVertexTracks(const AliVEvent *const inputEvent){
398 // Get Primary Vertex from tracks
400 const AliVVertex *trkvtx(NULL);
401 const AliESDEvent *esd(NULL);
402 const AliAODEvent *aod(NULL);
403 if((esd = dynamic_cast<const AliESDEvent *>(inputEvent))){
404 trkvtx = esd->GetPrimaryVertexTracks();
405 } else if((aod = dynamic_cast<const AliAODEvent *>(inputEvent))){
406 const AliVVertex *vtxTmp = aod->GetPrimaryVertex();
407 // check whether the primary vertex is the vertex from tracks
408 TString vtxTtl = vtxTmp->GetTitle();
409 if(vtxTtl.Contains("VertexerTracks")){