Skip to content

Commit

Permalink
switching BoostedDoubleSV tagger to the TMVAEvaluator class
Browse files Browse the repository at this point in the history
  • Loading branch information
ferencek committed Jun 22, 2015
1 parent 052f933 commit 357f848
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#define RecoBTag_SecondaryVertex_CandidateBoostedDoubleSecondaryVertexComputer_h

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "CommonTools/Utils/interface/TMVAEvaluator.h"
#include "RecoBTau/JetTagComputer/interface/JetTagComputer.h"
#include "DataFormats/JetReco/interface/JetCollection.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h"
#include "RecoBTag/SecondaryVertex/interface/MvaBoostedDoubleSecondaryVertexEstimator.h"
#include "RecoBTag/SecondaryVertex/interface/TrackKinematics.h"

#include "fastjet/PseudoJet.hh"
Expand Down Expand Up @@ -38,7 +38,7 @@ class CandidateBoostedDoubleSecondaryVertexComputer : public JetTagComputer {

edm::FileInPath weightFile_;
mutable std::mutex m_mutex;
[[cms::thread_guard("m_mutex")]] std::unique_ptr<MvaBoostedDoubleSecondaryVertexEstimator> mvaID;
[[cms::thread_guard("m_mutex")]] std::unique_ptr<TMVAEvaluator> mvaID;
};

#endif // RecoBTag_SecondaryVertex_CandidateBoostedDoubleSecondaryVertexComputer_h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ CandidateBoostedDoubleSecondaryVertexComputer::CandidateBoostedDoubleSecondaryVe
uses(2, "muonTagInfos");
uses(3, "elecTagInfos");

mvaID.reset(new MvaBoostedDoubleSecondaryVertexEstimator(weightFile_.fullPath()));
mvaID.reset(new TMVAEvaluator());

// variable order needs to be the same as in the training
std::vector<std::string> variables({"PFLepton_ptrel", "z_ratio1", "tau_dot", "SV_mass_0", "SV_vtx_EnergyRatio_0",
"SV_vtx_EnergyRatio_1","PFLepton_IP2D", "tau2/tau1", "nSL", "jetNTracksEtaRel"});
std::vector<std::string> spectators({"massGroomed", "flavour", "nbHadrons", "ptGroomed", "etaGroomed"});

mvaID->initialize("Color:Silent:Error", "BDTG", weightFile_.fullPath(), variables, spectators);
}


Expand All @@ -35,7 +42,7 @@ float CandidateBoostedDoubleSecondaryVertexComputer::discriminator(const TagInfo
// default discriminator value
float value = -10.;

// MvaBoostedDoubleSecondaryVertexEstimator is not thread safe
// TMVAEvaluator is not thread safe
std::lock_guard<std::mutex> lock(m_mutex);

// default variable values
Expand Down Expand Up @@ -143,8 +150,20 @@ float CandidateBoostedDoubleSecondaryVertexComputer::discriminator(const TagInfo
}
}

std::map<std::string,float> inputs;
inputs["z_ratio1"] = z_ratio;
inputs["tau_dot"] = tau_dot;
inputs["SV_mass_0"] = SV_mass_0;
inputs["SV_vtx_EnergyRatio_0"] = SV_EnergyRatio_0;
inputs["SV_vtx_EnergyRatio_1"] = SV_EnergyRatio_1;
inputs["jetNTracksEtaRel"] = vertexNTracks;
inputs["PFLepton_ptrel"] = PFLepton_ptrel;
inputs["PFLepton_IP2D"] = PFLepton_IP2D;
inputs["nSL"] = nSL;
inputs["tau2/tau1"] = tau21;

// evaluate the MVA
value = mvaID->mvaValue(PFLepton_ptrel, z_ratio, tau_dot, SV_mass_0, SV_EnergyRatio_0, SV_EnergyRatio_1, PFLepton_IP2D, tau21, nSL, vertexNTracks);
value = mvaID->evaluate(inputs);

// return the final discriminator value
return value;
Expand Down

This file was deleted.

0 comments on commit 357f848

Please sign in to comment.