]>
Commit | Line | Data |
---|---|---|
5e2cf960 | 1 | /************************************************************************* |
2 | * Copyright(c) 1998-2009, 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 | ||
16 | /////////////////////////////////////////////////////////////////////////// | |
17 | // Dielectron HF // | |
18 | // // | |
19 | // // | |
20 | /* | |
21 | Detailed description | |
22 | ||
23 | ||
24 | */ | |
25 | // // | |
26 | /////////////////////////////////////////////////////////////////////////// | |
27 | ||
28 | #include <TVectorD.h> | |
29 | #include <TH1.h> | |
30 | #include <TAxis.h> | |
31 | ||
32 | #include <AliLog.h> | |
33 | ||
34 | #include "AliDielectron.h" | |
35 | #include "AliDielectronHelper.h" | |
36 | ||
37 | #include "AliDielectronHF.h" | |
38 | ||
39 | ClassImp(AliDielectronHF) | |
40 | ||
41 | AliDielectronHF::AliDielectronHF() : | |
42 | TNamed(), | |
43 | fArrPairType(0x0), | |
44 | fPairType(kOSonly), | |
45 | fAxes(kMaxCuts), | |
46 | fVarBinLimits(0x0), | |
47 | fVar(0) | |
48 | { | |
49 | // | |
50 | // Default Constructor | |
51 | // | |
52 | for (Int_t i=0; i<kMaxCuts; ++i){ | |
53 | fVarCuts[i]=0; | |
54 | fVarCutType[i]=0; | |
55 | fBinType[i]=kStdBin; | |
56 | } | |
57 | fAxes.SetOwner(kTRUE); | |
58 | } | |
59 | ||
60 | //______________________________________________ | |
61 | AliDielectronHF::AliDielectronHF(const char* name, const char* title) : | |
62 | TNamed(name, title), | |
63 | fArrPairType(0x0), | |
64 | fPairType(kOSonly), | |
65 | fAxes(kMaxCuts), | |
66 | fVarBinLimits(0x0), | |
67 | fVar(0) | |
68 | { | |
69 | // | |
70 | // Named Constructor | |
71 | // | |
72 | for (Int_t i=0; i<kMaxCuts; ++i){ | |
73 | fVarCuts[i]=0; | |
74 | fVarCutType[i]=0; | |
75 | fBinType[i]=kStdBin; | |
76 | } | |
77 | fAxes.SetOwner(kTRUE); | |
78 | } | |
79 | ||
80 | //______________________________________________ | |
81 | AliDielectronHF::~AliDielectronHF() | |
82 | { | |
83 | // | |
84 | // Default Destructor | |
85 | // | |
86 | fAxes.Delete(); | |
87 | } | |
88 | ||
89 | //________________________________________________________________ | |
90 | void AliDielectronHF::SetVariable(AliDielectronVarManager::ValueTypes type, | |
91 | Int_t nbins, Double_t min, Double_t max, Bool_t log) | |
92 | { | |
93 | // | |
94 | // Set main variable for the histos | |
95 | // | |
96 | ||
97 | fVarBinLimits=0x0; | |
98 | if (!log) fVarBinLimits=AliDielectronHelper::MakeLinBinning(nbins,min,max); | |
99 | else fVarBinLimits=AliDielectronHelper::MakeLogBinning(nbins,min,max); | |
100 | if (!fVarBinLimits) return ; | |
101 | ||
102 | fVar=(UShort_t)type; | |
103 | ||
104 | } | |
105 | ||
106 | //________________________________________________________________ | |
107 | void AliDielectronHF::AddCutVariable(AliDielectronVarManager::ValueTypes type, | |
108 | Int_t nbins, Double_t min, Double_t max, Bool_t log, Bool_t leg, EBinType btype) | |
109 | { | |
110 | // | |
111 | // Add a variable to the mixing handler | |
112 | // | |
113 | ||
114 | // limit number of variables to kMaxCuts | |
115 | if (fAxes.GetEntriesFast()>=kMaxCuts) return; | |
116 | ||
117 | TVectorD *binLimits=0x0; | |
118 | if (!log) binLimits=AliDielectronHelper::MakeLinBinning(nbins,min,max); | |
119 | else binLimits=AliDielectronHelper::MakeLogBinning(nbins,min,max); | |
120 | if (!binLimits) return; | |
121 | ||
122 | Int_t size=fAxes.GetEntriesFast(); | |
123 | fVarCuts[size]=(UShort_t)type; | |
124 | fVarCutType[size]=leg; | |
125 | fAxes.Add(binLimits->Clone()); | |
126 | fBinType[size]=btype; | |
127 | } | |
128 | ||
129 | //________________________________________________________________ | |
130 | void AliDielectronHF::AddCutVariable(AliDielectronVarManager::ValueTypes type, | |
131 | const char* binLimitStr, Bool_t leg, EBinType btype) | |
132 | { | |
133 | // | |
134 | // Add a variable to the mixing handler with arbitrary binning | |
135 | // | |
136 | ||
137 | // limit number of variables to kMaxCuts | |
138 | if (fAxes.GetEntriesFast()>=kMaxCuts) return; | |
139 | ||
140 | TVectorD *binLimits=AliDielectronHelper::MakeArbitraryBinning(binLimitStr); | |
141 | if (!binLimits) return; | |
142 | ||
143 | Int_t size=fAxes.GetEntriesFast(); | |
144 | fVarCuts[size]=(UShort_t)type; | |
145 | fVarCutType[size]=leg; | |
146 | fAxes.Add(binLimits); | |
147 | fBinType[size]=btype; | |
148 | } | |
149 | ||
150 | //________________________________________________________________ | |
151 | void AliDielectronHF::AddCutVariable(AliDielectronVarManager::ValueTypes type, | |
152 | TVectorD * binLimits, Bool_t leg, EBinType btype) | |
153 | { | |
154 | // | |
155 | // Add a variable to the mixing handler with a vector | |
156 | // the TVectorD is assumed to be surplus after the creation and will be deleted!!! | |
157 | // | |
158 | ||
159 | // limit number of variables to kMaxCuts | |
160 | if (fAxes.GetEntriesFast()>=kMaxCuts) return; | |
161 | ||
162 | if (!binLimits) return; | |
163 | ||
164 | Int_t size=fAxes.GetEntriesFast(); | |
165 | fVarCuts[size]=(UShort_t)type; | |
166 | fVarCutType[size]=leg; | |
167 | fAxes.Add(binLimits); | |
168 | fBinType[size]=btype; | |
169 | } | |
170 | ||
171 | //______________________________________________ | |
172 | void AliDielectronHF::Fill(Int_t pairIndex, const AliDielectronPair *particle) | |
173 | { | |
174 | // | |
175 | // fill histograms for event, pair and daughter cuts and pair types | |
176 | // | |
177 | ||
178 | // only selected pair types | |
179 | if(!IsPairTypeSelected(pairIndex)) return; | |
180 | ||
181 | TObjArray *histArr = static_cast<TObjArray*>(fArrPairType.At(pairIndex)); | |
182 | if(!histArr) return; | |
183 | ||
184 | Int_t size = GetNumberOfBins(); | |
185 | ||
186 | ||
187 | // get event and pair variables | |
188 | Double_t valuesPair[AliDielectronVarManager::kNMaxValues]; | |
189 | AliDielectronVarManager::Fill(particle,valuesPair); | |
190 | ||
191 | // get leg variables | |
192 | Double_t valuesLeg1[AliDielectronVarManager::kNMaxValues]={0}; | |
193 | AliDielectronVarManager::Fill(particle->GetFirstDaughter(),valuesLeg1); | |
194 | Double_t valuesLeg2[AliDielectronVarManager::kNMaxValues]={0}; | |
195 | AliDielectronVarManager::Fill(particle->GetSecondDaughter(),valuesLeg2); | |
196 | ||
197 | // loop over all histograms | |
198 | for(Int_t ihist=0; ihist<size; ihist++) { | |
199 | ||
200 | Int_t sizeAdd = 1; | |
201 | Bool_t selected = kTRUE; | |
202 | ||
203 | // loop over all cut variables | |
204 | Int_t nvars = fAxes.GetEntriesFast(); | |
205 | for(Int_t ivar=0; ivar<nvars; ivar++) { | |
206 | ||
207 | // get bin limits | |
208 | TVectorD *bins = static_cast<TVectorD*>(fAxes.At(ivar)); | |
209 | Int_t nbins = bins->GetNrows()-1; | |
210 | ||
211 | // bin limits for current ivar bin | |
212 | Int_t ibin = (ihist/sizeAdd)%nbins; | |
213 | Double_t lowEdge = (*bins)[ibin]; | |
214 | Double_t upEdge = (*bins)[ibin+1]; | |
215 | switch(fBinType[ivar]) { | |
216 | case kStdBin: upEdge=(*bins)[ibin+1]; break; | |
217 | case kBinToMax: upEdge=(*bins)[nbins]; break; | |
218 | case kBinFromMin: lowEdge=(*bins)[0]; break; | |
219 | case kSymBin: upEdge=(*bins)[nbins-ibin]; | |
220 | if(ibin>=((Double_t)(nbins+1))/2) upEdge=(*bins)[nbins]; // to avoid low>up | |
221 | break; | |
222 | } | |
223 | ||
224 | // leg variable | |
225 | if(fVarCutType) { | |
226 | if( (valuesLeg1[fVarCuts[ivar]] < lowEdge || valuesLeg1[fVarCuts[ivar]] >= upEdge) || | |
227 | (valuesLeg2[fVarCuts[ivar]] < lowEdge || valuesLeg2[fVarCuts[ivar]] >= upEdge) ) { | |
228 | selected=kFALSE; | |
229 | break; | |
230 | } | |
231 | } | |
232 | else { // pair and event variables | |
233 | if( (valuesPair[fVarCuts[ivar]] < lowEdge || valuesPair[fVarCuts[ivar]] >= upEdge) ) { | |
234 | selected=kFALSE; | |
235 | break; | |
236 | } | |
237 | } | |
238 | ||
239 | sizeAdd*=nbins; | |
240 | } //end of var cut loop | |
241 | ||
242 | // do not fill the histogram | |
243 | if(!selected) continue; | |
244 | ||
245 | // fill the histogram | |
246 | TH1F *tmp=static_cast<TH1F*>(histArr->At(ihist)); | |
247 | TString title = tmp->GetTitle(); | |
248 | AliDebug(10,title.Data()); | |
249 | ||
250 | tmp->Fill(valuesPair[fVar]); | |
251 | ||
252 | } //end of hist loop | |
253 | ||
254 | } | |
255 | ||
256 | //______________________________________________ | |
257 | void AliDielectronHF::Init() | |
258 | { | |
259 | // | |
260 | // initialise event buffers | |
261 | // | |
262 | ||
263 | // init pair type array | |
264 | fArrPairType.SetName(Form("%s_HF",GetName())); | |
265 | fArrPairType.Expand(AliDielectron::kEv1PMRot+1); | |
266 | ||
267 | TH1F *hist = 0x0; | |
268 | Int_t size = GetNumberOfBins(); | |
269 | AliDebug(10,Form("Creating a histo array with size %d \n",size)); | |
270 | ||
271 | Int_t sizeAdd = 1; | |
272 | ||
273 | // fill object array with the histograms | |
274 | TObjArray *histArr = new TObjArray(); | |
275 | histArr->Expand(size); | |
276 | ||
277 | for(Int_t ihist=0; ihist<size; ihist++) { | |
278 | hist=new TH1F(Form("histarr%04d",ihist),"",fVarBinLimits->GetNrows()-1,fVarBinLimits->GetMatrixArray()); | |
279 | hist->SetXTitle(Form("%s",AliDielectronVarManager::GetValueName(fVar))); | |
280 | hist->SetYTitle("#pairs"); | |
281 | histArr->AddAt(hist,ihist); | |
282 | } | |
283 | ||
284 | // loop over all cut variables | |
285 | Int_t nvars = fAxes.GetEntriesFast(); | |
286 | for(Int_t ivar=0; ivar<nvars; ivar++) { | |
287 | ||
288 | // get bin limits | |
289 | TVectorD *bins = static_cast<TVectorD*>(fAxes.At(ivar)); | |
290 | Int_t nbins = bins->GetNrows()-1; | |
291 | ||
292 | ||
293 | // loop over all histograms an set unique titles | |
294 | for(Int_t ihist=0; ihist<size; ihist++) { | |
295 | ||
296 | // get the lower limit for current ivar bin | |
297 | Int_t ibin = (ihist/sizeAdd)%nbins; | |
298 | Double_t lowEdge = (*bins)[ibin]; | |
299 | Double_t upEdge = (*bins)[ibin+1]; | |
300 | switch(fBinType[ivar]) { | |
301 | case kStdBin: upEdge=(*bins)[ibin+1]; break; | |
302 | case kBinToMax: upEdge=(*bins)[nbins]; break; | |
303 | case kBinFromMin: lowEdge=(*bins)[0]; break; | |
304 | case kSymBin: upEdge=(*bins)[nbins-ibin]; | |
305 | if(ibin>=((Double_t)(nbins+1))/2) upEdge=(*bins)[nbins]; // to avoid low>up | |
306 | break; | |
307 | } | |
308 | ||
309 | TH1F *tmp=static_cast<TH1F*>(histArr->At(ihist)); | |
310 | TString title = tmp->GetTitle(); | |
311 | if(ivar!=0) title+=":"; | |
312 | if(fVarCutType[ivar]) title+="Leg"; | |
313 | title+=AliDielectronVarManager::GetValueName(fVarCuts[ivar]); | |
314 | title+=Form("#%.2f#%.2f",lowEdge,upEdge); | |
315 | tmp->SetNameTitle(title.Data(),title.Data()); | |
316 | AliDebug(10,title.Data()); | |
317 | } | |
318 | sizeAdd*=nbins; | |
319 | } | |
320 | ||
321 | // copy array to the selected pair types | |
322 | for(Int_t i=0; i<AliDielectron::kEv1PMRot+1; i++) { | |
323 | if(IsPairTypeSelected(i)) fArrPairType[i]=(TObjArray*)histArr->Clone(Form("%s",AliDielectron::PairClassName(i))); | |
324 | else fArrPairType[i]=0x0; | |
325 | } | |
326 | ||
327 | // clean up | |
328 | if(histArr) { | |
329 | delete histArr; | |
330 | histArr=0; | |
331 | } | |
332 | ||
333 | } | |
334 | ||
335 | //______________________________________________ | |
336 | Int_t AliDielectronHF::GetNumberOfBins() const | |
337 | { | |
338 | // | |
339 | // return the number of bins this mixing handler has | |
340 | // | |
341 | Int_t size=1; | |
342 | for (Int_t i=0; i<fAxes.GetEntriesFast(); ++i) | |
343 | size*=((static_cast<TVectorD*>(fAxes.At(i)))->GetNrows()-1); | |
344 | return size; | |
345 | } | |
346 | ||
347 | //______________________________________________ | |
348 | Bool_t AliDielectronHF::IsPairTypeSelected(Int_t itype) | |
349 | { | |
350 | // | |
351 | // check whether a pair type was selected | |
352 | // | |
353 | ||
354 | Bool_t selected = kFALSE; | |
355 | ||
356 | // fill all | |
357 | if(fPairType==kAll) selected = kTRUE; | |
358 | ||
359 | switch(itype) { | |
360 | case AliDielectron::kEv1PP: | |
361 | case AliDielectron::kEv1MM: | |
362 | if(fPairType==kOSandLS) selected = kTRUE; | |
363 | break; | |
364 | case AliDielectron::kEv1PM: selected = kTRUE; | |
365 | break; | |
366 | case AliDielectron::kEv1PEv2P: | |
367 | case AliDielectron::kEv1MEv2P: | |
368 | case AliDielectron::kEv1PEv2M: | |
369 | case AliDielectron::kEv1MEv2M: | |
370 | if(fPairType==kOSandMIX) selected = kTRUE; | |
371 | break; | |
372 | case AliDielectron::kEv2PP: | |
373 | case AliDielectron::kEv2PM: | |
374 | case AliDielectron::kEv2MM: | |
375 | selected = kFALSE; | |
376 | break; | |
377 | case AliDielectron::kEv1PMRot: | |
378 | if(fPairType==kOSandROT) selected = kTRUE; | |
379 | break; | |
380 | } | |
381 | ||
382 | return selected; | |
383 | ||
384 | } | |
385 | ||
386 |