CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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_
 
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_
 
int maxTrackAlgo_
 
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::MuonCollection
muonToken_
 
bool muonTracker_
 
int nLayers_
 
int nLayersTight_
 
class TH2D * response_function
 
int rfType_
 
TCMETAlgotcmetAlgo_
 
std::vector< int > trkAlgos_
 
std::vector< int > trkQuality_
 
bool useCaloMuons_
 
bool usePvtxd0_
 
edm::Handle
< reco::VertexCollection
vertexHandle_
 
double vertexMaxDZ_
 
int vertexNdof_
 
double vertexRho_
 
edm::EDGetTokenT
< reco::VertexCollection
vertexToken_
 
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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 48 of file MuonTCMETValueMapProducer.cc.

References 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_, maxTrackAlgo_, minhits_, minhits_tight_, minpt_, muon_dptrel_, muonchi2_, muond0_, muonDeltaR_, muoneta_, muonGlobal_, muonhits_, muonMinValidStaHits_, muonpt_, muonToken_, muonTracker_, nLayers_, nLayersTight_, response_function, rfType_, tcmetAlgo_, 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  maxTrackAlgo_ = iConfig.getParameter<int>("trackAlgo_max");
65  maxd0cut_ = iConfig.getParameter<double>("d0_max" );
66  minpt_ = iConfig.getParameter<double>("pt_min" );
67  maxpt_ = iConfig.getParameter<double>("pt_max" );
68  maxeta_ = iConfig.getParameter<double>("eta_max" );
69  maxchi2_ = iConfig.getParameter<double>("chi2_max" );
70  minhits_ = iConfig.getParameter<double>("nhits_min" );
71  maxPtErr_ = iConfig.getParameter<double>("ptErr_max" );
72 
73  trkQuality_ = iConfig.getParameter<std::vector<int> >("track_quality");
74  trkAlgos_ = iConfig.getParameter<std::vector<int> >("track_algos" );
75  maxchi2_tight_ = iConfig.getParameter<double>("chi2_max_tight");
76  minhits_tight_ = iConfig.getParameter<double>("nhits_min_tight");
77  maxPtErr_tight_ = iConfig.getParameter<double>("ptErr_max_tight");
78  usePvtxd0_ = iConfig.getParameter<bool>("usePvtxd0");
79  d0cuta_ = iConfig.getParameter<double>("d0cuta");
80  d0cutb_ = iConfig.getParameter<double>("d0cutb");
81 
82  muon_dptrel_ = iConfig.getParameter<double>("muon_dptrel");
83  muond0_ = iConfig.getParameter<double>("d0_muon" );
84  muonpt_ = iConfig.getParameter<double>("pt_muon" );
85  muoneta_ = iConfig.getParameter<double>("eta_muon" );
86  muonchi2_ = iConfig.getParameter<double>("chi2_muon" );
87  muonhits_ = iConfig.getParameter<double>("nhits_muon" );
88  muonGlobal_ = iConfig.getParameter<bool>("global_muon");
89  muonTracker_ = iConfig.getParameter<bool>("tracker_muon");
90  muonDeltaR_ = iConfig.getParameter<double>("deltaR_muon");
91  useCaloMuons_ = iConfig.getParameter<bool>("useCaloMuons");
92  muonMinValidStaHits_ = iConfig.getParameter<int>("muonMinValidStaHits");
93 
95  tcmetAlgo_=new TCMETAlgo();
96 
97  if( rfType_ == 1 )
98  response_function = tcmetAlgo_->getResponseFunction_fit();
99  else if( rfType_ == 2 )
100  response_function = tcmetAlgo_->getResponseFunction_mode();
101 
102  muonToken_ = consumes<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("muonInputTag"));
103  beamSpotToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotInputTag"));
104  vertexToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexInputTag"));
105 
106 }
T getParameter(std::string const &) const
TH2D * getResponseFunction_fit()
Definition: TCMETAlgo.cc:3582
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
TH2D * getResponseFunction_mode()
Definition: TCMETAlgo.cc:5058
edm::EDGetTokenT< reco::MuonCollection > muonToken_
MuonTCMETValueMapProducer::~MuonTCMETValueMapProducer ( )

Definition at line 109 of file MuonTCMETValueMapProducer.cc.

References tcmetAlgo_.

110 {
111  delete tcmetAlgo_;
112 }

Member Function Documentation

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

Definition at line 233 of file MuonTCMETValueMapProducer.cc.

References funct::cos(), HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_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().

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

Definition at line 194 of file MuonTCMETValueMapProducer.cc.

References beamSpot_, reco::LeafCandidate::eta(), reco::Muon::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_, and reco::LeafCandidate::pt().

Referenced by produce().

195 {
196  double d0 = -999;
197  double nhits = 0;
198  double chi2 = 999;
199 
200  // get d0 corrected for beam spot
201  bool haveBeamSpot = true;
202  if( !beamSpot_.isValid() ) haveBeamSpot = false;
203 
204  if( muonGlobal_ && !muon->isGlobalMuon() ) return false;
205  if( muonTracker_ && !muon->isTrackerMuon() ) return false;
206 
207  const reco::TrackRef siTrack = muon->innerTrack();
208  const reco::TrackRef globalTrack = muon->globalTrack();
209 
210  Point bspot = haveBeamSpot ? beamSpot_->position() : Point(0,0,0);
211  if( siTrack.isNonnull() ) nhits = siTrack->numberOfValidHits();
212  if( globalTrack.isNonnull() )
213  {
214  d0 = -1 * globalTrack->dxy( bspot );
215  chi2 = globalTrack->normalizedChi2();
216  }
217 
218  if( fabs( d0 ) > muond0_ ) return false;
219  if( muon->pt() < muonpt_ ) return false;
220  if( fabs( muon->eta() ) > muoneta_ ) return false;
221  if( nhits < muonhits_ ) return false;
222  if( chi2 > muonchi2_ ) return false;
223  if( globalTrack->hitPattern().numberOfValidMuonHits() < muonMinValidStaHits_ ) return false;
224 
225  //reject muons with tracker dpt/pt > X
226  if( !siTrack.isNonnull() ) return false;
227  if( siTrack->ptError() / siTrack->pt() > muon_dptrel_ ) return false;
228 
229  else return true;
230 }
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool isTrackerMuon() const
Definition: Muon.h:219
bool isGlobalMuon() const
Definition: Muon.h:218
std::pair< double, double > Point
Definition: CaloEllipse.h:18
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
math::XYZPoint Point
bool isValid() const
Definition: HandleBase.h:76
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
edm::Handle< reco::BeamSpot > beamSpot_
virtual float pt() const GCC11_FINAL
transverse momentum
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 266 of file MuonTCMETValueMapProducer.cc.

References beamSpot_, GOODCOLL_filter_cfg::cut, d0cuta_, d0cutb_, hasValidVertex, 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_, maxTrackAlgo_, minhits_, minhits_tight_, nLayers(), nLayers_, nLayersTight_, funct::pow(), mathSSE::sqrt(), trkAlgos_, trkQuality_, vertexMaxDZ_, and vertices_.

Referenced by isGoodCaloMuon(), and produce().

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

Definition at line 428 of file MuonTCMETValueMapProducer.cc.

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

Referenced by produce().

429 {
430  if( vertices_->begin()->isFake() ) return false;
431  if( vertices_->begin()->ndof() < vertexNdof_ ) return false;
432  if( fabs( vertices_->begin()->z() ) > vertexZ_ ) return false;
433  if( sqrt( std::pow( vertices_->begin()->x() , 2 ) + std::pow( vertices_->begin()->y() , 2 ) ) > vertexRho_ ) return false;
434 
435  return true;
436 
437 }
const reco::VertexCollection * vertices_
T sqrt(T t)
Definition: SSEVec.h:48
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 421 of file MuonTCMETValueMapProducer.cc.

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

Referenced by isGoodTrack().

422 {
423  const reco::HitPattern& p = track->hitPattern();
424  return p.trackerLayersWithMeasurement();
425 }
int trackerLayersWithMeasurement() const
Definition: HitPattern.h:740
void MuonTCMETValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 115 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_, RPCpg::mu, reco::MuonMETCorrectionData::MuonCandidateValuesUsed, muons_, muonToken_, reco::MuonMETCorrectionData::NotUsed, edm::Handle< T >::product(), edm::ESHandle< class >::product(), propagateTrack(), edm::Event::put(), response_function, funct::sin(), reco::MuonMETCorrectionData::TreatedAsPion, useCaloMuons_, usePvtxd0_, vertexHandle_, vertexToken_, and vertices_.

116 {
117  iEvent.getByToken(muonToken_ , muons_);
119 
120  hasValidVertex = false;
121  if( usePvtxd0_ ){
123 
124  if( vertexHandle_.isValid() ) {
127  }
128  }
129 
130  edm::ESHandle<MagneticField> theMagField;
131  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
132  bField = theMagField.product();
133 
134  std::auto_ptr<edm::ValueMap<reco::MuonMETCorrectionData> > vm_muCorrData(new edm::ValueMap<reco::MuonMETCorrectionData>());
135 
136  std::vector<reco::MuonMETCorrectionData> v_muCorrData;
137 
138  unsigned int nMuons = muons_->size();
139 
140  for (unsigned int iMu = 0; iMu < nMuons; iMu++) {
141 
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 
159  if( mu_track->pt() < minpt_ )
161 
162  else {
163  int bin_index = response_function->FindBin( mu_track->eta(), mu_track->pt() );
164  double response = response_function->GetBinContent( bin_index );
165 
166  TVector3 outerTrkPosition = propagateTrack( mu );
167 
168  deltax = response * mu_track->p() * sin( outerTrkPosition.Theta() ) * cos( outerTrkPosition.Phi() );
169  deltay = response * mu_track->p() * sin( outerTrkPosition.Theta() ) * sin( outerTrkPosition.Phi() );
170 
172  }
173  }
174 
175  // figure out muon flag
176  if( isGoodMuon( mu ) )
178 
179  else if( useCaloMuons_ && isGoodCaloMuon( mu, iMu ) )
181 
182  else v_muCorrData.push_back( muMETCorrData );
183  }
184 
185  edm::ValueMap<reco::MuonMETCorrectionData>::Filler dataFiller(*vm_muCorrData);
186 
187  dataFiller.insert( muons_, v_muCorrData.begin(), v_muCorrData.end());
188  dataFiller.fill();
189 
190  iEvent.put(vm_muCorrData, "muCorrData");
191 }
class TVector3 propagateTrack(const reco::Muon *)
edm::Handle< reco::VertexCollection > vertexHandle_
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
bool isTrackerMuon() const
Definition: Muon.h:219
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:218
bool isGoodCaloMuon(const reco::Muon *, const unsigned int)
bool isCaloMuon() const
Definition: Muon.h:221
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
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:76
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:81
edm::Handle< reco::BeamSpot > beamSpot_
edm::EDGetTokenT< reco::MuonCollection > muonToken_
TVector3 MuonTCMETValueMapProducer::propagateTrack ( const reco::Muon muon)
private

Definition at line 362 of file MuonTCMETValueMapProducer.cc.

References alongMomentum, AnalyticalPropagator_cfi::AnalyticalPropagator, Reference_intrackfit_cff::barrel, bField, Plane::build(), newFWLiteAna::build, edm::Ref< C, T, F >::get(), TrajectoryStateOnSurface::globalPosition(), reco::Muon::innerTrack(), edm::Ref< C, T, F >::isNonnull(), TrajectoryStateOnSurface::isValid(), M_PI, Pi, CosmicsPD_Skims::radius, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

363 {
364 
365  TVector3 outerTrkPosition;
366 
367  outerTrkPosition.SetPtEtaPhi( 999., -10., 2 * TMath::Pi() );
368 
369  const reco::TrackRef track = muon->innerTrack();
370 
371  if( !track.isNonnull() )
372  {
373  return outerTrkPosition;
374  }
375 
376  GlobalPoint tpVertex ( track->vx(), track->vy(), track->vz() );
377  GlobalVector tpMomentum ( track.get()->px(), track.get()->py(), track.get()->pz() );
378  int tpCharge ( track->charge() );
379 
380  FreeTrajectoryState fts ( tpVertex, tpMomentum, tpCharge, bField);
381 
382  const double zdist = 314.;
383 
384  const double radius = 130.;
385 
386  const double corner = 1.479;
387 
390 
391  Cylinder::CylinderPointer barrel = Cylinder::build( Cylinder::PositionType (0, 0, 0), Cylinder::RotationType (), radius);
392 
394 
396 
397  if( track.get()->eta() < -corner )
398  {
399  tsos = myAP.propagate( fts, *lendcap);
400  }
401  else if( fabs(track.get()->eta()) < corner )
402  {
403  tsos = myAP.propagate( fts, *barrel);
404  }
405  else if( track.get()->eta() > corner )
406  {
407  tsos = myAP.propagate( fts, *rendcap);
408  }
409 
410  if( tsos.isValid() )
411  outerTrkPosition.SetXYZ( tsos.globalPosition().x(), tsos.globalPosition().y(), tsos.globalPosition().z() );
412 
413  else
414  outerTrkPosition.SetPtEtaPhi( 999., -10., 2 * TMath::Pi() );
415 
416  return outerTrkPosition;
417 }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
const double Pi
virtual TrackRef innerTrack() const
Definition: Muon.h:48
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:30
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
static PlanePointer build(Args &&...args)
Definition: Plane.h:36
T z() const
Definition: PV3DBase.h:64
#define M_PI
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
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().

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().

int cms::MuonTCMETValueMapProducer::maxTrackAlgo_
private

Definition at line 80 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<int> 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().