AliPhysics  8dc8609 (8dc8609)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliConversionAODBGHandlerRP.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Authors: Daniel Lohner (Daniel.Lohner@cern.ch), *
5 * Lucia Leardini (lucia.leardini@cern.ch)*
6 * Version 1.0 *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16 
17 #if !defined( __CINT__) || defined(__MAKECINT__)
18 
19 #include <exception>
20 #include <iostream>
21 #include "AliLog.h"
22 #include "AliEventplane.h"
24 using namespace std;
25 #endif
26 
28 
29 //________________________________________________________________________
31  fIsHeavyIon(IsHeavyIon),
32  fUseChargedTrackMult(UseChargedTrackMult),
33  fNEvents(NEvents),
34  fBGEventCounter(NULL),
35  fNBGEvents(NULL),
36  fNBinsRP(8),
37  fNBinsZ(7),
38  fNBinsMultiplicity(5+Int_t(fUseChargedTrackMult)),
39  fBinLimitsArrayRP(NULL),
40  fBinLimitsArrayZ(NULL),
41  fBinLimitsArrayMultiplicity(NULL),
42  fBGEvents(fNBinsRP,AliGammaConversionVertexPositionVector(fNBinsZ,AliGammaConversionBGEventVector(fNEvents)))
43 // fBGPool(fNBinsZ,AliGammaConversionMultiplicityVector(fNBinsMultiplicity,AliGammaConversionBGEventVector(fNEvents)))
44 {
45 
46  // RP angle Binning
48  for(Int_t i=0; i < fNBinsRP+1; i++){
49  fBinLimitsArrayRP[i] = i*TMath::Pi()/Double_t(fNBinsRP);
50  }
51 
52  // Vertex Z Binning
53 
55  fBinLimitsArrayZ[0] = -50.00;
56  fBinLimitsArrayZ[1] = -3.375;
57  fBinLimitsArrayZ[2] = -1.605;
58  fBinLimitsArrayZ[3] = -0.225;
59  fBinLimitsArrayZ[4] = 1.065;
60  fBinLimitsArrayZ[5] = 2.445;
61  fBinLimitsArrayZ[6] = 4.245;
62  fBinLimitsArrayZ[7] = 50.00;
63 
64  // MultiplicityBins
66 
68  // Use Charged Particle Multiplicity
75 
76  if(fIsHeavyIon){
80  fBinLimitsArrayMultiplicity[3] = 1000.;
81  fBinLimitsArrayMultiplicity[4] = 1500.;
82  fBinLimitsArrayMultiplicity[5] = 5000.;
83  }
84  } else {
85  // Use V0 Multiplicity
91 
92  if(fIsHeavyIon){
98  }
99  }
100  Initialize();
101 }
102 
103 //________________________________________________________________________
105 {
106  if(fBinLimitsArrayRP){
107  delete[] fBinLimitsArrayRP;
108  fBinLimitsArrayRP=0x0;
109  }
110 
111  if(fBinLimitsArrayZ){
112  delete[] fBinLimitsArrayZ;
113  fBinLimitsArrayZ=0x0;
114  }
115 
119  }
120 
121  if(fBGEventCounter){
122  for(Int_t psi = 0; psi < fNBinsRP; psi++){
123  delete[] fBGEventCounter[psi];
124  }
125  delete[] fBGEventCounter;
126  fBGEventCounter = NULL;
127  }
128 
129  // Delete pool
130 
131  for(Int_t psi = 0; psi < fNBinsRP; psi++){
132  for(Int_t z = 0; z < fNBinsZ; z++){
133  for(Int_t eventCounter=0; eventCounter < fNBGEvents[psi][z] && eventCounter<fNEvents; eventCounter++){
134 
135  for(UInt_t d=0; d < fBGEvents[psi][z][eventCounter].size(); d++){
136  delete (AliAODConversionPhoton*)(fBGEvents[psi][z][eventCounter][d]);
137 
138  }
139  }
140  }
141  }
142 
143  if(fNBGEvents){
144  for(Int_t psi = 0; psi < fNBinsRP; psi++){
145  delete[] fNBGEvents[psi];
146  }
147  delete[] fNBGEvents;
148  fNBGEvents = NULL;
149  }
150 
151 }
152 
153 //________________________________________________________________________
155 
156  // Counter
157 
158  if(fBGEventCounter == NULL){
159  fBGEventCounter = new Int_t*[fNBinsRP];
160  }
161  for(Int_t psi = 0; psi < fNBinsRP; psi++){
162  fBGEventCounter[psi] = new Int_t[fNBinsZ];
163  }
164  for(Int_t psi = 0; psi < fNBinsRP; psi++){
165  for(Int_t z = 0; z < fNBinsZ; z++){
166  fBGEventCounter[psi][z] = 0;
167  }
168  }
169 
170 
171  if(fNBGEvents == NULL){
172  fNBGEvents = new Int_t*[fNBinsRP];
173  }
174  for(Int_t psi = 0; psi < fNBinsRP; psi++){
175  fNBGEvents[psi] = new Int_t[fNBinsZ];
176  }
177  for(Int_t psi = 0; psi < fNBinsRP; psi++){
178  for(Int_t z = 0; z < fNBinsZ; z++){
179  fNBGEvents[psi][z] = 0;
180  }
181  }
182 }
183 
184 //-------------------------------------------------------------
186 
187  if(fNBinsRP < 2){
188  return 0;
189  }
190 
191  if(psivalue<=fBinLimitsArrayRP[0]){
192  return -1;
193  }
194 
195  for(Int_t i = 0; i < fNBinsRP; i++){
196  if(psivalue >= fBinLimitsArrayRP[i] && psivalue <= fBinLimitsArrayRP[i+1]){
197  return i;
198  }
199  }
200  return -1;
201 }
202 
203 //-------------------------------------------------------------
205 
206  if(fNBinsZ < 2){
207  return 0;
208  }
209 
210  if(zvalue<=fBinLimitsArrayZ[0]){
211  return -1;
212  }
213 
214  for(Int_t i=0; i < fNBinsZ; i++){
215  if(zvalue >= fBinLimitsArrayZ[i] && zvalue <= fBinLimitsArrayZ[i+1]){
216  return i;
217  }
218  }
219  return -1;
220 }
221 
222 //-------------------------------------------------------------
224 
225  if(fNBinsMultiplicity < 2){
226  return 0;
227  }
228 
229  for(Int_t i=0; i < fNBinsMultiplicity; i++){
230  if(multiplicity >= fBinLimitsArrayMultiplicity[i] && multiplicity < fBinLimitsArrayMultiplicity[i+1]){
231  return i;
232  }
233  }
234  return -1;
235 }
236 
237 //-------------------------------------------------------------
238 Bool_t AliConversionAODBGHandlerRP::FindBins(TObjArray * const eventGammas,AliVEvent *fInputEvent,Int_t &psibin,Int_t &zbin){
239 
240  Double_t eventplaneangle;
241  AliEventplane *EventPlane = fInputEvent->GetEventplane();
242  if(fIsHeavyIon ==1)eventplaneangle = EventPlane->GetEventplane("V0",fInputEvent,2);
243  else eventplaneangle = 0.0;
244  psibin = GetRPBinIndex(eventplaneangle);
245 
246  Double_t vertexz = fInputEvent->GetPrimaryVertex()->GetZ();
247  zbin = GetZBinIndex(vertexz);
248 
249  if(psibin < fNBinsRP && zbin < fNBinsZ){
250  if(psibin >= 0 && zbin >= 0 ){
251  return kTRUE;
252  }
253  }
254  //cout<<Form("Requested BG pool does not exist: z %i m %i",zbin)<<endl;
255  return kFALSE;
256 }
257 
258 //-------------------------------------------------------------
259 Bool_t AliConversionAODBGHandlerRP::FindBins(TList * const eventGammas,AliVEvent *fInputEvent,Int_t &psibin,Int_t &zbin){
260 
261  Double_t eventplaneangle;
262  AliEventplane *EventPlane = fInputEvent->GetEventplane();
263  if(fIsHeavyIon ==1)eventplaneangle = EventPlane->GetEventplane("V0",fInputEvent,2);
264  else eventplaneangle = 0.0;
265  psibin = GetRPBinIndex(eventplaneangle);
266 
267  Double_t vertexz=fInputEvent->GetPrimaryVertex()->GetZ();
268  zbin = GetZBinIndex(vertexz);
269 
270  if(psibin < fNBinsRP && zbin < fNBinsZ){
271  if(psibin >= 0 && zbin >= 0 ){
272  return kTRUE;
273  }
274  }
275  //cout<<Form("Requested BG pool does not exist: z %i m %i",zbin)<<endl;
276  return kFALSE;
277 }
278 
279 
280 //-------------------------------------------------------------
281 void AliConversionAODBGHandlerRP::AddEvent(TObjArray * const eventGammas,AliVEvent *fInputEvent){
282 
283  if(eventGammas->GetEntriesFast()==0)return;
284 
285  Int_t psi;
286  Int_t z;
287 
288  if(FindBins(eventGammas,fInputEvent,psi,z)){
289  // If Event Stack is full, replace the first entry (First in first out)
290  if(fBGEventCounter[psi][z] >= fNEvents){
291  fBGEventCounter[psi][z] = 0;
292  }
293 
294  // Update number of Events stored
295  if(fNBGEvents[psi][z] < fNEvents){
296  fNBGEvents[psi][z]++;
297  }
298 
299  Int_t eventCounter = fBGEventCounter[psi][z];
300 
301  //clear the vector for old gammas
302  for(UInt_t d = 0; d < fBGEvents[psi][z][eventCounter].size(); d++){
303  delete (AliAODConversionPhoton*)(fBGEvents[psi][z][eventCounter][d]);
304  }
305 
306  fBGEvents[psi][z][eventCounter].clear();
307 
308  // add the gammas to the vector
309  for(Int_t i = 0; i < eventGammas->GetEntriesFast(); i++){
310  fBGEvents[psi][z][eventCounter].push_back(new AliAODConversionPhoton(*(AliAODConversionPhoton*)(eventGammas->At(i))));
311  }
312 
313  fBGEventCounter[psi][z]++;
314  }
315 }
316 //-------------------------------------------------------------
317 void AliConversionAODBGHandlerRP::AddEvent(TList * const eventGammas,AliVEvent *fInputEvent){
318  if(eventGammas->GetEntries()==0)return;
319 
320  Int_t psi;
321  Int_t z;
322 
323  if(FindBins(eventGammas,fInputEvent,psi,z)){
324  // If Event Stack is full, replace the first entry (First in first out)
325  if(fBGEventCounter[psi][z] >= fNEvents){
326  fBGEventCounter[psi][z]=0;
327  }
328 
329  // Update number of Events stored
330  if(fNBGEvents[psi][z] < fNEvents){
331  fNBGEvents[psi][z]++;
332  }
333 
334  Int_t eventCounter = fBGEventCounter[psi][z];
335 
336  //clear the vector for old gammas
337  for(UInt_t d = 0; d < fBGEvents[psi][z][eventCounter].size(); d++){
338  delete (AliAODConversionPhoton*)(fBGEvents[psi][z][eventCounter][d]);
339  }
340 
341  fBGEvents[psi][z][eventCounter].clear();
342 
343  // add the gammas to the vector
344  for(Int_t i = 0; i < eventGammas->GetEntries(); i++){
345  fBGEvents[psi][z][eventCounter].push_back(new AliAODConversionPhoton(*(AliAODConversionPhoton*)(eventGammas->At(i))));
346  }
347 
348  fBGEventCounter[psi][z]++;
349  }
350 }
351 
352 //-------------------------------------------------------------
354  Int_t psibin;
355  Int_t zbin;
356 
357  if(FindBins(eventGammas,fInputEvent,psibin,zbin)){
358  return &(fBGEvents[psibin][zbin][event]);
359  }
360  return NULL;
361 }
362 //-------------------------------------------------------------
364  Int_t psibin;
365  Int_t zbin;
366 
367  if(FindBins(eventGammas,fInputEvent,psibin,zbin)){
368  return &(fBGEvents[psibin][zbin][event]);
369  }
370  return NULL;
371 }
372 
373 //-------------------------------------------------------------
374 Int_t AliConversionAODBGHandlerRP::GetNBGEvents(TObjArray * const eventGammas,AliVEvent *fInputEvent){
375  Int_t psibin;
376  Int_t zbin;
377 
378  if(FindBins(eventGammas,fInputEvent,psibin,zbin)){
379  return fNBGEvents[psibin][zbin];
380  }
381  return 0;
382 }
383 //-------------------------------------------------------------
384 Int_t AliConversionAODBGHandlerRP::GetNBGEvents(TList * const eventGammas,AliVEvent *fInputEvent){
385  Int_t psibin;
386  Int_t zbin;
387 
388  if(FindBins(eventGammas,fInputEvent,psibin,zbin)){
389  return fNBGEvents[psibin][zbin];
390  }
391  return 0;
392 }
393 
Double_t * fBinLimitsArrayZ
bin limits RP array
double Double_t
Definition: External.C:58
AliGammaConversionPhotonVector * GetBGGoodGammas(TObjArray *const eventGammas, AliVEvent *fInputEvent, Int_t event)
Bool_t FindBins(TObjArray *const eventGammas, AliVEvent *fInputEvent, Int_t &psibin, Int_t &zbin)
AliConversionAODBGHandlerRP(Bool_t IsHeavyIon=kFALSE, Bool_t UseChargedTrackMult=kTRUE, Int_t NEvents=10)
Int_t GetRPBinIndex(Double_t psi) const
int Int_t
Definition: External.C:63
Int_t GetMultiplicityBinIndex(Int_t mult) const
unsigned int UInt_t
Definition: External.C:33
Double_t * fBinLimitsArrayMultiplicity
bin limits z array
vector< AliGammaConversionPhotonVector > AliGammaConversionBGEventVector
AliGammaConversionBGVector fBGEvents
bin limit multiplicity array
vector< AliGammaConversionBGEventVector > AliGammaConversionVertexPositionVector
void AddEvent(TObjArray *const eventGammas, AliVEvent *fInputEvent)
bool Bool_t
Definition: External.C:53
vector< AliAODConversionPhoton * > AliGammaConversionPhotonVector