CMS 3D CMS Logo

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::ParameterSetvpset
 

Public Member Functions

 CharmTagger (const edm::ParameterSet &)
 explicit ctor More...
 
float discriminator (const TagInfoHelper &tagInfo) const override
 b-tag a jet based on track-to-jet parameters in the extened info collection More...
 
void initialize (const JetTagComputerRecord &record) override
 
 ~CharmTagger () override
 
- 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

bool defaultValueNoTracks_
 
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(), JetChargeProducer_cfi::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  defaultValueNoTracks_(configuration.getParameter<bool>("defaultValueNoTracks"))
24 {
25  vpset vars_definition = configuration.getParameter<vpset>("variables");
26  for(auto &var : vars_definition) {
27  MVAVar mva_var;
28  mva_var.name = var.getParameter<std::string>("name");
29  mva_var.id = reco::getTaggingVariableName(
30  var.getParameter<std::string>("taggingVarName")
31  );
32  mva_var.has_index = var.existsAs<int>("idx") ;
33  mva_var.index = mva_var.has_index ? var.getParameter<int>("idx") : 0;
34  mva_var.default_value = var.getParameter<double>("default");
35 
36  variables_.push_back(mva_var);
37  }
38 
39  uses(0, "pfImpactParameterTagInfos");
40  uses(1, "pfInclusiveSecondaryVertexFinderCvsLTagInfos");
41  uses(2, "softPFMuonsTagInfos");
42  uses(3, "softPFElectronsTagInfos");
43 }
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 defaultValueNoTracks_
Definition: CharmTagger.h:49
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 ( )
override

Definition at line 77 of file CharmTagger.cc.

78 {
79 }

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 82 of file CharmTagger.cc.

References defaultValueNoTracks_, JetTagComputer::TagInfoHelper::get(), haddnano::inputs, reco::btau::jetNTracks, mvaID_, sl_computer_, GlobalPosition_Frontier_DevDB_cff::tag, create_public_pileup_plots::vals, and variables_.

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

Reimplemented from JetTagComputer.

Definition at line 45 of file CharmTagger.cc.

References edm::FileInPath::fullPath(), gbrForest_label_, edm::eventsetup::EventSetupRecordImplementation< T >::get(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), mva_name_, mvaID_, candidateCombinedMVAV2Computer_cfi::spectators, use_adaBoost_, use_condDB_, use_GBRForest_, JetChargeProducer_cfi::var, variables_, and weight_file_.

46 {
47  mvaID_.reset(new TMVAEvaluator());
48 
49  std::vector<std::string> variable_names;
50  variable_names.reserve(variables_.size());
51 
52  for(auto &var : variables_) {
53  variable_names.push_back(var.name);
54  }
55  std::vector<std::string> spectators;
56 
57  if(use_condDB_) {
58  const GBRWrapperRcd & gbrWrapperRecord = record.getRecord<GBRWrapperRcd>();
59 
60  edm::ESHandle<GBRForest> gbrForestHandle;
61  gbrWrapperRecord.get(gbrForest_label_.c_str(), gbrForestHandle);
62 
63  mvaID_->initializeGBRForest(
64  gbrForestHandle.product(), variable_names,
66  );
67  }
68  else {
69  mvaID_->initialize(
70  "Color:Silent:Error", mva_name_,
71  weight_file_.fullPath(), variable_names,
73  );
74  }
75 }
edm::FileInPath weight_file_
Definition: CharmTagger.h:46
std::vector< MVAVar > variables_
Definition: CharmTagger.h:41
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) 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:163
bool use_adaBoost_
Definition: CharmTagger.h:48

Member Data Documentation

bool CharmTagger::defaultValueNoTracks_
private

Definition at line 49 of file CharmTagger.h.

Referenced by discriminator().

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().