Skip to content

Commit

Permalink
Merge pull request #25811 from makortel/pixelClusterizerModernize
Browse files Browse the repository at this point in the history
Some modernization for SiPixelClusterProducer
  • Loading branch information
cmsbuild committed Feb 5, 2019
2 parents f50d0f2 + aeeec1b commit 8957186
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 92 deletions.
Expand Up @@ -21,6 +21,7 @@
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"

Expand All @@ -33,6 +34,8 @@ class SiPixelGainCalibrationServiceBase {

SiPixelGainCalibrationServiceBase(){};
virtual ~SiPixelGainCalibrationServiceBase(){};

static void fillPSetDescription(edm::ParameterSetDescription& desc) {}

// default inplementation from PixelThresholdClusterizer
virtual void calibrate(uint32_t detID, DigiIterator b, DigiIterator e, float conversionFactor, float offset, int * electron);
Expand Down
7 changes: 7 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Expand Up @@ -47,11 +47,18 @@ def customiseFor2017DtUnpacking(process):

return process

def customiseFor25811(process):
for prod in producers_by_type(process, "SiPixelClusterProducer"):
if hasattr(prod, "MissCalibrate") and not prod.MissCalibrate.isTracked():
prod.MissCalibrate = cms.bool(prod.MissCalibrate.value())
return process

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

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

process = customiseFor25811(process)

return process
Expand Up @@ -58,7 +58,7 @@ PixelThresholdClusterizer::PixelThresholdClusterizer
thePhase2KinkADC( conf.getParameter<int>("Phase2KinkADC") ),
theNumOfRows(0), theNumOfCols(0), theDetid(0),
// Get the constants for the miss-calibration studies
doMissCalibrate( conf.getUntrackedParameter<bool>("MissCalibrate",true) ),
doMissCalibrate( conf.getParameter<bool>("MissCalibrate") ),
doSplitClusters( conf.getParameter<bool>("SplitClusters") )
{
theBuffer.setSize( theNumOfRows, theNumOfCols );
Expand All @@ -69,28 +69,22 @@ PixelThresholdClusterizer::~PixelThresholdClusterizer() {}

// Configuration descriptions
void
PixelThresholdClusterizer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
// siPixelClusters
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("src", edm::InputTag("siPixelDigis"));
PixelThresholdClusterizer::fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<int>("ChannelThreshold", 1000);
desc.addUntracked<bool>("MissCalibrate", true);
desc.add<bool>("MissCalibrate", true);
desc.add<bool>("SplitClusters", false);
desc.add<int>("VCaltoElectronGain", 65);
desc.add<int>("VCaltoElectronGain_L1", 65);
desc.add<int>("VCaltoElectronOffset", -414);
desc.add<int>("VCaltoElectronOffset_L1", -414);
desc.add<std::string>("payloadType", "Offline");
desc.add<int>("SeedThreshold", 1000);
desc.add<int>("ClusterThreshold_L1", 4000);
desc.add<int>("ClusterThreshold", 4000);
desc.add<int>("maxNumberOfClusters", -1);
desc.add<double>("ElectronPerADCGain", 135.);
desc.add<bool>("Phase2Calibration", false);
desc.add<int>("Phase2ReadoutMode", -1);
desc.add<double>("Phase2DigiBaseline", 1200.);
desc.add<int>("Phase2KinkADC", 8);
descriptions.add("siClustersFromPixelThresholdClusterizer", desc);
}

//----------------------------------------------------------------------------
Expand Down
Expand Up @@ -50,7 +50,6 @@
// Parameter Set:
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include <vector>
Expand All @@ -74,7 +73,7 @@ class dso_hidden PixelThresholdClusterizer final : public PixelClusterizerBase {
const std::vector<short>& badChannels,
edmNew::DetSetVector<SiPixelCluster>::FastFiller& output) override { clusterizeDetUnitT(input, pixDet, tTopo, badChannels, output); }

static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
static void fillPSetDescription(edm::ParameterSetDescription& desc);

private:

Expand Down
Expand Up @@ -32,6 +32,7 @@
// Framework
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

// STL
#include <vector>
Expand All @@ -48,26 +49,22 @@
//---------------------------------------------------------------------------
SiPixelClusterProducer::SiPixelClusterProducer(edm::ParameterSet const& conf)
:
theSiPixelGainCalibration_(nullptr),
clusterMode_( conf.getUntrackedParameter<std::string>("ClusterMode","PixelThresholdClusterizer") ),
clusterizer_(nullptr), // the default, in case we fail to make one
readyToCluster_(false), // since we obviously aren't
maxTotalClusters_( conf.getParameter<int32_t>( "maxNumberOfClusters" ) ),
payloadType_( conf.getParameter<std::string>( "payloadType" ) )
tPutPixelClusters(produces<SiPixelClusterCollectionNew>()),
clusterMode_( conf.getParameter<std::string>("ClusterMode") ),
maxTotalClusters_( conf.getParameter<int32_t>( "maxNumberOfClusters" ) )
{
if ( clusterMode_ == "PixelThresholdReclusterizer" )
tPixelClusters = consumes<SiPixelClusterCollectionNew>( conf.getParameter<edm::InputTag>("src") );
else
tPixelDigi = consumes<edm::DetSetVector<PixelDigi>>( conf.getParameter<edm::InputTag>("src") );
//--- Declare to the EDM what kind of collections we will be making.
produces<SiPixelClusterCollectionNew>();

if (strcmp(payloadType_.c_str(), "HLT") == 0)
theSiPixelGainCalibration_ = new SiPixelGainCalibrationForHLTService(conf);
else if (strcmp(payloadType_.c_str(), "Offline") == 0)
theSiPixelGainCalibration_ = new SiPixelGainCalibrationOfflineService(conf);
else if (strcmp(payloadType_.c_str(), "Full") == 0)
theSiPixelGainCalibration_ = new SiPixelGainCalibrationService(conf);
const auto& payloadType = conf.getParameter<std::string>( "payloadType" );
if (payloadType == "HLT")
theSiPixelGainCalibration_ = std::make_unique<SiPixelGainCalibrationForHLTService>(conf);
else if (payloadType == "Offline")
theSiPixelGainCalibration_ = std::make_unique<SiPixelGainCalibrationOfflineService>(conf);
else if (payloadType == "Full")
theSiPixelGainCalibration_ = std::make_unique<SiPixelGainCalibrationService>(conf);

//--- Make the algorithm(s) according to what the user specified
//--- in the ParameterSet.
Expand All @@ -76,10 +73,21 @@
}

// Destructor
SiPixelClusterProducer::~SiPixelClusterProducer() {
delete clusterizer_;
delete theSiPixelGainCalibration_;
}
SiPixelClusterProducer::~SiPixelClusterProducer() = default;

void SiPixelClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;

desc.add<edm::InputTag>("src", edm::InputTag("siPixelDigis"));
desc.add<std::string>("ClusterMode", "PixelThresholdClusterizer");
desc.add<int>("maxNumberOfClusters", -1)->setComment("-1 means no limit");
desc.add<std::string>("payloadType", "Offline")->setComment("Options: HLT - column granularity, Offline - gain:col/ped:pix");

PixelThresholdClusterizer::fillPSetDescription(desc);
SiPixelGainCalibrationServiceBase::fillPSetDescription(desc); // no-op, but in principle the structures are there...

descriptions.add("SiPixelClusterizerDefault", desc);
}


//---------------------------------------------------------------------------
Expand Down Expand Up @@ -120,7 +128,7 @@

// Step D: write output to file
output->shrink_to_fit();
e.put(std::move(output));
e.put(tPutPixelClusters, std::move(output));

}

Expand All @@ -132,16 +140,14 @@
void SiPixelClusterProducer::setupClusterizer(const edm::ParameterSet& conf) {

if ( clusterMode_ == "PixelThresholdReclusterizer" || clusterMode_ == "PixelThresholdClusterizer" ) {
clusterizer_ = new PixelThresholdClusterizer(conf);
clusterizer_->setSiPixelGainCalibrationService(theSiPixelGainCalibration_);
readyToCluster_ = true;
clusterizer_ = std::make_unique<PixelThresholdClusterizer>(conf);
clusterizer_->setSiPixelGainCalibrationService(theSiPixelGainCalibration_.get());
}
else {
edm::LogError("SiPixelClusterProducer") << "[SiPixelClusterProducer]:"
throw cms::Exception("Configuration") << "[SiPixelClusterProducer]:"
<<" choice " << clusterMode_ << " is invalid.\n"
<< "Possible choices:\n"
<< " PixelThresholdClusterizer";
readyToCluster_ = false;
}
}

Expand All @@ -153,13 +159,6 @@
void SiPixelClusterProducer::run(const T & input,
const edm::ESHandle<TrackerGeometry> & geom,
edmNew::DetSetVector<SiPixelCluster> & output) {
if ( ! readyToCluster_ ) {
edm::LogError("SiPixelClusterProducer")
<<" at least one clusterizer is not ready -- can't run!" ;
// TO DO: throw an exception here? The user may want to know...
return; // clusterizer is invalid, bail out
}

int numberOfDetUnits = 0;
int numberOfClusters = 0;

Expand Down
Expand Up @@ -47,6 +47,7 @@
#include "FWCore/Framework/interface/ESHandle.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/Utilities/interface/InputTag.h"

class dso_hidden SiPixelClusterProducer final : public edm::stream::EDProducer<> {
Expand All @@ -55,6 +56,8 @@
explicit SiPixelClusterProducer(const edm::ParameterSet& conf);
~SiPixelClusterProducer() override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

void setupClusterizer(const edm::ParameterSet& conf);

//--- The top-level event method.
Expand All @@ -69,17 +72,15 @@
private:
edm::EDGetTokenT<SiPixelClusterCollectionNew> tPixelClusters;
edm::EDGetTokenT<edm::DetSetVector<PixelDigi>> tPixelDigi;
edm::EDPutTokenT<SiPixelClusterCollectionNew> tPutPixelClusters;
// TO DO: maybe allow a map of pointers?
SiPixelGainCalibrationServiceBase * theSiPixelGainCalibration_;
std::unique_ptr<SiPixelGainCalibrationServiceBase> theSiPixelGainCalibration_;
const std::string clusterMode_; // user's choice of the clusterizer
PixelClusterizerBase * clusterizer_; // what we got (for now, one ptr to base class)
bool readyToCluster_; // needed clusterizers valid => good to go!
std::unique_ptr<PixelClusterizerBase> clusterizer_; // what we got (for now, one ptr to base class)
const TrackerTopology* tTopo_; // needed to get correct layer number

//! Optional limit on the total number of clusters
const int32_t maxTotalClusters_;

const std::string payloadType_;
};


Expand Down
@@ -1,61 +1,32 @@

import FWCore.ParameterSet.Config as cms

#
from CondTools.SiPixel.SiPixelGainCalibrationService_cfi import *
siPixelClusters = cms.EDProducer("SiPixelClusterProducer",
SiPixelGainCalibrationServiceParameters,
src = cms.InputTag("siPixelDigis"),
ChannelThreshold = cms.int32(1000),
MissCalibrate = cms.untracked.bool(True),
SplitClusters = cms.bool(False),
VCaltoElectronGain = cms.int32(65),
VCaltoElectronGain_L1 = cms.int32(65),
VCaltoElectronOffset = cms.int32(-414),
VCaltoElectronOffset_L1 = cms.int32(-414),
# **************************************
# **** payLoadType Options ****
# **** HLT - column granularity ****
# **** Offline - gain:col/ped:pix ****
# **************************************
payloadType = cms.string('Offline'),
#payloadType = cms.string('Full'),
SeedThreshold = cms.int32(1000),
ClusterThreshold = cms.int32(4000),
ClusterThreshold_L1 = cms.int32(4000),
# **************************************
maxNumberOfClusters = cms.int32(-1), # -1 means no limit.
ElectronPerADCGain = cms.double(135.0),
Phase2Calibration = cms.bool(False),
Phase2ReadoutMode = cms.int32(-1),
Phase2DigiBaseline = cms.double(1200.),
Phase2KinkADC = cms.int32(8),
)
from RecoLocalTracker.SiPixelClusterizer.SiPixelClusterizerDefault_cfi import SiPixelClusterizerDefault as _SiPixelClusterizerDefault
siPixelClusters = _SiPixelClusterizerDefault.clone()

# phase1 pixel
from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel
phase1Pixel.toModify(siPixelClusters,
VCaltoElectronGain = cms.int32(47), # L2-4: 47 +- 4.7
VCaltoElectronGain_L1 = cms.int32(50), # L1: 49.6 +- 2.6
VCaltoElectronOffset = cms.int32(-60), # L2-4: -60 +- 130
VCaltoElectronOffset_L1 = cms.int32(-670), # L1: -670 +- 220
ChannelThreshold = cms.int32(10),
SeedThreshold = cms.int32(1000),
ClusterThreshold = cms.int32(4000),
ClusterThreshold_L1 = cms.int32(2000)

VCaltoElectronGain = 47, # L2-4: 47 +- 4.7
VCaltoElectronGain_L1 = 50, # L1: 49.6 +- 2.6
VCaltoElectronOffset = -60, # L2-4: -60 +- 130
VCaltoElectronOffset_L1 = -670, # L1: -670 +- 220
ChannelThreshold = 10,
SeedThreshold = 1000,
ClusterThreshold = 4000,
ClusterThreshold_L1 = 2000
)

# Need these until phase2 pixel templates are used
from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
phase2_tracker.toModify(siPixelClusters, # FIXME
src = cms.InputTag('simSiPixelDigis', "Pixel"),
src = 'simSiPixelDigis:Pixel',
MissCalibrate = False,
Phase2Calibration = cms.bool(True),
Phase2ReadoutMode = cms.int32(-1), # Flag to decide Readout Mode : linear TDR (-1), dual slope with slope parameters (+1,+2,+3,+4 ...) with threshold subtraction
Phase2DigiBaseline = cms.double(1200.),
Phase2KinkADC = cms.int32(8),
ElectronPerADCGain = cms.double(600.) # it can be changed to something else (e.g. 135e) if needed
Phase2Calibration = True,
Phase2ReadoutMode = -1, # Flag to decide Readout Mode : linear TDR (-1), dual slope with slope parameters (+1,+2,+3,+4 ...) with threshold subtraction
Phase2DigiBaseline = 1200.,
Phase2KinkADC = 8,
ElectronPerADCGain = 600. # it can be changed to something else (e.g. 135e) if needed
)
from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2
(premix_stage2 & phase2_tracker).toModify(siPixelClusters,
Expand Down

0 comments on commit 8957186

Please sign in to comment.