-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[HGCAL] TICL SimTracksters #33318
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
Merged
cmsbuild
merged 22 commits into
cms-sw:master
from
felicepantaleo:TICL_TrackstersFromSimClustersProducer_11_3_X_2021-03-30-2300
Apr 16, 2021
Merged
[HGCAL] TICL SimTracksters #33318
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
64ea8d7
First skeleton of a Trackster from Simcluster producer
felicepantaleo 753c6a6
Fix bug
felicepantaleo cf9e934
Add simtracksters into the event content
felicepantaleo de19595
Make SimTracksters part of TICL Tasks
felicepantaleo 56e48e8
Create a SimTrackster per SimCluster
felicepantaleo 40e7159
Deleted methods should be public
felicepantaleo 91c4258
keep multiclusters from simtracksters
felicepantaleo b73deeb
cleanup
felicepantaleo e57b824
add multiclusters from simtrackstrs
felicepantaleo dba83a7
add simtracksters to validation
felicepantaleo dfdcc2f
Make multiplicity take the simulated energy fraction
felicepantaleo f191037
add simTracksters iteration to validation
felicepantaleo fda1d49
replacing tabs with spaces and speeding up --help
felicepantaleo f316363
make enabling simclusters validation plots
felicepantaleo 36eb148
cleanup
felicepantaleo da10fc7
Add SimTracksters to FEVT and PreValidation Sequence
felicepantaleo a92216e
Fix for premix wf
felicepantaleo a11ab0d
get ES data through token
felicepantaleo d81de08
update and reorder BuildFile
felicepantaleo 7944ae0
adding missing dependencies in BuildFile
felicepantaleo 26316a4
add comment to deprecate Multiclusters
felicepantaleo 0e28f7d
add name and date
felicepantaleo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,36 @@ | ||
| <use name="CommonTools/Utils"/> | ||
| <use name="RecoLocalCalo/HGCalRecProducers"/> | ||
| <use name="RecoLocalCalo/HGCalRecAlgos"/> | ||
| <use name="FWCore/Framework"/> | ||
| <use name="FWCore/ParameterSet"/> | ||
| <use name="FWCore/PluginManager"/> | ||
| <use name="DataFormats/CaloRecHit"/> | ||
| <use name="DataFormats/ParticleFlowCandidate"/> | ||
| <use name="DataFormats/Candidate"/> | ||
| <use name="DataFormats/Common"/> | ||
| <use name="DataFormats/GeometrySurface"/> | ||
| <use name="DataFormats/HGCalReco"/> | ||
| <use name="FWCore/MessageLogger"/> | ||
| <use name="DataFormats/L1TCorrelator"/> | ||
| <use name="DataFormats/L1Trigger"/> | ||
| <use name="DataFormats/Math"/> | ||
| <use name="DataFormats/ParticleFlowCandidate"/> | ||
| <use name="DataFormats/ParticleFlowReco"/> | ||
| <use name="DataFormats/TrackReco"/> | ||
| <use name="TrackingTools/Records"/> | ||
| <use name="FWCore/Framework"/> | ||
| <use name="FWCore/MessageLogger"/> | ||
| <use name="FWCore/ParameterSet"/> | ||
| <use name="FWCore/PluginManager"/> | ||
| <use name="FWCore/Utilities"/> | ||
| <use name="Geometry/CaloGeometry"/> | ||
| <use name="Geometry/CommonDetUnit"/> | ||
| <use name="Geometry/HGCalCommonData"/> | ||
| <use name="Geometry/Records"/> | ||
| <use name="MagneticField/Engine"/> | ||
| <use name="MagneticField/Records"/> | ||
| <use name="PhysicsTools/TensorFlow"/> | ||
| <use name="RecoLocalCalo/HGCalRecAlgos"/> | ||
| <use name="RecoLocalCalo/HGCalRecProducers"/> | ||
| <use name="RecoHGCal/TICL"/> | ||
| <use name="RecoParticleFlow/PFProducer"/> | ||
| <use name="SimDataFormats/Associations"/> | ||
| <use name="SimDataFormats/CaloAnalysis"/> | ||
| <use name="TrackingTools/GeomPropagators"/> | ||
| <use name="TrackingTools/Records"/> | ||
| <use name="TrackingTools/TrajectoryState"/> | ||
| <library file="*.cc" name="RecoHGCalTICLPlugins"> | ||
| <flags EDM_PLUGIN="1"/> | ||
| </library> |
151 changes: 151 additions & 0 deletions
151
RecoHGCal/TICL/plugins/TrackstersFromSimClustersProducer.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| // Author: Felice Pantaleo - [email protected] | ||
| // Date: 02/2021 | ||
|
|
||
| // user include files | ||
|
|
||
| #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/Framework/interface/stream/EDProducer.h" | ||
| #include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
| #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
|
|
||
| #include "DataFormats/CaloRecHit/interface/CaloCluster.h" | ||
| #include "DataFormats/ParticleFlowReco/interface/PFCluster.h" | ||
|
|
||
| #include "DataFormats/HGCalReco/interface/Trackster.h" | ||
|
|
||
| #include "DataFormats/Common/interface/ValueMap.h" | ||
| #include "SimDataFormats/Associations/interface/LayerClusterToSimClusterAssociator.h" | ||
| #include "SimDataFormats/CaloAnalysis/interface/SimCluster.h" | ||
felicepantaleo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h" | ||
|
|
||
| #include "TrackstersPCA.h" | ||
| #include <vector> | ||
| #include <iterator> | ||
| #include <algorithm> | ||
| using namespace ticl; | ||
|
|
||
| namespace { | ||
| Trackster::ParticleType tracksterParticleTypeFromPdgId(int pdgId, int charge) { | ||
| if (pdgId == 111) { | ||
felicepantaleo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return Trackster::ParticleType::neutral_pion; | ||
| } else { | ||
| pdgId = std::abs(pdgId); | ||
| if (pdgId == 22) { | ||
| return Trackster::ParticleType::photon; | ||
| } else if (pdgId == 11) { | ||
| return Trackster::ParticleType::electron; | ||
| } else if (pdgId == 13) { | ||
| return Trackster::ParticleType::muon; | ||
| } else { | ||
| bool isHadron = (pdgId > 100 and pdgId < 900) or (pdgId > 1000 and pdgId < 9000); | ||
| if (isHadron) { | ||
| if (charge != 0) { | ||
| return Trackster::ParticleType::charged_hadron; | ||
| } else { | ||
| return Trackster::ParticleType::neutral_hadron; | ||
| } | ||
| } else { | ||
| return Trackster::ParticleType::unknown; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } // namespace | ||
|
|
||
| class TrackstersFromSimClustersProducer : public edm::stream::EDProducer<> { | ||
| public: | ||
| explicit TrackstersFromSimClustersProducer(const edm::ParameterSet&); | ||
| ~TrackstersFromSimClustersProducer() override {} | ||
| static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
|
||
| void produce(edm::Event&, const edm::EventSetup&) override; | ||
|
|
||
| private: | ||
| std::string detector_; | ||
| const bool doNose_ = false; | ||
| const edm::EDGetTokenT<std::vector<reco::CaloCluster>> clusters_token_; | ||
| const edm::EDGetTokenT<edm::ValueMap<std::pair<float, float>>> clustersTime_token_; | ||
| const edm::EDGetTokenT<std::vector<float>> filtered_layerclusters_mask_token_; | ||
|
|
||
| edm::EDGetTokenT<std::vector<SimCluster>> simclusters_token_; | ||
|
|
||
| edm::InputTag associatorLayerClusterSimCluster_; | ||
| edm::EDGetTokenT<hgcal::SimToRecoCollectionWithSimClusters> associatorMapSimToReco_token_; | ||
| edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geom_token_; | ||
| hgcal::RecHitTools rhtools_; | ||
| }; | ||
| DEFINE_FWK_MODULE(TrackstersFromSimClustersProducer); | ||
|
|
||
| TrackstersFromSimClustersProducer::TrackstersFromSimClustersProducer(const edm::ParameterSet& ps) | ||
| : detector_(ps.getParameter<std::string>("detector")), | ||
| doNose_(detector_ == "HFNose"), | ||
| clusters_token_(consumes<std::vector<reco::CaloCluster>>(ps.getParameter<edm::InputTag>("layer_clusters"))), | ||
| clustersTime_token_( | ||
| consumes<edm::ValueMap<std::pair<float, float>>>(ps.getParameter<edm::InputTag>("time_layerclusters"))), | ||
| filtered_layerclusters_mask_token_(consumes<std::vector<float>>(ps.getParameter<edm::InputTag>("filtered_mask"))), | ||
| simclusters_token_(consumes<std::vector<SimCluster>>(ps.getParameter<edm::InputTag>("simclusters"))), | ||
| associatorLayerClusterSimCluster_(ps.getUntrackedParameter<edm::InputTag>("layerClusterSimClusterAssociator")), | ||
| associatorMapSimToReco_token_( | ||
| consumes<hgcal::SimToRecoCollectionWithSimClusters>(associatorLayerClusterSimCluster_)), | ||
| geom_token_(esConsumes()) { | ||
| produces<std::vector<Trackster>>(); | ||
| produces<std::vector<float>>(); | ||
| } | ||
|
|
||
| void TrackstersFromSimClustersProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
| // hgcalMultiClusters | ||
| edm::ParameterSetDescription desc; | ||
| desc.add<std::string>("detector", "HGCAL"); | ||
| desc.add<edm::InputTag>("layer_clusters", edm::InputTag("hgcalLayerClusters")); | ||
| desc.add<edm::InputTag>("time_layerclusters", edm::InputTag("hgcalLayerClusters", "timeLayerCluster")); | ||
| desc.add<edm::InputTag>("filtered_mask", edm::InputTag("filteredLayerClustersSimTracksters", "ticlSimTracksters")); | ||
| desc.add<edm::InputTag>("simclusters", edm::InputTag("mix", "MergedCaloTruth")); | ||
| desc.addUntracked<edm::InputTag>("layerClusterSimClusterAssociator", | ||
| edm::InputTag("layerClusterSimClusterAssociationProducer")); | ||
| descriptions.add("trackstersFromSimClustersProducer", desc); | ||
| } | ||
|
|
||
| void TrackstersFromSimClustersProducer::produce(edm::Event& evt, const edm::EventSetup& es) { | ||
| auto result = std::make_unique<std::vector<Trackster>>(); | ||
| auto output_mask = std::make_unique<std::vector<float>>(); | ||
| const auto& layerClusters = evt.get(clusters_token_); | ||
| const auto& layerClustersTimes = evt.get(clustersTime_token_); | ||
| const auto& inputClusterMask = evt.get(filtered_layerclusters_mask_token_); | ||
| output_mask->resize(layerClusters.size(), 1.f); | ||
|
|
||
| const auto& simclusters = evt.get(simclusters_token_); | ||
| const auto& simToRecoColl = evt.get(associatorMapSimToReco_token_); | ||
|
|
||
| const auto& geom = es.getData(geom_token_); | ||
| rhtools_.setGeometry(geom); | ||
| auto num_simclusters = simclusters.size(); | ||
| result->reserve(num_simclusters); | ||
| for (const auto& [key, values] : simToRecoColl) { | ||
| auto const& sc = *(key); | ||
| auto simClusterIndex = &sc - &simclusters[0]; | ||
| Trackster tmpTrackster; | ||
| tmpTrackster.zeroProbabilities(); | ||
| tmpTrackster.vertices().reserve(values.size()); | ||
| tmpTrackster.vertex_multiplicity().reserve(values.size()); | ||
|
|
||
| for (auto const& [lc, energyScorePair] : values) { | ||
| if (inputClusterMask[lc.index()] > 0) { | ||
| tmpTrackster.vertices().push_back(lc.index()); | ||
| double fraction = energyScorePair.first / lc->energy(); | ||
| (*output_mask)[lc.index()] -= fraction; | ||
| tmpTrackster.vertex_multiplicity().push_back(static_cast<uint8_t>(std::clamp(1. / fraction, 0., 255.))); | ||
| } | ||
| } | ||
| tmpTrackster.setIdProbability(tracksterParticleTypeFromPdgId(sc.pdgId(), sc.charge()), 1.f); | ||
| tmpTrackster.setSeed(key.id(), simClusterIndex); | ||
| result->emplace_back(tmpTrackster); | ||
| } | ||
| ticl::assignPCAtoTracksters( | ||
| *result, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE(doNose_)).z()); | ||
| evt.put(std::move(result)); | ||
| evt.put(std::move(output_mask)); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| from RecoHGCal.TICL.trackstersFromSimClustersProducer_cfi import trackstersFromSimClustersProducer as _trackstersFromSimClustersProducer | ||
| from RecoHGCal.TICL.multiClustersFromTrackstersProducer_cfi import multiClustersFromTrackstersProducer as _multiClustersFromTrackstersProducer | ||
| from RecoHGCal.TICL.filteredLayerClustersProducer_cfi import filteredLayerClustersProducer as _filteredLayerClustersProducer | ||
|
|
||
|
|
||
| # CA - PATTERN RECOGNITION | ||
|
|
||
|
|
||
| filteredLayerClustersSimTracksters = _filteredLayerClustersProducer.clone( | ||
| clusterFilter = "ClusterFilterByAlgoAndSize", | ||
| algo_number = 8, | ||
| min_cluster_size = 0, # inclusive | ||
| iteration_label = "ticlSimTracksters" | ||
| ) | ||
|
|
||
| ticlSimTracksters = _trackstersFromSimClustersProducer.clone( | ||
| ) | ||
|
|
||
| from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 | ||
| premix_stage2.toModify(ticlSimTracksters, | ||
| simclusters = "mixData:MergedCaloTruth" | ||
| ) | ||
|
|
||
| ticlMultiClustersFromSimTracksters = _multiClustersFromTrackstersProducer.clone( | ||
| Tracksters = "ticlSimTracksters" | ||
| ) | ||
|
|
||
| ticlSimTrackstersTask = cms.Task(filteredLayerClustersSimTracksters, ticlSimTracksters, ticlMultiClustersFromSimTracksters) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.