466 auto const det_prop = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event, clockData);
487 using Triplet = std::tuple<const recob::Hit*, const recob::Hit*, const recob::Hit*>;
488 using TripletMap = std::map<Triplet, std::vector<const recob::SpacePoint*>>;
490 TripletMap tripletMap;
493 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob();
498 art::Handle<std::vector<recob::PFParticle>> pfParticleHandle;
499 event.getByLabel(collectionLabel, pfParticleHandle);
501 if (!pfParticleHandle.isValid())
continue;
503 art::Handle< std::vector<recob::SpacePoint>> spacePointHandle;
504 event.getByLabel(collectionLabel, spacePointHandle);
506 if (!spacePointHandle.isValid())
continue;
509 art::FindManyP<recob::SpacePoint> pfPartSpacePointAssns(pfParticleHandle, event, collectionLabel);
512 art::FindManyP<recob::Hit> spHitAssnVec(spacePointHandle, event, collectionLabel);
515 using PFParticleToNumSPMap = std::map<const recob::PFParticle*,int>;
517 PFParticleToNumSPMap pfParticleToNumSPMap;
519 for(
size_t idx = 0; idx < pfParticleHandle->size(); idx++)
521 art::Ptr<recob::PFParticle> pfParticle(pfParticleHandle,idx);
523 std::vector<art::Ptr<recob::SpacePoint>> spacePointVec(pfPartSpacePointAssns.at(pfParticle.key()));
525 pfParticleToNumSPMap[pfParticle.get()] = spacePointVec.size();
531 art::FindManyP<recob::PFParticle> spacePointPFPartAssns(spacePointHandle, event, collectionLabel);
533 std::unordered_map<const recob::Hit*,int> uniqueHitMap;
537 for(
size_t idx = 0; idx < spacePointHandle->size(); idx++)
540 art::Ptr<recob::SpacePoint> spacePointPtr(spacePointHandle,idx);
542 std::vector<art::Ptr<recob::Hit>> associatedHits(spHitAssnVec.at(spacePointPtr.key()));
544 if (associatedHits.size() < 2)
546 mf::LogDebug(
"SpacePointAnalysis") <<
"I am certain this cannot happen... but here you go, space point with " << associatedHits.size() <<
" hits" << std::endl;
551 int nSpacePointsInPFParticle(0);
553 std::vector<art::Ptr<recob::PFParticle>> pfParticleVec(spacePointPFPartAssns.at(spacePointPtr.key()));
555 if (pfParticleVec.size() == 1) nSpacePointsInPFParticle = pfParticleToNumSPMap.at(pfParticleVec[0].get());
557 mf::LogDebug(
"SpacePointAnalysis") <<
"==> pfPartVec size: " << pfParticleVec.size() <<
", # space points: " << nSpacePointsInPFParticle << std::endl;
560 float spQuality = spacePointPtr->Chisq();
561 float spCharge = spacePointPtr->ErrXYZ()[1];
562 float spAsymmetry = spacePointPtr->ErrXYZ()[3];
563 const Double32_t* spPosition = spacePointPtr->XYZ();
564 float smallestPH = std::numeric_limits<float>::max();
565 float largestPH = 0.;
567 float averagePH = 0.;
568 float averagePT = 0.;
569 float largestDelT = 0.;
570 float smallestDelT = 100000.;
571 std::vector<float> hitPeakTimeVec = {-10000.,-20000.,-30000.};
572 std::vector<float> hitPeakRMSVec = {1000.,1000.,1000.};
573 int hitMultProduct = 1;
575 int numIntersections(0);
579 std::vector<const recob::Hit*> recobHitVec(3,
nullptr);
581 std::vector<float> peakAmpVec;
584 for(
const auto& hitPtr : associatedHits)
586 float peakAmplitude = hitPtr->PeakAmplitude();
587 float peakTime = hitPtr->PeakTime();
588 float rms = hitPtr->RMS();
589 int plane = hitPtr->WireID().Plane;
591 peakAmpVec.emplace_back(peakAmplitude);
594 uniqueHitMap[hitPtr.get()] = nSpacePointsInPFParticle;
596 recobHitVec[plane] = hitPtr.get();
598 averagePH += peakAmplitude;
599 smallestPH = std::min(peakAmplitude,smallestPH);
600 largestPH = std::max(peakAmplitude,largestPH);
602 hitMultProduct *= hitPtr->Multiplicity();
604 if (hitPtr->DegreesOfFreedom() < 2) numLongHits++;
607 hitPeakRMSVec[plane] = rms;
608 averagePT += hitPeakTimeVec[plane];
610 cryostat = hitPtr->WireID().Cryostat;
611 tpc = hitPtr->WireID().TPC;
614 Triplet hitTriplet(recobHitVec[0],recobHitVec[1],recobHitVec[2]);
616 tripletMap[hitTriplet].emplace_back(spacePointPtr.get());
618 averagePH /= float(numHits);
619 averagePT /= float(numHits);
621 for(
size_t planeIdx = 0; planeIdx < 3; planeIdx++)
624 if (hitPeakTimeVec[planeIdx] < 0)
continue;
626 float delT = hitPeakTimeVec[planeIdx] - averagePT;
660 for(
const auto& hitItr : uniqueHitMap)
667 int startTick = std::max( 0,
int(std::floor(peakTime - 3. * rms)));
668 int endTick = std::min(4096,
int(std::ceil( peakTime + 3. * rms)));
675 std::vector<int> numSpacePointVec = {0,0,0,0,0};
676 for(
const auto& tripletPair : tripletMap)
678 int numSpacePoints = std::min(numSpacePointVec.size()-1,tripletPair.second.size());
679 numSpacePointVec[numSpacePoints]++;
681 std::cout <<
"====>> Found " << tripletMap.size() <<
" SpacePoints, numbers: ";
std::vector< float > fHitSigma20Vec
std::vector< int > fClusterNSPVec
std::vector< float > fSPAsymmetryVec
std::vector< float > fHitDelta21Vec
std::vector< float > fHitDelta10Vec
std::vector< float > fHitSigma10Vec
std::vector< float > fSmallestDelTVec
std::vector< float > fHitSigma21Vec
geo::WireID WireID() const
The data type to uniquely identify a Plane.
std::vector< int > fHitMultProductVec
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
std::vector< float > fSPTotalChargeVec
std::vector< art::InputTag > fSpacePointLabelVec
std::vector< int > fSPCryostatVec
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
const geo::GeometryCore * fGeometry
pointer to Geometry service
std::vector< float > fSP_y
HitSpacePointObj fHitSpacePointObj
PlaneToT0OffsetMap fPlaneToT0OffsetMap
std::vector< float > fSP_x
PlaneID_t Plane
Index of the plane within its TPC.
std::vector< float > fSPQualityVec
std::vector< float > fLargestPHVec
std::vector< int > fNum2DHitsVec
std::vector< float > fAveragePHVec
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
float PeakTime() const
Time of the signal peak, in tick units.
std::vector< int > fNumIntersectSetVec
std::vector< float > fSP_z
std::vector< float > fLargestDelTVec
2D representation of charge deposited in the TDC/wire plane
std::size_t count(Cont const &cont)
HitTuplebjVec fHitTupleObjVec
std::vector< int > fNumLongHitsVec
std::vector< int > fSPTPCVec
std::vector< float > fHitDelta20Vec
BEGIN_PROLOG could also be cout
std::vector< float > fSmallestPHVec