7 #include "art/Framework/Core/ModuleMacros.h"
8 #include "art/Framework/Core/EDAnalyzer.h"
149 #include "art/Framework/Principal/Event.h"
150 #include "fhiclcpp/ParameterSet.h"
151 #include "art/Framework/Principal/Handle.h"
152 #include "art/Framework/Services/Registry/ServiceHandle.h"
153 #include "art_root_io/TFileService.h"
154 #include "art_root_io/TFileDirectory.h"
155 #include "messagefacility/MessageLogger/MessageLogger.h"
156 #include "canvas/Persistency/Common/FindManyP.h"
157 #include "canvas/Persistency/Common/FindOneP.h"
163 #include "nusimdata/SimulationBase/MCTruth.h"
167 namespace lar_pandora
185 m_cosmicLabel = pset.get<std::string>(
"CosmicTagModule",
"cosmictagger");
201 mf::LogDebug(
"LArPandora") <<
" *** PFParticleCosmicAna::beginJob() *** " << std::endl;
204 art::ServiceHandle<art::TFileService const>
tfs;
206 m_pRecoTree = tfs->make<TTree>(
"recoTree",
"LAr Cosmic Reco Tree");
238 m_pTrueTree = tfs->make<TTree>(
"trueTree",
"LAr Cosmic True Tree");
266 std::cout <<
" *** PFParticleCosmicAna::analyze(...) *** " << std::endl;
303 std::cout <<
" PFParticles: " << recoParticleVector.size() << std::endl;
322 this->
FillRecoTree(recoParticlesToHits, recoParticlesToTracks, recoTracksToCosmicTags);
327 this->
FillTrueTree(hitVector, trueHitsToParticles, recoHitsToParticles, particlesToTruth, recoParticlesToTracks, recoTracksToCosmicTags);
337 art::ServiceHandle<geo::Geometry const> theGeometry;
339 const double xmin(0.0);
340 const double xmax(2.0 * theGeometry->DetHalfWidth());
341 const double ymin(-theGeometry->DetHalfHeight());
342 const double ymax(+theGeometry->DetHalfHeight());
343 const double zmin(0.0);
344 const double zmax(theGeometry->DetLength());
382 for (PFParticlesToHits::const_iterator iter1 = recoParticlesToHits.begin(), iterEnd1 = recoParticlesToHits.end();
383 iter1 != iterEnd1; ++iter1)
385 const art::Ptr<recob::PFParticle> recoParticle = iter1->first;
387 const HitVector &hitVector = iter1->second;
388 if (hitVector.empty())
391 PFParticlesToTracks::const_iterator iter2 = recoParticlesToTracks.find(recoParticle);
392 if (recoParticlesToTracks.end() == iter2)
396 if (trackVector.empty())
402 m_self = recoParticle->Self();
430 for (TrackVector::const_iterator iter3 = trackVector.begin(), iterEnd3 = trackVector.end(); iter3 != iterEnd3; ++iter3)
432 const art::Ptr<recob::Track>
track = *iter3;
433 const float trackLength(track->Length());
440 const auto &trackVtxPosition = track->Vertex();
441 const auto &trackVtxDirection = track->VertexDirection();
442 const auto &trackEndPosition = track->End();
443 const auto &trackEndDirection = track->EndDirection();
503 for (HitVector::const_iterator iter2 = hitVector.begin(), iterEnd2 = hitVector.end(); iter2 != iterEnd2; ++iter2)
505 const art::Ptr<recob::Hit>
hit = *iter2;
507 HitsToMCParticles::const_iterator iter3 = trueHitsToParticles.find(hit);
508 if (trueHitsToParticles.end() == iter3)
511 const art::Ptr<simb::MCParticle> trueParticle = iter3->second;
513 MCParticlesToMCTruth::const_iterator iter4 = particlesToTruth.find(trueParticle);
514 if (particlesToTruth.end() == iter4)
515 throw cet::exception(
"LArPandora") <<
" PFParticleCosmicAna::analyze --- Found a true particle without any ancestry information ";
517 const art::Ptr<simb::MCTruth> truth = iter4->second;
519 float cosmicScore(-0.2);
521 HitsToPFParticles::const_iterator iter5 = recoHitsToParticles.find(hit);
522 if (recoHitsToParticles.end() != iter5)
524 const art::Ptr<recob::PFParticle> particle = iter5->second;
525 cosmicScore = this->
GetCosmicScore(particle, particlesToTracks, tracksToCosmicTags);
530 if (truth->NeutrinoSet())
562 float cosmicScore(0.f);
565 PFParticlesToTracks::const_iterator iter2 = recoParticlesToTracks.find(particle);
566 if (recoParticlesToTracks.end() != iter2)
568 for (TrackVector::const_iterator iter3 = iter2->second.begin(), iterEnd3 = iter2->second.end(); iter3 != iterEnd3; ++iter3)
570 const art::Ptr<recob::Track>
track = *iter3;
572 TracksToCosmicTags::const_iterator iter4 = recoTracksToCosmicTags.find(track);
573 if (recoTracksToCosmicTags.end() != iter4)
575 for (CosmicTagVector::const_iterator iter5 = iter4->second.begin(), iterEnd5 = iter4->second.end();
576 iter5 != iterEnd5; ++iter5)
578 const art::Ptr<anab::CosmicTag> cosmicTag = *iter5;
579 if (cosmicTag->CosmicScore() > cosmicScore)
580 cosmicScore = cosmicTag->CosmicScore();
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.
std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCParticle > > HitsToMCParticles
PFParticleCosmicAna class.
int m_nNeutrinoHitsSemiTagged
int m_nNeutrinoHitsReconstructed
void FillTrueTree(const HitVector &hitVector, const HitsToMCParticles &trueHitsToParticles, const HitsToPFParticles &recoHitsToParticles, const MCParticlesToMCTruth &particlesToTruth, const PFParticlesToTracks &particlesToTracks, const TracksToCosmicTags &tracksToCosmicTags)
Fill track-level variables using input maps between reconstructed objects.
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
process_name use argoneut_mc_hitfinder track
std::vector< art::Ptr< anab::CosmicTag > > CosmicTagVector
int m_nNeutrinoHitsNotTagged
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
int m_nCosmicHitsNotTagged
int m_nCosmicHitsSemiTagged
std::map< art::Ptr< recob::Track >, CosmicTagVector > TracksToCosmicTags
std::string m_hitfinderLabel
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
void reconfigure(fhicl::ParameterSet const &pset)
std::map< art::Ptr< simb::MCParticle >, HitVector > MCParticlesToHits
int m_nCosmicHitsReconstructed
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
double m_cosmicContainmentCut
std::string m_cosmicLabel
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
std::string m_particleLabel
int m_nNeutrinoHitsNotReconstructed
std::vector< art::Ptr< recob::Track > > TrackVector
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.
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
void FillRecoTree(const PFParticlesToHits &recoParticlesToHits, const PFParticlesToTracks &recoParticlesToTracks, const TracksToCosmicTags &recoTracksToCosmicTags)
Fill event-level variables using input maps between reconstructed objects.
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.
bool m_useDaughterMCParticles
std::string m_geantModuleLabel
std::vector< art::Ptr< recob::Hit > > HitVector
virtual ~PFParticleCosmicAna()
Destructor.
float GetCosmicScore(const art::Ptr< recob::PFParticle > particle, const PFParticlesToTracks &recoParticlesToTracks, const TracksToCosmicTags &recoTracksToCosmicTags) const
Get cosmic score for a PFParticle using track-level information.
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
static bool IsTrack(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as track-like.
std::string m_trackfitLabel
int m_nNeutrinoHitsFullyTagged
int m_nCosmicHitsNotReconstructed
art::ServiceHandle< art::TFileService > tfs
static void BuildMCParticleHitMaps(const art::Event &evt, const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
static void CollectMCParticles(const art::Event &evt, const std::string &label, MCParticleVector &particleVector)
Collect a vector of MCParticle objects from the ART event record.
bool m_useDaughterPFParticles
helper function for LArPandoraInterface producer module
PFParticleCosmicAna(fhicl::ParameterSet const &pset)
Constructor.
int m_nCosmicHitsFullyTagged
art framework interface to geometry description
BEGIN_PROLOG could also be cout
void analyze(const art::Event &evt)
static void CollectCosmicTags(const art::Event &evt, const std::string &label, CosmicTagVector &cosmicTagVector, TracksToCosmicTags &tracksToCosmicTags)
Collect a vector of cosmic tags from the ART event record.