Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-28 03:10:15

0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/Framework/interface/ESTransientHandle.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FWCore/Utilities/interface/StreamID.h"
0009 
0010 #include "RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h"
0011 #include "RecoMTD/Records/interface/MTDRecoGeometryRecord.h"
0012 
0013 #include "RecoMTD/DetLayers/interface/MTDSectorForwardDoubleLayer.h"
0014 #include "RecoMTD/DetLayers/interface/MTDDetSector.h"
0015 
0016 #include <DataFormats/ForwardDetId/interface/ETLDetId.h>
0017 
0018 #include <sstream>
0019 
0020 using namespace std;
0021 using namespace edm;
0022 
0023 class TestETLNavigation : public global::EDAnalyzer<> {
0024 public:
0025   TestETLNavigation(const ParameterSet& pset);
0026 
0027   void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
0028 
0029 private:
0030   const edm::ESInputTag tag_;
0031   edm::ESGetToken<MTDDetLayerGeometry, MTDRecoGeometryRecord> geomToken_;
0032 };
0033 
0034 TestETLNavigation::TestETLNavigation(const ParameterSet& iConfig) : tag_(edm::ESInputTag{"", ""}) {
0035   geomToken_ = esConsumes<MTDDetLayerGeometry, MTDRecoGeometryRecord>(tag_);
0036 }
0037 
0038 void TestETLNavigation::analyze(edm::StreamID, edm::Event const&, edm::EventSetup const& es) const {
0039   auto geo = es.getTransientHandle(geomToken_);
0040 
0041   const vector<const DetLayer*>& layers = geo->allETLLayers();
0042 
0043   // dump of ETL layers structure
0044 
0045   LogVerbatim("MTDLayerDump") << "\n\nTest of ETL navigation \n\n";
0046 
0047   for (const auto& ilay : layers) {
0048     const MTDSectorForwardDoubleLayer* layer = static_cast<const MTDSectorForwardDoubleLayer*>(ilay);
0049 
0050     LogVerbatim("MTDLayerDump") << std::fixed << "\nETL layer " << std::setw(4) << layer->subDetector()
0051                                 << " at z = " << std::setw(14) << layer->surface().position().z()
0052                                 << " sectors = " << std::setw(14) << layer->sectors().size()
0053                                 << " dets = " << std::setw(14) << layer->basicComponents().size()
0054                                 << " front dets = " << std::setw(14) << layer->frontLayer()->basicComponents().size()
0055                                 << " back dets = " << std::setw(14) << layer->backLayer()->basicComponents().size();
0056 
0057     unsigned int isectInd(0);
0058     for (const auto& isector : layer->sectors()) {
0059       isectInd++;
0060       LogVerbatim("MTDLayerDump") << std::fixed << "\nSector " << std::setw(4) << isectInd << "\n" << (*isector);
0061       unsigned int imodInd(0);
0062       for (const auto& imod : isector->basicComponents()) {
0063         imodInd++;
0064         ETLDetId modId(imod->geographicalId().rawId());
0065         LogVerbatim("MTDLayerDump") << std::fixed << std::setw(5) << imodInd << " ETLDetId " << modId.rawId()
0066                                     << " side = " << std::setw(4) << modId.mtdSide()
0067                                     << " Disc/Side/Sector = " << std::setw(4) << modId.nDisc() << " " << std::setw(4)
0068                                     << modId.discSide() << " " << std::setw(4) << modId.sector()
0069                                     << " mod/type = " << std::setw(4) << modId.module() << " " << std::setw(4)
0070                                     << modId.modType() << " pos = " << std::setprecision(4) << imod->position();
0071         for (int iside = -1; iside <= 1; iside += 2) {
0072           size_t idetNew = isector->hshift(modId, iside);
0073           if (idetNew >= isector->basicComponents().size()) {
0074             LogVerbatim("MTDLayerDump") << "...............hshift= " << std::fixed << std::setw(2) << iside
0075                                         << " out of range";
0076           } else {
0077             ETLDetId newId(isector->basicComponents()[idetNew]->geographicalId().rawId());
0078             LogVerbatim("MTDLayerDump") << std::fixed << "...............hshift= " << std::setw(2) << iside
0079                                         << " side = " << std::setw(4) << newId.mtdSide()
0080                                         << " Disc/Side/Sector = " << std::setw(4) << newId.nDisc() << " "
0081                                         << std::setw(4) << newId.discSide() << " " << std::setw(4) << newId.sector()
0082                                         << " mod/type = " << std::setw(4) << newId.module() << " " << std::setw(4)
0083                                         << newId.modType() << " pos = " << std::setprecision(4)
0084                                         << isector->basicComponents()[idetNew]->position();
0085           }
0086         }
0087         for (int iside = -1; iside <= 1; iside += 2) {
0088           size_t closest(isector->basicComponents().size());
0089           size_t idetNew = isector->vshift(modId, iside, closest);
0090           if (idetNew >= isector->basicComponents().size()) {
0091             LogVerbatim("MTDLayerDump") << "...............vshift= " << std::fixed << std::setw(2) << iside
0092                                         << " out of range";
0093             if (closest < isector->basicComponents().size()) {
0094               ETLDetId newId(isector->basicComponents()[closest]->geographicalId().rawId());
0095               LogVerbatim("MTDLayerDump")
0096                   << std::fixed << ".......closest.vshift= " << std::setw(2) << iside << " side = " << std::setw(4)
0097                   << newId.mtdSide() << " Disc/Side/Sector = " << std::setw(4) << newId.nDisc() << " " << std::setw(4)
0098                   << newId.discSide() << " " << std::setw(4) << newId.sector() << " mod/type = " << std::setw(4)
0099                   << newId.module() << " " << std::setw(4) << newId.modType() << " pos = " << std::setprecision(4)
0100                   << isector->basicComponents()[closest]->position();
0101             }
0102           } else {
0103             ETLDetId newId(isector->basicComponents()[idetNew]->geographicalId().rawId());
0104             LogVerbatim("MTDLayerDump") << std::fixed << "...............vshift= " << std::setw(2) << iside
0105                                         << " side = " << std::setw(4) << newId.mtdSide()
0106                                         << " Disc/Side/Sector = " << std::setw(4) << newId.nDisc() << " "
0107                                         << std::setw(4) << newId.discSide() << " " << std::setw(4) << newId.sector()
0108                                         << " mod/type = " << std::setw(4) << newId.module() << " " << std::setw(4)
0109                                         << newId.modType() << " pos = " << std::setprecision(4)
0110                                         << isector->basicComponents()[idetNew]->position();
0111           }
0112         }
0113       }
0114     }
0115   }
0116 }
0117 
0118 //define this as a plug-in
0119 #include <FWCore/Framework/interface/MakerMacros.h>
0120 DEFINE_FWK_MODULE(TestETLNavigation);