Skip to content

Commit c59dc0f

Browse files
committed
update
1 parent c211579 commit c59dc0f

2 files changed

Lines changed: 37 additions & 20 deletions

File tree

Common/Tools/Multiplicity/multGlauberNBDFitter.cxx

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ multGlauberNBDFitter::~multGlauberNBDFitter()
104104

105105
void multGlauberNBDFitter::InitGlauberNBD(const float mu, const float k, const float f, const float norm)
106106
{
107+
fNBDFitterMode = NBDFitterMode::Glauber;
107108
fGlauberNBD = new TF1("fGlauberNBD", this, &multGlauberNBDFitter::GlauberProbDistrib,
108109
0, 50000, 5, "multGlauberNBDFitter", "GlauberProbDistrib");
109110
fGlauberNBD->SetParameter(Index(FitPar::mu), mu);
@@ -120,16 +121,20 @@ void multGlauberNBDFitter::InitGlauberNBD(const float mu, const float k, const f
120121

121122
void multGlauberNBDFitter::InitTrentoNBD(const float mu, const float k, const float norm)
122123
{
124+
fNBDFitterMode = NBDFitterMode::Trento;
123125
fGlauberNBD = nullptr;
124126
fTrentoNBD = new TF1("fTrentoNBD", this, &multGlauberNBDFitter::TrentoProbDistrib,
125127
0, 50000, 5, "multGlauberNBDFitter", "TrentoProbDistrib");
126128
fTrentoNBD->SetParameter(Index(FitPar::mu), mu);
127129
fTrentoNBD->SetParameter(Index(FitPar::k), k);
128130
fTrentoNBD->SetParameter(Index(FitPar::norm), norm);
131+
fTrentoNBD->FixParameter(Index(FitPar::dMu), 0);
129132

130133
fTrentoNBD->SetParName(Index(FitPar::mu), "mu");
131134
fTrentoNBD->SetParName(Index(FitPar::k), "k");
135+
fTrentoNBD->SetParName(Index(FitPar::f), "f");
132136
fTrentoNBD->SetParName(Index(FitPar::norm), "norm");
137+
fTrentoNBD->SetParName(Index(FitPar::dMu), "dMu/dNanc");
133138
}
134139

135140
//______________________________________________________
@@ -139,22 +144,22 @@ double multGlauberNBDFitter::GlauberProbDistrib(const double* x, const double* p
139144
double lMultValue = x[0];
140145
double lProbability = 0.0;
141146
ffChanged = true;
142-
const double lAlmost0 = 1.e-13;
147+
static constexpr double Almost0 = 1.e-13;
143148
// Comment this line in order to make the code evaluate Nancestor all the time
144-
if (std::abs(fCurrentf - par[2]) < lAlmost0) {
149+
if (std::abs(fCurrentf - par[Index(FitPar::f)]) < Almost0) {
145150
ffChanged = false;
146151
}
147152

148153
//______________________________________________________
149154
// Recalculate the ancestor distribution in case f changed
150155
if (ffChanged) {
151-
fCurrentf = par[2];
156+
fCurrentf = par[Index(FitPar::f)];
152157
fhNanc->Reset();
153158

154159
for (int ibin = 0; ibin < fNNpNcPairs; ibin++) {
155-
double lOption0 = static_cast<int>(fNpart[ibin] * par[2] + fNcoll[ibin] * (1.0 - par[2]));
156-
double lOption1 = std::floor(fNpart[ibin] * par[2] + fNcoll[ibin] * (1.0 - par[2]) + 0.5);
157-
double lOption2 = (fNpart[ibin] * par[2] + fNcoll[ibin] * (1.0 - par[2]));
160+
double lOption0 = static_cast<int>(fNpart[ibin] * par[Index(FitPar::f)] + fNcoll[ibin] * (1.0 - par[Index(FitPar::f)]));
161+
double lOption1 = std::floor(fNpart[ibin] * par[Index(FitPar::f)] + fNcoll[ibin] * (1.0 - par[Index(FitPar::f)]) + 0.5);
162+
double lOption2 = (fNpart[ibin] * par[Index(FitPar::f)] + fNcoll[ibin] * (1.0 - par[Index(FitPar::f)]));
158163
if (fAncestorMode == AncestorMode::Truncated) {
159164
fhNanc->Fill(lOption0, fContent[ibin]);
160165
}
@@ -178,11 +183,10 @@ double multGlauberNBDFitter::GlauberProbDistrib(const double* x, const double* p
178183
for (long iNanc = lStartBin; iNanc < fhNanc->GetNbinsX() + 1; ++iNanc) {
179184
double lNancestors = fhNanc->GetBinCenter(iNanc);
180185
double lNancestorCount = fhNanc->GetBinContent(iNanc);
181-
// if(lNancestorCount<1e-12&&lNancestors>10) break;
182186

183187
// allow for variable mu in case requested
184-
double lThisMu = lNancestors * (par[0] + par[4] * lNancestors);
185-
double lThisk = lNancestors * par[1];
188+
double lThisMu = lNancestors * (par[Index(FitPar::mu)] + par[Index(FitPar::dMu)] * lNancestors);
189+
double lThisk = lNancestors * par[Index(FitPar::k)];
186190
double lpval = std::pow(1.0 + lThisMu / lThisk, -1);
187191
fNBD->SetParameter(Index(NBDPar::k), lThisk);
188192
fNBD->SetParameter(Index(NBDPar::p), lpval);
@@ -195,7 +199,7 @@ double multGlauberNBDFitter::GlauberProbDistrib(const double* x, const double* p
195199
lProbability += lNancestorCount * lMult;
196200
}
197201
//______________________________________________________
198-
return par[3] * lProbability;
202+
return par[Index(FitPar::norm)] * lProbability;
199203
}
200204

201205
double multGlauberNBDFitter::TrentoProbDistrib(const double* x, const double* par)
@@ -207,16 +211,16 @@ double multGlauberNBDFitter::TrentoProbDistrib(const double* x, const double* pa
207211
// Actually ealuate function
208212
for (long iNSrc = 1; iNSrc < fhNSources->GetNbinsX() + 1; ++iNSrc) {
209213
double lNsources = fhNSources->GetBinCenter(iNSrc);
210-
double lThisMu = lNsources * par[0];
211-
double lThisk = lNsources * par[1];
214+
double lThisMu = lNsources * par[Index(FitPar::mu)];
215+
double lThisk = lNsources * par[Index(FitPar::k)];
212216
double lpval = std::pow(1 + lThisMu / lThisk, -1);
213217
fNBD->SetParameter(Index(NBDPar::k), lThisk);
214218
fNBD->SetParameter(Index(NBDPar::p), lpval);
215219
double lMult = fNBD->Eval(lMultValue);
216220
lProbability += fhNSources->GetBinContent(fhNSources->FindBin(iNSrc)) * lMult;
217221
}
218222
//______________________________________________________
219-
return par[3] * lProbability;
223+
return par[Index(FitPar::norm)] * lProbability;
220224
}
221225

222226
//________________________________________________________________
@@ -267,10 +271,20 @@ TF1* multGlauberNBDFitter::GetGlauberNBD()
267271
return fGlauberNBD;
268272
}
269273

274+
TF1* multGlauberNBDFitter::GetTrentoNBD()
275+
{
276+
return fTrentoNBD;
277+
}
278+
270279
//________________________________________________________________
271280
void multGlauberNBDFitter::SetFitRange(const double lMin, const double lMax)
272281
{
273-
fGlauberNBD->SetRange(lMin, lMax);
282+
if (fGlauberNBD) {
283+
fGlauberNBD->SetRange(lMin, lMax);
284+
}
285+
if (fTrentoNBD) {
286+
fTrentoNBD->SetRange(lMin, lMax);
287+
}
274288
}
275289

276290
//________________________________________________________________
@@ -304,9 +318,11 @@ bool multGlauberNBDFitter::DoFit()
304318
bool lReturnValue = false;
305319
switch (fNBDFitterMode) {
306320
case NBDFitterMode::Glauber:
321+
LOG(info) << "Doing Glauber fit!!";
307322
lReturnValue = DoGlauberFit();
308323
break;
309324
case NBDFitterMode::Trento:
325+
LOG(info) << "Doing Trento fit!!";
310326
lReturnValue = DoTrentoFit();
311327
break;
312328

@@ -317,7 +333,7 @@ bool multGlauberNBDFitter::DoFit()
317333
timer->Stop();
318334
double lTotalTime = timer->RealTime();
319335
if (lReturnValue) {
320-
LOG(info) << "---> Fitting succeeded took " << lTotalTime << " seconds";
336+
LOG(info) << "---> Fitting succeeded after " << lTotalTime << " seconds";
321337
} else {
322338
LOG(info) << "---> Fitting failed after " << lTotalTime << " seconds";
323339
}
@@ -434,11 +450,11 @@ void multGlauberNBDFitter::CalculateAvNpNc(TProfile* lNPartProf, TProfile* lNCol
434450

435451
LOG(info) << "Acquiring values from the fit function...";
436452

437-
fMu = fGlauberNBD->GetParameter(0);
438-
fk = fGlauberNBD->GetParameter(1);
439-
ff = fGlauberNBD->GetParameter(2);
440-
fnorm = fGlauberNBD->GetParameter(3);
441-
fdMu = fGlauberNBD->GetParameter(4);
453+
fMu = fGlauberNBD->GetParameter(Index(FitPar::mu));
454+
fk = fGlauberNBD->GetParameter(Index(FitPar::k));
455+
ff = fGlauberNBD->GetParameter(Index(FitPar::f));
456+
fnorm = fGlauberNBD->GetParameter(Index(FitPar::norm));
457+
fdMu = fGlauberNBD->GetParameter(Index(FitPar::dMu));
442458

443459
LOG(info) << "Please inspect now: ";
444460
LOG(info) << "Glauber NBD mu ............: " << fMu;

Common/Tools/Multiplicity/multGlauberNBDFitter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class multGlauberNBDFitter : public TNamed
8888
// Interface to get funtions if asked to
8989
TF1* GetNBD();
9090
TF1* GetGlauberNBD();
91+
TF1* GetTrentoNBD();
9192

9293
// Helper
9394
bool InitializeNpNc();

0 commit comments

Comments
 (0)