ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LArSamples::ShapeDrawer Class Reference

#include <ShapeDrawer.h>

Collaboration diagram for LArSamples::ShapeDrawer:

Public Member Functions

 ShapeDrawer (int pars)
 Constructor (takes ownership of LArCellInfo object) More...
 
TGraphErrors * graph (const AbsShape &shape, const char *title="") const
 
TGraphErrors * draw (const AbsShape *shape, const char *title="", bool drawAxes=true, const char *gopt="P") const
 
bool draw (const char *title, const std::vector< const AbsShape * > &shapes, const AbsShape *reference=0, const AbsShape *refSamples=0) const
 
bool draw (const char *title, const AbsShape *shape, const AbsShape *reference=0, const AbsShape *refSamples=0) const
 
bool drawAndDelete (const char *title, const std::vector< const AbsShape * > &shapes, const AbsShape *reference=0, const AbsShape *refSamples=0) const
 
bool drawAndDelete (const char *title, const AbsShape *shape, const AbsShape *reference=0, const AbsShape *refSamples=0) const
 
bool colorize (TGraphErrors *data, unsigned int index) const
 
bool yAxisLimits (const std::vector< const AbsShape * > &shapes, double &yMin, double &yMax) const
 

Private Member Functions

bool drawRef (const char *title, const AbsShape *reference, const AbsShape *refSamples, bool first=true, TLegend *legend=0) const
 
bool drawData (const char *title, const std::vector< const AbsShape * > &shapes, const AbsShape *reference, bool first=true, TLegend *legend=0) const
 

Private Attributes

int m_pars
 

Detailed Description

Definition at line 26 of file ShapeDrawer.h.

Constructor & Destructor Documentation

◆ ShapeDrawer()

LArSamples::ShapeDrawer::ShapeDrawer ( int  pars)
inline

Constructor (takes ownership of LArCellInfo object)

Definition at line 31 of file ShapeDrawer.h.

31 : m_pars(pars) { }

Member Function Documentation

◆ colorize()

bool ShapeDrawer::colorize ( TGraphErrors *  data,
unsigned int  index 
) const

Definition at line 202 of file ShapeDrawer.cxx.

203 {
204  if (!data) return false;
205  const int nColors = 5;
206  int colors[nColors] = { 2,4,6,8,14 };
207 
208  data->SetMarkerColor(colors[index%nColors]); // use the 5 colors above
209  data->SetMarkerStyle(20 + ((index/nColors) % 50)); // for more choices change marker style from 20->30. Afterwards, loop back...
210  data->SetMarkerSize(1);
211  return true;
212 }

◆ draw() [1/3]

TGraphErrors * ShapeDrawer::draw ( const AbsShape shape,
const char *  title = "",
bool  drawAxes = true,
const char *  gopt = "P" 
) const

Definition at line 41 of file ShapeDrawer.cxx.

42 {
43  TGraphErrors* g = graph(*shape, title);
44  g->Draw(TString(drawAxes ? "A" : "") + gopt); // X=no errors
45  return g;
46 }

◆ draw() [2/3]

bool ShapeDrawer::draw ( const char *  title,
const AbsShape shape,
const AbsShape reference = 0,
const AbsShape refSamples = 0 
) const

Definition at line 172 of file ShapeDrawer.cxx.

173 {
174  std::vector<const AbsShape*> shapes;
175  shapes.push_back(shape);
176  return draw(title, shapes, reference, refSamples);
177 }

◆ draw() [3/3]

bool ShapeDrawer::draw ( const char *  title,
const std::vector< const AbsShape * > &  shapes,
const AbsShape reference = 0,
const AbsShape refSamples = 0 
) const

Definition at line 49 of file ShapeDrawer.cxx.

51 {
52  if (shapes.empty()) return false;
53 
54  if (m_pars & AtlasStyle) {
55  gStyle->SetTitleXOffset(1.0);
56  gStyle->SetPadTopMargin(0.13);
57  gStyle->SetPadBottomMargin(0.12);
58  gStyle->SetPadRightMargin(0.05);
59  gStyle->SetPadLeftMargin(0.12);
60  }
61 
62  TLegend* legend = nullptr;
63  if (m_pars & AtlasStyle) {
64  legend = new TLegend(0.45, 0.7, 0.8, 0.5, "", "NDC");
65  }
66  else if ((m_pars & Legend) && shapes.size() <= 4){
67  legend = new TLegend(0.6, 0.85, 0.85, 0.85 - 0.1*shapes.size(), "", "NDC");
68  }
69 
70  if (legend) {
71  legend->SetFillColor(0);
72  legend->SetLineColor(0);
73  legend->SetShadowColor(0);
74  legend->SetTextSize(0.06);
75  legend->SetMargin(0.12);
76  }
77 
78  if (m_pars & DataFirst) {
79  if (!drawData(title, shapes, reference, true, legend)) return false;
80  if (reference && !drawRef(title, reference, refSamples, false, legend)) return false;
81  if (m_pars & AtlasStyle) {
82  if (!drawData(title, shapes, reference, false)) return false;
83  TLatex l;
84  l.SetNDC();
85  l.SetTextSize(0.06);
86  l.DrawLatex(0.12,0.89, title);
87  }
88  }
89  else {
90  if (reference && !drawRef(title, reference, refSamples, true)) return false;
91  if (!drawData(title, shapes, reference, false)) return false;
92  }
93  if (legend && shapes.size() > 1) legend->Draw();
94  return true;
95 }

◆ drawAndDelete() [1/2]

bool ShapeDrawer::drawAndDelete ( const char *  title,
const AbsShape shape,
const AbsShape reference = 0,
const AbsShape refSamples = 0 
) const

Definition at line 192 of file ShapeDrawer.cxx.

193 {
194  bool result = draw(title, shape, reference, refSamples);
195  delete shape;
196  delete reference;
197  delete refSamples;
198  return result;
199 }

◆ drawAndDelete() [2/2]

bool ShapeDrawer::drawAndDelete ( const char *  title,
const std::vector< const AbsShape * > &  shapes,
const AbsShape reference = 0,
const AbsShape refSamples = 0 
) const

Definition at line 180 of file ShapeDrawer.cxx.

182 {
183  bool result = draw(title, shapes, reference, refSamples);
184  for (const AbsShape* shape : shapes)
185  delete shape;
186  delete reference;
187  delete refSamples;
188  return result;
189 }

◆ drawData()

bool ShapeDrawer::drawData ( const char *  title,
const std::vector< const AbsShape * > &  shapes,
const AbsShape reference,
bool  first = true,
TLegend *  legend = 0 
) const
private

Definition at line 133 of file ShapeDrawer.cxx.

135 {
136  Chi2Calc c2c;
137  double yMin = 0, yMax = 0;
138  if (!yAxisLimits(shapes, yMin, yMax)) return false;
139  cout << "Y limits = " << yMin << " " << yMax << endl;
140  for (unsigned int i = 0; i < shapes.size(); i++) {
141  if (!shapes[i]) return false;
142  TGraphErrors* data = graph(*shapes[i], title);
143  data->SetMinimum(yMin);
144  data->SetMaximum(yMax);
145  data->SetName(Form("data%d", i));
146  if (m_pars & AtlasStyle) {
147  data->GetXaxis()->SetLimits(-10, 800);
148  data->SetMarkerColor(2);
149  data->SetMarkerStyle(20);
150  data->SetMarkerSize(1.3);
151  }
152  else
153  if (!colorize(data, i)) return false;
154  data->Draw("P" + TString((first && i == 0) ? "A" : ""));
155  if (!legend) continue;
156  if (m_pars & AtlasStyle) {
157  legend->AddEntry(data, "Data", "P");
158  ((TLegendEntry*)legend->GetListOfPrimitives()->Last())->SetTextColor(data->GetMarkerColor());
159  }
160  else {
161  if (!reference || i >= 4) continue; // no chi2 printout...
162  double c2 = c2c.chi2(*shapes[i], *reference);
163  legend->AddEntry(data, Form("#chi^{2}/n = %.2f/%-2d", c2, c2c.nDof()), "P");
164  ((TLegendEntry*)legend->GetListOfPrimitives()->Last())->SetTextColor(data->GetMarkerColor());
165  }
166  }
167 
168  return true;
169 }

◆ drawRef()

bool ShapeDrawer::drawRef ( const char *  title,
const AbsShape reference,
const AbsShape refSamples,
bool  first = true,
TLegend *  legend = 0 
) const
private

Definition at line 98 of file ShapeDrawer.cxx.

99 {
100  if (m_pars & AtlasStyle) {
101  //SimpleShape* overSampledRef = reference->resample(125);
102  //TGraphErrors* ref = graph(*overSampledRef);
103  TGraphErrors* ref = graph(*reference);
104  ref->SetName("reference");
105  ref->SetMarkerStyle(21);
106  ref->SetMarkerSize(0.3);
107  ref->SetMarkerColor(4);
108  ref->SetLineColor(4);
109  ref->SetLineWidth(3);
110  ref->Draw("XC");
111  if (legend) {
112  TGraphErrors* refBigMarkers = new TGraphErrors(*ref);
113  refBigMarkers->SetMarkerSize(1);
114  legend->AddEntry(refBigMarkers, "Prediction", "L");
115  ((TLegendEntry*)legend->GetListOfPrimitives()->Last())->SetTextColor(ref->GetMarkerColor());
116  }
117  return true;
118  }
119 
120  TGraphErrors* ref = draw(reference, title, first, "CPX");
121  ref->SetName("reference");
122 
123  if (refSamples) {
124  TGraphErrors* ref2 = graph(*refSamples);
125  ref->SetName("reference_samples");
126  ref2->SetMarkerSize(1);
127  ref2->Draw("P");
128  }
129  return true;
130 }

◆ graph()

TGraphErrors * ShapeDrawer::graph ( const AbsShape shape,
const char *  title = "" 
) const

Definition at line 27 of file ShapeDrawer.cxx.

28 {
29  bool samplingTimeUnits = (m_pars & SamplingTimeUnits) != 0;
30  TGraphErrors* graph = shape.graph(samplingTimeUnits);
31  graph->SetTitle(title);
32  graph->SetMarkerStyle(20);
33  graph->SetMarkerSize(0.4);
34  graph->GetXaxis()->SetTitle(samplingTimeUnits ? "Sample Index" : "Time [ns]");
35  graph->GetYaxis()->SetTitle("ADC counts");
36  graph->GetYaxis()->SetTitleOffset(1.25);
37  return graph;
38 }

◆ yAxisLimits()

bool ShapeDrawer::yAxisLimits ( const std::vector< const AbsShape * > &  shapes,
double &  yMin,
double &  yMax 
) const

Definition at line 215 of file ShapeDrawer.cxx.

216 {
217  yMin = 0;
218  yMax = 0;
219  for (unsigned int i = 0; i < shapes.size(); i++) {
220  double sMin = shapes[i]->minValue(true);
221  double sMax = shapes[i]->maxValue(true);
222  if (sMin < yMin) yMin = sMin;
223  if (sMax > yMax) yMax = sMax;
224  }
225  yMin *= 1.2;
226  yMax *= 1.2;
227  return true;
228 }

Member Data Documentation

◆ m_pars

int LArSamples::ShapeDrawer::m_pars
private

Definition at line 54 of file ShapeDrawer.h.


The documentation for this class was generated from the following files:
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
get_generator_info.result
result
Definition: get_generator_info.py:21
LArSamples::SamplingTimeUnits
@ SamplingTimeUnits
Definition: ShapeDrawer.h:22
index
Definition: index.py:1
LArSamples::ShapeDrawer::drawRef
bool drawRef(const char *title, const AbsShape *reference, const AbsShape *refSamples, bool first=true, TLegend *legend=0) const
Definition: ShapeDrawer.cxx:98
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
reference
Definition: hcg.cxx:437
LArSamples::ShapeDrawer::colorize
bool colorize(TGraphErrors *data, unsigned int index) const
Definition: ShapeDrawer.cxx:202
LArSamples::ShapeDrawer::graph
TGraphErrors * graph(const AbsShape &shape, const char *title="") const
Definition: ShapeDrawer.cxx:27
LArSamples::Chi2Calc
Definition: Chi2Calc.h:26
LArSamples::AbsShape::graph
TGraphErrors * graph(bool timeInUnitOfSamples=false) const
Definition: AbsShape.cxx:186
perfmonmt-plotter.colors
dictionary colors
Definition: perfmonmt-plotter.py:21
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
covarianceTool.title
title
Definition: covarianceTool.py:542
LArSamples::ShapeDrawer::m_pars
int m_pars
Definition: ShapeDrawer.h:54
LArSamples::ShapeDrawer::yAxisLimits
bool yAxisLimits(const std::vector< const AbsShape * > &shapes, double &yMin, double &yMax) const
Definition: ShapeDrawer.cxx:215
plotBeamSpotVxVal.legend
legend
Definition: plotBeamSpotVxVal.py:98
LArSamples::AtlasStyle
@ AtlasStyle
Definition: ShapeDrawer.h:22
LArSamples::ShapeDrawer::draw
TGraphErrors * draw(const AbsShape *shape, const char *title="", bool drawAxes=true, const char *gopt="P") const
Definition: ShapeDrawer.cxx:41
python.DataFormatRates.c2
c2
Definition: DataFormatRates.py:123
ref
const boost::regex ref(r_ef)
LArSamples::AbsShape
Definition: AbsShape.h:28
DeMoScan.first
bool first
Definition: DeMoScan.py:536
dq_make_web_display.reference
reference
Definition: dq_make_web_display.py:44
LArSamples::Chi2Calc::nDof
unsigned int nDof() const
Definition: Chi2Calc.h:47
LArSamples::ShapeDrawer::drawData
bool drawData(const char *title, const std::vector< const AbsShape * > &shapes, const AbsShape *reference, bool first=true, TLegend *legend=0) const
Definition: ShapeDrawer.cxx:133
LArSamples::DataFirst
@ DataFirst
Definition: ShapeDrawer.h:22
Legend
slightly more convenient legend class
Definition: computils.h:335
LArSamples::Chi2Calc::chi2
double chi2(const AbsShape &data, const AbsShape &reference, const ScaledErrorData *shapeError=0, int lwb=-1, int upb=-1)
Definition: Chi2Calc.cxx:60