CMS 3D CMS Logo

L1GtBoardMapsTrivialProducer.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <memory>
20 
21 #include <string>
22 
23 // user include files
24 // base class
26 
29 
31 
32 // forward declarations
33 
34 //
35 
36 std::vector<L1GtObject> chInputObjects(const std::vector<std::string>& chInputStrings) {
37  std::vector<L1GtObject> chInputObjectsV;
38  chInputObjectsV.reserve(chInputStrings.size());
39 
41 
42  for (std::vector<std::string>::const_iterator itObj = chInputStrings.begin(); itObj != chInputStrings.end();
43  ++itObj) {
44  if ((*itObj) == "Mu") {
45  obj = Mu;
46  } else if ((*itObj) == "NoIsoEG") {
47  obj = NoIsoEG;
48  } else if ((*itObj) == "IsoEG") {
49  obj = IsoEG;
50  } else if ((*itObj) == "CenJet") {
51  obj = CenJet;
52  } else if ((*itObj) == "ForJet") {
53  obj = ForJet;
54  } else if ((*itObj) == "TauJet") {
55  obj = TauJet;
56  } else if ((*itObj) == "ETM") {
57  obj = ETM;
58  } else if ((*itObj) == "ETT") {
59  obj = ETT;
60  } else if ((*itObj) == "HTT") {
61  obj = HTT;
62  } else if ((*itObj) == "HTM") {
63  obj = HTM;
64  } else if ((*itObj) == "JetCounts") {
65  obj = JetCounts;
66  } else if ((*itObj) == "HfBitCounts") {
67  obj = HfBitCounts;
68  } else if ((*itObj) == "HfRingEtSums") {
69  obj = HfRingEtSums;
70  } else if ((*itObj) == "TechTrig") {
71  obj = TechTrig;
72  } else if ((*itObj) == "BPTX") {
73  obj = BPTX;
74  } else if ((*itObj) == "GtExternal") {
75  obj = GtExternal;
76  } else {
77  throw cms::Exception("Configuration") << "\nError: no such L1 GT object: " << (*itObj) << "\n"
78  << "\n Can not define the mapping of the L1 GT boards. \n"
79  << std::endl;
80  }
81 
82  chInputObjectsV.push_back(obj);
83  }
84 
85  return chInputObjectsV;
86 }
87 
88 // constructor(s)
90  // tell the framework what data is being produced
92 
93  // now do what ever other initialization is needed
94 
95  // get the list of the board names and indices
96  std::vector<std::string> boardList = parSet.getParameter<std::vector<std::string> >("BoardList");
97 
98  std::vector<int> boardIndexVec = parSet.getParameter<std::vector<int> >("BoardIndex");
99 
100  // check if the board list and the board indices are consistent
101  // i.e. have the same number of entries
102 
103  if (boardList.size() != boardIndexVec.size()) {
104  throw cms::Exception("Configuration") << "\nError: inconsistent length of board list and board indices.\n"
105  << "\n Can not define the mapping of the L1 GT boards. \n"
106  << std::endl;
107  }
108 
109  // L1 GT DAQ record map
110  std::vector<int> boardPositionDaqRecord = parSet.getParameter<std::vector<int> >("BoardPositionDaqRecord");
111 
112  if (boardList.size() != boardPositionDaqRecord.size()) {
113  throw cms::Exception("Configuration")
114  << "\nError: inconsistent length of board list and board indices in GT DAQ record.\n"
115  << "\n Can not define the mapping of the L1 GT boards. \n"
116  << std::endl;
117  }
118 
119  // L1 GT EVM record map
120  std::vector<int> boardPositionEvmRecord = parSet.getParameter<std::vector<int> >("BoardPositionEvmRecord");
121 
122  if (boardList.size() != boardPositionEvmRecord.size()) {
123  throw cms::Exception("Configuration")
124  << "\nError: inconsistent length of board list and board indices in GT EVM record.\n"
125  << "\n Can not define the mapping of the L1 GT boards. \n"
126  << std::endl;
127  }
128 
129  // L1 GT "active boards" map for DAQ record
130  std::vector<int> activeBoardsDaqRecord = parSet.getParameter<std::vector<int> >("ActiveBoardsDaqRecord");
131 
132  if (boardList.size() != activeBoardsDaqRecord.size()) {
133  throw cms::Exception("Configuration")
134  << "\nError: inconsistent length of board list and active boards in GT DAQ record.\n"
135  << "\n Can not define the mapping of the L1 GT boards. \n"
136  << std::endl;
137  }
138 
139  // L1 GT "active boards" map for EVM record
140  std::vector<int> activeBoardsEvmRecord = parSet.getParameter<std::vector<int> >("ActiveBoardsEvmRecord");
141 
142  if (boardList.size() != activeBoardsEvmRecord.size()) {
143  throw cms::Exception("Configuration")
144  << "\nError: inconsistent length of board list and active boards in GT EVM record.\n"
145  << "\n Can not define the mapping of the L1 GT boards. \n"
146  << std::endl;
147  }
148 
149  // L1 GT board - slot map
150  std::vector<int> boardSlotMap = parSet.getParameter<std::vector<int> >("BoardSlotMap");
151 
152  if (boardList.size() != boardSlotMap.size()) {
153  throw cms::Exception("Configuration") << "\nError: inconsistent length of board list and board - slot map.\n"
154  << "\n Can not define the mapping of the L1 GT boards. \n"
155  << std::endl;
156  }
157 
158  // L1 GT board name in hw record map
159  std::vector<int> boardHexNameMap = parSet.getParameter<std::vector<int> >("BoardHexNameMap");
160 
161  if (boardList.size() != boardHexNameMap.size()) {
162  throw cms::Exception("Configuration")
163  << "\nError: inconsistent length of board list and board name in hw record map.\n"
164  << "\n Can not define the mapping of the L1 GT boards. \n"
165  << std::endl;
166  }
167 
168  // GCT PSB to GT - map cables to input quadruplets and PSB indices
169 
170  // L1 GT cable list (GCT input to PSB)
171  std::vector<std::string> cableList = parSet.getParameter<std::vector<std::string> >("CableList");
172 
173  // L1 GT calo input to PSB map
174  // gives the mapping of GT calorimeter input to GT PSBs via PSB index
175  // 4 infinicables per PSB (last PSB can use only 2!)
176  std::vector<int> cableToPsbMap = parSet.getParameter<std::vector<int> >("CableToPsbMap");
177 
178  if (cableList.size() != cableToPsbMap.size()) {
179  throw cms::Exception("Configuration") << "\nError: inconsistent length of cable list and input to PSB list.\n"
180  << "\n Can not define the mapping of GCT quadruplets to GT PSBs.\n"
181  << std::endl;
182  }
183 
184  // detailed input configuration for PSB
185  std::vector<edm::ParameterSet> psbInput = parSet.getParameter<std::vector<edm::ParameterSet> >("PsbInput");
186 
187  // reserve space for L1 GT boards
188  m_gtBoardMaps.reserve(boardList.size());
189 
190  // fill the maps
191  int posVec = 0;
192 
193  for (std::vector<std::string>::const_iterator it = boardList.begin(); it != boardList.end(); ++it) {
194  L1GtBoardType boardType;
195 
196  if ((*it) == "GTFE") {
197  boardType = GTFE;
198  } else if ((*it) == "FDL") {
199  boardType = FDL;
200  } else if ((*it) == "PSB") {
201  boardType = PSB;
202  } else if ((*it) == "GMT") {
203  boardType = GMT;
204  } else if ((*it) == "TCS") {
205  boardType = TCS;
206  } else if ((*it) == "TIM") {
207  boardType = TIM;
208  } else {
209  throw cms::Exception("Configuration") << "\nError: no such board: " << (*it).c_str() << "\n"
210  << "\n Can not define the mapping of the L1 GT boards. \n"
211  << std::endl;
212  }
213 
214  // construct from board type and board index
215 
216  int iBoard = boardIndexVec.at(posVec);
217  L1GtBoard gtBoard = L1GtBoard(boardType, iBoard);
218 
219  // set the position of board data block
220  // in the GT DAQ readout record
221  gtBoard.setGtPositionDaqRecord(boardPositionDaqRecord.at(posVec));
222 
223  // set the position of board data block
224  // in the GT EVM readout record
225  gtBoard.setGtPositionEvmRecord(boardPositionEvmRecord.at(posVec));
226 
227  // set the bit of board in the GTFE ACTIVE_BOARDS
228  // for the GT DAQ readout record
229  gtBoard.setGtBitDaqActiveBoards(activeBoardsDaqRecord.at(posVec));
230 
231  // set the bit of board in the GTFE ACTIVE_BOARDS
232  // for the GT EVM readout record
233  gtBoard.setGtBitEvmActiveBoards(activeBoardsEvmRecord.at(posVec));
234 
235  // set board slot
236  int boardSlot = boardSlotMap.at(posVec);
237  gtBoard.setGtBoardSlot(boardSlot);
238 
239  // set board hex fragment name in hw record
240  gtBoard.setGtBoardHexName(boardHexNameMap.at(posVec));
241 
242  // set L1 quadruplet (4x16 bits)(cable) in the PSB input
243  // valid for PSB only
244 
245  if (boardType == PSB) {
246  L1GtPsbQuad psbQuad = Free;
247  int posCable = 0;
248  int iPsb = 0;
249  std::vector<L1GtPsbQuad> quadVec(L1GtBoard::NumberCablesBoard);
250 
251  for (std::vector<std::string>::const_iterator cIt = cableList.begin(); cIt != cableList.end(); ++cIt) {
252  if (*cIt == "TechTr") {
253  psbQuad = TechTr;
254  } else if (*cIt == "IsoEGQ") {
255  psbQuad = IsoEGQ;
256  } else if (*cIt == "NoIsoEGQ") {
257  psbQuad = NoIsoEGQ;
258  } else if (*cIt == "CenJetQ") {
259  psbQuad = CenJetQ;
260  } else if (*cIt == "ForJetQ") {
261  psbQuad = ForJetQ;
262  } else if (*cIt == "TauJetQ") {
263  psbQuad = TauJetQ;
264  } else if (*cIt == "ESumsQ") {
265  psbQuad = ESumsQ;
266  } else if (*cIt == "JetCountsQ") {
267  psbQuad = JetCountsQ;
268  } else if (*cIt == "MQB1") {
269  psbQuad = MQB1;
270  } else if (*cIt == "MQB2") {
271  psbQuad = MQB2;
272  } else if (*cIt == "MQF3") {
273  psbQuad = MQF3;
274  } else if (*cIt == "MQF4") {
275  psbQuad = MQF4;
276  } else if (*cIt == "MQB5") {
277  psbQuad = MQB5;
278  } else if (*cIt == "MQB6") {
279  psbQuad = MQB6;
280  } else if (*cIt == "MQF7") {
281  psbQuad = MQF7;
282  } else if (*cIt == "MQF8") {
283  psbQuad = MQF8;
284  } else if (*cIt == "MQB9") {
285  psbQuad = MQB9;
286  } else if (*cIt == "MQB10") {
287  psbQuad = MQB10;
288  } else if (*cIt == "MQF11") {
289  psbQuad = MQF11;
290  } else if (*cIt == "MQF12") {
291  psbQuad = MQF12;
292  } else if (*cIt == "Free") {
293  psbQuad = Free;
294  } else if (*cIt == "HfQ") {
295  psbQuad = HfQ;
296  } else {
297  // should not arrive here
298  throw cms::Exception("Configuration")
299  << "\nError: no such quadruplet: " << (*cIt).c_str() << "\n"
300  << "\n Can not define the mapping of quadruplets to the L1 PSB boards.\n"
301  << std::endl;
302  }
303 
304  int psbIndex = cableToPsbMap.at(posCable);
305 
306  if (psbIndex == gtBoard.gtBoardIndex()) {
307  if (iPsb > L1GtBoard::NumberCablesBoard) {
308  throw cms::Exception("Configuration")
309  << "\nError: too many cables for PSB_" << gtBoard.gtBoardIndex() << "\n\n "
310  << "Can not define the mapping of cables to L1 PSB boards. \n"
311  << std::endl;
312  }
313  quadVec[iPsb] = psbQuad;
314  iPsb++;
315  }
316  posCable++;
317  }
318 
319  gtBoard.setGtQuadInPsb(quadVec);
320  }
321 
322  if (boardType == PSB) {
323  std::map<int, std::vector<L1GtObject> > inputPsbChannels;
324 
325  std::vector<std::string> chStrings;
326  chStrings.reserve(2); // most channels have 2 objects
327 
328  std::vector<L1GtObject> chObjects;
329 
330  for (std::vector<edm::ParameterSet>::const_iterator itPSet = psbInput.begin(); itPSet != psbInput.end();
331  ++itPSet) {
332  //
333  int slot = itPSet->getParameter<int>("Slot");
334 
335  if (slot == boardSlot) {
336  chStrings = itPSet->getParameter<std::vector<std::string> >("Ch0");
337  chObjects = chInputObjects(chStrings);
338  inputPsbChannels[0] = chObjects;
339  chStrings.clear();
340  chObjects.clear();
341 
342  chStrings = itPSet->getParameter<std::vector<std::string> >("Ch1");
343  chObjects = chInputObjects(chStrings);
344  inputPsbChannels[1] = chObjects;
345  chStrings.clear();
346  chObjects.clear();
347 
348  chStrings = itPSet->getParameter<std::vector<std::string> >("Ch2");
349  chObjects = chInputObjects(chStrings);
350  inputPsbChannels[2] = chObjects;
351  chStrings.clear();
352  chObjects.clear();
353 
354  chStrings = itPSet->getParameter<std::vector<std::string> >("Ch3");
355  chObjects = chInputObjects(chStrings);
356  inputPsbChannels[3] = chObjects;
357  chStrings.clear();
358  chObjects.clear();
359 
360  chStrings = itPSet->getParameter<std::vector<std::string> >("Ch4");
361  chObjects = chInputObjects(chStrings);
362  inputPsbChannels[4] = chObjects;
363  chStrings.clear();
364  chObjects.clear();
365 
366  chStrings = itPSet->getParameter<std::vector<std::string> >("Ch5");
367  chObjects = chInputObjects(chStrings);
368  inputPsbChannels[5] = chObjects;
369  chStrings.clear();
370  chObjects.clear();
371 
372  chStrings = itPSet->getParameter<std::vector<std::string> >("Ch6");
373  chObjects = chInputObjects(chStrings);
374  inputPsbChannels[6] = chObjects;
375  chStrings.clear();
376  chObjects.clear();
377 
378  chStrings = itPSet->getParameter<std::vector<std::string> >("Ch7");
379  chObjects = chInputObjects(chStrings);
380  inputPsbChannels[7] = chObjects;
381  chStrings.clear();
382  chObjects.clear();
383  }
384  }
385 
386  gtBoard.setGtInputPsbChannels(inputPsbChannels);
387  }
388 
389  // push the board in the vector
390  m_gtBoardMaps.push_back(gtBoard);
391 
392  // increase the counter
393  posVec++;
394  }
395 }
396 
397 // destructor
399  // empty
400 }
401 
402 // member functions
403 
404 // method called to produce the data
405 std::unique_ptr<L1GtBoardMaps> L1GtBoardMapsTrivialProducer::produceBoardMaps(const L1GtBoardMapsRcd& iRecord) {
406  auto pL1GtBoardMaps = std::make_unique<L1GtBoardMaps>();
407 
408  pL1GtBoardMaps->setGtBoardMaps(m_gtBoardMaps);
409 
410  return pL1GtBoardMaps;
411 }
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Definition: L1GtObject.h:38
void setGtBoardSlot(const int &)
Definition: L1GtBoard.cc:204
void setGtBoardHexName(const int &)
Definition: L1GtBoard.cc:207
Definition: L1GtObject.h:35
void setGtBitEvmActiveBoards(const int &)
Definition: L1GtBoard.cc:199
std::vector< L1GtObject > chInputObjects(const std::vector< std::string > &chInputStrings)
void setGtPositionEvmRecord(const int &)
Definition: L1GtBoard.cc:187
Definition: L1GtObject.h:37
~L1GtBoardMapsTrivialProducer() override
destructor
std::unique_ptr< L1GtBoardMaps > produceBoardMaps(const L1GtBoardMapsRcd &)
public methods
std::vector< L1GtBoard > m_gtBoardMaps
L1 GT boards and their mapping.
const int gtBoardIndex() const
get / set board index
Definition: L1GtBoard.h:73
void setGtInputPsbChannels(const std::map< int, std::vector< L1GtObject > > &)
Definition: L1GtBoard.cc:215
void setGtBitDaqActiveBoards(const int &)
Definition: L1GtBoard.cc:193
void setGtPositionDaqRecord(const int &)
Definition: L1GtBoard.cc:181
L1GtBoardMapsTrivialProducer(const edm::ParameterSet &)
constructor
Definition: L1GtObject.h:29
Definition: L1GtObject.h:36
L1GtBoardType
board types in GT
L1GtPsbQuad
quadruples sent to GT via PSB
static const int NumberCablesBoard
number of InfiniCables per board
Definition: L1GtBoard.h:64
void setGtQuadInPsb(const std::vector< L1GtPsbQuad > &)
Definition: L1GtBoard.cc:211