8 #include "art/Framework/Core/EDAnalyzer.h"
9 #include "art/Framework/Core/ModuleMacros.h"
21 namespace lar_pandora {
114 double YZtoU(
const unsigned int cstat,
115 const unsigned int tpc,
117 const double z)
const;
127 double YZtoV(
const unsigned int cstat,
128 const unsigned int tpc,
130 const double z)
const;
180 #include "art/Framework/Principal/Event.h"
181 #include "art/Framework/Principal/Handle.h"
182 #include "art/Framework/Services/Registry/ServiceHandle.h"
183 #include "art_root_io/TFileDirectory.h"
184 #include "art_root_io/TFileService.h"
185 #include "fhiclcpp/ParameterSet.h"
186 #include "messagefacility/MessageLogger/MessageLogger.h"
202 #include "nusimdata/SimulationBase/MCParticle.h"
203 #include "nusimdata/SimulationBase/MCTruth.h"
207 namespace lar_pandora {
224 m_trackLabel = pset.get<std::string>(
"TrackModule",
"pandoraTrack");
225 m_showerLabel = pset.get<std::string>(
"ShowerModule",
"pandoraShower");
226 m_particleLabel = pset.get<std::string>(
"PFParticleModule",
"pandora");
228 m_clusterLabel = pset.get<std::string>(
"ClusterModule",
"pandora");
230 m_calwireLabel = pset.get<std::string>(
"CalWireModule",
"caldata");
239 mf::LogDebug(
"LArPandora") <<
" *** PFParticleHitDumper::beginJob() *** " << std::endl;
242 art::ServiceHandle<art::TFileService const>
tfs;
244 m_pRecoTracks = tfs->make<TTree>(
"pandoraTracks",
"LAr Reco Tracks");
252 m_pReco3D = tfs->make<TTree>(
"pandora3D",
"LAr Reco 3D");
267 m_pReco2D = tfs->make<TTree>(
"pandora2D",
"LAr Reco 2D");
280 m_pRecoComparison = tfs->make<TTree>(
"pandora2Dcomparison",
"LAr Reco 2D (comparison)");
291 m_pRecoWire = tfs->make<TTree>(
"rawdata",
"LAr Reco Wires");
342 art::ServiceHandle<geo::Geometry const> theGeometry;
376 LArPandoraHelper::DaughterMode::kUseDaughters,
393 this->
FillReco3D(particleVector, particlesToSpacePoints, spacePointsToHits);
398 this->
FillReco2D(evt, hitVector, hitsToParticles);
403 std::cout <<
" PFParticleHitDumper::FillAssociated2DHits(...) " << std::endl;
407 particlesToHitsClusters,
434 for (PFParticlesToTracks::const_iterator iter = particlesToTracks.begin(),
435 iterEnd = particlesToTracks.end();
438 const art::Ptr<recob::PFParticle> particle = iter->first;
443 if (!trackVector.empty()) {
445 std::cout <<
" Warning: Found particle with more than one associated track " << std::endl;
447 const art::Ptr<recob::Track>
track = *(trackVector.begin());
451 <<
" Trajectory Points)" << std::endl;
453 for (
unsigned int p = 0;
p < track->NumberTrajectoryPoints(); ++
p) {
454 const auto position(track->LocationAtPoint(
p));
486 if (particleVector.empty()) {
m_pReco3D->Fill(); }
491 for (
unsigned int i = 0; i < particleVector.size(); ++i) {
492 const art::Ptr<recob::PFParticle> particle = particleVector.at(i);
493 theParticleMap[particle->Self()] = particle;
497 for (PFParticlesToSpacePoints::const_iterator iter1 = particlesToSpacePoints.begin(),
498 iterEnd1 = particlesToSpacePoints.end();
501 const art::Ptr<recob::PFParticle> particle = iter1->first;
508 if (particle->IsPrimary()) {
m_primary = 1; }
510 const size_t parentID(particle->Parent());
511 PFParticleMap::const_iterator pIter = theParticleMap.find(parentID);
512 if (theParticleMap.end() == pIter)
513 throw cet::exception(
"LArPandora")
514 <<
" PFParticleHitDumper::analyze --- Found particle with ID code";
516 const art::Ptr<recob::PFParticle> particleParent = pIter->second;
522 << spacepoints.size() <<
" Space Points)" << std::endl;
524 for (
unsigned int j = 0; j < spacepoints.size(); ++j) {
525 const art::Ptr<recob::SpacePoint> spacepoint = spacepoints.at(j);
527 m_x = spacepoint->XYZ()[0];
528 m_y = spacepoint->XYZ()[1];
529 m_z = spacepoint->XYZ()[2];
531 SpacePointsToHits::const_iterator iter2 = spacePointsToHits.find(spacepoint);
532 if (spacePointsToHits.end() == iter2)
533 throw cet::exception(
"LArPandora")
534 <<
" PFParticleHitDumper::analyze --- Found space point without associated hit";
536 const art::Ptr<recob::Hit>
hit = iter2->second;
566 for (
unsigned int i = 0; i < particleVector.size(); ++i) {
574 const art::Ptr<recob::PFParticle> particle = particleVector.at(i);
578 PFParticlesToHits::const_iterator pIter = particlesToHits.find(particle);
579 PFParticlesToHits::const_iterator pIter2 = particlesToHitsClusters.find(particle);
581 if (particlesToHitsClusters.end() != pIter2)
m_hitsFromClusters = pIter2->second.size();
584 PFParticlesToTracks::const_iterator iter = particlesToTracks.find(particle);
585 const art::Ptr<recob::Track>
track = *(iter->second.begin());
587 TracksToHits::const_iterator iter2 = tracksToHits.find(track);
588 if (tracksToHits.end() != iter2) {
589 const HitVector& hitVector = iter2->second;
594 PFParticlesToShowers::const_iterator iter = particlesToShowers.find(particle);
595 const art::Ptr<recob::Shower>
shower = *(iter->second.begin());
597 ShowersToHits::const_iterator iter2 = showersToHits.find(shower);
598 if (showersToHits.end() != iter2) {
599 const HitVector& hitVector = iter2->second;
607 <<
" hits from clusters, and its recob::Track/Shower has "
633 if (hitVector.empty()) {
m_pReco2D->Fill(); }
636 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
639 for (
unsigned int i = 0; i < hitVector.size(); ++i) {
640 const art::Ptr<recob::Hit>
hit = hitVector.at(i);
645 HitsToPFParticles::const_iterator pIter = hitsToParticles.find(hit);
646 if (hitsToParticles.end() != pIter) {
647 const art::Ptr<recob::PFParticle> particle = pIter->second;
658 m_q = hit->Integral();
659 m_x =
detProp.ConvertTicksToX(hit->PeakTime(), wireID.Plane, wireID.TPC, wireID.Cryostat);
676 art::ServiceHandle<geo::Geometry const> theGeometry;
679 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(e);
682 int signalCounter(0);
684 for (
unsigned int i = 0; i < wireVector.size(); ++i) {
685 const art::Ptr<recob::Wire> wire = wireVector.at(i);
687 const std::vector<float>& signals(wire->Signal());
688 const std::vector<geo::WireID> wireIds = theGeometry->ChannelToWire(wire->Channel());
691 std::cout <<
" numWires=" << wireVector.size() <<
" numSignals=" << signals.size()
698 for (std::vector<float>::const_iterator tIter = signals.begin(), tIterEnd = signals.end();
707 for (std::vector<geo::WireID>::const_iterator wIter = wireIds.begin(),
708 wIterEnd = wireIds.end();
732 art::ServiceHandle<geo::Geometry const> theGeometry;
735 theGeometry->Cryostat(wireID.
Cryostat)
740 const double ay(xyzStart[1]);
741 const double az(xyzStart[2]);
744 theGeometry->Cryostat(wireID.
Cryostat)
749 const double by(xyzEnd[1]);
750 const double bz(xyzEnd[2]);
752 const double ny(by - ay);
753 const double nz(bz - az);
754 const double N2(ny * ny + nz * nz);
756 const double ry(ay - (ay * ny + az * nz) * ny / N2);
757 const double rz(az - (ay * ny + az * nz) * nz / N2);
758 const double sign((rz > 0.0) ? +1.0 : -1.0);
760 return sign * std::sqrt(ry * ry + rz * rz);
767 const unsigned int tpc,
769 const double z)
const
772 art::ServiceHandle<geo::Geometry const> theGeometry;
773 const double m_theta(theGeometry->WireAngleToVertical(
geo::kU, tpc, cstat));
774 return z * std::sin(m_theta) - y * std::cos(m_theta);
781 const unsigned int tpc,
783 const double z)
const
786 art::ServiceHandle<geo::Geometry const> theGeometry;
787 const double m_theta(theGeometry->WireAngleToVertical(
geo::kV, tpc, cstat));
788 return z * std::sin(m_theta) - y * std::cos(m_theta);
static void BuildPFParticleHitMaps(const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
Build mapping between PFParticles and Hits using PFParticle/SpacePoint/Hit maps.
void FillReco2D(const art::Event &event, const HitVector &hitVector, const HitsToPFParticles &hitsToParticles)
Store 2D hits.
process_name opflash particleana ie ie ie z
double YZtoU(const unsigned int cstat, const unsigned int tpc, const double y, const double z) const
Convert from (Y,Z) to U coordinate.
void analyze(const art::Event &evt)
Encapsulate the construction of a single cyostat.
int m_hitsFromTrackOrShower
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
std::string m_hitfinderLabel
Declaration of signal hit object.
double YZtoV(const unsigned int cstat, const unsigned int tpc, const double y, const double z) const
Convert from (Y,Z) to V coordinate.
virtual ~PFParticleHitDumper()
Destructor.
static void CollectWires(const art::Event &evt, const std::string &label, WireVector &wireVector)
Collect the reconstructed wires from the ART event record.
CryostatID_t Cryostat
Index of cryostat.
std::vector< art::Ptr< recob::Shower > > ShowerVector
WireID_t Wire
Index of the wire within its plane.
TTree * m_pRecoComparison
process_name use argoneut_mc_hitfinder track
void FillRecoWires(const art::Event &event, const WireVector &wireVector)
Store raw data.
std::string m_calwireLabel
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
double GetUVW(const geo::WireID &wireID) const
Conversion from wire ID to U/V/W coordinate.
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
static void CollectSpacePoints(const art::Event &evt, const std::string &label, SpacePointVector &spacePointVector, SpacePointsToHits &spacePointsToHits)
Collect the reconstructed SpacePoints and associated hits from the ART event record.
void FillAssociated2DHits(const art::Event &evt, const PFParticleVector &particleVector, const PFParticlesToHits &particlesToHits, const PFParticlesToHits &particlesToHitsClusters, const PFParticlesToTracks &particlesToTracks, const TracksToHits &tracksToHits, const PFParticlesToShowers &particlesToShowers, const ShowersToHits &showersToHits)
Store number of 2D hits associated to PFParticle in different ways.
bool m_printDebug
switch for print statements (TODO: use message service!)
std::map< art::Ptr< recob::PFParticle >, ShowerVector > PFParticlesToShowers
process_name opflash particleana ie ie y
PFParticleHitDumper class.
void reconfigure(fhicl::ParameterSet const &pset)
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
PFParticleHitDumper(fhicl::ParameterSet const &pset)
Constructor.
std::map< art::Ptr< recob::Shower >, HitVector > ShowersToHits
static void CollectShowers(const art::Event &evt, const std::string &label, ShowerVector &showerVector, PFParticlesToShowers &particlesToShowers)
Collect the reconstructed PFParticles and associated Showers from the ART event record.
std::vector< art::Ptr< recob::SpacePoint > > SpacePointVector
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
void FillReco3D(const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits)
Store 3D hits.
std::vector< art::Ptr< recob::Track > > TrackVector
std::string m_spacepointLabel
PlaneID_t Plane
Index of the plane within its TPC.
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
Declaration of cluster object.
std::map< art::Ptr< recob::Track >, HitVector > TracksToHits
static void CollectTracks(const art::Event &evt, const std::string &label, TrackVector &trackVector, PFParticlesToTracks &particlesToTracks)
Collect the reconstructed PFParticles and associated Tracks from the ART event record.
Definition of data types for geometry description.
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
std::string m_clusterLabel
Provides recob::Track data product.
static void CollectHits(const art::Event &evt, const std::string &label, HitVector &hitVector)
Collect the reconstructed Hits from the ART event record.
void FillRecoTracks(const PFParticlesToTracks &particlesToTracks)
Store 3D track hits.
std::vector< art::Ptr< recob::Hit > > HitVector
Encapsulate the construction of a single detector plane.
std::vector< art::Ptr< recob::Wire > > WireVector
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
Declaration of basic channel signal object.
int m_hitsFromSpacePoints
std::string m_particleLabel
art::ServiceHandle< art::TFileService > tfs
TPCID_t TPC
Index of the TPC within its cryostat.
helper function for LArPandoraInterface producer module
std::string m_showerLabel
art framework interface to geometry description
BEGIN_PROLOG could also be cout
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > SpacePointsToHits
Encapsulate the construction of a single detector plane.