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

53  {
54  cl3d_showerlength,
55  cl3d_coreshowerlength,
56  cl3d_firstlayer,
57  cl3d_maxlayer,
58  cl3d_seetot,
59  cl3d_seemax,
60  cl3d_spptot,
61  cl3d_sppmax,
62  cl3d_szz,
63  cl3d_srrtot,
64  cl3d_srrmax,
65  cl3d_srrmean
66  };

Constructor & Destructor Documentation

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

Definition at line 46 of file HGCalTriggerClusterIdentificationBDT.cc.

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

46 {};

Member Function Documentation

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

Definition at line 186 of file HGCalTriggerClusterIdentificationBDT.cc.

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

Referenced by decision(), and value().

187 {
188  for(unsigned cat=0; cat<categories_.size(); cat++)
189  {
190  if(categories_[cat].contains(pt, eta)) return static_cast<int>(cat);
191  }
192  return -1;
193 }
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 200 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 category(), and value().

201 {
202  switch(variable)
203  {
204  case ClusterVariable::cl3d_showerlength: return cluster.showerLength();
206  case ClusterVariable::cl3d_firstlayer: return cluster.firstLayer();
207  case ClusterVariable::cl3d_maxlayer: return cluster.maxLayer();
208  case ClusterVariable::cl3d_seetot: return cluster.sigmaEtaEtaTot();
209  case ClusterVariable::cl3d_seemax: return cluster.sigmaEtaEtaMax();
210  case ClusterVariable::cl3d_spptot: return cluster.sigmaPhiPhiTot();
211  case ClusterVariable::cl3d_sppmax: return cluster.sigmaPhiPhiMax();
212  case ClusterVariable::cl3d_szz: return cluster.sigmaZZ();
213  case ClusterVariable::cl3d_srrtot: return cluster.sigmaRRTot();
214  case ClusterVariable::cl3d_srrmax: return cluster.sigmaRRMax();
215  case ClusterVariable::cl3d_srrmean: return cluster.sigmaRRMean();
216  default: break;
217  }
218  return 0.;
219 }
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 175 of file HGCalTriggerClusterIdentificationBDT.cc.

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

Referenced by value(), and ~HGCalTriggerClusterIdentificationBDT().

176 {
177  float bdt_output = value(cluster);
178  float pt = cluster.pt();
179  float eta = cluster.eta();
180  int cat = category(pt, eta);
181  return (cat!=-1 ? bdt_output>working_points_.at(cat) : true);
182 }
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 89 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, value(), taus_updatedMVAIds_cff::variable, and working_points_.

Referenced by HGCalTriggerClusterIdentificationBDT(), and ~HGCalTriggerClusterIdentificationBDT().

90 {
91  if(!bdts_.empty())
92  {
93  edm::LogWarning("HGCalTriggerClusterIdentificationBDT|Initialization")
94  << "BDTs already initialized.";
95  return;
96  }
97  input_variables_ = conf.getParameter< std::vector<std::string> >("Inputs");
98  std::vector<std::string> bdt_files = conf.getParameter< std::vector<std::string> >("Weights");
99  std::vector<double> categories_etamin = conf.getParameter<std::vector<double>>("CategoriesEtaMin");
100  std::vector<double> categories_etamax = conf.getParameter<std::vector<double>>("CategoriesEtaMax");
101  std::vector<double> categories_ptmin = conf.getParameter<std::vector<double>>("CategoriesPtMin");
102  std::vector<double> categories_ptmax = conf.getParameter<std::vector<double>>("CategoriesPtMax");
103  working_points_ = conf.getParameter<std::vector<double>>("WorkingPoints");
104 
105  if(bdt_files.size()!=categories_etamin.size() ||
106  categories_etamin.size()!=categories_etamax.size() ||
107  categories_etamax.size()!=categories_ptmin.size() ||
108  categories_ptmin.size()!=categories_ptmax.size() ||
109  categories_ptmax.size()!=working_points_.size()
110  )
111  {
112  throw cms::Exception("HGCalTriggerClusterIdentificationBDT|BadInitialization")
113  << "Inconsistent numbers of categories, BDT weight files and working points";
114  }
115  categories_.reserve(working_points_.size());
116  bdts_.reserve(working_points_.size());
117  for(unsigned cat=0; cat<categories_etamin.size(); cat++)
118  {
119  categories_.emplace_back(
120  categories_ptmin[cat],
121  categories_ptmax[cat],
122  categories_etamin[cat],
123  categories_etamax[cat]);
124  }
125  std::vector<std::string> spectators = {};
126  for (const auto& file : bdt_files)
127  {
128  bdts_.emplace_back(new TMVAEvaluator());
129  bdts_.back()->initialize(
130  "!Color:Silent:!Error",
131  "BDT::bdt",
132  edm::FileInPath(file).fullPath(),
134  spectators,
135  false, false);
136  }
137 
138  // Transform input variable strings to enum values for later comparisons
139  input_variables_id_.reserve(input_variables_.size());
140  for(const auto& variable : input_variables_)
141  {
142  if(variable=="cl3d_showerlength") input_variables_id_.push_back(ClusterVariable::cl3d_showerlength);
143  else if(variable=="cl3d_coreshowerlength") input_variables_id_.push_back(ClusterVariable::cl3d_coreshowerlength);
144  else if(variable=="cl3d_firstlayer") input_variables_id_.push_back(ClusterVariable::cl3d_firstlayer);
145  else if(variable=="cl3d_maxlayer") input_variables_id_.push_back(ClusterVariable::cl3d_maxlayer);
146  else if(variable=="cl3d_seetot") input_variables_id_.push_back(ClusterVariable::cl3d_seetot);
147  else if(variable=="cl3d_seemax") input_variables_id_.push_back(ClusterVariable::cl3d_seemax);
148  else if(variable=="cl3d_spptot") input_variables_id_.push_back(ClusterVariable::cl3d_spptot);
149  else if(variable=="cl3d_sppmax") input_variables_id_.push_back(ClusterVariable::cl3d_sppmax);
150  else if(variable=="cl3d_szz") input_variables_id_.push_back(ClusterVariable::cl3d_szz);
151  else if(variable=="cl3d_srrtot") input_variables_id_.push_back(ClusterVariable::cl3d_srrtot);
152  else if(variable=="cl3d_srrmax") input_variables_id_.push_back(ClusterVariable::cl3d_srrmax);
153  else if(variable=="cl3d_srrmean") input_variables_id_.push_back(ClusterVariable::cl3d_srrmean);
154  }
155 }
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 159 of file HGCalTriggerClusterIdentificationBDT.cc.

References bdts_, eostools::cat(), category(), clusterVariable(), decision(), 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(), initialize(), and ~HGCalTriggerClusterIdentificationBDT().

160 {
161  std::map<std::string, float> inputs;
162  for(unsigned i=0; i<input_variables_.size(); i++)
163  {
165  }
166  float pt = cluster.pt();
167  float eta = cluster.eta();
168  int cat = category(pt, eta);
169  return (cat!=-1 ? bdts_.at(cat)->evaluate(inputs) : -999.);
170 }
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 68 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by initialize(), and value().

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

Definition at line 67 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by category(), and initialize().

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

Definition at line 70 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by initialize(), and value().

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

Definition at line 71 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by initialize(), and value().

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

Definition at line 69 of file HGCalTriggerClusterIdentificationBDT.cc.

Referenced by decision(), and initialize().