Skip to content

Commit

Permalink
simplify implementation of SiPixelQualityESProducer and use multiple …
Browse files Browse the repository at this point in the history
…instances of it
  • Loading branch information
missirol committed Aug 7, 2023
1 parent 4a98a53 commit 48ec58f
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,8 @@
# Default is "False".
siStripQualityESProducer.UseEmptyRunInfo = cms.bool(False)

from CalibTracker.SiPixelESProducers.SiPixelQualityESProducer_cfi import *
siPixelQualityESProducer.ListOfRecordToMerge = cms.VPSet(
cms.PSet( record = cms.string("SiPixelQualityFromDbRcd"),
tag = cms.string("")
),
cms.PSet( record = cms.string("SiPixelDetVOffRcd"),
tag = cms.string("")
)
)
from CalibTracker.SiPixelESProducers.siPixelQualityESProducer_cfi import *
from CalibTracker.SiPixelESProducers.siPixelQualityForRawToDigiESProducer_cfi import *

# Multiple scattering parametrisation
from RecoTracker.TkMSParametrization.multipleScatteringParametrisationMakerESProducer_cfi import *
96 changes: 24 additions & 72 deletions CalibTracker/SiPixelESProducers/plugins/SiPixelQualityESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,27 @@
//
//

// system include files
#include <memory>
#include <cassert>

// user include files
#include "CalibTracker/Records/interface/SiStripDependentRecords.h"
#include "CalibTracker/SiPixelESProducers/interface/SiPixelDetInfoFileReader.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
#include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
#include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h"
#include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h"
#include "CalibTracker/Records/interface/SiStripDependentRecords.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

using namespace edm;
#include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h"
#include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
#include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"

class SiPixelQualityESProducer : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
public:
SiPixelQualityESProducer(const edm::ParameterSet& iConfig);
~SiPixelQualityESProducer() override;
~SiPixelQualityESProducer() override = default;

std::unique_ptr<SiPixelQuality> produce(const SiPixelQualityRcd& iRecord);
std::unique_ptr<SiPixelQuality> produceWithLabel(const SiPixelQualityRcd& iRecord);
std::unique_ptr<SiPixelQuality> produceWithLabelRawToDigi(const SiPixelQualityRcd& iRecord);

static void fillDescriptions(edm::ConfigurationDescriptions&);

Expand All @@ -57,54 +45,29 @@ class SiPixelQualityESProducer : public edm::ESProducer, public edm::EventSetupR
const edm::IOVSyncValue&,
edm::ValidityInterval&) override;

struct Tokens {
Tokens() = default;
explicit Tokens(edm::ESConsumesCollector cc, const std::string& label) {
voffToken_ = cc.consumes();
dbobjectToken_ = cc.consumes(edm::ESInputTag{"", label});
}
edm::ESGetToken<SiStripDetVOff, SiPixelDetVOffRcd> voffToken_;
edm::ESGetToken<SiPixelQuality, SiPixelQualityFromDbRcd> dbobjectToken_;
};

std::unique_ptr<SiPixelQuality> get_pointer(const SiPixelQualityRcd& iRecord, const Tokens& tokens);

const Tokens defaultTokens_;
Tokens labelTokens_;
Tokens labelTokens_RawToDigi_;
edm::ESGetToken<SiPixelQuality, SiPixelQualityFromDbRcd> siPixelQualityFromDbToken_;
edm::ESGetToken<SiStripDetVOff, SiPixelDetVOffRcd> voffToken_;
};

//
// constructors and destructor
//
SiPixelQualityESProducer::SiPixelQualityESProducer(const edm::ParameterSet& iConfig) {
// setWhatProduced internally uses "appendToDataLabel" to name the output product of this ESProducer
auto const& appendToDataLabel = iConfig.getParameter<std::string>("appendToDataLabel");
auto esCC = setWhatProduced(this);

SiPixelQualityESProducer::SiPixelQualityESProducer(const edm::ParameterSet& conf_)
: defaultTokens_(setWhatProduced(this), "") {
edm::LogInfo("SiPixelQualityESProducer::SiPixelQualityESProducer");
// "siPixelQualityFromDbLabel" corresponds to the Label of a tag with Record
// "SiPixelQualityFromDbRcd" in the EventSetup (normally provided by the GlobalTag)
auto const& siPixelQualityFromDbLabel = iConfig.getParameter<std::string>("siPixelQualityFromDbLabel");
siPixelQualityFromDbToken_ = esCC.consumes(edm::ESInputTag{"", siPixelQualityFromDbLabel});
voffToken_ = esCC.consumes();

auto label = conf_.getParameter<std::string>("siPixelQualityLabel");

if (label == "forDigitizer") {
labelTokens_ =
Tokens(setWhatProduced(this, &SiPixelQualityESProducer::produceWithLabel, edm::es::Label(label)), label);
}

label = conf_.getParameter<std::string>("siPixelQualityLabel_RawToDigi");

if (label == "forRawToDigi") {
labelTokens_RawToDigi_ = Tokens(
setWhatProduced(this, &SiPixelQualityESProducer::produceWithLabelRawToDigi, edm::es::Label(label)), label);
}
findingRecord<SiPixelQualityRcd>();
}

SiPixelQualityESProducer::~SiPixelQualityESProducer() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
edm::LogInfo("SiPixelQualityESProducer")
<< "Module = \"" << description().label_ << "\" (appendToDataLabel = \"" << appendToDataLabel
<< "\", siPixelQualityFromDbLabel = \"" << siPixelQualityFromDbLabel << "\")";
}

std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::get_pointer(const SiPixelQualityRcd& iRecord,
const Tokens& tokens) {
std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQualityRcd& iRecord) {
///////////////////////////////////////////////////////
// errortype "whole" = int 0 in DB BadRocs = 65535 //
// errortype "tbmA" = int 1 in DB BadRocs = 255 //
Expand All @@ -118,23 +81,13 @@ std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::get_pointer(const SiPi
//BadModule.DetID = 1; BadModule.errorType = 0; BadModule.BadRocs = 65535; obj->addDisabledModule(BadModule);

//now the dbobject is the one copied from the db
auto dbptr = std::make_unique<SiPixelQuality>(iRecord.get(tokens.dbobjectToken_));
auto dbptr = std::make_unique<SiPixelQuality>(iRecord.get(siPixelQualityFromDbToken_));

//here is the magic line in which it switches off Bad Modules
dbptr->add(&(iRecord.get(tokens.voffToken_)));
dbptr->add(&(iRecord.get(voffToken_)));
return dbptr;
}

std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQualityRcd& iRecord) {
return get_pointer(iRecord, defaultTokens_);
}
std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produceWithLabel(const SiPixelQualityRcd& iRecord) {
return get_pointer(iRecord, labelTokens_);
}
std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produceWithLabelRawToDigi(const SiPixelQualityRcd& iRecord) {
return get_pointer(iRecord, labelTokens_RawToDigi_);
}

void SiPixelQualityESProducer::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
const edm::IOVSyncValue& iosv,
edm::ValidityInterval& oValidity) {
Expand All @@ -144,8 +97,7 @@ void SiPixelQualityESProducer::setIntervalFor(const edm::eventsetup::EventSetupR

void SiPixelQualityESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("siPixelQualityLabel", "");
desc.add<std::string>("siPixelQualityLabel_RawToDigi", "");
desc.add<std::string>("siPixelQualityFromDbLabel", "");
{
edm::ParameterSetDescription desc_ps;
desc_ps.add<std::string>("record", "SiPixelQualityFromDbRcd");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import FWCore.ParameterSet.Config as cms

from CalibTracker.SiPixelESProducers.siPixelQualityESProducer_cfi import siPixelQualityESProducer as _siPixelQualityESProducer

siPixelQualityForDigitizerESProducer = _siPixelQualityESProducer.clone(
appendToDataLabel = 'forDigitizer',
siPixelQualityFromDbLabel = 'forDigitizer'
)

# remove siPixelQualityForDigitizerESProducer when the modifier run2_SiPixel_2018 is not enabled
def _removeSiPixelQualityForDigitizerESProducer(process):
if hasattr(process, 'siPixelQualityForDigitizerESProducer'):
del process.siPixelQualityForDigitizerESProducer

from Configuration.Eras.Modifier_run2_SiPixel_2018_cff import run2_SiPixel_2018
removeSiPixelQualityForDigitizerESProducer_ = (~run2_SiPixel_2018).makeProcessModifier( _removeSiPixelQualityForDigitizerESProducer )
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import FWCore.ParameterSet.Config as cms

from CalibTracker.SiPixelESProducers.siPixelQualityESProducer_cfi import siPixelQualityESProducer as _siPixelQualityESProducer

siPixelQualityForRawToDigiESProducer = _siPixelQualityESProducer.clone(
appendToDataLabel = 'forRawToDigi',
siPixelQualityFromDbLabel = 'forRawToDigi'
)

# remove siPixelQualityForRawToDigiESProducer when the modifier siPixelQualityRawToDigi is not enabled
def _removeSiPixelQualityForRawToDigiESProducer(process):
if hasattr(process, 'siPixelQualityForRawToDigiESProducer'):
del process.siPixelQualityForRawToDigiESProducer

from Configuration.ProcessModifiers.siPixelQualityRawToDigi_cff import siPixelQualityRawToDigi
removeSiPixelQualityForRawToDigiESProducer_ = (~siPixelQualityRawToDigi).makeProcessModifier( _removeSiPixelQualityForRawToDigiESProducer )
9 changes: 1 addition & 8 deletions CondTools/SiPixel/test/SiPixelBadModule_ESProducer_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
process.GlobalTag.globaltag = 'START311_V1::All'

###### Quality ESProducer --- copied from SiStripESProducer
process.load("CalibTracker.SiPixelESProducers.SiPixelQualityESProducer_cfi")
process.load("CalibTracker.SiPixelESProducers.siPixelQualityESProducer_cfi")

process.GlobalTag.toGet = cms.VPSet(
cms.PSet(
Expand Down Expand Up @@ -66,10 +66,3 @@
)

process.p = cms.Path(process.BadModuleReader)







14 changes: 14 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,19 @@ def customizeHLTfor42410(process):

return process

def customizeHLTfor42497(process):
for producer in esproducers_by_type(process, 'SiPixelQualityESProducer'):
producer.siPixelQualityFromDbLabel = cms.string('')
producer.appendToDataLabel = ''
for parName in [
'siPixelQualityLabel',
'siPixelQualityLabel_RawToDigi',
]:
if hasattr(producer, parName):
producer.__delattr__(parName)

return process

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

Expand All @@ -281,5 +294,6 @@ def customizeHLTforCMSSW(process, menuType="GRun"):
process = customizeHLTfor41815(process)
process = customizeHLTfor41632(process)
process = customizeHLTfor42410(process)
process = customizeHLTfor42497(process)

return process
4 changes: 1 addition & 3 deletions SimGeneral/MixingModule/python/SiPixelSimParameters_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ def _modifyPixelDigitizerForRun3( digitizer ):
phase1Pixel.toModify( SiPixelSimBlock, func=_modifyPixelDigitizerForPhase1Pixel )

# use Label 'forDigitizer' for years >= 2018
from CalibTracker.SiPixelESProducers.SiPixelQualityESProducer_cfi import siPixelQualityESProducer
from Configuration.Eras.Modifier_run2_SiPixel_2018_cff import run2_SiPixel_2018
run2_SiPixel_2018.toModify(siPixelQualityESProducer,siPixelQualityLabel = 'forDigitizer',)
run2_SiPixel_2018.toModify(SiPixelSimBlock, SiPixelQualityLabel = 'forDigitizer',)
run2_SiPixel_2018.toModify(SiPixelSimBlock, SiPixelQualityLabel = 'forDigitizer')

# change the digitizer threshold for Run3
# - new layer1 installed: expected improvement in timing alignment of L1 and L2
Expand Down
3 changes: 3 additions & 0 deletions SimGeneral/MixingModule/python/pixelDigitizer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from Configuration.ProcessModifiers.premix_stage1_cff import premix_stage1
premix_stage1.toModify(pixelDigitizer, makeDigiSimLinks = False)

# ESProducer for SiPixelQuality with "forDigitizer" label
from CalibTracker.SiPixelESProducers.siPixelQualityForDigitizerESProducer_cfi import *

# Customize here instead of SiPixelSimBlock as the latter is imported
# also to DataMixer configuration, and the original version is needed
# there in stage2. Customize before phase2_tracker because this
Expand Down

0 comments on commit 48ec58f

Please sign in to comment.