]>
Commit | Line | Data |
---|---|---|
5e55d806 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt * | |
5 | * Version 1.0 * | |
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 | ||
16 | //////////////////////////////////////////////// | |
17 | //--------------------------------------------- | |
18 | // Class for handling of background calculation | |
19 | //--------------------------------------------- | |
20 | //////////////////////////////////////////////// | |
21 | ||
22 | #include "AliGammaConversionBGHandler.h" | |
23 | #include "AliKFParticle.h" | |
24 | #include "AliAnalysisTaskGammaConversion.h" | |
25 | ||
26 | using namespace std; | |
27 | ||
28 | ClassImp(AliGammaConversionBGHandler) | |
29 | ||
30 | AliGammaConversionBGHandler::AliGammaConversionBGHandler() : | |
31 | TObject(), | |
32 | fNEvents(10), | |
33 | fBGEventCounter(NULL), | |
34 | fNBinsZ(0), | |
35 | fNBinsMultiplicity(0), | |
36 | fBinLimitsArrayZ(NULL), | |
37 | fBinLimitsArrayMultiplicity(NULL), | |
38 | fBGEvents() | |
39 | { | |
40 | // constructor | |
41 | } | |
42 | ||
43 | AliGammaConversionBGHandler::AliGammaConversionBGHandler(UInt_t binsZ,UInt_t binsMultiplicity,UInt_t nEvents) : | |
44 | TObject(), | |
45 | fNEvents(nEvents), | |
46 | fBGEventCounter(NULL), | |
47 | fNBinsZ(binsZ), | |
48 | fNBinsMultiplicity(binsMultiplicity), | |
49 | fBinLimitsArrayZ(NULL), | |
50 | fBinLimitsArrayMultiplicity(NULL), | |
51 | fBGEvents(binsZ,AliGammaConversionMultipicityVector(binsMultiplicity,AliGammaConversionBGEventVector(nEvents))) | |
52 | { | |
53 | // constructor | |
54 | } | |
55 | ||
56 | AliGammaConversionBGHandler::AliGammaConversionBGHandler(const AliGammaConversionBGHandler & original) : | |
57 | TObject(original), | |
58 | fNEvents(original.fNEvents), | |
59 | fBGEventCounter(original.fBGEventCounter), | |
60 | fNBinsZ(original.fNBinsZ), | |
61 | fNBinsMultiplicity(original.fNBinsMultiplicity), | |
62 | fBinLimitsArrayZ(original.fBinLimitsArrayZ), | |
63 | fBinLimitsArrayMultiplicity(original.fBinLimitsArrayMultiplicity), | |
64 | fBGEvents(original.fBGEvents) | |
65 | { | |
66 | //copy constructor | |
67 | } | |
68 | ||
69 | AliGammaConversionBGHandler & AliGammaConversionBGHandler::operator = (const AliGammaConversionBGHandler & /*source*/) | |
70 | { | |
71 | // assignment operator | |
72 | return *this; | |
73 | } | |
74 | ||
75 | AliGammaConversionBGHandler::~AliGammaConversionBGHandler(){ | |
76 | ||
77 | //Kenneth remember to clear memory!!!!!!!!!!!!!!!!!!!!! | |
78 | if(fBGEventCounter){ | |
79 | for(Int_t z=0;z<fNBinsZ;z++){ | |
80 | delete[] fBGEventCounter[z]; | |
81 | } | |
82 | delete[] fBGEventCounter; | |
83 | fBGEventCounter = NULL; | |
84 | } | |
85 | ||
86 | if(fBinLimitsArrayZ){ | |
87 | delete[] fBinLimitsArrayZ; | |
88 | } | |
89 | ||
90 | if(fBinLimitsArrayMultiplicity){ | |
91 | delete[] fBinLimitsArrayMultiplicity; | |
92 | } | |
93 | } | |
94 | ||
95 | void AliGammaConversionBGHandler::Initialize(Double_t *zBinLimitsArray, Double_t *multiplicityBinLimitsArray){ | |
96 | // see header file for documantation | |
97 | ||
98 | if(zBinLimitsArray){ | |
99 | fBinLimitsArrayZ = zBinLimitsArray; | |
100 | } | |
101 | else{ | |
102 | //Print warning | |
103 | } | |
104 | ||
105 | if(multiplicityBinLimitsArray){ | |
106 | fBinLimitsArrayMultiplicity = multiplicityBinLimitsArray ; | |
107 | } | |
108 | else{ | |
109 | //Print warning | |
110 | } | |
111 | fBGEventCounter= new Int_t*[fNBinsZ]; | |
112 | for(Int_t z=0;z<fNBinsZ;z++){ | |
113 | fBGEventCounter[z]=new Int_t[fNBinsMultiplicity]; | |
114 | } | |
115 | } | |
116 | ||
117 | Int_t AliGammaConversionBGHandler::GetZBinIndex(Double_t zvalue){ | |
118 | // see header file for documantation | |
119 | if(fNBinsZ<2 || zvalue<=fBinLimitsArrayZ[0]){ | |
120 | return 0; | |
121 | } | |
122 | ||
123 | for(Int_t i=0; i<fNBinsZ-1 ;i++){ | |
124 | if(zvalue >= fBinLimitsArrayZ[i] && zvalue <= fBinLimitsArrayZ[i+1]){ | |
125 | return i; | |
126 | } | |
127 | } | |
128 | return fNBinsZ-1; | |
129 | } | |
130 | ||
131 | Int_t AliGammaConversionBGHandler::GetMultiplicityBinIndex(Int_t multiplicity){ | |
132 | // see header file for documantation | |
133 | if(fNBinsMultiplicity<2){ | |
134 | return 0; | |
135 | } | |
136 | ||
137 | for(Int_t i=0; i<fNBinsMultiplicity-1 ;i++){ | |
138 | if(multiplicity > fBinLimitsArrayMultiplicity[i] && multiplicity < fBinLimitsArrayMultiplicity[i+1]){ | |
139 | return i; | |
140 | } | |
141 | } | |
142 | return fNBinsMultiplicity-1; | |
143 | } | |
144 | ||
145 | void AliGammaConversionBGHandler::AddEvent(TClonesArray * eventGammas, Double_t zvalue, Int_t multiplicity){ | |
146 | // see header file for documantation | |
147 | ||
148 | Int_t z = GetZBinIndex(zvalue); | |
149 | Int_t m = GetMultiplicityBinIndex(multiplicity); | |
150 | ||
151 | if(fBGEventCounter[z][m] >= fNEvents -1){ | |
152 | fBGEventCounter[z][m]=0; | |
153 | } | |
154 | Int_t eventCounter=fBGEventCounter[z][m]; | |
155 | ||
156 | //first clear the vector which is present for any gammas | |
157 | fBGEvents[z][m][eventCounter].fReconstructedGammas.clear(); | |
158 | ||
159 | // add the gammas to the vector | |
160 | for(Int_t i=0; i< eventGammas->GetEntriesFast();i++){ | |
161 | ||
162 | fBGEvents[z][m][eventCounter].fReconstructedGammas.push_back((AliKFParticle*)(eventGammas->At(i))); | |
163 | } | |
164 | ||
165 | //set the z and multiplicity numbers | |
166 | fBGEvents[z][m][eventCounter].fZVertexPosition = zvalue; | |
167 | fBGEvents[z][m][eventCounter].fChargedTrackMultiplicity = multiplicity; | |
168 | } | |
169 | ||
170 | AliGammaConversionKFVector* AliGammaConversionBGHandler::GetBGGoodV0s(Int_t event, Double_t zvalue, Int_t multiplicity){ | |
171 | ||
172 | Int_t z = GetZBinIndex(zvalue); | |
173 | Int_t m = GetMultiplicityBinIndex(multiplicity); | |
174 | ||
175 | return &(fBGEvents[z][m][event].fReconstructedGammas); | |
176 | } |