84 const TObject &
object,
85 const dqm_core::AlgorithmConfig &
config )
89 if(
object.
IsA()->InheritsFrom(
"TH1" ))
93 throw dqm_core::BadConfig( ERS_HERE, name,
"dimension > 1 for Fit" );
101 throw dqm_core::BadConfig( ERS_HERE, name,
"does not inherit from TH1" );
121 if (
histogram->GetEffectiveEntries() < minstat ||
histogram->GetEffectiveEntries()==0) {
122 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
123 result->tags_[
"InsufficientEffectiveEntries"] =
histogram->GetEffectiveEntries();
128 int nbins =
x->GetNbins();
129 double high =
x->GetBinUpEdge(nbins);
130 double low =
x->GetBinUpEdge(0);
133 throw dqm_core::BadConfig( ERS_HERE, name,
"xmin and/or xmax value not in histogram bin range" );
150 if( lf == 1.0 ) option +=
"L";
151 else if ( lf == 2.0 ) option +=
"LL";
159 std::cout <<
" histo name " <<
histogram->GetName() << std::endl;
160 std::cout <<
" fit option " << option << std::endl;
163 if (
m_name ==
"gauspluspol1"){
165 m_func->SetParNames (
"Constant",
"Mean",
"Sigma",
"pol1[0]",
"pol1[1]");
167 else if (
m_name ==
"pol1"){
168 m_func->SetParNames (
"pol1[0]",
"pol1[1]");
170 else if (
m_name ==
"sinusoid") {
171 m_func->SetParameters(4.0,-1.0);
172 m_func->SetParNames(
"s1",
"s2");
174 else if (
m_name ==
"doublegaus"){
176 const_cast<TH1*
>(
histogram)->Fit(&f1,
"q");
179 f1.GetParameters(par);
180 m_func->SetParameters(par);
183 m_func->SetParameter(5,par[2]);
184 m_func->SetParNames(
"Constant",
"Mean",
"Sigma",
"Constant1",
"Mean1",
"Sigma1");
191 else if (
m_name ==
"gausplusexpo") {
193 m_func->SetParNames(
"Constant",
"Mean",
"Sigma",
"ConstantExpo",
"Slope");
195 else if (
m_name ==
"fermi") {
196 m_func->SetParameter(0,0.99);
197 m_func->SetParameter(1,5);
198 m_func->SetParameter(2,1);
199 m_func->SetParNames(
"Plateau",
"Threshold",
"Resolution");
201 else if(
m_name ==
"flat") {
202 if(
verbose)std::cout <<
"set "<<name<<
" parameters" << std::endl;
203 m_func->SetParNames(
"Height");
215 if(ignoreFirstLastBin) {
216 int firstNonEmptyBin=0;
217 int lastNonEmptyBin=0;
218 for(
int i=1 ; i<=nbins ; i++) {
224 for(
int i=nbins ; i>=0 ; i--) {
231 if( lastNonEmptyBin-firstNonEmptyBin>2) {
232 if (
x->GetBinLowEdge(firstNonEmptyBin+1) >
xmin ) {
233 xmin=
x->GetBinLowEdge(firstNonEmptyBin+1);
235 if (
x->GetBinUpEdge(lastNonEmptyBin-1) <
xmax ) {
236 xmax=
x->GetBinUpEdge(lastNonEmptyBin-1);
242 if (
m_name ==
"doublegaus") {
244 m_func->GetParameters(par);
245 if (std::abs(par[2]) > std::abs(par[5])) {
246 m_func->SetParNames(
"Constant1",
"Mean1",
"Sigma1",
"Constant",
"Mean",
"Sigma");
247 double sigma=
m_func->GetParameter(2);
248 m_func->SetParameter(2,std::abs(sigma));
251 m_func->SetParNames(
"Constant",
"Mean",
"Sigma",
"Constant1",
"Mean1",
"Sigma1");
252 double sigma=
m_func->GetParameter(5);
253 m_func->SetParameter(5,std::abs(sigma));
257 const int numsig =
m_func->GetParNumber(
"Sigma");
259 double sigma=
m_func->GetParameter(numsig);
260 m_func->SetParameter(numsig,std::abs(sigma));
267 catch ( dqm_core::Exception & ex ) {
268 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );