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

ECAL esConsumes migration of Calibration packages #35107

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.
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 @@ -8,21 +8,13 @@
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"

//#include "DataFormats/Common/interface/Handle.h"

#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
#include "FWCore/Utilities/interface/InputTag.h"
// raw data
#include "DataFormats/FEDRawData/interface/FEDRawData.h"
//#include "DataFormats/FEDRawData/interface/FEDNumbering.h"

// Geometry
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
// strip geometry
#include "CalibFormats/SiStripObjects/interface/SiStripRegionCabling.h"
#include "CalibTracker/Records/interface/SiStripRegionCablingRcd.h"

// egamma objects
#include "DataFormats/EgammaReco/interface/SuperCluster.h"
Expand All @@ -37,7 +29,6 @@

// Strip and pixel
#include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"

// detector id
#include "DataFormats/HcalDetId/interface/HcalDetId.h"
Expand All @@ -47,30 +38,26 @@
#include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
// Geometry
#include "Geometry/Records/interface/CaloTopologyRecord.h"
#include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
#include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
// strip geometry
#include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
// Message logger
#include "FWCore/MessageLogger/interface/MessageLogger.h"
// Strip and pixel
#include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
#include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h"

// Hcal objects
#include "CalibFormats/HcalObjects/interface/HcalDbService.h"
#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"

using namespace std;

/// Producer constructor
template <typename TEle, typename TCand>
SelectedElectronFEDListProducer<TEle, TCand>::SelectedElectronFEDListProducer(const edm::ParameterSet& iConfig) {
SelectedElectronFEDListProducer<TEle, TCand>::SelectedElectronFEDListProducer(const edm::ParameterSet& iConfig)
: hcalDbToken_(esConsumes()),
ecalMappingToken_(esConsumes()),
caloGeometryToken_(esConsumes()),
siPixelFedCablingMapToken_(esConsumes()),
trackerGeometryToken_(esConsumes()),
siStripRegionCablingToken_(esConsumes()) {
// input electron collection Tag
if (iConfig.existsAs<std::vector<edm::InputTag>>("electronTags")) {
electronTags_ = iConfig.getParameter<std::vector<edm::InputTag>>("electronTags");
Expand Down Expand Up @@ -309,36 +296,30 @@ void SelectedElectronFEDListProducer<TEle, TCand>::beginJob() {
template <typename TEle, typename TCand>
void SelectedElectronFEDListProducer<TEle, TCand>::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
// get the hcal electronics map
edm::ESHandle<HcalDbService> pSetup;
iSetup.get<HcalDbRecord>().get(pSetup);
HcalReadoutMap_ = pSetup->getHcalMapping();
const auto& pSetup = iSetup.getData(hcalDbToken_);
HcalReadoutMap_ = pSetup.getHcalMapping();

// get the ecal electronics map
edm::ESHandle<EcalElectronicsMapping> ecalmapping;
iSetup.get<EcalMappingRcd>().get(ecalmapping);
EcalMapping_ = ecalmapping.product();
EcalMapping_ = &iSetup.getData(ecalMappingToken_);

// get the calo geometry
edm::ESHandle<CaloGeometry> caloGeometry;
iSetup.get<CaloGeometryRecord>().get(caloGeometry);
GeometryCalo_ = caloGeometry.product();
const auto& caloGeometry = iSetup.getData(caloGeometryToken_);
GeometryCalo_ = &caloGeometry;

//ES geometry
GeometryES_ = caloGeometry->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
GeometryES_ = caloGeometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower);

// pixel tracker cabling map
edm::ESTransientHandle<SiPixelFedCablingMap> pixelCablingMap;
iSetup.get<SiPixelFedCablingMapRcd>().get(pixelCablingMap);
const auto pixelCablingMap = iSetup.getTransientHandle(siPixelFedCablingMapToken_);
PixelCabling_.reset();
PixelCabling_ = pixelCablingMap->cablingTree();

edm::ESHandle<TrackerGeometry> trackerGeometry;
iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
const auto& trackerGeometry = iSetup.getData(trackerGeometryToken_);

if (pixelModuleVector_.empty()) {
// build the tracker pixel module map
std::vector<const GeomDet*>::const_iterator itTracker = trackerGeometry->dets().begin();
for (; itTracker != trackerGeometry->dets().end(); ++itTracker) {
std::vector<const GeomDet*>::const_iterator itTracker = trackerGeometry.dets().begin();
for (; itTracker != trackerGeometry.dets().end(); ++itTracker) {
int subdet = (*itTracker)->geographicalId().subdetId();
if (!(subdet == PixelSubdetector::PixelBarrel || subdet == PixelSubdetector::PixelEndcap))
continue;
Expand All @@ -357,9 +338,7 @@ void SelectedElectronFEDListProducer<TEle, TCand>::produce(edm::Event& iEvent, c
std::sort(pixelModuleVector_.begin(), pixelModuleVector_.end());
}

edm::ESHandle<SiStripRegionCabling> SiStripCablingHandle;
iSetup.get<SiStripRegionCablingRcd>().get(SiStripCablingHandle);
StripRegionCabling_ = SiStripCablingHandle.product();
StripRegionCabling_ = &iSetup.getData(siStripRegionCablingToken_);

SiStripRegionCabling::Cabling SiStripCabling;
SiStripCabling = StripRegionCabling_->getRegionCabling();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
#ifndef SelectedElectronFEDListProducer_h
#define SelectedElectronFEDListProducer_h
#ifndef Calibration_EcalAlCaRecoProducers_SelectedElectronFEDListProducer_h
#define Calibration_EcalAlCaRecoProducers_SelectedElectronFEDListProducer_h

#include "DataFormats/BeamSpot/interface/BeamSpot.h"
// egamma objects
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"

#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
// Geometry
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
// strip geometry
#include "CalibFormats/SiStripObjects/interface/SiStripRegionCabling.h"
#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
#include "CalibTracker/Records/interface/SiStripRegionCablingRcd.h"
// Strip and pixel
#include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
// Hcal objects
#include "CalibFormats/HcalObjects/interface/HcalDbService.h"
#include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"

// Math
#include "DataFormats/Math/interface/normalizedPhi.h"

#include "FWCore/Framework/interface/stream/EDProducer.h"
// #include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
// Message logger
#include "FWCore/ServiceRegistry/interface/Service.h"

class InputTag;

class FEDRawDataCollection;

class SiPixelFedCablingMap;
class SiPixelFedCablingTree;
class SiStripFedCabling;
class SiStripRegionCabling;

class CaloGeometry;
class CaloSubdetectorGeometry;
class EcalElectronicsMapping;
class HcalElectronicsMap;

// Hcal rec hit: this is a Fwd file defining typedefs
Expand Down Expand Up @@ -131,6 +143,14 @@ class SelectedElectronFEDListProducer : public edm::stream::EDProducer<> {
std::vector<edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> > recoEcalCandidateToken_;
std::vector<edm::EDGetTokenT<TEleColl> > electronToken_;

// Token for the input collection
const edm::ESGetToken<HcalDbService, HcalDbRecord> hcalDbToken_;
const edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> ecalMappingToken_;
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryToken_;
const edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> siPixelFedCablingMapToken_;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryToken_;
const edm::ESGetToken<SiStripRegionCabling, SiStripRegionCablingRcd> siStripRegionCablingToken_;

// used inside the producer
math::XYZVector beamSpotPosition_;

Expand Down
34 changes: 21 additions & 13 deletions Calibration/EcalCalibAlgos/interface/ECALpedestalPCLHarvester.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "CondFormats/EcalObjects/interface/EcalPedestals.h"
#include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
#include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"

class ECALpedestalPCLHarvester : public DQMEDHarvester {
public:
Expand All @@ -41,24 +43,30 @@ class ECALpedestalPCLHarvester : public DQMEDHarvester {

void dqmPlots(const EcalPedestals& newpeds, DQMStore::IBooker& ibooker);

const EcalPedestals* currentPedestals_;
const EcalPedestals* g6g1Pedestals_;
const EcalChannelStatus* channelStatus_;
bool checkVariation(const EcalPedestalsMap& oldPedestals, const EcalPedestalsMap& newPedestals);
bool checkStatusCode(const DetId& id);
bool isGood(const DetId& id);

bool checkVariation(const EcalPedestalsMap& oldPedestals, const EcalPedestalsMap& newPedestals);
std::vector<int> chStatusToExclude_;
int minEntries_;
const int minEntries_;

int entriesEB_[EBDetId::kSizeForDenseIndexing];
int entriesEE_[EEDetId::kSizeForDenseIndexing];
bool checkAnomalies_; // whether or not to avoid creating sqlite file in case of many changed pedestals
double nSigma_; // threshold in sigmas to define a pedestal as changed
double thresholdAnomalies_; // threshold (fraction of changed pedestals) to avoid creation of sqlite file
std::string dqmDir_; // DQM directory where histograms are stored
std::string labelG6G1_; // DB label from which pedestals for G6 and G1 are to be copied
float threshDiffEB_; // if the new pedestals differs more than this from old, keep old
float threshDiffEE_; // same as above for EE. Stray channel protection
float threshChannelsAnalyzed_; // threshold for minimum percentage of channels analized to produce DQM plots
const bool checkAnomalies_; // whether or not to avoid creating sqlite file in case of many changed pedestals
const double nSigma_; // threshold in sigmas to define a pedestal as changed
const double thresholdAnomalies_; // threshold (fraction of changed pedestals) to avoid creation of sqlite file
const std::string dqmDir_; // DQM directory where histograms are stored
const std::string labelG6G1_; // DB label from which pedestals for G6 and G1 are to be copied
const float threshDiffEB_; // if the new pedestals differs more than this from old, keep old
const float threshDiffEE_; // same as above for EE. Stray channel protection
const float threshChannelsAnalyzed_; // threshold for minimum percentage of channels analized to produce DQM plots

// ES token
const edm::ESGetToken<EcalChannelStatus, EcalChannelStatusRcd> channelsStatusToken_;
const edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> pedestalsToken_;
const edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> g6g1PedestalsToken_;

const EcalPedestals* currentPedestals_;
const EcalPedestals* g6g1Pedestals_;
const EcalChannelStatus* channelStatus_;
};
3 changes: 3 additions & 0 deletions Calibration/EcalCalibAlgos/interface/ECALpedestalPCLworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "CondFormats/EcalObjects/interface/EcalPedestals.h"
#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
#include "DataFormats/TCDS/interface/BSTRecord.h"
#include "DataFormats/TCDS/interface/TCDSRecord.h"
Expand All @@ -43,6 +45,7 @@ class ECALpedestalPCLworker : public DQMEDAnalyzer {
edm::EDGetTokenT<EBDigiCollection> digiTokenEB_;
edm::EDGetTokenT<EEDigiCollection> digiTokenEE_;
edm::EDGetTokenT<TCDSRecord> tcdsToken_;
const edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> pedestalToken_;

std::vector<MonitorElement *> meEB_;
std::vector<MonitorElement *> meEE_;
Expand Down
59 changes: 34 additions & 25 deletions Calibration/EcalCalibAlgos/interface/EcalEleCalibLooper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "DataFormats/EgammaCandidates/interface/Electron.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"

#include "CLHEP/Matrix/GenMatrix.h"
#include "CLHEP/Matrix/Matrix.h"
Expand Down Expand Up @@ -60,64 +62,64 @@ class EcalEleCalibLooper : public edm::EDLooper {

private:
//! EcalBarrel Input Collection name
edm::InputTag m_barrelAlCa;
const edm::InputTag m_barrelAlCa;
//! EcalEndcap Input Collection name
edm::InputTag m_endcapAlCa;
const edm::InputTag m_endcapAlCa;
//! To take the electrons
edm::InputTag m_ElectronLabel;

//! reconstruction window size
int m_recoWindowSidex;
int m_recoWindowSidey;
const int m_recoWindowSidex;
const int m_recoWindowSidey;

//! eta size of the sub-matrix
int m_etaWidth; //PG sub matrix size and borders
const int m_etaWidth; //PG sub matrix size and borders
//! eta size of the additive border to the sub-matrix
// int m_etaBorder ; //FIXME
Comment on lines 77 to 78
Copy link
Contributor

Choose a reason for hiding this comment

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

is this commented out code expected to be used?

//! phi size of the sub-matrix
int m_phiWidthEB;
const int m_phiWidthEB;
//! phi size of the additive border to the sub-matrix
// int m_phiBorderEB //FIXME;
Comment on lines 81 to 82
Copy link
Contributor

Choose a reason for hiding this comment

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

is this commented out code expected to be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not know. I just did the esConsumes migration and I do not use this code otherwise.


//! eta start of the region of interest
int m_etaStart; //PG ECAL region to be calibrated
const int m_etaStart; //PG ECAL region to be calibrated
//! eta end of the region of interest
int m_etaEnd;
const int m_etaEnd;
//! phi start of the region of interest
int m_phiStartEB;
const int m_phiStartEB;
//! phi end of the region of interest
int m_phiEndEB;
const int m_phiEndEB;
//!DS For the EE
int m_radStart;
int m_radEnd;
int m_radWidth;
const int m_radStart;
const int m_radEnd;
const int m_radWidth;
//FIXME int m_radBorder ;
int m_phiStartEE;
int m_phiEndEE;
int m_phiWidthEE;
const int m_phiStartEE;
const int m_phiEndEE;
const int m_phiWidthEE;

//! maximum number of events per crystal
int m_maxSelectedNumPerXtal;
const int m_maxSelectedNumPerXtal;

//! single blocks calibrators
std::vector<VEcalCalibBlock *> m_EcalCalibBlocks;
//! minimum energy per crystal cut
double m_minEnergyPerCrystal;
const double m_minEnergyPerCrystal;
//! maximum energy per crystal cut
double m_maxEnergyPerCrystal;
const double m_maxEnergyPerCrystal;
//! minimum coefficient accepted (RAW)
double m_minCoeff;
const double m_minCoeff;
//! maximum coefficient accepted (RAW)
double m_maxCoeff;
const double m_maxCoeff;
//! to exclude the blocksolver
int m_usingBlockSolver;
const int m_usingBlockSolver;

//!the maps of recalib coeffs
EcalIntercalibConstantMap m_barrelMap;
EcalIntercalibConstantMap m_endcapMap;

//! DS sets the number of loops to do
unsigned int m_loops;
//! To take the electrons
edm::InputTag m_ElectronLabel;
const unsigned int m_loops;
//The map Filler
VFillMap *m_MapFiller;

Expand All @@ -136,6 +138,13 @@ class EcalEleCalibLooper : public edm::EDLooper {
std::map<int, int> m_xtalNumOfHits;

bool isfirstcall_;

//! ED token
const edm::EDGetTokenT<EBRecHitCollection> m_ebRecHitToken;
const edm::EDGetTokenT<EERecHitCollection> m_eeRecHitToken;
const edm::EDGetTokenT<reco::GsfElectronCollection> m_gsfElectronToken;
//! ES token
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> m_geometryToken;
};
#endif
#endif