]>
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> | |
d07ad639 | 30 | #include <TH1F.h> |
31 | #include <TH2.h> | |
32 | #include <TH3.h> | |
33 | #include <TProfile.h> | |
34 | #include <TProfile2D.h> | |
35 | #include <TProfile3D.h> | |
5e2cf960 | 36 | #include <TAxis.h> |
d07ad639 | 37 | #include <TString.h> |
38 | #include <TObjString.h> | |
39 | #include <TObjArray.h> | |
afa9303d | 40 | |
d07ad639 | 41 | #include <AliVParticle.h> |
5e2cf960 | 42 | #include <AliLog.h> |
43 | ||
44 | #include "AliDielectron.h" | |
45 | #include "AliDielectronHelper.h" | |
443a091c | 46 | #include "AliDielectronMC.h" |
47 | #include "AliDielectronPair.h" | |
48 | #include "AliDielectronSignalMC.h" | |
5e2cf960 | 49 | |
35363fb9 | 50 | #include "AliDielectronHistos.h" |
5e2cf960 | 51 | #include "AliDielectronHF.h" |
52 | ||
53 | ClassImp(AliDielectronHF) | |
54 | ||
55 | AliDielectronHF::AliDielectronHF() : | |
56 | TNamed(), | |
57 | fArrPairType(0x0), | |
58 | fPairType(kOSonly), | |
443a091c | 59 | fSignalsMC(0x0), |
5e2cf960 | 60 | fAxes(kMaxCuts), |
4d7704c5 | 61 | fHasMC(kFALSE), |
35363fb9 | 62 | fStepGenerated(kFALSE), |
d07ad639 | 63 | fRefObj(1) |
5e2cf960 | 64 | { |
65 | // | |
66 | // Default Constructor | |
67 | // | |
68 | for (Int_t i=0; i<kMaxCuts; ++i){ | |
69 | fVarCuts[i]=0; | |
70 | fVarCutType[i]=0; | |
71 | fBinType[i]=kStdBin; | |
72 | } | |
73 | fAxes.SetOwner(kTRUE); | |
d07ad639 | 74 | fRefObj.SetOwner(kTRUE); |
5e2cf960 | 75 | } |
76 | ||
77 | //______________________________________________ | |
78 | AliDielectronHF::AliDielectronHF(const char* name, const char* title) : | |
79 | TNamed(name, title), | |
80 | fArrPairType(0x0), | |
81 | fPairType(kOSonly), | |
443a091c | 82 | fSignalsMC(0x0), |
5e2cf960 | 83 | fAxes(kMaxCuts), |
4d7704c5 | 84 | fHasMC(kFALSE), |
35363fb9 | 85 | fStepGenerated(kFALSE), |
d07ad639 | 86 | fRefObj(1) |
5e2cf960 | 87 | { |
88 | // | |
89 | // Named Constructor | |
90 | // | |
91 | for (Int_t i=0; i<kMaxCuts; ++i){ | |
92 | fVarCuts[i]=0; | |
93 | fVarCutType[i]=0; | |
94 | fBinType[i]=kStdBin; | |
95 | } | |
96 | fAxes.SetOwner(kTRUE); | |
d07ad639 | 97 | fRefObj.SetOwner(kTRUE); |
5e2cf960 | 98 | } |
99 | ||
100 | //______________________________________________ | |
101 | AliDielectronHF::~AliDielectronHF() | |
102 | { | |
103 | // | |
104 | // Default Destructor | |
105 | // | |
106 | fAxes.Delete(); | |
107 | } | |
108 | ||
d07ad639 | 109 | //_____________________________________________________________________________ |
110 | void AliDielectronHF::UserProfile(const char* histClass, UInt_t valTypeP, | |
111 | const TVectorD * const binsX, | |
112 | UInt_t valTypeX, TString option) | |
5e2cf960 | 113 | { |
114 | // | |
d07ad639 | 115 | // Histogram creation 1D case with arbitraty binning X |
116 | // the TVectorD is assumed to be surplus after the creation and will be deleted!!! | |
5e2cf960 | 117 | // |
7afc8a0c | 118 | |
d07ad639 | 119 | TH1 *hist=0x0; |
120 | if(valTypeP==999) | |
121 | hist=new TH1F("","",binsX->GetNrows()-1,binsX->GetMatrixArray()); | |
122 | else { | |
123 | TString opt=""; Double_t pmin=0., pmax=0.; | |
124 | if(!option.IsNull()) { | |
125 | TObjArray *arr=option.Tokenize(";"); | |
126 | arr->SetOwner(); | |
127 | opt=((TObjString*)arr->At(0))->GetString(); | |
128 | if(arr->GetEntriesFast()>1) pmin=(((TObjString*)arr->At(1))->GetString()).Atof(); | |
129 | if(arr->GetEntriesFast()>2) pmax=(((TObjString*)arr->At(2))->GetString()).Atof(); | |
130 | delete arr; | |
131 | } | |
132 | hist=new TProfile("","",binsX->GetNrows()-1,binsX->GetMatrixArray()); | |
133 | ((TProfile*)hist)->BuildOptions(pmin,pmax,opt.Data()); | |
134 | // printf(" name %s PROFILE options: pmin %.1f pmax %.1f err %s \n",name,((TProfile*)hist)->GetYmin(),((TProfile*)hist)->GetYmax(),((TProfile*)hist)->GetErrorOption() ); | |
135 | } | |
136 | ||
137 | // store variales in axes | |
138 | UInt_t valType[4] = {0}; | |
139 | valType[0]=valTypeX; valType[1]=valTypeP; | |
140 | AliDielectronHistos::StoreVariables(hist, valType); | |
5e2cf960 | 141 | |
d07ad639 | 142 | // adapt the name and title of the histogram in case they are empty |
143 | AliDielectronHistos::AdaptNameTitle(hist, histClass); | |
144 | hist->SetName(Form("HF_%s",hist->GetName())); | |
145 | ||
146 | fRefObj.AddLast(hist); | |
147 | delete binsX; | |
148 | } | |
149 | ||
150 | //_____________________________________________________________________________ | |
151 | void AliDielectronHF::UserProfile(const char* histClass, UInt_t valTypeP, | |
152 | const TVectorD * const binsX, const TVectorD * const binsY, | |
153 | UInt_t valTypeX, UInt_t valTypeY, TString option) | |
154 | { | |
155 | // | |
156 | // Histogram creation 2D case with arbitraty binning X and Y | |
157 | // the TVectorD is assumed to be surplus after the creation and will be deleted!!! | |
158 | // | |
159 | ||
160 | TH1 *hist=0x0; | |
161 | if(valTypeP==999) { | |
162 | hist=new TH2F("","", | |
163 | binsX->GetNrows()-1,binsX->GetMatrixArray(), | |
164 | binsY->GetNrows()-1,binsY->GetMatrixArray()); | |
165 | } | |
166 | else { | |
167 | TString opt=""; Double_t pmin=0., pmax=0.; | |
168 | if(!option.IsNull()) { | |
169 | TObjArray *arr=option.Tokenize(";"); | |
170 | arr->SetOwner(); | |
171 | opt=((TObjString*)arr->At(0))->GetString(); | |
172 | if(arr->GetEntriesFast()>1) pmin=(((TObjString*)arr->At(1))->GetString()).Atof(); | |
173 | if(arr->GetEntriesFast()>2) pmax=(((TObjString*)arr->At(2))->GetString()).Atof(); | |
174 | delete arr; | |
175 | } | |
176 | hist=new TProfile2D("","", | |
177 | binsX->GetNrows()-1,binsX->GetMatrixArray(), | |
178 | binsY->GetNrows()-1,binsY->GetMatrixArray()); | |
179 | ((TProfile2D*)hist)->BuildOptions(pmin,pmax,opt.Data()); | |
180 | } | |
181 | ||
182 | // store variales in axes | |
183 | UInt_t valType[4] = {0}; | |
184 | valType[0]=valTypeX; valType[1]=valTypeY; valType[3]=valTypeP; | |
185 | AliDielectronHistos::StoreVariables(hist, valType); | |
186 | ||
187 | // adapt the name and title of the histogram in case they are empty | |
188 | AliDielectronHistos::AdaptNameTitle(hist, histClass); | |
189 | hist->SetName(Form("HF_%s",hist->GetName())); | |
190 | ||
191 | fRefObj.AddLast(hist); | |
192 | delete binsX; | |
193 | delete binsY; | |
194 | } | |
195 | ||
196 | //_____________________________________________________________________________ | |
197 | void AliDielectronHF::UserProfile(const char* histClass, UInt_t valTypeP, | |
198 | const TVectorD * const binsX, const TVectorD * const binsY, const TVectorD * const binsZ, | |
199 | UInt_t valTypeX, UInt_t valTypeY, UInt_t valTypeZ, TString option) | |
200 | { | |
201 | // | |
202 | // Histogram creation 3D case with arbitraty binning X, Y, Z | |
203 | // the TVectorD is assumed to be surplus after the creation and will be deleted!!! | |
204 | // | |
205 | TH1 *hist=0x0; | |
206 | if(valTypeP==999) { | |
207 | hist=new TH3F("","", | |
208 | binsX->GetNrows()-1,binsX->GetMatrixArray(), | |
209 | binsY->GetNrows()-1,binsY->GetMatrixArray(), | |
210 | binsZ->GetNrows()-1,binsZ->GetMatrixArray()); | |
211 | } | |
212 | else { | |
213 | TString opt=""; Double_t pmin=0., pmax=0.; | |
214 | if(!option.IsNull()) { | |
215 | TObjArray *arr=option.Tokenize(";"); | |
216 | arr->SetOwner(); | |
217 | opt=((TObjString*)arr->At(0))->GetString(); | |
218 | if(arr->GetEntriesFast()>1) pmin=(((TObjString*)arr->At(1))->GetString()).Atof(); | |
219 | if(arr->GetEntriesFast()>2) pmax=(((TObjString*)arr->At(2))->GetString()).Atof(); | |
220 | delete arr; | |
221 | } | |
222 | hist=new TProfile3D("","", | |
223 | binsX->GetNrows()-1,binsX->GetMatrixArray(), | |
224 | binsY->GetNrows()-1,binsY->GetMatrixArray(), | |
225 | binsZ->GetNrows()-1,binsZ->GetMatrixArray()); | |
226 | ((TProfile3D*)hist)->BuildOptions(pmin,pmax,opt.Data()); | |
227 | } | |
228 | ||
229 | // store variales in axes | |
230 | UInt_t valType[4] = {0}; | |
231 | valType[0]=valTypeX; valType[1]=valTypeY; valType[2]=valTypeZ; valType[3]=valTypeP; | |
232 | AliDielectronHistos::StoreVariables(hist, valType); | |
233 | ||
234 | // adapt the name and title of the histogram in case they are empty | |
235 | AliDielectronHistos::AdaptNameTitle(hist, histClass); | |
236 | hist->SetName(Form("HF_%s",hist->GetName())); | |
237 | ||
238 | fRefObj.AddLast(hist); | |
239 | delete binsX; | |
240 | delete binsY; | |
241 | delete binsZ; | |
5e2cf960 | 242 | } |
243 | ||
244 | //________________________________________________________________ | |
245 | void AliDielectronHF::AddCutVariable(AliDielectronVarManager::ValueTypes type, | |
d07ad639 | 246 | Int_t nbins, Double_t min, Double_t max, Bool_t log, Bool_t leg, EBinType btype) |
5e2cf960 | 247 | { |
248 | // | |
249 | // Add a variable to the mixing handler | |
250 | // | |
251 | ||
252 | // limit number of variables to kMaxCuts | |
253 | if (fAxes.GetEntriesFast()>=kMaxCuts) return; | |
254 | ||
255 | TVectorD *binLimits=0x0; | |
256 | if (!log) binLimits=AliDielectronHelper::MakeLinBinning(nbins,min,max); | |
257 | else binLimits=AliDielectronHelper::MakeLogBinning(nbins,min,max); | |
258 | if (!binLimits) return; | |
259 | ||
260 | Int_t size=fAxes.GetEntriesFast(); | |
261 | fVarCuts[size]=(UShort_t)type; | |
262 | fVarCutType[size]=leg; | |
263 | fAxes.Add(binLimits->Clone()); | |
264 | fBinType[size]=btype; | |
265 | } | |
266 | ||
267 | //________________________________________________________________ | |
268 | void AliDielectronHF::AddCutVariable(AliDielectronVarManager::ValueTypes type, | |
269 | const char* binLimitStr, Bool_t leg, EBinType btype) | |
270 | { | |
271 | // | |
272 | // Add a variable to the mixing handler with arbitrary binning | |
273 | // | |
274 | ||
275 | // limit number of variables to kMaxCuts | |
276 | if (fAxes.GetEntriesFast()>=kMaxCuts) return; | |
277 | ||
278 | TVectorD *binLimits=AliDielectronHelper::MakeArbitraryBinning(binLimitStr); | |
279 | if (!binLimits) return; | |
280 | ||
281 | Int_t size=fAxes.GetEntriesFast(); | |
282 | fVarCuts[size]=(UShort_t)type; | |
283 | fVarCutType[size]=leg; | |
284 | fAxes.Add(binLimits); | |
285 | fBinType[size]=btype; | |
286 | } | |
287 | ||
288 | //________________________________________________________________ | |
289 | void AliDielectronHF::AddCutVariable(AliDielectronVarManager::ValueTypes type, | |
290 | TVectorD * binLimits, Bool_t leg, EBinType btype) | |
291 | { | |
292 | // | |
293 | // Add a variable to the mixing handler with a vector | |
294 | // the TVectorD is assumed to be surplus after the creation and will be deleted!!! | |
295 | // | |
296 | ||
297 | // limit number of variables to kMaxCuts | |
298 | if (fAxes.GetEntriesFast()>=kMaxCuts) return; | |
299 | ||
300 | if (!binLimits) return; | |
301 | ||
302 | Int_t size=fAxes.GetEntriesFast(); | |
303 | fVarCuts[size]=(UShort_t)type; | |
304 | fVarCutType[size]=leg; | |
305 | fAxes.Add(binLimits); | |
306 | fBinType[size]=btype; | |
307 | } | |
308 | ||
309 | //______________________________________________ | |
443a091c | 310 | void AliDielectronHF::Fill(Int_t label1, Int_t label2, Int_t nSignal) |
5e2cf960 | 311 | { |
312 | // | |
443a091c | 313 | // fill the pure MC part of the container starting from a pair of 2 particles (part1 and part2 are legs) |
5e2cf960 | 314 | // |
4d7704c5 | 315 | // fill only if we have asked for these steps |
316 | if(!fStepGenerated) return; | |
5e2cf960 | 317 | |
443a091c | 318 | AliVParticle* part1 = AliDielectronMC::Instance()->GetMCTrackFromMCEvent(label1); |
319 | AliVParticle* part2 = AliDielectronMC::Instance()->GetMCTrackFromMCEvent(label2); | |
5e2cf960 | 320 | |
443a091c | 321 | AliDielectronMC* dieMC = AliDielectronMC::Instance(); |
322 | ||
323 | Int_t mLabel1 = dieMC->GetMothersLabel(label1); // should work for both ESD and AOD | |
324 | Int_t mLabel2 = dieMC->GetMothersLabel(label2); | |
5e2cf960 | 325 | |
443a091c | 326 | // check the same mother option |
327 | AliDielectronSignalMC* sigMC = (AliDielectronSignalMC*)fSignalsMC->At(nSignal); | |
328 | if(sigMC->GetMothersRelation()==AliDielectronSignalMC::kSame && mLabel1!=mLabel2) return; | |
329 | if(sigMC->GetMothersRelation()==AliDielectronSignalMC::kDifferent && mLabel1==mLabel2) return; | |
330 | ||
331 | // fill the leg variables | |
332 | Double_t valuesLeg1[AliDielectronVarManager::kNMaxValues]; | |
333 | Double_t valuesLeg2[AliDielectronVarManager::kNMaxValues]; | |
334 | AliDielectronVarManager::Fill(part1,valuesLeg1); | |
335 | AliDielectronVarManager::Fill(part2,valuesLeg2); | |
336 | ||
337 | // fill the pair and event variables | |
338 | Double_t valuesPair[AliDielectronVarManager::kNMaxValues]; | |
339 | AliDielectronVarManager::Fill(dieMC->GetMCEvent(), valuesPair); | |
340 | AliDielectronVarManager::FillVarMCParticle2(part1,part2,valuesPair); | |
341 | ||
342 | if(part1->Charge()*part2->Charge()<0) { | |
88204efa | 343 | //valuesPair[AliDielectronVarManager::kPairType]=1; |
344 | // for(Int_t i=0; i<fAxes.GetEntriesFast(); i++) { | |
345 | // printf("[D]: %s %f %f %f \n", | |
346 | // AliDielectronVarManager::GetValueName(fVarCuts[i]), | |
347 | // valuesLeg1[fVarCuts[i]], valuesLeg2[fVarCuts[i]], valuesPair[fVarCuts[i]]); | |
348 | // } | |
d07ad639 | 349 | Fill(nSignal+fSignalsMC->GetEntries(), valuesPair, valuesLeg1, valuesLeg2); |
443a091c | 350 | } |
d07ad639 | 351 | // only OS at the moment |
443a091c | 352 | // else if(part1->Charge()>0) |
353 | // valuesPair[AliDielectronVarManager::kPairType]=0; | |
354 | // else | |
355 | // valuesPair[AliDielectronVarManager::kPairType]=2; // if one of the two particles is neutral, the pair will go here | |
356 | ||
357 | return; | |
358 | } | |
359 | //______________________________________________ | |
360 | void AliDielectronHF::Fill(Int_t pairIndex, const AliDielectronPair *particle) | |
361 | { | |
362 | // | |
363 | // fill histograms for event, pair and daughter cuts and pair types | |
364 | // | |
5e2cf960 | 365 | |
443a091c | 366 | // only OS pairs in case of MC |
367 | if(fHasMC && pairIndex!=AliDielectron::kEv1PM) return; | |
368 | ||
369 | // only selected pair types in case of data | |
370 | if(!IsPairTypeSelected(pairIndex)) return; | |
5e2cf960 | 371 | |
372 | // get event and pair variables | |
373 | Double_t valuesPair[AliDielectronVarManager::kNMaxValues]; | |
374 | AliDielectronVarManager::Fill(particle,valuesPair); | |
375 | ||
376 | // get leg variables | |
377 | Double_t valuesLeg1[AliDielectronVarManager::kNMaxValues]={0}; | |
378 | AliDielectronVarManager::Fill(particle->GetFirstDaughter(),valuesLeg1); | |
379 | Double_t valuesLeg2[AliDielectronVarManager::kNMaxValues]={0}; | |
380 | AliDielectronVarManager::Fill(particle->GetSecondDaughter(),valuesLeg2); | |
381 | ||
443a091c | 382 | // fill |
383 | if(!fHasMC) { Fill(pairIndex, valuesPair, valuesLeg1, valuesLeg2); } | |
384 | if(fHasMC && fSignalsMC) { | |
385 | for(Int_t i=0; i<fSignalsMC->GetEntries(); i++) { | |
386 | if(AliDielectronMC::Instance()->IsMCTruth(particle, (AliDielectronSignalMC*)fSignalsMC->At(i))) | |
387 | Fill(i, valuesPair, valuesLeg1, valuesLeg2); | |
388 | } | |
389 | } | |
390 | ||
391 | return; | |
392 | ||
393 | } | |
394 | ||
395 | //______________________________________________ | |
396 | void AliDielectronHF::Fill(Int_t Index, Double_t * const valuesPair, Double_t * const valuesLeg1, Double_t * const valuesLeg2) | |
397 | { | |
398 | // | |
399 | // main fill function using index and values as input | |
400 | // | |
401 | ||
402 | TObjArray *histArr = static_cast<TObjArray*>(fArrPairType.At(Index)); | |
403 | if(!histArr) return; | |
404 | ||
405 | Int_t size = GetNumberOfBins(); | |
5e2cf960 | 406 | // loop over all histograms |
407 | for(Int_t ihist=0; ihist<size; ihist++) { | |
408 | ||
35363fb9 | 409 | Int_t sizeAdd = 1; |
5e2cf960 | 410 | Bool_t selected = kTRUE; |
411 | ||
412 | // loop over all cut variables | |
413 | Int_t nvars = fAxes.GetEntriesFast(); | |
414 | for(Int_t ivar=0; ivar<nvars; ivar++) { | |
415 | ||
416 | // get bin limits | |
417 | TVectorD *bins = static_cast<TVectorD*>(fAxes.At(ivar)); | |
418 | Int_t nbins = bins->GetNrows()-1; | |
419 | ||
420 | // bin limits for current ivar bin | |
35363fb9 | 421 | Int_t ibin = (ihist/sizeAdd)%nbins; |
5e2cf960 | 422 | Double_t lowEdge = (*bins)[ibin]; |
423 | Double_t upEdge = (*bins)[ibin+1]; | |
424 | switch(fBinType[ivar]) { | |
425 | case kStdBin: upEdge=(*bins)[ibin+1]; break; | |
426 | case kBinToMax: upEdge=(*bins)[nbins]; break; | |
427 | case kBinFromMin: lowEdge=(*bins)[0]; break; | |
35363fb9 | 428 | case kSymBin: upEdge=(*bins)[nbins-ibin]; |
5e2cf960 | 429 | if(ibin>=((Double_t)(nbins+1))/2) upEdge=(*bins)[nbins]; // to avoid low>up |
430 | break; | |
431 | } | |
443a091c | 432 | |
5e2cf960 | 433 | // leg variable |
443a091c | 434 | if(fVarCutType[ivar]) { |
5e2cf960 | 435 | if( (valuesLeg1[fVarCuts[ivar]] < lowEdge || valuesLeg1[fVarCuts[ivar]] >= upEdge) || |
436 | (valuesLeg2[fVarCuts[ivar]] < lowEdge || valuesLeg2[fVarCuts[ivar]] >= upEdge) ) { | |
437 | selected=kFALSE; | |
438 | break; | |
439 | } | |
35363fb9 | 440 | } |
5e2cf960 | 441 | else { // pair and event variables |
442 | if( (valuesPair[fVarCuts[ivar]] < lowEdge || valuesPair[fVarCuts[ivar]] >= upEdge) ) { | |
443 | selected=kFALSE; | |
444 | break; | |
445 | } | |
446 | } | |
35363fb9 | 447 | |
5e2cf960 | 448 | sizeAdd*=nbins; |
449 | } //end of var cut loop | |
35363fb9 | 450 | |
5e2cf960 | 451 | // do not fill the histogram |
452 | if(!selected) continue; | |
35363fb9 | 453 | |
454 | // fill the object with Pair and event values (TODO: this needs to be changed) | |
d07ad639 | 455 | TObjArray *tmp = (TObjArray*) histArr->At(ihist); |
35363fb9 | 456 | TString title = tmp->GetName(); |
5e2cf960 | 457 | AliDebug(10,title.Data()); |
d07ad639 | 458 | for(Int_t i=0; i<tmp->GetEntriesFast(); i++) { |
459 | AliDielectronHistos::FillValues(tmp->At(i), valuesPair); | |
460 | } | |
35363fb9 | 461 | // AliDebug(10,Form("Fill var %d %s value %f in %s \n",fVar,AliDielectronVarManager::GetValueName(fVar),valuesPair[fVar],tmp->GetName())); |
5e2cf960 | 462 | } //end of hist loop |
35363fb9 | 463 | |
5e2cf960 | 464 | } |
465 | ||
466 | //______________________________________________ | |
467 | void AliDielectronHF::Init() | |
468 | { | |
469 | // | |
470 | // initialise event buffers | |
471 | // | |
472 | ||
443a091c | 473 | // has MC signals |
474 | fHasMC=AliDielectronMC::Instance()->HasMC(); | |
4d7704c5 | 475 | Int_t steps = 0; |
476 | if(fHasMC) steps=fSignalsMC->GetEntries(); | |
477 | if(fStepGenerated) steps*=2; | |
443a091c | 478 | |
5e2cf960 | 479 | // init pair type array |
480 | fArrPairType.SetName(Form("%s_HF",GetName())); | |
4d7704c5 | 481 | if(fHasMC) fArrPairType.Expand(steps); |
443a091c | 482 | else fArrPairType.Expand(AliDielectron::kEv1PMRot+1); |
5e2cf960 | 483 | |
5e2cf960 | 484 | Int_t size = GetNumberOfBins(); |
485 | AliDebug(10,Form("Creating a histo array with size %d \n",size)); | |
486 | ||
487 | Int_t sizeAdd = 1; | |
488 | ||
489 | // fill object array with the histograms | |
490 | TObjArray *histArr = new TObjArray(); | |
491 | histArr->Expand(size); | |
492 | ||
35363fb9 | 493 | // printf("fRefObj %p \n",fRefObj); |
5e2cf960 | 494 | for(Int_t ihist=0; ihist<size; ihist++) { |
d07ad639 | 495 | histArr->AddAt(fRefObj.Clone(""), ihist); |
496 | //histArr->AddAt(fRefObj.Clone(Form("h%04d",ihist)), ihist); | |
5e2cf960 | 497 | } |
498 | ||
499 | // loop over all cut variables | |
500 | Int_t nvars = fAxes.GetEntriesFast(); | |
501 | for(Int_t ivar=0; ivar<nvars; ivar++) { | |
502 | ||
503 | // get bin limits | |
504 | TVectorD *bins = static_cast<TVectorD*>(fAxes.At(ivar)); | |
505 | Int_t nbins = bins->GetNrows()-1; | |
506 | ||
507 | ||
508 | // loop over all histograms an set unique titles | |
509 | for(Int_t ihist=0; ihist<size; ihist++) { | |
510 | ||
511 | // get the lower limit for current ivar bin | |
512 | Int_t ibin = (ihist/sizeAdd)%nbins; | |
513 | Double_t lowEdge = (*bins)[ibin]; | |
514 | Double_t upEdge = (*bins)[ibin+1]; | |
515 | switch(fBinType[ivar]) { | |
516 | case kStdBin: upEdge=(*bins)[ibin+1]; break; | |
517 | case kBinToMax: upEdge=(*bins)[nbins]; break; | |
518 | case kBinFromMin: lowEdge=(*bins)[0]; break; | |
519 | case kSymBin: upEdge=(*bins)[nbins-ibin]; | |
520 | if(ibin>=((Double_t)(nbins+1))/2) upEdge=(*bins)[nbins]; // to avoid low>up | |
521 | break; | |
522 | } | |
523 | ||
d07ad639 | 524 | TObjArray *tmp= (TObjArray*) histArr->At(ihist); |
35363fb9 | 525 | TString title = tmp->GetName(); |
d07ad639 | 526 | if(!ivar) title =""; |
527 | if( ivar) title+=":"; | |
5e2cf960 | 528 | if(fVarCutType[ivar]) title+="Leg"; |
529 | title+=AliDielectronVarManager::GetValueName(fVarCuts[ivar]); | |
530 | title+=Form("#%.2f#%.2f",lowEdge,upEdge); | |
35363fb9 | 531 | tmp->SetName(title.Data()); |
5e2cf960 | 532 | AliDebug(10,title.Data()); |
533 | } | |
534 | sizeAdd*=nbins; | |
535 | } | |
536 | ||
443a091c | 537 | // copy array to the selected pair types/ MC sources |
538 | if(fHasMC) { | |
539 | for(Int_t i=0; i<fSignalsMC->GetEntries(); i++) { | |
4d7704c5 | 540 | TString title = Form("(Signal: %s)",fSignalsMC->At(i)->GetTitle()); |
541 | fArrPairType[i]=(TObjArray*)histArr->Clone(title.Data()); | |
542 | if(fStepGenerated) { | |
543 | title+=" MC truth"; | |
544 | fArrPairType[i+fSignalsMC->GetEntries()]=(TObjArray*)histArr->Clone(title.Data()); | |
545 | } | |
546 | } | |
547 | } | |
548 | else { | |
443a091c | 549 | for(Int_t i=0; i<AliDielectron::kEv1PMRot+1; i++) { |
550 | if(IsPairTypeSelected(i)) fArrPairType[i]=(TObjArray*)histArr->Clone(Form("%s",AliDielectron::PairClassName(i))); | |
551 | else fArrPairType[i]=0x0; | |
552 | } | |
5e2cf960 | 553 | } |
554 | ||
555 | // clean up | |
556 | if(histArr) { | |
557 | delete histArr; | |
558 | histArr=0; | |
559 | } | |
560 | ||
561 | } | |
562 | ||
563 | //______________________________________________ | |
564 | Int_t AliDielectronHF::GetNumberOfBins() const | |
565 | { | |
566 | // | |
567 | // return the number of bins this mixing handler has | |
568 | // | |
569 | Int_t size=1; | |
570 | for (Int_t i=0; i<fAxes.GetEntriesFast(); ++i) | |
571 | size*=((static_cast<TVectorD*>(fAxes.At(i)))->GetNrows()-1); | |
572 | return size; | |
573 | } | |
574 | ||
575 | //______________________________________________ | |
576 | Bool_t AliDielectronHF::IsPairTypeSelected(Int_t itype) | |
577 | { | |
578 | // | |
579 | // check whether a pair type was selected | |
580 | // | |
581 | ||
582 | Bool_t selected = kFALSE; | |
583 | ||
584 | // fill all | |
585 | if(fPairType==kAll) selected = kTRUE; | |
586 | ||
587 | switch(itype) { | |
588 | case AliDielectron::kEv1PP: | |
589 | case AliDielectron::kEv1MM: | |
590 | if(fPairType==kOSandLS) selected = kTRUE; | |
591 | break; | |
592 | case AliDielectron::kEv1PM: selected = kTRUE; | |
593 | break; | |
594 | case AliDielectron::kEv1PEv2P: | |
595 | case AliDielectron::kEv1MEv2P: | |
596 | case AliDielectron::kEv1PEv2M: | |
597 | case AliDielectron::kEv1MEv2M: | |
598 | if(fPairType==kOSandMIX) selected = kTRUE; | |
599 | break; | |
600 | case AliDielectron::kEv2PP: | |
601 | case AliDielectron::kEv2PM: | |
602 | case AliDielectron::kEv2MM: | |
603 | selected = kFALSE; | |
604 | break; | |
605 | case AliDielectron::kEv1PMRot: | |
606 | if(fPairType==kOSandROT) selected = kTRUE; | |
607 | break; | |
608 | } | |
609 | ||
610 | return selected; | |
611 | ||
612 | } | |
613 | ||
614 |