CMS 3D CMS Logo

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