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