Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:18

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 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0033 
0034 #include "DetectorDescription/Core/interface/DDCompactView.h"
0035 #include "DetectorDescription/Core/interface/DDExpandedView.h"
0036 #include "DetectorDescription/Core/interface/DDSpecifics.h"
0037 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0038 #include "Geometry/Records/interface/MuonNumberingRecord.h"
0039 #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h"
0040 
0041 #include "CoralBase/Exception.h"
0042 
0043 class MuonNumberingTester : public edm::one::EDAnalyzer<> {
0044 public:
0045   explicit MuonNumberingTester(const edm::ParameterSet&);
0046   ~MuonNumberingTester() override = default;
0047 
0048   void beginJob() override {}
0049   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0050   void endJob() override {}
0051 
0052 private:
0053   edm::ESGetToken<DDCompactView, IdealGeometryRecord> tokDDD_;
0054   edm::ESGetToken<MuonDDDConstants, MuonNumberingRecord> tokMuon_;
0055 };
0056 
0057 MuonNumberingTester::MuonNumberingTester(const edm::ParameterSet& iConfig)
0058     : tokDDD_{esConsumes<DDCompactView, IdealGeometryRecord>(edm::ESInputTag{})},
0059       tokMuon_{esConsumes<MuonDDDConstants, MuonNumberingRecord>(edm::ESInputTag{})} {}
0060 
0061 // ------------ method called to produce the data  ------------
0062 void MuonNumberingTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0063   using namespace edm;
0064 
0065   edm::LogVerbatim("MuonNumbering") << "Here I am ";
0066 
0067   const auto& pDD = iSetup.getData(tokDDD_);
0068   const auto& pMNDC = iSetup.getData(tokMuon_);
0069 
0070   try {
0071     DDExpandedView epv(pDD);
0072     edm::LogVerbatim("MuonNumbering") << " without firstchild or next... epv.logicalPart() =" << epv.logicalPart();
0073   } catch (const DDLogicalPart& iException) {
0074     throw cms::Exception("Geometry") << "DDORAReader::readDB caught a DDLogicalPart exception: \"" << iException
0075                                      << "\"";
0076   } catch (const coral::Exception& e) {
0077     throw cms::Exception("Geometry") << "DDORAReader::readDB caught coral::Exception: \"" << e.what() << "\"";
0078   } catch (std::exception& e) {
0079     throw cms::Exception("Geometry") << "DDORAReader::readDB caught std::exception: \"" << e.what() << "\"";
0080   } catch (...) {
0081     throw cms::Exception("Geometry") << "DDORAReader::readDB caught UNKNOWN!!! exception.";
0082   }
0083   edm::LogVerbatim("MuonNumbering") << "set the toFind string to \"level\"";
0084   std::string toFind("level");
0085   edm::LogVerbatim("MuonNumbering") << "about to de-reference the edm::ESHandle<MuonDDDConstants> pMNDC";
0086   const MuonDDDConstants mdc(pMNDC);
0087   edm::LogVerbatim("MuonNumbering") << "about to getValue( toFind )";
0088   int level = mdc.getValue(toFind);
0089   edm::LogVerbatim("MuonNumbering") << "level = " << level;
0090 }
0091 
0092 //define this as a plug-in
0093 DEFINE_FWK_MODULE(MuonNumberingTester);