Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/Framework/interface/EventSetup.h"
0003 #include "FWCore/Framework/interface/ESHandle.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0006 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0007 #include "Geometry/CSCGeometry/interface/CSCLayer.h"
0008 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
0009 
0010 #include <string>
0011 #include <iomanip>  // for setw() etc.
0012 #include <vector>
0013 
0014 class CSCGeometryOfStrips : public edm::one::EDAnalyzer<> {
0015 public:
0016   explicit CSCGeometryOfStrips(const edm::ParameterSet&);
0017   ~CSCGeometryOfStrips() override = default;
0018 
0019   void beginJob() override {}
0020   void analyze(edm::Event const&, edm::EventSetup const&) override;
0021   void endJob() override {}
0022 
0023   const std::string& myName() { return myName_; }
0024 
0025 private:
0026   const int dashedLineWidth_;
0027   const std::string dashedLine_;
0028   const std::string myName_;
0029   const edm::ESGetToken<CSCGeometry, MuonGeometryRecord> tokGeom_;
0030 };
0031 
0032 CSCGeometryOfStrips::CSCGeometryOfStrips(const edm::ParameterSet& iConfig)
0033     : dashedLineWidth_(101),
0034       dashedLine_(std::string(dashedLineWidth_, '-')),
0035       myName_("CSCGeometryOfStrips"),
0036       tokGeom_(esConsumes()) {}
0037 
0038 void CSCGeometryOfStrips::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0039   //   const double dPi = Geom::pi();
0040   //   const double radToDeg = 180. / dPi;
0041 
0042   std::cout << myName() << ": Analyzer..." << std::endl;
0043   std::cout << "start " << dashedLine_ << std::endl;
0044 
0045   const edm::ESHandle<CSCGeometry>& pDD = iSetup.getHandle(tokGeom_);
0046   std::cout << " Geometry node for CSCGeometry is  " << &(*pDD) << std::endl;
0047   std::cout << " I have " << pDD->detTypes().size() << " detTypes" << std::endl;
0048   std::cout << " I have " << pDD->detUnits().size() << " detUnits" << std::endl;
0049   std::cout << " I have " << pDD->dets().size() << " dets" << std::endl;
0050   std::cout << " I have " << pDD->layers().size() << " layers" << std::endl;
0051   std::cout << " I have " << pDD->chambers().size() << " chambers" << std::endl;
0052 
0053   std::cout << myName() << ": Begin iteration over geometry..." << std::endl;
0054   std::cout << "iter " << dashedLine_ << std::endl;
0055 
0056   int icount = 0;
0057 
0058   // Check the DetUnits
0059   for (auto it : pDD->detUnits()) {
0060     // Do we really have a CSC layer?
0061 
0062     auto layer = dynamic_cast<CSCLayer const*>(it);
0063 
0064     if (layer) {
0065       ++icount;
0066       DetId detId = layer->geographicalId();
0067       int id = detId();  // or detId.rawId()
0068 
0069       std::cout << "\n"
0070                 << "Testing CSC layer# " << icount << " id= " << id << " = " << std::oct << id << std::dec
0071                 << " (octal) "
0072                 << "   E" << CSCDetId::endcap(id) << " S" << CSCDetId::station(id) << " R" << CSCDetId::ring(id) << " C"
0073                 << CSCDetId::chamber(id) << " L" << CSCDetId::layer(id) << std::endl;
0074 
0075       const CSCLayerGeometry* geom = layer->geometry();
0076       //        std::cout << *geom;
0077 
0078       const CSCStripTopology* topol = geom->topology();
0079       //        std::cout << "\n" << *topol;
0080 
0081       int nStrips = geom->numberOfStrips();
0082 
0083       float mps = 30.;
0084       if (nStrips < static_cast<int>(mps))
0085         mps = 8.;
0086 
0087       MeasurementPoint mp(mps, 0.3);
0088       MeasurementError merr(0.25, 0, 0.25);
0089 
0090       LocalPoint lp = topol->localPosition(mp);
0091       LocalError lerr = topol->localError(mp, merr);
0092 
0093       MeasurementPoint mp2 = topol->measurementPosition(lp);
0094       MeasurementError merr2 = topol->measurementError(lp, lerr);
0095 
0096       float strip = 30.;
0097       if (nStrips < static_cast<int>(strip))
0098         strip = 8.;
0099 
0100       LocalPoint lps = topol->localPosition(strip);
0101       float stripLP = topol->strip(lps);
0102 
0103       std::cout << "Strip check: strip in=" << strip << ", strip out=" << stripLP << std::endl;
0104       std::cout << "mp.x in=" << mp.x() << ",  mp.x out=" << mp2.x() << std::endl;
0105       std::cout << "mp.y in=" << mp.y() << ",  mp.y out=" << mp2.y() << std::endl;
0106 
0107       const float kEps = 1.E-04;
0108 
0109       if (fabs(strip - stripLP) > kEps) {
0110         std::cout << "...strip mismatch! " << std::endl;
0111       }
0112 
0113       if (fabs(mp.x() - mp2.x()) > kEps || fabs(mp.y() - mp2.y()) > kEps) {
0114         std::cout << "...measurement point mismatch!" << std::endl;
0115       }
0116 
0117       std::cout << "merr.uu in=" << merr.uu() << ", merr.uu out=" << merr2.uu() << std::endl;
0118       std::cout << "merr.uv in=" << merr.uv() << ", merr.uv out=" << merr2.uv() << std::endl;
0119       std::cout << "merr.vv in=" << merr.vv() << ", merr.vv out=" << merr2.vv() << std::endl;
0120 
0121       if (fabs(merr.uu() - merr2.uu()) > kEps || fabs(merr.vv() - merr2.vv()) > kEps ||
0122           fabs(merr.uv() - merr2.uv()) > kEps) {
0123         std::cout << "...measurement point error mismatch!" << std::endl;
0124       }
0125 
0126     } else {
0127       std::cout << "Could not dynamic_cast to a CSCLayer* " << std::endl;
0128     }
0129   }
0130   std::cout << dashedLine_ << " end" << std::endl;
0131   std::cout << " UPDATED 28.10.2012" << std::endl;
0132 }
0133 
0134 //define this as a plug-in
0135 DEFINE_FWK_MODULE(CSCGeometryOfStrips);