CMS 3D CMS Logo

Functions
alig_utils Namespace Reference

Functions

int fitProfile (TProfile *p, double x_mean, double x_rms, unsigned int minBinEntries, unsigned int minNBinsReasonable, double &sl, double &sl_unc)
 

Function Documentation

◆ fitProfile()

int alig_utils::fitProfile ( TProfile *  p,
double  x_mean,
double  x_rms,
unsigned int  minBinEntries,
unsigned int  minNBinsReasonable,
double &  sl,
double &  sl_unc 
)

Definition at line 14 of file utils.cc.

References AlCaHLTBitMon_ParallelJobs::p.

Referenced by PPSAlignmentHarvester::buildGraphFromMonitorElements(), and PPSAlignmentConfigurationESSource::buildVectorFromDirectory().

20  {
21  unsigned int n_reasonable = 0;
22  for (int bi = 1; bi <= p->GetNbinsX(); bi++) {
23  if (p->GetBinEntries(bi) < minBinEntries) {
24  p->SetBinContent(bi, 0.);
25  p->SetBinError(bi, 0.);
26  } else {
27  n_reasonable++;
28  }
29  }
30 
31  if (n_reasonable < minNBinsReasonable)
32  return 1;
33 
34  double x_min = x_mean - x_rms, x_max = x_mean + x_rms;
35 
36  auto ff_pol1 = std::make_unique<TF1>("ff_pol1", "[0] + [1]*x");
37 
38  ff_pol1->SetParameter(0., 0.);
39  p->Fit(ff_pol1.get(), "Q", "", x_min, x_max);
40 
41  sl = ff_pol1->GetParameter(1);
42  sl_unc = ff_pol1->GetParError(1);
43 
44  return 0;
45 }