Go to the documentation of this file.00001
00009 #include "HLTrigger/Muon/interface/HLTMuonL2PreFilter.h"
00010 #include "HLTrigger/Muon/interface/HLTMuonL2ToL1Map.h"
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012 #include "DataFormats/Common/interface/Handle.h"
00013 #include "DataFormats/Common/interface/RefToBase.h"
00014 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00015 #include "DataFormats/TrackReco/interface/Track.h"
00016 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00017 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
00018 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00019
00020
00021
00022
00023
00024 HLTMuonL2PreFilter::HLTMuonL2PreFilter(const edm::ParameterSet& iConfig):
00025 beamSpotTag_( iConfig.getParameter<edm::InputTag>("BeamSpotTag") ),
00026 candTag_( iConfig.getParameter<edm::InputTag >("CandTag") ),
00027 previousCandTag_( iConfig.getParameter<edm::InputTag >("PreviousCandTag") ),
00028 seedMapTag_( iConfig.getParameter<edm::InputTag >("SeedMapTag") ),
00029 minN_( iConfig.getParameter<int>("MinN") ),
00030 maxEta_( iConfig.getParameter<double>("MaxEta") ),
00031 minNhits_( iConfig.getParameter<int>("MinNhits") ),
00032 maxDr_( iConfig.getParameter<double>("MaxDr") ),
00033 maxDz_( iConfig.getParameter<double>("MaxDz") ),
00034 minPt_( iConfig.getParameter<double>("MinPt") ),
00035 nSigmaPt_( iConfig.getParameter<double>("NSigmaPt") ),
00036 saveTag_( iConfig.getUntrackedParameter<bool>("SaveTag", false) )
00037 {
00038 using namespace std;
00039
00040
00041 if(edm::isDebugEnabled()){
00042 ostringstream ss;
00043 ss<<"Constructed with parameters:"<<endl;
00044 ss<<" BeamSpotTag = "<<beamSpotTag_.encode()<<endl;
00045 ss<<" CandTag = "<<candTag_.encode()<<endl;
00046 ss<<" PreviousCandTag = "<<previousCandTag_.encode()<<endl;
00047 ss<<" SeedMapTag = "<<seedMapTag_.encode()<<endl;
00048 ss<<" MinN = "<<minN_<<endl;
00049 ss<<" MaxEta = "<<maxEta_<<endl;
00050 ss<<" MinNhits = "<<minNhits_<<endl;
00051 ss<<" MaxDr = "<<maxDr_<<endl;
00052 ss<<" MaxDz = "<<maxDz_<<endl;
00053 ss<<" MinPt = "<<minPt_<<endl;
00054 ss<<" NSigmaPt = "<<nSigmaPt_<<endl;
00055 ss<<" SaveTag = "<<saveTag_;
00056 LogDebug("HLTMuonL2PreFilter")<<ss.str();
00057 }
00058
00059
00060 produces<trigger::TriggerFilterObjectWithRefs>();
00061 }
00062
00063 HLTMuonL2PreFilter::~HLTMuonL2PreFilter()
00064 {
00065 }
00066
00067
00068
00069
00070
00071
00072 bool HLTMuonL2PreFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00073 {
00074
00075
00076
00077
00078 using namespace std;
00079 using namespace edm;
00080 using namespace reco;
00081 using namespace trigger;
00082 using namespace l1extra;
00083
00084
00085 auto_ptr<TriggerFilterObjectWithRefs> filterproduct(new TriggerFilterObjectWithRefs(path(), module()));
00086
00087
00088 if(saveTag_) filterproduct->addCollectionTag(candTag_);
00089
00090
00091 Handle<RecoChargedCandidateCollection> allMuons;
00092 iEvent.getByLabel(candTag_, allMuons);
00093
00094
00095 Handle<BeamSpot> beamSpotHandle;
00096 iEvent.getByLabel(beamSpotTag_, beamSpotHandle);
00097 BeamSpot::Point beamSpot = beamSpotHandle->position();
00098
00099
00100 HLTMuonL2ToL1Map mapL2ToL1(previousCandTag_, seedMapTag_, iEvent);
00101
00102
00103 int n = 0;
00104 for(RecoChargedCandidateCollection::const_iterator cand=allMuons->begin(); cand!=allMuons->end(); cand++){
00105 TrackRef mu = cand->get<TrackRef>();
00106
00107
00108 if(!mapL2ToL1.isTriggeredByL1(mu)) continue;
00109
00110
00111 if(fabs(mu->eta()) > maxEta_) continue;
00112
00113
00114 if(mu->numberOfValidHits() < minNhits_) continue;
00115
00116
00117 if(fabs(mu->dxy(beamSpot)) > maxDr_) continue;
00118
00119
00120 if(fabs(mu->dz(beamSpot)) > maxDz_) continue;
00121
00122
00123 double pt = mu->pt();
00124 double abspar0 = fabs(mu->parameter(0));
00125 double ptLx = pt;
00126
00127 if(abspar0 > 0) ptLx += nSigmaPt_*mu->error(0)/abspar0*pt;
00128 if(ptLx < minPt_) continue;
00129
00130
00131 filterproduct->addObject(TriggerMuon, RecoChargedCandidateRef(Ref<RecoChargedCandidateCollection>(allMuons, cand-allMuons->begin())));
00132
00133 n++;
00134 }
00135
00136
00137 const bool accept (n >= minN_);
00138
00139
00140 if(edm::isDebugEnabled()){
00141 ostringstream ss;
00142 ss<<"L2mu#"
00143 <<'\t'<<"q*pt"<<'\t'
00144 <<'\t'<<"q*ptLx"<<'\t'
00145 <<'\t'<<"eta"
00146 <<'\t'<<"phi"
00147 <<'\t'<<"nHits"
00148 <<'\t'<<"dr"<<'\t'
00149 <<'\t'<<"dz"<<'\t'
00150 <<'\t'<<"L1seed#"
00151 <<'\t'<<"isPrev"
00152 <<'\t'<<"isFired"
00153 <<endl;
00154 ss<<"-----------------------------------------------------------------------------------------------------------------------"<<endl;
00155 for (RecoChargedCandidateCollection::const_iterator cand = allMuons->begin(); cand != allMuons->end(); cand++) {
00156 TrackRef mu = cand->get<TrackRef>();
00157 ss<<setprecision(2)
00158 <<cand-allMuons->begin()
00159 <<'\t'<<scientific<<mu->charge()*mu->pt()
00160 <<'\t'<<scientific<<mu->charge()*mu->pt()*(1. + ((mu->parameter(0) != 0) ? nSigmaPt_*mu->error(0)/fabs(mu->parameter(0)) : 0.))
00161 <<'\t'<<fixed<<mu->eta()
00162 <<'\t'<<fixed<<mu->phi()
00163 <<'\t'<<mu->numberOfValidHits()
00164 <<'\t'<<scientific<<mu->d0()
00165 <<'\t'<<scientific<<mu->dz()
00166 <<'\t'<<mapL2ToL1.getL1Keys(mu)
00167 <<'\t'<<mapL2ToL1.isTriggeredByL1(mu);
00168 vector<RecoChargedCandidateRef> firedMuons;
00169 filterproduct->getObjects(TriggerMuon, firedMuons);
00170 ss<<'\t'<<(find(firedMuons.begin(), firedMuons.end(), RecoChargedCandidateRef(Ref<RecoChargedCandidateCollection>(allMuons, cand-allMuons->begin()))) != firedMuons.end())
00171 <<endl;
00172 }
00173 ss<<"-----------------------------------------------------------------------------------------------------------------------"<<endl;
00174 ss<<"Decision of filter is "<<accept<<", number of muons passing = "<<filterproduct->muonSize();
00175 LogDebug("HLTMuonL2PreFilter")<<ss.str();
00176 }
00177
00178
00179 iEvent.put(filterproduct);
00180
00181 return accept;
00182 }
00183