CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTEgammaL1MatchFilterRegional.cc
Go to the documentation of this file.
1 
9 
10 //#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
11 
13 
15 
18 
20 
23 
28 
29 
30 #define TWOPI 6.283185308
31 //
32 // constructors and destructor
33 //
35 {
36  candIsolatedTag_ = iConfig.getParameter< edm::InputTag > ("candIsolatedTag");
37  l1IsolatedTag_ = iConfig.getParameter< edm::InputTag > ("l1IsolatedTag");
38  candNonIsolatedTag_ = iConfig.getParameter< edm::InputTag > ("candNonIsolatedTag");
39  l1NonIsolatedTag_ = iConfig.getParameter< edm::InputTag > ("l1NonIsolatedTag");
40  L1SeedFilterTag_ = iConfig.getParameter< edm::InputTag > ("L1SeedFilterTag");
41  l1CenJetsTag_ = iConfig.getParameter< edm::InputTag > ("l1CenJetsTag");
42  ncandcut_ = iConfig.getParameter<int> ("ncandcut");
43  doIsolated_ = iConfig.getParameter<bool>("doIsolated");
44  region_eta_size_ = iConfig.getParameter<double> ("region_eta_size");
45  region_eta_size_ecap_ = iConfig.getParameter<double> ("region_eta_size_ecap");
46  region_phi_size_ = iConfig.getParameter<double> ("region_phi_size");
47  barrel_end_ = iConfig.getParameter<double> ("barrel_end");
48  endcap_end_ = iConfig.getParameter<double> ("endcap_end");
49 
50  candIsolatedToken_ = consumes<reco::RecoEcalCandidateCollection>(candIsolatedTag_);
51  if(!doIsolated_) candNonIsolatedToken_ = consumes<reco::RecoEcalCandidateCollection>(candNonIsolatedTag_);
52  L1SeedFilterToken_ = consumes<trigger::TriggerFilterObjectWithRefs>(L1SeedFilterTag_);
53 }
54 
56 
57 void
61  desc.add<edm::InputTag>("candIsolatedTag",edm::InputTag("hltRecoIsolatedEcalCandidate"));
62  desc.add<edm::InputTag>("l1IsolatedTag",edm::InputTag("l1extraParticles","Isolated"));
63  desc.add<edm::InputTag>("candNonIsolatedTag",edm::InputTag("hltRecoNonIsolatedEcalCandidate"));
64  desc.add<edm::InputTag>("l1NonIsolatedTag",edm::InputTag("l1extraParticles","NonIsolated"));
65  desc.add<edm::InputTag>("L1SeedFilterTag",edm::InputTag("theL1SeedFilter"));
66  desc.add<edm::InputTag>("l1CenJetsTag",edm::InputTag("hltL1extraParticles","Central"));
67  desc.add<int>("ncandcut",1);
68  desc.add<bool>("doIsolated",true);
69  desc.add<double>("region_eta_size",0.522);
70  desc.add<double>("region_eta_size_ecap",1.0);
71  desc.add<double>("region_phi_size",1.044);
72  desc.add<double>("barrel_end",1.4791);
73  desc.add<double>("endcap_end",2.65);
74  descriptions.add("hltEgammaL1MatchFilterRegional",desc);
75 }
76 
77 // ------------ method called to produce the data ------------
78 //configuration:
79 //doIsolated=true, only isolated superclusters are allowed to match isolated L1 seeds
80 //doIsolated=false, isolated superclusters are allowed to match either iso or non iso L1 seeds, non isolated superclusters are allowed only to match non-iso seeds. If no collection name is given for non-isolated superclusters, assumes the the isolated collection contains all (both iso + non iso) seeded superclusters.
81 bool
83 {
84  // std::cout <<"runnr "<<iEvent.id().run()<<" event "<<iEvent.id().event()<<std::endl;
85  using namespace trigger;
86  using namespace l1extra;
87 
88  if (saveTags()) {
89  filterproduct.addCollectionTag(l1IsolatedTag_);
90  if (not doIsolated_)
91  filterproduct.addCollectionTag(l1NonIsolatedTag_);
92  filterproduct.addCollectionTag(l1CenJetsTag_);
93  }
94 
96 
97  // Get the CaloGeometry
99  iSetup.get<L1CaloGeometryRecord>().get(l1CaloGeom) ;
100 
101 
102  // look at all candidates, check cuts and add to filter object
103  int n(0);
104 
105  // Get the recoEcalCandidates
107  iEvent.getByToken(candIsolatedToken_,recoIsolecalcands);
108 
109 
111  iEvent.getByToken (L1SeedFilterToken_,L1SeedOutput);
112 
113  std::vector<l1extra::L1EmParticleRef > l1EGIso;
114  L1SeedOutput->getObjects(TriggerL1IsoEG, l1EGIso);
115 
116  std::vector<l1extra::L1EmParticleRef > l1EGNonIso;
117  L1SeedOutput->getObjects(TriggerL1NoIsoEG, l1EGNonIso);
118 
119  std::vector<l1extra::L1JetParticleRef> l1Jets;
120  L1SeedOutput->getObjects(TriggerL1CenJet, l1Jets);
121 
122  for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand= recoIsolecalcands->begin(); recoecalcand!=recoIsolecalcands->end(); recoecalcand++) {
123 
124 
125  if(fabs(recoecalcand->eta()) < endcap_end_){
126  //SC should be inside the ECAL fiducial volume
127 
128  bool matchedSCIso = matchedToL1Cand(l1EGIso,recoecalcand->eta(),recoecalcand->phi());
129 
130  //now due to SC cleaning given preference to isolated candiates,
131  //if there is an isolated and nonisolated L1 cand in the same eta/phi bin
132  //the corresponding SC will be only in the isolated SC collection
133  //so if we are !doIsolated_, we need to run over the nonisol L1 collection as well
134  bool matchedSCNonIso=false;
135  if(!doIsolated_){
136  matchedSCNonIso = matchedToL1Cand(l1EGNonIso,recoecalcand->eta(),recoecalcand->phi());
137  }
138 
139  bool matchedSCJet = matchedToL1Cand(l1Jets,recoecalcand->eta(),recoecalcand->phi());
140  // if(matchedSCJet) std::cout <<"matched jet "<<this->moduleDescription().moduleLabel()<<std::endl;
141 
142  if(matchedSCIso || matchedSCNonIso || matchedSCJet) {
143  n++;
144 
145  ref = edm::Ref<reco::RecoEcalCandidateCollection>(recoIsolecalcands, distance(recoIsolecalcands->begin(),recoecalcand) );
146  filterproduct.addObject(TriggerCluster, ref);
147  }//end matched check
148 
149  }//end endcap fiduical check
150 
151  }//end loop over all isolated RecoEcalCandidates
152 
153  //if doIsolated_ is false now run over the nonisolated superclusters and non isolated L1 seeds
154  //however in the case we have a single collection of superclusters containing both iso L1 and non iso L1 seeded superclusters,
155  //we specific doIsolated=false to match to isolated superclusters to non isolated seeds in the above loop
156  //however we do not have a non isolated collection of superclusters so we have to protect against that
157  if(!doIsolated_ && !candNonIsolatedTag_.label().empty()) {
158 
160  iEvent.getByToken(candNonIsolatedToken_,recoNonIsolecalcands);
161 
162  for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand= recoNonIsolecalcands->begin(); recoecalcand!=recoNonIsolecalcands->end(); recoecalcand++) {
163  if(fabs(recoecalcand->eta()) < endcap_end_){
164  bool matchedSCNonIso = matchedToL1Cand(l1EGNonIso,recoecalcand->eta(),recoecalcand->phi());
165 
166  bool matchedSCJet = matchedToL1Cand(l1Jets,recoecalcand->eta(),recoecalcand->phi());
167 
168 
169  if(matchedSCNonIso || matchedSCJet) {
170  n++;
171  ref = edm::Ref<reco::RecoEcalCandidateCollection>(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(),recoecalcand) );
172  filterproduct.addObject(TriggerCluster, ref);
173  }//end matched check
174 
175  }//end endcap fiduical check
176 
177  }//end loop over all isolated RecoEcalCandidates
178  }//end doIsolatedCheck
179 
180 
181  // filter decision
182  bool accept(n>=ncandcut_);
183 
184  return accept;
185 }
186 
187 
188 bool
189 HLTEgammaL1MatchFilterRegional::matchedToL1Cand(const std::vector<l1extra::L1EmParticleRef >& l1Cands,const float scEta,const float scPhi) const
190 {
191  for (unsigned int i=0; i<l1Cands.size(); i++) {
192  //ORCA matching method
193  double etaBinLow = 0.;
194  double etaBinHigh = 0.;
195  if(fabs(scEta) < barrel_end_){
196  etaBinLow = l1Cands[i]->eta() - region_eta_size_/2.;
197  etaBinHigh = etaBinLow + region_eta_size_;
198  }
199  else{
200  etaBinLow = l1Cands[i]->eta() - region_eta_size_ecap_/2.;
201  etaBinHigh = etaBinLow + region_eta_size_ecap_;
202  }
203 
204  float deltaphi=fabs(scPhi -l1Cands[i]->phi());
205  if(deltaphi>TWOPI) deltaphi-=TWOPI;
206  if(deltaphi>TWOPI/2.) deltaphi=TWOPI-deltaphi;
207 
208  if(scEta < etaBinHigh && scEta > etaBinLow && deltaphi <region_phi_size_/2. ) {
209  return true;
210  }
211  }
212  return false;
213 }
214 
215 bool
216 HLTEgammaL1MatchFilterRegional::matchedToL1Cand(const std::vector<l1extra::L1JetParticleRef >& l1Cands,const float scEta,const float scPhi) const
217 {
218  for (unsigned int i=0; i<l1Cands.size(); i++) {
219  //ORCA matching method
220  double etaBinLow = 0.;
221  double etaBinHigh = 0.;
222  if(fabs(scEta) < barrel_end_){
223  etaBinLow = l1Cands[i]->eta() - region_eta_size_/2.;
224  etaBinHigh = etaBinLow + region_eta_size_;
225  }
226  else{
227  etaBinLow = l1Cands[i]->eta() - region_eta_size_ecap_/2.;
228  etaBinHigh = etaBinLow + region_eta_size_ecap_;
229  }
230 
231  float deltaphi=fabs(scPhi -l1Cands[i]->phi());
232  if(deltaphi>TWOPI) deltaphi-=TWOPI;
233  if(deltaphi>TWOPI/2.) deltaphi=TWOPI-deltaphi;
234 
235  if(scEta < etaBinHigh && scEta > etaBinLow && deltaphi <region_phi_size_/2. ) {
236  return true;
237  }
238  }
239  return false;
240 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > L1SeedFilterToken_
HLTEgammaL1MatchFilterRegional(const edm::ParameterSet &)
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > candNonIsolatedToken_
bool matchedToL1Cand(const std::vector< l1extra::L1EmParticleRef > &l1Cands, const float scEta, const float scPhi) const
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:24
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:230
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > candIsolatedToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:29
const T & get() const
Definition: EventSetup.h:56
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string const & label() const
Definition: InputTag.h:43
bool saveTags() const
Definition: HLTFilter.h:45
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override