Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025 #include "RecoMET/METProducers/interface/MuonMETValueMapProducer.h"
00026 #include "RecoMET/METAlgorithms/interface/MuonMETAlgo.h"
00027 #include "DataFormats/MuonReco/interface/Muon.h"
00028 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00029 #include "DataFormats/TrackReco/interface/Track.h"
00030 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00031 #include "DataFormats/Common/interface/ValueMap.h"
00032 #include "MagneticField/Engine/interface/MagneticField.h"
00033 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00034 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00035
00036
00037 #include "DataFormats/MuonReco/interface/MuonMETCorrectionData.h"
00038 #include "FWCore/Framework/interface/MakerMacros.h"
00039
00040 typedef math::XYZTLorentzVector LorentzVector;
00041 typedef math::XYZPoint Point;
00042
00043
00044 namespace cms {
00045 MuonMETValueMapProducer::MuonMETValueMapProducer(const edm::ParameterSet& iConfig) {
00046
00047 using namespace edm;
00048
00049 produces<ValueMap<reco::MuonMETCorrectionData> > ("muCorrData");
00050
00051
00052 minPt_ = iConfig.getParameter<double>("minPt" );
00053 maxEta_ = iConfig.getParameter<double>("maxEta" );
00054 isAlsoTkMu_ = iConfig.getParameter<bool> ("isAlsoTkMu" );
00055 maxNormChi2_ = iConfig.getParameter<double>("maxNormChi2" );
00056 maxd0_ = iConfig.getParameter<double>("maxd0" );
00057 minnHits_ = iConfig.getParameter<int> ("minnHits" );
00058 minnValidStaHits_ = iConfig.getParameter<int> ("minnValidStaHits" );
00059
00060 beamSpotInputTag_ = iConfig.getParameter<InputTag>("beamSpotInputTag" );
00061 muonInputTag_ = iConfig.getParameter<InputTag>("muonInputTag");
00062
00063
00064 useTrackAssociatorPositions_ = iConfig.getParameter<bool>("useTrackAssociatorPositions");
00065 useHO_ = iConfig.getParameter<bool>("useHO" );
00066
00067 ParameterSet trackAssociatorParams =
00068 iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
00069 trackAssociatorParameters_.loadParameters(trackAssociatorParams);
00070 trackAssociator_.useDefaultPropagator();
00071
00072 towerEtThreshold_ = iConfig.getParameter<double>("towerEtThreshold");
00073 useRecHits_ = iConfig.getParameter<bool>("useRecHits");
00074
00075 }
00076
00077
00078 MuonMETValueMapProducer::~MuonMETValueMapProducer()
00079 {
00080
00081
00082
00083
00084 }
00085
00086
00087
00088
00089
00090
00091
00092 void MuonMETValueMapProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00093
00094 using namespace edm;
00095 using namespace reco;
00096
00097
00098 Handle<View<reco::Muon> > muons;
00099 iEvent.getByLabel(muonInputTag_,muons);
00100
00101
00102 Handle<BeamSpot> beamSpotH;
00103 iEvent.getByLabel(beamSpotInputTag_, beamSpotH);
00104
00105
00106 edm::ESHandle<MagneticField> magneticField;
00107 iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
00108
00109 double bfield = magneticField->inTesla(GlobalPoint(0.,0.,0.)).z();
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 std::auto_ptr<ValueMap<MuonMETCorrectionData> > vm_muCorrData(new ValueMap<MuonMETCorrectionData>());
00123
00124 unsigned int nMuons = muons->size();
00125
00126 std::vector<MuonMETCorrectionData> v_muCorrData;
00127 for (unsigned int iMu=0; iMu<nMuons; iMu++) {
00128
00129 const reco::Muon* mu = &(*muons)[iMu];
00130 double deltax = 0.0;
00131 double deltay = 0.0;
00132
00133 TrackRef mu_track;
00134 if(mu->isGlobalMuon()) {
00135 mu_track = mu->globalTrack();
00136 } else if(mu->isTrackerMuon()) {
00137 mu_track = mu->innerTrack();
00138 } else
00139 mu_track = mu->outerTrack();
00140
00141 TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup,
00142 trackAssociator_.getFreeTrajectoryState(iSetup, *mu_track),
00143 trackAssociatorParameters_);
00144 MuonMETAlgo alg;
00145 alg.GetMuDepDeltas(mu, info,
00146 useTrackAssociatorPositions_, useRecHits_,
00147 useHO_, towerEtThreshold_,
00148 deltax, deltay, bfield);
00149
00150
00151
00152 MuonMETCorrectionData muMETCorrData(MuonMETCorrectionData::NotUsed, deltax, deltay);
00153
00154 if(!mu->isGlobalMuon()) {
00155 v_muCorrData.push_back(muMETCorrData);
00156 continue;
00157 }
00158
00159
00160
00161 if(!mu->isTrackerMuon() && isAlsoTkMu_) {
00162 v_muCorrData.push_back(muMETCorrData);
00163 continue;
00164 }
00165
00166
00167
00168 TrackRef globTk = mu->globalTrack();
00169 TrackRef siTk = mu->innerTrack();
00170
00171 if(mu->pt() < minPt_ || fabs(mu->eta()) > maxEta_) {
00172 v_muCorrData.push_back(muMETCorrData);
00173 continue;
00174 }
00175 if(globTk->chi2()/globTk->ndof() > maxNormChi2_) {
00176 v_muCorrData.push_back(muMETCorrData);
00177 continue;
00178 }
00179 if(fabs(globTk->dxy(beamSpotH->position())) > fabs(maxd0_) ) {
00180 v_muCorrData.push_back(muMETCorrData);
00181 continue;
00182 }
00183 if(siTk->numberOfValidHits() < minnHits_) {
00184 v_muCorrData.push_back(muMETCorrData);
00185 continue;
00186 }
00187
00188 if(globTk->hitPattern().numberOfValidMuonHits() < minnValidStaHits_) {
00189 v_muCorrData.push_back(muMETCorrData);
00190 continue;
00191 }
00192
00193 v_muCorrData.push_back(MuonMETCorrectionData(MuonMETCorrectionData::MuonCandidateValuesUsed, deltax, deltay));
00194 }
00195
00196 ValueMap<MuonMETCorrectionData>::Filler dataFiller(*vm_muCorrData);
00197
00198 dataFiller.insert(muons, v_muCorrData.begin(), v_muCorrData.end());
00199 dataFiller.fill();
00200
00201 iEvent.put(vm_muCorrData, "muCorrData");
00202
00203 }
00204
00205
00206 void MuonMETValueMapProducer::beginJob()
00207 {
00208 }
00209
00210
00211 void MuonMETValueMapProducer::endJob() {
00212 }
00213 }
00214
00215