Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
CRT::SpaceView Class Reference

#include <SpaceView.h>

Inheritance diagram for CRT::SpaceView:
CRT::ChannelView

Public Member Functions

 SpaceView (const std::string &name="CRTEvd", const std::string &title="CRT Event Display", const std::string &zTitle="Hits")
 
 SpaceView (TPad *pad, const std::string &name="CRTEvd", const std::string &title="CRT Event Display", const std::string &zTitle="Hits")
 
 SpaceView (const double zMax, const std::string &name="CRTEvd", const std::string &title="CRT Event Display", const std::string &zTitle="Hits")
 
 SpaceView (TPad *pad, const double zMax, const std::string &name="CRTEvd", const std::string &title="CRT Event Display", const std::string &zTitle="Hits")
 
- Public Member Functions inherited from CRT::ChannelView
 ChannelView ()
 
 ChannelView (TPad *pad)
 
virtual ~ChannelView ()
 
void Fill (const size_t module, const size_t channel, const double weight=1.0)
 
void SetValue (const size_t module, const size_t channel, const double value)
 
void Draw (const char *option)
 
void Reset (const char *option)
 

Protected Member Functions

virtual void doFill (const size_t module, const size_t channel, const double weight) override
 
virtual void doSetValue (const size_t module, const size_t channel, const double value) override
 
virtual void doDraw (const char *option) override
 
virtual void doReset (const char *option) override
 
- Protected Member Functions inherited from CRT::ChannelView
TPad * GetMainPad ()
 

Private Member Functions

template<class FUNC >
void doSomething (TH2 &hist, const size_t channel, const size_t module, FUNC &&func)
 
void ConfigHistogram (TH2 &hist)
 
void SetupPads ()
 

Private Attributes

TH2D fUpstream
 
TH2D fDownstream
 

Additional Inherited Members

- Static Protected Attributes inherited from CRT::ChannelView
static constexpr size_t NModules = 32
 
static constexpr size_t ChannelsPerModule = 64
 

Detailed Description

Definition at line 14 of file SpaceView.h.

Constructor & Destructor Documentation

CRT::SpaceView::SpaceView ( const std::string name = "CRTEvd",
const std::string title = "CRT Event Display",
const std::string zTitle = "Hits" 
)

Definition at line 40 of file SpaceView.cpp.

40  : ChannelView()
41  {
42  const auto binLimit = 4*ChannelsPerModule*2; //Frames are 4 modules high. 2 strips per module to simulate offsets of "bottom" strip layer
43  fUpstream = TH2D(("upstream"+name).c_str(), ("Upstream;cartoon x;cartoon y;"+zTitle).c_str(), binLimit, 0, binLimit, binLimit, 0, binLimit);
45 
46  fDownstream = TH2D(("downstream"+name).c_str(), ("Downstream;cartoon x;cartoon y;"+zTitle).c_str(), binLimit, 0, binLimit, binLimit, 0, binLimit);
48 
49  SetupPads();
50  }
static QCString name
Definition: declinfo.cpp:673
TH2D fDownstream
Definition: SpaceView.h:34
void ConfigHistogram(TH2 &hist)
Definition: SpaceView.cpp:19
void SetupPads()
Definition: SpaceView.cpp:26
static constexpr size_t ChannelsPerModule
Definition: ChannelView.h:45
TH2D fUpstream
Definition: SpaceView.h:33
CRT::SpaceView::SpaceView ( TPad *  pad,
const std::string name = "CRTEvd",
const std::string title = "CRT Event Display",
const std::string zTitle = "Hits" 
)

Definition at line 52 of file SpaceView.cpp.

52  : ChannelView(pad)
53  {
54  const auto binLimit = 4*ChannelsPerModule*2;
55  std::cout << "binLimit is " << binLimit << " = 4*" << ChannelsPerModule << "*2\n";
56  fUpstream = TH2D(("upstream"+name).c_str(), ("Upstream;cartoon x;cartoon y;"+zTitle).c_str(), binLimit, 0, binLimit, binLimit, 0, binLimit);
57  fDownstream = TH2D(("downstream"+name).c_str(), ("Downstream;cartoon x;cartoon y;"+zTitle).c_str(), binLimit, 0, binLimit, binLimit, 0, binLimit);
58 
61 
62  SetupPads();
63  }
static QCString name
Definition: declinfo.cpp:673
TH2D fDownstream
Definition: SpaceView.h:34
void ConfigHistogram(TH2 &hist)
Definition: SpaceView.cpp:19
void SetupPads()
Definition: SpaceView.cpp:26
static constexpr size_t ChannelsPerModule
Definition: ChannelView.h:45
TH2D fUpstream
Definition: SpaceView.h:33
CRT::SpaceView::SpaceView ( const double  zMax,
const std::string name = "CRTEvd",
const std::string title = "CRT Event Display",
const std::string zTitle = "Hits" 
)

Definition at line 65 of file SpaceView.cpp.

65  : SpaceView(name, title, zTitle)
66  {
67  fUpstream.SetMaximum(zMax);
68  fDownstream.SetMaximum(zMax);
69  }
static QCString name
Definition: declinfo.cpp:673
TH2D fDownstream
Definition: SpaceView.h:34
TH2D fUpstream
Definition: SpaceView.h:33
SpaceView(const std::string &name="CRTEvd", const std::string &title="CRT Event Display", const std::string &zTitle="Hits")
Definition: SpaceView.cpp:40
CRT::SpaceView::SpaceView ( TPad *  pad,
const double  zMax,
const std::string name = "CRTEvd",
const std::string title = "CRT Event Display",
const std::string zTitle = "Hits" 
)

Definition at line 71 of file SpaceView.cpp.

71  : SpaceView(pad, name, title, zTitle)
72  {
73  fUpstream.SetMaximum(zMax);
74  fDownstream.SetMaximum(zMax);
75  }
static QCString name
Definition: declinfo.cpp:673
TH2D fDownstream
Definition: SpaceView.h:34
TH2D fUpstream
Definition: SpaceView.h:33
SpaceView(const std::string &name="CRTEvd", const std::string &title="CRT Event Display", const std::string &zTitle="Hits")
Definition: SpaceView.cpp:40

Member Function Documentation

void CRT::SpaceView::ConfigHistogram ( TH2 &  hist)
private

Definition at line 19 of file SpaceView.cpp.

20  {
21  hist.SetStats(false);
22  //auto zAxis = hist.GetZaxis();
23  //TODO: x and y labels based on approximate module positions?
24  }
void CRT::SpaceView::doDraw ( const char *  option)
overrideprotectedvirtual

Implements CRT::ChannelView.

Definition at line 156 of file SpaceView.cpp.

157  {
158  util::StyleSentry old; //Save the old style during this function so I don't change it
159 
160  gStyle->SetOptStat(0);
161  fUpstream.UseCurrentStyle();
162  fDownstream.UseCurrentStyle();
163 
164  auto main = GetMainPad();
165  main->cd(1);
166  fUpstream.Draw(option);
167 
168  main->cd(2);
169  fDownstream.Draw(option);
170  }
TH2D fDownstream
Definition: SpaceView.h:34
TPad * GetMainPad()
Definition: ChannelView.h:47
TH2D fUpstream
Definition: SpaceView.h:33
void CRT::SpaceView::doFill ( const size_t  module,
const size_t  channel,
const double  weight 
)
overrideprotectedvirtual

Implements CRT::ChannelView.

Definition at line 77 of file SpaceView.cpp.

78  {
79  doSomething((module < NModules/2l)?fUpstream:fDownstream, module, channel,
80  [&weight](auto& hist, const auto x, const auto y) { hist.Fill(x, y, weight); });
81  }
TH2D fDownstream
Definition: SpaceView.h:34
uint8_t channel
Definition: CRTFragment.hh:201
static QStrList * l
Definition: config.cpp:1044
weight
Definition: test.py:257
static constexpr size_t NModules
Definition: ChannelView.h:44
void doSomething(TH2 &hist, const size_t channel, const size_t module, FUNC &&func)
Definition: SpaceView.cpp:84
TH2D fUpstream
Definition: SpaceView.h:33
list x
Definition: train.py:276
void CRT::SpaceView::doReset ( const char *  option)
overrideprotectedvirtual

Implements CRT::ChannelView.

Definition at line 172 of file SpaceView.cpp.

173  {
174  fUpstream.Reset(option);
175  fDownstream.Reset(option);
176  }
TH2D fDownstream
Definition: SpaceView.h:34
TH2D fUpstream
Definition: SpaceView.h:33
void CRT::SpaceView::doSetValue ( const size_t  module,
const size_t  channel,
const double  value 
)
overrideprotectedvirtual

Implements CRT::ChannelView.

Definition at line 150 of file SpaceView.cpp.

151  {
153  [&value](auto& hist, const auto x, const auto y) { hist.SetBinContent(x, y, value); });
154  }
TH2D fDownstream
Definition: SpaceView.h:34
uint8_t channel
Definition: CRTFragment.hh:201
void doSomething(TH2 &hist, const size_t channel, const size_t module, FUNC &&func)
Definition: SpaceView.cpp:84
TH2D fUpstream
Definition: SpaceView.h:33
list x
Definition: train.py:276
template<class FUNC >
void CRT::SpaceView::doSomething ( TH2 &  hist,
const size_t  channel,
const size_t  module,
FUNC &&  func 
)
private

Definition at line 84 of file SpaceView.cpp.

85  {
86  //When doing things like this in the future, a frame would be a good logical abstraction layer.
87  const size_t local = module%16;
88  const int nXBins = hist.GetXaxis()->GetNbins(), nYBins = hist.GetYaxis()->GetNbins(), endOfFrame = 2l*ChannelsPerModule*2l;
89  //Frames are 2 modules x 2 modules. 2 columns per strip
90  const bool secondLayer = (channel > 32);
91 
92  std::cout << "module is " << module << ", channel is " << channel << ", local is " << local << ".\n";
93  if(local < 2) //Top beam-left
94  {
95  const auto xbin = endOfFrame-(local*ChannelsPerModule+channel)*2+secondLayer;
96  std::cout << "Filling beam-left with subtraction at xbin=" << xbin << "\n";
97  for(int ybin = endOfFrame; ybin < nYBins; ++ybin)
98  {
99  //Fill both strips that this channel overlaps
100  func(hist, xbin, ybin);
101  func(hist, xbin-1, ybin);
102  }
103  }
104  else if(local > 13) //Top beam-right
105  {
106  const auto xbin = nXBins-((local-14)*ChannelsPerModule+channel)*2+secondLayer;
107  std::cout << "Filling beam-right with subtraction at xbin=" << xbin << "\n";
108  for(int ybin = endOfFrame; ybin < nYBins; ++ybin)
109  {
110  //Fill both strips that this channel overlaps
111  func(hist, xbin, ybin);
112  func(hist, xbin-1, ybin);
113  }
114  }
115  else if(local > 5 && local < 10) //Bottom vertical module
116  {
117  const auto xbin = ((local-6)*ChannelsPerModule+channel)*2-secondLayer; //Entire face is 4 modules x 4 modules
118  std::cout << "Filling at xbin=" << xbin << "\n";
119  for(int ybin = 0; ybin < endOfFrame; ++ybin)
120  {
121  //Fill both strips that this channel overlaps
122  func(hist, xbin, ybin);
123  func(hist, xbin+1, ybin);
124  }
125  }
126  else if(local < 6) //Beam-left horizontal module
127  {
128  const auto ybin = nYBins-((local-2)*ChannelsPerModule+channel)*2+secondLayer; //Entire face is 4 modules x 4 modules
129  std::cout << "Filling at ybin=" << ybin << "\n";
130  for(int xbin = 0; xbin < endOfFrame; ++xbin)
131  {
132  //Fill both strips that this channel overlaps
133  func(hist, xbin, ybin);
134  func(hist, xbin, ybin-1);
135  }
136  }
137  else //Beam-right horizontal module
138  {
139  const auto ybin = ((local-10)*ChannelsPerModule+channel)*2-secondLayer; //Entire face is 4 modules x 4 modules
140  std::cout << "Filling at ybin=" << ybin << "\n";
141  for(int xbin = endOfFrame; xbin < nXBins; ++xbin)
142  {
143  //Fill both strips that this channel overlaps
144  func(hist, xbin, ybin);
145  func(hist, xbin, ybin+1);
146  }
147  }
148  }
uint8_t channel
Definition: CRTFragment.hh:201
static QStrList * l
Definition: config.cpp:1044
static constexpr size_t ChannelsPerModule
Definition: ChannelView.h:45
def func()
Definition: docstring.py:7
void CRT::SpaceView::SetupPads ( )
private

Definition at line 26 of file SpaceView.cpp.

27  {
28  auto main = GetMainPad(); //Observer pointer
29  main->Divide(2);
30 
31  //Set up upstream pad
32  main->cd(1);
33  gPad->SetLogz();
34 
35  //Set up downstream pad
36  main->cd(2);
37  gPad->SetLogz();
38  }
TPad * GetMainPad()
Definition: ChannelView.h:47

Member Data Documentation

TH2D CRT::SpaceView::fDownstream
private

Definition at line 34 of file SpaceView.h.

TH2D CRT::SpaceView::fUpstream
private

Definition at line 33 of file SpaceView.h.


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