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

HFNose: ticl updates #33001

Merged
merged 14 commits into from
Mar 22, 2021
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_;
mariadalfonso marked this conversation as resolved.
Show resolved Hide resolved

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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use a more expressive name? Also for the downstream HADn and TrkEMn.

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
)
16 changes: 8 additions & 8 deletions SimGeneral/MixingModule/python/caloTruthProducer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
from Configuration.ProcessModifiers.premix_stage1_cff import premix_stage1
premix_stage1.toModify(caloParticles, premixStage1 = True)

#from Configuration.Eras.Modifier_phase2_hfnose_cff import phase2_hfnose
#phase2_hfnose.toModify(
# caloParticles,
# simHitCollections = dict(
# hgc = caloParticles.simHitCollections.hgc + [cms.InputTag('g4SimHits','HFNoseHits')],
# hcal = cms.VInputTag(cms.InputTag('g4SimHits','HcalHits'))
# )
#)
from Configuration.Eras.Modifier_phase2_hfnose_cff import phase2_hfnose
phase2_hfnose.toModify(
caloParticles,
simHitCollections = dict(
hgc = caloParticles.simHitCollections.hgc + [cms.InputTag('g4SimHits','HFNoseHits')],
hcal = cms.VInputTag(cms.InputTag('g4SimHits','HcalHits'))
)
)

from Configuration.ProcessModifiers.run3_ecalclustering_cff import run3_ecalclustering
run3_ecalclustering.toModify(
Expand Down