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 917 of file computils.h.

Constructor & Destructor Documentation

◆ Plots()

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

Definition at line 921 of file computils.h.

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

Member Function Documentation

◆ Draw()

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

Definition at line 1155 of file computils.h.

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

◆ 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 1164 of file computils.h.

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

◆ 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 1023 of file computils.h.

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

◆ GetXaxisTitle()

std::string Plots::GetXaxisTitle ( )
inline

Definition at line 1196 of file computils.h.

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

◆ GetYaxisTitle()

std::string Plots::GetYaxisTitle ( )
inline

Definition at line 1201 of file computils.h.

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

◆ hi()

double Plots::hi ( ) const
inline

Definition at line 1123 of file computils.h.

1123 { return m_hi; }

◆ limits()

void Plots::limits ( )
inline

Definition at line 1145 of file computils.h.

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

◆ lo()

double Plots::lo ( ) const
inline

Definition at line 1122 of file computils.h.

1122 { return m_lo; }

◆ Max()

void Plots::Max ( double  scale)
inline

Definition at line 1015 of file computils.h.

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

◆ MaxScale()

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

Definition at line 956 of file computils.h.

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

◆ Min()

void Plots::Min ( double  scale)
inline

Definition at line 1002 of file computils.h.

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

◆ MinScale()

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

Definition at line 975 of file computils.h.

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

◆ 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 1217 of file computils.h.

1217  {
1218  std::vector<Plotter>::push_back( val );
1219  }

◆ realmax()

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

Definition at line 942 of file computils.h.

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

◆ realmin()

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

Definition at line 931 of file computils.h.

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

◆ SetLogx()

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

Definition at line 1193 of file computils.h.

1193 { m_logx=b; }

◆ SetLogy()

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

Definition at line 1194 of file computils.h.

1194 { m_logy=b; }

◆ SetRangeUser()

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

Definition at line 1134 of file computils.h.

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

◆ setwatermark()

static void Plots::setwatermark ( bool  b)
inlinestatic

Definition at line 1223 of file computils.h.

1223 { s_watermark = b; }

◆ SetXaxisTitle()

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

Definition at line 1206 of file computils.h.

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

◆ SetYaxisTitle()

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

Definition at line 1210 of file computils.h.

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

◆ sortx()

void Plots::sortx ( const AxisInfo xinfo)
inline

Definition at line 1088 of file computils.h.

1088  {
1089 
1090  if ( xinfo.rangeset() ) {
1091  m_lo = xinfo.lo();
1092  m_hi = xinfo.hi();
1093  }
1094 
1095  if ( xinfo.autoset() && size() > 0 ) {
1096  std::vector<double> limits = findxrange( xinfo.symmetric() );
1097  if ( xinfo.rangeset() ) {
1098  if ( limits[0]<m_lo ) m_lo = limits[0];
1099  if ( limits[1]>m_hi ) m_hi = limits[1];
1100  }
1101  else {
1102  m_lo = limits[0];
1103  m_hi = limits[1];
1104  }
1105  }
1106  else if (size() == 0)
1107  {
1108  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;
1109  m_lo = 0;
1110  m_hi = 1;
1111  }
1112 
1113  if ( xinfo.rangeset() || xinfo.autoset() ) {
1114  SetRangeUser( m_lo, m_hi );
1115  if ( xinfo.log() && m_lo>0 ) SetLogx(true);
1116  else SetLogx(false);
1117  }
1118 
1119  }

◆ xrange()

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

Definition at line 1126 of file computils.h.

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

Member Data Documentation

◆ elements

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

STL member.

◆ m_hi

double Plots::m_hi
private

Definition at line 1243 of file computils.h.

◆ m_lo

double Plots::m_lo
private

Definition at line 1242 of file computils.h.

◆ m_logx

bool Plots::m_logx
private

canvas log setting

Definition at line 1230 of file computils.h.

◆ m_logy

bool Plots::m_logy
private

Definition at line 1231 of file computils.h.

◆ m_max

double Plots::m_max
private

Definition at line 1235 of file computils.h.

◆ m_maxset

bool Plots::m_maxset
private

yaxis range setting

Definition at line 1234 of file computils.h.

◆ m_min

double Plots::m_min
private

Definition at line 1238 of file computils.h.

◆ m_minset

bool Plots::m_minset
private

Definition at line 1237 of file computils.h.

◆ m_name

std::string Plots::m_name
private

Definition at line 1227 of file computils.h.

◆ m_rangeset

bool Plots::m_rangeset
private

xaxis range setting

Definition at line 1241 of file computils.h.

◆ m_trim_errors

bool Plots::m_trim_errors
private

Definition at line 1245 of file computils.h.

◆ s_watermark

bool Plots::s_watermark = true
staticprivate

Definition at line 1249 of file computils.h.


The documentation for this class was generated from the following files:
empty
bool empty(TH1 *h)
Definition: computils.cxx:296
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Plots::m_rangeset
bool m_rangeset
xaxis range setting
Definition: computils.h:1241
AxisInfo::log
bool log() const
Definition: computils.h:250
ymin
double ymin
Definition: listroot.cxx:63
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:252
Plots::Draw_i
void Draw_i(Legend &leg, bool means=false)
Definition: computils.h:1164
AxisInfo::lo
double lo() const
Definition: computils.h:268
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
Plots::m_max
double m_max
Definition: computils.h:1235
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
Plots::limits
void limits()
Definition: computils.h:1145
DrawLabel
int DrawLabel(float xstart, float ystart, string label)
Definition: GraphToolKit.h:13
AxisInfo::symmetric
bool symmetric() const
Definition: computils.h:258
IDTPMcnv.href
href
Definition: IDTPMcnv.py:30
Plots::lo
double lo() const
Definition: computils.h:1122
Plots::SetRangeUser
void SetRangeUser(double lo, double hi)
Definition: computils.h:1134
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:42
Plots::findxrange
std::vector< double > findxrange(bool symmetric=false)
Definition: computils.h:1023
AxisInfo::rangeset
bool rangeset() const
Definition: computils.h:260
Plots::realmin
double realmin(double lo=0, double hi=0)
Definition: computils.h:931
compute_lumi.leg
leg
Definition: compute_lumi.py:95
findxrangeuser
std::vector< double > findxrangeuser(TH1 *h, bool symmetric=false)
Definition: computils.cxx:525
Plots::realmax
double realmax(double lo=0, double hi=0)
Definition: computils.h:942
Plots::m_maxset
bool m_maxset
yaxis range setting
Definition: computils.h:1234
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
IDTPMcnv.htest
htest
Definition: IDTPMcnv.py:31
python.PyAthena.v
v
Definition: PyAthena.py:154
Plots::m_minset
bool m_minset
Definition: computils.h:1237
AxisInfo::hi
double hi() const
Definition: computils.h:269
Plots::m_logy
bool m_logy
Definition: computils.h:1231
Plots::m_hi
double m_hi
Definition: computils.h:1243
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
Plots::m_min
double m_min
Definition: computils.h:1238
DeMoScan.first
bool first
Definition: DeMoScan.py:534
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
Plots::m_lo
double m_lo
Definition: computils.h:1242
LINES
bool LINES
Definition: computils.cxx:41
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
Plots::xrange
void xrange(bool symmetric=false)
Definition: computils.h:1126
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:1230
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
Plots::s_watermark
static bool s_watermark
Definition: computils.h:1249
Plots::hi
double hi() const
Definition: computils.h:1123
stime
std::string stime()
return the current data and time
Definition: computils.cxx:215
Plots::SetLogx
void SetLogx(bool b=true)
Definition: computils.h:1193
ymax
double ymax
Definition: listroot.cxx:64
Plots::m_name
std::string m_name
Definition: computils.h:1227
Plots::m_trim_errors
bool m_trim_errors
Definition: computils.h:1245