Skip to content

Commit

Permalink
Include minL1Qual in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjun committed Jun 22, 2021
1 parent bdcf4ae commit a659f04
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
7 changes: 4 additions & 3 deletions RecoMuon/TrackerSeedGenerator/interface/SeedMvaEstimator.h
Expand Up @@ -25,22 +25,23 @@ class SeedMvaEstimator {
SeedMvaEstimator(const edm::FileInPath& weightsfile,
const std::vector<double>& scale_mean,
const std::vector<double>& scale_std,
const bool isFromL1);
const bool isFromL1,
const int minL1Qual);
~SeedMvaEstimator();

double computeMva(const TrajectorySeed&,
const GlobalVector&,
const l1t::MuonBxCollection&,
int minL1Qual,
const reco::RecoChargedCandidateCollection&) const;

private:
std::unique_ptr<const GBRForest> gbrForest_;
const std::vector<double> scale_mean_;
const std::vector<double> scale_std_;
const bool isFromL1_;
const int minL1Qual_;

void getL1MuonVariables(const GlobalVector&, const l1t::MuonBxCollection&, int minL1Qual, float&, float&) const;
void getL1MuonVariables(const GlobalVector&, const l1t::MuonBxCollection&, float&, float&) const;
void getL2MuonVariables(const GlobalVector&, const reco::RecoChargedCandidateCollection&, float&, float&) const;
};
#endif
Expand Up @@ -115,9 +115,9 @@ MuonHLTSeedMVAClassifier::MuonHLTSeedMVAClassifier(const edm::ParameterSet& iCon
minL1Qual_(iConfig.getParameter<int>("minL1Qual")),
baseScore_(iConfig.getParameter<double>("baseScore")) {
if (!rejectAll_) {
mvaEstimator_ =
std::make_pair(std::make_unique<SeedMvaEstimator>(mvaFileB_, mvaScaleMeanB_, mvaScaleStdB_, isFromL1_),
std::make_unique<SeedMvaEstimator>(mvaFileE_, mvaScaleMeanE_, mvaScaleStdE_, isFromL1_));
mvaEstimator_ = std::make_pair(
std::make_unique<SeedMvaEstimator>(mvaFileB_, mvaScaleMeanB_, mvaScaleStdB_, isFromL1_, minL1Qual_),
std::make_unique<SeedMvaEstimator>(mvaFileE_, mvaScaleMeanE_, mvaScaleStdE_, isFromL1_, minL1Qual_));
}

produces<TrajectorySeedCollection>();
Expand Down Expand Up @@ -229,9 +229,9 @@ double MuonHLTSeedMVAClassifier::getSeedMva(const PairSeedMvaEstimator& pairMvaE
const reco::RecoChargedCandidateCollection& l2Muons) {
double mva = 0.;
if (std::abs(global_p.eta()) < etaEdge_) {
mva = pairMvaEstimator.first->computeMva(seed, global_p, l1Muons, minL1Qual_, l2Muons);
mva = pairMvaEstimator.first->computeMva(seed, global_p, l1Muons, l2Muons);
} else {
mva = pairMvaEstimator.second->computeMva(seed, global_p, l1Muons, minL1Qual_, l2Muons);
mva = pairMvaEstimator.second->computeMva(seed, global_p, l1Muons, l2Muons);
}

return (mva + baseScore_);
Expand Down
11 changes: 5 additions & 6 deletions RecoMuon/TrackerSeedGenerator/src/SeedMvaEstimator.cc
Expand Up @@ -9,8 +9,9 @@
SeedMvaEstimator::SeedMvaEstimator(const edm::FileInPath& weightsfile,
const std::vector<double>& scale_mean,
const std::vector<double>& scale_std,
const bool isFromL1)
: scale_mean_(scale_mean), scale_std_(scale_std), isFromL1_(isFromL1) {
const bool isFromL1,
const int minL1Qual)
: scale_mean_(scale_mean), scale_std_(scale_std), isFromL1_(isFromL1), minL1Qual_(minL1Qual) {
gbrForest_ = createGBRForest(weightsfile);
}

Expand All @@ -36,15 +37,14 @@ namespace {

void SeedMvaEstimator::getL1MuonVariables(const GlobalVector& global_p,
const l1t::MuonBxCollection& l1Muons,
int minL1Qual,
float& dR2dRL1SeedP,
float& dPhidRL1SeedP) const {
for (int ibx = l1Muons.getFirstBX(); ibx <= l1Muons.getLastBX(); ++ibx) {
if (ibx != 0)
continue; // -- only take when ibx == 0 -- //

for (auto it = l1Muons.begin(ibx); it != l1Muons.end(ibx); it++) {
if (it->hwQual() < minL1Qual)
if (it->hwQual() < minL1Qual_)
continue;

float dR2tmp = reco::deltaR2(it->etaAtVtx(), it->phiAtVtx(), global_p.eta(), global_p.phi());
Expand Down Expand Up @@ -72,7 +72,6 @@ void SeedMvaEstimator::getL2MuonVariables(const GlobalVector& global_p,
double SeedMvaEstimator::computeMva(const TrajectorySeed& seed,
const GlobalVector& global_p,
const l1t::MuonBxCollection& l1Muons,
int minL1Qual,
const reco::RecoChargedCandidateCollection& l2Muons) const {
static constexpr float initDRdPhi(99999.);
auto kLast = isFromL1_ ? kLastL1 : kLastL2;
Expand All @@ -87,7 +86,7 @@ double SeedMvaEstimator::computeMva(const TrajectorySeed& seed,

float dR2dRL1SeedP = initDRdPhi;
float dPhidRL1SeedP = initDRdPhi;
getL1MuonVariables(global_p, l1Muons, minL1Qual, dR2dRL1SeedP, dPhidRL1SeedP);
getL1MuonVariables(global_p, l1Muons, dR2dRL1SeedP, dPhidRL1SeedP);

var[kDRdRL1SeedP] = std::sqrt(dR2dRL1SeedP);
var[kDPhidRL1SeedP] = dPhidRL1SeedP;
Expand Down

0 comments on commit a659f04

Please sign in to comment.