CMS 3D CMS Logo

L1GctElectronSorter.cc
Go to the documentation of this file.
2 #include <algorithm>
3 
6  m_id(nInputs),
7  m_isolation(iso),
8  m_inputCands(nInputs*4),
9  m_outputCands(4)
10 {}
11 
13 {
14 }
15 
16 // clear buffers
18  m_inputCands.clear();
19  m_inputCands.resize(m_id*4);
20 
21  m_outputCands.clear();
22  m_outputCands.resize(4);
23 }
24 
32  temp.setBx(bxAbs());
33  m_inputCands.assign(m_id*4, temp);
34 }
35 
36 // get the input data
38  // This does nothing, assume the input candidates get pushed in
39 }
40 
41 //Process sorts the electron candidates after rank and stores the highest four (in the outputCands vector)
43 
44  //Convert from caloEmCand to gctEmCand and make temporary copy of data
45  std::vector<prioritisedEmCand> data(m_inputCands.size());
46  // Assign a "priority" for sorting - this assumes the candidates
47  // have already been filled in "priority order"
48  for (unsigned i=0; i<m_inputCands.size(); i++) {
50  data.at(i) = c;
51  }
52 
53  //Then sort it
54  sort(data.begin(),data.end(),rankByGt);
55 
56  //Copy data to output buffer
57  for(int i = 0; i<4; i++){
58  m_outputCands.at(i) = data.at(i).emCand;
59  }
60 }
61 
63  // Fills the candidates in "priority order"
64  // The lowest numbered RCT crate in each FPGA has highest priority.
65  // We distinguish the two FPGAs on a leaf card by the number of inputs.
66  // FPGA U1 has 5 inputs (crates 4-8) and FPGA U2 has 4 inputs (crates 0-3).
67  // Within a crate the four input candidates are arranged in the order
68  // that they arrive on the cable, using the index() method.
69  unsigned crate = cand.rctCrate();
70  unsigned input = ( (m_id==4) ? (crate%9) : (crate%9 - 4) );
71  unsigned i = input*4 + (3-cand.index());
72  if (m_inputCands.at(i).rank()==0) {
73  m_inputCands.at(i) = cand;
74  }
75 }
76 
77 std::ostream& operator<<(std::ostream& s, const L1GctElectronSorter& ems) {
78  s << "===L1GctElectronSorter===" << std::endl;
79  s << "Algo type = " << ems.m_isolation << std::endl;
80  s << "No of Electron Input Candidates = " << ems.m_inputCands.size()<< std::endl;
81  s << "No of Electron Output Candidates = " << ems.m_outputCands.size()<< std::endl;
82  return s;
83 }
84 
static bool rankByGt(const prioritisedEmCand &x, const prioritisedEmCand &y)
void setupObjects() override
Initialise inputs with null objects for the correct bunch crossing if required.
std::vector< L1GctEmCand > m_outputCands
output data
bool m_isolation
type of electron to sort (isolated = 0 or non isolated = 1)
L1GctElectronSorter(int nInputs, bool iso)
constructor; set type (isolated or non-isolated)
void setBx(int16_t bx)
set BX
Definition: L1CaloEmCand.cc:69
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:18
std::vector< L1CaloEmCand > m_inputCands
input data
static std::string const input
Definition: EdmProvDump.cc:48
ABC for a GCT trigger data processing unit.
void process() override
process the data, fill output buffers
unsigned rctCrate() const
get RCT crate
Definition: L1CaloEmCand.h:53
Class that sorts electron candidates.
void resetProcessor() override
Separate reset methods for the processor itself and any data stored in pipelines. ...
void fetchInput() override
get input data from sources
void setInputEmCand(const L1CaloEmCand &cand)
set input candidate
friend std::ostream & operator<<(std::ostream &s, const L1GctElectronSorter &card)
overload of cout operator
int m_id
algo ID (is it FPGA 1 or 2 processing)
unsigned index() const
get index on cable
Definition: L1CaloEmCand.h:59
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int bxAbs() const