LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
ems::EMShower3D Class Reference
Inheritance diagram for ems::EMShower3D:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::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 beginJob () override
 
void produce (art::Event &e) override
 
void reconfigure (fhicl::ParameterSet const &p)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Member Functions

recob::Track ConvertFrom (pma::Track3D &src)
 
recob::Track ConvertFrom2 (pma::Track3D &src)
 
recob::Cluster ConvertFrom (const std::vector< art::Ptr< recob::Hit > > &src)
 
std::vector< ems::DirOfGamma * > CollectShower2D (art::Event const &e)
 
void Link (art::Event const &e, std::vector< ems::DirOfGamma * > input)
 
void Reoptimize ()
 
void Make3DSeg (art::Event const &e, std::vector< ems::DirOfGamma * > pair)
 
bool Validate (art::Event const &e, const pma::Track3D &src, size_t plane)
 
bool Validate (std::vector< ems::DirOfGamma * > input, size_t id1, size_t id2, size_t c1, size_t c2, size_t plane3)
 
void FilterOutSmallParts (double r2d, const std::vector< art::Ptr< recob::Hit > > &hits_in, std::vector< art::Ptr< recob::Hit > > &hits_out)
 
bool GetCloseHits (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 (art::Event const &e, std::vector< ems::DirOfGamma * > input, size_t id)
 

Private Attributes

std::vector< IniSegfInisegs
 
std::vector< IniSegfSeltracks
 
std::vector< IniSegfPMA3D
 
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 67 of file EMShower3D_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

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

Definition at line 137 of file EMShower3D_module.cc.

References reconfigure().

138  : fProjectionMatchingAlg(p.get< fhicl::ParameterSet >("ProjectionMatchingAlg")),
139  fCalorimetryAlg(p.get< fhicl::ParameterSet >("CalorimetryAlg"))
140 {
141  reconfigure(p);
142 
143  produces< std::vector<recob::Track> >();
144  produces< std::vector<recob::Vertex> >();
145  produces< std::vector<recob::Cluster> >();
146  produces< std::vector<recob::SpacePoint> >();
147  produces< art::Assns<recob::Track, recob::Hit> >();
148  produces< art::Assns<recob::Track, recob::Vertex> >();
149  produces< art::Assns<recob::Cluster, recob::Hit> >();
150  produces< art::Assns<recob::Track, recob::SpacePoint> >();
151  produces< art::Assns<recob::SpacePoint, recob::Hit> >();
152  produces< art::Assns<recob::Track, recob::Cluster> >();
153 }
void reconfigure(fhicl::ParameterSet const &p)
calo::CalorimetryAlg fCalorimetryAlg
pma::ProjectionMatchingAlg fProjectionMatchingAlg
ems::EMShower3D::EMShower3D ( EMShower3D const &  )
delete
ems::EMShower3D::EMShower3D ( EMShower3D &&  )
delete

Member Function Documentation

void ems::EMShower3D::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 155 of file EMShower3D_module.cc.

156 {
157 }
std::vector< ems::DirOfGamma * > ems::EMShower3D::CollectShower2D ( art::Event const &  e)
private

Definition at line 587 of file EMShower3D_module.cc.

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

Referenced by produce().

588 {
589  std::vector< ems::DirOfGamma* > input;
590 
591  if (e.getByLabel(fCluModuleLabel, fCluListHandle))
592  {
594  for (unsigned int c = 0; c < fCluListHandle->size(); c++)
595  {
596  std::vector< art::Ptr<recob::Hit> > hitlist;
597  hitlist = fb.at(c);
598 
599  if (hitlist.size() > 5)
600  {
601  std::vector< art::Ptr<recob::Hit> > hits_out;
602  FilterOutSmallParts(2.0, hitlist, hits_out);
603 
604  if (hits_out.size() > 5)
605  {
606  fClusters.push_back(hits_out);
607 
608  ems::DirOfGamma * sh = new ems::DirOfGamma(hits_out, 14, c);
609 
610  if (sh->GetHits2D().size())
611  input.push_back(sh);
612  }
613  }
614  }
615  }
616 
617  return input;
618 }
art::Handle< std::vector< recob::Cluster > > fCluListHandle
void FilterOutSmallParts(double r2d, const std::vector< art::Ptr< recob::Hit > > &hits_in, std::vector< art::Ptr< recob::Hit > > &hits_out)
TFile fb("Li6.root")
std::vector< std::vector< art::Ptr< recob::Hit > > > fClusters
Float_t e
Definition: plot.C:34
std::string fCluModuleLabel
std::vector< Hit2D * > const & GetHits2D(void) const
Definition: DirOfGamma.h:126
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
recob::Track ems::EMShower3D::ConvertFrom ( pma::Track3D src)
private

Definition at line 174 of file EMShower3D_module.cc.

References pma::Track3D::back(), pma::Hit3D::Cryo(), calo::CalorimetryAlg::dEdx_AREA(), fCalorimetryAlg, fIniIndex, fProjectionMatchingAlg, pma::Track3D::front(), util::kBogusD, pma::Hit3D::Point3D(), pma::ProjectionMatchingAlg::selectInitialHits(), pma::Track3D::size(), and pma::Hit3D::TPC().

Referenced by produce().

175 {
176  auto const* geom = lar::providerFrom<geo::Geometry>();
177  auto const* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
178 
179  double avdrift = (src.front()->Point3D().X() + src.back()->Point3D().X()) * 0.5;
180  unsigned int nplanes = geom->Nplanes(src.front()->TPC(), src.front()->Cryo());
181  size_t nusedhitsmax = 0; int bestplane = -1;
182  for (unsigned int p = 0; p < nplanes; ++p)
183  {
184  unsigned int nusedP = 0;
185  fProjectionMatchingAlg.selectInitialHits(src, p, &nusedP);
186 
187  if (nusedP > nusedhitsmax)
188  {
189  nusedhitsmax = nusedP;
190  bestplane = int(p);
191  }
192  }
193 
194  std::vector< std::vector< double > > vdedx;
195  std::vector< double > dedx;
196 
197  for (unsigned int p = 0; p < nplanes; ++p)
198  {
199  unsigned int nusedP = 0;
200  double dqdxplane = fProjectionMatchingAlg.selectInitialHits(src, p, &nusedP);
201  double timeP = detprop->ConvertXToTicks(avdrift,
202  p,
203  src.front()->TPC(),
204  src.front()->Cryo());
205  double dEdxplane = fCalorimetryAlg.dEdx_AREA(dqdxplane, timeP, p);
206  dedx.push_back(dEdxplane);
207  if (int(p) == bestplane) dedx.push_back(1);
208  else dedx.push_back(0);
209  vdedx.push_back(dedx);
210  }
211 
212  std::vector< TVector3 > xyz, dircos;
213 
214  for (size_t i = 0; i < src.size(); i++)
215  {
216  xyz.push_back(src[i]->Point3D());
217 
218  if (i < src.size() - 1)
219  {
220  TVector3 dc(src[i + 1]->Point3D());
221  dc -= src[i]->Point3D();
222  dc *= 1.0 / dc.Mag();
223  dircos.push_back(dc);
224  }
225  else dircos.push_back(dircos.back());
226  }
227 
228  return recob::Track(xyz, dircos, vdedx, std::vector< double >(2, util::kBogusD), fIniIndex);
229 }
unsigned int TPC(void) const
Definition: PmaHit3D.h:57
unsigned int Cryo(void) const
Definition: PmaHit3D.h:56
double dEdx_AREA(art::Ptr< recob::Hit > hit, double pitch, double T0=0) const
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
unsigned int fIniIndex
double selectInitialHits(pma::Track3D &trk, unsigned int view=geo::kZ, unsigned int *nused=0) const
pma::Hit3D *& back()
Definition: PmaTrack3D.h:74
calo::CalorimetryAlg fCalorimetryAlg
TVector3 const & Point3D(void) const
Definition: PmaHit3D.h:48
pma::ProjectionMatchingAlg fProjectionMatchingAlg
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1035
constexpr double kBogusD
obviously bogus double value
size_t size() const
Definition: PmaTrack3D.h:76
pma::Hit3D *& front()
Definition: PmaTrack3D.h:72
recob::Cluster ems::EMShower3D::ConvertFrom ( const std::vector< art::Ptr< recob::Hit > > &  src)
private

Definition at line 168 of file EMShower3D_module.cc.

References fClIndex.

169 {
170 
171  return recob::Cluster(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, src.size(), 0.0F, 0.0F, fClIndex, src[0]->View(), src[0]->WireID().planeID());
172 }
Set of hits with a 2D structure.
Definition: Cluster.h:71
unsigned int fClIndex
recob::Track ems::EMShower3D::ConvertFrom2 ( pma::Track3D src)
private

Definition at line 231 of file EMShower3D_module.cc.

References pma::Track3D::back(), pma::Hit3D::Cryo(), calo::CalorimetryAlg::dEdx_AREA(), fCalorimetryAlg, fIniIndex, fProjectionMatchingAlg, pma::Track3D::front(), util::kBogusD, pma::Hit3D::Point3D(), pma::ProjectionMatchingAlg::selectInitialHits(), pma::Track3D::size(), and pma::Hit3D::TPC().

Referenced by produce().

232 {
233 
234  auto const* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
235  auto const* geom = lar::providerFrom<geo::Geometry>();
236 
237  double avdrift = (src.front()->Point3D().X() + src.back()->Point3D().X()) * 0.5;
238  unsigned int nplanes = geom->Nplanes(src.front()->TPC(), src.front()->Cryo());
239  size_t nusedhitsmax = 0; int bestplane = -1;
240  for (unsigned int p = 0; p < nplanes; ++p)
241  {
242  unsigned int nusedP = 0;
243  fProjectionMatchingAlg.selectInitialHits(src, p, &nusedP);
244 
245  if (nusedP > nusedhitsmax)
246  {
247  nusedhitsmax = nusedP;
248  bestplane = int(p);
249  }
250  }
251 
252  std::vector< std::vector< double > > vdedx;
253  std::vector< double > dedx;
254 
255  for (unsigned int p = 0; p < nplanes; ++p)
256  {
257  unsigned int nusedP = 0;
258  double dqdxplane = fProjectionMatchingAlg.selectInitialHits(src, p, &nusedP);
259  double timeP = detprop->ConvertXToTicks(avdrift,
260  p,
261  src.front()->TPC(),
262  src.front()->Cryo());
263  double dEdxplane = fCalorimetryAlg.dEdx_AREA(dqdxplane, timeP, p);
264  dedx.push_back(dEdxplane);
265  if (int(p) == bestplane) dedx.push_back(1);
266  else dedx.push_back(0);
267  vdedx.push_back(dedx);
268  }
269 
270  std::vector< TVector3 > xyz, dircos;
271 
272  for (size_t i = 0; i < src.size(); i++)
273  {
274  xyz.push_back(src[i]->Point3D());
275 
276  if (i < src.size() - 1)
277  {
278  TVector3 dc(src[i + 1]->Point3D());
279  dc -= src[i]->Point3D();
280  dc *= 1.0 / dc.Mag();
281  dircos.push_back(dc);
282  }
283  else dircos.push_back(dircos.back());
284  }
285 
286  return recob::Track(xyz, dircos, vdedx, std::vector< double >(2, util::kBogusD), fIniIndex);
287 }
unsigned int TPC(void) const
Definition: PmaHit3D.h:57
unsigned int Cryo(void) const
Definition: PmaHit3D.h:56
double dEdx_AREA(art::Ptr< recob::Hit > hit, double pitch, double T0=0) const
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
unsigned int fIniIndex
double selectInitialHits(pma::Track3D &trk, unsigned int view=geo::kZ, unsigned int *nused=0) const
pma::Hit3D *& back()
Definition: PmaTrack3D.h:74
calo::CalorimetryAlg fCalorimetryAlg
TVector3 const & Point3D(void) const
Definition: PmaHit3D.h:48
pma::ProjectionMatchingAlg fProjectionMatchingAlg
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1035
constexpr double kBogusD
obviously bogus double value
size_t size() const
Definition: PmaTrack3D.h:76
pma::Hit3D *& front()
Definition: PmaTrack3D.h:72
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
void ems::EMShower3D::FilterOutSmallParts ( double  r2d,
const std::vector< art::Ptr< recob::Hit > > &  hits_in,
std::vector< art::Ptr< recob::Hit > > &  hits_out 
)
private

Definition at line 955 of file EMShower3D_module.cc.

References DEFINE_ART_MODULE, and GetCloseHits().

Referenced by CollectShower2D().

959 {
960  size_t min_size = hits_in.size() / 5;
961  if (min_size < 3) min_size = 3;
962 
963  std::vector<size_t> used;
964  std::vector< art::Ptr<recob::Hit> > close_hits;
965 
966  while (GetCloseHits(r2d, hits_in, used, close_hits))
967  {
968  if (close_hits.size() > min_size)
969  for (auto h : close_hits) hits_out.push_back(h);
970  }
971 }
bool GetCloseHits(double r2d, const std::vector< art::Ptr< recob::Hit > > &hits_in, std::vector< size_t > &used, std::vector< art::Ptr< recob::Hit > > &hits_out)
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
bool ems::EMShower3D::GetCloseHits ( 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 889 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().

894 {
895 
896  hits_out.clear();
897 
898  const double gapMargin = 5.0; // can be changed to f(id_tpc1, id_tpc2)
899  size_t idx = 0;
900 
901  while ((idx < hits_in.size()) && Has(used, idx)) idx++;
902 
903  if (idx < hits_in.size())
904  {
905  hits_out.push_back(hits_in[idx]);
906  used.push_back(idx);
907 
908 
909  double r2d2 = r2d*r2d;
910  double gapMargin2 = sqrt(2 * gapMargin*gapMargin);
911  gapMargin2 = (gapMargin2 + r2d)*(gapMargin2 + r2d);
912 
913  bool collect = true;
914  while (collect)
915  {
916  collect = false;
917  for (size_t i = 0; i < hits_in.size(); i++)
918  if (!Has(used, i))
919  {
920  art::Ptr<recob::Hit> hi = hits_in[i];
921  TVector2 hi_cm = pma::WireDriftToCm(hi->WireID().Wire, hi->PeakTime(), hi->WireID().Plane, hi->WireID().TPC, hi->WireID().Cryostat);
922 
923  bool accept = false;
924  //for (auto const& ho : hits_out)
925  for (size_t idx_o = 0; idx_o < hits_out.size(); idx_o++)
926  {
927  art::Ptr<recob::Hit> ho = hits_out[idx_o];
928 
929  double d2 = pma::Dist2(
930  hi_cm, pma::WireDriftToCm(ho->WireID().Wire, ho->PeakTime(), ho->WireID().Plane, ho->WireID().TPC, ho->WireID().Cryostat));
931 
932  if (hi->WireID().TPC == ho->WireID().TPC)
933  {
934  if (d2 < r2d2) { accept = true; break; }
935  }
936  else
937  {
938  if (d2 < gapMargin2) { accept = true; break; }
939  }
940  }
941  if (accept)
942  {
943  collect = true;
944  hits_out.push_back(hi);
945  used.push_back(i);
946  }
947  }
948  }
949  return true;
950  }
951  else return false;
952 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:130
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:313
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:219
TVector2 WireDriftToCm(unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:307
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:203
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
bool ems::EMShower3D::Has ( const std::vector< size_t > &  v,
size_t  idx 
)
private

Definition at line 883 of file EMShower3D_module.cc.

Referenced by GetCloseHits().

884 {
885  for (auto c : v) if (c == idx) return true;
886  return false;
887 }
void ems::EMShower3D::Link ( art::Event const &  e,
std::vector< ems::DirOfGamma * >  input 
)
private

Definition at line 620 of file EMShower3D_module.cc.

References LinkCandidates(), Make3DSeg(), t1, and t2.

Referenced by produce().

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

Definition at line 697 of file EMShower3D_module.cc.

References geo::GeometryCore::Cryostat(), Make3DSeg(), geo::CryostatGeo::MaxPlanes(), t1, t2, and Validate().

Referenced by Link().

698 {
700 
701  size_t index = id; bool found = false;
702 
703  if (input[id]->GetCandidates().size() < 2) { return index; }
704 
705  double mindist = 3.0; // cm
706  std::vector< ems::DirOfGamma* > pairs;
707 
708  size_t idcsave = 0; size_t idcjsave = 0;
709  size_t c = 0; size_t idsave = 0;
710  while (c < input[id]->GetCandidates().size())
711  {
712 
713  size_t startview = input[id]->GetCandidates()[c].GetPlane();
714  size_t tpc = input[id]->GetCandidates()[c].GetTPC();
715  size_t cryo = input[id]->GetCandidates()[c].GetCryo();
716 
717  float t1 = input[id]->GetCandidates()[c].GetPosition().Y(); // y --> drift in 2D space.
718 
719  // loop over 2D showers
720  for (size_t j = 0; j < input.size(); ++j)
721  {
722  if (!input[j]->GetCandidates().size()) continue;
723  if (j == id) continue;
724 
725  // loop over candidates
726  for (size_t cj = 0; cj < input[j]->GetCandidates().size(); ++cj)
727  {
728  size_t secondview = input[j]->GetCandidates()[cj].GetPlane();
729  size_t tpc_j = input[j]->GetCandidates()[cj].GetTPC();
730  size_t cryo_j = input[j]->GetCandidates()[cj].GetCryo();
731 
732  size_t thirdview = startview;
733 
734  const geo::CryostatGeo& cryostat = geom->Cryostat(cryo);
735  for (size_t p = 0; p < cryostat.MaxPlanes(); p++)
736  if ((p == startview) || (p == secondview)) {continue;}
737  else {thirdview = p; break;}
738 
739 
740  if ((startview != secondview) && (tpc == tpc_j) && (cryo == cryo_j))// && Validate(input, id, cj, thirdview))
741  {
742  float t2 = input[j]->GetCandidates()[cj].GetPosition().Y();
743  float dist = fabs(t2 - t1);
744 
745  if ((dist < mindist) && Validate(input, id, j, c, cj, thirdview))
746  {
747  mindist = dist;
748  pairs.clear();
749  pairs.push_back(input[id]); pairs.push_back(input[j]);
750  idsave = j; index = j;
751  idcsave = c; idcjsave = cj;
752  found = true;
753  }
754  }
755  }
756  }
757 
758  c++;
759  }
760 
761  if (found && pairs.size())
762  {
763  input[id]->SetIdCandidate(idcsave);
764  input[idsave]->SetIdCandidate(idcjsave);
765  Make3DSeg(e, pairs);
766  }
767 
768  return index;
769 }
TTree * t1
Definition: plottest35.C:26
unsigned int MaxPlanes() const
Returns the largest number of planes among the TPCs in this cryostat.
Geometry information for a single cryostat.
Definition: CryostatGeo.h:36
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
bool Validate(art::Event const &e, const pma::Track3D &src, size_t plane)
TTree * t2
Definition: plottest35.C:36
void Make3DSeg(art::Event const &e, std::vector< ems::DirOfGamma * > pair)
Float_t e
Definition: plot.C:34
void ems::EMShower3D::Make3DSeg ( art::Event const &  e,
std::vector< ems::DirOfGamma * >  pair 
)
private

Definition at line 771 of file EMShower3D_module.cc.

References pma::Track3D::back(), pma::ProjectionMatchingAlg::buildSegment(), fInisegs, pma::Track3D::Flip(), fProjectionMatchingAlg, pma::Hit3D::Hit2DPtr(), IniSeg::hits1, IniSeg::hits2, IniSeg::idcl1, IniSeg::idcl2, IniSeg::track, IniSeg::view1, and IniSeg::view2.

Referenced by Link(), and LinkCandidates().

772 {
773  if (pair.size() < 2) return;
774 
775  // to build a track correctly 2d hits must belong to the same tpc
776  size_t tpc1 = pair[0]->GetFirstHit()->WireID().TPC;
777  size_t tpc2 = pair[1]->GetFirstHit()->WireID().TPC;
778 
779  std::vector< art::Ptr< recob::Hit > > vec1 = pair[0]->GetIniHits();
780  std::vector< art::Ptr< recob::Hit > > vec2 = pair[1]->GetIniHits();
781 
782  if ((vec1.size() < 3) && (vec2.size() < 3)) return;
783 
784  std::vector< art::Ptr<recob::Hit> > hitscl1uniquetpc;
785  std::vector< art::Ptr<recob::Hit> > hitscl2uniquetpc;
786 
787  if (tpc1 == tpc2)
788  for (size_t i = 0; i < vec1.size(); ++i)
789  for (size_t j = 0; j < vec2.size(); ++j)
790  if ((vec1[i]->WireID().TPC == vec2[j]->WireID().TPC) && (tpc1 == vec2[j]->WireID().TPC))
791  {
792  hitscl1uniquetpc.push_back(vec1[i]);
793  hitscl2uniquetpc.push_back(vec2[j]);
794  }
795 
796  if ((hitscl1uniquetpc.size() > 2) && (hitscl2uniquetpc.size() > 2))
797  {
798  pma::Track3D* trk = fProjectionMatchingAlg.buildSegment(hitscl1uniquetpc, hitscl2uniquetpc);
799 
800  //pma::Track3D* trk = fProjectionMatchingAlg.buildSegment(vec1, vec2);
801 
802  // turn the track that front is at vertex - easier to handle associations.
803  if ((trk->back()->Hit2DPtr() == pair[0]->GetFirstHit())
804  || (trk->back()->Hit2DPtr() == pair[1]->GetFirstHit())) trk->Flip();
805 
806 
807  IniSeg initrack;
808  initrack.idcl1 = pair[0]->GetIdCl();
809  initrack.view1 = pair[0]->GetFirstHit()->WireID().Plane;
810  initrack.hits1 = hitscl1uniquetpc;
811  initrack.idcl2 = pair[1]->GetIdCl();
812  initrack.view2 = pair[1]->GetFirstHit()->WireID().Plane;
813  initrack.hits2 = hitscl2uniquetpc;
814  initrack.track = trk;
815 
816  fInisegs.push_back(initrack);
817 
818 
819  }
820 }
bool Flip(std::vector< pma::Track3D * > &allTracks)
Definition: PmaTrack3D.cxx:499
size_t idcl1
art::Ptr< recob::Hit > const & Hit2DPtr(void) const
Definition: PmaHit3D.h:46
size_t view2
pma::Track3D * buildSegment(const std::vector< art::Ptr< recob::Hit > > &hits_1, const std::vector< art::Ptr< recob::Hit > > &hits_2=std::vector< art::Ptr< recob::Hit > >()) const
size_t idcl2
pma::Hit3D *& back()
Definition: PmaTrack3D.h:74
pma::ProjectionMatchingAlg fProjectionMatchingAlg
size_t view1
std::vector< art::Ptr< recob::Hit > > hits2
std::vector< art::Ptr< recob::Hit > > hits1
pma::Track3D * track
std::vector< IniSeg > fInisegs
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
EMShower3D& ems::EMShower3D::operator= ( EMShower3D const &  )
delete
EMShower3D& ems::EMShower3D::operator= ( EMShower3D &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void ems::EMShower3D::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 289 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::DataViewImpl::getByLabel(), pma::Hit3D::Hit2DPtr(), Link(), pma::Hit3D::Point3D(), art::PtrVector< T >::push_back(), art::Event::put(), Reoptimize(), art::PtrVector< T >::size(), and track.

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

Definition at line 159 of file EMShower3D_module.cc.

References fCluModuleLabel, fTrk3DModuleLabel, and fhicl::ParameterSet::get().

Referenced by EMShower3D().

160 {
161  fCluModuleLabel = p.get< std::string >("ClustersModuleLabel");
162  //fProjectionMatchingAlg.reconfigure(p.get< fhicl::ParameterSet >("ProjectionMatchingAlg")); // use constructor-time config only
163  fTrk3DModuleLabel = p.get< std::string >("Trk3DModuleLabel");
164 
165  return;
166 }
std::string fTrk3DModuleLabel
std::string fCluModuleLabel
void ems::EMShower3D::Reoptimize ( )
private

Definition at line 507 of file EMShower3D_module.cc.

References pma::Track3D::back(), pma::ProjectionMatchingAlg::buildSegment(), pma::Dist2(), pma::Track3D::Flip(), fProjectionMatchingAlg, pma::Track3D::front(), fSeltracks, hits(), IniSeg::hits1, IniSeg::hits2, IniSeg::hits3, IniSeg::idcl1, IniSeg::idcl2, IniSeg::idcl3, pma::Hit3D::Point3D(), track, IniSeg::track, IniSeg::view1, IniSeg::view2, and IniSeg::view3.

Referenced by produce().

508 {
509  if (!fSeltracks.size()) return;
510  const float min_dist = 3.0F;
511  size_t ta = 0;
512  while (ta < (fSeltracks.size() - 1))
513  {
514  size_t tb = ta + 1;
515  bool found = false;
516  while (tb < fSeltracks.size())
517  {
518  if (ta == tb) {tb++; continue;}
519 
520  TVector3 p1 = fSeltracks[ta].track->front()->Point3D();
521  TVector3 p2 = fSeltracks[tb].track->front()->Point3D();
522  float dist = std::sqrt(pma::Dist2(p1, p2));
523 
524  if (dist < min_dist)
525  if ((fSeltracks[ta].idcl1 == fSeltracks[tb].idcl1) || (fSeltracks[ta].idcl1 == fSeltracks[tb].idcl2) ||
526  (fSeltracks[ta].idcl2 == fSeltracks[tb].idcl1) || (fSeltracks[ta].idcl2 == fSeltracks[tb].idcl2))
527  {
528  found = true;
529  size_t view3 = fSeltracks[ta].view1; size_t idcl3 = fSeltracks[ta].idcl1;
530  std::vector< art::Ptr< recob::Hit > > hits3 = fSeltracks[ta].hits1;
531  std::vector< art::Ptr< recob::Hit > > hits = fSeltracks[ta].hits1;
532  for (size_t h = 0; h < fSeltracks[ta].hits2.size(); ++h)
533  hits.push_back(fSeltracks[ta].hits2[h]);
534 
535  if ((fSeltracks[tb].view1 != fSeltracks[ta].view1) && (fSeltracks[tb].view1 != fSeltracks[ta].view2))
536  {
537  view3 = fSeltracks[tb].view1;
538  for (size_t h = 0; h < fSeltracks[tb].hits1.size(); ++h)
539  hits.push_back(fSeltracks[tb].hits1[h]);
540  }
541  if ((fSeltracks[tb].view2 != fSeltracks[ta].view1) && (fSeltracks[tb].view2 != fSeltracks[ta].view2))
542  {
543  view3 = fSeltracks[tb].view2;
544  for (size_t h = 0; h < fSeltracks[tb].hits2.size(); ++h)
545  hits.push_back(fSeltracks[tb].hits2[h]);
546  }
547 
548 
549  if ((view3 == fSeltracks[ta].view1) || (view3 == fSeltracks[ta].view2))
550  {
551  delete fSeltracks[ta].track;
552  fSeltracks.erase(fSeltracks.begin() + ta);
553  }
554  else
555  {
557 
558  if (pma::Dist2(track->back()->Point3D(), fSeltracks[ta].track->front()->Point3D()) <
559  pma::Dist2(track->front()->Point3D(), fSeltracks[ta].track->front()->Point3D()))
560  track->Flip();
561 
562  IniSeg initrack;
563  initrack.idcl1 = fSeltracks[ta].idcl1; initrack.idcl3 = idcl3;
564  initrack.view1 = fSeltracks[ta].view1; initrack.view3 = view3;
565  initrack.hits1 = fSeltracks[ta].hits1; initrack.hits3 = hits3;
566  initrack.idcl2 = fSeltracks[ta].idcl2;
567  initrack.view2 = fSeltracks[ta].view2;
568  initrack.hits2 = fSeltracks[ta].hits2;
569  initrack.track = track;
570 
571 
572  delete fSeltracks[tb].track; delete fSeltracks[ta].track;
573  fSeltracks.erase(fSeltracks.begin() + tb); fSeltracks.erase(fSeltracks.begin() + ta);
574  fSeltracks.push_back(initrack);
575 
576  }
577  }
578 
579  if (found) break;
580  tb++;
581  }
582 
583  if (!found) ta++;
584  }
585 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
bool Flip(std::vector< pma::Track3D * > &allTracks)
Definition: PmaTrack3D.cxx:499
size_t idcl1
size_t view3
size_t view2
void hits()
Definition: readHits.C:15
std::vector< art::Ptr< recob::Hit > > hits3
size_t idcl3
pma::Track3D * buildSegment(const std::vector< art::Ptr< recob::Hit > > &hits_1, const std::vector< art::Ptr< recob::Hit > > &hits_2=std::vector< art::Ptr< recob::Hit > >()) const
size_t idcl2
pma::Hit3D *& back()
Definition: PmaTrack3D.h:74
TVector3 const & Point3D(void) const
Definition: PmaHit3D.h:48
pma::ProjectionMatchingAlg fProjectionMatchingAlg
size_t view1
std::vector< art::Ptr< recob::Hit > > hits2
std::vector< art::Ptr< recob::Hit > > hits1
std::vector< IniSeg > fSeltracks
pma::Track3D * track
Float_t track
Definition: plot.C:34
pma::Hit3D *& front()
Definition: PmaTrack3D.h:72
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
bool ems::EMShower3D::Validate ( art::Event const &  e,
const pma::Track3D src,
size_t  plane 
)
private

Definition at line 865 of file EMShower3D_module.cc.

References fCluListHandle, fCluModuleLabel, fClustersNotUsed, fProjectionMatchingAlg, hits(), and pma::ProjectionMatchingAlg::validate().

Referenced by LinkCandidates().

866 {
867  bool result = false;
868 
870  std::vector< art::Ptr<recob::Hit> > hitscl;
871  for (size_t id = 0; id < fClustersNotUsed.size(); id++)
872  {
873  std::vector< art::Ptr<recob::Hit> > hits = fbc.at(fClustersNotUsed[id]);
874  for (size_t i = 0; i < hits.size(); i++) hitscl.push_back(hits[i]);
875  }
876 
877 
878  if (fProjectionMatchingAlg.validate(src, hitscl) > 0.2) result = true;
879 
880  return result;
881 }
std::vector< size_t > fClustersNotUsed
art::Handle< std::vector< recob::Cluster > > fCluListHandle
void hits()
Definition: readHits.C:15
pma::ProjectionMatchingAlg fProjectionMatchingAlg
Float_t e
Definition: plot.C:34
std::string fCluModuleLabel
double validate(const pma::Track3D &trk, const std::vector< art::Ptr< recob::Hit > > &hits) const
bool ems::EMShower3D::Validate ( std::vector< ems::DirOfGamma * >  input,
size_t  id1,
size_t  id2,
size_t  c1,
size_t  c2,
size_t  plane3 
)
private

Definition at line 822 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.

823 {
824  bool result = false;
825  if (id1 == id2) return false;
826 
827  std::vector< art::Ptr< recob::Hit > > vec1 = input[id1]->GetCandidates()[c1].GetIniHits();
828  std::vector< art::Ptr< recob::Hit > > vec2 = input[id2]->GetCandidates()[c2].GetIniHits();
829 
830  if ((vec1.size() < 3) || (vec2.size() < 3)) return false;
831 
832  std::vector< art::Ptr<recob::Hit> > hitscl1uniquetpc;
833  std::vector< art::Ptr<recob::Hit> > hitscl2uniquetpc;
834 
835  size_t tpc = vec1[0]->WireID().TPC;
836  for (size_t i = 0; i < vec1.size(); ++i)
837  for (size_t j = 0; j < vec2.size(); ++j)
838  if ((vec1[i]->WireID().TPC == tpc) && (vec2[j]->WireID().TPC == tpc))
839  {
840  hitscl1uniquetpc.push_back(vec1[i]);
841  hitscl2uniquetpc.push_back(vec2[j]);
842  }
843 
844  if ((hitscl1uniquetpc.size() < 3) || (hitscl2uniquetpc.size() < 3)) return false;
845 
846  pma::Track3D* track = fProjectionMatchingAlg.buildSegment(hitscl1uniquetpc, hitscl2uniquetpc);
847  for (size_t i = 0; i < input.size(); ++i)
848  {
849  std::vector< Hit2D* > hits2dcl = input[i]->GetHits2D();
850  for (size_t h = 0; h < hits2dcl.size(); ++h)
851  {
852  TVector2 pfront = pma::GetProjectionToPlane(track->front()->Point3D(), plane3, track->FrontTPC(), track->FrontCryo());
853  TVector2 pback = pma::GetProjectionToPlane(track->back()->Point3D(), plane3, track->BackTPC(), track->BackCryo());
854  if ( (pma::Dist2(hits2dcl[h]->GetPointCm(), pfront) < 1.0F) &&
855  (pma::Dist2(hits2dcl[h]->GetPointCm(), pback) < 1.0F) )
856  {result = true; break;}
857  }
858  }
859  delete track;
860  return result;
861 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
unsigned int FrontTPC(void) const
Definition: PmaTrack3D.h:104
unsigned int BackTPC(void) const
Definition: PmaTrack3D.h:107
TCanvas * c1
Definition: plotHisto.C:7
TCanvas * c2
Definition: plot_hist.C:75
unsigned int BackCryo(void) const
Definition: PmaTrack3D.h:108
pma::Track3D * buildSegment(const std::vector< art::Ptr< recob::Hit > > &hits_1, const std::vector< art::Ptr< recob::Hit > > &hits_2=std::vector< art::Ptr< recob::Hit > >()) const
pma::Hit3D *& back()
Definition: PmaTrack3D.h:74
unsigned int FrontCryo(void) const
Definition: PmaTrack3D.h:105
TVector3 const & Point3D(void) const
Definition: PmaHit3D.h:48
pma::ProjectionMatchingAlg fProjectionMatchingAlg
TVector2 GetProjectionToPlane(const TVector3 &p, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:291
Float_t track
Definition: plot.C:34
pma::Hit3D *& front()
Definition: PmaTrack3D.h:72
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

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

Definition at line 131 of file EMShower3D_module.cc.

Referenced by ConvertFrom(), and ConvertFrom2().

unsigned int ems::EMShower3D::fClIndex
private

Definition at line 124 of file EMShower3D_module.cc.

Referenced by ConvertFrom(), and produce().

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

Definition at line 133 of file EMShower3D_module.cc.

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

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

Definition at line 127 of file EMShower3D_module.cc.

Referenced by CollectShower2D(), produce(), reconfigure(), and Validate().

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

Definition at line 119 of file EMShower3D_module.cc.

Referenced by CollectShower2D(), and produce().

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

Definition at line 121 of file EMShower3D_module.cc.

Referenced by produce(), and Validate().

unsigned int ems::EMShower3D::fIniIndex
private

Definition at line 125 of file EMShower3D_module.cc.

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

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

Definition at line 115 of file EMShower3D_module.cc.

Referenced by Make3DSeg(), and produce().

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

Definition at line 117 of file EMShower3D_module.cc.

Referenced by produce().

pma::ProjectionMatchingAlg ems::EMShower3D::fProjectionMatchingAlg
private

Definition at line 130 of file EMShower3D_module.cc.

Referenced by ConvertFrom(), ConvertFrom2(), Make3DSeg(), Reoptimize(), and Validate().

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

Definition at line 116 of file EMShower3D_module.cc.

Referenced by produce(), and Reoptimize().

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

Definition at line 122 of file EMShower3D_module.cc.

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

Definition at line 128 of file EMShower3D_module.cc.

Referenced by reconfigure().

unsigned int ems::EMShower3D::fTrkIndex
private

Definition at line 124 of file EMShower3D_module.cc.

Referenced by produce().


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