101 std::vector<double>
const& Wire_2dvtx,
102 std::vector<double>
const& Time_2dvtx,
103 std::vector<double>
const& Plane_2dvtx);
109 std::vector<double>
const& merge_vtxY,
110 std::vector<double>
const& merge_vtxZ,
111 std::vector<double>
const& merge_vtxStgth);
134 std::vector<std::vector<int>>
Cls;
167 produces<std::vector<recob::Vertex>>();
168 produces<std::vector<recob::EndPoint2D>>();
169 produces<art::Assns<recob::EndPoint2D, recob::Hit>>();
173 produces<art::Assns<recob::Vertex, recob::Hit>>();
174 produces<art::Assns<recob::Vertex, recob::Shower>>();
175 produces<art::Assns<recob::Vertex, recob::Track>>();
191 for (
auto const& tpcid : geom->Iterate<
geo::TPCID>()) {
192 if (wireReadoutGeom.Nplanes(tpcid) > 2) {
194 std::cout <<
"yeah" << std::endl;
200 auto vcol = std::make_unique<std::vector<recob::Vertex>>();
201 auto epcol = std::make_unique<std::vector<recob::EndPoint2D>>();
202 auto assnep = std::make_unique<art::Assns<recob::EndPoint2D, recob::Hit>>();
203 auto assnsh = std::make_unique<art::Assns<recob::Vertex, recob::Shower>>();
204 auto assntr = std::make_unique<art::Assns<recob::Vertex, recob::Track>>();
205 auto assnh = std::make_unique<art::Assns<recob::Vertex, recob::Hit>>();
214 std::vector<art::Ptr<recob::EndPoint2D>> ccrawlerEndPoints;
221 mf::LogWarning(
"FeatureVertexFinder") <<
"Failed to get EndPoint2d's from Cluster Crawler";
230 std::vector<art::Ptr<recob::EndPoint2D>> cornerEndPoints;
237 mf::LogWarning(
"FeatureVertexFinder") <<
"Failed to get EndPoint2d's from Corner Finder";
252 for (
unsigned int ii = 0; ii < clusterListHandle->size(); ++ii) {
264 mf::LogWarning(
"FeatureVertexFinder") <<
"Failed to get Cluster from default cluster module";
285 double tempxyz[3] = {
290 if (tempxyz[0] == 0 && tempxyz[1] == 0 && tempxyz[2] == 0) {
continue; }
292 vcol->push_back(the3Dvertex);
298 for (
auto const& plane : wireReadoutGeom.Iterate<
geo::PlaneGeo>()) {
299 auto const& planeID = plane.
ID();
305 if (temp2dXYZ.X() == 0 && temp2dXYZ.Y() == 0 && temp2dXYZ.Z() == 0) {
continue; }
308 double EndPoint2d_TimeTick = detProp.ConvertXToTicks(temp2dXYZ.X(), planeID);
309 int EndPoint2d_Wire = 0;
310 int EndPoint2d_Channel = 0;
314 EndPoint2d_Wire = plane.NearestWireID(temp2dXYZ).Wire;
322 EndPoint2d_Channel = wireReadoutGeom.NearestChannel(temp2dXYZ, planeID);
330 geo::View_t View = wireReadoutGeom.View(EndPoint2d_Channel);
334 epcol->emplace_back(EndPoint2d_TimeTick,
356 double tempxyz[3] = {
360 if (bail > 0) {
continue; }
361 if (tempxyz[0] == 0 && tempxyz[1] == 0 && tempxyz[2] == 0) {
continue; }
364 vcol->emplace_back(tempxyz, vcol->size());
372 for (
auto const& plane : wireReadoutGeom.Iterate<
geo::PlaneGeo>()) {
373 auto const& planeID = plane.ID();
380 double EndPoint2d_TimeTick = detProp.ConvertXToTicks(temp2dXYZ.X(), planeID);
381 int EndPoint2d_Wire = 0;
382 int EndPoint2d_Channel = 0;
385 EndPoint2d_Wire = plane.NearestWireID(temp2dXYZ).Wire;
393 EndPoint2d_Channel = wireReadoutGeom.NearestChannel(temp2dXYZ, planeID);
401 geo::View_t View = wireReadoutGeom.View(EndPoint2d_Channel);
405 epcol->emplace_back(EndPoint2d_TimeTick,
415 mf::LogVerbatim(
"Summary") << std::setfill(
'-') << std::setw(175) <<
"-" << std::setfill(
' ');
417 for (
size_t i = 0; i < epcol->size(); ++i)
419 for (
size_t i = 0; i < vcol->size(); ++i)
422 evt.
put(std::move(epcol));
423 evt.
put(std::move(vcol));
424 evt.
put(std::move(assnep));
425 evt.
put(std::move(assntr));
426 evt.
put(std::move(assnsh));
427 evt.
put(std::move(assnh));
468 auto const numEndPoints =
size(EndPoints);
469 for (
auto const& tpcid : geom->Iterate<
geo::TPCID>()) {
470 for (
size_t iendpt1 = 0; iendpt1 < numEndPoints; ++iendpt1) {
471 for (
size_t iendpt2 = iendpt1 + 1; iendpt2 < numEndPoints; ++iendpt2) {
473 auto const& endpt1 = *EndPoints[iendpt1];
474 auto const& endpt2 = *EndPoints[iendpt2];
480 if (endpt1_planeid.Plane == endpt2_planeid.Plane)
continue;
483 float tempXFeature1 = detProp.
ConvertTicksToX(endpt1.DriftTime(), endpt1_planeid);
484 float tempXFeature2 = detProp.
ConvertTicksToX(endpt2.DriftTime(), endpt2_planeid);
487 if (
std::abs(tempXFeature1 - tempXFeature2) >= 0.5)
continue;
494 wireReadoutGeom.ChannelsIntersect(wireReadoutGeom.PlaneWireToChannel(endpt1_wireid),
495 wireReadoutGeom.PlaneWireToChannel(endpt2_wireid));
496 if (!intersection)
continue;
511 for (
size_t iendpt3 = iendpt2 + 1; iendpt3 < numEndPoints; ++iendpt3) {
512 auto const& endpt3 = *EndPoints[iendpt3];
519 if (endpt3_planeid.Plane == endpt2_planeid.Plane ||
520 endpt3_planeid.Plane == endpt1_planeid.Plane)
525 float const tempXFeature3 = detProp.
ConvertTicksToX(endpt3.DriftTime(), endpt3_wireid);
527 if (
std::abs(tempXFeature3 - tempXFeature2) >= 1.0 ||
528 std::abs(tempXFeature3 - tempXFeature1) >= 1.0) {
533 if (!wireReadoutGeom.ChannelsIntersect(
534 wireReadoutGeom.PlaneWireToChannel(endpt3_wireid),
535 wireReadoutGeom.PlaneWireToChannel(endpt1_wireid)) ||
536 !wireReadoutGeom.ChannelsIntersect(
537 wireReadoutGeom.PlaneWireToChannel(endpt3_wireid),
538 wireReadoutGeom.PlaneWireToChannel(endpt2_wireid))) {
542 detProp.
ConvertTicksToX(endpt1.DriftTime(), endpt1_wireid.asPlaneID()));
546 wireReadoutGeom.WireIDsIntersect(endpt1_wireid, endpt2_wireid).value();
549 candidate_strength.push_back(endpt1.Strength() + endpt2.Strength() + endpt3.Strength());
554 if (iendpt1 < numEndPoints) { ++iendpt1; }
555 if (iendpt2 < numEndPoints) { ++iendpt2; }
556 if (iendpt3 < numEndPoints) { ++iendpt3; }
574 int nClustersFound = 0;
580 for (
size_t iclu = 0; iclu < RawClusters.
size(); ++iclu) {
582 std::vector<art::Ptr<recob::Hit>>
hit = fmhit.at(iclu);
586 if (hit.size() < 15) {
continue; }
591 if (view >= Cls.size()) {
592 std::cerr << __PRETTY_FUNCTION__ <<
"\033[93m Logic error in my code ... view " << view
593 <<
" not supported ! \033[00m" << std::endl;
597 Cls.at(RawClusters.
at(iclu)->View()).push_back(iclu);
601 std::vector<double> wires;
602 std::vector<double> times;
609 for (
size_t i = 0; i < hit.size(); ++i) {
610 wires.push_back(hit[i]->
WireID().Wire);
611 times.push_back(hit[i]->PeakTime());
622 TGraph* the2Dtrack =
new TGraph(n, &wires[0], ×[0]);
625 the2Dtrack->Fit(
"pol1",
"Q");
626 TF1* pol1 = (TF1*)the2Dtrack->GetFunction(
"pol1");
629 pol1->GetParameters(par);
630 parerror[1] = pol1->GetParError(1);
631 double FitChi2 = pol1->GetChisquare();
632 double FitNDF = pol1->GetNDF();
634 double fitGoodness = FitChi2 / FitNDF;
637 if (fitGoodness > 10) {
638 dtdwstart.push_back(std::tan(RawClusters[iclu]->StartAngle()));
651 <<
"Fitter failed, using the clusters default dTdW()";
653 dtdwstart.push_back(std::tan(RawClusters[iclu]->StartAngle()));
664 dtdwstart.push_back(std::tan(RawClusters[iclu]->StartAngle()));
673 for (
auto const& tpcid : geom->Iterate<
geo::TPCID>()) {
674 for (
unsigned int i = 0; i < wireReadoutGeom.Nplanes(tpcid); ++i) {
678 if (Cls[i].
size() >= 1) {
682 for (
unsigned int j = 0; j < Cls[i].size(); ++j) {
684 Clu_Plane.push_back(RawClusters.
at(Cls.at(i).at(j))->View());
693 Clu_Length.push_back(std::sqrt(pow((RawClusters.
at(Cls.at(i).at(j))->StartWire() -
694 RawClusters.
at(Cls.at(i).at(j))->EndWire()) *
697 pow(RawClusters.
at(Cls.at(i).at(j))->StartTick() -
698 RawClusters.
at(Cls.at(i).at(j))->EndTick(),
705 RawClusters.
at(Cls.at(i).at(j))->StartTick() -
706 (
dtdwstart[Cls[i][j]] * RawClusters.
at(Cls.at(i).at(j))->StartWire()));
713 RawClusters.
at(Cls.at(i).at(j))->EndTick() -
714 (
dtdwstart[Cls[i][j]] * RawClusters.
at(Cls.at(i).at(j))->EndWire()));
737 for (
unsigned int n = nClustersFound;
n > 0;
n--) {
742 for (
unsigned int m = 0; m <
n; m++) {
751 float intersection_X =
758 float intersection_X2 =
766 if (intersection_X2 < 1) { intersection_X2 = -999; }
767 if (intersection_X2 > wireReadoutGeom.Nwires(planeid)) { intersection_X2 = -999; }
768 if (intersection_Y2 < 0) { intersection_Y2 = -999; }
770 if (intersection_X < 1) { intersection_X = -999; }
771 if (intersection_X > wireReadoutGeom.Nwires(planeid)) { intersection_X = -999; }
772 if (intersection_Y < 0) { intersection_Y = -999; }
779 std::vector<art::Ptr<recob::Hit>> hitClu1 = fmhit.at(m);
780 std::vector<art::Ptr<recob::Hit>> hitClu2 = fmhit.at(n);
787 intersection_X2 = -999;
788 intersection_Y2 = -999;
793 intersection_X = -999;
794 intersection_Y = -999;
803 intersection_X2 = -999;
804 intersection_Y2 = -999;
809 intersection_X = -999;
810 intersection_Y = -999;
814 mf::LogWarning(
"FeatureVertexFinder") <<
"FindManyHit Function faild";
815 intersection_X = -999;
816 intersection_Y = -999;
817 intersection_X2 = -999;
818 intersection_Y2 = -999;
825 if (intersection_X2 > 1 && intersection_Y2 > 0 &&
826 (intersection_X2 < wireReadoutGeom.Nwires(planeid)) &&
837 if (intersection_X > 1 && intersection_Y > 0 &&
838 (intersection_X < wireReadoutGeom.Nwires(planeid)) &&
856 std::vector<double>
const& Wire_2dvtx,
857 std::vector<double>
const& Time_2dvtx,
858 std::vector<double>
const& Plane_2dvtx)
860 std::vector<double> vtx_wire_merged;
861 std::vector<double> vtx_time_merged;
862 std::vector<double> vtx_plane_merged;
872 for (
size_t vtxloop1 = 0; vtxloop1 < Wire_2dvtx.size(); vtxloop1++) {
873 if (Wire_2dvtx[vtxloop1] < 0) {
continue; }
879 for (
size_t vtxloop2 = vtxloop1 + 1; vtxloop2 < Wire_2dvtx.size(); vtxloop2++) {
880 if (Wire_2dvtx[vtxloop2] < 0) {
continue; }
883 if (Plane_2dvtx[vtxloop1] == Plane_2dvtx[vtxloop2]) {
886 if (fabs(Wire_2dvtx[vtxloop1] - Wire_2dvtx[vtxloop2]) < 4) {
889 if (fabs(Time_2dvtx[vtxloop1] - Time_2dvtx[vtxloop2]) < 10) {
890 vtx_wire_merged.push_back(((Wire_2dvtx[vtxloop2] + Wire_2dvtx[vtxloop1]) / 2));
891 vtx_time_merged.push_back(((Time_2dvtx[vtxloop2] + Time_2dvtx[vtxloop1]) / 2));
892 vtx_plane_merged.push_back(Plane_2dvtx[vtxloop1]);
895 if (vtxloop2 < Wire_2dvtx.size()) { vtxloop2++; }
896 if (vtxloop1 < Wire_2dvtx.size()) { vtxloop1++; }
902 vtx_wire_merged.push_back(Wire_2dvtx[vtxloop1]);
903 vtx_time_merged.push_back(Time_2dvtx[vtxloop1]);
904 vtx_plane_merged.push_back(Plane_2dvtx[vtxloop1]);
910 uint32_t vtx1_channel = 0;
911 uint32_t vtx2_channel = 0;
916 for (
auto const& tpcid : geom->Iterate<
geo::TPCID>()) {
917 for (
unsigned int vtx = vtx_wire_merged.size(); vtx > 0; --vtx) {
918 for (
unsigned int vtx1 = 0; vtx1 < vtx; ++vtx1) {
921 if (vtx_plane_merged[vtx1] == vtx_plane_merged[vtx])
continue;
926 geo::PlaneID const vtx1_planeid(tpcid, vtx_plane_merged[vtx1]);
927 geo::WireID const vtx1_wireid(vtx1_planeid, vtx_wire_merged[vtx1]);
929 vtx1_channel = wireReadoutGeom.PlaneWireToChannel(vtx1_wireid);
932 mf::LogWarning(
"FeatureVertexFinder") <<
"PlaneWireToChannel Failed";
936 geo::PlaneID const vtx2_planeid(tpcid, vtx_plane_merged[vtx]);
937 geo::WireID const vtx2_wireid(vtx2_planeid, vtx_wire_merged[vtx]);
939 vtx2_channel = wireReadoutGeom.PlaneWireToChannel(vtx2_wireid);
942 mf::LogWarning(
"FeatureVertexFinder") <<
"PlaneWireToChannel Failed";
947 auto intersection = wireReadoutGeom.ChannelsIntersect(vtx1_channel, vtx2_channel);
949 mf::LogWarning(
"FeatureVertexFinder") <<
"match failed for some reason";
954 float tempXCluster1 = detProp.
ConvertTicksToX(vtx_time_merged[vtx1], vtx1_planeid);
955 float tempXCluster2 = detProp.
ConvertTicksToX(vtx_time_merged[vtx], vtx2_planeid);
980 std::vector<double>
const& merge_vtxX,
981 std::vector<double>
const& merge_vtxY,
982 std::vector<double>
const& merge_vtxZ,
983 std::vector<double>
const& merge_vtxStgth)
985 std::vector<double> x_3dVertex_dupRemoved = {0.};
986 std::vector<double> y_3dVertex_dupRemoved = {0.};
987 std::vector<double> z_3dVertex_dupRemoved = {0.};
988 std::vector<double> strength_dupRemoved = {0.};
991 for (
size_t dup = 0; dup < merge_vtxX.size(); dup++) {
993 float tempX_dup = merge_vtxX[dup];
994 float tempY_dup = merge_vtxY[dup];
995 float tempZ_dup = merge_vtxZ[dup];
996 float tempStgth = merge_vtxStgth[dup];
998 bool duplicate_found =
false;
1001 for (
size_t check = dup + 1; check < merge_vtxX.size(); check++) {
1005 if (
std::abs(merge_vtxX[check] - tempX_dup) < 0.1 &&
1006 std::abs(merge_vtxY[check] - tempY_dup) < 0.1 &&
1007 std::abs(merge_vtxZ[check] - tempZ_dup) < 0.1) {
1008 duplicate_found =
true;
1015 if (!duplicate_found && tempX_dup > 0) {
1016 x_3dVertex_dupRemoved.push_back(tempX_dup);
1017 y_3dVertex_dupRemoved.push_back(tempY_dup);
1018 z_3dVertex_dupRemoved.push_back(tempZ_dup);
1019 strength_dupRemoved.push_back(tempStgth);
1028 double tempX, tempY, tempZ, tempS;
1031 for (
size_t npri = 0; (npri < x_3dVertex_dupRemoved.size()) && flag; npri++) {
1033 for (
size_t mpri = 0; mpri < x_3dVertex_dupRemoved.size() - 1; mpri++) {
1035 if (strength_dupRemoved[mpri + 1] > strength_dupRemoved[mpri] ||
1036 (strength_dupRemoved[mpri + 1] == strength_dupRemoved[mpri] &&
1037 z_3dVertex_dupRemoved[mpri] > z_3dVertex_dupRemoved[mpri + 1])) {
1038 tempX = x_3dVertex_dupRemoved[mpri];
1039 x_3dVertex_dupRemoved[mpri] = x_3dVertex_dupRemoved[mpri + 1];
1040 x_3dVertex_dupRemoved[mpri + 1] = tempX;
1042 tempY = y_3dVertex_dupRemoved[mpri];
1043 y_3dVertex_dupRemoved[mpri] = y_3dVertex_dupRemoved[mpri + 1];
1044 y_3dVertex_dupRemoved[mpri + 1] = tempY;
1046 tempZ = z_3dVertex_dupRemoved[mpri];
1047 z_3dVertex_dupRemoved[mpri] = z_3dVertex_dupRemoved[mpri + 1];
1048 z_3dVertex_dupRemoved[mpri + 1] = tempZ;
1050 tempS = strength_dupRemoved[mpri];
1051 strength_dupRemoved[mpri] = strength_dupRemoved[mpri + 1];
1052 strength_dupRemoved[mpri + 1] = tempS;
1061 for (
size_t count = 0; count < x_3dVertex_dupRemoved.size(); count++) {
std::vector< double > Clu_Plane
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::vector< double > TwoDvtx_wire
Encapsulate the construction of a single cyostat .
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::vector< double > TwoDvtx_time
Declaration of signal hit object.
std::vector< double > Clu_EndPos_Wire
std::vector< double > candidate_y
EDProducer(fhicl::ParameterSet const &pset)
The data type to uniquely identify a Plane.
void produce(art::Event &evt) override
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::vector< double > candidate_strength
std::vector< double > Clu_Length
std::vector< double > Clu_Yintercept
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
void MergeAndSort3dVtxCandidate(std::vector< double > const &merge_vtxX, std::vector< double > const &merge_vtxY, std::vector< double > const &merge_vtxZ, std::vector< double > const &merge_vtxStgth)
std::vector< double > Clu_EndPos_TimeTick
std::vector< double > MergeSort3dVtx_strength
std::vector< double > candidate_z
Definition of vertex object for LArSoft.
std::vector< double > Clu_StartPos_TimeTick
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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)
#define DEFINE_ART_MODULE(klass)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void push_back(Ptr< U > const &p)
std::vector< double > Clu_StartPos_Wire
std::vector< double > MergeSort3dVtx_zpos
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
std::string fClusterModuleLabel
void Find2dClusterVertexCandidates(detinfo::DetectorPropertiesData const &detProp, art::PtrVector< recob::Cluster > RawClusters, art::FindManyP< recob::Hit > fmhit)
unsigned int NumberTimeSamples() const
std::string fCornerFinderModuleLabel
reference at(size_type n)
std::vector< double > dtdwstart
FeatureVertexFinder(fhicl::ParameterSet const &pset)
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
Declaration of cluster object.
Detector simulation of raw signals on wires.
std::vector< double > MergeSort3dVtx_ypos
double ConvertTicksToX(double ticks, int p, int t, int c) const
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
std::vector< double > MergeSort3dVtx_xpos
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Provides recob::Track data product.
std::vector< double > Clu_Slope
std::vector< double > TwoDvtx_plane
int ID() const
Return vertex id.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< double > dtdwstartError
constexpr WireID()=default
Default constructor: an invalid TPC ID.
std::vector< double > candidate_x
std::string fCCrawlerEndPoint2dModuleLabel
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::string fHitModuleLabel
void Get3dVertexCandidates(detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::EndPoint2D >> const &EndPoints, bool PlaneDet)
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
Encapsulate the construction of a single detector plane .
std::vector< double > Clu_Yintercept2