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

[HGCal] TICL v3 major upgrade #31906

Merged
merged 66 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
89b12fb
Created a ClusterFilter by Algo, Size and Layer Range
felicepantaleo Sep 29, 2020
f39f3a9
include an Electromagnetic TrackSeeded iteration as first iteration
felicepantaleo Sep 30, 2020
2e437da
Add the range of layers to the filter parameters
felicepantaleo Sep 30, 2020
eceff27
Inject tracksters from the track seeded electromagnetic interation in…
felicepantaleo Sep 30, 2020
d53fa4c
create empty multiclusters
felicepantaleo Oct 2, 2020
a394f3e
Add TrkEM tracksters into the Merge collection
rovere Oct 5, 2020
1082657
Select trackster-PID also on EM/Total trackster energy ratio
rovere Oct 5, 2020
0101b45
Fix merge conflict.
rovere Oct 5, 2020
b039481
Fix input collection for TRK iteration to be the output of EM iteration
felicepantaleo Oct 7, 2020
23b0397
Sorting seeding regions by track momentum
felicepantaleo Oct 7, 2020
d69212b
Use only clusters with minimum size of 3
felicepantaleo Oct 7, 2020
cb843b5
Filter only with a maxLayerId in TRKEM iteration.
felicepantaleo Oct 7, 2020
8790b01
Remove MIP iteration
felicepantaleo Oct 7, 2020
41636a6
clang format
felicepantaleo Oct 7, 2020
9eb885d
Limit Global EM iteration to layer 30
felicepantaleo Oct 8, 2020
dbbaaae
Limit track seeded iterations to tracks with at most 2 missing outer …
felicepantaleo Oct 8, 2020
b576c9e
Add TrkEM products to EventContent
felicepantaleo Oct 8, 2020
72725e3
Remove missing layers cut for EM based iterations
felicepantaleo Oct 8, 2020
918c3a4
Introducing a shower_start_max_layer cut
felicepantaleo Oct 8, 2020
1524925
raising shower_start_max_layer from 3 to 7 in EM iterations
felicepantaleo Oct 9, 2020
cdb0e6a
Count usage of layer clusters, only for those tracksters passing the …
felicepantaleo Oct 9, 2020
936c100
Protect from empty multiclusters
felicepantaleo Oct 7, 2020
56d168a
Increasing missing outer hits from 3 to 5
felicepantaleo Oct 12, 2020
9f62bea
increase missing layer from 0 to 1 and loosen min_cos_theta to 0.961 …
felicepantaleo Oct 12, 2020
d6af9c3
tighten min_cos_theta from 0.961 to 0.978 in EM iterations
felicepantaleo Oct 12, 2020
0b56bd3
Rename parameter missing_layers to skip_layers.
felicepantaleo Oct 13, 2020
7d80a78
Retuning of PR cuts in EM iterations
felicepantaleo Oct 13, 2020
42413cc
Introducing two cuts: a max_missing_layers_in_trackster and a minimum…
felicepantaleo Oct 13, 2020
b93c8ad
Refactoring
felicepantaleo Oct 13, 2020
1251839
Update cuts
rovere Oct 13, 2020
4c54e8b
Make max_missing_layers_in_trackster cut inclusive
felicepantaleo Oct 13, 2020
97b951b
code format
felicepantaleo Oct 13, 2020
01a0f3e
Move trackster energy calculation after the selections are applied
felicepantaleo Oct 13, 2020
86ecf55
Add a new max_longitudinal_sigmaPCA cut for EM iterations, with an in…
felicepantaleo Oct 13, 2020
f497df5
Add a new cut: root_doublet_max_distance_from_seed for TrkEM iteratio…
felicepantaleo Oct 13, 2020
6d28404
clang format
felicepantaleo Oct 13, 2020
9638aa7
fix trackster to seed association
felicepantaleo Oct 14, 2020
4317f3f
Setting max_missing_layers_in_trackster to 2 from 0 in EM iterations
felicepantaleo Oct 14, 2020
5bdb770
Fix compilation error in C++
rovere Oct 14, 2020
57b342c
Remove duplicate python parameter
rovere Oct 14, 2020
efbafb6
Sorting seeding regions by pT rather than p
felicepantaleo Oct 16, 2020
8d6e738
Added TICL PF interpretation.
felicepantaleo Oct 16, 2020
20adab6
Feed PFTICL the correct InputTag
felicepantaleo Oct 19, 2020
6c32c60
Adapt event content
felicepantaleo Oct 19, 2020
d3a76b3
Address review comments
felicepantaleo Oct 23, 2020
f2dda06
remove unused import
felicepantaleo Oct 23, 2020
882ff98
Fix Validation for empty tracksters
felicepantaleo Oct 27, 2020
202b865
modify comment to reflect code
felicepantaleo Oct 28, 2020
5289d77
replace parameter root_doublet_max_distance_from_seed with its square
felicepantaleo Oct 28, 2020
ec4a82b
Optimization
felicepantaleo Oct 28, 2020
d771885
remove unused parameter
felicepantaleo Oct 28, 2020
69128ff
remove commented out code
felicepantaleo Oct 28, 2020
0d4b6f0
optimization
felicepantaleo Oct 28, 2020
a61f591
code format
felicepantaleo Oct 28, 2020
b4a8cec
code format
felicepantaleo Oct 28, 2020
2147081
code format
felicepantaleo Oct 28, 2020
1c730e1
optimization
felicepantaleo Oct 30, 2020
520d3ad
Simplify energy assignment
felicepantaleo Oct 30, 2020
5dcb727
Provide EcalEnergy and HcalEnergy to JetMET for calibration
felicepantaleo Oct 30, 2020
c432855
code format
felicepantaleo Oct 30, 2020
8a48807
assign track momentum direction at point of closest approach instead …
felicepantaleo Nov 1, 2020
abc84da
avoid copy
felicepantaleo Nov 1, 2020
2443c12
Add missing const.
felicepantaleo Nov 2, 2020
a4029c0
Make track cuts configurable
felicepantaleo Nov 2, 2020
bbbacf1
code format
felicepantaleo Nov 2, 2020
92c59aa
fix configurable parameter
felicepantaleo Nov 3, 2020
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
8 changes: 8 additions & 0 deletions DataFormats/HGCalReco/interface/TICLLayerTile.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ class TICLLayerTileT {
return phiBin;
}

std::array<int, 4> searchBoxEtaPhi(float etaMin, float etaMax, float phiMin, float phiMax) const {
int etaBinMin = etaBin(etaMin);
int etaBinMax = etaBin(etaMax);
int phiBinMin = phiBin(phiMin);
int phiBinMax = phiBin(phiMax);
return std::array<int, 4>({{etaBinMin, etaBinMax, phiBinMin, phiBinMax}});
}

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

int globalBin(double eta, double phi) const { return phiBin(phi) + etaBin(eta) * T::nPhiBins; }
Expand Down
4 changes: 2 additions & 2 deletions RecoHGCal/Configuration/python/RecoHGCal_EventContent_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'keep *_ticlMultiClustersFromTrackstersEM_*_*',
'keep *_ticlMultiClustersFromTrackstersHAD_*_*',
'keep *_ticlMultiClustersFromTrackstersTrk_*_*',
'keep *_ticlMultiClustersFromTrackstersTrkEM_*_*',
'keep *_ticlMultiClustersFromTrackstersMIP_*_*',
'keep *_ticlMultiClustersFromTrackstersMerge_*_*',
)
Expand All @@ -15,16 +16,15 @@
#RECO content
TICL_RECO = cms.PSet(
outputCommands = cms.untracked.vstring(
'keep *_ticlTrackstersTrkEM_*_*',
'keep *_ticlTrackstersEM_*_*',
'keep *_ticlTrackstersHAD_*_*',
'keep *_ticlTrackstersTrk_*_*',
'keep *_ticlTrackstersMIP_*_*',
'keep *_ticlTrackstersMerge_*_*',
'keep *_ticlCandidateFromTracksters_*_*',
'keep *_ticlTrackstersHFNoseEM_*_*',
'keep *_ticlTrackstersHFNoseMIP_*_*',
'keep *_ticlTrackstersHFNoseMerge_*_*',
'keep *_ticlCandidateFromTrackstersHFNose_*_*',
'keep *_pfTICL_*_*'
)
)
Expand Down
55 changes: 55 additions & 0 deletions RecoHGCal/TICL/plugins/ClusterFilterByAlgoAndSizeAndLayerRange.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Authors: Marco Rovere - [email protected], Felice Pantaleo - [email protected]
// Date: 09/2020

#ifndef RecoHGCal_TICL_ClusterFilterByAlgoAndSizeAndLayerRange_H__
#define RecoHGCal_TICL_ClusterFilterByAlgoAndSizeAndLayerRange_H__

#include "DataFormats/CaloRecHit/interface/CaloCluster.h"
#include "ClusterFilterBase.h"

#include <memory>
#include <utility>

// Filter clusters that belong to a specific algorithm
namespace ticl {
class ClusterFilterByAlgoAndSizeAndLayerRange final : public ClusterFilterBase {
public:
ClusterFilterByAlgoAndSizeAndLayerRange(const edm::ParameterSet& ps)
: ClusterFilterBase(ps),
algo_number_(ps.getParameter<int>("algo_number")),
min_cluster_size_(ps.getParameter<int>("min_cluster_size")),
max_cluster_size_(ps.getParameter<int>("max_cluster_size")),
min_layerId_(ps.getParameter<int>("min_layerId")),
max_layerId_(ps.getParameter<int>("max_layerId")) {}
~ClusterFilterByAlgoAndSizeAndLayerRange() override{};

void filter(const std::vector<reco::CaloCluster>& layerClusters,
const HgcalClusterFilterMask& availableLayerClusters,
std::vector<float>& layerClustersMask,
hgcal::RecHitTools& rhtools) const override {
auto filteredLayerClusters = std::make_unique<HgcalClusterFilterMask>();
for (auto const& cl : availableLayerClusters) {
auto const& layerCluster = layerClusters[cl.first];
auto const& haf = layerCluster.hitsAndFractions();
auto layerId = rhtools.getLayerWithOffset(haf[0].first);

if (layerCluster.algo() == algo_number_ and layerId <= max_layerId_ and layerId >= min_layerId_ and
haf.size() <= max_cluster_size_ and
(haf.size() >= min_cluster_size_ or !(rhtools.isSilicon(haf[0].first)))) {
filteredLayerClusters->emplace_back(cl);
} else {
layerClustersMask[cl.first] = 0.;
}
}
}

private:
int algo_number_;
unsigned int min_cluster_size_;
unsigned int max_cluster_size_;
unsigned int min_layerId_;
unsigned int max_layerId_;
};
} // namespace ticl

#endif
2 changes: 2 additions & 0 deletions RecoHGCal/TICL/plugins/FilteredLayerClustersProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ void FilteredLayerClustersProducer::fillDescriptions(edm::ConfigurationDescripti
desc.add<int>("algo_number", 9);
desc.add<int>("min_cluster_size", 0);
desc.add<int>("max_cluster_size", 9999);
desc.add<int>("min_layerId", 0);
desc.add<int>("max_layerId", 9999);
descriptions.add("filteredLayerClustersProducer", desc);
}

Expand Down
34 changes: 25 additions & 9 deletions RecoHGCal/TICL/plugins/HGCGraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ void HGCGraphT<TILES>::makeAndConnectDoublets(const TILES &histo,
int deltaIPhi,
float minCosTheta,
float minCosPointing,
float root_doublet_max_distance_from_seed_squared,
float etaLimitIncreaseWindow,
int missing_layers,
int skip_layers,
int maxNumberOfLayers,
float maxDeltaTime) {
isOuterClusterOfDoublets_.clear();
isOuterClusterOfDoublets_.resize(layerClusters.size());
allDoublets_.clear();
theRootDoublets_.clear();
bool checkDistanceRootDoubletVsSeed = root_doublet_max_distance_from_seed_squared < 9999;
float origin_eta;
float origin_phi;
for (const auto &r : regions) {
bool isGlobal = (r.index == -1);
auto zSide = r.zSide;
Expand All @@ -37,19 +41,22 @@ void HGCGraphT<TILES>::makeAndConnectDoublets(const TILES &histo,
startPhiBin = 0;
endEtaBin = nEtaBins;
endPhiBin = nPhiBins;
origin_eta = 0;
origin_phi = 0;
} else {
auto firstLayerOnZSide = maxNumberOfLayers * zSide;
const auto &firstLayerHisto = histo[firstLayerOnZSide];

int entryEtaBin = firstLayerHisto.etaBin(r.origin.eta());
int entryPhiBin = firstLayerHisto.phiBin(r.origin.phi());
origin_eta = r.origin.eta();
origin_phi = r.origin.phi();
int entryEtaBin = firstLayerHisto.etaBin(origin_eta);
int entryPhiBin = firstLayerHisto.phiBin(origin_phi);
// For track-seeded iterations, if the impact point is below a certain
// eta-threshold, i.e., it has higher eta, make the initial search
// window bigger in both eta and phi by one bin, to contain better low
// energy showers.
auto etaWindow = deltaIEta;
auto phiWindow = deltaIPhi;
if (std::abs(r.origin.eta()) > etaLimitIncreaseWindow) {
if (std::abs(origin_eta) > etaLimitIncreaseWindow) {
etaWindow++;
phiWindow++;
LogDebug("HGCGraph") << "Limit of Eta for increase: " << etaLimitIncreaseWindow
Expand All @@ -60,9 +67,9 @@ void HGCGraphT<TILES>::makeAndConnectDoublets(const TILES &histo,
startPhiBin = entryPhiBin - phiWindow;
endPhiBin = entryPhiBin + phiWindow + 1;
if (verbosity_ > Guru) {
LogDebug("HGCGraph") << " Entrance eta, phi: " << r.origin.eta() << ", " << r.origin.phi()
LogDebug("HGCGraph") << " Entrance eta, phi: " << origin_eta << ", " << origin_phi
<< " entryEtaBin: " << entryEtaBin << " entryPhiBin: " << entryPhiBin
<< " globalBin: " << firstLayerHisto.globalBin(r.origin.eta(), r.origin.phi())
<< " globalBin: " << firstLayerHisto.globalBin(origin_eta, origin_phi)
<< " on layer: " << firstLayerOnZSide << " startEtaBin: " << startEtaBin
<< " endEtaBin: " << endEtaBin << " startPhiBin: " << startPhiBin
<< " endPhiBin: " << endPhiBin << " phiBin(0): " << firstLayerHisto.phiBin(0.)
Expand All @@ -75,7 +82,7 @@ void HGCGraphT<TILES>::makeAndConnectDoublets(const TILES &histo,
}

for (int il = 0; il < maxNumberOfLayers - 1; ++il) {
for (int outer_layer = 0; outer_layer < std::min(1 + missing_layers, maxNumberOfLayers - 1 - il); ++outer_layer) {
for (int outer_layer = 0; outer_layer < std::min(1 + skip_layers, maxNumberOfLayers - 1 - il); ++outer_layer) {
int currentInnerLayerId = il + maxNumberOfLayers * zSide;
int currentOuterLayerId = currentInnerLayerId + 1 + outer_layer;
auto const &outerLayerHisto = histo[currentOuterLayerId];
Expand Down Expand Up @@ -171,8 +178,17 @@ void HGCGraphT<TILES>::makeAndConnectDoublets(const TILES &histo,
minCosTheta,
minCosPointing,
verbosity_ > Advanced);
if (isRootDoublet)
if (isRootDoublet and checkDistanceRootDoubletVsSeed) {
auto dEtaSquared = (layerClusters[innerClusterId].eta() - origin_eta);
dEtaSquared *= dEtaSquared;
auto dPhiSquared = (layerClusters[innerClusterId].phi() - origin_phi);
dPhiSquared *= dPhiSquared;
if (dEtaSquared + dPhiSquared > root_doublet_max_distance_from_seed_squared)
isRootDoublet = false;
}
if (isRootDoublet) {
theRootDoublets_.push_back(doubletId);
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion RecoHGCal/TICL/plugins/HGCGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class HGCGraphT {
int deltaIPhi,
float minCosThetai,
float maxCosPointing,
float root_doublet_max_distance_from_seed_squared,
float etaLimitIncreaseWindow,
int missing_layers,
int skip_layers,
int maxNumberOfLayers,
float maxDeltaTime);

Expand Down
23 changes: 12 additions & 11 deletions RecoHGCal/TICL/plugins/MultiClustersFromTrackstersProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ void MultiClustersFromTrackstersProducer::produce(edm::Event& evt, const edm::Ev
}

std::for_each(std::begin(tracksters), std::end(tracksters), [&](auto const& trackster) {
// Do not create a multicluster if the trackster has no layer clusters.
// Create an empty multicluster if the trackster has no layer clusters.
// This could happen when a seed leads to no trackster and a dummy one is produced.

std::array<double, 3> baricenter{{0., 0., 0.}};
double total_weight = 0.;
reco::HGCalMultiCluster temp;
int counter = 0;
if (!trackster.vertices().empty()) {
std::array<double, 3> baricenter{{0., 0., 0.}};
double total_weight = 0.;
reco::HGCalMultiCluster temp;
int counter = 0;
std::for_each(std::begin(trackster.vertices()), std::end(trackster.vertices()), [&](unsigned int idx) {
temp.push_back(clusterPtrs[idx]);
auto fraction = 1.f / trackster.vertex_multiplicity(counter++);
Expand All @@ -86,13 +87,13 @@ void MultiClustersFromTrackstersProducer::produce(edm::Event& evt, const edm::Ev
std::begin(baricenter), std::end(baricenter), std::begin(baricenter), [&total_weight](double val) -> double {
return val / total_weight;
});
temp.setEnergy(total_weight);
temp.setCorrectedEnergy(total_weight);
temp.setPosition(math::XYZPoint(baricenter[0], baricenter[1], baricenter[2]));
temp.setAlgoId(reco::CaloCluster::hgcal_em);
temp.setTime(trackster.time(), trackster.timeError());
multiclusters->push_back(temp);
}
temp.setEnergy(total_weight);
felicepantaleo marked this conversation as resolved.
Show resolved Hide resolved
temp.setCorrectedEnergy(total_weight);
temp.setPosition(math::XYZPoint(baricenter[0], baricenter[1], baricenter[2]));
temp.setAlgoId(reco::CaloCluster::hgcal_em);
temp.setTime(trackster.time(), trackster.timeError());
multiclusters->push_back(temp);
});

evt.put(std::move(multiclusters));
Expand Down
13 changes: 12 additions & 1 deletion RecoHGCal/TICL/plugins/PFTICLProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ PFTICLProducer::PFTICLProducer(const edm::ParameterSet& conf)

void PFTICLProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("ticlCandidateSrc", edm::InputTag("ticlCandidateFromTracksters"));
desc.add<edm::InputTag>("ticlCandidateSrc", edm::InputTag("ticlTrackstersMerge"));
descriptions.add("pfTICLProducer", desc);
}

Expand All @@ -52,6 +52,15 @@ void PFTICLProducer::produce(edm::StreamID, edm::Event& evt, const edm::EventSet
const auto abs_pdg_id = std::abs(ticl_cand.pdgId());
const auto charge = ticl_cand.charge();
const auto& four_mom = ticl_cand.p4();
double ecal_energy = 0.;

for (const auto& t : ticl_cand.tracksters()) {
double ecal_energy_fraction = t->raw_em_pt() / t->raw_pt();
ecal_energy += t->raw_energy() * ecal_energy_fraction;
}
double hcal_energy = ticl_cand.rawEnergy() - ecal_energy;
// fix for floating point rounding could go slightly below 0
hcal_energy = hcal_energy < 0 ? 0 : hcal_energy;

reco::PFCandidate::ParticleType part_type;
switch (abs_pdg_id) {
Expand All @@ -78,6 +87,8 @@ void PFTICLProducer::produce(edm::StreamID, edm::Event& evt, const edm::EventSet
candidates->emplace_back(charge, four_mom, part_type);

auto& candidate = candidates->back();
candidate.setEcalEnergy(ecal_energy, ecal_energy);
candidate.setHcalEnergy(hcal_energy, hcal_energy);
if (candidate.charge()) { // otherwise PFCandidate throws
// Construct edm::Ref from edm::Ptr. As of now, assumes type to be reco::Track. To be extended (either via
// dynamic type checking or configuration) if additional track types are needed.
Expand Down
Loading