Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
evd::PlotView Class Reference

View showing collections of plots related to this event. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-02/EventDisplay/PlotView.h"

Inheritance diagram for evd::PlotView:
evdb::Canvas evdb::Printable

Public Member Functions

 PlotView (TGMainFrame *mf)
 
 ~PlotView ()
 
const char * Description () const
 
const char * PrintTag () const
 
void Parse (std::vector< PlotPad > &pads)
 
void Draw (const char *opt="")
 
virtual void Print (const char *f)
 
void Connect ()
 Make signal/slot connections. More...
 

Static Public Member Functions

static void AddToListOfPrintables (const char *name, evdb::Printable *p)
 
static void RemoveFromListOfPrintables (evdb::Printable *p)
 
static std::map< std::string, evdb::Printable * > & GetPrintables ()
 

Protected Attributes

TGCompositeFrame * fFrame
 Graphics frame. More...
 
TGLayoutHints * fLayout
 Layout hints for frame. More...
 
TRootEmbeddedCanvas * fEmbCanvas
 Embedded canvas. More...
 
TCanvas * fCanvas
 The ROOT drawing canvas. More...
 
unsigned short fXsize
 Size of the canvas;. More...
 
unsigned short fYsize
 Size of the canvas;. More...
 
float fAspectRatio
 fYsize/fXsize More...
 

Detailed Description

View showing collections of plots related to this event.

Definition at line 30 of file PlotView.h.

Constructor & Destructor Documentation

evd::PlotView::PlotView ( TGMainFrame *  mf)

Definition at line 76 of file PlotView.cxx.

76 : evdb::Canvas(mf) { }
evd::PlotView::~PlotView ( )

Definition at line 80 of file PlotView.cxx.

80 { }

Member Function Documentation

void evdb::Printable::AddToListOfPrintables ( const char *  name,
evdb::Printable p 
)
staticinherited

Definition at line 29 of file Printable.cxx.

References om::cerr, and string.

Referenced by evdb::Canvas::Connect(), evdb::ObjListCanvas::Connect(), evdb::Printable::Description(), and evdb::testCanvas1::testCanvas1().

31  {
33 
34  if (gsPrintables[s] == 0) {
35  gsPrintables[s] = p;
36  }
37  else {
38  if (gsPrintables[s] != p) {
39  std::cerr << "Printable: Name " << name << " reused.\n";
40  std::abort();
41  }
42  }
43  }
const XML_Char * name
Definition: expat.h:151
static std::map< std::string, evdb::Printable * > gsPrintables
Definition: Printable.cxx:14
const char * p
Definition: xmltok.h:285
OStream cerr
Definition: OStream.cxx:7
const XML_Char * s
Definition: expat.h:262
enum BeamMode string
void evdb::Canvas::Connect ( )
inherited

Make signal/slot connections.

Definition at line 68 of file Canvas.cxx.

References evdb::Printable::AddToListOfPrintables(), and evdb::Canvas::Description().

Referenced by evdb::Canvas::Description(), and evdb::DisplayWindow::DisplayWindow().

69  {
70  // Make connections for drawing and printing
71  // IoModule::Instance()->Connect("NewEvent()",
72  // "evdb::Canvas",this,"Draw()");
74  }
virtual const char * Description() const
Definition: Canvas.h:33
static void AddToListOfPrintables(const char *name, evdb::Printable *p)
Definition: Printable.cxx:29
const char* evd::PlotView::Description ( ) const
inlinevirtual

Reimplemented from evdb::Canvas.

Definition at line 37 of file PlotView.h.

37 { return "Event Plots"; }
void evd::PlotView::Draw ( const char *  opt = "")
virtual

Implements evdb::Canvas.

Definition at line 129 of file PlotView.cxx.

References om::cerr, allTimeWatchdog::endl, evt, evdb::Canvas::fCanvas, find_by_name(), evd::Plot::fModule, evd::Plot::fObject, evd::Plot::fOptions, evd::PlotPad::fPlot, art::DataViewImpl::getByLabel(), evdb::EventHolder::GetEvent(), MECModelEnuComparisons::i, evdb::EventHolder::Instance(), calib::j, datagram_client::kv, submit_hadd::l, m, MECModelEnuComparisons::opt, fabricate::options, allInOneTrainingPlots::pad, Parse(), plot(), r(), string, and tokenize().

130  {
131  evdb::Canvas::fCanvas->Clear();
133  if (evt==0) return;
134 
135  evdb::Canvas::fCanvas->cd();
136 
137  // Get the pad descriptions
138  std::vector<PlotPad> pads;
139  this->Parse(pads);
140 
141  // Lay out the main canvas to hold the pads
142  unsigned int nx=1, ny=1;
143  while (nx*ny < pads.size()) {
144  if (nx-ny<2) ++nx;
145  else { --nx; ++ny;}
146  }
147  evdb::Canvas::fCanvas->Divide(nx,ny);
148 
149  //
150  // Loop over the pads and draw the plots
151  //
152  unsigned int i, j, k;
153  for (i=0; i<pads.size(); ++i) {
154  evdb::Canvas::fCanvas->cd(i+1);
155  // nuevdb/EventDisplayBase/RootEnv.cxx sets some huge margins on gStyle. Just
156  // reset our pad to some more sensible margins here.
157  gPad->SetBottomMargin(.1);
158  gPad->SetLeftMargin(.1);
159  gPad->SetTopMargin(.05);
160  gPad->SetRightMargin(.05);
161 
162  const PlotPad& pad = pads[i];
163  for (j=0; j<pad.fPlot.size(); ++j) {
164  const Plot& plot = pad.fPlot[j];
165 
166  // Find the plot object we've been requested to plot...
167  TObject* obj=0;
175 
176  evt->getByLabel(plot.fModule, th1f);
177  evt->getByLabel(plot.fModule, th2f);
178  evt->getByLabel(plot.fModule, th1d);
179  evt->getByLabel(plot.fModule, th2d);
180  evt->getByLabel(plot.fModule, tprofile);
181  evt->getByLabel(plot.fModule, tgraph);
182  evt->getByLabel(plot.fModule, tgrapherrors);
183 
184  obj = find_by_name(plot.fObject,
185  th1f,
186  th2f,
187  th1d,
188  th2d,
189  tprofile,
190  tgraph,
191  tgrapherrors);
192  if (obj==0) {
193  std::cerr << "find_by_name failed to find "
194  << plot.fModule << "/" << plot.fObject
195  << " in event." << std::endl;
196  continue;
197  }
198 
199  TAttLine* l = dynamic_cast<TAttLine*>(obj);
200  TAttMarker* m = dynamic_cast<TAttMarker*>(obj);
201 
202  // Tease out the plotting options
204  if (j>0) options += "same";
205  for (k=0; k<plot.fOptions.size(); ++k) {
206  const std::string& opt = plot.fOptions[k];
207 
208  bool r = false;
209  if (opt=="logx") { gPad->SetLogx(); r=true; }
210  if (opt=="logy") { gPad->SetLogy(); r=true; }
211  if (opt=="logz") { gPad->SetLogz(); r=true; }
212  if (opt=="gridx") { gPad->SetGridx(); r=true; }
213  if (opt=="gridy") { gPad->SetGridy(); r=true; }
214  if (r==false && opt.find("=")!=std::string::npos) {
215  std::vector<std::string> kv;
216  tokenize(opt, kv, "=");
217  if (kv.size()!=2) abort();
218  if (kv[0]=="lstyle") { if (l) l->SetLineStyle(atoi(kv[1].c_str())); r=true; }
219  if (kv[0]=="lwidth") { if (l) l->SetLineWidth(atoi(kv[1].c_str())); r=true; }
220  if (kv[0]=="lcolor") { if (l) l->SetLineColor(atoi(kv[1].c_str())); r=true; }
221  if (kv[0]=="mstyle") { if (m) m->SetMarkerStyle(atoi(kv[1].c_str())); r=true; }
222  if (kv[0]=="msize") { if (m) m->SetMarkerSize(atof(kv[1].c_str())); r=true; }
223  if (kv[0]=="mcolor") { if (m) m->SetMarkerColor(atoi(kv[1].c_str())); r=true; }
224  }
225  if (r==false) { options += ","; options += opt; }
226  } // Loop on options k
227  obj->Draw(options.c_str());
228  } // Loop on plots j
229  } // Loop on pads i
230  evdb::Canvas::fCanvas->Update();
231  }
const art::Event * GetEvent() const
Definition: EventHolder.cxx:45
static void tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters)
Definition: PlotView.cxx:26
OStream cerr
Definition: OStream.cxx:7
static TObject * find_by_name(const std::string &n, art::Handle< std::vector< TH1F > > &th1f, art::Handle< std::vector< TH2F > > &th2f, art::Handle< std::vector< TH1D > > &th1d, art::Handle< std::vector< TH2D > > &th2d, art::Handle< std::vector< TProfile > > &tprofile, art::Handle< std::vector< TGraph > > &tgraph, art::Handle< std::vector< TGraphErrors > > &tgrapherrors)
Definition: PlotView.cxx:42
TCanvas * fCanvas
The ROOT drawing canvas.
Definition: Canvas.h:42
====================================================================== ///
Definition: CutFlow_Data.C:28
static EventHolder * Instance()
Definition: EventHolder.cxx:15
int evt
const double j
Definition: BetheBloch.cxx:29
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
TRandom3 r(0)
void Parse(std::vector< PlotPad > &pads)
Definition: PlotView.cxx:88
void plot(std::string label, std::map< std::string, std::map< std::string, Spectrum * >> &plots, bool log)
enum BeamMode string
std::map< std::string, evdb::Printable * > & evdb::Printable::GetPrintables ( )
staticinherited

Definition at line 61 of file Printable.cxx.

References evdb::gsPrintables.

Referenced by evdb::Printable::Description(), evd::SliceNavigator::postProcessEvent(), evdb::EventDisplay::postProcessEvent(), and evdb::PrintDialog::PrintDialog().

62  {
63  return gsPrintables;
64  }
static std::map< std::string, evdb::Printable * > gsPrintables
Definition: Printable.cxx:14
void evd::PlotView::Parse ( std::vector< PlotPad > &  pads)

Parse out the configuration strings into a collection of modules, plots, and drawing options

Definition at line 88 of file PlotView.cxx.

References update_sam_good_runs_metadata::fields, evd::Plot::fModule, evd::Plot::fObject, evd::Plot::fOptions, evd::PlotDrawingOptions::fPadDescription, evd::PlotPad::fPlot, MECModelEnuComparisons::i, if(), calib::j, allInOneTrainingPlots::pad, plot(), plots, submit_syst::str, string, and tokenize().

Referenced by Draw().

89  {
91 
92  unsigned int i, j;
93 
95  for (i=0; i<plot->fPadDescription.size(); ++i) {
96  PlotPad pad;
97 
98  // Remove white space
99  str = plot->fPadDescription[i];
100  if (str.find(" ")!=std::string::npos) {
101  str.erase(remove_if(str.begin(), str.end(), isspace));
102  }
103 
104  // Split into plots separated by "+"'s
105  std::vector<std::string> plots;
106  tokenize(str, plots, "+");
107  for (j=0; j<plots.size(); ++j) {
108  Plot plot;
109 
110  // module, object and plot options are separted by "/"
111  std::vector<std::string> fields;
112  tokenize(plots[j], fields, "/");
113 
114  // Get the module, object and plot options
115 
116  if (fields.size()>0) plot.fModule = fields[0];
117  if (fields.size()>1) plot.fObject = fields[1];
118  if (fields.size()>2) {
119  tokenize(fields[2], plot.fOptions, ",");
120  }
121  pad.fPlot.push_back(plot);
122  }
123  pads.push_back(pad);
124  }
125  }
static void tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters)
Definition: PlotView.cxx:26
====================================================================== ///
Definition: CutFlow_Data.C:28
if(dump)
const std::vector< Plot > plots
const double j
Definition: BetheBloch.cxx:29
void plot(std::string label, std::map< std::string, std::map< std::string, Spectrum * >> &plots, bool log)
std::vector< std::string > fPadDescription
What&#39;s in a pad?
enum BeamMode string
void evdb::Canvas::Print ( const char *  f)
virtualinherited

Implements evdb::Printable.

Definition at line 88 of file Canvas.cxx.

References evdb::Canvas::fCanvas.

Referenced by evdb::Canvas::Description().

88 { fCanvas->Print(f); }
TCanvas * fCanvas
The ROOT drawing canvas.
Definition: Canvas.h:42
const char* evd::PlotView::PrintTag ( ) const
inlinevirtual

Reimplemented from evdb::Canvas.

Definition at line 38 of file PlotView.h.

References Draw(), and MECModelEnuComparisons::opt.

38 { return "plots"; }
void evdb::Printable::RemoveFromListOfPrintables ( evdb::Printable p)
staticinherited

Definition at line 47 of file Printable.cxx.

Referenced by evdb::Printable::Description(), evdb::Printable::~Printable(), and evdb::testCanvas1::~testCanvas1().

48  {
49  std::map<std::string,Printable*>::iterator itr(gsPrintables.begin());
50  std::map<std::string,Printable*>::iterator itrEnd(gsPrintables.end());
51  for (; itr!=itrEnd; ++itr) {
52  if ( itr->second == p) {
53  gsPrintables.erase(itr);
54  return;
55  }
56  }
57  }
static std::map< std::string, evdb::Printable * > gsPrintables
Definition: Printable.cxx:14

Member Data Documentation

float evdb::Canvas::fAspectRatio
protectedinherited

fYsize/fXsize

Definition at line 46 of file Canvas.h.

Referenced by evdb::Canvas::Canvas().

TCanvas* evdb::Canvas::fCanvas
protectedinherited
TRootEmbeddedCanvas* evdb::Canvas::fEmbCanvas
protectedinherited

Embedded canvas.

Definition at line 41 of file Canvas.h.

Referenced by evdb::Canvas::Canvas(), evd::XZYZProjectionsView::XZYZProjectionsView(), and evdb::Canvas::~Canvas().

TGCompositeFrame* evdb::Canvas::fFrame
protectedinherited

Graphics frame.

Definition at line 39 of file Canvas.h.

Referenced by evdb::Canvas::Canvas(), and evdb::Canvas::~Canvas().

TGLayoutHints* evdb::Canvas::fLayout
protectedinherited

Layout hints for frame.

Definition at line 40 of file Canvas.h.

Referenced by evdb::Canvas::Canvas(), evd::XZYZProjectionsView::XZYZProjectionsView(), and evdb::Canvas::~Canvas().

unsigned short evdb::Canvas::fXsize
protectedinherited

Size of the canvas;.

Definition at line 44 of file Canvas.h.

Referenced by evdb::Canvas::Canvas().

unsigned short evdb::Canvas::fYsize
protectedinherited

Size of the canvas;.

Definition at line 45 of file Canvas.h.

Referenced by evdb::Canvas::Canvas().


The documentation for this class was generated from the following files: