17 out_in_dfs_(conf.getParameter<
bool>(
"out_in_dfs")),
18 max_out_in_hops_(conf.getParameter<
int>(
"max_out_in_hops")),
19 min_cos_theta_(conf.getParameter<double>(
"min_cos_theta")),
20 min_cos_pointing_(conf.getParameter<double>(
"min_cos_pointing")),
21 missing_layers_(conf.getParameter<
int>(
"missing_layers")),
22 min_clusters_per_ntuplet_(conf.getParameter<
int>(
"min_clusters_per_ntuplet")),
23 max_delta_time_(conf.getParameter<double>(
"max_delta_time")),
24 eidInputName_(conf.getParameter<
std::
string>(
"eid_input_name")),
25 eidOutputNameEnergy_(conf.getParameter<
std::
string>(
"eid_output_name_energy")),
26 eidOutputNameId_(conf.getParameter<
std::
string>(
"eid_output_name_id")),
27 eidMinClusterEnergy_(conf.getParameter<double>(
"eid_min_cluster_energy")),
28 eidNLayers_(conf.getParameter<
int>(
"eid_n_layers")),
29 eidNClusters_(conf.getParameter<
int>(
"eid_n_clusters")),
33 if (trackstersCache ==
nullptr || trackstersCache->
eidGraphDef ==
nullptr) {
35 <<
"PatternRecognitionbyCA received an empty graph definition from the global cache";
43 std::vector<Trackster> &
result) {
49 LogDebug(
"HGCPatterRecoByCA") <<
"Making Tracksters with CA" << std::endl;
51 std::vector<HGCDoublet::HGCntuplet> foundNtuplets;
52 std::vector<int> seedIndices;
53 std::vector<uint8_t> layer_cluster_usage(input.
layerClusters.size(), 0);
73 for (
auto const &ntuplet : foundNtuplets) {
74 std::set<unsigned int> effective_cluster_idx;
75 for (
auto const &doublet : ntuplet) {
76 auto innerCluster =
doublets[doublet].innerClusterId();
77 auto outerCluster =
doublets[doublet].outerClusterId();
78 effective_cluster_idx.insert(innerCluster);
79 effective_cluster_idx.insert(outerCluster);
81 LogDebug(
"HGCPatterRecoByCA") <<
"New doublet " << doublet <<
" for trackster: " << result.size() <<
" InnerCl " 82 << innerCluster <<
" " << input.
layerClusters[innerCluster].x() <<
" " 84 << input.
layerClusters[innerCluster].z() <<
" OuterCl " << outerCluster <<
" " 87 << input.
layerClusters[outerCluster].z() <<
" " << tracksterId << std::endl;
90 for (
auto const i : effective_cluster_idx) {
91 layer_cluster_usage[
i]++;
92 LogDebug(
"HGCPatterRecoByCA") <<
"LayerID: " <<
i <<
" count: " << (
int)layer_cluster_usage[
i] << std::endl;
96 tmp.vertices.reserve(effective_cluster_idx.size());
97 tmp.vertex_multiplicity.resize(effective_cluster_idx.size(), 0);
100 tmp.seedID = input.
regions[0].collectionID;
101 tmp.seedIndex = seedIndices[tracksterId];
103 result.push_back(tmp);
107 for (
auto &trackster : result) {
108 assert(trackster.vertices.size() <= trackster.vertex_multiplicity.size());
109 for (
size_t i = 0;
i < trackster.vertices.size(); ++
i) {
110 trackster.vertex_multiplicity[
i] = layer_cluster_usage[trackster.vertices[
i]];
111 LogDebug(
"HGCPatterRecoByCA") <<
"LayerID: " << trackster.vertices[
i]
112 <<
" count: " << (
int)trackster.vertex_multiplicity[
i] << std::endl;
121 std::vector<Trackster> &tracksters) {
145 std::vector<int> tracksterIndices;
146 for (
int i = 0;
i < (
int)tracksters.size();
i++) {
148 tracksters[
i].regressed_energy = 0.;
149 for (
float &
p : tracksters[
i].id_probabilities) {
156 float sumClusterEnergy = 0.;
161 tracksterIndices.push_back(
i);
168 int batchSize = (
int)tracksterIndices.size();
169 if (batchSize == 0) {
175 tensorflow::Tensor
input(tensorflow::DT_FLOAT, shape);
178 std::vector<tensorflow::Tensor>
outputs;
188 for (
int i = 0;
i < batchSize;
i++) {
189 const Trackster &trackster = tracksters[tracksterIndices[
i]];
194 std::vector<int> clusterIndices(trackster.
vertices.size());
196 clusterIndices[
k] =
k;
198 sort(clusterIndices.begin(), clusterIndices.end(), [&layerClusters, &trackster](
const int &
a,
const int &
b) {
199 return layerClusters[trackster.
vertices[
a]].energy() > layerClusters[trackster.
vertices[
b]].energy();
206 for (
const int &
k : clusterIndices) {
212 float *
features = &input.tensor<
float, 4>()(
i, j, seenClusters[j], 0);
215 *(features++) =
float(cluster.
eta());
216 *(features++) =
float(cluster.
phi());
241 float *
energy = outputs[0].flat<
float>().
data();
243 for (
const int &
i : tracksterIndices) {
244 tracksters[
i].regressed_energy = *(energy++);
252 float *probs = outputs[probsIdx].flat<
float>().
data();
254 for (
const int &
i : tracksterIndices) {
255 for (
float &
p : tracksters[
i].id_probabilities) {
Session * createSession(SessionOptions &sessionOptions)
std::vector< NamedTensor > NamedTensorList
std::vector< unsigned int > vertices
const unsigned int max_out_in_hops_
const int min_clusters_per_ntuplet_
static const int eidNFeatures_
~PatternRecognitionbyCA() override
double eta() const
pseudorapidity of cluster centroid
static std::string const input
PatternRecognitionbyCA(const edm::ParameterSet &conf, const CacheBase *cache)
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
hgcal::RecHitTools rhtools_
void energyRegressionAndID(const std::vector< reco::CaloCluster > &layerClusters, std::vector< Trackster > &result)
void makeTracksters(const PatternRecognitionAlgoBase::Inputs &input, std::vector< Trackster > &result) override
const float min_cos_pointing_
const std::unique_ptr< HGCGraph > theGraph_
const float max_delta_time_
const std::string eidOutputNameId_
std::atomic< tensorflow::GraphDef * > eidGraphDef
double energy() const
cluster energy
const float eidMinClusterEnergy_
const float min_cos_theta_
const std::string eidInputName_
const std::string eidOutputNameEnergy_
char data[epos_bytes_allocation]
const int missing_layers_
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, const std::vector< std::string > &targetNodes, std::vector< Tensor > *outputs)
double phi() const
azimuthal angle of cluster centroid
tensorflow::Session * eidSession_