12 #include "art/Framework/Core/EDProducer.h"
13 #include "art/Framework/Core/ModuleMacros.h"
14 #include "art/Framework/Principal/Event.h"
15 #include "art/Framework/Services/Registry/ServiceHandle.h"
16 #include "canvas/Persistency/Common/PtrVector.h"
17 #include "messagefacility/MessageLogger/MessageLogger.h"
43 std::vector<double>& uvw,
44 std::vector<double>& t,
49 std::vector<recob::EndPoint2D> EndPoints);
54 std::vector<recob::EndPoint2D>
const& EndPoints,
55 art::PtrVector<recob::Hit>
const&
Hits);
58 std::vector<recob::SpacePoint>& sps,
59 bool ApplyFilter =
true);
62 std::vector<int>& ConnectionPoint1,
63 std::vector<int>& ConnectionPoint2);
80 , fSP(pset.get<fhicl::ParameterSet>(
"SpacepointPset"))
81 , fCorner(pset.get<fhicl::ParameterSet>(
"CornerPset"))
82 , fHitModuleLabel{pset.get<std::string>(
"HitModuleLabel")}
83 , fCalDataModuleLabel{pset.get<std::string>(
"CornerPset.CalDataModuleLabel")}
84 , fLineIntFraction{pset.get<
double>(
"LineIntFraction")}
85 , fLineIntThreshold{pset.get<
double>(
"LineIntThreshold")}
87 produces<std::vector<recob::Seed>>();
95 art::Handle<std::vector<recob::Hit>> hith;
98 art::PtrVector<recob::Hit> hitvec;
99 for (
unsigned int i = 0; i < hith->size(); ++i) {
100 art::Ptr<recob::Hit> prod(hith, i);
101 hitvec.push_back(prod);
105 art::Handle<std::vector<recob::Wire>> wireHandle;
107 std::vector<recob::Wire>
const& wireVec(*wireHandle);
112 std::vector<recob::EndPoint2D> EndPoints;
117 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
119 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
123 std::unique_ptr<std::vector<recob::Seed>>
seeds(
new std::vector<recob::Seed>);
125 for (
size_t i = 0; i != SeedsToStore.size(); ++i)
126 seeds->push_back(SeedsToStore.at(i));
128 evt.put(std::move(seeds));
133 std::map<int, std::vector<double>>
136 std::map<int, std::vector<double>> EndPointTimesInPlane;
137 for (
size_t i = 0; i != EndPoints.size(); ++i) {
138 EndPointTimesInPlane[EndPoints.at(i).View()].push_back(EndPoints.at(i).DriftTime());
141 for (std::map<
int, std::vector<double>>::iterator itEpTime = EndPointTimesInPlane.begin();
142 itEpTime != EndPointTimesInPlane.end();
144 std::sort(itEpTime->second.begin(), itEpTime->second.end());
146 return EndPointTimesInPlane;
151 std::vector<recob::Seed>
153 std::vector<recob::SpacePoint>& spts,
156 std::vector<recob::Seed> SeedsToReturn;
158 std::vector<int> ConnectionPoint1;
159 std::vector<int> ConnectionPoint2;
160 std::map<int, std::vector<int>> SeedConnections;
162 for (
size_t i = 0; i != spts.size(); ++i) {
163 for (
size_t j = 0; j != i; ++j) {
168 std::vector<double> t_i, t_j;
170 std::vector<double> uvw_i;
171 std::vector<double> uvw_j;
173 for (
size_t d = 0; d != 3; ++d) {
174 xyz_i[d] = spts.at(i).XYZ()[d];
175 xyz_j[d] = spts.at(j).XYZ()[d];
181 bool ThisLineGood =
true;
183 for (
size_t p = 0;
p != uvw_i.size(); ++
p) {
196 for (
size_t d = 0; d != 3; ++d) {
197 Pos[d] = 0.5 * (xyz_i[d] + xyz_j[d]);
198 Dir[d] = 0.5 * (xyz_i[d] - xyz_j[d]);
202 ConnectionPoint1.push_back(i);
203 ConnectionPoint2.push_back(j);
205 SeedsToReturn.push_back(
recob::Seed(Pos, Dir, Err, Err));
212 mf::LogInfo(
"FeatureTracker")
213 <<
"Seeds after filter " << SeedsToReturn.size() <<
" seeds" << std::endl;
216 return SeedsToReturn;
223 std::vector<int>& ConnectionPoint1,
224 std::vector<int>& ConnectionPoint2)
227 std::map<int, bool> MarkedForRemoval;
229 std::map<int, std::vector<int>> SeedsSharingPoint;
230 for (
size_t i = 0; i != Seeds.size(); ++i) {
231 SeedsSharingPoint[ConnectionPoint1[i]].push_back(i);
232 SeedsSharingPoint[ConnectionPoint2[i]].push_back(i);
235 for (
size_t s = 0;
s != Seeds.size(); ++
s) {
237 int StartPt = ConnectionPoint1.at(
s);
238 int EndPt = ConnectionPoint2.at(
s);
241 for (
size_t SeedsWithThisStart = 0; SeedsWithThisStart != SeedsSharingPoint[StartPt].size();
242 SeedsWithThisStart++) {
243 int i = SeedsSharingPoint[StartPt].at(SeedsWithThisStart);
244 if (ConnectionPoint1.at(i) == StartPt)
245 MidPt = ConnectionPoint2.at(i);
246 else if (ConnectionPoint2.at(i) == StartPt)
247 MidPt = ConnectionPoint1.at(i);
249 for (
size_t SeedsWithThisMid = 0; SeedsWithThisMid != SeedsSharingPoint[MidPt].size();
250 SeedsWithThisMid++) {
251 int j = SeedsSharingPoint[MidPt].at(SeedsWithThisMid);
252 if ((ConnectionPoint1.at(j) == EndPt) || (ConnectionPoint2.at(j) == EndPt)) {
254 double Lengthi = Seeds.at(i).GetLength();
255 double Lengthj = Seeds.at(j).GetLength();
256 double Lengths = Seeds.at(
s).GetLength();
258 if ((Lengths > Lengthi) && (Lengths > Lengthj)) {
259 MarkedForRemoval[i] =
true;
260 MarkedForRemoval[j] =
true;
263 if ((Lengthi > Lengths) && (Lengthi > Lengthj)) {
264 MarkedForRemoval[
s] =
true;
265 MarkedForRemoval[j] =
true;
267 if ((Lengthj > Lengthi) && (Lengthj > Lengths)) {
268 MarkedForRemoval[
s] =
true;
269 MarkedForRemoval[i] =
true;
275 for (std::map<int, bool>::reverse_iterator itrem = MarkedForRemoval.rbegin();
276 itrem != MarkedForRemoval.rend();
278 if (itrem->second ==
true) {
279 Seeds.erase(Seeds.begin() + itrem->first);
280 ConnectionPoint1.erase(ConnectionPoint1.begin() + itrem->first);
281 ConnectionPoint2.erase(ConnectionPoint2.begin() + itrem->first);
291 std::vector<double>& uvw,
292 std::vector<double>& t,
296 art::ServiceHandle<geo::Geometry const> geo;
298 int NPlanes = geo->Cryostat(cryo).TPC(tpc).Nplanes();
303 for (
int plane = 0; plane != NPlanes; plane++) {
304 uvw[plane] = geo->NearestWire(xyz, plane, tpc, cryo);
311 std::vector<recob::SpacePoint>
314 std::vector<recob::EndPoint2D>
const& EndPoints,
315 art::PtrVector<recob::Hit>
const&
Hits)
318 art::PtrVector<recob::Hit> HitsForEndPoints;
321 for (std::vector<recob::EndPoint2D>::const_iterator itEP = EndPoints.begin();
322 itEP != EndPoints.end();
324 int EPMatchCount = 0;
326 for (art::PtrVector<recob::Hit>::const_iterator itHit = Hits.begin(); itHit != Hits.end();
329 if ((itEP->View() == (*itHit)->View()) &&
330 (itEP->WireID().Wire == (*itHit)->WireID().Wire)) {
331 HitsForEndPoints.push_back(*itHit);
336 std::vector<recob::SpacePoint> spts;
339 for (
size_t i = 0; i != spts.size(); ++i) {
340 for (
size_t p = 0;
p != 3; ++
p) {
341 double Closest = 100000;
343 for (
size_t epTime = 0; epTime !=
fEndPointTimes[
p].size(); ++epTime) {
std::vector< recob::SpacePoint > Get3DFeaturePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< recob::EndPoint2D > const &EndPoints, art::PtrVector< recob::Hit > const &Hits)
void RemoveDuplicatePaths(std::vector< recob::Seed > &Seeds, std::vector< int > &ConnectionPoint1, std::vector< int > &ConnectionPoint2)
Encapsulate the construction of a single cyostat.
Declaration of signal hit object.
void GetProjectedEnds(detinfo::DetectorPropertiesData const &detProp, TVector3 xyz, std::vector< double > &uvw, std::vector< double > &t, int tpc=0, int cryo=0)
TH2F const & GetWireDataHist(unsigned int) const
void get_feature_points(std::vector< recob::EndPoint2D > &, geo::Geometry const &)
std::map< int, std::vector< double > > ExtractEndPointTimes(std::vector< recob::EndPoint2D > EndPoints)
art::ServiceHandle< geo::Geometry const > fGeometryHandle
void GrabWires(std::vector< recob::Wire > const &wireVec, geo::Geometry const &)
void produce(art::Event &evt) override
algorithm to find feature 2D points
void makeSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
float line_integral(TH2F const &hist, int x1, float y1, int x2, float y2, float threshold) const
double ConvertXToTicks(double X, int p, int t, int c) const
std::string fCalDataModuleLabel
std::map< int, std::vector< double > > fEndPointTimes
std::string fHitModuleLabel
std::vector< TrajPoint > seeds
art::PtrVector< recob::Hit > Hits
Contains all timing reference information for the detector.
then echo File list $list not found else cat $list while read file do echo $file sed s
std::vector< recob::Seed > GetValidLines(detinfo::DetectorPropertiesData const &detProp, std::vector< recob::SpacePoint > &sps, bool ApplyFilter=true)
Declaration of basic channel signal object.
Algorithm for generating space points from hits.
art framework interface to geometry description
Encapsulate the construction of a single detector plane.
corner::CornerFinderAlg fCorner
FeatureTracker(fhicl::ParameterSet const &pset)