CMS 3D CMS Logo

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