Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:28

0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/MakerMacros.h"
0003 #include "FWCore/Framework/interface/ESTransientHandle.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0007 #include "DetectorDescription/DDCMS/interface/DDCompactView.h"
0008 #include "DetectorDescription/DDCMS/interface/DDFilteredView.h"
0009 
0010 #include <iostream>
0011 
0012 using namespace std;
0013 using namespace cms;
0014 using namespace edm;
0015 
0016 class DDTestFilteredView : public one::EDAnalyzer<> {
0017 public:
0018   explicit DDTestFilteredView(const ParameterSet& iConfig)
0019       : m_tag(iConfig.getParameter<ESInputTag>("DDDetector")), m_token(esConsumes(m_tag)) {}
0020 
0021   void beginJob() override {}
0022   void analyze(Event const& iEvent, EventSetup const&) override;
0023   void endJob() override {}
0024 
0025 private:
0026   const ESInputTag m_tag;
0027   const ESGetToken<DDCompactView, IdealGeometryRecord> m_token;
0028 };
0029 
0030 void DDTestFilteredView::analyze(const Event&, const EventSetup& iEventSetup) {
0031   LogVerbatim("Geometry") << "DDTestFilteredView::analyze: " << m_tag;
0032   ESTransientHandle<DDCompactView> cpv = iEventSetup.getTransientHandle(m_token);
0033 
0034   DDFilteredView fv(cpv->detector(), cpv->detector()->worldVolume());
0035 
0036   std::string attribute{"CMSCutsRegion"};
0037   cms::DDSpecParRefs ref;
0038   const cms::DDSpecParRegistry& mypar = cpv->specpars();
0039   mypar.filter(ref, attribute, "MuonChamber");
0040   fv.mergedSpecifics(ref);
0041 
0042   fv.printFilter();
0043 
0044   bool doLoop = fv.firstChild();
0045   LogVerbatim("Geometry") << "DDTestFilteredView::analyze: first child " << fv.path();
0046   while (doLoop) {
0047     edm::LogVerbatim("Geometry") << "DDTestFilteredView::analyze: next node = " << fv.path();
0048     doLoop = fv.firstChild();
0049   }
0050 
0051   LogVerbatim("Geometry") << "DDTestFilteredView::analyze done.";
0052 }
0053 
0054 DEFINE_FWK_MODULE(DDTestFilteredView);