forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TICLv5 configuration and Skeletons linking (cms-sw#22)
* ticlv5: configure ticlv5 for validation * ticlv5: first skeletons implementation for trackster linking * replace cout with LogDebug in TICLGraph * make parameters configurable in Linking with skeletons * code-format * ticlv5: fixing hgcalvalidation in ticlv5 modifier --------- Co-authored-by: Wahid Redjeb <[email protected]>
- Loading branch information
Showing
11 changed files
with
773 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "TICLGraph.h" | ||
|
||
void Node::findSubComponents(std::vector<Node>& graph, std::vector<unsigned int>& subComponent, std::string tabs) { | ||
tabs += "\t"; | ||
if (!alreadyVisited_) { | ||
LogDebug("TICLGraph") << tabs << " Visiting node " << index_ << std::endl; | ||
alreadyVisited_ = true; | ||
subComponent.push_back(index_); | ||
for (auto const& neighbour : neighboursId_) { | ||
LogDebug("TICLGraph") << tabs << " Trying to visit " << neighbour << std::endl; | ||
graph[neighbour].findSubComponents(graph, subComponent, tabs); | ||
} | ||
} | ||
} | ||
|
||
std::vector<std::vector<unsigned int>> TICLGraph::findSubComponents() { | ||
std::vector<std::vector<unsigned int>> components; | ||
for (auto const& node : nodes_) { | ||
auto const id = node.getId(); | ||
if (isRootNode_[id]) { | ||
//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; | ||
} | ||
|
||
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); | ||
|
||
for (auto const& neighbourIndex : nodes_[nodeIndex].getNeighbours()) { | ||
if (visited.find(neighbourIndex) == visited.end()) { | ||
dfsForCC(neighbourIndex, visited, component); | ||
} | ||
} | ||
} | ||
|
||
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); | ||
} | ||
} | ||
return components; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#ifndef DataFormats_HGCalReco_TICLGraph_h | ||
#define DataFormats_HGCalReco_TICLGraph_h | ||
|
||
#include "DataFormats/HGCalReco/interface/Trackster.h" | ||
#include "DataFormats/TrackReco/interface/Track.h" | ||
#include <unordered_set> | ||
|
||
class Node { | ||
public: | ||
Node() = default; | ||
Node(unsigned index, bool isTrackster = true) : index_(index), isTrackster_(isTrackster), alreadyVisited_{false} {}; | ||
|
||
inline void addNeighbour(unsigned int trackster_id) { neighboursId_.push_back(trackster_id); } | ||
|
||
inline const unsigned int getId() const { return index_; } | ||
std::vector<unsigned int> getNeighbours() const { return neighboursId_; } | ||
void findSubComponents(std::vector<Node>& graph, std::vector<unsigned int>& subComponent, std::string tabs); | ||
|
||
~Node() = default; | ||
|
||
private: | ||
unsigned index_; | ||
bool isTrackster_; | ||
|
||
std::vector<unsigned int> neighboursId_; | ||
bool alreadyVisited_; | ||
|
||
//bool areCompatible(const std::vector<Node>& graph, const unsigned int& outerNode) { return true; }; | ||
}; | ||
|
||
class TICLGraph { | ||
public: | ||
// can i remove default constructor ?? edm::Wrapper problem | ||
// without default constructor i could initialize connectedComponents when building the Graph | ||
TICLGraph() = default; | ||
TICLGraph(std::vector<Node>& n, std::vector<int> isRootNode) { | ||
nodes_ = n; | ||
isRootNode_ = isRootNode; | ||
}; | ||
inline const std::vector<Node>& getNodes() const { return nodes_; } | ||
inline const Node& getNode(int i) const { return nodes_[i]; } | ||
|
||
std::vector<std::vector<unsigned int>> findSubComponents(); | ||
|
||
~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; | ||
|
||
private: | ||
std::vector<Node> nodes_; | ||
std::vector<int> isRootNode_; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// #include "TracksterLinkingbySkeletons.h" | ||
// #include "TracksterLinkingbySuperClustering.h" | ||
#include "FWCore/ParameterSet/interface/ValidatedPluginFactoryMacros.h" | ||
#include "FWCore/ParameterSet/interface/ValidatedPluginMacros.h" | ||
#include "TracksterLinkingbyFastJet.h" | ||
#include "TracksterLinkingbySkeletons.h" | ||
#include "RecoHGCal/TICL/plugins/TracksterLinkingPluginFactory.h" | ||
|
||
EDM_REGISTER_VALIDATED_PLUGINFACTORY(TracksterLinkingPluginFactory, "TracksterLinkingPluginFactory"); | ||
// DEFINE_EDM_VALIDATED_PLUGIN(TracksterLinkingPluginFactory, ticl::TracksterLinkingbySkeletons, "Skeletons"); | ||
DEFINE_EDM_VALIDATED_PLUGIN(TracksterLinkingPluginFactory, ticl::TracksterLinkingbySkeletons, "Skeletons"); | ||
// DEFINE_EDM_VALIDATED_PLUGIN(TracksterLinkingPluginFactory, ticl::TracksterLinkingbySuperClustering, "SuperClustering"); | ||
DEFINE_EDM_VALIDATED_PLUGIN(TracksterLinkingPluginFactory, ticl::TracksterLinkingbyFastJet, "FastJet"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,4 @@ void TracksterLinkingbyFastJet::linkTracksters( | |
linkedResultTracksters.push_back(linkedTracksters); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.