Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/Math/interface/Rounding.h"
0002 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "FWCore/Framework/interface/ESTransientHandle.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0008 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0009 
0010 #include <iostream>
0011 #include <string>
0012 
0013 using namespace std;
0014 using namespace cms;
0015 using namespace edm;
0016 using namespace cms_rounding;
0017 
0018 class DTGeometryTest : public one::EDAnalyzer<> {
0019 public:
0020   explicit DTGeometryTest(const ParameterSet&);
0021 
0022   void beginJob() override {}
0023   void analyze(Event const& iEvent, EventSetup const&) override;
0024   void endJob() override {}
0025 
0026 private:
0027   const string m_label;
0028   const edm::ESGetToken<DTGeometry, MuonGeometryRecord> m_token;
0029 };
0030 
0031 DTGeometryTest::DTGeometryTest(const ParameterSet& iConfig)
0032     : m_label(iConfig.getUntrackedParameter<string>("fromDataLabel", "")),
0033       m_token(esConsumes<DTGeometry, MuonGeometryRecord>(edm::ESInputTag{"", m_label})) {}
0034 
0035 void DTGeometryTest::analyze(const Event&, const EventSetup& iEventSetup) {
0036   LogVerbatim("DTGeometryTest") << "DTGeometryTest::analyze: " << m_label;
0037   ESTransientHandle<DTGeometry> pDD = iEventSetup.getTransientHandle(m_token);
0038 
0039   LogVerbatim("DTGeometryTest") << " Geometry node for DTGeom is " << (pDD.isValid() ? "valid" : "not valid");
0040   LogVerbatim("DTGeometryTest") << " I have " << pDD->detTypes().size() << " detTypes";
0041   LogVerbatim("DTGeometryTest") << " I have " << pDD->detUnits().size() << " detUnits";
0042   LogVerbatim("DTGeometryTest") << " I have " << pDD->dets().size() << " dets";
0043   LogVerbatim("DTGeometryTest") << " I have " << pDD->layers().size() << " layers";
0044   LogVerbatim("DTGeometryTest") << " I have " << pDD->superLayers().size() << " superlayers";
0045   LogVerbatim("DTGeometryTest") << " I have " << pDD->chambers().size() << " chambers";
0046 
0047   // check chamber
0048   LogVerbatim("DTGeometryTest") << "CHAMBERS " << string(120, '-');
0049 
0050   LogVerbatim("DTGeometryTest").log([&](auto& log) {
0051     for (auto det : pDD->chambers()) {
0052       const BoundPlane& surf = det->surface();
0053       log << "Chamber " << det->id() << " Position " << surf.position() << " normVect "
0054           << roundVecIfNear0(surf.normalVector()) << " bounds W/H/L: " << surf.bounds().width() << "/"
0055           << surf.bounds().thickness() << "/" << surf.bounds().length() << "\n";
0056     }
0057   });
0058   LogVerbatim("DTGeometryTest") << "END " << string(120, '-');
0059 
0060   // check superlayers
0061   LogVerbatim("DTGeometryTest") << "SUPERLAYERS " << string(120, '-');
0062   LogVerbatim("DTGeometryTest").log([&](auto& log) {
0063     for (auto det : pDD->superLayers()) {
0064       const BoundPlane& surf = det->surface();
0065       log << "SuperLayer " << det->id() << " chamber " << det->chamber()->id() << " Position " << surf.position()
0066           << " normVect " << roundVecIfNear0(surf.normalVector()) << " bounds W/H/L: " << surf.bounds().width() << "/"
0067           << surf.bounds().thickness() << "/" << surf.bounds().length() << "\n";
0068     }
0069   });
0070   LogVerbatim("DTGeometryTest") << "END " << string(120, '-');
0071 
0072   // check layers
0073   LogVerbatim("DTGeometryTest") << "LAYERS " << string(120, '-');
0074 
0075   LogVerbatim("DTGeometryTest").log([&](auto& log) {
0076     for (auto det : pDD->layers()) {
0077       const DTTopology& topo = det->specificTopology();
0078       const BoundPlane& surf = det->surface();
0079       log << "Layer " << det->id() << " SL " << det->superLayer()->id() << " chamber " << det->chamber()->id()
0080           << " Topology W/H/L: " << topo.cellWidth() << "/" << topo.cellHeight() << "/" << topo.cellLenght()
0081           << " first/last/# wire " << topo.firstChannel() << "/" << topo.lastChannel() << "/" << topo.channels()
0082           << " Position " << surf.position() << " normVect " << roundVecIfNear0(surf.normalVector())
0083           << " bounds W/H/L: " << surf.bounds().width() << "/" << surf.bounds().thickness() << "/"
0084           << surf.bounds().length() << "\n";
0085     }
0086   });
0087   LogVerbatim("DTGeometryTest") << "END " << string(120, '-');
0088 }
0089 
0090 DEFINE_FWK_MODULE(DTGeometryTest);