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::Event &iEvent, const edm::EventSetup &iSetup)
 
 ConditionHelper ()
 
unsigned int get_fw_version () const
 
unsigned int get_pc_lut_version () 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::ESHandle< L1TMuonEndCapParamsparams_
 
unsigned long long params_cache_id_
 

Detailed Description

Definition at line 18 of file ConditionHelper.h.

Constructor & Destructor Documentation

ConditionHelper::ConditionHelper ( )

Definition at line 13 of file ConditionHelper.cc.

13  :
14  params_cache_id_(0ULL), forest_cache_id_(0ULL) {
15 }
unsigned long long params_cache_id_
unsigned long long forest_cache_id_
ConditionHelper::~ConditionHelper ( )

Definition at line 17 of file ConditionHelper.cc.

17  {
18 }

Member Function Documentation

void ConditionHelper::checkAndUpdateConditions ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 20 of file ConditionHelper.cc.

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

Referenced by TrackFinder::process().

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

Definition at line 61 of file ConditionHelper.cc.

References L1TMuonEndCapParams::firmwareVersion_, and params_.

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

61  {
62  // std::cout << " - Getting firmware version from ConditionHelper: version = " << params_->firmwareVersion_ << std::endl;
63  return params_->firmwareVersion_;
64 }
edm::ESHandle< L1TMuonEndCapParams > params_
unsigned int ConditionHelper::get_pc_lut_version ( ) const

Definition at line 74 of file ConditionHelper.cc.

References L1TMuonEndCapParams::firmwareVersion_, and params_.

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

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

Definition at line 66 of file ConditionHelper.cc.

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

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

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

Definition at line 26 of file ConditionHelper.h.

Referenced by TrackFinder::process().

26 { return *forest_; }
edm::ESHandle< L1TMuonEndCapForest > forest_
const L1TMuonEndCapParams& ConditionHelper::getParams ( ) const
inline

Definition at line 25 of file ConditionHelper.h.

25 { return *params_; }
edm::ESHandle< L1TMuonEndCapParams > params_

Member Data Documentation

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

Definition at line 41 of file ConditionHelper.h.

Referenced by checkAndUpdateConditions().

unsigned long long ConditionHelper::forest_cache_id_
private

Definition at line 38 of file ConditionHelper.h.

Referenced by checkAndUpdateConditions().

edm::ESHandle<L1TMuonEndCapParams> ConditionHelper::params_
private
unsigned long long ConditionHelper::params_cache_id_
private

Definition at line 37 of file ConditionHelper.h.

Referenced by checkAndUpdateConditions().