62{
63
64
65 const TGraph * graph;
66 if(
object.
IsA()->InheritsFrom(
"TGraph" ))
67 {
68 graph =
static_cast<const TGraph*
>(&
object);
69 }
70 else {
71 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TGraph" );
72 }
73
74
77
80
84
85
90
91
92
93
94
95 if (graph->GetN() < minpoint || graph->GetN()==0) {
96 if(
verbose)std::cout <<
name <<
" number of points are too small " << graph->GetN() << std::endl;
97 dqm_core::Result *
result =
new dqm_core::Result(dqm_core::Result::Undefined);
98 result->tags_[
"InsufficientN"] = graph->GetN();
100 }
101 if(
verbose)std::cout <<
name <<
" enough number of points " << graph->GetN() << std::endl;
102
103 TAxis *
x = graph->GetXaxis();
104 int nbins =
x->GetNbins();
105 double high =
x->GetBinUpEdge(nbins);
106 double low =
x->GetBinUpEdge(0);
107
108
110 throw dqm_core::BadConfig( ERS_HERE, name, "xmin and/or xmax value not in graph bin range" );
111 }
112
113 std::string option;
114
115
117
118
119 option="N";
120 } else {
121
122
123 option = "QN";
124 }
125
126
127
128 if ( minSig != 0 ) option += "E";
129 if ( improve ) option += "M";
130
132 std::cout <<" graph name " << graph->GetName() << std::endl;
133 std::cout <<" fit option " << option << std::endl;
134 }
135
137 if(
verbose)std::cout <<
"set "<<
name<<
" parameters" << std::endl;
139 m_func->SetParameter(1,xaxismean);
140 m_func->SetParameter(2,xdiff/50.);
141 m_func->SetParNames(
"Plateau",
"Threshold",
"Resolution");
142
145 m_func->SetParLimits(2, 0., xdiff/4. );
146 }
147 else if(
m_name ==
"erf") {
148 if(
verbose)std::cout <<
"set "<<
name<<
" parameters" << std::endl;
150 m_func->SetParameter(1,xaxismean);
151 m_func->SetParameter(2,xdiff/50.);
152 m_func->SetParNames(
"Plateau",
"Threshold",
"Resolution");
153
156 m_func->SetParLimits(2, 0., xdiff/4. );
157 }
158 else if(
m_name ==
"flat") {
159 if(
verbose)std::cout <<
"set "<<
name<<
" parameters" << std::endl;
160 m_func->SetParNames(
"Height");
161 }
162
163
164
165
166
167
168
169
170
171 if(
verbose)std::cout <<
"fit "<<
name<<
" with interval cut " <<
xmin <<
" - " <<
xmax << std::endl;
172 const_cast<TGraph*
>(graph)->Fit(
m_func.get(), option.c_str(),
"",
xmin,
xmax );
173
174 const int numsig =
m_func->GetParNumber(
"Sigma");
175 if (numsig != -1 ){
177 m_func->SetParameter(numsig,std::abs(sigma));
178 }
179
180 try {
183 }
184 catch ( dqm_core::Exception & ex ) {
185 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
186 }
187}
#define IsA
Declare the TObject style functions.