12 #include "art_root_io/TFileService.h" 13 #include "cetlib_except/exception.h" 97 if (fOutputHistograms) {
108 dir.make<TH1F>(Form(
"DStopStart_%1zu",
fPlane),
";Delta Stop/Start;", 200, 0., 200.);
110 dir.make<TH1F>(Form(
"DMaxTMinT_%1zu",
fPlane),
";Delta Max/Min Tick;", 200, 0., 200.);
112 dir.make<TH1F>(Form(
"DMaxDMinD_%1zu",
fPlane),
";Delta Max/Min Deriv;", 200, 0., 200.);
120 const recob::Wire::RegionsOfInterest_t::datarange_t& dataRange,
121 const size_t roiStartTick,
123 const size_t eventCount,
132 const Waveform& waveform = dataRange.data();
135 fWaveformTool->triangleSmooth(rawDerivativeVec, derivativeVec);
138 size_t plane = wids[0].Plane;
139 size_t cryo = wids[0].Cryostat;
140 size_t tpc = wids[0].TPC;
141 size_t wire = wids[0].Wire;
144 hitCandidateVec.clear();
154 if (hitCandidateVec.empty()) {
156 std::cout <<
"** C/T/P: " << cryo <<
"/" << tpc <<
"/" << plane <<
", wire: " << wire
157 <<
" has not hits with input size: " << waveform.size() <<
std::endl;
162 for (
auto& hitCandidate : hitCandidateVec) {
163 size_t centerIdx = hitCandidate.hitCenter;
165 hitCandidate.hitHeight = waveform.at(centerIdx);
181 Form(
"HitPlane_%1zu/ev%04zu/c%1zut%1zuwire_%05zu", plane, eventCount, cryo, tpc, wire));
183 size_t waveformSize = waveform.size();
184 int waveStart = roiStartTick;
185 int waveStop = waveStart + waveformSize;
187 TProfile* waveHist = dir.make<TProfile>(
188 Form(
"HWfm_%03zu_ctw%01zu-%01zu-%01zu-%05zu", channelCnt, cryo, tpc, plane, wire),
195 TProfile* derivHist = dir.make<TProfile>(
196 Form(
"HDer_%03zu_ctw%01zu-%01zu-%01zu-%05zu", channelCnt, cryo, tpc, plane, wire),
203 TProfile* candHitHist = dir.make<TProfile>(
204 Form(
"HCan_%03zu_ctw%01zu-%01zu-%01zu-%05zu", channelCnt, cryo, tpc, plane, wire),
211 TProfile* maxDerivHist = dir.make<TProfile>(
212 Form(
"HMax_%03zu_ctw%01zu-%01zu-%01zu-%05zu", channelCnt, cryo, tpc, plane, wire),
221 for (
size_t idx = 0; idx < waveform.size(); idx++) {
222 waveHist->Fill(roiStartTick + idx, waveform.at(idx));
223 derivHist->Fill(roiStartTick + idx, derivativeVec.at(idx));
227 for (
const auto& hitCandidate : hitCandidateVec) {
228 candHitHist->Fill(hitCandidate.hitCenter, hitCandidate.hitHeight);
229 maxDerivHist->Fill(hitCandidate.maxTick, hitCandidate.maxDerivative);
230 maxDerivHist->Fill(hitCandidate.minTick, hitCandidate.minDerivative);
232 fDStopStartHist->Fill(hitCandidate.stopTick - hitCandidate.startTick, 1.);
244 const size_t roiStartTick,
246 float dPeakThreshold,
253 std::pair<Waveform::const_iterator, Waveform::const_iterator> minMaxPair =
254 std::minmax_element(startItr, stopItr);
260 if (std::fabs(*maxItr) > std::fabs(*minItr))
266 float range = *maxItr - *minItr;
269 if (deltaTicks >= dTicksThreshold && range > dPeakThreshold) {
283 if (startTick > dTicksThreshold) {
285 if (*(newEndItr - 1) > 0.) {
295 startItr, newEndItr + 1, roiStartTick, dTicksThreshold, dPeakThreshold, hitCandidateVec);
302 std::min_element(maxItr, minItr, [](
const auto&
left,
const auto&
right) {
303 return std::fabs(
left) < std::fabs(
right);
312 hitCandidate.
startTick = roiStartTick + startTick;
313 hitCandidate.
stopTick = roiStartTick + stopTick;
316 hitCandidate.
maxDerivative = maxItr != stopItr ? *maxItr : 0.;
317 hitCandidate.
minDerivative = minItr != stopItr ? *minItr : 0.;
323 hitCandidateVec.push_back(hitCandidate);
326 if (std::distance(newStartItr, stopItr) > dTicksThreshold) {
328 if (*(newStartItr + 1) < 0.) {
339 roiStartTick + stopTick,
351 const recob::Wire::RegionsOfInterest_t::datarange_t& rangeData,
356 if (hitCandidateVec.empty())
return;
364 size_t lastStopTick = hitCandidateVec.front().stopTick;
367 for (
const auto& hitCandidate : hitCandidateVec) {
372 !groupedHitVec.empty()) {
373 mergedHitsVec.emplace_back(groupedHitVec);
375 groupedHitVec.clear();
379 groupedHitVec.emplace_back(hitCandidate);
381 lastStopTick = hitCandidate.stopTick;
386 if (!groupedHitVec.empty()) mergedHitsVec.emplace_back(groupedHitVec);
400 while ((lastItr + 1) != stopItr) {
401 if (*(lastItr + 1) > *lastItr)
break;
420 while ((lastItr - 1) != startItr) {
421 if (*(lastItr - 1) < *lastItr)
break;
445 while (loopItr != startItr) {
447 if (*loopItr < 0. || !(*loopItr < *lastItr))
break;
469 while (loopItr != stopItr) {
471 if (*loopItr > 0. || !(*loopItr > *lastItr))
break;
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
art framework interface to geometry description
T get(std::string const &key) const
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
Description of geometry of one entire detector.
This provides an interface for tools which are tasked with finding candidate hits on input waveforms...
QTextStream & endl(QTextStream &s)