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

Public Member Functions

 MuonTCMETValueMapProducer (const edm::ParameterSet &)
 
 ~MuonTCMETValueMapProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- 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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
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 &)
 
class TVector3 propagateTrack (const reco::Muon *)
 

Private Attributes

edm::Handle< reco::BeamSpotbeamSpot_h
 
edm::InputTag beamSpotInputTag_
 
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_
 
edm::Handle< reco::MuonCollectionmuon_h
 
double muonchi2_
 
double muond0_
 
double muonDeltaR_
 
double muoneta_
 
bool muonGlobal_
 
double muonhits_
 
edm::InputTag muonInputTag_
 
int muonMinValidStaHits_
 
double muonpt_
 
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_
 
const reco::VertexCollectionvertexColl
 
edm::Handle
< reco::VertexCollection
VertexHandle
 
edm::InputTag vertexInputTag_
 
double vertexMaxDZ_
 
int vertexNdof_
 
double vertexRho_
 
double vertexZ_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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 38 of file MuonTCMETValueMapProducer.h.

Constructor & Destructor Documentation

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

Definition at line 58 of file MuonTCMETValueMapProducer.cc.

References beamSpotInputTag_, d0cuta_, d0cutb_, edm::ParameterSet::getParameter(), 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_, muonInputTag_, muonMinValidStaHits_, muonpt_, muonTracker_, nLayers_, nLayersTight_, response_function, rfType_, tcmetAlgo_, trkAlgos_, trkQuality_, useCaloMuons_, usePvtxd0_, vertexInputTag_, vertexMaxDZ_, vertexNdof_, vertexRho_, and vertexZ_.

58  {
59 
60  produces<edm::ValueMap<reco::MuonMETCorrectionData> > ("muCorrData");
61 
62  // get input collections
63  muonInputTag_ = iConfig.getParameter<edm::InputTag>("muonInputTag" );
64  beamSpotInputTag_ = iConfig.getParameter<edm::InputTag>("beamSpotInputTag");
65  vertexInputTag_ = iConfig.getParameter<edm::InputTag>("vertexInputTag");
66 
67  rfType_ = iConfig.getParameter<int>("rf_type");
68 
69  nLayers_ = iConfig.getParameter<int> ("nLayers");
70  nLayersTight_ = iConfig.getParameter<int> ("nLayersTight");
71  vertexNdof_ = iConfig.getParameter<int> ("vertexNdof");
72  vertexZ_ = iConfig.getParameter<double> ("vertexZ");
73  vertexRho_ = iConfig.getParameter<double> ("vertexRho");
74  vertexMaxDZ_ = iConfig.getParameter<double> ("vertexMaxDZ");
75  maxpt_eta20_ = iConfig.getParameter<double> ("maxpt_eta20");
76  maxpt_eta25_ = iConfig.getParameter<double> ("maxpt_eta25");
77 
78  // get configuration parameters
79  maxTrackAlgo_ = iConfig.getParameter<int>("trackAlgo_max");
80  maxd0cut_ = iConfig.getParameter<double>("d0_max" );
81  minpt_ = iConfig.getParameter<double>("pt_min" );
82  maxpt_ = iConfig.getParameter<double>("pt_max" );
83  maxeta_ = iConfig.getParameter<double>("eta_max" );
84  maxchi2_ = iConfig.getParameter<double>("chi2_max" );
85  minhits_ = iConfig.getParameter<double>("nhits_min" );
86  maxPtErr_ = iConfig.getParameter<double>("ptErr_max" );
87 
88  trkQuality_ = iConfig.getParameter<std::vector<int> >("track_quality");
89  trkAlgos_ = iConfig.getParameter<std::vector<int> >("track_algos" );
90  maxchi2_tight_ = iConfig.getParameter<double>("chi2_max_tight");
91  minhits_tight_ = iConfig.getParameter<double>("nhits_min_tight");
92  maxPtErr_tight_ = iConfig.getParameter<double>("ptErr_max_tight");
93  usePvtxd0_ = iConfig.getParameter<bool>("usePvtxd0");
94  d0cuta_ = iConfig.getParameter<double>("d0cuta");
95  d0cutb_ = iConfig.getParameter<double>("d0cutb");
96 
97  muon_dptrel_ = iConfig.getParameter<double>("muon_dptrel");
98  muond0_ = iConfig.getParameter<double>("d0_muon" );
99  muonpt_ = iConfig.getParameter<double>("pt_muon" );
100  muoneta_ = iConfig.getParameter<double>("eta_muon" );
101  muonchi2_ = iConfig.getParameter<double>("chi2_muon" );
102  muonhits_ = iConfig.getParameter<double>("nhits_muon" );
103  muonGlobal_ = iConfig.getParameter<bool>("global_muon");
104  muonTracker_ = iConfig.getParameter<bool>("tracker_muon");
105  muonDeltaR_ = iConfig.getParameter<double>("deltaR_muon");
106  useCaloMuons_ = iConfig.getParameter<bool>("useCaloMuons");
107  muonMinValidStaHits_ = iConfig.getParameter<int>("muonMinValidStaHits");
108 
109  response_function = 0;
110  tcmetAlgo_=new TCMETAlgo();
111  }
T getParameter(std::string const &) const
MuonTCMETValueMapProducer::~MuonTCMETValueMapProducer ( )

Definition at line 113 of file MuonTCMETValueMapProducer.cc.

References tcmetAlgo_.

114  {
115 
116  // do anything here that needs to be done at desctruction time
117  // (e.g. close files, deallocate resources etc.)
118  delete tcmetAlgo_;
119  }

Member Function Documentation

void MuonTCMETValueMapProducer::beginJob ( void  )
privatevirtual
void MuonTCMETValueMapProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 230 of file MuonTCMETValueMapProducer.cc.

230  {
231  }
bool MuonTCMETValueMapProducer::isGoodCaloMuon ( const reco::Muon muon,
const unsigned int  index 
)
private

Definition at line 271 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, muon_h, muonDeltaR_, and reco::LeafCandidate::pt().

Referenced by produce().

271  {
272 
273  if( muon->pt() < 10 ) return false;
274 
275  if( !isGoodTrack( muon ) ) return false;
276 
277  const reco::TrackRef inputSiliconTrack = muon->innerTrack();
278  if( !inputSiliconTrack.isNonnull() ) return false;
279 
280  //check if it is in the vicinity of a global or tracker muon
281  unsigned int nMuons = muon_h->size();
282  for (unsigned int iMu = 0; iMu < nMuons; iMu++) {
283 
284  if( iMu == index ) continue;
285 
286  const reco::Muon* mu = &(*muon_h)[iMu];
287 
288  const reco::TrackRef testSiliconTrack = mu->innerTrack();
289  if( !testSiliconTrack.isNonnull() ) continue;
290 
291  double deltaEta = inputSiliconTrack.get()->eta() - testSiliconTrack.get()->eta();
292  double deltaPhi = acos( cos( inputSiliconTrack.get()->phi() - testSiliconTrack.get()->phi() ) );
293  double deltaR = TMath::Sqrt( deltaEta * deltaEta + deltaPhi * deltaPhi );
294 
295  if( deltaR < muonDeltaR_ ) return false;
296  }
297 
298  return true;
299  }
virtual TrackRef innerTrack() const
Definition: Muon.h:49
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 > muon_h
const int mu
Definition: Constants.h:23
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 234 of file MuonTCMETValueMapProducer.cc.

References beamSpot_h, 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().

234  {
235  double d0 = -999;
236  double nhits = 0;
237  double chi2 = 999;
238 
239  // get d0 corrected for beam spot
240  bool haveBeamSpot = true;
241  if( !beamSpot_h.isValid() ) haveBeamSpot = false;
242 
243  if( muonGlobal_ && !muon->isGlobalMuon() ) return false;
244  if( muonTracker_ && !muon->isTrackerMuon() ) return false;
245 
246  const reco::TrackRef siTrack = muon->innerTrack();
247  const reco::TrackRef globalTrack = muon->globalTrack();
248 
249  Point bspot = haveBeamSpot ? beamSpot_h->position() : Point(0,0,0);
250  if( siTrack.isNonnull() ) nhits = siTrack->numberOfValidHits();
251  if( globalTrack.isNonnull() ) {
252  d0 = -1 * globalTrack->dxy( bspot );
253  chi2 = globalTrack->normalizedChi2();
254  }
255 
256  if( fabs( d0 ) > muond0_ ) return false;
257  if( muon->pt() < muonpt_ ) return false;
258  if( fabs( muon->eta() ) > muoneta_ ) return false;
259  if( nhits < muonhits_ ) return false;
260  if( chi2 > muonchi2_ ) return false;
261  if( globalTrack->hitPattern().numberOfValidMuonHits() < muonMinValidStaHits_ ) return false;
262 
263  //reject muons with tracker dpt/pt > X
264  if( !siTrack.isNonnull() ) return false;
265  if( siTrack->ptError() / siTrack->pt() > muon_dptrel_ ) return false;
266 
267  else return true;
268  }
virtual TrackRef innerTrack() const
Definition: Muon.h:49
bool isTrackerMuon() const
Definition: Muon.h:220
bool isGlobalMuon() const
Definition: Muon.h:219
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_h
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:55
bool MuonTCMETValueMapProducer::isGoodTrack ( const reco::Muon muon)
private

Definition at line 302 of file MuonTCMETValueMapProducer.cc.

References beamSpot_h, 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_, vertexColl, and vertexMaxDZ_.

Referenced by isGoodCaloMuon(), and produce().

302  {
303  double d0 = -999;
304 
305  const reco::TrackRef siTrack = muon->innerTrack();
306  if (!siTrack.isNonnull())
307  return false;
308 
309  if( hasValidVertex ){
310  //get d0 corrected for primary vertex
311 
312  const Point pvtx = Point(vertexColl->begin()->x(),
313  vertexColl->begin()->y(),
314  vertexColl->begin()->z());
315 
316  d0 = -1 * siTrack->dxy( pvtx );
317 
318  double dz = siTrack->dz( pvtx );
319 
320  if( fabs( dz ) < vertexMaxDZ_ ){
321 
322  //get d0 corrected for pvtx
323  d0 = -1 * siTrack->dxy( pvtx );
324 
325  }else{
326 
327  // get d0 corrected for beam spot
328  bool haveBeamSpot = true;
329  if( !beamSpot_h.isValid() ) haveBeamSpot = false;
330 
331  Point bspot = haveBeamSpot ? beamSpot_h->position() : Point(0,0,0);
332  d0 = -1 * siTrack->dxy( bspot );
333 
334  }
335  }else{
336 
337  // get d0 corrected for beam spot
338  bool haveBeamSpot = true;
339  if( !beamSpot_h.isValid() ) haveBeamSpot = false;
340 
341  Point bspot = haveBeamSpot ? beamSpot_h->position() : Point(0,0,0);
342  d0 = -1 * siTrack->dxy( bspot );
343  }
344 
345  if( siTrack->algo() < maxTrackAlgo_ ){
346  //1st 4 tracking iterations (pT-dependent d0 cut)
347 
348  float d0cut = sqrt(std::pow(d0cuta_,2) + std::pow(d0cutb_/siTrack->pt(),2));
349  if(d0cut > maxd0cut_) d0cut = maxd0cut_;
350 
351  if( fabs( d0 ) > d0cut ) return false;
352  if( nLayers( siTrack ) < nLayers_ ) return false;
353  }
354  else{
355  //last 2 tracking iterations (tighten chi2, nhits, pt error cuts)
356 
357  if( siTrack->normalizedChi2() > maxchi2_tight_ ) return false;
358  if( siTrack->numberOfValidHits() < minhits_tight_ ) return false;
359  if( (siTrack->ptError() / siTrack->pt()) > maxPtErr_tight_ ) return false;
360  if( nLayers( siTrack ) < nLayersTight_ ) return false;
361  }
362 
363  if( siTrack->numberOfValidHits() < minhits_ ) return false;
364  if( siTrack->normalizedChi2() > maxchi2_ ) return false;
365  if( fabs( siTrack->eta() ) > maxeta_ ) return false;
366  if( siTrack->pt() > maxpt_ ) return false;
367  if( (siTrack->ptError() / siTrack->pt()) > maxPtErr_ ) return false;
368  if( fabs( siTrack->eta() ) > 2.5 && siTrack->pt() > maxpt_eta25_ ) return false;
369  if( fabs( siTrack->eta() ) > 2.0 && siTrack->pt() > maxpt_eta20_ ) return false;
370 
371  int cut = 0;
372  for( unsigned int i = 0; i < trkQuality_.size(); i++ ) {
373 
374  cut |= (1 << trkQuality_.at(i));
375  }
376 
377  if( !( (siTrack->qualityMask() & cut) == cut ) ) return false;
378 
379  bool isGoodAlgo = false;
380  if( trkAlgos_.size() == 0 ) isGoodAlgo = true;
381  for( unsigned int i = 0; i < trkAlgos_.size(); i++ ) {
382 
383  if( siTrack->algo() == trkAlgos_.at(i) ) isGoodAlgo = true;
384  }
385 
386  if( !isGoodAlgo ) return false;
387 
388  return true;
389  }
int i
Definition: DBlmapReader.cc:9
const reco::VertexCollection * vertexColl
virtual TrackRef innerTrack() const
Definition: Muon.h:49
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_h
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
bool MuonTCMETValueMapProducer::isValidVertex ( )
private

Definition at line 453 of file MuonTCMETValueMapProducer.cc.

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

Referenced by produce().

453  {
454 
455  if( vertexColl->begin()->isFake() ) return false;
456  if( vertexColl->begin()->ndof() < vertexNdof_ ) return false;
457  if( fabs( vertexColl->begin()->z() ) > vertexZ_ ) return false;
458  if( sqrt( std::pow( vertexColl->begin()->x() , 2 ) + std::pow( vertexColl->begin()->y() , 2 ) ) > vertexRho_ ) return false;
459 
460  return true;
461 
462  }
const reco::VertexCollection * vertexColl
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 446 of file MuonTCMETValueMapProducer.cc.

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

Referenced by isGoodTrack().

446  {
447  const reco::HitPattern& p = track->hitPattern();
448  return p.trackerLayersWithMeasurement();
449  }
int trackerLayersWithMeasurement() const
Definition: HitPattern.h:721
void MuonTCMETValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 126 of file MuonTCMETValueMapProducer.cc.

References beamSpot_h, beamSpotInputTag_, bField, funct::cos(), edm::helper::Filler< Map >::fill(), edm::EventSetup::get(), edm::Event::getByLabel(), 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, muon_h, reco::MuonMETCorrectionData::MuonCandidateValuesUsed, muonInputTag_, reco::MuonMETCorrectionData::NotUsed, edm::Handle< T >::product(), edm::ESHandle< class >::product(), propagateTrack(), edm::Event::put(), response_function, funct::sin(), reco::MuonMETCorrectionData::TreatedAsPion, useCaloMuons_, usePvtxd0_, vertexColl, VertexHandle, and vertexInputTag_.

126  {
127 
128  //get input collections
129  iEvent.getByLabel(muonInputTag_ , muon_h );
131 
132  //get vertex collection
133  hasValidVertex = false;
134  if( usePvtxd0_ ){
136 
137  if( VertexHandle.isValid() ) {
140  }
141  }
142 
143  //get the Bfield
144  edm::ESHandle<MagneticField> theMagField;
145  iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
146  bField = theMagField.product();
147 
148  //make a ValueMap of ints => flags for
149  //met correction. The values and meanings of the flags are :
150  // flag==0 ---> The muon is not used to correct the MET by default
151  // flag==1 ---> The muon is used to correct the MET. The Global pt is used.
152  // flag==2 ---> The muon is used to correct the MET. The tracker pt is used.
153  // flag==3 ---> The muon is used to correct the MET. The standalone pt is used.
154  // flag==4 ---> The muon is used to correct the MET as pion using the tcMET ZSP RF.
155  // flag==5 ---> The muon is used to correct the MET. The default fit is used; i.e. we get the pt from muon->pt().
156  // In general, the flag should never be 3. You do not want to correct the MET using
157  // the pt measurement from the standalone system (unless you really know what you're
158  // doing
159 
160  std::auto_ptr<edm::ValueMap<reco::MuonMETCorrectionData> > vm_muCorrData(new edm::ValueMap<reco::MuonMETCorrectionData>());
161 
162  std::vector<reco::MuonMETCorrectionData> v_muCorrData;
163 
164  unsigned int nMuons = muon_h->size();
165 
166  for (unsigned int iMu = 0; iMu < nMuons; iMu++) {
167 
168  const reco::Muon* mu = &(*muon_h)[iMu];
169  double deltax = 0.0;
170  double deltay = 0.0;
171 
173 
174  reco::TrackRef mu_track;
175  if( mu->isGlobalMuon() || mu->isTrackerMuon() || mu->isCaloMuon() )
176  mu_track = mu->innerTrack();
177  else {
178  v_muCorrData.push_back( muMETCorrData );
179  continue;
180  }
181 
182  // figure out depositions muons would make if they were treated as pions
183  if( isGoodTrack( mu ) ) {
184 
185  if( mu_track->pt() < minpt_ )
187 
188  else {
189  int bin_index = response_function->FindBin( mu_track->eta(), mu_track->pt() );
190  double response = response_function->GetBinContent( bin_index );
191 
192  TVector3 outerTrkPosition = propagateTrack( mu );
193 
194  deltax = response * mu_track->p() * sin( outerTrkPosition.Theta() ) * cos( outerTrkPosition.Phi() );
195  deltay = response * mu_track->p() * sin( outerTrkPosition.Theta() ) * sin( outerTrkPosition.Phi() );
196 
198  }
199  }
200 
201  // figure out muon flag
202  if( isGoodMuon( mu ) )
204 
205  else if( useCaloMuons_ && isGoodCaloMuon( mu, iMu ) )
207 
208  else v_muCorrData.push_back( muMETCorrData );
209  }
210 
211  edm::ValueMap<reco::MuonMETCorrectionData>::Filler dataFiller(*vm_muCorrData);
212 
213  dataFiller.insert( muon_h, v_muCorrData.begin(), v_muCorrData.end());
214  dataFiller.fill();
215 
216  iEvent.put(vm_muCorrData, "muCorrData");
217  }
class TVector3 propagateTrack(const reco::Muon *)
const reco::VertexCollection * vertexColl
virtual TrackRef innerTrack() const
Definition: Muon.h:49
bool isTrackerMuon() const
Definition: Muon.h:220
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool isGlobalMuon() const
Definition: Muon.h:219
bool isGoodCaloMuon(const reco::Muon *, const unsigned int)
bool isCaloMuon() const
Definition: Muon.h:222
edm::Handle< reco::VertexCollection > VertexHandle
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::Handle< reco::MuonCollection > muon_h
const int mu
Definition: Constants.h:23
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
edm::Handle< reco::BeamSpot > beamSpot_h
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
TVector3 MuonTCMETValueMapProducer::propagateTrack ( const reco::Muon muon)
private

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

392  {
393 
394  TVector3 outerTrkPosition;
395 
396  outerTrkPosition.SetPtEtaPhi( 999., -10., 2 * TMath::Pi() );
397 
398  const reco::TrackRef track = muon->innerTrack();
399 
400  if( !track.isNonnull() ) {
401  return outerTrkPosition;
402  }
403 
404  GlobalPoint tpVertex ( track->vx(), track->vy(), track->vz() );
405  GlobalVector tpMomentum ( track.get()->px(), track.get()->py(), track.get()->pz() );
406  int tpCharge ( track->charge() );
407 
408  FreeTrajectoryState fts ( tpVertex, tpMomentum, tpCharge, bField);
409 
410  const double zdist = 314.;
411 
412  const double radius = 130.;
413 
414  const double corner = 1.479;
415 
418 
419  Cylinder::CylinderPointer barrel = Cylinder::build( Cylinder::PositionType (0, 0, 0), Cylinder::RotationType (), radius);
420 
422 
424 
425  if( track.get()->eta() < -corner ) {
426  tsos = myAP.propagate( fts, *lendcap);
427  }
428  else if( fabs(track.get()->eta()) < corner ) {
429  tsos = myAP.propagate( fts, *barrel);
430  }
431  else if( track.get()->eta() > corner ) {
432  tsos = myAP.propagate( fts, *rendcap);
433  }
434 
435  if( tsos.isValid() )
436  outerTrkPosition.SetXYZ( tsos.globalPosition().x(), tsos.globalPosition().y(), tsos.globalPosition().z() );
437 
438  else
439  outerTrkPosition.SetPtEtaPhi( 999., -10., 2 * TMath::Pi() );
440 
441  return outerTrkPosition;
442  }
TkRotation< Scalar > RotationType
Definition: Definitions.h:29
const double Pi
virtual TrackRef innerTrack() const
Definition: Muon.h:49
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
Definition: BFit3D.cc:3
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_h
private

Definition at line 53 of file MuonTCMETValueMapProducer.h.

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

edm::InputTag cms::MuonTCMETValueMapProducer::beamSpotInputTag_
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().

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

Definition at line 52 of file MuonTCMETValueMapProducer.h.

Referenced by isGoodCaloMuon(), and produce().

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

edm::InputTag cms::MuonTCMETValueMapProducer::muonInputTag_
private

Definition at line 56 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and produce().

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

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 beginJob(), MuonTCMETValueMapProducer(), and produce().

int cms::MuonTCMETValueMapProducer::rfType_
private

Definition at line 71 of file MuonTCMETValueMapProducer.h.

Referenced by beginJob(), and 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().

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

Definition at line 62 of file MuonTCMETValueMapProducer.h.

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

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

Definition at line 54 of file MuonTCMETValueMapProducer.h.

Referenced by produce().

edm::InputTag cms::MuonTCMETValueMapProducer::vertexInputTag_
private

Definition at line 58 of file MuonTCMETValueMapProducer.h.

Referenced by MuonTCMETValueMapProducer(), and 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().

double cms::MuonTCMETValueMapProducer::vertexZ_
private

Definition at line 75 of file MuonTCMETValueMapProducer.h.

Referenced by isValidVertex(), and MuonTCMETValueMapProducer().