test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CandidateBoostedDoubleSecondaryVertexComputer.cc
Go to the documentation of this file.
2 
5 
10 
11 
13  useCondDB_(parameters.getParameter<bool>("useCondDB")),
14  gbrForestLabel_(parameters.existsAs<std::string>("gbrForestLabel") ? parameters.getParameter<std::string>("gbrForestLabel") : ""),
15  weightFile_(parameters.existsAs<edm::FileInPath>("weightFile") ? parameters.getParameter<edm::FileInPath>("weightFile") : edm::FileInPath()),
16  useGBRForest_(parameters.existsAs<bool>("useGBRForest") ? parameters.getParameter<bool>("useGBRForest") : false),
17  useAdaBoost_(parameters.existsAs<bool>("useAdaBoost") ? parameters.getParameter<bool>("useAdaBoost") : false)
18 {
19  uses(0, "svTagInfos");
20 
21  mvaID.reset(new TMVAEvaluator());
22 }
23 
25 {
26  // variable names and order need to be the same as in the training
27  std::vector<std::string> variables({"z_ratio",
28  "trackSipdSig_3","trackSipdSig_2","trackSipdSig_1","trackSipdSig_0",
29  "trackSipdSig_1_0","trackSipdSig_0_0","trackSipdSig_1_1","trackSipdSig_0_1",
30  "trackSip2dSigAboveCharm_0","trackSip2dSigAboveBottom_0","trackSip2dSigAboveBottom_1",
31  "tau0_trackEtaRel_0","tau0_trackEtaRel_1","tau0_trackEtaRel_2",
32  "tau1_trackEtaRel_0","tau1_trackEtaRel_1","tau1_trackEtaRel_2",
33  "tau_vertexMass_0","tau_vertexEnergyRatio_0","tau_vertexDeltaR_0","tau_flightDistance2dSig_0",
34  "tau_vertexMass_1","tau_vertexEnergyRatio_1","tau_flightDistance2dSig_1",
35  "jetNTracks","nSV"});
36  // book TMVA readers
37  std::vector<std::string> spectators({"massPruned", "flavour", "nbHadrons", "ptPruned", "etaPruned"});
38 
39  if (useCondDB_)
40  {
41  const GBRWrapperRcd & gbrWrapperRecord = record.getRecord<GBRWrapperRcd>();
42 
43  edm::ESHandle<GBRForest> gbrForestHandle;
44  gbrWrapperRecord.get(gbrForestLabel_.c_str(), gbrForestHandle);
45 
46  mvaID->initializeGBRForest(gbrForestHandle.product(), variables, spectators, useAdaBoost_);
47  }
48  else
49  mvaID->initialize("Color:Silent:Error", "BDT", weightFile_.fullPath(), variables, spectators, useGBRForest_, useAdaBoost_);
50 }
51 
53 {
54  // get the TagInfo
55  const reco::BoostedDoubleSVTagInfo & bdsvTagInfo = tagInfo.get<reco::BoostedDoubleSVTagInfo>(0);
56 
57  // get the TaggingVariables
58  const reco::TaggingVariableList vars = bdsvTagInfo.taggingVariables();
59 
60  // default discriminator value
61  float value = -10.;
62 
63  std::map<std::string,float> inputs;
64  inputs["z_ratio"] = vars.get(reco::btau::z_ratio);
65  inputs["trackSipdSig_3"] = vars.get(reco::btau::trackSip3dSig_3);
66  inputs["trackSipdSig_2"] = vars.get(reco::btau::trackSip3dSig_2);
67  inputs["trackSipdSig_1"] = vars.get(reco::btau::trackSip3dSig_1);
68  inputs["trackSipdSig_0"] = vars.get(reco::btau::trackSip3dSig_0);
69  inputs["trackSipdSig_1_0"] = vars.get(reco::btau::tau2_trackSip3dSig_0);
70  inputs["trackSipdSig_0_0"] = vars.get(reco::btau::tau1_trackSip3dSig_0);
71  inputs["trackSipdSig_1_1"] = vars.get(reco::btau::tau2_trackSip3dSig_1);
72  inputs["trackSipdSig_0_1"] = vars.get(reco::btau::tau1_trackSip3dSig_1);
73  inputs["trackSip2dSigAboveCharm_0"] = vars.get(reco::btau::trackSip2dSigAboveCharm);
74  inputs["trackSip2dSigAboveBottom_0"] = vars.get(reco::btau::trackSip2dSigAboveBottom_0);
75  inputs["trackSip2dSigAboveBottom_1"] = vars.get(reco::btau::trackSip2dSigAboveBottom_1);
76  inputs["tau1_trackEtaRel_0"] = vars.get(reco::btau::tau2_trackEtaRel_0);
77  inputs["tau1_trackEtaRel_1"] = vars.get(reco::btau::tau2_trackEtaRel_1);
78  inputs["tau1_trackEtaRel_2"] = vars.get(reco::btau::tau2_trackEtaRel_2);
79  inputs["tau0_trackEtaRel_0"] = vars.get(reco::btau::tau1_trackEtaRel_0);
80  inputs["tau0_trackEtaRel_1"] = vars.get(reco::btau::tau1_trackEtaRel_1);
81  inputs["tau0_trackEtaRel_2"] = vars.get(reco::btau::tau1_trackEtaRel_2);
82  inputs["tau_vertexMass_0"] = vars.get(reco::btau::tau1_vertexMass);
83  inputs["tau_vertexEnergyRatio_0"] = vars.get(reco::btau::tau1_vertexEnergyRatio);
84  inputs["tau_vertexDeltaR_0"] = vars.get(reco::btau::tau1_vertexDeltaR);
85  inputs["tau_flightDistance2dSig_0"] = vars.get(reco::btau::tau1_flightDistance2dSig);
86  inputs["tau_vertexMass_1"] = vars.get(reco::btau::tau2_vertexMass);
87  inputs["tau_vertexEnergyRatio_1"] = vars.get(reco::btau::tau2_vertexEnergyRatio);
88  inputs["tau_flightDistance2dSig_1"] = vars.get(reco::btau::tau2_flightDistance2dSig);
89  inputs["jetNTracks"] = vars.get(reco::btau::jetNTracks);
90  inputs["nSV"] = vars.get(reco::btau::jetNSecondaryVertices);
91 
92  // evaluate the MVA
93  value = mvaID->evaluate(inputs);
94 
95  // return the final discriminator value
96  return value;
97 }
const T & get(unsigned int index=0) const
JetCorrectorParameters::Record record
Definition: classes.h:7
void get(HolderT &iHolder) const
void uses(unsigned int id, const std::string &label)
float discriminator(const TagInfoHelper &tagInfos) const override
volatile std::atomic< bool > shutdown_flag false
std::string fullPath() const
Definition: FileInPath.cc:184
virtual TaggingVariableList taggingVariables(void) const
returns a description of the extended informations in a TaggingVariableList