9 * @ingroup pwg2_forward_scripts_corr
11 Color_t Color(UShort_t d, Char_t r ) const
13 return ((d == 1 ? kRed : (d == 2 ? kGreen : kBlue))
14 + ((r == 'I' || r == 'i') ? 2 : -2));
26 * @ingroup pwg2_forward_scripts_corr
29 RunCopyELossFit(UShort_t sys, UShort_t cms, Short_t field, Bool_t mc=false,
32 RunCopyELossFit(sys == 1 ? "pp" : "PbPb",
41 * @param sys Collision system
42 * @param cms Center of mass energy per nucleon in GeV
43 * @param field Magnetic field
44 * @param mc Monte-carlo flag
45 * @param path File path
48 * @ingroup pwg2_forward_scripts_corr
51 RunCopyELossFit(const char* sys, UShort_t cms, Short_t field, bool mc=false,
54 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
55 gSystem->Load("libPWG2forward.so");
57 AliFMDAnaParameters* p = AliFMDAnaParameters::Instance();
59 p->SetEnergy(Float_t(cms));
60 p->SetMagField(Float_t(field));
61 p->SetCollisionSystem(sys);
63 p->SetBackgroundPath(path);
64 p->SetEnergyPath(path);
65 p->SetEventSelectionPath(path);
66 p->SetSharingEfficiencyPath(path);
68 p->Init(true, AliFMDAnaParameters::kBackgroundCorrection|
69 AliFMDAnaParameters::kEnergyDistributions);
71 Int_t nVtx = p->GetNvtxBins();
72 Double_t minVtx = -p->GetVtxCutZ();
73 Double_t maxVtx = -p->GetVtxCutZ();
74 Int_t nEta = p->GetNetaBins();
75 Double_t minEta = p->GetEtaMin();
76 Double_t maxEta = p->GetEtaMax();
78 TAxis vtxAxis(nVtx, minVtx, maxVtx);
79 TAxis etaAxis(nEta, minEta, maxEta);
80 AliFMDCorrELossFit* m = new AliFMDCorrELossFit;
81 m->SetEtaAxis(etaAxis);
83 for (UShort_t d = 1; d <= 3; d++) {
84 UShort_t nQ = (d == 1 ? 1 : 2);
85 for (UShort_t q = 0; q < nQ; q++) {
86 Char_t r = (q == 0 ? 'I' : 'O');
88 for (UShort_t b = 1; b < nEta; b++) {
89 Double_t eta = etaAxis.GetBinCenter(b);
90 Info("RunCopyELossFit", "FMD%d%c, bin %3d, eta %+8.4f", d, r, b, eta);
91 if (eta < minEta || eta > maxEta) continue;
92 TH1F* oldhist = p->GetEnergyDistribution(d,r,eta);
94 Warning("RunCopyELossFit",
95 "Didn't find energy distribution for FMD%d%c, eta bin %3d",
99 TF1* oldfunc = oldhist->GetFunction("FMDfitFunc");
101 // Warning("RunCopyELossFit",
102 // "Didn't find energy fit for FMD%d%c, eta bin %3d",
106 Double_t chi2 = oldfunc->GetChisquare();
107 UShort_t nu = oldfunc->GetNDF();
108 Double_t c = oldfunc->GetParameter(0);
109 Double_t delta = oldfunc->GetParameter(1);
110 Double_t xi = oldfunc->GetParameter(2);
111 Double_t a2 = 0, a3 = 0, ea2 = 0, ea3 = 0;
112 if (oldfunc->GetNpar() >= 4) {
113 a2 = oldfunc->GetParameter(3);
114 ea2 = oldfunc->GetParError(3);
116 if (oldfunc->GetNpar() >= 5) {
117 a3 = oldfunc->GetParameter(4);
118 ea3 = oldfunc->GetParError(4);
120 Int_t n = (a3 < 1e-5 ? (a2 < 1e-5 ? 1 : 2) : 3);
121 Double_t ec = oldfunc->GetParError(0);
122 Double_t edelta = oldfunc->GetParError(1);
123 Double_t exi = oldfunc->GetParError(2);
124 delta = delta - xi * -0.22278298;
125 edelta = TMath::Sqrt(TMath::Power(edelta,2) -
126 TMath::Power(0.22278298*exi,2));
127 Info("RunCopyELossFit", "FMD%d%c etabin=%3d: n=%d\n"
128 " C=%f+/-%f, Delta=%f+/-%f, xi=%f+/-%f, a2=%f+/-%f, a3=%f+/-%f",
129 d, r, b, n, c, ec, delta, edelta, xi, exi, a2, ea2, a3, ea3);
130 Double_t a[] = { a2, a3, -9999 };
131 Double_t ea[] = { ea2, ea3, -9999 };
133 AliFMDCorrELossFit::ELossFit* fit = new
134 AliFMDCorrELossFit::ELossFit(0, n,
142 fit->CalculateQuality();
148 Info("RunCopyELossFit", "Setting fit FMD%d%c etabin=%3d: %p",
150 m->SetFit(d, r, b, fit);
154 UShort_t isys = AliForwardUtil::ParseCollisionSystem(sys);
155 AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
156 TString fname(mgr.GetFileName(AliForwardCorrectionManager::kELossFits,
157 isys, cms, field, mc));
158 TFile* output = TFile::Open(fname.Data(), "RECREATE");
160 Warning("RunCopyELossFit", "Failed to open output file %s", fname.Data());
163 m->Write(mgr.GetObjectName(AliForwardCorrectionManager::kELossFits));
166 Info("RunCopyELossFit",
167 "File %s created. It should be copied to %s and stored in SVN",
168 fname.Data(), mgr.GetFileDir(AliForwardCorrectionManager::kELossFits));