Skip to content

Commit

Permalink
Prepare EcalLaserCorrectionService for concurrent IOVs
Browse files Browse the repository at this point in the history
  • Loading branch information
wddgit committed Aug 31, 2018
1 parent d1d92b0 commit 74a5e11
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 28 deletions.
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;
};

0 comments on commit 74a5e11

Please sign in to comment.