Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-14 11:45:24

0001 // -*- C++ -*-
0002 //
0003 // Package:    GBRWrapperMaker
0004 // Class:      GBRWrapperMaker
0005 //
0006 /**\class GBRWrapperMaker GBRWrapperMaker.cc GBRWrap/GBRWrapperMaker/src/GBRWrapperMaker.cc
0007 
0008  Description: [one line class summary]
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Josh Bendavid
0015 //         Created:  Tue Nov  8 22:26:45 CET 2011
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0025 
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 #include "TFile.h"
0031 #include "CondFormats/GBRForest/interface/GBRForestD.h"
0032 #include "FWCore/ServiceRegistry/interface/Service.h"
0033 
0034 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0035 #include "FWCore/Framework/interface/ESHandle.h"
0036 #include "FWCore/Framework/interface/EventSetup.h"
0037 #include "CondFormats/DataRecord/interface/GBRWrapperRcd.h"
0038 
0039 //
0040 // class declaration
0041 //
0042 
0043 class GBRWrapperMaker : public edm::one::EDAnalyzer<> {
0044 public:
0045   explicit GBRWrapperMaker(const edm::ParameterSet&);
0046   ~GBRWrapperMaker() = default;
0047 
0048   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0049 
0050 private:
0051   virtual void beginJob() override;
0052   virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
0053   virtual void endJob() override;
0054 };
0055 
0056 GBRWrapperMaker::GBRWrapperMaker(const edm::ParameterSet& iConfig) {}
0057 
0058 //
0059 // member functions
0060 //
0061 
0062 // ------------ method called for each event  ------------
0063 void GBRWrapperMaker::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0064   using namespace edm;
0065 
0066   TFile* infile = new TFile("../data/GBRLikelihood_Clustering_746_bx25_HLT.root", "READ");
0067   edm::LogPrint("GBRWrapperMaker") << "Load forest";
0068   GBRForestD* gbreb = (GBRForestD*)infile->Get("EBCorrection");
0069   GBRForestD* gbrebvar = (GBRForestD*)infile->Get("EBUncertainty");
0070   GBRForestD* gbree = (GBRForestD*)infile->Get("EECorrection");
0071   GBRForestD* gbreevar = (GBRForestD*)infile->Get("EEUncertainty");
0072 
0073   edm::LogPrint("GBRWrapperMaker") << "Make objects";
0074   edm::Service<cond::service::PoolDBOutputService> poolDbService;
0075   if (poolDbService.isAvailable()) {
0076     poolDbService->writeOneIOV(*gbreb, poolDbService->beginOfTime(), "mustacheSC_online_EBCorrection");
0077     poolDbService->writeOneIOV(*gbrebvar, poolDbService->beginOfTime(), "mustacheSC_online_EBUncertainty");
0078     poolDbService->writeOneIOV(*gbree, poolDbService->beginOfTime(), "mustacheSC_online_EECorrection");
0079     poolDbService->writeOneIOV(*gbreevar, poolDbService->beginOfTime(), "mustacheSC_online_EEUncertainty");
0080   }
0081 }
0082 
0083 // ------------ method called once each job just before starting event loop  ------------
0084 void GBRWrapperMaker::beginJob() {}
0085 
0086 // ------------ method called once each job just after ending the event loop  ------------
0087 void GBRWrapperMaker::endJob() {}
0088 
0089 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0090 void GBRWrapperMaker::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0091   //The following says we do not know what parameters are allowed so do no validation
0092   // Please change this to state exactly what you do use, even if it is no parameters
0093   edm::ParameterSetDescription desc;
0094   desc.setUnknown();
0095   descriptions.addDefault(desc);
0096 }
0097 
0098 //define this as a plug-in
0099 DEFINE_FWK_MODULE(GBRWrapperMaker);