CMS 3D CMS Logo

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

#include <ElectronTagger.h>

Inheritance diagram for ElectronTagger:
JetTagComputer

Public Member Functions

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

const std::string m_gbrForestLabel
 
const btag::LeptonSelector m_selector
 
const bool m_useAdaBoost
 
const bool m_useCondDB
 
const bool m_useGBRForest
 
const edm::FileInPath m_weightFile
 
std::unique_ptr< TMVAEvaluatormvaID
 

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
P. Demin - UCL, Louvain-la-Neuve - Belgium

Definition at line 16 of file ElectronTagger.h.

Constructor & Destructor Documentation

ElectronTagger::ElectronTagger ( const edm::ParameterSet cfg)

explicit ctor

Definition at line 14 of file ElectronTagger.cc.

References mvaID, and JetTagComputer::uses().

14  :
15  m_selector(cfg),
16  m_useCondDB(cfg.getParameter<bool>("useCondDB")),
17  m_gbrForestLabel(cfg.existsAs<std::string>("gbrForestLabel") ? cfg.getParameter<std::string>("gbrForestLabel") : ""),
18  m_weightFile(cfg.existsAs<edm::FileInPath>("weightFile") ? cfg.getParameter<edm::FileInPath>("weightFile") : edm::FileInPath()),
19  m_useGBRForest(cfg.existsAs<bool>("useGBRForest") ? cfg.getParameter<bool>("useGBRForest") : false),
20  m_useAdaBoost(cfg.existsAs<bool>("useAdaBoost") ? cfg.getParameter<bool>("useAdaBoost") : false)
21  {
22  uses("seTagInfos");
23  mvaID.reset(new TMVAEvaluator());
24  }
T getParameter(std::string const &) const
const bool m_useAdaBoost
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
const bool m_useCondDB
const btag::LeptonSelector m_selector
const bool m_useGBRForest
const edm::FileInPath m_weightFile
void uses(unsigned int id, const std::string &label)
std::unique_ptr< TMVAEvaluator > mvaID
const std::string m_gbrForestLabel

Member Function Documentation

float ElectronTagger::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 46 of file ElectronTagger.cc.

References funct::abs(), reco::SoftLeptonProperties::deltaR, reco::SoftLeptonProperties::elec_mva, f, JetTagComputer::TagInfoHelper::get(), i, infinity, info(), SiPixelRawToDigiRegional_cfi::inputs, btag::LeptonSelector::isNegative(), reco::TemplatedSoftLeptonTagInfo< REF >::leptons(), m_selector, mvaID, reco::TemplatedSoftLeptonTagInfo< REF >::properties(), reco::SoftLeptonProperties::ptRel, random, reco::SoftLeptonProperties::ratio, reco::SoftLeptonProperties::sip2dsig, reco::SoftLeptonProperties::sip3dsig, and GlobalPosition_Frontier_DevDB_cff::tag.

46  {
47  // default value, used if there are no leptons associated to this jet
48  float bestTag = - std::numeric_limits<float>::infinity();
50 
51  std::mt19937_64 random;
52  std::uniform_real_distribution<float> dist(0.f,1.f);
53 
54  // if there are multiple leptons, look for the highest tag result
55  for (unsigned int i = 0; i < info.leptons(); i++) {
56  const reco::SoftLeptonProperties & properties = info.properties(i);
57  if (m_selector(properties)) {
58  int theSeed=1+round(10000.0*std::abs(properties.deltaR));
59  random.seed(theSeed);
60  float rndm = dist(random);
61  //for negative tagger, flip 50% of the negative signs to positive value
62  float sip3dsig = (m_selector.isNegative() && rndm<0.5) ? -properties.sip3dsig : properties.sip3dsig;
63  float sip2dsig = (m_selector.isNegative() && rndm<0.5) ? -properties.sip2dsig : properties.sip2dsig;
64 
65  std::map<std::string,float> inputs;
66  inputs["sip3d"] = sip3dsig;
67  inputs["sip2d"] = sip2dsig;
68  inputs["ptRel"] = properties.ptRel;
69  inputs["deltaR"] = properties.deltaR;
70  inputs["ratio"] = properties.ratio;
71  inputs["mva_e_pi"] = properties.elec_mva;
72 
73  float tag = mvaID->evaluate(inputs);
74  // Transform output between 0 and 1
75  tag = (tag+1.0)/2.0;
76  if (tag > bestTag)
77  bestTag = tag;
78  }
79  }
80  return bestTag;
81 }
int i
Definition: DBlmapReader.cc:9
static const TGPicture * info(bool iBackgroundIsBlack)
TRandom random
Definition: MVATrainer.cc:138
const SoftLeptonProperties & properties(size_t i) const
const btag::LeptonSelector m_selector
const double infinity
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
std::unique_ptr< TMVAEvaluator > mvaID
bool isNegative() const
void ElectronTagger::initialize ( const JetTagComputerRecord record)
overridevirtual

Reimplemented from JetTagComputer.

Definition at line 26 of file ElectronTagger.cc.

References edm::FileInPath::fullPath(), edm::eventsetup::EventSetupRecord::get(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), m_gbrForestLabel, m_useAdaBoost, m_useCondDB, m_useGBRForest, m_weightFile, mvaID, and makeLayoutFileForGui::variables.

27 {
28  // variable names and order need to be the same as in the training
29  std::vector<std::string> variables({"sip3d", "sip2d", "ptRel", "deltaR", "ratio", "mva_e_pi"});
30  std::vector<std::string> spectators;
31 
32  if (m_useCondDB)
33  {
34  const GBRWrapperRcd & gbrWrapperRecord = record.getRecord<GBRWrapperRcd>();
35 
36  edm::ESHandle<GBRForest> gbrForestHandle;
37  gbrWrapperRecord.get(m_gbrForestLabel.c_str(), gbrForestHandle);
38 
39  mvaID->initializeGBRForest(gbrForestHandle.product(), variables, spectators, m_useAdaBoost);
40  }
41  else
42  mvaID->initialize("Color:Silent:Error", "BDT", m_weightFile.fullPath(), variables, spectators, m_useGBRForest, m_useAdaBoost);
43 }
const bool m_useAdaBoost
const bool m_useCondDB
const bool m_useGBRForest
const edm::FileInPath m_weightFile
void get(HolderT &iHolder) const
std::unique_ptr< TMVAEvaluator > mvaID
std::string fullPath() const
Definition: FileInPath.cc:165
const std::string m_gbrForestLabel

Member Data Documentation

const std::string ElectronTagger::m_gbrForestLabel
private

Definition at line 27 of file ElectronTagger.h.

Referenced by initialize().

const btag::LeptonSelector ElectronTagger::m_selector
private

Definition at line 25 of file ElectronTagger.h.

Referenced by discriminator().

const bool ElectronTagger::m_useAdaBoost
private

Definition at line 30 of file ElectronTagger.h.

Referenced by initialize().

const bool ElectronTagger::m_useCondDB
private

Definition at line 26 of file ElectronTagger.h.

Referenced by initialize().

const bool ElectronTagger::m_useGBRForest
private

Definition at line 29 of file ElectronTagger.h.

Referenced by initialize().

const edm::FileInPath ElectronTagger::m_weightFile
private

Definition at line 28 of file ElectronTagger.h.

Referenced by initialize().

std::unique_ptr<TMVAEvaluator> ElectronTagger::mvaID
private

Definition at line 32 of file ElectronTagger.h.

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