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
 
class  WorkingPoint
 

Public Member Functions

bool decision (const l1t::HGCalMulticluster &cluster, unsigned wp=0) const final
 
 HGCalTriggerClusterIdentificationBDT ()
 
void initialize (const edm::ParameterSet &conf) final
 
float value (const l1t::HGCalMulticluster &cluster) const final
 
const std::vector< std::string > & working_points () 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< std::vector< WorkingPoint > > working_points_
 
std::vector< std::string > working_points_names_
 

Detailed Description

Definition at line 8 of file HGCalTriggerClusterIdentificationBDT.cc.

Member Enumeration Documentation

◆ ClusterVariable

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 58 of file HGCalTriggerClusterIdentificationBDT.cc.

58  {
59  cl3d_showerlength,
60  cl3d_coreshowerlength,
61  cl3d_firstlayer,
62  cl3d_maxlayer,
63  cl3d_seetot,
64  cl3d_seemax,
65  cl3d_spptot,
66  cl3d_sppmax,
67  cl3d_szz,
68  cl3d_srrtot,
69  cl3d_srrmax,
70  cl3d_srrmean
71  };

Constructor & Destructor Documentation

◆ HGCalTriggerClusterIdentificationBDT()

HGCalTriggerClusterIdentificationBDT::HGCalTriggerClusterIdentificationBDT ( )

◆ ~HGCalTriggerClusterIdentificationBDT()

HGCalTriggerClusterIdentificationBDT::~HGCalTriggerClusterIdentificationBDT ( )
inlineoverride

Definition at line 51 of file HGCalTriggerClusterIdentificationBDT.cc.

51 {};

Member Function Documentation

◆ category()

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

Definition at line 189 of file HGCalTriggerClusterIdentificationBDT.cc.

References eostools::cat(), categories_, edm::contains(), PVValHelper::eta, and DiDispStaMuonMonitor_cfi::pt.

Referenced by decision(), and value().

189  {
190  for (unsigned cat = 0; cat < categories_.size(); cat++) {
191  if (categories_[cat].contains(pt, eta))
192  return static_cast<int>(cat);
193  }
194  return -1;
195 }
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
def cat(path)
Definition: eostools.py:401

◆ clusterVariable()

float HGCalTriggerClusterIdentificationBDT::clusterVariable ( ClusterVariable  variable,
const l1t::HGCalMulticluster cluster 
) const
private

Definition at line 197 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(), l1t::HGCalClusterT< C >::sigmaZZ(), and taus_updatedMVAIds_cff::variable.

Referenced by value().

198  {
199  switch (variable) {
201  return cluster.showerLength();
203  return cluster.coreShowerLength();
205  return cluster.firstLayer();
207  return cluster.maxLayer();
209  return cluster.sigmaEtaEtaTot();
211  return cluster.sigmaEtaEtaMax();
213  return cluster.sigmaPhiPhiTot();
215  return cluster.sigmaPhiPhiMax();
217  return cluster.sigmaZZ();
219  return cluster.sigmaRRTot();
221  return cluster.sigmaRRMax();
223  return cluster.sigmaRRMean();
224  default:
225  break;
226  }
227  return 0.;
228 }
float sigmaEtaEtaTot() const
int coreShowerLength() const
float sigmaPhiPhiTot() const
float sigmaPhiPhiMax() const
int firstLayer() const
float sigmaRRMax() const
int showerLength() const
int maxLayer() const
float sigmaRRTot() const
float sigmaRRMean() const
float sigmaZZ() const
float sigmaEtaEtaMax() const

◆ decision()

bool HGCalTriggerClusterIdentificationBDT::decision ( const l1t::HGCalMulticluster cluster,
unsigned  wp = 0 
) const
finalvirtual

Implements HGCalTriggerClusterIdentificationBase.

Definition at line 181 of file HGCalTriggerClusterIdentificationBDT.cc.

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

181  {
182  float bdt_output = value(cluster);
183  float pt = cluster.pt();
184  float eta = cluster.eta();
185  int cat = category(pt, eta);
186  return (cat != -1 ? bdt_output > working_points_.at(cat).at(wp).working_point() : true);
187 }
double pt() const final
transverse momentum
def cat(path)
Definition: eostools.py:401
std::vector< std::vector< WorkingPoint > > working_points_
float value(const l1t::HGCalMulticluster &cluster) const final
double eta() const final
momentum pseudorapidity

◆ initialize()

void HGCalTriggerClusterIdentificationBDT::initialize ( const edm::ParameterSet conf)
finalvirtual

Implements HGCalTriggerClusterIdentificationBase.

Definition at line 88 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, geometryDiff::file, contentValuesFiles::fullPath, edm::ParameterSet::getParameter(), input_variables_, input_variables_id_, candidateCombinedMVAV2Computer_cfi::spectators, AlCaHLTBitMon_QueryRunRegistry::string, taus_updatedMVAIds_cff::variable, working_points_, and working_points_names_.

88  {
89  if (!bdts_.empty()) {
90  edm::LogWarning("HGCalTriggerClusterIdentificationBDT|Initialization") << "BDTs already initialized.";
91  return;
92  }
93  input_variables_ = conf.getParameter<std::vector<std::string>>("Inputs");
94  std::vector<std::string> bdt_files = conf.getParameter<std::vector<std::string>>("Weights");
95  std::vector<double> categories_etamin = conf.getParameter<std::vector<double>>("CategoriesEtaMin");
96  std::vector<double> categories_etamax = conf.getParameter<std::vector<double>>("CategoriesEtaMax");
97  std::vector<double> categories_ptmin = conf.getParameter<std::vector<double>>("CategoriesPtMin");
98  std::vector<double> categories_ptmax = conf.getParameter<std::vector<double>>("CategoriesPtMax");
99 
100  if (bdt_files.size() != categories_etamin.size() || categories_etamin.size() != categories_etamax.size() ||
101  categories_etamax.size() != categories_ptmin.size() || categories_ptmin.size() != categories_ptmax.size()) {
102  throw cms::Exception("HGCalTriggerClusterIdentificationBDT|BadInitialization")
103  << "Inconsistent numbers of categories, BDT weight files and working points";
104  }
105  size_t categories_size = categories_etamin.size();
106 
107  const auto wps_conf = conf.getParameter<std::vector<edm::ParameterSet>>("WorkingPoints");
108  working_points_.resize(categories_size);
109  for (const auto& wp_conf : wps_conf) {
110  std::string wp_name = wp_conf.getParameter<std::string>("Name");
111  std::vector<double> wps = wp_conf.getParameter<std::vector<double>>("WorkingPoint");
112  working_points_names_.emplace_back(wp_name);
113  if (wps.size() != categories_size) {
114  throw cms::Exception("HGCalTriggerClusterIdentificationBDT|BadInitialization")
115  << "Inconsistent number of categories in working point '" << wp_name << "'";
116  }
117  for (size_t cat = 0; cat < categories_size; cat++) {
118  working_points_[cat].emplace_back(wp_name, wps[cat]);
119  }
120  }
121 
122  categories_.reserve(categories_size);
123  bdts_.reserve(categories_size);
124  for (size_t cat = 0; cat < categories_size; cat++) {
125  categories_.emplace_back(
126  categories_ptmin[cat], categories_ptmax[cat], categories_etamin[cat], categories_etamax[cat]);
127  }
128  std::vector<std::string> spectators = {};
129  for (const auto& file : bdt_files) {
130  bdts_.emplace_back(new TMVAEvaluator());
131  bdts_.back()->initialize("!Color:Silent:!Error",
132  "BDT::bdt",
135  spectators,
136  false,
137  false);
138  }
139 
140  // Transform input variable strings to enum values for later comparisons
141  input_variables_id_.reserve(input_variables_.size());
142  for (const auto& variable : input_variables_) {
143  if (variable == "cl3d_showerlength")
145  else if (variable == "cl3d_coreshowerlength")
147  else if (variable == "cl3d_firstlayer")
149  else if (variable == "cl3d_maxlayer")
151  else if (variable == "cl3d_seetot")
153  else if (variable == "cl3d_seemax")
155  else if (variable == "cl3d_spptot")
157  else if (variable == "cl3d_sppmax")
159  else if (variable == "cl3d_szz")
161  else if (variable == "cl3d_srrtot")
163  else if (variable == "cl3d_srrmax")
165  else if (variable == "cl3d_srrmean")
167  }
168 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
def cat(path)
Definition: eostools.py:401
std::vector< std::vector< WorkingPoint > > working_points_
std::vector< std::unique_ptr< TMVAEvaluator > > bdts_
Log< level::Warning, false > LogWarning

◆ value()

float HGCalTriggerClusterIdentificationBDT::value ( const l1t::HGCalMulticluster cluster) const
finalvirtual

Implements HGCalTriggerClusterIdentificationBase.

Definition at line 170 of file HGCalTriggerClusterIdentificationBDT.cc.

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

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

170  {
171  std::map<std::string, float> inputs;
172  for (unsigned i = 0; i < input_variables_.size(); i++) {
174  }
175  float pt = cluster.pt();
176  float eta = cluster.eta();
177  int cat = category(pt, eta);
178  return (cat != -1 ? bdts_.at(cat)->evaluate(inputs) : -999.);
179 }
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_
double eta() const final
momentum pseudorapidity

◆ working_points()

const std::vector<std::string>& HGCalTriggerClusterIdentificationBDT::working_points ( ) const
inlinefinalvirtual

Member Data Documentation

◆ bdts_

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

Definition at line 73 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by initialize(), and value().

◆ categories_

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

Definition at line 72 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by category(), and initialize().

◆ input_variables_

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

Definition at line 75 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by initialize(), and value().

◆ input_variables_id_

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

Definition at line 76 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by initialize(), and value().

◆ working_points_

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

Definition at line 74 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by decision(), and initialize().

◆ working_points_names_

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

Definition at line 77 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by initialize(), and working_points().