CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Attributes
CharmTagger Class Reference

#include <CharmTagger.h>

Inheritance diagram for CharmTagger:
JetTagComputer

Classes

struct  MVAVar
 

Public Types

typedef std::vector
< edm::ParameterSet
vpset
 

Public Member Functions

 CharmTagger (const edm::ParameterSet &)
 explicit ctor More...
 
virtual float discriminator (const TagInfoHelper &tagInfo) const override
 b-tag a jet based on track-to-jet parameters in the extened info collection More...
 
virtual void initialize (const JetTagComputerRecord &record) override
 
 ~CharmTagger ()
 
- Public Member Functions inherited from JetTagComputer
const std::vector< std::string > & getInputLabels () const
 
 JetTagComputer ()
 
 JetTagComputer (const edm::ParameterSet &configuration)
 
float operator() (const reco::BaseTagInfo &info) const
 
float operator() (const TagInfoHelper &helper) const
 
void setupDone ()
 
virtual ~JetTagComputer ()
 

Private Attributes

std::string gbrForest_label_
 
std::string mva_name_
 
std::unique_ptr< TMVAEvaluatormvaID_
 
CombinedSVSoftLeptonComputer sl_computer_
 
bool use_adaBoost_
 
bool use_condDB_
 
bool use_GBRForest_
 
std::vector< MVAVarvariables_
 
edm::FileInPath weight_file_
 

Additional Inherited Members

- Protected Member Functions inherited from JetTagComputer
virtual float discriminator (const reco::BaseTagInfo &) const
 
void uses (unsigned int id, const std::string &label)
 
void uses (const std::string &label)
 

Detailed Description

Author
M. Verzetti, U. Rochester, N.Y. copied from ElectronTagger.h

Definition at line 20 of file CharmTagger.h.

Member Typedef Documentation

typedef std::vector<edm::ParameterSet> CharmTagger::vpset

Definition at line 28 of file CharmTagger.h.

Constructor & Destructor Documentation

CharmTagger::CharmTagger ( const edm::ParameterSet configuration)

explicit ctor

Definition at line 15 of file CharmTagger.cc.

References CharmTagger::MVAVar::default_value, edm::ParameterSet::getParameter(), reco::getTaggingVariableName(), CharmTagger::MVAVar::has_index, CharmTagger::MVAVar::id, CharmTagger::MVAVar::index, CharmTagger::MVAVar::name, AlCaHLTBitMon_QueryRunRegistry::string, JetTagComputer::uses(), MetTreeProducer::var(), and variables_.

15  :
16  sl_computer_(configuration.getParameter<edm::ParameterSet>("slComputerCfg")),
17  mva_name_( configuration.getParameter<std::string >("mvaName") ),
18  use_condDB_(configuration.getParameter<bool>("useCondDB")),
19  gbrForest_label_(configuration.getParameter<std::string>("gbrForestLabel")),
20  weight_file_(configuration.getParameter<edm::FileInPath>("weightFile")),
21  use_GBRForest_(configuration.getParameter<bool>("useGBRForest")),
22  use_adaBoost_(configuration.getParameter<bool>("useAdaBoost"))
23 {
24  vpset vars_definition = configuration.getParameter<vpset>("variables");
25  for(auto &var : vars_definition) {
26  MVAVar mva_var;
27  mva_var.name = var.getParameter<std::string>("name");
28  mva_var.id = reco::getTaggingVariableName(
29  var.getParameter<std::string>("taggingVarName")
30  );
31  mva_var.has_index = var.existsAs<int>("idx") ;
32  mva_var.index = mva_var.has_index ? var.getParameter<int>("idx") : 0;
33  mva_var.default_value = var.getParameter<double>("default");
34 
35  variables_.push_back(mva_var);
36  }
37 
38  uses(0, "pfImpactParameterTagInfos");
39  uses(1, "pfInclusiveSecondaryVertexFinderCvsLTagInfos");
40  uses(2, "softPFMuonsTagInfos");
41  uses(3, "softPFElectronsTagInfos");
42 }
T getParameter(std::string const &) const
edm::FileInPath weight_file_
Definition: CharmTagger.h:46
std::vector< MVAVar > variables_
Definition: CharmTagger.h:41
CombinedSVSoftLeptonComputer sl_computer_
Definition: CharmTagger.h:40
void uses(unsigned int id, const std::string &label)
std::string gbrForest_label_
Definition: CharmTagger.h:45
std::string mva_name_
Definition: CharmTagger.h:43
bool use_condDB_
Definition: CharmTagger.h:44
TaggingVariableName getTaggingVariableName(const std::string &name)
std::vector< edm::ParameterSet > vpset
Definition: CharmTagger.h:28
bool use_GBRForest_
Definition: CharmTagger.h:47
bool use_adaBoost_
Definition: CharmTagger.h:48
CharmTagger::~CharmTagger ( )

Definition at line 76 of file CharmTagger.cc.

77 {
78 }

Member Function Documentation

float CharmTagger::discriminator ( const TagInfoHelper tagInfo) const
overridevirtual

b-tag a jet based on track-to-jet parameters in the extened info collection

Reimplemented from JetTagComputer.

Definition at line 81 of file CharmTagger.cc.

References JetTagComputer::TagInfoHelper::get(), SiPixelRawToDigiRegional_cfi::inputs, mvaID_, sl_computer_, GlobalPosition_Frontier_DevDB_cff::tag, create_public_pileup_plots::vals, and variables_.

81  {
82  // default value, used if there are no leptons associated to this jet
83  const reco::CandIPTagInfo & ip_info = tagInfo.get<reco::CandIPTagInfo>(0);
87  reco::TaggingVariableList vars = sl_computer_(ip_info, sv_info, softmu_info, softel_info);
88 
89  // Loop over input variables
90  std::map<std::string, float> inputs;
91  for(auto &mva_var : variables_){
92  //vectorial tagging variable
93  if(mva_var.has_index){
94  std::vector<float> vals = vars.getList(mva_var.id, false);
95  inputs[mva_var.name] = (vals.size() > mva_var.index) ? vals[mva_var.index] : mva_var.default_value;
96  }
97  //single value tagging var
98  else {
99  inputs[mva_var.name] = vars.get(mva_var.id, mva_var.default_value);
100  }
101  }
102 
103  //get the MVA output
104  float tag = mvaID_->evaluate(inputs);
105  return tag;
106 }
std::vector< MVAVar > variables_
Definition: CharmTagger.h:41
CombinedSVSoftLeptonComputer sl_computer_
Definition: CharmTagger.h:40
std::unique_ptr< TMVAEvaluator > mvaID_
Definition: CharmTagger.h:39
void CharmTagger::initialize ( const JetTagComputerRecord record)
overridevirtual

Reimplemented from JetTagComputer.

Definition at line 44 of file CharmTagger.cc.

References edm::FileInPath::fullPath(), gbrForest_label_, edm::eventsetup::EventSetupRecord::get(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), mva_name_, mvaID_, use_adaBoost_, use_condDB_, use_GBRForest_, MetTreeProducer::var(), variables_, and weight_file_.

45 {
46  mvaID_.reset(new TMVAEvaluator());
47 
48  std::vector<std::string> variable_names;
49  variable_names.reserve(variables_.size());
50 
51  for(auto &var : variables_) {
52  variable_names.push_back(var.name);
53  }
54  std::vector<std::string> spectators;
55 
56  if(use_condDB_) {
57  const GBRWrapperRcd & gbrWrapperRecord = record.getRecord<GBRWrapperRcd>();
58 
59  edm::ESHandle<GBRForest> gbrForestHandle;
60  gbrWrapperRecord.get(gbrForest_label_.c_str(), gbrForestHandle);
61 
62  mvaID_->initializeGBRForest(
63  gbrForestHandle.product(), variable_names,
64  spectators, use_adaBoost_
65  );
66  }
67  else {
68  mvaID_->initialize(
69  "Color:Silent:Error", mva_name_.c_str(),
70  weight_file_.fullPath(), variable_names,
71  spectators, use_GBRForest_, use_adaBoost_
72  );
73  }
74 }
edm::FileInPath weight_file_
Definition: CharmTagger.h:46
std::vector< MVAVar > variables_
Definition: CharmTagger.h:41
void get(HolderT &iHolder) const
std::string gbrForest_label_
Definition: CharmTagger.h:45
std::string mva_name_
Definition: CharmTagger.h:43
bool use_condDB_
Definition: CharmTagger.h:44
std::unique_ptr< TMVAEvaluator > mvaID_
Definition: CharmTagger.h:39
bool use_GBRForest_
Definition: CharmTagger.h:47
std::string fullPath() const
Definition: FileInPath.cc:165
bool use_adaBoost_
Definition: CharmTagger.h:48

Member Data Documentation

std::string CharmTagger::gbrForest_label_
private

Definition at line 45 of file CharmTagger.h.

Referenced by initialize().

std::string CharmTagger::mva_name_
private

Definition at line 43 of file CharmTagger.h.

Referenced by initialize().

std::unique_ptr<TMVAEvaluator> CharmTagger::mvaID_
private

Definition at line 39 of file CharmTagger.h.

Referenced by discriminator(), and initialize().

CombinedSVSoftLeptonComputer CharmTagger::sl_computer_
private

Definition at line 40 of file CharmTagger.h.

Referenced by discriminator().

bool CharmTagger::use_adaBoost_
private

Definition at line 48 of file CharmTagger.h.

Referenced by initialize().

bool CharmTagger::use_condDB_
private

Definition at line 44 of file CharmTagger.h.

Referenced by initialize().

bool CharmTagger::use_GBRForest_
private

Definition at line 47 of file CharmTagger.h.

Referenced by initialize().

std::vector<MVAVar> CharmTagger::variables_
private

Definition at line 41 of file CharmTagger.h.

Referenced by CharmTagger(), discriminator(), and initialize().

edm::FileInPath CharmTagger::weight_file_
private

Definition at line 46 of file CharmTagger.h.

Referenced by initialize().