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

[12.3.X] CalibTracker: fallback to the OnlineLuminosityRecord when SCAL is not available #38385

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions CalibTracker/SiStripCommon/plugins/ShallowEventDataProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ShallowEventDataProducer::ShallowEventDataProducer(const edm::ParameterSet& iCon
#endif

scalerToken_ = consumes<LumiScalersCollection>(iConfig.getParameter<edm::InputTag>("lumiScalers"));
metaDataToken_ = consumes<OnlineLuminosityRecord>(iConfig.getParameter<edm::InputTag>("metadata"));
}

void ShallowEventDataProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
Expand Down Expand Up @@ -57,15 +58,20 @@ void ShallowEventDataProducer::produce(edm::StreamID, edm::Event& iEvent, const
#endif

// Luminosity informations
edm::Handle<LumiScalersCollection> lumiScalers;
edm::Handle<LumiScalersCollection> lumiScalers = iEvent.getHandle(scalerToken_);
edm::Handle<OnlineLuminosityRecord> metaData = iEvent.getHandle(metaDataToken_);

float instLumi_ = 0;
float PU_ = 0;
iEvent.getByToken(scalerToken_, lumiScalers);
if (lumiScalers.isValid()) {

if (lumiScalers.isValid() && !lumiScalers->empty()) {
if (lumiScalers->begin() != lumiScalers->end()) {
instLumi_ = lumiScalers->begin()->instantLumi();
PU_ = lumiScalers->begin()->pileup();
}
} else if (metaData.isValid()) {
instLumi_ = metaData->instLumi();
PU_ = metaData->avgPileUp();
} else {
edm::LogInfo("ShallowEventDataProducer")
<< "LumiScalers collection not found in the event; will write dummy values";
Expand Down
2 changes: 2 additions & 0 deletions CalibTracker/SiStripCommon/plugins/ShallowEventDataProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Utilities/interface/EDPutToken.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
#include "DataFormats/OnlineMetaData/interface/OnlineLuminosityRecord.h"
#include "DataFormats/Scalers/interface/LumiScalers.h"
#include <vector>

Expand All @@ -15,6 +16,7 @@ class ShallowEventDataProducer : public edm::global::EDProducer<> {
private:
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
edm::EDGetTokenT<LumiScalersCollection> scalerToken_;
edm::EDGetTokenT<OnlineLuminosityRecord> metaDataToken_;

edm::EDPutTokenT<unsigned int> runPut_;
edm::EDPutTokenT<unsigned int> eventPut_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
shallowEventRun = cms.EDProducer(
"ShallowEventDataProducer",
trigRecord = cms.InputTag('gtDigis'),
lumiScalers = cms.InputTag("scalersRawToDigi")
lumiScalers = cms.InputTag("scalersRawToDigi"),
metadata = cms.InputTag('onlineMetaDataDigis')
)
19 changes: 14 additions & 5 deletions CalibTracker/SiStripHitEfficiency/plugins/HitEff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
using namespace std;
HitEff::HitEff(const edm::ParameterSet& conf)
: scalerToken_(consumes<LumiScalersCollection>(conf.getParameter<edm::InputTag>("lumiScalers"))),
metaDataToken_(consumes<OnlineLuminosityRecord>(conf.getParameter<edm::InputTag>("metadata"))),
commonModeToken_(mayConsume<edm::DetSetVector<SiStripRawDigi> >(conf.getParameter<edm::InputTag>("commonMode"))),
siStripClusterInfo_(consumesCollector()),
combinatorialTracks_token_(
Expand Down Expand Up @@ -181,14 +182,22 @@ void HitEff::analyze(const edm::Event& e, const edm::EventSetup& es) {
int bunch_nr = e.bunchCrossing();

// Luminosity informations
edm::Handle<LumiScalersCollection> lumiScalers;
edm::Handle<LumiScalersCollection> lumiScalers = e.getHandle(scalerToken_);
edm::Handle<OnlineLuminosityRecord> metaData = e.getHandle(metaDataToken_);

instLumi = 0;
PU = 0;
if (addLumi_) {
e.getByToken(scalerToken_, lumiScalers);
if (lumiScalers->begin() != lumiScalers->end()) {
instLumi = lumiScalers->begin()->instantLumi();
PU = lumiScalers->begin()->pileup();
if (lumiScalers.isValid() && !lumiScalers->empty()) {
if (lumiScalers->begin() != lumiScalers->end()) {
instLumi = lumiScalers->begin()->instantLumi();
PU = lumiScalers->begin()->pileup();
}
} else if (metaData.isValid()) {
instLumi = metaData->instLumi();
PU = metaData->avgPileUp();
} else {
edm::LogWarning("SiStripHitEfficiencyWorker") << "could not find a source for the Luminosity and PU";
}
}

Expand Down
2 changes: 2 additions & 0 deletions CalibTracker/SiStripHitEfficiency/plugins/HitEff.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementError.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/MeasurementVector.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/OnlineMetaData/interface/OnlineLuminosityRecord.h"
#include "DataFormats/Scalers/interface/LumiScalers.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/SiStripDigi/interface/SiStripRawDigi.h"
Expand Down Expand Up @@ -61,6 +62,7 @@ class HitEff : public edm::one::EDAnalyzer<> {
// ----------member data ---------------------------

const edm::EDGetTokenT<LumiScalersCollection> scalerToken_;
const edm::EDGetTokenT<OnlineLuminosityRecord> metaDataToken_;
const edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > commonModeToken_;

SiStripClusterInfo siStripClusterInfo_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/GeometryVector/interface/GlobalVector.h"
#include "DataFormats/GeometryVector/interface/LocalVector.h"
#include "DataFormats/OnlineMetaData/interface/OnlineLuminosityRecord.h"
#include "DataFormats/Scalers/interface/LumiScalers.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/SiStripCommon/interface/ConstantsForHardwareSystems.h" /* for STRIPS_PER_APV*/
Expand Down Expand Up @@ -85,6 +86,7 @@ class SiStripHitEfficiencyWorker : public DQMEDAnalyzer {

// event data tokens
const edm::EDGetTokenT<LumiScalersCollection> scalerToken_;
const edm::EDGetTokenT<OnlineLuminosityRecord> metaDataToken_;
const edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi>> commonModeToken_;
const edm::EDGetTokenT<reco::TrackCollection> combinatorialTracks_token_;
const edm::EDGetTokenT<std::vector<Trajectory>> trajectories_token_;
Expand Down Expand Up @@ -180,6 +182,7 @@ class SiStripHitEfficiencyWorker : public DQMEDAnalyzer {

SiStripHitEfficiencyWorker::SiStripHitEfficiencyWorker(const edm::ParameterSet& conf)
: scalerToken_(consumes<LumiScalersCollection>(conf.getParameter<edm::InputTag>("lumiScalers"))),
metaDataToken_(consumes<OnlineLuminosityRecord>(conf.getParameter<edm::InputTag>("metadata"))),
commonModeToken_(mayConsume<edm::DetSetVector<SiStripRawDigi>>(conf.getParameter<edm::InputTag>("commonMode"))),
combinatorialTracks_token_(
consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("combinatorialTracks"))),
Expand Down Expand Up @@ -363,16 +366,25 @@ void SiStripHitEfficiencyWorker::analyze(const edm::Event& e, const edm::EventSe
// Step A: Get Inputs

// Luminosity informations
edm::Handle<LumiScalersCollection> lumiScalers;
edm::Handle<LumiScalersCollection> lumiScalers = e.getHandle(scalerToken_);
edm::Handle<OnlineLuminosityRecord> metaData = e.getHandle(metaDataToken_);

float instLumi = 0;
float PU = 0;
if (addLumi_) {
e.getByToken(scalerToken_, lumiScalers);
if (lumiScalers->begin() != lumiScalers->end()) {
instLumi = lumiScalers->begin()->instantLumi();
PU = lumiScalers->begin()->pileup();
if (lumiScalers.isValid() && !lumiScalers->empty()) {
if (lumiScalers->begin() != lumiScalers->end()) {
instLumi = lumiScalers->begin()->instantLumi();
PU = lumiScalers->begin()->pileup();
}
} else if (metaData.isValid()) {
instLumi = metaData->instLumi();
PU = metaData->avgPileUp();
} else {
edm::LogWarning("SiStripHitEfficiencyWorker") << "could not find a source for the Luminosity and PU";
}
}

h_bx->Fill(e.bunchCrossing());
h_instLumi->Fill(instLumi);
h_PU->Fill(PU);
Expand Down Expand Up @@ -989,6 +1001,7 @@ void SiStripHitEfficiencyWorker::fillDescriptions(edm::ConfigurationDescriptions
desc.add<edm::InputTag>("combinatorialTracks", edm::InputTag{"generalTracks"});
desc.add<edm::InputTag>("commonMode", edm::InputTag{"siStripDigis", "CommonMode"});
desc.add<edm::InputTag>("lumiScalers", edm::InputTag{"scalersRawToDigi"});
desc.add<edm::InputTag>("metadata", edm::InputTag{"onlineMetaDataDigis"});
desc.add<edm::InputTag>("siStripClusters", edm::InputTag{"siStripClusters"});
desc.add<edm::InputTag>("siStripDigis", edm::InputTag{"siStripDigis"});
desc.add<edm::InputTag>("trackerEvent", edm::InputTag{"MeasurementTrackerEvent"});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
siStripDigis = cms.InputTag("siStripDigis"),
trackerEvent = cms.InputTag("MeasurementTrackerEvent"),
lumiScalers = cms.InputTag("scalersRawToDigi"),
metadata = cms.InputTag('onlineMetaDataDigis'),
addLumi = cms.untracked.bool(False),
commonMode = cms.InputTag("siStripDigis", "CommonMode"),
addCommonMode = cms.untracked.bool(False),
Expand Down