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::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Types

typedef std::shared_ptr< L1TMuonEndCapForestReturnType
 
- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 

Public Member Functions

 L1TMuonEndCapForestESProducer (const edm::ParameterSet &)
 
ReturnType produce (const L1TMuonEndCapForestRcd &)
 
 ~L1TMuonEndCapForestESProducer () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () 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::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 

Detailed Description

Definition at line 23 of file L1TMuonEndCapForestESProducer.cc.

Member Typedef Documentation

Definition at line 28 of file L1TMuonEndCapForestESProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 41 of file L1TMuonEndCapForestESProducer.cc.

References edm::ParameterSet::getParameter().

42 {
43  setWhatProduced(this);
44 
45  ptLUTVersion = iConfig.getParameter<int>("PtAssignVersion");
46  bdtXMLDir = iConfig.getParameter<string>("bdtXMLDir");
47 }
T getParameter(std::string const &) const
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
L1TMuonEndCapForestESProducer::~L1TMuonEndCapForestESProducer ( )
inlineoverride

Definition at line 26 of file L1TMuonEndCapForestESProducer.cc.

26 {}

Member Function Documentation

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

Definition at line 92 of file L1TMuonEndCapForestESProducer.cc.

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

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

Definition at line 51 of file L1TMuonEndCapForestESProducer.cc.

References emtf::Node::getFitValue(), emtf::Node::getLeftDaughter(), emtf::Node::getRightDaughter(), emtf::Node::getSplitValue(), emtf::Node::getSplitVariable(), PFRecoTauDiscriminationByIsolation_cfi::offset, L1TMuonEndCapForest::DTreeNode::splitVar, and create_public_lumi_plots::transform.

51  {
52  // original implementation use 0 ptr for non-existing children nodes, return empty cond tree (vector of nodes)
53  if( !node ) return L1TMuonEndCapForest::DTree();
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 = (!left_subtree.empty()?1:0); // left subtree (if exists) is placed right after the root -> index=1
66  transform(left_subtree.cbegin(), // source from
67  left_subtree.cend(), // source till
68  cond_tree.begin() + 1, // destination
69  [] (L1TMuonEndCapForest::DTreeNode cond_node) {
70  // increment indecies only for existing children, left 0 for non-existing
71  if( cond_node.ileft ) cond_node.ileft += 1;
72  if( cond_node.iright) cond_node.iright += 1;
73  return cond_node;
74  }
75  );
76  unsigned int offset = left_subtree.size();
77  local_root.iright = (offset+right_subtree.size() ? 1 + offset : 0); // right subtree is placed after the left one
78  transform(right_subtree.cbegin(), // source from
79  right_subtree.cend(), // source till
80  cond_tree.begin() + 1 + offset, // destination
82  // increment indecies only for existing children, left 0 for non-existing
83  if( cond_node.ileft ) cond_node.ileft += 1 + offset;
84  if( cond_node.iright) cond_node.iright += 1 + offset;
85  return cond_node;
86  }
87  );
88  return cond_tree;
89 }
L1TMuonEndCapForest::DTree traverse(emtf::Node *tree)
std::vector< DTreeNode > DTree

Member Data Documentation

string L1TMuonEndCapForestESProducer::bdtXMLDir
private

Definition at line 34 of file L1TMuonEndCapForestESProducer.cc.

int L1TMuonEndCapForestESProducer::ptLUTVersion
private

Definition at line 33 of file L1TMuonEndCapForestESProducer.cc.