11 #include "nuevdb/EventDisplayBase/EventHolder.h"
12 #include "nuevdb/EventDisplayBase/View2D.h"
14 #include "art/Framework/Principal/Handle.h"
15 #include "art/Framework/Services/Registry/ServiceHandle.h"
16 #include "art/Utilities/ToolMacros.h"
17 #include "canvas/Persistency/Common/FindManyP.h"
18 #include "cetlib_except/exception.h"
19 #include "messagefacility/MessageLogger/MessageLogger.h"
22 #include "TPolyLine.h"
34 void configure(
const fhicl::ParameterSet& pset)
override;
81 art::ServiceHandle<evd::RecoDrawingOptions const> recoOpt;
84 const art::Event*
event = evdb::EventHolder::Instance()->GetEvent();
89 for (
size_t imod = 0; imod < recoOpt->fHitLabels.size(); ++imod) {
91 art::InputTag
const which = recoOpt->fHitLabels[imod];
93 art::Handle<std::vector<recob::Hit>> hitVecHandle;
94 event->getByLabel(which, hitVecHandle);
97 art::PtrVector<recob::Hit> hitPtrVec;
100 for (
size_t hitIdx = 0; hitIdx < hitVecHandle->size(); hitIdx++) {
101 art::Ptr<recob::Hit>
hit(hitVecHandle, hitIdx);
103 if (hit->Channel() == channel) hitPtrVec.push_back(hit);
106 catch (cet::exception&
e) {
107 mf::LogWarning(
"DrawGausHits") <<
"DrawGausHits"
108 <<
" failed with message:\n"
112 if (hitPtrVec.empty())
continue;
115 std::sort(hitPtrVec.begin(), hitPtrVec.end(), [](
const auto&
left,
const auto&
right) {
116 return left->PeakTime() <
right->PeakTime();
120 art::FindManyP<recob::Wire> wireAssnsVec(hitPtrVec, *event, which);
121 std::vector<float> wireDataVec;
124 if (wireAssnsVec.isValid() && wireAssnsVec.size() > 0) {
125 auto hwafp = wireAssnsVec.at(0).front();
126 if (!hwafp.isNull() && hwafp.isAvailable()) { wireDataVec = hwafp->Signal(); }
138 for (
const auto&
hit : hitPtrVec) {
140 if (
hit->PeakTime() - 3. *
hit->RMS() > lastEndTick) {
141 if (!roiHitParamsVec.empty()) hitParamsVec.push_back(roiHitParamsVec);
142 roiHitParamsVec.clear();
147 hitParams.hitCenter =
hit->PeakTime();
148 hitParams.hitSigma =
hit->RMS();
149 hitParams.hitHeight =
hit->PeakAmplitude();
150 hitParams.hitStart =
hit->StartTick();
151 hitParams.hitEnd =
hit->EndTick();
153 lastEndTick = hitParams.hitEnd;
155 roiHitParamsVec.emplace_back(hitParams);
160 if (!roiHitParamsVec.empty()) hitParamsVec.push_back(roiHitParamsVec);
164 for (
const auto& roiHitParamsVec : hitParamsVec) {
166 double roiStart = roiHitParamsVec.front().hitStart;
167 double roiStop = roiHitParamsVec.back().hitEnd;
169 std::string funcString =
"gaus(0)";
170 std::string funcName = Form(
"hitshape_%05zu_c%02zu",
size_t(channel), roiCount++);
172 for (
size_t idx = 1; idx < roiHitParamsVec.size(); idx++)
178 if (
fFloatBaseline && !wireDataVec.empty()) baseline = wireDataVec.at(roiStart);
183 std::make_unique<TF1>(funcName.c_str(), funcString.c_str(), roiStart, roiStop));
189 for (
const auto& hitParams : roiHitParamsVec) {
190 hitFunc.SetParameter(idx + 0, hitParams.hitHeight);
191 hitFunc.SetParameter(idx + 1, hitParams.hitCenter);
192 hitFunc.SetParameter(idx + 2, hitParams.hitSigma);
194 TPolyLine&
hitHeight = view2D.AddPolyLine(2, kBlack, 1, 1);
196 hitHeight.SetPoint(0, hitParams.hitCenter, baseline);
197 hitHeight.SetPoint(1, hitParams.hitCenter, hitParams.hitHeight + baseline);
199 hitHeight.Draw(
"same");
201 TPolyLine&
hitSigma = view2D.AddPolyLine(2, kGray, 1, 1);
204 0, hitParams.hitCenter - hitParams.hitSigma, 0.6 * hitParams.hitHeight + baseline);
206 1, hitParams.hitCenter + hitParams.hitSigma, 0.6 * hitParams.hitHeight + baseline);
208 hitSigma.Draw(
"same");
213 hitFunc.Draw(
"same");
Declaration of signal hit object.
int TDCtick_t
Type representing a TDC tick.
std::string to_string(WindowPattern const &pattern)
Declaration of basic channel signal object.
unsigned int ChannelID_t
Type representing the ID of a readout channel.