File indexing completed on 2024-06-06 04:27:03
0001 #include "L1Trigger/L1TMuonEndCap/interface/ConditionHelper.h"
0002
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/ConsumesCollector.h"
0005
0006 #include "CondFormats/L1TObjects/interface/L1TMuonEndCapParams.h"
0007 #include "CondFormats/DataRecord/interface/L1TMuonEndCapParamsRcd.h"
0008
0009 #include "CondFormats/L1TObjects/interface/L1TMuonEndCapForest.h"
0010 #include "CondFormats/DataRecord/interface/L1TMuonEndCapForestRcd.h"
0011
0012 #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine.h"
0013
0014 ConditionHelper::ConditionHelper(edm::ConsumesCollector iC)
0015 : params_cache_id_(0ULL), forest_cache_id_(0ULL), paramsToken_(iC.esConsumes()), forestToken_(iC.esConsumes()) {}
0016
0017 ConditionHelper::~ConditionHelper() {}
0018
0019 void ConditionHelper::checkAndUpdateConditions(const edm::EventSetup& iSetup) {
0020 bool new_params = false;
0021 bool new_forests = false;
0022
0023
0024 auto params_setup = iSetup.get<L1TMuonEndCapParamsRcd>();
0025 if (params_setup.cacheIdentifier() != params_cache_id_) {
0026 params_ = params_setup.getHandle(paramsToken_);
0027
0028
0029
0030
0031
0032 params_cache_id_ = params_setup.cacheIdentifier();
0033 new_params = true;
0034 }
0035
0036
0037 auto forest_setup = iSetup.get<L1TMuonEndCapForestRcd>();
0038 if (forest_setup.cacheIdentifier() != forest_cache_id_) {
0039 forest_ = forest_setup.getHandle(forestToken_);
0040
0041
0042
0043
0044
0045 forest_cache_id_ = forest_setup.cacheIdentifier();
0046 new_forests = true;
0047 }
0048
0049 bool new_conditions = (new_params || new_forests);
0050 if (new_conditions) {
0051 edm::LogInfo("L1T") << "EMTF updating conditions: pc_lut_ver: " << get_pc_lut_version()
0052 << " pt_lut_ver: " << get_pt_lut_version() << " fw_ver: " << get_fw_version();
0053 }
0054
0055
0056
0057
0058 }
0059
0060 unsigned int ConditionHelper::get_fw_version() const {
0061
0062 return params_->firmwareVersion_;
0063 }
0064
0065 unsigned int ConditionHelper::get_pt_lut_version() const {
0066
0067
0068 if (params_->firmwareVersion_ < 50000)
0069 return 5;
0070 return (params_->PtAssignVersion_ & 0xff);
0071 }
0072
0073 unsigned int ConditionHelper::get_pc_lut_version() const {
0074
0075
0076
0077
0078
0079
0080 if (params_->firmwareVersion_ < 50000) {
0081 return 0;
0082 } else if (params_->firmwareVersion_ < 1537467271) {
0083 return 1;
0084 } else if (params_->firmwareVersion_ <
0085 1664468309) {
0086 return 2;
0087 } else if (params_->firmwareVersion_ <
0088 1687686338) {
0089 return 3;
0090 } else if (params_->firmwareVersion_ <
0091 1716282790) {
0092 return 4;
0093 } else {
0094 return 5;
0095 }
0096 }
0097
0098 unsigned int ConditionHelper::get_pc_lut_version_unchecked() const {
0099
0100 return params_->PhiMatchWindowSt1_;
0101 }