ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
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::vector< std::string >& xBinLabelsVec,
29 const std::string& yTitle,
30 unsigned int nBinsY, float yLow, float yHigh,
31 bool doLogLinBinsY, const std::vector<float>& yBinsVec,
32 const std::vector< std::string >& yBinLabelsVec,
33 const std::string& zTitle,
34 unsigned int nBinsZ, float zLow, float zHigh,
35 bool doLogLinBinsZ, const std::vector<float>& zBinsVec,
36 const std::vector< std::string >& zBinLabelsVec,
37 const std::string& folder ) :
42 m_folder( folder ), m_is1D( false ), m_is2D( false ), m_is3D( false )
43{
45 if( m_title.empty() ) m_title = m_name;
46
48 m_xAxis = ( nBinsX != 0 ) ? std::make_pair( xLow, xHigh ) :
49 std::make_pair( std::numeric_limits<float>::quiet_NaN(),
50 std::numeric_limits<float>::quiet_NaN() );
51
52 m_yAxis = ( nBinsY != 0 ) ? std::make_pair( yLow, yHigh ) :
53 std::make_pair( std::numeric_limits<float>::quiet_NaN(),
54 std::numeric_limits<float>::quiet_NaN() );
55
56 m_zAxis = ( nBinsZ != 0 ) ? std::make_pair( zLow, zHigh ) :
57 std::make_pair( std::numeric_limits<float>::quiet_NaN(),
58 std::numeric_limits<float>::quiet_NaN() );
59
64
69
71 m_empty = not isValid();
72
73 // Re-compute digest strings
74 if( not m_empty ) digest();
75}
76
77
83{
85 if( m_name.empty() or m_type.empty() ) return false;
86
88 bool sane =
89 ( m_type.find( "TH1" ) != std::string::npos ) or
90 ( m_type.find( "TH2" ) != std::string::npos ) or
91 ( m_type.find( "TH3" ) != std::string::npos ) or
92 ( m_type.find( "TProfile" ) != std::string::npos ) or // 1D and 2D
93 ( m_type.find( "TEfficiency" ) != std::string::npos ); // 1D and 2D
94
96 const bool sensibleXBins = ( m_nBinsX != 0 ) and ( not std::isnan( m_nBinsX ) );
97 const bool sensibleYBins = ( m_nBinsY != 0 ) and ( not std::isnan( m_nBinsY ) );
98 const bool sensibleZBins = ( m_nBinsZ != 0 ) and ( not std::isnan( m_nBinsZ ) );
99
103 const bool sensibleXLimits = ( not std::isnan( m_xAxis.first ) ) and
104 ( not std::isnan( m_xAxis.second ) ) and
105 ( m_xAxis.first != m_xAxis.second );
106
107 const bool sensibleYLimits = ( not std::isnan( m_yAxis.first ) ) and
108 ( not std::isnan( m_yAxis.second ) ) and
109 ( m_yAxis.first != m_yAxis.second );
110
111 const bool sensibleZLimits = ( not std::isnan( m_zAxis.first ) ) and
112 ( not std::isnan( m_zAxis.second ) ) and
113 ( m_zAxis.first != m_zAxis.second );
114
116 sane = sane and sensibleXBins and sensibleXLimits;
117
119 if( m_is2D ) {
120 sane = sane and sensibleYBins and sensibleYLimits;
121
123 if( m_is3D ) {
124 sane = sane and sensibleZBins and sensibleZLimits;
125 }
126 }
127
128 return sane;
129}
130
131
138{
139 if( m_folder.empty() ){
141 } else {
143 if( m_folder[0] == '/' ) {
144 m_folder.erase( m_folder.begin() );
145 }
147 if( m_folder.back() != '/' ) m_folder += "/";
149 }
150}
151
152
158{
159 std::stringstream ss;
160 ss << m_name << " - " << m_type << " - " << m_title
161 << " - " << m_xTitle << " : (" << m_nBinsX << ", " << m_xAxis.first << ", " << m_xAxis.second << " )"
162 << " - " << m_yTitle << " : (" << m_nBinsY << ", " << m_yAxis.first << ", " << m_yAxis.second << " )"
163 << " - " << m_zTitle << " : (" << m_nBinsZ << ", " << m_zAxis.first << ", " << m_zAxis.second << " )";
164
165 m_plotDigest = ss.str();
166}
167
168
175{
176 std::stringstream ss;
177 ss << m_title << ";" << m_xTitle << ";" << m_yTitle << ";" << m_zTitle;
178
179 m_titleDigest = ss.str();
180}
181
182
188{
189 m_is1D = ( m_type.find("TH1") != std::string::npos ) or
190 ( m_type == "TProfile" ) or ( m_type == "TEfficiency" );
191
192 m_is2D = ( m_type.find("TH2") != std::string::npos ) or
193 ( m_type.find("2D") != std::string::npos );
194
195 m_is3D = ( m_type.find("TH3") != std::string::npos ) or
196 ( m_type.find("3D") != std::string::npos );
197}
static Double_t ss
Class to store (internally) each plot definition in this package (originally based on the SingleHisto...
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::vector< std::string > &xBinLabelsVec={}, const std::string &yTitle="", unsigned int nBinsY=0, float yLow=0., float yHigh=0., bool doLogLinBinsY=false, const std::vector< float > &yBinsVec={}, const std::vector< std::string > &yBinLabelsVec={}, const std::string &zTitle="", unsigned int nBinsZ=0, float zLow=0., float zHigh=0., bool doLogLinBinsZ=false, const std::vector< float > &zBinsVec={}, const std::vector< std::string > &zBinLabelsVec={}, const std::string &folder="")
Parametrised Constructor.
void setzBinLabelsVec(const std::vector< std::string > &vec)
void redoPlotDigest()
recompute m_plotDigest
const std::vector< float > & xBinsVec() const
const std::string & zTitle() const
const std::vector< std::string > & yBinLabelsVec() const
void setxBinLabelsVec(const std::vector< std::string > &vec)
const std::string & xTitle() const
void setxBinsVec(const std::vector< float > &vec)
void redoIdDigest()
recompute m_identifier
const std::string & folder() const
void redoTypeDigest()
recompute m_is*D
void setzBinsVec(const std::vector< float > &vec)
const std::vector< float > & yBinsVec() const
const std::vector< float > & zBinsVec() const
void setyBinsVec(const std::vector< float > &vec)
void setyBinLabelsVec(const std::vector< std::string > &vec)
const std::string & yTitle() const
void digest()
recompute m_identifier, m_plotDigest, m_titleDigest, m_is*D
const std::string & name() const
void redoTitleDigest()
recompute m_titleDigest
const std::vector< std::string > & zBinLabelsVec() const
std::string m_name
main members
const std::vector< std::string > & xBinLabelsVec() const
const std::string & title() const
const std::string & type() const
std::string m_identifier
derived members, i.e. dependant on main members