Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:23

0001 #include <memory>
0002 
0003 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0004 #include "FWCore/Framework/interface/ESHandle.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 
0009 #include "CalibMuon/CSCCalibration/interface/CSCChannelMapperBase.h"
0010 #include "CalibMuon/CSCCalibration/interface/CSCChannelMapperRecord.h"
0011 #include <iostream>
0012 
0013 class CSCMapperTestStartup : public edm::one::EDAnalyzer<> {
0014 public:
0015   explicit CSCMapperTestStartup(const edm::ParameterSet &);
0016   ~CSCMapperTestStartup() = default;
0017 
0018 private:
0019   virtual void beginJob();
0020   virtual void analyze(const edm::Event &, const edm::EventSetup &);
0021   virtual void endJob();
0022 
0023   std::string algoName;
0024 
0025   const edm::ESGetToken<CSCChannelMapperBase, CSCChannelMapperRecord> theCSCChannelMapperToken_;
0026 };
0027 
0028 CSCMapperTestStartup::CSCMapperTestStartup(const edm::ParameterSet &pset) : theCSCChannelMapperToken_(esConsumes()) {}
0029 
0030 void CSCMapperTestStartup::analyze(const edm::Event &ev, const edm::EventSetup &iSetup) {
0031   const int egeo[] = {1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2};        // endcap 1=+z, 2=-z
0032   const int sgeo[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};        // station 1-4
0033   const int rgeo[] = {1, 1, 1, 4, 4, 4, 1, 1, 1, 4, 4, 4};        // ring 1-4
0034   const int cgeo[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};        // chamber 1-18/36
0035   const int lgeo[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};        // layer 1-6
0036   const int tgeo[] = {1, 32, 64, 1, 8, 16, 1, 32, 64, 1, 8, 16};  // strip 1-80 (16, 48 64)
0037 
0038   const int eraw[] = {1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2};            // endcap 1=+z, 2=-z
0039   const int sraw[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};            // station 1-4
0040   const int rraw[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};            // ring 1-3
0041   const int craw[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};            // chamber 1-18/36
0042   const int lraw[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};            // layer 1-6
0043   const int traw[] = {1, 32, 64, 65, 72, 80, 1, 32, 64, 65, 72, 80};  // strip 1-80 (16, 48 64)
0044 
0045   const int estrip[] = {1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2};            // endcap 1=+z, 2=-z
0046   const int sstrip[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};            // station 1-4
0047   const int rstrip[] = {1, 1, 1, 4, 4, 4, 1, 1, 1, 4, 4, 4};            // ring 1-3
0048   const int cstrip[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};            // chamber 1-18/36
0049   const int lstrip[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};            // layer 1-6
0050   const int tstrip[] = {1, 32, 64, 65, 72, 80, 1, 32, 64, 65, 72, 80};  // strip 1-80 (16, 48 64)
0051 
0052   const int edetid[] = {1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2};  // endcap 1=+z, 2=-z
0053   const int sdetid[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};  // station 1-4
0054   const int rdetid[] = {1, 1, 1, 4, 4, 4, 1, 1, 1, 4, 4, 4};  // ring 1-3
0055   const int cdetid[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};  // chamber 1-18/36
0056   const int ldetid[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};  // layer 1-6
0057 
0058   const auto mapper_ = &iSetup.getData(theCSCChannelMapperToken_);
0059 
0060   algoName = mapper_->name();
0061 
0062   std::cout << "CSCMapperTestStartup: analyze sees algorithm " << algoName << " in Event Setup" << std::endl;
0063 
0064   size_t isiz = 12;
0065 
0066   std::cout << "\n" << algoName << "::rawStripChannel for:" << std::endl;
0067 
0068   std::cout << " E   S   R   C   L   geom   raw\n"
0069             << "                     chan   chan" << std::endl;
0070 
0071   for (size_t i = 0; i < isiz; ++i) {
0072     int ie = egeo[i];
0073     int is = sgeo[i];
0074     int ir = rgeo[i];
0075     int ic = cgeo[i];
0076     int il = lgeo[i];
0077     int igeo = tgeo[i];
0078 
0079     CSCDetId id(ie, is, ir, ic, il);
0080     int iraw = mapper_->rawStripChannel(id, igeo);
0081 
0082     std::cout << std::setw(2) << ie << std::setw(4) << is << std::setw(4) << ir << std::setw(4) << ic << std::setw(4)
0083               << il << std::setw(7) << igeo << std::setw(7) << iraw << std::endl;
0084   }
0085 
0086   std::cout << "\n" << algoName << "::geomStripChannel for:" << std::endl;
0087 
0088   std::cout << " E   S   R   C   L    raw   geom\n"
0089             << "                     chan   chan" << std::endl;
0090 
0091   for (size_t i = 0; i < isiz; ++i) {
0092     int ie = eraw[i];
0093     int is = sraw[i];
0094     int ir = rraw[i];
0095     int ic = craw[i];
0096     int il = lraw[i];
0097     int igeo = traw[i];
0098 
0099     CSCDetId id(ie, is, ir, ic, il);
0100     int iraw = mapper_->geomStripChannel(id, igeo);
0101 
0102     std::cout << std::setw(2) << ie << std::setw(4) << is << std::setw(4) << ir << std::setw(4) << ic << std::setw(4)
0103               << il << std::setw(7) << igeo << std::setw(7) << iraw << std::endl;
0104   }
0105 
0106   std::cout << "\n" << algoName << "::channelFromStrip for:" << std::endl;
0107 
0108   std::cout << " E   S   R   C   L   strip  chan" << std::endl;
0109 
0110   for (size_t i = 0; i < isiz; ++i) {
0111     int ie = estrip[i];
0112     int is = sstrip[i];
0113     int ir = rstrip[i];
0114     int ic = cstrip[i];
0115     int il = lstrip[i];
0116     int istrip = tstrip[i];
0117 
0118     CSCDetId id(ie, is, ir, ic, il);
0119     int ichan = mapper_->channelFromStrip(id, istrip);
0120 
0121     std::cout << std::setw(2) << ie << std::setw(4) << is << std::setw(4) << ir << std::setw(4) << ic << std::setw(4)
0122               << il << std::setw(7) << istrip << std::setw(7) << ichan << std::endl;
0123   }
0124 
0125   std::cout << "\n" << algoName << "::rawCSCDetId for:" << std::endl;
0126 
0127   std::cout << "          "
0128             << "CSCDetId IN"
0129             << "         "
0130             << "CSCDetId OUT" << std::endl;
0131 
0132   for (size_t i = 0; i < isiz; ++i) {
0133     int ie = edetid[i];
0134     int is = sdetid[i];
0135     int ir = rdetid[i];
0136     int ic = cdetid[i];
0137     int il = ldetid[i];
0138 
0139     CSCDetId id(ie, is, ir, ic, il);
0140     CSCDetId idout = mapper_->rawCSCDetId(id);
0141 
0142     std::cout << " " << id << " " << idout << std::endl;
0143   }
0144 }
0145 
0146 void CSCMapperTestStartup::beginJob() {}
0147 
0148 void CSCMapperTestStartup::endJob() {}
0149 
0150 // define this as a plug-in
0151 DEFINE_FWK_MODULE(CSCMapperTestStartup);