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.
2 #include "rctDataBase.h"
3 
4 
11 
13 
15 
16 #include <iostream>
17 #include <fstream>
18 
20 
21 #include "CaloCollections.h"
22 #include "RCTEmRegionUnpacker.h"
23 
24 namespace l1t {
25  namespace stage1 {
26  void
28  {
29  int nBX, firstBX, lastBX;
30  nBX = int(ceil(block.header().getSize() / 6.));
31  getBXRange(nBX, firstBX, lastBX);
32 
33  auto resRCTEMCands_ = static_cast<CaloCollections*>(coll)->getCaloEmCands();
34 
35  // Initialise index
36  int unsigned i = 0;
37 
38  for (int bx=firstBX; bx<=lastBX; bx++){
39 
40  unsigned int crate;
41  bool even=0;
42 
43  std::vector <uint32_t> uint;
44  uint.reserve(6);
45 
46  PhysicsToBitConverter converter;
47  rctDataBase database;
48  int mp7link=(int)(block.header().getID()/2);
49  database.GetLinkRCT(mp7link,crate,even);
50 
51  uint.push_back(block.payload()[i++]);
52  uint.push_back(block.payload()[i++]);
53  uint.push_back(block.payload()[i++]);
54  uint.push_back(block.payload()[i++]);
55  uint.push_back(block.payload()[i++]);
56  uint.push_back(block.payload()[i++]);
57 
58  LogDebug("L1T")<<"--------------- mp7 link ="<<mp7link<<"RCT crate id="<<crate<<", RCT crate even="<<even<<std::endl;
59 
60  if(!even) {
61  for(int i=0;i<6;i++) converter.Set32bitWordLinkOdd(i,uint[i]);
62  converter.Convert();
63 
64  for(int j = 0; j < 4; j++) {
65 
66  unsigned int rank=(unsigned int)converter.GetNEEt(j);
67  unsigned int reg=(unsigned int)converter.GetNEReg(j);
68  unsigned int card=(unsigned int)converter.GetNECard(j);
69 
70  LogDebug("L1T")<<"UNPACKER, CRATE"<<crate<<"NON ISO em rank="<<rank<<", region="<<reg<<", card="<<card<<std::endl;
71 
72  L1CaloEmCand em = L1CaloEmCand(rank,reg,card,crate,false,j,bx);
73  resRCTEMCands_->push_back(em);
74  }
75 
76  for(int j = 0; j < 4; j++) {
77 
78  unsigned int rank=converter.GetIEEt(j);
79  unsigned int reg=converter.GetIEReg(j);
80  unsigned int card=converter.GetIECard(j);
81 
82  LogDebug("L1T")<<"UNPACKER, CRATE"<<crate<<"ISO em rank="<<rank<<", region="<<reg<<", card="<<card<<std::endl;
83  L1CaloEmCand em = L1CaloEmCand(rank,reg,card,crate,true,j,bx);
84  resRCTEMCands_->push_back(em);
85  }
86  }// end if odd
87  }// end of loop over BX
88  }
89 
90  void
92  {
93  int nBX, firstBX, lastBX;
94  nBX = int(ceil(block.header().getSize() / 6.));
95  getBXRange(nBX, firstBX, lastBX);
96 
97  auto resRCTRegions_ = static_cast<CaloCollections*>(coll)->getCaloRegions();
98 
99  // Initialise index
100  int unsigned i = 0;
101  std::vector <uint32_t> uint;
102  uint.reserve(6);
103 
104  for (int bx=firstBX; bx<=lastBX; bx++){
105 
106  unsigned int crate;
107  bool even=0;
108 
109  PhysicsToBitConverter converter;
110  rctDataBase database;
111  int mp7link=(int)(block.header().getID()/2);
112  database.GetLinkRCT(mp7link,crate,even);
113 
114  uint.push_back(block.payload()[i++]);
115  uint.push_back(block.payload()[i++]);
116  uint.push_back(block.payload()[i++]);
117  uint.push_back(block.payload()[i++]);
118  uint.push_back(block.payload()[i++]);
119  uint.push_back(block.payload()[i++]);
120 
121  LogDebug("L1T")<<"--------------- mp7 link ="<<mp7link<<"RCT crate id="<<crate<<", RCT crate even="<<even<<std::endl;
122 
123  if(!even) {
124 
125  for(int i=0;i<6;i++) converter.Set32bitWordLinkOdd(i,uint[i]);
126  converter.Convert();
127 
128  for(int j = 0; j < 8; j++) {
129 
130  unsigned int hfet=(unsigned int)converter.GetHFEt(j);
131  bool hfgrain=(bool)converter.GetHFFg(j);
132 
133  LogDebug("L1T")<<"UNPACKER, CRATE"<<crate<<"region="<<j<<", rgnEt="<<hfet<<std::endl;
134  L1CaloRegion rgn = L1CaloRegion(hfet,hfgrain,crate,j);
135  rgn.setBx(bx);
136  resRCTRegions_->push_back(rgn);
137  }
138  }// end if odd
139 
140 
141  else{
142 
143  for(int i=0;i<6;i++) converter.Set32bitWordLinkEven(i,uint[i]);
144  converter.Convert();
145 
146  for(int j = 0; j < 7; j++) {
147  for(int k = 0; k < 2; k++) {
148 
149  unsigned int RCet=(unsigned int)converter.GetRCEt(j,k);
150  bool overflow=(bool)converter.GetRCOf(j,k);
151  bool tauveto=(bool)converter.GetRCTau(j,k);
152  bool hadveto=(bool)converter.GetRCHad(j,k);
153  bool quiet=false; //to be fixed
154 
155  LogDebug("L1T")<<"UNPACKER, CRATE="<<crate<<",region="<<k<<", card="<<j<<", rgnEt="<<RCet<<", overflow="<<overflow<<", tauveto="<<tauveto<<", hadveto="<<hadveto<<std::endl;
156  L1CaloRegion rgn = L1CaloRegion(RCet,overflow,tauveto,hadveto,quiet,crate,j,k);
157  rgn.setBx(bx);
158  resRCTRegions_->push_back(rgn);
159  }
160  }
161  }// end if even
162  }// end of loop over BX
163  }
164 
166  if (block.header().getCapID() == 0) {
167  unpack_region(block, coll);
168  } else if (block.header().getCapID() == 1) {
169  unpack_em(block, coll);
170  } else {
171  return false;
172  }
173  return true;
174  }
175  }
176 }
177 
#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)
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
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)
#define DEFINE_L1T_UNPACKER(type)
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)