LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
ems::EMShower3D Class Reference
Inheritance diagram for ems::EMShower3D:
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

 EMShower3D (fhicl::ParameterSet const &p)
 
 EMShower3D (EMShower3D const &)=delete
 
 EMShower3D (EMShower3D &&)=delete
 
EMShower3Doperator= (EMShower3D const &)=delete
 
EMShower3Doperator= (EMShower3D &&)=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)
 
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 &e) override
 
recob::Track ConvertFrom (detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, pma::Track3D &src)
 
recob::Track ConvertFrom2 (detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, pma::Track3D &src)
 
recob::Cluster ConvertFrom (const std::vector< art::Ptr< recob::Hit >> &src)
 
std::vector< ems::DirOfGamma * > CollectShower2D (detinfo::DetectorPropertiesData const &detProp, art::Event const &e)
 
void Link (detinfo::DetectorPropertiesData const &detProp, std::vector< ems::DirOfGamma * > input)
 
void Reoptimize (detinfo::DetectorPropertiesData const &detProp)
 
void Make3DSeg (detinfo::DetectorPropertiesData const &detProp, std::vector< ems::DirOfGamma * > pair)
 
bool Validate (detinfo::DetectorPropertiesData const &detProp, std::vector< ems::DirOfGamma * > input, size_t id1, size_t id2, size_t c1, size_t c2, size_t plane3)
 
void FilterOutSmallParts (detinfo::DetectorPropertiesData const &detProp, double r2d, const std::vector< art::Ptr< recob::Hit >> &hits_in, std::vector< art::Ptr< recob::Hit >> &hits_out)
 
bool GetCloseHits (detinfo::DetectorPropertiesData const &detProp, double r2d, const std::vector< art::Ptr< recob::Hit >> &hits_in, std::vector< size_t > &used, std::vector< art::Ptr< recob::Hit >> &hits_out)
 
bool Has (const std::vector< size_t > &v, size_t idx)
 
size_t LinkCandidates (detinfo::DetectorPropertiesData const &detProp, std::vector< ems::DirOfGamma * > input, size_t id)
 

Private Attributes

std::vector< IniSeg > fInisegs
 
std::vector< IniSeg > fSeltracks
 
std::vector< IniSeg > fPMA3D
 
std::vector< std::vector< art::Ptr< recob::Hit > > > fClusters
 
std::vector< size_t > fClustersNotUsed
 
std::vector< size_t > fTracksNotUsed
 
unsigned int fTrkIndex
 
unsigned int fClIndex
 
unsigned int fIniIndex
 
std::string fCluModuleLabel
 
std::string fTrk3DModuleLabel
 
pma::ProjectionMatchingAlg fProjectionMatchingAlg
 
calo::CalorimetryAlg fCalorimetryAlg
 
art::Handle< std::vector< recob::Cluster > > fCluListHandle
 

Detailed Description

Definition at line 54 of file EMShower3D_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

ems::EMShower3D::EMShower3D ( fhicl::ParameterSet const &  p)
explicit

Definition at line 132 of file EMShower3D_module.cc.

References fCalorimetryAlg, fCluModuleLabel, fProjectionMatchingAlg, and fTrk3DModuleLabel.

133  : EDProducer{p}
134  , fProjectionMatchingAlg(p.get<fhicl::ParameterSet>("ProjectionMatchingAlg"))
135  , fCalorimetryAlg(p.get<fhicl::ParameterSet>("CalorimetryAlg"))
136 {
137  fCluModuleLabel = p.get<std::string>("ClustersModuleLabel");
138  fTrk3DModuleLabel = p.get<std::string>("Trk3DModuleLabel");
139 
140  produces<std::vector<recob::Track>>();
141  produces<std::vector<recob::Vertex>>();
142  produces<std::vector<recob::Cluster>>();
143  produces<std::vector<recob::SpacePoint>>();
144  produces<art::Assns<recob::Track, recob::Hit>>();
145  produces<art::Assns<recob::Track, recob::Vertex>>();
146  produces<art::Assns<recob::Cluster, recob::Hit>>();
147  produces<art::Assns<recob::Track, recob::SpacePoint>>();
148  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
149  produces<art::Assns<recob::Track, recob::Cluster>>();
150 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
std::string fTrk3DModuleLabel
calo::CalorimetryAlg fCalorimetryAlg
pma::ProjectionMatchingAlg fProjectionMatchingAlg
std::string fCluModuleLabel
ems::EMShower3D::EMShower3D ( EMShower3D const &  )
delete
ems::EMShower3D::EMShower3D ( EMShower3D &&  )
delete

Member Function Documentation

std::vector< ems::DirOfGamma * > ems::EMShower3D::CollectShower2D ( detinfo::DetectorPropertiesData const &  detProp,
art::Event const &  e 
)
private

Definition at line 582 of file EMShower3D_module.cc.

References fb(), fCluListHandle, fCluModuleLabel, fClusters, FilterOutSmallParts(), art::ProductRetriever::getByLabel(), and ems::DirOfGamma::GetHits2D().

Referenced by produce().

585 {
586  std::vector<ems::DirOfGamma*> input;
587 
588  if (e.getByLabel(fCluModuleLabel, fCluListHandle)) {
590  for (unsigned int c = 0; c < fCluListHandle->size(); c++) {
591  std::vector<art::Ptr<recob::Hit>> hitlist;
592  hitlist = fb.at(c);
593 
594  if (hitlist.size() > 5) {
595  std::vector<art::Ptr<recob::Hit>> hits_out;
596  FilterOutSmallParts(detProp, 2.0, hitlist, hits_out);
597 
598  if (hits_out.size() > 5) {
599  fClusters.push_back(hits_out);
600 
601  ems::DirOfGamma* sh = new ems::DirOfGamma(detProp, hits_out, 14, c);
602 
603  if (sh->GetHits2D().size()) input.push_back(sh);
604  }
605  }
606  }
607  }
608 
609  return input;
610 }
std::vector< std::vector< art::Ptr< recob::Hit > > > fClusters
art::Handle< std::vector< recob::Cluster > > fCluListHandle
void FilterOutSmallParts(detinfo::DetectorPropertiesData const &detProp, double r2d, const std::vector< art::Ptr< recob::Hit >> &hits_in, std::vector< art::Ptr< recob::Hit >> &hits_out)
std::vector< Hit2D * > const & GetHits2D() const
Definition: DirOfGamma.h:133
TFile fb("Li6.root")
Float_t e
Definition: plot.C:35
std::string fCluModuleLabel
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 &)
recob::Track ems::EMShower3D::ConvertFrom ( detinfo::DetectorClocksData const &  clock_data,
detinfo::DetectorPropertiesData const &  det_prop,
pma::Track3D src 
)
private

Definition at line 180 of file EMShower3D_module.cc.

References pma::Track3D::back(), recob::tracking::convertCollToPoint(), recob::tracking::convertCollToVector(), detinfo::DetectorPropertiesData::ConvertXToTicks(), pma::Hit3D::Cryo(), calo::CalorimetryAlg::dEdx_AREA(), fCalorimetryAlg, fIniIndex, fProjectionMatchingAlg, pma::Track3D::front(), Get, pma::Hit3D::Point3D(), pma::ProjectionMatchingAlg::selectInitialHits(), pma::Track3D::size(), and pma::Hit3D::TPC().

Referenced by produce().

183 {
184  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
185  double avdrift = (src.front()->Point3D().X() + src.back()->Point3D().X()) * 0.5;
186  unsigned int nplanes = wireReadoutGeom.Nplanes({src.front()->Cryo(), src.front()->TPC()});
187  size_t nusedhitsmax = 0;
188  int bestplane = -1;
189  for (unsigned int p = 0; p < nplanes; ++p) {
190  unsigned int nusedP = 0;
191  fProjectionMatchingAlg.selectInitialHits(src, p, &nusedP);
192 
193  if (nusedP > nusedhitsmax) {
194  nusedhitsmax = nusedP;
195  bestplane = int(p);
196  }
197  }
198 
199  std::vector<std::vector<double>> vdedx;
200  std::vector<double> dedx;
201 
202  for (unsigned int p = 0; p < nplanes; ++p) {
203  unsigned int nusedP = 0;
204  double dqdxplane = fProjectionMatchingAlg.selectInitialHits(src, p, &nusedP);
205  double timeP = detProp.ConvertXToTicks(avdrift, p, src.front()->TPC(), src.front()->Cryo());
206  double dEdxplane = fCalorimetryAlg.dEdx_AREA(clock_data, detProp, dqdxplane, timeP, p);
207  dedx.push_back(dEdxplane);
208  if (int(p) == bestplane)
209  dedx.push_back(1);
210  else
211  dedx.push_back(0);
212  vdedx.push_back(dedx);
213  }
214 
215  std::vector<TVector3> xyz, dircos;
216 
217  for (size_t i = 0; i < src.size(); i++) {
218  xyz.push_back(src[i]->Point3D());
219 
220  if (i < src.size() - 1) {
221  TVector3 dc(src[i + 1]->Point3D());
222  dc -= src[i]->Point3D();
223  dc *= 1.0 / dc.Mag();
224  dircos.push_back(dc);
225  }
226  else
227  dircos.push_back(dircos.back());
228  }
229 
232  recob::Track::Flags_t(xyz.size()),
233  false),
234  0,
235  -1.,
236  0,
239  fIniIndex);
240 }
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
Definition: TrackingTypes.h:78
pma::Hit3D const * front() const
Definition: PmaTrack3D.h:87
unsigned int Cryo() const noexcept
Definition: PmaHit3D.h:58
TrackTrajectory::Flags_t Flags_t
Definition: Track.h:67
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
TVector3 const & Point3D() const
Definition: PmaHit3D.h:50
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 >> SMatrixSym55
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
unsigned int fIniIndex
double selectInitialHits(pma::Track3D &trk, unsigned int view=geo::kZ, unsigned int *nused=0) const
A trajectory in space reconstructed from hits.
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
Definition: TrackingTypes.h:68
calo::CalorimetryAlg fCalorimetryAlg
pma::ProjectionMatchingAlg fProjectionMatchingAlg
double dEdx_AREA(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, recob::Hit const &hit, double pitch, double T0=0) const
pma::Hit3D const * back() const
Definition: PmaTrack3D.h:88
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:992
unsigned int TPC() const noexcept
Definition: PmaHit3D.h:59
size_t size() const
Definition: PmaTrack3D.h:89
recob::Cluster ems::EMShower3D::ConvertFrom ( const std::vector< art::Ptr< recob::Hit >> &  src)
private

Definition at line 152 of file EMShower3D_module.cc.

References fClIndex.

153 {
154  return recob::Cluster(0.0F,
155  0.0F,
156  0.0F,
157  0.0F,
158  0.0F,
159  0.0F,
160  0.0F,
161  0.0F,
162  0.0F,
163  0.0F,
164  0.0F,
165  0.0F,
166  0.0F,
167  0.0F,
168  0.0F,
169  0.0F,
170  0.0F,
171  0.0F,
172  src.size(),
173  0.0F,
174  0.0F,
175  fClIndex,
176  src[0]->View(),
177  src[0]->WireID().planeID());
178 }
Set of hits with a 2D structure.
Definition: Cluster.h:69
unsigned int fClIndex
recob::Track ems::EMShower3D::ConvertFrom2 ( detinfo::DetectorClocksData const &  clock_data,
detinfo::DetectorPropertiesData const &  det_prop,
pma::Track3D src 
)
private

Definition at line 242 of file EMShower3D_module.cc.

References pma::Track3D::back(), recob::tracking::convertCollToPoint(), recob::tracking::convertCollToVector(), detinfo::DetectorPropertiesData::ConvertXToTicks(), pma::Hit3D::Cryo(), calo::CalorimetryAlg::dEdx_AREA(), fCalorimetryAlg, fIniIndex, fProjectionMatchingAlg, pma::Track3D::front(), Get, pma::Hit3D::Point3D(), pma::ProjectionMatchingAlg::selectInitialHits(), pma::Track3D::size(), and pma::Hit3D::TPC().

Referenced by produce().

245 {
246  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
247 
248  double avdrift = (src.front()->Point3D().X() + src.back()->Point3D().X()) * 0.5;
249  unsigned int nplanes = wireReadoutGeom.Nplanes({src.front()->Cryo(), src.front()->TPC()});
250  size_t nusedhitsmax = 0;
251  int bestplane = -1;
252  for (unsigned int p = 0; p < nplanes; ++p) {
253  unsigned int nusedP = 0;
254  fProjectionMatchingAlg.selectInitialHits(src, p, &nusedP);
255 
256  if (nusedP > nusedhitsmax) {
257  nusedhitsmax = nusedP;
258  bestplane = int(p);
259  }
260  }
261 
262  std::vector<std::vector<double>> vdedx;
263  std::vector<double> dedx;
264 
265  for (unsigned int p = 0; p < nplanes; ++p) {
266  unsigned int nusedP = 0;
267  double dqdxplane = fProjectionMatchingAlg.selectInitialHits(src, p, &nusedP);
268  double timeP = detProp.ConvertXToTicks(avdrift, p, src.front()->TPC(), src.front()->Cryo());
269  double dEdxplane = fCalorimetryAlg.dEdx_AREA(clockData, detProp, dqdxplane, timeP, p);
270  dedx.push_back(dEdxplane);
271  if (int(p) == bestplane)
272  dedx.push_back(1);
273  else
274  dedx.push_back(0);
275  vdedx.push_back(dedx);
276  }
277 
278  std::vector<TVector3> xyz, dircos;
279 
280  for (size_t i = 0; i < src.size(); i++) {
281  xyz.push_back(src[i]->Point3D());
282 
283  if (i < src.size() - 1) {
284  TVector3 dc(src[i + 1]->Point3D());
285  dc -= src[i]->Point3D();
286  dc *= 1.0 / dc.Mag();
287  dircos.push_back(dc);
288  }
289  else
290  dircos.push_back(dircos.back());
291  }
292 
295  recob::Track::Flags_t(xyz.size()),
296  false),
297  0,
298  -1.,
299  0,
302  fIniIndex);
303 }
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
Definition: TrackingTypes.h:78
pma::Hit3D const * front() const
Definition: PmaTrack3D.h:87
unsigned int Cryo() const noexcept
Definition: PmaHit3D.h:58
TrackTrajectory::Flags_t Flags_t
Definition: Track.h:67
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
TVector3 const & Point3D() const
Definition: PmaHit3D.h:50
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 >> SMatrixSym55
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
unsigned int fIniIndex
double selectInitialHits(pma::Track3D &trk, unsigned int view=geo::kZ, unsigned int *nused=0) const
A trajectory in space reconstructed from hits.
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
Definition: TrackingTypes.h:68
calo::CalorimetryAlg fCalorimetryAlg
pma::ProjectionMatchingAlg fProjectionMatchingAlg
double dEdx_AREA(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, recob::Hit const &hit, double pitch, double T0=0) const
pma::Hit3D const * back() const
Definition: PmaTrack3D.h:88
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:992
unsigned int TPC() const noexcept
Definition: PmaHit3D.h:59
size_t size() const
Definition: PmaTrack3D.h:89
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
void ems::EMShower3D::FilterOutSmallParts ( detinfo::DetectorPropertiesData const &  detProp,
double  r2d,
const std::vector< art::Ptr< recob::Hit >> &  hits_in,
std::vector< art::Ptr< recob::Hit >> &  hits_out 
)
private

Definition at line 942 of file EMShower3D_module.cc.

References DEFINE_ART_MODULE, and GetCloseHits().

Referenced by CollectShower2D().

946 {
947  size_t min_size = hits_in.size() / 5;
948  if (min_size < 3) min_size = 3;
949 
950  std::vector<size_t> used;
951  std::vector<art::Ptr<recob::Hit>> close_hits;
952 
953  while (GetCloseHits(detProp, r2d, hits_in, used, close_hits)) {
954  if (close_hits.size() > min_size)
955  for (auto h : close_hits)
956  hits_out.push_back(h);
957  }
958 }
bool GetCloseHits(detinfo::DetectorPropertiesData const &detProp, double r2d, const std::vector< art::Ptr< recob::Hit >> &hits_in, std::vector< size_t > &used, std::vector< art::Ptr< recob::Hit >> &hits_out)
bool ems::EMShower3D::GetCloseHits ( detinfo::DetectorPropertiesData const &  detProp,
double  r2d,
const std::vector< art::Ptr< recob::Hit >> &  hits_in,
std::vector< size_t > &  used,
std::vector< art::Ptr< recob::Hit >> &  hits_out 
)
private

Definition at line 867 of file EMShower3D_module.cc.

References geo::CryostatID::Cryostat, pma::Dist2(), Has(), recob::Hit::PeakTime(), geo::PlaneID::Plane, geo::TPCID::TPC, geo::WireID::Wire, pma::WireDriftToCm(), and recob::Hit::WireID().

Referenced by FilterOutSmallParts().

872 {
873 
874  hits_out.clear();
875 
876  const double gapMargin = 5.0; // can be changed to f(id_tpc1, id_tpc2)
877  size_t idx = 0;
878 
879  while ((idx < hits_in.size()) && Has(used, idx))
880  idx++;
881 
882  if (idx < hits_in.size()) {
883  hits_out.push_back(hits_in[idx]);
884  used.push_back(idx);
885 
886  double r2d2 = r2d * r2d;
887  double gapMargin2 = sqrt(2 * gapMargin * gapMargin);
888  gapMargin2 = (gapMargin2 + r2d) * (gapMargin2 + r2d);
889 
890  bool collect = true;
891  while (collect) {
892  collect = false;
893  for (size_t i = 0; i < hits_in.size(); i++)
894  if (!Has(used, i)) {
895  art::Ptr<recob::Hit> hi = hits_in[i];
896  TVector2 hi_cm = pma::WireDriftToCm(detProp,
897  hi->WireID().Wire,
898  hi->PeakTime(),
899  hi->WireID().Plane,
900  hi->WireID().TPC,
901  hi->WireID().Cryostat);
902 
903  bool accept = false;
904  // for (auto const& ho : hits_out)
905  for (size_t idx_o = 0; idx_o < hits_out.size(); idx_o++) {
906  art::Ptr<recob::Hit> ho = hits_out[idx_o];
907 
908  double d2 = pma::Dist2(hi_cm,
909  pma::WireDriftToCm(detProp,
910  ho->WireID().Wire,
911  ho->PeakTime(),
912  ho->WireID().Plane,
913  ho->WireID().TPC,
914  ho->WireID().Cryostat));
915 
916  if (hi->WireID().TPC == ho->WireID().TPC) {
917  if (d2 < r2d2) {
918  accept = true;
919  break;
920  }
921  }
922  else {
923  if (d2 < gapMargin2) {
924  accept = true;
925  break;
926  }
927  }
928  }
929  if (accept) {
930  collect = true;
931  hits_out.push_back(hi);
932  used.push_back(i);
933  }
934  }
935  }
936  return true;
937  }
938  else
939  return false;
940 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:195
TVector2 WireDriftToCm(detinfo::DetectorPropertiesData const &detProp, unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:286
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:430
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:290
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:373
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:226
bool Has(const std::vector< size_t > &v, size_t idx)
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:315
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
bool ems::EMShower3D::Has ( const std::vector< size_t > &  v,
size_t  idx 
)
private

Definition at line 860 of file EMShower3D_module.cc.

Referenced by GetCloseHits().

861 {
862  for (auto c : v)
863  if (c == idx) return true;
864  return false;
865 }
void ems::EMShower3D::Link ( detinfo::DetectorPropertiesData const &  detProp,
std::vector< ems::DirOfGamma * >  input 
)
private

Definition at line 612 of file EMShower3D_module.cc.

References detinfo::DetectorPropertiesData::ConvertTicksToX(), larg4::dist(), LinkCandidates(), Make3DSeg(), t1, and t2.

Referenced by produce().

614 {
615  std::vector<std::vector<size_t>> saveids;
616  std::vector<size_t> saveidsnotusedcls;
617  size_t i = 0;
618 
619  while (i < input.size()) {
620  if (!input[i]->GetCandidates().size()) {
621  i++;
622  continue;
623  }
624 
625  double mindist = 1.0; // cm
626  std::vector<ems::DirOfGamma*> pairs;
627 
628  size_t startview = input[i]->GetFirstHit()->WireID().Plane;
629  size_t tpc = input[i]->GetFirstHit()->WireID().TPC;
630  size_t cryo = input[i]->GetFirstHit()->WireID().Cryostat;
631 
632  float t1 = detProp.ConvertTicksToX(input[i]->GetFirstHit()->PeakTime(), startview, tpc, cryo);
633 
634  unsigned int idsave = 0;
635  for (unsigned int j = 0; j < input.size(); j++) {
636  if (!input[j]->GetCandidates().size()) continue;
637 
638  size_t secondview = input[j]->GetFirstHit()->WireID().Plane;
639  size_t tpc_j = input[j]->GetFirstHit()->WireID().TPC;
640  size_t cryo_j = input[j]->GetFirstHit()->WireID().Cryostat;
641 
642  if ((i != j) && (secondview != startview) && (tpc == tpc_j) && (cryo == cryo_j)) {
643  float t2 =
644  detProp.ConvertTicksToX(input[j]->GetFirstHit()->PeakTime(), secondview, tpc_j, cryo_j);
645  float dist = fabs(t2 - t1);
646 
647  if (dist < mindist) {
648  mindist = dist;
649  pairs.clear();
650  pairs.push_back(input[i]);
651  pairs.push_back(input[j]);
652  idsave = j;
653  }
654  }
655  }
656 
657  bool exist = false;
658  for (unsigned int v = 0; v < saveids.size(); v++)
659  if ((saveids[v][0] == i) || (saveids[v][0] == idsave))
660  if ((saveids[v][1] == i) || (saveids[v][1] == idsave)) exist = true;
661 
662  if (pairs.size()) {
663  if (!exist) Make3DSeg(detProp, pairs);
664 
665  std::vector<size_t> ids;
666  ids.push_back(i);
667  ids.push_back(idsave);
668  saveids.push_back(ids);
669  }
670  else {
671  saveidsnotusedcls.push_back(i);
672  }
673 
674  i++;
675  }
676 
677  i = 0;
678  while (i < saveidsnotusedcls.size()) {
679  LinkCandidates(detProp, input, i);
680  i++;
681  }
682 }
TTree * t1
Definition: plottest35.C:26
void Make3DSeg(detinfo::DetectorPropertiesData const &detProp, std::vector< ems::DirOfGamma * > pair)
size_t LinkCandidates(detinfo::DetectorPropertiesData const &detProp, std::vector< ems::DirOfGamma * > input, size_t id)
TTree * t2
Definition: plottest35.C:36
double dist(const TReal *x, const TReal *y, const unsigned int dimension)
size_t ems::EMShower3D::LinkCandidates ( detinfo::DetectorPropertiesData const &  detProp,
std::vector< ems::DirOfGamma * >  input,
size_t  id 
)
private

Definition at line 684 of file EMShower3D_module.cc.

References larg4::dist(), Get, Make3DSeg(), util::size(), t1, t2, and Validate().

Referenced by Link().

687 {
688  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
689 
690  size_t index = id;
691  bool found = false;
692 
693  if (input[id]->GetCandidates().size() < 2) { return index; }
694 
695  double mindist = 3.0; // cm
696  std::vector<ems::DirOfGamma*> pairs;
697 
698  size_t idcsave = 0;
699  size_t idcjsave = 0;
700  size_t c = 0;
701  size_t idsave = 0;
702  while (c < input[id]->GetCandidates().size()) {
703 
704  size_t startview = input[id]->GetCandidates()[c].GetPlane();
705  size_t tpc = input[id]->GetCandidates()[c].GetTPC();
706  size_t cryo = input[id]->GetCandidates()[c].GetCryo();
707 
708  float t1 = input[id]->GetCandidates()[c].GetPosition().Y(); // y --> drift in 2D space.
709 
710  // loop over 2D showers
711  for (size_t j = 0; j < input.size(); ++j) {
712  if (!input[j]->GetCandidates().size()) continue;
713  if (j == id) continue;
714 
715  // loop over candidates
716  for (size_t cj = 0; cj < input[j]->GetCandidates().size(); ++cj) {
717  size_t secondview = input[j]->GetCandidates()[cj].GetPlane();
718  size_t tpc_j = input[j]->GetCandidates()[cj].GetTPC();
719  size_t cryo_j = input[j]->GetCandidates()[cj].GetCryo();
720 
721  size_t thirdview = startview;
722 
723  for (geo::PlaneGeo const& plane :
724  wireReadoutGeom.Iterate<geo::PlaneGeo>(geo::CryostatID(cryo))) {
725  auto const p = plane.ID().Plane;
726  if ((p == startview) || (p == secondview)) { continue; }
727  else {
728  thirdview = p;
729  break;
730  }
731  }
732 
733  if ((startview != secondview) && (tpc == tpc_j) && (cryo == cryo_j)) {
734  float t2 = input[j]->GetCandidates()[cj].GetPosition().Y();
735  float dist = fabs(t2 - t1);
736 
737  if ((dist < mindist) && Validate(detProp, input, id, j, c, cj, thirdview)) {
738  mindist = dist;
739  pairs.clear();
740  pairs.push_back(input[id]);
741  pairs.push_back(input[j]);
742  idsave = j;
743  index = j;
744  idcsave = c;
745  idcjsave = cj;
746  found = true;
747  }
748  }
749  }
750  }
751 
752  c++;
753  }
754 
755  if (found && pairs.size()) {
756  input[id]->SetIdCandidate(idcsave);
757  input[idsave]->SetIdCandidate(idcjsave);
758  Make3DSeg(detProp, pairs);
759  }
760 
761  return index;
762 }
TTree * t1
Definition: plottest35.C:26
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
bool Validate(detinfo::DetectorPropertiesData const &detProp, std::vector< ems::DirOfGamma * > input, size_t id1, size_t id2, size_t c1, size_t c2, size_t plane3)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
void Make3DSeg(detinfo::DetectorPropertiesData const &detProp, std::vector< ems::DirOfGamma * > pair)
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:67
TTree * t2
Definition: plottest35.C:36
double dist(const TReal *x, const TReal *y, const unsigned int dimension)
The data type to uniquely identify a cryostat.
Definition: geo_types.h:187
void ems::EMShower3D::Make3DSeg ( detinfo::DetectorPropertiesData const &  detProp,
std::vector< ems::DirOfGamma * >  pair 
)
private

Definition at line 764 of file EMShower3D_module.cc.

References pma::Track3D::back(), pma::ProjectionMatchingAlg::buildSegment(), fInisegs, pma::Track3D::Flip(), fProjectionMatchingAlg, and pma::Hit3D::Hit2DPtr().

Referenced by Link(), and LinkCandidates().

766 {
767  if (pair.size() < 2) return;
768 
769  // to build a track correctly 2d hits must belong to the same tpc
770  size_t tpc1 = pair[0]->GetFirstHit()->WireID().TPC;
771  size_t tpc2 = pair[1]->GetFirstHit()->WireID().TPC;
772 
773  std::vector<art::Ptr<recob::Hit>> vec1 = pair[0]->GetIniHits();
774  std::vector<art::Ptr<recob::Hit>> vec2 = pair[1]->GetIniHits();
775 
776  if ((vec1.size() < 3) && (vec2.size() < 3)) return;
777 
778  std::vector<art::Ptr<recob::Hit>> hitscl1uniquetpc;
779  std::vector<art::Ptr<recob::Hit>> hitscl2uniquetpc;
780 
781  if (tpc1 == tpc2)
782  for (size_t i = 0; i < vec1.size(); ++i)
783  for (size_t j = 0; j < vec2.size(); ++j)
784  if ((vec1[i]->WireID().TPC == vec2[j]->WireID().TPC) && (tpc1 == vec2[j]->WireID().TPC)) {
785  hitscl1uniquetpc.push_back(vec1[i]);
786  hitscl2uniquetpc.push_back(vec2[j]);
787  }
788 
789  if ((hitscl1uniquetpc.size() > 2) && (hitscl2uniquetpc.size() > 2)) {
790  pma::Track3D* trk =
791  fProjectionMatchingAlg.buildSegment(detProp, hitscl1uniquetpc, hitscl2uniquetpc);
792 
793  // turn the track that front is at vertex - easier to handle associations.
794  if ((trk->back()->Hit2DPtr() == pair[0]->GetFirstHit()) ||
795  (trk->back()->Hit2DPtr() == pair[1]->GetFirstHit()))
796  trk->Flip();
797 
798  IniSeg initrack;
799  initrack.idcl1 = pair[0]->GetIdCl();
800  initrack.view1 = pair[0]->GetFirstHit()->WireID().Plane;
801  initrack.hits1 = hitscl1uniquetpc;
802  initrack.idcl2 = pair[1]->GetIdCl();
803  initrack.view2 = pair[1]->GetFirstHit()->WireID().Plane;
804  initrack.hits2 = hitscl2uniquetpc;
805  initrack.track = trk;
806 
807  fInisegs.push_back(initrack);
808  }
809 }
std::vector< IniSeg > fInisegs
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
pma::Track3D * buildSegment(const detinfo::DetectorPropertiesData &clockData, const std::vector< art::Ptr< recob::Hit >> &hits_1, const std::vector< art::Ptr< recob::Hit >> &hits_2={}) const
pma::ProjectionMatchingAlg fProjectionMatchingAlg
pma::Hit3D const * back() const
Definition: PmaTrack3D.h:88
art::Ptr< recob::Hit > const & Hit2DPtr() const
Definition: PmaHit3D.h:48
bool Flip(const detinfo::DetectorPropertiesData &detProp, std::vector< pma::Track3D * > &allTracks)
Definition: PmaTrack3D.cxx:527
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(), reco::shower::LArPandoraModularShowerCreation::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
EMShower3D& ems::EMShower3D::operator= ( EMShower3D const &  )
delete
EMShower3D& ems::EMShower3D::operator= ( EMShower3D &&  )
delete
void ems::EMShower3D::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 305 of file EMShower3D_module.cc.

References art::PtrVector< T >::clear(), CollectShower2D(), ConvertFrom(), ConvertFrom2(), util::CreateAssn(), fb(), fClIndex, fCluListHandle, fCluModuleLabel, fClusters, fClustersNotUsed, fIniIndex, fInisegs, fPMA3D, fSeltracks, fTrkIndex, art::ProductRetriever::getByLabel(), pma::Hit3D::Hit2DPtr(), Link(), pma::Hit3D::Point3D(), art::PtrVector< T >::push_back(), art::Event::put(), Reoptimize(), art::PtrVector< T >::size(), and track.

306 {
308  fSeltracks.clear();
309  fInisegs.clear();
310  fClusters.clear();
311  fPMA3D.clear();
312  fClustersNotUsed.clear();
313 
314  auto tracks = std::make_unique<std::vector<recob::Track>>();
315  auto vertices = std::make_unique<std::vector<recob::Vertex>>();
316  auto clusters = std::make_unique<std::vector<recob::Cluster>>();
317  auto allsp = std::make_unique<std::vector<recob::SpacePoint>>();
318 
319  auto trk2hit = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
320  auto trk2vtx = std::make_unique<art::Assns<recob::Track, recob::Vertex>>();
321  auto cl2hit = std::make_unique<art::Assns<recob::Cluster, recob::Hit>>();
322  auto trk2cl = std::make_unique<art::Assns<recob::Track, recob::Cluster>>();
323  auto trk2sp = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
324  auto sp2hit = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
325 
326  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
327  auto const detProp =
329 
331  fClustersNotUsed.clear();
332  fInisegs.clear();
334 
335  for (size_t id = 0; id < fCluListHandle->size(); id++) {
336  std::vector<art::Ptr<recob::Hit>> hitlist;
337  hitlist = fb.at(id);
338 
339  if (hitlist.size() > 5) fClustersNotUsed.push_back(id);
340  }
341 
342  std::vector<ems::DirOfGamma*> showernviews = CollectShower2D(detProp, e);
343 
344  Link(detProp, showernviews);
345 
346  while (fInisegs.size()) {
347  fSeltracks.push_back(fInisegs[0]);
348  fInisegs.erase(fInisegs.begin() + 0);
349  }
350 
351  Reoptimize(detProp);
352 
353  // conversion from pma track to recob::track
354 
355  size_t spStart = 0, spEnd = 0;
356  double sp_pos[3], sp_err[6], vtx_pos[3];
357  for (size_t i = 0; i < 6; i++)
358  sp_err[i] = 1.0;
359 
360  fTrkIndex = 0;
361 
362  for (auto const& trk : fSeltracks) {
363  tracks->push_back(ConvertFrom(clockData, detProp, *(trk.track)));
364 
365  vtx_pos[0] = trk.track->front()->Point3D().X();
366  vtx_pos[1] = trk.track->front()->Point3D().Y();
367  vtx_pos[2] = trk.track->front()->Point3D().Z();
368  vertices->emplace_back(vtx_pos, fTrkIndex);
369 
370  ++fTrkIndex;
371 
372  std::vector<art::Ptr<recob::Cluster>> cl2d;
373  cl2d.emplace_back(fCluListHandle, trk.idcl1);
374  cl2d.emplace_back(fCluListHandle, trk.idcl2);
375 
376  std::vector<art::Ptr<recob::Hit>> hits2d;
378 
379  spStart = allsp->size();
380  for (int h = trk.track->size() - 1; h >= 0; h--) {
381  pma::Hit3D* h3d = (*trk.track)[h];
382  hits2d.push_back(h3d->Hit2DPtr());
383 
384  if ((h == 0) || (sp_pos[0] != h3d->Point3D().X()) || (sp_pos[1] != h3d->Point3D().Y()) ||
385  (sp_pos[2] != h3d->Point3D().Z())) {
386  if (sp_hits.size()) // hits assigned to the previous sp
387  {
388  util::CreateAssn(e, *allsp, sp_hits, *sp2hit);
389  sp_hits.clear();
390  }
391  sp_pos[0] = h3d->Point3D().X();
392  sp_pos[1] = h3d->Point3D().Y();
393  sp_pos[2] = h3d->Point3D().Z();
394  allsp->push_back(recob::SpacePoint(sp_pos, sp_err, 1.0));
395  }
396  sp_hits.push_back(h3d->Hit2DPtr());
397  }
398  if (sp_hits.size()) // hits assigned to the last sp
399  {
400  util::CreateAssn(e, *allsp, sp_hits, *sp2hit);
401  }
402  spEnd = allsp->size();
403 
404  if (vertices->size()) {
405  size_t vtx_idx = (size_t)(vertices->size() - 1);
406  util::CreateAssn(e, *tracks, *vertices, *trk2vtx, vtx_idx, vtx_idx + 1);
407  }
408 
409  if (cl2d.size()) { util::CreateAssn(e, *tracks, cl2d, *trk2cl); }
410 
411  if (hits2d.size()) {
412  util::CreateAssn(e, *tracks, *allsp, *trk2sp, spStart, spEnd);
413  util::CreateAssn(e, *tracks, hits2d, *trk2hit);
414  }
415  }
416 
417  fIniIndex = fTrkIndex + 1;
418  for (auto const& trk : fPMA3D) {
419  tracks->push_back(ConvertFrom2(clockData, detProp, *(trk.track)));
420 
421  fIniIndex++;
422 
423  std::vector<art::Ptr<recob::Cluster>> cl2d;
424  cl2d.push_back(art::Ptr<recob::Cluster>(fCluListHandle, trk.idcl1));
425  cl2d.push_back(art::Ptr<recob::Cluster>(fCluListHandle, trk.idcl2));
426 
427  std::vector<art::Ptr<recob::Hit>> hits2d;
429 
430  spStart = allsp->size();
431  for (int h = trk.track->size() - 1; h >= 0; h--) {
432  pma::Hit3D* h3d = (*trk.track)[h];
433  hits2d.push_back(h3d->Hit2DPtr());
434 
435  if ((h == 0) || (sp_pos[0] != h3d->Point3D().X()) || (sp_pos[1] != h3d->Point3D().Y()) ||
436  (sp_pos[2] != h3d->Point3D().Z())) {
437  if (sp_hits.size()) // hits assigned to the previous sp
438  {
439  util::CreateAssn(e, *allsp, sp_hits, *sp2hit);
440  sp_hits.clear();
441  }
442  sp_pos[0] = h3d->Point3D().X();
443  sp_pos[1] = h3d->Point3D().Y();
444  sp_pos[2] = h3d->Point3D().Z();
445  allsp->push_back(recob::SpacePoint(sp_pos, sp_err, 1.0));
446  }
447  sp_hits.push_back(h3d->Hit2DPtr());
448  }
449  if (sp_hits.size()) // hits assigned to the last sp
450  {
451  util::CreateAssn(e, *allsp, sp_hits, *sp2hit);
452  }
453  spEnd = allsp->size();
454 
455  if (cl2d.size()) { util::CreateAssn(e, *tracks, cl2d, *trk2cl); }
456 
457  if (hits2d.size()) {
458  util::CreateAssn(e, *tracks, *allsp, *trk2sp, spStart, spEnd);
459  util::CreateAssn(e, *tracks, hits2d, *trk2hit);
460  }
461  }
462 
463  // create cluster from hits, which were an input to find initial part of the cascade.
464  fClIndex = 0;
465  for (auto const& cl : fClusters)
466  if (cl.size()) {
467  clusters->push_back(ConvertFrom(cl));
468  fClIndex++;
469 
470  util::CreateAssn(e, *clusters, cl, *cl2hit);
471  }
472 
473  for (unsigned int i = 0; i < showernviews.size(); i++)
474  delete showernviews[i];
475 
476  for (unsigned int i = 0; i < fSeltracks.size(); i++)
477  delete fSeltracks[i].track;
478 
479  for (unsigned int i = 0; i < fInisegs.size(); i++)
480  delete fInisegs[i].track;
481 
482  for (unsigned int i = 0; i < fPMA3D.size(); i++)
483  delete fPMA3D[i].track;
484  }
485 
486  e.put(std::move(tracks));
487  e.put(std::move(vertices));
488  e.put(std::move(clusters));
489  e.put(std::move(allsp));
490 
491  e.put(std::move(trk2hit));
492  e.put(std::move(trk2vtx));
493  e.put(std::move(cl2hit));
494  e.put(std::move(trk2cl));
495  e.put(std::move(trk2sp));
496  e.put(std::move(sp2hit));
497 }
void Link(detinfo::DetectorPropertiesData const &detProp, std::vector< ems::DirOfGamma * > input)
std::vector< std::vector< art::Ptr< recob::Hit > > > fClusters
art::Handle< std::vector< recob::Cluster > > fCluListHandle
TVector3 const & Point3D() const
Definition: PmaHit3D.h:50
unsigned int fIniIndex
unsigned int fClIndex
std::vector< IniSeg > fInisegs
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
unsigned int fTrkIndex
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
std::vector< ems::DirOfGamma * > CollectShower2D(detinfo::DetectorPropertiesData const &detProp, art::Event const &e)
size_type size() const
Definition: PtrVector.h:302
TFile fb("Li6.root")
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.
std::vector< IniSeg > fPMA3D
recob::Track ConvertFrom(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, pma::Track3D &src)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
recob::Track ConvertFrom2(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, pma::Track3D &src)
std::vector< size_t > fClustersNotUsed
art::Ptr< recob::Hit > const & Hit2DPtr() const
Definition: PmaHit3D.h:48
std::vector< IniSeg > fSeltracks
void Reoptimize(detinfo::DetectorPropertiesData const &detProp)
std::string fCluModuleLabel
Float_t track
Definition: plot.C:35
void clear()
Definition: PtrVector.h:533
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 ems::EMShower3D::Reoptimize ( detinfo::DetectorPropertiesData const &  detProp)
private

Definition at line 499 of file EMShower3D_module.cc.

References pma::Track3D::back(), pma::ProjectionMatchingAlg::buildSegment(), larg4::dist(), pma::Dist2(), util::empty(), pma::Track3D::Flip(), fProjectionMatchingAlg, pma::Track3D::front(), fSeltracks, hits(), pma::Hit3D::Point3D(), and track.

Referenced by produce().

500 {
501  if (empty(fSeltracks)) return;
502  const float min_dist = 3.0F;
503  size_t ta = 0;
504  while (ta < (fSeltracks.size() - 1)) {
505  size_t tb = ta + 1;
506  bool found = false;
507  while (tb < fSeltracks.size()) {
508  if (ta == tb) {
509  tb++;
510  continue;
511  }
512 
513  TVector3 p1 = fSeltracks[ta].track->front()->Point3D();
514  TVector3 p2 = fSeltracks[tb].track->front()->Point3D();
515  float dist = std::sqrt(pma::Dist2(p1, p2));
516 
517  if (dist < min_dist)
518  if ((fSeltracks[ta].idcl1 == fSeltracks[tb].idcl1) ||
519  (fSeltracks[ta].idcl1 == fSeltracks[tb].idcl2) ||
520  (fSeltracks[ta].idcl2 == fSeltracks[tb].idcl1) ||
521  (fSeltracks[ta].idcl2 == fSeltracks[tb].idcl2)) {
522  found = true;
523  size_t view3 = fSeltracks[ta].view1;
524  size_t idcl3 = fSeltracks[ta].idcl1;
525  std::vector<art::Ptr<recob::Hit>> hits3 = fSeltracks[ta].hits1;
526  std::vector<art::Ptr<recob::Hit>> hits = fSeltracks[ta].hits1;
527  for (size_t h = 0; h < fSeltracks[ta].hits2.size(); ++h)
528  hits.push_back(fSeltracks[ta].hits2[h]);
529 
530  if ((fSeltracks[tb].view1 != fSeltracks[ta].view1) &&
531  (fSeltracks[tb].view1 != fSeltracks[ta].view2)) {
532  view3 = fSeltracks[tb].view1;
533  for (size_t h = 0; h < fSeltracks[tb].hits1.size(); ++h)
534  hits.push_back(fSeltracks[tb].hits1[h]);
535  }
536  if ((fSeltracks[tb].view2 != fSeltracks[ta].view1) &&
537  (fSeltracks[tb].view2 != fSeltracks[ta].view2)) {
538  view3 = fSeltracks[tb].view2;
539  for (size_t h = 0; h < fSeltracks[tb].hits2.size(); ++h)
540  hits.push_back(fSeltracks[tb].hits2[h]);
541  }
542 
543  if ((view3 == fSeltracks[ta].view1) || (view3 == fSeltracks[ta].view2)) {
544  delete fSeltracks[ta].track;
545  fSeltracks.erase(fSeltracks.begin() + ta);
546  }
547  else {
549 
550  if (pma::Dist2(track->back()->Point3D(), fSeltracks[ta].track->front()->Point3D()) <
551  pma::Dist2(track->front()->Point3D(), fSeltracks[ta].track->front()->Point3D()))
552  track->Flip();
553 
554  IniSeg initrack;
555  initrack.idcl1 = fSeltracks[ta].idcl1;
556  initrack.idcl3 = idcl3;
557  initrack.view1 = fSeltracks[ta].view1;
558  initrack.view3 = view3;
559  initrack.hits1 = fSeltracks[ta].hits1;
560  initrack.hits3 = hits3;
561  initrack.idcl2 = fSeltracks[ta].idcl2;
562  initrack.view2 = fSeltracks[ta].view2;
563  initrack.hits2 = fSeltracks[ta].hits2;
564  initrack.track = track;
565 
566  delete fSeltracks[tb].track;
567  delete fSeltracks[ta].track;
568  fSeltracks.erase(fSeltracks.begin() + tb);
569  fSeltracks.erase(fSeltracks.begin() + ta);
570  fSeltracks.push_back(initrack);
571  }
572  }
573 
574  if (found) break;
575  tb++;
576  }
577 
578  if (!found) ta++;
579  }
580 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
pma::Hit3D const * front() const
Definition: PmaTrack3D.h:87
TVector3 const & Point3D() const
Definition: PmaHit3D.h:50
void hits()
Definition: readHits.C:15
pma::Track3D * buildSegment(const detinfo::DetectorPropertiesData &clockData, const std::vector< art::Ptr< recob::Hit >> &hits_1, const std::vector< art::Ptr< recob::Hit >> &hits_2={}) const
double dist(const TReal *x, const TReal *y, const unsigned int dimension)
pma::ProjectionMatchingAlg fProjectionMatchingAlg
pma::Hit3D const * back() const
Definition: PmaTrack3D.h:88
std::vector< IniSeg > fSeltracks
bool Flip(const detinfo::DetectorPropertiesData &detProp, std::vector< pma::Track3D * > &allTracks)
Definition: PmaTrack3D.cxx:527
Float_t track
Definition: plot.C:35
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109
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)
bool ems::EMShower3D::Validate ( detinfo::DetectorPropertiesData const &  detProp,
std::vector< ems::DirOfGamma * >  input,
size_t  id1,
size_t  id2,
size_t  c1,
size_t  c2,
size_t  plane3 
)
private

Definition at line 811 of file EMShower3D_module.cc.

References pma::Track3D::back(), pma::Track3D::BackCryo(), pma::Track3D::BackTPC(), pma::ProjectionMatchingAlg::buildSegment(), c1, c2, pma::Dist2(), fProjectionMatchingAlg, pma::Track3D::front(), pma::Track3D::FrontCryo(), pma::Track3D::FrontTPC(), pma::GetProjectionToPlane(), pma::Hit3D::Point3D(), and track.

Referenced by LinkCandidates().

818 {
819  bool result = false;
820  if (id1 == id2) return false;
821 
822  std::vector<art::Ptr<recob::Hit>> vec1 = input[id1]->GetCandidates()[c1].GetIniHits();
823  std::vector<art::Ptr<recob::Hit>> vec2 = input[id2]->GetCandidates()[c2].GetIniHits();
824 
825  if ((vec1.size() < 3) || (vec2.size() < 3)) return false;
826 
827  std::vector<art::Ptr<recob::Hit>> hitscl1uniquetpc;
828  std::vector<art::Ptr<recob::Hit>> hitscl2uniquetpc;
829 
830  size_t tpc = vec1[0]->WireID().TPC;
831  for (size_t i = 0; i < vec1.size(); ++i)
832  for (size_t j = 0; j < vec2.size(); ++j)
833  if ((vec1[i]->WireID().TPC == tpc) && (vec2[j]->WireID().TPC == tpc)) {
834  hitscl1uniquetpc.push_back(vec1[i]);
835  hitscl2uniquetpc.push_back(vec2[j]);
836  }
837 
838  if ((hitscl1uniquetpc.size() < 3) || (hitscl2uniquetpc.size() < 3)) return false;
839 
841  fProjectionMatchingAlg.buildSegment(detProp, hitscl1uniquetpc, hitscl2uniquetpc);
842  for (size_t i = 0; i < input.size(); ++i) {
843  std::vector<Hit2D*> hits2dcl = input[i]->GetHits2D();
844  for (size_t h = 0; h < hits2dcl.size(); ++h) {
845  TVector2 pfront = pma::GetProjectionToPlane(
846  track->front()->Point3D(), plane3, track->FrontTPC(), track->FrontCryo());
847  TVector2 pback = pma::GetProjectionToPlane(
848  track->back()->Point3D(), plane3, track->BackTPC(), track->BackCryo());
849  if ((pma::Dist2(hits2dcl[h]->GetPointCm(), pfront) < 1.0F) &&
850  (pma::Dist2(hits2dcl[h]->GetPointCm(), pback) < 1.0F)) {
851  result = true;
852  break;
853  }
854  }
855  }
856  delete track;
857  return result;
858 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
pma::Hit3D const * front() const
Definition: PmaTrack3D.h:87
TVector3 const & Point3D() const
Definition: PmaHit3D.h:50
unsigned int BackTPC() const
Definition: PmaTrack3D.h:121
unsigned int BackCryo() const
Definition: PmaTrack3D.h:122
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
unsigned int FrontTPC() const
Definition: PmaTrack3D.h:118
unsigned int FrontCryo() const
Definition: PmaTrack3D.h:119
pma::Track3D * buildSegment(const detinfo::DetectorPropertiesData &clockData, const std::vector< art::Ptr< recob::Hit >> &hits_1, const std::vector< art::Ptr< recob::Hit >> &hits_2={}) const
pma::ProjectionMatchingAlg fProjectionMatchingAlg
TVector2 GetProjectionToPlane(const TVector3 &p, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:263
pma::Hit3D const * back() const
Definition: PmaTrack3D.h:88
Float_t track
Definition: plot.C:35

Member Data Documentation

calo::CalorimetryAlg ems::EMShower3D::fCalorimetryAlg
private

Definition at line 127 of file EMShower3D_module.cc.

Referenced by ConvertFrom(), ConvertFrom2(), and EMShower3D().

unsigned int ems::EMShower3D::fClIndex
private

Definition at line 120 of file EMShower3D_module.cc.

Referenced by ConvertFrom(), and produce().

art::Handle<std::vector<recob::Cluster> > ems::EMShower3D::fCluListHandle
private

Definition at line 129 of file EMShower3D_module.cc.

Referenced by CollectShower2D(), and produce().

std::string ems::EMShower3D::fCluModuleLabel
private

Definition at line 123 of file EMShower3D_module.cc.

Referenced by CollectShower2D(), EMShower3D(), and produce().

std::vector<std::vector<art::Ptr<recob::Hit> > > ems::EMShower3D::fClusters
private

Definition at line 114 of file EMShower3D_module.cc.

Referenced by CollectShower2D(), and produce().

std::vector<size_t> ems::EMShower3D::fClustersNotUsed
private

Definition at line 116 of file EMShower3D_module.cc.

Referenced by produce().

unsigned int ems::EMShower3D::fIniIndex
private

Definition at line 121 of file EMShower3D_module.cc.

Referenced by ConvertFrom(), ConvertFrom2(), and produce().

std::vector<IniSeg> ems::EMShower3D::fInisegs
private

Definition at line 110 of file EMShower3D_module.cc.

Referenced by Make3DSeg(), and produce().

std::vector<IniSeg> ems::EMShower3D::fPMA3D
private

Definition at line 112 of file EMShower3D_module.cc.

Referenced by produce().

pma::ProjectionMatchingAlg ems::EMShower3D::fProjectionMatchingAlg
private
std::vector<IniSeg> ems::EMShower3D::fSeltracks
private

Definition at line 111 of file EMShower3D_module.cc.

Referenced by produce(), and Reoptimize().

std::vector<size_t> ems::EMShower3D::fTracksNotUsed
private

Definition at line 117 of file EMShower3D_module.cc.

std::string ems::EMShower3D::fTrk3DModuleLabel
private

Definition at line 124 of file EMShower3D_module.cc.

Referenced by EMShower3D().

unsigned int ems::EMShower3D::fTrkIndex
private

Definition at line 119 of file EMShower3D_module.cc.

Referenced by produce().


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