CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cms::MuonTCMETValueMapProducer Class Reference

#include <MuonTCMETValueMapProducer.h>

Inheritance diagram for cms::MuonTCMETValueMapProducer:
edm::stream::EDProducer<>

Public Member Functions

 MuonTCMETValueMapProducer (const edm::ParameterSet &)
 
 ~MuonTCMETValueMapProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

bool isGoodCaloMuon (const reco::Muon *, const unsigned int)
 
bool isGoodMuon (const reco::Muon *)
 
bool isGoodTrack (const reco::Muon *)
 
bool isValidVertex ()
 
int nLayers (const reco::TrackRef)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
class TVector3 propagateTrack (const reco::Muon *)
 

Private Attributes

edm::Handle< reco::BeamSpotbeamSpot_
 
edm::EDGetTokenT< reco::BeamSpotbeamSpotToken_
 
const class MagneticFieldbField
 
double d0cuta_
 
double d0cutb_
 
bool hasValidVertex
 
double maxchi2_
 
double maxchi2_tight_
 
double maxd0cut_
 
double maxeta_
 
double maxpt_
 
double maxpt_eta20_
 
double maxpt_eta25_
 
double maxPtErr_
 
double maxPtErr_tight_
 
double minhits_
 
double minhits_tight_
 
double minpt_
 
double muon_dptrel_
 
double muonchi2_
 
double muond0_
 
double muonDeltaR_
 
double muoneta_
 
bool muonGlobal_
 
double muonhits_
 
int muonMinValidStaHits_
 
double muonpt_
 
edm::Handle< reco::MuonCollectionmuons_
 
edm::EDGetTokenT< reco::MuonCollectionmuonToken_
 
bool muonTracker_
 
int nLayers_
 
int nLayersTight_
 
class TH2D * response_function
 
int rfType_
 
TCMETAlgotcmetAlgo_
 
std::vector< reco::TrackBase::TrackAlgorithmtrackAlgos_
 
std::vector< reco::TrackBase::TrackAlgorithmtrkAlgos_
 
std::vector< int > trkQuality_
 
bool useCaloMuons_
 
bool usePvtxd0_
 
edm::Handle< reco::VertexCollectionvertexHandle_
 
double vertexMaxDZ_
 
int vertexNdof_
 
double vertexRho_
 
edm::EDGetTokenT< reco::VertexCollectionvertexToken_
 
double vertexZ_
 
const reco::VertexCollectionvertices_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 40 of file MuonTCMETValueMapProducer.h.

Constructor & Destructor Documentation

MuonTCMETValueMapProducer::MuonTCMETValueMapProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 49 of file MuonTCMETValueMapProducer.cc.

References a, reco::TrackBase::algoByName(), hltMVAJetPuId_cff::algos, beamSpotToken_, d0cuta_, d0cutb_, edm::ParameterSet::getParameter(), TCMETAlgo::getResponseFunction_fit(), TCMETAlgo::getResponseFunction_mode(), maxchi2_, maxchi2_tight_, maxd0cut_, maxeta_, maxpt_, maxpt_eta20_, maxpt_eta25_, maxPtErr_, maxPtErr_tight_, minhits_, minhits_tight_, minpt_, muon_dptrel_, muonchi2_, muond0_, muonDeltaR_, muoneta_, muonGlobal_, muonhits_, muonMinValidStaHits_, muonpt_, muonToken_, muonTracker_, nLayers_, nLayersTight_, response_function, rfType_, AlCaHLTBitMon_QueryRunRegistry::string, tcmetAlgo_, HcalDetIdTransform::transform(), trkAlgos_, trkQuality_, useCaloMuons_, usePvtxd0_, vertexMaxDZ_, vertexNdof_, vertexRho_, vertexToken_, and vertexZ_.

49  {
50  produces<edm::ValueMap<reco::MuonMETCorrectionData>>("muCorrData");
51 
52  rfType_ = iConfig.getParameter<int>("rf_type");
53 
54  nLayers_ = iConfig.getParameter<int>("nLayers");
55  nLayersTight_ = iConfig.getParameter<int>("nLayersTight");
56  vertexNdof_ = iConfig.getParameter<int>("vertexNdof");
57  vertexZ_ = iConfig.getParameter<double>("vertexZ");
58  vertexRho_ = iConfig.getParameter<double>("vertexRho");
59  vertexMaxDZ_ = iConfig.getParameter<double>("vertexMaxDZ");
60  maxpt_eta20_ = iConfig.getParameter<double>("maxpt_eta20");
61  maxpt_eta25_ = iConfig.getParameter<double>("maxpt_eta25");
62 
63  // get configuration parameters
64  std::vector<std::string> algos = iConfig.getParameter<std::vector<std::string>>("trackAlgos");
65  std::transform(algos.begin(), algos.end(), std::back_inserter(trkAlgos_), [](const std::string& a) {
67  });
68  maxd0cut_ = iConfig.getParameter<double>("d0_max");
69  minpt_ = iConfig.getParameter<double>("pt_min");
70  maxpt_ = iConfig.getParameter<double>("pt_max");
71  maxeta_ = iConfig.getParameter<double>("eta_max");
72  maxchi2_ = iConfig.getParameter<double>("chi2_max");
73  minhits_ = iConfig.getParameter<double>("nhits_min");
74  maxPtErr_ = iConfig.getParameter<double>("ptErr_max");
75 
76  trkQuality_ = iConfig.getParameter<std::vector<int>>("track_quality");
77  algos = iConfig.getParameter<std::vector<std::string>>("track_algos");
78  std::transform(algos.begin(), algos.end(), std::back_inserter(trkAlgos_), [](const std::string& a) {
80  });
81  maxchi2_tight_ = iConfig.getParameter<double>("chi2_max_tight");
82  minhits_tight_ = iConfig.getParameter<double>("nhits_min_tight");
83  maxPtErr_tight_ = iConfig.getParameter<double>("ptErr_max_tight");
84  usePvtxd0_ = iConfig.getParameter<bool>("usePvtxd0");
85  d0cuta_ = iConfig.getParameter<double>("d0cuta");
86  d0cutb_ = iConfig.getParameter<double>("d0cutb");
87 
88  muon_dptrel_ = iConfig.getParameter<double>("muon_dptrel");
89  muond0_ = iConfig.getParameter<double>("d0_muon");
90  muonpt_ = iConfig.getParameter<double>("pt_muon");
91  muoneta_ = iConfig.getParameter<double>("eta_muon");
92  muonchi2_ = iConfig.getParameter<double>("chi2_muon");
93  muonhits_ = iConfig.getParameter<double>("nhits_muon");
94  muonGlobal_ = iConfig.getParameter<bool>("global_muon");
95  muonTracker_ = iConfig.getParameter<bool>("tracker_muon");
96  muonDeltaR_ = iConfig.getParameter<double>("deltaR_muon");
97  useCaloMuons_ = iConfig.getParameter<bool>("useCaloMuons");
98  muonMinValidStaHits_ = iConfig.getParameter<int>("muonMinValidStaHits");
99 
100  response_function = nullptr;
101  tcmetAlgo_ = new TCMETAlgo();
102 
103  if (rfType_ == 1)
104  response_function = tcmetAlgo_->getResponseFunction_fit();
105  else if (rfType_ == 2)
106  response_function = tcmetAlgo_->getResponseFunction_mode();
107 
108  muonToken_ = consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("muonInputTag"));
109  beamSpotToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotInputTag"));
110  vertexToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexInputTag"));
111  }
T getParameter(std::string const &) const
TH2D * getResponseFunction_fit()
Definition: TCMETAlgo.cc:3522
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
std::vector< reco::TrackBase::TrackAlgorithm > trkAlgos_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
TH2D * getResponseFunction_mode()
Definition: TCMETAlgo.cc:4994
double a
Definition: hdecay.h:119
static TrackAlgorithm algoByName(const std::string &name)
Definition: TrackBase.cc:137
edm::EDGetTokenT< reco::MuonCollection > muonToken_
unsigned transform(const HcalDetId &id, unsigned transformCode)
MuonTCMETValueMapProducer::~MuonTCMETValueMapProducer ( )
override

Definition at line 114 of file MuonTCMETValueMapProducer.cc.

References tcmetAlgo_.

Member Function Documentation

bool MuonTCMETValueMapProducer::isGoodCaloMuon ( const reco::Muon muon,
const unsigned int  index 
)
private

Definition at line 246 of file MuonTCMETValueMapProducer.cc.

References funct::cos(), spr::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, PbPb_ZMuSkimMuonDPG_cff::deltaR, edm::Ref< C, T, F >::get(), reco::Muon::innerTrack(), isGoodTrack(), edm::Ref< C, T, F >::isNonnull(), amptDefaultParameters_cff::mu, muonDeltaR_, muons_, jets_cff::nMuons, and reco::LeafCandidate::pt().

Referenced by produce().

246  {
247  if (muon->pt() < 10)
248  return false;
249 
250  if (!isGoodTrack(muon))
251  return false;
252 
253  const reco::TrackRef inputSiliconTrack = muon->innerTrack();
254  if (!inputSiliconTrack.isNonnull())
255  return false;
256 
257  //check if it is in the vicinity of a global or tracker muon
258  unsigned int nMuons = muons_->size();
259  for (unsigned int iMu = 0; iMu < nMuons; iMu++) {
260  if (iMu == index)
261  continue;
262 
263  const reco::Muon* mu = &(*muons_)[iMu];
264 
265  const reco::TrackRef testSiliconTrack = mu->innerTrack();
266  if (!testSiliconTrack.isNonnull())
267  continue;
268 
269  double deltaEta = inputSiliconTrack.get()->eta() - testSiliconTrack.get()->eta();
270  double deltaPhi = acos(cos(inputSiliconTrack.get()->phi() - testSiliconTrack.get()->phi()));
271  double deltaR = TMath::Sqrt(deltaEta * deltaEta + deltaPhi * deltaPhi);
272 
273  if (deltaR < muonDeltaR_)
274  return false;
275  }
276 
277  return true;
278  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
virtual TrackRef innerTrack() const
Definition: Muon.h:45
double pt() const final
transverse momentum
static const double deltaEta
Definition: CaloConstants.h:8
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::Handle< reco::MuonCollection > muons_
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
bool MuonTCMETValueMapProducer::isGoodMuon ( const reco::Muon muon)
private

Definition at line 196 of file MuonTCMETValueMapProducer.cc.

References beamSpot_, hltPixelTracks_cff::chi2, HLTMuonOfflineAnalyzer_cfi::d0, reco::LeafCandidate::eta(), reco::Muon::globalTrack(), cutBasedMuonId_MuonPOG_V0_cff::globalTrack, reco::Muon::innerTrack(), reco::Muon::isGlobalMuon(), edm::Ref< C, T, F >::isNonnull(), reco::Muon::isTrackerMuon(), edm::HandleBase::isValid(), muon_dptrel_, muonchi2_, muond0_, muoneta_, muonGlobal_, muonhits_, muonMinValidStaHits_, muonpt_, muonTracker_, nhits, reco::BeamSpot::position(), and reco::LeafCandidate::pt().

Referenced by produce().

196  {
197  double d0 = -999;
198  double nhits = 0;
199  double chi2 = 999;
200 
201  // get d0 corrected for beam spot
202  bool haveBeamSpot = true;
203  if (!beamSpot_.isValid())
204  haveBeamSpot = false;
205 
206  if (muonGlobal_ && !muon->isGlobalMuon())
207  return false;
208  if (muonTracker_ && !muon->isTrackerMuon())
209  return false;
210 
211  const reco::TrackRef siTrack = muon->innerTrack();
212  const reco::TrackRef globalTrack = muon->globalTrack();
213 
214  Point bspot = haveBeamSpot ? beamSpot_->position() : Point(0, 0, 0);
215  if (siTrack.isNonnull())
216  nhits = siTrack->numberOfValidHits();
217  if (globalTrack.isNonnull()) {
218  d0 = -1 * globalTrack->dxy(bspot);
219  chi2 = globalTrack->normalizedChi2();
220  }
221 
222  if (fabs(d0) > muond0_)
223  return false;
224  if (muon->pt() < muonpt_)
225  return false;
226  if (fabs(muon->eta()) > muoneta_)
227  return false;
228  if (nhits < muonhits_)
229  return false;
230  if (chi2 > muonchi2_)
231  return false;
232  if (globalTrack->hitPattern().numberOfValidMuonHits() < muonMinValidStaHits_)
233  return false;
234 
235  //reject muons with tracker dpt/pt > X
236  if (!siTrack.isNonnull())
237  return false;
238  if (siTrack->ptError() / siTrack->pt() > muon_dptrel_)
239  return false;
240 
241  else
242  return true;
243  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
double eta() const final
momentum pseudorapidity
virtual TrackRef innerTrack() const
Definition: Muon.h:45
double pt() const final
transverse momentum
bool isTrackerMuon() const override
Definition: Muon.h:299
bool isGlobalMuon() const override
Definition: Muon.h:298
bool isValid() const
Definition: HandleBase.h:70
math::XYZPoint Point
edm::Handle< reco::BeamSpot > beamSpot_
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
const Point & position() const
position
Definition: BeamSpot.h:59
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:51
bool MuonTCMETValueMapProducer::isGoodTrack ( const reco::Muon muon)
private

Definition at line 281 of file MuonTCMETValueMapProducer.cc.

References beamSpot_, TkAlMuonSelectors_cfi::cut, HLTMuonOfflineAnalyzer_cfi::d0, d0cuta_, d0cutb_, PVValHelper::dz, spr::find(), hasValidVertex, mps_fire::i, reco::Muon::innerTrack(), edm::Ref< C, T, F >::isNonnull(), edm::HandleBase::isValid(), maxchi2_, maxchi2_tight_, maxd0cut_, maxeta_, maxpt_, maxpt_eta20_, maxpt_eta25_, maxPtErr_, maxPtErr_tight_, minhits_, minhits_tight_, nLayers(), nLayers_, nLayersTight_, reco::BeamSpot::position(), funct::pow(), mathSSE::sqrt(), trackAlgos_, trkAlgos_, trkQuality_, vertexMaxDZ_, and vertices_.

Referenced by isGoodCaloMuon(), and produce().

281  {
282  double d0;
283 
284  const reco::TrackRef siTrack = muon->innerTrack();
285  if (!siTrack.isNonnull())
286  return false;
287 
288  if (hasValidVertex) {
289  //get d0 corrected for primary vertex
290 
291  const Point pvtx = Point(vertices_->begin()->x(), vertices_->begin()->y(), vertices_->begin()->z());
292 
293  double dz = siTrack->dz(pvtx);
294 
295  if (fabs(dz) < vertexMaxDZ_) {
296  //get d0 corrected for pvtx
297  d0 = -1 * siTrack->dxy(pvtx);
298 
299  } else {
300  // get d0 corrected for beam spot
301  bool haveBeamSpot = true;
302  if (!beamSpot_.isValid())
303  haveBeamSpot = false;
304 
305  Point bspot = haveBeamSpot ? beamSpot_->position() : Point(0, 0, 0);
306  d0 = -1 * siTrack->dxy(bspot);
307  }
308  } else {
309  // get d0 corrected for beam spot
310  bool haveBeamSpot = true;
311  if (!beamSpot_.isValid())
312  haveBeamSpot = false;
313 
314  Point bspot = haveBeamSpot ? beamSpot_->position() : Point(0, 0, 0);
315  d0 = -1 * siTrack->dxy(bspot);
316  }
317 
318  if (std::find(trackAlgos_.begin(), trackAlgos_.end(), siTrack->algo()) != trackAlgos_.end()) {
319  //1st 4 tracking iterations (pT-dependent d0 cut)
320 
321  float d0cut = sqrt(std::pow(d0cuta_, 2) + std::pow(d0cutb_ / siTrack->pt(), 2));
322  if (d0cut > maxd0cut_)
323  d0cut = maxd0cut_;
324 
325  if (fabs(d0) > d0cut)
326  return false;
327  if (nLayers(siTrack) < nLayers_)
328  return false;
329  } else {
330  //last 2 tracking iterations (tighten chi2, nhits, pt error cuts)
331 
332  if (siTrack->normalizedChi2() > maxchi2_tight_)
333  return false;
334  if (siTrack->numberOfValidHits() < minhits_tight_)
335  return false;
336  if ((siTrack->ptError() / siTrack->pt()) > maxPtErr_tight_)
337  return false;
338  if (nLayers(siTrack) < nLayersTight_)
339  return false;
340  }
341 
342  if (siTrack->numberOfValidHits() < minhits_)
343  return false;
344  if (siTrack->normalizedChi2() > maxchi2_)
345  return false;
346  if (fabs(siTrack->eta()) > maxeta_)
347  return false;
348  if (siTrack->pt() > maxpt_)
349  return false;
350  if ((siTrack->ptError() / siTrack->pt()) > maxPtErr_)
351  return false;
352  if (fabs(siTrack->eta()) > 2.5 && siTrack->pt() > maxpt_eta25_)
353  return false;
354  if (fabs(siTrack->eta()) > 2.0 && siTrack->pt() > maxpt_eta20_)
355  return false;
356 
357  int cut = 0;
358  for (unsigned int i = 0; i < trkQuality_.size(); i++) {
359  cut |= (1 << trkQuality_.at(i));
360  }
361 
362  if (!((siTrack->qualityMask() & cut) == cut))
363  return false;
364 
365  bool isGoodAlgo = false;
366  if (trkAlgos_.empty())
367  isGoodAlgo = true;
368  for (unsigned int i = 0; i < trkAlgos_.size(); i++) {
369  if (siTrack->algo() == trkAlgos_.at(i))
370  isGoodAlgo = true;
371  }
372 
373  if (!isGoodAlgo)
374  return false;
375 
376  return true;
377  }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< reco::TrackBase::TrackAlgorithm > trackAlgos_
virtual TrackRef innerTrack() const
Definition: Muon.h:45
const reco::VertexCollection * vertices_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< reco::TrackBase::TrackAlgorithm > trkAlgos_
T sqrt(T t)
Definition: SSEVec.h:19
bool isValid() const
Definition: HandleBase.h:70
math::XYZPoint Point
edm::Handle< reco::BeamSpot > beamSpot_
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
const Point & position() const
position
Definition: BeamSpot.h:59
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
bool MuonTCMETValueMapProducer::isValidVertex ( )
private

Definition at line 437 of file MuonTCMETValueMapProducer.cc.

References funct::pow(), mathSSE::sqrt(), vertexNdof_, vertexRho_, vertexZ_, and vertices_.

Referenced by produce().

437  {
438  if (vertices_->begin()->isFake())
439  return false;
440  if (vertices_->begin()->ndof() < vertexNdof_)
441  return false;
442  if (fabs(vertices_->begin()->z()) > vertexZ_)
443  return false;
444  if (sqrt(std::pow(vertices_->begin()->x(), 2) + std::pow(vertices_->begin()->y(), 2)) > vertexRho_)
445  return false;
446 
447  return true;
448  }
const reco::VertexCollection * vertices_
T sqrt(T t)
Definition: SSEVec.h:19
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
int MuonTCMETValueMapProducer::nLayers ( const reco::TrackRef  track)
private

Definition at line 431 of file MuonTCMETValueMapProducer.cc.

References AlCaHLTBitMon_ParallelJobs::p, and reco::HitPattern::trackerLayersWithMeasurement().

Referenced by isGoodTrack().

431  {
432  const reco::HitPattern& p = track->hitPattern();
433  return p.trackerLayersWithMeasurement();
434  }
int trackerLayersWithMeasurement() const
Definition: HitPattern.cc:513
void MuonTCMETValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 117 of file MuonTCMETValueMapProducer.cc.

References beamSpot_, beamSpotToken_, bField, funct::cos(), edm::helper::Filler< Map >::fill(), edm::EventSetup::get(), edm::Event::getByToken(), hasValidVertex, reco::Muon::innerTrack(), edm::helper::Filler< Map >::insert(), reco::Muon::isCaloMuon(), reco::Muon::isGlobalMuon(), isGoodCaloMuon(), isGoodMuon(), isGoodTrack(), reco::Muon::isTrackerMuon(), edm::HandleBase::isValid(), isValidVertex(), minpt_, eostools::move(), amptDefaultParameters_cff::mu, reco::MuonMETCorrectionData::MuonCandidateValuesUsed, muons_, muonToken_, jets_cff::nMuons, reco::MuonMETCorrectionData::NotUsed, edm::Handle< T >::product(), edm::ESHandle< T >::product(), propagateTrack(), edm::Event::put(), response_function, funct::sin(), reco::MuonMETCorrectionData::TreatedAsPion, useCaloMuons_, usePvtxd0_, vertexHandle_, vertexToken_, and vertices_.

117  {
118  iEvent.getByToken(muonToken_, muons_);
120 
121  hasValidVertex = false;
122  if (usePvtxd0_) {
124 
125  if (vertexHandle_.isValid()) {
128  }
129  }
130 
131  edm::ESHandle<MagneticField> theMagField;
132  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
133  bField = theMagField.product();
134 
135  auto vm_muCorrData = std::make_unique<edm::ValueMap<reco::MuonMETCorrectionData>>();
136 
137  std::vector<reco::MuonMETCorrectionData> v_muCorrData;
138 
139  unsigned int nMuons = muons_->size();
140 
141  for (unsigned int iMu = 0; iMu < nMuons; iMu++) {
142  const reco::Muon* mu = &(*muons_)[iMu];
143  double deltax = 0.0;
144  double deltay = 0.0;
145 
147 
148  reco::TrackRef mu_track;
149  if (mu->isGlobalMuon() || mu->isTrackerMuon() || mu->isCaloMuon())
150  mu_track = mu->innerTrack();
151  else {
152  v_muCorrData.push_back(muMETCorrData);
153  continue;
154  }
155 
156  // figure out depositions muons would make if they were treated as pions
157  if (isGoodTrack(mu)) {
158  if (mu_track->pt() < minpt_)
160 
161  else {
162  int bin_index = response_function->FindBin(mu_track->eta(), mu_track->pt());
163  double response = response_function->GetBinContent(bin_index);
164 
165  TVector3 outerTrkPosition = propagateTrack(mu);
166 
167  deltax = response * mu_track->p() * sin(outerTrkPosition.Theta()) * cos(outerTrkPosition.Phi());
168  deltay = response * mu_track->p() * sin(outerTrkPosition.Theta()) * sin(outerTrkPosition.Phi());
169 
171  }
172  }
173 
174  // figure out muon flag
175  if (isGoodMuon(mu))
176  v_muCorrData.push_back(
178 
179  else if (useCaloMuons_ && isGoodCaloMuon(mu, iMu))
180  v_muCorrData.push_back(
182 
183  else
184  v_muCorrData.push_back(muMETCorrData);
185  }
186 
187  edm::ValueMap<reco::MuonMETCorrectionData>::Filler dataFiller(*vm_muCorrData);
188 
189  dataFiller.insert(muons_, v_muCorrData.begin(), v_muCorrData.end());
190  dataFiller.fill();
191 
192  iEvent.put(std::move(vm_muCorrData), "muCorrData");
193  }
class TVector3 propagateTrack(const reco::Muon *)
edm::Handle< reco::VertexCollection > vertexHandle_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
virtual TrackRef innerTrack() const
Definition: Muon.h:45
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const reco::VertexCollection * vertices_
const class MagneticField * bField
bool isGoodCaloMuon(const reco::Muon *, const unsigned int)
bool isTrackerMuon() const override
Definition: Muon.h:299
bool isGlobalMuon() const override
Definition: Muon.h:298
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::Handle< reco::MuonCollection > muons_
bool isValid() const
Definition: HandleBase.h:70
T const * product() const
Definition: Handle.h:69
edm::Handle< reco::BeamSpot > beamSpot_
T get() const
Definition: EventSetup.h:73
bool isCaloMuon() const override
Definition: Muon.h:301
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< reco::MuonCollection > muonToken_
def move(src, dest)
Definition: eostools.py:511
TVector3 MuonTCMETValueMapProducer::propagateTrack ( const reco::Muon muon)
private

Definition at line 380 of file MuonTCMETValueMapProducer.cc.

References alongMomentum, Reference_intrackfit_cff::barrel, bField, Plane::build(), Cylinder::build(), distTCMET_cfi::corner, edm::Ref< C, T, F >::get(), TrajectoryStateOnSurface::globalPosition(), reco::Muon::innerTrack(), edm::Ref< C, T, F >::isNonnull(), TrajectoryStateOnSurface::isValid(), M_PI, Pi, Propagator::propagate(), CosmicsPD_Skims::radius, HLT_2018_cff::track, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and distTCMET_cfi::zdist.

Referenced by produce().

380  {
381  TVector3 outerTrkPosition;
382 
383  outerTrkPosition.SetPtEtaPhi(999., -10., 2 * TMath::Pi());
384 
385  const reco::TrackRef track = muon->innerTrack();
386 
387  if (!track.isNonnull()) {
388  return outerTrkPosition;
389  }
390 
391  GlobalPoint tpVertex(track->vx(), track->vy(), track->vz());
392  GlobalVector tpMomentum(track.get()->px(), track.get()->py(), track.get()->pz());
393  int tpCharge(track->charge());
394 
395  FreeTrajectoryState fts(tpVertex, tpMomentum, tpCharge, bField);
396 
397  const double zdist = 314.;
398 
399  const double radius = 130.;
400 
401  const double corner = 1.479;
402 
405 
408 
410 
412 
413  if (track.get()->eta() < -corner) {
414  tsos = myAP.propagate(fts, *lendcap);
415  } else if (fabs(track.get()->eta()) < corner) {
416  tsos = myAP.propagate(fts, *barrel);
417  } else if (track.get()->eta() > corner) {
418  tsos = myAP.propagate(fts, *rendcap);
419  }
420 
421  if (tsos.isValid())
422  outerTrkPosition.SetXYZ(tsos.globalPosition().x(), tsos.globalPosition().y(), tsos.globalPosition().z());
423 
424  else
425  outerTrkPosition.SetPtEtaPhi(999., -10., 2 * TMath::Pi());
426 
427  return outerTrkPosition;
428  }
const double Pi
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
virtual TrackRef innerTrack() const
Definition: Muon.h:45
T y() const
Definition: PV3DBase.h:60
GlobalPoint globalPosition() const
const class MagneticField * bField
static CylinderPointer build(const PositionType &pos, const RotationType &rot, Scalar radius, Bounds *bounds=0)
Definition: Cylinder.h:45
static PlanePointer build(Args &&...args)
Definition: Plane.h:33
T z() const
Definition: PV3DBase.h:61
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
#define M_PI
T x() const
Definition: PV3DBase.h:59

Member Data Documentation

edm::Handle<reco::BeamSpot> cms::MuonTCMETValueMapProducer::beamSpot_
private

Definition at line 49 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), isGoodTrack(), and produce().

edm::EDGetTokenT<reco::BeamSpot> cms::MuonTCMETValueMapProducer::beamSpotToken_
private

Definition at line 53 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

const class MagneticField* cms::MuonTCMETValueMapProducer::bField
private

Definition at line 56 of file MuonTCMETValueMapProducer.h.

Referenced by produce(), and propagateTrack().

double cms::MuonTCMETValueMapProducer::d0cuta_
private

Definition at line 87 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::d0cutb_
private

Definition at line 88 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

bool cms::MuonTCMETValueMapProducer::hasValidVertex
private

Definition at line 65 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and produce().

double cms::MuonTCMETValueMapProducer::maxchi2_
private

Definition at line 80 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxchi2_tight_
private

Definition at line 84 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxd0cut_
private

Definition at line 83 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxeta_
private

Definition at line 79 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxpt_
private

Definition at line 78 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxpt_eta20_
private

Definition at line 75 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxpt_eta25_
private

Definition at line 74 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxPtErr_
private

Definition at line 82 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxPtErr_tight_
private

Definition at line 86 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::minhits_
private

Definition at line 81 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::minhits_tight_
private

Definition at line 85 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::minpt_
private

Definition at line 77 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

double cms::MuonTCMETValueMapProducer::muon_dptrel_
private

Definition at line 100 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muonchi2_
private

Definition at line 96 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muond0_
private

Definition at line 98 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muonDeltaR_
private

Definition at line 99 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodCaloMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muoneta_
private

Definition at line 95 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

bool cms::MuonTCMETValueMapProducer::muonGlobal_
private

Definition at line 62 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muonhits_
private

Definition at line 97 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

int cms::MuonTCMETValueMapProducer::muonMinValidStaHits_
private

Definition at line 93 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muonpt_
private

Definition at line 94 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

edm::Handle<reco::MuonCollection> cms::MuonTCMETValueMapProducer::muons_
private

Definition at line 48 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodCaloMuon(), and produce().

edm::EDGetTokenT<reco::MuonCollection> cms::MuonTCMETValueMapProducer::muonToken_
private

Definition at line 52 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

bool cms::MuonTCMETValueMapProducer::muonTracker_
private

Definition at line 63 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

int cms::MuonTCMETValueMapProducer::nLayers_
private

Definition at line 68 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

int cms::MuonTCMETValueMapProducer::nLayersTight_
private

Definition at line 69 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

class TH2D* cms::MuonTCMETValueMapProducer::response_function
private

Definition at line 60 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

int cms::MuonTCMETValueMapProducer::rfType_
private

Definition at line 67 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer().

TCMETAlgo* cms::MuonTCMETValueMapProducer::tcmetAlgo_
private
std::vector<reco::TrackBase::TrackAlgorithm> cms::MuonTCMETValueMapProducer::trackAlgos_
private

Definition at line 76 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack().

std::vector<reco::TrackBase::TrackAlgorithm> cms::MuonTCMETValueMapProducer::trkAlgos_
private

Definition at line 91 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

std::vector<int> cms::MuonTCMETValueMapProducer::trkQuality_
private

Definition at line 90 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

bool cms::MuonTCMETValueMapProducer::useCaloMuons_
private

Definition at line 64 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

bool cms::MuonTCMETValueMapProducer::usePvtxd0_
private

Definition at line 89 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

edm::Handle<reco::VertexCollection> cms::MuonTCMETValueMapProducer::vertexHandle_
private

Definition at line 50 of file MuonTCMETValueMapProducer.h.

Referenced by produce().

double cms::MuonTCMETValueMapProducer::vertexMaxDZ_
private

Definition at line 73 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

int cms::MuonTCMETValueMapProducer::vertexNdof_
private

Definition at line 70 of file MuonTCMETValueMapProducer.h.

Referenced by isValidVertex(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::vertexRho_
private

Definition at line 72 of file MuonTCMETValueMapProducer.h.

Referenced by isValidVertex(), and MuonTCMETValueMapProducer().

edm::EDGetTokenT<reco::VertexCollection> cms::MuonTCMETValueMapProducer::vertexToken_
private

Definition at line 54 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

double cms::MuonTCMETValueMapProducer::vertexZ_
private

Definition at line 71 of file MuonTCMETValueMapProducer.h.

Referenced by isValidVertex(), and MuonTCMETValueMapProducer().

const reco::VertexCollection* cms::MuonTCMETValueMapProducer::vertices_
private

Definition at line 58 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), isValidVertex(), and produce().