File indexing completed on 2024-04-06 12:25:59
0001 #include <RecoLocalMuon/CSCRecHitD/src/CSCRecoConditions.h>
0002 #include <CondFormats/CSCObjects/interface/CSCChannelTranslator.h>
0003 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0004 #include <iostream>
0005
0006 CSCRecoConditions::CSCRecoConditions(const edm::ParameterSet& ps, edm::ConsumesCollector cc) : theConditions(ps, cc) {}
0007
0008 CSCRecoConditions::~CSCRecoConditions() {}
0009
0010 void CSCRecoConditions::initializeEvent(const edm::EventSetup& es) { theConditions.initializeEvent(es); }
0011
0012
0013 void CSCRecoConditions::fillBadChannelWords(const CSCDetId& id) { theConditions.fillBadChannelWords(id); }
0014
0015
0016
0017
0018 float CSCRecoConditions::pedestal(const CSCDetId& id, int geomChannel) const {
0019 LogTrace("CSCRecoConditions") << id << " geomChannel " << geomChannel << " pedestal "
0020 << theConditions.pedestal(id, geomChannel);
0021 return theConditions.pedestal(id, geomChannel);
0022 }
0023
0024 float CSCRecoConditions::pedestalSigma(const CSCDetId& id, int geomChannel) const {
0025 return theConditions.pedestalSigma(id, geomChannel);
0026 }
0027
0028 float CSCRecoConditions::gain(const CSCDetId& id, int geomChannel) const {
0029 LogTrace("CSCRecoConditions") << id << " geomChannel " << geomChannel << " gain "
0030 << theConditions.gain(id, geomChannel);
0031 return theConditions.gain(id, geomChannel);
0032 }
0033
0034
0035
0036 float CSCRecoConditions::chipCorrection(const CSCDetId& id, int geomStrip) const {
0037
0038 int geomChannel = theConditions.channelFromStrip(id, geomStrip);
0039 return theConditions.chipCorrection(id, geomChannel);
0040 }
0041
0042
0043
0044
0045
0046
0047 void CSCRecoConditions::stripWeights(const CSCDetId& id, short int nstrips, float* weights) const {
0048 for (short int i = 1; i < nstrips + 1; ++i) {
0049 weights[i - 1] = stripWeight(id, i);
0050 }
0051 }
0052
0053
0054
0055
0056 float CSCRecoConditions::stripWeight(const CSCDetId& id, int geomStrip) const {
0057 int geomChannel = theConditions.channelFromStrip(id, geomStrip);
0058 float w = averageGain() / gain(id, geomChannel);
0059
0060 if (w > 1.5)
0061 w = 1.5;
0062 if (w < 0.5)
0063 w = 0.5;
0064 LogTrace("CSCRecoConditions") << id << " geomStrip " << geomStrip << " stripWeight " << w;
0065 return w;
0066 }
0067
0068 void CSCRecoConditions::noiseMatrix(const CSCDetId& id, int geomStrip, std::vector<float>& nMatrix) const {
0069
0070
0071 nMatrix.clear();
0072
0073
0074 const float fakeme12[15] = {8.64, 3.47, 2.45, 8.60, 3.28, 1.88, 8.61, 3.18, 1.99, 7.67, 2.64, 0., 7.71, 0., 0.};
0075
0076 float elem[15];
0077
0078 for (short int i = geomStrip - 1; i < geomStrip + 2; ++i) {
0079 std::vector<float> me(12);
0080
0081 float w = stripWeight(id, i);
0082 w = w * w;
0083 int geomChannel = theConditions.channelFromStrip(id, i);
0084 theConditions.noiseMatrixElements(id, geomChannel, me);
0085 for (short int j = 0; j < 11; ++j) {
0086 elem[j] = me[j] * w;
0087 }
0088 elem[11] = 0.;
0089 elem[12] = me[11] * w;
0090 elem[13] = 0.;
0091 elem[14] = 0.;
0092
0093
0094 bool isFlawed = false;
0095 for (short int k = 0; k < 15; ++k) {
0096 if (elem[k] < 0.001)
0097 elem[k] = 0.001;
0098 if (elem[k] > 50.)
0099 isFlawed = true;
0100 }
0101
0102 if (isFlawed) {
0103
0104 for (short int m = 0; m < 15; ++m) {
0105 elem[m] = fakeme12[m];
0106 }
0107 }
0108
0109 for (int k = 0; k < 15; ++k) {
0110 nMatrix.push_back(elem[k]);
0111 }
0112 }
0113 }
0114
0115 void CSCRecoConditions::crossTalk(const CSCDetId& id, int geomStrip, std::vector<float>& xtalks) const {
0116
0117
0118 xtalks.clear();
0119
0120 for (short int i = geomStrip - 1; i < geomStrip + 2; ++i) {
0121 int geomChannel = theConditions.channelFromStrip(id, i);
0122 std::vector<float> ct(4);
0123 theConditions.crossTalk(id, geomChannel, ct);
0124 xtalks.push_back(ct[0]);
0125 xtalks.push_back(ct[1]);
0126 xtalks.push_back(ct[2]);
0127 xtalks.push_back(ct[3]);
0128 }
0129 }
0130
0131
0132 bool CSCRecoConditions::nearBadStrip(const CSCDetId& id, int geomStrip, int nstrips) const {
0133 bool nearBad = (badStrip(id, geomStrip - 1, nstrips) || badStrip(id, geomStrip + 1, nstrips));
0134 return nearBad;
0135 }
0136
0137
0138 bool CSCRecoConditions::badStrip(const CSCDetId& id, int geomStrip, int nstrips) const {
0139
0140
0141
0142 bool bad = true;
0143
0144 if (id != theConditions.idOfBadChannelWords()) {
0145 bad = false;
0146 return bad;
0147 }
0148
0149 if (geomStrip > 0 && geomStrip <= nstrips) {
0150 bad = false;
0151 int geomChan = theConditions.channelFromStrip(id, geomStrip);
0152 int rawChan = theConditions.rawStripChannel(id, geomChan);
0153 if (rawChan > 0 && rawChan < 113) {
0154 const std::bitset<112>& badStrips = theConditions.badStripWord();
0155 bad = badStrips.test(rawChan - 1);
0156 }
0157 }
0158 return bad;
0159 }
0160
0161
0162 const std::bitset<112>& CSCRecoConditions::badWireWord(const CSCDetId& id) const { return theConditions.badWireWord(); }
0163
0164 float CSCRecoConditions::chamberTimingCorrection(const CSCDetId& id) const {
0165 return theConditions.chamberTimingCorrection(id);
0166 }
0167
0168 float CSCRecoConditions::anodeBXoffset(const CSCDetId& id) const { return theConditions.anodeBXoffset(id); }
0169
0170 float CSCRecoConditions::gasGainCorrection(const CSCDetId& id, int geomStrip, int wiregroup) const {
0171 int geomChannel = theConditions.channelFromStrip(id, geomStrip);
0172 return theConditions.gasGainCorrection(id, geomChannel, wiregroup);
0173 }