Fix
[u/mrichter/AliRoot.git] / CORRFW / AliCFEventGenCuts.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 generator level: for the moment just
16// the requirements on the MB process type, number of tracks and on
17// the 3-D vertex position are implemented
18// The argument of IsSelected member function (passed object) is cast into
19// an AliMCEvent. 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#include "TBits.h"
25#include "TList.h"
26#include "AliLog.h"
27#include "AliMCEvent.h"
28#include <AliGenEventHeader.h>
29#include <AliGenPythiaEventHeader.h>
30#include <AliGenCocktailEventHeader.h>
31#include "AliCFEventGenCuts.h"
32
33ClassImp(AliCFEventGenCuts)
34//____________________________________________________________________
35AliCFEventGenCuts::AliCFEventGenCuts() :
36 AliCFCutBase(),
e426fac9 37 fMBProcType(-1),
563113d0 38 fNTracksMin(-1),
39 fNTracksMax(100000),
40 fRequireVtxCuts(kFALSE),
41 fVtxXMax(1.e99),
42 fVtxYMax(1.e99),
43 fVtxZMax(1.e99),
44 fVtxXMin(-1.e99),
45 fVtxYMin(-1.e99),
46 fVtxZMin(-1.e99),
47 fBitMap(0x0)
48{
49 //
50 //ctor
51 //
52 fBitMap=new TBits(0);
53}
54//____________________________________________________________________
55AliCFEventGenCuts::AliCFEventGenCuts(Char_t* name, Char_t* title) :
56 AliCFCutBase(name,title),
e426fac9 57 fMBProcType(-1),
563113d0 58 fNTracksMin(-1),
59 fNTracksMax(100000),
60 fRequireVtxCuts(kFALSE),
61 fVtxXMax(1.e99),
62 fVtxYMax(1.e99),
63 fVtxZMax(1.e99),
64 fVtxXMin(-1.e99),
65 fVtxYMin(-1.e99),
66 fVtxZMin(-1.e99),
67 fBitMap(0x0)
68 {
69 //
70 //ctor
71 //
72 fBitMap=new TBits(0);
73 }
74//____________________________________________________________________
75AliCFEventGenCuts::AliCFEventGenCuts(const AliCFEventGenCuts& c) :
76 AliCFCutBase(c),
e426fac9 77 fMBProcType(c.fMBProcType),
563113d0 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 fBitMap(c.fBitMap)
88
89{
90 //
91 //copy constructor
92 //
93}
94//____________________________________________________________________
95AliCFEventGenCuts::~AliCFEventGenCuts() {
96 //
97 //dtor
98 //
99
100 if(fBitMap)delete fBitMap;
101}
102//____________________________________________________________________
103AliCFEventGenCuts& AliCFEventGenCuts::operator=(const AliCFEventGenCuts& c)
104{
105 //
106 // Assignment operator
107 //
108 if (this != &c) {
109 AliCFCutBase::operator=(c) ;
e426fac9 110 fMBProcType=c.fMBProcType;
563113d0 111 fNTracksMin=c.fNTracksMin;
112 fNTracksMax=c.fNTracksMax;
113 fRequireVtxCuts=c.fRequireVtxCuts;
114 fVtxXMax=c.fVtxXMax;
115 fVtxYMax=c.fVtxYMax;
116 fVtxZMax=c.fVtxZMax;
117 fVtxXMin=c.fVtxXMin;
118 fVtxYMin=c.fVtxYMin;
119 fVtxZMin=c.fVtxZMin;
120 fBitMap=c.fBitMap;
121 }
122 return *this ;
123}
124//____________________________________________________________________
9eeae5d5 125Bool_t AliCFEventGenCuts::IsSelected(TObject* obj) {
563113d0 126 //
127 //Check if the requested cuts are passed
128 //
129
107a3100 130 SelectionBitMap(obj);
563113d0 131
132 Bool_t isSelected = kTRUE;
133
107a3100 134 for (UInt_t icut=0; icut<fBitMap->GetNbits();icut++)
135 if(!fBitMap->TestBitNumber(icut)) isSelected = kFALSE;
563113d0 136
137 return isSelected;
138
139}
140
141//____________________________________________________________________
107a3100 142void AliCFEventGenCuts::SelectionBitMap(TObject* obj){
563113d0 143 //
144 //cut on the MB process type, the number of charged and neutral
145 //tracks and on the event vertex. So far specific to AliMCEvents
146 //
147
148 //Check if the requested cuts are passed and return a bitmap
149 for(Int_t j=0;j<kNCuts;j++)fBitMap->SetBitNumber(j,kFALSE);
150 AliMCEvent* ev = dynamic_cast<AliMCEvent *>(obj);
107a3100 151 if ( !ev ) return;
563113d0 152 AliGenEventHeader*genHeader = ev->GenEventHeader();
153
154
155 fBitMap->SetBitNumber(0,kTRUE);
e426fac9 156 if(fMBProcType>-1){
157 Int_t process=ProcType(genHeader);
563113d0 158 if(process==-1){
159 AliInfo(Form(" not a pythia event, not checking on the process type"));
160 }else{
161
e426fac9 162 switch (fMBProcType) {
563113d0 163 case kND:
164 {
165 if (!( process!=92 && process!=93 && process!=94))
166 fBitMap->SetBitNumber(0,kFALSE);
167 break;
168 }
169 case kSD:
170 {
171 if (!( process==92 || process==93))
172 fBitMap->SetBitNumber(0,kFALSE);
173 break;
174 }
175 case kDD:
176 {
177 if (!( process==94))
178 fBitMap->SetBitNumber(0,kFALSE);
179 break;
180 }
181 }
182 }
183 }
184
185
186 //Number of charged+neutral tracks:
187 Int_t nTracks = ev->GetNumberOfTracks();
188 fBitMap->SetBitNumber(1,kTRUE); //assume it is ok...
189 if(nTracks<fNTracksMin || nTracks>fNTracksMax)
190 fBitMap->SetBitNumber(1,kFALSE);
191
192 //now check the vertex cuts
193 for(Int_t j=2;j<kNCuts;j++)fBitMap->SetBitNumber(j,kTRUE);
194
195 TArrayF vtxPos(3);
196 genHeader->PrimaryVertex(vtxPos);
197
198 if(fRequireVtxCuts){
199 // Apply the cut
200 if (vtxPos[0]>fVtxXMax || vtxPos[0]<fVtxXMin)
201 fBitMap->SetBitNumber(2,kFALSE);
202 if (vtxPos[1]>fVtxYMax || vtxPos[1]<fVtxYMin)
203 fBitMap->SetBitNumber(3,kFALSE);
204 if (vtxPos[2]>fVtxZMax || vtxPos[2]<fVtxZMin)
205 fBitMap->SetBitNumber(4,kFALSE);
206 }
107a3100 207 return;
563113d0 208}
209
210 //______________________________________________________________________
e426fac9 211Bool_t AliCFEventGenCuts::IsMBProcType(AliMCEvent *ev, PrType iproc){
563113d0 212 //
213 //returns the type of MB process (if pythia events)
214 //
215
563113d0 216 if ( !ev ) return kFALSE ;
217
218 AliGenEventHeader*genHeader = ev->GenEventHeader();
219
e426fac9 220 Int_t process=ProcType(genHeader);
563113d0 221
e426fac9 222 switch (iproc) {
223 case kND: //Non Diffractive: Actually what is checked is ALL - SD - DD
563113d0 224 {
225 if ( process!=92 && process!=93 && process!=94)
226 return kTRUE;
227 }
806504ec 228 break;
563113d0 229 case kSD: //Single Diffractive
230 {
231 if ( process==92 || process==93)
232 return kTRUE;
233 }
806504ec 234 break;
563113d0 235 case kDD: //Double Diffractive
236 {
237 if ( process==94)
238 return kTRUE;
239 }
806504ec 240 break;
241 default: return kFALSE; break;
563113d0 242 }
4bc0c5f9 243
806504ec 244 return kFALSE;
563113d0 245}
e426fac9 246 //____________________________________________________________________________
247Int_t AliCFEventGenCuts::ProcType(AliGenEventHeader *genHeader) {
563113d0 248
e426fac9 249 //get the Pythia process type: if we are not dealing with pythia stuff,
563113d0 250 //return -1 and we do not apply the cut
251 //
252
253 // can only read pythia headers, either directly or from cocktalil header
254 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
255
256 if (!pythiaGenHeader) {
257
258 AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(genHeader);
259 if (!genCocktailHeader) {
260 return -1;
261 }
262
263 TList* headerList = genCocktailHeader->GetHeaders();
264 if (!headerList) {
265 return -1;
266 }
267
268 for (Int_t i=0; i<headerList->GetEntries(); i++) {
269 pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
270 if (pythiaGenHeader)
271 break;
272 }
273
274 if (!pythiaGenHeader) {
275 return -1;
276 }
277 }
278
279 Int_t process=pythiaGenHeader->ProcessType();
280 return process;
281}
e426fac9 282