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 
51 
52 //____________________________________________________________________________||
53 namespace cms {
54 
56  : minPt_(iConfig.getParameter<double>("minPt")),
57  maxEta_(iConfig.getParameter<double>("maxEta")),
58  isAlsoTkMu_(iConfig.getParameter<bool>("isAlsoTkMu")),
59  maxNormChi2_(iConfig.getParameter<double>("maxNormChi2")),
60  maxd0_(iConfig.getParameter<double>("maxd0")),
61  minnHits_(iConfig.getParameter<int>("minnHits")),
62  minnValidStaHits_(iConfig.getParameter<int>("minnValidStaHits")),
63  useTrackAssociatorPositions_(iConfig.getParameter<bool>("useTrackAssociatorPositions")),
64  useHO_(iConfig.getParameter<bool>("useHO")),
65  towerEtThreshold_(iConfig.getParameter<double>("towerEtThreshold")),
66  useRecHits_(iConfig.getParameter<bool>("useRecHits")) {
67  muonToken_ = consumes<edm::View<reco::Muon>>(iConfig.getParameter<edm::InputTag>("muonInputTag"));
68  beamSpotToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotInputTag"));
69  magFieldToken_ = esConsumes<MagneticField, IdealMagneticFieldRecord>();
70 
71  edm::ParameterSet trackAssociatorParams = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
72  edm::ConsumesCollector iC = consumesCollector();
73  trackAssociatorParameters_.loadParameters(trackAssociatorParams, iC);
75 
76  produces<edm::ValueMap<reco::MuonMETCorrectionData>>("muCorrData");
77  }
78 
79  //____________________________________________________________________________||
82  iEvent.getByToken(muonToken_, muons);
83 
85  iEvent.getByToken(beamSpotToken_, beamSpot);
86 
88 
89  double bfield = magneticField.inTesla(GlobalPoint(0., 0., 0.)).z();
90 
91  std::vector<reco::MuonMETCorrectionData> muCorrDataList;
92 
93  for (edm::View<reco::Muon>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
94  double deltax = 0.0;
95  double deltay = 0.0;
96  determine_deltax_deltay(deltax, deltay, *muon, bfield, magneticField, iEvent, iSetup);
97 
99 
100  reco::MuonMETCorrectionData muMETCorrData(muCorrType, deltax, deltay);
101  muCorrDataList.push_back(muMETCorrData);
102  }
103 
104  auto valueMapMuCorrData = std::make_unique<edm::ValueMap<reco::MuonMETCorrectionData>>();
105 
106  edm::ValueMap<reco::MuonMETCorrectionData>::Filler dataFiller(*valueMapMuCorrData);
107 
108  dataFiller.insert(muons, muCorrDataList.begin(), muCorrDataList.end());
109  dataFiller.fill();
110 
111  iEvent.put(std::move(valueMapMuCorrData), "muCorrData");
112  }
113 
114  //____________________________________________________________________________||
116  double& deltay,
117  const reco::Muon& muon,
118  double bfield,
121  const edm::EventSetup& iSetup) {
122  reco::TrackRef mu_track;
123  if (muon.isGlobalMuon())
124  mu_track = muon.globalTrack();
125  else if (muon.isTrackerMuon() || muon.isRPCMuon() || muon.isGEMMuon() || muon.isME0Muon())
126  mu_track = muon.innerTrack();
127  else
128  mu_track = muon.outerTrack();
129 
132 
133  MuonMETAlgo alg;
134  alg.GetMuDepDeltas(
136  }
137 
138  //____________________________________________________________________________||
140  const reco::Muon& muon, const math::XYZPoint& beamSpotPosition) {
141  if (should_type_MuonCandidateValuesUsed(muon, beamSpotPosition))
142  return reco::MuonMETCorrectionData::Type::MuonCandidateValuesUsed;
143 
144  return reco::MuonMETCorrectionData::Type::NotUsed;
145  }
146 
147  //____________________________________________________________________________||
149  const math::XYZPoint& beamSpotPosition) {
150  if (!muon.isGlobalMuon())
151  return false;
152  if (!muon.isTrackerMuon() && isAlsoTkMu_)
153  return false;
154  reco::TrackRef globTk = muon.globalTrack();
155  reco::TrackRef siTk = muon.innerTrack();
156 
157  if (muon.pt() < minPt_ || fabs(muon.eta()) > maxEta_)
158  return false;
159  if (globTk->chi2() / globTk->ndof() > maxNormChi2_)
160  return false;
161  if (fabs(globTk->dxy(beamSpotPosition)) > fabs(maxd0_))
162  return false;
163  if (siTk->numberOfValidHits() < minnHits_)
164  return false;
165  if (globTk->hitPattern().numberOfValidMuonHits() < minnValidStaHits_)
166  return false;
167  return true;
168  }
169 
170  //____________________________________________________________________________||
171 } // namespace cms
172 
173 //____________________________________________________________________________||
cms::MuonMETValueMapProducer::decide_correction_type
reco::MuonMETCorrectionData::Type decide_correction_type(const reco::Muon &muon, const math::XYZPoint &beamSpotPosition)
Definition: MuonMETValueMapProducer.cc:139
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
electrons_cff.bool
bool
Definition: electrons_cff.py:366
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
MessageLogger.h
muon
Definition: MuonCocktails.h:17
TrackDetectorAssociator::useDefaultPropagator
void useDefaultPropagator()
use the default propagator
Definition: TrackDetectorAssociator.cc:81
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
MuonMETAlgo::GetMuDepDeltas
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
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
edm::Handle
Definition: AssociativeIterator.h:50
cms::MuonMETValueMapProducer::minnValidStaHits_
int minnValidStaHits_
Definition: MuonMETValueMapProducer.h:65
reco::Muon
Definition: Muon.h:27
edm::Ref< TrackCollection >
MakerMacros.h
cms::MuonMETValueMapProducer::muonToken_
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
Definition: MuonMETValueMapProducer.h:72
cms::MuonMETValueMapProducer::beamSpotToken_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
Definition: MuonMETValueMapProducer.h:73
Track.h
TrackFwd.h
cms::MuonMETValueMapProducer::magFieldToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
Definition: MuonMETValueMapProducer.h:74
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11725
cms::MuonMETValueMapProducer::should_type_MuonCandidateValuesUsed
bool should_type_MuonCandidateValuesUsed(const reco::Muon &muon, const math::XYZPoint &beamSpotPosition)
Definition: MuonMETValueMapProducer.cc:148
cms::MuonMETValueMapProducer::useTrackAssociatorPositions_
bool useTrackAssociatorPositions_
Definition: MuonMETValueMapProducer.h:67
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
TrackAssociatorParameters::loadParameters
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
Definition: TrackAssociatorParameters.cc:18
cms::MuonMETValueMapProducer::useRecHits_
bool useRecHits_
Definition: MuonMETValueMapProducer.h:70
MuonMETAlgo
Definition: MuonMETAlgo.h:39
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
cms::MuonMETValueMapProducer::towerEtThreshold_
double towerEtThreshold_
Definition: MuonMETValueMapProducer.h:69
cms::MuonMETValueMapProducer::MuonMETValueMapProducer
MuonMETValueMapProducer(const edm::ParameterSet &)
Definition: MuonMETValueMapProducer.cc:55
TrackDetectorAssociator::getFreeTrajectoryState
static FreeTrajectoryState getFreeTrajectoryState(const MagneticField *, const reco::Track &)
get FreeTrajectoryState from different track representations
Definition: TrackDetectorAssociator.cc:553
cms::MuonMETValueMapProducer::isAlsoTkMu_
bool isAlsoTkMu_
Definition: MuonMETValueMapProducer.h:61
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
MuonMETAlgo.h
cms::MuonMETValueMapProducer::trackAssociator_
TrackDetectorAssociator trackAssociator_
Definition: MuonMETValueMapProducer.h:77
edm::EventSetup
Definition: EventSetup.h:58
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
cms::MuonMETValueMapProducer::trackAssociatorParameters_
TrackAssociatorParameters trackAssociatorParameters_
Definition: MuonMETValueMapProducer.h:76
ValueMap.h
MuonMETValueMapProducer.h
TrackDetMatchInfo
Definition: TrackDetMatchInfo.h:13
reco::MuonMETCorrectionData::Type
Type
Definition: MuonMETCorrectionData.h:9
eostools.move
def move(src, dest)
Definition: eostools.py:511
cms::MuonMETValueMapProducer::minnHits_
int minnHits_
Definition: MuonMETValueMapProducer.h:64
cms::MuonMETValueMapProducer::minPt_
double minPt_
Definition: MuonMETValueMapProducer.h:59
cms::MuonMETValueMapProducer::maxEta_
double maxEta_
Definition: MuonMETValueMapProducer.h:60
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
cms::MuonMETValueMapProducer::useHO_
bool useHO_
Definition: MuonMETValueMapProducer.h:68
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::helper::Filler
Definition: ValueMap.h:22
TrackDetectorAssociator::associate
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
Definition: TrackDetectorAssociator.cc:110
cms::MuonMETValueMapProducer::maxNormChi2_
double maxNormChi2_
Definition: MuonMETValueMapProducer.h:62
reco::MuonMETCorrectionData
Definition: MuonMETCorrectionData.h:7
cms::MuonMETValueMapProducer::maxd0_
double maxd0_
Definition: MuonMETValueMapProducer.h:63
cms::MuonMETValueMapProducer::determine_deltax_deltay
void determine_deltax_deltay(double &deltax, double &deltay, const reco::Muon &muon, double bfield, const MagneticField &magneticField, edm::Event &iEvent, const edm::EventSetup &iSetup)
Definition: MuonMETValueMapProducer.cc:115
edm::Event
Definition: Event.h:73
MagneticField
Definition: MagneticField.h:19
cms::MuonMETValueMapProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: MuonMETValueMapProducer.cc:80
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21