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

Premix option c, with 2 tags, ECAL, 11_0_X #27974

Closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Toyoko Orimoto (Caltech), 10 July 2007
// Andrea Massironi, 3 Aug 2019
//

#ifndef ECALLASERCORRECTION_ECALLASERDBRECORDMC_H
#define ECALLASERCORRECTION_ECALLASERDBRECORDMC_H

#include "boost/mpl/vector.hpp"
#include "FWCore/Framework/interface/DependentRecordImplementation.h"
// #include "FWCore/Framework/interface/EventSetupRecordImplementation.h"

#include "CondFormats/DataRecord/interface/EcalLaserAlphasRcd.h"
#include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRefRcd.h"
#include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosMCRcd.h"
#include "CondFormats/DataRecord/interface/EcalLinearCorrectionsRcd.h"

// class EcalLaserDbRecordMC : public edm::eventsetup::EventSetupRecordMCImplementation<EcalLaserDbRecordMC> {};

class EcalLaserDbRecordMC
: public edm::eventsetup::DependentRecordImplementation<EcalLaserDbRecordMC,
boost::mpl::vector<EcalLaserAlphasRcd,
EcalLaserAPDPNRatiosRefRcd,
EcalLaserAPDPNRatiosMCRcd,
EcalLinearCorrectionsRcd> > {};

#endif /* ECALLASERCORRECTION_ECALLASERDBRECORDMC_H */
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Toyoko Orimoto (Caltech), 10 July 2007
//

#ifndef EcalLaserDbServiceMC_h
#define EcalLaserDbServiceMC_h

#include <memory>
#include <tbb/concurrent_unordered_set.h>

#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "DataFormats/EcalDetId/interface/EEDetId.h"
#include "DataFormats/Provenance/interface/Timestamp.h"

#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"

#include "CondFormats/EcalObjects/interface/EcalLaserAlphas.h"
#include "CondFormats/EcalObjects/interface/EcalLaserAPDPNRatiosRef.h"
#include "CondFormats/EcalObjects/interface/EcalLaserAPDPNRatiosMC.h"
#include "CondFormats/EcalObjects/interface/EcalLinearCorrections.h"

class EcalLaserDbServiceMC {
public:
EcalLaserDbServiceMC();

const EcalLaserAlphas* getAlphas() const;
const EcalLaserAPDPNRatiosRef* getAPDPNRatiosRef() const;
const EcalLaserAPDPNRatiosMC* getAPDPNRatiosMC() const;
const EcalLinearCorrections* getLinearCorrections() const;
float getLaserCorrection(DetId const& xid, edm::Timestamp const& iTime) const;

void setAlphaData(const EcalLaserAlphas* fItem) { mAlphas_ = fItem; }
void setAPDPNRefData(const EcalLaserAPDPNRatiosRef* fItem) { mAPDPNRatiosRef_ = fItem; }
void setAPDPNData(const EcalLaserAPDPNRatiosMC* fItem) { mAPDPNRatiosMC_ = fItem; }
void setLinearCorrectionsData(const EcalLinearCorrections* fItem) { mLinearCorrections_ = fItem; }

private:
const EcalLaserAlphas* mAlphas_;
const EcalLaserAPDPNRatiosRef* mAPDPNRatiosRef_;
const EcalLaserAPDPNRatiosMC* mAPDPNRatiosMC_;
const EcalLinearCorrections* mLinearCorrections_;

typedef tbb::concurrent_unordered_set<uint32_t> ErrorMapT;
mutable ErrorMapT channelsWithInvalidCorrection_;
};

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// Toyoko Orimoto (Caltech), 10 July 2007
// Andrea Massironi, 3 Aug 2019
//

// system include files
#include <iostream>
#include <fstream>

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

#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbServiceMC.h"
#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecordMC.h"

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

EcalLaserCorrectionServiceMC::EcalLaserCorrectionServiceMC(const edm::ParameterSet& fConfig)
: ESProducer()
// mDumpRequest (),
Copy link
Contributor

Choose a reason for hiding this comment

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

@amassiro why all this commented code?

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 can remove it if needed.

I followed the same structure as
https://github.com/cms-sw/cmssw/blob/master/CalibCalorimetry/EcalLaserCorrection/plugins/EcalLaserCorrectionService.cc
... where also there a lot of commented code is written.

// mDumpStream(0)
{
//the following line is needed to tell the framework what
// data is being produced
// setWhatProduced (this, (dependsOn (&EcalLaserCorrectionServiceMC::apdpnCallback)));

setWhatProduced(this);

//now do what ever other initialization is needed

// mDumpRequest = fConfig.getUntrackedParameter <std::vector <std::string> > ("dump", std::vector<std::string>());
// if (!mDumpRequest.empty()) {
// std::string otputFile = fConfig.getUntrackedParameter <std::string> ("file", "");
// mDumpStream = otputFile.empty () ? &std::cout : new std::ofstream (otputFile.c_str());
// }
}

EcalLaserCorrectionServiceMC::~EcalLaserCorrectionServiceMC() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
// if (mDumpStream != &std::cout) delete mDumpStream;
}

//
// member functions
//

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

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

host->ifRecordChanges<EcalLaserAPDPNRatiosMCRcd>(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<EcalLaserDbServiceMC>
}

void EcalLaserCorrectionServiceMC::setupAlpha(const EcalLaserAlphasRcd& fRecord, EcalLaserDbServiceMC& service) {
edm::ESHandle<EcalLaserAlphas> item;
fRecord.get(item);
service.setAlphaData(item.product());
}

void EcalLaserCorrectionServiceMC::setupApdpnRef(const EcalLaserAPDPNRatiosRefRcd& fRecord,
EcalLaserDbServiceMC& service) {
edm::ESHandle<EcalLaserAPDPNRatiosRef> item;
fRecord.get(item);
service.setAPDPNRefData(item.product());
}

void EcalLaserCorrectionServiceMC::setupApdpn(const EcalLaserAPDPNRatiosMCRcd& fRecord, EcalLaserDbServiceMC& service) {
edm::ESHandle<EcalLaserAPDPNRatiosMC> item;
fRecord.get(item);
service.setAPDPNData(item.product());
}

void EcalLaserCorrectionServiceMC::setupLinear(const EcalLinearCorrectionsRcd& fRecord, EcalLaserDbServiceMC& service) {
edm::ESHandle<EcalLinearCorrections> item;
fRecord.get(item);
service.setLinearCorrectionsData(item.product());
}

DEFINE_FWK_EVENTSETUP_MODULE(EcalLaserCorrectionServiceMC);
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Toyoko Orimoto (Caltech), 10 July 2007
// Andrea Massironi, 3 Aug 2019
//

// system include files
#include <memory>

// 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 EcalLaserDbServiceMC;
class EcalLaserDbRecordMC;

#include "CondFormats/DataRecord/interface/EcalLaserAlphasRcd.h"
#include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRefRcd.h"
#include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosMCRcd.h"
#include "CondFormats/DataRecord/interface/EcalLinearCorrectionsRcd.h"

class EcalLaserCorrectionServiceMC : public edm::ESProducer {
public:
EcalLaserCorrectionServiceMC(const edm::ParameterSet&);
~EcalLaserCorrectionServiceMC() override;

std::shared_ptr<EcalLaserDbServiceMC> produce(const EcalLaserDbRecordMC&);

private:
using HostType = edm::ESProductHost<EcalLaserDbServiceMC,
EcalLaserAlphasRcd,
EcalLaserAPDPNRatiosRefRcd,
EcalLaserAPDPNRatiosMCRcd,
EcalLinearCorrectionsRcd>;

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

// ----------member data ---------------------------
edm::ReusableObjectHolder<HostType> holder_;

// std::vector<std::string> mDumpRequest;
// std::ostream* mDumpStream;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecordMC.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

EVENTSETUP_RECORD_REG(EcalLaserDbRecordMC);
Loading