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

Public Member Functions

 EmLikeHits (fhicl::ParameterSet const &p)
 
 EmLikeHits (EmLikeHits const &)=delete
 
 EmLikeHits (EmLikeHits &&)=delete
 
EmLikeHitsoperator= (EmLikeHits const &)=delete
 
EmLikeHitsoperator= (EmLikeHits &&)=delete
 
void reconfigure (fhicl::ParameterSet const &p)
 
void produce (art::Event &e) override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void removeHitsAssignedToTracks (std::vector< art::Ptr< recob::Hit > > &hitlist, const std::vector< recob::Track > &tracks, const art::FindManyP< recob::Hit > &fbp)
 
void removeUnmatchedHitsCloseToTracks (detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit > > &hitlist, const std::vector< recob::Track > &tracks, const art::FindManyP< recob::Hit > &fbp)
 
bool isCloseToTrack (TVector2 p, const recob::Track &trk, unsigned int view, unsigned int tpc, unsigned int cryo)
 

Static Private Member Functions

static double getDist2 (const TVector2 &psrc, const TVector2 &p0, const TVector2 &p1)
 

Private Attributes

std::string fHitModuleLabel
 
std::string fTrk3DModuleLabel
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 47 of file EmLikeHits_module.cc.

Constructor & Destructor Documentation

dune::EmLikeHits::EmLikeHits ( fhicl::ParameterSet const &  p)
explicit

Definition at line 97 of file EmLikeHits_module.cc.

97  : EDProducer{p}
98 {
99  this->reconfigure(p);
100  produces< std::vector<recob::Hit> >();
101 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
p
Definition: test.py:223
void reconfigure(fhicl::ParameterSet const &p)
dune::EmLikeHits::EmLikeHits ( EmLikeHits const &  )
delete
dune::EmLikeHits::EmLikeHits ( EmLikeHits &&  )
delete

Member Function Documentation

double dune::EmLikeHits::getDist2 ( const TVector2 &  psrc,
const TVector2 &  p0,
const TVector2 &  p1 
)
staticprivate

Definition at line 236 of file EmLikeHits_module.cc.

237 {
238  TVector2 v0(psrc); v0 -= p0;
239  TVector2 v1(p1); v1 -= p0;
240 
241  TVector2 v2(psrc); v2 -= p1;
242  TVector2 v3(v1); v3 *= -1.0;
243 
244  double v0Norm2 = v0.Mod2();
245  double v1Norm2 = v1.Mod2();
246 
247  double eps = 1.0E-7; // 0.001mm
248  if (v1Norm2 > eps)
249  {
250  double mag01 = sqrt(v0Norm2 * v1Norm2);
251  double cosine01 = 0.0;
252  if (mag01 != 0.0) cosine01 = v0 * v1 / mag01;
253 
254  double v2Norm2 = v2.Mod2();
255  double mag23 = sqrt(v2Norm2 * v3.Mod2());
256  double cosine23 = 0.0;
257  if (mag23 != 0.0) cosine23 = v2 * v3 / mag23;
258 
259  double result = 0.0;
260  if ((cosine01 > 0.0) && (cosine23 > 0.0))
261  {
262  result = (1.0 - cosine01 * cosine01) * v0Norm2;
263  }
264  else
265  {
266  if (cosine01 <= 0.0) result = v0Norm2;
267  else result = v2Norm2;
268  }
269 
270  if (result >= 0.0) return result;
271  else return 0.0;
272  }
273  else
274  {
275  v1 = p0; v1 += p1; v1 *= 0.5;
276  return pma::Dist2(v1, psrc);
277  }
278 }
static QCString result
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:37
bool dune::EmLikeHits::isCloseToTrack ( TVector2  p,
const recob::Track trk,
unsigned int  view,
unsigned int  tpc,
unsigned int  cryo 
)
private

Definition at line 137 of file EmLikeHits_module.cc.

139 {
141  double wirePitch = geom->TPC(tpc, cryo).Plane(view).WirePitch();
142 
143  //double driftPitch = detProp.GetXTicksCoefficient(tpc, cryo);
144 
145  double max_d2_d = 0.3 * 0.3;
146  double max_d2_w = (wirePitch + 0.1) * (wirePitch + 0.1);
147 
148  bool isClose = false;
149  for (size_t i = 0; i < trk.NumberTrajectoryPoints() - 1; ++i)
150  {
151  TVector2 p0 = pma::GetVectorProjectionToPlane(trk.LocationAtPoint<TVector3>(i), view, tpc, cryo);
152  TVector2 p1 = pma::GetVectorProjectionToPlane(trk.LocationAtPoint<TVector3>(i + 1), view, tpc, cryo);
153  double d2 = getDist2(p, p0, p1);
154 
155  double dpx = fabs(p0.X() - p1.X());
156  double dpy = fabs(p0.Y() - p1.Y());
157 
158  if (((dpx > 0.5 * dpy) && (d2 < max_d2_d)) || (d2 < max_d2_w))
159  {
160  isClose = true; break;
161  }
162  }
163  return isClose;
164 }
Point_t const & LocationAtPoint(size_t i) const
Definition: Track.h:126
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:102
static double getDist2(const TVector2 &psrc, const TVector2 &p0, const TVector2 &p1)
p
Definition: test.py:223
TVector2 GetVectorProjectionToPlane(const TVector3 &v, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:281
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
Definition: TPCGeo.cxx:263
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:411
EmLikeHits& dune::EmLikeHits::operator= ( EmLikeHits const &  )
delete
EmLikeHits& dune::EmLikeHits::operator= ( EmLikeHits &&  )
delete
void dune::EmLikeHits::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 209 of file EmLikeHits_module.cc.

210 {
211  std::unique_ptr< std::vector< recob::Hit > > not_track_hits(new std::vector< recob::Hit >);
212 
213  std::vector< art::Ptr<recob::Hit> > hitlist;
214  auto hitListHandle = evt.getHandle< std::vector<recob::Hit> >(fHitModuleLabel);
215  auto trkListHandle = evt.getHandle< std::vector<recob::Track> >(fTrk3DModuleLabel);
216 
217  if (hitListHandle && trkListHandle)
218  {
219  art::FindManyP< recob::Hit > fbp(trkListHandle, evt, fTrk3DModuleLabel);
220 
221  art::fill_ptr_vector(hitlist, hitListHandle);
222  mf::LogVerbatim("EmLikeHits") << "all hits: " << hitlist.size() << std::endl;
223 
224  removeHitsAssignedToTracks(hitlist, *trkListHandle, fbp);
225  auto const detProp =
227  removeUnmatchedHitsCloseToTracks(detProp, hitlist, *trkListHandle, fbp);
228 
229  for (auto const& hit : hitlist) not_track_hits->push_back(recob::Hit(*hit));
230  mf::LogVerbatim("EmLikeHits") << "remaining not track-like hits: " << not_track_hits->size() << std::endl;
231  }
232  evt.put(std::move(not_track_hits));
233 }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void removeUnmatchedHitsCloseToTracks(detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit > > &hitlist, const std::vector< recob::Track > &tracks, const art::FindManyP< recob::Hit > &fbp)
std::string fHitModuleLabel
std::string fTrk3DModuleLabel
def move(depos, offset)
Definition: depos.py:107
void removeHitsAssignedToTracks(std::vector< art::Ptr< recob::Hit > > &hitlist, const std::vector< recob::Track > &tracks, const art::FindManyP< recob::Hit > &fbp)
Detector simulation of raw signals on wires.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
QTextStream & endl(QTextStream &s)
void dune::EmLikeHits::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 104 of file EmLikeHits_module.cc.

105 {
106  fHitModuleLabel = pset.get< std::string >("HitModuleLabel");
107  fTrk3DModuleLabel = pset.get< std::string >("Trk3DModuleLabel");
108 }
std::string string
Definition: nybbler.cc:12
std::string fHitModuleLabel
std::string fTrk3DModuleLabel
void dune::EmLikeHits::removeHitsAssignedToTracks ( std::vector< art::Ptr< recob::Hit > > &  hitlist,
const std::vector< recob::Track > &  tracks,
const art::FindManyP< recob::Hit > &  fbp 
)
private

Definition at line 111 of file EmLikeHits_module.cc.

115 {
116  for (size_t t = 0; t < tracks.size(); t++)
117  if (!(tracks[t].ID() & 0x10000))
118  {
119  std::vector< art::Ptr<recob::Hit> > v = fbp.at(t);
120  mf::LogVerbatim("EmLikeHits") << " track-like trajectory: " << v.size() << std::endl;
121  size_t ih = 0;
122  while (ih < hitlist.size())
123  {
124  bool found = false;
125  for (size_t it = 0; it < v.size(); it++)
126  if (v[it].key() == hitlist[ih].key())
127  {
128  found = true; break;
129  }
130  if (found) hitlist.erase(hitlist.begin() + ih);
131  else ih++;
132  }
133  }
134 }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
unsigned int ID
def key(type, name=None)
Definition: graph.py:13
QTextStream & endl(QTextStream &s)
void dune::EmLikeHits::removeUnmatchedHitsCloseToTracks ( detinfo::DetectorPropertiesData const &  detProp,
std::vector< art::Ptr< recob::Hit > > &  hitlist,
const std::vector< recob::Track > &  tracks,
const art::FindManyP< recob::Hit > &  fbp 
)
private

Definition at line 167 of file EmLikeHits_module.cc.

172 {
173  size_t ih = 0;
174  while (ih < hitlist.size())
175  {
176  bool unmatched = true, close = false;;
177  for (size_t t = 0; t < tracks.size(); t++)
178  {
179  std::vector< art::Ptr<recob::Hit> > v = fbp.at(t);
180  for (size_t it = 0; it < v.size(); it++)
181  if (v[it].key() == hitlist[ih].key())
182  {
183  unmatched = false; break;
184  }
185  if (!unmatched) break;
186  }
187  if (unmatched)
188  {
189  unsigned int plane = hitlist[ih]->WireID().Plane;
190  unsigned int tpc = hitlist[ih]->WireID().TPC;
191  unsigned int cryo = hitlist[ih]->WireID().Cryostat;
192 
193  TVector2 hcm = pma::WireDriftToCm(detProp,
194  hitlist[ih]->WireID().Wire, hitlist[ih]->PeakTime(), plane, tpc, cryo);
195 
196  for (size_t t = 0; t < tracks.size(); t++)
197  if (!(tracks[t].ID() & 0x10000) &&
198  isCloseToTrack(hcm, tracks[t], plane, tpc, cryo))
199  {
200  close = true; break;
201  }
202  }
203  if (close) hitlist.erase(hitlist.begin() + ih);
204  else ih++;
205  }
206 }
unsigned int ID
TVector2 WireDriftToCm(detinfo::DetectorPropertiesData const &detProp, unsigned int wire, float drift, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: Utilities.cxx:294
int close(int)
Closes the file descriptor fd.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
def key(type, name=None)
Definition: graph.py:13
bool isCloseToTrack(TVector2 p, const recob::Track &trk, unsigned int view, unsigned int tpc, unsigned int cryo)

Member Data Documentation

std::string dune::EmLikeHits::fHitModuleLabel
private

Definition at line 91 of file EmLikeHits_module.cc.

std::string dune::EmLikeHits::fTrk3DModuleLabel
private

Definition at line 92 of file EmLikeHits_module.cc.


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