diff --git a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc index a6d5bc0329e39..732ec0febc758 100644 --- a/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc +++ b/CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLWorker.cc @@ -128,7 +128,7 @@ class SiPixelLorentzAnglePCLWorker : public DQMEDAnalyzer { // template stuff edm::ESWatcher watchSiPixelTemplateRcd_; const SiPixelTemplateDBObject* templateDBobject_; - std::vector thePixelTemp_; + const std::vector* thePixelTemp_ = nullptr; LorentzAngleAnalysisTypeEnum analysisType_; std::string folder_; @@ -195,6 +195,7 @@ class SiPixelLorentzAnglePCLWorker : public DQMEDAnalyzer { edm::ESGetToken geomEsToken_; edm::ESGetToken topoEsToken_; edm::ESGetToken siPixelTemplateEsToken_; + edm::ESGetToken, SiPixelTemplateDBObjectESProducerRcd> siPixelTemplateStoreEsToken_; edm::ESGetToken topoPerEventEsToken_; edm::ESGetToken geomPerEventEsToken_; edm::ESGetToken magneticFieldToken_; @@ -223,6 +224,7 @@ SiPixelLorentzAnglePCLWorker::SiPixelLorentzAnglePCLWorker(const edm::ParameterS geomEsToken_(esConsumes()), topoEsToken_(esConsumes()), siPixelTemplateEsToken_(esConsumes()), + siPixelTemplateStoreEsToken_(esConsumes()), topoPerEventEsToken_(esConsumes()), geomPerEventEsToken_(esConsumes()), magneticFieldToken_(esConsumes()) { @@ -467,7 +469,7 @@ void SiPixelLorentzAnglePCLWorker::analyze(edm::Event const& iEvent, edm::EventS if (notInPCL_) { // fill the template from the store (from dqmBeginRun) - SiPixelTemplate theTemplate(thePixelTemp_); + SiPixelTemplate theTemplate(*thePixelTemp_); float locBx = (cotbeta < 0.) ? -1 : 1.; float locBz = (cotalpha < 0.) ? -locBx : locBx; @@ -639,7 +641,7 @@ void SiPixelLorentzAnglePCLWorker::analyze(edm::Event const& iEvent, edm::EventS if (notInPCL_) { // fill the template from the store (from dqmBeginRun) - SiPixelTemplate theTemplate(thePixelTemp_); + SiPixelTemplate theTemplate(*thePixelTemp_); float locBx = (cotbeta < 0.) ? -1 : 1.; float locBz = (cotalpha < 0.) ? -locBx : locBx; @@ -730,11 +732,7 @@ void SiPixelLorentzAnglePCLWorker::dqmBeginRun(edm::Run const& run, edm::EventSe // Initialize 1D templates if (watchSiPixelTemplateRcd_.check(iSetup)) { templateDBobject_ = &iSetup.getData(siPixelTemplateEsToken_); - if (!SiPixelTemplate::pushfile(*templateDBobject_, thePixelTemp_)) { - edm::LogError("SiPixelLorentzAnglePCLWorker") - << "Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " - << (*templateDBobject_).version(); - } + thePixelTemp_ = &iSetup.getData(siPixelTemplateStoreEsToken_); } } diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_cff.py index a03ef70f2e36d..9a0358f88c3af 100644 --- a/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_cff.py +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngleMCS_cff.py @@ -26,6 +26,7 @@ from RecoTracker.Configuration.RecoTrackerP5_cff import * from RecoTracker.TrackProducer.TrackRefitter_cfi import * from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import * +from RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi import * ALCARECOPixelLACalibrationTracksRefitMCS = TrackRefitter.clone(src = "ALCARECOPixelLACalibrationTracksMCS", TrajectoryInEvent = True, @@ -65,5 +66,6 @@ ALCARECOCalCosmicsFilterForSiPixelLorentzAngleMCS * ALCARECOPixelLATrackFilterRefitMCS * ALCARECOSiPixelLACalibMCS * - MEtoEDMConvertSiPixelLorentzAngleMCS + MEtoEDMConvertSiPixelLorentzAngleMCS, + cms.Task(SiPixelTemplateStoreESProducer) ) diff --git a/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngle_cff.py b/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngle_cff.py index d7de69d618d6d..7fbb485038ee6 100644 --- a/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngle_cff.py +++ b/Calibration/TkAlCaRecoProducers/python/ALCARECOPromptCalibProdSiPixelLorentzAngle_cff.py @@ -62,9 +62,11 @@ ) # The actual sequence +from RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi import * seqALCARECOPromptCalibProdSiPixelLorentzAngle = cms.Sequence( ALCARECOCalSignleMuonFilterForSiPixelLorentzAngle * ALCARECOPixelLATrackFilterRefit * ALCARECOSiPixelLACalib * - MEtoEDMConvertSiPixelLorentzAngle + MEtoEDMConvertSiPixelLorentzAngle, + cms.Task(SiPixelTemplateStoreESProducer) ) diff --git a/CondFormats/SiPixelTransient/BuildFile.xml b/CondFormats/SiPixelTransient/BuildFile.xml index 92d171eeba92e..747165cc944df 100644 --- a/CondFormats/SiPixelTransient/BuildFile.xml +++ b/CondFormats/SiPixelTransient/BuildFile.xml @@ -1,5 +1,6 @@ + diff --git a/CondFormats/SiPixelTransient/src/T_EventSetup_SiPixelTemplateStore.cc b/CondFormats/SiPixelTransient/src/T_EventSetup_SiPixelTemplateStore.cc new file mode 100644 index 0000000000000..35b9cc46991f5 --- /dev/null +++ b/CondFormats/SiPixelTransient/src/T_EventSetup_SiPixelTemplateStore.cc @@ -0,0 +1,19 @@ +// -*- C++ -*- +// +// Package: CondFormats/SiPixelTransient +// Class : T_EventSetup_SiPixelTemplateStore +// +// Implementation: +// [Notes on implementation] +// +// Original Author: Christopher Jones +// Created: Tue, 08 Aug 2023 15:33:48 GMT +// + +// system include files + +// user include files +#include "CondFormats/SiPixelTransient/interface/SiPixelTemplate.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +TYPELOOKUP_DATA_REG(std::vector); diff --git a/DQM/SiPixelPhase1Config/python/SiPixelPhase1OfflineDQM_source_cff.py b/DQM/SiPixelPhase1Config/python/SiPixelPhase1OfflineDQM_source_cff.py index 5b409b5b7fa6f..9604c9f4320b8 100644 --- a/DQM/SiPixelPhase1Config/python/SiPixelPhase1OfflineDQM_source_cff.py +++ b/DQM/SiPixelPhase1Config/python/SiPixelPhase1OfflineDQM_source_cff.py @@ -14,6 +14,7 @@ from DQM.SiPixelPhase1Track.SiPixelPhase1ResidualsExtra_cfi import * # Clusters ontrack/offtrack (also general tracks) from DQM.SiPixelPhase1Track.SiPixelPhase1TrackClusters_cfi import * +from RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi import * # Hit Efficiencies from DQM.SiPixelPhase1Track.SiPixelPhase1TrackEfficiency_cfi import * # FED/RAW Data @@ -24,7 +25,6 @@ from DQM.SiPixelPhase1Summary.SiPixelBarycenter_cfi import * - from RecoTracker.PixelLowPtUtilities.ClusterShapeHitFilterESProducer_cfi import * from RecoLocalTracker.SiStripClusterizer.SiStripClusterChargeCut_cfi import * from DQM.SiPixelPhase1Track.SiPixelPhase1EfficiencyExtras_cfi import * @@ -39,7 +39,8 @@ + SiPixelPhase1RecHitsAnalyzer + SiPixelPhase1TrackResidualsAnalyzer + SiPixelPhase1TrackClustersAnalyzer - + SiPixelPhase1TrackEfficiencyAnalyzer + + SiPixelPhase1TrackEfficiencyAnalyzer, + cms.Task(SiPixelTemplateStoreESProducer) ) diff --git a/DQM/SiPixelPhase1Config/python/SiPixelPhase1OnlineDQM_Timing_cff.py b/DQM/SiPixelPhase1Config/python/SiPixelPhase1OnlineDQM_Timing_cff.py index ff64e24c45200..e268b8062f012 100644 --- a/DQM/SiPixelPhase1Config/python/SiPixelPhase1OnlineDQM_Timing_cff.py +++ b/DQM/SiPixelPhase1Config/python/SiPixelPhase1OnlineDQM_Timing_cff.py @@ -97,12 +97,12 @@ # Cluster (track-independent) monitoring from DQM.SiPixelPhase1Common.SiPixelPhase1Clusters_cfi import * +from RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi import * # Track cluster from DQM.SiPixelPhase1Track.SiPixelPhase1TrackClusters_cfi import * from DQM.SiPixelPhase1Track.SiPixelPhase1TrackResiduals_cfi import * - # Raw data errors from DQM.SiPixelPhase1Common.SiPixelPhase1RawData_cfi import * @@ -115,7 +115,8 @@ + SiPixelPhase1ClustersAnalyzer + SiPixelPhase1RawDataAnalyzer + SiPixelPhase1TrackClustersAnalyzer - + SiPixelPhase1TrackResidualsAnalyzer + + SiPixelPhase1TrackResidualsAnalyzer, + cms.Task(SiPixelTemplateStoreESProducer) ) siPixelPhase1OnlineDQM_harvesting = cms.Sequence( @@ -149,7 +150,8 @@ + SiPixelPhase1ClustersAnalyzer + SiPixelPhase1RawDataAnalyzer + SiPixelPhase1TrackClustersAnalyzer_cosmics - + SiPixelPhase1TrackResidualsAnalyzer_cosmics + + SiPixelPhase1TrackResidualsAnalyzer_cosmics, + cms.Task(SiPixelTemplateStoreESProducer) ) ## Additional settings for pp_run (Phase 0 test) @@ -177,6 +179,7 @@ + SiPixelPhase1RawDataAnalyzer + SiPixelPhase1TrackClustersAnalyzer_pprun + SiPixelPhase1TrackResidualsAnalyzer_pprun - + SiPixelPhase1TrackEfficiencyAnalyzer_pprun + + SiPixelPhase1TrackEfficiencyAnalyzer_pprun, + cms.Task(SiPixelTemplateStoreESProducer) ) diff --git a/DQM/SiPixelPhase1Config/python/SiPixelPhase1OnlineDQM_cff.py b/DQM/SiPixelPhase1Config/python/SiPixelPhase1OnlineDQM_cff.py index 48a54228082a7..5e9cc8a6a9a3b 100644 --- a/DQM/SiPixelPhase1Config/python/SiPixelPhase1OnlineDQM_cff.py +++ b/DQM/SiPixelPhase1Config/python/SiPixelPhase1OnlineDQM_cff.py @@ -70,6 +70,8 @@ # Track cluster from DQM.SiPixelPhase1Track.SiPixelPhase1TrackClusters_cfi import * +from RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi import * + SiPixelPhase1TrackClustersOnTrackCorrCharge.enabled=cms.bool(False) SiPixelPhase1TrackTemplateCorr.enabled=cms.bool(False) SiPixelPhase1TrackClustersOnTrackCorrChargeOuter.enabled=cms.bool(False) @@ -86,6 +88,7 @@ + SiPixelPhase1TrackClustersAnalyzer + SiPixelPhase1TrackResidualsAnalyzer # + SiPixelPhase1GeometryDebugAnalyzer + , cms.Task(SiPixelTemplateStoreESProducer) ) siPixelPhase1OnlineDQM_harvesting = cms.Sequence( @@ -119,7 +122,8 @@ + SiPixelPhase1ClustersAnalyzer + SiPixelPhase1RawDataAnalyzer + SiPixelPhase1TrackClustersAnalyzer_cosmics - + SiPixelPhase1TrackResidualsAnalyzer_cosmics + + SiPixelPhase1TrackResidualsAnalyzer_cosmics, + cms.Task(SiPixelTemplateStoreESProducer) ) ## Additional settings for pp_run @@ -142,7 +146,8 @@ + SiPixelPhase1ClustersAnalyzer + SiPixelPhase1RawDataAnalyzer + SiPixelPhase1TrackClustersAnalyzer_pprun - + SiPixelPhase1TrackResidualsAnalyzer_pprun + + SiPixelPhase1TrackResidualsAnalyzer_pprun, + cms.Task(SiPixelTemplateStoreESProducer) ) siPixelPhase1OnlineDQM_timing_harvesting = siPixelPhase1OnlineDQM_harvesting.copyAndExclude([ diff --git a/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1TrackClusters.cc b/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1TrackClusters.cc index e0772b2f3cf7e..6c1a64c1d86cd 100644 --- a/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1TrackClusters.cc +++ b/DQM/SiPixelPhase1Track/plugins/SiPixelPhase1TrackClusters.cc @@ -88,8 +88,8 @@ namespace { private: const bool applyVertexCut_; - const SiPixelTemplateDBObject* templateDBobject_; - std::vector thePixelTemp_; + const SiPixelTemplateDBObject* templateDBobject_ = nullptr; + const std::vector* thePixelTemp_ = nullptr; const TrackerTopology* tkTpl = nullptr; edm::EDGetTokenT tracksToken_; @@ -101,6 +101,7 @@ namespace { edm::ESGetToken clusterShapeHitFilterToken_; edm::ESGetToken templateDBobjectToken_; + edm::ESGetToken, SiPixelTemplateDBObjectESProducerRcd> templateStoreToken_; }; SiPixelPhase1TrackClusters::SiPixelPhase1TrackClusters(const edm::ParameterSet& iConfig) @@ -118,6 +119,7 @@ namespace { trackerGeomToken_ = esConsumes(); clusterShapeHitFilterToken_ = esConsumes(edm::ESInputTag("", "ClusterShapeHitFilter")); + templateStoreToken_ = esConsumes(); templateDBobjectToken_ = esConsumes(); } @@ -127,10 +129,7 @@ namespace { // Initialize 1D templates templateDBobject_ = &iSetup.getData(templateDBobjectToken_); - if (!SiPixelTemplate::pushfile(*templateDBobject_, thePixelTemp_)) - edm::LogError("SiPixelPhase1TrackClusters") - << "Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " - << (*templateDBobject_).version() << std::endl; + thePixelTemp_ = &iSetup.getData(templateStoreToken_); } void SiPixelPhase1TrackClusters::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { @@ -162,7 +161,7 @@ namespace { return; } - SiPixelTemplate templ(thePixelTemp_); + SiPixelTemplate templ(*thePixelTemp_); edm::Handle pixelClusterShapeCacheH; iEvent.getByToken(pixelClusterShapeCacheToken_, pixelClusterShapeCacheH); diff --git a/DQMOffline/Trigger/python/SiPixel_OfflineMonitoring_cff.py b/DQMOffline/Trigger/python/SiPixel_OfflineMonitoring_cff.py index 562025b0fd8f9..709fe6f77318d 100644 --- a/DQMOffline/Trigger/python/SiPixel_OfflineMonitoring_cff.py +++ b/DQMOffline/Trigger/python/SiPixel_OfflineMonitoring_cff.py @@ -4,6 +4,7 @@ from DQMOffline.Trigger.SiPixel_OfflineMonitoring_TrackCluster_cff import * from RecoTracker.PixelLowPtUtilities.siPixelClusterShapeCache_cfi import * from DQM.SiPixelMonitorTrack.RefitterForPixelDQM import * +from RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi import * hltSiPixelClusterShapeCache = siPixelClusterShapeCache.clone(src = 'hltSiPixelClusters') hltrefittedForPixelDQM = refittedForPixelDQM.clone(src ='hltMergedTracks', @@ -12,5 +13,6 @@ hltSiPixelClusterShapeCache + hltSiPixelPhase1ClustersAnalyzer + hltrefittedForPixelDQM - + hltSiPixelPhase1TrackClustersAnalyzer + + hltSiPixelPhase1TrackClustersAnalyzer, + cms.Task(SiPixelTemplateStoreESProducer) ) diff --git a/DQMOffline/Trigger/python/SiStrip_OfflineMonitoring_cff.py b/DQMOffline/Trigger/python/SiStrip_OfflineMonitoring_cff.py index 504aae8564d97..78ea580d92b3e 100644 --- a/DQMOffline/Trigger/python/SiStrip_OfflineMonitoring_cff.py +++ b/DQMOffline/Trigger/python/SiStrip_OfflineMonitoring_cff.py @@ -7,6 +7,7 @@ #HLTsiStripClusters.SiStripRefGetter = cms.InputTag("hltSiStripClusters") # SiStripCluster monitoring +from RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi import SiPixelTemplateStoreESProducer as hltSiPixelTemplateStoreESProducer import DQM.SiStripMonitorCluster.SiStripMonitorCluster_cfi HLTSiStripMonitorCluster = DQM.SiStripMonitorCluster.SiStripMonitorCluster_cfi.SiStripMonitorCluster.clone( ClusterProducerStrip = "hltSiStripRawToClustersFacility", diff --git a/FastSimulation/Configuration/python/Reconstruction_BefMix_cff.py b/FastSimulation/Configuration/python/Reconstruction_BefMix_cff.py index 91bda4c77044c..b91aa1dd999e8 100644 --- a/FastSimulation/Configuration/python/Reconstruction_BefMix_cff.py +++ b/FastSimulation/Configuration/python/Reconstruction_BefMix_cff.py @@ -41,6 +41,7 @@ from FastSimulation.Tracking.iterativeTk_cff import * from TrackingTools.TrackFitters.TrackFitters_cff import * +from RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi import * reconstruction_befmix = cms.Sequence( offlineBeamSpot @@ -48,5 +49,6 @@ * fastMatchedTrackerRecHits * fastMatchedTrackerRecHitCombinations * MeasurementTrackerEvent - * iterTracking + * iterTracking, + cms.Task(SiPixelTemplateStoreESProducer) ) diff --git a/FastSimulation/TrackingRecHitProducer/interface/PixelTemplateSmearerBase.h b/FastSimulation/TrackingRecHitProducer/interface/PixelTemplateSmearerBase.h index 9dd5a6d7904c2..627e9bc205a14 100644 --- a/FastSimulation/TrackingRecHitProducer/interface/PixelTemplateSmearerBase.h +++ b/FastSimulation/TrackingRecHitProducer/interface/PixelTemplateSmearerBase.h @@ -49,9 +49,9 @@ class PixelTemplateSmearerBase : public TrackingRecHitAlgorithm { bool mergeHitsOn = false; // if true then see if neighboring hits might merge //--- Template DB Object(s) - const SiPixelTemplateDBObject* pixelTemplateDBObject_ = nullptr; // needed for template<-->DetId map. - std::vector thePixelTemp_; // our own template storage - std::vector& thePixelTempRef = thePixelTemp_; // points to the one we will use. + const SiPixelTemplateDBObject* pixelTemplateDBObject_ = nullptr; // needed for template<-->DetId map. + std::vector thePixelTemp_; // our own template storage + const std::vector* thePixelTempRef = &thePixelTemp_; // points to the one we will use. int templateId = -1; //--- Flag to tell us whether we are in barrel or in forward. @@ -92,7 +92,7 @@ class PixelTemplateSmearerBase : public TrackingRecHitAlgorithm { void beginRun(edm::Run const& run, const edm::EventSetup& eventSetup, const SiPixelTemplateDBObject* pixelTemplateDBObjectPtr, - std::vector& tempStoreRef) override; + const std::vector& tempStoreRef) override; // void endEvent(edm::Event& event, const edm::EventSetup& eventSetup) override; //--- Process all unmerged hits. Calls smearHit() for each. diff --git a/FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitAlgorithm.h b/FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitAlgorithm.h index 806d3a0c73734..d0edaff3601cf 100644 --- a/FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitAlgorithm.h +++ b/FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitAlgorithm.h @@ -51,7 +51,7 @@ class TrackingRecHitAlgorithm { virtual void beginRun(edm::Run const& run, const edm::EventSetup& eventSetup, const SiPixelTemplateDBObject* pixelTemplateDBObjectPtr, - std::vector& tempStoreRef); + const std::vector& tempStoreRef); //this function will only be called once per event virtual void beginEvent(edm::Event& event, const edm::EventSetup& eventSetup); diff --git a/FastSimulation/TrackingRecHitProducer/plugins/TrackingRecHitProducer.cc b/FastSimulation/TrackingRecHitProducer/plugins/TrackingRecHitProducer.cc index a0487ba7d33d6..5eaee86f17906 100644 --- a/FastSimulation/TrackingRecHitProducer/plugins/TrackingRecHitProducer.cc +++ b/FastSimulation/TrackingRecHitProducer/plugins/TrackingRecHitProducer.cc @@ -48,8 +48,9 @@ class TrackingRecHitProducer : public edm::stream::EDProducer<> { unsigned long long _trackerTopologyCacheID = 0; std::map _detIdPipes; void setupDetIdPipes(const edm::EventSetup& eventSetup); - std::vector _pixelTempStore; // pixel template storage const edm::ESGetToken siPixelTemplateDBObjectESToken_; + const edm::ESGetToken, SiPixelTemplateDBObjectESProducerRcd> + siPixelTemplateStoreESToken_; const edm::ESGetToken trackerGeometryESToken_; const edm::ESGetToken trackerTopologyESToken_; @@ -115,17 +116,10 @@ void TrackingRecHitProducer::beginRun(edm::Run const& run, const edm::EventSetup // to a no-op. const SiPixelTemplateDBObject& pixelTemplateDBObject = eventSetup.getData(siPixelTemplateDBObjectESToken_); - - //--- Now that we have the DB object, load the correct templates from the DB. - // (They are needed for data and full sim MC, so in a production FastSim - // run, everything should already be in the DB.) - if (!SiPixelTemplate::pushfile(pixelTemplateDBObject, _pixelTempStore)) { - throw cms::Exception("TrackingRecHitProducer:") - << "SiPixel Templates not loaded correctly from the DB object!" << std::endl; - } + const auto& pixelTemplateStore = eventSetup.getData(siPixelTemplateStoreESToken_); for (auto& algo : _recHitAlgorithms) { - algo->beginRun(run, eventSetup, &pixelTemplateDBObject, _pixelTempStore); + algo->beginRun(run, eventSetup, &pixelTemplateDBObject, pixelTemplateStore); } } diff --git a/FastSimulation/TrackingRecHitProducer/src/PixelTemplateSmearerBase.cc b/FastSimulation/TrackingRecHitProducer/src/PixelTemplateSmearerBase.cc index 0b2ab2b963670..d7c2ab27e0afe 100644 --- a/FastSimulation/TrackingRecHitProducer/src/PixelTemplateSmearerBase.cc +++ b/FastSimulation/TrackingRecHitProducer/src/PixelTemplateSmearerBase.cc @@ -136,14 +136,14 @@ PixelTemplateSmearerBase::~PixelTemplateSmearerBase() {} void PixelTemplateSmearerBase::beginRun(edm::Run const& run, const edm::EventSetup& eventSetup, const SiPixelTemplateDBObject* pixelTemplateDBObjectPtr, - std::vector& tempStoreRef) { + const std::vector& tempStoreRef) { //--- Check if we need to use the template from the DB (namely if // id == -1). Otherwise the template has already been loaded from // the ascii file in constructor, and thePixelTempRef wakes up // pointing to thePixelTemp_, so then we use our own store. // if (templateId == -1) { - thePixelTempRef = tempStoreRef; // we use the store from TrackingRecHitProducer + thePixelTempRef = &tempStoreRef; // we use the store from TrackingRecHitProducer pixelTemplateDBObject_ = pixelTemplateDBObjectPtr; // needed for template<-->DetId map. } @@ -392,7 +392,7 @@ FastSingleTrackerRecHit PixelTemplateSmearerBase::smearHit(const PSimHit& simHit } //--- Make the template object - SiPixelTemplate templ(thePixelTempRef); + SiPixelTemplate templ(*thePixelTempRef); //--- Produce the template that corresponds to our local angles. templ.interpolate(ID, cotalpha, cotbeta); @@ -778,7 +778,7 @@ FastSingleTrackerRecHit PixelTemplateSmearerBase::smearMergeGroup(MergeGroup* mg } //--- Make the template object - SiPixelTemplate templ(thePixelTempRef); + SiPixelTemplate templ(*thePixelTempRef); //--- Produce the template that corresponds to our local angles. templ.interpolate(ID, cotalpha, cotbeta); diff --git a/FastSimulation/TrackingRecHitProducer/src/TrackingRecHitAlgorithm.cc b/FastSimulation/TrackingRecHitProducer/src/TrackingRecHitAlgorithm.cc index 2ac1c9f781d45..bcb6852039c21 100644 --- a/FastSimulation/TrackingRecHitProducer/src/TrackingRecHitAlgorithm.cc +++ b/FastSimulation/TrackingRecHitProducer/src/TrackingRecHitAlgorithm.cc @@ -66,7 +66,7 @@ void TrackingRecHitAlgorithm::beginStream(const edm::StreamID& id) { void TrackingRecHitAlgorithm::beginRun(edm::Run const& run, const edm::EventSetup& eventSetup, const SiPixelTemplateDBObject* pixelTemplateDBObjectPtr, - std::vector& tempStoreRef) { + const std::vector& tempStoreRef) { // The default is to do nothing. } diff --git a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h index 2c753edf03c00..1982cff15f81c 100644 --- a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h +++ b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPEClusterRepair.h @@ -56,6 +56,7 @@ class PixelCPEClusterRepair : public PixelCPEBase { const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, + const std::vector *, const SiPixelTemplateDBObject *, const SiPixel2DTemplateDBObject *); @@ -97,7 +98,8 @@ class PixelCPEClusterRepair : public PixelCPEBase { void fill2DTemplIDs(); // Template storage - std::vector thePixelTemp_; + std::vector const *thePixelTemp_; + std::vector thePixelTempCache_; std::vector thePixelTemp2D_; int speed_; diff --git a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPETemplateReco.h b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPETemplateReco.h index 93e8ee9971891..dc92fae67d4c6 100644 --- a/RecoLocalTracker/SiPixelRecHits/interface/PixelCPETemplateReco.h +++ b/RecoLocalTracker/SiPixelRecHits/interface/PixelCPETemplateReco.h @@ -56,6 +56,7 @@ class PixelCPETemplateReco : public PixelCPEBase { const TrackerGeometry &, const TrackerTopology &, const SiPixelLorentzAngle *, + const std::vector *, const SiPixelTemplateDBObject *); ~PixelCPETemplateReco() override; @@ -74,7 +75,8 @@ class PixelCPETemplateReco : public PixelCPEBase { LocalError localError(DetParam const &theDetParam, ClusterParam &theClusterParam) const override; // Template storage - std::vector thePixelTemp_; + std::vector thePixelTempCache_; + const std::vector *thePixelTemp_; int speed_; diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/BuildFile.xml b/RecoLocalTracker/SiPixelRecHits/plugins/BuildFile.xml index 3a1a0bec51250..00c88eadd4b51 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/BuildFile.xml +++ b/RecoLocalTracker/SiPixelRecHits/plugins/BuildFile.xml @@ -6,6 +6,7 @@ + diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPEClusterRepairESProducer.cc b/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPEClusterRepairESProducer.cc index 1c97241056c31..9ffd3759bb585 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPEClusterRepairESProducer.cc +++ b/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPEClusterRepairESProducer.cc @@ -30,6 +30,7 @@ class PixelCPEClusterRepairESProducer : public edm::ESProducer { edm::ESGetToken pDDToken_; edm::ESGetToken hTTToken_; edm::ESGetToken lorentzAngleToken_; + edm::ESGetToken, SiPixelTemplateDBObjectESProducerRcd> templateStoreToken_; edm::ESGetToken templateDBobjectToken_; edm::ESGetToken templateDBobject2DToken_; @@ -51,6 +52,7 @@ PixelCPEClusterRepairESProducer::PixelCPEClusterRepairESProducer(const edm::Para magfieldToken_ = c.consumes(); pDDToken_ = c.consumes(); hTTToken_ = c.consumes(); + templateStoreToken_ = c.consumes(); templateDBobjectToken_ = c.consumes(); templateDBobject2DToken_ = c.consumes(); if (useLAFromDB_ || doLorentzFromAlignment_) { @@ -91,6 +93,7 @@ std::unique_ptr PixelCPEClusterRepairESProducer: iRecord.get(pDDToken_), iRecord.get(hTTToken_), lorentzAngleProduct, + &iRecord.get(templateStoreToken_), &iRecord.get(templateDBobjectToken_), &iRecord.get(templateDBobject2DToken_)); } diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPETemplateRecoESProducer.cc b/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPETemplateRecoESProducer.cc index 696d3700f96f7..074c1290f7d54 100644 --- a/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPETemplateRecoESProducer.cc +++ b/RecoLocalTracker/SiPixelRecHits/plugins/PixelCPETemplateRecoESProducer.cc @@ -28,6 +28,7 @@ class PixelCPETemplateRecoESProducer : public edm::ESProducer { edm::ESGetToken hTTToken_; edm::ESGetToken lorentzAngleToken_; edm::ESGetToken templateDBobjectToken_; + edm::ESGetToken, SiPixelTemplateDBObjectESProducerRcd> templateStoreToken_; edm::ParameterSet pset_; bool doLorentzFromAlignment_; @@ -48,6 +49,7 @@ PixelCPETemplateRecoESProducer::PixelCPETemplateRecoESProducer(const edm::Parame pDDToken_ = c.consumes(); hTTToken_ = c.consumes(); templateDBobjectToken_ = c.consumes(); + templateStoreToken_ = c.consumes(); if (useLAFromDB_ || doLorentzFromAlignment_) { char const* laLabel = doLorentzFromAlignment_ ? "fromAlignment" : ""; lorentzAngleToken_ = c.consumes(edm::ESInputTag("", laLabel)); @@ -69,6 +71,7 @@ std::unique_ptr PixelCPETemplateRecoESProducer:: iRecord.get(pDDToken_), iRecord.get(hTTToken_), lorentzAngleProduct, + &iRecord.get(templateStoreToken_), &iRecord.get(templateDBobjectToken_)); } diff --git a/RecoLocalTracker/SiPixelRecHits/plugins/SiPixelTemplateStoreESProducer.cc b/RecoLocalTracker/SiPixelRecHits/plugins/SiPixelTemplateStoreESProducer.cc new file mode 100644 index 0000000000000..4a9b9ab2907bf --- /dev/null +++ b/RecoLocalTracker/SiPixelRecHits/plugins/SiPixelTemplateStoreESProducer.cc @@ -0,0 +1,80 @@ +// -*- C++ -*- +// +// Package: RecoLocalTracker/SiPixelRecHits +// Class : SiPixelTemplateStoreESProducer +// +// Implementation: +// [Notes on implementation] +// +// Original Author: Christopher Jones +// Created: Tue, 08 Aug 2023 14:21:50 GMT +// + +// system include files + +// user include files +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/ModuleFactory.h" + +#include "CondFormats/SiPixelTransient/interface/SiPixelTemplate.h" +#include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h" + +#include "CalibTracker/Records/interface/SiPixelTemplateDBObjectESProducerRcd.h" + +class SiPixelTemplateStoreESProducer : public edm::ESProducer { +public: + SiPixelTemplateStoreESProducer(edm::ParameterSet const&); + static void fillDescriptions(edm::ConfigurationDescriptions&); + + std::unique_ptr> produce(const SiPixelTemplateDBObjectESProducerRcd&); + +private: + edm::ESGetToken token_; +}; + +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// +SiPixelTemplateStoreESProducer::SiPixelTemplateStoreESProducer(edm::ParameterSet const& iPSet) { + token_ = setWhatProduced(this).consumes(); +} + +// +// member functions +// +std::unique_ptr> SiPixelTemplateStoreESProducer::produce( + const SiPixelTemplateDBObjectESProducerRcd& iRecord) { + auto returnValue = std::make_unique>(); + + if (not SiPixelTemplate::pushfile(iRecord.get(token_), *returnValue)) { + throw cms::Exception("SiPixelTemplateDBObjectFailure") + << "Templates not filled correctly. Check the DB. Using SiPixelTemplateDBObject version " + << iRecord.get(token_).version(); + } + + return returnValue; +} + +// +// const member functions +// + +// +// static member functions +// +void SiPixelTemplateStoreESProducer::fillDescriptions(edm::ConfigurationDescriptions& iDesc) { + edm::ParameterSetDescription iPSet; + iDesc.addDefault(iPSet); + iDesc.add("SiPixelTemplateStoreESProducer", iPSet); +} + +DEFINE_FWK_EVENTSETUP_MODULE(SiPixelTemplateStoreESProducer); +; diff --git a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc index ac84748b74be1..8a7df758538f5 100644 --- a/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc +++ b/RecoLocalTracker/SiPixelRecHits/src/PixelCPEClusterRepair.cc @@ -40,6 +40,7 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const& conf, const TrackerGeometry& geom, const TrackerTopology& ttopo, const SiPixelLorentzAngle* lorentzAngle, + const std::vector* templateStore, const SiPixelTemplateDBObject* templateDBobject, const SiPixel2DTemplateDBObject* templateDBobject2D) : PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr, 1) { @@ -47,12 +48,7 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const& conf, //--- Parameter to decide between DB or text file template access if (LoadTemplatesFromDB_) { - // Initialize template store to the selected ID [Morris, 6/25/08] - if (!SiPixelTemplate::pushfile(*templateDBobject_, thePixelTemp_)) - throw cms::Exception("PixelCPEClusterRepair") - << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " - << (*templateDBobject_).version() << "\n\n"; - + thePixelTemp_ = templateStore; // Initialize template store to the selected ID [Morris, 6/25/08] if (!SiPixelTemplate2D::pushfile(*templateDBobject2D, thePixelTemp2D_)) throw cms::Exception("PixelCPEClusterRepair") @@ -65,13 +61,14 @@ PixelCPEClusterRepair::PixelCPEClusterRepair(edm::ParameterSet const& conf, barrelTemplateID_ = conf.getParameter("barrelTemplateID"); forwardTemplateID_ = conf.getParameter("forwardTemplateID"); templateDir_ = conf.getParameter("directoryWithTemplates"); + thePixelTemp_ = &thePixelTempCache_; - if (!SiPixelTemplate::pushfile(barrelTemplateID_, thePixelTemp_, templateDir_)) + if (!SiPixelTemplate::pushfile(barrelTemplateID_, thePixelTempCache_, templateDir_)) throw cms::Exception("PixelCPEClusterRepair") << "\nERROR: Template ID " << barrelTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n"; - if (!SiPixelTemplate::pushfile(forwardTemplateID_, thePixelTemp_, templateDir_)) + if (!SiPixelTemplate::pushfile(forwardTemplateID_, thePixelTempCache_, templateDir_)) throw cms::Exception("PixelCPEClusterRepair") << "\nERROR: Template ID " << forwardTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n"; @@ -312,7 +309,7 @@ void PixelCPEClusterRepair::callTempReco1D(DetParam const& theDetParam, SiPixelTemplateReco::ClusMatrix& clusterPayload, int ID, LocalPoint& lp) const { - SiPixelTemplate templ(thePixelTemp_); + SiPixelTemplate templ(*thePixelTemp_); // Output: float nonsense = -99999.9f; // nonsense init value @@ -551,7 +548,7 @@ void PixelCPEClusterRepair::checkRecommend2D(DetParam const& theDetParam, return; } // The 1d pixel template - SiPixelTemplate templ(thePixelTemp_); + SiPixelTemplate templ(*thePixelTemp_); if (!templ.interpolate(ID, theClusterParam.cotalpha, theClusterParam.cotbeta, theDetParam.bz, theDetParam.bx)) { //error setting up template, return false theClusterParam.recommended2D_ = false; diff --git a/RecoLocalTracker/SiPixelRecHits/src/PixelCPETemplateReco.cc b/RecoLocalTracker/SiPixelRecHits/src/PixelCPETemplateReco.cc index 48752c6e12757..e29aa902ca8f9 100644 --- a/RecoLocalTracker/SiPixelRecHits/src/PixelCPETemplateReco.cc +++ b/RecoLocalTracker/SiPixelRecHits/src/PixelCPETemplateReco.cc @@ -45,6 +45,7 @@ PixelCPETemplateReco::PixelCPETemplateReco(edm::ParameterSet const& conf, const TrackerGeometry& geom, const TrackerTopology& ttopo, const SiPixelLorentzAngle* lorentzAngle, + const std::vector* templateStore, const SiPixelTemplateDBObject* templateDBobject) : PixelCPEBase(conf, mag, geom, ttopo, lorentzAngle, nullptr, templateDBobject, nullptr, 1) { //cout << endl; @@ -62,24 +63,20 @@ PixelCPETemplateReco::PixelCPETemplateReco(edm::ParameterSet const& conf, if (LoadTemplatesFromDB_) { //cout << "PixelCPETemplateReco: Loading templates from database (DB) --------- " << endl; - - // Initialize template store to the selected ID [Morris, 6/25/08] - if (!SiPixelTemplate::pushfile(*templateDBobject_, thePixelTemp_)) - throw cms::Exception("PixelCPETemplateReco") - << "\nERROR: Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version " - << (*templateDBobject_).version() << "\n\n"; + thePixelTemp_ = templateStore; } else { //cout << "PixelCPETemplateReco : Loading templates for barrel and forward from ASCII files ----------" << endl; barrelTemplateID_ = conf.getParameter("barrelTemplateID"); forwardTemplateID_ = conf.getParameter("forwardTemplateID"); templateDir_ = conf.getParameter("directoryWithTemplates"); - if (!SiPixelTemplate::pushfile(barrelTemplateID_, thePixelTemp_, templateDir_)) + thePixelTemp_ = &thePixelTempCache_; + if (!SiPixelTemplate::pushfile(barrelTemplateID_, thePixelTempCache_, templateDir_)) throw cms::Exception("PixelCPETemplateReco") << "\nERROR: Template ID " << barrelTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n"; - if (!SiPixelTemplate::pushfile(forwardTemplateID_, thePixelTemp_, templateDir_)) + if (!SiPixelTemplate::pushfile(forwardTemplateID_, thePixelTempCache_, templateDir_)) throw cms::Exception("PixelCPETemplateReco") << "\nERROR: Template ID " << forwardTemplateID_ << " not loaded correctly from text file. Reconstruction will fail.\n\n"; @@ -129,7 +126,7 @@ LocalPoint PixelCPETemplateReco::localPosition(DetParam const& theDetParam, Clus } //cout << "PixelCPETemplateReco : ID = " << ID << endl; - SiPixelTemplate templ(thePixelTemp_); + SiPixelTemplate templ(*thePixelTemp_); // Preparing to retrieve ADC counts from the SiPixeltheClusterParam.theCluster-> In the cluster, // we have the following: