CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Comp2RefChi2 Class Reference

#include <QTest.h>

Inheritance diagram for Comp2RefChi2:
SimpleTest QCriterion

Public Member Functions

 Comp2RefChi2 (const std::string &name)
 
float runTest (const MonitorElement *me) override
 
- Public Member Functions inherited from SimpleTest
std::vector< DQMChannelgetBadChannels () const override
 get vector of channels that failed test (not always relevant!) More...
 
void setMinimumEntries (unsigned n)
 set minimum # of entries needed More...
 
 SimpleTest (const std::string &name, bool keepBadChannels=false)
 
- Public Member Functions inherited from QCriterion
std::string algoName () const
 get algorithm name More...
 
std::string getMessage () const
 get message attached to test More...
 
std::string getName () const
 get name of quality test More...
 
int getStatus () const
 (class should be created by DQMStore class) More...
 
void setErrorProb (float prob)
 
void setWarningProb (float prob)
 set probability limit for warning and error (default: 90% and 50%) More...
 

Static Public Member Functions

static std::string getAlgoName ()
 

Protected Member Functions

void setMessage () override
 set status & message after test has run More...
 
- Protected Member Functions inherited from QCriterion
void init ()
 initialize values More...
 
 QCriterion (std::string qtname)
 
float runTest (const MonitorElement *me, QReport &qr, DQMNet::QValue &qv)
 
void setAlgoName (std::string name)
 set algorithm name More...
 
void setVerbose (int verbose)
 probability limits for warnings, errors More...
 
virtual ~QCriterion ()=default
 

Protected Attributes

double chi2_
 
int Ndof_
 
- Protected Attributes inherited from SimpleTest
std::vector< DQMChannelbadChannels_
 
bool keepBadChannels_
 
unsigned minEntries_
 
- Protected Attributes inherited from QCriterion
std::string algoName_
 name of quality test More...
 
float errorProb_
 
std::string message_
 quality test status More...
 
float prob_
 name of algorithm More...
 
std::string qtname_
 
int status_
 
int verbose_
 
float warningProb_
 message attached to test More...
 

Detailed Description

Definition at line 186 of file QTest.h.

Constructor & Destructor Documentation

Comp2RefChi2::Comp2RefChi2 ( const std::string &  name)
inline

Definition at line 189 of file QTest.h.

References QCriterion::setAlgoName().

189  :SimpleTest(name)
190  {
192  }
static std::string getAlgoName()
Definition: QTest.h:193
void setAlgoName(std::string name)
set algorithm name
Definition: QTest.h:80
SimpleTest(const std::string &name, bool keepBadChannels=false)
Definition: QTest.h:140

Member Function Documentation

static std::string Comp2RefChi2::getAlgoName ( )
inlinestatic

Definition at line 193 of file QTest.h.

References QCriterion::runTest().

Referenced by QTestConfigure::EnableComp2RefChi2Test(), QTestConfigure::enableTests(), and QTestParameterNames::QTestParameterNames().

193 { return "Comp2RefChi2"; }
float Comp2RefChi2::runTest ( const MonitorElement me)
overridevirtual

Reimplemented from QCriterion.

Definition at line 174 of file QTest.cc.

References vertices_cff::chi2, pfSecondaryVertexTagInfos_cfi::constraint, gather_cfg::cout, MonitorElement::DQM_KIND_TH1D, MonitorElement::DQM_KIND_TH1F, MonitorElement::DQM_KIND_TH1S, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::getRefRootObject(), MonitorElement::getRefTH1D(), MonitorElement::getRefTH1F(), MonitorElement::getRefTH1S(), MonitorElement::getRefTProfile(), MonitorElement::getRootObject(), MonitorElement::getTH1D(), MonitorElement::getTH1F(), MonitorElement::getTH1S(), MonitorElement::getTProfile(), h, mps_fire::i, MonitorElement::kind(), ndof, combinedConstraintHelpers::sum2(), and groupFilesInBlocks::temp.

175 {
176  if (!me)
177  return -1;
178  if (!me->getRootObject() || !me->getRefRootObject())
179  return -1;
180  TH1* h=nullptr;
181  TH1* ref_=nullptr;
182 
183  if (verbose_>1)
184  std::cout << "QTest:" << getAlgoName() << "::runTest called on "
185  << me-> getFullname() << "\n";
186  //-- TH1F
188  {
189  h = me->getTH1F(); // access Test histo
190  ref_ = me->getRefTH1F(); //access Ref histo
191  }
192  //-- TH1S
193  else if (me->kind()==MonitorElement::DQM_KIND_TH1S)
194  {
195  h = me->getTH1S(); // access Test histo
196  ref_ = me->getRefTH1S(); //access Ref histo
197  }
198  //-- TH1D
199  else if (me->kind()==MonitorElement::DQM_KIND_TH1D)
200  {
201  h = me->getTH1D(); // access Test histo
202  ref_ = me->getRefTH1D(); //access Ref histo
203  }
204  //-- TProfile
205  else if (me->kind()==MonitorElement::DQM_KIND_TPROFILE)
206  {
207  h = me->getTProfile(); // access Test histo
208  ref_ = me->getRefTProfile(); //access Ref histo
209  }
210  else
211  {
212  if (verbose_>0)
213  std::cout << "QTest::Comp2RefChi2"
214  << " ME does not contain TH1F/TH1S/TH1D/TProfile, exiting\n";
215  return -1;
216  }
217 
218  //-- isInvalid ? - Check consistency in number of channels
219  int ncx1 = h->GetXaxis()->GetNbins();
220  int ncx2 = ref_->GetXaxis()->GetNbins();
221  if ( ncx1 != ncx2)
222  {
223  if (verbose_>0)
224  std::cout << "QTest:Comp2RefChi2"
225  << " different number of channels! ("
226  << ncx1 << ", " << ncx2 << "), exiting\n";
227  return -1;
228  }
229 
230  //-- QUALITY TEST itself
231  //reset Results
232  Ndof_ = 0; chi2_ = -1.; ncx1 = ncx2 = -1;
233 
234  int i, i_start, i_end;
235  double chi2 = 0.; int ndof = 0; int constraint = 0;
236 
237  i_start = 1;
238  i_end = ncx1;
239  // if (fXaxis.TestBit(TAxis::kAxisRange)) {
240  i_start = h->GetXaxis()->GetFirst();
241  i_end = h->GetXaxis()->GetLast();
242  // }
243  ndof = i_end-i_start+1-constraint;
244 
245  //Compute the normalisation factor
246  double sum1=0, sum2=0;
247  for (i=i_start; i<=i_end; i++)
248  {
249  sum1 += h->GetBinContent(i);
250  sum2 += ref_->GetBinContent(i);
251  }
252 
253  //check that the histograms are not empty
254  if (sum1 == 0)
255  {
256  if (verbose_>0)
257  std::cout << "QTest:Comp2RefChi2"
258  << " Test Histogram " << h->GetName()
259  << " is empty, exiting\n";
260  return -1;
261  }
262  if (sum2 == 0)
263  {
264  if (verbose_>0)
265  std::cout << "QTest:Comp2RefChi2"
266  << " Ref Histogram " << ref_->GetName()
267  << " is empty, exiting\n";
268  return -1;
269  }
270 
271  double bin1, bin2, err1, err2, temp;
272  for (i=i_start; i<=i_end; i++)
273  {
274  bin1 = h->GetBinContent(i)/sum1;
275  bin2 = ref_->GetBinContent(i)/sum2;
276  if (bin1 ==0 && bin2==0)
277  {
278  --ndof; //no data means one less degree of freedom
279  }
280  else
281  {
282  temp = bin1-bin2;
283  err1=h->GetBinError(i); err2=ref_->GetBinError(i);
284  if (err1 == 0 && err2 == 0)
285  {
286  if (verbose_>0)
287  std::cout << "QTest:Comp2RefChi2"
288  << " bins with non-zero content and zero error, exiting\n";
289  return -1;
290  }
291  err1*=err1 ; err2*=err2;
292  err1/=sum1*sum1 ; err2/=sum2*sum2;
293  chi2 +=temp*temp/(err1+err2);
294  }
295  }
296  chi2_ = chi2; Ndof_ = ndof;
297  return TMath::Prob(0.5*chi2, int(0.5*ndof));
298 }
static std::string getAlgoName()
Definition: QTest.h:193
TProfile * getTProfile() const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
TH1F * getTH1F() const
int verbose_
Definition: QTest.h:120
TObject * getRootObject() const
TObject * getRefRootObject() const
TH1F * getRefTH1F() const
int Ndof_
Definition: QTest.h:209
TH1S * getRefTH1S() const
TH1D * getTH1D() const
TH1D * getRefTH1D() const
TH1S * getTH1S() const
double chi2_
Definition: QTest.h:209
TProfile * getRefTProfile() const
Kind kind() const
Get the type of the monitor element.
void Comp2RefChi2::setMessage ( )
inlineoverrideprotectedvirtual

set status & message after test has run

Reimplemented from SimpleTest.

Definition at line 198 of file QTest.h.

References QCriterion::errorProb_, QCriterion::message_, and QCriterion::warningProb_.

199  {
200  std::ostringstream message;
201  message << "chi2/Ndof = " << chi2_ << "/" << Ndof_
202  << ", minimum needed statistics = " << minEntries_
203  << " warning threshold = " << this->warningProb_
204  << " error threshold = " << this->errorProb_;
205  message_ = message.str();
206  }
int Ndof_
Definition: QTest.h:209
float errorProb_
Definition: QTest.h:118
std::string message_
quality test status
Definition: QTest.h:117
unsigned minEntries_
Definition: QTest.h:161
double chi2_
Definition: QTest.h:209
float warningProb_
message attached to test
Definition: QTest.h:118

Member Data Documentation

double Comp2RefChi2::chi2_
protected

Definition at line 209 of file QTest.h.

int Comp2RefChi2::Ndof_
protected

Definition at line 209 of file QTest.h.