CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTMuonL1toL3TkPreFilter.cc
Go to the documentation of this file.
1 
10 
13 
16 
25 
26 //
27 // constructors and destructor
28 //
29 using namespace std;
30 using namespace edm;
31 using namespace reco;
32 using namespace trigger;
33 
35  beamspotTag_ (iConfig.getParameter< edm::InputTag > ("BeamSpotTag")),
36  candTag_ (iConfig.getParameter<InputTag > ("CandTag")),
37  previousCandTag_ (iConfig.getParameter<InputTag > ("PreviousCandTag")),
38  min_N_ (iConfig.getParameter<int> ("MinN")),
39  max_Eta_ (iConfig.getParameter<double> ("MaxEta")),
40  min_Nhits_ (iConfig.getParameter<int> ("MinNhits")),
41  max_Dr_ (iConfig.getParameter<double> ("MaxDr")),
42  max_Dz_ (iConfig.getParameter<double> ("MaxDz")),
43  min_Pt_ (iConfig.getParameter<double> ("MinPt")),
44  nsigma_Pt_ (iConfig.getParameter<double> ("NSigmaPt"))
45 {
46 
47  LogDebug("HLTMuonL1toL3TkPreFilter")
48  << " CandTag/MinN/MaxEta/MinNhits/MaxDr/MaxDz/MinPt/NSigmaPt : "
49  << candTag_.encode()
50  << " " << min_N_
51  << " " << max_Eta_
52  << " " << min_Nhits_
53  << " " << max_Dr_
54  << " " << max_Dz_
55  << " " << min_Pt_
56  << " " << nsigma_Pt_;
57 
58  //register your products
59  produces<TriggerFilterObjectWithRefs>();
60 }
61 
63 {
64 }
65 
66 //
67 // member functions
68 //
69 
70 // ------------ method called to produce the data ------------
71 bool
73 {
74 
75  // All HLT filters must create and fill an HLT filter object,
76  // recording any reconstructed physics objects satisfying (or not)
77  // this HLT filter, and place it in the Event.
78 
79  // get hold of trks
81  iEvent.getByLabel(candTag_,mucands);
82  if (saveTags()) filterproduct.addCollectionTag(candTag_);
83  // sort them by L2Track
84  std::map<l1extra::L1MuonParticleRef, std::vector<RecoChargedCandidateRef> > L1toL3s;
85  unsigned int n = 0;
86  unsigned int maxN = mucands->size();
87  for (;n!=maxN;n++){
88  TrackRef tk = (*mucands)[n].track();
90  l1extra::L1MuonParticleRef l1mu = l3seedRef->l1Particle();
91  L1toL3s[l1mu].push_back(RecoChargedCandidateRef(mucands,n));
92  }
93 
94  // additionnal objects needed
95  Handle<TriggerFilterObjectWithRefs> previousLevelCands;
96  iEvent.getByLabel (previousCandTag_,previousLevelCands);
98  Handle<BeamSpot> recoBeamSpotHandle;
99  iEvent.getByLabel(beamspotTag_,recoBeamSpotHandle);
100  beamSpot = *recoBeamSpotHandle;
101 
102 
103  //needed to compare to L1
104  vector<l1extra::L1MuonParticleRef> vl1cands;
105  previousLevelCands->getObjects(TriggerL1Mu,vl1cands);
106 
107  std::map<l1extra::L1MuonParticleRef, std::vector<RecoChargedCandidateRef> > ::iterator L1toL3s_it = L1toL3s.begin();
108  std::map<l1extra::L1MuonParticleRef, std::vector<RecoChargedCandidateRef> > ::iterator L1toL3s_end = L1toL3s.end();
109  for (; L1toL3s_it!=L1toL3s_end; ++L1toL3s_it){
110 
111  if (!triggeredAtL1(L1toL3s_it->first,vl1cands)) continue;
112 
113  //loop over the L3Tk reconstructed for this L1.
114  unsigned int iTk=0;
115  unsigned int maxItk=L1toL3s_it->second.size();
116  for (; iTk!=maxItk; iTk++){
117 
118  RecoChargedCandidateRef & cand=L1toL3s_it->second[iTk];
119  TrackRef tk = cand->track();
120 
121  if (fabs(tk->eta())>max_Eta_) continue;
122 
123  // cut on number of hits
124  if (tk->numberOfValidHits()<min_Nhits_) continue;
125 
126  //dr cut
127  //if (fabs(tk->d0())>max_Dr_) continue;
128  if (fabs(tk->dxy(beamSpot.position()))>max_Dr_) continue;
129 
130  //dz cut
131  if (fabs(tk->dz())>max_Dz_) continue;
132 
133  // Pt threshold cut
134  double pt = tk->pt();
135  double err0 = tk->error(0);
136  double abspar0 = fabs(tk->parameter(0));
137  double ptLx = pt;
138  // convert 50% efficiency threshold to 90% efficiency threshold
139  if (abspar0>0) ptLx += nsigma_Pt_*err0/abspar0*pt;
140  LogTrace("HLTMuonL1toL3TkPreFilter") << " ...Muon in loop, pt= "
141  << pt << ", ptLx= " << ptLx;
142  if (ptLx<min_Pt_) continue;
143 
144  //one good L3Tk
145  filterproduct.addObject(TriggerMuon,cand);
146  break; // and go on with the next L1 association
147  }
148 
149  }//loop over L1s from L3 grouping
150 
151 
152  vector<RecoChargedCandidateRef> vref;
153  filterproduct.getObjects(TriggerMuon,vref);
154  for (unsigned int i=0; i<vref.size(); i++ ) {
155  TrackRef tk = vref[i]->track();
156  LogDebug("HLTMuonL1toL3TkPreFilter")
157  << " Track passing filter: pt= " << tk->pt() << ", eta: "
158  << tk->eta();
159  }
160 
161  // filter decision
162  const bool accept ((int)n >= min_N_);
163 
164  LogDebug("HLTMuonL1toL3TkPreFilter") << " >>>>> Result of HLTMuonL1toL3TkPreFilter is " << accept << ", number of muons passing thresholds= " << n;
165 
166  return accept;
167 }
168 bool
169 HLTMuonL1toL3TkPreFilter::triggeredAtL1(const l1extra::L1MuonParticleRef & l1mu,std::vector<l1extra::L1MuonParticleRef>& vcands)
170 {
171  bool ok=false;
172 
173  // compare to previously triggered L1
174  for (unsigned int i=0; i<vcands.size(); i++) {
175  // l1extra::L1MuonParticleRef candref = L1MuonParticleRef(vcands[i]);
176  if (vcands[i] == l1mu){
177  ok=true;
178  LogDebug("HLTMuonL1toL3TkPreFilter") << "The L1 mu triggered";
179  break;}
180  }
181  return ok;
182 }
183 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
enum start value shifted to 81 so as to avoid clashes with PDG codes
HLTMuonL1toL3TkPreFilter(const edm::ParameterSet &)
edm::Ref< RecoChargedCandidateCollection > RecoChargedCandidateRef
reference to an object in a collection of RecoChargedCandidate objects
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:22
std::string encode() const
Definition: InputTag.cc:72
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref&lt;C&gt;)
int iEvent
Definition: GenABIO.cc:243
bool triggeredAtL1(const l1extra::L1MuonParticleRef &l1mu, std::vector< l1extra::L1MuonParticleRef > &vcands)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define LogTrace(id)
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
bool saveTags() const
Definition: HLTFilter.h:45
const Point & position() const
position
Definition: BeamSpot.h:63
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct)