LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DrawWireHist_tool.cc
Go to the documentation of this file.
1 
12 
14 
19 
20 #include "TH1F.h"
21 
22 namespace evdb_tool {
23 
24  class DrawWireHist : public IWaveformDrawer {
25  public:
26  explicit DrawWireHist(const fhicl::ParameterSet& pset);
27 
28  ~DrawWireHist();
29 
30  void configure(const fhicl::ParameterSet& pset) override;
31  void Fill(evdb::View2D&, raw::ChannelID_t&, float, float) override;
32  void Draw(const std::string&, float, float) override;
33 
34  float getMaximum() const override { return fMaximum; };
35  float getMinimum() const override { return fMinimum; };
36 
37  private:
38  void BookHistogram(raw::ChannelID_t&, float, float);
39 
40  float fMaximum;
41  float fMinimum;
42 
43  std::vector<int> fColorMap;
44  std::unordered_map<std::string, std::unique_ptr<TH1F>> fRecoHistMap;
45  };
46 
47  //----------------------------------------------------------------------
48  // Constructor.
50  {
51  configure(pset);
52  }
53 
55 
57  {
58  fColorMap.push_back(kBlue);
59  fColorMap.push_back(kMagenta);
60  fColorMap.push_back(kBlack);
61  fColorMap.push_back(kRed);
62 
63  fRecoHistMap.clear();
64 
65  return;
66  }
67 
69  raw::ChannelID_t& channel,
70  float lowBin,
71  float numTicks)
72  {
75 
76  // Check if we're supposed to draw raw hits at all
77  if (rawOpt->fDrawRawDataOrCalibWires == 0) return;
78 
79  //grab the singleton with the event
81  if (!event) return;
82 
83  // Handle histograms
84  BookHistogram(channel, lowBin, numTicks);
85 
86  fMinimum = std::numeric_limits<float>::max();
87  fMaximum = std::numeric_limits<float>::lowest();
88 
89  int nWireLabels = 0;
90  for (size_t imod = 0; imod < recoOpt->fWireLabels.size(); ++imod) {
91  // Step one is to recover the hits for this label that match the input channel
92  art::InputTag const which = recoOpt->fWireLabels[imod];
93 
95  if (!event->getByLabel(which, wireVecHandle)) continue;
96  ++nWireLabels;
97 
98  for (size_t wireIdx = 0; wireIdx < wireVecHandle->size(); wireIdx++) {
99  art::Ptr<recob::Wire> wire(wireVecHandle, wireIdx);
100 
101  if (wire->Channel() != channel) continue;
102 
103  const std::vector<float>& signalVec = wire->Signal();
104 
105  TH1F* histPtr = fRecoHistMap.at(which.encode()).get();
106 
107  for (size_t idx = 0; idx < signalVec.size(); idx++) {
108  histPtr->Fill(float(idx) + 0.5, signalVec[idx]);
109 
110  fMinimum = std::min(fMinimum, signalVec[idx]);
111  fMaximum = std::max(fMaximum, signalVec[idx]);
112  }
113 
114  histPtr->SetLineColor(fColorMap.at((nWireLabels - 1) % recoOpt->fWireLabels.size()));
115 
116  // There is only one channel displayed so if here we are done
117  break;
118  }
119  } //end loop over HitFinding modules
120 
121  return;
122  }
123 
124  void DrawWireHist::Draw(const std::string& options, float maxLowVal, float maxHiVal)
125  {
126  for (const auto& histMap : fRecoHistMap) {
127  TH1F* histPtr = histMap.second.get();
128 
129  // Set the limits
130  histPtr->SetMaximum(maxHiVal);
131  histPtr->SetMinimum(maxLowVal);
132 
133  histPtr->Draw(options.c_str());
134  }
135 
136  return;
137  }
138 
139  //......................................................................
140  void DrawWireHist::BookHistogram(raw::ChannelID_t& channel, float startTick, float numTicks)
141  {
146 
147  // Get rid of the previous histograms
148  fRecoHistMap.clear();
149 
150  // Now add a histogram for each of the wire labels
151  for (auto& tag : recoOpt->fWireLabels) {
152  // figure out the signal type for this plane, assume that
153  // plane n in each TPC/cryostat has the same type
154  geo::SigType_t sigType = geo->SignalType(channel);
155  std::string tagString(tag.encode());
156  int numBins = numTicks;
157 
158  fRecoHistMap[tagString] = std::make_unique<TH1F>(
159  "fCALTQHisto", ";t [ticks];q [ADC]", numBins, startTick, startTick + numTicks);
160 
161  TH1F* histPtr = fRecoHistMap.at(tagString).get();
162 
163  histPtr->SetMaximum(cst->fRecoQHigh[(size_t)sigType]);
164  histPtr->SetMinimum(cst->fRecoQLow[(size_t)sigType]);
165 
166  histPtr->SetLineColor(kBlue);
167  histPtr->SetLineWidth(1);
168 
169  histPtr->GetXaxis()->SetLabelSize(0.10); // was 0.15
170  histPtr->GetXaxis()->SetLabelOffset(0.01); // was 0.00
171  histPtr->GetXaxis()->SetTitleSize(0.10); // was 0.15
172  histPtr->GetXaxis()->SetTitleOffset(0.60); // was 0.80
173 
174  histPtr->GetYaxis()->SetLabelSize(0.10); // was 0.15
175  histPtr->GetYaxis()->SetLabelOffset(0.002); // was 0.00
176  histPtr->GetYaxis()->SetTitleSize(0.10); // was 0.15
177  histPtr->GetYaxis()->SetTitleOffset(0.16); // was 0.80
178  }
179  }
180 
182 }
std::unordered_map< std::string, std::unique_ptr< TH1F > > fRecoHistMap
DrawWireHist(const fhicl::ParameterSet &pset)
const art::Event * GetEvent() const
Definition: EventHolder.cxx:45
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
int fDrawRawDataOrCalibWires
0 for raw
void BookHistogram(raw::ChannelID_t &, float, float)
float getMaximum() const override
std::string encode() const
Definition: InputTag.cc:97
Singleton to hold the current art::Event for the event display.
std::vector< double > fRecoQHigh
high edge of ADC values for drawing raw digits
std::vector< double > fRecoQLow
low edge of ADC values for drawing raw digits
The color scales used by the event display.
void Draw(const std::string &, float, float) override
void configure(const fhicl::ParameterSet &pset) override
std::vector< art::InputTag > fWireLabels
module labels that produced wires
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
Definition: Wire.h:223
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
static EventHolder * Instance()
Definition: EventHolder.cxx:15
std::vector< int > fColorMap
This provides an interface for tools which are tasked with drawing the "wire" data (deconvolved wavef...
std::vector< float > Signal() const
Return a zero-padded full length vector filled with RoI signal.
Definition: Wire.cxx:30
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
Declaration of basic channel signal object.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
float getMinimum() const override
Namespace collecting geometry-related classes utilities.
void Fill(evdb::View2D &, raw::ChannelID_t &, float, float) override
Definition: fwd.h:26
art framework interface to geometry description
Event finding and building.