CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
HDQMfitUtilities Class Reference

#include <HDQMfitUtilities.h>

Public Member Functions

double doGaussFit (MonitorElement *ME)
 
double doGaussFit (TH1F *)
 
double doLanGaussFit (MonitorElement *ME)
 
double doLanGaussFit (TH1F *)
 
double getFitChi ()
 
int getFitnDof ()
 
double getGaussPar (std::string s)
 
double getGaussParErr (std::string s)
 
double getLanGaussConv (std::string s)
 
double getLanGaussPar (std::string s)
 
double getLanGaussParErr (std::string s)
 
 HDQMfitUtilities ()
 
void init ()
 
 ~HDQMfitUtilities ()
 

Private Attributes

double chi2GausS
 
double epGausS [3]
 
double epLanGausS [4]
 
TF1 * gausFit
 
TF1 * langausFit
 
int32_t nDofGausS
 
double pGausS [3]
 
double pLanConv [2]
 
double pLanGausS [4]
 

Detailed Description

Definition at line 29 of file HDQMfitUtilities.h.

Constructor & Destructor Documentation

HDQMfitUtilities::HDQMfitUtilities ( )

Definition at line 178 of file HDQMfitUtilities.cc.

References init().

178  :langausFit(0),gausFit(0){
179  init();
180 }
HDQMfitUtilities::~HDQMfitUtilities ( )

Definition at line 198 of file HDQMfitUtilities.cc.

References gausFit, and langausFit.

198  {
199  if ( langausFit!=0 ) delete langausFit;
200  if ( gausFit!=0 ) delete gausFit;
201 }

Member Function Documentation

double HDQMfitUtilities::doGaussFit ( MonitorElement ME)
inline

Definition at line 40 of file HDQMfitUtilities.h.

References doGaussFit(), and MonitorElement::getTH1F().

Referenced by doGaussFit(), and DQMHistoryServiceBase::setDBValuesForGauss().

40 {return doGaussFit(ME->getTH1F());}
double doGaussFit(MonitorElement *ME)
TH1F * getTH1F(void) const
double HDQMfitUtilities::doGaussFit ( TH1F *  htoFit)

Definition at line 290 of file HDQMfitUtilities.cc.

References chi2GausS, epGausS, gausFit, HDQMUtil::Gauss(), i, init(), langausFit, nDofGausS, pGausS, SiStripMonitorClusterAlca_cfi::xmax, and SiStripMonitorClusterAlca_cfi::ymax.

290  {
291  init();
292  // if (htoFit->GetEntries()!=0) {
293  if (htoFit->Integral()!=0) {
294 
295  // Setting fit range and start values
296  double fr[2];
297  double sv[3], pllo[3], plhi[3];
298  fr[0]=htoFit->GetMean()-5*htoFit->GetRMS();
299  fr[1]=htoFit->GetMean()+5*htoFit->GetRMS();
300 
301  int32_t imax=htoFit->GetMaximumBin();
302  double xmax=htoFit->GetBinCenter(imax);
303  double ymax=htoFit->GetBinContent(imax);
304  int32_t i[2];
305  int32_t iArea[2];
306 
307  i[0]=htoFit->GetXaxis()->FindBin(fr[0]);
308  i[1]=htoFit->GetXaxis()->FindBin(fr[1]);
309 
310  iArea[0]=htoFit->GetXaxis()->FindBin(fr[0]);
311  iArea[1]=htoFit->GetXaxis()->FindBin(fr[1]);
312  double AreaFWHM=htoFit->Integral(iArea[0],iArea[1],"width");
313 
314  sv[2]=AreaFWHM/(4*ymax);
315  sv[1]=xmax;
316  sv[0]=htoFit->Integral(i[0],i[1],"width");
317 
318  plhi[0]=1000000.0; plhi[1]=10.0; plhi[2]=10.;
319  pllo[0]=1.5 ; pllo[1]=0.1; pllo[2]=0.3;
320  Char_t FunName[100];
321  sprintf(FunName,"FitfcnLG_%s",htoFit->GetName());
322  gausFit = new TF1(FunName,HDQMUtil::Gauss,fr[0],fr[1],3);
323  gausFit->SetParameters(sv);
324  gausFit->SetParNames("Constant","GaussPeak","Sigma");
325 
326  for (int32_t i=0; i<3; i++) {
327  gausFit->SetParLimits(i,pllo[i],plhi[i]);
328  }
329 
330  try{
331  htoFit->Fit(gausFit,"R0");
332 
333  gausFit->SetRange(fr[0],fr[1]);
334  gausFit->GetParameters(pGausS);
335  std::memcpy((void*) epGausS, (void*) gausFit->GetParErrors(), 3*sizeof(double));
336 
337  chi2GausS =langausFit->GetChisquare(); // obtain chi^2
338  nDofGausS = langausFit->GetNDF();// obtain ndf
339  }
340  catch(cms::Exception& iException){
341  edm::LogError("fitUtility") << "problem in fitting " << htoFit->GetTitle() << " \n\tDefault values of the parameters will be used";
342  pGausS[0]=-9999; pGausS[1]=-9999; pGausS[2]=-9999;
343  epGausS[0]=-9999; epGausS[1]=-9999; epGausS[2]=-9999;
344  chi2GausS=-9999; nDofGausS=-9999;
345  }
346 
347  }
348  else {
349  pGausS[0]=-9999; pGausS[1]=-9999; pGausS[2]=-9999;
350  epGausS[0]=-9999; epGausS[1]=-9999; epGausS[2]=-9999;
351  chi2GausS=-9999; nDofGausS=-9999;
352  }
353 
354  return htoFit->GetEntries();
355 }
int i
Definition: DBlmapReader.cc:9
double Gauss(double *x, double *par)
double HDQMfitUtilities::doLanGaussFit ( MonitorElement ME)
inline

Definition at line 37 of file HDQMfitUtilities.h.

References doLanGaussFit(), and MonitorElement::getTH1F().

Referenced by doLanGaussFit(), and DQMHistoryServiceBase::setDBValuesForLandau().

37 {return doLanGaussFit(ME->getTH1F());}
TH1F * getTH1F(void) const
double doLanGaussFit(MonitorElement *ME)
double HDQMfitUtilities::doLanGaussFit ( TH1F *  htoFit)

Definition at line 206 of file HDQMfitUtilities.cc.

References chi2GausS, epLanGausS, i, init(), HDQMUtil::langaufun(), HDQMUtil::langaupro(), langausFit, nDofGausS, pLanConv, pLanGausS, SiStripMonitorClusterAlca_cfi::xmax, and SiStripMonitorClusterAlca_cfi::ymax.

206  {
207  init();
208 
209  // if (htoFit->GetEntries()!=0) {
210  // Check for the entries excluding over/underflows
211  if (htoFit->Integral()!=0) {
212  edm::LogInfo("fitUtility")<<"Fitting "<< htoFit->GetTitle() <<std::endl;
213  // Setting fit range and start values
214  double fr[2];
215  double sv[4], pllo[4], plhi[4];
216  fr[0]=0.5*htoFit->GetMean();
217  fr[1]=3.0*htoFit->GetMean();
218 
219  // (EM) parameters setting good for signal only
220  int32_t imax=htoFit->GetMaximumBin();
221  double xmax=htoFit->GetBinCenter(imax);
222  double ymax=htoFit->GetBinContent(imax);
223  int32_t i[2];
224  int32_t iArea[2];
225 
226  i[0]=htoFit->GetXaxis()->FindBin(fr[0]);
227  i[1]=htoFit->GetXaxis()->FindBin(fr[1]);
228 
229  iArea[0]=htoFit->GetXaxis()->FindBin(fr[0]);
230  iArea[1]=htoFit->GetXaxis()->FindBin(fr[1]);
231  double AreaFWHM=htoFit->Integral(iArea[0],iArea[1],"width");
232 
233  sv[1]=xmax;
234  sv[2]=htoFit->Integral(i[0],i[1],"width");
235  sv[3]=AreaFWHM/(4*ymax);
236  sv[0]=sv[3];
237 
238  plhi[0]=25.0; plhi[1]=200.0; plhi[2]=1000000.0; plhi[3]=50.0;
239  pllo[0]=1.5 ; pllo[1]=10.0 ; pllo[2]=1.0 ; pllo[3]= 1.0;
240 
241  Char_t FunName[100];
242  sprintf(FunName,"FitfcnLG_%s",htoFit->GetName());
243 
244  langausFit = new TF1(FunName,HDQMUtil::langaufun,fr[0],fr[1],4);
245  langausFit->SetParameters(sv);
246  langausFit->SetParNames("Width","MP","Area","GSigma");
247 
248  for (int32_t i=0; i<4; i++) {
249  langausFit->SetParLimits(i,pllo[i],plhi[i]);
250  }
251 
252  try{
253  htoFit->Fit(langausFit,"R0"); // "R" fit in a range,"0" quiet fit
254 
255  langausFit->SetRange(fr[0],fr[1]);
256  langausFit->GetParameters(pLanGausS);
257  std::memcpy((void*) epLanGausS, (void*) langausFit->GetParErrors(), 4*sizeof(double));
258 
259  chi2GausS =langausFit->GetChisquare(); // obtain chi^2
260  nDofGausS = langausFit->GetNDF(); // obtain ndf
261 
262  double sPeak, sFWHM;
263  HDQMUtil::langaupro(pLanGausS,sPeak,sFWHM);
264  pLanConv[0]=sPeak;
265  pLanConv[1]=sFWHM;
266  edm::LogInfo("fitUtility") << "langaupro: max " << sPeak << std::endl;
267  edm::LogInfo("fitUtility") << "langaupro: FWHM " << sFWHM << std::endl;
268  }
269  catch(cms::Exception& iException){
270  edm::LogError("fitUtility") << "problem in fitting " << htoFit->GetTitle() << " \n\tDefault values of the parameters will be used";
271  pLanGausS[0]=-9999; pLanGausS[1]=-9999; pLanGausS[2]=-9999; pLanGausS[3]=-9999;
272  epLanGausS[0]=-9999; epLanGausS[1]=-9999; epLanGausS[2]=-9999; epLanGausS[3]=-9999;
273  pLanConv[0]=-9999; pLanConv[1]=-9999;
274  chi2GausS=-9999; nDofGausS=-9999;
275  }
276  }
277  else {
278  pLanGausS[0]=-9999; pLanGausS[1]=-9999; pLanGausS[2]=-9999; pLanGausS[3]=-9999;
279  epLanGausS[0]=-9999; epLanGausS[1]=-9999; epLanGausS[2]=-9999; epLanGausS[3]=-9999;
280  pLanConv[0]=-9999; pLanConv[1]=-9999;
281  chi2GausS=-9999; nDofGausS=-9999;
282  }
283 
284  return htoFit->GetEntries();
285 
286 }
int i
Definition: DBlmapReader.cc:9
int32_t langaupro(double *params, double &maxx, double &FWHM)
double langaufun(double *x, double *par)
double HDQMfitUtilities::getFitChi ( )
inline
int HDQMfitUtilities::getFitnDof ( )
inline
double HDQMfitUtilities::getGaussPar ( std::string  s)

Definition at line 393 of file HDQMfitUtilities.cc.

References pGausS.

Referenced by DQMHistoryServiceBase::setDBValuesForGauss().

393  {
394  if(s=="area")
395  return pGausS[0];
396  else if(s=="mean")
397  return pGausS[1];
398  else if(s=="sigma")
399  return pGausS[2];
400  else
401  return -99999;
402 }
double HDQMfitUtilities::getGaussParErr ( std::string  s)

Definition at line 404 of file HDQMfitUtilities.cc.

References epGausS.

404  {
405  if(s=="area")
406  return epGausS[0];
407  else if(s=="mean")
408  return epGausS[1];
409  else if(s=="sigma")
410  return epGausS[2];
411  else
412  return -99999;
413 }
double HDQMfitUtilities::getLanGaussConv ( std::string  s)

Definition at line 384 of file HDQMfitUtilities.cc.

References pLanConv.

Referenced by DQMHistoryServiceBase::setDBValuesForLandau().

384  {
385  if(s=="mpv")
386  return pLanConv[0];
387  else if(s=="fwhm")
388  return pLanConv[1];
389  else
390  return -99999;
391 }
double HDQMfitUtilities::getLanGaussPar ( std::string  s)

Definition at line 358 of file HDQMfitUtilities.cc.

References pLanGausS.

Referenced by DQMHistoryServiceBase::setDBValuesForLandau().

358  {
359  if(s=="landau_width")
360  return pLanGausS[0];
361  else if(s=="mpv")
362  return pLanGausS[1];
363  else if(s=="area")
364  return pLanGausS[2];
365  else if(s=="gauss_sigma")
366  return pLanGausS[3];
367  else
368  return -99999;
369 }
double HDQMfitUtilities::getLanGaussParErr ( std::string  s)

Definition at line 371 of file HDQMfitUtilities.cc.

References epLanGausS.

Referenced by DQMHistoryServiceBase::setDBValuesForLandau().

371  {
372  if(s=="landau_width")
373  return epLanGausS[0];
374  else if(s=="mpv")
375  return epLanGausS[1];
376  else if(s=="area")
377  return epLanGausS[2];
378  else if(s=="gauss_sigma")
379  return epLanGausS[3];
380  else
381  return -99999;
382 }
void HDQMfitUtilities::init ( void  )

Definition at line 183 of file HDQMfitUtilities.cc.

References chi2GausS, epGausS, epLanGausS, nDofGausS, pGausS, pLanConv, and pLanGausS.

Referenced by doGaussFit(), doLanGaussFit(), and HDQMfitUtilities().

183  {
184  pLanGausS[0]=0 ; pLanGausS[1]=0; pLanGausS[2]=0; pLanGausS[3]=0;
185  epLanGausS[0]=0; epLanGausS[1]=0; epLanGausS[2]=0; epLanGausS[3]=0;
186  pGausS[0]=0 ; pGausS[1]=0; pGausS[2]=0;
187  epGausS[0]=0; epGausS[1]=0; epGausS[2]=0;
188  pLanConv[0]=0; pLanConv[1]=0;
189 
190  //if ( langausFit!=0 ) delete langausFit;
191  //if ( gausFit!=0 ) delete gausFit;
192 
193  chi2GausS = -9999.;
194  nDofGausS = -9999;
195 }

Member Data Documentation

double HDQMfitUtilities::chi2GausS
private

Definition at line 58 of file HDQMfitUtilities.h.

Referenced by doGaussFit(), doLanGaussFit(), getFitChi(), and init().

double HDQMfitUtilities::epGausS[3]
private

Definition at line 56 of file HDQMfitUtilities.h.

Referenced by doGaussFit(), getGaussParErr(), and init().

double HDQMfitUtilities::epLanGausS[4]
private

Definition at line 55 of file HDQMfitUtilities.h.

Referenced by doLanGaussFit(), getLanGaussParErr(), and init().

TF1* HDQMfitUtilities::gausFit
private

Definition at line 61 of file HDQMfitUtilities.h.

Referenced by doGaussFit(), and ~HDQMfitUtilities().

TF1* HDQMfitUtilities::langausFit
private

Definition at line 60 of file HDQMfitUtilities.h.

Referenced by doGaussFit(), doLanGaussFit(), and ~HDQMfitUtilities().

int32_t HDQMfitUtilities::nDofGausS
private

Definition at line 59 of file HDQMfitUtilities.h.

Referenced by doGaussFit(), doLanGaussFit(), getFitnDof(), and init().

double HDQMfitUtilities::pGausS[3]
private

Definition at line 56 of file HDQMfitUtilities.h.

Referenced by doGaussFit(), getGaussPar(), and init().

double HDQMfitUtilities::pLanConv[2]
private

Definition at line 57 of file HDQMfitUtilities.h.

Referenced by doLanGaussFit(), getLanGaussConv(), and init().

double HDQMfitUtilities::pLanGausS[4]
private

Definition at line 55 of file HDQMfitUtilities.h.

Referenced by doLanGaussFit(), getLanGaussPar(), and init().