CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
HGCalTriggerClusterIdentificationBDT Class Reference
Inheritance diagram for HGCalTriggerClusterIdentificationBDT:
HGCalTriggerClusterIdentificationBase

Classes

class  Category
 

Public Member Functions

bool decision (const l1t::HGCalMulticluster &cluster) const final
 
 HGCalTriggerClusterIdentificationBDT ()
 
void initialize (const edm::ParameterSet &conf) final
 
float value (const l1t::HGCalMulticluster &cluster) const final
 
 ~HGCalTriggerClusterIdentificationBDT () override
 
- Public Member Functions inherited from HGCalTriggerClusterIdentificationBase
 HGCalTriggerClusterIdentificationBase ()
 
virtual ~HGCalTriggerClusterIdentificationBase ()
 

Private Types

enum  ClusterVariable {
  ClusterVariable::cl3d_showerlength, ClusterVariable::cl3d_coreshowerlength, ClusterVariable::cl3d_firstlayer, ClusterVariable::cl3d_maxlayer,
  ClusterVariable::cl3d_seetot, ClusterVariable::cl3d_seemax, ClusterVariable::cl3d_spptot, ClusterVariable::cl3d_sppmax,
  ClusterVariable::cl3d_szz, ClusterVariable::cl3d_srrtot, ClusterVariable::cl3d_srrmax, ClusterVariable::cl3d_srrmean
}
 

Private Member Functions

int category (float pt, float eta) const
 
float clusterVariable (ClusterVariable, const l1t::HGCalMulticluster &) const
 

Private Attributes

std::vector< std::unique_ptr< TMVAEvaluator > > bdts_
 
std::vector< Categorycategories_
 
std::vector< std::string > input_variables_
 
std::vector< ClusterVariableinput_variables_id_
 
std::vector< double > working_points_
 

Detailed Description

Definition at line 8 of file HGCalTriggerClusterIdentificationBDT.cc.

Member Enumeration Documentation

Enumerator
cl3d_showerlength 
cl3d_coreshowerlength 
cl3d_firstlayer 
cl3d_maxlayer 
cl3d_seetot 
cl3d_seemax 
cl3d_spptot 
cl3d_sppmax 
cl3d_szz 
cl3d_srrtot 
cl3d_srrmax 
cl3d_srrmean 

Definition at line 44 of file HGCalTriggerClusterIdentificationBDT.cc.

44  {
45  cl3d_showerlength,
46  cl3d_coreshowerlength,
47  cl3d_firstlayer,
48  cl3d_maxlayer,
49  cl3d_seetot,
50  cl3d_seemax,
51  cl3d_spptot,
52  cl3d_sppmax,
53  cl3d_szz,
54  cl3d_srrtot,
55  cl3d_srrmax,
56  cl3d_srrmean
57  };

Constructor & Destructor Documentation

HGCalTriggerClusterIdentificationBDT::HGCalTriggerClusterIdentificationBDT ( )
HGCalTriggerClusterIdentificationBDT::~HGCalTriggerClusterIdentificationBDT ( )
inlineoverride

Definition at line 38 of file HGCalTriggerClusterIdentificationBDT.cc.

References decision(), initialize(), and value().

38 {};

Member Function Documentation

int HGCalTriggerClusterIdentificationBDT::category ( float  pt,
float  eta 
) const
private

Definition at line 159 of file HGCalTriggerClusterIdentificationBDT.cc.

References eostools::cat(), categories_, and edm::contains().

Referenced by decision(), and value().

159  {
160  for (unsigned cat = 0; cat < categories_.size(); cat++) {
161  if (categories_[cat].contains(pt, eta))
162  return static_cast<int>(cat);
163  }
164  return -1;
165 }
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
def cat(path)
Definition: eostools.py:401
float HGCalTriggerClusterIdentificationBDT::clusterVariable ( ClusterVariable  variable,
const l1t::HGCalMulticluster cluster 
) const
private

Definition at line 167 of file HGCalTriggerClusterIdentificationBDT.cc.

References cl3d_coreshowerlength, cl3d_firstlayer, cl3d_maxlayer, cl3d_seemax, cl3d_seetot, cl3d_showerlength, cl3d_sppmax, cl3d_spptot, cl3d_srrmax, cl3d_srrmean, cl3d_srrtot, cl3d_szz, l1t::HGCalClusterT< C >::coreShowerLength(), l1t::HGCalClusterT< C >::firstLayer(), l1t::HGCalClusterT< C >::maxLayer(), l1t::HGCalClusterT< C >::showerLength(), l1t::HGCalClusterT< C >::sigmaEtaEtaMax(), l1t::HGCalClusterT< C >::sigmaEtaEtaTot(), l1t::HGCalClusterT< C >::sigmaPhiPhiMax(), l1t::HGCalClusterT< C >::sigmaPhiPhiTot(), l1t::HGCalClusterT< C >::sigmaRRMax(), l1t::HGCalClusterT< C >::sigmaRRMean(), l1t::HGCalClusterT< C >::sigmaRRTot(), and l1t::HGCalClusterT< C >::sigmaZZ().

Referenced by value().

168  {
169  switch (variable) {
171  return cluster.showerLength();
173  return cluster.coreShowerLength();
175  return cluster.firstLayer();
177  return cluster.maxLayer();
179  return cluster.sigmaEtaEtaTot();
181  return cluster.sigmaEtaEtaMax();
183  return cluster.sigmaPhiPhiTot();
185  return cluster.sigmaPhiPhiMax();
187  return cluster.sigmaZZ();
189  return cluster.sigmaRRTot();
191  return cluster.sigmaRRMax();
193  return cluster.sigmaRRMean();
194  default:
195  break;
196  }
197  return 0.;
198 }
int maxLayer() const
float sigmaPhiPhiTot() const
float sigmaEtaEtaMax() const
float sigmaRRTot() const
float sigmaZZ() const
int showerLength() const
float sigmaEtaEtaTot() const
int coreShowerLength() const
int firstLayer() const
float sigmaRRMean() const
float sigmaRRMax() const
float sigmaPhiPhiMax() const
bool HGCalTriggerClusterIdentificationBDT::decision ( const l1t::HGCalMulticluster cluster) const
finalvirtual

Implements HGCalTriggerClusterIdentificationBase.

Definition at line 151 of file HGCalTriggerClusterIdentificationBDT.cc.

References eostools::cat(), category(), PVValHelper::eta, reco::LeafCandidate::eta(), EnergyCorrector::pt, reco::LeafCandidate::pt(), value(), and working_points_.

Referenced by ~HGCalTriggerClusterIdentificationBDT().

151  {
152  float bdt_output = value(cluster);
153  float pt = cluster.pt();
154  float eta = cluster.eta();
155  int cat = category(pt, eta);
156  return (cat != -1 ? bdt_output > working_points_.at(cat) : true);
157 }
double eta() const final
momentum pseudorapidity
double pt() const final
transverse momentum
def cat(path)
Definition: eostools.py:401
float value(const l1t::HGCalMulticluster &cluster) const final
void HGCalTriggerClusterIdentificationBDT::initialize ( const edm::ParameterSet conf)
finalvirtual

Implements HGCalTriggerClusterIdentificationBase.

Definition at line 73 of file HGCalTriggerClusterIdentificationBDT.cc.

References bdts_, eostools::cat(), categories_, cl3d_coreshowerlength, cl3d_firstlayer, cl3d_maxlayer, cl3d_seemax, cl3d_seetot, cl3d_showerlength, cl3d_sppmax, cl3d_spptot, cl3d_srrmax, cl3d_srrmean, cl3d_srrtot, cl3d_szz, Exception, FrontierConditions_GlobalTag_cff::file, edm::ParameterSet::getParameter(), input_variables_, input_variables_id_, candidateCombinedMVAV2Computer_cfi::spectators, taus_updatedMVAIds_cff::variable, and working_points_.

Referenced by ~HGCalTriggerClusterIdentificationBDT().

73  {
74  if (!bdts_.empty()) {
75  edm::LogWarning("HGCalTriggerClusterIdentificationBDT|Initialization") << "BDTs already initialized.";
76  return;
77  }
78  input_variables_ = conf.getParameter<std::vector<std::string>>("Inputs");
79  std::vector<std::string> bdt_files = conf.getParameter<std::vector<std::string>>("Weights");
80  std::vector<double> categories_etamin = conf.getParameter<std::vector<double>>("CategoriesEtaMin");
81  std::vector<double> categories_etamax = conf.getParameter<std::vector<double>>("CategoriesEtaMax");
82  std::vector<double> categories_ptmin = conf.getParameter<std::vector<double>>("CategoriesPtMin");
83  std::vector<double> categories_ptmax = conf.getParameter<std::vector<double>>("CategoriesPtMax");
84  working_points_ = conf.getParameter<std::vector<double>>("WorkingPoints");
85 
86  if (bdt_files.size() != categories_etamin.size() || categories_etamin.size() != categories_etamax.size() ||
87  categories_etamax.size() != categories_ptmin.size() || categories_ptmin.size() != categories_ptmax.size() ||
88  categories_ptmax.size() != working_points_.size()) {
89  throw cms::Exception("HGCalTriggerClusterIdentificationBDT|BadInitialization")
90  << "Inconsistent numbers of categories, BDT weight files and working points";
91  }
92  categories_.reserve(working_points_.size());
93  bdts_.reserve(working_points_.size());
94  for (unsigned cat = 0; cat < categories_etamin.size(); cat++) {
95  categories_.emplace_back(
96  categories_ptmin[cat], categories_ptmax[cat], categories_etamin[cat], categories_etamax[cat]);
97  }
98  std::vector<std::string> spectators = {};
99  for (const auto& file : bdt_files) {
100  bdts_.emplace_back(new TMVAEvaluator());
101  bdts_.back()->initialize("!Color:Silent:!Error",
102  "BDT::bdt",
103  edm::FileInPath(file).fullPath(),
105  spectators,
106  false,
107  false);
108  }
109 
110  // Transform input variable strings to enum values for later comparisons
111  input_variables_id_.reserve(input_variables_.size());
112  for (const auto& variable : input_variables_) {
113  if (variable == "cl3d_showerlength")
115  else if (variable == "cl3d_coreshowerlength")
117  else if (variable == "cl3d_firstlayer")
119  else if (variable == "cl3d_maxlayer")
121  else if (variable == "cl3d_seetot")
123  else if (variable == "cl3d_seemax")
125  else if (variable == "cl3d_spptot")
127  else if (variable == "cl3d_sppmax")
129  else if (variable == "cl3d_szz")
131  else if (variable == "cl3d_srrtot")
133  else if (variable == "cl3d_srrmax")
135  else if (variable == "cl3d_srrmean")
137  }
138 }
T getParameter(std::string const &) const
def cat(path)
Definition: eostools.py:401
std::vector< std::unique_ptr< TMVAEvaluator > > bdts_
float HGCalTriggerClusterIdentificationBDT::value ( const l1t::HGCalMulticluster cluster) const
finalvirtual

Implements HGCalTriggerClusterIdentificationBase.

Definition at line 140 of file HGCalTriggerClusterIdentificationBDT.cc.

References bdts_, eostools::cat(), category(), clusterVariable(), PVValHelper::eta, reco::LeafCandidate::eta(), mps_fire::i, input_variables_, input_variables_id_, PatBasicFWLiteJetAnalyzer_Selector_cfg::inputs, EnergyCorrector::pt, and reco::LeafCandidate::pt().

Referenced by average.Average::average(), decision(), and ~HGCalTriggerClusterIdentificationBDT().

140  {
141  std::map<std::string, float> inputs;
142  for (unsigned i = 0; i < input_variables_.size(); i++) {
144  }
145  float pt = cluster.pt();
146  float eta = cluster.eta();
147  int cat = category(pt, eta);
148  return (cat != -1 ? bdts_.at(cat)->evaluate(inputs) : -999.);
149 }
double eta() const final
momentum pseudorapidity
double pt() const final
transverse momentum
def cat(path)
Definition: eostools.py:401
float clusterVariable(ClusterVariable, const l1t::HGCalMulticluster &) const
std::vector< std::unique_ptr< TMVAEvaluator > > bdts_

Member Data Documentation

std::vector<std::unique_ptr<TMVAEvaluator> > HGCalTriggerClusterIdentificationBDT::bdts_
private

Definition at line 59 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by initialize(), and value().

std::vector<Category> HGCalTriggerClusterIdentificationBDT::categories_
private

Definition at line 58 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by category(), and initialize().

std::vector<std::string> HGCalTriggerClusterIdentificationBDT::input_variables_
private

Definition at line 61 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by initialize(), and value().

std::vector<ClusterVariable> HGCalTriggerClusterIdentificationBDT::input_variables_id_
private

Definition at line 62 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by initialize(), and value().

std::vector<double> HGCalTriggerClusterIdentificationBDT::working_points_
private

Definition at line 60 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by decision(), and initialize().