CMS 3D CMS Logo

DTTTrigConstantShift.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  */
5 
6 #include "DTTTrigConstantShift.h"
11 
16 
17 #include <cmath>
18 
19 using namespace std;
20 using namespace edm;
21 
22 namespace dtCalibration {
23 
24  DTTTrigConstantShift::DTTTrigConstantShift(const ParameterSet& pset, edm::ConsumesCollector cc)
25  : calibChamber_(pset.getParameter<string>("calibChamber")), value_(pset.getParameter<double>("value")) {
26  ttrigToken_ =
27  cc.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", pset.getUntrackedParameter<string>("dbLabel")));
28  LogVerbatim("Calibration") << "[DTTTrigConstantShift] Applying constant correction value: " << value_ << endl;
29 
30  if (!calibChamber_.empty() && calibChamber_ != "None" && calibChamber_ != "All") {
31  stringstream linestr;
32  int selWheel, selStation, selSector;
33  linestr << calibChamber_;
34  linestr >> selWheel >> selStation >> selSector;
35  chosenChamberId_ = DTChamberId(selWheel, selStation, selSector);
36  LogVerbatim("Calibration") << "[DTTTrigConstantShift] Chosen chamber: " << chosenChamberId_ << endl;
37  }
38  //FIXME: Check if chosen chamber is valid.
39  }
40 
42 
44  // Get tTrig record from DB
46  tTrigMap_ = &*tTrig;
47  }
48 
50  float tTrigMean, tTrigSigma, kFactor;
51  int status = tTrigMap_->get(slId, tTrigMean, tTrigSigma, kFactor, DTTimeUnits::ns);
52  if (status != 0)
53  throw cms::Exception("[DTTTrigConstantShift]") << "Could not find tTrig entry in DB for" << slId << endl;
54 
55  float tTrigMeanNew = tTrigMean;
56  if (!calibChamber_.empty() && calibChamber_ != "None") {
57  if ((calibChamber_ == "All") || (calibChamber_ != "All" && slId.chamberId() == chosenChamberId_)) {
58  tTrigMeanNew = tTrigMean + value_;
59  }
60  }
61 
62  return DTTTrigData(tTrigMeanNew, tTrigSigma, kFactor);
63  }
64 
65 } // namespace dtCalibration
Log< level::Info, true > LogVerbatim
void setES(const edm::EventSetup &setup) override
DTTTrigData correction(const DTSuperLayerId &) override
DTChamberId chamberId() const
Return the corresponding ChamberId.
edm::ESGetToken< DTTtrig, DTTtrigRcd > ttrigToken_
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:59
HLT enums.