LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
TQPad.cxx
Go to the documentation of this file.
7 #include "TH1F.h"
8 #include "TPad.h"
9 
12 #include "cetlib_except/exception.h"
13 
23 
24 // C/C++ standard libraries
25 #include <algorithm> // std::min(), std::max()
26 
27 namespace evd {
28 
29  static const int kRAW = 0;
30  static const int kCALIB = 1;
31  static const int kQ = 0;
32  static const int kTQ = 1;
33 
34  //......................................................................
35 
36  TQPad::TQPad(const char* nm,
37  const char* ti,
38  double x1,
39  double y1,
40  double x2,
41  double y2,
42  const char* opt,
43  unsigned int plane,
44  unsigned int wire)
45  : DrawingPad(nm, ti, x1, y1, x2, y2), fWire(wire), fPlane(plane), fFrameHist(0)
46  {
47  unsigned int planes = art::ServiceHandle<geo::WireReadout const>()->Get().Nplanes();
48 
49  Pad()->cd();
50 
51  Pad()->SetLeftMargin(0.050);
52  Pad()->SetRightMargin(0.050);
53 
54  Pad()->SetTopMargin(0.005);
55  Pad()->SetBottomMargin(0.110);
56 
57  // there has to be a better way of doing this that does
58  // not have a case for each number of planes in a detector
59  if (planes == 2 && fPlane > 0) {
60  Pad()->SetTopMargin(0.110);
61  Pad()->SetBottomMargin(0.010);
62  }
63  else if (planes > 2) {
64  if (fPlane == 1) {
65  Pad()->SetTopMargin(0.005);
66  Pad()->SetBottomMargin(0.010);
67  }
68  else if (fPlane == 2) {
69  Pad()->SetTopMargin(0.110);
70  Pad()->SetBottomMargin(0.010);
71  }
72  }
73 
74  std::string opts(opt);
75  if (opts == "TQ") {
76  fTQ = kTQ;
77  // BB adjust the vertical spacing
78  Pad()->SetTopMargin(0);
79  Pad()->SetBottomMargin(0.2);
80  }
81  if (opts == "Q") { fTQ = kQ; }
82 
83  BookHistogram();
84  fView = new evdb::View2D();
85 
88 
89  fHitDrawerTool = art::make_tool<evdb_tool::IWFHitDrawer>(recoOptions->fHitDrawerParams);
91  art::make_tool<evdb_tool::IWaveformDrawer>(rawOptions->fRawDigitDrawerParams);
92  fWireDrawerTool = art::make_tool<evdb_tool::IWaveformDrawer>(recoOptions->fWireDrawerParams);
93  }
94 
95  //......................................................................
96 
98  {
99  if (fView) {
100  delete fView;
101  fView = nullptr;
102  }
103  if (fFrameHist) {
104  delete fFrameHist;
105  fFrameHist = nullptr;
106  }
107  }
108 
109  //......................................................................
110  void TQPad::Draw()
111  {
113 
114  //grab the singleton with the event
116  if (!evt) return;
117 
118  fPad->Clear();
119  fPad->cd();
120 
121  // Note this handles drawing waveforms for both SP and DP where the difference is handled by the tools
122  if (fTQ == kTQ) {
123  // Recover a channel number from current information
124  geo::WireID const wireid{drawopt->fCryostat, drawopt->fTPC, fPlane, fWire};
125  raw::ChannelID_t channel =
126  art::ServiceHandle<geo::WireReadout const>()->Get().PlaneWireToChannel(wireid);
127 
128  // Call the tools to fill the histograms for RawDigits and Wire data
129  fRawDigitDrawerTool->Fill(
130  *fView, channel, RawDataDraw()->StartTick(), RawDataDraw()->TotalClockTicks());
131  fWireDrawerTool->Fill(
132  *fView, channel, RawDataDraw()->StartTick(), RawDataDraw()->TotalClockTicks());
133 
134  // Vertical limits set for the enclosing histogram, then draw it with axes only
135  float maxLowVal = std::min(fRawDigitDrawerTool->getMinimum(), fWireDrawerTool->getMinimum());
136  float maxHiVal = std::max(fRawDigitDrawerTool->getMaximum(), fWireDrawerTool->getMaximum());
137 
138  if (drawopt->fDrawRawDataOrCalibWires == kCALIB) {
139  maxLowVal = fWireDrawerTool->getMinimum();
140  maxHiVal = fWireDrawerTool->getMaximum();
141  }
142 
143  if (maxLowVal < std::numeric_limits<float>::max())
144  maxLowVal -= 5.;
145  else
146  maxLowVal = -10.;
147  if (maxHiVal > std::numeric_limits<float>::lowest())
148  maxHiVal += 5.;
149  else
150  maxHiVal = 10.;
151 
152  fFrameHist->SetMaximum(maxHiVal);
153  fFrameHist->SetMinimum(maxLowVal);
154  fFrameHist->Draw("AXIS");
155 
156  // draw with histogram style, only (square) lines, no errors
157  static const std::string defaultDrawOptions = "HIST same";
158 
159  // Draw the desired histograms
160  // If its not just the raw hists then we output the wire histograms
161  if (drawopt->fDrawRawDataOrCalibWires != kRAW) {
162  fWireDrawerTool->Draw(defaultDrawOptions.c_str(), maxLowVal, maxHiVal);
163 
164  fHitDrawerTool->Draw(*fView, channel);
165  }
166 
167  // Likewise, if it is not just the calib hists then we output the raw histogram
168  if (drawopt->fDrawRawDataOrCalibWires != kCALIB)
169  fRawDigitDrawerTool->Draw(defaultDrawOptions.c_str(), maxLowVal, maxHiVal);
170 
171  // This is a remnant from a time long past...
172  fFrameHist->SetTitleOffset(0.2, "Y");
173  } // end if fTQ == kTQ
174  }
175 
176  //......................................................................
178  {
179  if (fFrameHist) {
180  delete fFrameHist;
181  fFrameHist = 0;
182  }
183 
186 
187  // figure out the signal type for this plane, assume that
188  // plane n in each TPC/cryostat has the same type
189  geo::PlaneID planeid(drawopt->CurrentTPC(), fPlane);
190  geo::SigType_t sigType =
191  art::ServiceHandle<geo::WireReadout const>()->Get().SignalType(planeid);
192 
194  double qxloraw = cst->fRawQLow[(size_t)sigType];
195  double qxhiraw = cst->fRawQHigh[(size_t)sigType];
196  double tqxlo = 1. * RawDataDraw()->StartTick();
197  double tqxhi = 1. * RawDataDraw()->TotalClockTicks();
198 
199  switch (fTQ) {
200  case kQ:
201  fFrameHist = new TH1F("fFrameHist", ";t [ticks];[ADC]", 2, 0., 1.);
202  fFrameHist->SetMaximum(qxhiraw);
203  fFrameHist->SetMinimum(qxloraw);
204  break; // kQ
205  case kTQ:
206  fFrameHist = new TH1F("fFrameHist", ";t [ticks];q [ADC]", (int)tqxhi, tqxlo, tqxhi + tqxlo);
207  break;
208  default: throw cet::exception("TQPad") << __func__ << ": unexpected quantity #" << fTQ << "\n";
209  } //end if fTQ == kTQ
210 
211  // Set the label, title size and offsets
212  // Note this is the base histogram so this control these for both the raw and wire histograms
213  fFrameHist->GetXaxis()->SetLabelSize(0.10);
214  fFrameHist->GetXaxis()->SetLabelOffset(0.00);
215  fFrameHist->GetXaxis()->SetTitleSize(0.10);
216  fFrameHist->GetXaxis()->SetTitleOffset(0.80);
217 
218  fFrameHist->GetYaxis()->SetLabelSize(0.10);
219  fFrameHist->GetYaxis()->SetLabelOffset(0.01);
220  fFrameHist->GetYaxis()->SetTitleSize(0.10);
221  fFrameHist->GetYaxis()->SetTitleOffset(0.80);
222  }
223 
224 }
const art::Event * GetEvent() const
Definition: EventHolder.cxx:45
IWFHitDrawerPtr fHitDrawerTool
An instance of the tool to draw hits.
Definition: TQPad.h:57
std::vector< double > fRawQLow
low edge of ADC values for drawing raw digits
unsigned int fTPC
TPC number to draw, typically set by TWQProjectionView.
unsigned int fPlane
Which plane in the detector.
Definition: TQPad.h:53
TH1F * fFrameHist
A dummy histogram to define the axes.
Definition: TQPad.h:55
Float_t y1[n_points_granero]
Definition: compare.C:5
void BookHistogram()
Definition: TQPad.cxx:177
int fDrawRawDataOrCalibWires
0 for raw
Float_t x1[n_points_granero]
Definition: compare.C:5
IWaveformDrawerPtr fWireDrawerTool
An instance of the tool to draw hits.
Definition: TQPad.h:59
The data type to uniquely identify a Plane.
Definition: geo_types.h:364
fhicl::ParameterSet fRawDigitDrawerParams
FHICL parameters for the RawDigit waveform display.
Drawing pad for time or charge histograms.
static const int kRAW
Definition: TQPad.cxx:29
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
A collection of drawable 2-D objects.
static const int kCALIB
Definition: TQPad.cxx:30
void Draw()
Definition: TQPad.cxx:110
Singleton to hold the current art::Event for the event display.
Float_t y2[n_points_geant4]
Definition: compare.C:26
unsigned int fWire
Definition: TQPad.h:52
The color scales used by the event display.
evdb::View2D * fView
Superimpose scale on 1D histo.
Definition: TQPad.h:56
LArSoft includes.
RawDataDrawer * RawDataDraw()
Definition: DrawingPad.cxx:121
unsigned int fCryostat
Cryostat number to draw, typically set by TWQProjectionView.
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
static EventHolder * Instance()
Definition: EventHolder.cxx:15
fhicl::ParameterSet fWireDrawerParams
FHICL parameters for the wire drawing.
Base class for event display drawing pads.
Definition: DrawingPad.h:26
This provides an interface for tools which are tasked with drawing the "wire" data (deconvolved wavef...
TPad * Pad()
Definition: DrawingPad.h:30
geo::TPCID CurrentTPC() const
Returns the current TPC as a TPCID.
double TotalClockTicks() const
Definition: RawDataDrawer.h:78
static const int kQ
Definition: TQPad.cxx:31
Class to aid in the rendering of RawData objects.
static const int kTQ
Definition: TQPad.cxx:32
std::vector< double > fRawQHigh
high edge of ADC values for drawing raw digits
IWaveformDrawerPtr fRawDigitDrawerTool
An instance of the tool to draw hits.
Definition: TQPad.h:58
int fTQ
0 = plot shows charge only, 1 = plot shows charge vs time for a wire
Definition: TQPad.h:54
double StartTick() const
Definition: RawDataDrawer.h:77
~TQPad()
Definition: TQPad.cxx:97
TPad * fPad
The ROOT graphics pad.
Definition: DrawingPad.h:44
fhicl::ParameterSet fHitDrawerParams
FHICL parameters for the hit drawing.
TCEvent evt
Definition: DataStructs.cxx:8
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
Float_t x2[n_points_geant4]
Definition: compare.C:26
TQPad(const char *nm, const char *ti, double x1, double y1, double x2, double y2, const char *opt, unsigned int plane, unsigned int wire)
Definition: TQPad.cxx:36
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33