Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-07 23:58:12

0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0005 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0006 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0007 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0010 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
0011 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0012 
0013 #include <climits>
0014 #include <iostream>
0015 
0016 class TrackerTopologyAnalyzer : public edm::one::EDAnalyzer<> {
0017 public:
0018   explicit TrackerTopologyAnalyzer(const edm::ParameterSet&);
0019   ~TrackerTopologyAnalyzer() override = default;
0020 
0021   void beginJob() override {}
0022   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0023   void endJob() override {}
0024 
0025 private:
0026   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tokTopo_;
0027   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tokGeo_;
0028 };
0029 
0030 TrackerTopologyAnalyzer::TrackerTopologyAnalyzer(const edm::ParameterSet&)
0031     : tokTopo_(esConsumes<TrackerTopology, TrackerTopologyRcd>()),
0032       tokGeo_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()) {}
0033 
0034 void TrackerTopologyAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0035   //Retrieve tracker topology from geometry
0036   const TrackerTopology* tTopo = &iSetup.getData(tokTopo_);
0037 
0038   typedef std::vector<DetId> DetIdContainer;
0039 
0040   const auto& geo = iSetup.getHandle(tokGeo_);
0041 
0042   DetIdContainer allIds = geo->detIds();
0043   unsigned int nOk = 0;
0044   unsigned int resultsOld[100];
0045   unsigned int resultsNew[100];
0046   unsigned int nComp = 14;
0047 
0048   //result 0 is layer number
0049   for (DetIdContainer::const_iterator id = allIds.begin(), detUnitIdEnd = allIds.end(); id != detUnitIdEnd; ++id) {
0050     if (id->det() == DetId::Tracker) {
0051       unsigned int subdet = id->subdetId();
0052 
0053       for (unsigned int i = 0; i < nComp; i++)
0054         resultsOld[i] = 0;
0055       for (unsigned int i = 0; i < nComp; i++)
0056         resultsNew[i] = 0;
0057 
0058       resultsNew[0] = tTopo->layer(*id);
0059       resultsNew[1] = tTopo->module(*id);
0060       //[2] is ladder - which is pxb specific
0061       //or side for all the others
0062       //[3] is tobRod and tec/tib/tid order
0063       //
0064       std::string DetIdPrint;
0065 
0066       if (subdet == PixelSubdetector::PixelBarrel) {
0067         DetIdPrint = tTopo->print(*id);
0068         std::cout << DetIdPrint << std::endl;
0069         resultsOld[0] = tTopo->pxbLayer(*id);
0070         resultsOld[1] = tTopo->pxbModule(*id);
0071         resultsNew[2] = tTopo->pxbLadder(*id);
0072         resultsNew[3] = 0;
0073         resultsOld[2] = tTopo->pxbLadder(*id);
0074       } else if (subdet == PixelSubdetector::PixelEndcap) {
0075         DetIdPrint = tTopo->print(*id);
0076         std::cout << DetIdPrint << std::endl;
0077         resultsOld[0] = tTopo->pxfDisk(*id);
0078         resultsOld[1] = tTopo->pxfModule(*id);
0079         resultsNew[2] = tTopo->pxfSide(*id);
0080         resultsNew[3] = 0;
0081         resultsNew[4] = tTopo->pxfDisk(*id);
0082         resultsNew[5] = tTopo->pxfBlade(*id);
0083         resultsNew[6] = tTopo->pxfPanel(*id);
0084         resultsOld[2] = tTopo->pxfSide(*id);
0085         resultsOld[4] = tTopo->pxfDisk(*id);
0086         resultsOld[5] = tTopo->pxfBlade(*id);
0087         resultsOld[6] = tTopo->pxfPanel(*id);
0088       } else if (subdet == StripSubdetector::TIB) {
0089         DetIdPrint = tTopo->print(*id);
0090         std::cout << DetIdPrint << std::endl;
0091         resultsOld[0] = tTopo->tibLayer(*id);
0092         resultsOld[1] = tTopo->tibModule(*id);
0093         resultsNew[2] = tTopo->tibSide(*id);
0094         resultsNew[3] = tTopo->tibOrder(*id);
0095         resultsNew[4] = 0;
0096         resultsNew[5] = 0;
0097         resultsNew[6] = tTopo->tibIsDoubleSide(*id);
0098         resultsNew[7] = tTopo->tibIsRPhi(*id);
0099         resultsNew[8] = tTopo->tibIsStereo(*id);
0100         resultsNew[9] = tTopo->tibIsZPlusSide(*id);
0101         resultsNew[10] = tTopo->tibIsZMinusSide(*id);
0102         resultsNew[11] = tTopo->tibString(*id);
0103         resultsNew[12] = tTopo->tibIsInternalString(*id);
0104         resultsNew[13] = tTopo->tibIsExternalString(*id);
0105         resultsOld[2] = tTopo->tibSide(*id);
0106         resultsOld[3] = tTopo->tibOrder(*id);
0107         resultsOld[6] = tTopo->tibIsDoubleSide(*id);
0108         resultsOld[7] = tTopo->tibIsRPhi(*id);
0109         resultsOld[8] = tTopo->tibIsStereo(*id);
0110         resultsOld[9] = tTopo->tibIsZPlusSide(*id);
0111         resultsOld[10] = tTopo->tibIsZMinusSide(*id);
0112         resultsOld[11] = tTopo->tibString(*id);
0113         resultsOld[12] = tTopo->tibIsInternalString(*id);
0114         resultsOld[13] = tTopo->tibIsExternalString(*id);
0115 
0116       } else if (subdet == StripSubdetector::TID) {
0117         DetIdPrint = tTopo->print(*id);
0118         std::cout << DetIdPrint << std::endl;
0119         resultsOld[0] = tTopo->tidWheel(*id);
0120         resultsOld[1] = tTopo->tidModule(*id);
0121         resultsNew[2] = tTopo->tidSide(*id);
0122         resultsNew[3] = tTopo->tidOrder(*id);
0123         resultsNew[4] = tTopo->tidRing(*id);
0124         resultsNew[5] = 0;
0125         resultsNew[6] = tTopo->tidIsDoubleSide(*id);
0126         resultsNew[7] = tTopo->tidIsRPhi(*id);
0127         resultsNew[8] = tTopo->tidIsStereo(*id);
0128         resultsNew[9] = tTopo->tidIsZPlusSide(*id);
0129         resultsNew[10] = tTopo->tidIsZMinusSide(*id);
0130         resultsNew[11] = tTopo->tidIsBackRing(*id);
0131         resultsNew[12] = tTopo->tidIsFrontRing(*id);
0132         resultsOld[2] = tTopo->tidSide(*id);
0133         resultsOld[3] = tTopo->tidOrder(*id);
0134         resultsOld[4] = tTopo->tidRing(*id);
0135         resultsOld[6] = tTopo->tidIsDoubleSide(*id);
0136         resultsOld[7] = tTopo->tidIsRPhi(*id);
0137         resultsOld[8] = tTopo->tidIsStereo(*id);
0138         resultsOld[9] = tTopo->tidIsZPlusSide(*id);
0139         resultsOld[10] = tTopo->tidIsZMinusSide(*id);
0140         resultsOld[11] = tTopo->tidIsBackRing(*id);
0141         resultsOld[12] = tTopo->tidIsFrontRing(*id);
0142       } else if (subdet == StripSubdetector::TOB) {
0143         DetIdPrint = tTopo->print(*id);
0144         std::cout << DetIdPrint << std::endl;
0145         resultsOld[0] = tTopo->tobLayer(*id);
0146         resultsOld[1] = tTopo->tobModule(*id);
0147         resultsNew[2] = tTopo->tobSide(*id);
0148         resultsNew[3] = tTopo->tobRod(*id);
0149         resultsNew[4] = 0;
0150         resultsNew[5] = 0;
0151         resultsNew[6] = tTopo->tobIsDoubleSide(*id);
0152         resultsNew[7] = tTopo->tobIsRPhi(*id);
0153         resultsNew[8] = tTopo->tobIsStereo(*id);
0154         resultsNew[9] = tTopo->tobIsZPlusSide(*id);
0155         resultsNew[10] = tTopo->tobIsZMinusSide(*id);
0156         resultsOld[2] = tTopo->tobSide(*id);
0157         resultsOld[3] = tTopo->tobRod(*id);
0158         resultsOld[6] = tTopo->tobIsDoubleSide(*id);
0159         resultsOld[7] = tTopo->tobIsRPhi(*id);
0160         resultsOld[8] = tTopo->tobIsStereo(*id);
0161         resultsOld[9] = tTopo->tobIsZPlusSide(*id);
0162         resultsOld[10] = tTopo->tobIsZMinusSide(*id);
0163       } else if (subdet == StripSubdetector::TEC) {
0164         DetIdPrint = tTopo->print(*id);
0165         std::cout << DetIdPrint << std::endl;
0166         resultsOld[0] = tTopo->tecWheel(*id);
0167         resultsOld[1] = tTopo->tecModule(*id);
0168         resultsNew[2] = tTopo->tecSide(*id);
0169         resultsNew[3] = tTopo->tecOrder(*id);
0170         resultsNew[4] = tTopo->tecRing(*id);
0171         resultsNew[5] = tTopo->tecPetalNumber(*id);
0172         resultsNew[6] = tTopo->tecIsDoubleSide(*id);
0173         resultsNew[7] = tTopo->tecIsRPhi(*id);
0174         resultsNew[8] = tTopo->tecIsStereo(*id);
0175         resultsNew[9] = tTopo->tecIsBackPetal(*id);
0176         resultsNew[10] = tTopo->tecIsFrontPetal(*id);
0177         resultsOld[2] = tTopo->tecSide(*id);
0178         resultsOld[3] = tTopo->tecOrder(*id);
0179         resultsOld[4] = tTopo->tecRing(*id);
0180         resultsOld[5] = tTopo->tecPetalNumber(*id);
0181         resultsOld[6] = tTopo->tecIsDoubleSide(*id);
0182         resultsOld[7] = tTopo->tecIsRPhi(*id);
0183         resultsOld[8] = tTopo->tecIsStereo(*id);
0184         resultsOld[9] = tTopo->tecIsBackPetal(*id);
0185         resultsOld[10] = tTopo->tecIsFrontPetal(*id);
0186       }
0187 
0188       bool isGood = true;
0189       for (unsigned int i = 0; i < nComp; i++)
0190         if (resultsOld[i] != resultsNew[i])
0191           isGood = false;
0192 
0193       if (isGood)
0194         nOk += 1;
0195       else {
0196         std::cout << "Bad " << id->rawId() << " " << id->subdetId() << " ";
0197         for (unsigned int i = 0; i < nComp; i++)
0198           std::cout << "[" << resultsOld[i] << "," << resultsNew[i] << "] " << std::endl;
0199       }
0200 
0201       const GeomDet* geom = geo->idToDet(*id);
0202       std::cout << "  (phi, z, r) : (" << geom->surface().position().phi() << " , " << geom->surface().position().z()
0203                 << " , " << geom->surface().position().perp() << ")" << std::endl;
0204     }
0205   }
0206   std::cout << "Good: " << nOk << std::endl;
0207 }
0208 
0209 DEFINE_FWK_MODULE(TrackerTopologyAnalyzer);