9 const Double_t eMass = 0.000511; //electron mass
10 const Double_t piMass = 0.13957; //pion mass
11 const Double_t kMass = 0.493676999999999977; //kaon mass
12 const Double_t pMass = 0.938271999999999995; //proton mass
15 Double_t fitf3G(Double_t* xx, Double_t* par);
16 Double_t FitFunc(Double_t* x, Double_t *par);
17 Double_t SigmaFunc(Double_t* x, Double_t *par);
21 Double_t fixMIP = 50.0;
22 Double_t fixPlateau = 75.0;
25 class DeDxFitInfo : public TObject
30 void Print(Option_t* option="") const;
43 TString calibFileName;
45 ClassDef(DeDxFitInfo, 1); // Help class
48 //_____________________________________________________________________________
51 DeDxFitInfo::DeDxFitInfo():
61 // default constructor
62 for(Int_t i = 0; i < 8; i++) {
68 //_________________________________________________________
69 void DeDxFitInfo::Print(Option_t* option) const
72 cout << "Option: " << option << endl;
74 cout << ClassName() << " : " << GetName() << endl
75 << "MIP: " << MIP << endl
76 << "Plateau: " << plateau << endl
77 << "OptionDeDx: " << optionDeDx << endl
78 << "nDeDxPar: " << nDeDxPar << endl;
79 for(Int_t i = 0; i < nDeDxPar; i++) {
81 cout << "parDeDx[" << i << "] = " << parDeDx[i] << endl;
83 cout << "OptionSigma: " << optionSigma << endl
84 << "nSigmaPar: " << nSigmaPar << endl;
85 for(Int_t i = 0; i < nSigmaPar; i++) {
87 cout << "parSigma[" << i << "] = " << parSigma[i] << endl;
90 if(calibFileName.IsNull()) {
91 cout << "No eta calibration file." << endl;
93 cout << "Eta calibration file: " << calibFileName.Data() << endl;
97 //______________________________________________________________________________
98 Double_t fitf3G(Double_t* xx, Double_t* par)
101 // Could speed up fit by forcing it to use <p>. In that way the parameters
102 // could be amde statis cand only changed when going to a new p bin
105 Double_t dedx = xx[1];
107 const Int_t bin = hDeDxVsP->GetXaxis()->FindBin(p);
110 // cout << "p before: " << p;
111 p = hMeanP->GetBinContent(bin);
112 // cout << ", p after: " << p << endl;
114 const Int_t binStart = Int_t(par[0]);
115 const Int_t binStop = Int_t(par[1]);
117 if(bin<binStart || bin>binStop) {
119 cout << "Error: bin " << bin << " not inside inteval [" << binStart
120 << "; " << binStop << "]" << endl;
124 const Int_t nParDeDx = Int_t(par[2]);
126 Double_t* parDeDx = &par[3];
128 Int_t offset = 4 + nParDeDx; // binStart + binStop + nParDeDx + optionDedx + nParDeDx parameters
130 const Int_t nParSigma = Int_t(par[offset]);
131 offset += 1; // nParSigma
133 Double_t* parSigma = &par[offset];
134 offset += 1 + nParSigma; // optionSigma + nParSigma parameters
136 Double_t piMean = FitFunc(&p, parDeDx);
137 Double_t pKeff = p*piMass/kMass; // corresponding p of a pion with same dE/dx
138 Double_t kMean = FitFunc(&pKeff, parDeDx);
139 Double_t pPeff = p*piMass/pMass; // corresponding p of a pion with same dE/dx
140 Double_t pMean = FitFunc(&pPeff, parDeDx);
142 const Double_t piSigma = SigmaFunc(&piMean, parSigma);
143 const Double_t kSigma = SigmaFunc(&kMean, parSigma);
144 const Double_t pSigma = SigmaFunc(&pMean, parSigma);
147 const Int_t j = bin - binStart;
148 const Double_t piYield = par[j * 3 + offset + 0];
149 const Double_t kYield = par[j * 3 + offset + 1];
150 const Double_t pYield = par[j * 3 + offset + 2];
152 return piYield* TMath::Gaus(dedx, piMean, piSigma, kTRUE)
153 + kYield * TMath::Gaus(dedx, kMean, kSigma, kTRUE)
154 + pYield * TMath::Gaus(dedx, pMean, pSigma, kTRUE);
158 //______________________________________________________________________________
159 Double_t FitFunc(Double_t* x, Double_t *par)
161 static const Double_t bgMIP = 0.5/piMass;
162 static const Double_t beta2MIP = bgMIP*bgMIP / (1.0+bgMIP*bgMIP);
163 // static const Double_t betapowMIP = TMath;
164 static const Double_t logMIP = TMath::Log(1+bgMIP);
168 Int_t option = TMath::Nint(par[0]);
169 Int_t specie = option;
190 case 4: // just use bg
194 cout << "Error in FitFunc: specie " << specie << " not supported!!!!!" << endl;
203 const Double_t beta2 = bg*bg / (1.0+bg*bg);
207 case 1: // standard parametrisation
210 c0/beta^2 + c1 * log (1+x)
212 const Double_t c0 = par[1];
213 const Double_t c1 = par[2];
215 const Double_t value = c0/beta2 + c1*TMath::Log(1+bg);
219 case 2: // fix the dE/dx to 50 at 0.5 GeV/c
221 const Double_t c1 = par[1];
222 const Double_t c0 = (fixMIP-par[1]*logMIP) * beta2MIP;
224 const Double_t value = c0/beta2 + c1*TMath::Log(1+bg);
228 case 3: // fix the dE/dx to 50 at 0.5 GeV/c and the plateau to 75
231 a/beta^2 + b/c*log( (1+x)^c / (1 + d*(1+x)^c) )
233 Assymptotic behavior:
235 1) Small bg (and d small so that d*(1+x)^c << 1)
237 a/beta^2 + b * log (1+x)
239 So this is the same beavior as the standard expression.
241 2) Large bg where d*(1+x)^c >> 1
242 a - b/c*log(d) = plateau
243 -> d = exp(c*(a-plateau)/b)
246 const Double_t b = par[1];
247 const Double_t a = (fixMIP-par[1]*logMIP) * beta2MIP;
248 const Double_t c = par[2];
249 const Double_t d = TMath::Exp(c*(a-fixPlateau)/b);
251 // cout << bg << ": " << a << ", " << b << ", " << c << ", " << d << endl;
253 const Double_t powbg = TMath::Power(1.0+bg, c);
255 const Double_t value = a/beta2 + b/c*TMath::Log(powbg/(1.0 + d*powbg));
259 case 4: // fix the dE/dx to 50 at 0.5 GeV/c and the plateau to 75
262 a/beta^2 + b/c*log( (1+x)^c / (1 + d*(1+x)^c) )
264 Assymptotic behavior:
266 1) Small bg (and d small so that d*(1+x)^c << 1)
268 a/beta^2 + b * log (1+x)
270 So this is the same beavior as the standard expression.
272 2) Large bg where d*(1+x)^c >> 1
273 a - b/c*log(d) = plateau
274 -> d = exp(c*(a-plateau)/b)
277 const Double_t a = par[1];
278 const Double_t b = par[2];
279 const Double_t c = par[3];
280 const Double_t d = TMath::Exp(c*(a-fixPlateau)/b);
282 // cout << bg << ": " << a << ", " << b << ", " << c << ", " << d << endl;
284 const Double_t powbg = TMath::Power(1.0+bg, c);
286 const Double_t value = a/beta2 + b/c*TMath::Log(powbg/(1.0 + d*powbg));
290 case 5: // fix the dE/dx to 50 at 0.5 GeV/c and the plateau to 75
293 a/beta^2 + b/c*log( (1+x)^c / (1 + d*(1+x)^c) )
295 Assymptotic behavior:
297 1) Small bg (and d small so that d*(1+x)^c << 1)
299 a/beta^2 + b * log (1+x)
301 So this is the same beavior as the standard expression.
303 2) Large bg where d*(1+x)^c >> 1
304 a - b/c*log(d) = plateau
305 -> d = exp(c*(a-plateau)/b)
308 const Double_t a = par[1];
309 const Double_t b = par[2];
310 const Double_t c = par[3];
311 const Double_t d = TMath::Exp(c*(a-fixPlateau)/b);
312 const Double_t e = par[4];
314 // cout << bg << ": " << a << ", " << b << ", " << c << ", " << d << endl;
316 const Double_t powbg = TMath::Power(1.0+bg, c);
318 const Double_t value = a/TMath::Power(beta2,e) + b/c*TMath::Log(powbg/(1.0 + d*powbg));
325 a/beta^(e/2) + b/c*log( (1+x)^c / (1 + d*(1+x)^c) )
327 Assymptotic behavior:
329 1) Small bg (and d small so that d*(1+x)^c << 1)
331 a/beta^(e/2) + b * log (1+x)
333 So this is the same beavior as the standard expression.
335 2) Large bg where d*(1+x)^c >> 1
336 a - b/c*log(d) = plateau
337 -> d = exp(c*(a-plateau)/b)
339 In this version we have 2 plateaus!!!!
340 Plateau 1 = electrons!
346 const Double_t a = par[1];
347 const Double_t b = par[2];
348 const Double_t c = par[3];
349 const Double_t d = TMath::Exp(c*(a-par[5])/b);
350 const Double_t e = par[4];
352 // cout << bg << ": " << a << ", " << b << ", " << c << ", " << d << endl;
354 const Double_t powbg = TMath::Power(1.0+bg, c);
356 const Double_t value = a/TMath::Power(beta2,e) + b/c*TMath::Log(powbg/(1.0 + d*powbg));
363 a/beta^(d/2) - b*log( c + 1.0/(1.0+x) )
365 Assymptotic behavior:
367 1) Small bg (and d small so that d*(1+x)^c << 1)
369 a/beta^(d/2) - b * log (1+x)
371 So this is the same beavior as the standard expression.
373 2) Large bg where c << 1
374 -b*log(c) = plateau-a
375 -> c = exp((a-plateau)/b)
378 const Double_t a = par[1];
379 const Double_t b = par[2];
380 const Double_t c = TMath::Exp((a-fixPlateau)/b);
381 const Double_t d = par[3];
383 // cout << bg << ": " << a << ", " << b << ", " << c << ", " << d << endl;
385 const Double_t value = a/TMath::Power(beta2,d) - b*TMath::Log(c + 1.0/(1.0+bg));
391 a/beta^(d/2) - b*log( c + 1.0/(1.0+x^e) )
393 Assymptotic behavior:
395 1) Small bg (and d small so that d*(1+x)^c << 1)
397 a/beta^(d/2) - b * log (1+x^e)
399 So this is the same beavior as the standard expression.
401 2) Large bg where c << 1
402 -b*log(c) = plateau-a
403 -> c = exp((a-plateau)/b)
406 const Double_t a = par[1];
407 const Double_t b = par[2];
408 const Double_t c = TMath::Exp((a-fixPlateau)/b);
409 const Double_t d = par[3];
410 const Double_t e = par[4];
412 // cout << bg << ": " << a << ", " << b << ", " << c << ", " << d << endl;
414 const Double_t value = a/TMath::Power(beta2,d) - b*TMath::Log(c + 1.0/(1.0+bg) + e/(1.0+TMath::Power(bg, 2)));
418 // case 3: // fix the dE/dx to 50 at 0.5 GeV/c + powerlaw
420 // static const bgMIP = 0.5/piMass;
421 // static const beta2MIP = bgMIP*bgMIP / (1.0+bgMIP*bgMIP);
422 // static const logMIP = TMath::Log(1+bgMIP);
424 // const Double_t c1 = par[1];
425 // const Double_t c2 = par[2]; // expect it to be 0.75 from Bichsel (beta**-1.5 instead of -2)
426 // const Double_t c0 = (50.0-par[1]*logMIP) * beta2MIP;
428 // const Double_t value = TMathh::Power(c0/beta2, c2) + c1*TMath::Log(1+bg);
435 cout << "Error in FitFunc: option " << option << " not supported!!!!!" << endl;
439 //______________________________________________________________________________
440 Double_t SigmaFunc(Double_t* x, Double_t *par)
442 Int_t option = Int_t(par[0]);
445 case 1: // fixed sigma
448 case 2: // relative sigma
451 case 3: // relative sigma + extrapolation
452 return (par[1] + (x[0]-fixMIP)*par[2])*x[0];
454 case 4: // relative sigma with dE/dx to some power close to 1
455 return par[1]*TMath::Power(x[0], par[2]);
457 case 5: // relative sigma with dE/dx to some power close to 1
458 return TMath::Sqrt(par[1]*par[1]*x[0]*x[0] + par[2]*par[2]);
460 case 6: // relative sigma with dE/dx to some power close to 1
461 return par[1]*x[0]*TMath::Power(x[0]/50.0, par[2]);
463 case 7: // 1/x^some power + constant
464 return x[0]*(par[2]*TMath::Power(x[0], -par[3]) + par[1]);
466 case 8: // for fitting relative sigma
467 return par[2]*TMath::Power(x[0], -par[3]) + par[1];
469 case 9: // for fitting relative sigma
470 return par[1]+par[2]*x[0]+par[3]*x[0]*x[0];
472 case 10: // for fitting relative sigma
473 return par[1]+par[2]*x[0]+par[3]*x[0]*x[0]-par[4]/(x[0]*x[0]*x[0])-par[5]/(x[0]*x[0]);
475 case 11: // for fitting relative sigma
476 return x[0]*(par[1]+par[2]*x[0]+par[3]*x[0]*x[0]-par[4]/(x[0]*x[0]*x[0])-par[5]/(x[0]*x[0]));
478 case 12: // for fitting relative sigma
479 return par[1]+par[2]*x[0]+par[3]*x[0]*x[0];
481 case 13: // for fitting relative sigma
482 return x[0]*(par[1]+par[2]*x[0]+par[3]*x[0]*x[0]);
484 case 14: // for fitting relative sigma
485 return par[1]+par[2]*x[0];
487 case 15: // for fitting relative sigma
488 return x[0]*(par[1]+par[2]*x[0]);
500 cout << "Error in SigmaFunc: option " << option << " not supported!!!!!" << endl;