Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-25 03:29:34

0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/ServiceRegistry/interface/Service.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Framework/interface/ESTransientHandle.h"
0009 #include "CondFormats/RecoGeometryObjects/interface/RecoIdealGeometry.h"
0010 #include "Geometry/DTGeometryBuilderinterface/DTGeometryParsFromDD.h"
0011 #include "Geometry/Records/interface/RecoIdealGeometryRcd.h"
0012 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0013 #include "DetectorDescription/Core/interface/DDCompactView.h"
0014 #include "Geometry/Records/interface/MuonNumberingRecord.h"
0015 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
0016 
0017 #include <iostream>
0018 #include <string>
0019 #include <vector>
0020 #include <map>
0021 #include <sstream>
0022 #include <algorithm>
0023 
0024 class DTRecoIdealDBLoader : public edm::one::EDAnalyzer<> {
0025 public:
0026   explicit DTRecoIdealDBLoader(const edm::ParameterSet& iConfig);
0027   ~DTRecoIdealDBLoader();
0028 
0029   void beginJob() override;
0030   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0031   void endJob() override;
0032 
0033 private:
0034   const std::string label_;
0035   const edm::ESGetToken<DTGeometry, MuonGeometryRecord> tokDT_;
0036   const edm::ESGetToken<DDCompactView, IdealGeometryRecord> tokDDD_;
0037   int rotNumSeed_;
0038 };
0039 
0040 using namespace std;
0041 
0042 DTRecoIdealDBLoader::DTRecoIdealDBLoader(const edm::ParameterSet& iConfig)
0043     : label_(),
0044       tokDT_{esConsumes<DTGeometry, MuonGeometryRecord>(edm::ESInputTag{})},
0045       tokDDD_{esConsumes<DDCompactView, IdealGeometryRecord>(edm::ESInputTag{"", label_})} {
0046   std::cout << "DTRecoIdealDBLoader::DTRecoIdealDBLoader" << std::endl;
0047 }
0048 
0049 DTRecoIdealDBLoader::~DTRecoIdealDBLoader() { std::cout << "DTRecoIdealDBLoader::~DTRecoIdealDBLoader" << std::endl; }
0050 
0051 void DTRecoIdealDBLoader::analyze(const edm::Event& evt, const edm::EventSetup& es) {
0052   std::cout << "DTRecoIdealDBLoader::beginJob" << std::endl;
0053   RecoIdealGeometry rig;
0054 
0055   edm::Service<cond::service::PoolDBOutputService> mydbservice;
0056   if (!mydbservice.isAvailable()) {
0057     std::cout << "PoolDBOutputService unavailable" << std::endl;
0058     return;
0059   }
0060 
0061   const DDCompactView& cpv = es.getData(tokDDD_);
0062   const auto& pMNDC = &es.getData(tokDT_);
0063   DTGeometryParsFromDD dtgp;
0064 
0065   dtgp.build(&cpv, *pMNDC, rig);
0066   std::cout << "RecoIdealGeometry " << rig.size() << std::endl;
0067 
0068   if (mydbservice->isNewTagRequest("RecoIdealGeometryRcd")) {
0069     cout << "mydbservice " << mydbservice->beginOfTime() << " to " << mydbservice->endOfTime() << endl;
0070     mydbservice->createOneIOV(rig, mydbservice->beginOfTime(), "RecoIdealGeometryRcd");
0071   } else {
0072     std::cout << "RecoIdealGeometryRcd Tag is already present." << std::endl;
0073   }
0074 }
0075 
0076 #include "FWCore/Framework/interface/MakerMacros.h"
0077 DEFINE_FWK_MODULE(DTRecoIdealDBLoader);