Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-02 03:38:53

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