some cleanup+ add diagnostic histograms
[u/mrichter/AliRoot.git] / CORRFW / AliCFEventRecCuts.cxx
CommitLineData
563113d0 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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
23//
24//
25#include "TBits.h"
26#include "AliLog.h"
27#include "AliESDEvent.h"
28#include "AliESDVertex.h"
29#include "AliCFEventRecCuts.h"
30ClassImp(AliCFEventRecCuts)
31//____________________________________________________________________
32AliCFEventRecCuts::AliCFEventRecCuts() :
33 AliCFCutBase(),
34 fNTracksMin(-1),
35 fNTracksMax(1000000),
36 fRequireVtxCuts(kFALSE),
37 fVtxXMax(1.e99),
38 fVtxYMax(1.e99),
39 fVtxZMax(1.e99),
40 fVtxXMin(-1.e99),
41 fVtxYMin(-1.e99),
42 fVtxZMin(-1.e99),
43 fVtxXResMax(1.e99),
44 fVtxYResMax(1.e99),
45 fVtxZResMax(1.e99),
46 fBitMap(0x0)
47{
48 //
49 //ctor
50 //
51 fBitMap=new TBits(0);
52}
53//____________________________________________________________________
54AliCFEventRecCuts::AliCFEventRecCuts(Char_t* name, Char_t* title) :
55 AliCFCutBase(name,title),
56 fNTracksMin(-1),
57 fNTracksMax(1000000),
58 fRequireVtxCuts(kFALSE),
59 fVtxXMax(1.e99),
60 fVtxYMax(1.e99),
61 fVtxZMax(1.e99),
62 fVtxXMin(-1.e99),
63 fVtxYMin(-1.e99),
64 fVtxZMin(-1.e99),
65 fVtxXResMax(1.e99),
66 fVtxYResMax(1.e99),
67 fVtxZResMax(1.e99),
68 fBitMap(0x0)
69 {
70 //
71 //ctor
72 //
73 fBitMap=new TBits(0);
74 }
75//____________________________________________________________________
76AliCFEventRecCuts::AliCFEventRecCuts(const AliCFEventRecCuts& c) :
77 AliCFCutBase(c),
78 fNTracksMin(c.fNTracksMin),
79 fNTracksMax(c.fNTracksMax),
80 fRequireVtxCuts(c.fRequireVtxCuts),
81 fVtxXMax(c.fVtxXMax),
82 fVtxYMax(c.fVtxYMax),
83 fVtxZMax(c.fVtxZMax),
84 fVtxXMin(c.fVtxXMin),
85 fVtxYMin(c.fVtxYMin),
86 fVtxZMin(c.fVtxZMin),
87 fVtxXResMax(c.fVtxXResMax),
88 fVtxYResMax(c.fVtxYResMax),
89 fVtxZResMax(c.fVtxZResMax),
90 fBitMap(c.fBitMap)
91
92{
93 //
94 //copy constructor
95 //
96}
97//____________________________________________________________________
98AliCFEventRecCuts::~AliCFEventRecCuts() {
99 //
100 //dtor
101 //
102
103 if(fBitMap)delete fBitMap;
104}
105//____________________________________________________________________
106AliCFEventRecCuts& AliCFEventRecCuts::operator=(const AliCFEventRecCuts& c)
107{
108 //
109 // Assignment operator
110 //
111 if (this != &c) {
112 AliCFCutBase::operator=(c) ;
113 fNTracksMin=c.fNTracksMin;
114 fNTracksMax=c.fNTracksMax;
115 fRequireVtxCuts=c.fRequireVtxCuts;
116 fVtxXMax=c.fVtxXMax;
117 fVtxYMax=c.fVtxYMax;
118 fVtxZMax=c.fVtxZMax;
119 fVtxXMin=c.fVtxXMin;
120 fVtxYMin=c.fVtxYMin;
121 fVtxZMin=c.fVtxZMin;
122 fVtxXResMax=c.fVtxXResMax;
123 fVtxYResMax=c.fVtxYResMax;
124 fVtxZResMax=c.fVtxZResMax;
125 fBitMap=c.fBitMap;
126 }
127 return *this ;
128}
129//____________________________________________________________________
130Bool_t AliCFEventRecCuts::IsSelected(TObject* obj) {
131 //
132 //Check if the requested cuts are passed
133 //
134
135 TBits *bitmap = SelectionBitMap(obj);
136
137 Bool_t isSelected = kTRUE;
138
139 for (UInt_t icut=0; icut<bitmap->GetNbits();icut++)
140 if(!bitmap->TestBitNumber(icut)) isSelected = kFALSE;
141
142 return isSelected;
143
144}
145
146//____________________________________________________________________
147TBits *AliCFEventRecCuts::SelectionBitMap(TObject* obj) {
148 //
149 //cut on the number of charged tracks and on the event vertex.
150 //so far specific to AliESDEvents
151 //
152
153 //Check if the requested cuts are passed and return a bitmap
154 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
155 AliESDEvent* esd = dynamic_cast<AliESDEvent *>(obj);
156 if ( !esd ) return fBitMap ;
157
158 //now start checking the cuts,
159 //first assume the event will be accepted:
160 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE);
161
162 //Number of charged tracks:
163 Int_t nTracks = esd->GetNumberOfTracks();
164 if(nTracks<fNTracksMin || nTracks>fNTracksMax)
165 fBitMap->SetBitNumber(0,kFALSE);
166
167 if(fRequireVtxCuts){
168 const AliESDVertex* vtxESD = esd->GetVertex();
169 if(!vtxESD){
170 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
171 return fBitMap;
172 }
173 // Require the vertex to have been reconstructed successfully
174 if (strcmp(vtxESD->GetName(), "default")==0){
175 AliWarning(Form(" No reconstructed vertex found, skip event"));
176 for(Int_t j=1;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
177 return fBitMap;
178 }
179 // Pick up the position and uncertainties
180
181 Double_t vtxPos[3];
182 vtxPos[0] = vtxESD->GetXv();
183 vtxPos[1] = vtxESD->GetYv();
184 vtxPos[2] = vtxESD->GetZv();
185
186 Double_t vtxRes[3];
187 vtxRes[0] = vtxESD->GetXRes();
188 vtxRes[1] = vtxESD->GetYRes();
189 vtxRes[2] = vtxESD->GetZRes();
190
191 // Apply the cut
192
193 if (vtxPos[0]>fVtxXMax || vtxPos[0]<fVtxXMin)
194 fBitMap->SetBitNumber(1,kFALSE);
195 if (vtxPos[1]>fVtxYMax || vtxPos[1]<fVtxYMin)
196 fBitMap->SetBitNumber(2,kFALSE);
197 if (vtxPos[2]>fVtxZMax || vtxPos[2]<fVtxZMin)
198 fBitMap->SetBitNumber(3,kFALSE);
199 if (vtxRes[0]==0 || vtxRes[0]>fVtxXResMax)
200 fBitMap->SetBitNumber(4,kFALSE);
201 if (vtxRes[1]==0 || vtxRes[1]>fVtxYResMax)
202 fBitMap->SetBitNumber(5,kFALSE);
203 if (vtxRes[2]==0 || vtxRes[2]>fVtxZResMax)
204 fBitMap->SetBitNumber(6,kFALSE);
205 }
206 return fBitMap;
207}
208//__________________________________________________________________________________
209void AliCFEventRecCuts::GetBitMap(TObject* obj, TBits *bitmap) {
210 //
211 // retrieve the pointer to the bitmap
212 //
213 bitmap = SelectionBitMap(obj);
214
215}