CMS 3D CMS Logo

ConditionHelper.cc
Go to the documentation of this file.
2 
4 
7 
10 
12 
13 ConditionHelper::ConditionHelper() : params_cache_id_(0ULL), forest_cache_id_(0ULL) {}
14 
16 
18  bool new_params = false;
19  bool new_forests = false;
20 
21  // Pull configuration from the EventSetup
22  auto params_setup = iSetup.get<L1TMuonEndCapParamsRcd>();
23  if (params_setup.cacheIdentifier() != params_cache_id_) {
24  params_setup.get(params_);
25 
26  // with the magic above you can use params_->fwVersion to change emulator's behavior
27  // ...
28 
29  // reset cache id
30  params_cache_id_ = params_setup.cacheIdentifier();
31  new_params = true;
32  }
33 
34  // Pull pt LUT from the EventSetup
35  auto forest_setup = iSetup.get<L1TMuonEndCapForestRcd>();
36  if (forest_setup.cacheIdentifier() != forest_cache_id_) {
37  forest_setup.get(forest_);
38 
39  // at this point we want to reload the newly pulled pT LUT
40  // ...
41 
42  // reset cache id
43  forest_cache_id_ = forest_setup.cacheIdentifier();
44  new_forests = true;
45  }
46 
47  bool new_conditions = (new_params || new_forests);
48  if (new_conditions) {
49  edm::LogInfo("L1T") << "EMTF updating conditions: pc_lut_ver: " << get_pc_lut_version()
50  << " pt_lut_ver: " << get_pt_lut_version() << " fw_ver: " << get_fw_version();
51  }
52 
53  // Debug
54  //edm::LogWarning("L1T") << "EMTF new conditions? Yes (1) or no (0)? -- " << new_conditions << std::endl;
55  //edm::LogWarning("L1T") << "EMTF updating conditions: pc_lut_ver: " << get_pc_lut_version() << " pt_lut_ver: " << get_pt_lut_version() << " fw_ver: " << get_fw_version();
56 }
57 
58 unsigned int ConditionHelper::get_fw_version() const {
59  // std::cout << " - Getting firmware version from ConditionHelper: version = " << params_->firmwareVersion_ << std::endl;
60  return params_->firmwareVersion_;
61 }
62 
64  // std::cout << " - Getting pT LUT version from ConditionHelper: version = " << (params_->PtAssignVersion_ & 0xff);
65  // std::cout << " (lowest bits of " << params_->PtAssignVersion_ << ")" << std::endl;
66  if (params_->firmwareVersion_ < 50000) // for 2016
67  return 5;
68  return (params_->PtAssignVersion_ & 0xff); // Version indicated by first two bytes
69 }
70 
72  // "PhiMatchWindowSt1" arbitrarily re-mapped to Primitive conversion (PC LUT) version
73  // because of rigid CondFormats naming conventions - AWB 02.06.17
74  // std::cout << " - Getting proper PC LUT version from ConditionHelper: version = " << params_->PhiMatchWindowSt1_ << std::endl;
75  // return params_->PhiMatchWindowSt1_;
76 
77  // Hack until we figure out why the database is returning "0" for 2017 data - AWB 04.08.17
78  // std::cout << " - Getting hacked PC LUT version from ConditionHelper: version = " << (params_->firmwareVersion_ >= 50000) << std::endl;
79  if (params_->firmwareVersion_ < 50000) { // For 2016
80  return 0;
81  } else if (params_->firmwareVersion_ < 1537467271) { // From the beginning of 2017
82  return 1; // Corresponding to FW timestamps before Sept. 20, 2018
83  } else {
84  return 2; // Starting September 26, 2018 with run 323556 (data only, not in MC)
85  }
86 }
87 
89  // See comment in get_pc_lut_version()
91 }
L1TMuonEndCapParams::PtAssignVersion_
unsigned PtAssignVersion_
Definition: L1TMuonEndCapParams.h:28
edm::LogInfo
Definition: MessageLogger.h:254
ConditionHelper::forest_
edm::ESHandle< L1TMuonEndCapForest > forest_
Definition: ConditionHelper.h:40
ConditionHelper::get_pc_lut_version_unchecked
unsigned int get_pc_lut_version_unchecked() const
Definition: ConditionHelper.cc:88
L1TMuonEndCapParams.h
L1TMuonEndCapForestRcd.h
ConditionHelper::ConditionHelper
ConditionHelper()
Definition: ConditionHelper.cc:13
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
ConditionHelper.h
ConditionHelper::get_fw_version
unsigned int get_fw_version() const
Definition: ConditionHelper.cc:58
L1TMuonEndCapForestRcd
Definition: L1TMuonEndCapForestRcd.h:11
L1TMuonEndCapForest.h
L1TMuonEndCapParams::firmwareVersion_
unsigned firmwareVersion_
Definition: L1TMuonEndCapParams.h:28
ConditionHelper::params_cache_id_
unsigned long long params_cache_id_
Definition: ConditionHelper.h:36
L1TMuonEndCapParamsRcd
Definition: L1TMuonEndCapParamsRcd.h:11
iEvent
int iEvent
Definition: GenABIO.cc:224
ConditionHelper::get_pc_lut_version
unsigned int get_pc_lut_version() const
Definition: ConditionHelper.cc:71
ConditionHelper::params_
edm::ESHandle< L1TMuonEndCapParams > params_
Definition: ConditionHelper.h:39
edm::EventSetup
Definition: EventSetup.h:57
L1TMuonEndCapParamsRcd.h
ConditionHelper::forest_cache_id_
unsigned long long forest_cache_id_
Definition: ConditionHelper.h:37
L1TMuonEndCapParams::PhiMatchWindowSt1_
int PhiMatchWindowSt1_
Definition: L1TMuonEndCapParams.h:29
EventSetup.h
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition: EventSetupRecordImplementation.h:74
PtAssignmentEngine.h
edm::Event
Definition: Event.h:73
ConditionHelper::get_pt_lut_version
unsigned int get_pt_lut_version() const
Definition: ConditionHelper.cc:63
ConditionHelper::checkAndUpdateConditions
void checkAndUpdateConditions(const edm::Event &iEvent, const edm::EventSetup &iSetup)
Definition: ConditionHelper.cc:17
ConditionHelper::~ConditionHelper
~ConditionHelper()
Definition: ConditionHelper.cc:15