CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ConditionHelper Class Reference

#include <ConditionHelper.h>

Public Member Functions

void checkAndUpdateConditions (const edm::EventSetup &iSetup)
 
 ConditionHelper (edm::ConsumesCollector)
 
unsigned int get_fw_version () const
 
unsigned int get_pc_lut_version () const
 
unsigned int get_pc_lut_version_unchecked () const
 
unsigned int get_pt_lut_version () const
 
const L1TMuonEndCapForestgetForest () const
 
const L1TMuonEndCapParamsgetParams () const
 
 ~ConditionHelper ()
 

Private Attributes

edm::ESHandle< L1TMuonEndCapForestforest_
 
unsigned long long forest_cache_id_
 
edm::ESGetToken< L1TMuonEndCapForest, L1TMuonEndCapForestRcdforestToken_
 
edm::ESHandle< L1TMuonEndCapParamsparams_
 
unsigned long long params_cache_id_
 
edm::ESGetToken< L1TMuonEndCapParams, L1TMuonEndCapParamsRcdparamsToken_
 

Detailed Description

Definition at line 19 of file ConditionHelper.h.

Constructor & Destructor Documentation

◆ ConditionHelper()

ConditionHelper::ConditionHelper ( edm::ConsumesCollector  iC)

Definition at line 14 of file ConditionHelper.cc.

edm::ESGetToken< L1TMuonEndCapForest, L1TMuonEndCapForestRcd > forestToken_
edm::ESGetToken< L1TMuonEndCapParams, L1TMuonEndCapParamsRcd > paramsToken_
unsigned long long params_cache_id_
unsigned long long forest_cache_id_

◆ ~ConditionHelper()

ConditionHelper::~ConditionHelper ( )

Definition at line 17 of file ConditionHelper.cc.

17 {}

Member Function Documentation

◆ checkAndUpdateConditions()

void ConditionHelper::checkAndUpdateConditions ( const edm::EventSetup iSetup)

Definition at line 19 of file ConditionHelper.cc.

References forest_, forest_cache_id_, forestToken_, edm::EventSetup::get(), get_fw_version(), get_pc_lut_version(), get_pt_lut_version(), params_, params_cache_id_, and paramsToken_.

Referenced by EMTFSetup::reload().

19  {
20  bool new_params = false;
21  bool new_forests = false;
22 
23  // Pull configuration from the EventSetup
24  auto params_setup = iSetup.get<L1TMuonEndCapParamsRcd>();
25  if (params_setup.cacheIdentifier() != params_cache_id_) {
26  params_ = params_setup.getHandle(paramsToken_);
27 
28  // with the magic above you can use params_->fwVersion to change emulator's behavior
29  // ...
30 
31  // reset cache id
32  params_cache_id_ = params_setup.cacheIdentifier();
33  new_params = true;
34  }
35 
36  // Pull pt LUT from the EventSetup
37  auto forest_setup = iSetup.get<L1TMuonEndCapForestRcd>();
38  if (forest_setup.cacheIdentifier() != forest_cache_id_) {
39  forest_ = forest_setup.getHandle(forestToken_);
40 
41  // at this point we want to reload the newly pulled pT LUT
42  // ...
43 
44  // reset cache id
45  forest_cache_id_ = forest_setup.cacheIdentifier();
46  new_forests = true;
47  }
48 
49  bool new_conditions = (new_params || new_forests);
50  if (new_conditions) {
51  edm::LogInfo("L1T") << "EMTF updating conditions: pc_lut_ver: " << get_pc_lut_version()
52  << " pt_lut_ver: " << get_pt_lut_version() << " fw_ver: " << get_fw_version();
53  }
54 
55  // Debug
56  //edm::LogWarning("L1T") << "EMTF new conditions? Yes (1) or no (0)? -- " << new_conditions << std::endl;
57  //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();
58 }
edm::ESHandle< L1TMuonEndCapParams > params_
edm::ESHandle< L1TMuonEndCapForest > forest_
edm::ESGetToken< L1TMuonEndCapForest, L1TMuonEndCapForestRcd > forestToken_
edm::ESGetToken< L1TMuonEndCapParams, L1TMuonEndCapParamsRcd > paramsToken_
T get() const
Definition: EventSetup.h:82
Log< level::Info, false > LogInfo
unsigned int get_fw_version() const
unsigned long long params_cache_id_
unsigned int get_pc_lut_version() const
unsigned long long forest_cache_id_
unsigned int get_pt_lut_version() const

◆ get_fw_version()

unsigned int ConditionHelper::get_fw_version ( ) const

Definition at line 60 of file ConditionHelper.cc.

References L1TMuonEndCapParams::firmwareVersion_, and params_.

Referenced by checkAndUpdateConditions(), and EMTFSetup::reload().

60  {
61  // std::cout << " - Getting firmware version from ConditionHelper: version = " << params_->firmwareVersion_ << std::endl;
62  return params_->firmwareVersion_;
63 }
edm::ESHandle< L1TMuonEndCapParams > params_

◆ get_pc_lut_version()

unsigned int ConditionHelper::get_pc_lut_version ( ) const

Definition at line 73 of file ConditionHelper.cc.

References L1TMuonEndCapParams::firmwareVersion_, and params_.

Referenced by checkAndUpdateConditions(), TrackFinder::process(), and EMTFSetup::reload().

73  {
74  // "PhiMatchWindowSt1" arbitrarily re-mapped to Primitive conversion (PC LUT) version
75  // because of rigid CondFormats naming conventions - AWB 02.06.17
76  // std::cout << " - Getting proper PC LUT version from ConditionHelper: version = " << params_->PhiMatchWindowSt1_ << std::endl;
77  // return params_->PhiMatchWindowSt1_;
78 
79  // Hack until we figure out why the database is returning "0" for 2017 data - AWB 04.08.17
80  // std::cout << " - Getting hacked PC LUT version from ConditionHelper: version = " << (params_->firmwareVersion_ >= 50000) << std::endl;
81  if (params_->firmwareVersion_ < 50000) { // For 2016
82  return 0;
83  } else if (params_->firmwareVersion_ < 1537467271) { // From the beginning of 2017
84  return 1; // Corresponding to FW timestamps before Sept. 20, 2018
85  } else {
86  return 2; // Starting September 26, 2018 with run 323556 (data only, not in MC)
87  }
88 }
edm::ESHandle< L1TMuonEndCapParams > params_

◆ get_pc_lut_version_unchecked()

unsigned int ConditionHelper::get_pc_lut_version_unchecked ( ) const

Definition at line 90 of file ConditionHelper.cc.

References params_, and L1TMuonEndCapParams::PhiMatchWindowSt1_.

Referenced by TrackFinder::process(), and EMTFSetup::reload().

90  {
91  // See comment in get_pc_lut_version()
93 }
edm::ESHandle< L1TMuonEndCapParams > params_

◆ get_pt_lut_version()

unsigned int ConditionHelper::get_pt_lut_version ( ) const

Definition at line 65 of file ConditionHelper.cc.

References L1TMuonEndCapParams::firmwareVersion_, params_, and L1TMuonEndCapParams::PtAssignVersion_.

Referenced by checkAndUpdateConditions(), and EMTFSetup::reload().

65  {
66  // std::cout << " - Getting pT LUT version from ConditionHelper: version = " << (params_->PtAssignVersion_ & 0xff);
67  // std::cout << " (lowest bits of " << params_->PtAssignVersion_ << ")" << std::endl;
68  if (params_->firmwareVersion_ < 50000) // for 2016
69  return 5;
70  return (params_->PtAssignVersion_ & 0xff); // Version indicated by first two bytes
71 }
edm::ESHandle< L1TMuonEndCapParams > params_

◆ getForest()

const L1TMuonEndCapForest* ConditionHelper::getForest ( ) const
inline

Definition at line 27 of file ConditionHelper.h.

References forest_, and edm::ESHandle< T >::product().

Referenced by EMTFSetup::reload().

27 { return forest_.product(); }
edm::ESHandle< L1TMuonEndCapForest > forest_
T const * product() const
Definition: ESHandle.h:86

◆ getParams()

const L1TMuonEndCapParams* ConditionHelper::getParams ( ) const
inline

Definition at line 26 of file ConditionHelper.h.

References params_, and edm::ESHandle< T >::product().

26 { return params_.product(); }
edm::ESHandle< L1TMuonEndCapParams > params_
T const * product() const
Definition: ESHandle.h:86

Member Data Documentation

◆ forest_

edm::ESHandle<L1TMuonEndCapForest> ConditionHelper::forest_
private

Definition at line 45 of file ConditionHelper.h.

Referenced by checkAndUpdateConditions(), and getForest().

◆ forest_cache_id_

unsigned long long ConditionHelper::forest_cache_id_
private

Definition at line 40 of file ConditionHelper.h.

Referenced by checkAndUpdateConditions().

◆ forestToken_

edm::ESGetToken<L1TMuonEndCapForest, L1TMuonEndCapForestRcd> ConditionHelper::forestToken_
private

Definition at line 44 of file ConditionHelper.h.

Referenced by checkAndUpdateConditions().

◆ params_

edm::ESHandle<L1TMuonEndCapParams> ConditionHelper::params_
private

◆ params_cache_id_

unsigned long long ConditionHelper::params_cache_id_
private

Definition at line 39 of file ConditionHelper.h.

Referenced by checkAndUpdateConditions().

◆ paramsToken_

edm::ESGetToken<L1TMuonEndCapParams, L1TMuonEndCapParamsRcd> ConditionHelper::paramsToken_
private

Definition at line 42 of file ConditionHelper.h.

Referenced by checkAndUpdateConditions().