test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 ***
11 
12 const unsigned int L1GctTdrJetFinder::N_COLS = 4;
13 const unsigned int L1GctTdrJetFinder::CENTRAL_COL0 = 1;
14 
17 {
18  this->reset();
19  // Initialise parameters for Region input calculations in the
20  // derived class so we get the right values of constants.
21  static const unsigned NPHI = L1CaloRegionDetId::N_PHI;
22  m_minColThisJf = (NPHI + m_id*2 - CENTRAL_COL0) % NPHI;
23 }
24 
26 {
27 }
28 
29 ostream& operator << (ostream& os, const L1GctTdrJetFinder& algo)
30 {
31  os << "===L1GctTdrJetFinder===" << endl;
32  const L1GctJetFinderBase* temp = &algo;
33  os << *temp;
34  return os;
35 }
36 
38 {
39 }
40 
42 {
43  if (setupOk()) {
44  findJets();
45  sortJets();
46  doEnergySums();
47  }
48 }
49 
51 
53 {
54  UShort jetNum = 0; //holds the number of jets currently found
55  UShort centreIndex = COL_OFFSET*this->centralCol0();
56  for(UShort column = 0; column <2; ++column) //Find jets in the central search region
57  {
58  //don't include row zero as it is not in the search region
59  ++centreIndex;
60  for (UShort row = 1; row < COL_OFFSET; ++row)
61  {
62  //Determine if we are at end of the HF or not (so need 3*2 window)
63  bool hfBoundary = (row == COL_OFFSET-1);
64  //Determine if we are at the end of the endcap HCAL regions, so need boundary condition tauveto
65  bool heBoundary = (row == COL_OFFSET-5);
66 
67  //debug checks for improper input indices
68  if ((centreIndex % COL_OFFSET != 0) //Don't want the 4 regions from other half of detector
69  && (centreIndex >= COL_OFFSET) //Don't want the shared column to left of jet finding area
70  && (centreIndex < (MAX_REGIONS_IN - COL_OFFSET))) { //Don't want column to the right either
71 
72  if(detectJet(centreIndex, hfBoundary))
73  {
74  if (jetNum < MAX_JETS_OUT) {
75 
76  m_outputJets.at(jetNum).setRawsum(calcJetEnergy(centreIndex, hfBoundary));
77  m_outputJets.at(jetNum).setDetId(calcJetPosition(centreIndex));
78  m_outputJets.at(jetNum).setBx(m_inputRegions.at(centreIndex).bx());
79  if(row < COL_OFFSET-4) //if we are not in the HF, perform tauVeto analysis
80  {
81  m_outputJets.at(jetNum).setForward(false);
82  m_outputJets.at(jetNum).setTauVeto(calcJetTauVeto(centreIndex,heBoundary));
83  }
84  else //can't be a tau jet because we are in the HF
85  {
86  m_outputJets.at(jetNum).setForward(true);
87  m_outputJets.at(jetNum).setTauVeto(true);
88  }
89  ++jetNum;
90  }
91  }
92  ++centreIndex;
93  }
94  }
95  }
96 }
97 
98 // Returns true if region index is the centre of a jet. Set boundary = true if at edge of HCAL.
99 bool L1GctTdrJetFinder::detectJet(const UShort centreIndex, const bool boundary) const
100 {
101  if(!boundary) //Not at boundary, so use 3*3 window of regions to determine if a jet
102  {
103  // Get the energy of the central region
104  ULong testEt = m_inputRegions.at(centreIndex).et();
105 
106  //Test if our region qualifies as a jet by comparing its energy with the energies of the
107  //surrounding eight regions. In the event of neighbouring regions with identical energy,
108  //this will locate the jet in the lower-most (furthest away from eta=0), left-most (least phi) region.
109  if(testEt > m_inputRegions.at(centreIndex-1-COL_OFFSET).et() &&
110  testEt > m_inputRegions.at(centreIndex - COL_OFFSET).et() &&
111  testEt > m_inputRegions.at(centreIndex+1-COL_OFFSET).et() &&
112 
113  testEt >= m_inputRegions.at(centreIndex - 1).et() &&
114  testEt > m_inputRegions.at(centreIndex + 1).et() &&
115 
116  testEt >= m_inputRegions.at(centreIndex-1+COL_OFFSET).et() &&
117  testEt >= m_inputRegions.at(centreIndex + COL_OFFSET).et() &&
118  testEt >= m_inputRegions.at(centreIndex+1+COL_OFFSET).et())
119  {
120  return true;
121  }
122 //USE THIS BLOCK INSTEAD IF YOU WANT OVERFLOW BIT FUNCTIONALITY
123 //*** BUT IT WILL NEED MODIFICATION SINCE L1GctRegion IS OBSOLETE ***
124 /* // Get the energy of the central region & OR the overflow bit to become the MSB
125  ULong testEt = (m_inputRegions.at(centreIndex).et() | (m_inputRegions.at(centreIndex).getOverFlow() << L1GctRegion::ET_BITWIDTH));
126 
127  //Test if our region qualifies as a jet by comparing its energy with the energies of the
128  //surrounding eight regions. In the event of neighbouring regions with identical energy,
129  //this will locate the jet in the lower-most (furthest away from eta=0), left-most (least phi) region.
130  if(testEt > (m_inputRegions.at(centreIndex-1-COL_OFFSET).et() | (m_inputRegions.at(centreIndex-1-COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
131  testEt > (m_inputRegions.at(centreIndex - COL_OFFSET).et() | (m_inputRegions.at(centreIndex - COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
132  testEt > (m_inputRegions.at(centreIndex+1-COL_OFFSET).et() | (m_inputRegions.at(centreIndex+1-COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
133 
134  testEt >= (m_inputRegions.at(centreIndex - 1).et() | (m_inputRegions.at(centreIndex - 1).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
135  testEt > (m_inputRegions.at(centreIndex + 1).et() | (m_inputRegions.at(centreIndex + 1).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
136 
137  testEt >= (m_inputRegions.at(centreIndex-1+COL_OFFSET).et() | (m_inputRegions.at(centreIndex-1+COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
138  testEt >= (m_inputRegions.at(centreIndex + COL_OFFSET).et() | (m_inputRegions.at(centreIndex + COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)) &&
139  testEt >= (m_inputRegions.at(centreIndex+1+COL_OFFSET).et() | (m_inputRegions.at(centreIndex+1+COL_OFFSET).getOverFlow() << L1GctRegion::ET_BITWIDTH)))
140  {
141  return true;
142  }
143 */ //END OVERFLOW FUNCTIONALITY
144  }
145  else //...so only test surround 5 regions in our jet testing.
146  {
147  // Get the energy of the central region
148  // Don't need all the overflow bit adjustments as above, since we are in the HF here
149  ULong testEt = m_inputRegions.at(centreIndex).et();
150 
151  if(testEt > m_inputRegions.at(centreIndex-1-COL_OFFSET).et() &&
152  testEt > m_inputRegions.at(centreIndex - COL_OFFSET).et() &&
153 
154  testEt >= m_inputRegions.at(centreIndex - 1).et() &&
155 
156  testEt >= m_inputRegions.at(centreIndex-1+COL_OFFSET).et() &&
157  testEt >= m_inputRegions.at(centreIndex + COL_OFFSET).et())
158  {
159  return true;
160  }
161  }
162  return false;
163 }
164 
165 //returns the energy sum of the nine regions centred (physically) about centreIndex
166 L1GctJetFinderBase::ULong L1GctTdrJetFinder::calcJetEnergy(const UShort centreIndex, const bool boundary) const
167 {
168  ULong energy = 0;
169 
170  if(!boundary)
171  {
172  for(int column = -1; column <= +1; ++column)
173  {
174  energy += m_inputRegions.at(centreIndex-1 + (column*COL_OFFSET)).et() +
175  m_inputRegions.at( centreIndex + (column*COL_OFFSET)).et() +
176  m_inputRegions.at(centreIndex+1 + (column*COL_OFFSET)).et();
177  }
178  }
179  else
180  {
181  for(int column = -1; column <= +1; ++column)
182  {
183  energy += m_inputRegions.at(centreIndex-1 + (column*COL_OFFSET)).et() +
184  m_inputRegions.at( centreIndex + (column*COL_OFFSET)).et();
185  }
186  }
187 
188  return energy;
189 }
190 
191 // returns the encoded (eta, phi) position of the centre region
193 {
194  return m_inputRegions.at(centreIndex).id();
195 }
196 
197 // returns the combined tauveto of the nine regions centred (physically) about centreIndex. Set boundary = true if at edge of Endcap.
198 bool L1GctTdrJetFinder::calcJetTauVeto(const UShort centreIndex, const bool boundary) const
199 {
200  bool partial[3] = {false, false, false};
201 
202  if(!boundary)
203  {
204  for(int column = -1; column <= +1; ++column)
205  {
206  partial[column+1] = m_inputRegions.at(centreIndex-1 + (column*COL_OFFSET)).tauVeto() ||
207  m_inputRegions.at( centreIndex + (column*COL_OFFSET)).tauVeto() ||
208  m_inputRegions.at(centreIndex+1 + (column*COL_OFFSET)).tauVeto();
209  }
210  }
211  else
212  {
213  for(int column = -1; column <= +1; ++column)
214  {
215  partial[column+1] = m_inputRegions.at(centreIndex-1 + (column*COL_OFFSET)).tauVeto() ||
216  m_inputRegions.at( centreIndex + (column*COL_OFFSET)).tauVeto();
217  }
218  }
219  return partial[0] || partial[1] || partial[2];
220 }
221 
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
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:188
static const unsigned N_ETA
Base class to allow implementation of jetFinder algorithms.
virtual unsigned centralCol0() const
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
virtual void process()
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
virtual void fetchInput()
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.