All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ShowerReco3D Class Reference
Inheritance diagram for ShowerReco3D:

Public Member Functions

 ShowerReco3D (fhicl::ParameterSet const &p)
 
 ShowerReco3D (ShowerReco3D const &)=delete
 
 ShowerReco3D (ShowerReco3D &&)=delete
 
ShowerReco3Doperator= (ShowerReco3D const &)=delete
 
ShowerReco3Doperator= (ShowerReco3D &&)=delete
 

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
 

Detailed Description

Definition at line 42 of file ShowerReco3D_module.cc.

Constructor & Destructor Documentation

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

Definition at line 70 of file ShowerReco3D_module.cc.

70  : EDProducer{p}
71 {
72  fInputProducer = p.get<std::string>("InputProducer");
73  fUsePFParticle = p.get<bool>("UsePFParticle");
74  produces<std::vector<recob::Shower>>();
75  produces<art::Assns<recob::Shower, recob::Cluster>>();
76  produces<art::Assns<recob::Shower, recob::Hit>>();
77  if (fUsePFParticle) produces<art::Assns<recob::PFParticle, recob::Shower>>();
78 
79  // Instantiate algorithms
80  fCaloAlgo = new ::calo::CalorimetryAlg(p.get<fhicl::ParameterSet>("CalorimetryAlg"));
81  fShowerAlgo = new ::showerreco::ShowerRecoAlg;
82  fCPAlgoArray = new ::cmtool::CPAlgoArray;
83  fCPAlgoNHits = new ::cmtool::CPAlgoNHits;
84  fCPAlgoIgnoreTracks = new ::cmtool::CPAlgoIgnoreTracks;
85  fCFAlgoTimeOverlap = new ::cmtool::CFAlgoTimeOverlap;
86 
87  // Configure
88  fCPAlgoNHits->SetMinHits(p.get<int>("MinHits"));
89 
92 
95 
96  fShowerAlgo->Verbose(p.get<bool>("Verbosity"));
97  fShowerAlgo->SetUseArea(p.get<bool>("UseArea"));
98  fShowerAlgo->setEcorrection(p.get<bool>("ApplyMCEnergyCorrection"));
99  fShowerAlgo->CaloAlgo(fCaloAlgo);
100 
102 }
void Algo(ShowerRecoAlgBase *alg)
::calo::CalorimetryAlg * fCaloAlgo
::cmtool::CPAlgoArray * fCPAlgoArray
::showerreco::ShowerRecoManager fManager
pdgs p
Definition: selectors.fcl:22
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
BEGIN_PROLOG local::showertrajpointdedx icarus_pandorashower_3dTraj ShowerFinderTools[3] CalorimetryAlg
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)
overrideprivate

Definition at line 105 of file ShowerReco3D_module.cc.

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

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

Definition at line 67 of file ShowerReco3D_module.cc.

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

Definition at line 64 of file ShowerReco3D_module.cc.

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

Definition at line 66 of file ShowerReco3D_module.cc.

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

Definition at line 65 of file ShowerReco3D_module.cc.

std::string ShowerReco3D::fInputProducer
private

Definition at line 60 of file ShowerReco3D_module.cc.

::showerreco::ShowerRecoManager ShowerReco3D::fManager
private

Definition at line 61 of file ShowerReco3D_module.cc.

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

Definition at line 62 of file ShowerReco3D_module.cc.

bool ShowerReco3D::fUsePFParticle
private

Definition at line 59 of file ShowerReco3D_module.cc.


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