Interface for filling histograms.
390 art::Handle< std::vector<sim::SimChannel>> simChannelHandle;
394 if (!simChannelHandle.isValid() || simChannelHandle->empty())
return;
396 art::Handle< std::vector<raw::RawDigit> > rawDigitHandle;
399 art::Handle< std::vector<recob::Wire> > wireHandle;
402 art::Handle< std::vector<recob::Hit> > hitHandle;
405 art::Handle< std::vector<simb::MCParticle>> mcParticleHandle;
408 if (!rawDigitHandle.isValid() || !wireHandle.isValid() || !hitHandle.isValid() || !mcParticleHandle.isValid())
return;
411 art::Handle< std::vector<int>> badChannelHandle;
423 using ChanToWireMap = std::unordered_map<raw::ChannelID_t,const recob::Wire*>;
425 ChanToWireMap channelToWireMap;
427 for(
const auto& wire : *wireHandle) channelToWireMap[wire.Channel()] = &wire;
431 using ChanToRawDigitMap = std::unordered_map<raw::ChannelID_t,const raw::RawDigit*>;
433 ChanToRawDigitMap chanToRawDigitMap;
435 for(
const auto& rawDigit : *rawDigitHandle) chanToRawDigitMap[rawDigit.Channel()] = &rawDigit;
439 using ChanToHitVecMap = std::unordered_map<raw::ChannelID_t,std::vector<const recob::Hit*>>;
440 ChanToHitVecMap channelToHitVec;
442 for(
const auto&
hit : *hitHandle) channelToHitVec[
hit.Channel()].push_back(&
hit);
445 using TrackIDToMCParticleMap = std::unordered_map<int, const simb::MCParticle*>;
447 TrackIDToMCParticleMap trackIDToMCParticleMap;
449 for(
const auto& mcParticle : *mcParticleHandle) trackIDToMCParticleMap[mcParticle.TrackId()] = &mcParticle;
456 using TDCToIDEMap = std::map<unsigned short, sim::IDE>;
457 using ChanToTDCToIDEMap = std::map<raw::ChannelID_t, TDCToIDEMap>;
458 using PartToChanToTDCToIDEMap = std::unordered_map<int, ChanToTDCToIDEMap>;
460 PartToChanToTDCToIDEMap partToChanToTDCToIDEMap;
463 for(
const auto& simChannel : *simChannelHandle)
465 for(
const auto& tdcide : simChannel.TDCIDEMap())
467 for(
const auto& ide : tdcide.second) partToChanToTDCToIDEMap[ide.trackID][simChannel.Channel()][tdcide.first] = ide;
471 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(event);
474 std::vector<int> nSimChannelHitVec = {0,0,0};
475 std::vector<int> nRecobHitVec = {0,0,0};
477 for(
const auto& partToChanInfo : partToChanToTDCToIDEMap)
479 TrackIDToMCParticleMap::const_iterator trackIDToMCPartItr = trackIDToMCParticleMap.find(partToChanInfo.first);
481 if (trackIDToMCPartItr == trackIDToMCParticleMap.end())
continue;
483 int trackPDGCode = trackIDToMCPartItr->second->PdgCode();
484 std::string processName = trackIDToMCPartItr->second->Process();
487 if (fabs(trackPDGCode) != 13 || processName !=
"primary")
continue;
490 Eigen::Vector3f partStartPos(trackIDToMCPartItr->second->Vx(),trackIDToMCPartItr->second->Vy(),trackIDToMCPartItr->second->Vz());
491 Eigen::Vector3f partStartDir(trackIDToMCPartItr->second->Px(),trackIDToMCPartItr->second->Py(),trackIDToMCPartItr->second->Pz());
493 partStartDir.normalize();
495 Eigen::Vector2f partStartDirVecXZ(partStartDir[0],partStartDir[2]);
497 partStartDirVecXZ.normalize();
501 std::vector<Eigen::Vector3f> lastPositionVec = {partStartPos,partStartPos,partStartPos};
503 for(
const auto& chanToTDCToIDEMap : partToChanInfo.second)
519 if (badChannelHandle.isValid())
522 std::vector<int>::const_iterator badItr = std::find(badChannelHandle->begin(),badChannelHandle->end(),chanToTDCToIDEMap.first);
524 if (badItr != badChannelHandle->end())
continue;
545 TDCToIDEMap tdcToIDEMap = chanToTDCToIDEMap.second;
546 float totalElectrons(0.);
547 float maxElectrons(0.);
548 unsigned short maxElectronsTDC(0);
549 int nMatchedWires(0);
557 unsigned int plane = wids[0].Plane;
560 Eigen::Vector3f avePosition(0.,0.,0.);
562 for(
const auto& ideVal : tdcToIDEMap)
564 totalElectrons += ideVal.second.numElectrons;
566 if (maxElectrons < ideVal.second.numElectrons)
568 maxElectrons = ideVal.second.numElectrons;
569 maxElectronsTDC = ideVal.first;
572 avePosition += Eigen::Vector3f(ideVal.second.x,ideVal.second.y,ideVal.second.z);
577 avePosition /= float(tdcToIDEMap.size());
579 Eigen::Vector3f partDirVec = avePosition - lastPositionVec[plane];
581 partDirVec.normalize();
583 lastPositionVec[plane] = avePosition;
586 Eigen::Vector2f projPairDirVec(partDirVec[0],partDirVec[2]);
588 projPairDirVec.normalize();
590 float cosThetaXZ = projPairDirVec[0];
592 totalElectrons = std::min(totalElectrons,
float(99900.));
597 nSimChannelHitVec[plane]++;
599 unsigned short startTDC = tdcToIDEMap.begin()->first;
600 unsigned short stopTDC = tdcToIDEMap.rbegin()->first;
603 unsigned short startTick = clockData.TPCTDC2Tick(startTDC) +
fOffsetVec[plane];
604 unsigned short stopTick = clockData.TPCTDC2Tick(stopTDC) +
fOffsetVec[plane];
605 unsigned short maxETick = clockData.TPCTDC2Tick(maxElectronsTDC) +
fOffsetVec[plane];
610 float nElectronsTotalBest(0.);
611 float hitSummedADCBest(0.);
612 float hitIntegralBest(0.);
613 float hitPeakTimeBest(0.);
614 float hitPeakAmpBest(-100.);
615 float hitRMSBest(0.);
616 int hitMultiplicityBest(0);
617 int hitLocalIndexBest(0);
618 float hitGoodnessBest(0.);
619 int hitNumDegreesBest(0);
620 float hitBaselineBest(0.);
621 float hitSnippetLenBest(0.);
622 unsigned short hitStopTickBest(0);
623 unsigned short hitStartTickBest(0);
627 ChanToWireMap::const_iterator wireItr = channelToWireMap.find(chanToTDCToIDEMap.first);
629 if (wireItr != channelToWireMap.end())
635 for(
const auto& range : signalROI.
get_ranges())
642 const std::vector<float>& signal = range.data();
647 if (roiFirstBinTick > stopTick || roiLastBinTick < startTick)
continue;
649 wireRangePtr = ⦥
664 ChanToHitVecMap::iterator hitIter = channelToHitVec.find(chanToTDCToIDEMap.first);
666 if (hitIter != channelToHitVec.end())
672 for(
const auto&
hit : hitIter->second)
674 unsigned short hitStartTick =
hit->PeakTime() -
fSigmaVec[plane] *
hit->RMS();
675 unsigned short hitStopTick =
hit->PeakTime() +
fSigmaVec[plane] *
hit->RMS();
679 if (hitStartTick > stopTick || hitStopTick < startTick)
681 if (plane == 2) rejectedHit =
hit;
685 float hitHeight =
hit->PeakAmplitude();
688 if (hitHeight < hitPeakAmpBest)
continue;
690 hitPeakAmpBest = hitHeight;
692 hitStartTickBest = hitStartTick;
693 hitStopTickBest = hitStopTick;
700 nElectronsTotalBest = 0.;
701 hitPeakTimeBest = bestHit->
PeakTime();
702 hitIntegralBest = bestHit->
Integral();
704 hitRMSBest = bestHit->
RMS();
710 hitBaselineBest = 0.;
715 for(
unsigned short tick = hitStartTickBest;
tick <= hitStopTickBest;
tick++)
717 unsigned short hitTDC = clockData.TPCTick2TDC(
tick -
fOffsetVec[plane]);
719 TDCToIDEMap::iterator ideIterator = tdcToIDEMap.find(hitTDC);
721 if (ideIterator != tdcToIDEMap.end()) nElectronsTotalBest += ideIterator->second.numElectrons;
725 if (nMatchedHits > 0)
727 float chgRatioADC = hitSummedADCBest > 0. ? totalElectrons / hitSummedADCBest : 0.;
728 float chgRatioInt = hitIntegralBest > 0. ? totalElectrons / hitIntegralBest : 0.;
734 fHitVsSimChgVec[plane]->Fill(std::min(hitSummedADCBest,
float(999.)), totalElectrons, 1.);
735 fHitVsSimIntVec[plane]->Fill(std::min(hitIntegralBest,
float(999.)), totalElectrons, 1.);
736 fToteVHitEIntVec[plane]->Fill(std::min(totalElectrons,
float(99999.)),std::min(nElectronsTotalBest,
float(99999.)),1.);
740 fHitNumTDCVec[plane]->Fill(std::min(
float(hitStopTickBest - hitStartTickBest),
float(99.5)), 1.);
741 fSnippetLenVec[plane]->Fill(std::min(hitSnippetLenBest,
float(99.5)), 1.);
744 nRecobHitVec[plane]++;
746 else if (rejectedHit)
751 mf::LogDebug(
"HitFinderAnalysis") <<
"**> TPC: " << rejectedHit->
WireID().
TPC <<
", Plane " << rejectedHit->
WireID().
Plane <<
", wire: " << rejectedHit->
WireID().
Wire <<
", hit start/stop tick: " << hitStartTick <<
"/" << hitStopTick <<
", start/stop ticks: " << startTick <<
"/" << stopTick << std::endl;
752 mf::LogDebug(
"HitFinderAnalysis") <<
" TPC/Plane/Wire: " << wids[0].TPC <<
"/" << plane <<
"/" << wids[0].Wire <<
", Track # hits: " << partToChanInfo.second.size() <<
", # hits: " << hitIter->second.size() <<
", # electrons: " << totalElectrons <<
", pulse Height: " << rejectedHit->
PeakAmplitude() <<
", charge: " << rejectedHit->
Integral() <<
", " << rejectedHit->
SummedADC() << std::endl;
756 mf::LogDebug(
"HitFinderAnalysis") <<
"==> No match, TPC/Plane/Wire: " <<
"/" << wids[0].TPC <<
"/" << wids[0].Plane <<
"/" << wids[0].Wire <<
", # electrons: " << totalElectrons <<
", startTick: " << startTick <<
", stopTick: " << stopTick << std::endl;
762 fWireEfficVec.at(plane)->Fill(totalElectrons, std::min(nMatchedWires,1), 1.);
763 fWireEfficPHVec.at(plane)->Fill(maxElectrons, std::min(nMatchedWires,1), 1.);
765 float matchHit = std::min(nMatchedHits,1);
766 float snippetLen = std::min(
float(stopTick - startTick),
float(99.5));
769 fHitEfficVec[plane]->Fill(totalElectrons, matchHit, 1.);
775 fHitENEvXZVec[plane]->Fill(cosThetaXZ, totalElectrons, matchHit);
779 fCryoVec.push_back(wids[0].Cryostat);
812 if (nSimChannelHitVec[idx] > 10)
814 float hitEfficiency = float(nRecobHitVec[idx]) / float(nSimChannelHitVec[idx]);
817 fNRecobHitVec[idx]->Fill(std::min(nRecobHitVec[idx],1999), 1.);
std::vector< TH1F * > fSimDivHitChgVec
art::InputTag fBadChannelProducerLabel
short int LocalIndex() const
How well do we believe we know this hit?
std::vector< int > fWireVec
std::vector< float > fHitPeakAmpVec
BEGIN_PROLOG true icarus_rawdigitfilter FilterTools FilterPlane1 Plane
std::vector< int > fNumDegreesVec
std::vector< int > fTPCVec
std::vector< TH1F * > fMaxElectronsHistVec
std::vector< TProfile * > fHitEfficXZVec
std::vector< int > fHitMultiplicityVec
std::vector< TProfile * > fCosXZvRMSVec
std::vector< TH1F * > fHitSumADCVec
std::vector< float > fHitGoodnessVec
std::vector< int > fOffsetVec
Allow offsets for each plane.
geo::WireID WireID() const
float RMS() const
RMS of the hit shape, in tick units.
std::vector< TProfile * > fWireEfficPHVec
std::vector< int > fStopTickVec
std::vector< TProfile * > fHitEfficPHVec
std::vector< int > fCryoVec
std::vector< float > fSigmaVec
Window size for matching to SimChannels.
int DegreesOfFreedom() const
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
std::vector< int > fHitLocalIndexVec
art::InputTag fHitProducerLabel
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.
std::vector< TProfile * > fHitEfficRMSVec
art::InputTag fSimChannelProducerLabel
float GoodnessOfFit() const
Degrees of freedom in the determination of the hit signal shape (-1 by default)
short int Multiplicity() const
How many hits could this one be shared with.
std::vector< int > fMaxETickVec
std::vector< TH2F * > fHitVsSimChgVec
float PeakAmplitude() const
The estimated amplitude of the hit at its peak, in ADC units.
std::vector< TH1F * > fNMatchedHitVec
std::vector< TH1F * > fNSimChannelHitsVec
int TDCtick_t
Type representing a TDC tick.
std::vector< int > fHitStopTickVec
std::vector< TH1F * > fHitEfficiencyVec
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
std::vector< TProfile * > fWireEfficVec
std::vector< TH1F * > fSimNumTDCVec
std::vector< float > fHitSummedADCVec
std::vector< float > fPartDirY
std::vector< int > fStartTickVec
std::vector< TProfile * > fHitEfficVec
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
virtual Status_t Status(raw::ChannelID_t channel) const
Returns a status integer with arbitrary meaning.
const geo::GeometryCore * fGeometry
pointer to Geometry service
Class providing information about the quality of channels.
PlaneID_t Plane
Index of the plane within its TPC.
std::vector< float > fTotalElectronsVec
std::vector< float > fPartDirZ
std::vector< float > fHitIntegralVec
raw::TDCtick_t StartTick() const
Initial tdc tick for hit.
std::vector< TProfile2D * > fHitENEvXZVec
std::vector< TH1F * > fDeltaMidTDCVec
raw::TDCtick_t EndTick() const
Final tdc tick for hit.
std::vector< float > fPartDirX
art::InputTag fRawDigitProducerLabel
std::vector< int > fNMatchedHits
float PeakTime() const
Time of the signal peak, in tick units.
std::vector< TH1F * > fTotalElectronsHistVec
std::vector< float > fHitBaselinevec
std::vector< TH1F * > fHitElectronsVec
std::vector< int > fPlaneVec
std::vector< TH1F * > fHitNumTDCVec
std::vector< int > fHitStartTickVec
Range class, with range and data.
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
std::vector< TH1F * > fHitPulseWidthVec
std::vector< float > fHitPeakTimeVec
std::vector< TH2F * > fToteVHitEIntVec
2D representation of charge deposited in the TDC/wire plane
std::vector< TH1F * > fHitPulseHeightVec
std::vector< TH1F * > fHitIntegralHistVec
int fMinAllowedChanStatus
Don't consider channels with lower status.
std::vector< TH1F * > fNRecobHitVec
TPCID_t TPC
Index of the TPC within its cryostat.
std::vector< TH1F * > fSimDivHitChg1Vec
std::vector< TH2F * > fHitVsSimIntVec
std::vector< TH1F * > fSnippetLenVec
std::vector< float > fHitPeakRMSVec
art::InputTag fMCParticleProducerLabel
art::InputTag fWireProducerLabel
std::vector< int > fNMatchedWires
std::vector< float > fMaxElectronsVec