test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1CaloRegion.cc
Go to the documentation of this file.
1 
2 
4 
5 using std::ostream;
6 using std::endl;
7 using std::hex;
8 using std::dec;
9 
10 // default constructor
11 L1CaloRegion::L1CaloRegion() : m_id(), m_data(0), m_bx(0) { }
12 
13 
14 // constructor for RCT emulator (HB/HE regions)
15 L1CaloRegion::L1CaloRegion(unsigned et, bool overFlow, bool tauVeto, bool mip, bool quiet, unsigned crate, unsigned card, unsigned rgn) :
16  m_id(crate, card, rgn),
17  m_data(0), // over-ridden below
18  m_bx(0)
19 {
20  pack(et, overFlow, tauVeto, mip, quiet);
21 }
22 
23 // constructor for RCT emulator (HF regions)
24 L1CaloRegion::L1CaloRegion(unsigned et, bool fineGrain, unsigned crate, unsigned rgn) :
25  m_id(crate, 999, rgn),
26  m_data(0), // over-ridden below
27  m_bx(0)
28 {
29  pack((et & 0xff), (et >= 0xff), fineGrain, false, false);
30 }
31 
32 // construct from global eta, phi indices
34  bool overFlow,
35  bool fineGrain,
36  bool mip,
37  bool quiet,
38  unsigned ieta,
39  unsigned iphi) :
40  m_id(ieta, iphi),
41  m_data(0), // over-ridden below
42  m_bx(0)
43 {
44  pack(et, overFlow, fineGrain, mip, quiet);
45 }
46 
47 //constructor for unpacking
48 L1CaloRegion::L1CaloRegion(uint16_t data, unsigned ieta, unsigned iphi, int16_t bx) :
49  m_id(ieta, iphi),
50  m_data(data),
51  m_bx(bx)
52 {
53 
54 }
55 
56 // destructor
58 
59 // named ctors
60 
61 // for HB/HE from RCT indices
63  bool overFlow,
64  bool tauVeto,
65  bool mip,
66  bool quiet,
67  unsigned crate,
68  unsigned card,
69  unsigned rgn) {
71  r.setRegionId( L1CaloRegionDetId(crate, card, rgn) );
72  r.setBx(0);
73  r.pack(et, overFlow, tauVeto, mip, quiet);
74  return r;
75 }
76 
77 // for HF from RCT indices
79  bool fineGrain,
80  unsigned crate,
81  unsigned rgn) {
83  r.setRegionId( L1CaloRegionDetId(crate, 999, rgn) );
84  r.setBx(0);
85  r.pack((et & 0xff), (et >= 0xff), fineGrain, false, false);
86  return r;
87 }
88 
89 // HB/HE/HF from GCT indices
91  bool overFlow,
92  bool fineGrain,
93  bool mip,
94  bool quiet,
95  unsigned ieta,
96  unsigned iphi) {
98  r.setRegionId( L1CaloRegionDetId(ieta, iphi) );
99  r.setBx(0);
100  r.pack(et, overFlow, fineGrain, mip, quiet);
101  return r;
102 }
103 
104 //constructor for unpacking
106  unsigned ieta,
107  unsigned iphi,
108  uint16_t block,
109  uint16_t index,
110  int16_t bx)
111 {
112  L1CaloRegion r;
113  r.setRegionId( L1CaloRegionDetId(ieta,iphi) );
114  r.setRawData(data);
115  r.setCaptureBlock(block);
116  r.setCaptureIndex(index);
117  r.setBx(bx);
118  return r;
119 }
120 
122  const bool overFlow,
123  const bool fineGrain,
124  const unsigned ieta,
125  const unsigned iphi,
126  const int16_t bx) {
127  L1CaloRegion r;
128  r.setRegionId( L1CaloRegionDetId(ieta, iphi) );
129  r.setBx(bx);
130  r.pack12BitsEt(et, overFlow, fineGrain, false, false);
131  return r;
132 
133 }
134 
135 // set BX
136 void L1CaloRegion::setBx(int16_t bx) {
137  m_bx = bx;
138 }
139 
140 // set mip bit
141 void L1CaloRegion::setMip(bool mip) {
142  if (mip) { m_data |= 0x1000; }
143  else { m_data &= 0xefff; }
144 }
145 
146 // set quiet bit
147 void L1CaloRegion::setQuiet(bool quiet) {
148  if (quiet) { m_data |= 0x2000; }
149  else { m_data &= 0xdfff; }
150 }
151 
152 void L1CaloRegion::pack(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet) {
153  bool checkOvF = overFlow || (et>=0x400);
154  m_data =
155  (et & 0x3ff) |
156  ((checkOvF) ? 0x400 : 0x0) |
157  ((fineGrain) ? 0x800 : 0x0) |
158  ((mip) ? 0x1000 : 0x0) |
159  ((quiet) ? 0x2000 : 0x0);
160 }
161 
162 void L1CaloRegion::pack12BitsEt(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet) {
163  bool checkOvF = overFlow || (et>=0x400);
164  m_data =
165  (et & 0xfff) |
166  ((checkOvF) ? 0x400 : 0x0) |
167  ((fineGrain) ? 0x800 : 0x0) |
168  ((mip) ? 0x1000 : 0x0) |
169  ((quiet) ? 0x2000 : 0x0);
170 }
171 
172 // print to stream
173 ostream& operator << (ostream& os, const L1CaloRegion& reg) {
174  os << "L1CaloRegion:";
175  os << " Et=" << reg.et();
176  os << " o/f=" << reg.overFlow();
177  os << " f/g=" << reg.fineGrain();
178  os << " tau=" << reg.tauVeto() << endl;
179  os << " RCT crate=" << reg.rctCrate();
180  os << " RCT card=" << reg.rctCard();
181  os << " RCT rgn=" << reg.rctRegionIndex();
182  os << " RCT eta=" << reg.rctEta();
183  os << " RCT phi=" << reg.rctPhi() << endl;
184  os << " GCT eta=" << reg.gctEta();
185  os << " GCT phi=" << reg.gctPhi() << endl;
186  os << hex << " cap block=" << reg.capBlock() << dec << ", index=" << reg.capIndex() << ", BX=" << reg.bx();
187  return os;
188 }
189 
int16_t bx() const
get bunch-crossing index
Definition: L1CaloRegion.h:192
unsigned capIndex() const
what index within capture block
Definition: L1CaloRegion.h:189
~L1CaloRegion()
destructor
Definition: L1CaloRegion.cc:57
unsigned et() const
get Et
Definition: L1CaloRegion.h:116
bool overFlow() const
get overflow
Definition: L1CaloRegion.h:122
uint16_t m_data
region data : et, overflow, fine grain/tau veto, mip and quiet bits
Definition: L1CaloRegion.h:221
unsigned rctEta() const
get local eta index (within RCT crate)
Definition: L1CaloRegion.h:174
unsigned rctCrate() const
get RCT crate ID
Definition: L1CaloRegion.h:165
unsigned rctCard() const
get RCT reciever card ID (valid output for HB/HE)
Definition: L1CaloRegion.h:168
void setRawData(uint32_t data)
set data
Definition: L1CaloRegion.h:146
void setBx(int16_t bx)
set bx
static L1CaloRegion makeHBHERegion(const unsigned et, const bool overFlow, const bool tauVeto, const bool mip, const bool quiet, const unsigned crate, const unsigned card, const unsigned rgn)
constructor HB/HE region from components
Definition: L1CaloRegion.cc:62
unsigned rctRegionIndex() const
get RCT region index
Definition: L1CaloRegion.h:171
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
void setRegionId(L1CaloRegionDetId id)
set region ID
Definition: L1CaloRegion.h:209
void setCaptureBlock(uint16_t capBlock)
set cap block
Definition: L1CaloRegion.h:137
bool tauVeto() const
get tau veto bit
Definition: L1CaloRegion.h:125
void setCaptureIndex(uint16_t capIndex)
set cap index
Definition: L1CaloRegion.h:140
unsigned rctPhi() const
get local phi index (within RCT crate)
Definition: L1CaloRegion.h:177
void setMip(bool mip)
set MIP bit (required for GCT emulator standalone operation)
void pack(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet)
pack the raw data from arguments (used in constructors)
void pack12BitsEt(unsigned et, bool overFlow, bool fineGrain, bool mip, bool quiet)
pack the raw data from arguments (used in constructors)
static L1CaloRegion makeGctJetRegion(const unsigned et, const bool overFlow, const bool fineGrain, const unsigned ieta, const unsigned iphi, const int16_t bx)
construct region for use in GCT internal jet-finding
bool fineGrain() const
get fine grain bit
Definition: L1CaloRegion.h:128
unsigned gctEta() const
get GCT eta index
Definition: L1CaloRegion.h:180
static L1CaloRegion makeRegionFromGctIndices(const unsigned et, const bool overFlow, const bool fineGrain, const bool mip, const bool quiet, const unsigned ieta, const unsigned iphi)
construct region from GCT indices
Definition: L1CaloRegion.cc:90
unsigned gctPhi() const
get GCT phi index
Definition: L1CaloRegion.h:183
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int16_t m_bx
Definition: L1CaloRegion.h:224
void setQuiet(bool quiet)
set quiet bit (required for GCT emulator standalone operation)
static L1CaloRegion makeHFRegion(const unsigned et, const bool fineGrain, const unsigned crate, const unsigned rgn)
construct HF region from components
Definition: L1CaloRegion.cc:78
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:22
static L1CaloRegion makeRegionFromUnpacker(const uint16_t data, const unsigned ieta, const unsigned iphi, const uint16_t block, const uint16_t index, const int16_t bx)
constructor from raw data and GCT indices for unpacking
unsigned capBlock() const
which capture block did this come from
Definition: L1CaloRegion.h:186
L1CaloRegion()
default constructor
Definition: L1CaloRegion.cc:11