ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | Static Private Attributes | List of all members
Plots Class Reference

set of generic plots More...

#include <computils.h>

Inheritance diagram for Plots:
Collaboration diagram for Plots:

Public Member Functions

 Plots (const std::string &s="", bool errors=false)
 
double realmin (double lo=0, double hi=0)
 
double realmax (double lo=0, double hi=0)
 
void MaxScale (double scale=1.1, double lo=0, double hi=0)
 
void MinScale (double scale, double lo=0, double hi=0)
 
void Min (double scale)
 
void Max (double scale)
 
std::vector< double > findxrange (bool symmetric=false)
 
void sortx (const AxisInfo &xinfo)
 
double lo () const
 
double hi () const
 
void xrange (bool symmetric=false)
 
void SetRangeUser (double lo, double hi)
 
void limits ()
 
void Draw (Legend &leg, bool means=false)
 
void Draw_i (Legend &leg, bool means=false)
 
void SetLogx (bool b=true)
 
void SetLogy (bool b=true)
 
std::string GetXaxisTitle ()
 
std::string GetYaxisTitle ()
 
void SetXaxisTitle (const std::string &s)
 
void SetYaxisTitle (const std::string &s)
 
void push_back (const Plotter &val)
 this is so that we can update the stats as we go along, but no updating isn't done at the moment
More...
 

Static Public Member Functions

static void setwatermark (bool b)
 

Public Attributes

elements
 STL member. More...
 

Private Attributes

std::string m_name
 
bool m_logx
 canvas log setting More...
 
bool m_logy
 
bool m_maxset
 yaxis range setting More...
 
double m_max
 
bool m_minset
 
double m_min
 
bool m_rangeset
 xaxis range setting More...
 
double m_lo
 
double m_hi
 
bool m_trim_errors
 

Static Private Attributes

static bool s_watermark = true
 

Detailed Description

set of generic plots

Definition at line 915 of file computils.h.

Constructor & Destructor Documentation

◆ Plots()

Plots::Plots ( const std::string &  s = "",
bool  errors = false 
)
inline

Definition at line 919 of file computils.h.

919  :
920  m_name(s),
921  m_logx(false), m_logy(false),
922  m_maxset(false), m_max(0),
923  m_minset(false), m_min(0),
924  m_rangeset(false),
925  m_lo(0.0), m_hi(0.0),
927  { }

Member Function Documentation

◆ Draw()

void Plots::Draw ( Legend leg,
bool  means = false 
)
inline

Definition at line 1153 of file computils.h.

1153  {
1154  Draw_i( leg, means );
1155  if ( LINES ) {
1156  LINES=false;
1157  Draw_i( leg, means );
1158  LINES=true;
1159  }
1160  }

◆ Draw_i()

void Plots::Draw_i ( Legend leg,
bool  means = false 
)
inline

increase the number of log labels if only a few decades

still can't get this working correctly - for the time being leave these alternative loop orders in place but commented out until we can find a better solution ...

Definition at line 1162 of file computils.h.

1162  {
1163 
1164  bool first = true;
1165 
1166  if ( m_logy ) {
1167  for ( unsigned i=0 ; i<size() ; i++, first=false ) {
1168  double ymax = at(i).htest()->GetMaximum();
1169  double ymin = at(i).htest()->GetMinimum();
1170  at(i).htest()->GetYaxis()->SetMoreLogLabels(true);
1171  if ( ymax/ymin>1e6 ) at(i).htest()->GetYaxis()->SetMoreLogLabels(false);
1172  break;
1173  }
1174  }
1175 
1176  for ( unsigned i=0 ; i<size() ; i++ ) at(i).trim_errors( m_trim_errors );
1177 
1180 
1181  // for ( unsigned i=0 ; i<size() ; i++, first=false ) at(i).DrawLegend( i, leg, means, first, (i==size()-1) );
1182  // for ( unsigned i=0 ; i<size() ; i++, first=false ) at(i).Draw( i, &leg, means, first, (i==size()-1) );
1183  for ( unsigned i=size() ; i-- ; first=false ) at(i).Draw( i, &leg, means, first, i==0 );
1184 
1185  if ( s_watermark ) DrawLabel(0.1, 0.02, "built "+stime()+release, kBlack, 0.03 );
1186 
1187  gPad->SetLogy(m_logy);
1188  gPad->SetLogx(m_logx);
1189  }

◆ findxrange()

std::vector<double> Plots::findxrange ( bool  symmetric = false)
inline

don't use empty histograms to find the bin limits unless they are all empty

Definition at line 1021 of file computils.h.

1021  {
1022 
1025 
1026  std::vector<double> v(2,0);
1027 
1028  TH1F* hf = at(0).htest();
1029 
1030  double vlo = 1e21;
1031  double vhi = -1e21;
1032 
1033  if ( hf->GetBinLowEdge(1)<vlo ) vlo = hf->GetBinLowEdge(1);
1034  if ( hf->GetBinLowEdge(hf->GetNbinsX()+1)>vhi ) vhi = hf->GetBinLowEdge( hf->GetNbinsX()+1 );
1035 
1036  if ( size()>0 ) v = ::findxrangeuser( hf, symmetric );
1037 
1038  bool first = false;
1039 
1040  for ( unsigned i=1 ; i<size() ; i++ ) {
1041 
1042  hf = at(i).htest();
1043 
1044  if ( ::empty( hf ) ) continue;
1045 
1046  if ( hf->GetBinLowEdge(1)<vlo ) vlo = hf->GetBinLowEdge(1);
1047  if ( hf->GetBinLowEdge(hf->GetNbinsX()+1)>vhi ) vhi = hf->GetBinLowEdge( hf->GetNbinsX()+1 );
1048 
1049  std::vector<double> limits = ::findxrangeuser( hf, symmetric );
1050 
1051  double lo = limits[0];
1052  double hi = limits[1];
1053 
1054  if ( first ) {
1055  v[0] = lo;
1056  v[1] = hi;
1057  }
1058  else {
1059  if ( v[0]>lo ) v[0] = lo;
1060  if ( v[1]<hi ) v[1] = hi;
1061  }
1062 
1063  first = false;
1064  }
1065 
1066  double upper = ( v[1]-v[0] )*1.1 + v[0];
1067  double lower = v[0] - ( v[1]-v[0] )*0.1;
1068 
1069  if ( m_logx ) {
1070  double dx = std::log10(v[1])-std::log10(v[0]);
1071  upper = std::pow(10,dx*1.1 + std::log10(v[0]));
1072  lower = std::pow(10,std::log10(v[0]) - dx*0.1);
1073  }
1074 
1075  if ( lower<vlo ) lower = vlo;
1076  if ( upper>vhi ) upper = vhi;
1077 
1078  v[0] = lower;
1079  v[1] = upper;
1080 
1081  return v;
1082  }

◆ GetXaxisTitle()

std::string Plots::GetXaxisTitle ( )
inline

Definition at line 1194 of file computils.h.

1194  {
1195  if ( size()>0 ) return at(0).htest()->GetXaxis()->GetTitle();
1196  return "";
1197  }

◆ GetYaxisTitle()

std::string Plots::GetYaxisTitle ( )
inline

Definition at line 1199 of file computils.h.

1199  {
1200  if ( size()>0 ) return at(0).htest()->GetYaxis()->GetTitle();
1201  return "";
1202  }

◆ hi()

double Plots::hi ( ) const
inline

Definition at line 1121 of file computils.h.

1121 { return m_hi; }

◆ limits()

void Plots::limits ( )
inline

Definition at line 1143 of file computils.h.

1143  {
1144  double rmax = realmax();
1145  double rmin = realmin();
1146  if ( rmin<0 ) {
1147  std::cout << "\tlimits \t" << m_name << "\tmin " << rmin << "\tmax " << rmax << std::endl;
1148  }
1149  }

◆ lo()

double Plots::lo ( ) const
inline

Definition at line 1120 of file computils.h.

1120 { return m_lo; }

◆ Max()

void Plots::Max ( double  scale)
inline

Definition at line 1013 of file computils.h.

1013  {
1014  m_maxset = true;
1015  for ( unsigned i=0 ; i<size() ; i++ ) {
1016  if ( at(i).href() ) at(i).href()->SetMaximum(scale);
1017  at(i).htest()->SetMaximum(scale);
1018  }
1019  }

◆ MaxScale()

void Plots::MaxScale ( double  scale = 1.1,
double  lo = 0,
double  hi = 0 
)
inline

Definition at line 954 of file computils.h.

954  {
955 
956  if ( size()<1 ) return;
957 
958  double tmax = realmax(lo,hi);
959  double tmin = realmin(lo,hi);
960 
961  m_max = scale*tmin;
962 
963  if ( m_logy ) m_min = tmin;
964 
965  for ( unsigned i=0 ; i<size() ; i++ ) {
966  if ( at(i).href() ) at(i).href()->SetMaximum(scale*tmax);
967  at(i).htest()->SetMaximum(scale*tmax);
968  }
969 
970  }

◆ Min()

void Plots::Min ( double  scale)
inline

Definition at line 1000 of file computils.h.

1000  {
1001  m_minset = true;
1002  for ( unsigned i=0 ; i<size() ; i++ ) {
1003  if ( at(i).href() ) at(i).href()->SetMinimum(scale);
1004  at(i).htest()->SetMinimum(scale);
1005  if ( m_logy ) {
1006  if ( at(i).href() ) if ( at(i).href()->GetMinimum()<=0 ) at(i).href()->GetMinimum(1e-4);
1007  if ( at(i).htest()->GetMinimum()<=0 ) at(i).htest()->GetMinimum(1e-4);
1008  }
1009  }
1010  }

◆ MinScale()

void Plots::MinScale ( double  scale,
double  lo = 0,
double  hi = 0 
)
inline

Definition at line 973 of file computils.h.

973  {
974 
975  if ( size()<1 ) return;
976 
977  if ( scale==0 ) {
978  for ( unsigned i=0 ; i<size() ; i++ ) {
979  if ( at(i).href() ) at(i).href()->SetMinimum(0);
980  at(i).htest()->SetMinimum(0);
981  }
982  return;
983  }
984 
985 
986  double tmin = 0;
987 
988  if ( lo!=hi ) tmin = realmin( lo, hi );
989  else tmin = realmin();
990 
991  m_min = scale*tmin;
992 
993  for ( unsigned i=0 ; i<size() ; i++ ) {
994  if ( at(i).href() ) at(i).href()->SetMinimum(scale*tmin);
995  at(i).htest()->SetMinimum(scale*tmin);
996  }
997  }

◆ push_back()

void Plots::push_back ( const Plotter val)
inline

this is so that we can update the stats as we go along, but no updating isn't done at the moment

Definition at line 1215 of file computils.h.

1215  {
1216  std::vector<Plotter>::push_back( val );
1217  }

◆ realmax()

double Plots::realmax ( double  lo = 0,
double  hi = 0 
)
inline

Definition at line 940 of file computils.h.

940  {
941  bool first = true;
942  double max = 0;
943  for ( unsigned i=0 ; i<size() ; i++ ) {
944  // double rmref = realmin( at(i).href(), false );
945  double rmtest = ::realmax( at(i).htest(), false, lo, hi );
946  if ( rmtest!=0 && ( first || max<rmtest ) ) max = rmtest;
947  if ( rmtest!=0 ) first = false;
948  }
949  return max;
950  }

◆ realmin()

double Plots::realmin ( double  lo = 0,
double  hi = 0 
)
inline

Definition at line 929 of file computils.h.

929  {
930  bool first = true;
931  double min = 1000;
932  for ( unsigned i=0 ; i<size() ; i++ ) {
933  double rmtest = ::realmin( at(i).htest(), false, lo, hi );
934  if ( rmtest!=0 && ( first || min>rmtest ) ) min = rmtest;
935  if ( rmtest!=0 ) first = false;
936  }
937  return min;
938  }

◆ SetLogx()

void Plots::SetLogx ( bool  b = true)
inline

Definition at line 1191 of file computils.h.

1191 { m_logx=b; }

◆ SetLogy()

void Plots::SetLogy ( bool  b = true)
inline

Definition at line 1192 of file computils.h.

1192 { m_logy=b; }

◆ SetRangeUser()

void Plots::SetRangeUser ( double  lo,
double  hi 
)
inline

Definition at line 1132 of file computils.h.

1132  {
1133  m_rangeset = true;
1134  m_lo = lo;
1135  m_hi = hi;
1136  for ( unsigned i=0 ; i<size() ; i++ ) {
1137  if ( at(i).href() ) at(i).href()->GetXaxis()->SetRangeUser( m_lo, m_hi );
1138  at(i).htest()->GetXaxis()->SetRangeUser( m_lo, m_hi );
1139  }
1140  }

◆ setwatermark()

static void Plots::setwatermark ( bool  b)
inlinestatic

Definition at line 1221 of file computils.h.

1221 { s_watermark = b; }

◆ SetXaxisTitle()

void Plots::SetXaxisTitle ( const std::string &  s)
inline

Definition at line 1204 of file computils.h.

1204  {
1205  if ( size()>0 ) at(0).htest()->GetXaxis()->SetTitle(s.c_str());
1206  }

◆ SetYaxisTitle()

void Plots::SetYaxisTitle ( const std::string &  s)
inline

Definition at line 1208 of file computils.h.

1208  {
1209  if ( size()>0 ) at(0).htest()->GetYaxis()->SetTitle(s.c_str());
1210  }

◆ sortx()

void Plots::sortx ( const AxisInfo xinfo)
inline

Definition at line 1086 of file computils.h.

1086  {
1087 
1088  if ( xinfo.rangeset() ) {
1089  m_lo = xinfo.lo();
1090  m_hi = xinfo.hi();
1091  }
1092 
1093  if ( xinfo.autoset() && size() > 0 ) {
1094  std::vector<double> limits = findxrange( xinfo.symmetric() );
1095  if ( xinfo.rangeset() ) {
1096  if ( limits[0]<m_lo ) m_lo = limits[0];
1097  if ( limits[1]>m_hi ) m_hi = limits[1];
1098  }
1099  else {
1100  m_lo = limits[0];
1101  m_hi = limits[1];
1102  }
1103  }
1104  else if (size() == 0)
1105  {
1106  std::cout<<"Warning in computils.h::sortx() size=0. Setting m_lo/m_hi to 0/1. You will probably have empty figures."<<std::endl;
1107  m_lo = 0;
1108  m_hi = 1;
1109  }
1110 
1111  if ( xinfo.rangeset() || xinfo.autoset() ) {
1112  SetRangeUser( m_lo, m_hi );
1113  if ( xinfo.log() && m_lo>0 ) SetLogx(true);
1114  else SetLogx(false);
1115  }
1116 
1117  }

◆ xrange()

void Plots::xrange ( bool  symmetric = false)
inline

Definition at line 1124 of file computils.h.

1124  {
1125  m_rangeset = false;
1126  for ( unsigned i=0 ; i<size() ; i++ ) {
1127  if ( at(i).href() ) ::xrange( at(i).href(), symmetric );
1128  ::xrange( at(i).htest(), symmetric );
1129  }
1130  }

Member Data Documentation

◆ elements

T std::vector< T >::elements
inherited

STL member.

◆ m_hi

double Plots::m_hi
private

Definition at line 1241 of file computils.h.

◆ m_lo

double Plots::m_lo
private

Definition at line 1240 of file computils.h.

◆ m_logx

bool Plots::m_logx
private

canvas log setting

Definition at line 1228 of file computils.h.

◆ m_logy

bool Plots::m_logy
private

Definition at line 1229 of file computils.h.

◆ m_max

double Plots::m_max
private

Definition at line 1233 of file computils.h.

◆ m_maxset

bool Plots::m_maxset
private

yaxis range setting

Definition at line 1232 of file computils.h.

◆ m_min

double Plots::m_min
private

Definition at line 1236 of file computils.h.

◆ m_minset

bool Plots::m_minset
private

Definition at line 1235 of file computils.h.

◆ m_name

std::string Plots::m_name
private

Definition at line 1225 of file computils.h.

◆ m_rangeset

bool Plots::m_rangeset
private

xaxis range setting

Definition at line 1239 of file computils.h.

◆ m_trim_errors

bool Plots::m_trim_errors
private

Definition at line 1243 of file computils.h.

◆ s_watermark

bool Plots::s_watermark = true
staticprivate

Definition at line 1247 of file computils.h.


The documentation for this class was generated from the following files:
empty
bool empty(TH1 *h)
Definition: computils.cxx:295
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Plots::m_rangeset
bool m_rangeset
xaxis range setting
Definition: computils.h:1239
AxisInfo::log
bool log() const
Definition: computils.h:248
ymin
double ymin
Definition: listroot.cxx:63
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
AxisInfo::autoset
bool autoset() const
Definition: computils.h:250
Plots::Draw_i
void Draw_i(Legend &leg, bool means=false)
Definition: computils.h:1162
AxisInfo::lo
double lo() const
Definition: computils.h:266
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
Plots::m_max
double m_max
Definition: computils.h:1233
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
Plots::limits
void limits()
Definition: computils.h:1143
DrawLabel
int DrawLabel(float xstart, float ystart, string label)
Definition: GraphToolKit.h:13
AxisInfo::symmetric
bool symmetric() const
Definition: computils.h:256
IDTPMcnv.href
href
Definition: IDTPMcnv.py:30
Plots::lo
double lo() const
Definition: computils.h:1120
Plots::SetRangeUser
void SetRangeUser(double lo, double hi)
Definition: computils.h:1132
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
lumiFormat.i
int i
Definition: lumiFormat.py:85
mergePhysValFiles.errors
list errors
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:43
Plots::findxrange
std::vector< double > findxrange(bool symmetric=false)
Definition: computils.h:1021
AxisInfo::rangeset
bool rangeset() const
Definition: computils.h:258
Plots::realmin
double realmin(double lo=0, double hi=0)
Definition: computils.h:929
compute_lumi.leg
leg
Definition: compute_lumi.py:95
findxrangeuser
std::vector< double > findxrangeuser(TH1 *h, bool symmetric=false)
Definition: computils.cxx:524
Plots::realmax
double realmax(double lo=0, double hi=0)
Definition: computils.h:940
Plots::m_maxset
bool m_maxset
yaxis range setting
Definition: computils.h:1232
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
IDTPMcnv.htest
htest
Definition: IDTPMcnv.py:31
python.PyAthena.v
v
Definition: PyAthena.py:154
Plots::m_minset
bool m_minset
Definition: computils.h:1235
AxisInfo::hi
double hi() const
Definition: computils.h:267
Plots::m_logy
bool m_logy
Definition: computils.h:1229
Plots::m_hi
double m_hi
Definition: computils.h:1241
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
Plots::m_min
double m_min
Definition: computils.h:1236
DeMoScan.first
bool first
Definition: DeMoScan.py:536
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
Plots::m_lo
double m_lo
Definition: computils.h:1240
LINES
bool LINES
Definition: computils.cxx:40
Plots::xrange
void xrange(bool symmetric=false)
Definition: computils.h:1124
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
Plots::m_logx
bool m_logx
canvas log setting
Definition: computils.h:1228
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
Plots::s_watermark
static bool s_watermark
Definition: computils.h:1247
Plots::hi
double hi() const
Definition: computils.h:1121
stime
std::string stime()
return the current data and time
Definition: computils.cxx:214
Plots::SetLogx
void SetLogx(bool b=true)
Definition: computils.h:1191
ymax
double ymax
Definition: listroot.cxx:64
Plots::m_name
std::string m_name
Definition: computils.h:1225
Plots::m_trim_errors
bool m_trim_errors
Definition: computils.h:1243