StandardPandora_module.cc
Go to the documentation of this file.
1 /**
2  * @file larpandora/LArPandoraInterface/StandardPandora_module.cc
3  *
4  * @brief A generic LArPandora ART Producer module intended to work on ALL LAr-TPC wire-readout experiments.
5  */
6 
8 
10 
11 #include <string>
12 
13 namespace lar_pandora
14 {
15 
16 /**
17  * @brief StandardPandora class
18  */
20 {
21 public:
22  /**
23  * @brief Constructor
24  *
25  * @param pset the parameter set
26  */
28 
29  /**
30  * @brief Destructor
31  */
33 
34 private:
37  void RunPandoraInstances();
38  void ResetPandoraInstances();
40 
41  /**
42  * @brief Pass external steering parameters, read from fhicl parameter set, to LArMaster Pandora algorithm
43  *
44  * @param pPandora the address of the relevant pandora instance
45  */
46  void ProvideExternalSteeringParameters(const pandora::Pandora *const pPandora) const;
47 };
48 
50 
51 } // namespace lar_pandora
52 
53 //------------------------------------------------------------------------------------------------------------------------------------------
54 // implementation follows
55 
56 #include "cetlib_except/exception.h"
57 
58 #include "Api/PandoraApi.h"
59 
65 
66 #ifdef LIBTORCH_DL
68 #endif
69 
70 namespace lar_pandora
71 {
72 
74  LArPandora(pset)
75 {
76 }
77 
78 //------------------------------------------------------------------------------------------------------------------------------------------
79 
81 {
82  this->DeletePandoraInstances();
83 }
84 
85 //------------------------------------------------------------------------------------------------------------------------------------------
86 
88 {
89  m_pPrimaryPandora = new pandora::Pandora();
90  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, LArContent::RegisterAlgorithms(*m_pPrimaryPandora));
91 #ifdef LIBTORCH_DL
92  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, LArDLContent::RegisterAlgorithms(*m_pPrimaryPandora));
93 #endif
94  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, LArContent::RegisterBasicPlugins(*m_pPrimaryPandora));
95 
96  // ATTN Potentially ill defined, unless coordinate system set up to ensure that all drift volumes have same wire angles and pitches
97  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::SetPseudoLayerPlugin(*m_pPrimaryPandora, new lar_content::LArPseudoLayerPlugin));
98  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::SetLArTransformationPlugin(*m_pPrimaryPandora, new lar_content::LArRotationalTransformationPlugin));
99 
101 }
102 
103 //------------------------------------------------------------------------------------------------------------------------------------------
104 
106 {
107  cet::search_path sp("FW_SEARCH_PATH");
108  std::string fullConfigFileName;
109 
110  if (!sp.find_file(m_configFile, fullConfigFileName))
111  throw cet::exception("StandardPandora") << " ConfigurePrimaryPandoraInstance - Failed to find xml configuration file " << m_configFile << " in FW search path";
112 
114  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::ReadSettings(*m_pPrimaryPandora, fullConfigFileName));
115 }
116 
117 //------------------------------------------------------------------------------------------------------------------------------------------
118 
120 {
121  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::ProcessEvent(*m_pPrimaryPandora));
122 }
123 
124 //------------------------------------------------------------------------------------------------------------------------------------------
125 
127 {
128  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::Reset(*m_pPrimaryPandora));
129 }
130 
131 //------------------------------------------------------------------------------------------------------------------------------------------
132 
134 {
136 }
137 
138 //------------------------------------------------------------------------------------------------------------------------------------------
139 
140 void StandardPandora::ProvideExternalSteeringParameters(const pandora::Pandora *const pPandora) const
141 {
142  auto *const pEventSteeringParameters = new lar_content::MasterAlgorithm::ExternalSteeringParameters;
144  pEventSteeringParameters->m_shouldRunStitching = m_shouldRunStitching;
145  pEventSteeringParameters->m_shouldRunCosmicHitRemoval = m_shouldRunCosmicHitRemoval;
146  pEventSteeringParameters->m_shouldRunSlicing = m_shouldRunSlicing;
147  pEventSteeringParameters->m_shouldRunNeutrinoRecoOption = m_shouldRunNeutrinoRecoOption;
148  pEventSteeringParameters->m_shouldRunCosmicRecoOption = m_shouldRunCosmicRecoOption;
149  pEventSteeringParameters->m_shouldPerformSliceId = m_shouldPerformSliceId;
150  pEventSteeringParameters->m_printOverallRecoStatus = m_printOverallRecoStatus;
151  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, pandora::ExternallyConfiguredAlgorithm::SetExternalParameters(*pPandora, "LArMaster", pEventSteeringParameters));
152 
153 #ifdef LIBTORCH_DL
154  auto *const pEventSettingsParametersCopy = new lar_content::MasterAlgorithm::ExternalSteeringParameters(*pEventSteeringParameters);
155  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, pandora::ExternallyConfiguredAlgorithm::SetExternalParameters(*pPandora,
156  "LArDLMaster", pEventSettingsParametersCopy));
157 #endif
158 }
159 
160 } // namespace lar_pandora
void ProvideExternalSteeringParameters(const pandora::Pandora *const pPandora) const
Pass external steering parameters, read from fhicl parameter set, to LArMaster Pandora algorithm...
Header file detailing content for use with particle flow reconstruction at liquid argon time projecti...
void DeletePandoraInstances()
Delete pandora instances.
Base producer module for reconstructing recob::PFParticles from recob::Hits.
static void DeletePandoraInstances(const pandora::Pandora *const pPrimaryPandora)
Delete all pandora instances associated with (and including) a specified primary pandora instance...
std::string string
Definition: nybbler.cc:12
bool m_shouldRunAllHitsCosmicReco
Steering: whether to run all hits cosmic-ray reconstruction.
Definition: LArPandora.h:43
bool m_shouldRunCosmicHitRemoval
Steering: whether to remove hits from tagged cosmic-rays.
Definition: LArPandora.h:46
pandora::InputBool m_shouldRunAllHitsCosmicReco
Whether to run all hits cosmic-ray reconstruction.
bool m_shouldRunNeutrinoRecoOption
Steering: whether to run neutrino reconstruction for each slice.
Definition: LArPandora.h:50
const pandora::Pandora * m_pPrimaryPandora
The address of the primary pandora instance.
Definition: ILArPandora.h:83
void ResetPandoraInstances()
Reset all associated pandora instances.
void RunPandoraInstances()
Run all associated pandora instances.
Header file for the master algorithm class.
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
bool m_printOverallRecoStatus
Steering: whether to print current operation status messages.
Definition: LArPandora.h:56
static void AddPrimaryPandoraInstance(const pandora::Pandora *const pPrimaryPandora)
Declare a new primary pandora instance and receive the relevant multi pandora book-keeping instance...
static pandora::StatusCode RegisterBasicPlugins(const pandora::Pandora &pandora)
Register the basic lar content plugins with pandora.
Definition: LArContent.cc:462
Header file for the rotational transformation plugin class.
Header file for the MultiPandoraApi class.
bool m_shouldRunCosmicRecoOption
Steering: whether to run cosmic-ray reconstruction for each slice.
Definition: LArPandora.h:52
std::string m_configFile
The config file.
Definition: LArPandora.h:40
static pandora::StatusCode RegisterAlgorithms(const pandora::Pandora &pandora)
Register all the lar content algorithms and tools with pandora.
Definition: LArContent.cc:446
bool m_shouldRunStitching
Steering: whether to stitch cosmic-ray muons crossing between volumes.
Definition: LArPandora.h:45
void ConfigurePandoraInstances()
Configure pandora instances.
std::string find_file(std::string const &filename) const
Definition: search_path.cc:96
void CreatePandoraInstances()
Create pandora instances.
Header file detailing content for use with particle flow reconstruction at liquid argon time projecti...
bool m_shouldRunSlicing
Steering: whether to slice events into separate regions for processing.
Definition: LArPandora.h:48
Header file for the lar pseudo layer plugin class.
LArPandora class.
Definition: LArPandora.h:24
static pandora::StatusCode RegisterAlgorithms(const pandora::Pandora &pandora)
Register all the lar dl content algorithms and tools with pandora.
Definition: LArDLContent.cc:89
StandardPandora(fhicl::ParameterSet const &pset)
Constructor.
bool m_shouldPerformSliceId
Steering: whether to identify slices and select most appropriate pfos.
Definition: LArPandora.h:54
LarPandoraPseudoLayerPlugin class.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33