Public Member Functions | Private Attributes | List of all members
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 26 of file HitSelector.h.

Constructor & Destructor Documentation

evd::HitSelector::HitSelector ( )

Definition at line 34 of file HitSelector.cxx.

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

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 187 of file HitSelector.cxx.

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

Definition at line 278 of file HitSelector.cxx.

279  {
281  infot->ClearSelectedHitList(plane);
282  }
void ClearSelectedHitList(int plane)
Definition: InfoTransfer.h:70
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 255 of file HitSelector.cxx.

256  {
258  return infot->GetSelectedHitList(plane);
259  }
std::vector< art::Ptr< recob::Hit > > GetSelectedHitList(unsigned int plane)
Definition: InfoTransfer.h:67
std::vector< const recob::Hit * > evd::HitSelector::GetSelectedHits ( unsigned int  plane)

Definition at line 262 of file HitSelector.cxx.

263  {
264  std::vector<art::Ptr<recob::Hit>> hits_saved;
265  std::vector<const recob::Hit*> hits_to_draw; //draw selected hits in a different color
266 
268  hits_saved = infot->GetSelectedHitList(plane);
269 
270  for (unsigned int i = 0; i < hits_saved.size(); i++)
271  hits_to_draw.push_back(hits_saved[i].get());
272 
273  return hits_to_draw;
274  }
std::vector< art::Ptr< recob::Hit > > GetSelectedHitList(unsigned int plane)
Definition: InfoTransfer.h:67
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 88 of file HitSelector.cxx.

96  {
99  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
100  auto const detProp =
102  util::GeometryUtilities const gser{*geo, clockData, detProp};
103  std::vector<art::Ptr<recob::Hit>> hits_to_save;
104 
106 
107  starthitout[plane].clear();
108  endhitout[plane].clear();
109 
110  starthitout[plane].resize(2);
111  endhitout[plane].resize(2);
112 
113  //convert input variables to cm-cm space required by GeometryUtilities
114  double x = xin * gser.WireToCm();
115  double x1 = x1in * gser.WireToCm();
116  double y = yin * gser.TimeToCm();
117  double y1 = y1in * gser.TimeToCm();
118 
119  double lslope = 0;
120 
121  if ((x - x1) != 0) lslope = (y - y1) / (x - x1);
122 
123  for (size_t imod = 0; imod < recoOpt->fHitLabels.size(); ++imod) {
124  art::InputTag const which = recoOpt->fHitLabels[imod];
125 
126  std::vector<art::Ptr<recob::Hit>> hitlist;
127  hitlist.clear();
128  evt.getByLabel(which, HitListHandle);
129 
130  for (unsigned int ii = 0; ii < HitListHandle->size(); ++ii) {
131  art::Ptr<recob::Hit> hit(HitListHandle, ii);
132  if (hit->WireID().Plane == plane) hitlist.push_back(hit);
133  }
134 
135  // Select Local Hit List
136  util::PxHitConverter PxC{gser};
137  std::vector<util::PxHit> pxhitlist;
138  PxC.GeneratePxHit(hitlist, pxhitlist);
139  std::vector<unsigned int> pxhitlist_local_index;
140  std::vector<util::PxHit> pxhitlist_local;
141  pxhitlist_local.clear();
142 
143  util::PxPoint startHit;
144  startHit.plane = pxhitlist.at(0).plane;
145  startHit.w = (x + x1) / 2;
146  startHit.t = (y + y1) / 2;
147 
148  double orttemp = std::hypot(y1 - y, x1 - x) / 2;
149 
150  gser.SelectLocalHitlistIndex(
151  pxhitlist, pxhitlist_local_index, startHit, orttemp, distance, lslope);
152 
153  for (unsigned int idx = 0; idx < pxhitlist_local_index.size(); idx++) {
154  hits_to_save.push_back(hitlist.at(pxhitlist_local_index.at(idx)));
155  pxhitlist_local.push_back(pxhitlist.at(pxhitlist_local_index.at(idx)));
156  }
157 
158  auto const hit_index = gser.FindClosestHitIndex(pxhitlist_local, x, y);
159  recob::Hit const& hit = *hits_to_save[hit_index];
160  starthitout[plane][1] = hit.PeakTime();
161  starthitout[plane][0] = hit.WireID().Wire;
162 
163  recob::Hit const& endhit = hit; // this obviously not correct, the fact that x,y are used for both start and end point, A.S. -> to debug
164  endhitout[plane][1] = endhit.PeakTime();
165  endhitout[plane][0] = endhit.WireID().Wire;
166  }
167 
169  infot->SetHitList(plane, hits_to_save);
170  infot->SetTestFlag(1);
171  if (good_plane) {
172  infot->SetStartHitCoords(plane, starthitout[plane]);
173  infot->SetEndHitCoords(plane, endhitout[plane]);
174  }
175  infot->SetEvtNumber(evt.id().event());
176  }
void SetTestFlag(int value)
Definition: InfoTransfer.h:51
geo::WireID WireID() const
Definition: Hit.h:233
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
void SetStartHitCoords(unsigned int plane, std::vector< double > starthitin)
Definition: InfoTransfer.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > hypot(T x, T y)
Definition: hypot.h:60
std::vector< std::vector< double > > starthitout
Definition: HitSelector.h:55
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)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
double t
Definition: PxUtils.h:11
void SetHitList(unsigned int p, std::vector< art::Ptr< recob::Hit > > hits_to_save)
Definition: InfoTransfer.h:61
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
Detector simulation of raw signals on wires.
double w
Definition: PxUtils.h:10
void SetEvtNumber(int value)
Definition: InfoTransfer.h:57
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
EventNumber_t event() const
Definition: EventID.h:116
void SetEndHitCoords(unsigned int plane, std::vector< double > endhitin)
Definition: InfoTransfer.h:102
list x
Definition: train.py:276
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
std::vector< art::InputTag > fHitLabels
module labels that produced hits
std::vector< std::vector< double > > endhitout
Definition: HitSelector.h:56
LArSoft geometry interface.
Definition: ChannelGeo.h:16
EventID id() const
Definition: Event.cc:34
unsigned int plane
Definition: PxUtils.h:12
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 50 of file HitSelector.cxx.

53  {
57  std::map<int, std::vector<art::Ptr<recob::Hit>>> hits_to_save;
58 
59  double KineticEnergy = 0;
61 
62  for (size_t imod = 0; imod < recoOpt->fHitLabels.size(); ++imod) {
63  art::InputTag const which = recoOpt->fHitLabels[imod];
64  evt.getByLabel(which, HitListHandle);
65  }
66 
67  infot->SetSeedList(seedlines);
68  for (std::map<int, std::vector<art::Ptr<recob::Hit>>>::iterator it = hits_to_save.begin();
69  it != hits_to_save.end();
70  ++it) {
71  infot->SetHitList(it->first, it->second);
72  }
73  infot->SetTestFlag(1);
74  infot->SetEvtNumber(evt.id().event());
75 
76  return KineticEnergy;
77  }
void SetTestFlag(int value)
Definition: InfoTransfer.h:51
struct vector vector
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
void SetHitList(unsigned int p, std::vector< art::Ptr< recob::Hit > > hits_to_save)
Definition: InfoTransfer.h:61
void SetEvtNumber(int value)
Definition: InfoTransfer.h:57
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:34
std::vector< recob::Seed > & evd::HitSelector::SeedVector ( )

Definition at line 286 of file HitSelector.cxx.

287  {
288  return fSeedVector;
289  }
std::vector< recob::Seed > fSeedVector
Definition: HitSelector.h:53

Member Data Documentation

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

Definition at line 56 of file HitSelector.h.

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

Definition at line 53 of file HitSelector.h.

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

Definition at line 55 of file HitSelector.h.


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