diff --git a/DataFormats/HGCalReco/interface/TICLCandidate.h b/DataFormats/HGCalReco/interface/TICLCandidate.h index 2582b9b811a32..3d72d8ebf54c0 100644 --- a/DataFormats/HGCalReco/interface/TICLCandidate.h +++ b/DataFormats/HGCalReco/interface/TICLCandidate.h @@ -9,6 +9,8 @@ #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "RecoHGCal/TICL/interface/commons.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + // A TICLCandidate is a lightweight physics object made from one or multiple Tracksters. class TICLCandidate : public reco::LeafCandidate { @@ -28,16 +30,13 @@ class TICLCandidate : public reco::LeafCandidate { timeError_(trackster->timeError()), rawEnergy_(0.f) {} - TICLCandidate(const edm::Ptr trackPtr, edm::Ptr& tracksterPtr) - : LeafCandidate(), - tracksters_({std::move(tracksterPtr)}), - trackPtr_(std::move(trackPtr)), - time_(0.f), - timeError_(-1.f) { - //TODO: Raise Error - assert(trackPtr_.isNonnull() or tracksters_[0].isNonnull()); - - if (tracksters_[0].isNonnull()) { + TICLCandidate(const edm::Ptr trackPtr, const edm::Ptr& tracksterPtr) + : LeafCandidate(), tracksters_{}, trackPtr_(trackPtr), time_(0.f), timeError_(-1.f) { + if (trackPtr_.isNull() and tracksterPtr.isNull()) + edm::LogError("TICLCandidate") << "At least one between track and trackster must be valid\n"; + + if (tracksterPtr.isNonnull()) { + tracksters_.push_back(std::move(tracksterPtr)); auto const& trackster = tracksters_[0].get(); idProbabilities_ = trackster->id_probabilities(); if (trackPtr_.isNonnull()) { @@ -65,9 +64,7 @@ class TICLCandidate : public reco::LeafCandidate { regrE); setP4(p4); } - } - - else { + } else { //candidate from track only auto const& tk = trackPtr_.get(); setPdgId(211 * tk->charge()); diff --git a/DataFormats/HGCalReco/interface/Trackster.h b/DataFormats/HGCalReco/interface/Trackster.h index 26a524cb07328..5591f5a0df38e 100644 --- a/DataFormats/HGCalReco/interface/Trackster.h +++ b/DataFormats/HGCalReco/interface/Trackster.h @@ -41,11 +41,12 @@ namespace ticl { regressed_energy_(0.f), raw_energy_(0.f), time_(0.f), + boundTime_(0.f), timeError_(-1.f), - raw_em_energy_(0.f), id_probabilities_{}, raw_pt_(0.f), raw_em_pt_(0.f), + raw_em_energy_(0.f), seedIndex_(-1), eigenvalues_{}, sigmas_{}, @@ -137,6 +138,8 @@ namespace ticl { } inline void setIdProbability(ParticleType type, float value) { id_probabilities_[int(type)] = value; } + inline void setBoundaryTime(float t) { boundTime_ = t; }; + inline const Trackster::IterationIndex ticlIteration() const { return (IterationIndex)iterationIndex_; } inline const std::vector &vertices() const { return vertices_; } inline const unsigned int vertices(int index) const { return vertices_[index]; } @@ -152,6 +155,7 @@ namespace ticl { inline const float raw_em_energy() const { return raw_em_energy_; } inline const float raw_pt() const { return raw_pt_; } inline const float raw_em_pt() const { return raw_em_pt_; } + inline const float boundaryTime() const { return boundTime_; }; inline const Vector &barycenter() const { return barycenter_; } inline const std::array &eigenvalues() const { return eigenvalues_; } inline const std::array &eigenvectors() const { return eigenvectors_; } @@ -173,8 +177,8 @@ namespace ticl { float raw_energy_; // -99, -1 if not available. ns units otherwise float time_; + float boundTime_; float timeError_; - float raw_em_energy_; // trackster ID probabilities std::array id_probabilities_; @@ -185,6 +189,7 @@ namespace ticl { std::vector vertex_multiplicity_; float raw_pt_; float raw_em_pt_; + float raw_em_energy_; // Product ID of the seeding collection used to create the Trackster. // For GlobalSeeding the ProductID is set to 0. For track-based seeding diff --git a/DataFormats/HGCalReco/src/classes_def.xml b/DataFormats/HGCalReco/src/classes_def.xml index 35a7d0d851814..7d4b3f16d2618 100644 --- a/DataFormats/HGCalReco/src/classes_def.xml +++ b/DataFormats/HGCalReco/src/classes_def.xml @@ -1,6 +1,7 @@ - + + diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py index e270470d447a7..dcdffc6090cb5 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHitL1Seeded_cfi.py @@ -1,6 +1,7 @@ import FWCore.ParameterSet.Config as cms +from RecoLocalCalo.HGCalRecProducers.HGCalUncalibRecHitProducer_cfi import HGCalUncalibRecHitProducer -HGCalUncalibRecHitL1Seeded = cms.EDProducer("HGCalUncalibRecHitProducer", +HGCalUncalibRecHitL1Seeded = HGCalUncalibRecHitProducer.clone( HGCEEConfig = cms.PSet( adcNbits = cms.uint32(10), adcSaturation = cms.double(100), @@ -13,7 +14,6 @@ toaLSB_ns = cms.double(0.0244) ), HGCEEdigiCollection = cms.InputTag("hgcalDigisL1Seeded","EE"), - HGCEEhitCollection = cms.string('HGCEEUncalibRecHits'), HGCHEBConfig = cms.PSet( adcNbits = cms.uint32(10), adcSaturation = cms.double(68.75), @@ -26,7 +26,6 @@ toaLSB_ns = cms.double(0.0244) ), HGCHEBdigiCollection = cms.InputTag("hgcalDigisL1Seeded","HEback"), - HGCHEBhitCollection = cms.string('HGCHEBUncalibRecHits'), HGCHEFConfig = cms.PSet( adcNbits = cms.uint32(10), adcSaturation = cms.double(100), @@ -39,7 +38,6 @@ toaLSB_ns = cms.double(0.0244) ), HGCHEFdigiCollection = cms.InputTag("hgcalDigisL1Seeded","HEfront"), - HGCHEFhitCollection = cms.string('HGCHEFUncalibRecHits'), HGCHFNoseConfig = cms.PSet( adcNbits = cms.uint32(10), adcSaturation = cms.double(100), @@ -50,8 +48,5 @@ tdcSaturation = cms.double(10000), tofDelay = cms.double(-33), toaLSB_ns = cms.double(0.0244) - ), - HGCHFNosedigiCollection = cms.InputTag("hfnoseDigis","HFNose"), - HGCHFNosehitCollection = cms.string('HGCHFNoseUncalibRecHits'), - algo = cms.string('HGCalUncalibRecHitWorkerWeights') + ) ) diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py index 031e9e33e8182..e806d59d6f389 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/HGCalUncalibRecHit_cfi.py @@ -1,6 +1,7 @@ import FWCore.ParameterSet.Config as cms +from RecoLocalCalo.HGCalRecProducers.HGCalUncalibRecHitProducer_cfi import HGCalUncalibRecHitProducer -HGCalUncalibRecHit = cms.EDProducer("HGCalUncalibRecHitProducer", +HGCalUncalibRecHit = HGCalUncalibRecHitProducer.clone( HGCEEConfig = cms.PSet( adcNbits = cms.uint32(10), adcSaturation = cms.double(100), @@ -12,8 +13,6 @@ tofDelay = cms.double(-9), toaLSB_ns = cms.double(0.0244) ), - HGCEEdigiCollection = cms.InputTag("hgcalDigis","EE"), - HGCEEhitCollection = cms.string('HGCEEUncalibRecHits'), HGCHEBConfig = cms.PSet( adcNbits = cms.uint32(10), adcSaturation = cms.double(68.75), @@ -25,8 +24,6 @@ tofDelay = cms.double(-14), toaLSB_ns = cms.double(0.0244) ), - HGCHEBdigiCollection = cms.InputTag("hgcalDigis","HEback"), - HGCHEBhitCollection = cms.string('HGCHEBUncalibRecHits'), HGCHEFConfig = cms.PSet( adcNbits = cms.uint32(10), adcSaturation = cms.double(100), @@ -38,8 +35,6 @@ tofDelay = cms.double(-11), toaLSB_ns = cms.double(0.0244) ), - HGCHEFdigiCollection = cms.InputTag("hgcalDigis","HEfront"), - HGCHEFhitCollection = cms.string('HGCHEFUncalibRecHits'), HGCHFNoseConfig = cms.PSet( adcNbits = cms.uint32(10), adcSaturation = cms.double(100), @@ -50,8 +45,5 @@ tdcSaturation = cms.double(10000), tofDelay = cms.double(-33), toaLSB_ns = cms.double(0.0244) - ), - HGCHFNosedigiCollection = cms.InputTag("hfnoseDigis","HFNose"), - HGCHFNosehitCollection = cms.string('HGCHFNoseUncalibRecHits'), - algo = cms.string('HGCalUncalibRecHitWorkerWeights') + ) ) diff --git a/RecoHGCal/TICL/interface/TICLInterpretationAlgoBase.h b/RecoHGCal/TICL/interface/TICLInterpretationAlgoBase.h index dcea1b755d2d3..784f1dcc4f751 100644 --- a/RecoHGCal/TICL/interface/TICLInterpretationAlgoBase.h +++ b/RecoHGCal/TICL/interface/TICLInterpretationAlgoBase.h @@ -65,16 +65,16 @@ namespace ticl { struct TrackTimingInformation { const edm::Handle> tkTime_h; const edm::Handle> tkTimeErr_h; - const edm::Handle> tkTimeQual_h; const edm::Handle> tkBeta_h; + const edm::Handle> tkPath_h; const edm::Handle> tkMtdPos_h; TrackTimingInformation(const edm::Handle> tkT, const edm::Handle> tkTE, - const edm::Handle> tkTQ, const edm::Handle> tkB, + const edm::Handle> tkP, const edm::Handle> mtdPos) - : tkTime_h(tkT), tkTimeErr_h(tkTE), tkTimeQual_h(tkTQ), tkBeta_h(tkB), tkMtdPos_h(mtdPos) {} + : tkTime_h(tkT), tkTimeErr_h(tkTE), tkBeta_h(tkB), tkPath_h(tkP), tkMtdPos_h(mtdPos) {} }; virtual void makeCandidates(const Inputs& input, diff --git a/RecoHGCal/TICL/plugins/GeneralInterpretationAlgo.cc b/RecoHGCal/TICL/plugins/GeneralInterpretationAlgo.cc index b2e86ca309080..7e166b8266b16 100644 --- a/RecoHGCal/TICL/plugins/GeneralInterpretationAlgo.cc +++ b/RecoHGCal/TICL/plugins/GeneralInterpretationAlgo.cc @@ -14,8 +14,7 @@ GeneralInterpretationAlgo::GeneralInterpretationAlgo(const edm::ParameterSet &co del_tk_ts_layer1_(conf.getParameter("delta_tk_ts_layer1")), del_tk_ts_int_(conf.getParameter("delta_tk_ts_interface")), del_ts_em_had_(conf.getParameter("delta_ts_em_had")), - del_ts_had_had_(conf.getParameter("delta_ts_had_had")), - timing_quality_threshold_(conf.getParameter("track_time_quality_threshold")) {} + del_ts_had_had_(conf.getParameter("delta_ts_had_had")) {} void GeneralInterpretationAlgo::initialize(const HGCalDDDConstants *hgcons, const hgcal::RecHitTools rhtools, @@ -155,7 +154,6 @@ bool GeneralInterpretationAlgo::timeAndEnergyCompatible(float &total_raw_energy, const Trackster &trackster, const float &tkT, const float &tkTErr, - const float &tkTimeQual, const float &tkBeta, const GlobalPoint &tkMtdPos, bool useMTDTiming) { @@ -167,7 +165,7 @@ bool GeneralInterpretationAlgo::timeAndEnergyCompatible(float &total_raw_energy, // compatible if trackster time is within 3sigma of // track time; compatible if either: no time assigned - // to trackster or track time quality is below threshold + // to trackster or track float tsT = trackster.time(); float tsTErr = trackster.timeError(); @@ -223,21 +221,12 @@ void GeneralInterpretationAlgo::makeCandidates(const Inputs &input, // to look for potential linkages in the appropriate tiles std::vector> trackPColl; // propagated track points and index of track in collection std::vector> tkPropIntColl; // tracks propagated to lastLayerEE - std::vector> tsPropIntColl; // Tracksters in CE-E, propagated to lastLayerEE - std::vector> tsHadPropIntColl; // Tracksters in CE-H, propagated to lastLayerEE trackPColl.reserve(tracks.size()); tkPropIntColl.reserve(tracks.size()); std::array tracksterPropTiles = {}; // all Tracksters, propagated to layer 1 std::array tsPropIntTiles = {}; // all Tracksters, propagated to lastLayerEE - std::array tsHadPropIntTiles = {}; // Tracksters in CE-H, propagated to lastLayerEE - - // linking : trackster is hadronic if its barycenter is in CE-H - auto isHadron = [&](const Trackster &t) -> bool { - auto boundary_z = rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z(); - return (std::abs(t.barycenter().Z()) > boundary_z); - }; if (TICLInterpretationAlgoBase::algo_verbosity_ > VerbosityLevel::Advanced) LogDebug("GeneralInterpretationAlgo") << "------- Geometric Linking ------- \n"; @@ -248,8 +237,6 @@ void GeneralInterpretationAlgo::makeCandidates(const Inputs &input, for (unsigned i = 0; i < tracks.size(); ++i) { if (!maskTracks.at(i)) continue; - const auto &tk = tracks.at(i); - reco::TrackRef trackref = reco::TrackRef(tkH, i); candidateTrackIds.push_back(i); } @@ -306,15 +293,7 @@ void GeneralInterpretationAlgo::makeCandidates(const Inputs &input, tsP = propagateTrackster(t, i, zVal, tsPropIntTiles); tsAllPropInt.emplace_back(tsP); - if (!isHadron(t)) // EM tracksters - tsPropIntColl.emplace_back(tsP, i); - else { // HAD - tsHadPropIntTiles[(t.barycenter().Z() > 0) ? 1 : 0].fill(tsP.Eta(), tsP.Phi(), i); - tsHadPropIntColl.emplace_back(tsP, i); - } } // TS - tsPropIntColl.shrink_to_fit(); - tsHadPropIntColl.shrink_to_fit(); std::vector> tsNearTk(tracks.size()); findTrackstersInWindow( @@ -329,8 +308,6 @@ void GeneralInterpretationAlgo::makeCandidates(const Inputs &input, std::vector> trackstersInTrackIndices; trackstersInTrackIndices.resize(tracks.size()); - resultCandidate.resize(tracks.size(), -1); - std::vector chargedMask(tracksters.size(), true); for (unsigned &i : candidateTrackIds) { if (tsNearTk[i].empty() && tsNearTkAtInt[i].empty()) { // nothing linked to track, make charged hadrons @@ -343,13 +320,11 @@ void GeneralInterpretationAlgo::makeCandidates(const Inputs &input, auto tkRef = reco::TrackRef(tkH, i); float track_time = 0.f; float track_timeErr = 0.f; - float track_timeQual = 0.f; float track_beta = 0.f; GlobalPoint track_MtdPos{0.f, 0.f, 0.f}; if (useMTDTiming) { track_time = (*inputTiming.tkTime_h)[tkRef]; track_timeErr = (*inputTiming.tkTimeErr_h)[tkRef]; - track_timeQual = (*inputTiming.tkTimeQual_h)[tkRef]; track_beta = (*inputTiming.tkBeta_h)[tkRef]; track_MtdPos = (*inputTiming.tkMtdPos_h)[tkRef]; } @@ -360,7 +335,6 @@ void GeneralInterpretationAlgo::makeCandidates(const Inputs &input, tracksters[tsIdx], track_time, track_timeErr, - track_timeQual, track_beta, track_MtdPos, useMTDTiming)) { @@ -374,7 +348,6 @@ void GeneralInterpretationAlgo::makeCandidates(const Inputs &input, tracksters[tsIdx], track_time, track_timeErr, - track_timeQual, track_beta, track_MtdPos, useMTDTiming)) { @@ -412,6 +385,5 @@ void GeneralInterpretationAlgo::fillPSetDescription(edm::ParameterSetDescription desc.add("delta_tk_ts_interface", 0.03); desc.add("delta_ts_em_had", 0.03); desc.add("delta_ts_had_had", 0.03); - desc.add("track_time_quality_threshold", 0.5); TICLInterpretationAlgoBase::fillPSetDescription(desc); } diff --git a/RecoHGCal/TICL/plugins/GeneralInterpretationAlgo.h b/RecoHGCal/TICL/plugins/GeneralInterpretationAlgo.h index 6a0c067b25ebd..6ef3254ba46e9 100644 --- a/RecoHGCal/TICL/plugins/GeneralInterpretationAlgo.h +++ b/RecoHGCal/TICL/plugins/GeneralInterpretationAlgo.h @@ -51,7 +51,6 @@ namespace ticl { const Trackster &trackster, const float &tkTime, const float &tkTimeErr, - const float &tkTimeQual, const float &tkBeta, const GlobalPoint &tkMtdPos, bool useMTDTiming); @@ -63,7 +62,6 @@ namespace ticl { const float del_ts_em_had_; const float del_ts_had_had_; - const float timing_quality_threshold_; const HGCalDDDConstants *hgcons_; std::unique_ptr firstDisk_[2]; diff --git a/RecoHGCal/TICL/plugins/MergedTrackstersProducer.cc b/RecoHGCal/TICL/plugins/MergedTrackstersProducer.cc new file mode 100644 index 0000000000000..dba31c3b6653d --- /dev/null +++ b/RecoHGCal/TICL/plugins/MergedTrackstersProducer.cc @@ -0,0 +1,58 @@ +// Author: Felice Pantaleo, Wahid Redjeb, Aurora Perego (CERN) - felice.pantaleo@cern.ch, wahid.redjeb@cern.ch, aurora.perego@cern.ch +// Date: 12/2023 +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/PluginDescription.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "DataFormats/HGCalReco/interface/Trackster.h" + +using namespace ticl; + +class MergedTrackstersProducer : public edm::stream::EDProducer<> { +public: + explicit MergedTrackstersProducer(const edm::ParameterSet &ps); + ~MergedTrackstersProducer() override{}; + void produce(edm::Event &, const edm::EventSetup &) override; + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + +private: + edm::EDGetTokenT> egamma_tracksters_token_; + + edm::EDGetTokenT> general_tracksters_token_; +}; + +MergedTrackstersProducer::MergedTrackstersProducer(const edm::ParameterSet &ps) + : egamma_tracksters_token_( + consumes>(ps.getParameter("egamma_tracksters"))), + general_tracksters_token_( + consumes>(ps.getParameter("had_tracksters"))) { + produces>(); +} + +void MergedTrackstersProducer::produce(edm::Event &evt, const edm::EventSetup &es) { + auto resultTracksters = std::make_unique>(); + auto const &egamma_tracksters = evt.get(egamma_tracksters_token_); + auto const &had_tracksters = evt.get(general_tracksters_token_); + for (auto const &eg_trackster : egamma_tracksters) { + resultTracksters->push_back(eg_trackster); + } + for (auto const &had_trackster : had_tracksters) { + resultTracksters->push_back(had_trackster); + } + + evt.put(std::move(resultTracksters)); +} + +void MergedTrackstersProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { + edm::ParameterSetDescription desc; + desc.add("egamma_tracksters", edm::InputTag("ticlTrackstersCLUE3DEM")); + desc.add("had_tracksters", edm::InputTag("ticlTrackstersCLUE3DHAD")); + descriptions.add("mergedTrackstersProducer", desc); +} + +DEFINE_FWK_MODULE(MergedTrackstersProducer); diff --git a/RecoHGCal/TICL/plugins/PFTICLProducer.cc b/RecoHGCal/TICL/plugins/PFTICLProducer.cc index a111ac95e2dd0..fbbbc3ca229fd 100644 --- a/RecoHGCal/TICL/plugins/PFTICLProducer.cc +++ b/RecoHGCal/TICL/plugins/PFTICLProducer.cc @@ -167,7 +167,7 @@ void PFTICLProducer::produce(edm::Event& evt, const edm::EventSetup& es) { // Compute weighted average between HGCAL and MTD timing const auto invTimeESqHGC = pow(timeEHGC, -2); const auto invTimeESqMTD = pow(timeEMTD, -2); - timeE = (invTimeESqHGC * invTimeESqMTD) / (invTimeESqHGC + invTimeESqMTD); + timeE = 1.f / (invTimeESqHGC + invTimeESqMTD); time = (timeHGC * invTimeESqHGC + timeMTD * invTimeESqMTD) * timeE; timeE = sqrt(timeE); } else if (timeEMTD > 0) { // Ignore HGCal timing until it will be TOF corrected diff --git a/RecoHGCal/TICL/plugins/PatternRecognitionbyCA.cc b/RecoHGCal/TICL/plugins/PatternRecognitionbyCA.cc index d4cb8d1f3a514..582cf9fe324a5 100644 --- a/RecoHGCal/TICL/plugins/PatternRecognitionbyCA.cc +++ b/RecoHGCal/TICL/plugins/PatternRecognitionbyCA.cc @@ -46,6 +46,7 @@ PatternRecognitionbyCA::PatternRecognitionbyCA(const edm::ParameterSet &c eidMinClusterEnergy_(conf.getParameter("eid_min_cluster_energy")), eidNLayers_(conf.getParameter("eid_n_layers")), eidNClusters_(conf.getParameter("eid_n_clusters")), + computeLocalTime_(conf.getParameter("computeLocalTime")), siblings_maxRSquared_(conf.getParameter>("siblings_maxRSquared")){}; template @@ -182,7 +183,8 @@ void PatternRecognitionbyCA::makeTracksters( ticl::assignPCAtoTracksters(tmpTracksters, input.layerClusters, input.layerClustersTime, - rhtools_.getPositionLayer(rhtools_.lastLayerEE(isHFnose), isHFnose).z()); + rhtools_.getPositionLayer(rhtools_.lastLayerEE(isHFnose), isHFnose).z(), + computeLocalTime_); // run energy regression and ID energyRegressionAndID(input.layerClusters, input.tfSession, tmpTracksters); @@ -243,7 +245,8 @@ void PatternRecognitionbyCA::makeTracksters( ticl::assignPCAtoTracksters(result, input.layerClusters, input.layerClustersTime, - rhtools_.getPositionLayer(rhtools_.lastLayerEE(isHFnose), isHFnose).z()); + rhtools_.getPositionLayer(rhtools_.lastLayerEE(isHFnose), isHFnose).z(), + computeLocalTime_); // run energy regression and ID energyRegressionAndID(input.layerClusters, input.tfSession, result); @@ -509,6 +512,7 @@ void PatternRecognitionbyCA::fillPSetDescription(edm::ParameterSetDescrip iDesc.add("eid_min_cluster_energy", 1.); iDesc.add("eid_n_layers", 50); iDesc.add("eid_n_clusters", 10); + iDesc.add("computeLocalTime", false); iDesc.add>("siblings_maxRSquared", {6e-4, 6e-4, 6e-4}); } diff --git a/RecoHGCal/TICL/plugins/PatternRecognitionbyCA.h b/RecoHGCal/TICL/plugins/PatternRecognitionbyCA.h index 1912520d89138..90bcddf06eabf 100644 --- a/RecoHGCal/TICL/plugins/PatternRecognitionbyCA.h +++ b/RecoHGCal/TICL/plugins/PatternRecognitionbyCA.h @@ -61,6 +61,7 @@ namespace ticl { const float eidMinClusterEnergy_; const int eidNLayers_; const int eidNClusters_; + const bool computeLocalTime_; hgcal::RecHitTools rhtools_; tensorflow::Session* eidSession_; diff --git a/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.cc b/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.cc index baf3d31b31eef..72a35e6216a89 100644 --- a/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.cc +++ b/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.cc @@ -44,7 +44,8 @@ PatternRecognitionbyCLUE3D::PatternRecognitionbyCLUE3D(const edm::Paramet eidOutputNameId_(conf.getParameter("eid_output_name_id")), eidMinClusterEnergy_(conf.getParameter("eid_min_cluster_energy")), eidNLayers_(conf.getParameter("eid_n_layers")), - eidNClusters_(conf.getParameter("eid_n_clusters")){}; + eidNClusters_(conf.getParameter("eid_n_clusters")), + computeLocalTime_(conf.getParameter("computeLocalTime")){}; template void PatternRecognitionbyCLUE3D::dumpTiles(const TILES &tiles) const { @@ -345,7 +346,8 @@ void PatternRecognitionbyCLUE3D::makeTracksters( ticl::assignPCAtoTracksters(result, input.layerClusters, input.layerClustersTime, - rhtools_.getPositionLayer(rhtools_.lastLayerEE(false), false).z()); + rhtools_.getPositionLayer(rhtools_.lastLayerEE(false), false).z(), + computeLocalTime_); // run energy regression and ID energyRegressionAndID(input.layerClusters, input.tfSession, result); @@ -904,6 +906,7 @@ void PatternRecognitionbyCLUE3D::fillPSetDescription(edm::ParameterSetDes iDesc.add("eid_min_cluster_energy", 1.); iDesc.add("eid_n_layers", 50); iDesc.add("eid_n_clusters", 10); + iDesc.add("computeLocalTime", false); } template class ticl::PatternRecognitionbyCLUE3D; diff --git a/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.h b/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.h index 3af7de4e11f75..243cd441732d3 100644 --- a/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.h +++ b/RecoHGCal/TICL/plugins/PatternRecognitionbyCLUE3D.h @@ -140,6 +140,7 @@ namespace ticl { const float eidMinClusterEnergy_; const int eidNLayers_; const int eidNClusters_; + const bool computeLocalTime_; hgcal::RecHitTools rhtools_; tensorflow::Session* eidSession_; diff --git a/RecoHGCal/TICL/plugins/PatternRecognitionbyFastJet.cc b/RecoHGCal/TICL/plugins/PatternRecognitionbyFastJet.cc index 2ffa2209991f0..c0d9fddea086d 100644 --- a/RecoHGCal/TICL/plugins/PatternRecognitionbyFastJet.cc +++ b/RecoHGCal/TICL/plugins/PatternRecognitionbyFastJet.cc @@ -37,7 +37,8 @@ PatternRecognitionbyFastJet::PatternRecognitionbyFastJet(const edm::Param eidOutputNameId_(conf.getParameter("eid_output_name_id")), eidMinClusterEnergy_(conf.getParameter("eid_min_cluster_energy")), eidNLayers_(conf.getParameter("eid_n_layers")), - eidNClusters_(conf.getParameter("eid_n_clusters")){}; + eidNClusters_(conf.getParameter("eid_n_clusters")), + computeLocalTime_(conf.getParameter("computeLocalTime")){}; template void PatternRecognitionbyFastJet::buildJetAndTracksters(std::vector &fjInputs, @@ -144,7 +145,8 @@ void PatternRecognitionbyFastJet::makeTracksters( ticl::assignPCAtoTracksters(result, input.layerClusters, input.layerClustersTime, - rhtools_.getPositionLayer(rhtools_.lastLayerEE(isHFnose), isHFnose).z()); + rhtools_.getPositionLayer(rhtools_.lastLayerEE(isHFnose), isHFnose).z(), + computeLocalTime_); // run energy regression and ID energyRegressionAndID(input.layerClusters, input.tfSession, result); @@ -309,6 +311,7 @@ void PatternRecognitionbyFastJet::fillPSetDescription(edm::ParameterSetDe iDesc.add("eid_min_cluster_energy", 1.); iDesc.add("eid_n_layers", 50); iDesc.add("eid_n_clusters", 10); + iDesc.add("computeLocalTime", false); } template class ticl::PatternRecognitionbyFastJet; diff --git a/RecoHGCal/TICL/plugins/PatternRecognitionbyFastJet.h b/RecoHGCal/TICL/plugins/PatternRecognitionbyFastJet.h index 2524a29921019..2811b54c8e6e4 100644 --- a/RecoHGCal/TICL/plugins/PatternRecognitionbyFastJet.h +++ b/RecoHGCal/TICL/plugins/PatternRecognitionbyFastJet.h @@ -40,6 +40,7 @@ namespace ticl { const float eidMinClusterEnergy_; const int eidNLayers_; const int eidNClusters_; + const bool computeLocalTime_; hgcal::RecHitTools rhtools_; tensorflow::Session* eidSession_; diff --git a/RecoHGCal/TICL/plugins/SimTrackstersProducer.cc b/RecoHGCal/TICL/plugins/SimTrackstersProducer.cc index 1bd563923a0ce..ef9835e594631 100644 --- a/RecoHGCal/TICL/plugins/SimTrackstersProducer.cc +++ b/RecoHGCal/TICL/plugins/SimTrackstersProducer.cc @@ -67,7 +67,7 @@ class SimTrackstersProducer : public edm::stream::EDProducer<> { const float energy, const int pdgId, const int charge, - float time, + const float time, const edm::ProductID seed, const Trackster::IterationIndex iter, std::vector& output_mask, @@ -78,6 +78,7 @@ class SimTrackstersProducer : public edm::stream::EDProducer<> { private: std::string detector_; const bool doNose_ = false; + const bool computeLocalTime_ = false; const edm::EDGetTokenT> clusters_token_; const edm::EDGetTokenT>> clustersTime_token_; const edm::EDGetTokenT> filtered_layerclusters_mask_token_; @@ -107,6 +108,7 @@ DEFINE_FWK_MODULE(SimTrackstersProducer); SimTrackstersProducer::SimTrackstersProducer(const edm::ParameterSet& ps) : detector_(ps.getParameter("detector")), doNose_(detector_ == "HFNose"), + computeLocalTime_(ps.getParameter("computeLocalTime")), clusters_token_(consumes(ps.getParameter("layer_clusters"))), clustersTime_token_(consumes(ps.getParameter("time_layerclusters"))), filtered_layerclusters_mask_token_(consumes(ps.getParameter("filtered_mask"))), @@ -138,6 +140,7 @@ SimTrackstersProducer::SimTrackstersProducer(const edm::ParameterSet& ps) void SimTrackstersProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; desc.add("detector", "HGCAL"); + desc.add("computeLocalTime", "false"); desc.add("layer_clusters", edm::InputTag("hgcalMergeLayerClusters")); desc.add("time_layerclusters", edm::InputTag("hgcalMergeLayerClusters", "timeLayerCluster")); desc.add("filtered_mask", edm::InputTag("filteredLayerClustersSimTracksters", "ticlSimTracksters")); @@ -217,6 +220,7 @@ void SimTrackstersProducer::addTrackster( tmpTrackster.setRegressedEnergy(energy); tmpTrackster.setIteration(iter); tmpTrackster.setSeed(seed, index); + tmpTrackster.setBoundaryTime(time * 1e9); if (add) { result[index] = tmpTrackster; loop_index += 1; @@ -353,11 +357,17 @@ void SimTrackstersProducer::produce(edm::Event& evt, const edm::EventSetup& es) } // TODO: remove time computation from PCA calculation and // store time from boundary position in simTracksters - ticl::assignPCAtoTracksters( - *result, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE(doNose_)).z()); + ticl::assignPCAtoTracksters(*result, + layerClusters, + layerClustersTimes, + rhtools_.getPositionLayer(rhtools_.lastLayerEE(doNose_)).z(), + computeLocalTime_); result->shrink_to_fit(); - ticl::assignPCAtoTracksters( - *result_fromCP, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE(doNose_)).z()); + ticl::assignPCAtoTracksters(*result_fromCP, + layerClusters, + layerClustersTimes, + rhtools_.getPositionLayer(rhtools_.lastLayerEE(doNose_)).z(), + computeLocalTime_); makePUTrackster(inputClusterMask, *output_mask, *resultPU, caloParticles_h.id(), 0); @@ -425,10 +435,6 @@ void SimTrackstersProducer::produce(edm::Event& evt, const edm::EventSetup& es) auto& cand = (*result_ticlCandidates)[cp_index]; cand.addTrackster(edm::Ptr(simTracksters_h, i)); - if (trackIndex != -1 and (trackIndex < 0 or trackIndex >= (long int)recoTracks.size())) { - } - cand.setTime((*result_fromCP)[cp_index].time()); - cand.setTimeError(0); if (trackIndex != -1 && caloparticles[cp_index].charge() != 0) cand.setTrackPtr(edm::Ptr(recoTracks_h, trackIndex)); toKeep.push_back(cp_index); @@ -451,6 +457,9 @@ void SimTrackstersProducer::produce(edm::Event& evt, const edm::EventSetup& es) float rawEnergy = 0.f; float regressedEnergy = 0.f; + cand.setTime(simVertices[cp.g4Tracks()[0].vertIndex()].position().t() * pow(10, 9)); + cand.setTimeError(0); + for (const auto& trackster : cand.tracksters()) { rawEnergy += trackster->raw_energy(); regressedEnergy += trackster->regressed_energy(); diff --git a/RecoHGCal/TICL/plugins/TICLCandidateProducer.cc b/RecoHGCal/TICL/plugins/TICLCandidateProducer.cc index 836dc2812d189..442a8351fef63 100644 --- a/RecoHGCal/TICL/plugins/TICLCandidateProducer.cc +++ b/RecoHGCal/TICL/plugins/TICLCandidateProducer.cc @@ -15,6 +15,7 @@ #include "FWCore/Framework/interface/ConsumesCollector.h" #include "DataFormats/Common/interface/OrphanHandle.h" +#include "DataFormats/BeamSpot/interface/BeamSpot.h" #include "DataFormats/CaloRecHit/interface/CaloCluster.h" #include "DataFormats/HGCalReco/interface/Common.h" #include "DataFormats/HGCalReco/interface/TICLLayerTile.h" @@ -42,6 +43,10 @@ #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" #include "TrackingTools/GeomPropagators/interface/Propagator.h" #include "TrackingTools/Records/interface/TrackingComponentsRecord.h" +#include "TrackingTools/TrajectoryState/interface/TrajectoryStateClosestToBeamLine.h" +#include "TrackingTools/PatternTools/interface/Trajectory.h" +#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" +#include "TrackingTools/PatternTools/interface/TSCBLBuilderWithPropagator.h" #include "MagneticField/Engine/interface/MagneticField.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" @@ -73,6 +78,13 @@ class TICLCandidateProducer : public edm::stream::EDProducer<> { const tensorflow::Session *, std::vector &result) const; + template + void assignTimeToCandidates(std::vector &resultCandidates, + edm::Handle> track_h, + TICLInterpretationAlgoBase::TrackTimingInformation inputTiming, + TrajTrackAssociationCollection trjtrks, + F func) const; + std::unique_ptr> generalInterpretationAlgo_; std::vector>> egamma_tracksters_tokens_; std::vector>>> egamma_tracksterlinks_tokens_; @@ -87,11 +99,11 @@ class TICLCandidateProducer : public edm::stream::EDProducer<> { const edm::EDGetTokenT> tracks_token_; edm::EDGetTokenT> tracks_time_token_; - edm::EDGetTokenT> tracks_time_quality_token_; edm::EDGetTokenT> tracks_time_err_token_; edm::EDGetTokenT> tracks_beta_token_; edm::EDGetTokenT> tracks_path_length_token_; edm::EDGetTokenT> tracks_glob_pos_token_; + const edm::EDGetTokenT trajTrackAssToken_; const edm::EDGetTokenT> muons_token_; const bool useMTDTiming_; @@ -101,6 +113,7 @@ class TICLCandidateProducer : public edm::stream::EDProducer<> { const std::string detector_; const std::string propName_; const edm::ESGetToken propagator_token_; + const edm::EDGetTokenT bsToken_; const std::string tfDnnLabel_; const edm::ESGetToken tfDnnToken_; @@ -120,6 +133,9 @@ class TICLCandidateProducer : public edm::stream::EDProducer<> { const StringCutObjectSelector cutTk_; static constexpr int eidNFeatures_ = 3; edm::ESGetToken hdc_token_; + edm::ESHandle bfield_; + edm::ESHandle propagator_; + static constexpr float c_light_ = CLHEP::c_light * CLHEP::ns / CLHEP::cm; }; TICLCandidateProducer::TICLCandidateProducer(const edm::ParameterSet &ps) @@ -127,6 +143,7 @@ TICLCandidateProducer::TICLCandidateProducer(const edm::ParameterSet &ps) clustersTime_token_( consumes>>(ps.getParameter("layer_clustersTime"))), tracks_token_(consumes>(ps.getParameter("tracks"))), + trajTrackAssToken_(consumes(ps.getParameter("trjtrkAss"))), muons_token_(consumes>(ps.getParameter("muons"))), useMTDTiming_(ps.getParameter("useMTDTiming")), geometry_token_(esConsumes()), @@ -135,6 +152,7 @@ TICLCandidateProducer::TICLCandidateProducer(const edm::ParameterSet &ps) propName_(ps.getParameter("propagator")), propagator_token_( esConsumes(edm::ESInputTag("", propName_))), + bsToken_(consumes(ps.getParameter("beamspot"))), tfDnnLabel_(ps.getParameter("tfDnnLabel")), tfDnnToken_(esConsumes(edm::ESInputTag("", tfDnnLabel_))), tfSession_(nullptr), @@ -182,7 +200,6 @@ TICLCandidateProducer::TICLCandidateProducer(const edm::ParameterSet &ps) hdc_token_ = esConsumes( edm::ESInputTag("", detectorName_)); tracks_time_token_ = consumes>(ps.getParameter("tracksTime")); - tracks_time_quality_token_ = consumes>(ps.getParameter("tracksTimeQual")); tracks_time_err_token_ = consumes>(ps.getParameter("tracksTimeErr")); tracks_beta_token_ = consumes>(ps.getParameter("tracksBeta")); tracks_path_length_token_ = consumes>(ps.getParameter("tracksPathLength")); @@ -212,16 +229,16 @@ void TICLCandidateProducer::beginRun(edm::Run const &iEvent, edm::EventSetup con edm::ESHandle geom = es.getHandle(geometry_token_); rhtools_.setGeometry(*geom); - edm::ESHandle bfield = es.getHandle(bfield_token_); - edm::ESHandle propagator = es.getHandle(propagator_token_); - generalInterpretationAlgo_->initialize(hgcons_, rhtools_, bfield, propagator); + bfield_ = es.getHandle(bfield_token_); + propagator_ = es.getHandle(propagator_token_); + generalInterpretationAlgo_->initialize(hgcons_, rhtools_, bfield_, propagator_); }; void filterTracks(edm::Handle> tkH, const std::vector &muons, const StringCutObjectSelector cutTk_, const float tkEnergyCut_, - std::vector maskTracks) { + std::vector &maskTracks) { auto const &tracks = *tkH; for (unsigned i = 0; i < tracks.size(); ++i) { const auto &tk = tracks[i]; @@ -231,18 +248,18 @@ void filterTracks(edm::Handle> tkH, int muId = PFMuonAlgo::muAssocToTrack(trackref, muons); if (!cutTk_((tk)) or muId != -1) { - maskTracks[i] = 0; + maskTracks[i] = false; continue; } // don't consider tracks below 2 GeV for linking if (std::sqrt(tk.p() * tk.p() + ticl::mpion2) < tkEnergyCut_) { - maskTracks[i] = 0; + maskTracks[i] = false; continue; } // record tracks that can be used to make a ticlcandidate - maskTracks[i] = 1; + maskTracks[i] = true; } } @@ -257,22 +274,28 @@ void TICLCandidateProducer::produce(edm::Event &evt, const edm::EventSetup &es) auto const &muons = evt.get(muons_token_); edm::Handle> tracks_h; + const auto &trjtrks = evt.get(trajTrackAssToken_); edm::Handle> trackTime_h; edm::Handle> trackTimeErr_h; - edm::Handle> trackTimeQual_h; edm::Handle> trackTimeBeta_h; + edm::Handle> trackPathToMTD_h; edm::Handle> trackTimeGlobalPosition_h; evt.getByToken(tracks_token_, tracks_h); const auto &tracks = *tracks_h; if (useMTDTiming_) { evt.getByToken(tracks_time_token_, trackTime_h); evt.getByToken(tracks_time_err_token_, trackTimeErr_h); - evt.getByToken(tracks_time_quality_token_, trackTimeQual_h); - evt.getByToken(tracks_time_err_token_, trackTimeBeta_h); + evt.getByToken(tracks_beta_token_, trackTimeBeta_h); + evt.getByToken(tracks_path_length_token_, trackPathToMTD_h); evt.getByToken(tracks_glob_pos_token_, trackTimeGlobalPosition_h); } + const auto &bs = evt.get(bsToken_); + + auto const bFieldProd = bfield_.product(); + const Propagator *propagator = propagator_.product(); + // loop over the original_masks_tokens_ and get the original masks collections and multiply them // to get the global mask std::vector original_global_mask(layerClusters.size(), 1.f); @@ -322,10 +345,10 @@ void TICLCandidateProducer::produce(edm::Event &evt, const edm::EventSetup &es) maskTracks); const typename TICLInterpretationAlgoBase::TrackTimingInformation inputTiming( - trackTime_h, trackTimeErr_h, trackTimeQual_h, trackTimeQual_h, trackTimeGlobalPosition_h); + trackTime_h, trackTimeErr_h, trackTimeBeta_h, trackPathToMTD_h, trackTimeGlobalPosition_h); auto resultCandidates = std::make_unique>(); - std::vector trackstersInTrackIndices(tracks.size()); + std::vector trackstersInTrackIndices(tracks.size(), -1); //TODO //egammaInterpretationAlg_->makecandidates(inputGSF, inputTiming, *resultTrackstersMerged, trackstersInGSFTrackIndices) @@ -334,21 +357,21 @@ void TICLCandidateProducer::produce(edm::Event &evt, const edm::EventSetup &es) generalInterpretationAlgo_->makeCandidates(input, inputTiming, *resultTracksters, trackstersInTrackIndices); assignPCAtoTracksters( - *resultTracksters, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z()); + *resultTracksters, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z(), true); energyRegressionAndID(layerClusters, tfSession_, *resultTracksters); - std::vector maskTracksters(resultTracksters->size(), 1); + std::vector maskTracksters(resultTracksters->size(), true); edm::OrphanHandle> resultTracksters_h = evt.put(std::move(resultTracksters)); //create ChargedCandidates for (size_t iTrack = 0; iTrack < tracks.size(); iTrack++) { auto const tracksterId = trackstersInTrackIndices[iTrack]; auto trackPtr = edm::Ptr(tracks_h, iTrack); - if (tracksterId != -1) { + if (tracksterId != -1 and !maskTracksters.empty()) { auto tracksterPtr = edm::Ptr(resultTracksters_h, tracksterId); TICLCandidate chargedCandidate(trackPtr, tracksterPtr); resultCandidates->push_back(chargedCandidate); - maskTracksters[tracksterId] = 0; + maskTracksters[tracksterId] = false; } else { //charged candidates track only edm::Ptr tracksterPtr; @@ -360,13 +383,67 @@ void TICLCandidateProducer::produce(edm::Event &evt, const edm::EventSetup &es) //Neutral Candidate for (size_t iTrackster = 0; iTrackster < maskTracksters.size(); iTrackster++) { if (maskTracksters[iTrackster]) { - edm::Ptr tracksterPtr(resultTracksters_h, 0); //= edm::Ptr(resultTracksters_h, iTrackster); + edm::Ptr tracksterPtr(resultTracksters_h, iTrackster); edm::Ptr trackPtr; TICLCandidate neutralCandidate(trackPtr, tracksterPtr); resultCandidates->push_back(neutralCandidate); } } + auto getPathLength = + [&](const reco::Track track, float zVal, const Trajectory &traj, TrajectoryStateClosestToBeamLine &tscbl) { + TrajectoryStateOnSurface stateForProjectionToBeamLineOnSurface = + traj.closestMeasurement(GlobalPoint(bs.x0(), bs.y0(), bs.z0())).updatedState(); + + if (!stateForProjectionToBeamLineOnSurface.isValid()) { + edm::LogError("CannotPropagateToBeamLine") + << "the state on the closest measurement is not valid. skipping track."; + return 0.f; + } + const FreeTrajectoryState &stateForProjectionToBeamLine = *stateForProjectionToBeamLineOnSurface.freeState(); + + TSCBLBuilderWithPropagator tscblBuilder(*propagator); + tscbl = tscblBuilder(stateForProjectionToBeamLine, bs); + + if (tscbl.isValid()) { + auto const &tscblPCA = tscbl.trackStateAtPCA(); + auto const &innSurface = traj.direction() == alongMomentum ? traj.firstMeasurement().updatedState().surface() + : traj.lastMeasurement().updatedState().surface(); + auto const &extSurface = traj.direction() == alongMomentum ? traj.lastMeasurement().updatedState().surface() + : traj.firstMeasurement().updatedState().surface(); + float pathlength = propagator->propagateWithPath(tscblPCA, innSurface).second; + + if (pathlength) { + const auto &fts_inn = trajectoryStateTransform::innerFreeState((track), bFieldProd); + const auto &t_inn_out = propagator->propagateWithPath(fts_inn, extSurface); + + if (t_inn_out.first.isValid()) { + pathlength += t_inn_out.second; + + std::pair rMinMax = hgcons_->rangeR(zVal, true); + + int iSide = int(track.eta() > 0); + float zSide = (iSide == 0) ? (-1. * zVal) : zVal; + const auto &disk = std::make_unique( + Disk::build(Disk::PositionType(0, 0, zSide), + Disk::RotationType(), + SimpleDiskBounds(rMinMax.first, rMinMax.second, zSide - 0.5, zSide + 0.5)) + .get()); + const auto &fts_out = trajectoryStateTransform::outerFreeState((track), bFieldProd); + const auto &tsos = propagator->propagateWithPath(fts_out, disk->surface()); + + if (tsos.first.isValid()) { + pathlength += tsos.second; + return pathlength; + } + } + } + } + return 0.f; + }; + + assignTimeToCandidates(*resultCandidates, tracks_h, inputTiming, trjtrks, getPathLength); + evt.put(std::move(resultCandidates)); } @@ -496,6 +573,68 @@ void TICLCandidateProducer::energyRegressionAndID(const std::vector +void TICLCandidateProducer::assignTimeToCandidates( + std::vector &resultCandidates, + edm::Handle> track_h, + TICLInterpretationAlgoBase::TrackTimingInformation inputTiming, + TrajTrackAssociationCollection trjtrks, + F func) const { + for (auto &cand : resultCandidates) { + float beta = 1; + float time = 0.f; + float invTimeErr = 0.f; + + // if (not cand.tracksters().size()) + // continue; + for (const auto &tr : cand.tracksters()) { + if (tr->timeError() > 0) { + const auto invTimeESq = pow(tr->timeError(), -2); + const auto x = tr->barycenter().X(); + const auto y = tr->barycenter().Y(); + const auto z = tr->barycenter().Z(); + auto path = std::sqrt(x * x + y * y + z * z); + if (cand.trackPtr().get() != nullptr) { + const auto &trackIndex = cand.trackPtr().get() - (edm::Ptr(track_h, 0)).get(); + const auto &trackRef = edm::Ref>(track_h, trackIndex); + if (useMTDTiming_ and (*inputTiming.tkTimeErr_h)[trackRef] > 0) { + const auto &trackMtdPos = (*inputTiming.tkMtdPos_h); + const auto xMtd = trackMtdPos[trackRef].x(); + const auto yMtd = trackMtdPos[trackRef].y(); + const auto zMtd = trackMtdPos[trackRef].z(); + + beta = (*inputTiming.tkBeta_h)[trackRef]; + path = std::sqrt((x - xMtd) * (x - xMtd) + (y - yMtd) * (y - yMtd) + (z - zMtd) * (z - zMtd)) + + (*inputTiming.tkPath_h)[trackRef]; + } else { + const auto &trackIndex = cand.trackPtr().get() - (edm::Ptr(track_h, 0)).get(); + for (const auto &trj : trjtrks) { + if (trj.val != edm::Ref>(track_h, trackIndex)) + continue; + const Trajectory &traj = *trj.key; + TrajectoryStateClosestToBeamLine tscbl; + + float pathLength = func(*(cand.trackPtr().get()), z, traj, tscbl); + if (pathLength) { + path = pathLength; + break; + } + } + } + } + time += (tr->time() - path / (beta * c_light_)) * invTimeESq; + invTimeErr += invTimeESq; + } + } + if (invTimeErr > 0) { + cand.setTime(time / invTimeErr); + // FIXME_ set a liminf of 0.02 ns on the ts error (based on residuals) + auto timeErr = sqrt(1.f / invTimeErr) > 0.02 ? sqrt(1.f / invTimeErr) : 0.02; + cand.setTimeError(timeErr); + } + } +} + void TICLCandidateProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { edm::ParameterSetDescription desc; edm::ParameterSetDescription interpretationDesc; @@ -510,15 +649,16 @@ void TICLCandidateProducer::fillDescriptions(edm::ConfigurationDescriptions &des desc.add("layer_clusters", edm::InputTag("hgcalMergeLayerClusters")); desc.add("layer_clustersTime", edm::InputTag("hgcalMergeLayerClusters", "timeLayerCluster")); desc.add("tracks", edm::InputTag("generalTracks")); - desc.add("tracksTime", edm::InputTag("tofPID:t0")); - desc.add("tracksTimeQual", edm::InputTag("mtdTrackQualityMVA:mtdQualMVA")); - desc.add("tracksTimeErr", edm::InputTag("tofPID:sigmat0")); + desc.add("trjtrkAss", edm::InputTag("generalTracks")); + desc.add("tracksTime", edm::InputTag("trackExtenderWithMTD:generalTracktmtd")); + desc.add("tracksTimeErr", edm::InputTag("trackExtenderWithMTD:generalTracksigmatmtd")); desc.add("tracksBeta", edm::InputTag("trackExtenderWithMTD:generalTrackBeta")); desc.add("tracksGlobalPosition", edm::InputTag("trackExtenderWithMTD:generalTrackmtdpos")); desc.add("tracksPathLength", edm::InputTag("trackExtenderWithMTD:generalTrackPathLength")); desc.add("muons", edm::InputTag("muons1stStep")); desc.add("detector", "HGCAL"); desc.add("propagator", "PropagatorWithMaterial"); + desc.add("beamspot", edm::InputTag("offlineBeamSpot")); desc.add("useMTDTiming", true); desc.add("tfDnnLabel", "tracksterSelectionTf"); desc.add("eid_input_name", "input"); diff --git a/RecoHGCal/TICL/plugins/TICLDumper.cc b/RecoHGCal/TICL/plugins/TICLDumper.cc index c265d2fb2280e..fe60e71d2ea8d 100644 --- a/RecoHGCal/TICL/plugins/TICLDumper.cc +++ b/RecoHGCal/TICL/plugins/TICLDumper.cc @@ -87,6 +87,10 @@ class TICLDumper : public edm::one::EDAnalyzer> tracks_time_token_; const edm::EDGetTokenT> tracks_time_quality_token_; const edm::EDGetTokenT> tracks_time_err_token_; + const edm::EDGetTokenT> tracks_beta_token_; + const edm::EDGetTokenT> tracks_time_mtd_token_; + const edm::EDGetTokenT> tracks_time_mtd_err_token_; + const edm::EDGetTokenT> tracks_pos_mtd_token_; const edm::EDGetTokenT> hgcaltracks_x_token_; const edm::EDGetTokenT> hgcaltracks_y_token_; const edm::EDGetTokenT> hgcaltracks_z_token_; @@ -186,6 +190,7 @@ class TICLDumper : public edm::one::EDAnalyzer> trackster_vertices_multiplicity; std::vector stsSC_trackster_time; + std::vector stsSC_trackster_timeBoundary; std::vector stsSC_trackster_timeError; std::vector stsSC_trackster_regressed_energy; std::vector stsSC_trackster_regressed_pt; @@ -238,6 +243,7 @@ class TICLDumper : public edm::one::EDAnalyzer> stsSC_trackster_vertices_correctedEnergyUncertainty; std::vector> stsSC_trackster_vertices_multiplicity; std::vector stsCP_trackster_time; + std::vector stsCP_trackster_timeBoundary; std::vector stsCP_trackster_timeError; std::vector stsCP_trackster_regressed_energy; std::vector stsCP_trackster_regressed_pt; @@ -299,9 +305,8 @@ class TICLDumper : public edm::one::EDAnalyzer simTICLCandidate_boundaryPx; std::vector simTICLCandidate_boundaryPy; std::vector simTICLCandidate_boundaryPz; - std::vector simTICLCandidate_trackTime; - std::vector simTICLCandidate_trackBeta; std::vector simTICLCandidate_caloParticleMass; + std::vector simTICLCandidate_time; std::vector simTICLCandidate_pdgId; std::vector simTICLCandidate_charge; std::vector simTICLCandidate_track_in_candidate; @@ -423,6 +428,10 @@ class TICLDumper : public edm::one::EDAnalyzer track_time; std::vector track_time_quality; std::vector track_time_err; + std::vector track_beta; + std::vector track_time_mtd; + std::vector track_time_mtd_err; + std::vector track_pos_mtd; std::vector track_nhits; TTree* trackster_tree_; @@ -475,6 +484,7 @@ void TICLDumper::clearVariables() { trackster_vertices_multiplicity.clear(); stsSC_trackster_time.clear(); + stsSC_trackster_timeBoundary.clear(); stsSC_trackster_timeError.clear(); stsSC_trackster_regressed_energy.clear(); stsSC_trackster_regressed_pt.clear(); @@ -528,6 +538,7 @@ void TICLDumper::clearVariables() { stsSC_trackster_vertices_multiplicity.clear(); stsCP_trackster_time.clear(); + stsCP_trackster_timeBoundary.clear(); stsCP_trackster_timeError.clear(); stsCP_trackster_regressed_energy.clear(); stsCP_trackster_regressed_pt.clear(); @@ -583,8 +594,7 @@ void TICLDumper::clearVariables() { simTICLCandidate_boundaryPx.clear(); simTICLCandidate_boundaryPy.clear(); simTICLCandidate_boundaryPz.clear(); - simTICLCandidate_trackTime.clear(); - simTICLCandidate_trackBeta.clear(); + simTICLCandidate_time.clear(); simTICLCandidate_caloParticleMass.clear(); simTICLCandidate_pdgId.clear(); simTICLCandidate_charge.clear(); @@ -714,6 +724,10 @@ void TICLDumper::clearVariables() { track_time.clear(); track_time_quality.clear(); track_time_err.clear(); + track_beta.clear(); + track_time_mtd.clear(); + track_time_mtd_err.clear(); + track_pos_mtd.clear(); track_nhits.clear(); }; @@ -725,6 +739,10 @@ TICLDumper::TICLDumper(const edm::ParameterSet& ps) tracks_time_token_(consumes>(ps.getParameter("tracksTime"))), tracks_time_quality_token_(consumes>(ps.getParameter("tracksTimeQual"))), tracks_time_err_token_(consumes>(ps.getParameter("tracksTimeErr"))), + tracks_beta_token_(consumes>(ps.getParameter("tracksBeta"))), + tracks_time_mtd_token_(consumes>(ps.getParameter("tracksTimeMtd"))), + tracks_time_mtd_err_token_(consumes>(ps.getParameter("tracksTimeMtdErr"))), + tracks_pos_mtd_token_(consumes>(ps.getParameter("tracksPosMtd"))), tracksters_merged_token_( consumes>(ps.getParameter("trackstersmerged"))), clustersTime_token_( @@ -947,6 +965,7 @@ void TICLDumper::beginJob() { simtrackstersSC_tree_->Branch("event", &ev_event_); simtrackstersSC_tree_->Branch("NTracksters", &stsSC_ntracksters_); simtrackstersSC_tree_->Branch("time", &stsSC_trackster_time); + simtrackstersSC_tree_->Branch("timeBoundary", &stsSC_trackster_timeBoundary); simtrackstersSC_tree_->Branch("timeError", &stsSC_trackster_timeError); simtrackstersSC_tree_->Branch("regressed_energy", &stsSC_trackster_regressed_energy); simtrackstersSC_tree_->Branch("regressed_pt", &stsSC_trackster_regressed_pt); @@ -1006,6 +1025,7 @@ void TICLDumper::beginJob() { simtrackstersCP_tree_->Branch("event", &ev_event_); simtrackstersCP_tree_->Branch("NTracksters", &stsCP_ntracksters_); simtrackstersCP_tree_->Branch("time", &stsCP_trackster_time); + simtrackstersCP_tree_->Branch("timeBoundary", &stsCP_trackster_timeBoundary); simtrackstersCP_tree_->Branch("timeError", &stsCP_trackster_timeError); simtrackstersCP_tree_->Branch("regressed_energy", &stsCP_trackster_regressed_energy); simtrackstersCP_tree_->Branch("regressed_pt", &stsCP_trackster_regressed_pt); @@ -1064,6 +1084,11 @@ void TICLDumper::beginJob() { tracks_tree_ = fs->make("tracks", "Tracks"); tracks_tree_->Branch("event", &ev_event_); tracks_tree_->Branch("track_id", &track_id); + tracks_tree_->Branch("track_hgcal_x", &track_hgcal_x); + tracks_tree_->Branch("track_hgcal_y", &track_hgcal_y); + tracks_tree_->Branch("track_hgcal_z", &track_hgcal_z); + tracks_tree_->Branch("track_hgcal_eta", &track_hgcal_eta); + tracks_tree_->Branch("track_hgcal_phi", &track_hgcal_phi); tracks_tree_->Branch("track_hgcal_pt", &track_hgcal_pt); tracks_tree_->Branch("track_pt", &track_pt); tracks_tree_->Branch("track_missing_outer_hits", &track_missing_outer_hits); @@ -1072,6 +1097,10 @@ void TICLDumper::beginJob() { tracks_tree_->Branch("track_time", &track_time); tracks_tree_->Branch("track_time_quality", &track_time_quality); tracks_tree_->Branch("track_time_err", &track_time_err); + tracks_tree_->Branch("track_beta", &track_beta); + tracks_tree_->Branch("track_time_mtd", &track_time_mtd); + tracks_tree_->Branch("track_time_mtd_err", &track_time_mtd_err); + tracks_tree_->Branch("track_pos_mtd", &track_pos_mtd); tracks_tree_->Branch("track_nhits", &track_nhits); } @@ -1086,8 +1115,7 @@ void TICLDumper::beginJob() { simTICLCandidate_tree->Branch("simTICLCandidate_boundaryPx", &simTICLCandidate_boundaryPx); simTICLCandidate_tree->Branch("simTICLCandidate_boundaryPy", &simTICLCandidate_boundaryPy); simTICLCandidate_tree->Branch("simTICLCandidate_boundaryPz", &simTICLCandidate_boundaryPz); - simTICLCandidate_tree->Branch("simTICLCandidate_trackTime", &simTICLCandidate_trackTime); - simTICLCandidate_tree->Branch("simTICLCandidate_trackBeta", &simTICLCandidate_trackBeta); + simTICLCandidate_tree->Branch("simTICLCandidate_time", &simTICLCandidate_time); simTICLCandidate_tree->Branch("simTICLCandidate_caloParticleMass", &simTICLCandidate_caloParticleMass); simTICLCandidate_tree->Branch("simTICLCandidate_pdgId", &simTICLCandidate_pdgId); simTICLCandidate_tree->Branch("simTICLCandidate_charge", &simTICLCandidate_charge); @@ -1169,10 +1197,26 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup) event.getByToken(tracks_time_err_token_, trackTimeErr_h); const auto& trackTimeErr = *trackTimeErr_h; + edm::Handle> trackBeta_h; + event.getByToken(tracks_beta_token_, trackBeta_h); + const auto& trackBeta = *trackBeta_h; + edm::Handle> trackTimeQual_h; event.getByToken(tracks_time_quality_token_, trackTimeQual_h); const auto& trackTimeQual = *trackTimeQual_h; + edm::Handle> trackTimeMtd_h; + event.getByToken(tracks_time_mtd_token_, trackTimeMtd_h); + const auto& trackTimeMtd = *trackTimeMtd_h; + + edm::Handle> trackTimeMtdErr_h; + event.getByToken(tracks_time_mtd_err_token_, trackTimeMtdErr_h); + const auto& trackTimeMtdErr = *trackTimeMtdErr_h; + + edm::Handle> trackPosMtd_h; + event.getByToken(tracks_pos_mtd_token_, trackPosMtd_h); + const auto& trackPosMtd = *trackPosMtd_h; + //Tracksters merged edm::Handle> tracksters_merged_h; event.getByToken(tracksters_merged_token_, tracksters_merged_h); @@ -1329,6 +1373,7 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup) ++trackster_iterator) { //per-trackster analysis stsSC_trackster_time.push_back(trackster_iterator->time()); + stsSC_trackster_timeBoundary.push_back(trackster_iterator->boundaryTime()); stsSC_trackster_timeError.push_back(trackster_iterator->timeError()); stsSC_trackster_regressed_energy.push_back(trackster_iterator->regressed_energy()); stsSC_trackster_raw_energy.push_back(trackster_iterator->raw_energy()); @@ -1474,6 +1519,7 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup) ++trackster_iterator) { //per-trackster analysis stsCP_trackster_time.push_back(trackster_iterator->time()); + stsCP_trackster_timeBoundary.push_back(trackster_iterator->boundaryTime()); stsCP_trackster_timeError.push_back(trackster_iterator->timeError()); stsCP_trackster_regressed_energy.push_back(trackster_iterator->regressed_energy()); stsCP_trackster_raw_energy.push_back(trackster_iterator->raw_energy()); @@ -1620,6 +1666,7 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup) simTICLCandidate_regressed_energy.push_back(cand.p4().energy()); simTICLCandidate_pdgId.push_back(cand.pdgId()); simTICLCandidate_charge.push_back(cand.charge()); + simTICLCandidate_time.push_back(cand.time()); std::vector tmpIdxVec; for (auto const& simTS : cand.tracksters()) { auto trackster_idx = simTS.get() - (edm::Ptr(simTrackstersSC_h, 0)).get(); @@ -1646,8 +1693,6 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup) simTICLCandidate_boundaryPx.push_back(globalMom.x()); simTICLCandidate_boundaryPy.push_back(globalMom.y()); simTICLCandidate_boundaryPz.push_back(globalMom.z()); - simTICLCandidate_trackTime.push_back(track.t0()); - simTICLCandidate_trackBeta.push_back(track.beta()); } else { simTICLCandidate_boundaryX.push_back(-999); simTICLCandidate_boundaryY.push_back(-999); @@ -1655,8 +1700,6 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup) simTICLCandidate_boundaryPx.push_back(-999); simTICLCandidate_boundaryPy.push_back(-999); simTICLCandidate_boundaryPz.push_back(-999); - simTICLCandidate_trackTime.push_back(-999); - simTICLCandidate_trackBeta.push_back(-999); } } else { simTICLCandidate_boundaryX.push_back(-999); @@ -1665,8 +1708,6 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup) simTICLCandidate_boundaryPx.push_back(-999); simTICLCandidate_boundaryPy.push_back(-999); simTICLCandidate_boundaryPz.push_back(-999); - simTICLCandidate_trackTime.push_back(-999); - simTICLCandidate_trackBeta.push_back(-999); } } @@ -1717,7 +1758,7 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup) auto trackster_ptrs = candidate.tracksters(); auto track_ptr = candidate.trackPtr(); for (const auto& ts_ptr : trackster_ptrs) { - auto ts_idx = ts_ptr.get() - (edm::Ptr(tracksters_handle, 0)).get(); + auto ts_idx = ts_ptr.get() - (edm::Ptr(tracksters_merged_h, 0)).get(); tracksters_in_candidate[i].push_back(ts_idx); } if (track_ptr.isNull()) @@ -2021,6 +2062,10 @@ void TICLDumper::analyze(const edm::Event& event, const edm::EventSetup& setup) track_time.push_back(trackTime[trackref]); track_time_quality.push_back(trackTimeQual[trackref]); track_time_err.push_back(trackTimeErr[trackref]); + track_beta.push_back(trackBeta[trackref]); + track_time_mtd.push_back(trackTimeMtd[trackref]); + track_time_mtd_err.push_back(trackTimeMtdErr[trackref]); + track_pos_mtd.push_back(trackPosMtd[trackref]); track_nhits.push_back(tracks[i].recHitsSize()); } } @@ -2057,6 +2102,10 @@ void TICLDumper::fillDescriptions(edm::ConfigurationDescriptions& descriptions) desc.add("tracksTime", edm::InputTag("tofPID:t0")); desc.add("tracksTimeQual", edm::InputTag("mtdTrackQualityMVA:mtdQualMVA")); desc.add("tracksTimeErr", edm::InputTag("tofPID:sigmat0")); + desc.add("tracksBeta", edm::InputTag("trackExtenderWithMTD:generalTrackBeta")); + desc.add("tracksTimeMtd", edm::InputTag("trackExtenderWithMTD:generalTracktmtd")); + desc.add("tracksTimeMtdErr", edm::InputTag("trackExtenderWithMTD:generalTracksigmatmtd")); + desc.add("tracksPosMtd", edm::InputTag("trackExtenderWithMTD:generalTrackmtdpos")); desc.add("trackstersmerged", edm::InputTag("ticlTrackstersMerge")); desc.add("simtrackstersSC", edm::InputTag("ticlSimTracksters")); desc.add("simtrackstersCP", edm::InputTag("ticlSimTracksters", "fromCPs")); diff --git a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc index 064b7bcbef051..92f9e6622ba16 100644 --- a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc +++ b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.cc @@ -165,7 +165,7 @@ void TracksterLinkingbySkeletons::linkTracksters( findSkeletonPoints(0.1f, trackster.raw_energy(), trackster.vertices(), rhtools_, layerClusters); auto const lastLayerZ = findSkeletonPoints(0.9f, trackster.raw_energy(), trackster.vertices(), rhtools_, layerClusters); - auto const t0_p1 = trackster.barycenter(); + auto const &t0_p1 = trackster.barycenter(); auto const t0_p0 = intersectLineWithSurface(firstLayerZ, t0_p1, trackster.eigenvectors(0)); auto const t0_p2 = intersectLineWithSurface(lastLayerZ, t0_p1, trackster.eigenvectors(0)); std::array skeleton{{t0_p0, t0_p1, t0_p2}}; diff --git a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h index defbebb67856b..d62903b9e13ba 100644 --- a/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h +++ b/RecoHGCal/TICL/plugins/TracksterLinkingbySkeletons.h @@ -24,7 +24,7 @@ namespace ticl { public: TracksterLinkingbySkeletons(const edm::ParameterSet& conf, edm::ConsumesCollector iC); - virtual ~TracksterLinkingbySkeletons() {} + ~TracksterLinkingbySkeletons() override {} void linkTracksters(const Inputs& input, std::vector& resultTracksters, diff --git a/RecoHGCal/TICL/plugins/TracksterLinksProducer.cc b/RecoHGCal/TICL/plugins/TracksterLinksProducer.cc index 72ef4d7623a05..aec98ce98684d 100644 --- a/RecoHGCal/TICL/plugins/TracksterLinksProducer.cc +++ b/RecoHGCal/TICL/plugins/TracksterLinksProducer.cc @@ -206,7 +206,7 @@ void TracksterLinksProducer::produce(edm::Event &evt, const edm::EventSetup &es) } assignPCAtoTracksters( - *resultTracksters, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z()); + *resultTracksters, layerClusters, layerClustersTimes, rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z(), true); evt.put(std::move(linkedResultTracksters)); evt.put(std::move(resultMask)); diff --git a/RecoHGCal/TICL/plugins/TrackstersPCA.cc b/RecoHGCal/TICL/plugins/TrackstersPCA.cc index 378c8598b24c8..0f58339e19e2d 100644 --- a/RecoHGCal/TICL/plugins/TrackstersPCA.cc +++ b/RecoHGCal/TICL/plugins/TrackstersPCA.cc @@ -1,8 +1,6 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "DataFormats/Common/interface/ValueMap.h" #include "RecoLocalCalo/HGCalRecProducers/interface/ComputeClusterTime.h" -#include "RecoHGCal/TICL/interface/commons.h" - #include "TrackstersPCA.h" #include @@ -15,6 +13,7 @@ void ticl::assignPCAtoTracksters(std::vector &tracksters, const std::vector &layerClusters, const edm::ValueMap> &layerClustersTime, double z_limit_em, + bool computeLocalTime, bool energyWeight) { LogDebug("TrackstersPCA_Eigen") << "------- Eigen -------" << std::endl; @@ -45,10 +44,6 @@ void ticl::assignPCAtoTracksters(std::vector &tracksters, sigmasEigen << 0., 0., 0.; Eigen::Matrix3d covM = Eigen::Matrix3d::Zero(); - std::vector times; - std::vector timeErrors; - std::set usedLC; - for (size_t i = 0; i < N; ++i) { auto fraction = 1.f / trackster.vertex_multiplicity(i); trackster.addToRawEnergy(layerClusters[trackster.vertices(i)].energy() * fraction); @@ -61,22 +56,11 @@ void ticl::assignPCAtoTracksters(std::vector &tracksters, fillPoint(layerClusters[trackster.vertices(i)], weight); for (size_t j = 0; j < 3; ++j) barycenter[j] += point[j]; - - // Add timing from layerClusters not already used - if ((usedLC.insert(trackster.vertices(i))).second) { - float timeE = layerClustersTime.get(trackster.vertices(i)).second; - if (timeE > 0.f) { - times.push_back(layerClustersTime.get(trackster.vertices(i)).first); - timeErrors.push_back(1. / pow(timeE, 2)); - } - } } + if (energyWeight && trackster.raw_energy()) barycenter /= trackster.raw_energy(); - hgcalsimclustertime::ComputeClusterTime timeEstimator; - std::pair timeTrackster = timeEstimator.fixSizeHighestDensity(times, timeErrors); - // Compute the Covariance Matrix and the sum of the squared weights, used // to compute the correct normalization. // The barycenter has to be known. @@ -92,7 +76,15 @@ void ticl::assignPCAtoTracksters(std::vector &tracksters, covM(y, x) = covM(x, y); } } - covM *= 1. / (1. - weights2_sum); + covM *= 1.f / (1.f - weights2_sum); + + std::pair timeTrackster; + if (computeLocalTime) + timeTrackster = ticl::computeLocalTracksterTime(trackster, layerClusters, layerClustersTime, barycenter, N); + else + timeTrackster = ticl::computeTracksterTime(trackster, layerClustersTime, N); + + trackster.setTimeAndError(timeTrackster.first, timeTrackster.second); // Perform the actual decomposition Eigen::SelfAdjointEigenSolver::RealVectorType eigenvalues_fromEigen; @@ -116,12 +108,12 @@ void ticl::assignPCAtoTracksters(std::vector &tracksters, (layerClusters[trackster.vertices(i)].energy() / trackster.vertex_multiplicity(i)) / trackster.raw_energy(); sigmasEigen += weight * (point_transformed.cwiseAbs2()); } - sigmas /= (1. - weights2_sum); - sigmasEigen /= (1. - weights2_sum); + sigmas /= (1.f - weights2_sum); + sigmasEigen /= (1.f - weights2_sum); // Add trackster attributes - trackster.setBarycenter(ticl::Vector(barycenter)); - trackster.setTimeAndError(timeTrackster.first, timeTrackster.second); + trackster.setBarycenter(ticl::Trackster::Vector(barycenter)); + trackster.fillPCAVariables( eigenvalues_fromEigen, eigenvectors_fromEigen, sigmas, sigmasEigen, 3, ticl::Trackster::PCAOrdering::ascending); @@ -151,3 +143,92 @@ void ticl::assignPCAtoTracksters(std::vector &tracksters, LogDebug("TrackstersPCA") << "covM: \n" << covM << std::endl; } } + +std::pair ticl::computeLocalTracksterTime(const Trackster &trackster, + const std::vector &layerClusters, + const edm::ValueMap> &layerClustersTime, + const Eigen::Vector3d &barycenter, + size_t N) { + float tracksterTime = 0.; + float tracksterTimeErr = 0.; + std::set usedLC; + + auto project_lc_to_pca = [](const std::vector &point, const std::vector &segment_end) { + double dot_product = 0.0; + double segment_dot = 0.0; + + for (int i = 0; i < 3; ++i) { + dot_product += point[i] * segment_end[i]; + segment_dot += segment_end[i] * segment_end[i]; + } + + double projection = 0.0; + if (segment_dot != 0.0) { + projection = dot_product / segment_dot; + } + + std::vector closest_point(3); + for (int i = 0; i < 3; ++i) { + closest_point[i] = projection * segment_end[i]; + } + + double distance = 0.0; + for (int i = 0; i < 3; ++i) { + distance += std::pow(point[i] - closest_point[i], 2); + } + + return std::sqrt(distance); + }; + + constexpr double c = 29.9792458; // cm/ns + for (size_t i = 0; i < N; ++i) { + // Add timing from layerClusters not already used + if ((usedLC.insert(trackster.vertices(i))).second) { + float timeE = layerClustersTime.get(trackster.vertices(i)).second; + if (timeE > 0.f) { + float time = layerClustersTime.get(trackster.vertices(i)).first; + timeE = 1.f / pow(timeE, 2); + float x = layerClusters[trackster.vertices(i)].x(); + float y = layerClusters[trackster.vertices(i)].y(); + float z = layerClusters[trackster.vertices(i)].z(); + + if (project_lc_to_pca({x, y, z}, {barycenter[0], barycenter[1], barycenter[2]}) < 3) { // set MR to 3 + float deltaT = 1.f / c * + std::sqrt(((barycenter[2] / z - 1.f) * x) * ((barycenter[2] / z - 1.f) * x) + + ((barycenter[2] / z - 1.f) * y) * ((barycenter[2] / z - 1.f) * y) + + (barycenter[2] - z) * (barycenter[2] - z)); + time = std::abs(barycenter[2]) < std::abs(z) ? time - deltaT : time + deltaT; + + tracksterTime += time * timeE; + tracksterTimeErr += timeE; + } + } + } + } + if (tracksterTimeErr > 0.f) + return {tracksterTime / tracksterTimeErr, 1.f / std::sqrt(tracksterTimeErr)}; + else + return {-99.f, -1.f}; +} + +std::pair ticl::computeTracksterTime(const Trackster &trackster, + const edm::ValueMap> &layerClustersTime, + size_t N) { + std::vector times; + std::vector timeErrors; + std::set usedLC; + + for (size_t i = 0; i < N; ++i) { + // Add timing from layerClusters not already used + if ((usedLC.insert(trackster.vertices(i))).second) { + float timeE = layerClustersTime.get(trackster.vertices(i)).second; + if (timeE > 0.f) { + times.push_back(layerClustersTime.get(trackster.vertices(i)).first); + timeErrors.push_back(1.f / pow(timeE, 2)); + } + } + } + + hgcalsimclustertime::ComputeClusterTime timeEstimator; + return timeEstimator.fixSizeHighestDensity(times, timeErrors); +} diff --git a/RecoHGCal/TICL/plugins/TrackstersPCA.h b/RecoHGCal/TICL/plugins/TrackstersPCA.h index ed172f8a27931..2b6de0bb409e9 100644 --- a/RecoHGCal/TICL/plugins/TrackstersPCA.h +++ b/RecoHGCal/TICL/plugins/TrackstersPCA.h @@ -10,6 +10,15 @@ namespace ticl { const std::vector &, const edm::ValueMap> &, double, + bool computeLocalTime = false, bool energyWeight = true); -} + std::pair computeLocalTracksterTime(const Trackster &trackster, + const std::vector &layerClusters, + const edm::ValueMap> &layerClustersTime, + const Eigen::Vector3d &barycenter, + size_t N); + std::pair computeTracksterTime(const Trackster &trackster, + const edm::ValueMap> &layerClustersTime, + size_t N); +} // namespace ticl #endif diff --git a/RecoHGCal/TICL/python/customiseForTICLv5_cff.py b/RecoHGCal/TICL/python/customiseForTICLv5_cff.py index 4f55f544ee641..4d3f635901905 100644 --- a/RecoHGCal/TICL/python/customiseForTICLv5_cff.py +++ b/RecoHGCal/TICL/python/customiseForTICLv5_cff.py @@ -14,12 +14,50 @@ from RecoHGCal.TICL.ticlCandidateProducer_cfi import ticlCandidateProducer as _ticlCandidateProducer from RecoHGCal.Configuration.RecoHGCal_EventContent_cff import customiseForTICLv5EventContent from RecoHGCal.TICL.iterativeTICL_cff import ticlIterLabels, ticlIterLabelsMerge +from RecoHGCal.TICL.ticlDumper_cfi import ticlDumper +from RecoHGCal.TICL.mergedTrackstersProducer_cfi import mergedTrackstersProducer as _mergedTrackstersProducer from SimCalorimetry.HGCalAssociatorProducers.TSToSimTSAssociation_cfi import tracksterSimTracksterAssociationLinkingbyCLUE3D as _tracksterSimTracksterAssociationLinkingbyCLUE3D from SimCalorimetry.HGCalAssociatorProducers.TSToSimTSAssociation_cfi import tracksterSimTracksterAssociationPRbyCLUE3D as _tracksterSimTracksterAssociationPRbyCLUE3D from Validation.HGCalValidation.HGCalValidator_cff import hgcalValidatorv5 +from RecoLocalCalo.HGCalRecProducers.HGCalUncalibRecHit_cfi import HGCalUncalibRecHit +from RecoHGCal.TICL.SimTracksters_cff import ticlSimTracksters +from RecoHGCal.TICL.FastJetStep_cff import ticlTrackstersFastJet +from RecoHGCal.TICL.EMStep_cff import ticlTrackstersEM, ticlTrackstersHFNoseEM +from RecoHGCal.TICL.TrkStep_cff import ticlTrackstersTrk, ticlTrackstersHFNoseTrk +from RecoHGCal.TICL.MIPStep_cff import ticlTrackstersMIP, ticlTrackstersHFNoseMIP +from RecoHGCal.TICL.HADStep_cff import ticlTrackstersHAD, ticlTrackstersHFNoseHAD +from RecoHGCal.TICL.CLUE3DEM_cff import ticlTrackstersCLUE3DEM +from RecoHGCal.TICL.CLUE3DHAD_cff import ticlTrackstersCLUE3DHAD +from RecoHGCal.TICL.CLUE3DHighStep_cff import ticlTrackstersCLUE3DHigh +from RecoHGCal.TICL.TrkEMStep_cff import ticlTrackstersTrkEM, filteredLayerClustersHFNoseTrkEM -def customiseForTICLv5(process): + +def customiseForTICLv5(process, enableDumper = False): + + process.HGCalUncalibRecHit.computeLocalTime = cms.bool(True) + process.ticlSimTracksters.computeLocalTime = cms.bool(True) + + process.ticlTrackstersFastJet.pluginPatternRecognitionByFastJet.computeLocalTime = cms.bool(True) + + process.ticlTrackstersEM.pluginPatternRecognitionByCA.computeLocalTime = cms.bool(True) + process.ticlTrackstersHFNoseEM.pluginPatternRecognitionByCA.computeLocalTime = cms.bool(True) + + process.ticlTrackstersTrk.pluginPatternRecognitionByCA.computeLocalTime = cms.bool(True) + process.ticlTrackstersHFNoseTrk.pluginPatternRecognitionByCA.computeLocalTime = cms.bool(True) + + process.ticlTrackstersMIP.pluginPatternRecognitionByCA.computeLocalTime = cms.bool(True) + process.ticlTrackstersHFNoseMIP.pluginPatternRecognitionByCA.computeLocalTime = cms.bool(True) + + process.ticlTrackstersHAD.pluginPatternRecognitionByCA.computeLocalTime = cms.bool(True) + process.ticlTrackstersHFNoseHAD.pluginPatternRecognitionByCA.computeLocalTime = cms.bool(True) + + process.ticlTrackstersCLUE3DHAD.pluginPatternRecognitionByCLUE3D.computeLocalTime = cms.bool(True) + process.ticlTrackstersCLUE3DEM.pluginPatternRecognitionByCLUE3D.computeLocalTime = cms.bool(True) + process.ticlTrackstersCLUE3DHigh.pluginPatternRecognitionByCLUE3D.computeLocalTime = cms.bool(True) + + process.ticlTrackstersTrkEM.pluginPatternRecognitionByCA.computeLocalTime = cms.bool(True) + process.ticlTrackstersHFNoseTrkEM.pluginPatternRecognitionByCA.computeLocalTime = cms.bool(True) process.ticlLayerTileTask = cms.Task(ticlLayerTileProducer) @@ -47,7 +85,14 @@ def customiseForTICLv5(process): label_tst = cms.InputTag("ticlTrackstersCLUE3DHAD") ) - + process.mergedTrackstersProducer = _mergedTrackstersProducer.clone() + + process.tracksterSimTracksterAssociationLinkingbyCLUE3D = _tracksterSimTracksterAssociationLinkingbyCLUE3D.clone( + label_tst = cms.InputTag("mergedTrackstersProducer") + ) + process.tracksterSimTracksterAssociationPRbyCLUE3D = _tracksterSimTracksterAssociationPRbyCLUE3D.clone( + label_tst = cms.InputTag("mergedTrackstersProducer") + ) process.iterTICLTask = cms.Task(process.ticlLayerTileTask, process.ticlIterationsTask, process.ticlTracksterLinksTask, @@ -62,11 +107,12 @@ def customiseForTICLv5(process): process.tracksterSimTracksterAssociationPRPU.label_tst = cms.InputTag("ticlTracksterLinks") process.mergeTICLTask = cms.Task() process.pfTICL.ticlCandidateSrc = cms.InputTag("ticlCandidate") - process.hgcalAssociators = cms.Task(process.lcAssocByEnergyScoreProducer, process.layerClusterCaloParticleAssociationProducer, + process.hgcalAssociators = cms.Task(process.mergedTrackstersProducer, process.lcAssocByEnergyScoreProducer, process.layerClusterCaloParticleAssociationProducer, process.scAssocByEnergyScoreProducer, process.layerClusterSimClusterAssociationProducer, process.lcSimTSAssocByEnergyScoreProducer, process.layerClusterSimTracksterAssociationProducer, process.simTsAssocByEnergyScoreProducer, process.simTracksterHitLCAssociatorByEnergyScoreProducer, process.tracksterSimTracksterAssociationLinking, process.tracksterSimTracksterAssociationPR, + process.tracksterSimTracksterAssociationLinkingbyCLUE3D, process.tracksterSimTracksterAssociationPRbyCLUE3D, process.tracksterSimTracksterAssociationLinkingbyCLUE3DEM, process.tracksterSimTracksterAssociationPRbyCLUE3DEM, process.tracksterSimTracksterAssociationLinkingbyCLUE3DHAD, process.tracksterSimTracksterAssociationPRbyCLUE3DHAD, process.tracksterSimTracksterAssociationLinkingPU, process.tracksterSimTracksterAssociationPRPU @@ -74,12 +120,33 @@ def customiseForTICLv5(process): process.hgcalValidatorv5 = hgcalValidatorv5.clone( ticlTrackstersMerge = cms.InputTag("ticlCandidate"), - trackstersclue3d = cms.InputTag("ticlTracksterLinks") + trackstersclue3d = cms.InputTag("mergedTrackstersProducer") ) process.hgcalValidatorSequence = cms.Sequence(process.hgcalValidatorv5) process.hgcalValidation = cms.Sequence(process.hgcalSimHitValidationEE+process.hgcalSimHitValidationHEF+process.hgcalSimHitValidationHEB+process.hgcalDigiValidationEE+process.hgcalDigiValidationHEF+process.hgcalDigiValidationHEB+process.hgcalRecHitValidationEE+process.hgcalRecHitValidationHEF+process.hgcalRecHitValidationHEB+process.hgcalHitValidationSequence+process.hgcalValidatorSequence+process.hgcalTiclPFValidation+process.hgcalPFJetValidation) process.globalValidationHGCal = cms.Sequence(process.hgcalValidation) process.validation_step9 = cms.EndPath(process.globalValidationHGCal) + if(enableDumper): + process.ticlDumper = ticlDumper.clone( + saveLCs=True, + saveCLUE3DTracksters=True, + saveTrackstersMerged=True, + saveSimTrackstersSC=True, + saveSimTrackstersCP=True, + saveTICLCandidate=True, + saveSimTICLCandidate=True, + saveTracks=True, + saveAssociations=True, + trackstersclue3d = cms.InputTag('mergedTrackstersProducer'), + ticlcandidates = cms.InputTag("ticlCandidate"), + trackstersmerged = cms.InputTag("ticlCandidate") + ) + process.TFileService = cms.Service("TFileService", + fileName=cms.string("histo.root") + ) + process.FEVTDEBUGHLToutput_step = cms.EndPath( + process.FEVTDEBUGHLToutput + process.ticlDumper) + process = customiseForTICLv5EventContent(process) diff --git a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h index ef9460644eb0d..6bff0e40d6a70 100644 --- a/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h +++ b/RecoLocalCalo/HGCalRecAlgos/interface/HGCalUncalibRecHitRecWeightsAlgo.h @@ -52,7 +52,7 @@ class HGCalUncalibRecHitRecWeightsAlgo { } /// Compute HGCUncalibratedRecHit from DataFrame - virtual HGCUncalibratedRecHit makeRecHit(const C& dataFrame) { + virtual HGCUncalibratedRecHit makeRecHit(const C& dataFrame, const bool computeLocalTime) { double amplitude_(-1.), pedestal_(-1.), jitter_(-99.), chi2_(-1.); uint32_t flag = 0; @@ -84,7 +84,8 @@ class HGCalUncalibRecHitRecWeightsAlgo { if (sample.getToAValid()) { const auto& dist2center = geom_ ? geom_->getPosition(dataFrame.id()).mag() : 0; - jitter_ = double(sample.toa()) * toaLSBToNS_ - dist2center / c_cm_ns - tofDelay_; + jitter_ = computeLocalTime ? double(sample.toa()) * toaLSBToNS_ - tofDelay_ + : double(sample.toa()) * toaLSBToNS_ - dist2center / c_cm_ns - tofDelay_; } int thickness = (ddd_ != nullptr) ? ddd_->waferType(dataFrame.id(), false) : 0; diff --git a/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerBaseClass.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerBaseClass.h index ba695de9e76a9..a1d19a74f6151 100644 --- a/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerBaseClass.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerBaseClass.h @@ -16,7 +16,7 @@ namespace edm { // change in the future. class HGCalUncalibRecHitWorkerBaseClass { public: - HGCalUncalibRecHitWorkerBaseClass(const edm::ParameterSet& ps, edm::ConsumesCollector iC) {} + HGCalUncalibRecHitWorkerBaseClass(const edm::ParameterSet& ps, edm::ConsumesCollector iC, bool localTime) {} virtual ~HGCalUncalibRecHitWorkerBaseClass() {} // run HGC-EE things @@ -38,6 +38,8 @@ class HGCalUncalibRecHitWorkerBaseClass { virtual bool runHGCHFNose(const edm::ESHandle& geom, const HGCalDigiCollection& digis, HGChfnoseUncalibratedRecHitCollection& result) = 0; + + bool computeLocalTime_ = false; }; #endif diff --git a/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerFactory.h b/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerFactory.h index da212b45757c5..5f3ed6f781e3b 100644 --- a/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerFactory.h +++ b/RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerFactory.h @@ -3,7 +3,8 @@ #include "FWCore/PluginManager/interface/PluginFactory.h" #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerBaseClass.h" -typedef edmplugin::PluginFactory +typedef edmplugin::PluginFactory HGCalUncalibRecHitWorkerFactory; #endif diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.cc index 4de1603e8eca4..304634cb3d2c3 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.cc @@ -23,7 +23,7 @@ HGCalUncalibRecHitProducer::HGCalUncalibRecHitProducer(const edm::ParameterSet& hebHitCollection_(ps.getParameter("HGCHEBhitCollection")), hfnoseHitCollection_(ps.getParameter("HGCHFNosehitCollection")), worker_{HGCalUncalibRecHitWorkerFactory::get()->create( - ps.getParameter("algo"), ps, consumesCollector())} { + ps.getParameter("algo"), ps, consumesCollector(), ps.getParameter("computeLocalTime"))} { produces(eeHitCollection_); produces(hefHitCollection_); produces(hebHitCollection_); @@ -69,6 +69,86 @@ void HGCalUncalibRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& evt.put(std::move(hfnoseUncalibRechits), hfnoseHitCollection_); } +void HGCalUncalibRecHitProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + // HGCalUncalibRecHit + edm::ParameterSetDescription desc; + desc.add("HGCEEdigiCollection", edm::InputTag("hgcalDigis", "EE")); + desc.add("HGCEEhitCollection", "HGCEEUncalibRecHits"); + desc.add("HGCHEFdigiCollection", edm::InputTag("hgcalDigis", "HEfront")); + desc.add("HGCHEFhitCollection", "HGCHEFUncalibRecHits"); + desc.add("HGCHEBdigiCollection", edm::InputTag("hgcalDigis", "HEback")); + desc.add("HGCHEBhitCollection", "HGCHEBUncalibRecHits"); + desc.add("HGCHFNosedigiCollection", edm::InputTag("hfnoseDigis", "HFNose")); + desc.add("HGCHFNosehitCollection", "HGCHFNoseUncalibRecHits"); + edm::ParameterSetDescription HGCEEConfigPSet; + HGCEEConfigPSet.add("isSiFE", true); + HGCEEConfigPSet.add("adcNbits", 10); + HGCEEConfigPSet.add("adcSaturation", 100); + HGCEEConfigPSet.add("tdcNbits", 12); + HGCEEConfigPSet.add("tdcSaturation", 10000); + HGCEEConfigPSet.add("tdcOnset", 60); + HGCEEConfigPSet.add("toaLSB_ns", 0.0244); + HGCEEConfigPSet.add("tofDelay", -9); + HGCEEConfigPSet.add>("fCPerMIP", + { + 1.25, + 2.57, + 3.88, + }); + desc.add("HGCEEConfig", HGCEEConfigPSet); + edm::ParameterSetDescription HGCHEFConfigPSet; + HGCHEFConfigPSet.add("isSiFE", true); + HGCHEFConfigPSet.add("adcNbits", 10); + HGCHEFConfigPSet.add("adcSaturation", 100); + HGCHEFConfigPSet.add("tdcNbits", 12); + HGCHEFConfigPSet.add("tdcSaturation", 10000); + HGCHEFConfigPSet.add("tdcOnset", 60); + HGCHEFConfigPSet.add("toaLSB_ns", 0.0244); + HGCHEFConfigPSet.add("tofDelay", -11); + HGCHEFConfigPSet.add>("fCPerMIP", + { + 1.25, + 2.57, + 3.88, + }); + desc.add("HGCHEFConfig", HGCHEFConfigPSet); + edm::ParameterSetDescription HGCHEBConfigPSet; + HGCHEBConfigPSet.add("isSiFE", true); + HGCHEBConfigPSet.add("adcNbits", 10); + HGCHEBConfigPSet.add("adcSaturation", 68.75); + HGCHEBConfigPSet.add("tdcNbits", 12); + HGCHEBConfigPSet.add("tdcSaturation", 1000); + HGCHEBConfigPSet.add("tdcOnset", 55); + HGCHEBConfigPSet.add("toaLSB_ns", 0.0244); + HGCHEBConfigPSet.add("tofDelay", -14); + HGCHEBConfigPSet.add>("fCPerMIP", + { + 1.0, + 1.0, + 1.0, + }); + desc.add("HGCHEBConfig", HGCHEBConfigPSet); + edm::ParameterSetDescription HGCHFNoseConfigPSet; + HGCHFNoseConfigPSet.add("isSiFE", false); + HGCHFNoseConfigPSet.add("adcNbits", 10); + HGCHFNoseConfigPSet.add("adcSaturation", 100); + HGCHFNoseConfigPSet.add("tdcNbits", 12); + HGCHFNoseConfigPSet.add("tdcSaturation", 10000); + HGCHFNoseConfigPSet.add("tdcOnset", 60); + HGCHFNoseConfigPSet.add("toaLSB_ns", 0.0244); + HGCHFNoseConfigPSet.add("tofDelay", -33); + HGCHFNoseConfigPSet.add>("fCPerMIP", + { + 1.25, + 2.57, + 3.88, + }); + desc.add("HGCHFNoseConfig", HGCHFNoseConfigPSet); + desc.add("algo", "HGCalUncalibRecHitWorkerWeights"); + desc.add("computeLocalTime", false); + descriptions.add("HGCalUncalibRecHitProducer", desc); +} + #include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(HGCalUncalibRecHitProducer); diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.h b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.h index 132a7dac48e0d..39991d1af95bc 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.h +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitProducer.h @@ -5,6 +5,8 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "DataFormats/HGCDigi/interface/HGCDataFrame.h" @@ -15,6 +17,7 @@ class HGCalUncalibRecHitProducer : public edm::stream::EDProducer<> { explicit HGCalUncalibRecHitProducer(const edm::ParameterSet& ps); ~HGCalUncalibRecHitProducer() override; void produce(edm::Event& evt, const edm::EventSetup& es) override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: const edm::EDGetTokenT eeDigiCollection_; // collection of HGCEE digis diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc index ea635c3b738c0..954d48ffdfa20 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.cc @@ -59,8 +59,10 @@ void configureIt(const edm::ParameterSet& conf, HGCalUncalibRecHitRecWeightsAlgo maker.set_tofDelay(conf.getParameter("tofDelay")); } -HGCalUncalibRecHitWorkerWeights::HGCalUncalibRecHitWorkerWeights(const edm::ParameterSet& ps, edm::ConsumesCollector iC) - : HGCalUncalibRecHitWorkerBaseClass(ps, iC) { +HGCalUncalibRecHitWorkerWeights::HGCalUncalibRecHitWorkerWeights(const edm::ParameterSet& ps, + edm::ConsumesCollector iC, + bool useTime) + : HGCalUncalibRecHitWorkerBaseClass(ps, iC, useTime) { const edm::ParameterSet& ee_cfg = ps.getParameterSet("HGCEEConfig"); const edm::ParameterSet& hef_cfg = ps.getParameterSet("HGCHEFConfig"); const edm::ParameterSet& heb_cfg = ps.getParameterSet("HGCHEBConfig"); @@ -69,6 +71,7 @@ HGCalUncalibRecHitWorkerWeights::HGCalUncalibRecHitWorkerWeights(const edm::Para configureIt(hef_cfg, uncalibMaker_hef_); configureIt(heb_cfg, uncalibMaker_heb_); configureIt(hfnose_cfg, uncalibMaker_hfnose_); + computeLocalTime_ = useTime; } bool HGCalUncalibRecHitWorkerWeights::run(const edm::ESHandle& geom, @@ -78,7 +81,7 @@ bool HGCalUncalibRecHitWorkerWeights::run(const edm::ESHandle& ge uncalibMaker.setGeometry(geom); result.reserve(result.size() + digis.size()); for (const auto& digi : digis) - result.push_back(uncalibMaker.makeRecHit(digi)); + result.push_back(uncalibMaker.makeRecHit(digi, computeLocalTime_)); return true; } diff --git a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.h b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.h index 9375dba97f09f..4473c4e49f0a3 100644 --- a/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.h +++ b/RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.h @@ -24,7 +24,7 @@ namespace edm { class HGCalUncalibRecHitWorkerWeights : public HGCalUncalibRecHitWorkerBaseClass { public: - HGCalUncalibRecHitWorkerWeights(const edm::ParameterSet&, edm::ConsumesCollector iC); + HGCalUncalibRecHitWorkerWeights(const edm::ParameterSet&, edm::ConsumesCollector iC, bool useTime); ~HGCalUncalibRecHitWorkerWeights() override{}; bool runHGCEE(const edm::ESHandle& geom, diff --git a/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py b/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py index c5546d21b420a..8174709580a25 100644 --- a/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py +++ b/RecoLocalCalo/HGCalRecProducers/python/HGCalUncalibRecHit_cfi.py @@ -1,21 +1,13 @@ import FWCore.ParameterSet.Config as cms +from RecoLocalCalo.HGCalRecProducers.HGCalUncalibRecHitProducer_cfi import HGCalUncalibRecHitProducer from SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi import hgceeDigitizer, hgchefrontDigitizer, hgchebackDigitizer, hfnoseDigitizer fCPerMIP_mpv = cms.vdouble(1.25,2.57,3.88) #120um, 200um, 300um fCPerMIP_mean = cms.vdouble(2.06,3.43,5.15) #120um, 200um, 300um # HGCAL producer of rechits starting from digis -HGCalUncalibRecHit = cms.EDProducer( - "HGCalUncalibRecHitProducer", - HGCEEdigiCollection = cms.InputTag('hgcalDigis:EE'), - HGCEEhitCollection = cms.string('HGCEEUncalibRecHits'), - HGCHEFdigiCollection = cms.InputTag('hgcalDigis:HEfront'), - HGCHEFhitCollection = cms.string('HGCHEFUncalibRecHits'), - HGCHEBdigiCollection = cms.InputTag('hgcalDigis:HEback'), - HGCHEBhitCollection = cms.string('HGCHEBUncalibRecHits'), - HGCHFNosedigiCollection = cms.InputTag('hfnoseDigis:HFNose'), - HGCHFNosehitCollection = cms.string('HGCHFNoseUncalibRecHits'), +HGCalUncalibRecHit = HGCalUncalibRecHitProducer.clone( HGCEEConfig = cms.PSet( isSiFE = cms.bool(True), @@ -71,9 +63,7 @@ toaLSB_ns = hfnoseDigitizer.digiCfg.feCfg.toaLSB_ns, tofDelay = hfnoseDigitizer.tofDelay, fCPerMIP = fCPerMIP_mpv - ), - - algo = cms.string("HGCalUncalibRecHitWorkerWeights") + ) ) from Configuration.Eras.Modifier_phase2_hgcalV10_cff import phase2_hgcalV10 diff --git a/Validation/HGCalValidation/interface/HGCalValidator.h b/Validation/HGCalValidation/interface/HGCalValidator.h index f2c8901c4bca9..8101ca43e8152 100644 --- a/Validation/HGCalValidation/interface/HGCalValidator.h +++ b/Validation/HGCalValidation/interface/HGCalValidator.h @@ -77,7 +77,7 @@ class HGCalValidator : public DQMGlobalEDAnalyzer { std::string label_TS_, label_TSToCPLinking_, label_TSToSTSPR_; std::vector label_clustersmask; const bool doCandidatesPlots_; - edm::InputTag label_candidates_; + std::string label_candidates_; const edm::FileInPath cummatbudinxo_; std::vector> labelToken; diff --git a/Validation/HGCalValidation/plugins/HGCalValidator.cc b/Validation/HGCalValidation/plugins/HGCalValidator.cc index 9cd9dc27ebdc6..052f6cd415cbb 100644 --- a/Validation/HGCalValidation/plugins/HGCalValidator.cc +++ b/Validation/HGCalValidation/plugins/HGCalValidator.cc @@ -31,7 +31,7 @@ HGCalValidator::HGCalValidator(const edm::ParameterSet& pset) label_TSToSTSPR_(pset.getParameter("label_TSToSTSPR")), label_clustersmask(pset.getParameter>("LayerClustersInputMask")), doCandidatesPlots_(pset.getUntrackedParameter("doCandidatesPlots")), - label_candidates_(pset.getParameter("ticlCandidates")), + label_candidates_(pset.getParameter("ticlCandidates")), cummatbudinxo_(pset.getParameter("cummatbudinxo")) { //In this way we can easily generalize to associations between other objects also. const edm::InputTag& label_cp_effic_tag = pset.getParameter("label_cp_effic"); @@ -248,8 +248,8 @@ void HGCalValidator::bookHistograms(DQMStore::IBooker& ibook, // Booking histograms concerning TICL candidates if (doCandidatesPlots_) { ibook.cd(); - ibook.setCurrentFolder(dirName_ + label_candidates_.label()); - candidateVal.bookCandidatesHistos(ibook, dirName_ + label_candidates_.label()); + ibook.setCurrentFolder(dirName_ + label_candidates_); + candidateVal.bookCandidatesHistos(ibook, dirName_ + label_candidates_); } } diff --git a/Validation/HGCalValidation/python/HGCalValidator_cfi.py b/Validation/HGCalValidation/python/HGCalValidator_cfi.py index 391818e0b5615..12e4f2d7184a3 100644 --- a/Validation/HGCalValidation/python/HGCalValidator_cfi.py +++ b/Validation/HGCalValidation/python/HGCalValidator_cfi.py @@ -138,7 +138,7 @@ label_TSToSTSPR = cms.string("TSToSTS_patternRecognition"), #candidates plots doCandidatesPlots = cms.untracked.bool(True), - ticlCandidates = cms.InputTag("ticlCandidate"), + ticlCandidates = cms.string("ticlCandidate"), ticlTrackstersMerge = cms.InputTag("ticlTrackstersMerge"), simTiclCandidates = cms.InputTag("ticlSimTracksters"),