File indexing completed on 2024-04-06 11:58:27
0001
0002
0003
0004
0005
0006
0007 #include "DTTTrigMatchRPhi.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 #include "FWCore/Framework/interface/ESHandle.h"
0011 #include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
0012 #include "CondFormats/DTObjects/interface/DTTtrig.h"
0013 #include "CondFormats/DataRecord/interface/DTTtrigRcd.h"
0014
0015 #include <cmath>
0016
0017 using namespace std;
0018 using namespace edm;
0019
0020 namespace dtCalibration {
0021
0022 DTTTrigMatchRPhi::DTTTrigMatchRPhi(const ParameterSet& pset, edm::ConsumesCollector cc) {
0023 ttrigToken_ =
0024 cc.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", pset.getUntrackedParameter<string>("dbLabel")));
0025 }
0026
0027 DTTTrigMatchRPhi::~DTTTrigMatchRPhi() {}
0028
0029 void DTTTrigMatchRPhi::setES(const EventSetup& setup) {
0030
0031 ESHandle<DTTtrig> tTrig = setup.getHandle(ttrigToken_);
0032 tTrigMap_ = &*tTrig;
0033 }
0034
0035 DTTTrigData DTTTrigMatchRPhi::correction(const DTSuperLayerId& slId) {
0036 float tTrigMean, tTrigSigma, kFactor;
0037 int status = tTrigMap_->get(slId, tTrigMean, tTrigSigma, kFactor, DTTimeUnits::ns);
0038
0039 if (slId.superLayer() == 2) {
0040 if (status != 0)
0041 throw cms::Exception("[DTTTrigMatchRPhi]") << "Could not find tTrig entry in DB for" << slId << endl;
0042 return DTTTrigData(tTrigMean, tTrigSigma, kFactor);
0043 } else {
0044 DTSuperLayerId partnerSLId(slId.chamberId(), (slId.superLayer() == 1) ? 3 : 1);
0045 float tTrigMeanNew, tTrigSigmaNew, kFactorNew;
0046 if (!status) {
0047 if (!tTrigMap_->get(partnerSLId, tTrigMeanNew, tTrigSigmaNew, kFactorNew, DTTimeUnits::ns)) {
0048 tTrigMeanNew = (tTrigMean + tTrigMeanNew) / 2.;
0049
0050 tTrigSigmaNew = (tTrigSigmaNew + tTrigSigma) / 2.;
0051
0052 kFactorNew = kFactor;
0053 return DTTTrigData(tTrigMeanNew, tTrigSigmaNew, kFactorNew);
0054 } else
0055 return DTTTrigData(tTrigMean, tTrigSigma, kFactor);
0056 } else {
0057 if (!tTrigMap_->get(partnerSLId, tTrigMeanNew, tTrigSigmaNew, kFactorNew, DTTimeUnits::ns))
0058 return DTTTrigData(tTrigMeanNew, tTrigSigmaNew, kFactorNew);
0059 else {
0060 throw cms::Exception("[DTTTrigMatchRPhi]") << "Could not find tTrig entry in DB for" << slId << "\n"
0061 << partnerSLId << endl;
0062 }
0063 }
0064 }
0065 }
0066
0067 }