LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
reco::shower::LArPandoraModularShowerCreation Class Reference
Inheritance diagram for reco::shower::LArPandoraModularShowerCreation:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 LArPandoraModularShowerCreation (fhicl::ParameterSet const &pset)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

void produce (art::Event &evt)
 
template<class T >
art::Ptr< T > GetProducedElementPtr (const std::string &InstanceName, const reco::shower::ShowerElementHolder &ShowerEleHolder, const int &iter=-1)
 

Private Attributes

unsigned int fNumPlanes
 
const art::InputTag fPFParticleLabel
 
const bool fAllowPartialShowers
 
const int fVerbose
 
const bool fUseAllParticles
 
const std::string fShowerStartPositionLabel
 
const std::string fShowerDirectionLabel
 
const std::string fShowerEnergyLabel
 
const std::string fShowerLengthLabel
 
const std::string fShowerOpeningAngleLabel
 
const std::string fShowerdEdxLabel
 
const std::string fShowerBestPlaneLabel
 
std::vector< std::unique_ptr< ShowerRecoTools::IShowerTool > > fShowerTools
 
std::vector< std::string > fShowerToolNames
 
reco::shower::ShowerProducedPtrsHolder uniqueproducerPtrs
 
art::ServiceHandle< geo::GeometryfGeom
 

Detailed Description

Definition at line 37 of file LArPandoraModularShowerCreation_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

reco::shower::LArPandoraModularShowerCreation::LArPandoraModularShowerCreation ( fhicl::ParameterSet const &  pset)

Definition at line 113 of file LArPandoraModularShowerCreation_module.cc.

References fAllowPartialShowers, fGeom, fNumPlanes, fPFParticleLabel, fShowerBestPlaneLabel, fShowerdEdxLabel, fShowerDirectionLabel, fShowerEnergyLabel, fShowerLengthLabel, fShowerOpeningAngleLabel, fShowerStartPositionLabel, fShowerToolNames, fShowerTools, fUseAllParticles, fVerbose, fhicl::ParameterSet::get(), art::InputTag::instance(), art::InputTag::label(), geo::GeometryCore::Nplanes(), reco::shower::ShowerProducedPtrsHolder::PrintPtrs(), art::InputTag::process(), art::ProductRegistryHelper::producesCollector(), fhicl::ParameterSet::put(), fhicl::ParameterSet::put_or_replace(), reco::shower::ShowerProducedPtrsHolder::SetShowerUniqueProduerPtr(), and uniqueproducerPtrs.

115  : EDProducer{pset}
116  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
117  , fAllowPartialShowers(pset.get<bool>("AllowPartialShowers"))
118  , fVerbose(pset.get<int>("Verbose", 0))
119  , fUseAllParticles(pset.get<bool>("UseAllParticles", false))
120  , fShowerStartPositionLabel(pset.get<std::string>("ShowerStartPositionLabel"))
121  , fShowerDirectionLabel(pset.get<std::string>("ShowerDirectionLabel"))
122  , fShowerEnergyLabel(pset.get<std::string>("ShowerEnergyLabel"))
123  , fShowerLengthLabel(pset.get<std::string>("ShowerLengthLabel"))
124  , fShowerOpeningAngleLabel(pset.get<std::string>("ShowerOpeningAngleLabel"))
125  , fShowerdEdxLabel(pset.get<std::string>("ShowerdEdxLabel"))
126  , fShowerBestPlaneLabel(pset.get<std::string>("ShowerBestPlaneLabel"))
127 {
128  //Intialise the tools
129  auto tool_psets = pset.get<std::vector<fhicl::ParameterSet>>("ShowerFinderTools");
130  for (auto& tool_pset : tool_psets) {
131 
132  const std::string tool_name(tool_pset.get<std::string>("tool_type"));
133  // If the PFPaticle label is not set for the tool, make it use the one for the module
134  // Note we also need to set the label in the Alg, via the base tool
135  if (!tool_pset.has_key("PFParticleLabel")) {
136 
137  // I cannot pass an art::InputTag as it is mangled, so lets make a string instead
138  const std::string PFParticleLabelString(fPFParticleLabel.label() + ":" +
139  fPFParticleLabel.instance() + ":" +
141 
142  tool_pset.put<std::string>("PFParticleLabel", PFParticleLabelString);
143  fhicl::ParameterSet base_pset = tool_pset.get<fhicl::ParameterSet>("BaseTools");
144  fhicl::ParameterSet alg_pset = base_pset.get<fhicl::ParameterSet>("LArPandoraShowerAlg");
145  alg_pset.put<std::string>("PFParticleLabel", PFParticleLabelString);
146  base_pset.put_or_replace<fhicl::ParameterSet>("LArPandoraShowerAlg", alg_pset);
147  tool_pset.put_or_replace<fhicl::ParameterSet>("BaseTools", base_pset);
148 
149  if (tool_pset.has_key("LArPandoraShowerCheatingAlg")) {
150  fhicl::ParameterSet cheat_alg_pset =
151  tool_pset.get<fhicl::ParameterSet>("LArPandoraShowerCheatingAlg");
152  cheat_alg_pset.put<std::string>("PFParticleLabel", PFParticleLabelString);
153  cheat_alg_pset.put_or_replace<fhicl::ParameterSet>("LArPandoraShowerAlg", alg_pset);
154  tool_pset.put_or_replace<fhicl::ParameterSet>("LArPandoraShowerCheatingAlg",
155  cheat_alg_pset);
156  }
157  }
158 
159  // If we have not explicitly set verboseness for a given tool, use global level
160  if (!tool_pset.has_key("Verbose")) { tool_pset.put<int>("Verbose", fVerbose); }
161 
162  fShowerTools.push_back(art::make_tool<ShowerRecoTools::IShowerTool>(tool_pset));
163  fShowerToolNames.push_back(tool_name);
164 
165  fNumPlanes = fGeom->Nplanes();
166  }
167 
168  // Initialise the EDProducer ptr in the tools
169  std::vector<std::string> SetupTools;
170  for (unsigned int i = 0; i < fShowerTools.size(); ++i) {
171  if (std::find(SetupTools.begin(), SetupTools.end(), fShowerToolNames[i]) != SetupTools.end()) {
172  continue;
173  }
174  fShowerTools[i]->SetPtr(&producesCollector());
175  fShowerTools[i]->InitaliseProducerPtr(uniqueproducerPtrs);
176  fShowerTools[i]->InitialiseProducers();
177  }
178 
179  //Initialise the other paramters.
180 
181  produces<std::vector<recob::Shower>>();
182  produces<art::Assns<recob::Shower, recob::Hit>>();
183  produces<art::Assns<recob::Shower, recob::Cluster>>();
184  produces<art::Assns<recob::Shower, recob::SpacePoint>>();
185  produces<art::Assns<recob::Shower, recob::PFParticle>>();
186 
187  // Output -- showers and associations with hits and clusters
188  uniqueproducerPtrs.SetShowerUniqueProduerPtr(type<std::vector<recob::Shower>>(), "shower");
190  "clusterAssociationsbase");
192  "hitAssociationsbase");
194  "spShowerAssociationsbase");
196  "pfShowerAssociationsbase");
197 
199 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
std::string const & instance() const noexcept
Definition: InputTag.cc:85
std::string const & process() const noexcept
Definition: InputTag.cc:91
std::string const & label() const noexcept
Definition: InputTag.cc:79
T get(std::string const &key) const
Definition: ParameterSet.h:314
ProducesCollector & producesCollector() noexcept
unsigned int Nplanes(TPCID const &tpcid=tpc_zero) const
Returns the total number of planes in the specified TPC.
Definition: GeometryCore.h:977
std::vector< std::unique_ptr< ShowerRecoTools::IShowerTool > > fShowerTools
void put_or_replace(std::string const &key)
int SetShowerUniqueProduerPtr(type< T >, const std::string &Name, const std::string &Instance="")
void put(std::string const &key)

Member Function Documentation

template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
template<class T >
art::Ptr< T > reco::shower::LArPandoraModularShowerCreation::GetProducedElementPtr ( const std::string &  InstanceName,
const reco::shower::ShowerElementHolder ShowerEleHolder,
const int &  iter = -1 
)
private

Definition at line 83 of file LArPandoraModularShowerCreation_module.cc.

References reco::shower::ShowerElementHolder::CheckElement(), reco::shower::ShowerProducedPtrsHolder::CheckUniqueProduerPtr(), reco::shower::ShowerProducedPtrsHolder::GetArtPtr(), reco::shower::ShowerElementHolder::GetShowerNumber(), and uniqueproducerPtrs.

87 {
88 
89  bool check_element = ShowerEleHolder.CheckElement(InstanceName);
90  if (!check_element) {
91  throw cet::exception("LArPandoraModularShowerCreation")
92  << "To get a element that does not exist" << std::endl;
93  }
94 
95  bool check_ptr = uniqueproducerPtrs.CheckUniqueProduerPtr(InstanceName);
96  if (!check_ptr) {
97  throw cet::exception("LArPandoraModularShowerCreation")
98  << "Tried to get a ptr that does not exist" << std::endl;
99  }
100 
101  //Get the number of the shower we are on.
102  int index;
103  if (iter != -1) { index = iter; }
104  else {
105  index = ShowerEleHolder.GetShowerNumber();
106  }
107 
108  //Make the ptr
109  art::Ptr<T> artptr = uniqueproducerPtrs.GetArtPtr<T>(InstanceName, index);
110  return artptr;
111 }
bool CheckUniqueProduerPtr(const std::string &Name) const
bool CheckElement(const std::string &Name) const
art::Ptr< T > GetArtPtr(const std::string &Name, const int &iter) const
Definition: fwd.h:26
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void reco::shower::LArPandoraModularShowerCreation::produce ( art::Event evt)
privatevirtual

Check all the producers

Implements art::EDProducer.

Definition at line 201 of file LArPandoraModularShowerCreation_module.cc.

References reco::shower::ShowerProducedPtrsHolder::AddDataProducts(), reco::shower::ShowerProducedPtrsHolder::AddSingle(), reco::shower::ShowerElementHolder::CheckAllElementTags(), reco::shower::ShowerProducedPtrsHolder::CheckAllProducedElements(), reco::shower::ShowerElementHolder::CheckElement(), reco::shower::ShowerElementHolder::ClearShower(), DEFINE_ART_MODULE, tca::evt, fAllowPartialShowers, art::fill_ptr_vector(), fNumPlanes, fPFParticleLabel, fShowerBestPlaneLabel, fShowerdEdxLabel, fShowerDirectionLabel, fShowerEnergyLabel, fShowerLengthLabel, fShowerOpeningAngleLabel, fShowerStartPositionLabel, fShowerToolNames, fShowerTools, fUseAllParticles, fVerbose, reco::shower::ShowerElementHolder::GetElement(), reco::shower::ShowerElementHolder::GetElementAndError(), reco::shower::ShowerElementHolder::GetFindManyP(), art::ProductRetriever::getValidHandle(), util::kBogusI, art::ModuleBase::moduleDescription(), art::ModuleDescription::moduleLabel(), reco::shower::ShowerProducedPtrsHolder::MoveAllToEvent(), reco::shower::ShowerElementHolder::PrintElements(), reco::shower::ShowerProducedPtrsHolder::reset(), reco::shower::ShowerElementHolder::SetElement(), reco::shower::ShowerProducedPtrsHolder::SetPtrMakers(), reco::shower::ShowerElementHolder::SetShowerNumber(), tca::ShowerEnergy(), util::to_string(), and uniqueproducerPtrs.

202 {
203 
204  //Ptr makers for the products
206  reco::shower::ShowerElementHolder showerEleHolder;
207 
208  //Get the PFParticles
209  auto const pfpHandle = evt.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
210  std::vector<art::Ptr<recob::PFParticle>> pfps;
211  art::fill_ptr_vector(pfps, pfpHandle);
212 
213  //Handle to access the pandora hits assans
214  auto const clusterHandle = evt.getValidHandle<std::vector<recob::Cluster>>(fPFParticleLabel);
215 
216  //Get the assoications to hits, clusters and spacespoints
217  const art::FindManyP<recob::Hit>& fmh =
218  showerEleHolder.GetFindManyP<recob::Hit>(clusterHandle, evt, fPFParticleLabel);
219  const art::FindManyP<recob::Cluster>& fmcp =
220  showerEleHolder.GetFindManyP<recob::Cluster>(pfpHandle, evt, fPFParticleLabel);
221  const art::FindManyP<recob::SpacePoint>& fmspp =
222  showerEleHolder.GetFindManyP<recob::SpacePoint>(pfpHandle, evt, fPFParticleLabel);
223 
224  //Holder to pass to the functions, contains the 6 properties of the shower
225  // - Start Poistion
226  // - Direction
227  // - Initial Track
228  // - Initial Track Hits
229  // - Energy
230  // - dEdx
231  // - Length
232  // - Opening Angle
233 
234  int shower_iter = 0;
235  //Loop of the pf particles
236  for (auto const& pfp : pfps) {
237 
238  //Update the shower iterator
239  showerEleHolder.SetShowerNumber(shower_iter);
240 
241  //loop only over showers unless otherwise specified
242  if (!fUseAllParticles && pfp->PdgCode() != 11 && pfp->PdgCode() != 22) continue;
243 
244  //Get the associated hits,clusters and spacepoints
245  const std::vector<art::Ptr<recob::Cluster>> showerClusters = fmcp.at(pfp.key());
246  const std::vector<art::Ptr<recob::SpacePoint>> showerSpacePoints = fmspp.at(pfp.key());
247 
248  // Check the pfp has at least 1 cluster (i.e. not a pfp neutrino)
249  if (!showerClusters.size()) continue;
250 
251  if (fVerbose > 1)
252  mf::LogInfo("LArPandoraModularShowerCreation")
253  << "Running on shower: " << shower_iter << std::endl;
254 
255  //Calculate the shower properties
256  //Loop over the shower tools
257  int err = 0;
258  for (unsigned int i = 0; i < fShowerTools.size(); i++) {
259 
260  //Calculate the metric
261  if (fVerbose > 1)
262  mf::LogInfo("LArPandoraModularShowerCreation")
263  << "Running shower tool: " << fShowerToolNames[i] << std::endl;
264  std::string evd_disp_append = fShowerToolNames[i] + "_iteration" + std::to_string(0) + "_" +
265  this->moduleDescription().moduleLabel();
266 
267  err = fShowerTools[i]->RunShowerTool(pfp, evt, showerEleHolder, evd_disp_append);
268 
269  if (err && fVerbose) {
270  mf::LogError("LArPandoraModularShowerCreation")
271  << "Error in shower tool: " << fShowerToolNames[i] << " with code: " << err << std::endl;
272  }
273  }
274 
275  //If we are are not allowing partial shower check all of the things
276  if (!fAllowPartialShowers) {
277  // If we recieved an error call from a tool return;
278 
279  // Check everything we need is in the shower element holder
280  if (!showerEleHolder.CheckElement(fShowerStartPositionLabel)) {
281  if (fVerbose)
282  mf::LogError("LArPandoraModularShowerCreation")
283  << "The start position is not set in the element holder. bailing" << std::endl;
284  continue;
285  }
286  if (!showerEleHolder.CheckElement(fShowerDirectionLabel)) {
287  if (fVerbose)
288  mf::LogError("LArPandoraModularShowerCreation")
289  << "The direction is not set in the element holder. bailing" << std::endl;
290  continue;
291  }
292  if (!showerEleHolder.CheckElement(fShowerEnergyLabel)) {
293  if (fVerbose)
294  mf::LogError("LArPandoraModularShowerCreation")
295  << "The energy is not set in the element holder. bailing" << std::endl;
296  continue;
297  }
298  if (!showerEleHolder.CheckElement(fShowerdEdxLabel)) {
299  if (fVerbose)
300  mf::LogError("LArPandoraModularShowerCreation")
301  << "The dEdx is not set in the element holder. bailing" << std::endl;
302  continue;
303  }
304  if (!showerEleHolder.CheckElement(fShowerBestPlaneLabel)) {
305  if (fVerbose)
306  mf::LogError("LArPandoraModularShowerCreation")
307  << "The BestPlane is not set in the element holder. bailing" << std::endl;
308  continue;
309  }
310  if (!showerEleHolder.CheckElement(fShowerLengthLabel)) {
311  if (fVerbose)
312  mf::LogError("LArPandoraModularShowerCreation")
313  << "The length is not set in the element holder. bailing" << std::endl;
314  continue;
315  }
316  if (!showerEleHolder.CheckElement(fShowerOpeningAngleLabel)) {
317  if (fVerbose)
318  mf::LogError("LArPandoraModularShowerCreation")
319  << "The opening angle is not set in the element holder. bailing" << std::endl;
320  continue;
321  }
322 
323  //Check All of the products that have been asked to be checked.
324  bool elements_are_set = showerEleHolder.CheckAllElementTags();
325  if (!elements_are_set) {
326  if (fVerbose)
327  mf::LogError("LArPandoraModularShowerCreation")
328  << "Not all the elements in the property holder which should be set are not. Bailing. "
329  << std::endl;
330  continue;
331  }
332 
334  bool producers_are_set = uniqueproducerPtrs.CheckAllProducedElements(showerEleHolder);
335  if (!producers_are_set) {
336  if (fVerbose)
337  mf::LogError("LArPandoraModularShowerCreation")
338  << "Not all the elements in the property holder which are produced are not set. "
339  "Bailing. "
340  << std::endl;
341  continue;
342  }
343  }
344 
345  //Get the properties
346  geo::Point_t ShowerStartPosition(-999, -999, -999);
347  geo::Vector_t ShowerDirection(-999, -999, -999);
348  std::vector<double> ShowerEnergy(fNumPlanes, -999);
349  std::vector<double> ShowerdEdx(fNumPlanes, -999);
350  int BestPlane(-999);
351  double ShowerLength(-999);
352  double ShowerOpeningAngle(-999);
353 
354  geo::Point_t ShowerStartPositionErr(-999, -999, -999);
355  geo::Vector_t ShowerDirectionErr(-999, -999, -999);
356  std::vector<double> ShowerEnergyErr(fNumPlanes, -999);
357  std::vector<double> ShowerdEdxErr(fNumPlanes, -999);
358 
359  err = 0;
360  if (showerEleHolder.CheckElement(fShowerStartPositionLabel))
361  err += showerEleHolder.GetElementAndError(
362  fShowerStartPositionLabel, ShowerStartPosition, ShowerStartPositionErr);
363  if (showerEleHolder.CheckElement(fShowerDirectionLabel))
364  err += showerEleHolder.GetElementAndError(
365  fShowerDirectionLabel, ShowerDirection, ShowerDirectionErr);
366  if (showerEleHolder.CheckElement(fShowerEnergyLabel))
367  err += showerEleHolder.GetElementAndError(fShowerEnergyLabel, ShowerEnergy, ShowerEnergyErr);
368  if (showerEleHolder.CheckElement(fShowerdEdxLabel))
369  err += showerEleHolder.GetElementAndError(fShowerdEdxLabel, ShowerdEdx, ShowerdEdxErr);
370  if (showerEleHolder.CheckElement(fShowerBestPlaneLabel))
371  err += showerEleHolder.GetElement(fShowerBestPlaneLabel, BestPlane);
372  if (showerEleHolder.CheckElement(fShowerLengthLabel))
373  err += showerEleHolder.GetElement(fShowerLengthLabel, ShowerLength);
374  if (showerEleHolder.CheckElement(fShowerOpeningAngleLabel))
375  err += showerEleHolder.GetElement(fShowerOpeningAngleLabel, ShowerOpeningAngle);
376 
377  if (err) {
378  throw cet::exception("LArPandoraModularShowerCreation")
379  << "Error in LArPandoraModularShowerCreation Module. A Check on a shower property failed "
380  << std::endl;
381  }
382 
383  if (fVerbose > 1) {
384  //Check the shower
385  std::cout << "Shower Vertex: X:" << ShowerStartPosition.X()
386  << " Y: " << ShowerStartPosition.Y() << " Z: " << ShowerStartPosition.Z()
387  << std::endl;
388  std::cout << "Shower Direction: X:" << ShowerDirection.X() << " Y: " << ShowerDirection.Y()
389  << " Z: " << ShowerDirection.Z() << std::endl;
390  std::cout << "Shower dEdx:";
391  for (unsigned int i = 0; i < fNumPlanes; i++) {
392  std::cout << " Plane " << i << ": " << ShowerdEdx.at(i);
393  }
394  std::cout << std::endl;
395  std::cout << "Shower Energy:";
396  for (unsigned int i = 0; i < fNumPlanes; i++) {
397  std::cout << " Plane " << i << ": " << ShowerEnergy.at(i);
398  }
399  std::cout << std::endl;
400  std::cout << "Shower Best Plane: " << BestPlane << std::endl;
401  std::cout << "Shower Length: " << ShowerLength << std::endl;
402  std::cout << "Shower Opening Angle: " << ShowerOpeningAngle << std::endl;
403 
404  //Print what has been created in the shower
405  showerEleHolder.PrintElements();
406  }
407 
408  if (ShowerdEdx.size() != fNumPlanes) {
409  throw cet::exception("LArPandoraModularShowerCreation")
410  << "dEdx vector is wrong size: " << ShowerdEdx.size()
411  << " compared to Nplanes: " << fNumPlanes << std::endl;
412  }
413  if (ShowerEnergy.size() != fNumPlanes) {
414  throw cet::exception("LArPandoraModularShowerCreation")
415  << "Energy vector is wrong size: " << ShowerEnergy.size()
416  << " compared to Nplanes: " << fNumPlanes << std::endl;
417  }
418 
419  //Make the shower
420  using namespace geo::vect;
421  recob::Shower shower(convertTo<TVector3>(ShowerDirection),
422  convertTo<TVector3>(ShowerDirectionErr),
423  convertTo<TVector3>(ShowerStartPosition),
424  convertTo<TVector3>(ShowerDirectionErr),
425  ShowerEnergy,
426  ShowerEnergyErr,
427  ShowerdEdx,
428  ShowerdEdxErr,
429  BestPlane,
431  ShowerLength,
432  ShowerOpeningAngle);
433  showerEleHolder.SetElement(shower, "shower");
434  ++shower_iter;
435  art::Ptr<recob::Shower> ShowerPtr =
436  this->GetProducedElementPtr<recob::Shower>("shower", showerEleHolder);
437 
438  //Associate the pfparticle
440  ShowerPtr, pfp, "pfShowerAssociationsbase");
441 
442  //Add the hits for each "cluster"
443  for (auto const& cluster : showerClusters) {
444 
445  //Associate the clusters
446  std::vector<art::Ptr<recob::Hit>> ClusterHits = fmh.at(cluster.key());
448  ShowerPtr, cluster, "clusterAssociationsbase");
449 
450  //Associate the hits
451  for (auto const& hit : ClusterHits) {
453  ShowerPtr, hit, "hitAssociationsbase");
454  }
455  }
456 
457  //Associate the spacepoints
458  for (auto const& sp : showerSpacePoints) {
460  ShowerPtr, sp, "spShowerAssociationsbase");
461  }
462 
463  //Loop over the tool data products and add them.
464  uniqueproducerPtrs.AddDataProducts(showerEleHolder);
465 
466  //AddAssociations
467  int assn_err = 0;
468  for (auto const& fShowerTool : fShowerTools) {
469  //AddAssociations
470  assn_err += fShowerTool->AddAssociations(pfp, evt, showerEleHolder);
471  }
472  if (!fAllowPartialShowers && assn_err > 0) {
473  if (fVerbose)
474  mf::LogError("LArPandoraModularShowerCreation")
475  << "A association failed and not allowing partial showers. The association will not be "
476  "added to the event "
477  << std::endl;
478  }
479 
480  //Reset the showerproperty holder.
481  showerEleHolder.ClearShower();
482  }
483 
484  //Put everything in the event.
486 
487  //Reset the ptrs to the data products
489 }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void AddDataProducts(const reco::shower::ShowerElementHolder &selement_holder)
std::string const & moduleLabel() const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
constexpr int kBogusI
obviously bogus integer value
Set of hits with a 2D structure.
Definition: Cluster.h:69
double ShowerEnergy(const ShowerStruct3D &ss3)
Definition: TCShower.cxx:3899
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
Utilities to manipulate geometry vectors.The utilities include generic vector interface facilities al...
void AddSingle(A &a, B &b, const std::string &Name)
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
Detector simulation of raw signals on wires.
bool CheckAllProducedElements(reco::shower::ShowerElementHolder &selement_holder) const
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
std::vector< std::unique_ptr< ShowerRecoTools::IShowerTool > > fShowerTools
int GetElementAndError(const std::string &Name, T &Element, T2 &ElementErr) const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
TCEvent evt
Definition: DataStructs.cxx:8
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 >> &handle, const art::Event &evt, const art::InputTag &moduleTag)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

const bool reco::shower::LArPandoraModularShowerCreation::fAllowPartialShowers
private
art::ServiceHandle<geo::Geometry> reco::shower::LArPandoraModularShowerCreation::fGeom
private
unsigned int reco::shower::LArPandoraModularShowerCreation::fNumPlanes
private
const art::InputTag reco::shower::LArPandoraModularShowerCreation::fPFParticleLabel
private
const std::string reco::shower::LArPandoraModularShowerCreation::fShowerBestPlaneLabel
private
const std::string reco::shower::LArPandoraModularShowerCreation::fShowerdEdxLabel
private
const std::string reco::shower::LArPandoraModularShowerCreation::fShowerDirectionLabel
private
const std::string reco::shower::LArPandoraModularShowerCreation::fShowerEnergyLabel
private
const std::string reco::shower::LArPandoraModularShowerCreation::fShowerLengthLabel
private
const std::string reco::shower::LArPandoraModularShowerCreation::fShowerOpeningAngleLabel
private
const std::string reco::shower::LArPandoraModularShowerCreation::fShowerStartPositionLabel
private
std::vector<std::string> reco::shower::LArPandoraModularShowerCreation::fShowerToolNames
private
std::vector<std::unique_ptr<ShowerRecoTools::IShowerTool> > reco::shower::LArPandoraModularShowerCreation::fShowerTools
private
const bool reco::shower::LArPandoraModularShowerCreation::fUseAllParticles
private
const int reco::shower::LArPandoraModularShowerCreation::fVerbose
private
reco::shower::ShowerProducedPtrsHolder reco::shower::LArPandoraModularShowerCreation::uniqueproducerPtrs
private

The documentation for this class was generated from the following file: