Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-24 02:11:03

0001 // -*- C++ -*-
0002 //
0003 // Package:    MuonNumberingTester
0004 // Class:      MuonNumberingTester
0005 //
0006 /**\class MuonNumberingTester MuonNumberingTester.cc test/MuonNumberingTester/src/MuonNumberingTester.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Michael Case
0015 //         Created:  Mon 2006/10/02
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <iostream>
0022 #include <fstream>
0023 
0024 // user include files
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0027 
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/EventSetup.h"
0030 #include "FWCore/Framework/interface/MakerMacros.h"
0031 
0032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0033 #include "DetectorDescription/Core/interface/DDCompactView.h"
0034 #include "DetectorDescription/Core/interface/DDExpandedView.h"
0035 #include "DetectorDescription/Core/interface/DDSpecifics.h"
0036 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0037 #include "Geometry/Records/interface/MuonNumberingRecord.h"
0038 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
0039 
0040 #include "CoralBase/Exception.h"
0041 
0042 class MuonNumberingTester : public edm::one::EDAnalyzer<> {
0043 public:
0044   explicit MuonNumberingTester(const edm::ParameterSet&);
0045   ~MuonNumberingTester() override;
0046 
0047   void beginJob() override {}
0048   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0049   void endJob() override {}
0050 
0051 private:
0052   edm::ESGetToken<DDCompactView, IdealGeometryRecord> tokDDD_;
0053   edm::ESGetToken<MuonDDDConstants, MuonNumberingRecord> tokMuon_;
0054 };
0055 
0056 MuonNumberingTester::MuonNumberingTester(const edm::ParameterSet& iConfig)
0057     : tokDDD_{esConsumes<DDCompactView, IdealGeometryRecord>(edm::ESInputTag{})},
0058       tokMuon_{esConsumes<MuonDDDConstants, MuonNumberingRecord>(edm::ESInputTag{})} {}
0059 
0060 MuonNumberingTester::~MuonNumberingTester() {}
0061 
0062 // ------------ method called to produce the data  ------------
0063 void MuonNumberingTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0064   using namespace edm;
0065 
0066   std::cout << "Here I am " << std::endl;
0067 
0068   const auto& pDD = iSetup.getData(tokDDD_);
0069   const auto& pMNDC = iSetup.getData(tokMuon_);
0070 
0071   try {
0072     DDExpandedView epv(pDD);
0073     std::cout << " without firstchild or next... epv.logicalPart() =" << epv.logicalPart() << std::endl;
0074   } catch (const DDLogicalPart& iException) {
0075     throw cms::Exception("Geometry") << "DDORAReader::readDB caught a DDLogicalPart exception: \"" << iException
0076                                      << "\"";
0077   } catch (const coral::Exception& e) {
0078     throw cms::Exception("Geometry") << "DDORAReader::readDB caught coral::Exception: \"" << e.what() << "\"";
0079   } catch (std::exception& e) {
0080     throw cms::Exception("Geometry") << "DDORAReader::readDB caught std::exception: \"" << e.what() << "\"";
0081   } catch (...) {
0082     throw cms::Exception("Geometry") << "DDORAReader::readDB caught UNKNOWN!!! exception." << std::endl;
0083   }
0084   std::cout << "set the toFind string to \"level\"" << std::endl;
0085   std::string toFind("level");
0086   std::cout << "about to de-reference the edm::ESHandle<MuonDDDConstants> pMNDC" << std::endl;
0087   const MuonDDDConstants mdc(pMNDC);
0088   std::cout << "about to getValue( toFind )" << std::endl;
0089   int level = mdc.getValue(toFind);
0090   std::cout << "level = " << level << std::endl;
0091 }
0092 
0093 //define this as a plug-in
0094 DEFINE_FWK_MODULE(MuonNumberingTester);