47 #include <dqm_core/AlgorithmManager.h>
48 #include <dqm_core/exceptions.h>
57 #include "TripleGaussCollFit_standalone.h"
73 int minidx = thehist->FindBin(minx),
maxidx = thehist->FindBin(maxx);
75 Double_t
val = thehist->GetBinContent(
idx);
84 const char*
const fmt =
"%0*d";
91 std::string lb_str =
"LB_";
92 int firstLB = (*goodLB)[0],
offset = 1;
93 unsigned int c = 1,
sz = goodLB->size(), psz =
static_cast<unsigned int>( std::log10(
sz))+1;
97 if ((*goodLB)[
c] == firstLB +
offset)
104 lo = thehist->GetXaxis()->GetBinLowEdge(firstLB);
106 if (lo == std::floor(lo))
107 sprintf(buf,
fmt, psz,
static_cast<Int_t
>(lo));
109 sprintf(buf,
fmt, psz,
static_cast<Int_t
>(std::floor(lo))+1);
114 hi = thehist->GetXaxis()->GetBinUpEdge(firstLB+
offset-1);
116 if (hi == std::floor(hi))
117 sprintf(buf,
fmt, psz,
static_cast<Int_t
>(std::floor(hi))-1);
119 sprintf(buf,
fmt, psz,
static_cast<Int_t
>(std::floor(hi)));
123 firstLB = (*goodLB)[
c];
130 lo = thehist->GetXaxis()->GetBinLowEdge(firstLB);
132 if (lo == std::floor(lo))
133 sprintf(buf,
fmt, psz,
static_cast<Int_t
>(lo));
135 sprintf(buf,
fmt, psz,
static_cast<Int_t
>(std::floor(lo))+1);
139 hi = thehist->GetXaxis()->GetBinUpEdge(firstLB+
offset-1);
140 if (hi == std::floor(hi))
141 sprintf(buf,
fmt, psz,
static_cast<Int_t
>(std::floor(hi))-1);
143 sprintf(buf,
fmt, psz,
static_cast<Int_t
>(std::floor(hi)));
145 result->tags_ [lb_str] = 1.0;
163 typedef std::map<std::string, double>
err_map;
165 #define PARAM_IS_AREA //if this is not in, the constants multiplying the Gaussians are defined as max_ht, not integr. area
193 out <<
"Gaus3_"+
m_name +
"_Fit: specialized fit for the Tile timining difference plot." << std::endl;
194 out <<
"Current parameter values: " << std::endl;
198 out <<
" Param. " <<
i <<
": " <<
m_gaus3_fn->GetParName(
i) <<
" , current value: "
202 out <<
" execute() has not been called" << std::endl;
204 out <<
"Parameter list: " << std::endl
205 <<
" allowFitMean: 1 allows fitting for a shift in the entire function around zero by up to 5ns" << std::endl
206 <<
" allowFitMeanNonzeroPeaks: 1 allows fitting of the distance between center and off-center Gaussians" << std::endl
207 <<
" allowFitResolution: 1 allows fitting the (shared) width of the Gaussians" << std::endl
208 <<
" reportSignificance: 1 reports the central peak significance for each LB as a tag" << std::endl
209 <<
" meanZeroPeak: starting or fixed mean of the Gaussian centered at zero" << std::endl
210 <<
" meanNonZeroPeaks: starting or fixed mean of the other Gaussians" << std::endl
211 <<
" resolutionAll: starting or fixed value of the width of the Gaussians" << std::endl
212 <<
" minSignificance: number of events required for checks to be valid, undefined if not set." << std::endl
213 <<
" centralPeakMinSignificance: significance of central peak required for a LB to pass threshold; default is 3.0" << std::endl
214 <<
" minEvents: number of events required to attempt a fit; default is 5." << std::endl ;
216 out <<
"Currently, no thresholds are defined." << std::endl;
223 if(
object.
IsA()->InheritsFrom(
"TH1"))
227 throw dqm_core::BadConfig( ERS_HERE,
m_name,
"called with histogram of dimension > 2" );
231 throw dqm_core::BadConfig( ERS_HERE,
m_name,
"called with object that does not inherit from TH1" );
239 throw dqm_core::BadConfig( ERS_HERE,
m_name,
"called with histogram with no bins");
243 const TH1*
proj =
static_cast<const TH2*
>(
histogram)->ProjectionY(
"", 0, 0);
244 if (
proj->GetNbinsX() >= 1) {
247 throw dqm_core::BadConfig( ERS_HERE,
m_name,
"called with histogram with no bins");
251 m_gaus3_fn =
new TF1(
"gaus3", Form(
"[3]/[2]/2.5066*%f*exp(-0.5*((x-[0]+[1])/[2])**2) + [4]/[2]/2.5066*%f*exp(-0.5*((x-[0])/[2])**2) + [5]/[2]/2.5066*%f*exp(-0.5*((x-[0]-[1])/[2])**2)",
binwidth,
binwidth,
binwidth), -100, 100);
253 m_gaus3_fn =
new TF1(
"gaus3",
"[3]*exp(-0.5*((x-[0]+[1])/[2])**2) + [4]*exp(-0.5*((x-[0])/[2])**2) + [5]*exp(-0.5*((x-[0]-[1])/[2])**2)", -100, 100);
256 m_gaus3_fn->SetParName(1,
"Mean_offzero_gaus");
262 Double_t resolutionAll, meanZeroPeak, meanNonzeroPeaks, minEvents;
275 m_gaus3_fn->SetParLimits(0, meanZeroPeak-5, meanZeroPeak+5);
281 m_gaus3_fn->SetParameter(1, meanNonzeroPeaks);
282 m_gaus3_fn->SetParLimits(1, meanNonzeroPeaks-10, meanNonzeroPeaks+10);
285 m_gaus3_fn->FixParameter(1, meanNonzeroPeaks);
306 for (err_map::const_iterator peit = paramErrors.begin(); peit != paramErrors.end(); ++peit) {
307 result->tags_[(*peit).first +
" Error"] = (*peit).second;
311 catch ( dqm_core::Exception & ex) {
312 throw dqm_core::BadConfig( ERS_HERE,
m_name, ex.what(), ex);
323 unsigned int psz = (
unsigned int) std::log10(nxbin)+1;
325 std::vector<int> goodLB;
327 const std::string sig_str =
"SIG_LB_";
329 for (
int lb = 0;
lb < nxbin;
lb++) {
331 sprintf(buf,
fmt, psz,
lb);
333 Double_t good_entries =
proj->GetEntries() -
proj->GetBinContent(0) -
proj->GetBinContent(
proj->GetNbinsX()+1);
334 if (good_entries < minEvents) {
336 result->tags_[sig_str+buf] = 0;
345 m_gaus3_fn->SetParameter(1, meanNonzeroPeaks);
353 result->histos_.push_back((TH1D*)
proj->Clone());
358 result->tags_[sig_str+buf] = 0;
366 goodLB.push_back(
lb);
371 if (goodLB.size() != 0)
380 #define ADJUST_VAL startVal = startVal * hist1D->GetBinWidth(1) / m_gaus3_fn->GetParameter(2) / 2.5066
388 const Double_t window = 5.0;
390 Double_t offset_all =
m_gaus3_fn->GetParameter(0);
391 Double_t offset_nz =
m_gaus3_fn->GetParameter(1);