Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:27

0001 #include <iomanip>
0002 #include <iostream>
0003 
0004 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0005 
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 
0011 #include "CondFormats/DataRecord/interface/L1TMuonOverlapFwVersionRcd.h"
0012 #include "CondFormats/DataRecord/interface/L1TMuonOverlapFwVersionO2ORcd.h"
0013 #include "CondFormats/L1TObjects/interface/L1TMuonOverlapFwVersion.h"
0014 #include "FWCore/ServiceRegistry/interface/Service.h"
0015 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0016 #include "CondCore/CondDB/interface/Session.h"
0017 
0018 using namespace std;
0019 
0020 class L1TMuonOverlapFwVersionTester : public edm::one::EDAnalyzer<> {
0021 private:
0022   bool isO2Opayload;
0023   bool writeToDB;
0024   edm::ESGetToken<L1TMuonOverlapFwVersion, L1TMuonOverlapFwVersionRcd> esToken;
0025   edm::ESGetToken<L1TMuonOverlapFwVersion, L1TMuonOverlapFwVersionO2ORcd> esToken_O2O;
0026 
0027 public:
0028   void analyze(const edm::Event &, const edm::EventSetup &) override;
0029 
0030   explicit L1TMuonOverlapFwVersionTester(const edm::ParameterSet &pset) : edm::one::EDAnalyzer<>() {
0031     isO2Opayload = pset.getUntrackedParameter<bool>("isO2Opayload", false);
0032     writeToDB = pset.getUntrackedParameter<bool>("writeToDB", false);
0033     esToken = esConsumes<L1TMuonOverlapFwVersion, L1TMuonOverlapFwVersionRcd>();
0034     esToken_O2O = esConsumes<L1TMuonOverlapFwVersion, L1TMuonOverlapFwVersionO2ORcd>();
0035   }
0036   ~L1TMuonOverlapFwVersionTester(void) override = default;
0037 };
0038 
0039 void L1TMuonOverlapFwVersionTester::analyze(const edm::Event &iEvent, const edm::EventSetup &evSetup) {
0040   L1TMuonOverlapFwVersion data;
0041   if (isO2Opayload)
0042     data = evSetup.getData(esToken_O2O);
0043   else
0044     data = evSetup.getData(esToken);
0045 
0046   edm::LogInfo("L1TMuonOverlapFwVersionTester")
0047       << "*** Contents of L1TMuonOverlapFwVersion: algoVersion() = " << data.algoVersion()
0048       << ", layersVersion() = " << data.layersVersion() << ", patternsVersion() = " << data.patternsVersion()
0049       << ", synthDate() = " << data.synthDate();
0050 
0051   if (writeToDB) {
0052     edm::Service<cond::service::PoolDBOutputService> poolDb;
0053     if (poolDb.isAvailable()) {
0054       edm::LogInfo("L1TMuonOverlapFwVersionTester") << "*** Writing payload to DB";
0055       cond::Time_t firstSinceTime = poolDb->beginOfTime();
0056       poolDb->writeOneIOV(
0057           data, firstSinceTime, (isO2Opayload ? "L1TMuonOverlapFwVersionO2ORcd" : "L1TMuonOverlapFwVersionRcd"));
0058     }
0059   }
0060 }
0061 
0062 #include "FWCore/PluginManager/interface/ModuleDef.h"
0063 #include "FWCore/Framework/interface/MakerMacros.h"
0064 #include "FWCore/Framework/interface/ModuleFactory.h"
0065 
0066 DEFINE_FWK_MODULE(L1TMuonOverlapFwVersionTester);