1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* See header file for a description of this class.
*
*/
#include "DTTTrigConstantShift.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/MuonDetId/interface/DTSuperLayerId.h"
#include "CondFormats/DTObjects/interface/DTTtrig.h"
#include "CondFormats/DataRecord/interface/DTTtrigRcd.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include <cmath>
using namespace std;
using namespace edm;
namespace dtCalibration {
DTTTrigConstantShift::DTTTrigConstantShift(const ParameterSet& pset, edm::ConsumesCollector cc)
: calibChamber_(pset.getParameter<string>("calibChamber")), value_(pset.getParameter<double>("value")) {
ttrigToken_ =
cc.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", pset.getUntrackedParameter<string>("dbLabel")));
LogVerbatim("Calibration") << "[DTTTrigConstantShift] Applying constant correction value: " << value_ << endl;
if (!calibChamber_.empty() && calibChamber_ != "None" && calibChamber_ != "All") {
stringstream linestr;
int selWheel, selStation, selSector;
linestr << calibChamber_;
linestr >> selWheel >> selStation >> selSector;
chosenChamberId_ = DTChamberId(selWheel, selStation, selSector);
LogVerbatim("Calibration") << "[DTTTrigConstantShift] Chosen chamber: " << chosenChamberId_ << endl;
}
//FIXME: Check if chosen chamber is valid.
}
DTTTrigConstantShift::~DTTTrigConstantShift() {}
void DTTTrigConstantShift::setES(const EventSetup& setup) {
// Get tTrig record from DB
ESHandle<DTTtrig> tTrig = setup.getHandle(ttrigToken_);
tTrigMap_ = &*tTrig;
}
DTTTrigData DTTTrigConstantShift::correction(const DTSuperLayerId& slId) {
float tTrigMean, tTrigSigma, kFactor;
int status = tTrigMap_->get(slId, tTrigMean, tTrigSigma, kFactor, DTTimeUnits::ns);
if (status != 0)
throw cms::Exception("[DTTTrigConstantShift]") << "Could not find tTrig entry in DB for" << slId << endl;
float tTrigMeanNew = tTrigMean;
if (!calibChamber_.empty() && calibChamber_ != "None") {
if ((calibChamber_ == "All") || (calibChamber_ != "All" && slId.chamberId() == chosenChamberId_)) {
tTrigMeanNew = tTrigMean + value_;
}
}
return DTTTrigData(tTrigMeanNew, tTrigSigma, kFactor);
}
} // namespace dtCalibration
|