Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated exists API in favor of fillDescriptions in SiPixelQualityESProducer #40135

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -36,6 +36,8 @@
#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

using namespace edm;

Expand All @@ -48,6 +50,8 @@ class SiPixelQualityESProducer : public edm::ESProducer, public edm::EventSetupR
std::unique_ptr<SiPixelQuality> produceWithLabel(const SiPixelQualityRcd& iRecord);
std::unique_ptr<SiPixelQuality> produceWithLabelRawToDigi(const SiPixelQualityRcd& iRecord);

static void fillDescriptions(edm::ConfigurationDescriptions&);

private:
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
const edm::IOVSyncValue&,
Expand Down Expand Up @@ -78,17 +82,14 @@ SiPixelQualityESProducer::SiPixelQualityESProducer(const edm::ParameterSet& conf
: defaultTokens_(setWhatProduced(this), "") {
edm::LogInfo("SiPixelQualityESProducer::SiPixelQualityESProducer");

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

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

label = conf_.exists("siPixelQualityLabel_RawToDigi")
? conf_.getParameter<std::string>("siPixelQualityLabel_RawToDigi")
: std::string{};
label = conf_.getParameter<std::string>("siPixelQualityLabel_RawToDigi");

if (label == "forRawToDigi") {
labelTokens_RawToDigi_ = Tokens(
Expand Down Expand Up @@ -141,4 +142,31 @@ void SiPixelQualityESProducer::setIntervalFor(const edm::eventsetup::EventSetupR
oValidity = infinity;
}

void SiPixelQualityESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::string>("siPixelQualityLabel", "");
desc.add<std::string>("siPixelQualityLabel_RawToDigi", "");
{
edm::ParameterSetDescription desc_ps;
desc_ps.add<std::string>("record", "SiPixelQualityFromDbRcd");
desc_ps.add<std::string>("tag", "");
std::vector<edm::ParameterSet> default_ps;
default_ps.reserve(2);
{
edm::ParameterSet temp;
temp.addParameter<std::string>("record", "SiPixelQualityFromDbRcd");
temp.addParameter<std::string>("tag", "");
default_ps.push_back(temp);
}
{
edm::ParameterSet temp;
temp.addParameter<std::string>("record", "SiPixelDetVOffRcd");
temp.addParameter<std::string>("tag", "");
default_ps.push_back(temp);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole section above could be replaced by a loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was also a literal copy-paste from the edmPythonConfigToCppValidation executable with some changes in variable names to make them a bit more descriptive. I am not actually sure what you want to put in the loop. If you are referring to the two default_ps.push_back(temp); calls, the record parameter differs in the two instances and introducing some if statements would seem less elegant that this implementation proposed by edmPythonConfigToCppValidation. This I leave as is for now unless I misunderstood what you meant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calls, the record parameter differs in the two instances and introducing some if

No need of an if, you can just declare an array with record names and loop over it with range-based loop while doing the push_back

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calls, the record parameter differs in the two instances and introducing some if

No need of an if, you can just declare an array with record names and loop over it with range-based loop while doing the push_back

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I find the readability of the code dumped by edmPythonConfigToCppValidation better than having it in a loop form because it resembles more the layout of the final cfi file. Unless there is some performance issue with the current implementation, which I doubt, I leave it as is :) If it bothers you that much, the branch is under the CMSTrackerDPG organization ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we have different taste in readability. Anyway It does not bother me at all, it was said upfront it's "cosmetics".

desc.addVPSet("ListOfRecordToMerge", desc_ps, default_ps);
}
descriptions.addWithDefaultLabel(desc);
}

DEFINE_FWK_EVENTSETUP_MODULE(SiPixelQualityESProducer);
@@ -1,9 +1,6 @@
import FWCore.ParameterSet.Config as cms

siPixelQualityESProducer = cms.ESProducer("SiPixelQualityESProducer",
siPixelQualityLabel = cms.string(""),
siPixelQualityLabel_RawToDigi = cms.string("")
)
from CalibTracker.SiPixelESProducers.siPixelQualityESProducer_cfi import siPixelQualityESProducer

from Configuration.ProcessModifiers.siPixelQualityRawToDigi_cff import siPixelQualityRawToDigi
siPixelQualityRawToDigi.toModify(siPixelQualityESProducer,
Expand Down