CMS 3D CMS Logo

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

#include <SeedMvaEstimatorPhase2.h>

Public Member Functions

double computeMva (const TrajectorySeed &, const GlobalVector &, const GlobalPoint &, const edm::Handle< l1t::TrackerMuonCollection > &, const edm::ESHandle< MagneticField > &, const Propagator &, const GeometricSearchTracker &) const
 
 SeedMvaEstimatorPhase2 (const edm::FileInPath &weightsfile, const std::vector< double > &scale_mean, const std::vector< double > &scale_std)
 
 ~SeedMvaEstimatorPhase2 ()
 

Private Member Functions

void getHitL1TkVariables (const TrajectorySeed &, const edm::Handle< l1t::TrackerMuonCollection > &, const edm::ESHandle< MagneticField > &, const Propagator &, const GeometricSearchTracker &, float &, float &, float &) const
 
vector< pair< LayerHit, LayerTSOS > > getHitTsosPairs (const TrajectorySeed &, const edm::Handle< l1t::TrackerMuonCollection > &, const edm::ESHandle< MagneticField > &, const Propagator &, const GeometricSearchTracker &) const
 
void getL1TTVariables (const TrajectorySeed &, const GlobalVector &, const GlobalPoint &, const edm::Handle< l1t::TrackerMuonCollection > &, float &, float &) const
 
vector< LayerTSOSgetTsosOnPixels (const TTTrack< Ref_Phase2TrackerDigi_ > &, const edm::ESHandle< MagneticField > &, const Propagator &, const GeometricSearchTracker &) const
 

Private Attributes

std::unique_ptr< const GBRForestgbrForest_
 
const std::vector< double > scale_mean_
 
const std::vector< double > scale_std_
 

Detailed Description

Definition at line 42 of file SeedMvaEstimatorPhase2.h.

Constructor & Destructor Documentation

◆ SeedMvaEstimatorPhase2()

SeedMvaEstimatorPhase2::SeedMvaEstimatorPhase2 ( const edm::FileInPath weightsfile,
const std::vector< double > &  scale_mean,
const std::vector< double > &  scale_std 
)

Definition at line 30 of file SeedMvaEstimatorPhase2.cc.

References createGBRForest(), and gbrForest_.

33  : scale_mean_(scale_mean), scale_std_(scale_std) {
34  gbrForest_ = createGBRForest(weightsfile);
35 }
const std::vector< double > scale_std_
std::unique_ptr< const GBRForest > gbrForest_
const std::vector< double > scale_mean_
std::unique_ptr< const GBRForest > createGBRForest(const std::string &weightsFile)

◆ ~SeedMvaEstimatorPhase2()

SeedMvaEstimatorPhase2::~SeedMvaEstimatorPhase2 ( )

Definition at line 37 of file SeedMvaEstimatorPhase2.cc.

37 {}

Member Function Documentation

◆ computeMva()

double SeedMvaEstimatorPhase2::computeMva ( const TrajectorySeed seed,
const GlobalVector global_p,
const GlobalPoint global_x,
const edm::Handle< l1t::TrackerMuonCollection > &  h_L1TkMu,
const edm::ESHandle< MagneticField > &  magfieldH,
const Propagator propagatorAlong,
const GeometricSearchTracker geomTracker 
) const

Definition at line 271 of file SeedMvaEstimatorPhase2.cc.

References gbrForest_, getHitL1TkVariables(), getL1TTVariables(), gpuVertexFinder::iv, Phase2::kDRdPhiL1TkMuSeedP, Phase2::kDRdRL1TkMuSeedP, Phase2::kExpd2HitL1Tk1, Phase2::kExpd2HitL1Tk2, Phase2::kExpd2HitL1Tk3, Phase2::kLast, Phase2::kTsosDxdz, Phase2::kTsosDydz, Phase2::kTsosErr0, Phase2::kTsosErr2, Phase2::kTsosErr5, Phase2::kTsosQbp, L1TMuonDQMOffline_cfi::propagatorAlong, scale_mean_, scale_std_, and fileCollector::seed.

277  {
278  float Phase2var[Phase2::kLast]{};
279 
280  Phase2var[Phase2::kTsosErr0] = seed.startingState().error(0);
281  Phase2var[Phase2::kTsosErr2] = seed.startingState().error(2);
282  Phase2var[Phase2::kTsosErr5] = seed.startingState().error(5);
283  Phase2var[Phase2::kTsosDxdz] = seed.startingState().parameters().dxdz();
284  Phase2var[Phase2::kTsosDydz] = seed.startingState().parameters().dydz();
285  Phase2var[Phase2::kTsosQbp] = seed.startingState().parameters().qbp();
286 
287  float initDRdPhi = 99999.;
288 
289  float DRL1TkMuSeedP = initDRdPhi;
290  float DPhiL1TkMuSeedP = initDRdPhi;
291  getL1TTVariables(seed, global_p, global_x, h_L1TkMu, DRL1TkMuSeedP, DPhiL1TkMuSeedP);
292  Phase2var[Phase2::kDRdRL1TkMuSeedP] = DRL1TkMuSeedP;
293  Phase2var[Phase2::kDRdPhiL1TkMuSeedP] = DPhiL1TkMuSeedP;
294 
295  float expd2HitL1Tk1 = initDRdPhi;
296  float expd2HitL1Tk2 = initDRdPhi;
297  float expd2HitL1Tk3 = initDRdPhi;
299  seed, h_L1TkMu, magfieldH, propagatorAlong, geomTracker, expd2HitL1Tk1, expd2HitL1Tk2, expd2HitL1Tk3);
300  Phase2var[Phase2::kExpd2HitL1Tk1] = expd2HitL1Tk1;
301  Phase2var[Phase2::kExpd2HitL1Tk2] = expd2HitL1Tk2;
302  Phase2var[Phase2::kExpd2HitL1Tk3] = expd2HitL1Tk3;
303 
304  for (int iv = 0; iv < Phase2::kLast; ++iv) {
305  Phase2var[iv] = (Phase2var[iv] - scale_mean_.at(iv)) / scale_std_.at(iv);
306  }
307 
308  return gbrForest_->GetResponse(Phase2var);
309 }
int32_t *__restrict__ iv
const std::vector< double > scale_std_
std::unique_ptr< const GBRForest > gbrForest_
void getL1TTVariables(const TrajectorySeed &, const GlobalVector &, const GlobalPoint &, const edm::Handle< l1t::TrackerMuonCollection > &, float &, float &) const
void getHitL1TkVariables(const TrajectorySeed &, const edm::Handle< l1t::TrackerMuonCollection > &, const edm::ESHandle< MagneticField > &, const Propagator &, const GeometricSearchTracker &, float &, float &, float &) const
const std::vector< double > scale_mean_

◆ getHitL1TkVariables()

void SeedMvaEstimatorPhase2::getHitL1TkVariables ( const TrajectorySeed seed,
const edm::Handle< l1t::TrackerMuonCollection > &  L1TkMuonHandle,
const edm::ESHandle< MagneticField > &  magfieldH,
const Propagator propagatorAlong,
const GeometricSearchTracker geomTracker,
float &  expd2HitL1Tk1,
float &  expd2HitL1Tk2,
float &  expd2HitL1Tk3 
) const
private

Definition at line 182 of file SeedMvaEstimatorPhase2.cc.

References JetChargeProducer_cfi::exp, newFWLiteAna::found, getHitTsosPairs(), funct::pow(), L1TMuonDQMOffline_cfi::propagatorAlong, and fileCollector::seed.

Referenced by computeMva().

189  {
190  vector<pair<LayerHit, LayerTSOS> > hitTsosPair =
191  getHitTsosPairs(seed, L1TkMuonHandle, magfieldH, propagatorAlong, geomTracker);
192 
193  bool found = (!hitTsosPair.empty());
194 
195  if (found) {
196  float l1x1 = 99999.;
197  float l1y1 = 99999.;
198  float l1z1 = 99999.;
199  float hitx1 = 99999.;
200  float hity1 = 99999.;
201  float hitz1 = 99999.;
202 
203  float l1x2 = 99999.;
204  float l1y2 = 99999.;
205  float l1z2 = 99999.;
206  float hitx2 = 99999.;
207  float hity2 = 99999.;
208  float hitz2 = 99999.;
209 
210  float l1x3 = 99999.;
211  float l1y3 = 99999.;
212  float l1z3 = 99999.;
213  float hitx3 = 99999.;
214  float hity3 = 99999.;
215  float hitz3 = 99999.;
216 
217  if (hitTsosPair.size() > 1) {
218  auto hit1 = hitTsosPair.at(0).first.second;
219  auto tsos1 = hitTsosPair.at(0).second.second;
220 
221  l1x1 = tsos1.globalPosition().x();
222  l1y1 = tsos1.globalPosition().y();
223  l1z1 = tsos1.globalPosition().z();
224  hitx1 = hit1->globalPosition().x();
225  hity1 = hit1->globalPosition().y();
226  hitz1 = hit1->globalPosition().z();
227 
228  auto hit2 = hitTsosPair.at(1).first.second;
229  auto tsos2 = hitTsosPair.at(1).second.second;
230 
231  l1x2 = tsos2.globalPosition().x();
232  l1y2 = tsos2.globalPosition().y();
233  l1z2 = tsos2.globalPosition().z();
234  hitx2 = hit2->globalPosition().x();
235  hity2 = hit2->globalPosition().y();
236  hitz2 = hit2->globalPosition().z();
237  }
238  if (hitTsosPair.size() > 2) {
239  auto hit3 = hitTsosPair.at(2).first.second;
240  auto tsos3 = hitTsosPair.at(2).second.second;
241 
242  l1x3 = tsos3.globalPosition().x();
243  l1y3 = tsos3.globalPosition().y();
244  l1z3 = tsos3.globalPosition().z();
245  hitx3 = hit3->globalPosition().x();
246  hity3 = hit3->globalPosition().y();
247  hitz3 = hit3->globalPosition().z();
248  }
249 
250  // If hit == 99999. >> cannot find hit info >> distance btw hit~tsos is large >> expd2HitL1Tk ~ 0
251  if (hitx1 != 99999.) {
252  expd2HitL1Tk1 = exp(-(pow((l1x1 - hitx1), 2) + pow((l1y1 - hity1), 2) + pow((l1z1 - hitz1), 2)));
253  } else {
254  expd2HitL1Tk1 = 0.;
255  }
256 
257  if (hitx2 != 99999.) {
258  expd2HitL1Tk2 = exp(-(pow((l1x2 - hitx2), 2) + pow((l1y2 - hity2), 2) + pow((l1z2 - hitz2), 2)));
259  } else {
260  expd2HitL1Tk2 = 0.;
261  }
262 
263  if (hitx3 != 99999.) {
264  expd2HitL1Tk3 = exp(-(pow((l1x3 - hitx3), 2) + pow((l1y3 - hity3), 2) + pow((l1z3 - hitz3), 2)));
265  } else {
266  expd2HitL1Tk3 = 0.;
267  }
268  }
269 }
vector< pair< LayerHit, LayerTSOS > > getHitTsosPairs(const TrajectorySeed &, const edm::Handle< l1t::TrackerMuonCollection > &, const edm::ESHandle< MagneticField > &, const Propagator &, const GeometricSearchTracker &) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ getHitTsosPairs()

vector< pair< LayerHit, LayerTSOS > > SeedMvaEstimatorPhase2::getHitTsosPairs ( const TrajectorySeed seed,
const edm::Handle< l1t::TrackerMuonCollection > &  L1TkMuonHandle,
const edm::ESHandle< MagneticField > &  magfieldH,
const Propagator propagatorAlong,
const GeometricSearchTracker geomTracker 
) const
private

Definition at line 126 of file SeedMvaEstimatorPhase2.cc.

References l1ctLayer1_cff::dr, nano_mu_digi_cff::float, getTsosOnPixels(), mps_fire::i, GeometricSearchTracker::idToLayer(), hltIter2Phase2L3FromL1TkMuonPixelSeedsFiltered_cfi::L1TkMu, mag(), MillePedeFileConverter_cfg::out, L1TMuonDQMOffline_cfi::propagatorAlong, fileCollector::seed, and mitigatedMETSequence_cff::U.

Referenced by getHitL1TkVariables().

131  {
132  vector<pair<LayerHit, LayerTSOS> > out = {};
133  float av_dr_min = 999.;
134 
135  // -- loop on L1TkMu
136  for (auto L1TkMu = L1TkMuonHandle->begin(); L1TkMu != L1TkMuonHandle->end(); ++L1TkMu) {
137  const vector<LayerTSOS> v_tsos = getTsosOnPixels(*L1TkMu->trkPtr(), magfieldH, propagatorAlong, geomTracker);
138 
139  // -- loop on recHits
140  vector<int> v_tsos_skip(v_tsos.size(), 0);
141  vector<pair<LayerHit, LayerTSOS> > hitTsosPair = {};
142  int ihit = 0;
143  for (const auto& hit : seed.recHits()) {
144  // -- look for closest tsos by absolute distance
145  int the_tsos = -99999;
146  float dr_min = 20.;
147  for (auto i = 0U; i < v_tsos.size(); ++i) {
148  if (v_tsos_skip.at(i))
149  continue;
150  float dr = (v_tsos.at(i).second.globalPosition() - hit.globalPosition()).mag();
151  if (dr < dr_min) {
152  dr_min = dr;
153  the_tsos = i;
154  v_tsos_skip.at(i) = 1;
155  }
156  }
157  if (the_tsos > -1) {
158  const DetLayer* thelayer = geomTracker.idToLayer(hit.geographicalId());
159  hitTsosPair.push_back(make_pair(make_pair(thelayer, &hit), v_tsos.at(the_tsos)));
160  }
161  ihit++;
162  } // loop on recHits
163 
164  // -- find tsos for all recHits?
165  if ((int)hitTsosPair.size() == ihit) {
166  float av_dr = 0.;
167  for (auto it = hitTsosPair.begin(); it != hitTsosPair.end(); ++it) {
168  auto hit = it->first.second;
169  auto tsos = it->second.second;
170  av_dr += (hit->globalPosition() - tsos.globalPosition()).mag();
171  }
172  av_dr = av_dr > 0 ? av_dr / (float)hitTsosPair.size() : 1.e6;
173  if (av_dr < av_dr_min) {
174  av_dr_min = av_dr;
175  out = hitTsosPair;
176  }
177  }
178  } // loop on L1TkMu
179  return out;
180 }
vector< LayerTSOS > getTsosOnPixels(const TTTrack< Ref_Phase2TrackerDigi_ > &, const edm::ESHandle< MagneticField > &, const Propagator &, const GeometricSearchTracker &) const
const DetLayer * idToLayer(const DetId &detId) const override
Give the DetId of a module, returns the pointer to the corresponding DetLayer.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())

◆ getL1TTVariables()

void SeedMvaEstimatorPhase2::getL1TTVariables ( const TrajectorySeed seed,
const GlobalVector global_p,
const GlobalPoint global_x,
const edm::Handle< l1t::TrackerMuonCollection > &  h_L1TkMu,
float &  DRL1TkMu,
float &  DPhiL1TkMu 
) const
private

Definition at line 39 of file SeedMvaEstimatorPhase2.cc.

References reco::deltaPhi(), reco::deltaR(), hltIter2Phase2L3FromL1TkMuonPixelSeedsFiltered_cfi::L1TkMu, and PV3DBase< T, PVType, FrameType >::phi().

Referenced by computeMva().

44  {
45  for (auto L1TkMu = h_L1TkMu->begin(); L1TkMu != h_L1TkMu->end(); ++L1TkMu) {
46  auto TkRef = L1TkMu->trkPtr();
47  float DRL1TkMu_tmp = reco::deltaR(*TkRef, global_p);
48  float DPhiL1TkMu_tmp = reco::deltaPhi(TkRef->phi(), global_p.phi());
49  if (DRL1TkMu_tmp < DRL1TkMu) {
50  DRL1TkMu = DRL1TkMu_tmp;
51  DPhiL1TkMu = DPhiL1TkMu_tmp;
52  }
53  }
54 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30

◆ getTsosOnPixels()

vector< LayerTSOS > SeedMvaEstimatorPhase2::getTsosOnPixels ( const TTTrack< Ref_Phase2TrackerDigi_ > &  l1tk,
const edm::ESHandle< MagneticField > &  magfieldH,
const Propagator propagatorAlong,
const GeometricSearchTracker geomTracker 
) const
private

Definition at line 56 of file SeedMvaEstimatorPhase2.cc.

References funct::abs(), PbPb_ZMuSkimMuonDPG_cff::deltaR, l1tTrackerHTMiss_cfi::deltaZ, TrajectoryStateOnSurface::globalDirection(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localPosition(), SiStripPI::max, TTTrack< T >::momentum(), GeometricSearchTracker::negPixelForwardLayers(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::perp2(), GeometricSearchTracker::pixelBarrelLayers(), TTTrack< T >::POCA(), GeometricSearchTracker::posPixelForwardLayers(), edm::ESHandle< T >::product(), L1TMuonDQMOffline_cfi::propagatorAlong, diffTwoXMLs::r2, TTTrack< T >::rInv(), PV3DBase< T, PVType, FrameType >::z(), and HLTMuonOfflineAnalyzer_cfi::z0.

Referenced by getHitTsosPairs().

59  {
60  vector<LayerTSOS> v_tsos = {};
61 
62  std::vector<BarrelDetLayer const*> const& bpix = geomTracker.pixelBarrelLayers();
63  std::vector<ForwardDetLayer const*> const& nfpix = geomTracker.negPixelForwardLayers();
64  std::vector<ForwardDetLayer const*> const& pfpix = geomTracker.posPixelForwardLayers();
65 
66  int chargeTk = l1tk.rInv() > 0. ? 1 : -1;
67  GlobalPoint gpos = l1tk.POCA();
68  GlobalVector gmom = l1tk.momentum();
69 
70  FreeTrajectoryState fts = FreeTrajectoryState(gpos, gmom, chargeTk, magfieldH.product());
71 
72  for (auto it = bpix.begin(); it != bpix.end(); ++it) {
73  TrajectoryStateOnSurface tsos = propagatorAlong.propagate(fts, (**it).specificSurface());
74  if (!tsos.isValid())
75  continue;
76 
77  auto z0 = std::abs(tsos.globalPosition().z() - (**it).specificSurface().position().z());
78  auto deltaZ = 0.5f * (**it).surface().bounds().length();
79  deltaZ += 0.5f * (**it).surface().bounds().thickness() * std::abs(tsos.globalDirection().z()) /
80  tsos.globalDirection().perp();
81  bool is_compatible = (z0 < deltaZ);
82 
83  if (is_compatible) {
84  v_tsos.push_back(make_pair((const DetLayer*)(*it), tsos));
85  }
86  }
87  for (auto it = nfpix.begin(); it != nfpix.end(); ++it) {
88  TrajectoryStateOnSurface tsos = propagatorAlong.propagate(fts, (**it).specificSurface());
89  if (!tsos.isValid())
90  continue;
91 
92  auto r2 = tsos.localPosition().perp2();
93  float deltaR = 0.5f * (**it).surface().bounds().thickness() * tsos.localDirection().perp() /
94  std::abs(tsos.localDirection().z());
95  auto ri2 = std::max((**it).specificSurface().innerRadius() - deltaR, 0.f);
96  ri2 *= ri2;
97  auto ro2 = (**it).specificSurface().outerRadius() + deltaR;
98  ro2 *= ro2;
99  bool is_compatible = ((r2 > ri2) && (r2 < ro2));
100 
101  if (is_compatible) {
102  v_tsos.push_back(make_pair((const DetLayer*)(*it), tsos));
103  }
104  }
105  for (auto it = pfpix.begin(); it != pfpix.end(); ++it) {
106  TrajectoryStateOnSurface tsos = propagatorAlong.propagate(fts, (**it).specificSurface());
107  if (!tsos.isValid())
108  continue;
109 
110  auto r2 = tsos.localPosition().perp2();
111  float deltaR = 0.5f * (**it).surface().bounds().thickness() * tsos.localDirection().perp() /
112  std::abs(tsos.localDirection().z());
113  auto ri2 = std::max((**it).specificSurface().innerRadius() - deltaR, 0.f);
114  ri2 *= ri2;
115  auto ro2 = (**it).specificSurface().outerRadius() + deltaR;
116  ro2 *= ro2;
117  bool is_compatible = ((r2 > ri2) && (r2 < ro2));
118  if (is_compatible) {
119  v_tsos.push_back(make_pair((const DetLayer*)(*it), tsos));
120  }
121  }
122  return v_tsos;
123 }
T perp() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:61
GlobalVector momentum() const
Track momentum.
Definition: TTTrack.h:295
std::vector< ForwardDetLayer const * > const & posPixelForwardLayers() const
T const * product() const
Definition: ESHandle.h:86
GlobalPoint globalPosition() const
LocalVector localDirection() const
std::vector< ForwardDetLayer const * > const & negPixelForwardLayers() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double rInv() const
Track curvature.
Definition: TTTrack.h:300
std::vector< BarrelDetLayer const * > const & pixelBarrelLayers() const
GlobalVector globalDirection() const
T perp2() const
Definition: PV3DBase.h:68
GlobalPoint POCA() const
POCA.
Definition: TTTrack.h:335

Member Data Documentation

◆ gbrForest_

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

Definition at line 58 of file SeedMvaEstimatorPhase2.h.

Referenced by computeMva(), and SeedMvaEstimatorPhase2().

◆ scale_mean_

const std::vector<double> SeedMvaEstimatorPhase2::scale_mean_
private

Definition at line 59 of file SeedMvaEstimatorPhase2.h.

Referenced by computeMva().

◆ scale_std_

const std::vector<double> SeedMvaEstimatorPhase2::scale_std_
private

Definition at line 60 of file SeedMvaEstimatorPhase2.h.

Referenced by computeMva().