]>
Commit | Line | Data |
---|---|---|
ce4a88f5 | 1 | /************************************************************************* |
2 | * Copyright(c) 1998-2008, 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 | * integrated flow estimate by * | |
18 | * fitting q-distribution * | |
19 | * * | |
20 | * author: Ante Bilandzic * | |
21 | * (anteb@nikhef.nl) * | |
22 | * * | |
23 | * based on the macro written * | |
24 | * by Sergei Voloshin * | |
25 | *******************************/ | |
26 | ||
27 | #define AliFlowAnalysisWithFittingQDistribution_cxx | |
28 | ||
29 | #include "Riostream.h" | |
30 | #include "AliFlowCommonConstants.h" | |
31 | #include "AliFlowCommonHist.h" | |
32 | #include "AliFlowCommonHistResults.h" | |
33 | #include "TChain.h" | |
34 | #include "TFile.h" | |
35 | #include "TList.h" | |
36 | #include "TF1.h" | |
ee0860e8 | 37 | #include "TLegend.h" |
ce4a88f5 | 38 | #include "TParticle.h" |
39 | #include "TProfile.h" | |
40 | #include "AliFlowEventSimple.h" | |
41 | #include "AliFlowTrackSimple.h" | |
42 | #include "AliFlowAnalysisWithFittingQDistribution.h" | |
43 | ||
44 | class TH1; | |
45 | class TGraph; | |
46 | class TPave; | |
47 | class TLatex; | |
48 | class TMarker; | |
49 | class TObjArray; | |
50 | class TList; | |
ce4a88f5 | 51 | class TSystem; |
52 | class TROOT; | |
53 | class AliFlowVector; | |
54 | class TVector; | |
55 | ||
56 | //================================================================================================================ | |
57 | ||
58 | ClassImp(AliFlowAnalysisWithFittingQDistribution) | |
59 | ||
60 | AliFlowAnalysisWithFittingQDistribution::AliFlowAnalysisWithFittingQDistribution(): | |
61 | fHistList(NULL), | |
62 | fCommonHists(NULL), | |
63 | fCommonHistsResults(NULL), | |
64 | fnBinsPhi(0), | |
65 | fPhiMin(0), | |
66 | fPhiMax(0), | |
67 | fPhiBinWidth(0), | |
68 | fnBinsPt(0), | |
69 | fPtMin(0), | |
70 | fPtMax(0), | |
71 | fPtBinWidth(0), | |
72 | fnBinsEta(0), | |
73 | fEtaMin(0), | |
74 | fEtaMax(0), | |
75 | fEtaBinWidth(0), | |
76 | fHarmonic(2), | |
77 | fAnalysisLabel(NULL), | |
78 | fWeightsList(NULL), | |
79 | fUsePhiWeights(kFALSE), | |
80 | fUsePtWeights(kFALSE), | |
81 | fUseEtaWeights(kFALSE), | |
82 | fUseParticleWeights(NULL), | |
83 | fPhiWeights(NULL), | |
84 | fPtWeights(NULL), | |
ee0860e8 | 85 | fEtaWeights(NULL), |
47426051 | 86 | // fitting parameters with default values harwired here (use dedicated macro fqd.C to change them): |
ee0860e8 | 87 | fFittingParameters(NULL), |
88 | fTreshold(5), | |
89 | fvStart(0.05), | |
90 | fvMin(0.0), | |
91 | fvMax(0.25), | |
92 | fSigma2Start(0.75), | |
47426051 | 93 | fSigma2Min(0.5), |
ee0860e8 | 94 | fSigma2Max(2.5), |
95 | fPlotResults(kFALSE), | |
96 | // rest: | |
97 | fLegend(NULL) | |
ce4a88f5 | 98 | { |
99 | // constructor | |
100 | ||
101 | // base list to hold all output objects: | |
102 | fHistList = new TList(); | |
103 | fHistList->SetName("cobjFQD"); | |
104 | fHistList->SetOwner(kTRUE); | |
105 | ||
106 | // analysis label; | |
107 | fAnalysisLabel = new TString(); | |
108 | ||
109 | // list to hold histograms with phi, pt and eta weights: | |
110 | fWeightsList = new TList(); | |
111 | ||
112 | // initialize all arrays: | |
113 | this->InitializeArrays(); | |
114 | ||
115 | } // end of constructor | |
116 | ||
117 | ||
118 | //================================================================================================================ | |
119 | ||
120 | ||
121 | AliFlowAnalysisWithFittingQDistribution::~AliFlowAnalysisWithFittingQDistribution() | |
122 | { | |
123 | // desctructor | |
124 | delete fHistList; | |
125 | } | |
126 | ||
127 | ||
128 | //================================================================================================================ | |
129 | ||
130 | ||
131 | void AliFlowAnalysisWithFittingQDistribution::Init() | |
132 | { | |
133 | // access constants and book everything | |
134 | ||
135 | // access constants: | |
136 | this->AccessConstants(); | |
137 | ||
138 | // booking: | |
139 | this->BookCommonHistograms(); | |
140 | this->BookAndFillWeightsHistograms(); | |
141 | this->BookEverythingForDistributions(); | |
142 | ||
ee0860e8 | 143 | // store fitting parameters: |
144 | this->StoreFittingParameters(); | |
145 | ||
ce4a88f5 | 146 | // nest lists: |
147 | fWeightsList->SetName("Weights"); | |
148 | fWeightsList->SetOwner(kTRUE); | |
149 | fHistList->Add(fWeightsList); | |
150 | ||
151 | // set harmonic in common control histograms (to be improved (should I do this somewhere else?)): | |
152 | (fCommonHists->GetHarmonic())->Fill(0.5,fHarmonic); | |
153 | ||
154 | } // end of void AliFlowAnalysisWithFittingQDistribution::Init() | |
155 | ||
156 | ||
157 | //================================================================================================================ | |
158 | ||
159 | ||
160 | void AliFlowAnalysisWithFittingQDistribution::Make(AliFlowEventSimple* anEvent) | |
161 | { | |
162 | // loop over data | |
163 | ||
47426051 | 164 | // a) fill the common control histograms; |
165 | // b) loop over data and calculate non-weighted and weighted Q-vector and sum of particle weights; | |
166 | // c) fill histograms for q-distribution; | |
167 | // d) reset e-b-e quantities. | |
ce4a88f5 | 168 | |
47426051 | 169 | // a) fill the common control histograms: |
ce4a88f5 | 170 | fCommonHists->FillControlHistograms(anEvent); |
171 | ||
172 | Double_t dPhi = 0.; // azimuthal angle in the laboratory frame | |
173 | Double_t dPt = 0.; // transverse momentum | |
174 | Double_t dEta = 0.; // pseudorapidity | |
175 | ||
176 | Double_t wPhi = 1.; // phi weight | |
177 | Double_t wPt = 1.; // pt weight | |
178 | Double_t wEta = 1.; // eta weight | |
179 | ||
180 | Int_t nPrim = anEvent->NumberOfTracks(); // nPrim = total number of primary tracks, i.e. nPrim = nRP + nPOI + rest, where: | |
181 | // nRP = # of particles used to determine the reaction plane; | |
182 | // nPOI = # of particles of interest for a detailed flow analysis; | |
183 | // rest = # of particles which are not niether RPs nor POIs. | |
184 | ||
185 | Int_t n = fHarmonic; // shortcut for the harmonic | |
186 | ||
187 | Double_t dReQ[2] = {0.}; // real part of Q-vector [0=particle weights not used, 1=particle weights used] | |
188 | Double_t dImQ[2] = {0.}; // imaginary part of Q-vector [0=particle weights not used, 1=particle weights used] | |
47426051 | 189 | Double_t dSumOfParticleWeights[2] = {0.}; // [0=particle weights not used, 1=particle weights used] |
ce4a88f5 | 190 | |
191 | AliFlowTrackSimple *aftsTrack = NULL; | |
47426051 | 192 | |
193 | // b) loop over data and calculate non-weighted and weighted Q-vector and sum of particle weights: | |
ce4a88f5 | 194 | for(Int_t i=0;i<nPrim;i++) |
195 | { | |
196 | aftsTrack=anEvent->GetTrack(i); | |
197 | if(aftsTrack) | |
198 | { | |
199 | if(!(aftsTrack->InRPSelection())) continue; // consider only tracks which are RPs | |
200 | ||
201 | dPhi = aftsTrack->Phi(); | |
202 | dPt = aftsTrack->Pt(); | |
203 | dEta = aftsTrack->Eta(); | |
204 | ||
205 | if(fUsePhiWeights && fPhiWeights && fnBinsPhi) // determine phi weight for this particle: | |
206 | { | |
207 | wPhi = fPhiWeights->GetBinContent(1+(Int_t)(TMath::Floor(dPhi*fnBinsPhi/TMath::TwoPi()))); | |
208 | } | |
209 | if(fUsePtWeights && fPtWeights && fnBinsPt) // determine pt weight for this particle: | |
210 | { | |
211 | wPt = fPtWeights->GetBinContent(1+(Int_t)(TMath::Floor((dPt-fPtMin)/fPtBinWidth))); | |
212 | } | |
213 | if(fUseEtaWeights && fEtaWeights && fEtaBinWidth) // determine eta weight for this particle: | |
214 | { | |
215 | wEta = fEtaWeights->GetBinContent(1+(Int_t)(TMath::Floor((dEta-fEtaMin)/fEtaBinWidth))); | |
216 | } | |
217 | ||
218 | // calculate real and imaginary part of non-weighted and weighted Q-vector and sum of particle weights for this event: | |
47426051 | 219 | for(Int_t pW=0;pW<1+(Int_t)(fUsePhiWeights||fUsePtWeights||fUseEtaWeights);pW++) // particle weights not used (0) or used (1) |
ce4a88f5 | 220 | { |
221 | // Q-vector: | |
222 | dReQ[pW]+=pow(wPhi*wPt*wEta,pW)*TMath::Cos(n*dPhi); | |
223 | dImQ[pW]+=pow(wPhi*wPt*wEta,pW)*TMath::Sin(n*dPhi); | |
224 | // sum of particle weights: | |
47426051 | 225 | dSumOfParticleWeights[pW] += pow(wPhi*wPt*wEta,pW); // if pW = 0, this sum gives # of RPs, i.e. multiplicity |
ce4a88f5 | 226 | } |
227 | ||
228 | } // end of if(aftsTrack) | |
229 | } // end of for(Int_t i=0;i<nPrim;i++) | |
230 | ||
47426051 | 231 | // c) fill histograms for q-distribution: |
232 | // calculating first q = Q\sqrt{sum of particle weights} (Remark: if particle weights are unit than sum of particle weights = multiplicity) | |
ce4a88f5 | 233 | Double_t q=0; |
47426051 | 234 | for(Int_t pW=0;pW<1+(Int_t)(fUsePhiWeights||fUsePtWeights||fUseEtaWeights);pW++) // particle weights not used (0) or used (1) |
ce4a88f5 | 235 | { |
236 | if(dSumOfParticleWeights[pW]) | |
237 | { | |
238 | q = pow(dReQ[pW]*dReQ[pW]+dImQ[pW]*dImQ[pW],0.5)/pow(dSumOfParticleWeights[pW],0.5); | |
239 | // fill histograms: | |
240 | fqDistribution[pW]->Fill(q,1.); | |
241 | fSumOfParticleWeights[pW]->Fill(dSumOfParticleWeights[pW],1.); | |
242 | } | |
243 | } | |
244 | ||
47426051 | 245 | // d) reset e-b-e quantities: |
246 | for(Int_t pW=0;pW<1+(Int_t)(fUsePhiWeights||fUsePtWeights||fUseEtaWeights);pW++) // particle weights not used (0) or used (1) | |
ce4a88f5 | 247 | { |
248 | dReQ[pW] = 0.; | |
249 | dImQ[pW] = 0.; | |
250 | dSumOfParticleWeights[pW] = 0.; | |
251 | } | |
252 | ||
47426051 | 253 | } // end of Make() |
254 | ||
255 | ||
256 | //================================================================================================================ | |
257 | ||
258 | ||
259 | void AliFlowAnalysisWithFittingQDistribution::Finish(Bool_t doFit) | |
260 | { | |
261 | // calculate the final results | |
262 | ||
263 | // a) acces the constants and all fitting paremeters; | |
264 | // b) access the flags for particle weights; | |
265 | // c) do final fit; | |
266 | // d) fill common hist results; | |
267 | // e) print on the screen the final results. | |
268 | ||
269 | // a) access the constants and all fitting paremeters: | |
270 | this->AccessConstants(); | |
271 | this->AccessFittingParameters(); | |
272 | ||
273 | // b) access the flags for particle weights: | |
274 | fUsePhiWeights = (Bool_t)fUseParticleWeights->GetBinContent(1); | |
275 | fUsePtWeights = (Bool_t)fUseParticleWeights->GetBinContent(2); | |
276 | fUseEtaWeights = (Bool_t)fUseParticleWeights->GetBinContent(3); | |
277 | ||
278 | // to be improved (moved somewhere else): | |
279 | if(fPlotResults) | |
280 | { | |
281 | fLegend = new TLegend(0.6,0.55,0.85,0.7); | |
282 | } | |
283 | ||
284 | // c) do final fit: | |
285 | if(doFit) | |
286 | { | |
287 | // particle weights not used: | |
288 | // 1) sigma^2 not fitted (fixed to 0.5): | |
289 | this->DoFit(kFALSE,kFALSE); | |
290 | // 2) sigma^2 fitted: | |
291 | this->DoFit(kFALSE,kTRUE); | |
292 | // particle weights used: | |
293 | if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights) | |
294 | { | |
295 | // 1) sigma^2 not fitted (fixed to 0.5): | |
296 | this->DoFit(kTRUE,kFALSE); | |
297 | // 2) sigma^2 fitted: | |
298 | this->DoFit(kTRUE,kTRUE); | |
299 | } | |
300 | ||
301 | // d) fill common hist results (by default fill results obtained with sigma^2 fitted): | |
302 | if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights) | |
303 | { | |
304 | this->FillCommonHistResultsIntFlow(kTRUE,kTRUE); | |
305 | } else | |
306 | { | |
307 | this->FillCommonHistResultsIntFlow(kFALSE,kTRUE); | |
308 | } | |
309 | ||
310 | // e) print on the screen the final results: | |
311 | this->PrintFinalResultsForIntegratedFlow(); | |
312 | ||
313 | } // end of if(doFit) | |
314 | ||
315 | } // end of void AliFlowAnalysisWithFittingQDistribution::Finish(Bool_t doFit) | |
ce4a88f5 | 316 | |
317 | ||
318 | //================================================================================================================ | |
319 | ||
320 | ||
321 | void AliFlowAnalysisWithFittingQDistribution::GetOutputHistograms(TList *outputListHistos) | |
322 | { | |
323 | // get pointers to all output histograms (called before Finish()) | |
324 | ||
325 | if(outputListHistos) | |
326 | { | |
327 | // 1.) common control histograms and common histograms for final results: | |
328 | TString commonHistName = "AliFlowCommonHistFQD"; | |
329 | commonHistName += fAnalysisLabel->Data(); | |
330 | AliFlowCommonHist *commonHist = dynamic_cast<AliFlowCommonHist*>(outputListHistos->FindObject(commonHistName.Data())); | |
331 | if(commonHist) this->SetCommonHists(commonHist); | |
332 | ||
333 | TString commonHistResName = "AliFlowCommonHistResultsFQD"; | |
334 | commonHistResName += fAnalysisLabel->Data(); | |
335 | AliFlowCommonHistResults *commonHistRes = dynamic_cast<AliFlowCommonHistResults*> | |
336 | (outputListHistos->FindObject(commonHistResName.Data())); | |
337 | if(commonHistRes) this->SetCommonHistsResults(commonHistRes); | |
338 | ||
339 | // 2.) weights: | |
340 | TList *weightsList = dynamic_cast<TList*>(outputListHistos->FindObject("Weights")); | |
341 | if(weightsList) this->SetWeightsList(weightsList); | |
342 | Bool_t bUsePhiWeights = kFALSE; | |
343 | Bool_t bUsePtWeights = kFALSE; | |
344 | Bool_t bUseEtaWeights = kFALSE; | |
345 | TString fUseParticleWeightsName = "fUseParticleWeightsFQD"; | |
346 | fUseParticleWeightsName += fAnalysisLabel->Data(); | |
347 | TProfile *useParticleWeights = dynamic_cast<TProfile*>(weightsList->FindObject(fUseParticleWeightsName.Data())); | |
348 | if(useParticleWeights) | |
349 | { | |
350 | this->SetUseParticleWeights(useParticleWeights); | |
351 | bUsePhiWeights = (Int_t)useParticleWeights->GetBinContent(1); | |
352 | bUsePtWeights = (Int_t)useParticleWeights->GetBinContent(2); | |
353 | bUseEtaWeights = (Int_t)useParticleWeights->GetBinContent(3); | |
354 | } | |
355 | ||
356 | // 3.) distributions and 4.) final results of fitting: | |
357 | TString pWeightsFlag[2] = {"pWeights not used","pWeights used"}; | |
97ab16dd | 358 | TString sigmaFlag[2] = {"#sigma^{2} not fitted","#sigma^{2} fitted"}; |
ce4a88f5 | 359 | |
360 | // q-distribution: | |
361 | TString qDistributionName = "fqDistribution"; | |
362 | qDistributionName += fAnalysisLabel->Data(); | |
363 | // sum of particle weights: | |
364 | TString sumOfParticleWeightsName = "fSumOfParticleWeightsName"; | |
365 | sumOfParticleWeightsName += fAnalysisLabel->Data(); | |
366 | // final results for integrated flow: | |
367 | TString intFlowName = "fIntFlowFQD"; | |
368 | intFlowName += fAnalysisLabel->Data(); | |
369 | // sigma^2: | |
370 | TString sigma2Name = "fSigma2"; | |
371 | sigma2Name += fAnalysisLabel->Data(); | |
97ab16dd | 372 | // chi^2: |
373 | TString chi2Name = "fChi2"; | |
374 | chi2Name += fAnalysisLabel->Data(); | |
ce4a88f5 | 375 | |
376 | TH1D *qDistribution[2] = {NULL}; | |
377 | TH1D *sumOfParticleWeights[2] = {NULL}; | |
378 | TH1D *intFlow[2][2] = {{NULL}}; | |
379 | TH1D *sigma2[2][2] = {{NULL}}; | |
97ab16dd | 380 | TH1D *chi2[2][2] = {{NULL}}; |
ce4a88f5 | 381 | |
382 | for(Int_t pW=0;pW<1+(Int_t)(bUsePhiWeights||bUsePtWeights||bUseEtaWeights);pW++) | |
383 | { | |
384 | // q-distribution: | |
385 | qDistribution[pW] = dynamic_cast<TH1D*>(outputListHistos->FindObject(Form("%s, %s",qDistributionName.Data(),pWeightsFlag[pW].Data()))); | |
386 | if(qDistribution[pW]) | |
387 | { | |
388 | this->SetqDistribution(qDistribution[pW],pW); | |
389 | } else | |
390 | { | |
391 | cout<<"WARNING: qDistribution[pW] is NULL in AFAWFQD::GOH() !!!!"<<endl; | |
392 | cout<<"pW = "<<pW<<endl; | |
393 | } | |
394 | // sum of particle weights: | |
395 | sumOfParticleWeights[pW] = dynamic_cast<TH1D*>(outputListHistos->FindObject(Form("%s, %s",sumOfParticleWeightsName.Data(),pWeightsFlag[pW].Data()))); | |
396 | if(sumOfParticleWeights[pW]) | |
397 | { | |
398 | this->SetSumOfParticleWeights(sumOfParticleWeights[pW],pW); | |
399 | } else | |
400 | { | |
401 | cout<<"WARNING: sumOfParticleWeights[pW] is NULL in AFAWFQD::GOH() !!!!"<<endl; | |
402 | cout<<"pW = "<<pW<<endl; | |
403 | } | |
404 | // final results: | |
405 | for(Int_t f=0;f<2;f++) | |
406 | { | |
407 | // final results for integrated flow: | |
408 | intFlow[pW][f] = dynamic_cast<TH1D*>(outputListHistos->FindObject(Form("%s, %s, %s",intFlowName.Data(),pWeightsFlag[pW].Data(),sigmaFlag[f].Data()))); | |
409 | if(intFlow[pW][f]) | |
410 | { | |
411 | this->SetIntFlow(intFlow[pW][f],pW,f); | |
412 | } else | |
413 | { | |
414 | cout<<"WARNING: intFlow[pW][f] is NULL in AFAWFQD::GOH() !!!!"<<endl; | |
415 | cout<<"pW = "<<pW<<endl; | |
416 | cout<<"f = "<<f<<endl; | |
417 | } | |
418 | // sigma^2: | |
419 | sigma2[pW][f] = dynamic_cast<TH1D*>(outputListHistos->FindObject(Form("%s, %s, %s",sigma2Name.Data(),pWeightsFlag[pW].Data(),sigmaFlag[f].Data()))); | |
420 | if(sigma2[pW][f]) | |
421 | { | |
422 | this->SetSigma2(sigma2[pW][f],pW,f); | |
423 | } else | |
424 | { | |
425 | cout<<"WARNING: sigma2[pW][f] is NULL in AFAWFQD::GOH() !!!!"<<endl; | |
426 | cout<<"pW = "<<pW<<endl; | |
427 | cout<<"f = "<<f<<endl; | |
428 | } | |
97ab16dd | 429 | // chi^2: |
430 | chi2[pW][f] = dynamic_cast<TH1D*>(outputListHistos->FindObject(Form("%s, %s, %s",chi2Name.Data(),pWeightsFlag[pW].Data(),sigmaFlag[f].Data()))); | |
431 | if(chi2[pW][f]) | |
432 | { | |
433 | this->SetChi2(chi2[pW][f],pW,f); | |
434 | } else | |
435 | { | |
436 | cout<<"WARNING: chi2[pW][f] is NULL in AFAWFQD::GOH() !!!!"<<endl; | |
437 | cout<<"pW = "<<pW<<endl; | |
438 | cout<<"f = "<<f<<endl; | |
439 | } | |
440 | ||
ce4a88f5 | 441 | } // end of for(Int_t f=0;f<2;f++) |
442 | } // end of for(Int_t pW=0;pW<1+(Int_t)(bUsePhiWeights||bUsePtWeights||bUseEtaWeights);pW++) | |
ee0860e8 | 443 | |
444 | // 5.) fitting parameters: | |
445 | // q-distribution: | |
446 | TString fittingParametersName = "fFittingParameters"; | |
447 | fittingParametersName += fAnalysisLabel->Data(); | |
448 | TProfile *fittingParameters = NULL; | |
449 | fittingParameters = dynamic_cast<TProfile*>(outputListHistos->FindObject(fittingParametersName.Data())); | |
450 | if(fittingParameters) | |
451 | { | |
452 | this->SetFittingParameters(fittingParameters); | |
453 | } else | |
454 | { | |
455 | cout<<"WARNING:fittingParameters is NULL in AFAWFQD::GOH() !!!!"<<endl; | |
456 | } | |
457 | ||
ce4a88f5 | 458 | } else // to if(outputListHistos) |
459 | { | |
460 | cout<<"WARNING: outputListHistos is NULL in AFAWFQD::GOH() !!!!"<<endl; | |
461 | exit(0); | |
462 | } | |
ee0860e8 | 463 | |
ce4a88f5 | 464 | |
465 | } // end of void AliFlowAnalysisWithFittingQDistribution::GetOutputHistograms(TList *outputListHistos) | |
466 | ||
467 | ||
468 | //================================================================================================================ | |
469 | ||
470 | ||
ce4a88f5 | 471 | void AliFlowAnalysisWithFittingQDistribution::WriteHistograms(TString* outputFileName) |
472 | { | |
473 | //store the final results in output .root file | |
474 | TFile *output = new TFile(outputFileName->Data(),"RECREATE"); | |
475 | //output->WriteObject(fHistList, "cobjFQD","SingleKey"); | |
476 | fHistList->SetName("cobjFQD"); | |
477 | fHistList->SetOwner(kTRUE); | |
478 | fHistList->Write(fHistList->GetName(), TObject::kSingleKey); | |
479 | delete output; | |
480 | } | |
481 | ||
482 | //================================================================================================================ | |
483 | ||
484 | void AliFlowAnalysisWithFittingQDistribution::WriteHistograms(TString outputFileName) | |
485 | { | |
486 | //store the final results in output .root file | |
487 | TFile *output = new TFile(outputFileName.Data(),"RECREATE"); | |
488 | //output->WriteObject(fHistList, "cobjFQD","SingleKey"); | |
489 | fHistList->SetName("cobjFQD"); | |
490 | fHistList->SetOwner(kTRUE); | |
491 | fHistList->Write(fHistList->GetName(), TObject::kSingleKey); | |
492 | delete output; | |
493 | } | |
494 | ||
495 | ||
ad87ae62 | 496 | //================================================================================================================ |
497 | ||
498 | ||
499 | void AliFlowAnalysisWithFittingQDistribution::WriteHistograms(TDirectoryFile *outputFileName) | |
500 | { | |
501 | //store the final results in output .root file | |
502 | fHistList->SetName("cobjFQD"); | |
503 | fHistList->SetOwner(kTRUE); | |
504 | outputFileName->Add(fHistList); | |
505 | outputFileName->Write(outputFileName->GetName(), TObject::kSingleKey); | |
506 | } | |
507 | ||
508 | ||
ce4a88f5 | 509 | //================================================================================================================ |
510 | ||
511 | ||
512 | void AliFlowAnalysisWithFittingQDistribution::InitializeArrays() | |
513 | { | |
514 | // initialize all arrays | |
515 | ||
47426051 | 516 | for(Int_t pW=0;pW<2;pW++) // particle weights not used (0) or used (1) |
ce4a88f5 | 517 | { |
518 | fSumOfParticleWeights[pW] = NULL; | |
519 | fqDistribution[pW] = NULL; | |
97ab16dd | 520 | for(Int_t f=0;f<2;f++) // sigma^2 not fitted (0) or fitted (1) |
ce4a88f5 | 521 | { |
522 | fIntFlow[pW][f] = NULL; | |
523 | fSigma2[pW][f] = NULL; | |
97ab16dd | 524 | fChi2[pW][f] = NULL; |
ce4a88f5 | 525 | } |
526 | } | |
527 | ||
528 | } // end of void AliFlowAnalysisWithFittingQDistribution::InitializeArrays() | |
529 | ||
530 | ||
531 | //================================================================================================================ | |
532 | ||
533 | ||
534 | void AliFlowAnalysisWithFittingQDistribution::BookCommonHistograms() | |
535 | { | |
536 | // book common histograms | |
537 | ||
538 | // common control histogram: | |
539 | TString commonHistName = "AliFlowCommonHistFQD"; | |
540 | commonHistName += fAnalysisLabel->Data(); | |
541 | fCommonHists = new AliFlowCommonHist(commonHistName.Data()); | |
542 | fHistList->Add(fCommonHists); | |
543 | ||
544 | // common histograms for final results: | |
545 | TString commonHistResName = "AliFlowCommonHistResultsFQD"; | |
546 | commonHistResName += fAnalysisLabel->Data(); | |
547 | fCommonHistsResults = new AliFlowCommonHistResults(commonHistResName.Data()); | |
548 | fHistList->Add(fCommonHistsResults); | |
549 | ||
47426051 | 550 | } // end of void AliFlowAnalysisWithFittingQDistribution::BookCommonHistograms() |
ce4a88f5 | 551 | |
552 | ||
553 | //================================================================================================================ | |
554 | ||
555 | ||
556 | void AliFlowAnalysisWithFittingQDistribution::BookAndFillWeightsHistograms() | |
557 | { | |
558 | // book and fill histograms which hold phi, pt and eta weights | |
559 | ||
560 | if(!fWeightsList) | |
561 | { | |
562 | cout<<"WARNING: fWeightsList is NULL in AFAWFQD::BAFWH() !!!!"<<endl; | |
563 | exit(0); | |
564 | } | |
565 | ||
566 | TString fUseParticleWeightsName = "fUseParticleWeightsFQD"; | |
567 | fUseParticleWeightsName += fAnalysisLabel->Data(); | |
568 | fUseParticleWeights = new TProfile(fUseParticleWeightsName.Data(),"0 = particle weight not used, 1 = particle weight used ",3,0,3); | |
47426051 | 569 | fUseParticleWeights->SetLabelSize(0.08); |
ce4a88f5 | 570 | (fUseParticleWeights->GetXaxis())->SetBinLabel(1,"w_{#phi}"); |
571 | (fUseParticleWeights->GetXaxis())->SetBinLabel(2,"w_{p_{T}}"); | |
572 | (fUseParticleWeights->GetXaxis())->SetBinLabel(3,"w_{#eta}"); | |
573 | fUseParticleWeights->Fill(0.5,(Int_t)fUsePhiWeights); | |
574 | fUseParticleWeights->Fill(1.5,(Int_t)fUsePtWeights); | |
575 | fUseParticleWeights->Fill(2.5,(Int_t)fUseEtaWeights); | |
576 | fWeightsList->Add(fUseParticleWeights); | |
577 | ||
578 | if(fUsePhiWeights) | |
579 | { | |
580 | if(fWeightsList->FindObject("phi_weights")) | |
581 | { | |
582 | fPhiWeights = dynamic_cast<TH1F*>(fWeightsList->FindObject("phi_weights")); | |
583 | if(fPhiWeights->GetBinWidth(1) != fPhiBinWidth) | |
584 | { | |
585 | cout<<"WARNING: fPhiWeights->GetBinWidth(1) != fPhiBinWidth in AFAWFQD::BAFWH() !!!! "<<endl; | |
586 | cout<<" This indicates inconsistent binning in phi histograms throughout the code."<<endl; | |
587 | exit(0); | |
588 | } | |
589 | } else | |
590 | { | |
591 | cout<<"WARNING: fWeightsList->FindObject(\"phi_weights\") is NULL in AFAWFQD::BAFWH() !!!!"<<endl; | |
592 | exit(0); | |
593 | } | |
594 | } // end of if(fUsePhiWeights) | |
595 | ||
596 | if(fUsePtWeights) | |
597 | { | |
598 | if(fWeightsList->FindObject("pt_weights")) | |
599 | { | |
600 | fPtWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("pt_weights")); | |
601 | if(fPtWeights->GetBinWidth(1) != fPtBinWidth) | |
602 | { | |
603 | cout<<"WARNING: fPtWeights->GetBinWidth(1) != fPtBinWidth in AFAWFQD::BAFWH() !!!! "<<endl; | |
604 | cout<<" This indicates insconsistent binning in pt histograms throughout the code."<<endl; | |
605 | exit(0); | |
606 | } | |
607 | } else | |
608 | { | |
609 | cout<<"WARNING: fWeightsList->FindObject(\"pt_weights\") is NULL in AFAWFQD::BAFWH() !!!!"<<endl; | |
610 | exit(0); | |
611 | } | |
612 | } // end of if(fUsePtWeights) | |
613 | ||
614 | if(fUseEtaWeights) | |
615 | { | |
616 | if(fWeightsList->FindObject("eta_weights")) | |
617 | { | |
618 | fEtaWeights = dynamic_cast<TH1D*>(fWeightsList->FindObject("eta_weights")); | |
619 | if(fEtaWeights->GetBinWidth(1) != fEtaBinWidth) | |
620 | { | |
621 | cout<<"WARNING: fEtaWeights->GetBinWidth(1) != fEtaBinWidth in AFAWFQD::BAFWH() !!!! "<<endl; | |
622 | cout<<" This indicates insconsistent binning in eta histograms throughout the code."<<endl; | |
623 | exit(0); | |
624 | } | |
625 | } else | |
626 | { | |
627 | cout<<"WARNING: fUseEtaWeights && fWeightsList->FindObject(\"eta_weights\") is NULL in AFAWFQD::BAFWH() !!!!"<<endl; | |
628 | exit(0); | |
629 | } | |
630 | } // end of if(fUseEtaWeights) | |
631 | ||
632 | } // end of AliFlowAnalysisWithFittingQDistribution::BookAndFillWeightsHistograms() | |
633 | ||
634 | ||
635 | //================================================================================================================================ | |
636 | ||
637 | ||
638 | void AliFlowAnalysisWithFittingQDistribution::AccessConstants() | |
639 | { | |
640 | // access needed common constants from AliFlowCommonConstants | |
641 | ||
bee2efdc | 642 | fnBinsPhi = AliFlowCommonConstants::GetMaster()->GetNbinsPhi(); |
643 | fPhiMin = AliFlowCommonConstants::GetMaster()->GetPhiMin(); | |
644 | fPhiMax = AliFlowCommonConstants::GetMaster()->GetPhiMax(); | |
ce4a88f5 | 645 | if(fnBinsPhi) fPhiBinWidth = (fPhiMax-fPhiMin)/fnBinsPhi; |
bee2efdc | 646 | fnBinsPt = AliFlowCommonConstants::GetMaster()->GetNbinsPt(); |
647 | fPtMin = AliFlowCommonConstants::GetMaster()->GetPtMin(); | |
648 | fPtMax = AliFlowCommonConstants::GetMaster()->GetPtMax(); | |
ce4a88f5 | 649 | if(fnBinsPt) fPtBinWidth = (fPtMax-fPtMin)/fnBinsPt; |
bee2efdc | 650 | fnBinsEta = AliFlowCommonConstants::GetMaster()->GetNbinsEta(); |
651 | fEtaMin = AliFlowCommonConstants::GetMaster()->GetEtaMin(); | |
652 | fEtaMax = AliFlowCommonConstants::GetMaster()->GetEtaMax(); | |
ce4a88f5 | 653 | if(fnBinsEta) fEtaBinWidth = (fEtaMax-fEtaMin)/fnBinsEta; |
654 | ||
655 | } // end of void AliFlowAnalysisWithFittingQDistribution::AccessConstants() | |
656 | ||
657 | ||
658 | //================================================================================================================================ | |
659 | ||
660 | ||
661 | void AliFlowAnalysisWithFittingQDistribution::BookEverythingForDistributions() | |
662 | { | |
663 | // book histograms for distributions | |
664 | ||
665 | TString pWeightsFlag[2] = {"pWeights not used","pWeights used"}; | |
97ab16dd | 666 | TString sigmaFlag[2] = {"#sigma^{2} not fitted","#sigma^{2} fitted"}; |
ce4a88f5 | 667 | // q-distribution: |
668 | TString fqDistributionName = "fqDistribution"; | |
669 | fqDistributionName += fAnalysisLabel->Data(); | |
670 | // sum of particle weights: | |
671 | TString fSumOfParticleWeightsName = "fSumOfParticleWeightsName"; | |
672 | fSumOfParticleWeightsName += fAnalysisLabel->Data(); | |
673 | // final results for integrated flow: | |
674 | TString fIntFlowName = "fIntFlowFQD"; | |
675 | fIntFlowName += fAnalysisLabel->Data(); | |
676 | // sigma^2: | |
677 | TString fSigma2Name = "fSigma2"; | |
678 | fSigma2Name += fAnalysisLabel->Data(); | |
97ab16dd | 679 | // chi^2: |
680 | TString fChi2Name = "fChi2"; | |
681 | fChi2Name += fAnalysisLabel->Data(); | |
ce4a88f5 | 682 | |
47426051 | 683 | for(Int_t pW=0;pW<1+(Int_t)(fUsePhiWeights||fUsePtWeights||fUseEtaWeights);pW++) // particle weights not used (0) or used (1) |
ce4a88f5 | 684 | { |
685 | // q-distribution: | |
686 | fqDistribution[pW] = new TH1D(Form("%s, %s",fqDistributionName.Data(),pWeightsFlag[pW].Data()),"q-distribution",10000,0,1000); | |
687 | fqDistribution[pW]->SetXTitle("q_{n}=Q_{n}/#sqrt{M}"); | |
688 | fqDistribution[pW]->SetYTitle("Counts"); | |
689 | fHistList->Add(fqDistribution[pW]); | |
690 | // sum of particle weights: | |
47426051 | 691 | fSumOfParticleWeights[pW] = new TH1D(Form("%s, %s",fSumOfParticleWeightsName.Data(),pWeightsFlag[pW].Data()),"Sum of particle weights",10000,0,10000); |
ce4a88f5 | 692 | fSumOfParticleWeights[pW]->SetXTitle("#sum_{i=1}^{N} w_{i}"); |
693 | fSumOfParticleWeights[pW]->SetYTitle("Counts"); | |
694 | fHistList->Add(fSumOfParticleWeights[pW]); | |
695 | ||
97ab16dd | 696 | for(Int_t f=0;f<2;f++) // sigma^2 not fitted (0) or fitted (1) |
ce4a88f5 | 697 | { |
698 | // final results for integrated flow: | |
699 | fIntFlow[pW][f] = new TH1D(Form("%s, %s, %s",fIntFlowName.Data(),pWeightsFlag[pW].Data(),sigmaFlag[f].Data()),"Integrated Flow",1,0,1); | |
700 | fIntFlow[pW][f]->SetLabelSize(0.08); | |
701 | (fIntFlow[pW][f]->GetXaxis())->SetBinLabel(1,"v_{n}"); | |
702 | fHistList->Add(fIntFlow[pW][f]); | |
703 | // sigma^2: | |
704 | fSigma2[pW][f] = new TH1D(Form("%s, %s, %s",fSigma2Name.Data(),pWeightsFlag[pW].Data(),sigmaFlag[f].Data()),"#sigma^{2}",1,0,1); | |
705 | fSigma2[pW][f]->SetLabelSize(0.08); | |
706 | (fSigma2[pW][f]->GetXaxis())->SetBinLabel(1,"#sigma^{2}"); | |
707 | fHistList->Add(fSigma2[pW][f]); | |
97ab16dd | 708 | // chi^2: |
47426051 | 709 | fChi2[pW][f] = new TH1D(Form("%s, %s, %s",fChi2Name.Data(),pWeightsFlag[pW].Data(),sigmaFlag[f].Data()),"#chi^{2} (Minuit)",1,0,1); |
97ab16dd | 710 | fChi2[pW][f]->SetLabelSize(0.08); |
711 | (fChi2[pW][f]->GetXaxis())->SetLabelOffset(0.01); | |
712 | (fChi2[pW][f]->GetXaxis())->SetBinLabel(1,"#chi^{2}"); | |
713 | fHistList->Add(fChi2[pW][f]); | |
47426051 | 714 | } // end of for(Int_t f=0;f<2;f++) // sigma^2 not fitted or fitted |
ce4a88f5 | 715 | |
47426051 | 716 | } // end of for(Int_t pW=0;pW<1+(Int_t)(fUsePhiWeights||fUsePtWeights||fUseEtaWeights);pW++) // particle weights not used (0) or used (1) |
ce4a88f5 | 717 | |
47426051 | 718 | // book profile fFittingParameters which will hold all fitting parameters: |
ee0860e8 | 719 | TString fFittingParametersName = "fFittingParameters"; |
720 | fFittingParametersName += fAnalysisLabel->Data(); | |
721 | fFittingParameters = new TProfile(fFittingParametersName.Data(),"Parameters for fitting q-distribution",8,0,8); | |
722 | fFittingParameters->SetLabelSize(0.05); | |
47426051 | 723 | (fFittingParameters->GetXaxis())->SetBinLabel(1,"treshold"); |
ee0860e8 | 724 | (fFittingParameters->GetXaxis())->SetBinLabel(2,"starting v_{n}"); |
725 | (fFittingParameters->GetXaxis())->SetBinLabel(3,"min. v_{n}"); | |
726 | (fFittingParameters->GetXaxis())->SetBinLabel(4,"max. v_{n}"); | |
727 | (fFittingParameters->GetXaxis())->SetBinLabel(5,"starting #sigma^{2}"); | |
728 | (fFittingParameters->GetXaxis())->SetBinLabel(6,"min. #sigma^{2}"); | |
729 | (fFittingParameters->GetXaxis())->SetBinLabel(7,"max. #sigma^{2}"); | |
730 | (fFittingParameters->GetXaxis())->SetBinLabel(8,"plot or not?"); | |
731 | fHistList->Add(fFittingParameters); | |
732 | ||
ce4a88f5 | 733 | } // end of void AliFlowAnalysisWithFittingQDistribution::BookEverythingForDistributions() |
734 | ||
735 | ||
736 | //================================================================================================================================ | |
737 | ||
738 | ||
97ab16dd | 739 | void AliFlowAnalysisWithFittingQDistribution::DoFit(Bool_t useParticleWeights, Bool_t sigma2Fitted) |
ce4a88f5 | 740 | { |
47426051 | 741 | // do final fit for q-distribution |
ce4a88f5 | 742 | |
743 | // shortcuts for flags: | |
744 | Int_t pW = (Int_t)(useParticleWeights); | |
97ab16dd | 745 | Int_t s2F = (Int_t)(sigma2Fitted); |
ce4a88f5 | 746 | |
47426051 | 747 | if(!(fqDistribution[pW] && fSumOfParticleWeights[pW] && fIntFlow[pW][s2F] && fSigma2[pW][s2F] && fChi2[pW][s2F])) |
748 | { | |
749 | cout<<"WARNING: fqDistribution[pW] && fSumOfParticleWeights[pW] && fIntFlow[pW][s2F] && fSigma2[pW][s2F] && fChi2[pW][s2F] is NULL in AFAWFQD::DoFit() !!!!"<<endl; | |
750 | cout<<"pW = "<<pW<<endl; | |
751 | cout<<"s2F = "<<s2F<<endl; | |
752 | exit(0); | |
ce4a88f5 | 753 | } |
754 | ||
755 | // average multiplicity and number of events: | |
756 | Double_t AvM = fSumOfParticleWeights[pW]->GetMean(1); | |
757 | //Int_t nEvts = (Int_t)fSumOfParticleWeights[pW]->GetEntries(); | |
758 | ||
47426051 | 759 | // start fitting from the bin with at least fTreshold entries, |
760 | // finish fitting at the bin with at least fTreshold entries: | |
761 | Int_t binMin = fqDistribution[pW]->FindFirstBinAbove(fTreshold); | |
762 | Int_t binMax = fqDistribution[pW]->FindLastBinAbove(fTreshold); | |
ce4a88f5 | 763 | Double_t binWidth = fqDistribution[pW]->GetBinWidth(4); // assuming that all bins have the same width |
764 | if(binWidth == 0) | |
765 | { | |
766 | cout<<"WARNING: binWidth == 0 in AFAWFQD::DoFit()"<<endl; | |
767 | exit(0); | |
768 | } | |
769 | Double_t qmin = (binMin-1)*binWidth; | |
770 | Double_t qmax = (binMax)*binWidth; | |
771 | Double_t ent = 0.; // number of entries between binMin and binMax: | |
772 | for(Int_t b=binMin;b<=binMax;b++) | |
773 | { | |
774 | ent += fqDistribution[pW]->GetBinContent(b); | |
775 | } | |
776 | Double_t norm = binWidth*ent; // norm (assuming that all bins have the same width) | |
777 | ||
778 | // fitting function: | |
779 | TF1 *fittingFun = new TF1("fittingFun","[2]*(x/[1])*exp(-(x*x+[0]*[0])/(2.*[1]))*TMath::BesselI0(x*[0]/[1])",qmin,qmax); | |
780 | ||
781 | fittingFun->SetParNames("v*sqrt{sum of particle weights}","sigma^2","norm"); | |
47426051 | 782 | fittingFun->SetParameters(fvStart*pow(AvM,0.5),fSigma2Start,norm); |
783 | fittingFun->SetParLimits(0,fvMin*pow(AvM,0.5),fvMax*pow(AvM,0.5)); | |
ee0860e8 | 784 | |
97ab16dd | 785 | if(s2F == 0) |
ce4a88f5 | 786 | { |
97ab16dd | 787 | fittingFun->FixParameter(1,0.5); |
ce4a88f5 | 788 | } else |
789 | { | |
47426051 | 790 | fittingFun->SetParLimits(1,fSigma2Min,fSigma2Max); |
ce4a88f5 | 791 | } |
792 | fittingFun->FixParameter(2,norm); | |
793 | ||
794 | // fitting (do it only if # of entries >50): // to be improved (this is only a pragmatics fix to avoid TMinuit crash) | |
795 | if(ent > 50) | |
796 | { | |
797 | fqDistribution[pW]->Fit("fittingFun","NQ","",qmin,qmax); | |
798 | } | |
799 | // results: | |
800 | Double_t v = 0.; // integrated flow | |
801 | Double_t vError = 0.; // error of integrated flow | |
802 | Double_t sigma2 = 0.; // sigma^2 | |
803 | Double_t sigma2Error = 0.; // error of sigma^2 | |
97ab16dd | 804 | Double_t chi2 = 0; // chi^2 from Minuit |
ce4a88f5 | 805 | |
806 | if(AvM) | |
807 | { | |
47426051 | 808 | // integrated flow: |
ce4a88f5 | 809 | v = fittingFun->GetParameter(0)/pow(AvM,0.5); |
810 | vError = fittingFun->GetParError(0)/pow(AvM,0.5); | |
47426051 | 811 | fIntFlow[pW][s2F]->SetBinContent(1,v); // s2F is shortcut for "sigma^2 fitted" |
812 | fIntFlow[pW][s2F]->SetBinError(1,vError); // s2F is shortcut for "sigma^2 fitted" | |
ce4a88f5 | 813 | } |
97ab16dd | 814 | |
815 | if(s2F == 0) // sigma^2 not fitted, but fixed to 0.5 | |
ce4a88f5 | 816 | { |
97ab16dd | 817 | // sigma^2: |
818 | sigma2 = 0.5; | |
ce4a88f5 | 819 | fSigma2[pW][0]->SetBinContent(1,sigma2); |
97ab16dd | 820 | fSigma2[pW][0]->SetBinError(1,0.); |
821 | // chi^2: | |
822 | chi2 = fittingFun->GetChisquare(); | |
823 | fChi2[pW][0]->SetBinContent(1,chi2); | |
47426051 | 824 | //fChi2[pW][0]->SetBinError(1,0.); |
97ab16dd | 825 | } else // sigma^2 fitted |
ce4a88f5 | 826 | { |
97ab16dd | 827 | // sigma^2: |
828 | sigma2 = fittingFun->GetParameter(1); | |
829 | sigma2Error = fittingFun->GetParError(1); | |
ee0860e8 | 830 | fSigma2[pW][1]->SetBinContent(1,sigma2); |
97ab16dd | 831 | fSigma2[pW][1]->SetBinError(1,sigma2Error); |
832 | // chi^2: | |
833 | chi2 = fittingFun->GetChisquare(); | |
834 | fChi2[pW][1]->SetBinContent(1,chi2); | |
47426051 | 835 | //fChi2[pW][1]->SetBinError(1,0.); |
ce4a88f5 | 836 | } |
837 | ||
47426051 | 838 | if(fPlotResults && !(fUsePhiWeights||fUsePtWeights||fUseEtaWeights)) // to be improved (plot also the plot when particle weights are used) |
ee0860e8 | 839 | { |
47426051 | 840 | // set ranges: // to be improved (there is certainly a better way to implement this) |
97ab16dd | 841 | Int_t firstNonEmptyBin = fqDistribution[pW]->FindFirstBinAbove(0); |
842 | Double_t lowRange = fqDistribution[pW]->GetBinLowEdge(firstNonEmptyBin); | |
843 | Int_t lastNonEmptyBin = fqDistribution[pW]->FindLastBinAbove(0); | |
844 | Double_t upperRange = fqDistribution[pW]->GetBinLowEdge(lastNonEmptyBin+10); | |
845 | (fqDistribution[pW]->GetXaxis())->SetRangeUser(lowRange,upperRange); | |
846 | ||
847 | if(s2F == 0) | |
ee0860e8 | 848 | { |
47426051 | 849 | // to be improved (there is certainly a better way to implement this) |
ee0860e8 | 850 | fqDistribution[pW]->SetFillColor(16); |
851 | fqDistribution[pW]->SetTitle("Fitted q-distribution"); | |
852 | fqDistribution[pW]->Draw(""); | |
97ab16dd | 853 | fLegend->AddEntry(fqDistribution[pW],"q-distribution","f"); |
854 | TF1 *fittingFunTemp = (TF1*)fittingFun->Clone("fittingFunTemp"); | |
855 | fittingFunTemp->SetLineColor(4); // 4 = blue color | |
856 | fittingFunTemp->Draw("SAME"); | |
857 | fLegend->AddEntry("fittingFunTemp","#sigma^{2} fixed","l"); | |
858 | fLegend->Draw("SAME"); | |
ee0860e8 | 859 | } else |
97ab16dd | 860 | { |
861 | fittingFun->SetLineColor(2); // 2 = red color | |
862 | fittingFun->Draw("SAME"); | |
863 | fLegend->AddEntry("fittingFun","#sigma^{2} fitted","l"); | |
ee0860e8 | 864 | } |
865 | } // end of if(fPlotResults) | |
866 | ||
ce4a88f5 | 867 | } // end of void AliFlowAnalysisWithFittingQDistribution::DoFit(Bool_t useParticleWeights) |
868 | ||
869 | ||
870 | //================================================================================================================================ | |
871 | ||
872 | ||
97ab16dd | 873 | void AliFlowAnalysisWithFittingQDistribution::FillCommonHistResultsIntFlow(Bool_t useParticleWeights, Bool_t sigma2Fitted) |
ce4a88f5 | 874 | { |
875 | // fill in AliFlowCommonHistResults histograms relevant for 'NONAME' integrated flow (to be improved (name)) | |
876 | ||
877 | // shortcuts for the flags: | |
47426051 | 878 | Int_t pW = (Int_t)(useParticleWeights); // particle weights not used (0) or used (1) |
97ab16dd | 879 | Int_t s2F = (Int_t)(sigma2Fitted); // 0 = sigma^2 not fitted (but fixed to 0.5), 1 = sigma^2 fitted |
ce4a88f5 | 880 | |
97ab16dd | 881 | if(!fIntFlow[pW][s2F]) |
ce4a88f5 | 882 | { |
97ab16dd | 883 | cout<<"WARNING: fIntFlow[pW][s2F] is NULL in AFAWFQD::FCHRIF() !!!!"<<endl; |
884 | cout<<"pW = "<<pW<<endl; | |
885 | cout<<"s2F = "<<s2F<<endl; | |
ce4a88f5 | 886 | exit(0); |
887 | } | |
888 | ||
ee0860e8 | 889 | if(!fSumOfParticleWeights[pW]) |
890 | { | |
891 | cout<<"WARNING: fSumOfParticleWeights[pW] is NULL in AFAWFQD::FCHRIF() !!!!"<<endl; | |
892 | cout<<"pW = "<<pW<<endl; | |
893 | exit(0); | |
894 | } | |
895 | ||
ce4a88f5 | 896 | if(!(fCommonHistsResults)) |
897 | { | |
898 | cout<<"WARNING: fCommonHistsResults is NULL in AFAWFQD::FCHRIF() !!!!"<<endl; | |
899 | exit(0); | |
900 | } | |
901 | ||
ee0860e8 | 902 | // fill integrated flow: |
97ab16dd | 903 | Double_t v = fIntFlow[pW][s2F]->GetBinContent(1); |
904 | Double_t vError = fIntFlow[pW][s2F]->GetBinError(1); | |
ce4a88f5 | 905 | |
906 | fCommonHistsResults->FillIntegratedFlow(v,vError); | |
907 | ||
97ab16dd | 908 | // fill chi (this chi stands for resolution, not to be confused with chi2 used before): |
ee0860e8 | 909 | Double_t AvM = fSumOfParticleWeights[pW]->GetMean(1); |
910 | Double_t chi = AvM*pow(v,2); | |
911 | if(chi>=0) | |
912 | { | |
913 | fCommonHistsResults->FillChi(pow(chi,0.5)); | |
914 | fCommonHistsResults->FillChiRP(pow(chi,0.5)); | |
915 | } | |
916 | ||
ce4a88f5 | 917 | } // end of void AliFlowAnalysisWithFittingQDistribution::FillCommonHistResultsIntFlow(Bool_t useParticleWeights, Bool_t sigma2NotFixed) |
918 | ||
919 | ||
920 | //================================================================================================================================ | |
921 | ||
922 | ||
923 | void AliFlowAnalysisWithFittingQDistribution::PrintFinalResultsForIntegratedFlow() | |
924 | { | |
925 | // print the final results for integrated flow on the screen | |
926 | ||
97ab16dd | 927 | // shortcuts: pW = particle weights |
928 | // s2F = sigma^2 fitted | |
ce4a88f5 | 929 | |
930 | for(Int_t pW=0;pW<1+(Int_t)(fUsePhiWeights||fUsePtWeights||fUseEtaWeights);pW++) | |
931 | { | |
932 | if(!fSumOfParticleWeights[pW]) | |
933 | { | |
934 | cout<<"WARNING: fSumOfParticleWeights[pW] is NULL in AFAWFQD::FCHRIF() !!!!"<<endl; | |
935 | cout<<"pW = "<<pW<<endl; | |
936 | exit(0); | |
937 | } | |
97ab16dd | 938 | for(Int_t s2F=0;s2F<2;s2F++) |
ce4a88f5 | 939 | { |
97ab16dd | 940 | if(!fIntFlow[pW][s2F]) |
ce4a88f5 | 941 | { |
97ab16dd | 942 | cout<<"WARNING: fIntFlow[pW][s2F] is NULL in AFAWFQD::FCHRIF() !!!!"<<endl; |
943 | cout<<"pW = "<<pW<<endl; | |
944 | cout<<"s2F = "<<s2F<<endl; | |
ce4a88f5 | 945 | exit(0); |
946 | } | |
947 | } | |
948 | } | |
949 | ||
950 | if(!(fCommonHistsResults)) | |
951 | { | |
952 | cout<<"WARNING: fCommonHistsResults is NULL in AFAWFQD::FCHRIF() !!!!"<<endl; | |
953 | exit(0); | |
954 | } | |
955 | ||
956 | // shortcut for the harmonic: | |
957 | Int_t n = (Int_t)(fCommonHists->GetHarmonic())->GetBinContent(1); | |
958 | ||
959 | // printing: | |
960 | cout<<" "<<endl; | |
961 | cout<<"***************************************"<<endl; | |
962 | cout<<"***************************************"<<endl; | |
963 | cout<<" integrated flow by fitting "<<endl; | |
964 | cout<<" q-distribution: "<<endl; | |
965 | if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights) | |
966 | { | |
967 | cout<<" (with weights) "<<endl; | |
968 | } else | |
969 | { | |
970 | cout<<" (without weights) "<<endl; | |
971 | } | |
972 | cout<<endl; | |
973 | ||
974 | if(fUsePhiWeights||fUsePtWeights||fUseEtaWeights) | |
975 | { | |
97ab16dd | 976 | cout<<"1.) sigma^2 not fitted: "<<endl; |
977 | cout<<" v_"<<n<<"{FQD} = "<<fIntFlow[1][0]->GetBinContent(1)<<" +/- "<<fIntFlow[1][0]->GetBinError(1)<<endl; | |
978 | cout<<" sigma^2 = 0.5 +/- 0 "<<endl; | |
979 | cout<<" chi^2 = "<<fChi2[1][0]->GetBinContent(1)<<" (Minuit)"<<endl; | |
980 | cout<<" "<<endl; | |
981 | cout<<"2.) sigma^2 fitted: "<<endl; | |
982 | cout<<" v_"<<n<<"{FQD} = "<<fIntFlow[1][1]->GetBinContent(1)<<" +/- "<<fIntFlow[1][1]->GetBinError(1)<<endl; | |
983 | cout<<" sigma^2 = "<<fSigma2[1][1]->GetBinContent(1)<<" +/- "<<fSigma2[1][1]->GetBinError(1)<<endl; | |
984 | cout<<" chi^2 = "<<fChi2[1][1]->GetBinContent(1)<<" (Minuit)"<<endl; | |
ce4a88f5 | 985 | cout<<" "<<endl; |
986 | cout<<" nEvts = "<<fSumOfParticleWeights[1]->GetEntries()<<", AvM = "<<fSumOfParticleWeights[1]->GetMean()<<endl; | |
987 | cout<<" "<<endl; | |
988 | } else | |
989 | { | |
97ab16dd | 990 | cout<<"1.) sigma^2 not fitted: "<<endl; |
991 | cout<<endl; | |
992 | cout<<" v_"<<n<<"{FQD} = "<<fIntFlow[0][0]->GetBinContent(1)<<" +/- "<<fIntFlow[0][0]->GetBinError(1)<<endl; | |
993 | cout<<" sigma^2 = 0.5 +/- 0 "<<endl; | |
994 | cout<<" chi^2 = "<<fChi2[0][0]->GetBinContent(1)<<" (Minuit)"<<endl; | |
995 | cout<<" "<<endl; | |
996 | cout<<"2.) sigma^2 fitted: "<<endl; | |
997 | cout<<endl; | |
998 | cout<<" v_"<<n<<"{FQD} = "<<fIntFlow[0][1]->GetBinContent(1)<<" +/- "<<fIntFlow[0][1]->GetBinError(1)<<endl; | |
999 | cout<<" sigma^2 = "<<fSigma2[0][1]->GetBinContent(1)<<" +/- "<<fSigma2[0][1]->GetBinError(1)<<endl; | |
1000 | cout<<" chi^2 = "<<fChi2[0][1]->GetBinContent(1)<<" (Minuit)"<<endl; | |
ce4a88f5 | 1001 | cout<<" "<<endl; |
1002 | cout<<" nEvts = "<<fSumOfParticleWeights[0]->GetEntries()<<", AvM = "<<fSumOfParticleWeights[0]->GetMean()<<endl; | |
1003 | cout<<" "<<endl; | |
1004 | } | |
1005 | ||
1006 | cout<<"***************************************"<<endl; | |
1007 | cout<<"***************************************"<<endl; | |
97ab16dd | 1008 | cout<<endl; |
1009 | ||
ce4a88f5 | 1010 | } // end of void AliFlowAnalysisWithFittingQDistribution::PrintFinalResultsForIntegratedFlow() |
1011 | ||
1012 | ||
1013 | //================================================================================================================================ | |
ee0860e8 | 1014 | |
1015 | ||
1016 | void AliFlowAnalysisWithFittingQDistribution::StoreFittingParameters() | |
1017 | { | |
1018 | // store fitting parameters in profile fFittingParameters | |
1019 | ||
1020 | // Binning of fFittingParameters is organized as follows: | |
1021 | // 1st bin: fTreshold | |
1022 | // 2nd bin: fvStart | |
1023 | // 3rd bin: fvMin | |
1024 | // 4th bin: fvMax | |
1025 | // 5th bin: fSigma2Start | |
1026 | // 6th bin: fSigma2Min | |
1027 | // 7th bin: fSigma2Max | |
47426051 | 1028 | // 8th bin: fPlotResults |
ee0860e8 | 1029 | |
1030 | if(!fFittingParameters) | |
1031 | { | |
1032 | cout<<"WARNING: fFittingParameters is NULL in AFAWFQD::SFP() !!!!"<<endl; | |
1033 | exit(0); | |
1034 | } | |
1035 | ||
1036 | fFittingParameters->Reset(); | |
1037 | fFittingParameters->Fill(0.5,fTreshold); | |
1038 | fFittingParameters->Fill(1.5,fvStart); | |
1039 | fFittingParameters->Fill(2.5,fvMin); | |
1040 | fFittingParameters->Fill(3.5,fvMax); | |
1041 | fFittingParameters->Fill(4.5,fSigma2Start); | |
1042 | fFittingParameters->Fill(5.5,fSigma2Min); | |
1043 | fFittingParameters->Fill(6.5,fSigma2Max); | |
47426051 | 1044 | fFittingParameters->Fill(7.5,(Int_t)fPlotResults); |
ee0860e8 | 1045 | |
1046 | } // end of void AliFlowAnalysisWithFittingQDistribution::StoreFittingParameters() | |
1047 | ||
1048 | ||
1049 | //================================================================================================================================ | |
1050 | ||
1051 | ||
1052 | void AliFlowAnalysisWithFittingQDistribution::AccessFittingParameters() | |
1053 | { | |
1054 | // access fitting parameters: | |
1055 | ||
1056 | if(!fFittingParameters) | |
1057 | { | |
1058 | cout<<"WARNING: fFittingParameters is NULL in AFAWFQD::AFP() !!!!"<<endl; | |
1059 | exit(0); | |
1060 | } | |
1061 | ||
1062 | fTreshold = fFittingParameters->GetBinContent(1); | |
1063 | fvStart = fFittingParameters->GetBinContent(2); | |
1064 | fvMin = fFittingParameters->GetBinContent(3); | |
1065 | fvMax = fFittingParameters->GetBinContent(4); | |
1066 | fSigma2Start = fFittingParameters->GetBinContent(5); | |
1067 | fSigma2Min = fFittingParameters->GetBinContent(6); | |
1068 | fSigma2Max = fFittingParameters->GetBinContent(7); | |
1069 | fPlotResults = (Bool_t) fFittingParameters->GetBinContent(8); | |
1070 | ||
1071 | } // end of void AliFlowAnalysisWithFittingQDistribution::AccessFittingParameters() |