CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
L1TMuonEndCapForestESProducer Class Reference
Inheritance diagram for L1TMuonEndCapForestESProducer:
edm::ESProducer edm::ESProductResolverFactoryProducer edm::eventsetup::ESProductResolverProvider

Public Types

using ReturnType = std::unique_ptr< L1TMuonEndCapForest >
 

Public Member Functions

 L1TMuonEndCapForestESProducer (const edm::ParameterSet &)
 
ReturnType produce (const L1TMuonEndCapForestRcd &)
 
 ~L1TMuonEndCapForestESProducer () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ESProducer (const ESProducer &)=delete
 
 ESProducer (ESProducer &&)=delete
 
ESResolverIndex const * getTokenIndices (unsigned int iIndex) const
 
ESRecordIndex const * getTokenRecordIndices (unsigned int iIndex) const
 
bool hasMayConsumes () const noexcept
 
size_t numberOfTokenIndices (unsigned int iIndex) const
 
ESProduceroperator= (const ESProducer &)=delete
 
ESProduceroperator= (ESProducer &&)=delete
 
SerialTaskQueueChainqueue ()
 
template<typename Record >
std::optional< std::vector< ESResolverIndex > > updateFromMayConsumes (unsigned int iIndex, const Record &iRecord) const
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &) final
 
 ~ESProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::ESProductResolverFactoryProducer
 ESProductResolverFactoryProducer ()
 
 ESProductResolverFactoryProducer (const ESProductResolverFactoryProducer &)=delete
 
const ESProductResolverFactoryProduceroperator= (const ESProductResolverFactoryProducer &)=delete
 
 ~ESProductResolverFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 

Private Member Functions

L1TMuonEndCapForest::DTree traverse (emtf::Node *tree)
 

Private Attributes

string bdtXMLDir
 
int ptLUTVersion
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Types inherited from edm::ESProductResolverFactoryProducer
using EventSetupRecordKey = eventsetup::EventSetupRecordKey
 
- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 
- Protected Member Functions inherited from edm::ESProducer
ESConsumesInfoconsumesInfoPushBackNew ()
 
unsigned int consumesInfoSize () const
 
template<typename CallbackT , typename TList , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TList *, const TRecord *iRecord, const es::Label &iLabel)
 
template<typename CallbackT , typename TRecord >
void registerProducts (std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>>, const eventsetup::produce::Null *, const TRecord *, const es::Label &)
 
template<typename T >
auto setWhatProduced (T *iThis, const es::Label &iLabel={})
 
template<typename T >
auto setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
auto setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
auto setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord >
auto setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel={})
 
template<typename T , typename TReturn , typename TRecord , typename TDecorator >
auto setWhatProduced (T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TDecorator &iDec, const es::Label &iLabel={})
 
template<typename TFunc >
auto setWhatProduced (TFunc &&func, const es::Label &iLabel={})
 
template<typename TReturn , typename TRecord , typename TFunc , typename TDecorator >
ESConsumesCollectorT< TRecord > setWhatProduced (TFunc &&func, TDecorator &&iDec, const es::Label &iLabel={})
 
void usesResources (std::vector< std::string > const &)
 
- Protected Member Functions inherited from edm::ESProductResolverFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ESProductResolverFactoryBase > iFactory, const std::string &iLabel=std::string())
 
KeyedResolversVector registerResolvers (const EventSetupRecordKey &, unsigned int iovIndex) override
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 

Detailed Description

Definition at line 23 of file L1TMuonEndCapForestESProducer.cc.

Member Typedef Documentation

◆ ReturnType

Definition at line 28 of file L1TMuonEndCapForestESProducer.cc.

Constructor & Destructor Documentation

◆ L1TMuonEndCapForestESProducer()

L1TMuonEndCapForestESProducer::L1TMuonEndCapForestESProducer ( const edm::ParameterSet iConfig)

Definition at line 41 of file L1TMuonEndCapForestESProducer.cc.

References fakeEmtfParams_empty_cff::bdtXMLDir, and edm::ParameterSet::getParameter().

41  {
42  setWhatProduced(this);
43 
44  ptLUTVersion = iConfig.getParameter<int>("PtAssignVersion");
45  bdtXMLDir = iConfig.getParameter<string>("bdtXMLDir");
46 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

◆ ~L1TMuonEndCapForestESProducer()

L1TMuonEndCapForestESProducer::~L1TMuonEndCapForestESProducer ( )
inlineoverride

Definition at line 26 of file L1TMuonEndCapForestESProducer.cc.

26 {}

Member Function Documentation

◆ produce()

L1TMuonEndCapForestESProducer::ReturnType L1TMuonEndCapForestESProducer::produce ( const L1TMuonEndCapForestRcd iRecord)

Definition at line 94 of file L1TMuonEndCapForestESProducer.cc.

References fakeEmtfParams_empty_cff::bdtXMLDir, PtAssignmentEngine::getAllowedModes(), emtf::Tree::getBoostWeight(), PtAssignmentEngine::getForests(), emtf::Tree::getRootNode(), emtf::Forest::getTree(), mps_fire::i, dqmiolumiharvest::j, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, eostools::move(), PtAssignmentEngine::read(), and emtf::Forest::size().

94  {
95  // piggyback on the PtAssignmentEngine class to read the XMLs in
96  PtAssignmentEngine* pt_assign_engine_;
97  std::unique_ptr<PtAssignmentEngine> pt_assign_engine_2016_;
98  std::unique_ptr<PtAssignmentEngine> pt_assign_engine_2017_;
99 
100  pt_assign_engine_2016_ = std::make_unique<PtAssignmentEngine2016>();
101  pt_assign_engine_2017_ = std::make_unique<PtAssignmentEngine2017>();
102 
103  if (ptLUTVersion <= 5)
104  pt_assign_engine_ = pt_assign_engine_2016_.get();
105  else
106  pt_assign_engine_ = pt_assign_engine_2017_.get();
107 
108  pt_assign_engine_->read(ptLUTVersion, bdtXMLDir);
109 
110  // get a hold on the forests; copy to non-const locals
111  std::array<emtf::Forest, 16> forests = pt_assign_engine_->getForests();
112  std::vector<int> allowedModes = pt_assign_engine_->getAllowedModes();
113  // construct empty cond payload
114  auto pEMTFForest = std::make_unique<L1TMuonEndCapForest>();
115  // pack the forests into the cond payload for each mode
116  pEMTFForest->forest_coll_.resize(0);
117  for (unsigned int i = 0; i < allowedModes.size(); i++) {
118  int mode = allowedModes[i];
119  pEMTFForest->forest_map_[mode] = i;
120  // convert emtf::Forest into the L1TMuonEndCapForest::DForest
121  emtf::Forest& forest = forests.at(mode);
122  // Store boostWeight (initial pT value of tree 0) as an integer: boostWeight x 1 million
123  pEMTFForest->forest_map_[mode + 16] = forest.getTree(0)->getBoostWeight() * 1000000;
124  L1TMuonEndCapForest::DForest cond_forest;
125  for (unsigned int j = 0; j < forest.size(); j++)
126  cond_forest.push_back(traverse(forest.getTree(j)->getRootNode()));
127  // of course, move has no effect here, but I'll keep it in case move constructor will be provided some day
128  pEMTFForest->forest_coll_.push_back(std::move(cond_forest));
129  }
130 
131  return pEMTFForest;
132 }
Node * getRootNode()
Definition: Tree.cc:155
const std::array< emtf::Forest, 16 > & getForests(void) const
const std::vector< int > & getAllowedModes(void) const
L1TMuonEndCapForest::DTree traverse(emtf::Node *tree)
std::vector< DTree > DForest
unsigned int size()
Definition: Forest.cc:127
double getBoostWeight(void) const
Definition: Tree.h:57
Tree * getTree(unsigned int i)
Definition: Forest.cc:114
void read(int pt_lut_version, const std::string &xml_dir)
def move(src, dest)
Definition: eostools.py:511

◆ traverse()

L1TMuonEndCapForest::DTree L1TMuonEndCapForestESProducer::traverse ( emtf::Node tree)
private

Definition at line 50 of file L1TMuonEndCapForestESProducer.cc.

References emtf::Node::getFitValue(), emtf::Node::getLeftDaughter(), emtf::Node::getRightDaughter(), emtf::Node::getSplitValue(), emtf::Node::getSplitVariable(), hltrates_dqm_sourceclient-live_cfg::offset, L1TMuonEndCapForest::DTreeNode::splitVar, and HcalDetIdTransform::transform().

50  {
51  // original implementation use 0 ptr for non-existing children nodes, return empty cond tree (vector of nodes)
52  if (!node)
54  // recur on left and then right child
55  L1TMuonEndCapForest::DTree left_subtree = traverse(node->getLeftDaughter());
56  L1TMuonEndCapForest::DTree right_subtree = traverse(node->getRightDaughter());
57  // allocate tree
58  L1TMuonEndCapForest::DTree cond_tree(1 + left_subtree.size() + right_subtree.size());
59  // copy the local root node
60  L1TMuonEndCapForest::DTreeNode& local_root = cond_tree[0];
61  local_root.splitVar = node->getSplitVariable();
62  local_root.splitVal = node->getSplitValue();
63  local_root.fitVal = node->getFitValue();
64  // shift children indicies and place the subtrees into the newly allocated tree
65  local_root.ileft =
66  (!left_subtree.empty() ? 1 : 0); // left subtree (if exists) is placed right after the root -> index=1
67  transform(left_subtree.cbegin(), // source from
68  left_subtree.cend(), // source till
69  cond_tree.begin() + 1, // destination
70  [](L1TMuonEndCapForest::DTreeNode cond_node) {
71  // increment indecies only for existing children, left 0 for non-existing
72  if (cond_node.ileft)
73  cond_node.ileft += 1;
74  if (cond_node.iright)
75  cond_node.iright += 1;
76  return cond_node;
77  });
78  unsigned int offset = left_subtree.size();
79  local_root.iright = (offset + right_subtree.size() ? 1 + offset : 0); // right subtree is placed after the left one
80  transform(right_subtree.cbegin(), // source from
81  right_subtree.cend(), // source till
82  cond_tree.begin() + 1 + offset, // destination
84  // increment indecies only for existing children, left 0 for non-existing
85  if (cond_node.ileft)
86  cond_node.ileft += 1 + offset;
87  if (cond_node.iright)
88  cond_node.iright += 1 + offset;
89  return cond_node;
90  });
91  return cond_tree;
92 }
L1TMuonEndCapForest::DTree traverse(emtf::Node *tree)
std::vector< DTreeNode > DTree
unsigned transform(const HcalDetId &id, unsigned transformCode)

Member Data Documentation

◆ bdtXMLDir

string L1TMuonEndCapForestESProducer::bdtXMLDir
private

Definition at line 34 of file L1TMuonEndCapForestESProducer.cc.

◆ ptLUTVersion

int L1TMuonEndCapForestESProducer::ptLUTVersion
private

Definition at line 33 of file L1TMuonEndCapForestESProducer.cc.