CMS 3D CMS Logo

L1GctJetLeafCard.cc
Go to the documentation of this file.
2 
4 
9 
11 
12 //DEFINE STATICS
14 
16  : L1GctProcessor(),
17  m_id(id),
18  m_whichJetFinder(jfType),
19  phiPosition(iphi),
20  m_exSum(0),
21  m_eySum(0),
22  m_hxSum(0),
23  m_hySum(0),
24  m_etSum(0),
25  m_htSum(0),
26  m_hfSums(),
27  m_exSumPipe(),
28  m_eySumPipe(),
29  m_hxSumPipe(),
30  m_hySumPipe(),
31  m_etSumPipe(),
32  m_htSumPipe(),
33  m_hfSumsPipe(),
34  m_ctorInputOk(true) {
35  //Check jetLeafCard setup
36  if (m_id < 0 || m_id > 5) {
37  m_ctorInputOk = false;
38  if (m_verbose) {
39  edm::LogWarning("L1GctSetupError") << "L1GctJetLeafCard::L1GctJetLeafCard() : Jet Leaf Card ID " << m_id
40  << " has been incorrectly constructed!\n"
41  << "ID number should be between the range of 0 to 5\n";
42  }
43  }
44 
45  //iphi is redundant
46  if (phiPosition != m_id % 3) {
47  m_ctorInputOk = false;
48  if (m_verbose) {
49  edm::LogWarning("L1GctSetupError") << "L1GctJetLeafCard::L1GctJetLeafCard() : Jet Leaf Card ID " << m_id
50  << " has been incorrectly constructed!\n"
51  << "Argument iphi is " << phiPosition << ", should be " << (m_id % 3)
52  << " for this ID value \n";
53  }
54  }
55 
56  switch (m_whichJetFinder) {
57  case tdrJetFinder:
58  m_jetFinderA = new L1GctTdrJetFinder(3 * id);
59  m_jetFinderB = new L1GctTdrJetFinder(3 * id + 1);
60  m_jetFinderC = new L1GctTdrJetFinder(3 * id + 2);
61  break;
62 
63  case hardwareJetFinder:
65  m_jetFinderB = new L1GctHardwareJetFinder(3 * id + 1);
66  m_jetFinderC = new L1GctHardwareJetFinder(3 * id + 2);
67  break;
68 
69  case nullJetFinder:
70  m_jetFinderA = new L1GctNullJetFinder(3 * id);
71  m_jetFinderB = new L1GctNullJetFinder(3 * id + 1);
72  m_jetFinderC = new L1GctNullJetFinder(3 * id + 2);
73  break;
74 
75  default:
76 
77  m_ctorInputOk = false;
78  if (m_verbose) {
79  edm::LogWarning("L1GctSetupError")
80  << "L1GctJetLeafCard::L1GctJetLeafCard() : Jet Leaf Card ID " << m_id
81  << " has been incorrectly constructed!\n"
82  << "Unrecognised jetFinder type " << m_whichJetFinder << ", cannot setup jetFinders\n";
83  }
84  }
85 
86  if (!m_ctorInputOk && m_verbose) {
87  edm::LogError("L1GctSetupError") << "Jet Leaf Card ID " << m_id << " has been incorrectly constructed";
88  }
89 }
90 
92  delete m_jetFinderA;
93  delete m_jetFinderB;
94  delete m_jetFinderC;
95 }
96 
98 void L1GctJetLeafCard::setNeighbourLeafCards(const std::vector<L1GctJetLeafCard*>& neighbours) {
99  std::vector<L1GctJetFinderBase*> jfNeighbours(2);
100 
101  if (neighbours.size() == 2) {
102  jfNeighbours.at(0) = neighbours.at(0)->getJetFinderC();
103  jfNeighbours.at(1) = m_jetFinderB;
104  m_jetFinderA->setNeighbourJetFinders(jfNeighbours);
105 
106  jfNeighbours.at(0) = m_jetFinderA;
107  jfNeighbours.at(1) = m_jetFinderC;
108  m_jetFinderB->setNeighbourJetFinders(jfNeighbours);
109 
110  jfNeighbours.at(0) = m_jetFinderB;
111  jfNeighbours.at(1) = neighbours.at(1)->getJetFinderA();
112  m_jetFinderC->setNeighbourJetFinders(jfNeighbours);
113 
114  } else {
115  m_ctorInputOk = false;
116  if (m_verbose) {
117  edm::LogWarning("L1GctSetupError") << "L1GctJetLeafCard::setNeighbourLeafCards() : In Jet Leaf Card ID " << m_id
118  << " size of input vector should be 2, but is in fact " << neighbours.size()
119  << "\n";
120  }
121  }
122 }
123 
124 std::ostream& operator<<(std::ostream& s, const L1GctJetLeafCard& card) {
125  using std::endl;
126 
127  s << "===L1GctJetLeafCard===" << endl;
128  s << "ID = " << card.m_id << endl;
129  s << "i_phi = " << card.phiPosition << endl;
130  ;
131  s << "Ex " << card.m_exSum << endl;
132  s << "Ey " << card.m_eySum << endl;
133  s << "Hx " << card.m_hxSum << endl;
134  s << "Hy " << card.m_hySum << endl;
135  s << "Et " << card.m_etSum << endl;
136  s << "Ht " << card.m_htSum << endl;
137  s << "JetFinder A : " << endl << (*card.m_jetFinderA);
138  s << "JetFinder B : " << endl << (*card.m_jetFinderB);
139  s << "JetFinder C : " << endl << (*card.m_jetFinderC);
140  s << endl;
141 
142  return s;
143 }
144 
148  m_jetFinderA->reset();
149  m_jetFinderB->reset();
150  m_jetFinderC->reset();
151 }
152 
154 void L1GctJetLeafCard::setBxRange(const int firstBx, const int numberOfBx) {
155  L1GctProcessor::setBxRange(firstBx, numberOfBx);
156  m_jetFinderA->setBxRange(firstBx, numberOfBx);
157  m_jetFinderB->setBxRange(firstBx, numberOfBx);
158  m_jetFinderC->setBxRange(firstBx, numberOfBx);
159 }
160 
166 }
167 
169  m_exSum.reset();
170  m_eySum.reset();
171  m_hxSum.reset();
172  m_hySum.reset();
173  m_etSum.reset();
174  m_htSum.reset();
175  m_hfSums.reset();
176 }
177 
179  m_exSumPipe.reset(numOfBx());
180  m_eySumPipe.reset(numOfBx());
181  m_hxSumPipe.reset(numOfBx());
182  m_hySumPipe.reset(numOfBx());
183  m_etSumPipe.reset(numOfBx());
184  m_htSumPipe.reset(numOfBx());
185  m_hfSumsPipe.reset(numOfBx());
186 }
187 
192 }
193 
195  // Check the setup
196  if (setupOk()) {
197  // Perform the jet finding
201 
202  // Finish Et and Ht sums for the Leaf Card
203  // First Et and missing Et
205  if (m_etSum.overFlow())
211 
212  // Exactly the same procedure for Ht and missing Ht
214  if (m_htSum.overFlow())
220 
221  // And the same again for Hf Sums
223 
224  // Store the outputs in pipelines
225  m_exSumPipe.store(m_exSum, bxRel());
226  m_eySumPipe.store(m_eySum, bxRel());
227  m_hxSumPipe.store(m_hxSum, bxRel());
228  m_hySumPipe.store(m_hySum, bxRel());
229  m_etSumPipe.store(m_etSum, bxRel());
230  m_htSumPipe.store(m_htSum, bxRel());
231  m_hfSumsPipe.store(m_hfSums, bxRel());
232  }
233 }
234 
237 }
238 
239 // get the jet output
241  return m_jetFinderA->getJets();
242 }
244  return m_jetFinderB->getJets();
245 }
247  return m_jetFinderC->getJets();
248 }
249 
251 std::vector<L1GctInternEtSum> L1GctJetLeafCard::getInternalEtSums() const {
252  std::vector<L1GctInternEtSum> result;
253  for (int bx = 0; bx < numOfBx(); bx++) {
254  result.push_back(L1GctInternEtSum::fromEmulatorJetTotEt(m_etSumPipe.contents.at(bx).value(),
255  m_etSumPipe.contents.at(bx).overFlow(),
256  static_cast<int16_t>(bx - bxMin())));
257  result.push_back(L1GctInternEtSum::fromEmulatorJetMissEt(m_exSumPipe.contents.at(bx).value(),
258  m_exSumPipe.contents.at(bx).overFlow(),
259  static_cast<int16_t>(bx - bxMin())));
260  result.push_back(L1GctInternEtSum::fromEmulatorJetMissEt(m_eySumPipe.contents.at(bx).value(),
261  m_eySumPipe.contents.at(bx).overFlow(),
262  static_cast<int16_t>(bx - bxMin())));
263  result.push_back(L1GctInternEtSum::fromEmulatorJetTotHt(m_htSumPipe.contents.at(bx).value(),
264  m_htSumPipe.contents.at(bx).overFlow(),
265  static_cast<int16_t>(bx - bxMin())));
266  }
267  return result;
268 }
269 
270 std::vector<L1GctInternHtMiss> L1GctJetLeafCard::getInternalHtMiss() const {
271  std::vector<L1GctInternHtMiss> result;
272  result.reserve(numOfBx());
273  for (int bx = 0; bx < numOfBx(); bx++) {
274  result.push_back(L1GctInternHtMiss::emulatorMissHtxHty(m_hxSumPipe.contents.at(bx).value(),
275  m_hySumPipe.contents.at(bx).value(),
276  m_hxSumPipe.contents.at(bx).overFlow(),
277  static_cast<int16_t>(bx - bxMin())));
278  }
279  return result;
280 }
int numOfBx() const
std::ostream & operator<<(std::ostream &s, const L1GctJetLeafCard &card)
htComponentType m_hySum
void reset()
complete reset of processor
Pipeline< htComponentType > m_hxSumPipe
3*3 sliding window algorithm jet finder.
htCompInternJfType getHxSum() const
Get the x component of vector Ht summed over jets above threshold.
L1GctJetFinderBase * m_jetFinderB
middle jetFinder in phi
std::vector< L1GctJetCand > JetVector
void reset()
clear internal buffers
~L1GctJetLeafCard() override
static L1GctInternEtSum fromEmulatorJetTotEt(unsigned totEt, bool overFlow, int16_t bx)
Emulator constructors.
L1GctJetFinderBase * m_jetFinderC
highest jetFinder in phi
bool m_verbose
Flag to control output messages.
std::vector< L1GctInternEtSum > getInternalEtSums() const
get the Et sums in internal component format
std::vector< L1GctJetCand > getOutputJetsC() const
Ouptut jetfinder C jets (highest jetFinder in phi)
Pipeline< etHadType > m_htSumPipe
Pipeline< etTotalType > m_etSumPipe
etHadType getHtSum() const
Get the scalar sum of Ht summed over jets above threshold.
bool setupOk() const
Check setup is Ok.
void setNeighbourLeafCards(const std::vector< L1GctJetLeafCard *> &neighbours)
set pointers to neighbours - needed to complete the setup
no-op jet finder for test purposes.
Log< level::Error, false > LogError
int bxRel() const
std::vector< L1GctJetCand > getOutputJetsB() const
Output jetfinder B jets (middle jetFinder in phi)
bool overFlow() const
access overflow
etCompInternJfType getExSum() const
Get the x component of vector Et summed over the input regions.
ABC for a GCT trigger data processing unit.
void process() override
process the data and set outputs
static L1GctInternEtSum fromEmulatorJetTotHt(unsigned totHt, bool overFlow, int16_t bx)
void process() override=0
process the data, fill output buffers; to be filled in by derived jetFinders
void resetProcessor() override
Separate reset methods for the processor itself and any data stored in pipelines. ...
int bxMin() const
Support for multiple beam crossing operation.
Pipeline< etComponentType > m_eySumPipe
Pipeline< htComponentType > m_hySumPipe
void fetchInput() override
set the input buffers
etCompInternJfType getEySum() const
Get the y component of vector Et summed over the input regions.
std::vector< L1GctJetCand > getOutputJetsA() const
Output jetfinder A jets (lowest jetFinder in phi)
void setBxRange(const int firstBx, const int numberOfBx)
define the bunch crossing range to process
JetVector getJets() const
Get the located jets.
L1GctTwosComplement< L1GctInternHtMiss::kMissHxOrHyNBits > htComponentType
void setBxRange(const int firstBx, const int numberOfBx)
define the bunch crossing range to process
jetFinderType m_whichJetFinder
bool setupOk() const
Check setup is Ok.
htCompInternJfType getHySum() const
Get the y component of vector Ht summed over jets above threshold.
void setNextBx(const int bx)
partially clear buffers
static const int MAX_JET_FINDERS
Number of jetfinders per jet leaf card.
static L1GctInternHtMiss emulatorMissHtxHty(const int htx, const int hty, const bool overFlow, const int16_t bx)
Named ctor for making missing Ht x & y components object from emulator (wheel input).
void fetchInput() override=0
get input data from sources; to be filled in by derived jetFinders
L1GctJetLeafCard(int id, int iphi, jetFinderType jfType=tdrJetFinder)
hfTowerSumsType m_hfSums
std::vector< L1GctInternHtMiss > getInternalHtMiss() const
void reset()
reset value and overflow to zero
L1GctJetFinderBase * m_jetFinderA
lowest jetFinder in phi
void setNeighbourJetFinders(const std::vector< L1GctJetFinderBase *> &neighbours)
Set pointers to neighbours - needed to complete the setup.
void setValue(unsigned value)
Set value from unsigned.
Pipeline< hfTowerSumsType > m_hfSumsPipe
etComponentType m_eySum
void reset()
reset value and overflow to zero
Emulation of the hardware jet finder.
Pipeline< etComponentType > m_exSumPipe
static L1GctInternEtSum fromEmulatorJetMissEt(int missEtxOrEty, bool overFlow, int16_t bx)
Log< level::Warning, false > LogWarning
void setNextBx(const int bxnum)
clear input data buffers and process a new bunch crossing
etTotalType getEtSum() const
Get the scalar sum of Et summed over the input regions.
void resetPipelines() override
htComponentType m_hxSum
hfTowerSumsType getHfSums() const
Get the Hf tower Et sums and tower-over-threshold counts.
L1GctTwosComplement< L1GctInternEtSum::kMissExOrEyNBits > etComponentType
etComponentType m_exSum