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 
10 
11 //#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
12 
14 
16 
18 
21 
22 
23 
26 
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  ncandcut_ = iConfig.getParameter<int> ("ncandcut");
42  doIsolated_ = iConfig.getParameter<bool>("doIsolated");
43 
44 
45  region_eta_size_ = iConfig.getParameter<double> ("region_eta_size");
46  region_eta_size_ecap_ = iConfig.getParameter<double> ("region_eta_size_ecap");
47  region_phi_size_ = iConfig.getParameter<double> ("region_phi_size");
48  barrel_end_ = iConfig.getParameter<double> ("barrel_end");
49  endcap_end_ = iConfig.getParameter<double> ("endcap_end");
50 }
51 
53 
54 
55 // ------------ method called to produce the data ------------
56 //configuration:
57 //doIsolated=true, only isolated superclusters are allowed to match isolated L1 seeds
58 //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.
59 bool
61 {
62  // std::cout <<"runnr "<<iEvent.id().run()<<" event "<<iEvent.id().event()<<std::endl;
63  using namespace trigger;
64  using namespace l1extra;
65 
66  if (saveTags()) {
67  filterproduct.addCollectionTag(l1IsolatedTag_);
68  if (not doIsolated_)
69  filterproduct.addCollectionTag(l1NonIsolatedTag_);
70  }
71 
73 
74  // Get the CaloGeometry
76  iSetup.get<L1CaloGeometryRecord>().get(l1CaloGeom) ;
77 
78 
79  // look at all candidates, check cuts and add to filter object
80  int n(0);
81 
82  // Get the recoEcalCandidates
84  iEvent.getByLabel(candIsolatedTag_,recoIsolecalcands);
85 
86 
88 
89  iEvent.getByLabel (L1SeedFilterTag_,L1SeedOutput);
90 
91  std::vector<l1extra::L1EmParticleRef > l1EGIso;
92  L1SeedOutput->getObjects(TriggerL1IsoEG, l1EGIso);
93 
94  std::vector<l1extra::L1EmParticleRef > l1EGNonIso;
95  L1SeedOutput->getObjects(TriggerL1NoIsoEG, l1EGNonIso);
96 
97 
98  for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand= recoIsolecalcands->begin(); recoecalcand!=recoIsolecalcands->end(); recoecalcand++) {
99 
100 
101  if(fabs(recoecalcand->eta()) < endcap_end_){
102  //SC should be inside the ECAL fiducial volume
103 
104  bool matchedSCIso = matchedToL1Cand(l1EGIso,recoecalcand->eta(),recoecalcand->phi());
105 
106  //now due to SC cleaning given preference to isolated candiates,
107  //if there is an isolated and nonisolated L1 cand in the same eta/phi bin
108  //the corresponding SC will be only in the isolated SC collection
109  //so if we are !doIsolated_, we need to run over the nonisol L1 collection as well
110  bool matchedSCNonIso=false;
111  if(!doIsolated_){
112  matchedSCNonIso = matchedToL1Cand(l1EGNonIso,recoecalcand->eta(),recoecalcand->phi());
113  }
114 
115 
116  if(matchedSCIso || matchedSCNonIso) {
117  n++;
118 
119  ref = edm::Ref<reco::RecoEcalCandidateCollection>(recoIsolecalcands, distance(recoIsolecalcands->begin(),recoecalcand) );
120  filterproduct.addObject(TriggerCluster, ref);
121  }//end matched check
122 
123  }//end endcap fiduical check
124 
125  }//end loop over all isolated RecoEcalCandidates
126 
127  //if doIsolated_ is false now run over the nonisolated superclusters and non isolated L1 seeds
128  //however in the case we have a single collection of superclusters containing both iso L1 and non iso L1 seeded superclusters,
129  //we specific doIsolated=false to match to isolated superclusters to non isolated seeds in the above loop
130  //however we do not have a non isolated collection of superclusters so we have to protect against that
131  if(!doIsolated_ && !candNonIsolatedTag_.label().empty()) {
132 
134  iEvent.getByLabel(candNonIsolatedTag_,recoNonIsolecalcands);
135 
136  for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand= recoNonIsolecalcands->begin(); recoecalcand!=recoNonIsolecalcands->end(); recoecalcand++) {
137  if(fabs(recoecalcand->eta()) < endcap_end_){
138  bool matchedSCNonIso = matchedToL1Cand(l1EGNonIso,recoecalcand->eta(),recoecalcand->phi());
139 
140  if(matchedSCNonIso) {
141  n++;
142  ref = edm::Ref<reco::RecoEcalCandidateCollection>(recoNonIsolecalcands, distance(recoNonIsolecalcands->begin(),recoecalcand) );
143  filterproduct.addObject(TriggerCluster, ref);
144  }//end matched check
145 
146  }//end endcap fiduical check
147 
148  }//end loop over all isolated RecoEcalCandidates
149  }//end doIsolatedCheck
150 
151 
152  // filter decision
153  bool accept(n>=ncandcut_);
154 
155  return accept;
156 }
157 
158 
159 bool
160 HLTEgammaL1MatchFilterRegional::matchedToL1Cand(const std::vector<l1extra::L1EmParticleRef >& l1Cands,const float scEta,const float scPhi)
161 {
162  for (unsigned int i=0; i<l1Cands.size(); i++) {
163  //ORCA matching method
164  double etaBinLow = 0.;
165  double etaBinHigh = 0.;
166  if(fabs(scEta) < barrel_end_){
167  etaBinLow = l1Cands[i]->eta() - region_eta_size_/2.;
168  etaBinHigh = etaBinLow + region_eta_size_;
169  }
170  else{
171  etaBinLow = l1Cands[i]->eta() - region_eta_size_ecap_/2.;
172  etaBinHigh = etaBinLow + region_eta_size_ecap_;
173  }
174 
175  float deltaphi=fabs(scPhi -l1Cands[i]->phi());
176  if(deltaphi>TWOPI) deltaphi-=TWOPI;
177  if(deltaphi>TWOPI/2.) deltaphi=TWOPI-deltaphi;
178 
179  if(scEta < etaBinHigh && scEta > etaBinLow && deltaphi <region_phi_size_/2. ) {
180  return true;
181  }
182  }
183  return false;
184 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
HLTEgammaL1MatchFilterRegional(const edm::ParameterSet &)
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct)
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:22
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref&lt;C&gt;)
bool matchedToL1Cand(const std::vector< l1extra::L1EmParticleRef > &l1Cands, const float scEta, const float scPhi)
int iEvent
Definition: GenABIO.cc:243
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const T & get() const
Definition: EventSetup.h:55
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
std::string const & label() const
Definition: InputTag.h:25
bool saveTags() const
Definition: HLTFilter.h:45
Definition: DDAxes.h:10