Skip to content

Commit

Permalink
TICLv5.1 : Improve skeleton linking and parameters tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
waredjeb committed Oct 29, 2024
1 parent bd0bb1c commit bdcc39c
Show file tree
Hide file tree
Showing 10 changed files with 547 additions and 227 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,53 @@
layer_clustersTime = cms.InputTag("hltHgcalMergeLayerClusters","timeLayerCluster"),
inferenceAlgo = cms.string('TracksterInferenceByDNN'),
linkingPSet = cms.PSet(
algo_verbosity = cms.int32(0),
cylinder_radius_sqr = cms.vdouble(9, 9),
dot_prod_th = cms.double(0.97),
max_distance_projective_sqr = cms.vdouble(60, 60),
max_distance_projective_sqr_closest_points = cms.vdouble(60, 60),
max_z_distance_closest_points = cms.vdouble(35, 35),
min_distance_z = cms.vdouble(30, 30),
min_num_lcs = cms.uint32(7),
min_trackster_energy = cms.double(10),
pca_quality_th = cms.double(0.85),
track_time_quality_threshold = cms.double(0.5),
type = cms.string('Skeletons'),
wind = cms.double(0.036)
cylinder_radius_sqr_split = cms.double(9),
proj_distance_split = cms.double(5),
track_time_quality_threshold = cms.double(0.5),
wind = cms.double(0.072),
min_num_lcs = cms.uint32(15),
min_trackster_energy = cms.double(20),
pca_quality_th = cms.double(0.85),
dot_prod_th = cms.double(0.97),
deltaRxy = cms.double(4),
lower_boundary = cms.vdouble(
20,
10
),
upper_boundary = cms.vdouble(
150,
100
),
upper_distance_projective_sqr = cms.vdouble(
30,
60
),
lower_distance_projective_sqr = cms.vdouble(
30,
30
),
min_distance_z = cms.vdouble(
35,
35
),
upper_distance_projective_sqr_closest_points = cms.vdouble(
10,
30
),
lower_distance_projective_sqr_closest_points = cms.vdouble(
10,
50
),
max_z_distance_closest_points = cms.vdouble(
35,
35
),
cylinder_radius_sqr = cms.vdouble(
9,
15
),
algo_verbosity = cms.int32(0),
type = cms.string('Skeletons')
),
pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet(
algo_verbosity = cms.int32(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,53 @@
layer_clustersTime = cms.InputTag("hltHgcalMergeLayerClusters","timeLayerCluster"),
inferenceAlgo = cms.string('TracksterInferenceByDNN'),
linkingPSet = cms.PSet(
algo_verbosity = cms.int32(0),
cylinder_radius_sqr = cms.vdouble(9, 9),
dot_prod_th = cms.double(0.97),
max_distance_projective_sqr = cms.vdouble(60, 60),
max_distance_projective_sqr_closest_points = cms.vdouble(60, 60),
max_z_distance_closest_points = cms.vdouble(35, 35),
min_distance_z = cms.vdouble(30, 30),
min_num_lcs = cms.uint32(7),
min_trackster_energy = cms.double(10),
pca_quality_th = cms.double(0.85),
track_time_quality_threshold = cms.double(0.5),
type = cms.string('Skeletons'),
wind = cms.double(0.036)
cylinder_radius_sqr_split = cms.double(9),
proj_distance_split = cms.double(5),
track_time_quality_threshold = cms.double(0.5),
wind = cms.double(0.072),
min_num_lcs = cms.uint32(15),
min_trackster_energy = cms.double(20),
pca_quality_th = cms.double(0.85),
dot_prod_th = cms.double(0.97),
deltaRxy = cms.double(4),
lower_boundary = cms.vdouble(
20,
10
),
upper_boundary = cms.vdouble(
150,
100
),
upper_distance_projective_sqr = cms.vdouble(
30,
60
),
lower_distance_projective_sqr = cms.vdouble(
30,
30
),
min_distance_z = cms.vdouble(
35,
35
),
upper_distance_projective_sqr_closest_points = cms.vdouble(
10,
30
),
lower_distance_projective_sqr_closest_points = cms.vdouble(
10,
50
),
max_z_distance_closest_points = cms.vdouble(
35,
35
),
cylinder_radius_sqr = cms.vdouble(
9,
15
),
algo_verbosity = cms.int32(0),
type = cms.string('Skeletons')
),
pluginInferenceAlgoTracksterInferenceByDNN = cms.PSet(
algo_verbosity = cms.int32(0),
Expand Down
18 changes: 14 additions & 4 deletions RecoHGCal/TICL/plugins/TICLDumper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -595,10 +595,10 @@ class TICLDumper : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::Sh
const edm::EDGetTokenT<std::vector<reco::Muon>> muons_token_;
const edm::EDGetTokenT<edm::ValueMap<std::pair<float, float>>> clustersTime_token_;
const edm::EDGetTokenT<std::vector<int>> tracksterSeeds_token_;
const edm::EDGetTokenT<std::vector<std::vector<unsigned int>>> superclustering_linkedResultTracksters_token;
const edm::EDGetTokenT<reco::SuperClusterCollection> recoSuperClusters_token;
const edm::EDGetTokenT<reco::CaloClusterCollection> recoSuperClusters_caloClusters_token;
const edm::EDGetTokenT<std::vector<ticl::Trackster>> recoSuperClusters_sourceTracksters_token;
edm::EDGetTokenT<std::vector<std::vector<unsigned int>>> superclustering_linkedResultTracksters_token;
edm::EDGetTokenT<reco::SuperClusterCollection> recoSuperClusters_token;
edm::EDGetTokenT<reco::CaloClusterCollection> recoSuperClusters_caloClusters_token;
edm::EDGetTokenT<std::vector<ticl::Trackster>> recoSuperClusters_sourceTracksters_token;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometry_token_;
const edm::EDGetTokenT<std::vector<ticl::Trackster>> simTracksters_SC_token_; // needed for simticlcandidate
const edm::EDGetTokenT<std::vector<TICLCandidate>> simTICLCandidate_token_;
Expand Down Expand Up @@ -884,6 +884,16 @@ TICLDumper::TICLDumper(const edm::ParameterSet& ps)
saveTICLCandidate_(ps.getParameter<bool>("saveSimTICLCandidate")),
saveSimTICLCandidate_(ps.getParameter<bool>("saveSimTICLCandidate")),
saveTracks_(ps.getParameter<bool>("saveTracks")) {
if (saveSuperclustering_) {
superclustering_linkedResultTracksters_token =
consumes<std::vector<std::vector<unsigned int>>>(ps.getParameter<edm::InputTag>("superclustering"));
recoSuperClusters_token =
consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("recoSuperClusters"));
recoSuperClusters_caloClusters_token =
consumes<reco::CaloClusterCollection>(ps.getParameter<edm::InputTag>("recoSuperClusters"));
recoSuperClusters_sourceTracksters_token = consumes<std::vector<ticl::Trackster>>(
ps.getParameter<edm::InputTag>("recoSuperClusters_sourceTracksterCollection"));
}
std::string detectorName_ = (detector_ == "HFNose") ? "HGCalHFNoseSensitive" : "HGCalEESensitive";
hdc_token_ =
esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(edm::ESInputTag("", detectorName_));
Expand Down
57 changes: 39 additions & 18 deletions RecoHGCal/TICL/plugins/TICLGraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ namespace ticl {
}
} // namespace ticl

TICLGraph::TICLGraph(std::vector<ticl::Node>& nodes) {
nodes_ = nodes;
rootNodes_.reserve(nodes_.size());
findRootNodes();
rootNodes_.shrink_to_fit();
}

std::vector<std::vector<unsigned int>> TICLGraph::findSubComponents() {
std::vector<std::vector<unsigned int>> components;
for (auto const& node : nodes_) {
Expand All @@ -29,32 +36,46 @@ std::vector<std::vector<unsigned int>> TICLGraph::findSubComponents() {
components.push_back(tmpSubComponents);
}
}
// Second loop: DFS for non-root nodes that haven't been visited
for (auto const& node : nodes_) {
auto const id = node.getId();
if (!node.alreadyVisited()) { // Use the alreadyVisited() method
// Node not visited yet, so perform DFS
std::string tabs = "\t";
std::vector<unsigned int> tmpSubComponents;
nodes_[id].findSubComponents(nodes_, tmpSubComponents, tabs);
components.push_back(tmpSubComponents);
}
}
return components;
}

void TICLGraph::dfsForCC(unsigned int nodeIndex,
std::unordered_set<unsigned int>& visited,
std::vector<unsigned int>& component) const {
visited.insert(nodeIndex);
component.push_back(nodeIndex);
std::vector<std::vector<unsigned int>> TICLGraph::findSubComponents(std::vector<ticl::Node>& rootNodes) {
std::vector<std::vector<unsigned int>> components;
for (auto const& node : rootNodes) {
auto const id = node.getId();
//LogDebug("TICLGraph") << "DFS Starting From " << id << std::endl;
std::string tabs = "\t";
std::vector<unsigned int> tmpSubComponents;
nodes_[id].findSubComponents(nodes_, tmpSubComponents, tabs);
components.push_back(tmpSubComponents);
}
return components;
}

for (auto const& neighbourIndex : nodes_[nodeIndex].getOuterNeighbours()) {
if (visited.find(neighbourIndex) == visited.end()) {
dfsForCC(neighbourIndex, visited, component);
inline void TICLGraph::findRootNodes() {
for (auto const& n : nodes_) {
if (n.getInnerNeighbours().size() == 0) {
rootNodes_.push_back(n);
}
}
}

std::vector<std::vector<unsigned int>> TICLGraph::getConnectedComponents() const {
std::unordered_set<unsigned int> visited;
std::vector<std::vector<unsigned int>> components;

for (unsigned int i = 0; i < nodes_.size(); ++i) {
if (visited.find(i) == visited.end()) {
std::vector<unsigned int> component;
dfsForCC(i, visited, component);
components.push_back(component);
bool TICLGraph::isGraphOk() {
for (auto n : nodes_) {
if (n.getInnerNeighbours().size() > 1) {
return false;
}
}
return components;
return true;
}
17 changes: 8 additions & 9 deletions RecoHGCal/TICL/plugins/TICLGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ namespace ticl {
auto findInner = std::find(innerNeighboursId_.begin(), innerNeighboursId_.end(), tid);
return findInner != innerNeighboursId_.end();
}
inline bool alreadyVisited() const { return alreadyVisited_; }

~Node() = default;

private:
unsigned index_;
unsigned int index_;
bool isTrackster_;

std::vector<unsigned int> outerNeighboursId_;
Expand All @@ -44,25 +45,23 @@ class TICLGraph {
// can i remove default constructor ?? edm::Wrapper problem
// without default constructor i could initialize connectedComponents when building the Graph
TICLGraph() = default;
TICLGraph(std::vector<ticl::Node>& n, std::vector<int> isRootNode) {
nodes_ = n;
isRootNode_ = isRootNode;
};
TICLGraph(std::vector<ticl::Node>& nodes);
inline const std::vector<ticl::Node>& getNodes() const { return nodes_; }
inline const ticl::Node& getNode(int i) const { return nodes_[i]; }
inline std::vector<ticl::Node> getRootNodes() const { return rootNodes_; }
inline void findRootNodes();

std::vector<std::vector<unsigned int>> findSubComponents();
std::vector<std::vector<unsigned int>> findSubComponents(std::vector<ticl::Node>& rootNodes);

~TICLGraph() = default;

void dfsForCC(unsigned int nodeIndex,
std::unordered_set<unsigned int>& visited,
std::vector<unsigned int>& component) const;

std::vector<std::vector<unsigned int>> getConnectedComponents() const;
bool isGraphOk();

private:
std::vector<ticl::Node> nodes_;
std::vector<ticl::Node> rootNodes_;
std::vector<int> isRootNode_;
};

Expand Down
Loading

0 comments on commit bdcc39c

Please sign in to comment.