Skip to content

Commit

Permalink
Merge pull request cms-sw#36078 from thomreis/ecal-esconsumes-migrati…
Browse files Browse the repository at this point in the history
…on-test-dirs

ECAL esConsumes migration of files in test directories
  • Loading branch information
cmsbuild authored Nov 15, 2021
2 parents 8de9f02 + 338290a commit d6a8633
Show file tree
Hide file tree
Showing 15 changed files with 486 additions and 607 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,44 @@
*
*/

#include <iostream>

#include <FWCore/Framework/interface/EDAnalyzer.h>
#include <FWCore/Framework/interface/Event.h>
#include <FWCore/Framework/interface/MakerMacros.h>
#include "FWCore/Framework/interface/global/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/DataRecord/interface/EcalGlobalShowerContainmentCorrectionsVsEtaRcd.h"
#include "CondFormats/EcalCorrections/interface/EcalGlobalShowerContainmentCorrectionsVsEta.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"

#include "DataFormats/EcalDetId/interface/EBDetId.h"

class EcalContainmentCorrectionAnalyzer : public edm::EDAnalyzer {
class EcalContainmentCorrectionAnalyzer : public edm::global::EDAnalyzer<> {
public:
EcalContainmentCorrectionAnalyzer(const edm::ParameterSet &ps);
~EcalContainmentCorrectionAnalyzer();
explicit EcalContainmentCorrectionAnalyzer(const edm::ParameterSet &ps);
~EcalContainmentCorrectionAnalyzer() override = default;

void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const override;

protected:
void analyze(edm::Event const &iEvent, const edm::EventSetup &iSetup);
const edm::ESGetToken<EcalGlobalShowerContainmentCorrectionsVsEta, EcalGlobalShowerContainmentCorrectionsVsEtaRcd>
esToken_;
};

DEFINE_FWK_MODULE(EcalContainmentCorrectionAnalyzer);

EcalContainmentCorrectionAnalyzer::EcalContainmentCorrectionAnalyzer(const edm::ParameterSet &ps) {}

EcalContainmentCorrectionAnalyzer::~EcalContainmentCorrectionAnalyzer() {}

void EcalContainmentCorrectionAnalyzer::analyze(edm::Event const &iEvent, const edm::EventSetup &iSetup) {
using namespace edm;
using namespace std;
EcalContainmentCorrectionAnalyzer::EcalContainmentCorrectionAnalyzer(const edm::ParameterSet &ps)
: esToken_(esConsumes()) {}

ESHandle<EcalGlobalShowerContainmentCorrectionsVsEta> pCorr;
iSetup.get<EcalGlobalShowerContainmentCorrectionsVsEtaRcd>().get(pCorr);
void EcalContainmentCorrectionAnalyzer::analyze(edm::StreamID,
edm::Event const &iEvent,
const edm::EventSetup &iSetup) const {
const auto &corr = iSetup.getData(esToken_);

for (int i = 1; i < 86; i++) {
for (int i = 1; i < 86; ++i) {
EBDetId aId(i, 1, EBDetId::ETAPHIMODE);
double e3x3 = pCorr->correction3x3(aId);
double e5x5 = pCorr->correction5x5(aId);
std::cout << "ieta " << aId.ieta() << " " << e3x3 << " " << e5x5 << std::endl;
double e3x3 = corr.correction3x3(aId);
double e5x5 = corr.correction5x5(aId);
edm::LogVerbatim("EcalContainmentCorrectionAnalyzer")
<< "ieta " << aId.ieta() << " " << e3x3 << " " << e5x5 << "\n";
}
}
58 changes: 24 additions & 34 deletions CalibCalorimetry/EcalLaserCorrection/test/EcalLaserDbAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@

// system include files
#include <memory>
//#include <time.h>
#include <string>
#include <map>
#include <iostream>
#include <vector>

// user include files
#include "FWCore/Framework/interface/EDAnalyzer.h"

#include "FWCore/Framework/interface/global/EDAnalyzer.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"

#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h"
Expand All @@ -28,17 +20,16 @@

#include "DataFormats/EcalDetId/interface/EBDetId.h"

using namespace std;

class EcalLaserDbAnalyzer : public edm::EDAnalyzer {
class EcalLaserDbAnalyzer : public edm::global::EDAnalyzer<> {
public:
explicit EcalLaserDbAnalyzer(const edm::ParameterSet&);
~EcalLaserDbAnalyzer();
~EcalLaserDbAnalyzer() override = default;

virtual void analyze(const edm::Event&, const edm::EventSetup&);
void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;

private:
// ----------member data ---------------------------
const edm::ESGetToken<EcalLaserDbService, EcalLaserDbRecord> laserDbToken_;
};

//
Expand All @@ -52,38 +43,35 @@ class EcalLaserDbAnalyzer : public edm::EDAnalyzer {
//
// constructors and destructor
//
EcalLaserDbAnalyzer::EcalLaserDbAnalyzer(const edm::ParameterSet& iConfig) {}

EcalLaserDbAnalyzer::~EcalLaserDbAnalyzer() {}
EcalLaserDbAnalyzer::EcalLaserDbAnalyzer(const edm::ParameterSet& iConfig) : laserDbToken_(esConsumes()) {}

//
// member functions
//

// ------------ method called to produce the data ------------
void EcalLaserDbAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
void EcalLaserDbAnalyzer::analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const& iSetup) const {
// get record from offline DB
edm::ESHandle<EcalLaserDbService> pSetup;
iSetup.get<EcalLaserDbRecord>().get(pSetup);
std::cout << "EcalLaserDbAnalyzer::analyze-> got EcalLaserDbRecord: " << std::endl;
const auto& setup = iSetup.getData(laserDbToken_);
edm::LogInfo("EcalLaserDbService") << "EcalLaserDbAnalyzer::analyze-> got EcalLaserDbRecord:";

EcalLaserAPDPNRatios::EcalLaserAPDPNpair apdpnpair;
const EcalLaserAPDPNRatios* myapdpn = pSetup->getAPDPNRatios();
const EcalLaserAPDPNRatios* myapdpn = setup.getAPDPNRatios();
const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = myapdpn->getLaserMap();

// EcalLaserAPDPNRatios::EcalLaserTimeStamp timestamp;
// const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = myapdpn->getTimeMap();

EcalLaserAPDPNref apdpnref;
const EcalLaserAPDPNRatiosRef* myapdpnref = pSetup->getAPDPNRatiosRef();
const EcalLaserAPDPNRatiosRef* myapdpnref = setup.getAPDPNRatiosRef();
const EcalLaserAPDPNRatiosRefMap& laserRefMap = myapdpnref->getMap();

EcalLaserAlpha alpha;
const EcalLaserAlphas* myalpha = pSetup->getAlphas();
const EcalLaserAlphas* myalpha = setup.getAlphas();
const EcalLaserAlphaMap& laserAlphaMap = myalpha->getMap();

EcalLinearCorrections::Values linValues;
const EcalLinearCorrections* mylinear = pSetup->getLinearCorrections();
const EcalLinearCorrections* mylinear = setup.getLinearCorrections();
const EcalLinearCorrections::EcalValueMap& linearValueMap = mylinear->getValueMap();

for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
Expand All @@ -92,38 +80,40 @@ void EcalLaserDbAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetu
for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
EBDetId ebdetid(ieta, iphi);

std::cout << ebdetid << " " << ebdetid.ietaSM() << " " << ebdetid.iphiSM() << std::endl;
edm::LogVerbatim("EcalLaserDbService") << ebdetid << " " << ebdetid.ietaSM() << " " << ebdetid.iphiSM() << "\n";

EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap::const_iterator itratio = laserRatiosMap.find(ebdetid);
if (itratio != laserRatiosMap.end()) {
apdpnpair = (*itratio);
std::cout << " APDPN pair = " << apdpnpair.p1 << " , " << apdpnpair.p2 << " , " << apdpnpair.p3 << std::endl;
edm::LogVerbatim("EcalLaserDbService")
<< " APDPN pair = " << apdpnpair.p1 << " , " << apdpnpair.p2 << " , " << apdpnpair.p3 << "\n";
} else {
edm::LogError("EcalLaserDbService") << "error with laserRatiosMap!" << endl;
edm::LogError("EcalLaserDbService") << "error with laserRatiosMap!";
}

EcalLinearCorrections::EcalValueMap::const_iterator itlin = linearValueMap.find(ebdetid);
if (itlin != linearValueMap.end()) {
linValues = (*itlin);
std::cout << " APDPN pair = " << linValues.p1 << " , " << linValues.p2 << " , " << linValues.p3 << std::endl;
edm::LogVerbatim("EcalLaserDbService")
<< " APDPN pair = " << linValues.p1 << " , " << linValues.p2 << " , " << linValues.p3 << "\n";
} else {
edm::LogError("EcalLaserDbService") << "error with linearValuesMap!" << endl;
edm::LogError("EcalLaserDbService") << "error with linearValuesMap!";
}

EcalLaserAPDPNRatiosRefMap::const_iterator itref = laserRefMap.find(ebdetid);
if (itref != laserRefMap.end()) {
apdpnref = (*itref);
std::cout << " APDPN ref = " << apdpnref << std::endl;
edm::LogVerbatim("EcalLaserDbService") << " APDPN ref = " << apdpnref << "\n";
} else {
edm::LogError("EcalLaserDbService") << "error with laserRefMap!" << endl;
edm::LogError("EcalLaserDbService") << "error with laserRefMap!";
}

EcalLaserAlphaMap::const_iterator italpha = laserAlphaMap.find(ebdetid);
if (italpha != laserAlphaMap.end()) {
alpha = (*italpha);
std::cout << " ALPHA = " << alpha << std::endl;
edm::LogVerbatim("EcalLaserDbService") << " ALPHA = " << alpha << "\n";
} else {
edm::LogError("EcalLaserDbService") << "error with laserAlphaMap!" << endl;
edm::LogError("EcalLaserDbService") << "error with laserAlphaMap!";
}
}
}
Expand Down
93 changes: 42 additions & 51 deletions CalibCalorimetry/EcalLaserCorrection/test/EcalLaserTestAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
#include <vector>

// user include files
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"

#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h"
Expand All @@ -29,12 +28,12 @@
using namespace std;
//using namespace oracle::occi;

class EcalLaserTestAnalyzer : public edm::EDAnalyzer {
class EcalLaserTestAnalyzer : public edm::one::EDAnalyzer<> {
public:
explicit EcalLaserTestAnalyzer(const edm::ParameterSet&);
~EcalLaserTestAnalyzer();
~EcalLaserTestAnalyzer() override = default;

virtual void analyze(const edm::Event&, const edm::EventSetup&);
void analyze(edm::Event const&, edm::EventSetup const&) override;

private:
// std::string m_timetype;
Expand All @@ -44,6 +43,7 @@ class EcalLaserTestAnalyzer : public edm::EDAnalyzer {
// unsigned long m_lastRun ;

// ----------member data ---------------------------
const edm::ESGetToken<EcalLaserDbService, EcalLaserDbRecord> laserDbToken_;
};

//
Expand All @@ -58,7 +58,7 @@ class EcalLaserTestAnalyzer : public edm::EDAnalyzer {
// constructors and destructor
//
EcalLaserTestAnalyzer::EcalLaserTestAnalyzer(const edm::ParameterSet& iConfig)
//:
: laserDbToken_(esConsumes())
// m_timetype(iConfig.getParameter<std::string>("timetype")),
// m_cacheIDs(),
// m_records()
Expand All @@ -84,11 +84,6 @@ EcalLaserTestAnalyzer::EcalLaserTestAnalyzer(const edm::ParameterSet& iConfig)
// }
}

EcalLaserTestAnalyzer::~EcalLaserTestAnalyzer() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}

//
// member functions
//
Expand All @@ -98,10 +93,9 @@ void EcalLaserTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSe
// using namespace edm;

// get record from offline DB
edm::ESHandle<EcalLaserDbService> pSetup;
iSetup.get<EcalLaserDbRecord>().get(pSetup);
const auto& setup = iSetup.getData(laserDbToken_);
std::cout << "EcalLaserTestAnalyzer::analyze-> got EcalLaserDbRecord: " << std::endl;
// pSetup->setVerbosity(true);
// setup.setVerbosity(true);

// int ieta = 83;
// int iphi = 168;
Expand All @@ -121,7 +115,7 @@ void EcalLaserTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSe
// // << dccid << " " << tccid
// // << std::endl;

// float blah = pSetup->getLaserCorrection(testid, testtime);
// float blah = setup.getLaserCorrection(testid, testtime);
// std::cout << " EcalLaserTestAnalyzer: " << blah << std::endl;

std::cout << "---> FIRST ECAL BARREL " << endl;
Expand Down Expand Up @@ -150,7 +144,7 @@ void EcalLaserTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSe
<< std::endl;
// std::cout << testid << std::endl;

float blah = pSetup->getLaserCorrection(testid, iEvent.time());
float blah = setup.getLaserCorrection(testid, iEvent.time());
std::cout << " EcalLaserTestAnalyzer: " << iEvent.time().value() << " " << blah << std::endl;

} catch (...) {
Expand All @@ -164,41 +158,38 @@ void EcalLaserTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSe
for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
// make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
try {
// +Z side
EEDetId testidpos(iX, iY, 1);
// edm::Timestamp testtime(12000);
// std::cout << " EcalLaserTestAnalyzer: " << testidpos << " " << testidpos.isc() << endl;

// // test of elec mapping
// EcalElectronicsId myidpos = TheMapping->getElectronicsId(testidpos);
std::cout << std::endl
<< "CRYSTAL EE+: " << testidpos << " " << testidpos.isc()
<< " "
// << testidpos.rawId() << " : " << myidpos << " " << myidpos.rawId() << " : "
// << myidpos.dccId()
<< std::endl;
// //

float blah = pSetup->getLaserCorrection(testidpos, iEvent.time());
std::cout << " EcalLaserTestAnalyzer: " << iEvent.time().value() << " " << blah << std::endl;

// -Z side
EEDetId testidneg(iX, iY, -1);
// std::cout << " EcalLaserTestAnalyzer: " << testidneg << " " << testidneg.isc() << endl;

// EcalElectronicsId myidneg = TheMapping->getElectronicsId(testidneg);
std::cout << std::endl
<< "CRYSTAL EE-: " << testidneg << " " << testidneg.isc()
<< " "
// << testidneg.rawId() << " : " << myidneg << " " << myidneg.rawId() << " : "
// << myidneg.dccId()
<< std::endl;

blah = pSetup->getLaserCorrection(testidneg, iEvent.time());
std::cout << " EcalLaserTestAnalyzer: " << iEvent.time().value() << " " << blah << std::endl;
} catch (...) {
}
// +Z side
EEDetId testidpos(iX, iY, 1);
// edm::Timestamp testtime(12000);
// std::cout << " EcalLaserTestAnalyzer: " << testidpos << " " << testidpos.isc() << endl;

// // test of elec mapping
// EcalElectronicsId myidpos = TheMapping->getElectronicsId(testidpos);
std::cout << std::endl
<< "CRYSTAL EE+: " << testidpos << " " << testidpos.isc()
<< " "
// << testidpos.rawId() << " : " << myidpos << " " << myidpos.rawId() << " : "
// << myidpos.dccId()
<< std::endl;
// //

float blah = setup.getLaserCorrection(testidpos, iEvent.time());
std::cout << " EcalLaserTestAnalyzer: " << iEvent.time().value() << " " << blah << std::endl;

// -Z side
EEDetId testidneg(iX, iY, -1);
// std::cout << " EcalLaserTestAnalyzer: " << testidneg << " " << testidneg.isc() << endl;

// EcalElectronicsId myidneg = TheMapping->getElectronicsId(testidneg);
std::cout << std::endl
<< "CRYSTAL EE-: " << testidneg << " " << testidneg.isc()
<< " "
// << testidneg.rawId() << " : " << myidneg << " " << myidneg.rawId() << " : "
// << myidneg.dccId()
<< std::endl;

blah = setup.getLaserCorrection(testidneg, iEvent.time());
std::cout << " EcalLaserTestAnalyzer: " << iEvent.time().value() << " " << blah << std::endl;
}
}
}
Expand Down
Loading

0 comments on commit d6a8633

Please sign in to comment.