44 #include "TGraphErrors.h"
45 #include "TGraphAsymmErrors.h"
52 #include "TVirtualFitter.h"
57 #include "TVirtualFitter.h"
58 #include "TFitResultPtr.h"
59 #include "Minuit2/Minuit2Minimizer.h"
60 #include "Math/Functor.h"
62 #include "AliUnfolding.h"
63 #include "AliAnaChargedJetResponseMaker.h"
67 #include "RooUnfold.h"
68 #include "RooUnfoldResponse.h"
69 #include "RooUnfoldSvd.h"
70 #include "RooUnfoldBayes.h"
71 #include "TSVDUnfold.h"
77 fResponseMaker (new AliAnaChargedJetResponseMaker()),
83 fPower (new TF1(
"fPower",
"[0]*TMath::Power(x,-([1]))",0.,300.)),
88 fRefreshInput (kTRUE),
89 fOutputFileName (
"UnfoldedSpectra.root"),
91 fCentralityArray (0x0),
92 fMergeBinsArray (0x0),
93 fCentralityWeights (0x0),
96 fMergeWithWeight (1.),
97 fDetectorResponse (0x0),
102 fBayesianIterOut (4),
103 fBayesianSmoothIn (0.),
104 fBayesianSmoothOut (0.),
105 fAvoidRoundingError (kFALSE),
106 fUnfoldingAlgorithm (kChi2),
107 fPrior (kPriorMeasured),
111 fBinsTruePrior (0x0),
118 fNormalizeSpectra (kFALSE),
119 fSmoothenPrior (kFALSE),
123 fSmoothenCounts (kTRUE),
125 fRawInputProvided (kFALSE),
126 fEventPlaneRes (.63),
127 fUseDetectorResponse(kTRUE),
128 fUseDptResponse (kTRUE),
130 fDphiUnfolding (kTRUE),
131 fDphiDptUnfolding (kFALSE),
133 fTitleFontSize (-999.),
134 fRMSSpectrumIn (0x0),
135 fRMSSpectrumOut (0x0),
138 fDeltaPtDeltaPhi (0x0),
139 fJetPtDeltaPhi (0x0),
146 fFullResponseIn (0x0),
147 fFullResponseOut (0x0),
149 fSubdueError (kTRUE),
150 fUnfoldedSpectrumIn (0x0),
151 fUnfoldedSpectrumOut(0x0) {
152 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
153 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
155 fResponseMaker->SetRMMergeWeightFunction(
new TF1(
"weightFunction",
"x*TMath::Power(1.+(1./(8.*0.9))*x, -8.)", 0, 200));
161 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
162 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
178 printf(
" AliJetFlowTools::Make() Fatal error \n - couldn't prepare for unfolding ! \n");
199 measuredJetSpectrumIn =
reinterpret_cast<TH1D*
>(
Bootstrap(measuredJetSpectrumIn, kFALSE));
200 measuredJetSpectrumOut =
reinterpret_cast<TH1D*
>(
Bootstrap(measuredJetSpectrumOut, kFALSE));
225 printf(
" > No response, exiting ! < \n" );
239 TH1D* kinematicEfficiencyIn = resizedResponseIn->ProjectionX();
240 kinematicEfficiencyIn->SetNameTitle(
"kin_eff_IN",
"kin_eff_IN");
241 TH1D* kinematicEfficiencyOut = resizedResponseOut->ProjectionX();
242 kinematicEfficiencyOut->SetNameTitle(
"kin_eff_OUT",
"kin_eff_OUT");
244 for(
Int_t i(0); i < kinematicEfficiencyOut->GetXaxis()->GetNbins(); i++) {
245 kinematicEfficiencyIn->SetBinError(1+i, 0.);
246 kinematicEfficiencyOut->SetBinError(1+i, 0.);
248 TH1D* jetFindingEfficiency(0x0);
251 jetFindingEfficiency->SetNameTitle(Form(
"%s_coarse", jetFindingEfficiency->GetName()), Form(
"%s_coarse", jetFindingEfficiency->GetName()));
255 TH1D* unfoldedJetSpectrumIn(0x0);
256 TH1D* unfoldedJetSpectrumOut(0x0);
258 TDirectoryFile* dirIn =
new TDirectoryFile(Form(
"InPlane___%s",
fActiveString.Data()), Form(
"InPlane___%s",
fActiveString.Data()));
262 measuredJetSpectrumIn,
264 kinematicEfficiencyIn,
265 measuredJetSpectrumTrueBinsIn,
267 jetFindingEfficiency);
268 resizedResponseIn->SetNameTitle(
"ResponseMatrixIn",
"response matrix in plane");
269 resizedResponseIn->SetXTitle(
"p_{T, jet}^{true} (GeV/#it{c})");
270 resizedResponseIn->SetYTitle(
"p_{T, jet}^{rec} (GeV/#it{c})");
271 resizedResponseIn =
ProtectHeap(resizedResponseIn);
272 resizedResponseIn->Write();
273 kinematicEfficiencyIn->SetNameTitle(
"KinematicEfficiencyIn",
"Kinematic efficiency, in plane");
274 kinematicEfficiencyIn =
ProtectHeap(kinematicEfficiencyIn);
275 kinematicEfficiencyIn->Write();
281 fSpectrumIn->SetNameTitle(
"[ORIG]JetSpectrum",
"[INPUT] Jet spectrum, in plane");
283 fDptInDist->SetNameTitle(
"[ORIG]DeltaPt",
"#delta p_{T} distribution, in plane");
285 fDptIn->SetNameTitle(
"[ORIG]DeltaPtMatrix",
"#delta p_{T} matrix, in plane");
287 fFullResponseIn->SetNameTitle(
"ResponseMatrix",
"Response matrix, in plane");
292 TDirectoryFile* dirOut =
new TDirectoryFile(Form(
"OutOfPlane___%s",
fActiveString.Data()), Form(
"OutOfPlane___%s",
fActiveString.Data()));
296 measuredJetSpectrumOut,
298 kinematicEfficiencyOut,
299 measuredJetSpectrumTrueBinsOut,
301 jetFindingEfficiency);
302 resizedResponseOut->SetNameTitle(
"ResponseMatrixOut",
"response matrix in plane");
303 resizedResponseOut->SetXTitle(
"p_{T, jet}^{true} (GeV/#it{c})");
304 resizedResponseOut->SetYTitle(
"p_{T, jet}^{rec} (GeV/#it{c})");
305 resizedResponseOut =
ProtectHeap(resizedResponseOut);
306 resizedResponseOut->Write();
307 kinematicEfficiencyOut->SetNameTitle(
"KinematicEfficiencyOut",
"Kinematic efficiency, Out plane");
308 kinematicEfficiencyOut =
ProtectHeap(kinematicEfficiencyOut);
309 kinematicEfficiencyOut->Write();
313 if(jetFindingEfficiency) jetFindingEfficiency->Write();
316 fSpectrumOut->SetNameTitle(
"[ORIG]JetSpectrum",
"[INPUT]Jet spectrum, Out plane");
318 fDptOutDist->SetNameTitle(
"[ORIG]DeltaPt",
"#delta p_{T} distribution, Out plane");
320 fDptOut->SetNameTitle(
"[ORIG]DeltaPtMatrix",
"#delta p_{T} matrix, Out plane");
322 fFullResponseOut->SetNameTitle(
"[ORIG]ResponseMatrix",
"Response matrix, Out plane");
328 if(unfoldedJetSpectrumIn && unfoldedJetSpectrumOut && unfoldedJetSpectrumIn && unfoldedJetSpectrumOut) {
329 TGraphErrors* ratio(
GetRatio((
TH1D*)unfoldedJetSpectrumIn->Clone(
"unfoldedLocal_in"), (
TH1D*)unfoldedJetSpectrumOut->Clone(
"unfoldedLocal_out")));
331 ratio->SetNameTitle(
"RatioInOutPlane",
"Ratio in plane, out of plane jet spectrum");
332 ratio->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
333 ratio->GetYaxis()->SetTitle(
"yield IN / yield OUT");
338 for(
Int_t i(0); i < ratio->GetXaxis()->GetNbins(); i++) {
339 if(unfoldedJetSpectrumIn->GetBinError(i+1) > 0)
fRMSSpectrumIn->Fill(
fRMSSpectrumIn->GetBinCenter(i+1), unfoldedJetSpectrumIn->GetBinContent(i+1), 1./TMath::Power(unfoldedJetSpectrumIn->GetBinError(i+1), 2.));
340 if(unfoldedJetSpectrumOut->GetBinError(i+1) > 0)
fRMSSpectrumOut->Fill(
fRMSSpectrumOut->GetBinCenter(i+1), unfoldedJetSpectrumOut->GetBinContent(i+1), 1./TMath::Power(unfoldedJetSpectrumOut->GetBinError(i+1), 2.));
341 if(unfoldedJetSpectrumOut->GetBinContent(i+1) > 0)
fRMSRatio->Fill(
fRMSSpectrumIn->GetBinCenter(i+1), unfoldedJetSpectrumIn->GetBinContent(i+1) / unfoldedJetSpectrumOut->GetBinContent(i+1));
346 v2->SetNameTitle(
"v2",
"v_{2} from different in, out of plane yield");
347 v2->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
348 v2->GetYaxis()->SetTitle(
"v_{2}");
352 }
else if (unfoldedJetSpectrumOut && unfoldedJetSpectrumIn) {
355 ratio->SetNameTitle(
"[NC]RatioInOutPlane",
"[NC]Ratio in plane, out of plane jet spectrum");
356 ratio->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
357 ratio->GetYaxis()->SetTitle(
"yield IN / yield OUT");
363 v2->SetNameTitle(
"v2",
"v_{2} from different in, out of plane yield");
364 v2->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
365 v2->GetYaxis()->SetTitle(
"v_{2}");
372 unfoldedJetSpectrumIn->Sumw2();
374 unfoldedJetSpectrumIn->Write();
375 unfoldedJetSpectrumOut->Sumw2();
377 unfoldedJetSpectrumOut->Write();
380 SaveConfiguration(unfoldedJetSpectrumIn ? kTRUE : kFALSE, unfoldedJetSpectrumOut ? kTRUE : kFALSE);
381 TH1D* unfoldedJetSpectrumInForSub((
TH1D*)unfoldedJetSpectrumIn->Clone(
"forSubIn"));
382 TH1D* unfoldedJetSpectrumOutForSub((
TH1D*)unfoldedJetSpectrumOut->Clone(
"forSubOut"));
383 unfoldedJetSpectrumInForSub->Add(unfoldedJetSpectrumOutForSub, -1.);
384 unfoldedJetSpectrumInForSub=
ProtectHeap(unfoldedJetSpectrumInForSub);
385 unfoldedJetSpectrumInForSub->Write();
390 const TH1D* measuredJetSpectrum,
391 const TH2D* resizedResponse,
392 const TH1D* kinematicEfficiency,
393 const TH1D* measuredJetSpectrumTrueBins,
395 const TH1D* jetFindingEfficiency)
397 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
398 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
409 TH1D* clone((
TH1D*)measuredJetSpectrum->Clone(
"clone"));
410 clone->SetNameTitle(Form(
"MeasuredJetSpectrum%s", suffix.Data()), Form(
"measuredJetSpectrum %s", suffix.Data()));
415 return (this->*myFunction)( measuredJetSpectrum, resizedResponse, kinematicEfficiency, measuredJetSpectrumTrueBins,
suffix, jetFindingEfficiency);
419 const TH1D* measuredJetSpectrum,
420 const TH2D* resizedResponse,
421 const TH1D* kinematicEfficiency,
422 const TH1D* measuredJetSpectrumTrueBins,
424 const TH1D* jetFindingEfficiency)
426 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
427 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
434 AliUnfolding::SetUnfoldingMethod(AliUnfolding::kChi2Minimization);
435 if(!strcmp(
"in", suffix.Data())) AliUnfolding::SetChi2Regularization(AliUnfolding::kLogLog,
fBetaIn);
436 else if(!strcmp(
"out", suffix.Data())) AliUnfolding::SetChi2Regularization(AliUnfolding::kLogLog,
fBetaOut);
437 if(!strcmp(
"prior_in", suffix.Data())) AliUnfolding::SetChi2Regularization(AliUnfolding::kLogLog,
fBetaIn);
438 else if(!strcmp(
"prior_out", suffix.Data())) AliUnfolding::SetChi2Regularization(AliUnfolding::kLogLog,
fBetaOut);
446 TH1D *measuredJetSpectrumLocal = (
TH1D*)measuredJetSpectrum->Clone(Form(
"measuredJetSpectrumLocal_%s", suffix.Data()));
448 TH1D *unfoldedLocal(
new TH1D(Form(
"unfoldedLocal_%s", suffix.Data()), Form(
"unfoldedLocal_%s", suffix.Data()),
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
451 TH2D* resizedResponseLocal = (
TH2D*)resizedResponse->Clone(Form(
"resizedResponseLocal_%s", suffix.Data()));
452 TH1D* kinematicEfficiencyLocal = (
TH1D*)kinematicEfficiency->Clone(Form(
"kinematicEfficiencyLocal_%s", suffix.Data()));
455 TH1D *priorLocal = (
TH1D*)measuredJetSpectrumTrueBins->Clone(Form(
"priorLocal_%s", suffix.Data()));
460 Int_t status(-1), i(0);
461 while(status < 0 && i < 100) {
464 if (i > 0) priorLocal = (
TH1D*)unfoldedLocal->Clone(Form(
"priorLocal_%s_%i", suffix.Data(), i));
465 status = AliUnfolding::Unfold(
466 resizedResponseLocal,
467 kinematicEfficiencyLocal,
468 measuredJetSpectrumLocal,
476 if(status == 0 && gMinuit->fISW[1] == 3) {
478 TVirtualFitter *
fitter(TVirtualFitter::GetFitter());
479 if(gMinuit) gMinuit->Command(
"SET COV");
480 TMatrixD covarianceMatrix(
fBinsTrue->GetSize()-1,
fBinsTrue->GetSize()-1, fitter->GetCovarianceMatrix());
483 hPearson =
new TH2D(*pearson);
484 hPearson->SetNameTitle(Form(
"PearsonCoefficients_%s", suffix.Data()), Form(
"Pearson coefficients, %s plane", suffix.Data()));
491 TH1D *foldedLocal(
fResponseMaker->MultiplyResponseGenerated(unfoldedLocal, resizedResponseLocal,kinematicEfficiencyLocal));
492 foldedLocal->SetNameTitle(Form(
"RefoldedSpectrum_%s", suffix.Data()), Form(
"Refolded jet spectrum, %s plane", suffix.Data()));
493 unfoldedLocal->SetNameTitle(Form(
"UnfoldedSpectrum_%s", suffix.Data()), Form(
"Unfolded jet spectrum, %s plane", suffix.Data()));
496 ratio->SetNameTitle(
"RatioRefoldedMeasured", Form(
"Ratio measured, re-folded %s ", suffix.Data()));
497 ratio->GetYaxis()->SetTitle(
"ratio measured / re-folded");
504 measuredJetSpectrumLocal->SetNameTitle(Form(
"InputSpectrum_%s", suffix.Data()), Form(
"InputSpectrum_%s", suffix.Data()));
505 measuredJetSpectrumLocal =
ProtectHeap(measuredJetSpectrumLocal);
506 measuredJetSpectrumLocal->Write();
508 resizedResponseLocal =
ProtectHeap(resizedResponseLocal);
509 resizedResponseLocal->Write();
512 if(jetFindingEfficiency) unfoldedLocal->Divide(jetFindingEfficiency);
513 unfoldedLocal->Write();
516 foldedLocal->Write();
522 TH1F* fitStatus(
new TH1F(Form(
"fitStatus_%s_%s",
fActiveString.Data(), suffix.Data()), Form(
"fitStatus_%s_%s",
fActiveString.Data(), suffix.Data()), 4, -0.5, 3.5));
523 fitStatus->SetBinContent(1, AliUnfolding::fChi2FromFit);
524 fitStatus->GetXaxis()->SetBinLabel(1,
"fChi2FromFit");
525 fitStatus->SetBinContent(2, AliUnfolding::fPenaltyVal);
526 fitStatus->GetXaxis()->SetBinLabel(2,
"fPenaltyVal");
528 fitStatus->GetXaxis()->SetBinLabel(3,
"DOF");
529 fitStatus->SetBinContent(4, (!strcmp(suffix.Data(),
"in")) ?
fBetaIn :
fBetaOut);
530 fitStatus->GetXaxis()->SetBinLabel(4, (!strcmp(suffix.Data(),
"in")) ?
"fBetaIn" :
"fBetaOut");
533 return unfoldedLocal;
537 const TH1D* measuredJetSpectrum,
538 const TH2D* resizedResponse,
539 const TH1D* kinematicEfficiency,
540 const TH1D* measuredJetSpectrumTrueBins,
542 const TH1D* jetFindingEfficiency)
544 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
545 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
551 measuredJetSpectrumTrueBins,
553 jetFindingEfficiency));
555 printf(
" > couldn't find prior ! < \n");
557 }
else printf(
" 1) retrieved prior \n");
564 TH1D *measuredJetSpectrumLocal((
TH1D*)measuredJetSpectrum->Clone(Form(
"jets_%s", suffix.Data())));
566 TH2D *resizedResponseLocal((
TH2D*)resizedResponse->Clone(Form(
"resizedResponseLocal_%s", suffix.Data())));
569 TH2D *resizedResponseLocalNorm((
TH2D*)resizedResponse->Clone(Form(
"resizedResponseLocalNorm_%s", suffix.Data())));
570 resizedResponseLocalNorm =
NormalizeTH2D(resizedResponseLocalNorm);
572 TH1D *kinematicEfficiencyLocal((
TH1D*)kinematicEfficiency->Clone(Form(
"kinematicEfficiency_%s", suffix.Data())));
574 TH1D *unfoldedLocalSVD(0x0);
575 TH1D *foldedLocalSVD(0x0);
576 cout <<
" 2) setup necessary input " << endl;
578 RooUnfold::ErrorTreatment errorTreatment = (
fSVDToy) ? RooUnfold::kCovToy : RooUnfold::kCovariance;
579 cout <<
" step 3) configured routine " << endl;
583 TH2* responseMatrixLocalTransposePrior(
fResponseMaker->GetTransposeResponsMatrix(resizedResponseLocal));
584 responseMatrixLocalTransposePrior->SetNameTitle(Form(
"prior_%s_%s", responseMatrixLocalTransposePrior->GetName(), suffix.Data()),Form(
"prior_%s_%s", responseMatrixLocalTransposePrior->GetName(), suffix.Data()));
587 responseMatrixLocalTransposePrior =
fResponseMaker->NormalizeResponsMatrixYaxisWithPrior(responseMatrixLocalTransposePrior, priorLocal);
588 cout <<
" 4) retrieved first transpose matrix " << endl;
591 RooUnfoldResponse responseSVD(0, 0, responseMatrixLocalTransposePrior, Form(
"respCombinedSVD_%s", suffix.Data()), Form(
"respCombinedSVD_%s", suffix.Data()));
592 cout <<
" 5) retrieved roo unfold response object " << endl;
595 RooUnfoldSvd unfoldSVD(&responseSVD, measuredJetSpectrumLocal, (!strcmp(suffix.Data(),
"in")) ?
fSVDRegIn :
fSVDRegOut);
596 unfoldedLocalSVD = (
TH1D*)unfoldSVD.Hreco(errorTreatment);
598 unfoldedLocalSVD->Divide(kinematicEfficiencyLocal);
601 TMatrixD covarianceMatrix = unfoldSVD.Ereco(errorTreatment);
605 hPearson =
new TH2D(*pearson);
607 hPearson->SetNameTitle(Form(
"PearsonCoefficients_%s", suffix.Data()), Form(
"Pearson coefficients_%s", suffix.Data()));
614 TSVDUnfold* svdUnfold(unfoldSVD.Impl());
615 TH1* hSVal(svdUnfold->GetSV());
616 TH1D* hdi(svdUnfold->GetD());
617 hSVal->SetNameTitle(
"SingularValuesOfAC",
"Singular values of AC^{-1}");
618 hSVal->SetXTitle(
"singular values");
620 hdi->SetNameTitle(
"dVector",
"d vector after orthogonal transformation");
621 hdi->SetXTitle(
"|d_{i}^{kreg}|");
623 cout <<
" plotted singular values and d_i vector " << endl;
626 foldedLocalSVD =
fResponseMaker->MultiplyResponseGenerated(unfoldedLocalSVD, resizedResponseLocalNorm, kinematicEfficiencyLocal);
627 TGraphErrors* ratio(
GetRatio(measuredJetSpectrumLocal, foldedLocalSVD,
"ratio measured / re-folded", kTRUE));
628 ratio->SetNameTitle(Form(
"RatioRefoldedMeasured_%s",
fActiveString.Data()), Form(
"Ratio measured / re-folded %s",
fActiveString.Data()));
629 ratio->GetXaxis()->SetTitle(
"p_{t}^{rec, rec} [GeV/ c]");
630 ratio->GetYaxis()->SetTitle(
"ratio measured / re-folded");
632 cout <<
" 7) refolded the unfolded spectrum " << endl;
635 measuredJetSpectrumLocal->SetNameTitle(Form(
"InputSpectrum_%s", suffix.Data()), Form(
"input spectrum (measured) %s", suffix.Data()));
636 measuredJetSpectrumLocal =
ProtectHeap(measuredJetSpectrumLocal);
637 measuredJetSpectrumLocal->SetXTitle(
"p_{t}^{rec} [GeV/c]");
638 measuredJetSpectrumLocal->Write();
639 unfoldedLocalSVD->SetNameTitle(Form(
"UnfoldedSpectrum_%s",suffix.Data()), Form(
"unfolded spectrum %s", suffix.Data()));
641 if(jetFindingEfficiency) unfoldedLocalSVD->Divide(jetFindingEfficiency);
642 unfoldedLocalSVD->Write();
643 foldedLocalSVD->SetNameTitle(Form(
"RefoldedSpectrum_%s", suffix.Data()), Form(
"refoldedSpectrum_%s", suffix.Data()));
645 foldedLocalSVD->Write();
648 responseMatrixLocalTransposePrior->SetNameTitle(
"TransposeResponseMatrix",
"Transpose of response matrix, normalize with prior");
649 responseMatrixLocalTransposePrior->SetXTitle(
"p_{T, jet}^{true} [GeV/c]");
650 responseMatrixLocalTransposePrior->SetYTitle(
"p_{T, jet}^{rec} [GeV/c]");
651 responseMatrixLocalTransposePrior->Write();
652 priorLocal->SetNameTitle(
"PriorOriginal",
"Prior, original");
653 priorLocal->SetXTitle(
"p_{t} [GeV/c]");
656 resizedResponseLocalNorm =
ProtectHeap(resizedResponseLocalNorm);
657 resizedResponseLocalNorm->Write();
660 TH1F* fitStatus(
new TH1F(Form(
"fitStatus_%s_%s",
fActiveString.Data(), suffix.Data()), Form(
"fitStatus_%s_%s",
fActiveString.Data(), suffix.Data()), 1, -0.5, 0.5));
662 fitStatus->GetXaxis()->SetBinLabel(1, (!strcmp(suffix.Data(),
"in")) ?
"fSVDRegIn" :
"fSVDRegOut");
665 return unfoldedLocalSVD;
669 const TH1D* measuredJetSpectrum,
670 const TH2D* resizedResponse,
671 const TH1D* kinematicEfficiency,
672 const TH1D* measuredJetSpectrumTrueBins,
674 const TH1D* jetFindingEfficiency)
676 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
677 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
685 AliUnfolding::SetUnfoldingMethod(AliUnfolding::kBayesian);
697 measuredJetSpectrumTrueBins,
699 jetFindingEfficiency));
701 printf(
" > couldn't find prior ! < \n");
703 }
else printf(
" 1) retrieved prior \n");
708 TH1D *measuredJetSpectrumLocal = (
TH1D*)measuredJetSpectrum->Clone(Form(
"measuredJetSpectrumLocal_%s", suffix.Data()));
710 TH1D *unfoldedLocal(
new TH1D(Form(
"unfoldedLocal_%s", suffix.Data()), Form(
"unfoldedLocal_%s", suffix.Data()),
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
713 TH2D* resizedResponseLocal = (
TH2D*)resizedResponse->Clone(Form(
"resizedResponseLocal_%s", suffix.Data()));
714 TH1D* kinematicEfficiencyLocal = (
TH1D*)kinematicEfficiency->Clone(Form(
"kinematicEfficiencyLocal_%s", suffix.Data()));
717 Int_t status(-1), i(0);
718 while(status < 0 && i < 100) {
721 if (i > 0) priorLocal = (
TH1D*)unfoldedLocal->Clone(Form(
"priorLocal_%s_%i", suffix.Data(), i));
722 status = AliUnfolding::Unfold(
723 resizedResponseLocal,
724 kinematicEfficiencyLocal,
725 measuredJetSpectrumLocal,
733 if(status == 0 && gMinuit->fISW[1] == 3) {
735 TVirtualFitter *
fitter(TVirtualFitter::GetFitter());
736 if(gMinuit) gMinuit->Command(
"SET COV");
737 TMatrixD covarianceMatrix(
fBinsTrue->GetSize()-1,
fBinsTrue->GetSize()-1, fitter->GetCovarianceMatrix());
740 hPearson=
new TH2D(*pearson);
741 hPearson->SetNameTitle(Form(
"PearsonCoefficients_%s", suffix.Data()), Form(
"Pearson coefficients, %s plane", suffix.Data()));
748 TH1D *foldedLocal(
fResponseMaker->MultiplyResponseGenerated(unfoldedLocal, resizedResponseLocal,kinematicEfficiencyLocal));
749 foldedLocal->SetNameTitle(Form(
"RefoldedSpectrum_%s", suffix.Data()), Form(
"Refolded jet spectrum, %s plane", suffix.Data()));
750 unfoldedLocal->SetNameTitle(Form(
"UnfoldedSpectrum_%s", suffix.Data()), Form(
"Unfolded jet spectrum, %s plane", suffix.Data()));
753 ratio->SetNameTitle(
"RatioRefoldedMeasured", Form(
"Ratio measured, re-folded %s ", suffix.Data()));
754 ratio->GetYaxis()->SetTitle(
"ratio measured / re-folded");
761 measuredJetSpectrumLocal->SetNameTitle(Form(
"InputSpectrum_%s", suffix.Data()), Form(
"InputSpectrum_%s", suffix.Data()));
762 measuredJetSpectrumLocal =
ProtectHeap(measuredJetSpectrumLocal);
763 measuredJetSpectrumLocal->Write();
765 resizedResponseLocal =
ProtectHeap(resizedResponseLocal);
766 resizedResponseLocal->Write();
769 if(jetFindingEfficiency) unfoldedLocal->Divide(jetFindingEfficiency);
770 unfoldedLocal->Write();
773 foldedLocal->Write();
779 TH1F* fitStatus(
new TH1F(Form(
"fitStatus_%s_%s",
fActiveString.Data(), suffix.Data()), Form(
"fitStatus_%s_%s",
fActiveString.Data(), suffix.Data()), 4, -0.5, 3.5));
780 fitStatus->SetBinContent(1, AliUnfolding::fChi2FromFit);
781 fitStatus->GetXaxis()->SetBinLabel(1,
"fChi2FromFit");
782 fitStatus->SetBinContent(2, AliUnfolding::fPenaltyVal);
783 fitStatus->GetXaxis()->SetBinLabel(2,
"fPenaltyVal");
785 fitStatus->GetXaxis()->SetBinLabel(3,
"DOF");
786 fitStatus->SetBinContent(4, (!strcmp(suffix.Data(),
"in")) ?
fBetaIn :
fBetaOut);
787 fitStatus->GetXaxis()->SetBinLabel(4, (!strcmp(suffix.Data(),
"in")) ?
"fBetaIn" :
"fBetaOut");
790 return unfoldedLocal;
794 const TH1D* measuredJetSpectrum,
795 const TH2D* resizedResponse,
796 const TH1D* kinematicEfficiency,
797 const TH1D* measuredJetSpectrumTrueBins,
799 const TH1D* jetFindingEfficiency)
801 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
802 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
811 measuredJetSpectrumTrueBins,
813 jetFindingEfficiency));
815 printf(
" > couldn't find prior ! < \n");
817 }
else printf(
" 1) retrieved prior \n");
822 TH1D *measuredJetSpectrumLocal((
TH1D*)measuredJetSpectrum->Clone(Form(
"jets_%s", suffix.Data())));
824 TH2D *resizedResponseLocal((
TH2D*)resizedResponse->Clone(Form(
"resizedResponseLocal_%s", suffix.Data())));
827 TH2D *resizedResponseLocalNorm((
TH2D*)resizedResponse->Clone(Form(
"resizedResponseLocalNorm_%s", suffix.Data())));
828 resizedResponseLocalNorm =
NormalizeTH2D(resizedResponseLocalNorm);
830 TH1D *kinematicEfficiencyLocal((
TH1D*)kinematicEfficiency->Clone(Form(
"kinematicEfficiency_%s", suffix.Data())));
832 TH1D *unfoldedLocalBayes(0x0);
833 TH1D *foldedLocalBayes(0x0);
834 cout <<
" 2) setup necessary input " << endl;
837 TH2* responseMatrixLocalTransposePrior(
fResponseMaker->GetTransposeResponsMatrix(resizedResponseLocal));
838 responseMatrixLocalTransposePrior->SetNameTitle(Form(
"prior_%s_%s", responseMatrixLocalTransposePrior->GetName(), suffix.Data()),Form(
"prior_%s_%s", responseMatrixLocalTransposePrior->GetName(), suffix.Data()));
841 responseMatrixLocalTransposePrior =
fResponseMaker->NormalizeResponsMatrixYaxisWithPrior(responseMatrixLocalTransposePrior, priorLocal);
843 RooUnfoldResponse responseBayes(0, 0, responseMatrixLocalTransposePrior, Form(
"respCombinedBayes_%s", suffix.Data()), Form(
"respCombinedBayes_%s", suffix.Data()));
847 RooUnfold::ErrorTreatment errorTreatment = (
fSVDToy) ? RooUnfold::kCovToy : RooUnfold::kCovariance;
848 unfoldedLocalBayes = (
TH1D*)unfoldBayes.Hreco(errorTreatment);
850 unfoldedLocalBayes->Divide(kinematicEfficiencyLocal);
852 TMatrixD covarianceMatrix = unfoldBayes.Ereco(errorTreatment);
856 hPearson =
new TH2D(*pearson);
858 hPearson->SetNameTitle(Form(
"PearsonCoefficients_%s", suffix.Data()), Form(
"Pearson coefficients_%s", suffix.Data()));
865 foldedLocalBayes =
fResponseMaker->MultiplyResponseGenerated(unfoldedLocalBayes, resizedResponseLocalNorm, kinematicEfficiencyLocal);
866 TGraphErrors* ratio(
GetRatio(measuredJetSpectrumLocal, foldedLocalBayes,
"ratio measured / re-folded", kTRUE));
867 ratio->SetNameTitle(Form(
"RatioRefoldedMeasured_%s",
fActiveString.Data()), Form(
"Ratio measured / re-folded %s",
fActiveString.Data()));
868 ratio->GetXaxis()->SetTitle(
"p_{t}^{rec, rec} [GeV/ c]");
869 ratio->GetYaxis()->SetTitle(
"ratio measured / re-folded");
871 cout <<
" 7) refolded the unfolded spectrum " << endl;
874 measuredJetSpectrumLocal->SetNameTitle(Form(
"InputSpectrum_%s", suffix.Data()), Form(
"input spectrum (measured) %s", suffix.Data()));
875 measuredJetSpectrumLocal =
ProtectHeap(measuredJetSpectrumLocal);
876 measuredJetSpectrumLocal->SetXTitle(
"p_{t}^{rec} [GeV/c]");
877 measuredJetSpectrumLocal->Write();
878 unfoldedLocalBayes->SetNameTitle(Form(
"UnfoldedSpectrum_%s",suffix.Data()), Form(
"unfolded spectrum %s", suffix.Data()));
879 unfoldedLocalBayes =
ProtectHeap(unfoldedLocalBayes);
880 if(jetFindingEfficiency) unfoldedLocalBayes->Divide(jetFindingEfficiency);
881 unfoldedLocalBayes->Write();
882 foldedLocalBayes->SetNameTitle(Form(
"RefoldedSpectrum_%s", suffix.Data()), Form(
"refoldedSpectrum_%s", suffix.Data()));
884 foldedLocalBayes->Write();
887 responseMatrixLocalTransposePrior->SetNameTitle(
"TransposeResponseMatrix",
"Transpose of response matrix, normalize with prior");
888 responseMatrixLocalTransposePrior->SetXTitle(
"p_{T, jet}^{true} [GeV/c]");
889 responseMatrixLocalTransposePrior->SetYTitle(
"p_{T, jet}^{rec} [GeV/c]");
890 responseMatrixLocalTransposePrior->Write();
891 priorLocal->SetNameTitle(
"PriorOriginal",
"Prior, original");
892 priorLocal->SetXTitle(
"p_{t} [GeV/c]");
895 resizedResponseLocalNorm =
ProtectHeap(resizedResponseLocalNorm);
896 resizedResponseLocalNorm->Write();
899 TH1F* fitStatus(
new TH1F(Form(
"fitStatus_%s_%s",
fActiveString.Data(), suffix.Data()), Form(
"fitStatus_%s_%s",
fActiveString.Data(), suffix.Data()), 1, -0.5, 0.5));
901 fitStatus->GetXaxis()->SetBinLabel(1, (!strcmp(suffix.Data(),
"in")) ?
"fBayesianIterIn" :
"fBayesianIterOut");
904 return unfoldedLocalBayes;
908 const TH1D* measuredJetSpectrum,
909 const TH2D* resizedResponse,
910 const TH1D* kinematicEfficiency,
911 const TH1D* measuredJetSpectrumTrueBins,
913 const TH1D* jetFindingEfficiency)
915 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
916 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
923 TH1D* unfoldedLocal((
TH1D*)measuredJetSpectrum->Clone(Form(
"unfoldedLocal_%s", suffix.Data())));
926 TH2D* resizedResponseLocal = (
TH2D*)resizedResponse->Clone(Form(
"resizedResponseLocal_%s", suffix.Data()));
927 TH1D* kinematicEfficiencyLocal = (
TH1D*)kinematicEfficiency->Clone(Form(
"kinematicEfficiencyLocal_%s", suffix.Data()));
930 TH1D *foldedLocal(
fResponseMaker->MultiplyResponseGenerated(unfoldedLocal, resizedResponseLocal,kinematicEfficiencyLocal));
931 foldedLocal->SetNameTitle(Form(
"RefoldedSpectrum_%s", suffix.Data()), Form(
"Refolded jet spectrum, %s plane", suffix.Data()));
932 unfoldedLocal->SetNameTitle(Form(
"UnfoldedSpectrum_%s", suffix.Data()), Form(
"Unfolded jet spectrum, %s plane", suffix.Data()));
936 TH1D* measuredJetSpectrumLocal((
TH1D*)(measuredJetSpectrum->Clone(
"tempObject")));
937 measuredJetSpectrumLocal->SetNameTitle(Form(
"InputSpectrum_%s", suffix.Data()), Form(
"InputSpectrum_%s", suffix.Data()));
938 measuredJetSpectrumLocal =
ProtectHeap(measuredJetSpectrumLocal);
939 measuredJetSpectrumLocal->Write();
941 resizedResponseLocal =
ProtectHeap(resizedResponseLocal);
942 resizedResponseLocal->Write();
945 if(jetFindingEfficiency) unfoldedLocal->Divide(jetFindingEfficiency);
946 unfoldedLocal->Write();
949 foldedLocal->Write();
957 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
958 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
963 printf(
" AliJetFlowTools::PrepareForUnfolding() fInputList not found \n - Set a list using AliJetFlowTools::SetInputList() \n");
966 if(!
fDetectorResponse) printf(
" WARNING, no detector response supplied ! May be ok (depending on what you want to do) \n ");
969 printf(
" AliJetFlowTools::PrepareForUnfolding() no true or rec bins set, aborting ! \n");
985 if(!
fInputList->FindObject(spectrumName.Data())) {
986 printf(
" Couldn't find spectrum %s ! \n", spectrumName.Data());
996 printf(
"Extracted %s wight weight %.2f \n", spectrumName.Data(),
fCentralityWeights->At(0));
1000 printf(
" Merging with %s with weight %.4f \n", spectrumName.Data(),
fCentralityWeights->At(i));
1006 printf(
" Adding additional output %s \n", spectrumName.Data());
1033 if(!rho)
return 0x0;
1035 if (normalizeToFullSpectrum)
fEventCount = rho->GetEntries();
1046 if(error > 0)
fSpectrumIn->SetBinError(1+i, error);
1047 else fSpectrumIn->SetBinError(1+i, TMath::Sqrt(pt));
1069 printf(
" Couldn't find delta pt matrix %s ! \n", deltaptName.Data());
1070 printf(
" > may be ok, depending no what you want to do < \n");
1078 printf(
"Extracted %s with weight %.2f \n", deltaptName.Data(),
fCentralityWeights->At(0));
1081 printf(
" Merging with %s with weight %.4f \n", deltaptName.Data(),
fCentralityWeights->At(i));
1087 printf(
" Adding additional data %s \n", deltaptName.Data());
1106 TMatrixD* rfIn =
new TMatrixD(-50, 249, -50, 249);
1107 for(
Int_t j(-50); j < 250; j++) {
1109 for(
Int_t k(-50); k < 250; k++) {
1114 TMatrixD* rfOut =
new TMatrixD(-50, 249, -50, 249);
1115 for(
Int_t j(-50); j < 250; j++) {
1117 for(
Int_t k(-50); k < 250; k++) {
1124 fDptIn->GetXaxis()->SetTitle(
"p_{T, jet}^{gen} [GeV/c]");
1125 fDptIn->GetYaxis()->SetTitle(
"p_{T, jet}^{rec} [GeV/c]");
1129 fDptOut->GetXaxis()->SetTitle(
"p_{T, jet}^{gen} [GeV/c]");
1130 fDptOut->GetYaxis()->SetTitle(
"p_{T, jet}^{rec} [GeV/c]");
1140 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1141 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1144 printf(
" AliJetFlowTools::PrepareForUnfolding() fInputList not found \n - Set a list using AliJetFlowTools::SetInputList() \n");
1147 if(!
fDetectorResponse) printf(
" WARNING, no detector response supplied ! May be ok (depending on what you want to do) \n ");
1150 printf(
" AliJetFlowTools::PrepareForUnfolding() no true or rec bins set, aborting ! \n");
1161 if(!fJetPtDeltaPhi) {
1162 printf(
" Couldn't find spectrum %s ! \n", spectrumName.Data());
1168 fJetPtDeltaPhi->Add(((
TH2D*)
fInputList->FindObject(spectrumName.Data())));
1171 fJetPtDeltaPhi =
ProtectHeap(fJetPtDeltaPhi, kFALSE);
1173 fSpectrumIn = fJetPtDeltaPhi->ProjectionY(Form(
"_py_in_%s", spectrumName.Data()), low, up,
"e");
1183 printf(
" Couldn't find delta pt matrix %s ! \n", deltaptName.Data());
1184 printf(
" > may be ok, depending no what you want to do < \n");
1199 TMatrixD* rfIn =
new TMatrixD(-50, 249, -50, 249);
1200 for(
Int_t j(-50); j < 250; j++) {
1202 for(
Int_t k(-50); k < 250; k++) {
1209 fDptIn->GetXaxis()->SetTitle(
"p_{T, jet}^{gen} [GeV/c]");
1210 fDptIn->GetYaxis()->SetTitle(
"p_{T, jet}^{rec} [GeV/c]");
1217 const TH1D* measuredJetSpectrum,
1218 const TH2D* resizedResponse,
1219 const TH1D* kinematicEfficiency,
1220 const TH1D* measuredJetSpectrumTrueBins,
1222 const TH1D* jetFindingEfficiency)
1224 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1225 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1229 TH1D* unfolded(0x0);
1230 TDirectoryFile* dirOut =
new TDirectoryFile(Form(
"Prior_%s___%s", suffix.Data(),
fActiveString.Data()), Form(
"Prior_%s___%s", suffix.Data(),
fActiveString.Data()));
1235 printf(
"> GetPrior:: FATAL ERROR! TF1 prior requested but prior has not been set ! < \n");
1242 printf(
"> GetPrior:: FATAL ERROR! pythia prior requested but prior has not been set ! < \n");
1263 TH1D* kinematicEfficiencyChi2(resizedResponseChi2->ProjectionX());
1264 kinematicEfficiencyChi2->SetNameTitle(
"kin_eff_chi2",
"kin_eff_chi2");
1265 for(
Int_t i(0); i < kinematicEfficiencyChi2->GetXaxis()->GetNbins(); i++) kinematicEfficiencyChi2->SetBinError(1+i, 0.);
1267 measuredJetSpectrumChi2,
1268 resizedResponseChi2,
1269 kinematicEfficiencyChi2,
1270 measuredJetSpectrumTrueBinsChi2,
1271 TString(Form(
"prior_%s", suffix.Data())));
1273 printf(
" > GetPrior:: panic, couldn't get prior from Chi2 unfolding! \n");
1274 printf(
" probably Chi2 unfolding did not converge < \n");
1279 fBinsRec = tempArrayRec;
1284 measuredJetSpectrum,
1286 kinematicEfficiency,
1287 measuredJetSpectrumTrueBins,
1288 TString(Form(
"prior_%s", suffix.Data())));
1290 printf(
" > GetPrior:: panic, couldn't get prior from Chi2 unfolding! \n");
1291 printf(
" probably Chi2 unfolding did not converge < \n");
1301 unfolded = (
TH1D*)measuredJetSpectrumTrueBins->Clone(Form(
"kPriorMeasured_%s", suffix.Data()));
1307 if(jetFindingEfficiency) unfolded->Divide(jetFindingEfficiency);
1308 TH1D *priorLocal((
TH1D*)unfolded->Clone(Form(
"priorUnfolded_%s", suffix.Data())));
1315 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1316 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1319 printf(
" > ResizeXaxisTH!D:: fatal error, NULL pointer passed < \n");
1323 TH1D* resized =
new TH1D(Form(
"%s_resized_%s", histo->GetName(), suffix.Data()), Form(
"%s_resized_%s", histo->GetName(), suffix.Data()), up-low, (
double)low, (double)up);
1325 Int_t l = histo->GetXaxis()->FindBin(low);
1328 for(
Int_t i(0); i < up-low; i++) {
1329 _x = histo->GetBinContent(l+i);
1330 _xx=histo->GetBinError(l+i);
1331 resized->SetBinContent(i+1, _x);
1332 resized->SetBinError(i+1, _xx);
1339 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1340 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1343 printf(
" > ResizeYaxisTH2D:: fatal error, NULL pointer passed < \n");
1347 TH2D* resized =
new TH2D(Form(
"%s_resized_%s", histo->GetName(), suffix.Data()), Form(
"%s_resized_%s", histo->GetName(), suffix.Data()), x->GetSize()-1, x->GetArray(), y->GetSize()-1, y->GetArray());
1350 Int_t low = histo->GetYaxis()->FindBin(y->At(0));
1353 for(
Int_t i(0); i < x->GetSize(); i++) {
1354 for(
Int_t j(0); j < y->GetSize(); j++) {
1355 _x = histo->GetBinContent(i, low+j);
1356 _xx=histo->GetBinError(i, low+1+j);
1357 resized->SetBinContent(i, j, _x);
1358 resized->SetBinError(i, j, _xx);
1367 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1368 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1371 printf(
" > NormalizeTH2D:: NULL pointer passed, returning NULL < \n");
1374 Int_t binsX = histo->GetXaxis()->GetNbins();
1375 Int_t binsY = histo->GetYaxis()->GetNbins();
1378 for(
Int_t i(0); i < binsX; i++) {
1380 for(
Int_t j(0); j < binsY; j++) {
1381 weight+=histo->GetBinContent(i+1, j+1);
1383 for(
Int_t j(0); j < binsY; j++) {
1384 if (weight <= 0 )
continue;
1385 histo->SetBinContent(1+i, j+1, histo->GetBinContent(1+i, j+1)/weight);
1386 if(noError) histo->SetBinError( 1+i, j+1, 0.);
1387 else histo->SetBinError( 1+i, j+1, histo->GetBinError( 1+i, j+1)/weight);
1394 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1395 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1400 printf(
" > Bootstrap:: fatal error,NULL pointer passed! \n");
1403 else printf(
" > Bootstrap:: resampling, may take some time \n");
1405 TH1* bootstrapped((
TH1*)(hist->Clone(Form(
"%s_bootstrapped", hist->GetName()))));
1406 bootstrapped->Reset();
1416 Int_t sampledMean(0), entries(0);
1418 for(
Int_t i(0); i < hist->GetXaxis()->GetNbins(); i++) {
1420 mean = hist->GetBinContent(i+1);
1421 sigma = hist->GetBinError(i+1);
1423 sampledMean = TMath::Nint(
gRandom->Gaus(mean, sigma));
1424 printf(
" sampled %i from original number %.2f \n", sampledMean, mean);
1426 bootstrapped->SetBinContent(i+1, sampledMean);
1427 if(sampledMean > 0) bootstrapped->SetBinError(i+1, TMath::Sqrt(sampledMean));
1428 entries += sampledMean;
1430 printf(
" Done bootstrapping, setting number of entries to %i \n", entries);
1431 bootstrapped->SetEntries((
double)entries);
1435 if(kill)
delete hist;
1437 return bootstrapped;
1441 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1442 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1446 if(!histo || !bins) {
1447 printf(
" > RebinTH1D:: fatal error, NULL pointer passed < \n");
1451 TString name = histo->GetName();
1454 TH1D* rebinned = 0x0;
1457 if(histo->GetBinContent(1) > 1 ) {
1458 rebinned =
new TH1D(name.Data(), name.Data(), bins->GetSize()-1, bins->GetArray());
1459 for(
Int_t i(0); i < histo->GetXaxis()->GetNbins(); i++) {
1461 rebinned->Fill(histo->GetBinCenter(i+1), histo->GetBinContent(i+1));
1463 }
else rebinned =
reinterpret_cast<TH1D*
>(histo->Rebin(bins->GetSize()-1, name.Data(), bins->GetArray()));
1464 if(kill)
delete histo;
1469 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1470 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1475 printf(
" > RebinTH2D:: function called with NULL arguments < \n");
1478 TString name(Form(
"%s_%s", rebinMe->GetName(), suffix.Data()));
1479 return (
TH2D*)
fResponseMaker->MakeResponseMatrixRebin(rebinMe, (
TH2*)(
new TH2D(name.Data(), name.Data(), binsTrue->GetSize()-1, binsTrue->GetArray(), binsRec->GetSize()-1, binsRec->GetArray())), kTRUE);
1484 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1485 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1488 if (a->GetNbinsX() != b->GetNbinsY())
return 0x0;
1490 for (
Int_t y1 = 1; y1 <= a->GetNbinsY(); y1++) {
1491 for (
Int_t x2 = 1; x2 <= b->GetNbinsX(); x2++) {
1493 for (
Int_t x1 = 1; x1 <= a->GetNbinsX(); x1++) {
1495 val += a->GetBinContent(x1, y1) * b->GetBinContent(x2, y2);
1497 c->SetBinContent(x2, y1, val);
1498 c->SetBinError(x2, y1, 0.);
1501 if(strcmp(name.Data(),
"")) c->SetNameTitle(name.Data(), name.Data());
1507 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1508 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1512 Double_t integral = histo->Integral()*scale;
1513 if (integral > 0 && scale == 1.) histo->Scale(1./integral,
"width");
1514 else if (scale != 1.) histo->Scale(1./scale,
"width");
1515 else printf(
" > Histogram integral < 0, cannot normalize \n");
1521 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1522 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1525 if(!(bins&&spectrum)) {
1526 printf(
" > NULL pointer passed as argument in MergeSpectrumBins ! < \n");
1529 Double_t sum(0), error(0), pearson(0);
1531 sum += spectrum->GetBinContent(bins->At(0));
1532 sum += spectrum->GetBinContent(bins->At(1));
1534 error += TMath::Power(spectrum->GetBinError(bins->At(0)), 2);
1535 error += TMath::Power(spectrum->GetBinError(bins->At(1)), 2);
1537 pearson = corr->GetBinContent(bins->At(0), bins->At(1));
1539 printf(
" > PANIC ! something is wrong with the covariance matrix, assuming full correlation ! < \n ");
1542 error += 2.*spectrum->GetBinError(bins->At(0))*spectrum->GetBinError(bins->At(1))*pearson;
1543 spectrum->SetBinContent(1, sum);
1544 if(error <= 0)
return spectrum;
1545 spectrum->SetBinError(1, TMath::Sqrt(error));
1546 printf(
" > sum is %.2f \t error is %.8f < \n", sum, error);
1547 printf(
" > REPLACING BIN CONTENT OF FIRST BIN (%i) WITH MERGED BINS (%i) and (%i) < \n", 1, bins->At(0), bins->At(1));
1553 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1554 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1557 TMatrixD *pearsonCoefficients((TMatrixD*)covarianceMatrix->Clone(
"pearsonCoefficients"));
1558 Int_t nrows(covarianceMatrix->GetNrows()), ncols(covarianceMatrix->GetNcols());
1560 if(nrows==0 && ncols==0)
return 0x0;
1561 for(
Int_t row = 0; row < nrows; row++) {
1562 for(
Int_t col = 0; col<ncols; col++) {
1563 if((*covarianceMatrix)(row,row)!=0. && (*covarianceMatrix)(col,col)!=0.) pearson = (*covarianceMatrix)(row,col)/TMath::Sqrt((*covarianceMatrix)(row,row)*(*covarianceMatrix)(col,col));
1564 (*pearsonCoefficients)(row,col) = pearson;
1567 return pearsonCoefficients;
1571 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1572 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1579 if(!spectrum || !
function)
return 0x0;
1580 if(start > max) printf(
" > cannot extrapolate fit beyond fit range ! < " );
1581 TH1D* temp = (
TH1D*)spectrum->Clone(Form(
"%s_smoothened", spectrum->GetName()));
1583 TFitResultPtr r = temp->Fit(
function,
"",
"", min, max);
1585 for(
Int_t i(0); i < temp->GetNbinsX() + 1; i++) {
1586 if(temp->GetBinCenter(i) > start) {
1587 (counts) ? temp->SetBinContent(i, (
int)(function->Integral(temp->GetXaxis()->GetBinLowEdge(i),temp->GetXaxis()->GetBinUpEdge(i))/temp->GetXaxis()->GetBinWidth(i))) : temp->SetBinContent(i, function->Integral(temp->GetXaxis()->GetBinLowEdge(i),temp->GetXaxis()->GetBinUpEdge(i))/temp->GetXaxis()->GetBinWidth(i));
1588 if(temp->GetBinContent(i) > 0) temp->SetBinError(i, TMath::Sqrt(temp->GetBinContent(i)));
1592 if(kill)
delete spectrum;
1598 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1599 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1605 gStyle->SetCanvasColor(-1);
1606 gStyle->SetPadColor(-1);
1607 gStyle->SetFrameFillColor(-1);
1608 gStyle->SetHistFillColor(-1);
1609 gStyle->SetTitleFillColor(-1);
1610 gStyle->SetFillColor(-1);
1611 gStyle->SetFillStyle(4000);
1612 gStyle->SetStatStyle(0);
1613 gStyle->SetTitleStyle(0);
1614 gStyle->SetCanvasBorderSize(0);
1615 gStyle->SetFrameBorderSize(0);
1616 gStyle->SetLegendBorderSize(0);
1617 gStyle->SetStatBorderSize(0);
1618 gStyle->SetTitleBorderSize(0);
1620 gStyle->Reset(
"Plain");
1621 gStyle->SetOptTitle(0);
1622 gStyle->SetOptStat(0);
1623 gStyle->SetPalette(1);
1624 gStyle->SetCanvasColor(10);
1625 gStyle->SetCanvasBorderMode(0);
1626 gStyle->SetFrameLineWidth(1);
1627 gStyle->SetFrameFillColor(kWhite);
1628 gStyle->SetPadColor(10);
1629 gStyle->SetPadTickX(1);
1630 gStyle->SetPadTickY(1);
1631 gStyle->SetPadBottomMargin(0.17);
1632 gStyle->SetPadLeftMargin(0.15);
1633 gStyle->SetHistLineWidth(1);
1634 gStyle->SetHistLineColor(kRed);
1635 gStyle->SetFuncWidth(2);
1636 gStyle->SetFuncColor(kGreen);
1637 gStyle->SetLineWidth(2);
1638 gStyle->SetLabelSize(0.045,
"xyz");
1639 gStyle->SetLabelOffset(0.01,
"y");
1640 gStyle->SetLabelOffset(0.01,
"x");
1641 gStyle->SetLabelColor(kBlack,
"xyz");
1642 gStyle->SetTitleSize(0.05,
"xyz");
1643 gStyle->SetTitleOffset(1.25,
"y");
1644 gStyle->SetTitleOffset(1.2,
"x");
1645 gStyle->SetTitleFillColor(kWhite);
1646 gStyle->SetTextSizePixels(26);
1647 gStyle->SetTextFont(42);
1648 gStyle->SetLegendBorderSize(0);
1649 gStyle->SetLegendFillColor(kWhite);
1650 gStyle->SetLegendFont(42);
1656 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1657 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1661 if(!strcmp(style.Data(),
"PEARSON")) {
1662 printf(
" > style PEARSON canvas < \n");
1663 gStyle->SetOptStat(0);
1668 }
else if(!strcmp(style.Data(),
"SPECTRUM")) {
1669 printf(
" > style SPECTRUM canvas < \n");
1670 gStyle->SetOptStat(0);
1676 }
else printf(
" > Style called with unknown option %s \n returning < \n", style.Data());
1681 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1682 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1687 c->SetLeftMargin(.25);
1688 c->SetBottomMargin(.25);
1691 if(!strcmp(style.Data(),
"PEARSON")) {
1692 printf(
" > style PEARSON pad < \n");
1693 gStyle->SetOptStat(0);
1698 }
else if(!strcmp(style.Data(),
"SPECTRUM")) {
1699 printf(
" > style SPECTRUM pad < \n");
1700 gStyle->SetOptStat(0);
1706 }
else if (!strcmp(style.Data(),
"GRID")) {
1707 printf(
" > style GRID pad < \n");
1708 gStyle->SetOptStat(0);
1712 }
else printf(
" > Style called with unknown option %s \n returning < \n", style.Data());
1717 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1718 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1723 l->SetBorderSize(0);
1724 if(gStyle) l->SetTextSize(gStyle->GetTextSize()*.08);
1729 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1730 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1734 h->GetYaxis()->SetNdivisions(505);
1735 h->SetLineColor(col);
1736 h->SetMarkerColor(col);
1738 h->SetMarkerSize(1.5);
1741 h->GetYaxis()->SetLabelSize(0.05);
1742 h->GetXaxis()->SetLabelSize(0.05);
1743 h->GetYaxis()->SetTitleOffset(1.5);
1744 h->GetXaxis()->SetTitleOffset(1.5);
1745 h->GetYaxis()->SetTitleSize(.05);
1746 h->GetXaxis()->SetTitleSize(.05);
1750 h->SetTitle(
"IN PLANE");
1751 h->GetXaxis()->SetTitle(
"#it{p}_{T}^{ch, jet} (GeV/#it{c})");
1752 h->GetYaxis()->SetTitle(
"#frac{d#it{N}}{d#it{p}_{T}}");
1755 h->SetTitle(
"OUT OF PLANE");
1756 h->GetYaxis()->SetTitle(
"#frac{d#it{N}}{d#it{p}_{T}}");
1757 h->GetXaxis()->SetTitle(
"#it{p}_{T, jet}^{ch} (GeV/#it{c})");
1760 h->SetTitle(
"UNFOLDED");
1761 h->GetYaxis()->SetTitle(
"#frac{d#it{N}}{d#it{p}_{T}}");
1762 h->GetXaxis()->SetTitle(
"#it{p}_{T, jet}^{ch} (GeV/#it{c})");
1765 h->SetTitle(
"FOLDED");
1766 h->GetYaxis()->SetTitle(
"#frac{d#it{N}}{d#it{p}_{T}}");
1767 h->GetXaxis()->SetTitle(
"#it{p}_{T, jet}^{ch} (GeV/#it{c})");
1770 h->SetTitle(
"MEASURED");
1771 h->GetYaxis()->SetTitle(
"#frac{d#it{N}}{d#it{p}_{T}}");
1772 h->GetXaxis()->SetTitle(
"#it{p}_{T, jet}^{cht} (GeV/#it{c})");
1775 h->SetFillColor(col);
1777 h->GetXaxis()->SetTitle(
"#it{p}_{T, jet}^{ch} (GeV/#it{c})");
1778 h->SetBarOffset(0.2);
1781 h->SetMarkerStyle(8);
1782 h->SetMarkerSize(1.5);
1785 h->GetYaxis()->SetTitle(
"[counts]");
1786 h->GetXaxis()->SetTitle(
"#Delta #phi");
1794 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1795 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1799 h->GetYaxis()->SetNdivisions(505);
1800 h->SetLineColor(col);
1801 h->SetMarkerColor(col);
1803 h->SetMarkerSize(1.5);
1805 h->SetFillColor(kCyan);
1807 h->GetYaxis()->SetLabelSize(0.05);
1808 h->GetXaxis()->SetLabelSize(0.05);
1809 h->GetYaxis()->SetTitleOffset(1.6);
1810 h->GetXaxis()->SetTitleOffset(1.6);
1811 h->GetYaxis()->SetTitleSize(.05);
1812 h->GetXaxis()->SetTitleSize(.05);
1814 h->GetXaxis()->SetTitle(
"#it{p}_{T, jet}^{ch} (GeV/#it{c})");
1817 h->SetTitle(
"IN PLANE");
1818 h->GetYaxis()->SetTitle(
"#frac{d#it{N}}{d#it{p}_{T}}");
1821 h->SetTitle(
"OUT OF PLANE");
1822 h->GetYaxis()->SetTitle(
"#frac{d#it{N}}{d#it{p}_{T}}");
1825 h->SetTitle(
"UNFOLDED");
1826 h->GetYaxis()->SetTitle(
"#frac{d#it{N}}{d#it{p}_{T}}");
1829 h->SetTitle(
"FOLDED");
1830 h->GetYaxis()->SetTitle(
"#frac{d#it{N}}{d#it{p}_{T}}");
1833 h->SetTitle(
"MEASURED");
1834 h->GetYaxis()->SetTitle(
"#frac{d#it{N}}{d#it{p}_{T}}");
1837 h->GetYaxis()->SetTitle(
"(d#it{N}^{ch, jet}_{in plane}/(d#it{p}_{T}d#eta))/(d#it{N}^{ch,jet}_{out of plane}/(d#it{p}_{T}d#eta))");
1840 h->GetYaxis()->SetTitle(
"#it{v}_{2}^{ch, jet} {EP, |#Delta#eta|>0.9 } ");
1841 h->GetYaxis()->SetRangeUser(-.5, 1.);
1842 h->SetMarkerStyle(8);
1843 h->SetMarkerSize(1.5);
1857 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1858 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1862 TFile* readMe(
new TFile(inFile.Data(),
"READ"));
1863 if(readMe->IsZombie()) {
1864 printf(
" > Fatal error, couldn't read %s for post processing ! < \n", inFile.Data());
1867 printf(
"\n\n\n\t\t GetNominalValues \n > Recovered the following file structure : \n <");
1869 TFile* output(
new TFile(outFile.Data(),
"RECREATE"));
1875 Int_t iIn[] = {in->At(0), in->At(0)};
1876 Int_t iOut[] = {out->At(0), out->At(0)};
1883 dud, dud, dud, dud, dud, dud,
1895 ratio->SetDirectory(0);
1918 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
1919 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
1923 TFile* readMe(
new TFile(in.Data(),
"READ"));
1924 if(readMe->IsZombie()) {
1925 printf(
" > Fatal error, couldn't read %s for post processing ! < \n", in.Data());
1928 printf(
"\n\n\n\t\t GetCorrelatedUncertainty \n > Recovered the following file structure : \n <");
1930 TFile* output(
new TFile(out.Data(),
"RECREATE"));
1935 TH1D* relativeErrorVariationInLow(0x0);
1936 TH1D* relativeErrorVariationInUp(0x0);
1937 TH1D* relativeErrorVariationOutLow(0x0);
1938 TH1D* relativeErrorVariationOutUp(0x0);
1939 TH1D* relativeError2ndVariationInLow(0x0);
1940 TH1D* relativeError2ndVariationInUp(0x0);
1941 TH1D* relativeError2ndVariationOutLow(0x0);
1942 TH1D* relativeError2ndVariationOutUp(0x0);
1943 TH1D* relativeStatisticalErrorIn(0x0);
1944 TH1D* relativeStatisticalErrorOut(0x0);
1946 TH1D* nominal(
new TH1D(
"ratio in plane, out of plane",
"ratio in plane, out of plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
1948 TH1D* nominalOut(
new TH1D(
"out of plane jet yield",
"out of plane jet yield",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
1951 if(variationsIn && variationsOut) {
1955 relativeErrorVariationInUp,
1956 relativeErrorVariationInLow,
1957 relativeErrorVariationOutUp,
1958 relativeErrorVariationOutLow,
1959 relativeStatisticalErrorIn,
1960 relativeStatisticalErrorOut,
1971 if(relativeErrorVariationInUp) {
1973 TCanvas* relativeErrorVariation(
new TCanvas(Form(
"relativeError_%s", type.Data()), Form(
"relativeError_%s", type.Data())));
1974 relativeErrorVariation->Divide(2);
1975 relativeErrorVariation->cd(1);
1976 Style(gPad,
"GRID");
1977 relativeErrorVariationInUp->DrawCopy(
"b");
1978 relativeErrorVariationInLow->DrawCopy(
"same b");
1980 relativeErrorVariation->cd(2);
1981 Style(gPad,
"GRID");
1982 relativeErrorVariationOutUp->DrawCopy(
"b");
1983 relativeErrorVariationOutLow->DrawCopy(
"same b");
1986 relativeErrorVariation->Write();
1991 TF1* lin =
new TF1(
"lin",
"[0]", rangeLow, rangeUp);
1992 relativeErrorVariationInUp->Fit(lin,
"L",
"", rangeLow, rangeUp);
1993 if(gMinuit->fISW[1] != 3) printf(
" fit is NOT ok ! " );
1994 for(
Int_t i(0); i < relativeErrorVariationInUp->GetNbinsX(); i++) {
1995 relativeErrorVariationInUp->SetBinContent(i+1, lin->GetParameter(0));
1997 relativeErrorVariationInLow->Fit(lin,
"L",
"", rangeLow, rangeUp);
1998 printf(
" > Fit over diced resonse, new value for all bins is %.4f < \n ", lin->GetParameter(0));
1999 for(
Int_t i(0); i < relativeErrorVariationInUp->GetNbinsX(); i++) {
2000 relativeErrorVariationInLow->SetBinContent(i+1, 0);
2002 relativeErrorVariationOutUp->Fit(lin,
"L",
"", rangeLow, rangeUp);
2003 printf(
" > Fit over diced resonse, new value for all bins is %.4f < \n ", lin->GetParameter(0));
2004 for(
Int_t i(0); i < relativeErrorVariationInUp->GetNbinsX(); i++) {
2005 relativeErrorVariationOutUp->SetBinContent(i+1, lin->GetParameter(0));
2007 relativeErrorVariationOutLow->Fit(lin,
"L",
"", rangeLow, rangeUp);
2008 printf(
" > Fit over diced resonse, new value for all bins is %.4f < \n ", lin->GetParameter(0));
2009 for(
Int_t i(0); i < relativeErrorVariationInUp->GetNbinsX(); i++) {
2010 relativeErrorVariationOutLow->SetBinContent(i+1, 0);
2015 if(variations2ndIn && variations2ndOut) {
2019 relativeError2ndVariationInUp,
2020 relativeError2ndVariationInLow,
2021 relativeError2ndVariationOutUp,
2022 relativeError2ndVariationOutLow,
2023 relativeStatisticalErrorIn,
2024 relativeStatisticalErrorOut,
2035 if(relativeError2ndVariationInUp) {
2037 TCanvas* relativeError2ndVariation(
new TCanvas(Form(
"relativeError2nd_%s", type2.Data()), Form(
"relativeError2nd_%s", type2.Data())));
2038 relativeError2ndVariation->Divide(2);
2039 relativeError2ndVariation->cd(1);
2040 Style(gPad,
"GRID");
2041 relativeError2ndVariationInUp->DrawCopy(
"b");
2042 relativeError2ndVariationInLow->DrawCopy(
"same b");
2044 relativeError2ndVariation->cd(2);
2045 Style(gPad,
"GRID");
2046 relativeError2ndVariationOutUp->DrawCopy(
"b");
2047 relativeError2ndVariationOutLow->DrawCopy(
"same b");
2050 relativeError2ndVariation->Write();
2056 TH1D* relativeErrorInUp(
new TH1D(
"max correlated uncertainty in plane",
"max correlated uncertainty in plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2057 TH1D* relativeErrorOutUp(
new TH1D(
"max correlated uncertainty out of plane",
"max correlated uncertainty out of plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2058 TH1D* relativeErrorInLow(
new TH1D(
"min correlated uncertainty in plane",
"min correlated uncertainty in plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2059 TH1D* relativeErrorOutLow(
new TH1D(
"min correlated uncertainty out of plane",
"min correlated uncertainty out of plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2060 relativeErrorInUp->SetYTitle(
"relative uncertainty");
2061 relativeErrorOutUp->SetYTitle(
"relative uncertainty");
2062 relativeErrorInLow->SetYTitle(
"relative uncertainty");
2063 relativeErrorOutLow->SetYTitle(
"relative uncertainty");
2066 Double_t aInUp(0.), bInUp(0.), cInUp(0.), dInUp(0.);
2067 Double_t aOutUp(0.), bOutUp(0.), cOutUp(0.), dOutUp(0.);
2068 Double_t aInLow(0.), bInLow(0.), cInLow(0.), dInLow(0.);
2069 Double_t aOutLow(0.), bOutLow(0.), cOutLow(0.), dOutLow(0.);
2073 if(relativeErrorVariationInUp) aInUp = relativeErrorVariationInUp->GetBinContent(b+1);
2074 if(relativeErrorVariationOutUp) aOutUp = relativeErrorVariationOutUp->GetBinContent(b+1);
2075 if(relativeError2ndVariationInUp) bInUp = relativeError2ndVariationInUp->GetBinContent(b+1);
2076 if(relativeError2ndVariationOutUp) bInLow = relativeError2ndVariationOutUp->GetBinContent(b+1);
2077 dInUp = aInUp*aInUp + bInUp*bInUp + cInUp*cInUp;
2079 if(sym) dInUp += aInLow*aInLow;
2080 if(dInUp > 0) relativeErrorInUp->SetBinContent(b+1, TMath::Sqrt(dInUp));
2081 dOutUp = aOutUp*aOutUp + bOutUp*bOutUp + cOutUp*cOutUp;
2082 if(sym) dOutUp += aOutLow*aOutLow;
2083 if(dOutUp > 0) relativeErrorOutUp->SetBinContent(b+1, TMath::Sqrt(dOutUp));
2085 if(relativeErrorVariationInLow) aInLow = relativeErrorVariationInLow->GetBinContent(b+1);
2086 if(relativeErrorVariationOutLow) aOutLow = relativeErrorVariationOutLow->GetBinContent(b+1);
2087 if(relativeError2ndVariationInLow) bInLow = relativeError2ndVariationInLow->GetBinContent(b+1);
2088 if(relativeError2ndVariationOutLow) bOutLow = relativeError2ndVariationOutLow->GetBinContent(b+1);
2089 dInLow = aInLow*aInLow + bInLow*bInLow + cInLow*cInLow;
2090 if(sym) dInLow += aInUp*aInUp;
2091 if(dInLow > 0) relativeErrorInLow->SetBinContent(b+1, -1*TMath::Sqrt(dInLow));
2092 dOutLow = aOutLow*aOutLow + bOutLow*bOutLow + cOutLow*cOutLow;
2093 if(sym) dOutLow += aOutUp*aOutUp;
2094 if(dOutLow > 0) relativeErrorOutLow->SetBinContent(b+1, -1.*TMath::Sqrt(dOutLow));
2112 lowErr = relativeErrorInLow->GetBinContent(i+1)*relativeErrorInLow->GetBinContent(i+1)+relativeErrorOutUp->GetBinContent(1+i)*relativeErrorOutUp->GetBinContent(i+1);
2113 upErr = relativeErrorInUp->GetBinContent(i+1)*relativeErrorInUp->GetBinContent(i+1)+relativeErrorOutLow->GetBinContent(i+1)*relativeErrorOutLow->GetBinContent(i+1);
2115 lowErr = relativeErrorInLow->GetBinContent(i+1)*relativeErrorInLow->GetBinContent(i+1)+relativeErrorOutLow->GetBinContent(1+i)*relativeErrorOutLow->GetBinContent(i+1) -2.*corr*relativeErrorInLow->GetBinContent(i+1)*relativeErrorOutLow->GetBinContent(i+1);
2116 upErr = relativeErrorInUp->GetBinContent(i+1)*relativeErrorInUp->GetBinContent(i+1)+relativeErrorOutUp->GetBinContent(i+1)*relativeErrorOutUp->GetBinContent(i+1) - 2.*corr*relativeErrorInUp->GetBinContent(i+1)*relativeErrorOutUp->GetBinContent(i+1);
2118 ayl[i] = TMath::Sqrt(TMath::Abs(lowErr))*nominal->GetBinContent(i+1);
2119 ayh[i] = TMath::Sqrt(TMath::Abs(upErr))*nominal->GetBinContent(i+1);
2121 Double_t binWidth(nominal->GetBinWidth(i+1));
2122 axl[i] = binWidth/2.;
2123 axh[i] = binWidth/2.;
2125 ax[i] = nominal->GetBinCenter(i+1);
2126 ay[i] = nominal->GetBinContent(i+1);
2131 nominalError->SetName(
"correlated uncertainty");
2132 TCanvas* nominalCanvas(
new TCanvas(
"nominalCanvas",
"nominalCanvas"));
2133 nominalCanvas->Divide(2);
2134 nominalCanvas->cd(1);
2135 Style(nominal, kBlack);
2137 nominalError->SetLineColor(kCyan);
2138 nominalError->SetMarkerColor(kCyan);
2139 nominalError->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
2140 nominalError->GetYaxis()->SetRangeUser(.7, 2.2);
2141 nominalError->DrawClone(
"a2");
2142 nominal->DrawCopy(
"same E1");
2144 Style(gPad,
"GRID");
2145 Style(nominalCanvas);
2151 "v_{2} with shape uncertainty",
2155 relativeErrorOutLow,
2160 nominalCanvas->cd(2);
2161 Style(nominalV2, kBlack);
2163 nominalV2Error->SetLineColor(kCyan);
2164 nominalV2Error->SetMarkerColor(kCyan);
2165 nominalV2Error->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
2166 nominalV2Error->DrawClone(
"a2");
2167 nominalV2->DrawClone(
"same E1");
2169 Style(gPad,
"GRID");
2170 Style(nominalCanvas);
2172 nominalCanvas->Write();
2175 TCanvas* relativeError(
new TCanvas(
"relativeCorrelatedError",
" relativeCorrelatedError"));
2176 relativeError->Divide(2);
2177 relativeError->cd(1);
2178 Style(gPad,
"GRID");
2179 relativeErrorInUp->GetYaxis()->SetRangeUser(-1.5, 3.);
2181 Style(relativeErrorInLow, kGreen,
kBar);
2182 relativeErrorInUp->DrawCopy(
"b");
2183 relativeErrorInLow->DrawCopy(
"same b");
2184 Style(relativeStatisticalErrorIn, kRed);
2185 relativeStatisticalErrorIn->DrawCopy(
"same");
2187 relativeError->cd(2);
2188 Style(gPad,
"GRID");
2189 relativeErrorOutUp->GetYaxis()->SetRangeUser(-1.5, 3.);
2191 Style(relativeErrorOutLow, kGreen,
kBar);
2192 relativeErrorOutUp->DrawCopy(
"b");
2193 relativeErrorOutLow->DrawCopy(
"same b");
2194 Style(relativeStatisticalErrorOut, kRed);
2195 relativeStatisticalErrorOut->DrawCopy(
"same");
2200 relativeError->Write();
2219 Bool_t regularizationOnV2
2222 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
2223 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
2227 TFile* readMe(
new TFile(in.Data(),
"READ"));
2228 if(readMe->IsZombie()) {
2229 printf(
" > Fatal error, couldn't read %s for post processing ! < \n", in.Data());
2232 printf(
"\n\n\n\t\t DOSYSTEMATICS \n > Recovered the following file structure : \n <");
2234 TFile* output(
new TFile(out.Data(),
"RECREATE"));
2236 TH1D* relativeErrorRegularizationInLow(0x0);
2237 TH1D* relativeErrorRegularizationInUp(0x0);
2238 TH1D* relativeErrorRecBinInLow(0x0);
2239 TH1D* relativeErrorRecBinInUp(0x0);
2240 TH1D* relativeErrorMethodInLow(0x0);
2241 TH1D* relativeErrorMethodInUp(0x0);
2242 TH1D* relativeErrorRegularizationOutLow(0x0);
2243 TH1D* relativeErrorRegularizationOutUp(0x0);
2244 TH1D* relativeErrorRecBinOutLow(0x0);
2245 TH1D* relativeErrorRecBinOutUp(0x0);
2246 TH1D* relativeStatisticalErrorIn(0x0);
2247 TH1D* relativeStatisticalErrorOut(0x0);
2248 TH1D* relativeErrorMethodOutLow(0x0);
2249 TH1D* relativeErrorMethodOutUp(0x0);
2251 TH1D* nominal(
new TH1D(
"ratio in plane, out of plane",
"ratio in plane, out of plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2253 TH1D* nominalOut(
new TH1D(
"out of plane jet yield",
"out of plane jet yield",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2256 if(regularizationIn && regularizationOut) {
2260 relativeErrorRegularizationInUp,
2261 relativeErrorRegularizationInLow,
2262 relativeErrorRegularizationOutUp,
2263 relativeErrorRegularizationOutLow,
2264 relativeStatisticalErrorIn,
2265 relativeStatisticalErrorOut,
2275 !regularizationOnV2);
2276 if(relativeErrorRegularizationInUp && !regularizationOnV2 ) {
2278 TCanvas* relativeErrorRegularization(
new TCanvas(
"relativeErrorRegularization",
"relativeErrorRegularization"));
2279 relativeErrorRegularization->Divide(2);
2280 relativeErrorRegularization->cd(1);
2281 Style(gPad,
"GRID");
2282 relativeErrorRegularizationInUp->DrawCopy(
"b");
2283 relativeErrorRegularizationInLow->DrawCopy(
"same b");
2285 relativeErrorRegularization->cd(2);
2286 Style(gPad,
"GRID");
2287 relativeErrorRegularizationOutUp->DrawCopy(
"b");
2288 relativeErrorRegularizationOutLow->DrawCopy(
"same b");
2291 relativeErrorRegularization->Write();
2292 }
else if(relativeErrorRegularizationInUp && regularizationOnV2 ) {
2294 TCanvas* relativeErrorRegularization(
new TCanvas(
"relativeErrorRegularization",
"relativeErrorRegularization"));
2295 Style(gPad,
"GRID");
2296 relativeErrorRegularization->cd(1);
2297 TH1F* relativeErrorRegularizationInUpErrors = (TH1F*)relativeErrorRegularizationInUp->Clone();
2298 for(
Int_t i(1); i < relativeErrorRegularizationInUp->GetNbinsX() + 1; i++) {
2299 relativeErrorRegularizationInUpErrors->SetBinContent(i, relativeErrorRegularizationInUp->GetBinError(i));
2300 relativeErrorRegularizationInUpErrors->SetBinError(i, 0);
2302 relativeErrorRegularizationInUpErrors->GetYaxis()->SetTitle(
"absolute error on v_{2} from unfolding");
2303 relativeErrorRegularizationInUpErrors->GetXaxis()->SetTitle(
"#it{p}_{T, jet}^{ch} (GeV/#it{c})");
2304 relativeErrorRegularizationInUpErrors->DrawCopy(
"b");
2305 Style(gPad,
"GRID");
2306 relativeErrorRegularization->Write();
2309 if(recBinIn && recBinOut) {
2313 relativeErrorRecBinInUp,
2314 relativeErrorRecBinInLow,
2315 relativeErrorRecBinOutUp,
2316 relativeErrorRecBinOutLow,
2317 relativeStatisticalErrorIn,
2318 relativeStatisticalErrorOut,
2329 if(relativeErrorRecBinOutUp) {
2331 TCanvas* relativeErrorRecBin(
new TCanvas(
"relativeErrorRecBin",
" relativeErrorRecBin"));
2332 relativeErrorRecBin->Divide(2);
2333 relativeErrorRecBin->cd(1);
2334 Style(gPad,
"GRID");
2335 relativeErrorRecBinInUp->DrawCopy(
"b");
2336 relativeErrorRecBinInLow->DrawCopy(
"same b");
2338 relativeErrorRecBin->cd(2);
2339 Style(gPad,
"GRID");
2340 relativeErrorRecBinOutUp->DrawCopy(
"b");
2341 relativeErrorRecBinOutLow->DrawCopy(
"same b");
2344 relativeErrorRecBin->Write();
2347 if(methodIn && methodOut) {
2351 relativeErrorMethodInUp,
2352 relativeErrorMethodInLow,
2353 relativeErrorMethodOutUp,
2354 relativeErrorMethodOutLow,
2355 relativeStatisticalErrorIn,
2356 relativeStatisticalErrorOut,
2367 if(relativeErrorMethodInUp) {
2368 TCanvas* relativeErrorMethod(
new TCanvas(
"relativeErrorMethod",
"relativeErrorMethod"));
2369 relativeErrorMethod->Divide(2);
2370 relativeErrorMethod->cd(1);
2371 Style(gPad,
"GRID");
2372 relativeErrorMethodInUp->DrawCopy(
"b");
2373 relativeErrorMethodInLow->DrawCopy(
"same b");
2375 relativeErrorMethod->cd(2);
2376 Style(gPad,
"GRID");
2377 relativeErrorMethodOutUp->DrawCopy(
"b");
2378 relativeErrorMethodOutLow->DrawCopy(
"same b");
2381 relativeErrorMethod->Write();
2386 TH1D* relativeErrorInUp(
new TH1D(
"max shape uncertainty in plane",
"max shape uncertainty in plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2387 TH1D* relativeErrorOutUp(
new TH1D(
"max shape uncertainty out of plane",
"max shape uncertainty out of plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2388 TH1D* relativeErrorInLow(
new TH1D(
"min shape uncertainty in plane",
"min shape uncertainty in plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2389 TH1D* relativeErrorOutLow(
new TH1D(
"min shape uncertainty out of plane",
"min shape uncertainty out of plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2390 relativeErrorInUp->SetYTitle(
"relative uncertainty");
2391 relativeErrorOutUp->SetYTitle(
"relative uncertainty");
2392 relativeErrorInLow->SetYTitle(
"relative uncertainty");
2393 relativeErrorOutLow->SetYTitle(
"relative uncertainty");
2396 Double_t aInUp(0.), cInUp(0.), dInUp(0.), eInUp(0.);
2397 Double_t aOutUp(0.), cOutUp(0.), dOutUp(0.), eOutUp(0.);
2398 Double_t aInLow(0.), cInLow(0.), dInLow(0.), eInLow(0.);
2399 Double_t aOutLow(0.), cOutLow(0.), dOutLow(0.), eOutLow(0.);
2408 if(relativeErrorRegularizationInUp && !regularizationOnV2) aInUp = relativeErrorRegularizationInUp->GetBinContent(b+1);
2409 if(relativeErrorRegularizationOutUp && !regularizationOnV2) aOutUp = relativeErrorRegularizationOutUp->GetBinContent(b+1);
2410 if(relativeErrorRecBinInUp) cInUp = relativeErrorRecBinInUp->GetBinContent(b+1);
2411 if(relativeErrorRecBinOutUp) cOutUp = relativeErrorRecBinOutUp->GetBinContent(b+1);
2412 if(relativeErrorMethodInUp) dInUp = relativeErrorMethodInUp->GetBinContent(b+1);
2413 if(relativeErrorMethodOutUp) dOutUp = relativeErrorMethodOutUp->GetBinContent(b+1);
2415 if(relativeErrorRegularizationInLow) aInLow = relativeErrorRegularizationInLow->GetBinContent(b+1);
2416 if(relativeErrorRegularizationOutLow) aOutLow = relativeErrorRegularizationOutLow->GetBinContent(b+1);
2417 if(relativeErrorRecBinInLow) cInLow = relativeErrorRecBinInLow->GetBinContent(b+1);
2418 if(relativeErrorRecBinOutLow) cOutLow = relativeErrorRecBinOutLow->GetBinContent(b+1);
2419 if(relativeErrorMethodInLow) dInLow = relativeErrorMethodInLow->GetBinContent(b+1);
2420 if(relativeErrorMethodOutLow) dOutLow = relativeErrorMethodOutLow->GetBinContent(b+1);
2429 if(aInLow > aInUp) { aInUp = aInLow;
2430 }
else {aInLow = aInUp;}
2431 if(aOutLow > aOutUp) { aOutUp = aOutLow;
2432 }
else { aOutLow = aOutUp;}
2433 if(cInLow > cInUp) { cInUp = cInLow;
2434 }
else {cInLow = cInUp; };
2435 if(cOutLow > cOutUp ) { cOutUp = cOutLow;
2436 }
else { cOutLow = cOutUp; }
2438 if(dInLow < dInUp) {dInLow = dInUp;
2439 }
else { dInUp = dInLow;}
2440 if(dOutLow < dOutUp) { dOutLow = dOutUp;
2441 }
else { dOutUp = dOutLow; }
2444 eInUp = aInUp*aInUp + cInUp*cInUp + dInUp*dInUp;
2445 if(eInUp > 0) relativeErrorInUp->SetBinContent(b+1, 1.*TMath::Sqrt(eInUp));
2446 eOutUp = aOutUp*aOutUp + cOutUp*cOutUp + dOutUp*dOutUp;
2447 if(eOutUp > 0) relativeErrorOutUp->SetBinContent(b+1, 1.*TMath::Sqrt(eOutUp));
2449 eInLow = aInLow*aInLow + cInLow*cInLow + dInLow*dInLow;
2450 if(eInLow > 0) relativeErrorInLow->SetBinContent(b+1, -1.*TMath::Sqrt(eInLow));
2451 eOutLow = aOutLow*aOutLow + cOutLow*cOutLow + dOutLow*dOutLow;
2452 if(eOutLow > 0) relativeErrorOutLow->SetBinContent(b+1, -1.*TMath::Sqrt(eOutLow));
2454 printf(
"%i) \teInUp %.4f \t eInLow %.4f \t eOutUp %4.f \t eOutLow %4.f \n", b, eInUp, eInLow, eOutUp, eOutLow);
2470 lowErr = relativeErrorInLow->GetBinContent(i+1)*relativeErrorInLow->GetBinContent(i+1)+relativeErrorOutUp->GetBinContent(1+i)*relativeErrorOutUp->GetBinContent(i+1);
2471 upErr = relativeErrorInUp->GetBinContent(i+1)*relativeErrorInUp->GetBinContent(i+1)+relativeErrorOutLow->GetBinContent(i+1)*relativeErrorOutLow->GetBinContent(i+1);
2473 ayl[i] = TMath::Sqrt(lowErr)*nominal->GetBinContent(i+1);
2474 ayh[i] = TMath::Sqrt(upErr)*nominal->GetBinContent(i+1);
2476 Double_t binWidth(nominal->GetBinWidth(i+1));
2477 axl[i] = binWidth/2.;
2478 axh[i] = binWidth/2.;
2480 ax[i] = nominal->GetBinCenter(i+1);
2481 ay[i] = nominal->GetBinContent(i+1);
2487 nominalError->SetName(
"shape uncertainty");
2488 TCanvas* nominalCanvas(
new TCanvas(
"nominalCanvas",
"nominalCanvas"));
2489 nominalCanvas->Divide(2);
2490 nominalCanvas->cd(1);
2491 Style(nominal, kBlack);
2493 nominalError->SetLineColor(kCyan);
2494 nominalError->SetMarkerColor(kCyan);
2495 nominalError->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
2496 nominalError->GetYaxis()->SetRangeUser(.7, 2.2);
2497 nominalError->DrawClone(
"a2");
2498 nominal->DrawCopy(
"same E1");
2500 Style(gPad,
"GRID");
2501 Style(nominalCanvas);
2507 "v_{2} with shape uncertainty",
2511 relativeErrorOutLow,
2518 nominalCanvas->cd(2);
2519 Style(nominalV2, kBlack);
2521 nominalV2Error->SetLineColor(kCyan);
2522 nominalV2Error->SetMarkerColor(kCyan);
2523 nominalV2Error->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
2524 nominalV2Error->DrawClone(
"a2");
2525 nominalV2->DrawClone(
"same E1");
2527 Style(gPad,
"GRID");
2528 Style(nominalCanvas);
2530 nominalCanvas->Write();
2532 TCanvas* relativeError(
new TCanvas(
"relativeError",
" relativeError"));
2533 relativeError->Divide(2);
2534 relativeError->cd(1);
2535 Style(gPad,
"GRID");
2536 relativeErrorInUp->GetYaxis()->SetRangeUser(-1.5, 3.);
2538 Style(relativeErrorInLow, kGreen,
kBar);
2539 relativeErrorInUp->DrawCopy(
"b");
2540 relativeErrorInLow->DrawCopy(
"same b");
2541 Style(relativeStatisticalErrorIn, kRed);
2542 relativeStatisticalErrorIn->DrawCopy(
"same");
2544 relativeError->cd(2);
2545 Style(gPad,
"GRID");
2547 Style(relativeErrorOutLow, kGreen,
kBar);
2548 relativeErrorOutUp->DrawCopy(
"b");
2549 if(relativeErrorOutLow) relativeErrorOutLow->DrawCopy(
"same b");
2550 if(relativeStatisticalErrorOut)
Style(relativeStatisticalErrorOut, kRed);
2551 if(relativeStatisticalErrorOut) relativeStatisticalErrorOut->DrawCopy(
"same");
2556 relativeError->Write();
2563 TH1D*& relativeErrorInUp,
2564 TH1D*& relativeErrorInLow,
2565 TH1D*& relativeErrorOutUp,
2566 TH1D*& relativeErrorOutLow,
2567 TH1D*& relativeStatisticalErrorIn,
2568 TH1D*& relativeStatisticalErrorOut,
2581 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
2582 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
2588 printf(
" >>> systematic wrapper called for %s <<< \n", source.Data());
2594 return (this->*myFunction)(
2600 relativeErrorOutLow,
2601 relativeStatisticalErrorIn,
2602 relativeStatisticalErrorOut,
2617 TH1D*& relativeErrorInUp,
2618 TH1D*& relativeErrorInLow,
2619 TH1D*& relativeErrorOutUp,
2620 TH1D*& relativeErrorOutLow,
2621 TH1D*& relativeStatisticalErrorIn,
2622 TH1D*& relativeStatisticalErrorOut,
2634 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
2635 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
2638 TList* listOfKeys((
TList*)readMe->GetListOfKeys());
2640 printf(
" > Fatal error, couldn't retrieve list of keys. Input file might have been corrupted ! < \n");
2644 if(variationsIn->GetSize() != variationsOut->GetSize()) {
2645 printf(
" > DoSystematics: fatal error, input arrays have different sizes ! < \n ");
2648 TDirectoryFile* defRootDirIn(dynamic_cast<TDirectoryFile*>(readMe->Get(listOfKeys->At(variationsIn->At(0))->GetName())));
2649 TDirectoryFile* defRootDirOut(dynamic_cast<TDirectoryFile*>(readMe->Get(listOfKeys->At(variationsOut->At(0))->GetName())));
2650 if(!(defRootDirIn && defRootDirOut)) {
2651 printf(
" > DoSystematics: fatal error, couldn't retrieve nominal values ! < \n ");
2654 TString defIn(defRootDirIn->GetName());
2655 TString defOut(defRootDirOut->GetName());
2658 TLine* lineLow(
new TLine(rangeLow, 0., rangeLow, 2.));
2659 TLine* lineUp(
new TLine(rangeUp, 0., rangeUp, 2.));
2660 lineLow->SetLineColor(11);
2661 lineUp->SetLineColor(11);
2662 lineLow->SetLineWidth(3);
2663 lineUp->SetLineWidth(3);
2670 relativeErrorInUp =
new TH1D(Form(
"relative error (up) from %s", source.Data()), Form(
"relative error (up) from %s", source.Data()),
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray());
2671 relativeErrorInLow =
new TH1D(Form(
"relative error (low) from %s", source.Data()), Form(
"relative error (low) from %s", source.Data()),
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray());
2672 relativeErrorOutUp =
new TH1D(Form(
"relative error (up) from %s", source.Data()), Form(
"relative error (up) from %s", source.Data()),
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray());
2673 relativeErrorOutLow =
new TH1D(Form(
"relative error (low) from %s", source.Data()), Form(
"relative error (low) from %s", source.Data()),
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray());
2676 relativeErrorInUp->SetBinContent(b+1, 1.);
2677 relativeErrorInUp->SetBinError(b+1, 0.);
2678 relativeErrorOutUp->SetBinContent(b+1, 1.);
2679 relativeErrorOutUp->SetBinError(b+1, .0);
2680 relativeErrorInLow->SetBinContent(b+1, 1.);
2681 relativeErrorInLow->SetBinError(b+1, 0.);
2682 relativeErrorOutLow->SetBinContent(b+1, 1.);
2683 relativeErrorOutLow->SetBinError(b+1, .0);
2685 relativeErrorInUp->SetBinContent(b+1, 0.);
2686 relativeErrorInUp->SetBinError(b+1, 0.);
2687 relativeErrorOutUp->SetBinContent(b+1, 0.);
2688 relativeErrorOutUp->SetBinError(b+1, 0.);
2689 relativeErrorInLow->SetBinContent(b+1, 0.);
2690 relativeErrorInLow->SetBinError(b+1, 0.);
2691 relativeErrorOutLow->SetBinContent(b+1, 0.);
2692 relativeErrorOutLow->SetBinError(b+1, 0.);
2695 Int_t relativeErrorInUpN[100] = {0};
2696 Int_t relativeErrorOutUpN[100] = {0};
2697 Int_t relativeErrorInLowN[100] = {0};
2698 Int_t relativeErrorOutLowN[100] = {0};
2701 if(!relativeStatisticalErrorIn || !relativeStatisticalErrorOut) {
2702 relativeStatisticalErrorIn =
new TH1D(
"relative statistical error, in plane",
"relative statistical error, in plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray());
2703 relativeStatisticalErrorOut =
new TH1D(
"relative statistical error, out of plane",
"relative statistital error, out of plane",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray());
2707 TCanvas* canvasIn(
new TCanvas(Form(
"SYST_%s_PearsonIn", source.Data()), Form(
"SYST_%s_PearsonIn", source.Data())));
2708 TCanvas* canvasOut(0x0);
2709 if(
fDphiUnfolding) canvasOut =
new TCanvas(Form(
"SYST_%s_PearsonOut", source.Data()), Form(
"SYST_%s_PearsonOut", source.Data()));
2710 TCanvas* canvasRatioMeasuredRefoldedIn(
new TCanvas(Form(
"SYST_%s_RefoldedIn", source.Data()), Form(
"SYST_%s_RefoldedIn", source.Data())));
2711 TCanvas* canvasRatioMeasuredRefoldedOut(0x0);
2712 if(
fDphiUnfolding) canvasRatioMeasuredRefoldedOut =
new TCanvas(Form(
"SYST_%s_RefoldedOut", source.Data()), Form(
"SYST_%s_RefoldedOut", source.Data()));
2713 TCanvas* canvasSpectraIn(
new TCanvas(Form(
"SYST_%s_SpectraIn", source.Data()), Form(
"SYST_%s_SpectraIn", source.Data())));
2714 TCanvas* canvasSpectraOut(0x0);
2715 if(
fDphiUnfolding) canvasSpectraOut =
new TCanvas(Form(
"SYST_%s_SpectraOut", source.Data()), Form(
"SYST_%s_SpectraOut", source.Data()));
2716 TCanvas* canvasRatio(0x0);
2717 if(
fDphiUnfolding) canvasRatio =
new TCanvas(Form(
"SYST_%s_Ratio", source.Data()), Form(
"SYST_%s_Ratio", source.Data()));
2718 TCanvas* canvasV2(0x0);
2719 if(
fDphiUnfolding) canvasV2 =
new TCanvas(Form(
"SYST_%s_V2", source.Data()), Form(
"SYST_%s_V2", source.Data()));
2720 TCanvas* canvasMISC(
new TCanvas(Form(
"SYST_%s_MISC", source.Data()), Form(
"SYST_%s_MISC", source.Data())));
2721 TCanvas* canvasMasterIn(
new TCanvas(Form(
"SYST_%s_defaultIn", source.Data()), Form(
"SYST_%s_defaultIn", source.Data())));
2722 TCanvas* canvasMasterOut(0x0);
2723 if(
fDphiUnfolding) canvasMasterOut =
new TCanvas(Form(
"SYST_%s_defaultOut", source.Data()), Form(
"SYST_%s_defaultOut", source.Data()));
2724 (
fDphiUnfolding) ? canvasMISC->Divide(4, 2) : canvasMISC->Divide(4, 1);
2726 TCanvas* canvasProfiles(
new TCanvas(Form(
"SYST_%s_canvasProfiles", source.Data()), Form(
"SYST_%s_canvasProfiles", source.Data())));
2727 canvasProfiles->Divide(2);
2728 TProfile* ratioProfile(
new TProfile(Form(
"SYST_%s_ratioProfile", source.Data()), Form(
"SYST_%s_ratioProfile", source.Data()),
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2729 TProfile* v2Profile(
new TProfile(Form(
"SYST_%s_v2Profile", source.Data()), Form(
"SYST_%s_v2Profile", source.Data()),
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
2733 columns = variationsIn->GetSize()-1;
2734 (TMath::Floor(variationsIn->GetSize()/(float)columns)+((variationsIn->GetSize()%columns)>0));
2735 canvasIn->Divide(columns, rows);
2736 if(canvasOut) canvasOut->Divide(columns, rows);
2737 canvasRatioMeasuredRefoldedIn->Divide(columns, rows);
2738 if(canvasRatioMeasuredRefoldedOut) canvasRatioMeasuredRefoldedOut->Divide(columns, rows);
2739 canvasSpectraIn->Divide(columns, rows);
2740 if(canvasSpectraOut) canvasSpectraOut->Divide(columns, rows);
2741 if(canvasRatio) canvasRatio->Divide(columns, rows);
2742 if(canvasV2) canvasV2->Divide(columns, rows);
2743 canvasMasterIn->Divide(columns, rows);
2744 if(canvasMasterOut) canvasMasterOut->Divide(columns, rows);
2747 TCanvas* canvasNominalIn(
new TCanvas(Form(
"Nominal_%s_PearsonIn", source.Data()), Form(
"Nominal_%s_PearsonIn", source.Data())));
2748 TCanvas* canvasNominalOut(0x0);
2749 if(
fDphiUnfolding) canvasNominalOut =
new TCanvas(Form(
"Nominal_%s_PearsonOut", source.Data()), Form(
"Nominal_%s_PearsonOut", source.Data()));
2750 TCanvas* canvasNominalRatioMeasuredRefoldedIn(
new TCanvas(Form(
"Nominal_%s_RefoldedIn", source.Data()), Form(
"Nominal_%s_RefoldedIn", source.Data())));
2751 TCanvas* canvasNominalRatioMeasuredRefoldedOut(0x0);
2752 if(
fDphiUnfolding) canvasNominalRatioMeasuredRefoldedOut =
new TCanvas(Form(
"Nominal_%s_RefoldedOut", source.Data()), Form(
"Nominal_%s_RefoldedOut", source.Data()));
2753 TCanvas* canvasNominalSpectraIn(
new TCanvas(Form(
"Nominal_%s_SpectraIn", source.Data()), Form(
"Nominal_%s_SpectraIn", source.Data())));
2754 TCanvas* canvasNominalSpectraOut(0x0);
2755 if(
fDphiUnfolding) canvasNominalSpectraOut =
new TCanvas(Form(
"Nominal_%s_SpectraOut", source.Data()), Form(
"Nominal_%s_SpectraOut", source.Data()));
2756 TCanvas* canvasNominalRatio(0x0);
2757 if(
fDphiUnfolding) canvasNominalRatio =
new TCanvas(Form(
"Nominal_%s_Ratio", source.Data()), Form(
"Nominal_%s_Ratio", source.Data()));
2758 TCanvas* canvasNominalV2(0x0);
2759 if(
fDphiUnfolding) canvasNominalV2 =
new TCanvas(Form(
"Nominal_%s_V2", source.Data()), Form(
"Nominal_%s_V2", source.Data()));
2760 TCanvas* canvasNominalMISC(
new TCanvas(Form(
"Nominal_%s_MISC", source.Data()), Form(
"Nominal_%s_MISC", source.Data())));
2761 TCanvas* canvasNominalMasterIn(
new TCanvas(Form(
"Nominal_%s_defaultIn", source.Data()), Form(
"Nominal_%s_defaultIn", source.Data())));
2762 TCanvas* canvasNominalMasterOut(0x0);
2763 if(
fDphiUnfolding) canvasNominalMasterOut =
new TCanvas(Form(
"Nominal_%s_defaultOut", source.Data()), Form(
"Nominal_%s_defaultOut", source.Data()));
2764 (
fDphiUnfolding) ? canvasNominalMISC->Divide(4, 2) : canvasNominalMISC->Divide(4, 1);
2766 canvasNominalSpectraIn->Divide(2);
2767 if(canvasNominalSpectraOut) canvasNominalSpectraOut->Divide(2);
2769 canvasNominalMasterIn->Divide(2);
2770 if(canvasNominalMasterOut) canvasNominalMasterOut->Divide(2);
2773 TH1D* defaultUnfoldedJetSpectrumIn(0x0);
2774 TH1D* defaultUnfoldedJetSpectrumOut(0x0);
2775 TDirectoryFile* defDirIn = (TDirectoryFile*)defRootDirIn->Get(Form(
"InPlane___%s", defIn.Data()));
2776 TDirectoryFile* defDirOut = (TDirectoryFile*)defRootDirOut->Get(Form(
"OutOfPlane___%s", defOut.Data()));
2777 if(defDirIn) defaultUnfoldedJetSpectrumIn = (
TH1D*)defDirIn->Get(Form(
"UnfoldedSpectrum_in_%s", defIn.Data()));
2778 if(defDirOut) defaultUnfoldedJetSpectrumOut = (
TH1D*)defDirOut->Get(Form(
"UnfoldedSpectrum_out_%s", defOut.Data()));
2779 printf(
" > succesfully extracted default results < \n");
2782 TDirectoryFile* tempDirIn(0x0);
2783 TDirectoryFile* tempDirOut(0x0);
2784 TDirectoryFile* tempIn(0x0);
2785 TDirectoryFile* tempOut(0x0);
2786 TH1D* unfoldedSpectrumInForRatio(0x0);
2787 TH1D* unfoldedSpectrumOutForRatio(0x0);
2788 for(
Int_t i(0), j(-1); i < variationsIn->GetSize(); i++) {
2789 tempDirIn = (
dynamic_cast<TDirectoryFile*
>(readMe->Get(listOfKeys->At(variationsIn->At(i))->GetName())));
2790 tempDirOut = (
dynamic_cast<TDirectoryFile*
>(readMe->Get(listOfKeys->At(variationsOut->At(i))->GetName())));
2791 if(!(tempDirIn && tempDirOut)) {
2792 printf(
" > DoSystematics: couldn't get a set of variations < \n");
2795 TString dirNameIn(tempDirIn->GetName());
2796 TString dirNameOut(tempDirOut->GetName());
2798 tempIn = (TDirectoryFile*)tempDirIn->Get(Form(
"InPlane___%s", dirNameIn.Data()));
2799 tempOut = (TDirectoryFile*)tempDirOut->Get(Form(
"OutOfPlane___%s", dirNameOut.Data()));
2803 TH2D* pIn((
TH2D*)tempIn->Get(Form(
"PearsonCoefficients_in_%s", dirNameIn.Data())));
2805 printf(
" - %s in plane converged \n", dirNameIn.Data());
2807 if(i==0) canvasNominalIn->cd(j);
2808 Style(gPad,
"PEARSON");
2809 pIn->DrawCopy(
"colz");
2813 printf(
" > found RatioRefoldedMeasured < \n");
2814 canvasRatioMeasuredRefoldedIn->cd(j);
2815 if(i==0) canvasNominalRatioMeasuredRefoldedIn->cd(j);
2816 Style(gPad,
"GRID");
2817 rIn->SetFillColor(kRed);
2820 TH1D* dvector((
TH1D*)tempIn->Get(
"dVector"));
2821 TH1D* avalue((
TH1D*)tempIn->Get(
"SingularValuesOfAC"));
2822 TH2D* rm((
TH2D*)tempIn->Get(Form(
"ResponseMatrixIn_%s", dirNameIn.Data())));
2823 TH1D* eff((
TH1D*)tempIn->Get(Form(
"KinematicEfficiencyIn_%s", dirNameIn.Data())));
2824 if(dvector && avalue && rm && eff) {
2830 if(i==0) canvasNominalMISC->cd(1);
2831 Style(gPad,
"SPECTRUM");
2832 dvector->DrawCopy();
2834 if(i==0) canvasNominalMISC->cd(2);
2835 Style(gPad,
"SPECTRUM");
2838 if(i==0) canvasNominalMISC->cd(3);
2839 Style(gPad,
"PEARSON");
2840 rm->DrawCopy(
"colz");
2842 if(i==0) canvasNominalMISC->cd(4);
2843 Style(gPad,
"GRID");
2845 }
else if(rm && eff) {
2849 if(i==0) canvasNominalMISC->cd(3);
2850 Style(gPad,
"PEARSON");
2851 rm->DrawCopy(
"colz");
2853 if(i==0) canvasNominalMISC->cd(4);
2854 Style(gPad,
"GRID");
2858 TH1D* inputSpectrum((
TH1D*)tempIn->Get(Form(
"InputSpectrum_in_%s", dirNameIn.Data())));
2859 TH1D* unfoldedSpectrum((
TH1D*)tempIn->Get(Form(
"UnfoldedSpectrum_in_%s", dirNameIn.Data())));
2860 unfoldedSpectrumInForRatio =
ProtectHeap(unfoldedSpectrum, kFALSE,
TString(
"ForRatio"));
2861 TH1D* refoldedSpectrum((
TH1D*)tempIn->Get(Form(
"RefoldedSpectrum_in_%s", dirNameIn.Data())));
2862 if(inputSpectrum && unfoldedSpectrum && refoldedSpectrum) {
2863 if(defaultUnfoldedJetSpectrumIn) {
2865 TH1D* temp((
TH1D*)defaultUnfoldedJetSpectrumIn->Clone(Form(
"defaultUnfoldedJetSpectrumIn_%s", dirNameIn.Data())));
2866 temp->Divide(unfoldedSpectrum);
2871 if( temp->GetBinContent(b+1) < 1 && temp->GetBinContent(b+1) < relativeErrorInUp->GetBinContent(b+1)) {
2872 relativeErrorInUp->SetBinContent(b+1, temp->GetBinContent(b+1));
2873 relativeErrorInUp->SetBinError(b+1, temp->GetBinError(b+1));
2876 else if(temp->GetBinContent(b+1) > 1 && temp->GetBinContent(b+1) > relativeErrorInLow->GetBinContent(b+1)) {
2877 relativeErrorInLow->SetBinContent(b+1, temp->GetBinContent(b+1));
2878 relativeErrorInLow->SetBinError(b+1, temp->GetBinError(b+1));
2881 printf(
" oops shouldnt be here \n " );
2882 if(temp->GetBinContent(b+1) < 1) {
2883 relativeErrorInUp->SetBinContent(b+1, relativeErrorInUp->GetBinContent(b+1)+TMath::Power(1.-temp->GetBinContent(b+1), 2));
2884 relativeErrorInUpN[b]++;
2887 else if(temp->GetBinContent(b+1) > 1) {
2888 relativeErrorInLow->SetBinContent(b+1, relativeErrorInLow->GetBinContent(b+1)+TMath::Power(1.-temp->GetBinContent(b+1), 2));
2889 relativeErrorInLowN[b]++;
2893 relativeErrorInUp->SetBinContent(b+1, relativeErrorInUp->GetBinContent(b+1)+TMath::Power(temp->GetBinContent(b+1)-1., 2));
2894 relativeErrorInUpN[b]++;
2896 if(temp->GetBinError(b+1) > 0) relativeStatisticalErrorIn->SetBinContent(b+1, temp->GetBinError(b+1)/temp->GetBinContent(b+1));
2898 temp->SetTitle(Form(
"[%s] / [%s]", defIn.Data(), dirNameIn.Data()));
2899 temp->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
2900 temp->GetYaxis()->SetTitle(
"ratio");
2901 canvasMasterIn->cd(j);
2902 temp->GetYaxis()->SetRangeUser(0., 2);
2903 Style(gPad,
"GRID");
2905 canvasNominalMasterIn->cd(1);
2906 Style(gPad,
"GRID");
2908 TH1D* tempSyst((
TH1D*)temp->Clone(Form(
"%s_syst", temp->GetName())));
2909 tempSyst->SetTitle(Form(
"[%s] / [%s]", defIn.Data(), dirNameIn.Data()));
2910 Style(tempSyst, (EColor)(i+2));
2911 if(i==1) tempSyst->DrawCopy();
2912 else tempSyst->DrawCopy(
"same");
2915 TH1F* fitStatus((TH1F*)tempIn->Get(Form(
"fitStatus_%s_in", dirNameIn.Data())));
2916 canvasSpectraIn->cd(j);
2917 if(i==0) canvasNominalSpectraIn->cd(1);
2920 unfoldedSpectrum->DrawCopy();
2922 inputSpectrum->DrawCopy(
"same");
2924 refoldedSpectrum->DrawCopy(
"same");
2927 if(fitStatus && fitStatus->GetNbinsX() == 4) {
2928 Float_t chi(fitStatus->GetBinContent(1));
2929 Float_t pen(fitStatus->GetBinContent(2));
2930 Int_t dof((
int)fitStatus->GetBinContent(3));
2931 Float_t beta(fitStatus->GetBinContent(4));
2932 l->AddEntry((
TObject*)0, Form(
"#chi %.2f \tP %.2f \tDOF %i, #beta %.2f", chi, pen, dof, beta),
"");
2933 }
else if (fitStatus) {
2934 Int_t reg((
int)fitStatus->GetBinContent(1));
2935 l->AddEntry((
TObject*)0, Form(
"REG %i", reg),
"");
2937 canvasNominalSpectraIn->cd(2);
2938 TH1D* tempSyst((
TH1D*)unfoldedSpectrum->Clone(Form(
"%s_syst", unfoldedSpectrum->GetName())));
2939 tempSyst->SetTitle(Form(
"[%s]", dirNameIn.Data()));
2940 Style(tempSyst, (EColor)(i+2));
2941 Style(gPad,
"SPECTRUM");
2942 if(i==0) tempSyst->DrawCopy();
2943 else tempSyst->DrawCopy(
"same");
2947 TH2D* pOut((
TH2D*)tempOut->Get(Form(
"PearsonCoefficients_out_%s", dirNameOut.Data())));
2949 printf(
" - %s out of plane converged \n", dirNameOut.Data());
2951 if(i==0) canvasNominalOut->cd(j);
2952 Style(gPad,
"PEARSON");
2953 pOut->DrawCopy(
"colz");
2957 printf(
" > found RatioRefoldedMeasured < \n");
2958 canvasRatioMeasuredRefoldedOut->cd(j);
2959 if(i==0) canvasNominalRatioMeasuredRefoldedOut->cd(j);
2960 Style(gPad,
"GRID");
2961 rOut->SetFillColor(kRed);
2964 TH1D* dvector((
TH1D*)tempOut->Get(
"dVector"));
2965 TH1D* avalue((
TH1D*)tempOut->Get(
"SingularValuesOfAC"));
2966 TH2D* rm((
TH2D*)tempOut->Get(Form(
"ResponseMatrixOut_%s", dirNameOut.Data())));
2967 TH1D* eff((
TH1D*)tempOut->Get(Form(
"KinematicEfficiencyOut_%s", dirNameOut.Data())));
2968 if(dvector && avalue && rm && eff) {
2974 if(i==0) canvasNominalMISC->cd(5);
2975 Style(gPad,
"SPECTRUM");
2976 dvector->DrawCopy();
2978 if(i==0) canvasNominalMISC->cd(6);
2979 Style(gPad,
"SPECTRUM");
2982 if(i==0) canvasNominalMISC->cd(7);
2983 Style(gPad,
"PEARSON");
2984 rm->DrawCopy(
"colz");
2986 if(i==0) canvasNominalMISC->cd(8);
2987 Style(gPad,
"GRID");
2989 }
else if(rm && eff) {
2993 if(i==0) canvasNominalMISC->cd(7);
2994 Style(gPad,
"PEARSON");
2995 rm->DrawCopy(
"colz");
2997 if(i==0) canvasNominalMISC->cd(8);
2998 Style(gPad,
"GRID");
3002 TH1D* inputSpectrum((
TH1D*)tempOut->Get(Form(
"InputSpectrum_out_%s", dirNameOut.Data())));
3003 TH1D* unfoldedSpectrum((
TH1D*)tempOut->Get(Form(
"UnfoldedSpectrum_out_%s", dirNameOut.Data())));
3004 unfoldedSpectrumOutForRatio =
ProtectHeap(unfoldedSpectrum, kFALSE,
TString(
"ForRatio"));
3005 TH1D* refoldedSpectrum((
TH1D*)tempOut->Get(Form(
"RefoldedSpectrum_out_%s", dirNameOut.Data())));
3006 if(inputSpectrum && unfoldedSpectrum && refoldedSpectrum) {
3007 if(defaultUnfoldedJetSpectrumOut) {
3009 TH1D* temp((
TH1D*)defaultUnfoldedJetSpectrumOut->Clone(Form(
"defaultUnfoldedJetSpectrumOut_%s", dirNameOut.Data())));
3010 temp->Divide(unfoldedSpectrum);
3015 if(temp->GetBinContent(b+1) < 1 && temp->GetBinContent(b+1) < relativeErrorOutUp->GetBinContent(b+1)) {
3016 relativeErrorOutUp->SetBinContent(b+1, temp->GetBinContent(b+1));
3017 relativeErrorOutUp->SetBinError(b+1, temp->GetBinError(b+1));
3020 else if(temp->GetBinContent(b+1) > 1 && temp->GetBinContent(b+1) > relativeErrorOutLow->GetBinContent(b+1)) {
3021 relativeErrorOutLow->SetBinContent(b+1, temp->GetBinContent(b+1));
3022 relativeErrorOutLow->SetBinError(b+1, temp->GetBinError(b+1));
3025 printf(
" OOps \n ");
3026 if(temp->GetBinContent(b+1) < 1) {
3027 relativeErrorOutUp->SetBinContent(b+1, relativeErrorOutUp->GetBinContent(b+1)+TMath::Power(1.-temp->GetBinContent(b+1), 2));
3028 relativeErrorOutUpN[b]++;
3030 else if(temp->GetBinContent(b+1) > 1) {
3031 relativeErrorOutLow->SetBinContent(b+1, relativeErrorOutLow->GetBinContent(b+1)+TMath::Power(1.-temp->GetBinContent(b+1), 2));
3032 relativeErrorOutLowN[b]++;
3036 relativeErrorOutUp->SetBinContent(b+1, relativeErrorOutUp->GetBinContent(b+1)+TMath::Power(temp->GetBinContent(b+1)-1., 2));
3037 relativeErrorOutUpN[b]++;
3039 if(temp->GetBinError(b+1) > 0) relativeStatisticalErrorOut->SetBinContent(b+1, temp->GetBinError(b+1)/temp->GetBinContent(b+1));
3041 temp->SetTitle(Form(
"[%s] / [%s]", defOut.Data(), dirNameOut.Data()));
3042 temp->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
3043 temp->GetYaxis()->SetTitle(
"ratio");
3044 canvasMasterOut->cd(j);
3045 temp->GetYaxis()->SetRangeUser(0., 2);
3046 Style(gPad,
"GRID");
3048 canvasNominalMasterOut->cd(1);
3049 Style(gPad,
"GRID");
3051 TH1D* tempSyst((
TH1D*)temp->Clone(Form(
"%s_syst", temp->GetName())));
3052 tempSyst->SetTitle(Form(
"[%s] / [%s]", defOut.Data(), dirNameOut.Data()));
3053 Style(tempSyst, (EColor)(i+2));
3054 if(i==1) tempSyst->DrawCopy();
3055 else tempSyst->DrawCopy(
"same");
3058 TH1F* fitStatus((TH1F*)tempOut->Get(Form(
"fitStatus_%s_out", dirNameOut.Data())));
3059 canvasSpectraOut->cd(j);
3060 if(i==0) canvasNominalSpectraOut->cd(1);
3063 unfoldedSpectrum->DrawCopy();
3065 inputSpectrum->DrawCopy(
"same");
3067 refoldedSpectrum->DrawCopy(
"same");
3070 if(fitStatus && fitStatus->GetNbinsX() == 4) {
3071 Float_t chi(fitStatus->GetBinContent(1));
3072 Float_t pen(fitStatus->GetBinContent(2));
3073 Int_t dof((
int)fitStatus->GetBinContent(3));
3074 Float_t beta(fitStatus->GetBinContent(4));
3075 l->AddEntry((
TObject*)0, Form(
"#chi %.2f \tP %.2f \tDOF %i, #beta %.2f", chi, pen, dof, beta),
"");
3076 }
else if (fitStatus) {
3077 Int_t reg((
int)fitStatus->GetBinContent(1));
3078 l->AddEntry((
TObject*)0, Form(
"REG %i", reg),
"");
3080 canvasNominalSpectraOut->cd(2);
3081 TH1D* tempSyst((
TH1D*)unfoldedSpectrum->Clone(Form(
"%s_syst", unfoldedSpectrum->GetName())));
3082 tempSyst->SetTitle(Form(
"[%s]", dirNameOut.Data()));
3083 Style(tempSyst, (EColor)(i+2));
3084 Style(gPad,
"SPECTRUM");
3085 if(i==0) tempSyst->DrawCopy();
3086 else tempSyst->DrawCopy(
"same");
3089 if(canvasRatio && canvasV2) {
3092 canvasNominalRatio->cd(j);
3093 if(nominal && nominalIn && nominalOut) {
3098 nominalIn = (
TH1D*)unfoldedSpectrumInForRatio->Clone(
"in plane jet yield");
3099 nominalOut = (
TH1D*)unfoldedSpectrumOutForRatio->Clone(
"out of plane jet yield");
3100 nominal = (
TH1D*)unfoldedSpectrumInForRatio->Clone(
"ratio in plane out of plane");
3101 nominal->Divide(nominal, unfoldedSpectrumOutForRatio);
3104 TGraphErrors* ratioYield(
GetRatio(unfoldedSpectrumInForRatio, unfoldedSpectrumOutForRatio,
TString(Form(
"ratio [in=%s, out=%s]", dirNameIn.Data(), dirNameOut.Data()))));
3109 ratioYield->GetPoint(b, _tempx, _tempy);
3110 ratioProfile->Fill(_tempx, _tempy);
3112 ratioProfile->GetYaxis()->SetRangeUser(-0., 2.);
3113 ratioProfile->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
3114 ratioYield->GetYaxis()->SetRangeUser(-0., 2.);
3115 ratioYield->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
3116 ratioYield->SetFillColor(kRed);
3117 ratioYield->Draw(
"ap");
3120 if(i==0) canvasNominalV2->cd(j);
3125 ratioV2->GetPoint(b, _tempx, _tempy);
3126 v2Profile->Fill(_tempx, _tempy);
3129 v2Profile->GetYaxis()->SetRangeUser(-0., 2.);
3130 v2Profile->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
3131 ratioV2->GetYaxis()->SetRangeUser(-.25, .75);
3132 ratioV2->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
3133 ratioV2->SetFillColor(kRed);
3134 ratioV2->Draw(
"ap");
3137 delete unfoldedSpectrumInForRatio;
3138 delete unfoldedSpectrumOutForRatio;
3141 canvasProfiles->cd(1);
3142 Style(ratioProfile);
3143 ratioProfile->DrawCopy();
3144 canvasProfiles->cd(2);
3146 v2Profile->DrawCopy();
3148 canvasProfiles->Write();
3156 canvasRatioMeasuredRefoldedIn->Write();
3157 if(canvasRatioMeasuredRefoldedOut) {
3159 canvasRatioMeasuredRefoldedOut->Write();
3162 canvasSpectraIn->Write();
3163 if(canvasSpectraOut) {
3165 canvasSpectraOut->Write();
3167 canvasRatio->Write();
3172 canvasMasterIn->Write();
3173 if(canvasMasterOut) {
3175 canvasMasterOut->Write();
3178 canvasMISC->Write();
3181 canvasNominalIn->Write();
3182 if(canvasNominalOut) {
3184 canvasNominalOut->Write();
3187 canvasNominalRatioMeasuredRefoldedIn->Write();
3188 if(canvasNominalRatioMeasuredRefoldedOut) {
3190 canvasNominalRatioMeasuredRefoldedOut->Write();
3192 canvasNominalSpectraIn->cd(2);
3195 canvasNominalSpectraIn->Write();
3196 if(canvasNominalSpectraOut) {
3197 canvasNominalSpectraOut->cd(2);
3200 canvasNominalSpectraOut->Write();
3202 canvasNominalRatio->Write();
3204 canvasNominalV2->Write();
3206 canvasNominalMasterIn->cd(1);
3208 lineUp->DrawClone(
"same");
3209 lineLow->DrawClone(
"same");
3211 canvasNominalMasterIn->Write();
3212 if(canvasNominalMasterOut) {
3213 canvasNominalMasterOut->cd(1);
3215 lineUp->DrawClone(
"same");
3216 lineLow->DrawClone(
"same");
3218 canvasNominalMasterOut->Write();
3221 canvasNominalMISC->Write();
3227 relativeErrorInUp->SetBinContent(b+1, -1.*(relativeErrorInUp->GetBinContent(b+1)-1));
3229 relativeErrorOutUp->SetBinContent(b+1, -1.*(relativeErrorOutUp->GetBinContent(b+1)-1));
3231 relativeErrorInLow->SetBinContent(b+1, -1.*(relativeErrorInLow->GetBinContent(b+1)-1));
3233 relativeErrorOutLow->SetBinContent(b+1, -1.*(relativeErrorOutLow->GetBinContent(b+1)-1));
3240 if(relativeErrorInUpN[b] < 1) relativeErrorInUpN[b] = 1;
3241 if(relativeErrorInLowN[b] < 1) relativeErrorInLowN[b] = 1;
3242 if(relativeErrorOutUpN[b] < 1) relativeErrorOutUpN[b] = 1;
3243 if(relativeErrorOutLowN[b] < 1) relativeErrorOutLowN[b] = 1;
3244 relativeErrorInUp->SetBinContent(b+1, TMath::Sqrt(relativeErrorInUp->GetBinContent(b+1)/relativeErrorInUpN[b]));
3246 relativeErrorOutUp->SetBinContent(b+1, TMath::Sqrt(relativeErrorOutUp->GetBinContent(b+1)/relativeErrorOutUpN[b]));
3248 relativeErrorInLow->SetBinContent(b+1, -1.*TMath::Sqrt(relativeErrorInLow->GetBinContent(b+1)/relativeErrorInLowN[b]));
3250 relativeErrorOutLow->SetBinContent(b+1, -1.*TMath::Sqrt(relativeErrorOutLow->GetBinContent(b+1)/relativeErrorOutLowN[b]));
3253 if(relativeErrorInUpN[b] < 1) relativeErrorInUpN[b] = 1;
3254 if(relativeErrorOutUpN[b] < 1) relativeErrorOutUpN[b] = 1;
3255 relativeErrorInUp->SetBinContent(b+1, TMath::Sqrt(relativeErrorInUp->GetBinContent(b+1)/relativeErrorInUpN[b]));
3256 relativeErrorOutUp->SetBinContent(b+1, TMath::Sqrt(relativeErrorOutUp->GetBinContent(b+1)/relativeErrorOutUpN[b]));
3260 relativeErrorInUp->SetYTitle(
"relative uncertainty");
3261 relativeErrorOutUp->SetYTitle(
"relative uncertainty");
3262 relativeErrorInLow->SetYTitle(
"relative uncertainty");
3263 relativeErrorOutLow->SetYTitle(
"relative uncertainty");
3264 relativeErrorInUp->GetYaxis()->SetRangeUser(-1.5, 3.);
3265 relativeErrorInLow->GetYaxis()->SetRangeUser(-1.5, 3.);
3266 relativeErrorOutUp->GetYaxis()->SetRangeUser(-1.5, 3.);
3267 relativeErrorOutLow->GetYaxis()->SetRangeUser(-1.5, 3.);
3269 canvasNominalMasterIn->cd(2);
3270 Style(gPad,
"GRID");
3272 Style(relativeErrorInLow, kGreen,
kBar);
3273 relativeErrorInUp->DrawCopy(
"b");
3274 relativeErrorInLow->DrawCopy(
"same b");
3277 canvasNominalMasterIn->Write();
3278 canvasNominalMasterOut->cd(2);
3279 Style(gPad,
"GRID");
3281 Style(relativeErrorOutLow, kGreen,
kBar);
3282 relativeErrorOutUp->DrawCopy(
"b");
3283 relativeErrorOutLow->DrawCopy(
"same b");
3286 canvasNominalMasterOut->Write();
3292 TH1D*& relativeErrorInUp,
3293 TH1D*& relativeErrorInLow,
3294 TH1D*& relativeErrorOutUp,
3295 TH1D*& relativeErrorOutLow,
3296 TH1D*& relativeStatisticalErrorIn,
3297 TH1D*& relativeStatisticalErrorOut,
3309 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
3310 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
3313 if(relativeErrorInUp)
delete relativeErrorInUp;
3314 relativeErrorInUp =
new TH1D(Form(
"absolute_systematic_uncertainty_%s", source.Data()), Form(
"absolute_systematic_uncertainty_%s", source.Data()),
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray());
3317 for(
Int_t i(0); i < variationsIn->GetSize(); i++) {
3318 printf(
" variation %i of %i \n", i, variationsIn->GetSize());
3320 Int_t iIn[] = {variationsIn->At(i), variationsIn->At(i)};
3321 Int_t iOut[] = {variationsOut->At(i), variationsOut->At(i)};
3328 dud, dud, dud, dud, dud, dud, dud,
3335 Form(
"error_on_v2_variation_%i", i));
3337 printf(
" nominal in %i binsX \n", nominalIn->GetNbinsX());
3338 printf(
" nominal out %i binsX \n", nominalOut->GetNbinsX());
3343 printf(
" v2 in %i binsX \n", v2->GetNbinsX());
3348 for(
Int_t k(0); k < nominal->GetNbinsX(); k++) {
3350 relativeErrorInUp->SetBinContent(k+1, relativeErrorInUp->GetBinContent(k+1) + TMath::Power(v2->GetBinContent(k+1)-nominal->GetBinContent(k+1), 2));
3351 printf(
" nominal bin %i is %.4f \n", k+1, nominal->GetBinContent(k+1));
3352 printf(
" variati bin %i is %.4f \n", k+1, v2->GetBinContent(k+1));
3353 printf(
" sum of squared difference is %.4f \n", relativeErrorInUp->GetBinContent(k+1));
3361 for(
Int_t k(0); k < nominal->GetNbinsX(); k++) {
3362 relativeErrorInUp->SetBinError(k+1, TMath::Sqrt(relativeErrorInUp->GetBinContent(k+1)/((double)variationsIn->GetSize())));
3363 printf(
" total absolute error in bin %i is %.4f \n", k+1, relativeErrorInUp->GetBinError(k+1));
3364 relativeErrorInUp->SetBinContent(k+1, relativeErrorInUp->GetBinError(k+1)/nominal->GetBinContent(k+1));
3369 for(
Int_t k(3); k < 8; k++) {
3370 av+=relativeErrorInUp->GetBinError(k+1);
3371 avct+=relativeErrorInUp->GetBinContent(k+1);
3375 avct/=((double)ctr);
3376 for(
Int_t k(8); k < nominal->GetNbinsX(); k++) {
3377 relativeErrorInUp->SetBinError(k+1, av);
3378 relativeErrorInUp->SetBinContent(k+1, avct);
3385 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
3386 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
3391 TFile readMe(in.Data(),
"READ");
3392 if(readMe.IsZombie()) {
3393 printf(
" > Fatal error, couldn't read %s for post processing ! < \n", in.Data());
3396 printf(
"\n\n\n\t\t POSTPROCESSING \n > Recovered the following file structure : \n <");
3398 TList* listOfKeys((
TList*)readMe.GetListOfKeys());
3400 printf(
" > Fatal error, couldn't retrieve list of keys. Input file might have been corrupted ! < \n");
3404 TCanvas* canvasIn(
new TCanvas(
"PearsonIn",
"PearsonIn"));
3405 TCanvas* canvasOut(0x0);
3406 if(
fDphiUnfolding) canvasOut =
new TCanvas(
"PearsonOut",
"PearsonOut");
3407 TCanvas* canvasRatioMeasuredRefoldedIn(
new TCanvas(
"RefoldedIn",
"RefoldedIn"));
3408 TCanvas* canvasRatioMeasuredRefoldedOut(0x0);
3409 if(
fDphiUnfolding) canvasRatioMeasuredRefoldedOut =
new TCanvas(
"RefoldedOut",
"RefoldedOut");
3410 TCanvas* canvasSpectraIn(
new TCanvas(
"SpectraIn",
"SpectraIn"));
3411 TCanvas* canvasSpectraOut(0x0);
3412 if(
fDphiUnfolding) canvasSpectraOut =
new TCanvas(
"SpectraOut",
"SpectraOut");
3413 TCanvas* canvasRatio(0x0);
3415 TCanvas* canvasV2(0x0);
3417 TCanvas* canvasMISC(
new TCanvas(
"MISC",
"MISC"));
3418 TCanvas* canvasMasterIn(
new TCanvas(
"defaultIn",
"defaultIn"));
3419 TCanvas* canvasMasterOut(0x0);
3420 if(
fDphiUnfolding) canvasMasterOut =
new TCanvas(
"defaultOut",
"defaultOut");
3421 (
fDphiUnfolding) ? canvasMISC->Divide(4, 2) : canvasMISC->Divide(4, 1);
3422 TDirectoryFile* defDir(0x0);
3423 TCanvas* canvasProfiles(
new TCanvas(
"canvasProfiles",
"canvasProfiles"));
3424 canvasProfiles->Divide(2);
3425 TProfile* ratioProfile(
new TProfile(
"ratioProfile",
"ratioProfile",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
3426 TProfile* v2Profile(
new TProfile(
"v2Profile",
"v2Profile",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
3429 for(
Int_t i(0); i < listOfKeys->GetSize(); i++) {
3430 if(dynamic_cast<TDirectoryFile*>(readMe.Get(listOfKeys->At(i)->GetName()))) {
3431 if(!strcmp(listOfKeys->At(i)->GetName(), def.Data())) defDir =
dynamic_cast<TDirectoryFile*
>(readMe.Get(listOfKeys->At(i)->GetName()));
3435 Int_t rows(TMath::Floor(cacheMe/(
float)columns)+((cacheMe%columns)>0));
3436 canvasIn->Divide(columns, rows);
3437 if(canvasOut) canvasOut->Divide(columns, rows);
3438 canvasRatioMeasuredRefoldedIn->Divide(columns, rows);
3439 if(canvasRatioMeasuredRefoldedOut) canvasRatioMeasuredRefoldedOut->Divide(columns, rows);
3440 canvasSpectraIn->Divide(columns, rows);
3441 if(canvasSpectraOut) canvasSpectraOut->Divide(columns, rows);
3442 if(canvasRatio) canvasRatio->Divide(columns, rows);
3443 if(canvasV2) canvasV2->Divide(columns, rows);
3445 canvasMasterIn->Divide(columns, rows);
3446 if(canvasMasterOut) canvasMasterOut->Divide(columns, rows);
3448 TH1D* defaultUnfoldedJetSpectrumIn(0x0);
3449 TH1D* defaultUnfoldedJetSpectrumOut(0x0);
3451 TDirectoryFile* defDirIn = (TDirectoryFile*)defDir->Get(Form(
"InPlane___%s", def.Data()));
3452 TDirectoryFile* defDirOut = (TDirectoryFile*)defDir->Get(Form(
"OutOfPlane___%s", def.Data()));
3453 if(defDirIn) defaultUnfoldedJetSpectrumIn = (
TH1D*)defDirIn->Get(Form(
"UnfoldedSpectrum_in_%s", def.Data()));
3454 if(defDirOut) defaultUnfoldedJetSpectrumOut = (
TH1D*)defDirOut->Get(Form(
"UnfoldedSpectrum_out_%s", def.Data()));
3455 printf(
" > succesfully extracted default results < \n");
3459 TDirectoryFile* tempDir(0x0);
3460 TDirectoryFile* tempIn(0x0);
3461 TDirectoryFile* tempOut(0x0);
3462 for(
Int_t i(0), j(0); i < listOfKeys->GetSize(); i++) {
3464 tempDir =
dynamic_cast<TDirectoryFile*
>(readMe.Get(listOfKeys->At(i)->GetName()));
3465 if(!tempDir)
continue;
3466 TString dirName(tempDir->GetName());
3468 tempIn = (TDirectoryFile*)tempDir->Get(Form(
"InPlane___%s", dirName.Data()));
3469 tempOut = (TDirectoryFile*)tempDir->Get(Form(
"OutOfPlane___%s", dirName.Data()));
3472 TString stringArray[] = {
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h"};
3473 TCanvas* tempPearson(
new TCanvas(Form(
"pearson_%s", dirName.Data()), Form(
"pearson_%s", dirName.Data())));
3474 tempPearson->Divide(4,2);
3475 TCanvas* tempRatio(
new TCanvas(Form(
"ratio_%s", dirName.Data()), Form(
"ratio_%s", dirName.Data())));
3476 tempRatio->Divide(4,2);
3477 TCanvas* tempResult(
new TCanvas(Form(
"result_%s", dirName.Data()), Form(
"result_%s", dirName.Data())));
3478 tempResult->Divide(4,2);
3479 for(
Int_t q(0); q < 8; q++) {
3480 tempIn = (TDirectoryFile*)tempDir->Get(Form(
"%s___%s", stringArray[q].
Data(), dirName.Data()));
3483 TH2D* pIn((
TH2D*)tempIn->Get(Form(
"PearsonCoefficients_in_%s", dirName.Data())));
3485 printf(
" - %s in plane converged \n", dirName.Data());
3486 tempPearson->cd(1+q);
3487 Style(gPad,
"PEARSON");
3488 pIn->DrawCopy(
"colz");
3492 printf(
" > found RatioRefoldedMeasured < \n");
3494 rIn->SetFillColor(kRed);
3497 TH1D* dvector((
TH1D*)tempIn->Get(
"dVector"));
3498 TH1D* avalue((
TH1D*)tempIn->Get(
"SingularValuesOfAC"));
3499 TH2D* rm((
TH2D*)tempIn->Get(Form(
"ResponseMatrixIn_%s", dirName.Data())));
3500 TH1D* eff((
TH1D*)tempIn->Get(Form(
"KinematicEfficiencyIn_%s", dirName.Data())));
3501 if(dvector && avalue && rm && eff) {
3507 Style(gPad,
"SPECTRUM");
3508 dvector->DrawCopy();
3510 Style(gPad,
"SPECTRUM");
3513 Style(gPad,
"PEARSON");
3514 rm->DrawCopy(
"colz");
3516 Style(gPad,
"GRID");
3518 }
else if(rm && eff) {
3522 Style(gPad,
"PEARSON");
3523 rm->DrawCopy(
"colz");
3525 Style(gPad,
"GRID");
3529 TH1D* inputSpectrum((
TH1D*)tempIn->Get(Form(
"InputSpectrum_in_%s", dirName.Data())));
3530 TH1D* unfoldedSpectrum((
TH1D*)tempIn->Get(Form(
"UnfoldedSpectrum_in_%s", dirName.Data())));
3531 TH1D* refoldedSpectrum((
TH1D*)tempIn->Get(Form(
"RefoldedSpectrum_in_%s", dirName.Data())));
3532 if(inputSpectrum && unfoldedSpectrum && refoldedSpectrum) {
3533 if(defaultUnfoldedJetSpectrumIn) {
3535 TH1D* temp((
TH1D*)defaultUnfoldedJetSpectrumIn->Clone(Form(
"defaultUnfoldedJetSpectrumIn_%s", dirName.Data())));
3536 temp->Divide(unfoldedSpectrum);
3537 temp->SetTitle(Form(
"ratio default unfolded / %s", dirName.Data()));
3538 temp->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
3539 temp->GetYaxis()->SetTitle(Form(
"%s / %s", def.Data(), dirName.Data()));
3540 canvasMasterIn->cd(j);
3541 temp->GetYaxis()->SetRangeUser(0., 2);
3544 TH1F* fitStatus((TH1F*)tempIn->Get(Form(
"fitStatus_%s_in", dirName.Data())));
3545 tempResult->cd(q+1);
3548 unfoldedSpectrum->DrawCopy();
3550 inputSpectrum->DrawCopy(
"same");
3552 refoldedSpectrum->DrawCopy(
"same");
3555 if(fitStatus && fitStatus->GetNbinsX() == 4) {
3556 Float_t chi(fitStatus->GetBinContent(1));
3557 Float_t pen(fitStatus->GetBinContent(2));
3558 Int_t dof((
int)fitStatus->GetBinContent(3));
3559 Float_t beta(fitStatus->GetBinContent(4));
3560 l->AddEntry((
TObject*)0, Form(
"#chi %.2f \tP %.2f \tDOF %i, #beta %.2f", chi, pen, dof, beta),
"");
3561 }
else if (fitStatus) {
3562 Int_t reg((
int)fitStatus->GetBinContent(1));
3563 l->AddEntry((
TObject*)0, Form(
"REG %i", reg),
"");
3571 TH2D* pIn((
TH2D*)tempIn->Get(Form(
"PearsonCoefficients_in_%s", dirName.Data())));
3573 printf(
" - %s in plane converged \n", dirName.Data());
3575 Style(gPad,
"PEARSON");
3576 pIn->DrawCopy(
"colz");
3580 printf(
" > found RatioRefoldedMeasured < \n");
3581 canvasRatioMeasuredRefoldedIn->cd(j);
3582 rIn->SetFillColor(kRed);
3585 TH1D* dvector((
TH1D*)tempIn->Get(
"dVector"));
3586 TH1D* avalue((
TH1D*)tempIn->Get(
"SingularValuesOfAC"));
3587 TH2D* rm((
TH2D*)tempIn->Get(Form(
"ResponseMatrixIn_%s", dirName.Data())));
3588 TH1D* eff((
TH1D*)tempIn->Get(Form(
"KinematicEfficiencyIn_%s", dirName.Data())));
3589 if(dvector && avalue && rm && eff) {
3595 Style(gPad,
"SPECTRUM");
3596 dvector->DrawCopy();
3598 Style(gPad,
"SPECTRUM");
3601 Style(gPad,
"PEARSON");
3602 rm->DrawCopy(
"colz");
3604 Style(gPad,
"GRID");
3606 }
else if(rm && eff) {
3610 Style(gPad,
"PEARSON");
3611 rm->DrawCopy(
"colz");
3613 Style(gPad,
"GRID");
3617 TH1D* inputSpectrum((
TH1D*)tempIn->Get(Form(
"InputSpectrum_in_%s", dirName.Data())));
3618 TH1D* unfoldedSpectrum((
TH1D*)tempIn->Get(Form(
"UnfoldedSpectrum_in_%s", dirName.Data())));
3619 TH1D* refoldedSpectrum((
TH1D*)tempIn->Get(Form(
"RefoldedSpectrum_in_%s", dirName.Data())));
3620 if(inputSpectrum && unfoldedSpectrum && refoldedSpectrum) {
3621 if(defaultUnfoldedJetSpectrumIn) {
3623 TH1D* temp((
TH1D*)defaultUnfoldedJetSpectrumIn->Clone(Form(
"defaultUnfoldedJetSpectrumIn_%s", dirName.Data())));
3624 temp->Divide(unfoldedSpectrum);
3625 temp->SetTitle(Form(
"ratio default unfolded / %s", dirName.Data()));
3626 temp->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
3627 temp->GetYaxis()->SetTitle(Form(
"%s / %s", def.Data(), dirName.Data()));
3628 canvasMasterIn->cd(j);
3629 temp->GetYaxis()->SetRangeUser(0., 2);
3632 TH1F* fitStatus((TH1F*)tempIn->Get(Form(
"fitStatus_%s_in", dirName.Data())));
3633 canvasSpectraIn->cd(j);
3636 unfoldedSpectrum->DrawCopy();
3638 inputSpectrum->DrawCopy(
"same");
3640 refoldedSpectrum->DrawCopy(
"same");
3643 if(fitStatus && fitStatus->GetNbinsX() == 4) {
3644 Float_t chi(fitStatus->GetBinContent(1));
3645 Float_t pen(fitStatus->GetBinContent(2));
3646 Int_t dof((
int)fitStatus->GetBinContent(3));
3647 Float_t beta(fitStatus->GetBinContent(4));
3648 l->AddEntry((
TObject*)0, Form(
"#chi %.2f \tP %.2f \tDOF %i, #beta %.2f", chi, pen, dof, beta),
"");
3649 }
else if (fitStatus) {
3650 Int_t reg((
int)fitStatus->GetBinContent(1));
3651 l->AddEntry((
TObject*)0, Form(
"REG %i", reg),
"");
3656 TH2D* pOut((
TH2D*)tempOut->Get(Form(
"PearsonCoefficients_out_%s", dirName.Data())));
3658 printf(
" - %s out of plane converged \n", dirName.Data());
3660 Style(gPad,
"PEARSON");
3661 pOut->DrawCopy(
"colz");
3665 printf(
" > found RatioRefoldedMeasured < \n");
3666 canvasRatioMeasuredRefoldedOut->cd(j);
3667 rOut->SetFillColor(kRed);
3670 TH1D* dvector((
TH1D*)tempOut->Get(
"dVector"));
3671 TH1D* avalue((
TH1D*)tempOut->Get(
"SingularValuesOfAC"));
3672 TH2D* rm((
TH2D*)tempOut->Get(Form(
"ResponseMatrixOut_%s", dirName.Data())));
3673 TH1D* eff((
TH1D*)tempOut->Get(Form(
"KinematicEfficiencyOut_%s", dirName.Data())));
3674 if(dvector && avalue && rm && eff) {
3680 Style(gPad,
"SPECTRUM");
3681 dvector->DrawCopy();
3683 Style(gPad,
"SPECTRUM");
3686 Style(gPad,
"PEARSON");
3687 rm->DrawCopy(
"colz");
3689 Style(gPad,
"GRID");
3691 }
else if(rm && eff) {
3695 Style(gPad,
"PEARSON");
3696 rm->DrawCopy(
"colz");
3698 Style(gPad,
"GRID");
3702 TH1D* inputSpectrum((
TH1D*)tempOut->Get(Form(
"InputSpectrum_out_%s", dirName.Data())));
3703 TH1D* unfoldedSpectrum((
TH1D*)tempOut->Get(Form(
"UnfoldedSpectrum_out_%s", dirName.Data())));
3704 TH1D* refoldedSpectrum((
TH1D*)tempOut->Get(Form(
"RefoldedSpectrum_out_%s", dirName.Data())));
3705 if(inputSpectrum && unfoldedSpectrum && refoldedSpectrum) {
3706 if(defaultUnfoldedJetSpectrumOut) {
3708 TH1D* temp((
TH1D*)defaultUnfoldedJetSpectrumOut->Clone(Form(
"defaultUnfoldedJetSpectrumOut_%s", dirName.Data())));
3709 temp->Divide(unfoldedSpectrum);
3710 temp->SetTitle(Form(
"ratio default unfolded / %s", dirName.Data()));
3711 temp->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
3712 temp->GetYaxis()->SetTitle(Form(
"%s / %s", def.Data(), dirName.Data()));
3713 canvasMasterOut->cd(j);
3714 temp->GetYaxis()->SetRangeUser(0., 2.);
3717 TH1F* fitStatus((TH1F*)tempOut->Get(Form(
"fitStatus_%s_out", dirName.Data())));
3718 canvasSpectraOut->cd(j);
3721 unfoldedSpectrum->DrawCopy();
3723 inputSpectrum->DrawCopy(
"same");
3725 refoldedSpectrum->DrawCopy(
"same");
3728 if(fitStatus && fitStatus->GetNbinsX() == 4) {
3729 Float_t chi(fitStatus->GetBinContent(1));
3730 Float_t pen(fitStatus->GetBinContent(2));
3731 Int_t dof((
int)fitStatus->GetBinContent(3));
3732 Float_t beta(fitStatus->GetBinContent(4));
3733 l->AddEntry((
TObject*)0, Form(
"#chi %.2f \tP %.2f \tDOF %i, #beta %.2f", chi, pen, dof, beta),
"");
3734 }
else if (fitStatus) {
3735 Int_t reg((
int)fitStatus->GetBinContent(1));
3736 l->AddEntry((
TObject*)0, Form(
"REG %i", reg),
"");
3740 if(canvasRatio && canvasV2) {
3747 ratioYield->GetPoint(b, _tempx, _tempy);
3748 ratioProfile->Fill(_tempx, _tempy);
3750 ratioProfile->GetYaxis()->SetRangeUser(-0., 2.);
3751 ratioProfile->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
3752 ratioYield->GetYaxis()->SetRangeUser(-0., 2.);
3753 ratioYield->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
3754 ratioYield->SetFillColor(kRed);
3755 ratioYield->Draw(
"ap");
3762 ratioV2->GetPoint(b, _tempx, _tempy);
3763 v2Profile->Fill(_tempx, _tempy);
3766 v2Profile->GetYaxis()->SetRangeUser(-0., 2.);
3767 v2Profile->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
3768 ratioV2->GetYaxis()->SetRangeUser(-.25, .75);
3769 ratioV2->GetXaxis()->SetRangeUser(rangeLow, rangeUp);
3770 ratioV2->SetFillColor(kRed);
3771 ratioV2->Draw(
"ap");
3775 TFile output(out.Data(),
"RECREATE");
3776 canvasProfiles->cd(1);
3777 Style(ratioProfile);
3778 ratioProfile->DrawCopy();
3779 canvasProfiles->cd(2);
3781 v2Profile->DrawCopy();
3783 canvasProfiles->Write();
3791 canvasRatioMeasuredRefoldedIn->Write();
3792 if(canvasRatioMeasuredRefoldedOut) {
3794 canvasRatioMeasuredRefoldedOut->Write();
3797 canvasSpectraIn->Write();
3798 if(canvasSpectraOut) {
3800 canvasSpectraOut->Write();
3802 canvasRatio->Write();
3807 canvasMasterIn->Write();
3808 if(canvasMasterOut) {
3810 canvasMasterOut->Write();
3813 canvasMISC->Write();
3820 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
3821 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
3826 TFile readMe(in.Data(),
"READ");
3827 if(readMe.IsZombie()) {
3828 printf(
" > Fatal error, couldn't read %s for post processing ! < \n", in.Data());
3831 printf(
"\n\n\n\t\t BootstrapSpectra \n > Recovered the following file structure : \n <");
3833 TList* listOfKeys((
TList*)readMe.GetListOfKeys());
3835 printf(
" > Fatal error, couldn't retrieve list of keys. Input file might have been corrupted ! < \n");
3839 TDirectoryFile* defDir(0x0);
3840 for(
Int_t i(0); i < listOfKeys->GetSize(); i++) {
3841 if(dynamic_cast<TDirectoryFile*>(readMe.Get(listOfKeys->At(i)->GetName()))) {
3842 if(!strcmp(listOfKeys->At(i)->GetName(), def.Data())) defDir =
dynamic_cast<TDirectoryFile*
>(readMe.Get(listOfKeys->At(i)->GetName()));
3848 TH1D* defaultUnfoldedJetSpectrumIn(0x0);
3849 TH1D* defaultUnfoldedJetSpectrumOut(0x0);
3850 TH1D* defaultInputSpectrumIn(0x0);
3851 TH1D* defaultInputSpectrumOut(0x0);
3854 TDirectoryFile* defDirIn = (TDirectoryFile*)defDir->Get(Form(
"InPlane___%s", def.Data()));
3855 TDirectoryFile* defDirOut = (TDirectoryFile*)defDir->Get(Form(
"OutOfPlane___%s", def.Data()));
3857 defaultUnfoldedJetSpectrumIn = (
TH1D*)defDirIn->Get(Form(
"UnfoldedSpectrum_in_%s", def.Data()));
3858 defaultInputSpectrumIn = (
TH1D*)defDirIn->Get(Form(
"InputSpectrum_in_%s", def.Data()));
3861 defaultUnfoldedJetSpectrumOut = (
TH1D*)defDirOut->Get(Form(
"UnfoldedSpectrum_out_%s", def.Data()));
3862 defaultInputSpectrumOut = (
TH1D*)defDirOut->Get(Form(
"InputSpectrum_out_%s", def.Data()));
3865 if((!defaultUnfoldedJetSpectrumIn && defaultUnfoldedJetSpectrumOut)) {
3866 printf(
" BootstrapSpectra: couldn't extract default spectra, aborting! \n");
3869 else v2Emperical =
GetV2(defaultUnfoldedJetSpectrumIn, defaultUnfoldedJetSpectrumOut,
fEventPlaneRes);
3874 delta0[i] =
new TH1F(Form(
"delta%i_%.2f-%.2f_gev", i,
fBinsTrue->At(i),
fBinsTrue->At(i+1)), Form(
"#Delta_{0, %i} p_{T} %.2f-%.2f GeV/c", i,
fBinsTrue->At(i),
fBinsTrue->At(i+1)), 30, -1., 1.);
3878 TCanvas* spectraIn(
new TCanvas(
"spectraIn",
"spectraIn"));
3879 TCanvas* spectraOut(
new TCanvas(
"spectraOut",
"spectraOut"));
3881 TF1* commonReference =
new TF1(
"v2_strong_bkg_comb",
"(x<=3)*.07+(x>3&&x<5)*(.07-(x-3)*.035)+(x>30&&x<40)*(x-30)*.005+(x>40)*.05", 0, 200);
3884 TDirectoryFile* tempDir(0x0);
3885 TDirectoryFile* tempIn(0x0);
3886 TDirectoryFile* tempOut(0x0);
3887 TH1D* unfoldedSpectrumIn(0x0);
3888 TH1D* unfoldedSpectrumOut(0x0);
3889 TH1D* measuredSpectrumIn(0x0);
3890 TH1D* measuredSpectrumOut(0x0);
3891 for(
Int_t i(0), j(0); i < listOfKeys->GetSize(); i++) {
3893 tempDir =
dynamic_cast<TDirectoryFile*
>(readMe.Get(listOfKeys->At(i)->GetName()));
3894 if(!tempDir)
continue;
3895 TString dirName(tempDir->GetName());
3897 if(!dirName.Contains(
"bootstrap"))
continue;
3899 tempIn = (TDirectoryFile*)tempDir->Get(Form(
"InPlane___%s", dirName.Data()));
3900 tempOut = (TDirectoryFile*)tempDir->Get(Form(
"OutOfPlane___%s", dirName.Data()));
3904 if(!(
TH2D*)tempIn->Get(Form(
"PearsonCoefficients_in_%s", dirName.Data())))
continue;
3905 unfoldedSpectrumIn = (
TH1D*)tempIn->Get(Form(
"UnfoldedSpectrum_in_%s", dirName.Data()));
3906 measuredSpectrumIn = (
TH1D*)tempIn->Get(Form(
"InputSpectrum_in_%s", dirName.Data()));
3908 (j==1) ? measuredSpectrumIn->DrawCopy() : measuredSpectrumIn->DrawCopy(
"same");
3911 if(!(
TH2D*)tempOut->Get(Form(
"PearsonCoefficients_out_%s", dirName.Data())))
continue;
3912 unfoldedSpectrumOut = (
TH1D*)tempOut->Get(Form(
"UnfoldedSpectrum_out_%s", dirName.Data()));
3913 measuredSpectrumOut = (
TH1D*)tempOut->Get(Form(
"InputSpectrum_out_%s", dirName.Data()));
3915 (j==1) ? measuredSpectrumOut->DrawCopy() : measuredSpectrumOut->DrawCopy(
"same");
3920 Double_t yBoot(0), yEmp(0), xDud(0);
3924 v2Bootstrapped->GetPoint(k, xDud, yBoot);
3925 v2Emperical->GetPoint(k, xDud, yEmp);
3926 if(commonReference) {
3927 if(!commonReference->Eval(xDud)<1e-10) {
3928 yEmp/=commonReference->Eval(xDud);
3929 yBoot/=commonReference->Eval(xDud);
3935 cout <<
" yEmp " << yEmp <<
" yBoot " << yBoot << endl;
3937 if(TMath::Abs(yBoot)>1e-10) delta0[k]->Fill(yEmp - yBoot);
3943 TFile output(out.Data(),
"RECREATE");
3944 defaultInputSpectrumIn->SetLineColor(kRed);
3946 defaultInputSpectrumIn->DrawCopy(
"same");
3947 defaultInputSpectrumOut->SetLineColor(kRed);
3949 defaultInputSpectrumOut->DrawCopy(
"same");
3951 spectraOut->Write();
3953 TH1F* delta0spread(
new TH1F(
"delta0spread",
"#sigma(#Delta_{0})",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
3954 TH1F* unfoldingError(
new TH1F(
"unfoldingError",
"error from unfolding algorithm",
fBinsTrue->GetSize()-1,
fBinsTrue->GetArray()));
3955 TF1* gaus(
new TF1(
"gaus",
"gaus", -1., 1.));
3958 delta0[i]->Fit(gaus);
3959 delta0[i]->GetYaxis()->SetTitle(
"counts");
3960 delta0[i]->GetXaxis()->SetTitle(
"(v_{2, jet}^{measured} - v_{2, jet}^{generated}) / input v_{2}");
3961 delta0spread->SetBinContent(i+1, gaus->GetParameter(1));
3962 delta0spread->SetBinError(i+1, gaus->GetParameter(2));
3963 cout <<
" mean " << gaus->GetParameter(1) << endl;
3964 cout <<
" sigm " << gaus->GetParameter(2) << endl;
3966 v2Emperical->GetPoint(i, xDud, yDud);
3967 unfoldingError->SetBinContent(i+1, 1e-10);
3968 if(commonReference && !commonReference->Eval(xDud)<1e-10) unfoldingError->SetBinError(i+1, v2Emperical->GetErrorY(i)/(commonReference->Eval(xDud)));
3969 else if(yDud>10e-10) unfoldingError->SetBinError(i+1, v2Emperical->GetErrorY(i)/yDud);
3970 else unfoldingError->SetBinError(i+1, 0.);
3972 delta0spread->GetXaxis()->SetTitle(
"p_{T}^{jet} (GeV/c)");
3973 delta0spread->GetYaxis()->SetTitle(
"(mean v_{2, jet}^{measured} - v_{2, jet}^{generated}) / input v_{2}");
3974 delta0spread->Write();
3975 unfoldingError->GetXaxis()->SetTitle(
"p_{T}^{jet} (GeV/c)");
3976 unfoldingError->GetYaxis()->SetTitle(
"(mean v_{2, jet}^{measured} - v_{2, jet}^{generated}) / input v_{2}");
3977 unfoldingError->Write();
3984 TH2D* detectorResponse,
3990 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
3991 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4001 printf(
" fDetectorResponse not found \n ");
4006 printf(
" No true or rec bins set, please set binning ! \n");
4033 fDptIn->GetXaxis()->SetTitle(
"p_{T, jet}^{gen} [GeV/c]");
4034 fDptIn->GetYaxis()->SetTitle(
"p_{T, jet}^{rec} [GeV/c]");
4037 fDptOut->GetXaxis()->SetTitle(
"p_{T, jet}^{gen} [GeV/c]");
4038 fDptOut->GetYaxis()->SetTitle(
"p_{T, jet}^{rec} [GeV/c]");
4048 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4049 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4054 printf(
" GetRatio called with NULL argument(s) \n ");
4059 gr->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
4060 Double_t binCent(0.), ratio(0.), error2(0.), binWidth(0.);
4061 TH1* dud((
TH1*)h1->Clone(
"dud"));
4065 if(!dud->Divide(h1, h2)) {
4066 printf(
" > ROOT failed to divide two histogams, dividing manually \n < ");
4067 for(
Int_t i(1); i <= h1->GetNbinsX(); i++) {
4068 binCent = h1->GetXaxis()->GetBinCenter(i);
4069 if(xmax > 0. && binCent > xmax)
continue;
4070 j = h2->FindBin(binCent);
4071 binWidth = h1->GetXaxis()->GetBinWidth(i);
4072 if(h2->GetBinContent(j) > 0.) {
4073 ratio = h1->GetBinContent(i)/h2->GetBinContent(j);
4074 Double_t A = h1->GetBinError(i)/h1->GetBinContent(i);
4075 Double_t B = h2->GetBinError(i)/h2->GetBinContent(i);
4076 error2 = ratio*ratio*A*A+ratio*ratio*B*B;
4077 if(error2 > 0 ) error2 = TMath::Sqrt(error2);
4078 gr->SetPoint(i-1, binCent, ratio);
4079 gr->SetPointError(i-1, 0.5*binWidth, error2);
4083 printf(
" > using ROOT to divide two histograms < \n");
4084 for(
Int_t i(1); i <= h1->GetNbinsX(); i++) {
4085 binCent = dud->GetXaxis()->GetBinCenter(i);
4086 if(xmax > 0. && binCent > xmax)
continue;
4087 binWidth = dud->GetXaxis()->GetBinWidth(i);
4088 gr->SetPoint(i-1,binCent,dud->GetBinContent(i));
4089 gr->SetPointError(i-1, 0.5*binWidth,dud->GetBinError(i));
4094 TF1* fit(
new TF1(
"lin",
"pol0", 10, 100));
4097 if(strcmp(name,
"")) gr->SetNameTitle(name.Data(), name.Data());
4104 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4105 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4111 printf(
" GetV2 called with NULL argument(s) \n ");
4115 gr->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
4116 Float_t binCent(0.), ratio(0.), error2(0.), binWidth(0.);
4117 Double_t pre(TMath::Pi()/(4.*r)), in(0.), out(0.), ein(0.), eout(0.);
4119 for(
Int_t i(1); i <= h1->GetNbinsX(); i++) {
4120 binCent = h1->GetXaxis()->GetBinCenter(i);
4121 binWidth = h1->GetXaxis()->GetBinWidth(i);
4122 if(h2->GetBinContent(i) > 0.) {
4123 in = h1->GetBinContent(i);
4124 ein = h1->GetBinError(i);
4125 out = h2->GetBinContent(i);
4126 eout = h2->GetBinError(i);
4127 ratio = pre*((in-out)/(in+out));
4128 error2 = (4.*out*out/(TMath::Power(in+out, 4)))*ein*ein+(4.*in*in/(TMath::Power(in+out, 4)))*eout*eout;
4129 error2 = error2*pre*pre;
4130 if(error2 > 0) error2 = TMath::Sqrt(error2);
4131 gr->SetPoint(i-1,binCent,ratio);
4132 gr->SetPointError(i-1,0.5*binWidth,error2);
4135 if(strcmp(name,
"")) gr->SetNameTitle(name.Data(), name.Data());
4141 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4142 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4148 printf(
" GetV2 called with NULL argument(s) \n ");
4151 TH1D* gr((
TH1D*)h1->Clone(name.Data()));
4152 gr->GetXaxis()->SetTitle(
"p_{T, jet} [GeV/c]");
4153 Float_t ratio(0.), error2(0.);
4154 Double_t pre(TMath::Pi()/(4.*r)), in(0.), out(0.), ein(0.), eout(0.);
4156 for(
Int_t i(1); i <= h1->GetNbinsX(); i++) {
4157 if(h2->GetBinContent(i) > 0.) {
4158 in = h1->GetBinContent(i);
4159 ein = h1->GetBinError(i);
4160 out = h2->GetBinContent(i);
4161 eout = h2->GetBinError(i);
4162 ratio = pre*((in-out)/(in+out));
4163 error2 = (4.*out*out/(TMath::Power(in+out, 4)))*ein*ein+(4.*in*in/(TMath::Power(in+out, 4)))*eout*eout;
4164 error2 = error2*pre*pre;
4165 if(error2 > 0) error2 = TMath::Sqrt(error2);
4166 gr->SetBinContent(i,ratio);
4167 gr->SetBinError(i,error2);
4170 if(strcmp(name,
"")) gr->SetNameTitle(name.Data(), name.Data());
4176 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4177 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4181 printf(
" > ConvertGraphToHistogram recevied a NULL pointer > \n");
4185 TH1F* hist(g->GetHistogram());
4186 Double_t xref(0), yref(0), yerr(0);
4188 for(
Int_t i(0); i < hist->GetNbinsX(); i++) {
4189 g->GetPoint(i, xref, yref);
4190 yerr = g->GetErrorY(i);
4191 hist->SetBinContent(i+1, yref);
4192 hist->SetBinError(i+1, yerr);
4199 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4200 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4205 printf(
" > ConvertGraphToHistogram recevied a NULL pointer > \n");
4209 printf(
"\n\n\n adding histo error to graph error \n\n\n\n");
4212 Double_t yerrL(0), yerrH(0), herr(0);
4214 for(
Int_t i(0); i < h->GetNbinsX(); i++) {
4215 yerrH = g->GetErrorY(i);
4216 yerrL = g->GetErrorY(i);
4217 herr = h->GetBinError(i+1);
4218 cout <<
" graph error H " << yerrH <<
"\t histo error " << herr << endl;
4219 cout <<
" graph error L " << yerrL <<
"\t histo error " << herr << endl;
4220 yerrH = TMath::Sqrt(yerrH*yerrH+herr*herr);
4221 yerrL = TMath::Sqrt(yerrL*yerrL+herr*herr);
4222 g->SetPointError(i, g->GetErrorX(i), g->GetErrorX(i), yerrL, yerrH);
4229 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4230 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4233 if(!h || b < a )
return 0.;
4236 Int_t binA(h->GetXaxis()->FindBin(a+.1));
4237 Int_t binB(h->GetXaxis()->FindBin(b+.1));
4240 for(
Int_t i(binA); i < binB; i++) {
4242 mean += h->GetBinContent(i);
4246 for(
Int_t i(binA); i < binB; i++) RMS += (mean-h->GetBinContent(i))*(mean-h->GetBinContent(i));
4247 return TMath::Sqrt(RMS/c);
4255 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4256 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4259 TF1* lin =
new TF1(
"lin", Form(
"(x<%i)*(pol1)+(x>%i)*[2]", (
int)pivot, (
int)pivot), a, b);
4261 TF1* fit_pol0 =
new TF1(
"fit_pol0",
"pol0", pivot, b);
4262 TF1* fit_pol1 =
new TF1(
"fit_pol1",
"pol1", a, pivot);
4264 TH1* h((
TH1*)h1->Clone(str.Data()));
4268 for(
Int_t i(1); i < h->GetNbinsX() + 1; i++) {
4269 _a = TMath::Abs(h1->GetBinContent(i));
4270 _b = TMath::Abs(h2->GetBinContent(i));
4272 h->SetBinContent(i, _a);
4273 h->SetBinError(i, h1->GetBinError(i));
4275 h->SetBinContent(i, _b);
4276 h->SetBinError(i, h2->GetBinError(i));
4284 h->Fit(fit_pol0,
"",
"", pivot, b);
4285 lin->SetParameter(2, (subdueError) ? 0. : fit_pol0->GetParameter(0));
4287 h->Fit(fit_pol1,
"",
"", a, pivot);
4290 if(fit_pol1->GetParameter(1) > 0) {
4291 fit_pol1 =
new TF1(
"fit_pol2",
"pol0", a, pivot);
4292 h->Fit(fit_pol1,
"",
"", a, pivot);
4293 lin->SetParameter(0, fit_pol1->GetParameter(0));
4294 lin->SetParameter(1, 0);
4296 lin->SetParameter(0, fit_pol1->GetParameter(0));
4297 lin->SetParameter(1, fit_pol1->GetParameter(1));
4302 h->GetListOfFunctions()->Add(lin);
4306 for(
Int_t i(1); i < h->GetNbinsX() + 1; i++) {
4308 Double_t dud(lin->Integral(h->GetXaxis()->GetBinLowEdge(i),h->GetXaxis()->GetBinUpEdge(i))/h->GetXaxis()->GetBinWidth(i));
4310 h1->SetBinContent(i, 0);
4311 h2->SetBinContent(i, 0);
4312 h1->SetBinError(i, 0);
4313 h2->SetBinError(i, 0);
4315 if(a > h->GetXaxis()->GetBinLowEdge(i) || b < h->GetXaxis()->GetBinUpEdge(i))
continue;
4318 h1->SetBinContent(i, dud);
4320 h2->SetBinContent(i, dud);
4330 TH1* relativeErrorInUp,
4331 TH1* relativeErrorInLow,
4332 TH1* relativeErrorOutUp,
4333 TH1* relativeErrorOutLow,
4336 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4337 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4349 Double_t in(0.), out(0.), einUp(0.), einLow(0.), eoutUp(0.), eoutLow(0.), error2Up(0.), error2Low(0.);
4353 in = h1->GetBinContent(i+1);
4354 einUp = TMath::Abs(in*relativeErrorInUp->GetBinContent(i+1));
4355 einLow = TMath::Abs(in*relativeErrorInLow->GetBinContent(1+i));
4356 out = h2->GetBinContent(i+1);
4357 eoutUp = TMath::Abs(out*relativeErrorOutUp->GetBinContent(1+i));
4358 eoutLow = TMath::Abs(out*relativeErrorOutLow->GetBinContent(1+i));
4361 error2Up = TMath::Power(((r*4.)/(TMath::Pi())),-2.)*((4.*out*out/(TMath::Power(in+out, 4)))*einUp*einUp+(4.*in*in/(TMath::Power(in+out, 4)))*eoutLow*eoutLow);
4362 error2Low =TMath::Power(((r*4.)/(TMath::Pi())),-2.)*((4.*out*out/(TMath::Power(in+out, 4)))*einLow*einLow+(4.*in*in/(TMath::Power(in+out, 4)))*eoutUp*eoutUp);
4364 error2Up = TMath::Power(((r*4.)/(TMath::Pi())),-2.)*((4.*out*out/(TMath::Power(in+out, 4)))*einUp*einUp+(4.*in*in/(TMath::Power(in+out, 4)))*eoutUp*eoutUp-((8.*out*in)/(TMath::Power(in+out, 4)))*rho*einUp*eoutUp);
4365 error2Low =TMath::Power(((r*4.)/(TMath::Pi())),-2.)*((4.*out*out/(TMath::Power(in+out, 4)))*einLow*einLow+(4.*in*in/(TMath::Power(in+out, 4)))*eoutLow*eoutLow-((8.*out*in)/(TMath::Power(in+out, 4)))*rho*einLow*eoutLow);
4367 if(error2Up > 0) error2Up = TMath::Sqrt(error2Up);
4368 if(error2Low > 0) error2Low = TMath::Sqrt(error2Low);
4373 Double_t binWidth(h1->GetBinWidth(i+1));
4374 axl[i] = binWidth/2.;
4375 axh[i] = binWidth/2.;
4377 tempV2->GetPoint(i, ax[i], ay[i]);
4388 nominalError->SetName(
"v_{2} with shape uncertainty");
4398 return nominalError;
4402 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4403 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4408 printf(
" > WriteObject:: called with NULL arguments \n ");
4410 }
else if(!strcmp(
"", suffix.Data()))
object->Write();
4412 TObject* newObject(object->Clone(Form(
"%s_%s", object->GetName(), suffix.Data())));
4415 if(kill)
delete object;
4419 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4420 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4430 Int_t bins(dpt->GetXaxis()->GetNbins());
4432 for(
Int_t i(0); i < bins; i++) _bins[i] = dpt->GetBinLowEdge(i+1);
4433 _bins[bins] = dpt->GetBinLowEdge(bins)+dpt->GetBinWidth(bins+1);
4434 TH2D* res(
new TH2D(Form(
"Response_from_%s", dpt->GetName()), Form(
"Response_from_%s", dpt->GetName()), bins, _bins, bins, _bins));
4435 for(
Int_t j(0); j < bins+1; j++) {
4437 for(
Int_t k(0); k < bins+1; k++) {
4438 (skip) ? res->SetBinContent(j, k, 0.) : res->SetBinContent(j, k, dpt->GetBinContent(dpt->GetXaxis()->FindBin(k-j)));
4439 if(AvoidRoundingError && k > j && TMath::AreEqualAbs(dpt->GetBinContent(dpt->GetBinContent(k-j)), 0, 1e-8)) skip = kTRUE;
4446 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4447 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4449 if(!binsTrue || !binsRec) {
4450 printf(
" > GetUnityResponse:: function called with NULL arguments < \n");
4453 TString name(Form(
"unityResponse_%s", suffix.Data()));
4454 TH2D* unity(
new TH2D(name.Data(), name.Data(), binsTrue->GetSize()-1, binsTrue->GetArray(), binsRec->GetSize()-1, binsRec->GetArray()));
4455 for(
Int_t i(0); i < binsTrue->GetSize(); i++) {
4456 for(
Int_t j(0); j < binsRec->GetSize(); j++) {
4457 if(i==j) unity->SetBinContent(1+i, 1+j, 1.);
4464 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4465 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4468 TH1F* summary =
new TH1F(
"UnfoldingConfiguration",
"UnfoldingConfiguration", 20, -.5, 19.5);
4469 summary->SetBinContent(1,
fBetaIn);
4470 summary->GetXaxis()->SetBinLabel(1,
"fBetaIn");
4471 summary->SetBinContent(2,
fBetaOut);
4472 summary->GetXaxis()->SetBinLabel(2,
"fBetaOut");
4474 summary->GetXaxis()->SetBinLabel(3,
"fCentralityArray[0]");
4475 summary->SetBinContent(4, (
int)convergedIn);
4476 summary->GetXaxis()->SetBinLabel(4,
"convergedIn");
4477 summary->SetBinContent(5, (
int)convergedOut);
4478 summary->GetXaxis()->SetBinLabel(5,
"convergedOut");
4480 summary->GetXaxis()->SetBinLabel(6,
"fAvoidRoundingError");
4482 summary->GetXaxis()->SetBinLabel(7,
"fUnfoldingAlgorithm");
4483 summary->SetBinContent(8, (
int)
fPrior);
4484 summary->GetXaxis()->SetBinLabel(8,
"fPrior");
4486 summary->GetXaxis()->SetBinLabel(9,
"fSVDRegIn");
4488 summary->GetXaxis()->SetBinLabel(10,
"fSVDRegOut");
4489 summary->SetBinContent(11, (
int)
fSVDToy);
4490 summary->GetXaxis()->SetBinLabel(11,
"fSVDToy");
4492 summary->GetXaxis()->SetBinLabel(12,
"fJetRadius");
4494 summary->GetXaxis()->SetBinLabel(13,
"fNormalizeSpectra");
4496 summary->GetXaxis()->SetBinLabel(14,
"fSmoothenPrior");
4497 summary->SetBinContent(15, (
int)
fTestMode);
4498 summary->GetXaxis()->SetBinLabel(15,
"fTestMode");
4500 summary->GetXaxis()->SetBinLabel(16,
"fUseDetectorResponse");
4502 summary->GetXaxis()->SetBinLabel(17,
"fBayesianIterIn");
4504 summary->GetXaxis()->SetBinLabel(18,
"fBayesianIterOut");
4506 summary->GetXaxis()->SetBinLabel(19,
"fBayesianSmoothIn");
4508 summary->GetXaxis()->SetBinLabel(20,
"fBayesianSmoothOut");
4512 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4513 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4516 TVirtualFitter*
fitter(TVirtualFitter::GetFitter());
4518 printf(
" > Found fitter, will delete it < \n");
4522 printf(
" > Found gMinuit, will re-create it < \n");
4524 gMinuit =
new TMinuit;
4526 AliUnfolding::fgCorrelationMatrix = 0;
4527 AliUnfolding::fgCorrelationMatrixSquared = 0;
4528 AliUnfolding::fgCorrelationCovarianceMatrix = 0;
4529 AliUnfolding::fgCurrentESDVector = 0;
4530 AliUnfolding::fgEntropyAPriori = 0;
4531 AliUnfolding::fgEfficiency = 0;
4532 AliUnfolding::fgUnfoldedAxis = 0;
4533 AliUnfolding::fgMeasuredAxis = 0;
4534 AliUnfolding::fgFitFunction = 0;
4535 AliUnfolding::fgMaxInput = -1;
4536 AliUnfolding::fgMaxParams = -1;
4537 AliUnfolding::fgOverflowBinLimit = -1;
4538 AliUnfolding::fgRegularizationWeight = 10000;
4539 AliUnfolding::fgSkipBinsBegin = 0;
4540 AliUnfolding::fgMinuitStepSize = 0.1;
4541 AliUnfolding::fgMinuitPrecision = 1e-6;
4542 AliUnfolding::fgMinuitMaxIterations = 1000000;
4543 AliUnfolding::fgMinuitStrategy = 1.;
4544 AliUnfolding::fgMinimumInitialValue = kFALSE;
4545 AliUnfolding::fgMinimumInitialValueFix = -1;
4546 AliUnfolding::fgNormalizeInput = kFALSE;
4547 AliUnfolding::fgNotFoundEvents = 0;
4548 AliUnfolding::fgSkipBin0InChi2 = kFALSE;
4549 AliUnfolding::fgBayesianSmoothing = 1;
4550 AliUnfolding::fgBayesianIterations = 10;
4552 AliUnfolding::fgCallCount = 0;
4553 AliUnfolding::fgPowern = 5;
4554 AliUnfolding::fChi2FromFit = 0.;
4555 AliUnfolding::fPenaltyVal = 0.;
4556 AliUnfolding::fAvgResidual = 0.;
4557 AliUnfolding::fgPrintChi2Details = 0;
4558 AliUnfolding::fgCanvas = 0;
4559 AliUnfolding::fghUnfolded = 0;
4560 AliUnfolding::fghCorrelation = 0;
4561 AliUnfolding::fghEfficiency = 0;
4562 AliUnfolding::fghMeasured = 0;
4563 AliUnfolding::SetMinuitStepSize(1.);
4564 AliUnfolding::SetMinuitPrecision(1e-6);
4565 AliUnfolding::SetMinuitMaxIterations(100000);
4566 AliUnfolding::SetMinuitStrategy(2.);
4567 AliUnfolding::SetDebug(1);
4571 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4572 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4575 if(!protect)
return 0x0;
4579 p->SetName(Form(
"%s_%s", protect->GetName(), tempString.Data()));
4580 p->SetTitle(Form(
"%s_%s", protect->GetTitle(), tempString.Data()));
4581 if(kill)
delete protect;
4586 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4587 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4590 if(!protect)
return 0x0;
4594 p->SetName(Form(
"%s_%s", protect->GetName(), tempString.Data()));
4595 p->SetTitle(Form(
"%s_%s", protect->GetTitle(), tempString.Data()));
4596 if(kill)
delete protect;
4601 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4602 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4605 if(!protect)
return 0x0;
4609 p->SetName(Form(
"%s_%s", protect->GetName(), tempString.Data()));
4610 p->SetTitle(Form(
"%s_%s", protect->GetTitle(), tempString.Data()));
4611 if(kill)
delete protect;
4616 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4617 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4631 Int_t low[] = {1, 6, 11, 16, 21, 26, 31, 36};
4632 Int_t up[] = {5, 10, 15, 20, 25, 30, 35, 40};
4633 TString stringArray[] = {
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h"};
4635 const Int_t dPhiBins(8);
4637 for(
Int_t i(0); i < ptBins; i++) dPtdPhi[i] =
new TH1D(Form(
"dPtdPhi_%i", i), Form(
"dPtdPhi_%i", i), dPhiBins, 0, TMath::Pi());
4639 for(
Int_t i(0); i < dPhiBins; i++) {
4664 TH1D* kinematicEfficiencyIn = resizedResponseIn->ProjectionX();
4665 kinematicEfficiencyIn->SetNameTitle(Form(
"kin_eff_%s", stringArray[i].
Data()), Form(
"kin_eff_%s", stringArray[i].
Data()));
4667 for(
Int_t j(0); j < kinematicEfficiencyIn->GetXaxis()->GetNbins(); j++) kinematicEfficiencyIn->SetBinError(1+j, 0.);
4668 TH1D* jetFindingEfficiency(0x0);
4671 jetFindingEfficiency->SetNameTitle(Form(
"%s_coarse", jetFindingEfficiency->GetName()), Form(
"%s_coarse", jetFindingEfficiency->GetName()));
4675 TH1D* unfoldedJetSpectrumIn(0x0);
4677 TDirectoryFile* dirIn =
new TDirectoryFile(Form(
"%s___%s", stringArray[i].
Data(),
fActiveString.Data()), Form(
"%s___%s", stringArray[i].
Data(),
fActiveString.Data()));
4681 measuredJetSpectrumIn,
4683 kinematicEfficiencyIn,
4684 measuredJetSpectrumTrueBinsIn,
4686 jetFindingEfficiency);
4689 resizedResponseIn->SetNameTitle(Form(
"ResponseMatrix_%s", stringArray[i].
Data()), Form(
"response matrix %s", stringArray[i].
Data()));
4690 resizedResponseIn->SetXTitle(
"p_{T, jet}^{true} [GeV/c]");
4691 resizedResponseIn->SetYTitle(
"p_{T, jet}^{rec} [GeV/c]");
4692 resizedResponseIn =
ProtectHeap(resizedResponseIn);
4693 resizedResponseIn->Write();
4694 kinematicEfficiencyIn->SetNameTitle(Form(
"KinematicEfficiency_%s", stringArray[i].
Data()), Form(
"Kinematic efficiency, %s", stringArray[i].
Data()));
4695 kinematicEfficiencyIn =
ProtectHeap(kinematicEfficiencyIn);
4696 kinematicEfficiencyIn->Write();
4697 fDetectorResponse->SetNameTitle(
"DetectorResponse",
"Detector response matrix");
4702 fSpectrumIn->SetNameTitle(
"[ORIG]JetSpectrum", Form(
"[INPUT] Jet spectrum, %s", stringArray[i].
Data()));
4704 fDptInDist->SetNameTitle(
"[ORIG]DeltaPt", Form(
"#delta p_{T} distribution, %s", stringArray[i].
Data()));
4706 fDptIn->SetNameTitle(
"[ORIG]DeltaPtMatrix", Form(
"#delta p_{T} matrix, %s", stringArray[i].
Data()));
4708 fFullResponseIn->SetNameTitle(
"ResponseMatrix", Form(
"Response matrix, %s", stringArray[i].
Data()));
4716 TH1D* dud(
ProtectHeap(unfoldedJetSpectrumIn, kTRUE, stringArray[i]));;
4720 for(
Int_t j(0); j < ptBins; j++) {
4722 Double_t integral(dud->IntegralAndError(j+1, j+2, integralError));
4723 dPtdPhi[j]->SetBinContent(i+1, integral);
4724 dPtdPhi[j]->SetBinError(i+1, integralError);
4730 TF1* fourier =
new TF1(
"fourier",
"[0]*(1.+0.5*[1]*(TMath::Cos(2.*x)))", 0, TMath::Pi());
4732 for(
Int_t i(0); i < ptBins; i++) {
4733 dPtdPhi[i]->Fit(fourier,
"VI");
4734 Style(gPad,
"PEARSON");
4736 dPtdPhi[i]->DrawCopy();
4745 v2->SetBinContent(1+i, fourier->GetParameter(1));
4746 v2->SetBinError(1+i, fourier->GetParError(1));
4747 Style(gPad,
"PEARSON");
4750 dPtdPhi[i]->Write();
4756 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4757 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4760 graph->GetPoint(0, x, y);
4761 graph->SetPoint(array->At(0)-1,
fBinsTrue->At(array->At(0)), y);
4762 graph->SetPointError(array->At(0)-1, 10, graph->GetErrorY(0));
4763 graph->SetPoint(array->At(1)-1, -5, -5);
4767 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4768 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4772 graph->GetPoint(0, x, y);
4773 graph->SetPoint(array->At(0)-1,
fBinsTrue->At(array->At(0)), y);
4774 Double_t yl = graph->GetErrorYlow(0);
4775 Double_t yh = graph->GetErrorYhigh(0);
4776 graph->SetPointError(array->At(0)-1, 10, 10, yl, yh);
4777 graph->SetPoint(array->At(1)-1, -5, -5);
4788 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4789 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4792 Double_t statE(0), shapeE(0), corrE(0), y(0), x(0);
4795 printf(
" double v2[] = {\n");
4797 for(
Int_t i(low); i < up+1; i++) {
4798 n->GetPoint(i, x, y);
4799 if(i==up) printf(
"%.4f}; \n\n", y);
4800 else printf(
"%.4f, \n", y);
4801 gV2->SetAt(y, iterator);
4805 printf(
" double stat[] = {\n");
4806 for(
Int_t i(low); i < up+1; i++) {
4807 y = n->GetErrorYlow(i);
4808 if(i==up) printf(
"%.4f}; \n\n", y);
4809 else printf(
"%.4f, \n", y);
4810 gStat->SetAt(y, iterator);
4814 printf(
" double shape[] = {\n");
4815 for(
Int_t i(low); i < up+1; i++) {
4816 y = shape->GetErrorYhigh(i);
4817 if (y < 0.0001) y = 0.0001;
4819 shape->SetPointEYhigh(i, y);
4820 y = shape->GetErrorYlow(i);
4821 if ( y < 0.0001) y = 0.0001;
4823 shape->SetPointEYlow(i, y);
4824 if(i==up) printf(
"%.4f}; \n\n", y);
4825 else printf(
"%.4f, \n", y);
4826 gShape->SetAt(y, iterator);
4830 printf(
" double corr[] = {\n");
4831 for(
Int_t i(low); i < up+1; i++) {
4833 corr->SetPointEYhigh(i, y);
4835 corr->SetPointEYlow(i, y);
4836 if(i==up) printf(
"%.4f}; \n\n", y);
4837 else printf(
"%.4f, \n", y);
4838 gCorr->SetAt(y, iterator);
4844 for(
Int_t i(low); i < up+1; i++) {
4850 n->GetPoint(i, x, y);
4851 statE += n->GetErrorY(i);
4852 shapeE += shape->GetErrorY(i);
4853 corrE += corr->GetErrorY(i);
4856 printf(
" ======================================\n");
4857 printf(
" > between %i and %i GeV/c \n", low, up);
4858 cout <<
" AVERAGE_SHAPE " << shapeE/ctr << endl;
4859 cout <<
" AVERAGE_CORR " << corrE/ctr << endl;
4860 cout <<
" AVERAGE_STAT " << statE/ctr << endl;
4865 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4866 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4871 ROOT::Minuit2::Minuit2Minimizer min ( ROOT::Minuit2::kMigrad );
4872 min.SetMaxFunctionCalls(1000000);
4873 min.SetMaxIterations(100000);
4874 min.SetTolerance(0.001);
4877 double step[] = {0.0000001, 0.0000001};
4878 double variable[] = {-1., -1.};
4882 min.SetVariable(0,
"epsilon_c",variable[0], step[0]);
4883 min.SetVariable(1,
"epsilon_b",variable[1], step[1]);
4891 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4892 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4918 chi2 += numerator/denominator;
4924 chi2 += epsc*epsc + sumEpsb/((float)counts);
4940 chi2 += numerator/denominator;
4946 chi2 += epsc*epsc + sumEpsb/((float)counts);
4953 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4954 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4963 #ifdef ALIJETFLOWTOOLS_DEBUG_FLAG
4964 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
4967 const Int_t DOF(7-2);
4969 printf(
" > locating minima < \n");
4971 f1->GetMinimumXY(x, y);
4972 f1->GetXaxis()->SetTitle(
"#epsilon{c}");
4973 f1->GetXaxis()->SetTitle(
"#epsilon_{b}");
4974 f1->GetZaxis()->SetTitle(
"#chi^{2}");
4976 printf(
" ===============================================================================\n");
4977 printf(
" > minimal chi2 f(%.8f, %.8f) = %.8f (i should be ok ... ) \n", x, y, f1->Eval(x, y));
4978 cout <<
" so the probability of finding data at least as imcompatible with " <<
gPwrtTo <<
" as the actually" << endl;
4979 cout <<
" observed data is " << TMath::Prob(f1->Eval(x, y), DOF) << endl;
4980 cout <<
" minimization parameters: EPSILON_B " << y << endl;
4981 cout <<
" EPSILON_C " << x << endl;
4982 printf(
" ===============================================================================\n");
4985 p = TMath::Prob(f1->Eval(x, y), DOF);
return jsonbuilder str().c_str()