CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Friends
L1GctElectronSorter Class Reference

Class that sorts electron candidates. More...

#include <L1GctElectronSorter.h>

Inheritance diagram for L1GctElectronSorter:
L1GctProcessor

Classes

struct  prioritisedEmCand
 

Public Member Functions

void fetchInput () override
 get input data from sources More...
 
std::vector< L1CaloEmCandgetInputCands ()
 
std::vector< L1GctEmCandgetOutputCands ()
 get output candidates More...
 
 L1GctElectronSorter (int nInputs, bool iso)
 constructor; set type (isolated or non-isolated) More...
 
void process () override
 process the data, fill output buffers More...
 
void setInputEmCand (const L1CaloEmCand &cand)
 set input candidate More...
 
 ~L1GctElectronSorter () override
 
- Public Member Functions inherited from L1GctProcessor
 L1GctProcessor ()
 
void reset ()
 complete reset of processor More...
 
void setBxRange (const int firstBx, const int numberOfBx)
 define the bunch crossing range to process More...
 
void setNextBx (const int bxnum)
 clear input data buffers and process a new bunch crossing More...
 
void setTerse ()
 
bool setupOk () const
 Method to check the setup for this processor. Returns true by default. More...
 
void setVerbose ()
 control output messages More...
 
virtual ~L1GctProcessor ()
 

Static Public Member Functions

static bool rankByGt (const prioritisedEmCand &x, const prioritisedEmCand &y)
 

Protected Member Functions

void resetPipelines () override
 
void resetProcessor () override
 Separate reset methods for the processor itself and any data stored in pipelines. More...
 
void setupObjects () override
 Initialise inputs with null objects for the correct bunch crossing if required. More...
 
- Protected Member Functions inherited from L1GctProcessor
int bxAbs () const
 
int bxMax () const
 
int bxMin () const
 Support for multiple beam crossing operation. More...
 
int bxRel () const
 
int numOfBx () const
 

Private Attributes

int m_id
 algo ID (is it FPGA 1 or 2 processing) More...
 
std::vector< L1CaloEmCandm_inputCands
 input data More...
 
bool m_isolation
 type of electron to sort (isolated = 0 or non isolated = 1) More...
 
std::vector< L1GctEmCandm_outputCands
 output data More...
 

Friends

std::ostream & operator<< (std::ostream &s, const L1GctElectronSorter &card)
 overload of cout operator More...
 

Additional Inherited Members

- Protected Attributes inherited from L1GctProcessor
bool m_verbose
 Flag to control output messages. More...
 

Detailed Description

Class that sorts electron candidates.

L1GctElectronSorter This class can be constructed to sort iso or non-iso electron candidates. The electrons are sorted in ascending order and the 4 highest in rank will be returned. It represents the 1st stage sorter FPGA's on the electron leaf cards.

Author
Maria Hansen
Date
21/04/06

Definition at line 27 of file L1GctElectronSorter.h.

Constructor & Destructor Documentation

L1GctElectronSorter::L1GctElectronSorter ( int  nInputs,
bool  iso 
)

constructor; set type (isolated or non-isolated)

Definition at line 4 of file L1GctElectronSorter.cc.

Referenced by rankByGt().

4  :
6  m_id(nInputs),
7  m_isolation(iso),
8  m_inputCands(nInputs*4),
10 {}
std::vector< L1GctEmCand > m_outputCands
output data
bool m_isolation
type of electron to sort (isolated = 0 or non isolated = 1)
std::vector< L1CaloEmCand > m_inputCands
input data
int m_id
algo ID (is it FPGA 1 or 2 processing)
L1GctElectronSorter::~L1GctElectronSorter ( )
override

Definition at line 12 of file L1GctElectronSorter.cc.

Referenced by rankByGt().

13 {
14 }

Member Function Documentation

void L1GctElectronSorter::fetchInput ( )
overridevirtual

get input data from sources

Implements L1GctProcessor.

Definition at line 37 of file L1GctElectronSorter.cc.

Referenced by rankByGt().

37  {
38  // This does nothing, assume the input candidates get pushed in
39 }
std::vector<L1CaloEmCand> L1GctElectronSorter::getInputCands ( )
inline

get input candidates

Definition at line 71 of file L1GctElectronSorter.h.

References m_inputCands.

71 { return m_inputCands; }
std::vector< L1CaloEmCand > m_inputCands
input data
std::vector<L1GctEmCand> L1GctElectronSorter::getOutputCands ( )
inline

get output candidates

Definition at line 74 of file L1GctElectronSorter.h.

References m_outputCands, operator<<, resetProcessor(), and alignCSCRings::s.

Referenced by L1GctElectronFinalSort::fetchInput().

74 { return m_outputCands; }
std::vector< L1GctEmCand > m_outputCands
output data
void L1GctElectronSorter::process ( )
overridevirtual

process the data, fill output buffers

Implements L1GctProcessor.

Definition at line 42 of file L1GctElectronSorter.cc.

References EnergyCorrector::c, data, mps_fire::i, m_inputCands, m_outputCands, and rankByGt().

Referenced by rankByGt().

42  {
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++) {
49  prioritisedEmCand c(m_inputCands.at(i), 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 }
static bool rankByGt(const prioritisedEmCand &x, const prioritisedEmCand &y)
std::vector< L1GctEmCand > m_outputCands
output data
std::vector< L1CaloEmCand > m_inputCands
input data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
static bool L1GctElectronSorter::rankByGt ( const prioritisedEmCand x,
const prioritisedEmCand y 
)
inlinestatic

comparison operator for sort, used here and in the ElectronFinalSort Candidates of equal rank are sorted by priority, with the lower value given precedence

Definition at line 52 of file L1GctElectronSorter.h.

References fetchInput(), L1GctElectronSorter(), L1GctElectronSorter::prioritisedEmCand::priority, process(), L1GctElectronSorter::prioritisedEmCand::rank(), setInputEmCand(), and ~L1GctElectronSorter().

Referenced by L1GctElectronFinalSort::process(), and process().

52  {
53  return ( x.rank() > y.rank() || ( (x.rank() == y.rank()) && (x.priority < y.priority) ) ) ;
54  }
void L1GctElectronSorter::resetPipelines ( )
inlineoverrideprotectedvirtual

Implements L1GctProcessor.

Definition at line 82 of file L1GctElectronSorter.h.

References setupObjects().

82 {}
void L1GctElectronSorter::resetProcessor ( )
overrideprotectedvirtual

Separate reset methods for the processor itself and any data stored in pipelines.

Implements L1GctProcessor.

Definition at line 17 of file L1GctElectronSorter.cc.

References m_id, m_inputCands, and m_outputCands.

Referenced by getOutputCands().

17  {
18  m_inputCands.clear();
19  m_inputCands.resize(m_id*4);
20 
21  m_outputCands.clear();
22  m_outputCands.resize(4);
23 }
std::vector< L1GctEmCand > m_outputCands
output data
std::vector< L1CaloEmCand > m_inputCands
input data
int m_id
algo ID (is it FPGA 1 or 2 processing)
void L1GctElectronSorter::setInputEmCand ( const L1CaloEmCand cand)

set input candidate

Definition at line 62 of file L1GctElectronSorter.cc.

References mps_fire::i, L1CaloEmCand::index(), input, m_id, m_inputCands, and L1CaloEmCand::rctCrate().

Referenced by rankByGt().

62  {
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 }
std::vector< L1CaloEmCand > m_inputCands
input data
static std::string const input
Definition: EdmProvDump.cc:45
unsigned rctCrate() const
get RCT crate
Definition: L1CaloEmCand.h:53
int m_id
algo ID (is it FPGA 1 or 2 processing)
unsigned index() const
get index on cable
Definition: L1CaloEmCand.h:59
void L1GctElectronSorter::setupObjects ( )
overrideprotectedvirtual

Initialise inputs with null objects for the correct bunch crossing if required.

Initialise inputs with null objects for the correct bunch crossing If no other input candidates "arrive", we have the correct bunch crossing to propagate through the processing.

Create a null input electron with the right bunch crossing, and fill the input candidates with copies of this.

Implements L1GctProcessor.

Definition at line 28 of file L1GctElectronSorter.cc.

References L1GctProcessor::bxAbs(), m_id, m_inputCands, L1CaloEmCand::setBx(), and groupFilesInBlocks::temp.

Referenced by resetPipelines().

28  {
32  temp.setBx(bxAbs());
33  m_inputCands.assign(m_id*4, temp);
34 }
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
int m_id
algo ID (is it FPGA 1 or 2 processing)
int bxAbs() const

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const L1GctElectronSorter card 
)
friend

overload of cout operator

Definition at line 77 of file L1GctElectronSorter.cc.

Referenced by getOutputCands().

77  {
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 }

Member Data Documentation

int L1GctElectronSorter::m_id
private

algo ID (is it FPGA 1 or 2 processing)

Definition at line 90 of file L1GctElectronSorter.h.

Referenced by resetProcessor(), setInputEmCand(), and setupObjects().

std::vector<L1CaloEmCand> L1GctElectronSorter::m_inputCands
private

input data

Definition at line 96 of file L1GctElectronSorter.h.

Referenced by getInputCands(), operator<<(), process(), resetProcessor(), setInputEmCand(), and setupObjects().

bool L1GctElectronSorter::m_isolation
private

type of electron to sort (isolated = 0 or non isolated = 1)

Definition at line 93 of file L1GctElectronSorter.h.

Referenced by operator<<().

std::vector<L1GctEmCand> L1GctElectronSorter::m_outputCands
private

output data

Definition at line 99 of file L1GctElectronSorter.h.

Referenced by getOutputCands(), operator<<(), process(), and resetProcessor().