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

Constructor & Destructor Documentation

◆ Plots()

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

Definition at line 917 of file computils.h.

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

Member Function Documentation

◆ Draw()

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

Definition at line 1151 of file computils.h.

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

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

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

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

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

◆ GetXaxisTitle()

std::string Plots::GetXaxisTitle ( )
inline

Definition at line 1192 of file computils.h.

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

◆ GetYaxisTitle()

std::string Plots::GetYaxisTitle ( )
inline

Definition at line 1197 of file computils.h.

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

◆ hi()

double Plots::hi ( ) const
inline

Definition at line 1119 of file computils.h.

1119 { return m_hi; }

◆ limits()

void Plots::limits ( )
inline

Definition at line 1141 of file computils.h.

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

◆ lo()

double Plots::lo ( ) const
inline

Definition at line 1118 of file computils.h.

1118 { return m_lo; }

◆ Max()

void Plots::Max ( double  scale)
inline

Definition at line 1011 of file computils.h.

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

◆ MaxScale()

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

Definition at line 952 of file computils.h.

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

◆ Min()

void Plots::Min ( double  scale)
inline

Definition at line 998 of file computils.h.

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

◆ MinScale()

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

Definition at line 971 of file computils.h.

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

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

1213  {
1214  std::vector<Plotter>::push_back( val );
1215  }

◆ realmax()

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

Definition at line 938 of file computils.h.

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

◆ realmin()

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

Definition at line 927 of file computils.h.

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

◆ SetLogx()

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

Definition at line 1189 of file computils.h.

1189 { m_logx=b; }

◆ SetLogy()

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

Definition at line 1190 of file computils.h.

1190 { m_logy=b; }

◆ SetRangeUser()

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

Definition at line 1130 of file computils.h.

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

◆ setwatermark()

static void Plots::setwatermark ( bool  b)
inlinestatic

Definition at line 1219 of file computils.h.

1219 { s_watermark = b; }

◆ SetXaxisTitle()

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

Definition at line 1202 of file computils.h.

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

◆ SetYaxisTitle()

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

Definition at line 1206 of file computils.h.

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

◆ sortx()

void Plots::sortx ( const AxisInfo xinfo)
inline

Definition at line 1084 of file computils.h.

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

◆ xrange()

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

Definition at line 1122 of file computils.h.

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

Member Data Documentation

◆ elements

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

STL member.

◆ m_hi

double Plots::m_hi
private

Definition at line 1239 of file computils.h.

◆ m_lo

double Plots::m_lo
private

Definition at line 1238 of file computils.h.

◆ m_logx

bool Plots::m_logx
private

canvas log setting

Definition at line 1226 of file computils.h.

◆ m_logy

bool Plots::m_logy
private

Definition at line 1227 of file computils.h.

◆ m_max

double Plots::m_max
private

Definition at line 1231 of file computils.h.

◆ m_maxset

bool Plots::m_maxset
private

yaxis range setting

Definition at line 1230 of file computils.h.

◆ m_min

double Plots::m_min
private

Definition at line 1234 of file computils.h.

◆ m_minset

bool Plots::m_minset
private

Definition at line 1233 of file computils.h.

◆ m_name

std::string Plots::m_name
private

Definition at line 1223 of file computils.h.

◆ m_rangeset

bool Plots::m_rangeset
private

xaxis range setting

Definition at line 1237 of file computils.h.

◆ m_trim_errors

bool Plots::m_trim_errors
private

Definition at line 1241 of file computils.h.

◆ s_watermark

bool Plots::s_watermark = true
staticprivate

Definition at line 1245 of file computils.h.


The documentation for this class was generated from the following files:
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Plots::m_rangeset
bool m_rangeset
xaxis range setting
Definition: computils.h:1237
AxisInfo::log
bool log() const
Definition: computils.h:246
ymin
double ymin
Definition: listroot.cxx:63
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
max
#define max(a, b)
Definition: cfImp.cxx:41
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
AxisInfo::autoset
bool autoset() const
Definition: computils.h:248
Plots::Draw_i
void Draw_i(Legend &leg, bool means=false)
Definition: computils.h:1160
AxisInfo::lo
double lo() const
Definition: computils.h:264
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
Plots::m_max
double m_max
Definition: computils.h:1231
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
Plots::limits
void limits()
Definition: computils.h:1141
DrawLabel
int DrawLabel(float xstart, float ystart, string label)
Definition: GraphToolKit.h:13
AxisInfo::symmetric
bool symmetric() const
Definition: computils.h:254
Plots::lo
double lo() const
Definition: computils.h:1118
Plots::SetRangeUser
void SetRangeUser(double lo, double hi)
Definition: computils.h:1130
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
lumiFormat.i
int i
Definition: lumiFormat.py:85
Plots::findxrange
std::vector< double > findxrange(bool symmetric=false)
Definition: computils.h:1019
AxisInfo::rangeset
bool rangeset() const
Definition: computils.h:256
Plots::realmin
double realmin(double lo=0, double hi=0)
Definition: computils.h:927
compute_lumi.leg
leg
Definition: compute_lumi.py:95
findxrangeuser
std::vector< double > findxrangeuser(TH1 *h, bool symmetric=false)
Definition: computils.cxx:523
Plots::realmax
double realmax(double lo=0, double hi=0)
Definition: computils.h:938
min
#define min(a, b)
Definition: cfImp.cxx:40
Plots::m_maxset
bool m_maxset
yaxis range setting
Definition: computils.h:1230
mergePhysValFiles.errors
list errors
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:43
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
python.PyAthena.v
v
Definition: PyAthena.py:154
Plots::m_minset
bool m_minset
Definition: computils.h:1233
AxisInfo::hi
double hi() const
Definition: computils.h:265
Plots::m_logy
bool m_logy
Definition: computils.h:1227
Plots::m_hi
double m_hi
Definition: computils.h:1239
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
Plots::m_min
double m_min
Definition: computils.h:1234
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:1238
LINES
bool LINES
Definition: computils.cxx:39
Plots::xrange
void xrange(bool symmetric=false)
Definition: computils.h:1122
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:1226
Plots::s_watermark
static bool s_watermark
Definition: computils.h:1245
Plots::hi
double hi() const
Definition: computils.h:1119
stime
std::string stime()
return the current data and time
Definition: computils.cxx:213
Plots::SetLogx
void SetLogx(bool b=true)
Definition: computils.h:1189
ymax
double ymax
Definition: listroot.cxx:64
Plots::m_name
std::string m_name
Definition: computils.h:1223
Plots::m_trim_errors
bool m_trim_errors
Definition: computils.h:1241