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 bool haveBeamSpot = true;
00105 if(!beamSpotH.isValid() )
00106 haveBeamSpot = false;
00107
00108
00109 edm::ESHandle<MagneticField> magneticField;
00110 iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
00111
00112 double bfield = magneticField->inTesla(GlobalPoint(0.,0.,0.)).z();
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 std::auto_ptr<ValueMap<MuonMETCorrectionData> > vm_muCorrData(new ValueMap<MuonMETCorrectionData>());
00126
00127 unsigned int nMuons = muons->size();
00128
00129 std::vector<MuonMETCorrectionData> v_muCorrData;
00130 for (unsigned int iMu=0; iMu<nMuons; iMu++) {
00131
00132 const reco::Muon* mu = &(*muons)[iMu];
00133 double deltax = 0.0;
00134 double deltay = 0.0;
00135
00136 TrackRef mu_track;
00137 if(mu->isGlobalMuon()) {
00138 mu_track = mu->globalTrack();
00139 } else if(mu->isTrackerMuon()) {
00140 mu_track = mu->innerTrack();
00141 } else
00142 mu_track = mu->outerTrack();
00143
00144 TrackDetMatchInfo info = trackAssociator_.associate(iEvent, iSetup,
00145 trackAssociator_.getFreeTrajectoryState(iSetup, *mu_track),
00146 trackAssociatorParameters_);
00147 MuonMETAlgo alg;
00148 alg.GetMuDepDeltas(mu, info,
00149 useTrackAssociatorPositions_, useRecHits_,
00150 useHO_, towerEtThreshold_,
00151 deltax, deltay, bfield);
00152
00153
00154
00155 MuonMETCorrectionData muMETCorrData(MuonMETCorrectionData::NotUsed, deltax, deltay);
00156
00157 if(!mu->isGlobalMuon()) {
00158 v_muCorrData.push_back(muMETCorrData);
00159 continue;
00160 }
00161
00162
00163
00164 if(!mu->isTrackerMuon() && isAlsoTkMu_) {
00165 v_muCorrData.push_back(muMETCorrData);
00166 continue;
00167 }
00168
00169
00170
00171 TrackRef globTk = mu->globalTrack();
00172 TrackRef siTk = mu->innerTrack();
00173
00174 if(mu->pt() < minPt_ || fabs(mu->eta()) > maxEta_) {
00175 v_muCorrData.push_back(muMETCorrData);
00176 continue;
00177 }
00178 if(globTk->chi2()/globTk->ndof() > maxNormChi2_) {
00179 v_muCorrData.push_back(muMETCorrData);
00180 continue;
00181 }
00182 if(fabs(globTk->dxy(beamSpotH->position())) > fabs(maxd0_) ) {
00183 v_muCorrData.push_back(muMETCorrData);
00184 continue;
00185 }
00186 if(siTk->numberOfValidHits() < minnHits_) {
00187 v_muCorrData.push_back(muMETCorrData);
00188 continue;
00189 }
00190
00191 if(globTk->hitPattern().numberOfValidMuonHits() < minnValidStaHits_) {
00192 v_muCorrData.push_back(muMETCorrData);
00193 continue;
00194 }
00195
00196 v_muCorrData.push_back(MuonMETCorrectionData(MuonMETCorrectionData::MuonCandidateValuesUsed, deltax, deltay));
00197 }
00198
00199 ValueMap<MuonMETCorrectionData>::Filler dataFiller(*vm_muCorrData);
00200
00201 dataFiller.insert(muons, v_muCorrData.begin(), v_muCorrData.end());
00202 dataFiller.fill();
00203
00204 iEvent.put(vm_muCorrData, "muCorrData");
00205
00206 }
00207
00208
00209 void MuonMETValueMapProducer::beginJob()
00210 {
00211 }
00212
00213
00214 void MuonMETValueMapProducer::endJob() {
00215 }
00216 }
00217
00218