12 #include "canvas/Persistency/Common/PtrVector.h"
13 #include "cetlib_except/exception.h"
20 #include "messagefacility/MessageLogger/MessageLogger.h"
39 : fMaxDT{pset.get<
double>(
"MaxDT")}
40 ,
fMaxS{pset.get<
double>(
"MaxS")}
42 ,
fEnableU{pset.get<
bool>(
"EnableU")}
43 ,
fEnableV{pset.get<
bool>(
"EnableV")}
44 ,
fEnableW{pset.get<
bool>(
"EnableW")}
45 ,
fFilter{pset.get<
bool>(
"Filter")}
46 ,
fMerge{pset.get<
bool>(
"Merge")}
55 throw cet::exception(
"SpacePointAlg") <<
"Filter and Merge flags are both true.\n";
59 std::cout <<
"SpacePointAlg configured with the following parameters:\n"
60 <<
" MaxDT = " <<
fMaxDT <<
"\n"
61 <<
" MaxS = " <<
fMaxS <<
"\n"
66 <<
" Filter = " <<
fFilter <<
"\n"
67 <<
" Merge = " <<
fMerge <<
"\n"
82 static bool first =
true;
88 art::ServiceHandle<geo::Geometry const> geom;
92 if (report) mf::LogInfo(
"SpacePointAlg") <<
"Updating geometry constants.\n";
94 for (
unsigned int cstat = 0; cstat < geom->Ncryostats(); ++cstat) {
98 unsigned int const ntpc = geom->Cryostat(cstat).NTPC();
100 for (
unsigned int tpc = 0; tpc < ntpc; ++tpc) {
101 const geo::TPCGeo& tpcgeom = geom->Cryostat(cstat).TPC(tpc);
105 unsigned int const nplane = tpcgeom.
Nplanes();
107 for (
unsigned int plane = 0; plane < nplane; ++plane) {
114 std::string viewname =
"?";
115 if (view ==
geo::kU) { viewname =
"U"; }
123 throw cet::exception(
"SpacePointAlg") <<
"Bad view = " << view <<
"\n";
125 std::string sigtypename =
"?";
128 sigtypename =
"Induction";
130 sigtypename =
"Collection";
132 throw cet::exception(
"SpacePointAlg") <<
"Bad signal type = " << sigtype <<
"\n";
134 std::string orientname =
"?";
137 orientname =
"Vertical";
139 orientname =
"Horizontal";
141 throw cet::exception(
"SpacePointAlg") <<
"Bad orientation = " << orient <<
"\n";
145 mf::LogInfo(
"SpacePointAlg")
146 <<
"\nCryostat, TPC, Plane: " << cstat <<
"," << tpc <<
", " << plane <<
"\n"
147 <<
" View: " << viewname <<
"\n"
148 <<
" SignalType: " << sigtypename <<
"\n"
149 <<
" Orientation: " << orientname <<
"\n"
150 <<
" Plane location: " << xyz[0] <<
"\n"
151 <<
" Plane pitch: " << tpcgeom.
Plane0Pitch(plane) <<
"\n"
153 <<
" Wire pitch: " << tpcgeom.
WirePitch() <<
"\n"
154 <<
" Time offset: " << detProp.
GetXTicksOffset(plane, tpc, cstat) <<
"\n";
158 throw cet::exception(
"SpacePointAlg") <<
"Horizontal wire geometry not implemented.\n";
172 art::ServiceHandle<geo::Geometry const> geom;
195 art::ServiceHandle<geo::Geometry const> geom;
199 if (hits.size() < 3)
return 0.;
203 if (hits.size() > 3) {
204 mf::LogError(
"SpacePointAlg") <<
"Method separation called with more than three htis.";
212 double dist[3] = {0., 0., 0.};
213 double sinth[3] = {0., 0., 0.};
214 double costh[3] = {0., 0., 0.};
215 unsigned int cstats[3];
216 unsigned int tpcs[3];
219 for (
int i = 0; i < 3; ++i) {
231 for (
int j = 0; j < i; ++j) {
234 mf::LogError(
"SpacePointAlg")
235 <<
"Method separation called with hits from multiple cryostats..";
240 mf::LogError(
"SpacePointAlg")
241 <<
"Method separation called with hits from multiple tpcs..";
246 mf::LogError(
"SpacePointAlg")
247 <<
"Method separation called with hits from the same plane..";
254 double hl = wgeom.
HalfL();
259 double s = (xyz1[1] - xyz[1]) / hl;
260 double c = (xyz1[2] - xyz[2]) / hl;
263 dist[hit.
WireID().
Plane] = xyz[2] * s - xyz[1] * c;
266 double S = ((sinth[1] * costh[2] - costh[1] * sinth[2]) * dist[0] +
267 (sinth[2] * costh[0] - costh[2] * sinth[0]) * dist[1] +
268 (sinth[0] * costh[1] - costh[0] * sinth[1]) * dist[2]);
278 const art::PtrVector<recob::Hit>& hits,
281 art::ServiceHandle<geo::Geometry const> geom;
283 int nhits = hits.size();
287 bool result = nhits >= 2 && nhits <= 3;
289 unsigned int tpc = 0;
290 unsigned int cstat = 0;
297 for (
int ihit1 = 0; result && ihit1 < nhits - 1; ++ihit1) {
310 const std::vector<int>& tid1 = mcinfo1.
trackIDs;
311 bool only_neg1 = tid1.size() > 0 && tid1.back() < 0;
315 for (
int ihit2 = ihit1 + 1; result && ihit2 < nhits; ++ihit2) {
322 result = result && hit1WireID.
TPC == hit2WireID.
TPC && view1 != view2 &&
328 tpc = hit1WireID.
TPC;
340 if (result && useMC) {
345 std::vector<int> tid2 = mcinfo2.
trackIDs;
346 bool only_neg2 = tid2.size() > 0 && tid2.back() < 0;
347 std::vector<int>::iterator it = std::set_intersection(
348 tid1.begin(), tid1.end(), tid2.begin(), tid2.end(), tid2.begin());
349 tid2.resize(it - tid2.begin());
356 bool only_neg3 = tid2.size() > 0 && tid2.back() < 0;
357 mc_ok = tid2.size() > 0 && (!only_neg3 || (only_neg1 && only_neg2));
358 result = result && mc_ok;
364 result = mcinfo1.
pchit[hit2WireID.
Plane] == &hit2 ||
375 if (result && nhits == 3) {
379 double dist[3] = {0., 0., 0.};
380 double sinth[3] = {0., 0., 0.};
381 double costh[3] = {0., 0., 0.};
383 for (
int i = 0; i < 3; ++i) {
391 if ((hitWireID.
TPC != tpc) || (hitWireID.
Cryostat != cstat))
392 throw cet::exception(
"SpacePointAlg") <<
"compatible(): geometry mismatch\n";
396 double hl = wgeom.
HalfL();
401 double s = (xyz1[1] - xyz[1]) / hl;
402 double c = (xyz1[2] - xyz[2]) / hl;
405 dist[hit.
WireID().
Plane] = xyz[2] * s - xyz[1] * c;
410 double S = ((sinth[1] * costh[2] - costh[1] * sinth[2]) * dist[0] +
411 (sinth[2] * costh[0] - costh[2] * sinth[0]) * dist[1] +
412 (sinth[0] * costh[1] - costh[0] * sinth[1]) * dist[2]);
429 const art::PtrVector<recob::Hit>& hits,
430 std::vector<recob::SpacePoint>& sptv,
433 art::ServiceHandle<geo::Geometry const> geom;
437 int nhits = hits.size();
442 throw cet::exception(
"SpacePointAlg") <<
"fillSpacePoint(): hit already present!\n";
447 double xyz[3] = {0., 0., 0.};
448 double errxyz[6] = {0., 0., 0., 0., 0., 0.};
458 for (art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end();
469 double w = 1. / (et * et);
476 double drift_time = 0.;
477 double var_time = 0.;
480 drift_time = sumtw / sumw;
482 var_time = 1. / sumw;
483 if (var_time < 0.) var_time = 0.;
484 chisq = sumt2w - sumtw * drift_time;
485 if (chisq < 0.) chisq = 0.;
487 xyz[0] = drift_time * timePitch;
488 errxyz[0] = var_time * timePitch * timePitch;
505 for (art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end();
514 double hl = wgeom.
HalfL();
519 double s = (cen1[1] - cen[1]) / hl;
520 double c = (cen1[2] - cen[2]) / hl;
521 double u = cen[2] * s - cen[1] * c;
522 double eu = geom->WirePitch(hitWireID.
Plane, hitWireID.
TPC) / std::sqrt(12.);
523 double w = 1. / (eu * eu);
537 double denom = sc2 * ss2 - ssc * ssc;
539 xyz[1] = (-suc * ss2 + sus * ssc) / denom;
540 xyz[2] = (sus * sc2 - suc * ssc) / denom;
541 errxyz[2] = ss2 / denom;
542 errxyz[4] = ssc / denom;
543 errxyz[5] = sc2 / denom;
574 std::vector<recob::SpacePoint>& spts,
575 std::multimap<double, KHitTrack>
const& trackMap)
const
579 art::PtrVector<recob::Hit> hits;
580 art::PtrVector<recob::Hit> compatible_hits;
581 for (std::multimap<double, KHitTrack>::const_iterator it = trackMap.begin();
582 it != trackMap.end();
588 const std::shared_ptr<const KHitBase>&
hit = track.
getHit();
591 const art::Ptr<recob::Hit> prhit = phit->
getHit();
595 hits.push_back(prhit);
603 if (compatible_hits.size() >= 2) {
605 compatible_hits.clear();
611 hits.push_back(prhit);
616 compatible_hits = hits;
622 if (compatible_hits.size() >= 2) {
635 const art::PtrVector<recob::Hit>& hits,
636 std::vector<recob::SpacePoint>& sptv,
639 art::ServiceHandle<geo::Geometry const> geom;
647 unsigned int tpc0 = 0;
648 unsigned int cstat0 = 0;
649 int nhits = hits.size();
651 tpc0 = hits.front()->WireID().TPC;
652 cstat0 = hits.front()->WireID().Cryostat;
658 throw cet::exception(
"SpacePointAlg") <<
"fillComplexSpacePoint(): hit already present!\n";
664 unsigned int nplanes = geom->Cryostat(cstat0).TPC(tpc0).Nplanes();
665 std::vector<int> numhits(nplanes, 0);
666 std::vector<double> weight(nplanes, 0.);
668 for (art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end();
674 assert(hitWireID.
Cryostat == cstat0);
675 assert(hitWireID.
TPC == tpc0);
676 assert(hitWireID.
Plane < nplanes);
677 ++numhits[hitWireID.
Plane];
680 for (
unsigned int plane = 0; plane < nplanes; ++plane) {
681 double np = numhits[plane];
682 if (np > 0.) weight[plane] = 1. / (np * np * np);
687 double xyz[3] = {0., 0., 0.};
688 double errxyz[6] = {0., 0., 0., 0., 0., 0.};
698 for (art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end();
709 double w = weight[hitWireID.
Plane] / (et * et);
716 double drift_time = 0.;
717 double var_time = 0.;
720 drift_time = sumtw / sumw;
721 var_time = sumt2w / sumw - drift_time * drift_time;
722 if (var_time < 0.) var_time = 0.;
723 chisq = sumt2w - sumtw * drift_time;
724 if (chisq < 0.) chisq = 0.;
726 xyz[0] = drift_time * timePitch;
727 errxyz[0] = var_time * timePitch * timePitch;
744 for (art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end();
753 double hl = wgeom.
HalfL();
758 double s = (cen1[1] - cen[1]) / hl;
759 double c = (cen1[2] - cen[2]) / hl;
760 double u = cen[2] * s - cen[1] * c;
761 double eu = geom->WirePitch(hitWireID.
Plane, hitWireID.
TPC) / std::sqrt(12.);
762 double w = weight[hitWireID.
Plane] / (eu * eu);
776 double denom = sc2 * ss2 - ssc * ssc;
778 xyz[1] = (-suc * ss2 + sus * ssc) / denom;
779 xyz[2] = (sus * sc2 - suc * ssc) / denom;
780 errxyz[2] = ss2 / denom;
781 errxyz[4] = ssc / denom;
782 errxyz[5] = sc2 / denom;
799 const art::PtrVector<recob::Hit>& hits,
800 std::vector<recob::SpacePoint>& spts)
const
812 const art::PtrVector<recob::Hit>& hits,
813 std::vector<recob::SpacePoint>& spts)
const
825 const art::PtrVector<recob::Hit>& hits,
826 std::vector<recob::SpacePoint>& spts,
829 art::ServiceHandle<geo::Geometry const> geom;
839 spts.erase(spts.begin(), spts.end());
852 std::vector<std::vector<std::vector<std::multimap<unsigned int, art::Ptr<recob::Hit>>>>> hitmap;
855 unsigned int ncstat = geom->Ncryostats();
856 hitmap.resize(ncstat);
857 for (
unsigned int cstat = 0; cstat < ncstat; ++cstat) {
858 unsigned int ntpc = geom->Cryostat(cstat).NTPC();
859 hitmap[cstat].resize(ntpc);
860 for (
unsigned int tpc = 0; tpc < ntpc; ++tpc) {
861 int nplane = geom->Cryostat(cstat).TPC(tpc).Nplanes();
862 hitmap[cstat][tpc].resize(nplane);
866 for (art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end();
868 const art::Ptr<recob::Hit>& phit = *ihit;
874 std::make_pair(phitWireID.
Wire, phit));
883 art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
886 for (
unsigned int cstat = 0; cstat < ncstat; ++cstat) {
887 for (
unsigned int tpc = 0; tpc < geom->Cryostat(cstat).NTPC(); ++tpc) {
888 int nplane = geom->Cryostat(cstat).TPC(tpc).Nplanes();
889 for (
int plane = 0; plane < nplane; ++plane) {
890 for (std::map<
unsigned int, art::Ptr<recob::Hit>>::const_iterator ihit =
891 hitmap[cstat][tpc][plane].
begin();
892 ihit != hitmap[cstat][tpc][plane].end();
894 const art::Ptr<recob::Hit>& phit = ihit->second;
900 mcinfo.
pchit.resize(nplane, 0);
901 mcinfo.
dist2.resize(nplane, 1.e20);
905 std::vector<sim::IDE> ides = bt_serv->HitToAvgSimIDEs(clockData, phit);
909 mcinfo.
trackIDs.reserve(ides.size());
910 for (std::vector<sim::IDE>::const_iterator i = ides.begin(); i != ides.end(); ++i)
911 mcinfo.
trackIDs.push_back(i->trackID);
917 mcinfo.
xyz = bt_serv->SimIDEsToXYZ(ides);
919 catch (cet::exception&
x) {
928 for (
unsigned int cstat = 0; cstat < ncstat; ++cstat) {
929 for (
unsigned int tpc = 0; tpc < geom->Cryostat(cstat).NTPC(); ++tpc) {
930 int nplane = geom->Cryostat(cstat).TPC(tpc).Nplanes();
931 for (
int plane = 0; plane < nplane; ++plane) {
932 for (std::map<
unsigned int, art::Ptr<recob::Hit>>::const_iterator ihit =
933 hitmap[cstat][tpc][plane].
begin();
934 ihit != hitmap[cstat][tpc][plane].end();
936 const art::Ptr<recob::Hit>& phit = ihit->second;
939 if (mcinfo.
xyz.size() != 0) {
940 assert(mcinfo.
xyz.size() == 3);
944 for (
int plane2 = 0; plane2 < nplane; ++plane2) {
945 for (std::map<
unsigned int, art::Ptr<recob::Hit>>::const_iterator jhit =
946 hitmap[cstat][tpc][plane2].
begin();
947 jhit != hitmap[cstat][tpc][plane2].end();
949 const art::Ptr<recob::Hit>& phit2 = jhit->second;
953 if (mcinfo2.
xyz.size() != 0) {
954 assert(mcinfo2.
xyz.size() == 3);
955 double dx = mcinfo.
xyz[0] - mcinfo2.
xyz[0];
956 double dy = mcinfo.
xyz[1] - mcinfo2.
xyz[1];
957 double dz = mcinfo.
xyz[2] - mcinfo2.
xyz[2];
958 double dist2 = dx * dx + dy * dy + dz * dz;
959 if (dist2 < mcinfo.
dist2[plane2]) {
960 mcinfo.
dist2[plane2] = dist2;
961 mcinfo.
pchit[plane2] = &hit2;
975 mf::LogDebug
debug(
"SpacePointAlg");
976 if (mf::isDebugEnabled()) {
977 debug <<
"Total hits = " << hits.size() <<
"\n\n";
979 for (
unsigned int cstat = 0; cstat < ncstat; ++cstat) {
980 for (
unsigned int tpc = 0; tpc < geom->Cryostat(cstat).NTPC(); ++tpc) {
981 int nplane = hitmap[cstat][tpc].size();
982 for (
int plane = 0; plane < nplane; ++plane) {
983 debug <<
"TPC, Plane: " << tpc <<
", " << plane
984 <<
", hits = " << hitmap[cstat][tpc][plane].size() <<
"\n";
996 std::multimap<sptkey_type, recob::SpacePoint> sptmap;
997 std::set<sptkey_type> sptkeys;
1000 for (
unsigned int cstat = 0; cstat < ncstat; ++cstat) {
1001 for (
unsigned int tpc = 0; tpc < geom->Cryostat(cstat).NTPC(); ++tpc) {
1016 int nplane = hitmap[cstat][tpc].size();
1017 std::vector<int> index(nplane);
1019 for (
int i = 0; i < nplane; ++i)
1022 for (
int i = 0; i < nplane - 1; ++i) {
1024 for (
int j = i + 1; j < nplane; ++j) {
1029 if ((hitmap[cstat][tpc][index[i]].
size() > hitmap[cstat][tpc][index[j]].
size() &&
1032 int temp = index[i];
1033 index[i] = index[j];
1042 std::vector<std::multimap<unsigned int, art::Ptr<recob::Hit>>>& hitsByPlaneVec =
1044 int nViewsWithHits(0);
1046 for (
int i = 0; i < nplane; i++) {
1047 if (hitsByPlaneVec[index[i]].
size() > 0) nViewsWithHits++;
1053 if ((nViewsWithHits == 2 || nplane == 2) &&
fMinViews <= 2) {
1056 for (
int i = 0; i < nplane - 1; ++i) {
1057 unsigned int plane1 = index[i];
1059 if (hitmap[cstat][tpc][plane1].
empty())
continue;
1061 for (
int j = i + 1; j < nplane; ++j) {
1062 unsigned int plane2 = index[j];
1064 if (hitmap[cstat][tpc][plane2].
empty())
continue;
1067 const geo::WireGeo& wgeo2 = geom->Cryostat(cstat).TPC(tpc).Plane(plane2).Wire(0);
1068 double hl2 = wgeo2.
HalfL();
1073 double s2 = (xyz22[1] - xyz21[1]) / (2. * hl2);
1074 double c2 = (xyz22[2] - xyz21[2]) / (2. * hl2);
1075 double dist2 = -xyz21[1] * c2 + xyz21[2] * s2;
1076 double pitch2 = geom->WirePitch(plane2, tpc, cstat);
1079 hitmap[cstat][tpc][plane1].
size() > hitmap[cstat][tpc][plane2].
size())
1080 throw cet::exception(
"SpacePointAlg")
1081 <<
"makeSpacePoints(): hitmaps with incompatible size\n";
1085 art::PtrVector<recob::Hit> hitvec;
1088 for (std::map<
unsigned int, art::Ptr<recob::Hit>>::const_iterator ihit1 =
1089 hitmap[cstat][tpc][plane1].
begin();
1090 ihit1 != hitmap[cstat][tpc][plane1].end();
1093 const art::Ptr<recob::Hit>& phit1 = ihit1->second;
1095 const geo::WireGeo& wgeo = geom->WireIDToWireGeo(phit1WireID);
1099 assert(phit1WireID.
Cryostat == cstat);
1100 assert(phit1WireID.
TPC == tpc);
1101 assert(phit1WireID.
Plane == plane1);
1102 double hl1 = wgeo.
HalfL();
1110 double wire21 = (-xyz1[1] * c2 + xyz1[2] * s2 - dist2) / pitch2;
1111 double wire22 = (-xyz2[1] * c2 + xyz2[2] * s2 - dist2) / pitch2;
1113 int wmin = std::max(0., std::min(wire21, wire22));
1114 int wmax = std::max(0., std::max(wire21, wire22) + 1.);
1116 std::map<unsigned int, art::Ptr<recob::Hit>>::const_iterator
1117 ihit2 = hitmap[cstat][tpc][plane2].lower_bound(wmin),
1118 ihit2end = hitmap[cstat][tpc][plane2].upper_bound(wmax);
1120 for (; ihit2 != ihit2end; ++ihit2) {
1122 const art::Ptr<recob::Hit>& phit2 = ihit2->second;
1129 hitvec.push_back(phit1);
1130 hitvec.push_back(phit2);
1131 bool ok =
compatible(detProp, hitvec, useMC);
1145 std::vector<recob::SpacePoint> sptv;
1147 sptkey_type key = &*phit2;
1148 sptmap.insert(std::pair<sptkey_type, recob::SpacePoint>(key, sptv.back()));
1149 sptkeys.insert(key);
1164 art::PtrVector<recob::Hit> hitvec;
1167 unsigned int plane1 = index[0];
1168 unsigned int plane2 = index[1];
1169 unsigned int plane3 = index[2];
1173 const geo::WireGeo& wgeo1 = geom->Cryostat(cstat).TPC(tpc).Plane(plane1).Wire(0);
1174 double hl1 = wgeo1.
HalfL();
1179 double s1 = (xyz12[1] - xyz11[1]) / (2. * hl1);
1180 double c1 = (xyz12[2] - xyz11[2]) / (2. * hl1);
1181 double dist1 = -xyz11[1] * c1 + xyz11[2] * s1;
1182 double pitch1 = geom->WirePitch(plane1, tpc, cstat);
1183 const double TicksOffset1 = detProp.
GetXTicksOffset(plane1, tpc, cstat);
1187 const geo::WireGeo& wgeo2 = geom->Cryostat(cstat).TPC(tpc).Plane(plane2).Wire(0);
1188 double hl2 = wgeo2.
HalfL();
1193 double s2 = (xyz22[1] - xyz21[1]) / (2. * hl2);
1194 double c2 = (xyz22[2] - xyz21[2]) / (2. * hl2);
1195 double dist2 = -xyz21[1] * c2 + xyz21[2] * s2;
1196 double pitch2 = geom->WirePitch(plane2, tpc, cstat);
1197 const double TicksOffset2 = detProp.
GetXTicksOffset(plane2, tpc, cstat);
1201 const geo::WireGeo& wgeo3 = geom->Cryostat(cstat).TPC(tpc).Plane(plane3).Wire(0);
1202 double hl3 = wgeo3.
HalfL();
1207 double s3 = (xyz32[1] - xyz31[1]) / (2. * hl3);
1208 double c3 = (xyz32[2] - xyz31[2]) / (2. * hl3);
1209 double dist3 = -xyz31[1] * c3 + xyz31[2] * s3;
1210 double pitch3 = geom->WirePitch(plane3, tpc, cstat);
1211 const double TicksOffset3 = detProp.
GetXTicksOffset(plane3, tpc, cstat);
1215 double s12 = s1 * c2 - s2 * c1;
1216 double s23 = s2 * c3 - s3 * c2;
1217 double s31 = s3 * c1 - s1 * c3;
1221 std::map<unsigned int, art::Ptr<recob::Hit>>::const_iterator
1222 ihit1 = hitmap[cstat][tpc][plane1].begin(),
1223 ihit1end = hitmap[cstat][tpc][plane1].end();
1224 for (; ihit1 != ihit1end; ++ihit1) {
1226 unsigned int wire1 = ihit1->first;
1227 const art::Ptr<recob::Hit>& phit1 = ihit1->second;
1229 const geo::WireGeo& wgeo = geom->WireIDToWireGeo(phit1WireID);
1233 assert(phit1WireID.
Cryostat == cstat);
1234 assert(phit1WireID.
TPC == tpc);
1235 assert(phit1WireID.
Plane == plane1);
1236 assert(phit1WireID.
Wire == wire1);
1237 double hl1 = wgeo.
HalfL();
1245 double t1 = phit1->PeakTime() - TicksOffset1;
1246 double u1 = wire1 * pitch1 + dist1;
1250 double wire21 = (-xyz1[1] * c2 + xyz1[2] * s2 - dist2) / pitch2;
1251 double wire22 = (-xyz2[1] * c2 + xyz2[2] * s2 - dist2) / pitch2;
1253 int wmin = std::max(0., std::min(wire21, wire22));
1254 int wmax = std::max(0., std::max(wire21, wire22) + 1.);
1256 std::map<unsigned int, art::Ptr<recob::Hit>>::const_iterator
1257 ihit2 = hitmap[cstat][tpc][plane2].lower_bound(wmin),
1258 ihit2end = hitmap[cstat][tpc][plane2].upper_bound(wmax);
1260 for (; ihit2 != ihit2end; ++ihit2) {
1262 int wire2 = ihit2->first;
1263 const art::Ptr<recob::Hit>& phit2 = ihit2->second;
1267 double t2 = phit2->PeakTime() - TicksOffset2;
1278 hitvec.push_back(phit1);
1279 hitvec.push_back(phit2);
1280 bool h12ok =
compatible(detProp, hitvec, useMC);
1285 double u2 = wire2 * pitch2 + dist2;
1289 double u3pred = (-u1 * s23 - u2 * s31) / s12;
1290 double w3pred = (u3pred - dist3) / pitch3;
1292 int w3min = std::max(0., std::ceil(w3pred - w3delta));
1293 int w3max = std::max(0., std::floor(w3pred + w3delta));
1295 std::map<unsigned int, art::Ptr<recob::Hit>>::const_iterator
1296 ihit3 = hitmap[cstat][tpc][plane3].lower_bound(w3min),
1297 ihit3end = hitmap[cstat][tpc][plane3].upper_bound(w3max);
1299 for (; ihit3 != ihit3end; ++ihit3) {
1301 int wire3 = ihit3->first;
1302 const art::Ptr<recob::Hit>& phit3 = ihit3->second;
1306 double t3 = phit3->PeakTime() - TicksOffset3;
1315 double u3 = wire3 * pitch3 + dist3;
1316 double S = s23 * u1 + s31 * u2 + s12 * u3;
1323 hitvec.push_back(phit1);
1324 hitvec.push_back(phit2);
1325 hitvec.push_back(phit3);
1326 bool h123ok =
compatible(detProp, hitvec, useMC);
1340 std::vector<recob::SpacePoint> sptv;
1342 sptkey_type key = &*phit3;
1344 std::pair<sptkey_type, recob::SpacePoint>(key, sptv.back()));
1345 sptkeys.insert(key);
1362 spts.reserve(spts.size() + sptkeys.size());
1367 for (std::set<sptkey_type>::const_iterator i = sptkeys.begin(); i != sptkeys.end(); ++i) {
1368 sptkey_type key = *i;
1373 double best_chisq = 0.;
1376 for (std::multimap<sptkey_type, recob::SpacePoint>::const_iterator j =
1377 sptmap.lower_bound(key);
1378 j != sptmap.upper_bound(key);
1381 if (best_spt == 0 || spt.
Chisq() < best_chisq) {
1383 best_chisq = spt.
Chisq();
1390 throw cet::exception(
"SpacePointAlg") <<
"makeSpacePoints(): no best point\n";
1391 spts.push_back(*best_spt);
1405 spts.reserve(spts.size() + sptkeys.size());
1410 for (std::set<sptkey_type>::const_iterator i = sptkeys.begin(); i != sptkeys.end(); ++i) {
1411 sptkey_type key = *i;
1417 std::multimap<sptkey_type, recob::SpacePoint>::const_iterator jSPT =
1418 sptmap.lower_bound(key),
1420 sptmap.upper_bound(key);
1422 art::PtrVector<recob::Hit> merged_hits;
1423 for (; jSPT != jSPTend; ++jSPT) {
1430 merged_hits.reserve(merged_hits.size() +
1432 for (art::PtrVector<recob::Hit>::const_iterator
k = spt_hits.begin();
1433 k != spt_hits.end();
1435 const art::Ptr<recob::Hit>&
hit = *
k;
1436 merged_hits.push_back(hit);
1442 std::sort(merged_hits.begin(), merged_hits.end());
1443 art::PtrVector<recob::Hit>::iterator it =
1444 std::unique(merged_hits.begin(), merged_hits.end());
1445 merged_hits.erase(it, merged_hits.end());
1464 spts.reserve(spts.size() + sptkeys.size());
1468 for (std::multimap<sptkey_type, recob::SpacePoint>::const_iterator j = sptmap.begin();
1472 spts.push_back(spt);
1483 if (mf::isDebugEnabled()) {
1484 debug <<
"\n2-hit space points = " << n2 <<
"\n"
1485 <<
"3-hit space points = " << n3 <<
"\n"
1486 <<
"2-hit filtered/merged space points = " << n2filt <<
"\n"
1487 <<
"3-hit filtered/merged space points = " << n3filt;
1494 const art::PtrVector<recob::Hit>&
1499 std::map<int, art::PtrVector<recob::Hit>>::const_iterator it =
fSptHitMap.find(spt.
ID());
1501 mf::LogWarning(
"SpacePointAlg")
1502 <<
"Looking for ID " << spt.
ID() <<
" from " <<
fSptHitMap.size() << std::endl;
1503 throw cet::exception(
"SpacePointAlg") <<
"No Hits associated with space point.\n";
1505 return (*it).second;
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Basic Kalman filter track class, plus one measurement on same surface.
const std::shared_ptr< const KHitBase > & getHit() const
Measurement.
see a below echo S(symbol in a section other than those above)
std::vector< const recob::Hit * > pchit
Pointer to nearest neighbor hit (indexed by plane).
std::map< const recob::Hit *, HitMCInfo > fHitMCMap
double fTickOffsetU
Tick offset for plane U.
Encapsulate the construction of a single cyostat.
double fMaxDT
Maximum time difference between planes.
process_name opflash particleana ie x
double GetXTicksCoefficient(int t, int c) const
WireGeo const & Wire(unsigned int iwire) const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
double GetXTicksOffset(int p, int t, int c) const
geo::WireID WireID() const
enum geo::_plane_orient Orient_t
unsigned int Nplanes() const
Number of planes in this tpc.
Declaration of signal hit object.
Kalman filter wire-time measurement on a SurfWireX surface.
void update(detinfo::DetectorPropertiesData const &detProp) const
The data type to uniquely identify a Plane.
std::vector< double > dist2
Distance to nearest neighbor hit (indexed by plane).
Geometry information for a single TPC.
bool fEnableW
Enable flag (W).
std::vector< int > trackIDs
Parent trackIDs.
const art::Ptr< recob::Hit > & getHit() const
Get original hit.
CryostatID_t Cryostat
Index of cryostat.
std::size_t size(FixedBins< T, C > const &) noexcept
Planes which measure Z direction.
geo::View_t View() const
View for the plane of the hit.
WireID_t Wire
Index of the wire within its plane.
process_name use argoneut_mc_hitfinder track
double ThetaZ() const
Returns angle of wire with respect to z axis in the Y-Z plane in radians.
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
void makeMCTruthSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
double separation(const art::PtrVector< recob::Hit > &hits) const
View_t View() const
Which coordinate does this plane measure.
Planes that are in the horizontal plane.
SpacePointAlg(const fhicl::ParameterSet &pset)
bool fEnableU
Enable flag (U).
Signal from induction planes.
std::map< int, art::PtrVector< recob::Hit > > fSptHitMap
Planes that are in the vertical plane (e.g. ArgoNeuT).
std::vector< double > xyz
Location of ionization (all tracks).
enum geo::_plane_sigtype SigType_t
void makeSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
void fillComplexSpacePoint(detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &sptv, int sptid) const
double WirePitch(unsigned plane=0) const
double fMaxS
Maximum space separation between wires.
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
double correctedTime(detinfo::DetectorPropertiesData const &detProp, const recob::Hit &hit) const
bool fPreferColl
Sort by collection wire.
double Plane0Pitch(unsigned int p) const
void fillSpacePoints(detinfo::DetectorPropertiesData const &detProp, std::vector< recob::SpacePoint > &spts, std::multimap< double, KHitTrack > const &trackMap) const
Fill a collection of space points.
Orient_t Orientation() const
What is the orientation of the plane.
Encapsulate the geometry of a wire.
auto begin(FixedBins< T, C > const &) noexcept
double HalfL() const
Returns half the length of the wire [cm].
float PeakTime() const
Time of the signal peak, in tick units.
double fTickOffsetV
Tick offset for plane V.
Encapsulate the construction of a single detector plane.
Contains all timing reference information for the detector.
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
then echo File list $list not found else cat $list while read file do echo $file sed s
double fTickOffsetW
Tick offset for plane W.
bool compatible(detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, bool useMC=false) const
constexpr WireID()=default
Default constructor: an invalid TPC ID.
int fMinViews
Mininum number of views per space point.
float SigmaPeakTime() const
Uncertainty for the signal peak, in tick units.
Planes which measure W (third view for Bo, MicroBooNE, etc).
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
2D representation of charge deposited in the TDC/wire plane
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
TPCID_t TPC
Index of the TPC within its cryostat.
Algorithm for generating space points from hits.
void fillSpacePoint(detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &sptv, int sptid) const
bool empty(FixedBins< T, C > const &) noexcept
const double * PlaneLocation(unsigned int p) const
art framework interface to geometry description
BEGIN_PROLOG could also be cout
Encapsulate the construction of a single detector plane.
Signal from collection planes.
bool fEnableV
Enable flag (V).