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

Prepare EcalLaserCorrectionService for concurrent IOVs #24463

Merged
merged 1 commit into from Sep 10, 2018
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
Expand Up @@ -27,7 +27,6 @@
class EcalLaserDbService {
public:
EcalLaserDbService ();
EcalLaserDbService (const edm::ParameterSet&);

const EcalLaserAlphas* getAlphas () const;
const EcalLaserAPDPNRatiosRef* getAPDPNRatiosRef () const;
Expand Down
Expand Up @@ -8,29 +8,22 @@

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


#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h"
#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecord.h"

#include "CalibCalorimetry/EcalLaserCorrection/plugins/EcalLaserCorrectionService.h"


EcalLaserCorrectionService::EcalLaserCorrectionService( const edm::ParameterSet& fConfig)
: ESProducer(),
mService_ ( new EcalLaserDbService ())
: ESProducer()
// mDumpRequest (),
// mDumpStream(0)
{
//the following line is needed to tell the framework what
// data is being produced
// setWhatProduced (this, (dependsOn (&EcalLaserCorrectionService::apdpnCallback)));

setWhatProduced (this, (dependsOn (&EcalLaserCorrectionService::alphaCallback) &
(&EcalLaserCorrectionService::apdpnRefCallback) &
(&EcalLaserCorrectionService::apdpnCallback) &
(&EcalLaserCorrectionService::linearCallback)
)
);
setWhatProduced (this);

//now do what ever other initialization is needed

Expand All @@ -56,31 +49,59 @@ EcalLaserCorrectionService::~EcalLaserCorrectionService()
//

// ------------ method called to produce the data ------------
std::shared_ptr<EcalLaserDbService> EcalLaserCorrectionService::produce( const EcalLaserDbRecord& )
std::shared_ptr<EcalLaserDbService> EcalLaserCorrectionService::produce( const EcalLaserDbRecord& record)
{
return mService_;
auto host = holder_.makeOrGet([]() {
return new HostType;
});

host->ifRecordChanges<EcalLinearCorrectionsRcd>(record,
[this,h=host.get()](auto const& rec) {
setupLinear(rec, *h);
});

host->ifRecordChanges<EcalLaserAPDPNRatiosRcd>(record,
[this,h=host.get()](auto const& rec) {
setupApdpn(rec, *h);
});

host->ifRecordChanges<EcalLaserAPDPNRatiosRefRcd>(record,
[this,h=host.get()](auto const& rec) {
setupApdpnRef(rec, *h);
});

host->ifRecordChanges<EcalLaserAlphasRcd>(record,
[this,h=host.get()](auto const& rec) {
setupAlpha(rec, *h);
});

return host; // automatically converts to std::shared_ptr<EcalLaserDbService>
}

void EcalLaserCorrectionService::alphaCallback (const EcalLaserAlphasRcd& fRecord) {
void EcalLaserCorrectionService::setupAlpha(const EcalLaserAlphasRcd& fRecord,
EcalLaserDbService& service) {
edm::ESHandle <EcalLaserAlphas> item;
fRecord.get (item);
mService_->setAlphaData (item.product ());
service.setAlphaData (item.product ());
}

void EcalLaserCorrectionService::apdpnRefCallback (const EcalLaserAPDPNRatiosRefRcd& fRecord) {
void EcalLaserCorrectionService::setupApdpnRef(const EcalLaserAPDPNRatiosRefRcd& fRecord,
EcalLaserDbService& service) {
edm::ESHandle <EcalLaserAPDPNRatiosRef> item;
fRecord.get (item);
mService_->setAPDPNRefData (item.product ());
service.setAPDPNRefData (item.product ());
}

void EcalLaserCorrectionService::apdpnCallback (const EcalLaserAPDPNRatiosRcd& fRecord) {
void EcalLaserCorrectionService::setupApdpn(const EcalLaserAPDPNRatiosRcd& fRecord,
EcalLaserDbService& service) {
edm::ESHandle <EcalLaserAPDPNRatios> item;
fRecord.get (item);
mService_->setAPDPNData (item.product ());
service.setAPDPNData (item.product ());
}

void EcalLaserCorrectionService::linearCallback (const EcalLinearCorrectionsRcd& fRecord) {
void EcalLaserCorrectionService::setupLinear(const EcalLinearCorrectionsRcd& fRecord,
EcalLaserDbService& service) {
edm::ESHandle <EcalLinearCorrections> item;
fRecord.get (item);
mService_->setLinearCorrectionsData (item.product ());
service.setLinearCorrectionsData (item.product ());
}
Expand Up @@ -8,6 +8,8 @@
// user include files
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Framework/interface/ESProductHost.h"
#include "FWCore/Utilities/interface/ReusableObjectHolder.h"

class EcalLaserDbService;
class EcalLaserDbRecord;
Expand All @@ -24,16 +26,27 @@ class EcalLaserCorrectionService : public edm::ESProducer {
~EcalLaserCorrectionService() override;

std::shared_ptr<EcalLaserDbService> produce( const EcalLaserDbRecord& );

// callbacks
void alphaCallback (const EcalLaserAlphasRcd& fRecord);
void apdpnRefCallback (const EcalLaserAPDPNRatiosRefRcd& fRecord);
void apdpnCallback (const EcalLaserAPDPNRatiosRcd& fRecord);
void linearCallback (const EcalLinearCorrectionsRcd& fRecord);


private:

using HostType = edm::ESProductHost<EcalLaserDbService,
EcalLaserAlphasRcd,
EcalLaserAPDPNRatiosRefRcd,
EcalLaserAPDPNRatiosRcd,
EcalLinearCorrectionsRcd>;

void setupAlpha(const EcalLaserAlphasRcd& fRecord,
EcalLaserDbService& service);
void setupApdpnRef(const EcalLaserAPDPNRatiosRefRcd& fRecord,
EcalLaserDbService& service);
void setupApdpn(const EcalLaserAPDPNRatiosRcd& fRecord,
EcalLaserDbService& service);
void setupLinear(const EcalLinearCorrectionsRcd& fRecord,
EcalLaserDbService& service);

// ----------member data ---------------------------
std::shared_ptr<EcalLaserDbService> mService_;
edm::ReusableObjectHolder<HostType> holder_;

// std::vector<std::string> mDumpRequest;
// std::ostream* mDumpStream;
};