Skip to content

Commit

Permalink
Merge pull request #42648 from Dr15Jones/SiPixelTemplateStoreFromES_13_0
Browse files Browse the repository at this point in the history
Moved creating SiPixelTemplateStore from DB to an ESProducer [13_0]
  • Loading branch information
cmsbuild authored Sep 1, 2023
2 parents cbfb519 + 06cb627 commit d835c8b
Show file tree
Hide file tree
Showing 32 changed files with 181 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,3 @@
process.TrackRefitter +
process.offlinePrimaryVerticesFromRefittedTrks +
process.jetHTAnalyzer)


Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class SiPixelLorentzAnglePCLWorker : public DQMEDAnalyzer {
// template stuff
edm::ESWatcher<SiPixelTemplateDBObjectESProducerRcd> watchSiPixelTemplateRcd_;
const SiPixelTemplateDBObject* templateDBobject_;
std::vector<SiPixelTemplateStore> thePixelTemp_;
const std::vector<SiPixelTemplateStore>* thePixelTemp_ = nullptr;

LorentzAngleAnalysisTypeEnum analysisType_;
std::string folder_;
Expand Down Expand Up @@ -195,6 +195,7 @@ class SiPixelLorentzAnglePCLWorker : public DQMEDAnalyzer {
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomEsToken_;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoEsToken_;
edm::ESGetToken<SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd> siPixelTemplateEsToken_;
edm::ESGetToken<std::vector<SiPixelTemplateStore>, SiPixelTemplateDBObjectESProducerRcd> siPixelTemplateStoreEsToken_;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoPerEventEsToken_;
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomPerEventEsToken_;
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magneticFieldToken_;
Expand Down Expand Up @@ -223,6 +224,7 @@ SiPixelLorentzAnglePCLWorker::SiPixelLorentzAnglePCLWorker(const edm::ParameterS
geomEsToken_(esConsumes<edm::Transition::BeginRun>()),
topoEsToken_(esConsumes<edm::Transition::BeginRun>()),
siPixelTemplateEsToken_(esConsumes<edm::Transition::BeginRun>()),
siPixelTemplateStoreEsToken_(esConsumes<edm::Transition::BeginRun>()),
topoPerEventEsToken_(esConsumes()),
geomPerEventEsToken_(esConsumes()),
magneticFieldToken_(esConsumes()) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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_);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@
ALCARECOCalCosmicsFilterForSiPixelLorentzAngleMCS *
ALCARECOPixelLATrackFilterRefitMCS *
ALCARECOSiPixelLACalibMCS *
MEtoEDMConvertSiPixelLorentzAngleMCS
MEtoEDMConvertSiPixelLorentzAngleMCS
)
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@
ALCARECOCalSignleMuonFilterForSiPixelLorentzAngle *
ALCARECOPixelLATrackFilterRefit *
ALCARECOSiPixelLACalib *
MEtoEDMConvertSiPixelLorentzAngle
MEtoEDMConvertSiPixelLorentzAngle
)
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
)

# refit and BS can be dropped if done together with RECO.
# track filter can be moved in acalreco if no otehr users
# track filter can be moved in acalreco if no other users
ALCARECOTrackFilterRefitAAG = cms.Sequence(ALCARECOCalibrationTracksAAG +
offlineBeamSpot +
ALCARECOCalibrationTracksRefitAAG )
Expand Down
Original file line number Diff line number Diff line change
@@ -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/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(std::vector<SiPixelTemplateStore>);
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,7 +25,6 @@
from DQM.SiPixelPhase1Summary.SiPixelBarycenter_cfi import *



from RecoPixelVertexing.PixelLowPtUtilities.ClusterShapeHitFilterESProducer_cfi import *
from RecoLocalTracker.SiStripClusterizer.SiStripClusterChargeCut_cfi import *
from DQM.SiPixelPhase1Track.SiPixelPhase1EfficiencyExtras_cfi import *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 *

Expand Down
2 changes: 2 additions & 0 deletions DQM/SiPixelPhase1Config/python/SiPixelPhase1OnlineDQM_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 6 additions & 7 deletions DQM/SiPixelPhase1Track/plugins/SiPixelPhase1TrackClusters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ namespace {

private:
const bool applyVertexCut_;
const SiPixelTemplateDBObject* templateDBobject_;
std::vector<SiPixelTemplateStore> thePixelTemp_;
const SiPixelTemplateDBObject* templateDBobject_ = nullptr;
const std::vector<SiPixelTemplateStore>* thePixelTemp_ = nullptr;
const TrackerTopology* tkTpl = nullptr;

edm::EDGetTokenT<reco::TrackCollection> tracksToken_;
Expand All @@ -101,6 +101,7 @@ namespace {
edm::ESGetToken<ClusterShapeHitFilter, CkfComponentsRecord> clusterShapeHitFilterToken_;

edm::ESGetToken<SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd> templateDBobjectToken_;
edm::ESGetToken<std::vector<SiPixelTemplateStore>, SiPixelTemplateDBObjectESProducerRcd> templateStoreToken_;
};

SiPixelPhase1TrackClusters::SiPixelPhase1TrackClusters(const edm::ParameterSet& iConfig)
Expand All @@ -118,6 +119,7 @@ namespace {
trackerGeomToken_ = esConsumes<edm::Transition::BeginRun>();
clusterShapeHitFilterToken_ =
esConsumes<ClusterShapeHitFilter, CkfComponentsRecord>(edm::ESInputTag("", "ClusterShapeHitFilter"));
templateStoreToken_ = esConsumes<edm::Transition::BeginRun>();
templateDBobjectToken_ = esConsumes<edm::Transition::BeginRun>();
}

Expand All @@ -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) {
Expand Down Expand Up @@ -162,7 +161,7 @@ namespace {
return;
}

SiPixelTemplate templ(thePixelTemp_);
SiPixelTemplate templ(*thePixelTemp_);

edm::Handle<SiPixelClusterShapeCache> pixelClusterShapeCacheH;
iEvent.getByToken(pixelClusterShapeCacheToken_, pixelClusterShapeCacheH);
Expand Down
4 changes: 3 additions & 1 deletion DQMOffline/Trigger/python/SiPixel_OfflineMonitoring_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from DQMOffline.Trigger.SiPixel_OfflineMonitoring_TrackCluster_cff import *
from RecoPixelVertexing.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',
Expand All @@ -14,5 +15,6 @@
hltSiPixelClusterShapeCache
+ hltSiPixelPhase1ClustersAnalyzer
+ hltrefittedForPixelDQM
+ hltSiPixelPhase1TrackClustersAnalyzer
+ hltSiPixelPhase1TrackClustersAnalyzer,
cms.Task(SiPixelTemplateStoreESProducer)
)
1 change: 1 addition & 0 deletions DQMOffline/Trigger/python/SiStrip_OfflineMonitoring_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#HLTsiStripClusters.SiStripRefGetter = cms.InputTag("hltSiStripClusters")

# SiStripCluster monitoring
from RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi import SiPixelTemplateStoreESProducer
import DQM.SiStripMonitorCluster.SiStripMonitorCluster_cfi
HLTSiStripMonitorCluster = DQM.SiStripMonitorCluster.SiStripMonitorCluster_cfi.SiStripMonitorCluster.clone(
ClusterProducerStrip = "hltSiStripRawToClustersFacility",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SiPixelTemplateStore> thePixelTemp_; // our own template storage
std::vector<SiPixelTemplateStore>& thePixelTempRef = thePixelTemp_; // points to the one we will use.
const SiPixelTemplateDBObject* pixelTemplateDBObject_ = nullptr; // needed for template<-->DetId map.
std::vector<SiPixelTemplateStore> thePixelTemp_; // our own template storage
const std::vector<SiPixelTemplateStore>* thePixelTempRef = &thePixelTemp_; // points to the one we will use.
int templateId = -1;

//--- Flag to tell us whether we are in barrel or in forward.
Expand Down Expand Up @@ -92,7 +92,7 @@ class PixelTemplateSmearerBase : public TrackingRecHitAlgorithm {
void beginRun(edm::Run const& run,
const edm::EventSetup& eventSetup,
const SiPixelTemplateDBObject* pixelTemplateDBObjectPtr,
std::vector<SiPixelTemplateStore>& tempStoreRef) override;
const std::vector<SiPixelTemplateStore>& tempStoreRef) override;
// void endEvent(edm::Event& event, const edm::EventSetup& eventSetup) override;

//--- Process all unmerged hits. Calls smearHit() for each.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TrackingRecHitAlgorithm {
virtual void beginRun(edm::Run const& run,
const edm::EventSetup& eventSetup,
const SiPixelTemplateDBObject* pixelTemplateDBObjectPtr,
std::vector<SiPixelTemplateStore>& tempStoreRef);
const std::vector<SiPixelTemplateStore>& tempStoreRef);

//this function will only be called once per event
virtual void beginEvent(edm::Event& event, const edm::EventSetup& eventSetup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class TrackingRecHitProducer : public edm::stream::EDProducer<> {
unsigned long long _trackerTopologyCacheID = 0;
std::map<unsigned int, TrackingRecHitPipe> _detIdPipes;
void setupDetIdPipes(const edm::EventSetup& eventSetup);
std::vector<SiPixelTemplateStore> _pixelTempStore; // pixel template storage
const edm::ESGetToken<SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd> siPixelTemplateDBObjectESToken_;
const edm::ESGetToken<std::vector<SiPixelTemplateStore>, SiPixelTemplateDBObjectESProducerRcd>
siPixelTemplateStoreESToken_;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryESToken_;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopologyESToken_;

Expand All @@ -69,6 +70,7 @@ class TrackingRecHitProducer : public edm::stream::EDProducer<> {

TrackingRecHitProducer::TrackingRecHitProducer(const edm::ParameterSet& config)
: siPixelTemplateDBObjectESToken_(esConsumes<edm::Transition::BeginRun>()),
siPixelTemplateStoreESToken_(esConsumes<edm::Transition::BeginRun>()),
trackerGeometryESToken_(esConsumes()),
trackerTopologyESToken_(esConsumes()) {
edm::ConsumesCollector consumeCollector = consumesCollector();
Expand Down Expand Up @@ -115,17 +117,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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ PixelTemplateSmearerBase::~PixelTemplateSmearerBase() {}
void PixelTemplateSmearerBase::beginRun(edm::Run const& run,
const edm::EventSetup& eventSetup,
const SiPixelTemplateDBObject* pixelTemplateDBObjectPtr,
std::vector<SiPixelTemplateStore>& tempStoreRef) {
const std::vector<SiPixelTemplateStore>& 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.
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SiPixelTemplateStore>& tempStoreRef) {
const std::vector<SiPixelTemplateStore>& tempStoreRef) {
// The default is to do nothing.
}

Expand Down
8 changes: 8 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,20 @@ def customiseForOffline(process):
return process


def customizeHLTfor42514(process):
for p in esproducers_by_type(process, 'SiPixelTemplateDBObjectESProducer'):
process.load('RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi')
break

return process

# CMSSW version specific customizations
def customizeHLTforCMSSW(process, menuType="GRun"):

process = customiseForOffline(process)

# add call to action function in proper order: newest last!
# process = customiseFor12718(process)
process = customizeHLTfor42514(process)

return process
1 change: 1 addition & 0 deletions RecoHI/HiTracking/python/HighPtTracking_PbPb_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from TrackingTools.TransientTrack.TransientTrackBuilder_cfi import * #also includes global tracking geometry
from RecoTracker.TransientTrackingRecHit.TTRHBuilders_cff import *
from RecoLocalTracker.SiPixelRecHits.PixelCPEESProducers_cff import * #cluster parameter estimator producer
from RecoLocalTracker.SiPixelRecHits.SiPixelTemplateStoreESProducer_cfi import SiPixelTemplateStoreESProducer
from RecoTracker.TkSeedingLayers.PixelLayerTriplets_cfi import *

### pixel primary vertices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class PixelCPEClusterRepair : public PixelCPEBase {
const TrackerGeometry &,
const TrackerTopology &,
const SiPixelLorentzAngle *,
const std::vector<SiPixelTemplateStore> *,
const SiPixelTemplateDBObject *,
const SiPixel2DTemplateDBObject *);

Expand Down Expand Up @@ -97,7 +98,8 @@ class PixelCPEClusterRepair : public PixelCPEBase {
void fill2DTemplIDs();

// Template storage
std::vector<SiPixelTemplateStore> thePixelTemp_;
std::vector<SiPixelTemplateStore> const *thePixelTemp_;
std::vector<SiPixelTemplateStore> thePixelTempCache_;
std::vector<SiPixelTemplateStore2D> thePixelTemp2D_;

int speed_;
Expand Down
Loading

0 comments on commit d835c8b

Please sign in to comment.