1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#ifndef CalibratedElectronProducer_h
#define CalibratedElectronProducer_h
#include <string>
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CondFormats/DataRecord/interface/GBRWrapperRcd.h"
#include "CondFormats/GBRForest/interface/GBRForest.h"
#include <TFile.h>
class GBRForestGetterFromDB : public edm::one::EDAnalyzer<> {
public:
explicit GBRForestGetterFromDB(const edm::ParameterSet &);
~GBRForestGetterFromDB() override;
void analyze(const edm::Event &, const edm::EventSetup &) override;
private:
std::string theGBRForestName;
std::string theOutputFileName;
std::string theOutputObjectName;
edm::ESGetToken<GBRForest, GBRWrapperRcd> theGBRForestToken_;
};
GBRForestGetterFromDB::GBRForestGetterFromDB(const edm::ParameterSet &conf)
: theGBRForestName(conf.getParameter<std::string>("grbForestName")),
theOutputFileName(conf.getUntrackedParameter<std::string>("outputFileName")),
theOutputObjectName(conf.getUntrackedParameter<std::string>(
"outputObjectName", theGBRForestName.empty() ? "GBRForest" : theGBRForestName)),
theGBRForestToken_(esConsumes()) {}
GBRForestGetterFromDB::~GBRForestGetterFromDB() {}
void GBRForestGetterFromDB::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
auto theGBRForestHandle = iSetup.getHandle(theGBRForestToken_);
TFile *fOut = TFile::Open(theOutputFileName.c_str(), "RECREATE");
fOut->WriteObject(theGBRForestHandle.product(), theOutputObjectName.c_str());
fOut->Close();
edm::LogPrint("GBRForestGetterFromDB") << "Wrote output to " << theOutputFileName;
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(GBRForestGetterFromDB);
#endif
|