CMS 3D CMS Logo

MuonMETValueMapProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: METProducers
4 // Class: MuonMETValueMapProducer
5 //
6 //
7 // Original Author: Puneeth Kalavase
8 // Created: Sun Mar 15 11:33:20 CDT 2009
9 //
10 
11 /*
12  The meanings ofr reco::MuonMETCorrectionData::Type
13  NotUsed = 0:
14  The muon is not used to correct the MET by default
15 
16  CombinedTrackUsed = 1, GlobalTrackUsed = 1:
17 
18  The muon is used to correct the MET. The Global pt is used. For
19  backward compatibility only
20 
21  InnerTrackUsed = 2, TrackUsed = 2:
22  The muon is used to correct the MET. The tracker pt is used. For
23  backward compatibility only
24 
25  OuterTrackUsed = 3, StandAloneTrackUsed = 3:
26  The muon is used to correct the MET. The standalone pt is used.
27  For backward compatibility only. In general, the flag should
28  never be 3. You do not want to correct the MET using the pt
29  measurement from the standalone system (unless you really know
30  what you're doing.
31 
32  TreatedAsPion = 4:
33  The muon was treated as a Pion. This is used for the tcMET
34  producer
35 
36  MuonP4V4QUsed = 5, MuonCandidateValuesUsed = 5:
37  The default fit is used, i.e, we get the pt from muon->pt
38 
39  (see DataFormats/MuonReco/interface/MuonMETCorrectionData.h)
40 */
41 
42 //____________________________________________________________________________||
44 
53 
54 //____________________________________________________________________________||
55 namespace cms {
56 
58  : minPt_(iConfig.getParameter<double>("minPt")),
59  maxEta_(iConfig.getParameter<double>("maxEta")),
60  isAlsoTkMu_(iConfig.getParameter<bool>("isAlsoTkMu")),
61  maxNormChi2_(iConfig.getParameter<double>("maxNormChi2")),
62  maxd0_(iConfig.getParameter<double>("maxd0")),
63  minnHits_(iConfig.getParameter<int>("minnHits")),
64  minnValidStaHits_(iConfig.getParameter<int>("minnValidStaHits")),
65  useTrackAssociatorPositions_(iConfig.getParameter<bool>("useTrackAssociatorPositions")),
66  useHO_(iConfig.getParameter<bool>("useHO")),
67  towerEtThreshold_(iConfig.getParameter<double>("towerEtThreshold")),
68  useRecHits_(iConfig.getParameter<bool>("useRecHits")) {
69  muonToken_ = consumes<edm::View<reco::Muon>>(iConfig.getParameter<edm::InputTag>("muonInputTag"));
70  beamSpotToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotInputTag"));
71 
72  edm::ParameterSet trackAssociatorParams = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
73  edm::ConsumesCollector iC = consumesCollector();
74  trackAssociatorParameters_.loadParameters(trackAssociatorParams, iC);
76 
77  produces<edm::ValueMap<reco::MuonMETCorrectionData>>("muCorrData");
78  }
79 
80  //____________________________________________________________________________||
83  iEvent.getByToken(muonToken_, muons);
84 
86  iEvent.getByToken(beamSpotToken_, beamSpot);
87 
89  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
90 
91  double bfield = magneticField->inTesla(GlobalPoint(0., 0., 0.)).z();
92 
93  std::vector<reco::MuonMETCorrectionData> muCorrDataList;
94 
95  for (edm::View<reco::Muon>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
96  double deltax = 0.0;
97  double deltay = 0.0;
98  determine_deltax_deltay(deltax, deltay, *muon, bfield, iEvent, iSetup);
99 
101 
102  reco::MuonMETCorrectionData muMETCorrData(muCorrType, deltax, deltay);
103  muCorrDataList.push_back(muMETCorrData);
104  }
105 
106  auto valueMapMuCorrData = std::make_unique<edm::ValueMap<reco::MuonMETCorrectionData>>();
107 
108  edm::ValueMap<reco::MuonMETCorrectionData>::Filler dataFiller(*valueMapMuCorrData);
109 
110  dataFiller.insert(muons, muCorrDataList.begin(), muCorrDataList.end());
111  dataFiller.fill();
112 
113  iEvent.put(std::move(valueMapMuCorrData), "muCorrData");
114  }
115 
116  //____________________________________________________________________________||
118  double& deltay,
119  const reco::Muon& muon,
120  double bfield,
122  const edm::EventSetup& iSetup) {
123  reco::TrackRef mu_track;
124  if (muon.isGlobalMuon())
125  mu_track = muon.globalTrack();
126  else if (muon.isTrackerMuon() || muon.isRPCMuon() || muon.isGEMMuon() || muon.isME0Muon())
127  mu_track = muon.innerTrack();
128  else
129  mu_track = muon.outerTrack();
130 
132  iEvent, iSetup, trackAssociator_.getFreeTrajectoryState(iSetup, *mu_track), trackAssociatorParameters_);
133 
134  MuonMETAlgo alg;
135  alg.GetMuDepDeltas(
136  &muon, info, useTrackAssociatorPositions_, useRecHits_, useHO_, towerEtThreshold_, deltax, deltay, bfield);
137  }
138 
139  //____________________________________________________________________________||
141  const reco::Muon& muon, const math::XYZPoint& beamSpotPosition) {
142  if (should_type_MuonCandidateValuesUsed(muon, beamSpotPosition))
143  return reco::MuonMETCorrectionData::Type::MuonCandidateValuesUsed;
144 
145  return reco::MuonMETCorrectionData::Type::NotUsed;
146  }
147 
148  //____________________________________________________________________________||
150  const math::XYZPoint& beamSpotPosition) {
151  if (!muon.isGlobalMuon())
152  return false;
153  if (!muon.isTrackerMuon() && isAlsoTkMu_)
154  return false;
155  reco::TrackRef globTk = muon.globalTrack();
156  reco::TrackRef siTk = muon.innerTrack();
157 
158  if (muon.pt() < minPt_ || fabs(muon.eta()) > maxEta_)
159  return false;
160  if (globTk->chi2() / globTk->ndof() > maxNormChi2_)
161  return false;
162  if (fabs(globTk->dxy(beamSpotPosition)) > fabs(maxd0_))
163  return false;
164  if (siTk->numberOfValidHits() < minnHits_)
165  return false;
166  if (globTk->hitPattern().numberOfValidMuonHits() < minnValidStaHits_)
167  return false;
168  return true;
169  }
170 
171  //____________________________________________________________________________||
172 } // namespace cms
173 
174 //____________________________________________________________________________||
T getParameter(std::string const &) const
static const TGPicture * info(bool iBackgroundIsBlack)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
double eta() const final
momentum pseudorapidity
virtual TrackRef innerTrack() const
Definition: Muon.h:45
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
void useDefaultPropagator()
use the default propagator
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
TrackDetectorAssociator trackAssociator_
double pt() const final
transverse momentum
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
bool isME0Muon() const
Definition: Muon.h:305
reco::MuonMETCorrectionData::Type decide_correction_type(const reco::Muon &muon, const math::XYZPoint &beamSpotPosition)
bool isTrackerMuon() const override
Definition: Muon.h:299
void GetMuDepDeltas(const reco::Muon *inputMuon, TrackDetMatchInfo &info, bool useTrackAssociatorPositions, bool useRecHits, bool useHO, double towerEtThreshold, double &deltax, double &deltay, double Bfield)
Definition: MuonMETAlgo.cc:96
bool isRPCMuon() const
Definition: Muon.h:303
int iEvent
Definition: GenABIO.cc:224
bool isGlobalMuon() const override
Definition: Muon.h:298
TrackAssociatorParameters trackAssociatorParameters_
T z() const
Definition: PV3DBase.h:61
void determine_deltax_deltay(double &deltax, double &deltay, const reco::Muon &muon, double bfield, edm::Event &iEvent, const edm::EventSetup &iSetup)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:48
Namespace of DDCMS conversion namespace.
void produce(edm::Event &, const edm::EventSetup &) override
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool isGEMMuon() const
Definition: Muon.h:304
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
MuonMETValueMapProducer(const edm::ParameterSet &)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
bool should_type_MuonCandidateValuesUsed(const reco::Muon &muon, const math::XYZPoint &beamSpotPosition)
T get() const
Definition: EventSetup.h:73
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
const Point & position() const
position
Definition: BeamSpot.h:59
def move(src, dest)
Definition: eostools.py:511
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:51