1 #if !defined( __CINT__) || defined(__MAKECINT__)
6 #include "AliConversionAODBGHandlerRP.h"
11 // Author Daniel Lohner (Daniel.Lohner@cern.ch)
14 ClassImp(AliConversionAODBGHandlerRP)
16 AliConversionAODBGHandlerRP::AliConversionAODBGHandlerRP() :
18 fBGEventCounter(NULL),
23 fBinLimitsArrayZ(NULL),
24 fBinLimitsArrayCentrality(NULL),
25 fBinLimitsArrayRP(NULL),
26 fBGEvents(fNBinsRP,AliGammaConversionVertexPositionVector(fNBinsZ,AliGammaConversionCentralityVector(fNBinsCentrality,AliGammaConversionBGEventVector(fNEvents))))
28 // Default Constructor
31 fBinLimitsArrayCentrality= new Double_t[fNBinsCentrality+1];
33 fBinLimitsArrayCentrality[0] = 0;
34 fBinLimitsArrayCentrality[1] = 5;
35 fBinLimitsArrayCentrality[2] = 10;
36 fBinLimitsArrayCentrality[3] = 20;
37 fBinLimitsArrayCentrality[4] = 40;
38 fBinLimitsArrayCentrality[5] = 60;
39 fBinLimitsArrayCentrality[6] = 90;
43 fBinLimitsArrayZ = new Double_t[fNBinsZ+1];
45 fBinLimitsArrayZ[0] = -10;
46 fBinLimitsArrayZ[1] = -5.4;
47 fBinLimitsArrayZ[2] = -2.8;
48 fBinLimitsArrayZ[3] = -0.6;
49 fBinLimitsArrayZ[4] = 1.4;
50 fBinLimitsArrayZ[5] = 3.5;
51 fBinLimitsArrayZ[6] = 6.1;
52 fBinLimitsArrayZ[7] = 10;
60 AliConversionAODBGHandlerRP::AliConversionAODBGHandlerRP(Int_t NEvents,Int_t NBinsZ,Double_t *BinLimitsZ,Int_t NBinsCentrality,Double_t *BinLimitsCentrality,Int_t NBinsRP) :
62 fBGEventCounter(NULL),
65 fNBinsCentrality(NBinsCentrality),
67 fBinLimitsArrayZ(BinLimitsZ),
68 fBinLimitsArrayCentrality(BinLimitsCentrality),
69 fBinLimitsArrayRP(NULL),
70 fBGEvents(fNBinsRP,AliGammaConversionVertexPositionVector(fNBinsZ,AliGammaConversionCentralityVector(fNBinsCentrality,AliGammaConversionBGEventVector(fNEvents))))
76 AliConversionAODBGHandlerRP::~AliConversionAODBGHandlerRP()
79 delete[] fBinLimitsArrayZ;
80 fBinLimitsArrayZ=0x0;}
81 if(fBinLimitsArrayCentrality){
82 delete[] fBinLimitsArrayCentrality;
83 fBinLimitsArrayCentrality=0x0;}
84 if(fBinLimitsArrayRP){
85 delete[] fBinLimitsArrayRP;
86 fBinLimitsArrayRP=0x0;}
90 for(Int_t psi=0;psi<fNBinsRP;psi++){
91 for(Int_t z=0;z<fNBinsZ;z++){
92 delete[] fBGEventCounter[psi][z];
94 delete[] fBGEventCounter[psi];
96 delete[] fBGEventCounter;
97 fBGEventCounter = NULL;
102 for(Int_t psi=0;psi<fNBinsRP;psi++){
103 for(Int_t z=0;z<fNBinsZ;z++){
104 for(Int_t m=0;m<fNBinsCentrality;m++){
105 for(Int_t eventCounter=0;eventCounter<fNBGEvents[psi][z][m]&&eventCounter<fNEvents;eventCounter++){
107 for(UInt_t d=0;d<fBGEvents[psi][z][m][eventCounter].size();d++){
108 delete (AliAODConversionPhoton*)(fBGEvents[psi][z][m][eventCounter][d]);
116 for(Int_t psi=0;psi<fNBinsRP;psi++){
117 for(Int_t z=0;z<fNBinsZ;z++){
118 delete[] fNBGEvents[psi][z];
120 delete[] fNBGEvents[psi];
130 void AliConversionAODBGHandlerRP::Initialize(){
134 fBinLimitsArrayRP=new Double_t[fNBinsRP+1];
136 for(Int_t i=0;i<fNBinsRP+1;i++){
137 fBinLimitsArrayRP[i] = i*TMath::Pi()/fNBinsRP;
142 if(fBGEventCounter == NULL){
143 fBGEventCounter= new Int_t**[fNBinsRP];
145 for(Int_t psi=0;psi<fNBinsRP;psi++){
146 fBGEventCounter[psi]= new Int_t*[fNBinsZ];
148 for(Int_t z=0;z<fNBinsZ;z++){
149 fBGEventCounter[psi][z]=new Int_t[fNBinsCentrality];
152 for(Int_t psi=0;psi<fNBinsRP;psi++){
153 for(Int_t z=0;z<fNBinsZ;z++){
154 for(Int_t m=0;m<fNBinsCentrality;m++){
155 fBGEventCounter[psi][z][m]=0;
161 if(fNBGEvents == NULL){
162 fNBGEvents= new Int_t**[fNBinsRP];
164 for(Int_t psi=0;psi<fNBinsRP;psi++){
165 fNBGEvents[psi]= new Int_t*[fNBinsZ];
167 for(Int_t z=0;z<fNBinsZ;z++){
168 fNBGEvents[psi][z]=new Int_t[fNBinsCentrality];
171 for(Int_t psi=0;psi<fNBinsRP;psi++){
172 for(Int_t z=0;z<fNBinsZ;z++){
173 for(Int_t m=0;m<fNBinsCentrality;m++){
174 fNBGEvents[psi][z][m]=0;
181 //-------------------------------------------------------------
183 Int_t AliConversionAODBGHandlerRP::GetZBinIndex(Double_t zvalue) const{
184 // see header file for documantation
185 if(fNBinsZ<2 || zvalue<=fBinLimitsArrayZ[0]){
189 for(Int_t i=0; i<fNBinsZ ;i++){
190 if(zvalue >= fBinLimitsArrayZ[i] && zvalue <= fBinLimitsArrayZ[i+1]){
196 //-------------------------------------------------------------
197 Int_t AliConversionAODBGHandlerRP::GetCentralityBinIndex(Int_t multiplicity) const{
198 if(fNBinsCentrality<2){
202 for(Int_t i=0; i<fNBinsCentrality ;i++){
203 if(multiplicity >= fBinLimitsArrayCentrality[i] && multiplicity < fBinLimitsArrayCentrality[i+1]){
210 //-------------------------------------------------------------
212 Int_t AliConversionAODBGHandlerRP::GetRPBinIndex(Double_t psivalue) const{
214 if(fNBinsRP<2 || psivalue<=fBinLimitsArrayRP[0]){
218 for(Int_t i=0; i<fNBinsRP ;i++){
219 if(psivalue >= fBinLimitsArrayRP[i] && psivalue <= fBinLimitsArrayRP[i+1]){
227 //-------------------------------------------------------------
228 void AliConversionAODBGHandlerRP::AddEvent(TClonesArray * const eventGammas,Double_t psivalue,Double_t zvalue, Int_t multiplicity){
231 Int_t z = GetZBinIndex(zvalue);
232 Int_t m = GetCentralityBinIndex(multiplicity);
233 Int_t psi=GetRPBinIndex(psivalue);
235 // If Event Stack is full, replace the first entry (First in first out)
236 if(fBGEventCounter[psi][z][m] >= fNEvents){
237 fBGEventCounter[psi][z][m]=0;
240 // Update number of Events stored
241 if(fNBGEvents[psi][z][m] < fNEvents){
242 fNBGEvents[psi][z][m]++;
246 Int_t eventCounter=fBGEventCounter[psi][z][m];
248 //clear the vector for old gammas
249 for(UInt_t d=0;d<fBGEvents[psi][z][m][eventCounter].size();d++){
250 delete (AliAODConversionPhoton*)(fBGEvents[psi][z][m][eventCounter][d]);
253 fBGEvents[psi][z][m][eventCounter].clear();
256 // add the gammas to the vector
258 for(Int_t i=0; i< eventGammas->GetEntriesFast();i++){
259 fBGEvents[psi][z][m][eventCounter].push_back(new AliAODConversionPhoton(*(AliAODConversionPhoton*)(eventGammas->At(i))));
262 fBGEventCounter[psi][z][m]++;
267 //-------------------------------------------------------------
268 AliGammaConversionPhotonVector* AliConversionAODBGHandlerRP::GetBGGoodGammas(Int_t psi,Int_t zbin, Int_t mbin, Int_t event){
269 //see headerfile for documentation
270 return &(fBGEvents[psi][zbin][mbin][event]);