Skip to content

Commit

Permalink
Merge pull request #33001 from mariadalfonso/ticlNosefixes
Browse files Browse the repository at this point in the history
HFNose: ticl updates
  • Loading branch information
cmsbuild authored Mar 22, 2021
2 parents 1b23a1c + b1df50f commit 3070a54
Show file tree
Hide file tree
Showing 17 changed files with 241 additions and 26 deletions.
2 changes: 2 additions & 0 deletions RecoHGCal/Configuration/python/RecoHGCal_EventContent_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
'keep *_ticlTrackstersTrk_*_*',
'keep *_ticlTrackstersMIP_*_*',
'keep *_ticlTrackstersMerge_*_*',
'keep *_ticlTrackstersHFNoseTrkEM_*_*',
'keep *_ticlTrackstersHFNoseEM_*_*',
'keep *_ticlTrackstersHFNoseMIP_*_*',
'keep *_ticlTrackstersHFNoseHAD_*_*',
'keep *_ticlTrackstersHFNoseMerge_*_*',
'keep *_pfTICL_*_*'
)
Expand Down
8 changes: 5 additions & 3 deletions RecoHGCal/TICL/plugins/PatternRecognitionbyCA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void PatternRecognitionbyCA<TILES>::makeTracksters(
ticl::assignPCAtoTracksters(tmpTracksters,
input.layerClusters,
input.layerClustersTime,
rhtools_.getPositionLayer(rhtools_.lastLayerEE(type)).z());
rhtools_.getPositionLayer(rhtools_.lastLayerEE(type), type).z());

// run energy regression and ID
energyRegressionAndID(input.layerClusters, tmpTracksters);
Expand Down Expand Up @@ -246,8 +246,10 @@ void PatternRecognitionbyCA<TILES>::makeTracksters(
tmp.swap(result);
}

ticl::assignPCAtoTracksters(
result, input.layerClusters, input.layerClustersTime, rhtools_.getPositionLayer(rhtools_.lastLayerEE(type)).z());
ticl::assignPCAtoTracksters(result,
input.layerClusters,
input.layerClustersTime,
rhtools_.getPositionLayer(rhtools_.lastLayerEE(type), type).z());

// run energy regression and ID
energyRegressionAndID(input.layerClusters, result);
Expand Down
2 changes: 2 additions & 0 deletions RecoHGCal/TICL/plugins/SeedingRegionAlgoFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
#include "SeedingRegionByTracks.h"
#include "SeedingRegionGlobal.h"
#include "SeedingRegionByL1.h"
#include "SeedingRegionByHF.h"

EDM_REGISTER_VALIDATED_PLUGINFACTORY(SeedingRegionAlgoFactory, "SeedingRegionAlgoFactory");

DEFINE_EDM_VALIDATED_PLUGIN(SeedingRegionAlgoFactory, ticl::SeedingRegionByTracks, "SeedingRegionByTracks");
DEFINE_EDM_VALIDATED_PLUGIN(SeedingRegionAlgoFactory, ticl::SeedingRegionGlobal, "SeedingRegionGlobal");
DEFINE_EDM_VALIDATED_PLUGIN(SeedingRegionAlgoFactory, ticl::SeedingRegionByL1, "SeedingRegionByL1");
DEFINE_EDM_VALIDATED_PLUGIN(SeedingRegionAlgoFactory, ticl::SeedingRegionByHF, "SeedingRegionByHF");
62 changes: 62 additions & 0 deletions RecoHGCal/TICL/plugins/SeedingRegionByHF.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <algorithm>
#include <set>
#include <vector>

#include "SeedingRegionByHF.h"

using namespace ticl;

SeedingRegionByHF::SeedingRegionByHF(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
: SeedingRegionAlgoBase(conf, sumes),
hfhits_token_(sumes.consumes<HFRecHitCollection>(conf.getParameter<edm::InputTag>("hits"))),
minAbsEta_(conf.getParameter<double>("minAbsEta")),
maxAbsEta_(conf.getParameter<double>("maxAbsEta")),
minEt_(conf.getParameter<double>("minEt")) {
geo_token_ = sumes.esConsumes<CaloGeometry, CaloGeometryRecord, edm::Transition::BeginRun>();
}

SeedingRegionByHF::~SeedingRegionByHF() {}

void SeedingRegionByHF::initialize(const edm::EventSetup &es) { geometry_ = &es.getData(geo_token_); }

void SeedingRegionByHF::makeRegions(const edm::Event &ev,
const edm::EventSetup &es,
std::vector<TICLSeedingRegion> &result) {
const auto &recHits = ev.get(hfhits_token_);

for (const auto &erh : recHits) {
const HcalDetId &detid = (HcalDetId)erh.detid();
if (erh.energy() < minEt_)
continue;

const GlobalPoint &globalPosition =
geometry_->getSubdetectorGeometry(DetId::Hcal, HcalForward)->getGeometry(detid)->getPosition(detid);
auto eta = globalPosition.eta();

if (std::abs(eta) < minAbsEta_ || std::abs(eta) > maxAbsEta_)
continue;

int iSide = int(eta > 0);
int idx = 0;
edm::ProductID hfSeedId = edm::ProductID(detid.rawId());

auto phi = globalPosition.phi();
double theta = 2 * atan(exp(eta));
result.emplace_back(
globalPosition, GlobalVector(GlobalVector::Polar(theta, phi, erh.energy())), iSide, idx, hfSeedId);
}

// sorting seeding region by descending momentum
std::sort(result.begin(), result.end(), [](const TICLSeedingRegion &a, const TICLSeedingRegion &b) {
return a.directionAtOrigin.perp2() > b.directionAtOrigin.perp2();
});
}

void SeedingRegionByHF::fillPSetDescription(edm::ParameterSetDescription &desc) {
desc.add<edm::InputTag>("hits", edm::InputTag("hfreco"));
desc.add<int>("algo_verbosity", 0);
desc.add<double>("minAbsEta", 3.0);
desc.add<double>("maxAbsEta", 4.0);
desc.add<double>("minEt", 5);
SeedingRegionAlgoBase::fillPSetDescription(desc);
}
54 changes: 54 additions & 0 deletions RecoHGCal/TICL/plugins/SeedingRegionByHF.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Author: [email protected]
// Date: 02/2021

#ifndef RecoHGCal_TICL_SeedingRegionByHF_h
#define RecoHGCal_TICL_SeedingRegionByHF_h
#include <memory> // unique_ptr
#include <string>
#include "RecoHGCal/TICL/plugins/SeedingRegionAlgoBase.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "DataFormats/HcalRecHit/interface/HFRecHit.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"

namespace ticl {
class SeedingRegionByHF final : public SeedingRegionAlgoBase {
public:
SeedingRegionByHF(const edm::ParameterSet& conf, edm::ConsumesCollector& sumes);
~SeedingRegionByHF() override;

void initialize(const edm::EventSetup& es) override;

void makeRegions(const edm::Event& ev, const edm::EventSetup& es, std::vector<TICLSeedingRegion>& result) override;
static void fillPSetDescription(edm::ParameterSetDescription& desc);
static edm::ParameterSetDescription makePSetDescription();

private:
void buildFirstLayers();

edm::EDGetTokenT<HFRecHitCollection> hfhits_token_;

int algoVerbosity_ = 0;

double minAbsEta_;
double maxAbsEta_;
double minEt_;

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geo_token_;
const CaloGeometry* geometry_;
};
} // namespace ticl
#endif
10 changes: 7 additions & 3 deletions RecoHGCal/TICL/plugins/SeedingRegionByTracks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ SeedingRegionByTracks::SeedingRegionByTracks(const edm::ParameterSet &conf, edm:
: SeedingRegionAlgoBase(conf, sumes),
tracks_token_(sumes.consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("tracks"))),
cutTk_(conf.getParameter<std::string>("cutTk")),
detector_(conf.getParameter<std::string>("detector")),
propName_(conf.getParameter<std::string>("propagator")),
hdc_token_(sumes.esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(
edm::ESInputTag("", detectorName_))),
bfield_token_(sumes.esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>()),
propagator_token_(sumes.esConsumes<Propagator, TrackingComponentsRecord, edm::Transition::BeginRun>(
edm::ESInputTag("", propName_))) {}
edm::ESInputTag("", propName_))) {
std::string detectorName_ = (detector_ == "HFNose") ? "HGCalHFNoseSensitive" : "HGCalEESensitive";
hdc_token_ = sumes.esConsumes<HGCalDDDConstants, IdealGeometryRecord, edm::Transition::BeginRun>(
edm::ESInputTag("", detectorName_));
}

SeedingRegionByTracks::~SeedingRegionByTracks() {}

Expand Down Expand Up @@ -71,6 +74,7 @@ void SeedingRegionByTracks::fillPSetDescription(edm::ParameterSetDescription &de
"1.48 < abs(eta) < 3.0 && pt > 1. && quality(\"highPurity\") && "
"hitPattern().numberOfLostHits(\"MISSING_OUTER_HITS\") < 5");
desc.add<std::string>("propagator", "PropagatorWithMaterial");
desc.add<std::string>("detector", "HGCAL");
SeedingRegionAlgoBase::fillPSetDescription(desc);
}

Expand Down
2 changes: 1 addition & 1 deletion RecoHGCal/TICL/plugins/SeedingRegionByTracks.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace ticl {
std::once_flag initializeGeometry_;
const HGCalDDDConstants* hgcons_;
const StringCutObjectSelector<reco::Track> cutTk_;
inline static const std::string detectorName_ = "HGCalEESensitive";
const std::string detector_;
edm::ESHandle<Propagator> propagator_;
const std::string propName_;
edm::ESHandle<MagneticField> bfield_;
Expand Down
3 changes: 2 additions & 1 deletion RecoHGCal/TICL/plugins/TICLSeedingRegionProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
#include "FWCore/ParameterSet/interface/PluginDescription.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "RecoHGCal/TICL/plugins/SeedingRegionAlgoBase.h"
#include "SeedingRegionAlgoFactory.h"
#include "SeedingRegionByL1.h"
#include "SeedingRegionByTracks.h"
#include "SeedingRegionGlobal.h"
#include "SeedingRegionAlgoFactory.h"
#include "SeedingRegionByHF.h"

using namespace ticl;

Expand Down
12 changes: 8 additions & 4 deletions RecoHGCal/TICL/python/EMStep_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,25 @@

filteredLayerClustersHFNoseEM = filteredLayerClustersEM.clone(
LayerClusters = 'hgcalLayerClustersHFNose',
LayerClustersInputMask = "hgcalLayerClustersHFNose:InitialLayerClustersMask",
LayerClustersInputMask = 'ticlTrackstersHFNoseTrkEM',
iteration_label = "EMn",
min_cluster_size = 2, # inclusive
algo_number = 9
#no tracking mask for EM for now
)

ticlTrackstersHFNoseEM = ticlTrackstersEM.clone(
detector = "HFNose",
layer_clusters = "hgcalLayerClustersHFNose",
layer_clusters_hfnose_tiles = "ticlLayerTileHFNose",
original_mask = "hgcalLayerClustersHFNose:InitialLayerClustersMask",
original_mask = "ticlTrackstersHFNoseTrkEM",
filtered_mask = "filteredLayerClustersHFNoseEM:EMn",
seeding_regions = "ticlSeedingGlobalHFNose",
time_layerclusters = "hgcalLayerClustersHFNose:timeLayerCluster",
min_layers_per_trackster = 6
itername = "EMn",
filter_on_categories = [0, 1],
min_layers_per_trackster = 5,
pid_threshold = 0.,
shower_start_max_layer = 5 ### inclusive
)

ticlHFNoseEMStepTask = cms.Task(ticlSeedingGlobalHFNose
Expand Down
31 changes: 30 additions & 1 deletion RecoHGCal/TICL/python/HADStep_cff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FWCore.ParameterSet.Config as cms

from RecoHGCal.TICL.TICLSeedingRegions_cff import ticlSeedingGlobal
from RecoHGCal.TICL.TICLSeedingRegions_cff import ticlSeedingGlobal, ticlSeedingGlobalHFNose
from RecoHGCal.TICL.ticlLayerTileProducer_cfi import ticlLayerTileProducer as _ticlLayerTileProducer
from RecoHGCal.TICL.trackstersProducer_cfi import trackstersProducer as _trackstersProducer
from RecoHGCal.TICL.filteredLayerClustersProducer_cfi import filteredLayerClustersProducer as _filteredLayerClustersProducer
Expand Down Expand Up @@ -44,3 +44,32 @@
,ticlTrackstersHAD
,ticlMultiClustersFromTrackstersHAD)

filteredLayerClustersHFNoseHAD = _filteredLayerClustersProducer.clone(
min_cluster_size = 2, # inclusive
algo_number = 9,
iteration_label = "HADn",
LayerClusters = 'hgcalLayerClustersHFNose',
LayerClustersInputMask = "hgcalLayerClustersHFNose:InitialLayerClustersMask"
)

ticlTrackstersHFNoseHAD = _trackstersProducer.clone(
detector = "HFNose",
layer_clusters = "hgcalLayerClustersHFNose",
layer_clusters_hfnose_tiles = "ticlLayerTileHFNose",
original_mask = "hgcalLayerClustersHFNose:InitialLayerClustersMask",
filtered_mask = "filteredLayerClustersHFNoseHAD:HADn",
seeding_regions = "ticlSeedingGlobalHFNose",
time_layerclusters = "hgcalLayerClustersHFNose:timeLayerCluster",
# For the moment we mask everything w/o requirements since we are last
pid_threshold = 0.,
skip_layers = 1,
min_layers_per_trackster = 5,
min_cos_theta = 0.866, # ~30 degrees
min_cos_pointing = 0.819, # ~35 degrees
max_delta_time = -1,
itername = "HADRONIC"
)

ticlHFNoseHADStepTask = cms.Task(ticlSeedingGlobalHFNose
,filteredLayerClustersHFNoseHAD
,ticlTrackstersHFNoseHAD)
13 changes: 13 additions & 0 deletions RecoHGCal/TICL/python/TICLSeedingRegions_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,16 @@
ticlSeedingGlobalHFNose = _ticlSeedingRegionProducer.clone(
seedingPSet = _ticlSeedingRegionProducer.seedingPSet.clone(type="SeedingRegionGlobal")
)

# fixme: empty seed, need to work on propagator
ticlSeedingTrkHFNose = _ticlSeedingRegionProducer.clone(
seedingPSet = _ticlSeedingRegionProducer.seedingPSet.clone(
type="SeedingRegionByTracks",
cutTk = cms.string('3. < abs(eta) < 4. && pt > 1. && quality("highPurity") && hitPattern().numberOfLostHits("MISSING_OUTER_HITS") < 5'),
detector = cms.string("HFNose")
)
)

ticlSeedingByHFHFNose = _ticlSeedingRegionProducer.clone(
seedingPSet = _ticlSeedingRegionProducer.seedingPSet.clone(type="SeedingRegionByHF")
)
32 changes: 30 additions & 2 deletions RecoHGCal/TICL/python/TrkEMStep_cff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FWCore.ParameterSet.Config as cms

from RecoHGCal.TICL.TICLSeedingRegions_cff import ticlSeedingTrk
from RecoHGCal.TICL.TICLSeedingRegions_cff import ticlSeedingTrk, ticlSeedingTrkHFNose
from RecoHGCal.TICL.trackstersProducer_cfi import trackstersProducer as _trackstersProducer
from RecoHGCal.TICL.filteredLayerClustersProducer_cfi import filteredLayerClustersProducer as _filteredLayerClustersProducer
from RecoHGCal.TICL.multiClustersFromTrackstersProducer_cfi import multiClustersFromTrackstersProducer as _multiClustersFromTrackstersProducer
Expand All @@ -18,7 +18,7 @@
# CA - PATTERN RECOGNITION

ticlTrackstersTrkEM = _trackstersProducer.clone(
filtered_mask = cms.InputTag("filteredLayerClustersTrkEM", "TrkEM"),
filtered_mask = "filteredLayerClustersTrkEM:TrkEM",
seeding_regions = "ticlSeedingTrk",
filter_on_categories = [0, 1],
pid_threshold = 0.5,
Expand Down Expand Up @@ -49,3 +49,31 @@
,ticlTrackstersTrkEM
,ticlMultiClustersFromTrackstersTrkEM)

filteredLayerClustersHFNoseTrkEM = filteredLayerClustersTrkEM.clone(
LayerClusters = 'hgcalLayerClustersHFNose',
LayerClustersInputMask = "hgcalLayerClustersHFNose:InitialLayerClustersMask",
min_cluster_size = 2, # inclusive
algo_number = 9,
iteration_label = "TrkEMn"
)

ticlTrackstersHFNoseTrkEM = ticlTrackstersTrkEM.clone(
detector = "HFNose",
layer_clusters = "hgcalLayerClustersHFNose",
layer_clusters_hfnose_tiles = "ticlLayerTileHFNose",
original_mask = "hgcalLayerClustersHFNose:InitialLayerClustersMask",
filtered_mask = "filteredLayerClustersHFNoseTrkEM:TrkEMn",
seeding_regions = "ticlSeedingTrkHFNose",
time_layerclusters = "hgcalLayerClustersHFNose:timeLayerCluster",
itername = "TrkEMn",
filter_on_categories = [0, 1],
min_layers_per_trackster = 5,
pid_threshold = 0.,
shower_start_max_layer = 5 #inclusive

)

ticlHFNoseTrkEMStepTask = cms.Task(ticlSeedingTrkHFNose
,filteredLayerClustersHFNoseTrkEM
,ticlTrackstersHFNoseTrkEM)

9 changes: 5 additions & 4 deletions RecoHGCal/TICL/python/iterativeTICL_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@

ticlLayerTileHFNoseTask = cms.Task(ticlLayerTileHFNose)

iterHFNoseTICLTask = cms.Task(
ticlLayerTileHFNoseTask,
ticlHFNoseMIPStepTask,
ticlHFNoseEMStepTask
iterHFNoseTICLTask = cms.Task(ticlLayerTileHFNoseTask
,ticlHFNoseTrkEMStepTask
,ticlHFNoseEMStepTask
,ticlHFNoseHADStepTask
,ticlHFNoseMIPStepTask
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
premix_stage2.toModify(layerClusterCaloParticleAssociation,
label_cp = "mixData:MergedCaloTruth"
)

layerClusterCaloParticleAssociationHFNose = layerClusterCaloParticleAssociation.clone(
label_lc = "hgcalLayerClustersHFNose"
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
premix_stage2.toModify(layerClusterSimClusterAssociation,
label_scl = "mixData:MergedCaloTruth"
)

layerClusterSimClusterAssociationHFNose = layerClusterSimClusterAssociation.clone(
label_lcl = "hgcalLayerClustersHFNose"
)
Loading

0 comments on commit 3070a54

Please sign in to comment.