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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuonTCMETValueMapProducer (const edm::ParameterSet &)
 
 ~MuonTCMETValueMapProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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)
 
virtual 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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 41 of file MuonTCMETValueMapProducer.h.

Constructor & Destructor Documentation

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

Definition at line 50 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_, create_public_lumi_plots::transform, trkAlgos_, trkQuality_, useCaloMuons_, usePvtxd0_, vertexMaxDZ_, vertexNdof_, vertexRho_, vertexToken_, and vertexZ_.

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

Definition at line 117 of file MuonTCMETValueMapProducer.cc.

References tcmetAlgo_.

118 {
119  delete tcmetAlgo_;
120 }

Member Function Documentation

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

Definition at line 241 of file MuonTCMETValueMapProducer.cc.

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

Referenced by produce().

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

Definition at line 202 of file MuonTCMETValueMapProducer.cc.

References beamSpot_, HiEvtPlane_cfi::chi2, allConversions_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().

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

Definition at line 274 of file MuonTCMETValueMapProducer.cc.

References beamSpot_, TkAlMuonSelectors_cfi::cut, allConversions_cfi::d0, d0cuta_, d0cutb_, allConversions_cfi::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().

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

Definition at line 436 of file MuonTCMETValueMapProducer.cc.

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

Referenced by produce().

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

Definition at line 429 of file MuonTCMETValueMapProducer.cc.

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

Referenced by isGoodTrack().

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

Definition at line 123 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(), RPCpg::mu, reco::MuonMETCorrectionData::MuonCandidateValuesUsed, muons_, muonToken_, 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_.

124 {
125  iEvent.getByToken(muonToken_ , muons_);
127 
128  hasValidVertex = false;
129  if( usePvtxd0_ ){
131 
132  if( vertexHandle_.isValid() ) {
135  }
136  }
137 
138  edm::ESHandle<MagneticField> theMagField;
139  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
140  bField = theMagField.product();
141 
142  auto vm_muCorrData = std::make_unique<edm::ValueMap<reco::MuonMETCorrectionData>>();
143 
144  std::vector<reco::MuonMETCorrectionData> v_muCorrData;
145 
146  unsigned int nMuons = muons_->size();
147 
148  for (unsigned int iMu = 0; iMu < nMuons; iMu++) {
149 
150  const reco::Muon* mu = &(*muons_)[iMu];
151  double deltax = 0.0;
152  double deltay = 0.0;
153 
155 
156  reco::TrackRef mu_track;
157  if( mu->isGlobalMuon() || mu->isTrackerMuon() || mu->isCaloMuon() )
158  mu_track = mu->innerTrack();
159  else {
160  v_muCorrData.push_back( muMETCorrData );
161  continue;
162  }
163 
164  // figure out depositions muons would make if they were treated as pions
165  if( isGoodTrack( mu ) ) {
166 
167  if( mu_track->pt() < minpt_ )
169 
170  else {
171  int bin_index = response_function->FindBin( mu_track->eta(), mu_track->pt() );
172  double response = response_function->GetBinContent( bin_index );
173 
174  TVector3 outerTrkPosition = propagateTrack( mu );
175 
176  deltax = response * mu_track->p() * sin( outerTrkPosition.Theta() ) * cos( outerTrkPosition.Phi() );
177  deltay = response * mu_track->p() * sin( outerTrkPosition.Theta() ) * sin( outerTrkPosition.Phi() );
178 
180  }
181  }
182 
183  // figure out muon flag
184  if( isGoodMuon( mu ) )
186 
187  else if( useCaloMuons_ && isGoodCaloMuon( mu, iMu ) )
189 
190  else v_muCorrData.push_back( muMETCorrData );
191  }
192 
193  edm::ValueMap<reco::MuonMETCorrectionData>::Filler dataFiller(*vm_muCorrData);
194 
195  dataFiller.insert( muons_, v_muCorrData.begin(), v_muCorrData.end());
196  dataFiller.fill();
197 
198  iEvent.put(std::move(vm_muCorrData), "muCorrData");
199 }
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:122
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
bool isTrackerMuon() const
Definition: Muon.h:226
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
const reco::VertexCollection * vertices_
bool isGlobalMuon() const
Definition: Muon.h:225
const class MagneticField * bField
bool isGoodCaloMuon(const reco::Muon *, const unsigned int)
bool isCaloMuon() const
Definition: Muon.h:228
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::Handle< reco::MuonCollection > muons_
const int mu
Definition: Constants.h:22
bool isValid() const
Definition: HandleBase.h:74
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
edm::Handle< reco::BeamSpot > beamSpot_
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< reco::MuonCollection > muonToken_
def move(src, dest)
Definition: eostools.py:510
TVector3 MuonTCMETValueMapProducer::propagateTrack ( const reco::Muon muon)
private

Definition at line 370 of file MuonTCMETValueMapProducer.cc.

References alongMomentum, Reference_intrackfit_cff::barrel, bField, Plane::build(), Cylinder::build(), TCMET_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(), TCMET_cfi::radius, HiIsolationCommonParameters_cff::track, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and TCMET_cfi::zdist.

Referenced by produce().

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

Member Data Documentation

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

Definition at line 53 of file MuonTCMETValueMapProducer.h.

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

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

Definition at line 57 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

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

Definition at line 60 of file MuonTCMETValueMapProducer.h.

Referenced by produce(), and propagateTrack().

double cms::MuonTCMETValueMapProducer::d0cuta_
private

Definition at line 91 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::d0cutb_
private

Definition at line 92 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

bool cms::MuonTCMETValueMapProducer::hasValidVertex
private

Definition at line 69 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and produce().

double cms::MuonTCMETValueMapProducer::maxchi2_
private

Definition at line 84 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxchi2_tight_
private

Definition at line 88 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxd0cut_
private

Definition at line 87 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxeta_
private

Definition at line 83 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxpt_
private

Definition at line 82 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxpt_eta20_
private

Definition at line 79 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxpt_eta25_
private

Definition at line 78 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxPtErr_
private

Definition at line 86 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::maxPtErr_tight_
private

Definition at line 90 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::minhits_
private

Definition at line 85 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::minhits_tight_
private

Definition at line 89 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::minpt_
private

Definition at line 81 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

double cms::MuonTCMETValueMapProducer::muon_dptrel_
private

Definition at line 104 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muonchi2_
private

Definition at line 100 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muond0_
private

Definition at line 102 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muonDeltaR_
private

Definition at line 103 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodCaloMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muoneta_
private

Definition at line 99 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

bool cms::MuonTCMETValueMapProducer::muonGlobal_
private

Definition at line 66 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muonhits_
private

Definition at line 101 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

int cms::MuonTCMETValueMapProducer::muonMinValidStaHits_
private

Definition at line 97 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::muonpt_
private

Definition at line 98 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

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

Definition at line 52 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodCaloMuon(), and produce().

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

Definition at line 56 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

bool cms::MuonTCMETValueMapProducer::muonTracker_
private

Definition at line 67 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodMuon(), and MuonTCMETValueMapProducer().

int cms::MuonTCMETValueMapProducer::nLayers_
private

Definition at line 72 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

int cms::MuonTCMETValueMapProducer::nLayersTight_
private

Definition at line 73 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

class TH2D* cms::MuonTCMETValueMapProducer::response_function
private

Definition at line 64 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

int cms::MuonTCMETValueMapProducer::rfType_
private

Definition at line 71 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer().

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

Definition at line 80 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack().

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

Definition at line 95 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

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

Definition at line 94 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

bool cms::MuonTCMETValueMapProducer::useCaloMuons_
private

Definition at line 68 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

bool cms::MuonTCMETValueMapProducer::usePvtxd0_
private

Definition at line 93 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

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

Definition at line 54 of file MuonTCMETValueMapProducer.h.

Referenced by produce().

double cms::MuonTCMETValueMapProducer::vertexMaxDZ_
private

Definition at line 77 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodTrack(), and MuonTCMETValueMapProducer().

int cms::MuonTCMETValueMapProducer::vertexNdof_
private

Definition at line 74 of file MuonTCMETValueMapProducer.h.

Referenced by isValidVertex(), and MuonTCMETValueMapProducer().

double cms::MuonTCMETValueMapProducer::vertexRho_
private

Definition at line 76 of file MuonTCMETValueMapProducer.h.

Referenced by isValidVertex(), and MuonTCMETValueMapProducer().

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

Definition at line 58 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

double cms::MuonTCMETValueMapProducer::vertexZ_
private

Definition at line 75 of file MuonTCMETValueMapProducer.h.

Referenced by isValidVertex(), and MuonTCMETValueMapProducer().

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

Definition at line 62 of file MuonTCMETValueMapProducer.h.

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