52 #include "canvas/Persistency/Common/FindManyP.h" 94 art::FindManyP<recob::Hit> fmhit);
100 std::vector<double>
const& Wire_2dvtx,
101 std::vector<double>
const& Time_2dvtx,
102 std::vector<double>
const& Plane_2dvtx);
109 std::vector<double> merge_vtxY,
110 std::vector<double> merge_vtxZ,
111 std::vector<double> merge_vtxStgth);
137 std::vector<std::vector<int>>
Cls;
171 produces<std::vector<recob::Vertex>>();
172 produces<std::vector<recob::EndPoint2D>>();
173 produces<art::Assns<recob::EndPoint2D, recob::Hit>>();
177 produces<art::Assns<recob::Vertex, recob::Hit>>();
178 produces<art::Assns<recob::Vertex, recob::Shower>>();
179 produces<art::Assns<recob::Vertex, recob::Track>>();
182 Cls.resize(geom->Nplanes(), std::vector<int>());
198 for (
size_t cstat = 0; cstat < geom->
Ncryostats(); ++cstat) {
199 for (
size_t tpc = 0; tpc < geom->
Cryostat(cstat).
NTPC(); ++tpc) {
208 auto vcol = std::make_unique<std::vector<recob::Vertex>>();
209 auto epcol = std::make_unique<std::vector<recob::EndPoint2D>>();
210 auto assnep = std::make_unique<art::Assns<recob::EndPoint2D, recob::Hit>>();
211 auto assnsh = std::make_unique<art::Assns<recob::Vertex, recob::Shower>>();
212 auto assntr = std::make_unique<art::Assns<recob::Vertex, recob::Track>>();
213 auto assnh = std::make_unique<art::Assns<recob::Vertex, recob::Hit>>();
222 std::vector<art::Ptr<recob::EndPoint2D>> ccrawlerEndPoints;
229 mf::LogWarning(
"FeatureVertexFinder") <<
"Failed to get EndPoint2d's from Cluster Crawler";
238 std::vector<art::Ptr<recob::EndPoint2D>> cornerEndPoints;
245 mf::LogWarning(
"FeatureVertexFinder") <<
"Failed to get EndPoint2d's from Corner Finder";
260 for (
unsigned int ii = 0; ii < clusterListHandle->size(); ++ii) {
272 mf::LogWarning(
"FeatureVertexFinder") <<
"Failed to get Cluster from default cluster module";
294 double tempxyz[3] = {
299 if (tempxyz[0] == 0 && tempxyz[1] == 0 && tempxyz[2] == 0) {
continue; }
301 vcol->push_back(the3Dvertex);
307 for (
size_t cstat = 0; cstat < geom->
Ncryostats(); ++cstat) {
308 for (
size_t tpc = 0; tpc < geom->
Cryostat(cstat).
NTPC(); ++tpc) {
310 double temp2dXYZ[3] = {
316 if (temp2dXYZ[0] == 0 && temp2dXYZ[1] == 0 && temp2dXYZ[2] == 0) {
continue; }
321 double EndPoint2d_TimeTick = detProp.ConvertXToTicks(temp2dXYZ[0], plane, tpc, cstat);
322 int EndPoint2d_Wire = 0;
323 int EndPoint2d_Channel = 0;
326 EndPoint2d_Wire = geom->
NearestWire(temp2dXYZ, plane, tpc, cstat);
334 EndPoint2d_Channel = geom->
NearestChannel(temp2dXYZ, plane, tpc, cstat);
343 geo::WireID wireID(cstat, tpc, plane, EndPoint2d_Wire);
373 double tempxyz[3] = {
378 if (bail > 0) {
continue; }
379 if (tempxyz[0] == 0 && tempxyz[1] == 0 && tempxyz[2] == 0) {
continue; }
383 vcol->push_back(the3Dvertex);
392 for (
size_t cstat = 0; cstat < geom->
Ncryostats(); ++cstat) {
394 for (
size_t tpc = 0; tpc < geom->
Cryostat(cstat).
NTPC(); ++tpc) {
405 double EndPoint2d_TimeTick = detProp.ConvertXToTicks(temp2dXYZ[0], plane, tpc, cstat);
406 int EndPoint2d_Wire = 0;
407 int EndPoint2d_Channel = 0;
410 EndPoint2d_Wire = geom->
NearestWire(temp2dXYZ, plane, tpc, cstat);
418 EndPoint2d_Channel = geom->
NearestChannel(temp2dXYZ, plane, tpc, cstat);
427 geo::WireID wireID(cstat, tpc, plane, EndPoint2d_Wire);
445 for (
size_t i = 0; i < epcol->size(); ++i)
447 for (
size_t i = 0; i < vcol->size(); ++i)
497 double y = 0.,
z = 0.;
498 double yy = 0., zz = 0.;
499 double yy2 = 0., zz2 = 0.;
500 double yy3 = 0., zz3 = 0.;
502 for (
size_t cstat = 0; cstat < geom->
Ncryostats(); ++cstat) {
503 for (
size_t tpc = 0; tpc < geom->
Cryostat(cstat).
NTPC(); ++tpc) {
504 for (
size_t endpt1 = 0; endpt1 < EndPoints.size(); endpt1++) {
505 for (
size_t endpt2 = endpt1 + 1; endpt2 < EndPoints.size(); endpt2++) {
510 if (EndPoints.at(endpt1)->WireID().Plane != EndPoints.at(endpt2)->WireID().Plane) {
515 float tempXFeature1 = detProp.
ConvertTicksToX(EndPoints.at(endpt1)->DriftTime(),
516 EndPoints.at(endpt1)->WireID().Plane,
519 float tempXFeature2 = detProp.
ConvertTicksToX(EndPoints.at(endpt2)->DriftTime(),
520 EndPoints.at(endpt2)->WireID().Plane,
529 EndPoints.at(endpt2)->WireID().Wire,
533 EndPoints.at(endpt1)->WireID().Wire,
538 std::abs(tempXFeature1 - tempXFeature2) < 0.5) {
548 EndPoints.at(endpt2)->Strength());
558 for (
size_t endpt3 = endpt2 + 1; endpt3 < EndPoints.size(); endpt3++) {
563 if (EndPoints.at(endpt3)->WireID().Plane !=
564 EndPoints.at(endpt2)->WireID().Plane &&
565 EndPoints.at(endpt3)->WireID().Plane !=
566 EndPoints.at(endpt1)->WireID().Plane &&
567 EndPoints.at(endpt1)->WireID().Plane !=
568 EndPoints.at(endpt2)->WireID().Plane) {
569 float tempXFeature3 =
571 EndPoints.at(endpt3)->WireID().Plane,
582 EndPoints.at(endpt3)->WireID().Wire,
586 EndPoints.at(endpt1)->WireID().Wire,
593 EndPoints.at(endpt3)->WireID().Wire,
597 EndPoints.at(endpt2)->WireID().Wire,
604 EndPoints.at(endpt2)->WireID().Wire,
608 EndPoints.at(endpt1)->WireID().Wire,
613 std::abs(tempXFeature3 - tempXFeature2) < 1.0 &&
614 std::abs(tempXFeature3 - tempXFeature1) < 1.0 &&
615 std::abs(tempXFeature1 - tempXFeature2) < 1.0) {
618 EndPoints.at(endpt1)->WireID().Plane,
625 EndPoints.at(endpt2)->WireID().Wire,
626 EndPoints.at(endpt1)->WireID().Plane,
627 EndPoints.at(endpt2)->WireID().Plane,
636 EndPoints.at(endpt2)->Strength() +
637 EndPoints.at(endpt3)->Strength());
644 if (endpt1 < EndPoints.size()) { endpt1++; }
645 if (endpt2 < EndPoints.size()) { endpt2++; }
646 if (endpt3 < EndPoints.size()) { endpt3++; }
671 art::FindManyP<recob::Hit> fmhit)
675 int nClustersFound = 0;
681 for (
size_t iclu = 0; iclu < RawClusters.
size(); ++iclu) {
683 std::vector<art::Ptr<recob::Hit>>
hit = fmhit.at(iclu);
687 if (hit.size() < 15) {
continue; }
692 if (view >= Cls.size()) {
693 std::cerr << __PRETTY_FUNCTION__ <<
"\033[93m Logic error in my code ... view " << view
694 <<
" not supported ! \033[00m" <<
std::endl;
698 Cls.at(RawClusters.
at(iclu)->View()).
push_back(iclu);
702 std::vector<double> wires;
703 std::vector<double> times;
710 for (
size_t i = 0; i < hit.size(); ++i) {
712 times.push_back(hit[i]->PeakTime());
723 TGraph* the2Dtrack =
new TGraph(n, &wires[0], ×[0]);
726 the2Dtrack->Fit(
"pol1",
"Q");
727 TF1* pol1 = (TF1*)the2Dtrack->GetFunction(
"pol1");
730 pol1->GetParameters(par);
731 parerror[1] = pol1->GetParError(1);
732 double FitChi2 = pol1->GetChisquare();
733 double FitNDF = pol1->GetNDF();
735 double fitGoodness = FitChi2 / FitNDF;
738 if (fitGoodness > 10) {
739 dtdwstart.push_back(std::tan(RawClusters[iclu]->StartAngle()));
752 <<
"Fitter failed, using the clusters default dTdW()";
754 dtdwstart.push_back(std::tan(RawClusters[iclu]->StartAngle()));
765 dtdwstart.push_back(std::tan(RawClusters[iclu]->StartAngle()));
774 for (
size_t cstat = 0; cstat < geom->
Ncryostats(); ++cstat) {
775 for (
size_t tpc = 0; tpc < geom->
Cryostat(cstat).
NTPC(); ++tpc) {
780 if (Cls[i].
size() >= 1) {
784 for (
unsigned int j = 0; j < Cls[i].size(); ++j) {
795 Clu_Length.push_back(std::sqrt(
pow((RawClusters.
at(Cls.at(i).at(j))->StartWire() -
796 RawClusters.
at(Cls.at(i).at(j))->EndWire()) *
799 pow(RawClusters.
at(Cls.at(i).at(j))->StartTick() -
800 RawClusters.
at(Cls.at(i).at(j))->EndTick(),
807 RawClusters.
at(Cls.at(i).at(j))->StartTick() -
808 (
dtdwstart[Cls[i][j]] * RawClusters.
at(Cls.at(i).at(j))->StartWire()));
815 RawClusters.
at(Cls.at(i).at(j))->EndTick() -
816 (
dtdwstart[Cls[i][j]] * RawClusters.
at(Cls.at(i).at(j))->EndWire()));
840 for (
unsigned int n = nClustersFound;
n > 0;
n--) {
845 for (
unsigned int m = 0;
m <
n;
m++) {
854 float intersection_X =
861 float intersection_X2 =
869 if (intersection_X2 < 1) { intersection_X2 = -999; }
870 if (intersection_X2 > geom->
Nwires(
Clu_Plane[m], 0, 0)) { intersection_X2 = -999; }
871 if (intersection_Y2 < 0) { intersection_Y2 = -999; }
873 if (intersection_X < 1) { intersection_X = -999; }
874 if (intersection_X > geom->
Nwires(
Clu_Plane[m], 0, 0)) { intersection_X = -999; }
875 if (intersection_Y < 0) { intersection_Y = -999; }
882 std::vector<art::Ptr<recob::Hit>> hitClu1 = fmhit.at(m);
883 std::vector<art::Ptr<recob::Hit>> hitClu2 = fmhit.at(n);
890 intersection_X2 = -999;
891 intersection_Y2 = -999;
896 intersection_X = -999;
897 intersection_Y = -999;
906 intersection_X2 = -999;
907 intersection_Y2 = -999;
912 intersection_X = -999;
913 intersection_Y = -999;
917 mf::LogWarning(
"FeatureVertexFinder") <<
"FindManyHit Function faild";
918 intersection_X = -999;
919 intersection_Y = -999;
920 intersection_X2 = -999;
921 intersection_Y2 = -999;
928 if (intersection_X2 > 1 && intersection_Y2 > 0 &&
929 (intersection_X2 < geom->Nwires(
Clu_Plane[m], 0, 0)) &&
940 if (intersection_X > 1 && intersection_Y > 0 &&
941 (intersection_X < geom->Nwires(
Clu_Plane[m], 0, 0)) &&
960 std::vector<double>
const& Wire_2dvtx,
961 std::vector<double>
const& Time_2dvtx,
962 std::vector<double>
const& Plane_2dvtx)
965 std::vector<double> vtx_wire_merged;
966 std::vector<double> vtx_time_merged;
967 std::vector<double> vtx_plane_merged;
969 double y_coord = 0, z_coord = 0;
979 for (
size_t vtxloop1 = 0; vtxloop1 < Wire_2dvtx.size(); vtxloop1++) {
980 if (Wire_2dvtx[vtxloop1] < 0) {
continue; }
986 for (
size_t vtxloop2 = vtxloop1 + 1; vtxloop2 < Wire_2dvtx.size(); vtxloop2++) {
987 if (Wire_2dvtx[vtxloop2] < 0) {
continue; }
991 if (Plane_2dvtx[vtxloop1] == Plane_2dvtx[vtxloop2]) {
996 if (fabs(Wire_2dvtx[vtxloop1] - Wire_2dvtx[vtxloop2]) < 4) {
1000 if (fabs(Time_2dvtx[vtxloop1] - Time_2dvtx[vtxloop2]) < 10) {
1001 vtx_wire_merged.push_back(((Wire_2dvtx[vtxloop2] + Wire_2dvtx[vtxloop1]) / 2));
1002 vtx_time_merged.push_back(((Time_2dvtx[vtxloop2] + Time_2dvtx[vtxloop1]) / 2));
1003 vtx_plane_merged.push_back(Plane_2dvtx[vtxloop1]);
1006 if (vtxloop2 < Wire_2dvtx.size()) { vtxloop2++; }
1007 if (vtxloop1 < Wire_2dvtx.size()) { vtxloop1++; }
1013 vtx_wire_merged.push_back(Wire_2dvtx[vtxloop1]);
1014 vtx_time_merged.push_back(Time_2dvtx[vtxloop1]);
1015 vtx_plane_merged.push_back(Plane_2dvtx[vtxloop1]);
1021 uint32_t vtx1_channel = 0;
1022 uint32_t vtx2_channel = 0;
1030 for (
size_t cstat = 0; cstat < geom->
Ncryostats(); ++cstat) {
1034 for (
size_t tpc = 0; tpc < geom->
Cryostat(cstat).
NTPC(); ++tpc) {
1035 for (
unsigned int vtx = vtx_wire_merged.size(); vtx > 0; vtx--) {
1036 for (
unsigned int vtx1 = 0; vtx1 < vtx; vtx1++) {
1041 if (vtx_plane_merged[vtx1] != vtx_plane_merged[vtx]) {
1050 unsigned int vtx1_plane = vtx_plane_merged[vtx1];
1051 unsigned int vtx1_wire = vtx_wire_merged[vtx1];
1056 mf::LogWarning(
"FeatureVertexFinder") <<
"PlaneWireToChannel Failed";
1061 unsigned int vtx2_plane = vtx_plane_merged[vtx];
1062 unsigned int vtx2_wire = vtx_wire_merged[vtx];
1067 mf::LogWarning(
"FeatureVertexFinder") <<
"PlaneWireToChannel Failed";
1079 mf::LogWarning(
"FeatureVertexFinder") <<
"match failed for some reason";
1088 float tempXCluster1 =
1089 detProp.
ConvertTicksToX(vtx_time_merged[vtx1], vtx1_plane, tpc, cstat);
1090 float tempXCluster2 =
1091 detProp.
ConvertTicksToX(vtx_time_merged[vtx], vtx2_plane, tpc, cstat);
1099 vtx_time_merged[vtx1], vtx_plane_merged[vtx1], tpc, cstat));
1123 std::vector<double> merge_vtxY,
1124 std::vector<double> merge_vtxZ,
1125 std::vector<double> merge_vtxStgth)
1128 std::vector<double> x_3dVertex_dupRemoved = {0.};
1129 std::vector<double> y_3dVertex_dupRemoved = {0.};
1130 std::vector<double> z_3dVertex_dupRemoved = {0.};
1131 std::vector<double> strength_dupRemoved = {0.};
1135 for (
size_t dup = 0; dup < merge_vtxX.size(); dup++) {
1137 float tempX_dup = merge_vtxX[dup];
1138 float tempY_dup = merge_vtxY[dup];
1139 float tempZ_dup = merge_vtxZ[dup];
1140 float tempStgth = merge_vtxStgth[dup];
1144 bool duplicate_found =
false;
1156 duplicate_found =
true;
1164 if (!duplicate_found && tempX_dup > 0) {
1165 x_3dVertex_dupRemoved.push_back(tempX_dup);
1166 y_3dVertex_dupRemoved.push_back(tempY_dup);
1167 z_3dVertex_dupRemoved.push_back(tempZ_dup);
1168 strength_dupRemoved.push_back(tempStgth);
1178 double tempX, tempY, tempZ, tempS;
1182 for (
size_t npri = 0; (npri < x_3dVertex_dupRemoved.size()) && flag; npri++) {
1184 for (
size_t mpri = 0; mpri < x_3dVertex_dupRemoved.size() - 1; mpri++) {
1186 if (strength_dupRemoved[mpri + 1] > strength_dupRemoved[mpri] ||
1187 (strength_dupRemoved[mpri + 1] == strength_dupRemoved[mpri] &&
1188 z_3dVertex_dupRemoved[mpri] > z_3dVertex_dupRemoved[mpri + 1])) {
1189 tempX = x_3dVertex_dupRemoved[mpri];
1190 x_3dVertex_dupRemoved[mpri] = x_3dVertex_dupRemoved[mpri + 1];
1191 x_3dVertex_dupRemoved[mpri + 1] = tempX;
1193 tempY = y_3dVertex_dupRemoved[mpri];
1194 y_3dVertex_dupRemoved[mpri] = y_3dVertex_dupRemoved[mpri + 1];
1195 y_3dVertex_dupRemoved[mpri + 1] = tempY;
1197 tempZ = z_3dVertex_dupRemoved[mpri];
1198 z_3dVertex_dupRemoved[mpri] = z_3dVertex_dupRemoved[mpri + 1];
1199 z_3dVertex_dupRemoved[mpri + 1] = tempZ;
1201 tempS = strength_dupRemoved[mpri];
1202 strength_dupRemoved[mpri] = strength_dupRemoved[mpri + 1];
1203 strength_dupRemoved[mpri + 1] = tempS;
1213 for (
size_t count = 0;
count < x_3dVertex_dupRemoved.size();
count++) {
std::vector< double > Clu_Plane
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void MergeAndSort3dVtxCandidate(std::vector< double > merge_vtxX, std::vector< double > merge_vtxY, std::vector< double > merge_vtxZ, std::vector< double > merge_vtxStgth)
std::vector< double > TwoDvtx_wire
Encapsulate the construction of a single cyostat.
AdcChannelData::View View
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
unsigned int Nplanes() const
Number of planes in this tpc.
std::vector< double > TwoDvtx_time
std::vector< double > Clu_EndPos_Wire
std::vector< double > candidate_y
EDProducer(fhicl::ParameterSet const &pset)
void produce(art::Event &evt) override
std::vector< double > candidate_strength
std::vector< double > Clu_Length
bool ChannelsIntersect(raw::ChannelID_t c1, raw::ChannelID_t c2, double &y, double &z) const
Returns an intersection point of two channels.
std::vector< double > Clu_Yintercept
std::vector< double > Clu_EndPos_TimeTick
std::vector< double > MergeSort3dVtx_strength
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
std::vector< double > candidate_z
Definition of vertex object for LArSoft.
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
bool check(const std::vector< std::vector< float > > &outputs)
art framework interface to geometry description
std::vector< double > Clu_StartPos_TimeTick
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
std::vector< std::vector< int > > Cls
void Find3dVtxFrom2dClusterVtxCand(detinfo::DetectorPropertiesData const &detProp, std::vector< double > const &Wire_2dvtx, std::vector< double > const &Time_2dvtx, std::vector< double > const &Plane_2dvtx)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
#define DEFINE_ART_MODULE(klass)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void push_back(Ptr< U > const &p)
void Get3dVertexCandidates(detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::EndPoint2D >> EndPoints, bool PlaneDet)
std::vector< double > Clu_StartPos_Wire
std::vector< double > MergeSort3dVtx_zpos
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
std::string fClusterModuleLabel
unsigned int NTPC() const
Number of TPCs in this cryostat.
void Find2dClusterVertexCandidates(detinfo::DetectorPropertiesData const &detProp, art::PtrVector< recob::Cluster > RawClusters, art::FindManyP< recob::Hit > fmhit)
unsigned int NumberTimeSamples() const
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::string fCornerFinderModuleLabel
reference at(size_type n)
std::vector< double > dtdwstart
FeatureVertexFinder(fhicl::ParameterSet const &pset)
bool IntersectionPoint(geo::WireID const &wid1, geo::WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Detector simulation of raw signals on wires.
std::vector< double > MergeSort3dVtx_ypos
Q_EXPORT QTSManip setw(int w)
double ConvertTicksToX(double ticks, int p, int t, int c) const
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
std::vector< double > MergeSort3dVtx_xpos
Declaration of signal hit object.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
std::vector< double > Clu_Slope
std::vector< double > TwoDvtx_plane
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Provides recob::Track data product.
std::vector< double > dtdwstartError
std::vector< double > candidate_x
std::string fCCrawlerEndPoint2dModuleLabel
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
raw::ChannelID_t NearestChannel(geo::Point_t const &worldLoc, geo::PlaneID const &planeid) const
Returns the ID of the channel nearest to the specified position.
std::string fHitModuleLabel
Q_EXPORT QTSManip setfill(int f)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Encapsulate the construction of a single detector plane.
std::vector< double > Clu_Yintercept2