CMS 3D CMS Logo

SeedMvaEstimator.cc
Go to the documentation of this file.
2 
5 
8 
10  const std::vector<double>& scale_mean,
11  const std::vector<double>& scale_std,
12  const bool isFromL1,
13  const int minL1Qual)
14  : scale_mean_(scale_mean), scale_std_(scale_std), isFromL1_(isFromL1), minL1Qual_(minL1Qual) {
15  gbrForest_ = createGBRForest(weightsfile);
16 }
17 
19 
20 namespace {
21  enum inputIndexes {
22  kTsosErr0, // 0
23  kTsosErr2, // 1
24  kTsosErr5, // 2
25  kTsosDxdz, // 3
26  kTsosDydz, // 4
27  kTsosQbp, // 5
28  kDRdRL1SeedP, // 6
29  kDPhidRL1SeedP, // 7
30  kLastL1, // 8
31 
32  kDRdRL2SeedP = 8, // 8
33  kDPhidRL2SeedP, // 9
34  kLastL2, // 10
35  };
36 } // namespace
37 
39  const l1t::MuonBxCollection& l1Muons,
40  float& dR2dRL1SeedP,
41  float& dPhidRL1SeedP) const {
42  for (int ibx = l1Muons.getFirstBX(); ibx <= l1Muons.getLastBX(); ++ibx) {
43  if (ibx != 0)
44  continue; // -- only take when ibx == 0 -- //
45 
46  for (auto it = l1Muons.begin(ibx); it != l1Muons.end(ibx); it++) {
47  if (it->hwQual() < minL1Qual_)
48  continue;
49 
50  float dR2tmp = reco::deltaR2(it->etaAtVtx(), it->phiAtVtx(), global_p.eta(), global_p.phi());
51  if (dR2tmp < dR2dRL1SeedP) {
52  dR2dRL1SeedP = dR2tmp;
53  dPhidRL1SeedP = reco::deltaPhi(it->phiAtVtx(), global_p.phi());
54  }
55  }
56  }
57 }
58 
61  float& dR2dRL2SeedP,
62  float& dPhidRL2SeedP) const {
63  for (auto it = l2Muons.begin(); it != l2Muons.end(); it++) {
64  float dR2tmp = reco::deltaR2(*it, global_p);
65  if (dR2tmp < dR2dRL2SeedP) {
66  dR2dRL2SeedP = dR2tmp;
67  dPhidRL2SeedP = reco::deltaPhi(it->phi(), global_p.phi());
68  }
69  }
70 }
71 
73  const GlobalVector& global_p,
74  const l1t::MuonBxCollection& l1Muons,
75  const reco::RecoChargedCandidateCollection& l2Muons) const {
76  static constexpr float initDRdPhi(99999.);
77  auto kLast = isFromL1_ ? kLastL1 : kLastL2;
78  float var[kLast];
79 
80  var[kTsosErr0] = seed.startingState().error(0);
81  var[kTsosErr2] = seed.startingState().error(2);
82  var[kTsosErr5] = seed.startingState().error(5);
83  var[kTsosDxdz] = seed.startingState().parameters().dxdz();
84  var[kTsosDydz] = seed.startingState().parameters().dydz();
85  var[kTsosQbp] = seed.startingState().parameters().qbp();
86 
87  float dR2dRL1SeedP = initDRdPhi;
88  float dPhidRL1SeedP = initDRdPhi;
89  getL1MuonVariables(global_p, l1Muons, dR2dRL1SeedP, dPhidRL1SeedP);
90 
91  var[kDRdRL1SeedP] = std::sqrt(dR2dRL1SeedP);
92  var[kDPhidRL1SeedP] = dPhidRL1SeedP;
93 
94  if (!isFromL1_) {
95  float dR2dRL2SeedP = initDRdPhi;
96  float dPhidRL2SeedP = initDRdPhi;
97  getL2MuonVariables(global_p, l2Muons, dR2dRL2SeedP, dPhidRL2SeedP);
98 
99  var[kDRdRL2SeedP] = std::sqrt(dR2dRL2SeedP);
100  var[kDPhidRL2SeedP] = dPhidRL2SeedP;
101  }
102 
103  for (int iv = 0; iv < kLast; ++iv) {
104  var[iv] = (var[iv] - scale_mean_.at(iv)) / scale_std_.at(iv);
105  }
106 
107  return gbrForest_->GetResponse(var);
108 }
Vector3DBase
Definition: Vector3DBase.h:8
SeedMvaEstimator::scale_mean_
const std::vector< double > scale_mean_
Definition: SeedMvaEstimator.h:39
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
deltaPhi.h
GBRForestTools.h
gpuVertexFinder::iv
int32_t *__restrict__ iv
Definition: gpuClusterTracksDBSCAN.h:42
createGBRForest
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)
Definition: GBRForestTools.cc:257
SeedMvaEstimator::getL2MuonVariables
void getL2MuonVariables(const GlobalVector &, const reco::RecoChargedCandidateCollection &, float &, float &) const
Definition: SeedMvaEstimator.cc:59
SeedMvaEstimator::getL1MuonVariables
void getL1MuonVariables(const GlobalVector &, const l1t::MuonBxCollection &, float &, float &) const
Definition: SeedMvaEstimator.cc:38
reco::RecoChargedCandidateCollection
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
Definition: RecoChargedCandidateFwd.h:9
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
fileCollector.seed
seed
Definition: fileCollector.py:127
BXVector
Definition: BXVector.h:15
BXVector::getFirstBX
int getFirstBX() const
edm::FileInPath
Definition: FileInPath.h:61
SeedMvaEstimator::scale_std_
const std::vector< double > scale_std_
Definition: SeedMvaEstimator.h:40
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
SeedMvaEstimator.h
SeedMvaEstimator::~SeedMvaEstimator
~SeedMvaEstimator()
Definition: SeedMvaEstimator.cc:18
BXVector::begin
const_iterator begin(int bx) const
FileInPath.h
SeedMvaEstimator::computeMva
double computeMva(const TrajectorySeed &, const GlobalVector &, const l1t::MuonBxCollection &, const reco::RecoChargedCandidateCollection &) const
Definition: SeedMvaEstimator.cc:72
BXVector::end
const_iterator end(int bx) const
SeedMvaEstimator::minL1Qual_
const int minL1Qual_
Definition: SeedMvaEstimator.h:42
deltaR.h
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
SeedMvaEstimator::isFromL1_
const bool isFromL1_
Definition: SeedMvaEstimator.h:41
TrajectorySeed
Definition: TrajectorySeed.h:18
SeedMvaEstimator::gbrForest_
std::unique_ptr< const GBRForest > gbrForest_
Definition: SeedMvaEstimator.h:38
inputIndexes
inputIndexes
Definition: MuonMvaEstimator.cc:24
BXVector::getLastBX
int getLastBX() const
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
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: SeedMvaEstimator.cc:9