86{
87
89 if(
object.
IsA()->InheritsFrom(
"TH1" ))
90 {
93 throw dqm_core::BadConfig( ERS_HERE, name, "dimension > 1 for Fit" );
94 }
95
96
97
98
99 }
100 else {
101 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
102 }
103
104
108
111
113
114
116
117
118
119
120
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();
125 }
126
128 int nbins =
x->GetNbins();
129 double high =
x->GetBinUpEdge(nbins);
130 double low =
x->GetBinUpEdge(0);
131
133 throw dqm_core::BadConfig( ERS_HERE, name, "xmin and/or xmax value not in histogram bin range" );
134 }
135
136 std::string option;
137
138
140
141
142 option="N";
143 } else {
144
145
146 option = "QN";
147 }
148
149
150 if( lf == 1.0 ) option += "L";
151 else if ( lf == 2.0 ) option += "LL";
152
153
154 if ( minSig != 0 ) {
155 option += "E";
156 }
157
159 std::cout <<
" histo name " <<
histogram->GetName() << std::endl;
160 std::cout <<" fit option " << option << std::endl;
161 }
162
163 if (
m_name ==
"gauspluspol1"){
165 m_func->SetParNames (
"Constant",
"Mean",
"Sigma",
"pol1[0]",
"pol1[1]");
166 }
167 else if (
m_name ==
"pol1"){
168 m_func->SetParNames (
"pol1[0]",
"pol1[1]");
169 }
170 else if (
m_name ==
"sinusoid") {
171 m_func->SetParameters(4.0,-1.0);
172 m_func->SetParNames(
"s1",
"s2");
173 }
174 else if (
m_name ==
"doublegaus"){
176 const_cast<TH1*
>(
histogram)->Fit(&f1,
"q");
178
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");
185
186
187
188
189
190 }
191 else if (
m_name ==
"gausplusexpo") {
193 m_func->SetParNames(
"Constant",
"Mean",
"Sigma",
"ConstantExpo",
"Slope");
194 }
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");
200 }
201 else if(
m_name ==
"flat") {
202 if(
verbose)std::cout <<
"set "<<
name<<
" parameters" << std::endl;
203 m_func->SetParNames(
"Height");
204 }
205
206
207
208
209
210
211
212
213
214
215 if(ignoreFirstLastBin) {
216 int firstNonEmptyBin=0;
217 int lastNonEmptyBin=0;
218 for(
int i=1 ;
i<=
nbins ;
i++) {
221 break;
222 }
223 }
224 for(
int i=nbins ;
i>=0 ;
i--) {
227 break;
228 }
229 }
230
231 if( lastNonEmptyBin-firstNonEmptyBin>2) {
232 if (
x->GetBinLowEdge(firstNonEmptyBin+1) >
xmin ) {
233 xmin=
x->GetBinLowEdge(firstNonEmptyBin+1);
234 }
235 if (
x->GetBinUpEdge(lastNonEmptyBin-1) <
xmax ) {
236 xmax=
x->GetBinUpEdge(lastNonEmptyBin-1);
237 }
238 }
239
240 }
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");
248 m_func->SetParameter(2,std::abs(sigma));
249 }
250 else {
251 m_func->SetParNames(
"Constant",
"Mean",
"Sigma",
"Constant1",
"Mean1",
"Sigma1");
253 m_func->SetParameter(5,std::abs(sigma));
254 }
255 }
256
257 const int numsig =
m_func->GetParNumber(
"Sigma");
258 if (numsig != -1 ){
260 m_func->SetParameter(numsig,std::abs(sigma));
261 }
262
263 try {
266 }
267 catch ( dqm_core::Exception & ex ) {
268 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
269 }
270}
std::unique_ptr< TF1 > m_func
#define IsA
Declare the TObject style functions.