CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RCTEmRegionUnpacker.cc
Go to the documentation of this file.
4 #include "rctDataBase.h"
5 
6 
13 
14 
15 #include <iostream>
16 #include <fstream>
17 
18 #include "CaloCollections.h"
19 
20 namespace l1t {
21  namespace stage1 {
22  class RCTEmRegionUnpacker : public Unpacker {
23  public:
24  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
25  private:
26  unsigned int counter_ = 0;
27  };
28  }
29 }
30 
31 // Implementation
32 
33 namespace l1t {
34  namespace stage1 {
35  void
37  {
38  int nBX, firstBX, lastBX;
39  nBX = int(ceil(block.header().getSize() / 6.));
40  getBXRange(nBX, firstBX, lastBX);
41 
42  auto resRCTEMCands_ = static_cast<CaloCollections*>(coll)->getCaloEmCands();
43 
44  // Initialise index
45  int unsigned i = 0;
46 
47  for (int bx=firstBX; bx<=lastBX; bx++){
48 
49  unsigned int crate;
50  bool even=0;
51 
52  std::vector <uint32_t> uint;
53  uint.reserve(6);
54 
55  PhysicsToBitConverter converter;
56  rctDataBase database;
57  int mp7link=(int)(block.header().getID()/2);
58  database.GetLinkRCT(mp7link,crate,even);
59 
60  uint.push_back(block.payload()[i++]);
61  uint.push_back(block.payload()[i++]);
62  uint.push_back(block.payload()[i++]);
63  uint.push_back(block.payload()[i++]);
64  uint.push_back(block.payload()[i++]);
65  uint.push_back(block.payload()[i++]);
66 
67  LogDebug("L1T")<<"--------------- mp7 link ="<<mp7link<<"RCT crate id="<<crate<<", RCT crate even="<<even<<std::endl;
68 
69  if(!even) {
70  for(int i=0;i<6;i++) converter.Set32bitWordLinkOdd(i,uint[i]);
71  converter.Convert();
72 
73  for(int j = 0; j < 4; j++) {
74 
75  unsigned int rank=(unsigned int)converter.GetNEEt(j);
76  unsigned int reg=(unsigned int)converter.GetNEReg(j);
77  unsigned int card=(unsigned int)converter.GetNECard(j);
78 
79  LogDebug("L1T")<<"UNPACKER, CRATE"<<crate<<"NON ISO em rank="<<rank<<", region="<<reg<<", card="<<card<<std::endl;
80 
81  L1CaloEmCand em = L1CaloEmCand(rank,reg,card,crate,false,j,bx);
82  resRCTEMCands_->push_back(em);
83  }
84 
85  for(int j = 0; j < 4; j++) {
86 
87  unsigned int rank=converter.GetIEEt(j);
88  unsigned int reg=converter.GetIEReg(j);
89  unsigned int card=converter.GetIECard(j);
90 
91  LogDebug("L1T")<<"UNPACKER, CRATE"<<crate<<"ISO em rank="<<rank<<", region="<<reg<<", card="<<card<<std::endl;
92  L1CaloEmCand em = L1CaloEmCand(rank,reg,card,crate,true,j,bx);
93  resRCTEMCands_->push_back(em);
94  }
95  }// end if odd
96  }// end of loop over BX
97  }
98 
99  void
101  {
102  int nBX, firstBX, lastBX;
103  nBX = int(ceil(block.header().getSize() / 6.));
104  getBXRange(nBX, firstBX, lastBX);
105 
106  auto resRCTRegions_ = static_cast<CaloCollections*>(coll)->getCaloRegions();
107 
108  // Initialise index
109  int unsigned i = 0;
110  std::vector <uint32_t> uint;
111  uint.reserve(6);
112 
113  for (int bx=firstBX; bx<=lastBX; bx++){
114 
115  unsigned int crate;
116  bool even=0;
117 
118  PhysicsToBitConverter converter;
119  rctDataBase database;
120  int mp7link=(int)(block.header().getID()/2);
121  database.GetLinkRCT(mp7link,crate,even);
122 
123  uint.push_back(block.payload()[i++]);
124  uint.push_back(block.payload()[i++]);
125  uint.push_back(block.payload()[i++]);
126  uint.push_back(block.payload()[i++]);
127  uint.push_back(block.payload()[i++]);
128  uint.push_back(block.payload()[i++]);
129 
130  LogDebug("L1T")<<"--------------- mp7 link ="<<mp7link<<"RCT crate id="<<crate<<", RCT crate even="<<even<<std::endl;
131 
132  if(!even) {
133 
134  for(int i=0;i<6;i++) converter.Set32bitWordLinkOdd(i,uint[i]);
135  converter.Convert();
136 
137  for(int j = 0; j < 8; j++) {
138 
139  unsigned int hfet=(unsigned int)converter.GetHFEt(j);
140  bool hfgrain=(bool)converter.GetHFFg(j);
141 
142  LogDebug("L1T")<<"UNPACKER, CRATE"<<crate<<"region="<<j<<", rgnEt="<<hfet<<std::endl;
143  L1CaloRegion rgn = L1CaloRegion(hfet,hfgrain,crate,j);
144  rgn.setBx(bx);
145  resRCTRegions_->push_back(rgn);
146  }
147  }// end if odd
148 
149 
150  else{
151 
152  for(int i=0;i<6;i++) converter.Set32bitWordLinkEven(i,uint[i]);
153  converter.Convert();
154 
155  for(int j = 0; j < 7; j++) {
156  for(int k = 0; k < 2; k++) {
157 
158  unsigned int RCet=(unsigned int)converter.GetRCEt(j,k);
159  bool overflow=(bool)converter.GetRCOf(j,k);
160  bool tauveto=(bool)converter.GetRCTau(j,k);
161  bool hadveto=(bool)converter.GetRCHad(j,k);
162  bool quiet=false; //to be fixed
163 
164  LogDebug("L1T")<<"UNPACKER, CRATE="<<crate<<",region="<<k<<", card="<<j<<", rgnEt="<<RCet<<", overflow="<<overflow<<", tauveto="<<tauveto<<", hadveto="<<hadveto<<std::endl;
165  L1CaloRegion rgn = L1CaloRegion(RCet,overflow,tauveto,hadveto,quiet,crate,j,k);
166  rgn.setBx(bx);
167  resRCTRegions_->push_back(rgn);
168  }
169  }
170  }// end if even
171  }// end of loop over BX
172  }
173 
175  if (block.header().getCapID() == 0) {
176  unpack_region(block, coll);
177  } else if (block.header().getCapID() == 1) {
178  unpack_em(block, coll);
179  } else {
180  return false;
181  }
182  return true;
183  }
184  }
185 }
186 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
int GetRCTau(int card, int region)
void unpack_em(const Block &block, UnpackerCollections *coll)
void unpack_region(const Block &block, UnpackerCollections *coll)
unsigned int getID() const
Definition: Block.h:22
void getBXRange(int nbx, int &first, int &last)
Definition: Unpacker.cc:12
BlockHeader header() const
Definition: Block.h:56
void setBx(int16_t bx)
set bx
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:18
std::vector< uint32_t > payload() const
Definition: Block.h:57
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:31
void Set32bitWordLinkEven(int index, uint32_t value)
int GetRCHad(int card, int region)
int j
Definition: DBlmapReader.cc:9
void GetLinkRCT(int linkMP7, unsigned int &RCTcrate, bool &RCTeven)
Definition: rctDataBase.h:63
int GetRCEt(int card, int region)
JetCorrectorParametersCollection coll
Definition: classes.h:10
unsigned int getCapID() const
Definition: Block.h:24
void Set32bitWordLinkOdd(int index, uint32_t value)
unsigned int getSize() const
Definition: Block.h:23
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:22
int GetRCOf(int card, int region)