File indexing completed on 2024-04-06 11:58:27
0001
0002
0003
0004
0005 #include "DTT0FEBPathCorrection.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Framework/interface/ESHandle.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010
0011 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0012 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0013 #include "Geometry/DTGeometry/interface/DTSuperLayer.h"
0014
0015 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0016 #include "CondFormats/DTObjects/interface/DTT0.h"
0017 #include "CondFormats/DataRecord/interface/DTT0Rcd.h"
0018 #include "FWCore/Framework/interface/ConsumesCollector.h"
0019
0020 #include <string>
0021 #include <sstream>
0022
0023 using namespace std;
0024 using namespace edm;
0025
0026 namespace dtCalibration {
0027
0028 DTT0FEBPathCorrection::DTT0FEBPathCorrection(const ParameterSet& pset, edm::ConsumesCollector cc)
0029 : calibChamber_(pset.getParameter<string>("calibChamber")), t0Token_(cc.esConsumes<edm::Transition::BeginRun>()) {
0030
0031 if (!calibChamber_.empty() && calibChamber_ != "None" && calibChamber_ != "All") {
0032 stringstream linestr;
0033 int selWheel, selStation, selSector;
0034 linestr << calibChamber_;
0035 linestr >> selWheel >> selStation >> selSector;
0036 chosenChamberId_ = DTChamberId(selWheel, selStation, selSector);
0037 LogVerbatim("Calibration") << "[DTT0FEBPathCorrection] Chosen chamber: " << chosenChamberId_ << endl;
0038 }
0039
0040 }
0041
0042 DTT0FEBPathCorrection::~DTT0FEBPathCorrection() {}
0043
0044 void DTT0FEBPathCorrection::setES(const EventSetup& setup) {
0045
0046 ESHandle<DTT0> t0H;
0047 t0H = setup.getHandle(t0Token_);
0048 t0Map_ = &setup.getData(t0Token_);
0049 LogVerbatim("Calibration") << "[DTT0FEBPathCorrection] T0 version: " << t0H->version();
0050 }
0051
0052 DTT0Data DTT0FEBPathCorrection::correction(const DTWireId& wireId) {
0053
0054
0055 DTChamberId chamberId = wireId.layerId().superlayerId().chamberId();
0056
0057 if (calibChamber_.empty() || calibChamber_ == "None")
0058 return defaultT0(wireId);
0059 if (calibChamber_ != "All" && chamberId != chosenChamberId_)
0060 return defaultT0(wireId);
0061
0062
0063 float t0Mean, t0RMS;
0064 int status = t0Map_->get(wireId, t0Mean, t0RMS, DTTimeUnits::counts);
0065 if (status != 0)
0066 throw cms::Exception("[DTT0FEBPathCorrection]") << "Could not find t0 entry in DB for" << wireId << endl;
0067 int wheel = chamberId.wheel();
0068 int station = chamberId.station();
0069 int sector = chamberId.sector();
0070 int sl = wireId.layerId().superlayerId().superlayer();
0071 int l = wireId.layerId().layer();
0072 int wire = wireId.wire();
0073 float t0MeanNew = t0Mean - t0FEBPathCorrection(wheel, station, sector, sl, l, wire);
0074 float t0RMSNew = t0RMS;
0075 return DTT0Data(t0MeanNew, t0RMSNew);
0076 }
0077
0078 DTT0Data DTT0FEBPathCorrection::defaultT0(const DTWireId& wireId) {
0079
0080 float t0Mean, t0RMS;
0081 int status = t0Map_->get(wireId, t0Mean, t0RMS, DTTimeUnits::counts);
0082 if (!status) {
0083 return DTT0Data(t0Mean, t0RMS);
0084 } else {
0085
0086 throw cms::Exception("[DTT0FEBPathCorrection]") << "Could not find t0 entry in DB for" << wireId << endl;
0087 }
0088 }
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 float DTT0FEBPathCorrection::t0FEBPathCorrection(int wheel, int st, int sec, int sl, int l, int w) {
0139
0140 if ((st == 1 && ((sl != 2 && w == 49) || (sl == 2 && w == 57))) || ((st == 2 || st == 3) && (sl == 2 && w == 57)))
0141 return 0.;
0142
0143 float dist[8] = {};
0144
0145
0146 if (l == 1 || l == 3) {
0147 dist[0] = +4.45;
0148 dist[1] = +2.45;
0149 dist[2] = -3.45;
0150 dist[3] = -5.45;
0151 dist[4] = -4.45;
0152 dist[5] = -2.45;
0153 dist[6] = +3.45;
0154 dist[7] = +5.45;
0155 }
0156
0157
0158 else {
0159 dist[0] = +5.45;
0160 dist[1] = +3.45;
0161 dist[2] = -2.45;
0162 dist[3] = -4.45;
0163 dist[4] = -5.45;
0164 dist[5] = -3.45;
0165 dist[6] = +2.45;
0166 dist[7] = +4.45;
0167 }
0168
0169
0170
0171 int pos = (w - 1) % 8;
0172
0173
0174
0175
0176
0177
0178 if ((st == 2 && sl != 2 && w >= 49) || (st == 4 && sec == 10 && w >= 49) ||
0179 (st == 4 && (sec == 8 || sec == 12) && w >= 81))
0180 pos = (w - 1 + 4) % 8;
0181
0182
0183
0184
0185
0186 return dist[pos] * 0.075;
0187 }
0188
0189 }