TwoAxisView.cpp
Go to the documentation of this file.
1 //File: TwoAxisView.cpp
2 //Brief: A histogramming interface that draws module number on one axis and channel number on the other.
3 //Author: Andrew Olivier aolivier@ur.rochester.edu
4 
5 //Include header
6 #include "plot/TwoAxisView.h"
7 
8 //ROOT includes
9 #include "TStyle.h"
10 
11 namespace
12 {
13  struct StyleSentry
14  {
15  StyleSentry(): fOldStyle(gStyle)
16  {
17  if(gStyle) gStyle = new TStyle(*gStyle);
18  else gStyle = new TStyle();
19  }
20 
21  ~StyleSentry() { gStyle = fOldStyle; }
22 
23  private:
24  TStyle* fOldStyle; //The old gStyle that will be restored when this object is destroyed
25  };
26 }
27 
28 namespace CRT
29 {
30  TwoAxisView::TwoAxisView(const std::string& name, const std::string& title, const std::string& xTitle, const std::string& yTitle,
31  const std::string& zTitle): ChannelView()
32  {
33  fHist = TH2D(name.c_str(), (title+";"+xTitle+";"+yTitle+";"+zTitle).c_str(), ChannelsPerModule, 0, ChannelsPerModule, NModules, 0, NModules);
34  fHist.SetStats(false);
35  fHist.SetMaximum(4096); //Set range to hard-coded maximum ADC value in CRT hardware
36  }
37 
38  TwoAxisView::TwoAxisView(const std::string& name, const std::string& title, const std::string& xTitle, const std::string& yTitle,
39  const std::string& zTitle, TPad* pad): ChannelView(pad)
40  {
41  fHist = TH2D(name.c_str(), (title+";"+xTitle+";"+yTitle+";"+zTitle).c_str(), ChannelsPerModule, 0, ChannelsPerModule, NModules, 0, NModules);
42  }
43 
44  TwoAxisView::TwoAxisView(const std::string& name, const std::string& title, const std::string& zTitle): TwoAxisView(name, title, "channel",
45  "module", zTitle)
46  {
47  }
48 
49  TwoAxisView::TwoAxisView(TPad* pad, const std::string& name, const std::string& title, const std::string& zTitle):
50  TwoAxisView(name, title, "channel", "module", zTitle, pad)
51  {
52  }
53 
54  void TwoAxisView::doFill(const size_t module, const size_t channel, const double weight)
55  {
56  fHist.Fill(channel, module, weight);
57  }
58 
59  void TwoAxisView::doSetValue(const size_t module, const size_t channel, const double value)
60  {
61  fHist.SetBinContent(fHist.GetBin(channel, module), value);
62  }
63 
64  void TwoAxisView::doDraw(const char* option)
65  {
66  StyleSentry old; //Save the old style during this function so I don't change it
67 
68  gStyle->SetOptStat(0);
69  fHist.UseCurrentStyle();
70  fHist.Draw(option);
71  }
72 
73  void TwoAxisView::doReset(const char* option)
74  {
75  fHist.Reset(option);
76  }
77 }
static QCString name
Definition: declinfo.cpp:673
TwoAxisView(const std::string &name="CRTEvd", const std::string &title="CRT Event Display", const std::string &zTitle="Hits")
Definition: TwoAxisView.cpp:44
std::string string
Definition: nybbler.cc:12
uint8_t channel
Definition: CRTFragment.hh:201
virtual void doFill(const size_t module, const size_t channel, const double weight) override
Definition: TwoAxisView.cpp:54
weight
Definition: test.py:257
virtual void doReset(const char *option) override
Definition: TwoAxisView.cpp:73
virtual void doSetValue(const size_t module, const size_t channel, const double value) override
Definition: TwoAxisView.cpp:59
static constexpr size_t ChannelsPerModule
Definition: ChannelView.h:45
static constexpr size_t NModules
Definition: ChannelView.h:44
virtual void doDraw(const char *option) override
Definition: TwoAxisView.cpp:64