ATLAS Offline Software
SinglePlotDefinition.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "SinglePlotDefinition.h"
13 
15 #include <limits> // std::numeric_limits
16 #include <cmath> // std::std::isnan
17 #include <sstream>
18 
19 
24  const std::string& name, const std::string& type, const std::string& title,
25  const std::string& xTitle,
26  unsigned int nBinsX, float xLow, float xHigh,
27  bool doLogLinBinsX, const std::vector<float>& xBinsVec,
28  const std::string& yTitle,
29  unsigned int nBinsY, float yLow, float yHigh,
30  bool doLogLinBinsY, const std::vector<float>& yBinsVec,
31  const std::string& zTitle,
32  unsigned int nBinsZ, float zLow, float zHigh,
33  bool doLogLinBinsZ, const std::vector<float>& zBinsVec,
34  const std::string& folder ) :
35  m_name( name ), m_type( type ), m_title( title ),
36  m_xTitle( xTitle ), m_yTitle( yTitle ), m_zTitle( zTitle ),
37  m_nBinsX( nBinsX ), m_nBinsY( nBinsY ), m_nBinsZ( nBinsZ ),
38  m_doLogLinBinsX( doLogLinBinsX ), m_doLogLinBinsY( doLogLinBinsY ), m_doLogLinBinsZ( doLogLinBinsZ ),
39  m_folder( folder ), m_is1D( false ), m_is2D( false ), m_is3D( false )
40 {
42  if( m_title.empty() ) m_title = m_name;
43 
45  m_xAxis = ( nBinsX != 0 ) ? std::make_pair( xLow, xHigh ) :
46  std::make_pair( std::numeric_limits<float>::quiet_NaN(),
47  std::numeric_limits<float>::quiet_NaN() );
48 
49  m_yAxis = ( nBinsY != 0 ) ? std::make_pair( yLow, yHigh ) :
50  std::make_pair( std::numeric_limits<float>::quiet_NaN(),
51  std::numeric_limits<float>::quiet_NaN() );
52 
53  m_zAxis = ( nBinsZ != 0 ) ? std::make_pair( zLow, zHigh ) :
54  std::make_pair( std::numeric_limits<float>::quiet_NaN(),
55  std::numeric_limits<float>::quiet_NaN() );
56 
59 
61  m_empty = not isValid();
62 
63  // Re-compute digest strings
64  if( not m_empty ) digest();
65 }
66 
67 
73 {
75  if( m_name.empty() or m_type.empty() ) return false;
76 
78  bool sane =
79  ( m_type.find( "TH1" ) != std::string::npos ) or
80  ( m_type.find( "TH2" ) != std::string::npos ) or
81  ( m_type.find( "TH3" ) != std::string::npos ) or
82  ( m_type.find( "TProfile" ) != std::string::npos ) or // 1D and 2D
83  ( m_type.find( "TEfficiency" ) != std::string::npos ); // 1D and 2D
84 
86  const bool sensibleXBins = ( m_nBinsX != 0 ) and ( not std::isnan( m_nBinsX ) );
87  const bool sensibleYBins = ( m_nBinsY != 0 ) and ( not std::isnan( m_nBinsY ) );
88  const bool sensibleZBins = ( m_nBinsZ != 0 ) and ( not std::isnan( m_nBinsZ ) );
89 
93  const bool sensibleXLimits = ( not std::isnan( m_xAxis.first ) ) and
94  ( not std::isnan( m_xAxis.second ) ) and
95  ( m_xAxis.first != m_xAxis.second );
96 
97  const bool sensibleYLimits = ( not std::isnan( m_yAxis.first ) ) and
98  ( not std::isnan( m_yAxis.second ) ) and
99  ( m_yAxis.first != m_yAxis.second );
100 
101  const bool sensibleZLimits = ( not std::isnan( m_zAxis.first ) ) and
102  ( not std::isnan( m_zAxis.second ) ) and
103  ( m_zAxis.first != m_zAxis.second );
104 
106  sane = sane and ( not( m_xTitle.empty() or m_yTitle.empty() ) );
107 
109  sane = sane and sensibleXBins and sensibleXLimits;
110 
112  if( m_is2D ) {
113  sane = sane and sensibleYBins and sensibleYLimits;
114 
116  if( m_is3D ) {
117  sane = sane and sensibleZBins and sensibleZLimits and ( not m_zTitle.empty() );
118  }
119  }
120 
121  return sane;
122 }
123 
124 
131 {
132  if( m_folder.empty() ){
133  m_identifier = m_name;
134  } else {
136  if( m_folder[0] == '/' ) {
137  m_folder.erase( m_folder.begin() );
138  }
140  if( m_folder.back() != '/' ) m_folder += "/";
141  m_identifier = m_folder + m_name;
142  }
143 }
144 
145 
151 {
152  std::stringstream ss;
153  ss << m_name << " - " << m_type << " - " << m_title
154  << " - " << m_xTitle << " : (" << m_nBinsX << ", " << m_xAxis.first << ", " << m_xAxis.second << " )"
155  << " - " << m_yTitle << " : (" << m_nBinsY << ", " << m_yAxis.first << ", " << m_yAxis.second << " )"
156  << " - " << m_zTitle << " : (" << m_nBinsZ << ", " << m_zAxis.first << ", " << m_zAxis.second << " )";
157 
158  m_plotDigest = ss.str();
159 }
160 
161 
168 {
169  std::stringstream ss;
170  ss << m_title << ";" << m_xTitle << ";" << m_yTitle << ";" << m_zTitle;
171 
172  m_titleDigest = ss.str();
173 }
174 
175 
181 {
182  m_is1D = ( m_type.find("TH1") != std::string::npos ) or
183  ( m_type == "TProfile" ) or ( m_type == "TEfficiency" );
184 
185  m_is2D = ( m_type.find("TH2") != std::string::npos ) or
186  ( m_type.find("2D") != std::string::npos );
187 
188  m_is3D = ( m_type.find("TH3") != std::string::npos ) or
189  ( m_type.find("3D") != std::string::npos );
190 }
IDTPM::SinglePlotDefinition::setxBinsVec
void setxBinsVec(const std::vector< float > &vec)
Definition: SinglePlotDefinition.h:106
IDTPM::SinglePlotDefinition::setzBinsVec
void setzBinsVec(const std::vector< float > &vec)
Definition: SinglePlotDefinition.h:112
IDTPM::SinglePlotDefinition::zBinsVec
const std::vector< float > & zBinsVec() const
Definition: SinglePlotDefinition.h:75
SinglePlotDefinition.h
Class to store (internally) each plot definition in this package (originally based on the SingleHisto...
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
IDTPM::SinglePlotDefinition::redoPlotDigest
void redoPlotDigest()
recompute m_plotDigest
Definition: SinglePlotDefinition.cxx:150
IDTPM::SinglePlotDefinition::digest
void digest()
recompute m_identifier, m_plotDigest, m_titleDigest, m_is*D
Definition: SinglePlotDefinition.h:131
IDTPM::SinglePlotDefinition::redoIdDigest
void redoIdDigest()
recompute m_identifier
Definition: SinglePlotDefinition.cxx:130
IDTPM::SinglePlotDefinition::m_name
std::string m_name
main members
Definition: SinglePlotDefinition.h:141
IDTPM::SinglePlotDefinition::isValid
bool isValid() const
Definition: SinglePlotDefinition.cxx:72
IDTPM::SinglePlotDefinition::yLow
float yLow() const
Definition: SinglePlotDefinition.h:66
IDTPM::SinglePlotDefinition::m_empty
bool m_empty
status member
Definition: SinglePlotDefinition.h:151
IDTPM::SinglePlotDefinition::SinglePlotDefinition
SinglePlotDefinition(const std::string &name="", const std::string &type="", const std::string &title="", const std::string &xTitle="", unsigned int nBinsX=0, float xLow=0., float xHigh=0., bool doLogLinBinsX=false, const std::vector< float > &xBinsVec={}, const std::string &yTitle="", unsigned int nBinsY=0, float yLow=0., float yHigh=0., bool doLogLinBinsY=false, const std::vector< float > &yBinsVec={}, const std::string &zTitle="", unsigned int nBinsZ=0, float zLow=0., float zHigh=0., bool doLogLinBinsZ=false, const std::vector< float > &zBinsVec={}, const std::string &folder="")
Parametrised Constructor.
Definition: SinglePlotDefinition.cxx:23
IDTPM::SinglePlotDefinition::m_yAxis
axesLimits_t m_yAxis
Definition: SinglePlotDefinition.h:145
IDTPM::SinglePlotDefinition::nBinsX
unsigned int nBinsX() const
Definition: SinglePlotDefinition.h:61
IDTPM::SinglePlotDefinition::yBinsVec
const std::vector< float > & yBinsVec() const
Definition: SinglePlotDefinition.h:74
IDTPM::SinglePlotDefinition::xHigh
float xHigh() const
Definition: SinglePlotDefinition.h:65
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
IDTPM::SinglePlotDefinition::m_title
std::string m_title
Definition: SinglePlotDefinition.h:143
IDTPM::SinglePlotDefinition::nBinsZ
unsigned int nBinsZ() const
Definition: SinglePlotDefinition.h:63
IDTPM::SinglePlotDefinition::zHigh
float zHigh() const
Definition: SinglePlotDefinition.h:69
covarianceTool.title
title
Definition: covarianceTool.py:542
IDTPM::SinglePlotDefinition::nBinsY
unsigned int nBinsY() const
Definition: SinglePlotDefinition.h:62
IDTPM::SinglePlotDefinition::yHigh
float yHigh() const
Definition: SinglePlotDefinition.h:67
IDTPM::SinglePlotDefinition::xBinsVec
const std::vector< float > & xBinsVec() const
Definition: SinglePlotDefinition.h:73
IDTPM::SinglePlotDefinition::xLow
float xLow() const
Definition: SinglePlotDefinition.h:64
IDTPM::SinglePlotDefinition::m_xAxis
axesLimits_t m_xAxis
Definition: SinglePlotDefinition.h:145
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IDTPM::SinglePlotDefinition::redoTitleDigest
void redoTitleDigest()
recompute m_titleDigest
Definition: SinglePlotDefinition.cxx:167
IDTPM::SinglePlotDefinition::setyBinsVec
void setyBinsVec(const std::vector< float > &vec)
Definition: SinglePlotDefinition.h:109
IDTPM::SinglePlotDefinition::m_zAxis
axesLimits_t m_zAxis
Definition: SinglePlotDefinition.h:145
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IDTPM::SinglePlotDefinition::zLow
float zLow() const
Definition: SinglePlotDefinition.h:68
CaloCondBlobAlgs_fillNoiseFromASCII.folder
folder
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:56
IDTPM::SinglePlotDefinition::redoTypeDigest
void redoTypeDigest()
recompute m_is*D
Definition: SinglePlotDefinition.cxx:180