CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetFinderMethods.cc
Go to the documentation of this file.
1 // JetFinderMethods.cc
2 // Author: Alex Barbieri
3 //
4 // This file should contain the different algorithms used to find jets.
5 // Currently the standard is the sliding window method, used by both
6 // HI and PP.
7 
11 
13 
14 #include <vector>
15 
16 namespace l1t {
17 
18  int deltaGctPhi(const CaloRegion & region, const CaloRegion & neighbor)
19  {
20  int phi1 = region.hwPhi();
21  int phi2 = neighbor.hwPhi();
22  int diff = phi1 - phi2;
23  if (std::abs(phi1 - phi2) == L1CaloRegionDetId::N_PHI-1) { //18 regions in phi
24  diff = -diff/std::abs(diff);
25  }
26  return diff;
27  }
28 
29  // turn each central region into a jet
30  void passThroughJets(const std::vector<l1t::CaloRegion> * regions,
31  std::vector<l1t::Jet> * uncalibjets)
32  {
33  for(std::vector<CaloRegion>::const_iterator region = regions->begin(); region != regions->end(); region++) {
34  int jetQual = 0;
35  if( region->hwEta() < 4 || region->hwEta() > 17)
36  jetQual = 2;
37  int jetET = region->hwPt();
38  int jetEta = region->hwEta();
39  int jetPhi = region->hwPhi();
40 
41  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > jetLorentz(0,0,0,0);
42  l1t::Jet theJet(*&jetLorentz, jetET, jetEta, jetPhi, jetQual);
43  uncalibjets->push_back(theJet);
44  }
45  }
46 
47  void slidingWindowJetFinder(const int jetSeedThreshold,
48  const std::vector<l1t::CaloRegion> * regions,
49  std::vector<l1t::Jet> * uncalibjets)
50  {
51  // std::cout << "Jet Seed: " << jetSeedThreshold << std::endl;
52  for(std::vector<CaloRegion>::const_iterator region = regions->begin(); region != regions->end(); region++) {
53  int regionET = region->hwPt(); //regionPhysicalEt(*region);
54  if (regionET <= jetSeedThreshold) continue;
55  int neighborN_et = 0;
56  int neighborS_et = 0;
57  int neighborE_et = 0;
58  int neighborW_et = 0;
59  int neighborNE_et = 0;
60  int neighborSW_et = 0;
61  int neighborNW_et = 0;
62  int neighborSE_et = 0;
63  unsigned int nNeighbors = 0;
64  for(std::vector<CaloRegion>::const_iterator neighbor = regions->begin(); neighbor != regions->end(); neighbor++) {
65  int neighborET = neighbor->hwPt(); //regionPhysicalEt(*neighbor);
66  if(deltaGctPhi(*region, *neighbor) == 1 &&
67  (region->hwEta() ) == neighbor->hwEta()) {
68  neighborN_et = neighborET;
69  nNeighbors++;
70  continue;
71  }
72  else if(deltaGctPhi(*region, *neighbor) == -1 &&
73  (region->hwEta() ) == neighbor->hwEta()) {
74  neighborS_et = neighborET;
75  nNeighbors++;
76  continue;
77  }
78  else if(deltaGctPhi(*region, *neighbor) == 0 &&
79  (region->hwEta() + 1) == neighbor->hwEta()) {
80  neighborE_et = neighborET;
81  nNeighbors++;
82  continue;
83  }
84  else if(deltaGctPhi(*region, *neighbor) == 0 &&
85  (region->hwEta() - 1) == neighbor->hwEta()) {
86  neighborW_et = neighborET;
87  nNeighbors++;
88  continue;
89  }
90  else if(deltaGctPhi(*region, *neighbor) == 1 &&
91  (region->hwEta() + 1) == neighbor->hwEta()) {
92  neighborNE_et = neighborET;
93  nNeighbors++;
94  continue;
95  }
96  else if(deltaGctPhi(*region, *neighbor) == -1 &&
97  (region->hwEta() - 1) == neighbor->hwEta()) {
98  neighborSW_et = neighborET;
99  nNeighbors++;
100  continue;
101  }
102  else if(deltaGctPhi(*region, *neighbor) == 1 &&
103  (region->hwEta() - 1) == neighbor->hwEta()) {
104  neighborNW_et = neighborET;
105  nNeighbors++;
106  continue;
107  }
108  else if(deltaGctPhi(*region, *neighbor) == -1 &&
109  (region->hwEta() + 1) == neighbor->hwEta()) {
110  neighborSE_et = neighborET;
111  nNeighbors++;
112  continue;
113  }
114  }
115  if(regionET > neighborN_et &&
116  regionET > neighborNW_et &&
117  regionET > neighborW_et &&
118  regionET > neighborSW_et &&
119  regionET >= neighborNE_et &&
120  regionET >= neighborE_et &&
121  regionET >= neighborSE_et &&
122  regionET >= neighborS_et) {
123  unsigned int jetET = regionET +
124  neighborN_et + neighborS_et + neighborE_et + neighborW_et +
125  neighborNE_et + neighborSW_et + neighborSE_et + neighborNW_et;
126 
127  int jetPhi = region->hwPhi();
128  int jetEta = region->hwEta();
129 
130  bool neighborCheck = (nNeighbors == 8);
131  // On the eta edge we only expect 5 neighbors
132  if (!neighborCheck && (jetEta == 0 || jetEta == 21) && nNeighbors == 5)
133  neighborCheck = true;
134 
135  if (!neighborCheck) {
136  std::cout << "phi: " << jetPhi << " eta: " << jetEta << " n: " << nNeighbors << std::endl;
137  assert(false);
138  }
139 
140  //first iteration, eta cut defines forward
141  //const bool forward = (jetEta <= 4 || jetEta >= 17);
142  const bool forward = (jetEta < 4 || jetEta > 17);
143  int jetQual = 0;
144  if(forward)
145  jetQual |= 0x2;
146 
147  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > jetLorentz(0,0,0,0);
148  l1t::Jet theJet(*&jetLorentz, jetET, jetEta, jetPhi, jetQual);
149  //l1t::Jet theJet(0, jetET, jetEta, jetPhi);
150 
151  uncalibjets->push_back(theJet);
152  }
153  }
154  }
155 
156  void TwelveByTwelveFinder(const int jetSeedThreshold,
157  const std::vector<l1t::CaloRegion> * regions,
158  std::vector<l1t::Jet> * uncalibjets)
159  {
160  // std::cout << "Jet Seed: " << jetSeedThreshold << std::endl;
161  for(std::vector<CaloRegion>::const_iterator region = regions->begin(); region != regions->end(); region++) {
162  int regionET = region->hwPt(); //regionPhysicalEt(*region);
163  if (regionET < jetSeedThreshold) continue;
164  int neighborN_et = 0;
165  int neighborS_et = 0;
166  int neighborE_et = 0;
167  int neighborW_et = 0;
168  int neighborNE_et = 0;
169  int neighborSW_et = 0;
170  int neighborNW_et = 0;
171  int neighborSE_et = 0;
172  unsigned int nNeighbors = 0;
173  for(std::vector<CaloRegion>::const_iterator neighbor = regions->begin(); neighbor != regions->end(); neighbor++) {
174  int neighborET = neighbor->hwPt(); //regionPhysicalEt(*neighbor);
175  if(deltaGctPhi(*region, *neighbor) == 1 &&
176  (region->hwEta() ) == neighbor->hwEta()) {
177  neighborN_et = neighborET;
178  nNeighbors++;
179  continue;
180  }
181  else if(deltaGctPhi(*region, *neighbor) == -1 &&
182  (region->hwEta() ) == neighbor->hwEta()) {
183  neighborS_et = neighborET;
184  nNeighbors++;
185  continue;
186  }
187  else if(deltaGctPhi(*region, *neighbor) == 0 &&
188  (region->hwEta() + 1) == neighbor->hwEta()) {
189  neighborE_et = neighborET;
190  nNeighbors++;
191  continue;
192  }
193  else if(deltaGctPhi(*region, *neighbor) == 0 &&
194  (region->hwEta() - 1) == neighbor->hwEta()) {
195  neighborW_et = neighborET;
196  nNeighbors++;
197  continue;
198  }
199  else if(deltaGctPhi(*region, *neighbor) == 1 &&
200  (region->hwEta() + 1) == neighbor->hwEta()) {
201  neighborNE_et = neighborET;
202  nNeighbors++;
203  continue;
204  }
205  else if(deltaGctPhi(*region, *neighbor) == -1 &&
206  (region->hwEta() - 1) == neighbor->hwEta()) {
207  neighborSW_et = neighborET;
208  nNeighbors++;
209  continue;
210  }
211  else if(deltaGctPhi(*region, *neighbor) == 1 &&
212  (region->hwEta() - 1) == neighbor->hwEta()) {
213  neighborNW_et = neighborET;
214  nNeighbors++;
215  continue;
216  }
217  else if(deltaGctPhi(*region, *neighbor) == -1 &&
218  (region->hwEta() + 1) == neighbor->hwEta()) {
219  neighborSE_et = neighborET;
220  nNeighbors++;
221  continue;
222  }
223  }
224  unsigned int jetET = regionET +
225  neighborN_et + neighborS_et + neighborE_et + neighborW_et +
226  neighborNE_et + neighborSW_et + neighborSE_et + neighborNW_et;
227 
228  int jetPhi = region->hwPhi();
229  int jetEta = region->hwEta();
230 
231  bool neighborCheck = (nNeighbors == 8);
232  // On the eta edge we only expect 5 neighbors
233  if (!neighborCheck && (jetEta == 0 || jetEta == 21) && nNeighbors == 5)
234  neighborCheck = true;
235 
236  if (!neighborCheck) {
237  std::cout << "phi: " << jetPhi << " eta: " << jetEta << " n: " << nNeighbors << std::endl;
238  assert(false);
239  }
240 
241  //first iteration, eta cut defines forward
242  //const bool forward = (jetEta <= 4 || jetEta >= 17);
243  const bool forward = (jetEta < 4 || jetEta > 17);
244  int jetQual = 0;
245  if(forward)
246  jetQual |= 0x2;
247 
248  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > jetLorentz(0,0,0,0);
249  l1t::Jet theJet(*&jetLorentz, jetET, jetEta, jetPhi, jetQual);
250  //l1t::Jet theJet(0, jetET, jetEta, jetPhi);
251 
252  uncalibjets->push_back(theJet);
253  }
254  }
255 }
int hwPhi() const
Definition: L1Candidate.cc:79
void TwelveByTwelveFinder(const int, const std::vector< l1t::CaloRegion > *regions, std::vector< l1t::Jet > *uncalibjets)
Definition: Jet.h:13
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void passThroughJets(const std::vector< l1t::CaloRegion > *regions, std::vector< l1t::Jet > *uncalibjets)
int deltaGctPhi(const CaloRegion &region, const CaloRegion &neighbor)
void slidingWindowJetFinder(const int, const std::vector< l1t::CaloRegion > *regions, std::vector< l1t::Jet > *uncalibjets)
tuple cout
Definition: gather_cfg.py:121
static const unsigned N_PHI