7 #include "art/Framework/Principal/Event.h"
8 #include "art/Framework/Principal/Handle.h"
9 #include "art/Framework/Services/Registry/ServiceHandle.h"
10 #include "messagefacility/MessageLogger/MessageLogger.h"
25 WriteMsg(
const char* fcn)
27 mf::LogVerbatim(
"HitSelector") <<
"HitSelector::" << fcn <<
" \n";
51 std::vector<util::PxLine> seedlines,
54 art::ServiceHandle<evd::InfoTransfer> infot;
55 art::ServiceHandle<geo::Geometry const> geom;
56 art::ServiceHandle<evd::RecoDrawingOptions const> recoOpt;
57 std::map<int, std::vector<art::Ptr<recob::Hit>>> hits_to_save;
59 double KineticEnergy = 0;
60 art::Handle<std::vector<recob::Hit>> HitListHandle;
62 for (
size_t imod = 0; imod < recoOpt->fHitLabels.size(); ++imod) {
63 art::InputTag
const which = recoOpt->fHitLabels[imod];
64 evt.getByLabel(which, HitListHandle);
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();
71 infot->SetHitList(it->first, it->second);
73 infot->SetTestFlag(1);
74 infot->SetEvtNumber(evt.id().event());
97 art::ServiceHandle<evd::RecoDrawingOptions const> recoOpt;
98 art::ServiceHandle<geo::Geometry const> geo;
99 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
101 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
103 std::vector<art::Ptr<recob::Hit>> hits_to_save;
105 art::Handle<std::vector<recob::Hit>> HitListHandle;
114 double x = xin * gser.WireToCm();
115 double x1 = x1in * gser.WireToCm();
116 double y = yin * gser.TimeToCm();
117 double y1 = y1in * gser.TimeToCm();
121 if ((x - x1) != 0) lslope = (y - y1) / (x - x1);
123 for (
size_t imod = 0; imod < recoOpt->fHitLabels.size(); ++imod) {
124 art::InputTag
const which = recoOpt->fHitLabels[imod];
126 std::vector<art::Ptr<recob::Hit>> hitlist;
128 evt.getByLabel(which, HitListHandle);
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);
137 std::vector<util::PxHit> pxhitlist;
139 std::vector<unsigned int> pxhitlist_local_index;
140 std::vector<util::PxHit> pxhitlist_local;
141 pxhitlist_local.clear();
144 startHit.
plane = pxhitlist.at(0).plane;
145 startHit.
w = (x + x1) / 2;
146 startHit.
t = (y + y1) / 2;
148 double orttemp = std::hypot(y1 - y, x1 - x) / 2;
150 gser.SelectLocalHitlistIndex(
151 pxhitlist, pxhitlist_local_index, startHit, orttemp, distance, lslope);
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)));
158 auto const hit_index = gser.FindClosestHitIndex(pxhitlist_local, x, y);
168 art::ServiceHandle<evd::InfoTransfer> infot;
169 infot->SetHitList(plane, hits_to_save);
170 infot->SetTestFlag(1);
172 infot->SetStartHitCoords(plane,
starthitout[plane]);
173 infot->SetEndHitCoords(plane,
endhitout[plane]);
175 infot->SetEvtNumber(evt.id().event());
189 art::ServiceHandle<evd::RecoDrawingOptions const> recoOpt;
190 art::ServiceHandle<geo::Geometry const> geo;
191 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
193 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
197 std::vector<art::Ptr<recob::Hit>> hits_saved;
198 std::vector<art::Ptr<recob::Hit>> hitlist;
200 double x = xin * gser.WireToCm();
201 double y = yin * gser.TimeToCm();
203 art::Handle<std::vector<recob::Hit>> HitListHandle;
205 for (
size_t imod = 0; imod < recoOpt->fHitLabels.size(); ++imod) {
206 art::InputTag
const which = recoOpt->fHitLabels[imod];
207 evt.getByLabel(which, HitListHandle);
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);
215 std::vector<util::PxHit> pxhitlist;
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");
224 art::ServiceHandle<evd::InfoTransfer> infot;
225 hits_saved = infot->GetSelectedHitList(plane);
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()) {
231 hits_saved.erase(hits_saved.begin() + jj);
237 if (found_it != 1) { hits_saved.push_back(hitlist[hitindex]); }
240 infot->SetHitList(plane, hits_saved);
241 infot->SetTestFlag(1);
242 infot->SetEvtNumber(evt.id().event());
254 std::vector<art::Ptr<recob::Hit>>
257 art::ServiceHandle<evd::InfoTransfer const> infot;
258 return infot->GetSelectedHitList(plane);
261 std::vector<const recob::Hit*>
264 std::vector<art::Ptr<recob::Hit>> hits_saved;
265 std::vector<const recob::Hit*> hits_to_draw;
267 art::ServiceHandle<evd::InfoTransfer const> infot;
268 hits_saved = infot->GetSelectedHitList(plane);
270 for (
unsigned int i = 0; i < hits_saved.size(); i++)
271 hits_to_draw.push_back(hits_saved[i].get());
280 art::ServiceHandle<evd::InfoTransfer> infot;
281 infot->ClearSelectedHitList(plane);
285 std::vector<recob::Seed>&
double SaveSeedLines(const art::Event &evt, std::vector< util::PxLine > seedline, double distance)
process_name opflash particleana ie x
geo::WireID WireID() const
void SaveHits(const art::Event &evt, unsigned int plane, double x, double y, double x1, double y1, double distance, bool good_plane=true)
WireID_t Wire
Index of the wire within its plane.
std::vector< art::Ptr< recob::Hit > > GetSelectedHitPtrs(unsigned int plane)
std::vector< std::vector< double > > starthitout
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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)
process_name opflash particleana ie ie y
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
std::vector< const recob::Hit * > GetSelectedHits(unsigned int plane)
Class to perform operations needed to select hits and pass them to a cluster.
std::vector< recob::Seed > fSeedVector
float PeakTime() const
Time of the signal peak, in tick units.
void ChangeHit(const art::Event &evt, unsigned int plane, double x, double y)
2D representation of charge deposited in the TDC/wire plane
void ClearHitList(unsigned int plane)
std::vector< std::vector< double > > endhitout
std::vector< recob::Seed > & SeedVector()
art framework interface to geometry description