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

Migrate ECAL Validation codes to ESConsumes #34637

Merged
merged 3 commits into from
Jul 29, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <memory>

// user include files
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
Expand Down Expand Up @@ -45,7 +45,7 @@ class TFile;

class EcalSimPhotonMCTruth;

class ContainmentCorrectionAnalyzer : public edm::EDAnalyzer {
class ContainmentCorrectionAnalyzer : public edm::one::EDAnalyzer<> {
public:
explicit ContainmentCorrectionAnalyzer(const edm::ParameterSet &);
~ContainmentCorrectionAnalyzer() override;
Expand All @@ -66,6 +66,7 @@ class ContainmentCorrectionAnalyzer : public edm::EDAnalyzer {
edm::EDGetTokenT<reco::SuperClusterCollection> EndcapSuperClusterCollection_;
edm::EDGetTokenT<EcalRecHitCollection> reducedBarrelRecHitCollection_;
edm::EDGetTokenT<EcalRecHitCollection> reducedEndcapRecHitCollection_;
edm::ESGetToken<CaloTopology, CaloTopologyRecord> pTopologyToken;

int nMCphotons;
std::vector<float> mcEnergy, mcEta, mcPhi, mcPt;
Expand Down
7 changes: 3 additions & 4 deletions Validation/EcalClusters/src/ContainmentCorrectionAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace edm;
using namespace std;
using namespace reco;

ContainmentCorrectionAnalyzer::ContainmentCorrectionAnalyzer(const ParameterSet &ps) {
ContainmentCorrectionAnalyzer::ContainmentCorrectionAnalyzer(const ParameterSet &ps) : pTopologyToken(esConsumes()) {
BarrelSuperClusterCollection_ =
consumes<reco::SuperClusterCollection>(ps.getParameter<InputTag>("BarrelSuperClusterCollection"));
EndcapSuperClusterCollection_ =
Expand Down Expand Up @@ -111,10 +111,9 @@ void ContainmentCorrectionAnalyzer::analyze(const Event &evt, const EventSetup &
}

const CaloTopology *topology = nullptr;
ESHandle<CaloTopology> pTopology;
es.get<CaloTopologyRecord>().get(pTopology);
auto pTopology = es.getHandle(pTopologyToken);
if (pTopology.isValid())
topology = pTopology.product();
topology = &es.getData(pTopologyToken);

std::vector<EcalSimPhotonMCTruth> photons = findMcTruth(theSimTracks, theSimVertexes);

Expand Down
5 changes: 4 additions & 1 deletion Validation/EcalDigis/interface/EcalBarrelDigisValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include <map>
#include "DQMServices/Core/interface/DQMEDAnalyzer.h"

#include <Validation/EcalDigis/interface/EcalBarrelDigisValidation.h>
#include "CalibCalorimetry/EcalTrivialCondModules/interface/EcalTrivialConditionRetriever.h"

class EcalBarrelDigisValidation : public DQMEDAnalyzer {
typedef std::map<uint32_t, float, std::less<uint32_t> > MapType;

Expand All @@ -55,7 +58,7 @@ class EcalBarrelDigisValidation : public DQMEDAnalyzer {
std::string outputFile_;

edm::EDGetTokenT<EBDigiCollection> EBdigiCollection_;

edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> pAgc;
std::map<int, double, std::less<int> > gainConv_;

double barrelADCtoGeV_;
Expand Down
3 changes: 3 additions & 0 deletions Validation/EcalDigis/interface/EcalDigisValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
#include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
#include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
#include <Validation/EcalDigis/interface/EcalDigisValidation.h>
#include "CalibCalorimetry/EcalTrivialCondModules/interface/EcalTrivialConditionRetriever.h"

#include <iostream>
#include <fstream>
Expand Down Expand Up @@ -75,6 +77,7 @@ class EcalDigisValidation : public DQMEDAnalyzer {
edm::EDGetTokenT<EBDigiCollection> EBdigiCollectionToken_;
edm::EDGetTokenT<EEDigiCollection> EEdigiCollectionToken_;
edm::EDGetTokenT<ESDigiCollection> ESdigiCollectionToken_;
edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> pAgc;

edm::EDGetTokenT<CrossingFrame<PCaloHit> > crossingFramePCaloHitEBToken_, crossingFramePCaloHitEEToken_,
crossingFramePCaloHitESToken_;
Expand Down
4 changes: 4 additions & 0 deletions Validation/EcalDigis/interface/EcalEndcapDigisValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include "DataFormats/EcalDigi/interface/EEDataFrame.h"
#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"

#include <Validation/EcalDigis/interface/EcalEndcapDigisValidation.h>
#include "CalibCalorimetry/EcalTrivialCondModules/interface/EcalTrivialConditionRetriever.h"

#include <iostream>
#include <fstream>
#include <vector>
Expand Down Expand Up @@ -56,6 +59,7 @@ class EcalEndcapDigisValidation : public DQMEDAnalyzer {
std::string outputFile_;

edm::EDGetTokenT<EEDigiCollection> EEdigiCollectionToken_;
edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> pAgc;

std::map<int, double, std::less<int> > gainConv_;

Expand Down
12 changes: 11 additions & 1 deletion Validation/EcalDigis/interface/EcalMixingModuleValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
#include "CondFormats/ESObjects/interface/ESPedestals.h"
#include "CondFormats/DataRecord/interface/ESPedestalsRcd.h"
#include "CondFormats/ESObjects/interface/ESIntercalibConstants.h"
#include <Validation/EcalDigis/interface/EcalBarrelDigisValidation.h>
#include "CalibCalorimetry/EcalTrivialCondModules/interface/EcalTrivialConditionRetriever.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"

#include <iostream>
#include <fstream>
Expand Down Expand Up @@ -106,10 +109,17 @@ class EcalMixingModuleValidation : public DQMOneEDAnalyzer<> {
edm::EDGetTokenT<EBDigiCollection> EBdigiCollectionToken_;
edm::EDGetTokenT<EEDigiCollection> EEdigiCollectionToken_;
edm::EDGetTokenT<ESDigiCollection> ESdigiCollectionToken_;

edm::EDGetTokenT<CrossingFrame<PCaloHit> > crossingFramePCaloHitEBToken_, crossingFramePCaloHitEEToken_,
crossingFramePCaloHitESToken_;

edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> pAgc;
edm::ESGetToken<ESGain, ESGainRcd> esgain_;
edm::ESGetToken<ESMIPToGeVConstant, ESMIPToGeVConstantRcd> esMIPToGeV_;
edm::ESGetToken<ESPedestals, ESPedestalsRcd> esPedestals_;
edm::ESGetToken<ESIntercalibConstants, ESIntercalibConstantsRcd> esMIPs_;
edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> dbPed;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> hGeometry;

std::map<int, double, std::less<int> > gainConv_;

double barrelADCtoGeV_;
Expand Down
19 changes: 19 additions & 0 deletions Validation/EcalDigis/interface/EcalSelectiveReadoutValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
#include "DataFormats/EcalDetId/interface/EcalScDetId.h"
#include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
#include "Geometry/EcalMapping/interface/EcalMappingRcd.h"

#include "CondFormats/EcalObjects/interface/EcalTPGLutIdMap.h"
#include "CondFormats/EcalObjects/interface/EcalTPGLutGroup.h"
#include "CondFormats/EcalObjects/interface/EcalTPGPhysicsConst.h"
#include "CondFormats/DataRecord/interface/EcalTPGLutIdMapRcd.h"
#include "CondFormats/DataRecord/interface/EcalTPGLutGroupRcd.h"
#include "CondFormats/DataRecord/interface/EcalTPGPhysicsConstRcd.h"

#include "Validation/EcalDigis/src/CollHandle.h"

Expand Down Expand Up @@ -393,6 +405,13 @@ class EcalSelectiveReadoutValidation : public DQMOneEDAnalyzer<> {
bool gain12; //all MGPA samples at gain 12?
};

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geoToken;
edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> ecalmapping;
edm::ESGetToken<EcalTrigTowerConstituentsMap, IdealGeometryRecord> hTriggerTowerMap;
edm::ESGetToken<EcalTPGPhysicsConst, EcalTPGPhysicsConstRcd> physHandle;
edm::ESGetToken<EcalTPGLutGroup, EcalTPGLutGroupRcd> lutGrpHandle;
edm::ESGetToken<EcalTPGLutIdMap, EcalTPGLutIdMapRcd> lutMapHandle;

/// number of bytes in 1 kByte:
static const int kByte_ = 1024;

Expand Down
7 changes: 3 additions & 4 deletions Validation/EcalDigis/src/EcalBarrelDigisValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ using namespace edm;
using namespace std;

EcalBarrelDigisValidation::EcalBarrelDigisValidation(const ParameterSet& ps)
: EBdigiCollection_(consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EBdigiCollection"))) {
: EBdigiCollection_(consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EBdigiCollection"))),
pAgc(esConsumes<edm::Transition::BeginRun>()) {
// verbosity switch
verbose_ = ps.getUntrackedParameter<bool>("verbose", false);

Expand Down Expand Up @@ -249,9 +250,7 @@ void EcalBarrelDigisValidation::analyze(Event const& e, EventSetup const& c) {

void EcalBarrelDigisValidation::checkCalibrations(edm::EventSetup const& eventSetup) {
// ADC -> GeV Scale
edm::ESHandle<EcalADCToGeVConstant> pAgc;
eventSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
const EcalADCToGeVConstant* agc = pAgc.product();
const EcalADCToGeVConstant* agc = &eventSetup.getData(pAgc);

EcalMGPAGainRatio* defaultRatios = new EcalMGPAGainRatio();

Expand Down
5 changes: 2 additions & 3 deletions Validation/EcalDigis/src/EcalDigisValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ EcalDigisValidation::EcalDigisValidation(const edm::ParameterSet& ps)
EBdigiCollectionToken_(consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EBdigiCollection"))),
EEdigiCollectionToken_(consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EEdigiCollection"))),
ESdigiCollectionToken_(consumes<ESDigiCollection>(ps.getParameter<edm::InputTag>("ESdigiCollection"))),
pAgc(esConsumes<edm::Transition::BeginRun>()),
crossingFramePCaloHitEBToken_(consumes<CrossingFrame<PCaloHit> >(edm::InputTag(
std::string("mix"), ps.getParameter<std::string>("moduleLabelG4") + std::string("EcalHitsEB")))),
crossingFramePCaloHitEEToken_(consumes<CrossingFrame<PCaloHit> >(edm::InputTag(
Expand Down Expand Up @@ -382,9 +383,7 @@ void EcalDigisValidation::analyze(edm::Event const& e, edm::EventSetup const& c)

void EcalDigisValidation::checkCalibrations(edm::EventSetup const& eventSetup) {
// ADC -> GeV Scale
edm::ESHandle<EcalADCToGeVConstant> pAgc;
eventSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
const EcalADCToGeVConstant* agc = pAgc.product();
const EcalADCToGeVConstant* agc = &eventSetup.getData(pAgc);

EcalMGPAGainRatio* defaultRatios = new EcalMGPAGainRatio();

Expand Down
7 changes: 3 additions & 4 deletions Validation/EcalDigis/src/EcalEndcapDigisValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ using namespace edm;
using namespace std;

EcalEndcapDigisValidation::EcalEndcapDigisValidation(const ParameterSet& ps)
: EEdigiCollectionToken_(consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EEdigiCollection"))) {
: EEdigiCollectionToken_(consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EEdigiCollection"))),
pAgc(esConsumes<edm::Transition::BeginRun>()) {
// verbosity switch
verbose_ = ps.getUntrackedParameter<bool>("verbose", false);

Expand Down Expand Up @@ -258,9 +259,7 @@ void EcalEndcapDigisValidation::analyze(Event const& e, EventSetup const& c) {

void EcalEndcapDigisValidation::checkCalibrations(edm::EventSetup const& eventSetup) {
// ADC -> GeV Scale
edm::ESHandle<EcalADCToGeVConstant> pAgc;
eventSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
const EcalADCToGeVConstant* agc = pAgc.product();
const EcalADCToGeVConstant* agc = &eventSetup.getData(pAgc);

EcalMGPAGainRatio* defaultRatios = new EcalMGPAGainRatio();

Expand Down
43 changes: 17 additions & 26 deletions Validation/EcalDigis/src/EcalMixingModuleValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ EcalMixingModuleValidation::EcalMixingModuleValidation(const edm::ParameterSet&
edm::InputTag(std::string("mix"), ps.getParameter<std::string>("hitsProducer") + std::string("EcalHitsEB")))),
crossingFramePCaloHitEEToken_(consumes<CrossingFrame<PCaloHit> >(
edm::InputTag(std::string("mix"), ps.getParameter<std::string>("hitsProducer") + std::string("EcalHitsEE")))),
crossingFramePCaloHitESToken_(consumes<CrossingFrame<PCaloHit> >(edm::InputTag(
std::string("mix"), ps.getParameter<std::string>("hitsProducer") + std::string("EcalHitsES")))) {
crossingFramePCaloHitESToken_(consumes<CrossingFrame<PCaloHit> >(
edm::InputTag(std::string("mix"), ps.getParameter<std::string>("hitsProducer") + std::string("EcalHitsES")))),
pAgc(esConsumes<edm::Transition::BeginRun>()),
esgain_(esConsumes<edm::Transition::BeginRun>()),
esMIPToGeV_(esConsumes<edm::Transition::BeginRun>()),
esPedestals_(esConsumes<edm::Transition::BeginRun>()),
esMIPs_(esConsumes<edm::Transition::BeginRun>()),
dbPed(esConsumes()),
hGeometry(esConsumes()) {
// needed for MixingModule checks

double simHitToPhotoelectronsBarrel = ps.getParameter<double>("simHitToPhotoelectronsBarrel");
Expand Down Expand Up @@ -605,9 +612,7 @@ void EcalMixingModuleValidation::analyze(edm::Event const& e, edm::EventSetup co

void EcalMixingModuleValidation::checkCalibrations(edm::EventSetup const& eventSetup) {
// ADC -> GeV Scale
edm::ESHandle<EcalADCToGeVConstant> pAgc;
eventSetup.get<EcalADCToGeVConstantRcd>().get(pAgc);
const EcalADCToGeVConstant* agc = pAgc.product();
const EcalADCToGeVConstant* agc = &eventSetup.getData(pAgc);

EcalMGPAGainRatio* defaultRatios = new EcalMGPAGainRatio();

Expand All @@ -630,20 +635,10 @@ void EcalMixingModuleValidation::checkCalibrations(edm::EventSetup const& eventS
LogDebug("EcalDigi") << " Endcap GeV/ADC = " << endcapADCtoGeV_;

// ES condition objects
edm::ESHandle<ESGain> esgain_;
edm::ESHandle<ESMIPToGeVConstant> esMIPToGeV_;
edm::ESHandle<ESPedestals> esPedestals_;
edm::ESHandle<ESIntercalibConstants> esMIPs_;

eventSetup.get<ESGainRcd>().get(esgain_);
eventSetup.get<ESMIPToGeVConstantRcd>().get(esMIPToGeV_);
eventSetup.get<ESPedestalsRcd>().get(esPedestals_);
eventSetup.get<ESIntercalibConstantsRcd>().get(esMIPs_);

const ESGain* esgain = esgain_.product();
m_ESpeds = esPedestals_.product();
m_ESmips = esMIPs_.product();
const ESMIPToGeVConstant* esMipToGeV = esMIPToGeV_.product();
const ESGain* esgain = &eventSetup.getData(esgain_);
m_ESpeds = &eventSetup.getData(esPedestals_);
m_ESmips = &eventSetup.getData(esMIPs_);
const ESMIPToGeVConstant* esMipToGeV = &eventSetup.getData(esMIPToGeV_);
m_ESgain = (int)esgain->getESGain();
const double valESMIPToGeV = (m_ESgain == 1) ? esMipToGeV->getESValueLow() : esMipToGeV->getESValueHigh();

Expand All @@ -657,9 +652,7 @@ void EcalMixingModuleValidation::checkCalibrations(edm::EventSetup const& eventS
void EcalMixingModuleValidation::checkPedestals(const edm::EventSetup& eventSetup) {
// Pedestals from event setup

edm::ESHandle<EcalPedestals> dbPed;
eventSetup.get<EcalPedestalsRcd>().get(dbPed);
thePedestals = dbPed.product();
thePedestals = &eventSetup.getData(dbPed);
}

void EcalMixingModuleValidation::findPedestal(const DetId& detId, int gainId, double& ped) const {
Expand Down Expand Up @@ -708,10 +701,8 @@ void EcalMixingModuleValidation::computeSDBunchDigi(const edm::EventSetup& event

// load the geometry

edm::ESHandle<CaloGeometry> hGeometry;
eventSetup.get<CaloGeometryRecord>().get(hGeometry);

const CaloGeometry* pGeometry = &*hGeometry;
auto hGeomHandle = eventSetup.getHandle(hGeometry);
const CaloGeometry* pGeometry = &*hGeomHandle;

// see if we need to update
if (pGeometry != theGeometry) {
Expand Down