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  const std::string& yTitle,
28  unsigned int nBinsY, float yLow, float yHigh,
29  const std::string& zTitle,
30  unsigned int nBinsZ, float zLow, float zHigh,
31  const std::string& folder ) :
32  m_name( name ), m_type( type ), m_title( title ),
33  m_xTitle( xTitle ), m_yTitle( yTitle ), m_zTitle( zTitle ),
34  m_nBinsX( nBinsX ), m_nBinsY( nBinsY ), m_nBinsZ( nBinsZ ),
35  m_folder( folder ), m_is1D( false ), m_is2D( false ), m_is3D( false )
36 {
38  if( m_title.empty() ) m_title = m_name;
39 
41  m_xAxis = ( nBinsX != 0 ) ? std::make_pair( xLow, xHigh ) :
42  std::make_pair( std::numeric_limits<float>::quiet_NaN(),
43  std::numeric_limits<float>::quiet_NaN() );
44 
45  m_yAxis = ( nBinsY != 0 ) ? std::make_pair( yLow, yHigh ) :
46  std::make_pair( std::numeric_limits<float>::quiet_NaN(),
47  std::numeric_limits<float>::quiet_NaN() );
48 
49  m_zAxis = ( nBinsZ != 0 ) ? std::make_pair( zLow, zHigh ) :
50  std::make_pair( std::numeric_limits<float>::quiet_NaN(),
51  std::numeric_limits<float>::quiet_NaN() );
52 
54  m_empty = not isValid();
55 
56  // Re-compute digest strings
57  if( not m_empty ) digest();
58 }
59 
60 
66 {
68  if( m_name.empty() or m_type.empty() ) return false;
69 
71  bool sane =
72  ( m_type.find( "TH1" ) != std::string::npos ) or
73  ( m_type.find( "TH2" ) != std::string::npos ) or
74  ( m_type.find( "TH3" ) != std::string::npos ) or
75  ( m_type.find( "TProfile" ) != std::string::npos ) or // 1D and 2D
76  ( m_type.find( "TEfficiency" ) != std::string::npos ); // 1D and 2D
77 
79  const bool sensibleXBins = ( m_nBinsX != 0 ) and ( not std::isnan( m_nBinsX ) );
80  const bool sensibleYBins = ( m_nBinsY != 0 ) and ( not std::isnan( m_nBinsY ) );
81  const bool sensibleZBins = ( m_nBinsZ != 0 ) and ( not std::isnan( m_nBinsZ ) );
82 
86  const bool sensibleXLimits = ( not std::isnan( m_xAxis.first ) ) and
87  ( not std::isnan( m_xAxis.second ) ) and
88  ( m_xAxis.first != m_xAxis.second );
89 
90  const bool sensibleYLimits = ( not std::isnan( m_yAxis.first ) ) and
91  ( not std::isnan( m_yAxis.second ) ) and
92  ( m_yAxis.first != m_yAxis.second );
93 
94  const bool sensibleZLimits = ( not std::isnan( m_zAxis.first ) ) and
95  ( not std::isnan( m_zAxis.second ) ) and
96  ( m_zAxis.first != m_zAxis.second );
97 
99  sane = sane and ( not( m_xTitle.empty() or m_yTitle.empty() ) );
100 
102  sane = sane and sensibleXBins and sensibleXLimits;
103 
105  if( m_is2D ) {
106  sane = sane and sensibleYBins and sensibleYLimits;
107 
109  if( m_is3D ) {
110  sane = sane and sensibleZBins and sensibleZLimits and ( not m_zTitle.empty() );
111  }
112  }
113 
114  return sane;
115 }
116 
117 
124 {
125  if( m_folder.empty() ){
126  m_identifier = m_name;
127  } else {
129  if( m_folder[0] == '/' ) {
130  m_folder.erase( m_folder.begin() );
131  }
133  if( m_folder.back() != '/' ) m_folder += "/";
134  m_identifier = m_folder + m_name;
135  }
136 }
137 
138 
144 {
145  std::stringstream ss;
146  ss << m_name << " - " << m_type << " - " << m_title
147  << " - " << m_xTitle << " : (" << m_nBinsX << ", " << m_xAxis.first << ", " << m_xAxis.second << " )"
148  << " - " << m_yTitle << " : (" << m_nBinsY << ", " << m_yAxis.first << ", " << m_yAxis.second << " )"
149  << " - " << m_zTitle << " : (" << m_nBinsZ << ", " << m_zAxis.first << ", " << m_zAxis.second << " )";
150 
151  m_plotDigest = ss.str();
152 }
153 
154 
161 {
162  std::stringstream ss;
163  ss << m_title << ";" << m_xTitle << ";" << m_yTitle << ";" << m_zTitle;
164 
165  m_titleDigest = ss.str();
166 }
167 
168 
174 {
175  m_is1D = ( m_type.find("TH1") != std::string::npos ) or
176  ( m_type == "TProfile" ) or ( m_type == "TEfficiency" );
177 
178  m_is2D = ( m_type.find("TH2") != std::string::npos ) or
179  ( m_type.find("2D") != std::string::npos );
180 
181  m_is3D = ( m_type.find("TH3") != std::string::npos ) or
182  ( m_type.find("3D") != std::string::npos );
183 }
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:143
IDTPM::SinglePlotDefinition::digest
void digest()
recompute m_identifier, m_plotDigest, m_titleDigest, m_is*D
Definition: SinglePlotDefinition.h:106
IDTPM::SinglePlotDefinition::redoIdDigest
void redoIdDigest()
recompute m_identifier
Definition: SinglePlotDefinition.cxx:123
IDTPM::SinglePlotDefinition::m_name
std::string m_name
main members
Definition: SinglePlotDefinition.h:116
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., const std::string &yTitle="", unsigned int nBinsY=0, float yLow=0., float yHigh=0., const std::string &zTitle="", unsigned int nBinsZ=0, float zLow=0., float zHigh=0., const std::string &folder="")
Parametrised Constructor.
Definition: SinglePlotDefinition.cxx:23
IDTPM::SinglePlotDefinition::isValid
bool isValid() const
Definition: SinglePlotDefinition.cxx:65
IDTPM::SinglePlotDefinition::yLow
float yLow() const
Definition: SinglePlotDefinition.h:62
IDTPM::SinglePlotDefinition::m_empty
bool m_empty
status member
Definition: SinglePlotDefinition.h:124
IDTPM::SinglePlotDefinition::m_yAxis
axesLimits_t m_yAxis
Definition: SinglePlotDefinition.h:120
IDTPM::SinglePlotDefinition::nBinsX
unsigned int nBinsX() const
Definition: SinglePlotDefinition.h:57
IDTPM::SinglePlotDefinition::xHigh
float xHigh() const
Definition: SinglePlotDefinition.h:61
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
IDTPM::SinglePlotDefinition::m_title
std::string m_title
Definition: SinglePlotDefinition.h:118
IDTPM::SinglePlotDefinition::nBinsZ
unsigned int nBinsZ() const
Definition: SinglePlotDefinition.h:59
IDTPM::SinglePlotDefinition::zHigh
float zHigh() const
Definition: SinglePlotDefinition.h:65
covarianceTool.title
title
Definition: covarianceTool.py:542
IDTPM::SinglePlotDefinition::nBinsY
unsigned int nBinsY() const
Definition: SinglePlotDefinition.h:58
IDTPM::SinglePlotDefinition::yHigh
float yHigh() const
Definition: SinglePlotDefinition.h:63
IDTPM::SinglePlotDefinition::xLow
float xLow() const
Definition: SinglePlotDefinition.h:60
IDTPM::SinglePlotDefinition::m_xAxis
axesLimits_t m_xAxis
Definition: SinglePlotDefinition.h:120
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
IDTPM::SinglePlotDefinition::redoTitleDigest
void redoTitleDigest()
recompute m_titleDigest
Definition: SinglePlotDefinition.cxx:160
IDTPM::SinglePlotDefinition::m_zAxis
axesLimits_t m_zAxis
Definition: SinglePlotDefinition.h:120
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IDTPM::SinglePlotDefinition::zLow
float zLow() const
Definition: SinglePlotDefinition.h:64
CaloCondBlobAlgs_fillNoiseFromASCII.folder
folder
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:56
IDTPM::SinglePlotDefinition::redoTypeDigest
void redoTypeDigest()
recompute m_is*D
Definition: SinglePlotDefinition.cxx:173