All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DrawWireHist_tool.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file DrawWireHist_tool.cc
3 /// \author T. Usher
4 ////////////////////////////////////////////////////////////////////////
5 
12 
13 #include "nuevdb/EventDisplayBase/EventHolder.h"
14 
15 #include "art/Framework/Principal/Handle.h"
16 #include "art/Framework/Services/Registry/ServiceHandle.h"
17 #include "art/Utilities/ToolMacros.h"
18 
19 #include "TH1F.h"
20 
21 namespace evdb_tool
22 {
23 
25 {
26 public:
27  explicit DrawWireHist(const fhicl::ParameterSet& pset);
28 
29  ~DrawWireHist();
30 
31  void configure(const fhicl::ParameterSet& pset) override;
32  void Fill(evdb::View2D&, raw::ChannelID_t&, float, float) override;
33  void Draw(const std::string&, float, float) override;
34 
35  float getMaximum() const override {return fMaximum;};
36  float getMinimum() const override {return fMinimum;};
37 
38 private:
39 
40  void BookHistogram(raw::ChannelID_t&, float, float);
41 
42  float fMaximum;
43  float fMinimum;
44 
45  std::vector<int> fColorMap;
46  std::unordered_map<std::string,std::unique_ptr<TH1F>> fRecoHistMap;
47 };
48 
49 //----------------------------------------------------------------------
50 // Constructor.
51 DrawWireHist::DrawWireHist(const fhicl::ParameterSet& pset)
52 {
53  configure(pset);
54 }
55 
57 {
58 }
59 
60 void DrawWireHist::configure(const fhicl::ParameterSet& pset)
61 {
62  fColorMap.push_back(kBlue);
63  fColorMap.push_back(kMagenta);
64  fColorMap.push_back(kBlack);
65  fColorMap.push_back(kRed);
66 
67  fRecoHistMap.clear();
68 
69  return;
70 }
71 
72 
73 void DrawWireHist::Fill(evdb::View2D& view2D,
74  raw::ChannelID_t& channel,
75  float lowBin,
76  float numTicks)
77 {
78  art::ServiceHandle<evd::RawDrawingOptions const> rawOpt;
79  art::ServiceHandle<evd::RecoDrawingOptions const> recoOpt;
80 
81  // Check if we're supposed to draw raw hits at all
82  if(rawOpt->fDrawRawDataOrCalibWires == 0) return;
83 
84  //grab the singleton with the event
85  const art::Event* event = evdb::EventHolder::Instance()->GetEvent();
86  if(!event) return;
87 
88  // Handle histograms
89  BookHistogram(channel, lowBin, numTicks);
90 
91  fMinimum = std::numeric_limits<float>::max();
92  fMaximum = std::numeric_limits<float>::lowest();
93 
94  int nWireLabels = 0;
95  for (size_t imod = 0; imod < recoOpt->fWireLabels.size(); ++imod)
96  {
97  // Step one is to recover the hits for this label that match the input channel
98  art::InputTag const which = recoOpt->fWireLabels[imod];
99 
100  art::Handle< std::vector<recob::Wire> > wireVecHandle;
101  if (!event->getByLabel(which, wireVecHandle)) continue;
102  ++nWireLabels;
103 
104  for(size_t wireIdx = 0; wireIdx < wireVecHandle->size(); wireIdx++)
105  {
106  art::Ptr<recob::Wire> wire(wireVecHandle, wireIdx);
107 
108  if (wire->Channel() != channel) continue;
109 
110  const std::vector<float>& signalVec = wire->Signal();
111 
112  TH1F* histPtr = fRecoHistMap.at(which.encode()).get();
113 
114  for(size_t idx = 0; idx < signalVec.size(); idx++)
115  {
116  histPtr->Fill(float(idx)+0.5,signalVec[idx]);
117 
118  fMinimum = std::min(fMinimum,signalVec[idx]);
119  fMaximum = std::max(fMaximum,signalVec[idx]);
120  }
121 
122  histPtr->SetLineColor(fColorMap.at((nWireLabels-1) % recoOpt->fWireLabels.size()));
123 
124  // There is only one channel displayed so if here we are done
125  break;
126  }
127  }//end loop over HitFinding modules
128 
129  return;
130 }
131 
132 void DrawWireHist::Draw(const std::string& options, float maxLowVal, float maxHiVal)
133 {
134  for(const auto& histMap : fRecoHistMap)
135  {
136  TH1F* histPtr = histMap.second.get();
137 
138  // Set the limits
139  histPtr->SetMaximum(maxHiVal);
140  histPtr->SetMinimum(maxLowVal);
141 
142  histPtr->Draw(options.c_str());
143  }
144 
145  return;
146 }
147 
148 //......................................................................
149 void DrawWireHist::BookHistogram(raw::ChannelID_t& channel, float startTick, float numTicks)
150 {
151  art::ServiceHandle<evd::RecoDrawingOptions const> recoOpt;
152  art::ServiceHandle<evd::ColorDrawingOptions const> cst;
153  art::ServiceHandle<evd::RawDrawingOptions const> drawopt;
154  art::ServiceHandle<geo::Geometry const> geo;
155 
156  // Get rid of the previous histograms
157  fRecoHistMap.clear();
158 
159  // Now add a histogram for each of the wire labels
160  for(auto& tag : recoOpt->fWireLabels)
161  {
162  // figure out the signal type for this plane, assume that
163  // plane n in each TPC/cryostat has the same type
164  geo::SigType_t sigType = geo->SignalType(channel);
165  std::string tagString(tag.encode());
166  int numBins = numTicks;
167 
168  fRecoHistMap[tagString] = std::make_unique<TH1F>("fCALTQHisto", ";t [ticks];q [ADC]",numBins,startTick,startTick+numTicks);
169 
170  TH1F* histPtr = fRecoHistMap.at(tagString).get();
171 
172  histPtr->SetMaximum(cst->fRecoQHigh[(size_t)sigType]);
173  histPtr->SetMinimum(cst->fRecoQLow[(size_t)sigType]);
174 
175  histPtr->SetLineColor(kBlue);
176  histPtr->SetLineWidth(1);
177 
178  histPtr->GetXaxis()->SetLabelSize (0.10); // was 0.15
179  histPtr->GetXaxis()->SetLabelOffset(0.01); // was 0.00
180  histPtr->GetXaxis()->SetTitleSize (0.10); // was 0.15
181  histPtr->GetXaxis()->SetTitleOffset(0.60); // was 0.80
182 
183  histPtr->GetYaxis()->SetLabelSize (0.10 ); // was 0.15
184  histPtr->GetYaxis()->SetLabelOffset(0.002); // was 0.00
185  histPtr->GetYaxis()->SetTitleSize (0.10 ); // was 0.15
186  histPtr->GetYaxis()->SetTitleOffset(0.16 ); // was 0.80
187  }
188 }
189 
190 DEFINE_ART_CLASS_TOOL(DrawWireHist)
191 }
DrawWireHist(const fhicl::ParameterSet &pset)
void BookHistogram(raw::ChannelID_t &, float, float)
float getMinimum() const override
The color scales used by the event display.
void Draw(const std::string &, float, float) override
void configure(const fhicl::ParameterSet &pset) override
std::unordered_map< std::string, std::unique_ptr< TH1F > > fRecoHistMap
enum geo::_plane_sigtype SigType_t
std::vector< int > fColorMap
This provides an interface for tools which are tasked with drawing the &quot;wire&quot; data (deconvolved wavef...
float getMaximum() const override
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker options
Declaration of basic channel signal object.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void Fill(evdb::View2D &, raw::ChannelID_t &, float, float) override
art framework interface to geometry description