15 #include "art_root_io/TFileDirectory.h" 16 #include "art_root_io/TFileService.h" 21 #include "cetlib/cpu_timer.h" 31 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h" 32 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" 59 struct Hit2DSetCompare {
63 using HitVector = std::vector<const reco::ClusterHit2D*>;
66 using Hit2DList = std::list<reco::ClusterHit2D>;
67 using Hit2DSet = std::set<const reco::ClusterHit2D*, Hit2DSetCompare>;
104 return m_timeVector[index];
125 std::vector<recob::Hit>&,
152 std::vector<std::pair<HitVector::iterator, HitVector::iterator>>;
160 using HitMatchPair = std::pair<const reco::ClusterHit2D*, reco::ClusterHit3D>;
180 float hitWidthSclFctr = 1.,
181 size_t hitPairCntr = 0)
const;
196 size_t minStatus)
const;
203 float pairDeltaTimeLimits)
const;
208 int FindNumberInRange(
const Hit2DSet& hit2DSet,
220 float DistanceFromPointToHitWire(
const Eigen::Vector3f& position,
226 void BuildChannelStatusVec()
const;
231 float chargeIntegral(
float,
float,
float,
int,
int)
const;
258 float m_wirePitch[3];
288 mutable bool m_weHaveAllBeenHereBefore =
false;
296 : m_geometry(
art::ServiceHandle<
geo::Geometry const>{}.get())
300 std::vector<art::InputTag>{
"gaushit"});
306 m_invalidTPCVec = pset.get<std::vector<int>>(
"InvalidTPCVec", std::vector<int>{});
325 m_tupleTree = tfs->make<TTree>(
"Hit3DBuilderTree",
"Tree by StandardHit3DBuilder");
349 collector.
produces<std::vector<recob::Hit>>();
394 lariov::ChannelStatusProvider::Status_t chanStat =
m_channelFilter->Status(channel);
404 return (*left).getAvePeakTime() < (*right).getAvePeakTime();
412 if (left->second.size() == right->second.size())
return left->first < right->first;
414 return left->second.size() > right->second.size();
430 std::unique_ptr<std::vector<recob::Hit>> outputHitPtrVec(
new std::vector<recob::Hit>);
442 if (!hitPairList.empty())
448 std::unique_ptr<art::Assns<recob::Wire, recob::Hit>> wireAssns(
454 std::unique_ptr<art::Assns<raw::RawDigit, recob::Hit>> rawDigitAssns(
460 evt.
put(std::move(outputHitPtrVec));
461 evt.
put(std::move(wireAssns));
462 evt.
put(std::move(rawDigitAssns));
478 cet::cpu_timer theClockMakeHits;
489 theClockMakeHits.stop();
494 mf::LogDebug(
"Cluster3D") <<
">>>>> 3D hit building done, found " << numHitPairs <<
" 3D Hits" 501 class SetHitEarliestTimeOrder {
503 SetHitEarliestTimeOrder() :
m_numRMS(1.) {}
504 SetHitEarliestTimeOrder(
float numRMS) :
m_numRMS(numRMS) {}
516 using HitVectorItrPair = std::pair<HitVector::iterator, HitVector::iterator>;
518 class SetStartTimeOrder {
520 SetStartTimeOrder() :
m_numRMS(1.) {}
521 SetStartTimeOrder(
float numRMS) :
m_numRMS(numRMS) {}
523 bool operator()(
const HitVectorItrPair& left,
const HitVectorItrPair& right)
const 526 if (left.first != left.second && right.first != right.second) {
528 return (*left.first)->getTimeTicks() -
m_numRMS * (*left.first)->getHit()->RMS() <
529 (*right.first)->getTimeTicks() -
m_numRMS * (*right.first)->getHit()->RMS();
532 return left.first != left.second;
561 size_t totalNumHits(0);
562 size_t hitPairCntr(0);
565 size_t nDeadChanHits(0);
571 planeToHitVectorMap.find(
geo::PlaneID(cryoIdx, tpcIdx, 0));
573 planeToHitVectorMap.find(
geo::PlaneID(cryoIdx, tpcIdx, 1));
575 planeToHitVectorMap.find(
geo::PlaneID(cryoIdx, tpcIdx, 2));
577 size_t nPlanesWithHits =
578 (mapItr0 != planeToHitVectorMap.end() && !mapItr0->second.empty() ? 1 : 0) +
579 (mapItr1 != planeToHitVectorMap.end() && !mapItr1->second.empty() ? 1 : 0) +
580 (mapItr2 != planeToHitVectorMap.end() && !mapItr2->second.empty() ? 1 : 0);
582 if (nPlanesWithHits < 2)
continue;
589 std::sort(hitVector0.begin(),
592 std::sort(hitVector1.begin(),
595 std::sort(hitVector2.begin(),
600 HitVectorItrPair(hitVector0.begin(), hitVector0.end()),
601 HitVectorItrPair(hitVector1.begin(), hitVector1.end()),
602 HitVectorItrPair(hitVector2.begin(), hitVector2.end())};
612 mf::LogDebug(
"Cluster3D") <<
"Total number hits: " << totalNumHits << std::endl;
613 mf::LogDebug(
"Cluster3D") <<
"Created a total of " << hitPairList.size()
614 <<
" hit pairs, counted: " << hitPairCntr << std::endl;
615 mf::LogDebug(
"Cluster3D") <<
"-- Triplets: " << nTriplets
616 <<
", dead channel pairs: " << nDeadChanHits << std::endl;
618 return hitPairList.size();
635 auto SetStartIterator =
637 while (startItr != endItr) {
639 if ((*startItr)->getTimeTicks() + numRMS * (*startItr)->getHit()->RMS() < startTime)
647 auto SetEndIterator =
649 while (firstItr != endItr) {
651 if ((*firstItr)->getTimeTicks() - numRMS * (*firstItr)->getHit()->RMS() < endTime)
671 std::numeric_limits<float>::epsilon();
672 float goldenTimeEnd = goldenHit->getTimeTicks() +
674 std::numeric_limits<float>::epsilon();
690 size_t n12Pairs =
findGoodHitPairs(goldenHit, hitItr1Start, hitItr1End, pair12Map);
691 size_t n13Pairs =
findGoodHitPairs(goldenHit, hitItr2Start, hitItr2End, pair13Map);
693 if (n12Pairs > n13Pairs)
698 hitItrVec[0].first++;
700 int nPlanesWithHits(0);
702 for (
auto& pair : hitItrVec)
703 if (pair.first != pair.second) nPlanesWithHits++;
705 if (nPlanesWithHits < 2)
break;
708 return hitPairList.size();
719 while (startItr != endItr) {
728 hitMatchMap[wireID].emplace_back(hit, pair);
741 if (!pair12Map.empty()) {
743 std::vector<reco::ClusterHit3D> tempDeadChanVec;
747 std::map<const reco::ClusterHit3D*, bool> usedPairMap;
750 for (
const auto& pair13 : pair13Map) {
751 for (
const auto& hit2Dhit3DPair : pair13.second)
752 usedPairMap[&hit2Dhit3DPair.second] =
false;
756 for (
const auto& pair12 : pair12Map) {
757 if (pair12.second.empty())
continue;
761 for (
const auto& hit2Dhit3DPair12 : pair12.second) {
765 usedPairMap[&pair1] =
false;
768 for (
const auto& pair13 : pair13Map) {
769 if (pair13.second.empty())
continue;
771 for (
const auto& hit2Dhit3DPair13 : pair13.second) {
779 triplet.
setID(hitPairList.size());
780 hitPairList.emplace_back(triplet);
781 usedPairMap[&pair1] =
true;
782 usedPairMap[&pair2] =
true;
791 for (
const auto& pairMapPair : usedPairMap) {
792 if (pairMapPair.second)
continue;
798 tempDeadChanVec.emplace_back(deadChanPair);
802 if (!tempDeadChanVec.empty()) {
804 if (tempDeadChanVec.size() > 1) {
806 std::sort(tempDeadChanVec.begin(),
807 tempDeadChanVec.end(),
808 [](
const auto&
left,
const auto&
right) {
809 return left.getDeltaPeakTime() / left.getSigmaPeakTime() <
810 right.getDeltaPeakTime() / right.getSigmaPeakTime();
814 float firstSig = tempDeadChanVec.front().getDeltaPeakTime() /
815 tempDeadChanVec.front().getSigmaPeakTime();
817 tempDeadChanVec.back().getDeltaPeakTime() / tempDeadChanVec.back().getSigmaPeakTime();
818 float sigRange = lastSig - firstSig;
822 float maxSignificance = std::max(0.75 * (firstSig + lastSig), 1.0);
825 tempDeadChanVec.begin(),
826 tempDeadChanVec.end(),
827 [&maxSignificance](
const auto& pair) {
828 return pair.getDeltaPeakTime() / pair.getSigmaPeakTime() > maxSignificance;
832 if (std::distance(tempDeadChanVec.begin(), firstBadElem) > 20)
833 firstBadElem = tempDeadChanVec.begin() + 20;
835 else if (firstBadElem == tempDeadChanVec.begin())
838 tempDeadChanVec.resize(std::distance(tempDeadChanVec.begin(), firstBadElem));
842 for (
auto& pair : tempDeadChanVec) {
843 pair.setID(hitPairList.size());
844 hitPairList.emplace_back(pair);
856 float hitWidthSclFctr,
857 size_t hitPairCntr)
const 888 float hit1Width = hitWidthSclFctr * hit1Sigma;
889 float hit2Width = hitWidthSclFctr * hit2Sigma;
892 if (fabs(hit1Peak - hit2Peak) <= (hit1Width + hit2Width)) {
894 float hit1SigSq = hit1Sigma * hit1Sigma;
895 float hit2SigSq = hit2Sigma * hit2Sigma;
896 float deltaPeakTime = std::fabs(hit1Peak - hit2Peak);
897 float sigmaPeakTime = std::sqrt(hit1SigSq + hit2SigSq);
903 float oneOverWghts = hit1SigSq * hit2SigSq / (hit1SigSq + hit2SigSq);
904 float avePeakTime = (hit1Peak / hit1SigSq + hit2Peak / hit2SigSq) * oneOverWghts;
906 float hitChiSquare = std::pow((hit1Peak - avePeakTime), 2) / hit1SigSq +
907 std::pow((hit2Peak - avePeakTime), 2) / hit2SigSq;
911 float xPosition = (xPositionHit1 / hit1SigSq + xPositionHit2 / hit2SigSq) * hit1SigSq *
912 hit2SigSq / (hit1SigSq + hit2SigSq);
914 Eigen::Vector3f position(
915 xPosition,
float(widIntersect->y),
float(widIntersect->z) -
m_zPosOffset);
931 hitVector.resize(3, NULL);
937 unsigned int tpcIdx = hit1->
WireID().
TPC;
940 std::vector<geo::WireID> wireIDVec = {
geo::WireID(cryostatIdx, tpcIdx, 0, 0),
948 std::vector<float> hitDelTSigVec = {0., 0., 0.};
950 hitDelTSigVec[hit1->
WireID().
Plane] = deltaPeakTime / sigmaPeakTime;
951 hitDelTSigVec[hit2->
WireID().
Plane] = deltaPeakTime / sigmaPeakTime;
987 static const double wirePitch =
1008 if (hitWireDist < wirePitch) {
1021 hit0 = pairHitVec[2];
1023 hit1 = pairHitVec[2];
1035 unsigned int statusBits(0x7);
1036 float avePeakTime(0.);
1037 float weightSum(0.);
1038 float xPosition(0.);
1044 for (
size_t planeIdx = 0; planeIdx < 3; planeIdx++) {
1047 wireIDVec[planeIdx] = hit2D->
WireID();
1062 float weight = 1. / (hitRMS * hitRMS);
1064 avePeakTime += peakTime *
weight;
1069 avePeakTime /= weightSum;
1070 xPosition /= weightSum;
1075 Eigen::Vector3f position(xPosition,
1076 float((pairYZVec[0] + pair0hYZVec[0] + pair1hYZVec[0]) / 3.),
1077 float((pairYZVec[1] + pair0hYZVec[1] + pair1hYZVec[1]) / 3.));
1080 float hitChiSquare(0.);
1081 float sigmaPeakTime(std::sqrt(1. / weightSum));
1082 std::vector<float> hitDelTSigVec;
1084 for (
const auto& hit2D : hitVector) {
1085 float hitRMS = hit2D->getHit()->RMS();
1088 if (hit2D->getHit()->DegreesOfFreedom() < 2)
1089 hitRMS = std::min(hit2D->getTimeTicks() - float(hit2D->getHit()->StartTick()),
1090 float(hit2D->getHit()->EndTick()) - hit2D->getTimeTicks());
1092 float combRMS = std::sqrt(hitRMS * hitRMS - sigmaPeakTime * sigmaPeakTime);
1093 float peakTime = hit2D->getTimeTicks();
1094 float deltaTime = peakTime - avePeakTime;
1095 float hitSig = deltaTime / combRMS;
1097 hitChiSquare += hitSig * hitSig;
1099 hitDelTSigVec.emplace_back(std::fabs(hitSig));
1104 int lowMinIndex(std::numeric_limits<int>::max());
1105 int lowMaxIndex(std::numeric_limits<int>::min());
1106 int hiMinIndex(std::numeric_limits<int>::max());
1107 int hiMaxIndex(std::numeric_limits<int>::min());
1110 for (
const auto& hit2D : hitVector) {
1111 float range = 2. * hit2D->getHit()->RMS();
1114 if (hit2D->getHit()->DegreesOfFreedom() < 2)
1115 range = std::min(hit2D->getTimeTicks() - float(hit2D->getHit()->StartTick()),
1116 float(hit2D->getHit()->EndTick()) - hit2D->getTimeTicks());
1118 int hitStart = hit2D->getHit()->PeakTime() - range - 0.5;
1119 int hitStop = hit2D->getHit()->PeakTime() + range + 0.5;
1121 lowMinIndex = std::min(hitStart, lowMinIndex);
1122 lowMaxIndex = std::max(hitStart, lowMaxIndex);
1123 hiMinIndex = std::min(hitStop + 1, hiMinIndex);
1124 hiMaxIndex = std::max(hitStop + 1, hiMaxIndex);
1128 if (hitChiSquare < m_maxHit3DChiSquare && hiMinIndex > lowMaxIndex) {
1130 std::vector<float> chargeVec;
1132 for (
const auto& hit2D : hitVector)
1134 hit2D->getHit()->PeakAmplitude(),
1135 hit2D->getHit()->RMS(),
1140 std::accumulate(chargeVec.begin(), chargeVec.end(), 0.) / float(chargeVec.size());
1141 float overlapRange = float(hiMinIndex - lowMaxIndex);
1142 float overlapFraction = overlapRange / float(hiMaxIndex - lowMinIndex);
1145 std::vector<float> smallestChargeDiffVec;
1146 std::vector<float> chargeAveVec;
1147 float smallestDiff(std::numeric_limits<float>::max());
1148 float maxDeltaPeak(0.);
1149 size_t chargeIndex(0);
1151 for (
size_t idx = 0; idx < 3; idx++) {
1152 size_t leftIdx = (idx + 2) % 3;
1153 size_t rightIdx = (idx + 1) % 3;
1155 smallestChargeDiffVec.push_back(
std::abs(chargeVec[leftIdx] - chargeVec[rightIdx]));
1156 chargeAveVec.push_back(
float(0.5 * (chargeVec[leftIdx] + chargeVec[rightIdx])));
1158 if (smallestChargeDiffVec.back() < smallestDiff) {
1159 smallestDiff = smallestChargeDiffVec.back();
1164 float deltaPeakTime =
1165 hitVector[leftIdx]->getTimeTicks() - hitVector[rightIdx]->getTimeTicks();
1167 if (
std::abs(deltaPeakTime) > maxDeltaPeak) maxDeltaPeak =
std::abs(deltaPeakTime);
1172 float chargeAsymmetry = (chargeAveVec[chargeIndex] - chargeVec[chargeIndex]) /
1173 (chargeAveVec[chargeIndex] + chargeVec[chargeIndex]);
1176 if (chargeAsymmetry < -1. || chargeAsymmetry > 1.) {
1179 std::cout <<
"============> Charge asymmetry out of range: " << chargeAsymmetry
1180 <<
" <============" << std::endl;
1181 std::cout <<
" hit C: " << hitWireID.
Cryostat <<
", TPC: " << hitWireID.
TPC 1182 <<
", Plane: " << hitWireID.
Plane <<
", Wire: " << hitWireID.
Wire 1184 std::cout <<
" charge: " << chargeVec[0] <<
", " << chargeVec[1] <<
", " 1185 << chargeVec[2] << std::endl;
1186 std::cout <<
" index: " << chargeIndex <<
", smallest diff: " << smallestDiff
1192 float deltaPeakTime = *std::max_element(hitDelTSigVec.begin(), hitDelTSigVec.end());
1207 if (maxDeltaPeak > overlapRange)
return result;
1244 for (
int sigPos = low; sigPos < hi; sigPos++) {
1245 float arg = (float(sigPos) - peakMean + 0.5) / peakSigma;
1246 integral += peakAmp * std::exp(-0.5 * arg * arg);
1254 size_t maxChanStatus,
1255 size_t minChanStatus)
const 1263 size_t missPlane(2);
1287 bool wireOneStatus = m_channelStatus[wireID.
Plane][wireID.
Wire + 1] < maxChanStatus &&
1288 m_channelStatus[wireID.
Plane][wireID.
Wire + 1] >= minChanStatus;
1291 if (wireStatus || wireOneStatus) {
1293 if (!wireStatus) wireID.
Wire += 1;
1298 Eigen::Vector3f newPosition(
1301 newPosition[1] = (newPosition[1] + widIntersect0->y + widIntersect1->y) / 3.;
1303 (newPosition[2] + widIntersect0->z + widIntersect1->z - 2. *
m_zPosOffset) / 3.;
1328 float pairDeltaTimeLimits)
const 1330 static const float minCharge(0.);
1337 for (
const auto& hit2D : hit2DSet) {
1338 if (hit2D->getHit()->Integral() < minCharge)
continue;
1340 float hitVPeakTime(hit2D->getTimeTicks());
1341 float deltaPeakTime(pairAvePeakTime - hitVPeakTime);
1343 if (deltaPeakTime > pairDeltaTimeLimits)
continue;
1345 if (deltaPeakTime < -pairDeltaTimeLimits)
break;
1347 pairDeltaTimeLimits = fabs(deltaPeakTime);
1358 static const float minCharge(0.);
1360 int numberInRange(0);
1364 for (
const auto& hit2D : hit2DSet) {
1365 if (hit2D->getHit()->Integral() < minCharge)
continue;
1367 float hitVPeakTime(hit2D->getTimeTicks());
1368 float deltaPeakTime(pairAvePeakTime - hitVPeakTime);
1370 if (deltaPeakTime > range)
continue;
1372 if (deltaPeakTime < -range)
break;
1377 return numberInRange;
1388 double distanceToWire =
1391 wireID.
Wire = int(distanceToWire);
1395 mf::LogWarning(
"Cluster3D") <<
"Exception caught finding nearest wire, position - " 1396 << exc.what() << std::endl;
1416 Eigen::Vector3d wireStart;
1417 Eigen::Vector3d wireEnd;
1422 Eigen::Vector3d hitPosition(wireStart[0], position[1], position[2]);
1425 Eigen::Vector3d wireDir = wireEnd - wireStart;
1427 wireDir.normalize();
1430 double arcLen = (hitPosition - wireStart).
dot(wireDir);
1432 Eigen::Vector3d docaVec = hitPosition - (wireStart + arcLen * wireDir);
1434 distance = docaVec.norm();
1438 mf::LogWarning(
"Cluster3D") <<
"Exception caught finding nearest wire, position - " 1439 << exc.what() << std::endl;
1470 std::vector<const recob::Hit*> recobHitVec;
1472 auto const clock_data =
1474 auto const det_prop =
1482 if (!recobHitHandle.
isValid() || recobHitHandle->size() == 0)
continue;
1484 recobHitVec.reserve(recobHitVec.size() + recobHitHandle->size());
1486 for (
const auto&
hit : *recobHitHandle)
1487 recobHitVec.push_back(&
hit);
1491 if (recobHitVec.empty())
return;
1493 cet::cpu_timer theClockMakeHits;
1499 std::map<geo::PlaneID, double> planeOffsetMap;
1502 std::string debugMessage(
"");
1515 det_prop.GetXTicksOffset(
geo::PlaneID(cryoIdx, tpcIdx, 1)) -
1516 det_prop.GetXTicksOffset(
geo::PlaneID(cryoIdx, tpcIdx, 0));
1518 det_prop.GetXTicksOffset(
geo::PlaneID(cryoIdx, tpcIdx, 2)) -
1519 det_prop.GetXTicksOffset(
geo::PlaneID(cryoIdx, tpcIdx, 0));
1523 std::ostringstream outputString;
1525 outputString <<
"***> plane 0 offset: " 1527 <<
", plane 1: " << planeOffsetMap[
geo::PlaneID(cryoIdx, tpcIdx, 1)]
1528 <<
", plane 2: " << planeOffsetMap[
geo::PlaneID(cryoIdx, tpcIdx, 2)]
1530 debugMessage += outputString.str();
1531 outputString <<
" Det prop plane 0: " 1532 << det_prop.GetXTicksOffset(
geo::PlaneID(cryoIdx, tpcIdx, 0))
1534 << det_prop.GetXTicksOffset(
geo::PlaneID(cryoIdx, tpcIdx, 1))
1536 << det_prop.GetXTicksOffset(
geo::PlaneID(cryoIdx, tpcIdx, 2))
1538 debugMessage += outputString.str();
1544 mf::LogDebug(
"Cluster3D") << debugMessage << std::endl;
1551 for (
const auto& recobHit : recobHitVec) {
1553 if (recobHit->Integral() < 0.)
continue;
1557 const std::vector<geo::WireID>& wireIDs =
1561 for (
const auto& wireID : wireIDs) {
1571 double hitPeakTime(recobHit->PeakTime() - planeOffsetMap[planeID]);
1572 double xPosition(det_prop.ConvertTicksToX(
1584 std::sort(hitVectorMap.second.begin(), hitVectorMap.second.end(),
SetHitTimeOrder);
1587 theClockMakeHits.stop();
1600 std::vector<recob::Hit>& hitPtrVec,
1604 cet::cpu_timer theClockBuildNewHits;
1612 std::set<const reco::ClusterHit2D*> visitedHit2DSet;
1625 for (
size_t idx = 0; idx < hit3D.getHits().size(); idx++) {
1629 if (visitedHit2DSet.find(hit2D) == visitedHit2DSet.end()) {
1630 visitedHit2DSet.insert(hit2D);
1633 hitPtrVec.emplace_back(
1640 recobHitToPtrMap[newHit] = ptrMaker(hitPtrVec.size() - 1);
1648 size_t numNewHits = hitPtrVec.size();
1651 theClockBuildNewHits.stop();
1656 mf::LogDebug(
"Cluster3D") <<
">>>>> New output recob::Hit size: " << numNewHits <<
" (vs " 1671 std::unordered_map<raw::ChannelID_t, art::Ptr<recob::Wire>> channelToWireMap;
1680 if (hitToWireAssns.isValid()) {
1681 for (
size_t wireIdx = 0; wireIdx < hitToWireAssns.size(); wireIdx++) {
1684 channelToWireMap[wire->
Channel()] = wire;
1690 for (
const auto& hitPtrPair : recobHitPtrMap) {
1693 std::unordered_map<raw::ChannelID_t, art::Ptr<recob::Wire>>
::iterator chanWireItr =
1694 channelToWireMap.find(channel);
1696 if (!(chanWireItr != channelToWireMap.
end())) {
1697 mf::LogDebug(
"Cluster3D") <<
"** Did not find channel to wire match! Skipping..." 1702 wireAssns.
addSingle(chanWireItr->second, hitPtrPair.second);
1717 std::unordered_map<raw::ChannelID_t, art::Ptr<raw::RawDigit>> channelToRawDigitMap;
1726 if (hitToRawDigitAssns.isValid()) {
1727 for (
size_t rawDigitIdx = 0; rawDigitIdx < hitToRawDigitAssns.size(); rawDigitIdx++) {
1730 channelToRawDigitMap[rawDigit->
Channel()] = rawDigit;
1736 for (
const auto& hitPtrPair : recobHitPtrMap) {
1739 std::unordered_map<raw::ChannelID_t, art::Ptr<raw::RawDigit>>
::iterator chanRawDigitItr =
1740 channelToRawDigitMap.find(channel);
1742 if (!(chanRawDigitItr != channelToRawDigitMap.
end())) {
1743 mf::LogDebug(
"Cluster3D") <<
"** Did not find channel to wire match! Skipping..." 1748 rawDigitAssns.
addSingle(chanRawDigitItr->second, hitPtrPair.second);
PlaneToWireToHitSetMap m_planeToWireToHitSetMap
void initialize(size_t id, unsigned int statusBits, const Eigen::Vector3f &position, float totalCharge, float avePeakTime, float deltaPeakTime, float sigmaPeakTime, float hitChiSquare, float overlapFraction, float chargeAsymmetry, float docaToAxis, float arclenToPoca, const ClusterHit2DVec &hitVec, const std::vector< float > &hitDelTSigVec, const std::vector< geo::WireID > &wireIDVec)
bool makeHitTriplet(reco::ClusterHit3D &pairOut, const reco::ClusterHit3D &pairIn, const reco::ClusterHit2D *hit2) const
Make a 3D HitPair object by checking two hits.
void findGoodTriplets(HitMatchPairVecMap &, HitMatchPairVecMap &, reco::HitPairList &) const
This algorithm takes lists of hit pairs and finds good triplets.
std::vector< float > m_maxDeltaPeakVec
float m_wirePitchScaleFactor
Scaling factor to determine max distance allowed between candidate pairs.
void setWireID(const geo::WireID &wid) const
std::vector< float > m_chiSquare3DVec
std::list< reco::ClusterHit3D > HitPairList
const geo::Geometry * m_geometry
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
unsigned int Nwires(PlaneID const &planeid) const
Returns the total number of wires in the specified plane.
std::vector< float > m_hitAsymmetryVec
void CreateNewRecobHitCollection(art::Event &, reco::HitPairList &, std::vector< recob::Hit > &, RecobHitToPtrMap &)
Create a new 2D hit collection from hits associated to 3D space points.
float getTimeTicks() const
std::vector< float > m_deltaTimeVec
std::vector< size_t > ChannelStatusVec
define data structure for keeping track of channel status
double WireCoordinate(Point_t const &point) const
Returns the coordinate of the point on the plane, in wire units.
const Eigen::Vector3f getPosition() const
bool SetHitTimeOrder(const reco::ClusterHit2D *left, const reco::ClusterHit2D *right)
float RMS() const
RMS of the hit shape, in tick units.
unsigned int NTPC(CryostatID const &cryoid=details::cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
Declaration of signal hit object.
size_t BuildHitPairMapByTPC(PlaneHitVectorItrPairVec &planeHitVectorItrPairVec, reco::HitPairList &hitPairList) const
virtual unsigned int Nchannels() const =0
Returns the total number of channels present (not necessarily contiguous)
The data type to uniquely identify a Plane.
const geo::WireID & WireID() const
ChannelID_t Channel() const
DAQ channel this raw data was read from.
TTree * m_tupleTree
output analysis tree
int findGoodHitPairs(const reco::ClusterHit2D *, HitVector::iterator &, HitVector::iterator &, HitMatchPairVecMap &) const
bool operator()(const reco::ClusterHit2D *, const reco::ClusterHit2D *) const
constexpr auto abs(T v)
Returns the absolute value of the argument.
int DegreesOfFreedom() const
Initial tdc tick for hit.
CryostatID_t Cryostat
Index of cryostat.
void BuildHit3D(reco::HitPairList &hitPairList) const
Given the ClusterHit2D objects, build the HitPairMap.
std::map< geo::WireID, HitMatchPairVec > HitMatchPairVecMap
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
bool makeHitPair(reco::ClusterHit3D &pairOut, const reco::ClusterHit2D *hit1, const reco::ClusterHit2D *hit2, float hitWidthSclFctr=1., size_t hitPairCntr=0) const
Make a HitPair object by checking two hits.
void produces(art::ProducesCollector &) override
Each algorithm may have different objects it wants "produced" so use this to let the top level produc...
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
WireID_t Wire
Index of the wire within its plane.
float getSigmaPeakTime() const
void Hit3DBuilder(art::Event &, reco::HitPairList &, RecobHitToPtrMap &) override
Given a set of recob hits, run DBscan to form 3D clusters.
std::vector< float > m_timeVector
std::map< geo::PlaneID, WireToHitSetMap > PlaneToWireToHitSetMap
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
bool SetPeakHitPairIteratorOrder(const reco::HitPairList::iterator &left, const reco::HitPairList::iterator &right)
const reco::ClusterHit2D * FindBestMatchingHit(const Hit2DSet &hit2DSet, const reco::ClusterHit3D &pair, float pairDeltaTimeLimits) const
A utility routine for finding a 2D hit closest in time to the given pair.
void BuildChannelStatusVec() const
Create the internal channel status vector (assume will eventually be event-by-event) ...
const recob::Hit * getHit() const
float PeakAmplitude() const
The estimated amplitude of the hit at its peak, in ADC units.
double Length() const
Length is associated with z coordinate [cm].
std::vector< float > m_spacePointChargeVec
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
float m_maxHit3DChiSquare
Provide ability to select hits based on "chi square".
bool isValid() const noexcept
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::vector< int > m_smallIndexVec
float getAvePeakTime() const
std::map< size_t, HitVector > HitVectorMap
Class managing the creation of a new recob::Hit object.
void makeWireAssns(const art::Event &, art::Assns< recob::Wire, recob::Hit > &, RecobHitToPtrMap &) const
Create recob::Wire to recob::Hit associations.
geo::WireID NearestWireID(const Eigen::Vector3f &position, const geo::WireID &wireID) const
Jacket the calls to finding the nearest wire in order to intercept the exceptions if out of range...
Helper functions to create a hit.
std::vector< art::InputTag > m_hitFinderTagVec
Data members to follow.
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
std::list< reco::ClusterHit2D > Hit2DList
std::vector< float > m_pairWireDistVec
std::vector< int > m_invalidTPCVec
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
bool m_outputHistograms
Take the time to create and fill some histograms for diagnostics.
std::map< geo::PlaneID, HitVector > PlaneToHitVectorMap
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
float chargeIntegral(float, float, float, int, int) const
Perform charge integration between limits.
Interface for a class providing readout channel mapping to geometry.
StandardHit3DBuilder class definiton.
int FindNumberInRange(const Hit2DSet &hit2DSet, const reco::ClusterHit3D &pair, float range) const
A utility routine for returning the number of 2D hits from the list in a given range.
const geo::WireReadoutGeom * m_wireReadoutGeom
Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
Hit2DList m_clusterHit2DMasterList
void CollectArtHits(const art::Event &evt) const
Extract the ART hits and the ART hit-particle relationships.
float getXPosition() const
TimeValues
enumerate the possible values for time checking if monitoring timing
std::vector< float > m_maxSideVecVec
The geometry of one entire detector, as served by art.
std::vector< HitMatchPair > HitMatchPairVec
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
constexpr auto dot(Vector const &a, OtherVector const &b)
Return cross product of two vectors.
raw::TDCtick_t StartTick() const
Initial tdc tick for hit.
IHit3DBuilder interface class definiton.
bool m_weHaveAllBeenHereBefore
Detector simulation of raw signals on wires.
bool makeDeadChannelPair(reco::ClusterHit3D &pairOut, const reco::ClusterHit3D &pair, size_t maxStatus, size_t minStatus) const
Make a 3D HitPair object from a valid pair and a dead channel in the missing plane.
float DistanceFromPointToHitWire(const Eigen::Vector3f &position, const geo::WireID &wireID) const
Jacket the calls to finding the nearest wire in order to intercept the exceptions if out of range...
void makeRawDigitAssns(const art::Event &, art::Assns< raw::RawDigit, recob::Hit > &, RecobHitToPtrMap &) const
Create raw::RawDigit to recob::Hit associations.
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, Point_t &intersection) const
Computes the intersection between two wires.
unsigned int Nplanes(TPCID const &tpcid=details::tpc_zero) const
Returns the total number of planes in the specified TPC.
const_iterator end() const
This provides an art tool interface definition for tools which construct 3D hits used in 3D clusterin...
std::vector< const reco::ClusterHit2D * > ClusterHit2DVec
std::set< const reco::ClusterHit2D *, Hit2DSetCompare > Hit2DSet
raw::TDCtick_t EndTick() const
Final tdc tick for hit.
const lariov::ChannelStatusProvider * m_channelFilter
std::map< geo::TPCID, PlaneToWireToHitSetMap > TPCToPlaneToWireToHitSetMap
ChannelStatusByPlaneVec m_channelStatus
std::vector< const reco::ClusterHit2D * > HitVector
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
bool operator()(const reco::HitPairClusterMap::iterator &left, const reco::HitPairClusterMap::iterator &right)
std::map< geo::TPCID, PlaneToHitVectorMap > TPCToPlaneToHitVectorMap
float PeakTime() const
Time of the signal peak, in tick units.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
std::pair< const reco::ClusterHit2D *, reco::ClusterHit3D > HitMatchPair
This builds a list of candidate hit pairs from lists of hits on two planes.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::vector< float > m_qualityMetricVec
void setID(const size_t &id) const
virtual std::vector< WireID > ChannelToWire(raw::ChannelID_t channel) const =0
std::vector< ChannelStatusVec > ChannelStatusByPlaneVec
std::vector< std::pair< HitVector::iterator, HitVector::iterator >> PlaneHitVectorItrPairVec
Given the ClusterHit2D objects, build the HitPairMap.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
size_t BuildHitPairMap(PlaneToHitVectorMap &planeToHitVectorMap, reco::HitPairList &hitPairList) const
Given the ClusterHit2D objects, build the HitPairMap.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
int trigger_offset(DetectorClocksData const &data)
StandardHit3DBuilder(fhicl::ParameterSet const &pset)
Constructor.
constexpr WireID()=default
Default constructor: an invalid TPC ID.
2D representation of charge deposited in the TDC/wire plane
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
TPCID_t TPC
Index of the TPC within its cryostat.
TPCGeo const & TPC(TPCID const &tpcid=details::tpc_zero) const
Returns the specified TPC.
second_as<> second
Type of time stored in seconds, in double precision.
std::vector< float > m_maxPullVec
float getTimeToExecute(IHit3DBuilder::TimeValues index) const override
If monitoring, recover the time to execute a particular function.
const ClusterHit2DVec & getHits() const
void clear()
clear the tuple vectors before processing next event
std::unordered_map< const recob::Hit *, art::Ptr< recob::Hit >> RecobHitToPtrMap
Defines a structure mapping art representation to internal.
void WireEndPoints(WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
std::vector< float > m_smallChargeDiffVec
void setPosition(const Eigen::Vector3f &pos) const
bool SetPairStartTimeOrder(const reco::ClusterHit3D &left, const reco::ClusterHit3D &right)
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
Event finding and building.
std::vector< float > m_overlapRangeVec
PlaneToHitVectorMap m_planeToHitVectorMap
std::map< unsigned int, Hit2DSet > WireToHitSetMap
constexpr PlaneID const & asPlaneID() const
Conversion to WireID (for convenience of notation).
unsigned getStatusBits() const
void setStatusBit(unsigned bits) const
std::vector< float > m_overlapFractionVec