File indexing completed on 2024-04-06 12:20:42
0001 #include "L1Trigger/L1THGCal/interface/HGCalTriggerCellCalibration.h"
0002
0003 #include <cmath>
0004
0005 HGCalTriggerCellCalibration::HGCalTriggerCellCalibration(const edm::ParameterSet& conf)
0006 : lsb_(conf.getParameter<double>("lsb")),
0007 fCperMIP_(conf.getParameter<std::vector<double>>("fCperMIP")),
0008 chargeCollectionEfficiency_(conf.getParameter<edm::ParameterSet>("chargeCollectionEfficiency")
0009 .getParameter<std::vector<double>>("values")),
0010 thicknessCorrection_(conf.getParameter<std::vector<double>>("thicknessCorrection")),
0011 dEdX_weights_(conf.getParameter<std::vector<double>>("dEdXweights")) {
0012 for (const auto& fCperMIP : fCperMIP_) {
0013 if (fCperMIP <= 0) {
0014 edm::LogWarning("DivisionByZero") << "WARNING: zero or negative MIP->fC correction factor. It won't be "
0015 "applied to correct trigger cell energies.";
0016 }
0017 }
0018 for (const auto& cce : chargeCollectionEfficiency_) {
0019 if (cce <= 0) {
0020 edm::LogWarning("DivisionByZero") << "WARNING: zero or negative cell-thickness correction factor. It won't be "
0021 "applied to correct trigger cell energies.";
0022 }
0023 }
0024 for (const auto& thickCorr : thicknessCorrection_) {
0025 if (thickCorr <= 0) {
0026 edm::LogWarning("DivisionByZero") << "WARNING: zero or negative cell-thickness correction factor. It won't be "
0027 "applied to correct trigger cell energies.";
0028 }
0029 }
0030 }
0031
0032 void HGCalTriggerCellCalibration::calibrateInMipT(l1t::HGCalTriggerCell& trgCell) const {
0033 DetId trgdetid(trgCell.detId());
0034 bool isSilicon = triggerTools_.isSilicon(trgdetid);
0035 constexpr int kScintillatorIndex = 0;
0036 unsigned thickness = isSilicon ? triggerTools_.thicknessIndex(trgdetid) : kScintillatorIndex;
0037 if (thickness >= fCperMIP_.size()) {
0038 throw cms::Exception("OutOfBound") << "Trying to access thickness index " << thickness
0039 << " in fCperMIP, which is of size " << fCperMIP_.size();
0040 }
0041 if (thickness >= chargeCollectionEfficiency_.size()) {
0042 throw cms::Exception("OutOfBound") << "Trying to access thickness index " << thickness
0043 << " in chargeCollectionEfficiency, which is of size "
0044 << chargeCollectionEfficiency_.size();
0045 }
0046
0047
0048 int hwPt = trgCell.hwPt();
0049
0050
0051 double amplitude = hwPt * lsb_;
0052
0053 if (chargeCollectionEfficiency_[thickness] > 0) {
0054 amplitude /= chargeCollectionEfficiency_[thickness];
0055 }
0056
0057
0058 double trgCellMipP = amplitude;
0059
0060 if (fCperMIP_[thickness] > 0) {
0061 trgCellMipP /= fCperMIP_[thickness];
0062 }
0063
0064
0065 double trgCellMipPt = trgCellMipP / std::cosh(trgCell.eta());
0066
0067
0068 trgCell.setMipPt(trgCellMipPt);
0069 }
0070
0071 void HGCalTriggerCellCalibration::calibrateMipTinGeV(l1t::HGCalTriggerCell& trgCell) const {
0072 constexpr double MevToGeV(0.001);
0073 double trgCellEt(0.);
0074
0075 DetId trgdetid(trgCell.detId());
0076 unsigned trgCellLayer = triggerTools_.layerWithOffset(trgdetid);
0077 bool isSilicon = triggerTools_.isSilicon(trgdetid);
0078 constexpr int kScintillatorIndex = 0;
0079 unsigned thickness = isSilicon ? triggerTools_.thicknessIndex(trgdetid) : kScintillatorIndex;
0080 if (thickness >= thicknessCorrection_.size()) {
0081 throw cms::Exception("OutOfBound") << "Trying to access thickness index " << thickness
0082 << " in thicknessCorrection, which is of size " << thicknessCorrection_.size();
0083 }
0084
0085
0086
0087 trgCellEt = trgCell.mipPt() * MevToGeV;
0088 trgCellEt *= dEdX_weights_.at(trgCellLayer);
0089
0090
0091 if (thicknessCorrection_[thickness] > 0) {
0092 trgCellEt /= thicknessCorrection_[thickness];
0093 }
0094
0095 math::PtEtaPhiMLorentzVector calibP4(trgCellEt, trgCell.eta(), trgCell.phi(), 0.);
0096 trgCell.setP4(calibP4);
0097 }
0098
0099 void HGCalTriggerCellCalibration::calibrateInGeV(l1t::HGCalTriggerCell& trgCell) const {
0100
0101 calibrateInMipT(trgCell);
0102
0103
0104 calibrateMipTinGeV(trgCell);
0105 }