LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
LArPandora.cxx
Go to the documentation of this file.
1 
10 #include "cetlib/cpu_timer.h"
11 
14 
16 
26 
28 
29 #include "Api/PandoraApi.h"
30 
33 
38 
39 #include <iostream>
40 #include <limits>
41 
42 namespace lar_pandora
43 {
44 
46  ILArPandora(pset),
47  m_configFile(pset.get<std::string>("ConfigFile")),
48  m_shouldRunAllHitsCosmicReco(pset.get<bool>("ShouldRunAllHitsCosmicReco")),
49  m_shouldRunStitching(pset.get<bool>("ShouldRunStitching")),
50  m_shouldRunCosmicHitRemoval(pset.get<bool>("ShouldRunCosmicHitRemoval")),
51  m_shouldRunSlicing(pset.get<bool>("ShouldRunSlicing")),
52  m_shouldRunNeutrinoRecoOption(pset.get<bool>("ShouldRunNeutrinoRecoOption")),
53  m_shouldRunCosmicRecoOption(pset.get<bool>("ShouldRunCosmicRecoOption")),
54  m_shouldPerformSliceId(pset.get<bool>("ShouldPerformSliceId")),
55  m_printOverallRecoStatus(pset.get<bool>("PrintOverallRecoStatus", false)),
56  m_generatorModuleLabel(pset.get<std::string>("GeneratorModuleLabel", "")),
57  m_geantModuleLabel(pset.get<std::string>("GeantModuleLabel", "largeant")),
58  m_hitfinderModuleLabel(pset.get<std::string>("HitFinderModuleLabel")),
59  m_backtrackerModuleLabel(pset.get<std::string>("BackTrackerModuleLabel","")),
60  m_enableProduction(pset.get<bool>("EnableProduction", true)),
61  m_enableDetectorGaps(pset.get<bool>("EnableLineGaps", true)),
62  m_enableMCParticles(pset.get<bool>("EnableMCParticles", false)),
63  m_lineGapsCreated(false)
64 {
65  m_inputSettings.m_useHitWidths = pset.get<bool>("UseHitWidths", true);
66  m_inputSettings.m_useBirksCorrection = pset.get<bool>("UseBirksCorrection", false);
67  m_inputSettings.m_uidOffset = pset.get<int>("UidOffset", 100000000);
68  m_inputSettings.m_dx_cm = pset.get<double>("DefaultHitWidth", 0.5);
69  m_inputSettings.m_int_cm = pset.get<double>("InteractionLength", 84.);
70  m_inputSettings.m_rad_cm = pset.get<double>("RadiationLength", 14.);
71  m_inputSettings.m_dEdX_mip = pset.get<double>("dEdXmip", 2.);
72  m_inputSettings.m_mips_max = pset.get<double>("MipsMax", 50.);
73  m_inputSettings.m_mips_if_negative = pset.get<double>("MipsIfNegative", 0.);
74  m_inputSettings.m_mips_to_gev = pset.get<double>("MipsToGeV", 3.5e-4);
75  m_inputSettings.m_recombination_factor = pset.get<double>("RecombinationFactor", 0.63);
78 
80  {
81  produces< std::vector<recob::PFParticle> >();
82  produces< std::vector<recob::SpacePoint> >();
83  produces< std::vector<recob::Cluster> >();
84  produces< std::vector<recob::Vertex> >();
85  produces< std::vector<larpandoraobj::PFParticleMetadata> >();
86 
87  produces< art::Assns<recob::PFParticle, larpandoraobj::PFParticleMetadata> >();
88  produces< art::Assns<recob::PFParticle, recob::SpacePoint> >();
89  produces< art::Assns<recob::PFParticle, recob::Cluster> >();
90  produces< art::Assns<recob::PFParticle, recob::Vertex> >();
91  produces< art::Assns<recob::SpacePoint, recob::Hit> >();
92  produces< art::Assns<recob::Cluster, recob::Hit> >();
93 
95  {
96  produces< std::vector<anab::T0> >();
97  produces< art::Assns<recob::PFParticle, anab::T0> >();
98  }
99  }
100 }
101 
102 //------------------------------------------------------------------------------------------------------------------------------------------
103 
105 {
106  LArDriftVolumeList driftVolumeList;
108 
109  this->CreatePandoraInstances();
110 
111  if (!m_pPrimaryPandora)
112  throw cet::exception("LArPandora") << " LArPandora::beginJob - failed to create primary Pandora instance " << std::endl;
113 
116 
117  // Pass basic LArTPC information to pandora instances
119 
120  // If using global drift volume approach, pass details of gaps between daughter volumes to the pandora instance
122  {
123  LArDetectorGapList listOfGaps;
125  LArPandoraInput::CreatePandoraDetectorGaps(m_inputSettings, driftVolumeList, listOfGaps);
126  }
127 
128  // Parse Pandora settings xml files
130 }
131 
132 //------------------------------------------------------------------------------------------------------------------------------------------
133 
135 {
136  IdToHitMap idToHitMap;
137  this->CreatePandoraInput(evt, idToHitMap);
138  this->RunPandoraInstances();
139  this->ProcessPandoraOutput(evt, idToHitMap);
140  this->ResetPandoraInstances();
141 }
142 
143 //------------------------------------------------------------------------------------------------------------------------------------------
144 
146 {
147  // ATTN Should complete gap creation in begin job callback, but channel status service functionality unavailable at that point
149  {
151  m_lineGapsCreated = true;
152  }
153 
154  HitVector artHits;
155  SimChannelVector artSimChannels;
156  HitsToTrackIDEs artHitsToTrackIDEs;
157  MCParticleVector artMCParticleVector;
158  RawMCParticleVector generatorArtMCParticleVector;
159  MCTruthToMCParticles artMCTruthToMCParticles;
160  MCParticlesToMCTruth artMCParticlesToMCTruth;
161 
163 
164  if (m_enableMCParticles && !evt.isRealData())
165  {
166  LArPandoraHelper::CollectMCParticles(evt, m_geantModuleLabel, artMCParticleVector);
167 
168  if (!m_generatorModuleLabel.empty())
169  LArPandoraHelper::CollectGeneratorMCParticles(evt, m_generatorModuleLabel, generatorArtMCParticleVector);
170 
171  LArPandoraHelper::CollectMCParticles(evt, m_geantModuleLabel, artMCTruthToMCParticles, artMCParticlesToMCTruth);
172 
174  if (!artSimChannels.empty())
175  {
176  LArPandoraHelper::BuildMCParticleHitMaps(artHits, artSimChannels, artHitsToTrackIDEs);
177  }
178  else
179  {
180  if (m_backtrackerModuleLabel.empty())
181  throw cet::exception("LArPandora") << " LArPandora::CreatePandoraInput - no sim channels found, backtracker module must be set in FHiCL " << std::endl;
182 
184  }
185  }
186 
188 
189  if (m_enableMCParticles && !evt.isRealData())
190  {
191  LArPandoraInput::CreatePandoraMCParticles(m_inputSettings, artMCTruthToMCParticles, artMCParticlesToMCTruth, generatorArtMCParticleVector);
192  LArPandoraInput::CreatePandoraMCLinks2D(m_inputSettings, idToHitMap, artHitsToTrackIDEs);
193  }
194 }
195 
196 //------------------------------------------------------------------------------------------------------------------------------------------
197 
199 {
200  if (m_enableProduction)
202 }
203 
204 } // namespace lar_pandora
std::map< art::Ptr< recob::Hit >, TrackIDEVector > HitsToTrackIDEs
Header file for the pfo helper class.
void CreatePandoraInput(art::Event &evt, IdToHitMap &idToHitMap)
Create pandora input hits, mc particles etc.
Definition: LArPandora.cxx:145
Base producer module for reconstructing recob::PFParticles from recob::Hits.
static void CreatePandoraMCParticles(const Settings &settings, const MCTruthToMCParticles &truthToParticles, const MCParticlesToMCTruth &particlesToTruth, const RawMCParticleVector &generatorMCParticleVector)
Create the Pandora MC particles from the MC particles.
static void CreatePandoraDetectorGaps(const Settings &settings, const LArDriftVolumeList &driftVolumeList, const LArDetectorGapList &listOfGaps)
Create pandora line gaps to cover dead regions between TPCs in a global drift volume approach...
const pandora::Pandora * m_pPrimaryPandora
std::vector< LArDetectorGap > LArDetectorGapList
ILArPandora class.
Definition: ILArPandora.h:25
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
Declaration of signal hit object.
std::vector< LArDriftVolume > LArDriftVolumeList
const pandora::Pandora * m_pPrimaryPandora
STL namespace.
std::map< int, art::Ptr< recob::Hit > > IdToHitMap
Definition: ILArPandora.h:20
Helper functions for processing outputs from pandora.
std::string m_backtrackerModuleLabel
The back tracker module label.
Definition: LArPandora.h:57
bool isRealData() const
Definition: Event.h:83
Particle class.
static void CreatePandoraHits2D(const Settings &settings, const LArDriftVolumeMap &driftVolumeMap, const HitVector &hitVector, IdToHitMap &idToHitMap)
Create the Pandora 2D hits from the ART hits.
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
static void CollectGeneratorMCParticles(const art::Event &evt, const std::string &label, RawMCParticleVector &particleVector)
Collect a vector of MCParticle objects from the generator in the ART event record. ATTN: This function is needed as accessing generator (opposed to Geant4) level MCParticles requires use of MCTruth block.
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
bool m_lineGapsCreated
Book-keeping: whether line gap creation has been called.
Definition: LArPandora.h:62
std::vector< art::Ptr< sim::SimChannel > > SimChannelVector
static void LoadGeometry(LArDriftVolumeList &outputVolumeList, LArDriftVolumeMap &outputVolumeMap)
Load drift volume geometry.
static void BuildMCParticleHitMaps(const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
const pandora::Pandora * m_pPrimaryPandora
The address of the primary pandora instance.
Definition: ILArPandora.h:82
LArDriftVolumeMap m_driftVolumeMap
The map from volume id to drift volume.
Definition: LArPandora.h:67
virtual void CreatePandoraInstances()=0
Create pandora instances.
std::string m_generatorModuleLabel
The generator module label.
Definition: LArPandora.h:54
std::string m_geantModuleLabel
The geant module label.
Definition: LArPandora.h:55
T get(std::string const &key) const
Definition: ParameterSet.h:231
static void CreatePandoraMCLinks2D(const Settings &settings, const HitMap &hitMap, const HitsToTrackIDEs &hitToParticleMap)
Create links between the 2D hits and Pandora MC particles.
void ProcessPandoraOutput(art::Event &evt, const IdToHitMap &idToHitMap)
Process pandora output particle flow objects.
Definition: LArPandora.cxx:198
static void ProduceArtOutput(const Settings &settings, const IdToHitMap &idToHitMap, art::Event &evt)
Convert the Pandora PFOs into ART clusters and write into ART event.
virtual void ResetPandoraInstances()=0
Reset all associated pandora instances.
Declaration of cluster object.
Provides recob::Track data product.
LArPandora(fhicl::ParameterSet const &pset)
Constructor.
Definition: LArPandora.cxx:45
std::vector< art::Ptr< recob::Hit > > HitVector
static void CollectSimChannels(const art::Event &evt, const std::string &label, SimChannelVector &simChannelVector)
Collect a vector of SimChannel objects from the ART event record.
static void CollectHits(const art::Event &evt, const std::string &label, HitVector &hitVector)
Collect the reconstructed Hits from the ART event record.
static void CreatePandoraReadoutGaps(const Settings &settings, const LArDriftVolumeMap &driftVolumeMap)
Create pandora line gaps to cover any (continuous regions of) bad channels.
bool m_enableDetectorGaps
Whether to pass detector gap information to Pandora instances.
Definition: LArPandora.h:60
void produce(art::Event &evt)
Definition: LArPandora.cxx:134
bool m_shouldRunStitching
Steering: whether to stitch cosmic-ray muons crossing between volumes.
Definition: LArPandora.h:42
std::vector< simb::MCParticle > RawMCParticleVector
LArPandoraInput::Settings m_inputSettings
The lar pandora input settings.
Definition: LArPandora.h:64
static void CreatePandoraLArTPCs(const Settings &settings, const LArDriftVolumeList &driftVolumeList)
Create pandora LArTPCs to represent the different drift volumes in use.
LArPandoraOutput::Settings m_outputSettings
The lar pandora output settings.
Definition: LArPandora.h:65
Helper functions for providing inputs to pandora.
Header file detailing content for use with particle flow reconstruction at liquid argon time projecti...
virtual void RunPandoraInstances()=0
Run all associated pandora instances.
bool m_enableMCParticles
Whether to pass mc information to Pandora instances to aid development.
Definition: LArPandora.h:61
bool m_enableProduction
Whether to persist output products.
Definition: LArPandora.h:59
static void CollectMCParticles(const art::Event &evt, const std::string &label, MCParticleVector &particleVector)
Collect a vector of MCParticle objects from the ART event record.
helper function for LArPandoraInterface producer module
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::string m_hitfinderModuleLabel
The hit finder module label.
Definition: LArPandora.h:56
virtual void ConfigurePandoraInstances()=0
Configure pandora instances.
static void LoadDetectorGaps(LArDetectorGapList &listOfGaps)
Load the 2D gaps that go with the chosen geometry.