CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1GctTdrJetFinder.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 
5 //DEFINE STATICS
6 // *** Note the following definition in terms of COL_OFFSET appears not to work ***
7 // *** for some deep C++ reason that I don't understand - GPH ***
8 // const unsigned int L1GctTdrJetFinder::MAX_REGIONS_IN = L1GctJetFinderBase::COL_OFFSET*L1GctTdrJetFinder::N_COLS;
9 // *** So - use the following instead ***
10 const unsigned int L1GctTdrJetFinder::MAX_REGIONS_IN =
12 
13 const unsigned int L1GctTdrJetFinder::N_COLS = 4;
14 const unsigned int L1GctTdrJetFinder::CENTRAL_COL0 = 1;
15 
17  this->reset();
18  // Initialise parameters for Region input calculations in the
19  // derived class so we get the right values of constants.
20  static const unsigned NPHI = L1CaloRegionDetId::N_PHI;
21  m_minColThisJf = (NPHI + m_id * 2 - CENTRAL_COL0) % NPHI;
22 }
23 
25 
26 ostream& operator<<(ostream& os, const L1GctTdrJetFinder& algo) {
27  os << "===L1GctTdrJetFinder===" << endl;
28  const L1GctJetFinderBase* temp = &algo;
29  os << *temp;
30  return os;
31 }
32 
34 
36  if (setupOk()) {
37  findJets();
38  sortJets();
39  doEnergySums();
40  }
41 }
42 
44 
46  UShort jetNum = 0; //holds the number of jets currently found
47  UShort centreIndex = COL_OFFSET * this->centralCol0();
48  for (UShort column = 0; column < 2; ++column) //Find jets in the central search region
49  {
50  //don't include row zero as it is not in the search region
51  ++centreIndex;
52  for (UShort row = 1; row < COL_OFFSET; ++row) {
53  //Determine if we are at end of the HF or not (so need 3*2 window)
54  bool hfBoundary = (row == COL_OFFSET - 1);
55  //Determine if we are at the end of the endcap HCAL regions, so need boundary condition tauveto
56  bool heBoundary = (row == COL_OFFSET - 5);
57 
58  //debug checks for improper input indices
59  if ((centreIndex % COL_OFFSET != 0) //Don't want the 4 regions from other half of detector
60  && (centreIndex >= COL_OFFSET) //Don't want the shared column to left of jet finding area
61  && (centreIndex < (MAX_REGIONS_IN - COL_OFFSET))) { //Don't want column to the right either
62 
63  if (detectJet(centreIndex, hfBoundary)) {
64  if (jetNum < MAX_JETS_OUT) {
65  m_outputJets.at(jetNum).setRawsum(calcJetEnergy(centreIndex, hfBoundary));
66  m_outputJets.at(jetNum).setDetId(calcJetPosition(centreIndex));
67  m_outputJets.at(jetNum).setBx(m_inputRegions.at(centreIndex).bx());
68  if (row < COL_OFFSET - 4) //if we are not in the HF, perform tauVeto analysis
69  {
70  m_outputJets.at(jetNum).setForward(false);
71  m_outputJets.at(jetNum).setTauVeto(calcJetTauVeto(centreIndex, heBoundary));
72  } else //can't be a tau jet because we are in the HF
73  {
74  m_outputJets.at(jetNum).setForward(true);
75  m_outputJets.at(jetNum).setTauVeto(true);
76  }
77  ++jetNum;
78  }
79  }
80  ++centreIndex;
81  }
82  }
83  }
84 }
85 
86 // Returns true if region index is the centre of a jet. Set boundary = true if at edge of HCAL.
87 bool L1GctTdrJetFinder::detectJet(const UShort centreIndex, const bool boundary) const {
88  if (!boundary) //Not at boundary, so use 3*3 window of regions to determine if a jet
89  {
90  // Get the energy of the central region
91  ULong testEt = m_inputRegions.at(centreIndex).et();
92 
93  //Test if our region qualifies as a jet by comparing its energy with the energies of the
94  //surrounding eight regions. In the event of neighbouring regions with identical energy,
95  //this will locate the jet in the lower-most (furthest away from eta=0), left-most (least phi) region.
96  if (testEt > m_inputRegions.at(centreIndex - 1 - COL_OFFSET).et() &&
97  testEt > m_inputRegions.at(centreIndex - COL_OFFSET).et() &&
98  testEt > m_inputRegions.at(centreIndex + 1 - COL_OFFSET).et() &&
99 
100  testEt >= m_inputRegions.at(centreIndex - 1).et() && testEt > m_inputRegions.at(centreIndex + 1).et() &&
101 
102  testEt >= m_inputRegions.at(centreIndex - 1 + COL_OFFSET).et() &&
103  testEt >= m_inputRegions.at(centreIndex + COL_OFFSET).et() &&
104  testEt >= m_inputRegions.at(centreIndex + 1 + COL_OFFSET).et()) {
105  return true;
106  }
107  //USE THIS BLOCK INSTEAD IF YOU WANT OVERFLOW BIT FUNCTIONALITY
108  //*** BUT IT WILL NEED MODIFICATION SINCE L1GctRegion IS OBSOLETE ***
109  /* // Get the energy of the central region & OR the overflow bit to become the MSB
110  ULong testEt = (m_inputRegions.at(centreIndex).et() | (m_inputRegions.at(centreIndex).getOverFlow() << L1GctRegion::ET_BITWIDTH));
111 
112  //Test if our region qualifies as a jet by comparing its energy with the energies of the
113  //surrounding eight regions. In the event of neighbouring regions with identical energy,
114  //this will locate the jet in the lower-most (furthest away from eta=0), left-most (least phi) region.
115  if(testEt > (m_inputRegions.at(centreIndex-1-COL_OFFSET).et() | (m_inputRegions.at(centreIndex-1-COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
116  testEt > (m_inputRegions.at(centreIndex - COL_OFFSET).et() | (m_inputRegions.at(centreIndex - COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
117  testEt > (m_inputRegions.at(centreIndex+1-COL_OFFSET).et() | (m_inputRegions.at(centreIndex+1-COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
118 
119  testEt >= (m_inputRegions.at(centreIndex - 1).et() | (m_inputRegions.at(centreIndex - 1).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
120  testEt > (m_inputRegions.at(centreIndex + 1).et() | (m_inputRegions.at(centreIndex + 1).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
121 
122  testEt >= (m_inputRegions.at(centreIndex-1+COL_OFFSET).et() | (m_inputRegions.at(centreIndex-1+COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
123  testEt >= (m_inputRegions.at(centreIndex + COL_OFFSET).et() | (m_inputRegions.at(centreIndex + COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
124  testEt >= (m_inputRegions.at(centreIndex+1+COL_OFFSET).et() | (m_inputRegions.at(centreIndex+1+COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)))
125  {
126  return true;
127  }
128 */ //END OVERFLOW FUNCTIONALITY
129  } else //...so only test surround 5 regions in our jet testing.
130  {
131  // Get the energy of the central region
132  // Don't need all the overflow bit adjustments as above, since we are in the HF here
133  ULong testEt = m_inputRegions.at(centreIndex).et();
134 
135  if (testEt > m_inputRegions.at(centreIndex - 1 - COL_OFFSET).et() &&
136  testEt > m_inputRegions.at(centreIndex - COL_OFFSET).et() &&
137 
138  testEt >= m_inputRegions.at(centreIndex - 1).et() &&
139 
140  testEt >= m_inputRegions.at(centreIndex - 1 + COL_OFFSET).et() &&
141  testEt >= m_inputRegions.at(centreIndex + COL_OFFSET).et()) {
142  return true;
143  }
144  }
145  return false;
146 }
147 
148 //returns the energy sum of the nine regions centred (physically) about centreIndex
149 L1GctJetFinderBase::ULong L1GctTdrJetFinder::calcJetEnergy(const UShort centreIndex, const bool boundary) const {
150  ULong energy = 0;
151 
152  if (!boundary) {
153  for (int column = -1; column <= +1; ++column) {
154  energy += m_inputRegions.at(centreIndex - 1 + (column * COL_OFFSET)).et() +
155  m_inputRegions.at(centreIndex + (column * COL_OFFSET)).et() +
156  m_inputRegions.at(centreIndex + 1 + (column * COL_OFFSET)).et();
157  }
158  } else {
159  for (int column = -1; column <= +1; ++column) {
160  energy += m_inputRegions.at(centreIndex - 1 + (column * COL_OFFSET)).et() +
161  m_inputRegions.at(centreIndex + (column * COL_OFFSET)).et();
162  }
163  }
164 
165  return energy;
166 }
167 
168 // returns the encoded (eta, phi) position of the centre region
170  return m_inputRegions.at(centreIndex).id();
171 }
172 
173 // returns the combined tauveto of the nine regions centred (physically) about centreIndex. Set boundary = true if at edge of Endcap.
174 bool L1GctTdrJetFinder::calcJetTauVeto(const UShort centreIndex, const bool boundary) const {
175  bool partial[3] = {false, false, false};
176 
177  if (!boundary) {
178  for (int column = -1; column <= +1; ++column) {
179  partial[column + 1] = m_inputRegions.at(centreIndex - 1 + (column * COL_OFFSET)).tauVeto() ||
180  m_inputRegions.at(centreIndex + (column * COL_OFFSET)).tauVeto() ||
181  m_inputRegions.at(centreIndex + 1 + (column * COL_OFFSET)).tauVeto();
182  }
183  } else {
184  for (int column = -1; column <= +1; ++column) {
185  partial[column + 1] = m_inputRegions.at(centreIndex - 1 + (column * COL_OFFSET)).tauVeto() ||
186  m_inputRegions.at(centreIndex + (column * COL_OFFSET)).tauVeto();
187  }
188  }
189  return partial[0] || partial[1] || partial[2];
190 }
void reset()
complete reset of processor
3*3 sliding window algorithm jet finder.
static const unsigned int MAX_JETS_OUT
Max of 6 jets found per jetfinder in a 2*11 search area.
static const unsigned int MAX_REGIONS_IN
The real jetFinders must define these constants.
unsigned long int ULong
~L1GctTdrJetFinder() override
void findJets()
Here is the TDR 3x3 sliding window jet finder algorithm.
bool calcJetTauVeto(const UShort centreIndex, const bool boundary=false) const
Returns combined tauVeto of the 9 regions centred (physically) about centreIndex. Set boundary = true...
bool setupOk() const
Check setup is Ok.
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
static const unsigned N_ETA
Base class to allow implementation of jetFinder algorithms.
ULong calcJetEnergy(const UShort centreIndex, const bool boundary=false) const
Returns energy sum of the 9 regions centred (physically) about centreIndex. Set boundary = true if at...
static const unsigned int CENTRAL_COL0
void process() override
process the data, fill output buffers
void sortJets()
Sort the found jets. All jetFinders should call this in process().
unsigned short int UShort
bool detectJet(const UShort centreIndex, const bool boundary=false) const
Returns true if region index is the centre of a jet. Set boundary = true if at edge of HCAL...
static const unsigned int COL_OFFSET
The index offset between columns.
RawJetVector m_outputJets
output jets
RegionsVector m_inputRegions
unsigned centralCol0() const override
void fetchInput() override
get input data from sources
L1CaloRegionDetId calcJetPosition(const UShort centreIndex) const
returns the encoded (eta, phi) position of the centre region
static const unsigned N_PHI
unsigned m_minColThisJf
parameter to determine which Regions belong in our acceptance
void doEnergySums()
Fill the Et strip sums and Ht sum. All jetFinders should call this in process().
static const unsigned int N_COLS
L1GctTdrJetFinder(int id)
id is 0-8 for -ve Eta jetfinders, 9-17 for +ve Eta, for increasing Phi.