CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GctEmCand.cc
Go to the documentation of this file.
2 
3 #include <iostream>
4 
5 
6 using std::ostream;
7 using std::string;
8 using std::hex;
9 using std::dec;
10 
11 // default constructor
13  m_data(0),
14  m_iso(false),
15  m_captureBlock(0),
16  m_captureIndex(0),
17  m_bx(0)
18 {
19 
20 }
21 
22 // construct from raw data, no source (i.e. no capBlock/capIndex); used in GT
23 L1GctEmCand::L1GctEmCand(uint16_t rawData, bool iso) :
24  m_data(rawData & 0x7fff), // 0x7fff is to mask off bit 15, which is not data that needs to be stored
25  m_iso(iso),
26  m_captureBlock(0),
27  m_captureIndex(0),
28  m_bx(0)
29 {
30 
31 }
32 
33 // construct from raw data with source - used in GCT unpacker
34  L1GctEmCand::L1GctEmCand(uint16_t rawData, bool iso, uint16_t block, uint16_t index, int16_t bx) :
35  m_data(rawData & 0x7fff), // 0x7fff is to mask off bit 15, which is not data that needs to be stored
36  m_iso(iso),
37  m_captureBlock(block&0xfff),
38  m_captureIndex(index&0xff),
39  m_bx(bx)
40 {
41 
42 }
43 
44 // construct from content - used in GCT emulator
45 // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
46 L1GctEmCand::L1GctEmCand(unsigned rank, unsigned phi, unsigned eta, bool iso) :
47  m_data(0), // override below
48  m_iso(iso),
49  m_captureBlock(0),
50  m_captureIndex(0),
51  m_bx(0)
52 
53 {
54  construct(rank, eta, phi);
55 }
56 
57 // construct from content, with source (i.e. capBlock/capIndex); will be used in GCT emulator one day?
58 // eta = -6 to -0, +0 to +6. Sign is bit 3, 1 means -ve Z, 0 means +ve Z
59 L1GctEmCand::L1GctEmCand(unsigned rank, unsigned phi, unsigned eta, bool iso, uint16_t block, uint16_t index, int16_t bx) :
60  m_data(0), // override below
61  m_iso(iso),
62  m_captureBlock(block&0xfff),
63  m_captureIndex(index&0xff),
64  m_bx(bx)
65 {
66  construct(rank, eta, phi);
67 }
68 
69 // construct from RCT output candidate
71  m_data(0), // override below
72  m_iso(c.isolated()),
73  m_captureBlock(0),
74  m_captureIndex(0),
75  m_bx(c.bx())
76 {
77  unsigned eta=((c.regionId().rctEta() & 0x7) | (c.regionId().ieta()<11 ? 0x8 : 0x0));
78  construct(c.rank(), eta, c.regionId().iphi());
79 }
80 
81 // destructor
83 
84 // name of candidate type
85 string L1GctEmCand::name() const {
86  return (isolated() ? "iso EM" : "non iso EM" );
87 }
88 
89 // was a candidate found
90 bool L1GctEmCand::empty() const {
91  return (rank() == 0);
92 }
93 
94 // return region object
96  // get global eta
97  unsigned eta = ( etaSign()==1 ? 10-(etaIndex()&0x7) : 11+(etaIndex()&0x7) );
98  return L1CaloRegionDetId(eta, phiIndex());
99 }
100 
101 // construct from rank, eta, phi
102 void L1GctEmCand::construct(unsigned rank, unsigned eta, unsigned phi) {
103  if (rank>0) {
104  m_data = (rank & 0x3f) + ((eta & 0xf)<<6) + ((phi & 0x1f)<<10);
105  } else {
106  // Default values for zero rank electrons,
107  // different in hardware for positive and negative eta
108  if ((eta & 0x8)==0) { m_data = 0x7000; } else { m_data = 0x7400; }
109  }
110 }
111 
112 // pretty print
113 ostream& operator<<(ostream& s, const L1GctEmCand& cand) {
114  s << "L1GctEmCand : ";
115  s << "rank=" << cand.rank();
116  s << ", etaSign=" << cand.etaSign() << ", eta=" << (cand.etaIndex()&0x7) << ", phi=" << cand.phiIndex();
117  s << ", iso=" << cand.isolated();
118  s << hex << " cap block=" << cand.capBlock() << dec << ", index=" << cand.capIndex() << ", BX=" << cand.bx();
119  return s;
120 }
121 
122 unsigned L1GctEmCand::phiIndex() const { return (m_data>>10) & 0x1f; }
123 unsigned L1GctEmCand::etaIndex() const { return (m_data>>6) & 0xf; }
124 unsigned L1GctEmCand::rank() const { return m_data & 0x3f; }
125 
126 
unsigned capIndex() const
what index within capture block
Definition: L1GctEmCand.h:79
unsigned etaSign() const
get eta sign (1 for -ve Z, 0 for +ve Z)
Definition: L1GctEmCand.h:67
unsigned ieta() const
global eta index (0-21)
unsigned rank() const
get rank bits
Definition: L1GctEmCand.cc:124
unsigned rctEta() const
return local RCT eta index (0-10)
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:18
T eta() const
unsigned phiIndex() const
get phi index (0-17)
Definition: L1GctEmCand.cc:122
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
Level-1 Trigger EM candidate at output of GCT.
Definition: L1GctEmCand.h:22
uint16_t m_data
Definition: L1GctEmCand.h:98
void construct(unsigned rank, unsigned eta, unsigned phi)
Definition: L1GctEmCand.cc:102
L1CaloRegionDetId regionId() const
get DetID object
Definition: L1CaloEmCand.h:65
L1CaloRegionDetId regionId() const
region associated with the candidate
Definition: L1GctEmCand.cc:95
unsigned rank() const
get rank bits
Definition: L1CaloEmCand.h:44
unsigned etaIndex() const
get eta index -6 to -0, +0 to +6 (bit 3 is sign, 1 for -ve Z, 0 for +ve Z)
Definition: L1GctEmCand.cc:123
std::string name() const
name of object
Definition: L1GctEmCand.cc:85
virtual ~L1GctEmCand()
destructor (virtual to prevent compiler warnings)
Definition: L1GctEmCand.cc:82
bool empty() const
was an object really found?
Definition: L1GctEmCand.cc:90
L1GctEmCand()
default constructor (for vector initialisation etc.)
Definition: L1GctEmCand.cc:12
bool isolated() const
which stream did this come from
Definition: L1GctEmCand.h:73
int16_t bx() const
get bunch-crossing index
Definition: L1GctEmCand.h:82
unsigned iphi() const
global phi index (0-17)
string s
Definition: asciidump.py:422
unsigned capBlock() const
which capture block did this come from
Definition: L1GctEmCand.h:76
Definition: DDAxes.h:10