966 if (!recobHitToVoxelIDMap.empty())
969 using Triplet = std::tuple<const recob::Hit*, const recob::Hit*, const recob::Hit*>;
970 using TripletMap = std::map<Triplet,std::vector<const recob::SpacePoint*>>;
972 TripletMap tripletMap;
977 art::Handle< std::vector<recob::SpacePoint>> spacePointHandle;
978 event.getByLabel(spacePointLabel, spacePointHandle);
980 if (!spacePointHandle.isValid())
continue;
983 art::FindManyP<recob::Hit> spHitAssnVec(spacePointHandle, event, spacePointLabel);
987 for(
size_t idx = 0; idx < spacePointHandle->size(); idx++)
989 art::Ptr<recob::SpacePoint> spacePointPtr(spacePointHandle,idx);
991 std::vector<art::Ptr<recob::Hit>> associatedHits(spHitAssnVec.at(spacePointPtr.key()));
993 if (associatedHits.size() != 3)
995 mf::LogDebug(
"SpacePointAnalysisMC") <<
"I am certain this cannot happen... but here you go, space point with " << associatedHits.size() <<
" hits" << std::endl;
1000 float spQuality = spacePointPtr->Chisq();
1001 float spCharge = spacePointPtr->ErrXYZ()[1];
1002 float spAsymmetry = spacePointPtr->ErrXYZ()[3];
1003 float smallestPH = std::numeric_limits<float>::max();
1004 float largestPH = 0.;
1006 float averagePH = 0.;
1007 float averagePT = 0.;
1008 float largestDelT = 0.;
1010 std::vector<int> numIDEsHitVec;
1011 std::vector<int> simHitDeltaTVec = {0,0,0};
1012 std::vector<float> hitPeakTimeVec = {-100.,-100.,-100.};
1013 std::vector<float> bigElecDepVec = {0.,0.,0.};
1014 std::vector<unsigned short> bigTDCVec = {0,0,0};
1015 int numIDEsSpacePoint(0);
1017 int numIntersections(0);
1019 std::vector<RecobHitToVoxelIDMap::const_iterator> recobHitToVoxelIterVec;
1021 std::vector<const recob::Hit*> recobHitVec(3,
nullptr);
1024 for(
const auto& hitPtr : associatedHits)
1026 RecobHitToVoxelIDMap::const_iterator hitToVoxelItr = recobHitToVoxelIDMap.find(hitPtr.get());
1028 float peakAmplitude = hitPtr->PeakAmplitude();
1029 float peakTime = hitPtr->PeakTime();
1030 int plane = hitPtr->WireID().Plane;
1032 recobHitVec[plane] = hitPtr.get();
1035 averagePH += peakAmplitude;
1036 averagePT += peakTime;
1038 smallestPH = std::min(peakAmplitude,smallestPH);
1039 largestPH = std::max(peakAmplitude,largestPH);
1041 if (hitPtr->DegreesOfFreedom() < 2) numLongHits++;
1043 if (hitToVoxelItr == recobHitToVoxelIDMap.end())
1045 numIDEsHitVec.push_back(0);
1049 recobHitToVoxelIterVec.push_back(hitToVoxelItr);
1050 numIDEsHitVec.push_back(hitToVoxelItr->second.size());
1052 hitPeakTimeVec[plane] = clockData.
TPCTick2TDC(peakTime);
1055 Triplet hitTriplet(recobHitVec[0],recobHitVec[1],recobHitVec[2]);
1057 tripletMap[hitTriplet].emplace_back(spacePointPtr.get());
1059 averagePH /= float(numHits);
1060 averagePT /= float(numHits);
1062 for(
const auto& hitPtr : associatedHits)
1064 float delT = hitPtr->PeakTime() - averagePT;
1071 if (recobHitToVoxelIterVec.size() == 3)
1074 std::vector<sim::LArVoxelID> firstIntersectionVec(recobHitToVoxelIterVec[0]->
second.size()+recobHitToVoxelIterVec[1]->second.size());
1076 std::vector<sim::LArVoxelID>::iterator firstIntersectionItr = std::set_intersection(recobHitToVoxelIterVec[0]->
second.begin(),recobHitToVoxelIterVec[0]->second.end(),
1077 recobHitToVoxelIterVec[1]->second.begin(),recobHitToVoxelIterVec[1]->second.end(),
1078 firstIntersectionVec.begin());
1080 firstIntersectionVec.resize(firstIntersectionItr - firstIntersectionVec.begin());
1083 if (!firstIntersectionVec.empty())
1086 std::vector<sim::LArVoxelID> secondIntersectionVec(firstIntersectionVec.size()+recobHitToVoxelIterVec[2]->second.size());
1088 std::vector<sim::LArVoxelID>::iterator secondIntersectionItr = std::set_intersection(firstIntersectionVec.begin(), firstIntersectionVec.end(),
1089 recobHitToVoxelIterVec[2]->second.begin(),recobHitToVoxelIterVec[2]->second.end(),
1090 secondIntersectionVec.begin());
1092 secondIntersectionVec.resize(secondIntersectionItr - secondIntersectionVec.begin());
1098 if (!secondIntersectionVec.empty())
1102 VoxelIDToPlaneTDCIDEMap::const_iterator planeToTDCToIDESetMap = voxelToPlaneTDCIDEMap.find(voxelID);
1104 if (planeToTDCToIDESetMap->second.size() > 2)
1106 numIDEsSpacePoint += 1;
1108 for(
const auto& planeInfoPair : planeToTDCToIDESetMap->second)
1110 unsigned short plane = planeInfoPair.first;
1112 unsigned short tdcBig = 0;
1114 for(
const auto& tdcIDEPair : planeInfoPair.second)
1116 for(
const auto& ide : tdcIDEPair.second)
1118 if (phBig < ide->numElectrons)
1120 phBig = ide->numElectrons;
1121 tdcBig = tdcIDEPair.first;
1126 bigElecDepVec[plane] = phBig;
1127 bigTDCVec[plane] = tdcBig;
1130 else std::cout <<
" --> Not matching all three planes" << std::endl;
1170 std::vector<int> numSpacePointVec = {0,0,0,0,0};
1171 for(
const auto& tripletPair : tripletMap)
1173 int numSpacePoints = std::min(numSpacePointVec.size()-1,tripletPair.second.size());
1174 numSpacePointVec[numSpacePoints]++;
1176 std::cout <<
"====>> Found " << tripletMap.size() <<
" SpacePoints, numbers: ";
std::vector< float > fBigElecDep2Vec
std::vector< float > fBigElecDep1Vec
std::vector< float > fBigElecDep0Vec
std::vector< int > fHitDelta21Vec
std::vector< int > fNumIDEsSpacePointVec
std::vector< float > fAveragePHVec
std::vector< int > fNumIDEsHit0Vec
std::vector< art::InputTag > fSpacePointLabelVec
std::vector< float > fSPQualityVec
std::vector< float > fSmallestPHVec
HitSpacePointObj fHitSpacePointObj
std::vector< int > fNumLongHitsVec
std::vector< float > fSPTotalChargeVec
std::vector< int > fHitDelta10Vec
std::vector< float > fSPAsymmetryVec
std::vector< float > fLargestDelTVec
std::vector< int > fSimHitDeltaT1Vec
std::vector< int > fNumPlanesSimMatchVec
std::vector< int > fSimHitDeltaT0Vec
std::vector< int > fSimDelta21Vec
std::vector< int > fSimDelta10Vec
std::vector< int > fNumIDEsHit2Vec
std::vector< int > fSimHitDeltaT2Vec
std::vector< int > fNumIDEsHit1Vec
std::size_t count(Cont const &cont)
std::vector< int > fNumIntersectSetVec
double TPCTick2TDC(double const tick) const
BEGIN_PROLOG could also be cout
std::vector< float > fLargestPHVec