Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
d20fce8
warm up porting
lastgeorge Oct 28, 2025
a457e9e
continue validation
lastgeorge Oct 28, 2025
eb3190d
continue validation
lastgeorge Oct 28, 2025
c7021b2
continue validation
lastgeorge Oct 28, 2025
8211d9b
continue validation
lastgeorge Oct 28, 2025
2ced978
fix a bug in the Box Recombination Model
lastgeorge Oct 28, 2025
277fd15
fix a bug in the Box Recombination Model
lastgeorge Oct 28, 2025
122ad0b
fix a bug
lastgeorge Oct 28, 2025
6a446b4
catch up
lastgeorge Oct 28, 2025
26db774
update logic
lastgeorge Oct 28, 2025
9653eaf
update code
lastgeorge Oct 28, 2025
089a471
implement algorithm for the break_segment_at_point
lastgeorge Oct 28, 2025
16da43d
continue validation
lastgeorge Oct 29, 2025
cf5d832
catch up
lastgeorge Oct 29, 2025
0e32d88
add validation to multi-track fitting
lastgeorge Nov 4, 2025
a75fd20
fix a bug
lastgeorge Nov 4, 2025
ad02e81
catch up
lastgeorge Nov 5, 2025
fca0f7c
continue dbug
lastgeorge Nov 6, 2025
49421f1
fix another bug
lastgeorge Nov 6, 2025
1e430e0
fix bug validation
lastgeorge Nov 6, 2025
7b37aab
add a function
lastgeorge Nov 27, 2025
8bb4783
add a function of check_direction
lastgeorge Nov 27, 2025
8d485e5
implement check_connectivity function
lastgeorge Nov 27, 2025
7444f5a
implement the connect_graph_overclustering_projection as connect_grap…
lastgeorge Nov 27, 2025
d999e6a
implement the new graph
lastgeorge Nov 27, 2025
3397df4
prepare files for Pattern Recognition
lastgeorge Nov 29, 2025
4a37136
add a function
lastgeorge Nov 29, 2025
b531f0a
implement some functions
lastgeorge Nov 29, 2025
87aea6e
put in a template
lastgeorge Nov 30, 2025
df694df
catch up
lastgeorge Nov 30, 2025
dea665a
implement init_first_segment
lastgeorge Nov 30, 2025
c0b0091
check the code
lastgeorge Nov 30, 2025
70d4033
catch code
lastgeorge Nov 30, 2025
6ddfa36
add proto_extend_point
lastgeorge Nov 30, 2025
19ff94b
implement function proto_break_tracks
lastgeorge Dec 1, 2025
ae3556f
implement the replace_segment_and_vertex function
lastgeorge Dec 1, 2025
ab4fcba
break_segment_into_two
lastgeorge Dec 1, 2025
a0572c3
implement break_segments function
lastgeorge Dec 1, 2025
8573112
update code
lastgeorge Dec 1, 2025
067122e
merge two segments into one
lastgeorge Dec 1, 2025
1b71a1e
add merge vertices
lastgeorge Dec 1, 2025
7ceced7
implement two examine_structure functions
lastgeorge Dec 5, 2025
a806d4b
add examine_structure_4
lastgeorge Dec 5, 2025
a07e55b
implement the find_other_segments
lastgeorge Dec 5, 2025
f59f3e9
implement the find_other_segments
lastgeorge Dec 5, 2025
3807877
clean up
lastgeorge Dec 6, 2025
3fa9812
catch up
lastgeorge Dec 6, 2025
c26940d
implement crawl_segment
lastgeorge Dec 7, 2025
911e339
add examine_segment
lastgeorge Dec 7, 2025
367cb73
implement the examine_vertices_1p
lastgeorge Dec 7, 2025
1ee2b3b
implement examine_Vertices_1
lastgeorge Dec 7, 2025
a1f3781
implement examine_vertices_2
lastgeorge Dec 7, 2025
883b9a9
implement examine_vertices_4
lastgeorge Dec 7, 2025
5305889
implement examine_vertices
lastgeorge Dec 7, 2025
d82f180
implement the examine partial identical segments
lastgeorge Dec 7, 2025
28fc7db
get_local_extension
lastgeorge Dec 7, 2025
c5cabfd
implement the examine_vertices_3 function
lastgeorge Dec 8, 2025
88c95a7
implement find_proto_vertex
lastgeorge Dec 8, 2025
7c17ed8
implement the init_point_segment
lastgeorge Dec 8, 2025
c58c0f7
implement the first function of examine_structure_final_1
lastgeorge Dec 16, 2025
ffd4f50
implement the examine_structure_final functions
lastgeorge Dec 16, 2025
e8ea63a
improve implementations
lastgeorge Dec 16, 2025
d5b4ada
implement the search_for_vertex_activities
lastgeorge Dec 17, 2025
d0f1673
catch up
lastgeorge Dec 17, 2025
9498c3b
catch up
lastgeorge Dec 17, 2025
32b80f3
add the local to global indices mapping
lastgeorge Dec 17, 2025
5bbb93d
update code
lastgeorge Dec 17, 2025
12142ef
add a function to transfer information from segment to cluster
lastgeorge Dec 17, 2025
7e91ac6
add sufficient code for transfer information from segment to cluster
lastgeorge Dec 17, 2025
f59a2da
implement determine_direction
lastgeorge Dec 18, 2025
b4a159a
implement examine_good_tracks
lastgeorge Dec 18, 2025
6901400
implement examine_good_tracks
lastgeorge Dec 18, 2025
e443a5d
implement another improve maps function
lastgeorge Dec 18, 2025
c1d02a0
implement the examine_maps function
lastgeorge Dec 18, 2025
717489f
implement the examine_all_showers
lastgeorge Dec 18, 2025
b928b5c
implement EM shower related
lastgeorge Dec 19, 2025
e8e3ea3
implement more functions
lastgeorge Jan 2, 2026
5275d78
implement find_cont_muon_segment function
lastgeorge Jan 2, 2026
e22c0c4
implement the examine_direction
lastgeorge Jan 2, 2026
85b0c8d
implement the eliminate_short_vertex_activities
lastgeorge Jan 2, 2026
368986c
update MyFCN
lastgeorge Jan 2, 2026
057db7c
fully implement MyFCN
lastgeorge Jan 2, 2026
6b66163
implement the fit_vertex function
lastgeorge Jan 2, 2026
38be7a0
implement the improve_vertex function
lastgeorge Jan 2, 2026
06bf9f5
implement the determine_main_vertex function
lastgeorge Jan 2, 2026
d0bf918
implement the examine_main_vertices
lastgeorge Jan 3, 2026
a69dd91
implement moer functions
lastgeorge Jan 3, 2026
e089ca5
update code
lastgeorge Jan 3, 2026
f131e01
add more functions
lastgeorge Jan 4, 2026
d5ee192
add more functions
lastgeorge Jan 4, 2026
f505bb8
continue working on the PRShower
lastgeorge Jan 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion aux/src/ClusterHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ std::map<std::string, size_t> Aux::count(const cluster_graph_t& cgraph, bool nod
}




std::unordered_map<int, std::set<cluster_vertex_t> > Aux::blob_clusters(
const cluster_graph_t& cg)
{
Expand Down Expand Up @@ -368,4 +370,4 @@ std::unordered_map<int, std::set<cluster_vertex_t> > Aux::blob_clusters(
}

return groups;
}
}
11 changes: 11 additions & 0 deletions cfg/pgrapher/common/clus.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ local wc = import "wirecell.jsonnet";
} + dv_cfg + pcts_cfg
},

tagger_check_neutrino(name="", trackfitting_config_file="", particle_dataset="", recombination_model="") :: {
type: "TaggerCheckNeutrino",
name: prefix + name,
data: {
grouping: "live", // Which grouping to process
trackfitting_config_file: trackfitting_config_file,
particle_dataset: particle_dataset,
recombination_model: recombination_model,
} + dv_cfg + pcts_cfg
},

pointed(name="", groupings=["live"]) :: {
type: "ClusteringPointed",
name: prefix+name,
Expand Down
24 changes: 24 additions & 0 deletions clus/inc/WireCellClus/Facade_Cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,30 @@ namespace WireCell::Clus::Facade {
double charge_cut = 4000.0,
bool disable_dead_mix_cell = true) const;

/// Get segment IDs for all points (computed from graph analysis)
/// @return Vector of segment IDs, -1 for unassigned points
std::vector<int> segment_ids() const;

/// Get shower flags for all points (computed from graph analysis)
/// @return Vector of flags, 1=shower, 0=track
std::vector<int> shower_flags() const;

/// Get segment ID for a specific point
/// @param point_index Global point index in cluster
/// @return Segment ID or -1 if unassigned
int segment_id(size_t point_index) const;

/// Get shower flag for a specific point
/// @param point_index Global point index in cluster
/// @return 1 if shower, 0 if track
int shower_flag(size_t point_index) const;

/// Invalidate cached segment data (IDs and shower flags)
/// Call this before re-computing segment information
void invalidate_segment_data() {
cache().invalidate_segment_data();
}



// Return vector is size 3 holding vectors of size npoints providing k-d tree coordinate points.
Expand Down
12 changes: 12 additions & 0 deletions clus/inc/WireCellClus/Facade_ClusterCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,23 @@ namespace WireCell::Clus::Facade {
// Set of point indices excluded during graph operations (equivalent to prototype's excluded_points)
std::set<size_t> excluded_points;

// Segment IDs by point index (computed from graph analysis)
std::vector<int> point_segment_ids;

// Shower flags by point index (computed from graph analysis)
std::vector<int> point_shower_flags;

// Steiner point cloud k-d tree cache
mutable std::unique_ptr<KDTree::MultiQuery> steiner_kd;
mutable decltype(std::declval<KDTree::MultiQuery>().get<double>(std::vector<std::string>{})) steiner_query3d;
mutable std::string cached_steiner_pc_name;
mutable bool steiner_kd_built{false};

// Invalidate segment-related cached data
void invalidate_segment_data() {
point_segment_ids.clear();
point_shower_flags.clear();
}
};

}
Expand Down
3 changes: 3 additions & 0 deletions clus/inc/WireCellClus/Facade_Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ namespace WireCell::Clus::Facade {
results_type get_closest_index(const geo_point_t& p, const size_t N) const;
/// @return index, geo_point_t
std::pair<size_t, geo_point_t> get_closest_wcpoint(const geo_point_t& p) const;
double get_closest_dis(const geo_point_t& p) const;

std::vector<std::pair<size_t, geo_point_t>> get_closest_wcpoints_radius(const geo_point_t& p, const double radius) const;

/// @param p_test1 is the point to start from
/// @param dir is the direction to search along
Expand Down
112 changes: 112 additions & 0 deletions clus/inc/WireCellClus/MyFCN.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#ifndef WIRECELLCLUS_MYFCN_H
#define WIRECELLCLUS_MYFCN_H

#include "WireCellClus/PRGraph.h"
#include "WireCellClus/Facade_Cluster.h"
#include "WireCellUtil/Units.h"
#include "WireCellClus/TrackFitting.h"


#include <vector>
#include <tuple>

namespace WireCell::Clus::PR {

/// MyFCN: Vertex fitting class for pattern recognition
/// Performs vertex position fitting by minimizing distances from segments
class MyFCN {
public:
/// Constructor
/// @param vtx The vertex to fit
/// @param flag_vtx_constraint Whether to constrain the vertex position
/// @param vtx_constraint_range Range for vertex constraint
/// @param vertex_protect_dis Protection distance for vertex
/// @param vertex_protect_dis_short_track Protection distance for short tracks
/// @param fit_dis Fitting distance
MyFCN(VertexPtr vtx,
bool flag_vtx_constraint = false,
double vtx_constraint_range = 1*units::cm,
double vertex_protect_dis = 1.5*units::cm,
double vertex_protect_dis_short_track = 0.9*units::cm,
double fit_dis = 6*units::cm);

~MyFCN();

/// Update the fitting range parameters
void update_fit_range(double tmp_vertex_protect_dis = 1.5*units::cm,
double tmp_vertex_protect_dis_short_track = 0.9*units::cm,
double tmp_fit_dis = 6*units::cm);

/// Add a segment to the fitting
void AddSegment(SegmentPtr sg);

/// Fit the vertex position
/// @return pair of (success flag, fitted position)
std::pair<bool, Facade::geo_point_t> FitVertex();

/// Update information after fitting
/// @param fit_pos The fitted position
/// @param temp_cluster The cluster being processed
/// @param default_dis_cut Default distance cut
void UpdateInfo(Facade::geo_point_t fit_pos,
Facade::Cluster& temp_cluster,
TrackFitting& track_fitter, IDetectorVolumes::pointer dv,
double default_dis_cut = 4.0*units::cm);

/// Get segment information at index i
/// @return pair of (segment pointer, index)
std::pair<SegmentPtr, int> get_seg_info(int i);

/// Get number of fittable tracks
int get_fittable_tracks();

/// Get vertex constraint flag
bool get_flag_vtx_constraint() { return flag_vtx_constraint; }

/// Set vertex constraint flag
void set_flag_vtx_constraint(bool val) { flag_vtx_constraint = val; }

/// Set vertex constraint range
void set_vtx_constraint_range(double val) { vtx_constraint_range = val; }

/// Get the vector of segments
std::vector<SegmentPtr>& get_segments() { return segments; }

/// Get the vector of point vectors
std::vector<std::vector<Facade::geo_point_t>>& get_vec_points() { return vec_points; }

/// Print points for debugging
void print_points();

/// Set enforce two track fit flag
void set_enforce_two_track_fit(bool val) { enforce_two_track_fit = val; }

/// Get enforce two track fit flag
bool get_enforce_two_track_fit() { return enforce_two_track_fit; }

private:
VertexPtr vtx;
bool enforce_two_track_fit;
bool flag_vtx_constraint;
double vtx_constraint_range;

double vertex_protect_dis;
double vertex_protect_dis_short_track;
double fit_dis;

std::vector<SegmentPtr> segments;
std::vector<std::vector<Facade::geo_point_t>> vec_points;

// PCA directions: tuple of (dir1, dir2, dir3)
std::vector<std::tuple<Facade::geo_point_t, Facade::geo_point_t, Facade::geo_point_t>> vec_PCA_dirs;

// PCA eigenvalues: tuple of (val1, val2, val3)
std::vector<std::tuple<double, double, double>> vec_PCA_vals;

// Centers for each segment
std::vector<Facade::geo_point_t> vec_centers;
};

} // namespace WireCell::Clus::PR

#endif // WIRECELLCLUS_MYFCN_H
Empty file.
Empty file.
Empty file.
Empty file.
Loading