ATLAS Offline Software
Classes | Functions
HistValFunctions Namespace Reference

Classes

class  TH1_FieldsAccess
 
class  TH2_FieldsAccess
 
class  TProfile2D_FieldsAccess
 
class  TProfile_FieldsAccess
 

Functions

void testfailed (const std::string &testname)
 
void testTypes ()
 
void test (const std::string &testname, double val1, double val2)
 
void test (const std::string &testname, const char *val1, const char *val2)
 
void compareFields NO_SANITIZE_UNDEFINED (TH1 *t1, TH1 *t2)
 
template<class T >
std::string toString (const T &t)
 
template<class T1 , class T2 >
std::string toString (const std::pair< T1, T2 > &p)
 
template<class T >
std::string toString (const std::vector< T > &v)
 
bool floatCompat (const double &val1, const double &val2, const double &eps)
 
bool compatible (const double &val1, const double &val2)
 
template<class T1 , class T2 >
bool compatible (const std::pair< T1, T2 > &val1, const std::pair< T1, T2 > &val2)
 
template<class T >
bool compatible (const std::vector< T > &val1, const std::vector< T > &val2)
 
template<class T1 , class T2 >
void testfailed (const std::string &testname, T1 val1, T2 val2)
 
template<class T1 , class T2 >
void test (const std::string &testname, T1 val1, T2 val2)
 
void compareFields (TH1 *t1, TH1 *t2)
 

Function Documentation

◆ compareFields()

void HistValFunctions::compareFields ( TH1 t1,
TH1 t2 
)

◆ compatible() [1/3]

bool HistValFunctions::compatible ( const double &  val1,
const double &  val2 
)
inline

Definition at line 51 of file validatefunctions.h.

52  {
53  return floatCompat(val1,val2,1.0e-5);
54  }

◆ compatible() [2/3]

template<class T1 , class T2 >
bool HistValFunctions::compatible ( const std::pair< T1, T2 > &  val1,
const std::pair< T1, T2 > &  val2 
)
inline

Definition at line 57 of file validatefunctions.h.

58  {
59  return compatible(val1.first,val2.first) && compatible(val1.second,val2.second);
60  }

◆ compatible() [3/3]

template<class T >
bool HistValFunctions::compatible ( const std::vector< T > &  val1,
const std::vector< T > &  val2 
)
inline

Definition at line 63 of file validatefunctions.h.

64  {
65  const unsigned n(val2.size());
66  if (val1.size()!=n)
67  return false;
68  for (unsigned i=0;i<n;++i)
69  if (!compatible(val1[i],val2[i]))
70  return false;
71  return true;
72  }

◆ floatCompat()

bool HistValFunctions::floatCompat ( const double &  val1,
const double &  val2,
const double &  eps 
)
inline

Definition at line 46 of file validatefunctions.h.

47  {
48  return (fabs(val1-val2)/(1.0+std::max(fabs(val1),fabs(val2)))<eps) || ((val1!=val1)&&(val2!=val2));
49  }

◆ NO_SANITIZE_UNDEFINED()

void compareFields HistValFunctions::NO_SANITIZE_UNDEFINED ( TH1 t1,
TH1 t2 
)

Definition at line 45 of file validatefunctions.cxx.

46  {
47  test("[TH1-level] GetXaxis()->GetLabelSize()",t1->GetXaxis()->GetLabelSize(),t2->GetXaxis()->GetLabelSize());
48  test("[TH1-level] GetXaxis()->GetTitle()",t1->GetXaxis()->GetTitle(),t2->GetXaxis()->GetTitle());
49  test("[TH1-level] GetYaxis()->GetLabelSize()",t1->GetYaxis()->GetLabelSize(),t2->GetYaxis()->GetLabelSize());
50  test("[TH1-level] GetYaxis()->GetTitle()",t1->GetYaxis()->GetTitle(),t2->GetYaxis()->GetTitle());
51  test("[TH1-level] GetMarkerColor()",t1->GetMarkerColor(),t2->GetMarkerColor());
52  test("[TH1-level] GetMarkerStyle()",t1->GetMarkerStyle(),t2->GetMarkerStyle());
53  test("[TH1-level] GetMarkerSize()",t1->GetMarkerSize(),t2->GetMarkerSize());
54  test("[TH1-level] GetMinimum()",t1->GetMinimum(),t2->GetMinimum());
55 
56  TH1_FieldsAccess * t1_fa(static_cast<TH1_FieldsAccess*>(t1));
57  TH1_FieldsAccess * t2_fa(static_cast<TH1_FieldsAccess*>(t2));
58  test("[TH1-level] fNcells",t1_fa->access_fNcells(), t2_fa->access_fNcells());
59  test("[TH1-level] fDimension",t1_fa->access_fDimension(), t2_fa->access_fDimension());
60  test("[TH1-level] fNormFactor",t1_fa->access_fNormFactor(), t2_fa->access_fNormFactor());
61  test("[TH1-level] fMaximum",t1_fa->access_fMaximum(), t2_fa->access_fMaximum());
62  test("[TH1-level] fMinimum",t1_fa->access_fMinimum(), t2_fa->access_fMinimum());
63  test("[TH1-level] fEntries",t1_fa->access_fEntries(), t2_fa->access_fEntries());
64  test("[TH1-level] fTsumw",t1_fa->access_fTsumw(), t2_fa->access_fTsumw());
65  test("[TH1-level] fTsumw2",t1_fa->access_fTsumw2(), t2_fa->access_fTsumw2());
66  test("[TH1-level] fTsumwx",t1_fa->access_fTsumwx(), t2_fa->access_fTsumwx());
67  test("[TH1-level] fTsumwx2",t1_fa->access_fTsumwx2(), t2_fa->access_fTsumwx2());
68  if (dynamic_cast<TH2*>(t1)) {
69  TH2_FieldsAccess * t1_fa2(static_cast<TH2_FieldsAccess*>(t1));
70  TH2_FieldsAccess * t2_fa2(static_cast<TH2_FieldsAccess*>(t2));
71  test("[TH1-level] fTsumwy",t1_fa2->access_fTsumwy(), t2_fa2->access_fTsumwy());
72  test("[TH1-level] fTsumwy2",t1_fa2->access_fTsumwy2(), t2_fa2->access_fTsumwy2());
73  test("[TH1-level] fTsumwxy",t1_fa2->access_fTsumwxy(), t2_fa2->access_fTsumwxy());
74  test("[TH1-level] fScalefactor",t1_fa2->access_fScalefactor(), t2_fa2->access_fScalefactor());
75  }
76  }

◆ test() [1/3]

void HistValFunctions::test ( const std::string &  testname,
const char *  val1,
const char *  val2 
)

Definition at line 34 of file validatefunctions.cxx.

35  {
36  if ((val1 == nullptr) or (val2==nullptr)){
37  testfailed(testname);
38  }
39  if (std::string(val1)!=std::string(val2))
40  testfailed(testname,val1,val2);
41  }

◆ test() [2/3]

void HistValFunctions::test ( const std::string &  testname,
double  val1,
double  val2 
)

Definition at line 27 of file validatefunctions.cxx.

28  {
29  if (!compatible(val1,val2))
30  testfailed(testname,val1,val2);
31  }

◆ test() [3/3]

template<class T1 , class T2 >
void HistValFunctions::test ( const std::string &  testname,
T1  val1,
T2  val2 
)
inline

Definition at line 85 of file validatefunctions.h.

86  {
87  if (val1!=val2)
88  testfailed(testname,val1,val2);
89  }

◆ testfailed() [1/2]

void HistValFunctions::testfailed ( const std::string &  testname)

Definition at line 10 of file validatefunctions.cxx.

11  {
12  std::cout<<"ERROR: HistValidator test failed: "<<testname<<std::endl;
13  std::abort();//gives a stack-trace
14  }

◆ testfailed() [2/2]

template<class T1 , class T2 >
void HistValFunctions::testfailed ( const std::string &  testname,
T1  val1,
T2  val2 
)
inline

Definition at line 78 of file validatefunctions.h.

79  {
80  std::cout<<"Value in h1 ("<<typeid(T1).name()<<"): ->"<<std::setprecision(14)<<val1<<std::setprecision(6)<<"<-"<<std::endl;
81  std::cout<<"Value in h2 ("<<typeid(T2).name()<<"): ->"<<std::setprecision(14)<<val2<<std::setprecision(6)<<"<-"<<std::endl;
82  testfailed(testname);
83  }

◆ testTypes()

void HistValFunctions::testTypes ( )

Definition at line 16 of file validatefunctions.cxx.

16  {
17  test("sizeof(unsigned char)=1", unsigned(1), sizeof(unsigned char));
18  test("sizeof(unsigned short)=2", unsigned(2), sizeof(unsigned short));
19  test("sizeof(float)=4", unsigned(4), sizeof(float));
20  test("sizeof(double)=8", unsigned(8), sizeof(double));
21  test("sizeof(double)=sizeof(Double_t)", sizeof(double), sizeof(Double_t));
22  test("sizeof(float)=sizeof(Float_t)", sizeof(float), sizeof(Float_t));
23  test("sizeof(int)=sizeof(Int_t)", sizeof(int), sizeof(Int_t));
24  }

◆ toString() [1/3]

template<class T1 , class T2 >
std::string HistValFunctions::toString ( const std::pair< T1, T2 > &  p)
inline

Definition at line 31 of file validatefunctions.h.

31  {
32  std::ostringstream s;
33  s<<"("<<toString(p.first)<<", "<<toString(p.second)<<")";
34  return s.str();
35  }

◆ toString() [2/3]

template<class T >
std::string HistValFunctions::toString ( const std::vector< T > &  v)
inline

Definition at line 37 of file validatefunctions.h.

37  {
38  std::ostringstream s;
39  s<<"[ ";
40  for (unsigned i=0;i<v.size();++i)
41  s<<(i==0?"":", ")<<toString(v.at(i));
42  s<<" ]";
43  return s.str();
44  }

◆ toString() [3/3]

template<class T >
std::string HistValFunctions::toString ( const T &  t)
inline

Definition at line 29 of file validatefunctions.h.

29 { std::ostringstream s;s<<t;return s.str(); }
HistValFunctions::floatCompat
bool floatCompat(const double &val1, const double &val2, const double &eps)
Definition: validatefunctions.h:46
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
max
#define max(a, b)
Definition: cfImp.cxx:41
HistValFunctions::test
void test(const std::string &testname, const char *val1, const char *val2)
Definition: validatefunctions.cxx:34
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
HistValFunctions::compatible
bool compatible(const double &val1, const double &val2)
Definition: validatefunctions.h:51
HistValFunctions::testfailed
void testfailed(const std::string &testname, T1 val1, T2 val2)
Definition: validatefunctions.h:78
HistValFunctions::compatible
bool compatible(const std::vector< T > &val1, const std::vector< T > &val2)
Definition: validatefunctions.h:63
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
TH2
Definition: rootspy.cxx:373
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.PyAthena.v
v
Definition: PyAthena.py:157
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
HistValFunctions::testfailed
void testfailed(const std::string &testname)
Definition: validatefunctions.cxx:10
HistValFunctions::toString
std::string toString(const std::vector< T > &v)
Definition: validatefunctions.h:37