CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SeedMvaEstimator Class Reference

#include <SeedMvaEstimator.h>

Public Member Functions

double computeMva (const TrajectorySeed &, const GlobalVector &, const l1t::MuonBxCollection &, const reco::RecoChargedCandidateCollection &) const
 
 SeedMvaEstimator (const edm::FileInPath &weightsfile, const std::vector< double > &scale_mean, const std::vector< double > &scale_std, const bool isFromL1, const int minL1Qual)
 
 ~SeedMvaEstimator ()
 

Private Member Functions

void getL1MuonVariables (const GlobalVector &, const l1t::MuonBxCollection &, float &, float &) const
 
void getL2MuonVariables (const GlobalVector &, const reco::RecoChargedCandidateCollection &, float &, float &) const
 

Private Attributes

std::unique_ptr< const GBRForestgbrForest_
 
const bool isFromL1_
 
const int minL1Qual_
 
std::vector< float > scale_istd_
 
const std::vector< float > scale_mean_
 

Detailed Description

Definition at line 41 of file SeedMvaEstimator.h.

Constructor & Destructor Documentation

◆ SeedMvaEstimator()

SeedMvaEstimator::SeedMvaEstimator ( const edm::FileInPath weightsfile,
const std::vector< double > &  scale_mean,
const std::vector< double > &  scale_std,
const bool  isFromL1,
const int  minL1Qual 
)

Definition at line 9 of file SeedMvaEstimator.cc.

References createGBRForest(), gbrForest_, scale_istd_, and findQualityFiles::v.

14  : scale_mean_(scale_mean.begin(), scale_mean.end()), isFromL1_(isFromL1), minL1Qual_(minL1Qual) {
15  scale_istd_.reserve(scale_std.size());
16  for (auto v : scale_std)
17  scale_istd_.push_back(1. / v);
18  gbrForest_ = createGBRForest(weightsfile);
19 }
const bool isFromL1_
std::unique_ptr< const GBRForest > gbrForest_
const std::vector< float > scale_mean_
std::vector< float > scale_istd_
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)

◆ ~SeedMvaEstimator()

SeedMvaEstimator::~SeedMvaEstimator ( )

Definition at line 21 of file SeedMvaEstimator.cc.

21 {}

Member Function Documentation

◆ computeMva()

double SeedMvaEstimator::computeMva ( const TrajectorySeed seed,
const GlobalVector global_p,
const l1t::MuonBxCollection l1Muons,
const reco::RecoChargedCandidateCollection l2Muons 
) const

Definition at line 58 of file SeedMvaEstimator.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), gbrForest_, getL1MuonVariables(), getL2MuonVariables(), isFromL1_, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::iv, Phase2::kLast, Phase2::kTsosDxdz, Phase2::kTsosDydz, Phase2::kTsosErr0, Phase2::kTsosErr2, Phase2::kTsosErr5, Phase2::kTsosQbp, scale_istd_, scale_mean_, fileCollector::seed, mathSSE::sqrt(), and trigObjTnPSource_cfi::var.

61  {
62  static constexpr float initDRdPhi(99999.);
63  auto kLast = isFromL1_ ? kLastL1 : kLastL2;
64  float var[kLast];
65 
66  var[kTsosErr0] = seed.startingState().error(0);
67  var[kTsosErr2] = seed.startingState().error(2);
68  var[kTsosErr5] = seed.startingState().error(5);
69  var[kTsosDxdz] = seed.startingState().parameters().dxdz();
70  var[kTsosDydz] = seed.startingState().parameters().dydz();
71  var[kTsosQbp] = seed.startingState().parameters().qbp();
72 
73  float dR2dRL1SeedP = initDRdPhi;
74  float dPhidRL1SeedP = initDRdPhi;
75  getL1MuonVariables(global_p, l1Muons, dR2dRL1SeedP, dPhidRL1SeedP);
76 
77  var[kDRdRL1SeedP] = std::sqrt(dR2dRL1SeedP);
78  var[kDPhidRL1SeedP] = dPhidRL1SeedP;
79 
80  if (!isFromL1_) {
81  float dR2dRL2SeedP = initDRdPhi;
82  float dPhidRL2SeedP = initDRdPhi;
83  getL2MuonVariables(global_p, l2Muons, dR2dRL2SeedP, dPhidRL2SeedP);
84 
85  var[kDRdRL2SeedP] = std::sqrt(dR2dRL2SeedP);
86  var[kDPhidRL2SeedP] = dPhidRL2SeedP;
87  }
88 
89  for (int iv = 0; iv < kLast; ++iv) {
90  var[iv] = (var[iv] - scale_mean_[iv]) * scale_istd_[iv];
91  }
92 
93  return gbrForest_->GetResponse(var);
94 }
const bool isFromL1_
T sqrt(T t)
Definition: SSEVec.h:23
std::unique_ptr< const GBRForest > gbrForest_
const std::vector< float > scale_mean_
void getL2MuonVariables(const GlobalVector &, const reco::RecoChargedCandidateCollection &, float &, float &) const
void getL1MuonVariables(const GlobalVector &, const l1t::MuonBxCollection &, float &, float &) const
std::vector< float > scale_istd_

◆ getL1MuonVariables()

void SeedMvaEstimator::getL1MuonVariables ( const GlobalVector global_p,
const l1t::MuonBxCollection l1Muons,
float &  dR2dRL1SeedP,
float &  dPhidRL1SeedP 
) const
private

Definition at line 23 of file SeedMvaEstimator.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), BXVector< T >::begin(), reco::deltaPhi(), reco::deltaR2(), BXVector< T >::end(), PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, minL1Qual_, and phi.

Referenced by computeMva().

26  {
27  int ibx = 0; // -- only take when ibx == 0 -- //
28 
29  auto eta = global_p.eta();
30  auto phi = global_p.barePhi();
31  for (auto it = l1Muons.begin(ibx); it != l1Muons.end(ibx); it++) {
32  if (it->hwQual() < minL1Qual_)
33  continue;
34 
35  float dR2tmp = reco::deltaR2(it->etaAtVtx(), it->phiAtVtx(), eta, phi);
36  if (dR2tmp < dR2dRL1SeedP) {
37  dR2dRL1SeedP = dR2tmp;
38  dPhidRL1SeedP = reco::deltaPhi(it->phiAtVtx(), phi);
39  }
40  }
41 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
T eta() const
Definition: PV3DBase.h:73
T barePhi() const
Definition: PV3DBase.h:65
const_iterator begin(int bx) const
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
const_iterator end(int bx) const

◆ getL2MuonVariables()

void SeedMvaEstimator::getL2MuonVariables ( const GlobalVector global_p,
const reco::RecoChargedCandidateCollection l2Muons,
float &  dR2dRL2SeedP,
float &  dPhidRL2SeedP 
) const
private

Definition at line 43 of file SeedMvaEstimator.cc.

References PV3DBase< T, PVType, FrameType >::barePhi(), reco::deltaPhi(), reco::deltaR2(), PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, and phi.

Referenced by computeMva().

46  {
47  auto eta = global_p.eta();
48  auto phi = global_p.barePhi();
49  for (auto it = l2Muons.begin(); it != l2Muons.end(); it++) {
50  float dR2tmp = reco::deltaR2(it->eta(), it->phi(), eta, phi);
51  if (dR2tmp < dR2dRL2SeedP) {
52  dR2dRL2SeedP = dR2tmp;
53  dPhidRL2SeedP = reco::deltaPhi(it->phi(), phi);
54  }
55  }
56 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
T eta() const
Definition: PV3DBase.h:73
T barePhi() const
Definition: PV3DBase.h:65
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16

Member Data Documentation

◆ gbrForest_

std::unique_ptr<const GBRForest> SeedMvaEstimator::gbrForest_
private

Definition at line 56 of file SeedMvaEstimator.h.

Referenced by computeMva(), and SeedMvaEstimator().

◆ isFromL1_

const bool SeedMvaEstimator::isFromL1_
private

Definition at line 59 of file SeedMvaEstimator.h.

Referenced by computeMva().

◆ minL1Qual_

const int SeedMvaEstimator::minL1Qual_
private

Definition at line 60 of file SeedMvaEstimator.h.

Referenced by getL1MuonVariables().

◆ scale_istd_

std::vector<float> SeedMvaEstimator::scale_istd_
private

Definition at line 58 of file SeedMvaEstimator.h.

Referenced by computeMva(), and SeedMvaEstimator().

◆ scale_mean_

const std::vector<float> SeedMvaEstimator::scale_mean_
private

Definition at line 57 of file SeedMvaEstimator.h.

Referenced by computeMva().