Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TICL Reorganization, reloaded. #27160

Merged
merged 17 commits into from Jun 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions DataFormats/HGCalReco/BuildFile.xml
@@ -0,0 +1,6 @@
<use name="DataFormats/Math"/>

<export>
<lib name="1"/>
</export>

23 changes: 23 additions & 0 deletions DataFormats/HGCalReco/interface/Common.h
@@ -0,0 +1,23 @@
#ifndef DataFormats_HGCalReco_Common_h
#define DataFormats_HGCalReco_Common_h

#include <vector>
#include <array>
#include <cstdint>

namespace ticl::constants {
constexpr float minEta = 1.5f;
constexpr float maxEta = 3.2f;
constexpr int nEtaBins = 34;
constexpr int nPhiBins = 126;
constexpr int nLayers = 104;
} // namespace ticl::constants

class TICLLayerTile;
namespace ticl {
typedef std::vector<std::pair<unsigned int, float> > HgcalClusterFilterMask;
typedef std::array<std::vector<unsigned int>, constants::nEtaBins * constants::nPhiBins> Tile;
typedef std::array<TICLLayerTile, ticl::constants::nLayers> Tiles;
} // namespace ticl

#endif // DataFormats_HGCalReco_Common_h
64 changes: 64 additions & 0 deletions DataFormats/HGCalReco/interface/TICLLayerTile.h
@@ -0,0 +1,64 @@
// Authors: Marco Rovere, Felice Pantaleo - marco.rovere@cern.ch, felice.pantaleo@cern.ch
// Date: 05/2019

#ifndef DataFormats_HGCalReco_TICLLayerTile_h
#define DataFormats_HGCalReco_TICLLayerTile_h

#include "DataFormats/HGCalReco/interface/Common.h"
#include "DataFormats/Math/interface/normalizedPhi.h"

class TICLLayerTile {
public:
void fill(double eta, double phi, unsigned int layerClusterId) {
tile_[globalBin(eta, phi)].push_back(layerClusterId);
}

int etaBin(float eta) const {
constexpr float etaRange = ticl::constants::maxEta - ticl::constants::minEta;
static_assert(etaRange >= 0.f);
float r = ticl::constants::nEtaBins / etaRange;
int etaBin = (std::abs(eta) - ticl::constants::minEta) * r;
etaBin = std::clamp(etaBin, 0, ticl::constants::nEtaBins);
return etaBin;
}

int phiBin(float phi) const {
auto normPhi = normalizedPhi(phi);
float r = ticl::constants::nPhiBins * M_1_PI * 0.5f;
int phiBin = (normPhi + M_PI) * r;

return phiBin;
}

int globalBin(int etaBin, int phiBin) const { return phiBin + etaBin * ticl::constants::nPhiBins; }

int globalBin(double eta, double phi) const { return phiBin(phi) + etaBin(eta) * ticl::constants::nPhiBins; }

void clear() {
auto nBins = ticl::constants::nEtaBins * ticl::constants::nPhiBins;
for (int j = 0; j < nBins; ++j)
tile_[j].clear();
}

const std::vector<unsigned int>& operator[](int globalBinId) const { return tile_[globalBinId]; }

private:
ticl::Tile tile_;
};

class TICLLayerTiles {
public:
// This class represents a collection of Tiles, one for each layer in
// HGCAL. The layer numbering should account for both sides of HGCAL and is
// not handled internally. It is the user's responsibility to properly
// number the layers and consistently access them here.
const TICLLayerTile& operator[](int layer) const { return tiles_[layer]; }
void fill(int layer, double eta, double phi, unsigned int layerClusterId) {
tiles_[layer].fill(eta, phi, layerClusterId);
}

private:
ticl::Tiles tiles_;
};

#endif
29 changes: 29 additions & 0 deletions DataFormats/HGCalReco/interface/Trackster.h
@@ -0,0 +1,29 @@
// Author: Felice Pantaleo - felice.pantaleo@cern.ch
// Date: 09/2018

#ifndef DataFormats_HGCalReco_Trackster_h
#define DataFormats_HGCalReco_Trackster_h

#include <array>
#include <vector>

// A Trackster is a Direct Acyclic Graph created when
// pattern recognition algorithms connect hits or
// layer clusters together in a 3D object.

namespace ticl {
struct Trackster {
// The vertices of the DAG are the indices of the
// 2d objects in the global collection
std::vector<unsigned int> vertices;
std::vector<uint8_t> vertex_multiplicity;

// The edges connect two vertices together in a directed doublet
// ATTENTION: order matters!
// A doublet generator should create edges in which:
// the first element is on the inner layer and
// the outer element is on the outer layer.
std::vector<std::array<unsigned int, 2> > edges;
};
} // namespace ticl
#endif
5 changes: 5 additions & 0 deletions DataFormats/HGCalReco/src/classes.h
@@ -0,0 +1,5 @@
#include <vector>
#include <array>
#include "DataFormats/HGCalReco/interface/Trackster.h"
#include "DataFormats/HGCalReco/interface/TICLLayerTile.h"
#include "DataFormats/Common/interface/Wrapper.h"
17 changes: 17 additions & 0 deletions DataFormats/HGCalReco/src/classes_def.xml
@@ -0,0 +1,17 @@

<lcgdict>
<class name="ticl::Trackster" ClassVersion="3">
<version ClassVersion="3" checksum="3878166595"/>
</class>
<class name="std::vector<ticl::Trackster>" />
<class name="edm::Wrapper<ticl::Trackster>" />
<class name="edm::Wrapper<std::vector<ticl::Trackster> >" />

<class name="TICLLayerTile" persistent="false">
<field name="tile_" transient="true"/>
</class>
<class name="TICLLayerTiles" persistent="false">
<field name="tiles_" transient="true"/>
</class>
<class name="edm::Wrapper<TICLLayerTiles> " />
</lcgdict>
6 changes: 0 additions & 6 deletions RecoHGCal/TICL/BuildFile.xml

This file was deleted.

16 changes: 0 additions & 16 deletions RecoHGCal/TICL/interface/Common.h

This file was deleted.

33 changes: 18 additions & 15 deletions RecoHGCal/TICL/interface/PatternRecognitionAlgoBase.h
Expand Up @@ -7,31 +7,34 @@
#include <memory>
#include <vector>
#include "DataFormats/CaloRecHit/interface/CaloCluster.h"
#include "DataFormats/HGCalReco/interface/Common.h"
#include "DataFormats/HGCalReco/interface/Trackster.h"
#include "DataFormats/HGCalReco/interface/TICLLayerTile.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "RecoHGCal/TICL/interface/Common.h"
#include "RecoHGCal/TICL/interface/Trackster.h"

namespace edm {
class Event;
class EventSetup;
class Event;
class EventSetup;
} // namespace edm

namespace ticl {
class PatternRecognitionAlgoBase {
public:
PatternRecognitionAlgoBase(const edm::ParameterSet& conf)
public:
PatternRecognitionAlgoBase(const edm::ParameterSet& conf)
: algo_verbosity_(conf.getParameter<int>("algo_verbosity")) {}
virtual ~PatternRecognitionAlgoBase(){};
virtual ~PatternRecognitionAlgoBase(){};

virtual void makeTracksters(const edm::Event& ev, const edm::EventSetup& es,
const std::vector<reco::CaloCluster>& layerClusters,
const HgcalClusterFilterMask& mask,
std::vector<Trackster>& result) = 0;
enum VerbosityLevel { None = 0, Basic, Advanced, Expert, Guru };
virtual void makeTracksters(const edm::Event& ev,
const edm::EventSetup& es,
const std::vector<reco::CaloCluster>& layerClusters,
const std::vector<float>& mask,
const TICLLayerTiles& tiles,
std::vector<Trackster>& result) = 0;
enum VerbosityLevel { None = 0, Basic, Advanced, Expert, Guru };

protected:
int algo_verbosity_;
protected:
int algo_verbosity_;
};
}
} // namespace ticl

#endif
28 changes: 0 additions & 28 deletions RecoHGCal/TICL/interface/Trackster.h

This file was deleted.

2 changes: 1 addition & 1 deletion RecoHGCal/TICL/plugins/BuildFile.xml
Expand Up @@ -6,11 +6,11 @@
<use name="FWCore/PluginManager"/>
<use name="DataFormats/HGCDigi"/>
<use name="DataFormats/HGCRecHit"/>
<use name="DataFormats/HGCalReco"/>
<use name="CondFormats/DataRecord"/>
<use name="FWCore/MessageLogger"/>
<use name="FWCore/MessageService"/>
<use name="Geometry/HGCalGeometry"/>
<use name="RecoHGCal/TICL"/>

<library file="*.cc" name="RecoHGCalTICLPlugins">
<flags EDM_PLUGIN="1"/>
Expand Down
20 changes: 10 additions & 10 deletions RecoHGCal/TICL/plugins/ClusterFilterBase.h
Expand Up @@ -4,28 +4,28 @@
#ifndef RecoHGCal_TICL_ClusterFilterBase_H__
#define RecoHGCal_TICL_ClusterFilterBase_H__

#include "RecoHGCal/TICL/interface/Common.h"
#include "DataFormats/HGCalReco/interface/Common.h"

#include <memory>
#include <vector>

namespace edm {
class ParameterSet;
class ParameterSet;
}
namespace reco {
class CaloCluster;
class CaloCluster;
}

namespace ticl {
class ClusterFilterBase {
public:
explicit ClusterFilterBase(const edm::ParameterSet&){};
virtual ~ClusterFilterBase(){};
public:
explicit ClusterFilterBase(const edm::ParameterSet&){};
virtual ~ClusterFilterBase(){};

virtual std::unique_ptr<HgcalClusterFilterMask> filter(
const std::vector<reco::CaloCluster>& layerClusters,
const HgcalClusterFilterMask& mask) const = 0;
virtual std::unique_ptr<HgcalClusterFilterMask> filter(const std::vector<reco::CaloCluster>& layerClusters,
const HgcalClusterFilterMask& mask,
std::vector<float>& layerClustersMask) const = 0;
};
}
} // namespace ticl

#endif
38 changes: 21 additions & 17 deletions RecoHGCal/TICL/plugins/ClusterFilterByAlgo.h
Expand Up @@ -12,25 +12,29 @@

// Filter clusters that belong to a specific algorithm
namespace ticl {
class ClusterFilterByAlgo final : public ClusterFilterBase {
public:
ClusterFilterByAlgo(const edm::ParameterSet& ps)
: ClusterFilterBase(ps), algo_number_(ps.getParameter<int>("algo_number")) {}
~ClusterFilterByAlgo() override {};
class ClusterFilterByAlgo final : public ClusterFilterBase {
public:
ClusterFilterByAlgo(const edm::ParameterSet& ps)
: ClusterFilterBase(ps), algo_number_(ps.getParameter<int>("algo_number")) {}
~ClusterFilterByAlgo() override{};

std::unique_ptr<HgcalClusterFilterMask> filter(
const std::vector<reco::CaloCluster>& layerClusters,
const HgcalClusterFilterMask& availableLayerClusters) const override {
auto filteredLayerClusters = std::make_unique<HgcalClusterFilterMask>();
for (auto const& cl : availableLayerClusters) {
if (layerClusters[cl.first].algo() == algo_number_) filteredLayerClusters->emplace_back(cl);
std::unique_ptr<HgcalClusterFilterMask> filter(const std::vector<reco::CaloCluster>& layerClusters,
const HgcalClusterFilterMask& availableLayerClusters,
std::vector<float>& layerClustersMask) const override {
auto filteredLayerClusters = std::make_unique<HgcalClusterFilterMask>();
for (auto const& cl : availableLayerClusters) {
if (layerClusters[cl.first].algo() == algo_number_) {
filteredLayerClusters->emplace_back(cl);
} else {
layerClustersMask[cl.first] = 0.;
}
}
return filteredLayerClusters;
}
return filteredLayerClusters;
}

private:
int algo_number_;
};
}
private:
int algo_number_;
};
} // namespace ticl

#endif