Public Member Functions | Private Member Functions | Private Attributes | List of all members
ShowerReco3D Class Reference
Inheritance diagram for ShowerReco3D:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 ShowerReco3D (fhicl::ParameterSet const &p)
 
 ShowerReco3D (ShowerReco3D const &)=delete
 
 ShowerReco3D (ShowerReco3D &&)=delete
 
ShowerReco3Doperator= (ShowerReco3D const &)=delete
 
ShowerReco3Doperator= (ShowerReco3D &&)=delete
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
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)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
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)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void produce (art::Event &e) override
 

Private Attributes

bool fUsePFParticle
 
std::string fInputProducer
 
::showerreco::ShowerRecoManager fManager
 
::showerreco::ShowerRecoAlgfShowerAlgo
 
::calo::CalorimetryAlgfCaloAlgo
 
::cmtool::CPAlgoArrayfCPAlgoArray
 
::cmtool::CPAlgoNHitsfCPAlgoNHits
 
::cmtool::CPAlgoIgnoreTracksfCPAlgoIgnoreTracks
 
::cmtool::CFAlgoTimeOverlapfCFAlgoTimeOverlap
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
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 ()
 

Detailed Description

Definition at line 40 of file ShowerReco3D_module.cc.

Constructor & Destructor Documentation

ShowerReco3D::ShowerReco3D ( fhicl::ParameterSet const &  p)
explicit

Definition at line 68 of file ShowerReco3D_module.cc.

68  : EDProducer{p}
69 {
70  fInputProducer = p.get<std::string>("InputProducer");
71  fUsePFParticle = p.get<bool>("UsePFParticle");
72  produces<std::vector<recob::Shower>>();
73  produces<art::Assns<recob::Shower, recob::Cluster>>();
74  produces<art::Assns<recob::Shower, recob::Hit>>();
75  if (fUsePFParticle) produces<art::Assns<recob::PFParticle, recob::Shower>>();
76 
77  // Instantiate algorithms
78  fCaloAlgo = new ::calo::CalorimetryAlg(p.get<fhicl::ParameterSet>("CalorimetryAlg"));
79  fShowerAlgo = new ::showerreco::ShowerRecoAlg;
80  fCPAlgoArray = new ::cmtool::CPAlgoArray;
81  fCPAlgoNHits = new ::cmtool::CPAlgoNHits;
82  fCPAlgoIgnoreTracks = new ::cmtool::CPAlgoIgnoreTracks;
83  fCFAlgoTimeOverlap = new ::cmtool::CFAlgoTimeOverlap;
84 
85  // Configure
86  fCPAlgoNHits->SetMinHits(p.get<int>("MinHits"));
87 
90 
93 
94  fShowerAlgo->Verbose(p.get<bool>("Verbosity"));
95  fShowerAlgo->SetUseArea(p.get<bool>("UseArea"));
96  fShowerAlgo->setEcorrection(p.get<bool>("ApplyMCEnergyCorrection"));
97  fShowerAlgo->CaloAlgo(fCaloAlgo);
98 
100 }
void Algo(ShowerRecoAlgBase *alg)
::calo::CalorimetryAlg * fCaloAlgo
::cmtool::CPAlgoArray * fCPAlgoArray
std::string string
Definition: nybbler.cc:12
::showerreco::ShowerRecoManager fManager
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
void AddAlgo(CPriorityAlgoBase *algo)
Setter to add a new algorithm.
Definition: CPAlgoArray.h:63
void SetMinHits(size_t n)
Setter for minimum # hits.
Definition: CPAlgoNHits.h:42
::cmtool::CFAlgoTimeOverlap * fCFAlgoTimeOverlap
void AddMatchAlgo(CFloatAlgoBase *algo)
A simple method to add an algorithm for merging.
Definition: CMatchManager.h:47
void CaloAlgo(calo::CalorimetryAlg *alg)
Definition: ShowerRecoAlg.h:36
std::string fInputProducer
void setEcorrection(bool on)
Function to set whether to use E correction.
Definition: ShowerRecoAlg.h:43
p
Definition: test.py:223
void SetUseArea(bool on)
Function to decide if to use Area or Pulse Amplitude for calculations.
Definition: ShowerRecoAlg.h:24
::cmtool::CMatchManager & MatchManager()
void Verbose(bool verbose)
Definition: ShowerRecoAlg.h:30
::cmtool::CPAlgoIgnoreTracks * fCPAlgoIgnoreTracks
::showerreco::ShowerRecoAlg * fShowerAlgo
::cmtool::CPAlgoNHits * fCPAlgoNHits
void AddPriorityAlgo(CPriorityAlgoBase *algo)
Setter to add an algorithm for priority determination.
Definition: CMManagerBase.h:80
ShowerReco3D::ShowerReco3D ( ShowerReco3D const &  )
delete
ShowerReco3D::ShowerReco3D ( ShowerReco3D &&  )
delete

Member Function Documentation

ShowerReco3D& ShowerReco3D::operator= ( ShowerReco3D const &  )
delete
ShowerReco3D& ShowerReco3D::operator= ( ShowerReco3D &&  )
delete
void ShowerReco3D::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 103 of file ShowerReco3D_module.cc.

104 {
105  auto const& geom = *lar::providerFrom<geo::Geometry>();
106  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
107  auto const detProp =
109  util::GeometryUtilities const gser{geom, clockData, detProp};
110 
111  // Create output data product containers
112  std::unique_ptr<std::vector<recob::Shower>> out_shower_v(new std::vector<recob::Shower>);
113  std::unique_ptr<art::Assns<recob::Shower, recob::Cluster>> sc_assn(
115  std::unique_ptr<art::Assns<recob::Shower, recob::Hit>> sh_assn(
117  std::unique_ptr<art::Assns<recob::PFParticle, recob::Shower>> sp_assn(
119 
120  // Preparation
121 
122  // Reset ShowerRecoManager
123  fManager.Reset();
124 
125  // Retrieve input clusters
127  e.getByLabel(fInputProducer, cHandle);
128 
129  if (!cHandle.isValid())
130  throw cet::exception(__FUNCTION__) << "Invalid input cluster label!" << std::endl;
131 
132  // Cluster type conversion: recob::Hit => util::PxHit
133  std::vector<std::vector<::util::PxHit>> local_clusters;
134  art::FindManyP<recob::Hit> hit_m(cHandle, e, fInputProducer);
135  ::util::PxHitConverter conv{gser};
136  for (size_t i = 0; i < cHandle->size(); ++i) {
137  local_clusters.push_back(std::vector<::util::PxHit>());
138 
139  const std::vector<art::Ptr<recob::Hit>>& hits = hit_m.at(i);
140 
141  conv.GeneratePxHit(hits, local_clusters.back());
142  }
143 
144  //
145  // Run shower reconstruction
146  //
147  // shower pfparticle index (later used to make an association)
148  std::vector<size_t> shower_pfpart_index;
149  // cluster combination in terms of cluster index (for ShowerRecoManager::Reconstruct)
150  std::vector<std::vector<unsigned int>> matched_pairs;
151  // shower vector container to receive from ShowerRecoManager::Reconstruct
152  std::vector<recob::Shower> shower_v;
153 
154  if (!fUsePFParticle) {
155  matched_pairs = fManager.Reconstruct(geom, clockData, detProp, local_clusters, shower_v);
156  }
157  else {
158 
159  // Retrieve PFParticle
161  e.getByLabel(fInputProducer, pfHandle);
162  if (!pfHandle.isValid())
163  throw cet::exception(__FUNCTION__) << "Invalid input PFParticle label!" << std::endl;
164 
165  // Make a cluster ptr => index map to fill matched_pairs
166  std::map<art::Ptr<recob::Cluster>, size_t> cmap;
167  for (size_t i = 0; i < cHandle->size(); ++i) {
168 
169  const art::Ptr<recob::Cluster> cptr(cHandle, i);
170 
171  cmap[cptr] = i;
172  }
173  // Now to fill matched_pairs retrieve association of pfpart => cluster(s)
174  art::FindManyP<recob::Cluster> cluster_m(pfHandle, e, fInputProducer);
175 
176  for (size_t i = 0; i < pfHandle->size(); ++i) {
177 
178  const art::Ptr<recob::PFParticle> pf(pfHandle, i);
179 
180  if (pf->PdgCode() != 11) continue;
181 
182  const std::vector<art::Ptr<recob::Cluster>>& clusters = cluster_m.at(i);
183 
184  std::vector<unsigned int> one_pair;
185  one_pair.reserve(clusters.size());
186 
187  for (auto const& cptr : clusters) {
188 
189  auto iter = cmap.find(cptr);
190  if (iter == cmap.end())
191  throw cet::exception(__FUNCTION__)
192  << "PFParticle=>Cluster association not valid!" << std::endl;
193 
194  one_pair.push_back((*iter).second);
195  }
196  matched_pairs.push_back(one_pair);
197  shower_pfpart_index.push_back(i);
198  }
199  // Run reconstruction
200  fManager.Reconstruct(geom, clockData, detProp, local_clusters, matched_pairs, shower_v);
201  }
202 
203  // Make sure output shower vector size is same as expected length
204  if (shower_v.size() != matched_pairs.size())
205  throw cet::exception(__FUNCTION__)
206  << "Logic error: # of matched pairs != # of reco-ed showers!" << std::endl;
207 
208  // Fill output shower vector data container
209  out_shower_v->reserve(shower_v.size());
210 
211  for (size_t i = 0; i < shower_v.size(); ++i) {
212 
213  // Set output shower ID
214  shower_v[i].set_id(i);
215 
216  out_shower_v->push_back(shower_v[i]);
217 
218  // Create shower=>cluster association
219  std::vector<art::Ptr<recob::Cluster>> ass_clusters;
220  // Create shower=>hit association
221  std::vector<art::Ptr<recob::Hit>> ass_hits;
222  for (auto const& cindex : matched_pairs[i]) {
223 
224  ass_clusters.push_back(art::Ptr<recob::Cluster>(cHandle, cindex));
225 
226  const std::vector<art::Ptr<recob::Hit>>& hits = hit_m.at(cindex);
227 
228  for (auto const& ptr : hits)
229  ass_hits.push_back(ptr);
230  }
231  // Shower=>Cluster
232  util::CreateAssn(*this, e, *(out_shower_v.get()), ass_clusters, *(sc_assn.get()));
233  // Shower=>Hits
234  util::CreateAssn(*this, e, *(out_shower_v.get()), ass_hits, *(sh_assn.get()));
235 
236  if (fUsePFParticle) {
237 
239  e.getByLabel(fInputProducer, pfHandle);
240 
241  art::Ptr<recob::PFParticle> pf_ptr(pfHandle, shower_pfpart_index[i]);
242 
243  util::CreateAssn(*this, e, *(out_shower_v.get()), pf_ptr, *(sp_assn.get()));
244  }
245  }
246 
247  // Store in an event record
248  e.put(std::move(out_shower_v));
249  e.put(std::move(sh_assn));
250  e.put(std::move(sc_assn));
251  if (fUsePFParticle) e.put(std::move(sp_assn));
252 }
::showerreco::ShowerRecoManager fManager
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
std::string fInputProducer
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
ClusterAss_t Reconstruct(geo::GeometryCore const &geom, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< std::vector< util::PxHit >> &clusters, std::vector<::recob::Shower > &showers)

Member Data Documentation

::calo::CalorimetryAlg* ShowerReco3D::fCaloAlgo
private

Definition at line 61 of file ShowerReco3D_module.cc.

::cmtool::CFAlgoTimeOverlap* ShowerReco3D::fCFAlgoTimeOverlap
private

Definition at line 65 of file ShowerReco3D_module.cc.

::cmtool::CPAlgoArray* ShowerReco3D::fCPAlgoArray
private

Definition at line 62 of file ShowerReco3D_module.cc.

::cmtool::CPAlgoIgnoreTracks* ShowerReco3D::fCPAlgoIgnoreTracks
private

Definition at line 64 of file ShowerReco3D_module.cc.

::cmtool::CPAlgoNHits* ShowerReco3D::fCPAlgoNHits
private

Definition at line 63 of file ShowerReco3D_module.cc.

std::string ShowerReco3D::fInputProducer
private

Definition at line 58 of file ShowerReco3D_module.cc.

::showerreco::ShowerRecoManager ShowerReco3D::fManager
private

Definition at line 59 of file ShowerReco3D_module.cc.

::showerreco::ShowerRecoAlg* ShowerReco3D::fShowerAlgo
private

Definition at line 60 of file ShowerReco3D_module.cc.

bool ShowerReco3D::fUsePFParticle
private

Definition at line 57 of file ShowerReco3D_module.cc.


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