LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evd::HitSelector Class Reference

#include "HitSelector.h"

Public Member Functions

 HitSelector ()
 
void SaveHits (const art::Event &evt, unsigned int plane, double x, double y, double x1, double y1, double distance, bool good_plane=true)
 
double SaveSeedLines (const art::Event &evt, std::vector< util::PxLine > seedline, double distance)
 
void ChangeHit (const art::Event &evt, unsigned int plane, double x, double y)
 
std::vector< const recob::Hit * > GetSelectedHits (unsigned int plane)
 
std::vector< art::Ptr< recob::Hit > > GetSelectedHitPtrs (unsigned int plane)
 
void ClearHitList (unsigned int plane)
 
std::vector< recob::Seed > & SeedVector ()
 

Private Attributes

std::vector< recob::SeedfSeedVector
 
std::vector< std::vector< double > > starthitout
 
std::vector< std::vector< double > > endhitout
 

Detailed Description

Definition at line 25 of file HitSelector.h.

Constructor & Destructor Documentation

evd::HitSelector::HitSelector ( )

Definition at line 33 of file HitSelector.cxx.

References endhitout, and starthitout.

34  {
35  starthitout.resize(3);
36  endhitout.resize(3);
37  }
std::vector< std::vector< double > > starthitout
Definition: HitSelector.h:54
std::vector< std::vector< double > > endhitout
Definition: HitSelector.h:55

Member Function Documentation

void evd::HitSelector::ChangeHit ( const art::Event evt,
unsigned int  plane,
double  xin,
double  yin 
)

Save HitList to infoTransfer service

Parameters
evt: Event handle to get data objects from
view: Pointer to view to draw on
plane: plane number of view

Definition at line 184 of file HitSelector.cxx.

References art::EventID::event(), evd::RecoDrawingOptions::fHitLabels, util::PxHitConverter::GeneratePxHit(), art::ProductRetriever::getByLabel(), evd::InfoTransfer::GetSelectedHitList(), art::Event::id(), geo::PlaneID::Plane, evd::InfoTransfer::SetEvtNumber(), evd::InfoTransfer::SetHitList(), evd::InfoTransfer::SetTestFlag(), recob::Hit::WireID(), x, and y.

Referenced by evd::TWireProjPad::SelectOneHit().

185  {
188  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
189  auto const detProp =
191  util::GeometryUtilities const gser{*geo, clockData, detProp};
192 
193  //get hits from info transfer, see if our selected hit is in it
194  std::vector<art::Ptr<recob::Hit>> hits_saved;
195  std::vector<art::Ptr<recob::Hit>> hitlist;
196 
197  double x = xin * gser.WireToCm();
198  double y = yin * gser.TimeToCm();
199 
201 
202  for (size_t imod = 0; imod < recoOpt->fHitLabels.size(); ++imod) {
203  art::InputTag const which = recoOpt->fHitLabels[imod];
204  evt.getByLabel(which, HitListHandle);
205 
206  for (unsigned int ii = 0; ii < HitListHandle->size(); ++ii) {
207  art::Ptr<recob::Hit> hit(HitListHandle, ii);
208  if (hit->WireID().Plane == plane) hitlist.push_back(hit);
209  }
210 
211  util::PxHitConverter PxC{gser};
212  std::vector<util::PxHit> pxhitlist;
213  PxC.GeneratePxHit(hitlist, pxhitlist);
214 
215  unsigned int hitindex = gser.FindClosestHitIndex(pxhitlist, x, y);
216  if (hitlist[hitindex].isNull() || (hitindex > hitlist.size())) {
217  WriteMsg("no luck finding hit in evd, please try again");
218  break;
219  }
220 
222  hits_saved = infot->GetSelectedHitList(plane);
223  int found_it = 0;
224  for (unsigned int jj = 0; jj < hits_saved.size(); ++jj) {
225  if (hitlist[hitindex]->PeakTime() == hits_saved[jj]->PeakTime()) {
226  if (hitlist[hitindex]->Channel() == hits_saved[jj]->Channel()) {
227  found_it = 1;
228  hits_saved.erase(hits_saved.begin() + jj);
229  }
230  }
231  }
232 
233  //if didn't find it, add it
234  if (found_it != 1) { hits_saved.push_back(hitlist[hitindex]); }
235 
236  //update the info transfer list
237  infot->SetHitList(plane, hits_saved);
238  infot->SetTestFlag(1);
239  infot->SetEvtNumber(evt.id().event());
240  }
241  }
Float_t x
Definition: compare.C:6
void SetTestFlag(int value)
Definition: InfoTransfer.h:55
Float_t y
Definition: compare.C:6
void SetHitList(unsigned int p, std::vector< art::Ptr< recob::Hit >> hits_to_save)
Definition: InfoTransfer.h:64
void GeneratePxHit(const std::vector< unsigned int > &hit_index, const std::vector< art::Ptr< recob::Hit >> hits, std::vector< PxHit > &pxhits) const
Generate: from 1 set of hits => 1 set of PxHits using indexes (association)
std::vector< art::Ptr< recob::Hit > > const & GetSelectedHitList(unsigned int plane) const
Definition: InfoTransfer.h:75
Detector simulation of raw signals on wires.
void SetEvtNumber(int value)
Definition: InfoTransfer.h:61
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
EventNumber_t event() const
Definition: EventID.h:116
std::vector< art::InputTag > fHitLabels
module labels that produced hits
Namespace collecting geometry-related classes utilities.
EventID id() const
Definition: Event.cc:23
void evd::HitSelector::ClearHitList ( unsigned int  plane)

Definition at line 272 of file HitSelector.cxx.

References evd::InfoTransfer::ClearSelectedHitList().

Referenced by evd::TWireProjPad::ClearHitList().

273  {
275  infot->ClearSelectedHitList(plane);
276  }
void ClearSelectedHitList(int plane)
Definition: InfoTransfer.h:80
std::vector< art::Ptr< recob::Hit > > evd::HitSelector::GetSelectedHitPtrs ( unsigned int  plane)

Save HitList to infoTransfer service

Parameters
evt: Event handle to get data objects from
view: Pointer to view to draw on
plane: plane number of view

Definition at line 251 of file HitSelector.cxx.

References evd::InfoTransfer::GetSelectedHitList().

252  {
254  return infot->GetSelectedHitList(plane);
255  }
std::vector< art::Ptr< recob::Hit > > const & GetSelectedHitList(unsigned int plane) const
Definition: InfoTransfer.h:75
std::vector< const recob::Hit * > evd::HitSelector::GetSelectedHits ( unsigned int  plane)

Definition at line 257 of file HitSelector.cxx.

References evd::InfoTransfer::GetSelectedHitList().

258  {
259  std::vector<art::Ptr<recob::Hit>> hits_saved;
260  std::vector<const recob::Hit*> hits_to_draw; //draw selected hits in a different color
261 
263  hits_saved = infot->GetSelectedHitList(plane);
264 
265  for (unsigned int i = 0; i < hits_saved.size(); i++)
266  hits_to_draw.push_back(hits_saved[i].get());
267 
268  return hits_to_draw;
269  }
std::vector< art::Ptr< recob::Hit > > const & GetSelectedHitList(unsigned int plane) const
Definition: InfoTransfer.h:75
void evd::HitSelector::SaveHits ( const art::Event evt,
unsigned int  plane,
double  xin,
double  yin,
double  x1in,
double  y1in,
double  distance,
bool  good_plane = true 
)

Save HitList to infoTransfer service

Parameters
evt: Event handle to get data objects from
view: Pointer to view to draw on
plane: plane number of view

Definition at line 85 of file HitSelector.cxx.

References endhitout, art::EventID::event(), evd::RecoDrawingOptions::fHitLabels, util::PxHitConverter::GeneratePxHit(), art::ProductRetriever::getByLabel(), art::Event::id(), recob::Hit::PeakTime(), util::PxPoint::plane, geo::PlaneID::Plane, evd::InfoTransfer::SetEndHitCoords(), evd::InfoTransfer::SetEvtNumber(), evd::InfoTransfer::SetHitList(), evd::InfoTransfer::SetStartHitCoords(), evd::InfoTransfer::SetTestFlag(), starthitout, util::PxPoint::t, util::PxPoint::w, geo::WireID::Wire, recob::Hit::WireID(), x, x1, y, and y1.

Referenced by evd::TWireProjPad::SaveHitList().

93  {
96  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
97  auto const detProp =
99  util::GeometryUtilities const gser{*geo, clockData, detProp};
100  std::vector<art::Ptr<recob::Hit>> hits_to_save;
101 
103 
104  starthitout[plane].clear();
105  endhitout[plane].clear();
106 
107  starthitout[plane].resize(2);
108  endhitout[plane].resize(2);
109 
110  //convert input variables to cm-cm space required by GeometryUtilities
111  double x = xin * gser.WireToCm();
112  double x1 = x1in * gser.WireToCm();
113  double y = yin * gser.TimeToCm();
114  double y1 = y1in * gser.TimeToCm();
115 
116  double lslope = 0;
117 
118  if ((x - x1) != 0) lslope = (y - y1) / (x - x1);
119 
120  for (size_t imod = 0; imod < recoOpt->fHitLabels.size(); ++imod) {
121  art::InputTag const which = recoOpt->fHitLabels[imod];
122 
123  std::vector<art::Ptr<recob::Hit>> hitlist;
124  hitlist.clear();
125  evt.getByLabel(which, HitListHandle);
126 
127  for (unsigned int ii = 0; ii < HitListHandle->size(); ++ii) {
128  art::Ptr<recob::Hit> hit(HitListHandle, ii);
129  if (hit->WireID().Plane == plane) hitlist.push_back(hit);
130  }
131 
132  // Select Local Hit List
133  util::PxHitConverter PxC{gser};
134  std::vector<util::PxHit> pxhitlist;
135  PxC.GeneratePxHit(hitlist, pxhitlist);
136  std::vector<unsigned int> pxhitlist_local_index;
137  std::vector<util::PxHit> pxhitlist_local;
138  pxhitlist_local.clear();
139 
140  util::PxPoint startHit;
141  startHit.plane = pxhitlist.at(0).plane;
142  startHit.w = (x + x1) / 2;
143  startHit.t = (y + y1) / 2;
144 
145  double orttemp = std::hypot(y1 - y, x1 - x) / 2;
146 
147  gser.SelectLocalHitlistIndex(
148  pxhitlist, pxhitlist_local_index, startHit, orttemp, distance, lslope);
149 
150  for (unsigned int idx = 0; idx < pxhitlist_local_index.size(); idx++) {
151  hits_to_save.push_back(hitlist.at(pxhitlist_local_index.at(idx)));
152  pxhitlist_local.push_back(pxhitlist.at(pxhitlist_local_index.at(idx)));
153  }
154 
155  auto const hit_index = gser.FindClosestHitIndex(pxhitlist_local, x, y);
156  recob::Hit const& hit = *hits_to_save[hit_index];
157  starthitout[plane][1] = hit.PeakTime();
158  starthitout[plane][0] = hit.WireID().Wire;
159 
160  recob::Hit const& endhit =
161  hit; // this obviously not correct, the fact that x,y are used for both start and end point, A.S. -> to debug
162  endhitout[plane][1] = endhit.PeakTime();
163  endhitout[plane][0] = endhit.WireID().Wire;
164  }
165 
167  infot->SetHitList(plane, hits_to_save);
168  infot->SetTestFlag(1);
169  if (good_plane) {
170  infot->SetStartHitCoords(plane, starthitout[plane]);
171  infot->SetEndHitCoords(plane, endhitout[plane]);
172  }
173  infot->SetEvtNumber(evt.id().event());
174  }
Float_t x
Definition: compare.C:6
void SetTestFlag(int value)
Definition: InfoTransfer.h:55
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
Float_t y
Definition: compare.C:6
void SetHitList(unsigned int p, std::vector< art::Ptr< recob::Hit >> hits_to_save)
Definition: InfoTransfer.h:64
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:280
void SetStartHitCoords(unsigned int plane, std::vector< double > starthitin)
Definition: InfoTransfer.h:112
std::vector< std::vector< double > > starthitout
Definition: HitSelector.h:54
void GeneratePxHit(const std::vector< unsigned int > &hit_index, const std::vector< art::Ptr< recob::Hit >> hits, std::vector< PxHit > &pxhits) const
Generate: from 1 set of hits => 1 set of PxHits using indexes (association)
double t
Definition: PxUtils.h:10
Detector simulation of raw signals on wires.
double w
Definition: PxUtils.h:9
void SetEvtNumber(int value)
Definition: InfoTransfer.h:61
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:220
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
EventNumber_t event() const
Definition: EventID.h:116
void SetEndHitCoords(unsigned int plane, std::vector< double > endhitin)
Definition: InfoTransfer.h:119
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
std::vector< art::InputTag > fHitLabels
module labels that produced hits
std::vector< std::vector< double > > endhitout
Definition: HitSelector.h:55
Namespace collecting geometry-related classes utilities.
EventID id() const
Definition: Event.cc:23
unsigned int plane
Definition: PxUtils.h:11
double evd::HitSelector::SaveSeedLines ( const art::Event evt,
std::vector< util::PxLine seedlines,
double  distance 
)

Save SeedLineList to infoTransfer service

Parameters
evt: Event handle to get data objects from
view: Pointer to view to draw on

Return value is the kinetic enegry of the track

Definition at line 48 of file HitSelector.cxx.

References art::EventID::event(), evd::RecoDrawingOptions::fHitLabels, art::ProductRetriever::getByLabel(), art::Event::id(), evd::InfoTransfer::SetEvtNumber(), evd::InfoTransfer::SetHitList(), evd::InfoTransfer::SetSeedList(), evd::InfoTransfer::SetTestFlag(), and lar::dump::vector().

Referenced by evd::TWireProjPad::SaveSeedList().

51  {
55  std::map<int, std::vector<art::Ptr<recob::Hit>>> hits_to_save;
56 
57  double KineticEnergy = 0;
59 
60  for (size_t imod = 0; imod < recoOpt->fHitLabels.size(); ++imod) {
61  art::InputTag const which = recoOpt->fHitLabels[imod];
62  evt.getByLabel(which, HitListHandle);
63  }
64 
65  infot->SetSeedList(seedlines);
66  for (std::map<int, std::vector<art::Ptr<recob::Hit>>>::iterator it = hits_to_save.begin();
67  it != hits_to_save.end();
68  ++it) {
69  infot->SetHitList(it->first, it->second);
70  }
71  infot->SetTestFlag(1);
72  infot->SetEvtNumber(evt.id().event());
73 
74  return KineticEnergy;
75  }
void SetTestFlag(int value)
Definition: InfoTransfer.h:55
void SetHitList(unsigned int p, std::vector< art::Ptr< recob::Hit >> hits_to_save)
Definition: InfoTransfer.h:64
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
void SetEvtNumber(int value)
Definition: InfoTransfer.h:61
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
void SetSeedList(std::vector< util::PxLine > seedlines)
EventNumber_t event() const
Definition: EventID.h:116
std::vector< art::InputTag > fHitLabels
module labels that produced hits
EventID id() const
Definition: Event.cc:23
std::vector< recob::Seed > & evd::HitSelector::SeedVector ( )

Definition at line 279 of file HitSelector.cxx.

References fSeedVector.

280  {
281  return fSeedVector;
282  }
std::vector< recob::Seed > fSeedVector
Definition: HitSelector.h:52

Member Data Documentation

std::vector<std::vector<double> > evd::HitSelector::endhitout
private

Definition at line 55 of file HitSelector.h.

Referenced by HitSelector(), and SaveHits().

std::vector<recob::Seed> evd::HitSelector::fSeedVector
private

Definition at line 52 of file HitSelector.h.

Referenced by SeedVector().

std::vector<std::vector<double> > evd::HitSelector::starthitout
private

Definition at line 54 of file HitSelector.h.

Referenced by HitSelector(), and SaveHits().


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