ATLAS Offline Software
TrigConfCoolL1PayloadConverters.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "CoolKernel/Record.h"
9 #include "CoolKernel/IFolder.h"
10 #include "CoralBase/Attribute.h"
11 #include "CoralBase/AttributeList.h"
12 #include "CoralBase/AttributeListException.h"
13 
14 #include "CTPfragment/CTPdataformatVersion.h"
15 
17 #include "TrigConfL1Data/PIT.h"
18 #include "TrigConfL1Data/Menu.h"
33 
34 #include <iostream>
35 #include <iomanip>
36 #include <bitset>
37 
38 #include "boost/lexical_cast.hpp"
39 #include <boost/algorithm/string.hpp>
40 
41 using boost::lexical_cast;
42 
43 using namespace std;
44 using namespace cool;
45 using namespace TrigConf;
46 
47 
48 
49 Record
51  Record payload(fld->payloadSpecification());
52  payload["ItemName"].setValue<cool::String255>(item.name());
53  payload["ItemVersion"].setValue<cool::UInt32>(item.version());
54  return payload;
55 }
56 
57 
58 Record
60  Record payload(fld->payloadSpecification());
61  vector<string> thresholdlist;
62  string logic, conditions;
63  item.buildLogic(logic, thresholdlist);
64  vector<string>::iterator thrIt = thresholdlist.begin();
65  for(;thrIt!=thresholdlist.end();++thrIt) {
66  if(thrIt!=thresholdlist.begin()) conditions += ";";
67  conditions += *thrIt;
68  }
69  payload["Logic"].setValue<cool::String255>(logic);
70  payload["ConditionsList"].setValue<cool::String4k>(conditions);
71  return payload;
72 }
73 
74 
75 Record
76 TrigConfCoolL1PayloadConverters::createLvl1JetWeightPayload( cool::IFolderPtr fld, const vector<int>& jetweights ) {
77  Record payload(fld->payloadSpecification());
78  std::string thrValDef("");
79  for(std::vector<int>::const_iterator wIt = jetweights.begin(); wIt!=jetweights.end(); ++wIt) {
80  if(wIt != jetweights.begin()) thrValDef += ",";
81  thrValDef += lexical_cast<std::string,int>(*wIt);
82  }
83  payload["Threshold"].setValue<cool::String255>("JetWeights");
84  payload["ThresholdValue"].setValue<cool::String4k>(thrValDef);
85  payload["Cable"].setValue<cool::String255>("");
86  return payload;
87 }
88 
89 
90 Record
92  Record payload(fld->payloadSpecification());
93  string thrValDef("");
94  thrValDef += lexical_cast<std::string,int>(metSigParams.xsSigmaScale()) + ",";
95  thrValDef += lexical_cast<std::string,int>(metSigParams.xsSigmaOffset()) + ",";
96  thrValDef += lexical_cast<std::string,int>(metSigParams.xeMin()) + ",";
97  thrValDef += lexical_cast<std::string,int>(metSigParams.xeMax()) + ",";
98  thrValDef += lexical_cast<std::string,int>(metSigParams.teSqrtMin()) + ",";
99  thrValDef += lexical_cast<std::string,int>(metSigParams.teSqrtMax());
100  payload["Threshold"].setValue<cool::String255>("METSigParams");
101  payload["ThresholdValue"].setValue<cool::String4k>(thrValDef);
102  payload["Cable"].setValue<cool::String255>("");
103  return payload;
104 }
105 
106 
107 Record
109  Record payload(fld->payloadSpecification());
110  // TriggerThreshold
111  string thrDef("");
112  thrDef += thr.name(); thrDef += ",";
113  thrDef += lexical_cast<std::string,int>(thr.version()); thrDef += ",";
114  thrDef += thr.type(); thrDef += ",";
115  thrDef += lexical_cast<std::string,int>(thr.mapping()); thrDef += ",";
116  thrDef += lexical_cast<std::string,bool>(thr.active());
117 
118 
119  // TriggerThresholdValue
120  string thrValDef("");
121  vector<TriggerThresholdValue*>::const_iterator thrValIt = thr.thresholdValueVector().begin();
122  vector<TriggerThresholdValue*>::const_iterator thrValEnd = thr.thresholdValueVector().end();
123  for(;thrValIt!=thrValEnd;++thrValIt) {
124  TriggerThresholdValue* thrVal = *thrValIt;
125 
126  string valName = thrVal->name();
127  string valType = thrVal->type();
128  string valThresholdval = lexical_cast<string,float> (thrVal->ptcut());
129  string valEtamin = lexical_cast<string,int> (thrVal->etamin());
130  string valEtamax = lexical_cast<string,int> (thrVal->etamax());
131  string valPhimin = lexical_cast<string,int> (thrVal->phimin());
132  string valPhimax = lexical_cast<string,int> (thrVal->phimax());
133  string valWindow = lexical_cast<string,int> (thrVal->window());
134  string valEm_isolation = "63";
135  string valHad_isolation = "63";
136  string valHad_veto = "63";
137  string valPriority = lexical_cast<string,float>(thrVal->priority());
138 
139  if ( thr.type()==L1DataDef::emType() ||
140  thr.type()==L1DataDef::tauType() ) {
141  ClusterThresholdValue* cluThrVal = dynamic_cast<ClusterThresholdValue*>(thrVal);
142  if(cluThrVal) {
143  valEm_isolation = lexical_cast<string,float>(cluThrVal->emIsolation());
144  valHad_isolation = lexical_cast<string,float>(cluThrVal->hadIsolation());
145  valHad_veto = lexical_cast<string,float>(cluThrVal->hadVeto());
146  }
147  } // for the other types nothing needs to be done
148 
149  if(thrValIt!=thr.thresholdValueVector().begin()) thrValDef += ";"; // separation between TTV's
150  thrValDef += valName; thrValDef += ",";
151  thrValDef += valType; thrValDef += ",";
152  thrValDef += valThresholdval; thrValDef += ",";
153  thrValDef += valEtamin; thrValDef += ",";
154  thrValDef += valEtamax; thrValDef += ",";
155  thrValDef += valPhimin; thrValDef += ",";
156  thrValDef += valPhimax; thrValDef += ",";
157  thrValDef += valEm_isolation; thrValDef += ",";
158  thrValDef += valHad_isolation; thrValDef += ",";
159  thrValDef += valHad_veto; thrValDef += ",";
160  thrValDef += valWindow; thrValDef += ",";
161  thrValDef += valPriority;
162  }
163 
164 
165  // Cable info
166  std::string cableDef("");
167  cableDef += thr.cableName(); cableDef += ",";
168  cableDef += thr.cableCtpin(); cableDef += ",";
169  cableDef += thr.cableConnector(); cableDef += ",";
170  cableDef += lexical_cast<std::string,int>(thr.cableStart()); cableDef += ",";
171  cableDef += lexical_cast<std::string,int>(thr.cableEnd());
172 
173  // fill the payload
174  payload["Threshold"].setValue<cool::String255>(thrDef);
175  payload["ThresholdValue"].setValue<cool::String4k>(thrValDef);
176  payload["Cable"].setValue<cool::String255>(cableDef);
177  return payload;
178 }
179 
180 
181 Record
182 TrigConfCoolL1PayloadConverters::createLvl1ConfigKeyPayload( cool::IFolderPtr fld, unsigned int lvl1PrescaleKey ) {
183  Record payload(fld->payloadSpecification());
184  payload["Lvl1PrescaleConfigurationKey"].setValue<cool::UInt32>(lvl1PrescaleKey);
185  return payload;
186 }
187 
188 
189 Record
191  Record payload(fld->payloadSpecification());
192  if(payload["Lvl1Prescale"].storageType()==cool::StorageType::Int32)
193  payload["Lvl1Prescale"].setValue<cool::Int32>(prescale);
194  else
195  payload["Lvl1Prescale"].setValue<cool::Int64>(prescale);
196  return payload;
197 }
198 
199 
200 Record
202  Record payload(fld->payloadSpecification());
203  if(payload["Lvl1Prescale"].storageType()==cool::StorageType::Int32)
204  payload["Lvl1Prescale"].setValue<cool::Int32>(prescale);
205  else
206  payload["Lvl1Prescale"].setValue<cool::Int64>(prescale);
207  return payload;
208 }
209 
210 
211 Record
212 TrigConfCoolL1PayloadConverters::createLvl1BGKeyPayload( cool::IFolderPtr fld, unsigned int lvl1BunchgroupKey) {
213  Record payload(fld->payloadSpecification());
214  payload["Lvl1BunchGroupConfigurationKey"].setValue<cool::UInt32>(lvl1BunchgroupKey);
215  return payload;
216 }
217 
218 
219 Record
221 
222  Record payload(fld->payloadSpecification());
223 
224  // the output vector
225  vector<unsigned char> codes(2 * TrigConfCoolFolderSpec::mBGContentBlobSize, 0 );
226 
227  std::vector<const BunchGroup*> bgOrdered(16,(const BunchGroup*)0);
228 
229  for(const BunchGroup & bgp: bgs.bunchGroups())
230  bgOrdered.at(bgp.internalNumber()) = &bgp;
231 
232 
233 
234 
235  for(int bgC=0; bgC<16; ++bgC) {
236  const BunchGroup* bg = bgOrdered[bgC];
237  if(bg==0) continue;
238 
239  // mask describes the current bunchgroup (BG1: 1, BG2: 2, BG3: 4, ..., BG8: 128)
240 
241  unsigned char mask = (1 << (bgC % 8) );
242  unsigned int bgOffset = bgC < 8 ? 0 : TrigConfCoolFolderSpec::mBGContentBlobSize; // for BG 8-15 we use the higher part of the blob
243 
244  for(int b : bg->bunches()) {
245  if(b<0 || b >= TrigConfCoolFolderSpec::mBGContentBlobSize) {
246  // this is a serious error which can't be ignored
247  std::string errorMsg =
248  "Bunch group " + to_string(bgC) + " contains bunch number "
249  + to_string(b) + " which is outside the range [0,3563]";
250  throw std::runtime_error(errorMsg);
251  }
252  codes[static_cast<unsigned int>(b) + bgOffset] |= mask;
253  }
254  }
255 
256  std::cout << "LVL1 bunchgroups [list 16 bunches per line]:" << std::endl;
258 
259  blob.resize( codes.size() );
260 
261  unsigned char* p = static_cast<unsigned char*>(blob.startingAddress());
262 
263  for (size_t i=0; i < codes.size() ; ++i,++p) {
264  *p = codes[i];
265 
266  cout << string(std::bitset<8>(codes[i]).to_string<char,std::char_traits<char>,std::allocator<char> >());
267  if((i+1)%16==0) cout << endl;
268  else cout << " ";
269  }
270  cout << endl;
271 
272  payload["BunchCode"].setValue<coral::Blob>( blob );
273 
274 
275  return payload;
276 }
277 
278 
279 
280 
281 
282 Record
283 TrigConfCoolL1PayloadConverters::createLvl1BGDescPayload( cool::IFolderPtr fld, const BunchGroupSet& bgs, const Menu& lvl1Menu) {
284 
285  CTPdataformatVersion ctpDataformat(lvl1Menu.thresholdConfig().ctpVersion());
286 
287  Record payload(fld->payloadSpecification());
288 
289 
290  for(const BunchGroup& bunchgroup: bgs.bunchGroups()) {
291 
292  unsigned int internalNumber = bunchgroup.internalNumber();
293 
294  const string bgname = bunchgroup.name();
295 
296  std::string payloadKey = "BunchGroup" + boost::lexical_cast<std::string,int>(internalNumber);
297 
298  if(payload.specification().exists(payloadKey)) {
299  std::cout << "Write bunch group " << payloadKey << ": '"<< bgname <<"'" << std::endl;
300  payload[payloadKey].setValue<cool::String255>( bgname );
301  } else {
302  std::cout << "WARNING: COOL DB schema has not yet made fields for bunchgroup " << internalNumber << " (" << bgname << ")" << endl;
303  }
304  }
305 
306  cout << "Writing bunch group description with size " << ctpDataformat.getMaxTrigItems() << endl;
307 
308  vector<unsigned char> codes( ctpDataformat.getMaxTrigItems() ,0);
309  for(TriggerItem* item: lvl1Menu.items() ) {
310 
311  unsigned int ctpid = item->ctpId();
312  if(ctpid >= codes.size())
313  throw runtime_error("Item ctpid exceeds blob size!");
314  const TriggerItemNode* topNode = item->topNode();
315  if(topNode==0)
316  throw runtime_error("Item " + item->name() + " has no definition nodes attached");
317  vector<bool> v1;
318  // get a vector of size 8, element true means the bunch group is
319  // in the item definition - assumes AND logic only!
320  topNode->getAllBunchGroups(v1);
321  for(size_t i = 0; i<v1.size();++i) {
322  if(v1[i]) codes[ctpid] |= (1<<i);
323  }
324 
325  cout << "Item " << setw(3) << setfill(' ') << ctpid << " bunch-group code "
326  << string(bitset<8>(codes[ctpid]).to_string<char,char_traits<char>,allocator<char> >())
327  << endl;
328  }
329 
330  // Get the blob, resize it to actual size, and push codes into it
331  // coral::Blob& blob = payload["ItemToBunchGroupMap"].data<coral::Blob>();
333  blob.resize( codes.size() );
334  unsigned char* p = static_cast<unsigned char*>(blob.startingAddress());
335  for (size_t i=0; i < codes.size(); ++i,++p) {
336  *p = codes[i];
337  }
338 
339  payload["ItemToBunchGroupMap"].setValue<coral::Blob>( blob );
340 
341  return payload;
342 }
343 
344 
345 
346 
347 // ------------------------------------------------------------
348 // createLvl1InputMapPayload(std::string pitMap)
349 // ------------------------------------------------------------
350 cool::Record
352 {
353  Record payload(fld->payloadSpecification());
354  payload["ThresholdName"].setValue<cool::String255>(tip.thresholdName());
355  payload["CtpinSlot"].setValue<cool::UChar>(static_cast<unsigned char>(tip.slot()));
356  payload["CtpinConnector"].setValue<cool::UChar>(static_cast<unsigned char>(tip.connector()));
357  payload["ThresholdBit"].setValue<cool::UChar>(static_cast<unsigned char>(tip.thresholdBit()));
358  payload["CableBit"].setValue<cool::UChar>(static_cast<unsigned char>(tip.cableBit()));
359  payload["ThresholdMapping"].setValue<cool::UChar>(static_cast<unsigned char>(tip.thresholdMapping()));
360  payload["ThresholdActive"].setValue<cool::Bool>(tip.thresholdActive());
361  return payload;
362 }
363 
364 // ------------------------------------------------------------
365 // createLvl1MonMapPayload(std::string monMap)
366 // ------------------------------------------------------------
367 cool::Record
369  const std::string& type,
370  const uint16_t& bgId,
371  const std::string& threshName,
372  const std::string& slot,
373  const std::string& con,
374  const std::string& mult,
375  const std::string& start,
376  const std::string& end,
377  const std::string& active,
378  const std::string& monName,
379  const std::string& CounterLogic)
380 {
381  Record payload(fld->payloadSpecification());
382  payload["CounterType"].setValue<cool::String255>(type);
383  payload["BunchGroupId"].setValue<cool::UChar>(static_cast<unsigned char>(bgId));
384  payload["ThresholdName"].setValue<cool::String255>(threshName);
385  payload["CtpinSlot"].setValue<cool::String255>(slot);
386  payload["CtpinConnector"].setValue<cool::String255>(con);
387  payload["Multiplicity"].setValue<cool::String255>(mult);
388  payload["ThresholdBitStart"].setValue<cool::String255>(start);
389  payload["ThresholdBitEnd"].setValue<cool::String255>(end);
390  payload["ThresholdActive"].setValue<cool::String255>(active);
391  payload["CounterName"].setValue<cool::String255>(monName);
392  payload["CounterLogic"].setValue<cool::String255>(CounterLogic);
393  return payload;
394 }
395 
396 
397 TriggerItem *
399  TriggerItem * item = new TriggerItem();
400  item->setName ( al["ItemName"]. data<cool::String255>() );
401  item->setVersion( al["ItemVersion"].data<cool::UInt32>() );
402  return item;
403 }
404 
405 
406 void
408  const vector<TriggerThreshold*>& thrs) {
409  string logic = al["Logic"].data<cool::String255>();
410  vector<string> condList = split(al["ConditionsList"].data<cool::String4k>(), ";");
411 
412  item->setCondition(logic, condList, thrs);
413 }
414 
415 
418  string thrDef = al["Threshold"].data<cool::String255>();
419  string thrValDef = al["ThresholdValue"].data<cool::String4k>();
420  string cableDef = al["Cable"].data<cool::String255>();
421 
422  // TriggerThreshold
423  TriggerThreshold * thr = new TriggerThreshold();
424  vector<string> thrDefV = split(thrDef,",");
425  thr->setName(thrDefV[0]);
426 
427  // there was a late request for adding the JetWeights to COOL since
428  // we don't want to add new folders to the schema, we added the
429  // twelve jetweights as a special Threshold to the COOL/Threshold folder
430  if(thr->name()=="JetWeights" || thr->name()=="METSigParams") {
431  thr->setCableName(thrValDef);
432  return thr;
433  }
434 
435  thr->setVersion(lexical_cast<int, string>(thrDefV[1]));
436  thr->setType(thrDefV[2]);
437  thr->setMapping(lexical_cast<int, string>(thrDefV[3]));
438  thr->setActive(lexical_cast<bool, string>(thrDefV[4]));
439 
440  // internal triggers have no mapping (and are usually not stored in COOL, except by the online L1)
441  // in order to insert them in the threshold vector at the right position they get a mapping according to their name
442  // BGRP0,BGRP1,BGRP2,BGRP3,BGRP4...
443  // RNDM0,RNDM1,RNDM2,...
444  // PCLK0,...
445  if(thr->isInternal()) {
446  string::size_type pos = thr->name().find_first_of("0123456789");
447  int mapping = boost::lexical_cast<int,string>(thr->name().substr(pos));
448  thr->setMapping( mapping );
449  }
450 
451  // TriggerThresholdValues
452  vector<string> thrAllValDefV = split(thrValDef,";");
453  for(const string& thrAllVal: thrAllValDefV) {
454  if(thrAllVal=="") continue;
455  vector<string> thrValDefV = split(thrAllVal,",");
456 
457  string valName = thrValDefV[0];
458  string valType = thrValDefV[1];
459  float valThresholdval = lexical_cast<float, string>(thrValDefV[2]);
460  int valEtamin = lexical_cast<int, string>(thrValDefV[3]);
461  int valEtamax = lexical_cast<int, string>(thrValDefV[4]);
462  int valPhimin = lexical_cast<int, string>(thrValDefV[5]);
463  int valPhimax = lexical_cast<int, string>(thrValDefV[6]);
464  float valEm_isolation = lexical_cast<float, string>(thrValDefV[7]);
465  float valHad_isolation = lexical_cast<float, string>(thrValDefV[8]);
466  float valHad_veto = lexical_cast<float, string>(thrValDefV[9]);
467  int valWindow = lexical_cast<int, string>(thrValDefV[10]);
468  float valPriority = lexical_cast<float, string>(thrValDefV[11]);
469 
470  TriggerThresholdValue* thrv = TriggerThreshold::createThresholdValue( thr->type() );
471  if(thrv) {
472  thrv->setName(valName);
473  thrv->setType(valType);
474  thrv->setName(valName);
475  thrv->setType(valType);
476  thrv->setPtcut(valThresholdval);
477  thrv->setPriority(valPriority);
478  thrv->setEtaMin(valEtamin);
479  thrv->setEtaMax(valEtamax);
480  thrv->setPhiMin(valPhimin);
481  thrv->setPhiMax(valPhimax);
482  thrv->setWindow(valWindow);
483  ClusterThresholdValue* cluthrval = dynamic_cast<ClusterThresholdValue*>(thrv);
484  if(cluthrval) {
485  cluthrval->setEmIsolation(valEm_isolation);
486  cluthrval->setHadIsolation(valHad_isolation);
487  cluthrval->setHadVeto(valHad_veto);
488  }
489  }
490  thr->addThresholdValue(thrv);
491  }
492 
493  // add the cable information
494  vector<string> cableDefV = split(cableDef,",");
495  string cableName = cableDefV[0];
496  string cableCtpin = cableDefV[1];
497  string cableConnector = cableDefV[2];
498  int cableStart = lexical_cast<int,std::string>(cableDefV[3]);
499  int cableEnd = lexical_cast<int,std::string>(cableDefV[4]);
500  thr->setCableName ( cableName );
501  thr->setCableCtpin ( cableCtpin);
502  string ctpin(cableCtpin);
503  boost::to_lower(ctpin);
504  if( ctpin == "ctpcore" ) {
505  thr->setInput( "ctpcore" );
506  } else {
507  thr->setInput( "ctpin" );
508  }
509  thr->setCableConnector( cableConnector);
510  thr->setCableStart ( cableStart );
511  thr->setCableEnd ( cableEnd );
512 
513  return thr;
514 }
515 
516 
517 vector<BunchGroup>
519  const coral::Blob& blob = al["BunchCode"].data<coral::Blob>();
520 
521  // check blob size - if we ever change the blob size, we have to work with schema versions here
522  if(blob.size() != 3564 && blob.size() != 2 * 3564)
523  throw runtime_error("Read BLOB for BunchCode of unexpected size!");
524 
525 
526  unsigned int numberBG = (blob.size() == 3564) ? 8 : 16;
527 
528  vector<BunchGroup> bgV(numberBG);
529  unsigned int bgIdx(0);
530  for(BunchGroup & bg : bgV) {
531  bg.setInternalNumber(bgIdx++);
532  }
533 
534  const unsigned char* p = static_cast<const unsigned char*>(blob.startingAddress());
535 
536  for (size_t bunch = 0; bunch < 3564; ++bunch, ++p) {
537  unsigned char mask = *p;
538  for(int i=0; i<8;i++) {
539  if( (mask>>i) & 0x1) bgV[i].addBunch(bunch);
540  }
541  }
542 
543  if(blob.size() == 2 * 3564) { // Run 2 with have 8 more BG
544  for (size_t bunch = 0; bunch < 3564; ++bunch, ++p) {
545  unsigned char mask = *p;
546  for(int i=0; i<8;i++)
547  if( (mask>>i) & 0x1) bgV[8+i].addBunch(bunch);
548  }
549  }
550  return bgV;
551 }
552 
553 
554 pair< vector<string>, map<unsigned int,unsigned char> >
556  vector<string> names;
557  names.push_back(al["BunchGroup0"].data<cool::String255>());
558  names.push_back(al["BunchGroup1"].data<cool::String255>());
559  names.push_back(al["BunchGroup2"].data<cool::String255>());
560  names.push_back(al["BunchGroup3"].data<cool::String255>());
561  names.push_back(al["BunchGroup4"].data<cool::String255>());
562  names.push_back(al["BunchGroup5"].data<cool::String255>());
563  names.push_back(al["BunchGroup6"].data<cool::String255>());
564  names.push_back(al["BunchGroup7"].data<cool::String255>());
565  try {
566  names.push_back(al["BunchGroup8"].data<cool::String255>());
567  names.push_back(al["BunchGroup9"].data<cool::String255>());
568  names.push_back(al["BunchGroup10"].data<cool::String255>());
569  names.push_back(al["BunchGroup11"].data<cool::String255>());
570  names.push_back(al["BunchGroup12"].data<cool::String255>());
571  names.push_back(al["BunchGroup13"].data<cool::String255>());
572  names.push_back(al["BunchGroup14"].data<cool::String255>());
573  names.push_back(al["BunchGroup15"].data<cool::String255>());
574  }
575  catch(const coral::AttributeListException &) {} // run2
576 
577  std::map<unsigned int,unsigned char> codes;
578  const coral::Blob& blob = al["ItemToBunchGroupMap"].data<coral::Blob>();
579  // check blob size - if we ever change the blob size, have to work
580  // with schema versions here
581 
582  if(blob.size() != 256 && blob.size() != 512)
583  throw runtime_error("Read BLOB for ItemToBunchGroupMap of unexpected size!");
584 
585  const unsigned char* p = static_cast<const unsigned char*>(blob.startingAddress());
586  for (long i = 0; i < blob.size(); ++i,++p) {
587  unsigned char mask = (*p);
588  codes.insert( make_pair(i,mask) );
589  }
590  return make_pair(names,codes);
591 }
592 
593 
594 void
596  unsigned int & lvl1PrescaleKey )
597 {
598  lvl1PrescaleKey = al["Lvl1PrescaleConfigurationKey"].data<cool::UInt32>();
599 }
600 
601 
602 void
604 {
605  if ( al["Lvl1Prescale"].specification().type() == typeid(cool::Int32) )
606  prescaleValue = al["Lvl1Prescale"].data<cool::Int32>();
607  else
608  prescaleValue = al["Lvl1Prescale"].data<cool::Int64>();
609 }
610 
611 
612 void
614 {
615  if ( al["Lvl1Prescale"].specification().type() == typeid(cool::Int32) )
616  prescaleValue = al["Lvl1Prescale"].data<cool::Int32>();
617  else
618  prescaleValue = al["Lvl1Prescale"].data<cool::Int64>();
619 }
620 
621 
622 int
624 {
625  return al["Lvl1BunchGroupConfigurationKey"].data<cool::UInt32>();
626 }
627 
628 
629 PIT*
631 {
632  TrigConf::PIT* pit = new TrigConf::PIT();
633  pit->setThresholdName( al["ThresholdName"].data<cool::String255>() );
634  pit->setCtpinSlot( static_cast<uint16_t>(al["CtpinSlot"].data<cool::UChar>()) );
635  pit->setCtpinConnector( static_cast<uint16_t>(al["CtpinConnector"].data<cool::UChar>()) );
636  pit->setThresholdBit( static_cast<uint16_t>(al["ThresholdBit"].data<cool::UChar>()) );
637  pit->setCableBit( static_cast<uint16_t>(al["CableBit"].data<cool::UChar>()) );
638  pit->setThresholdMapping( static_cast<uint16_t>(al["ThresholdMapping"].data<cool::UChar>()) );
639  pit->setThresholdActive( al["ThresholdActive"].data<cool::Bool>() );
640 
641  return pit;
642 }
643 
644 TIP*
646 {
647  TrigConf::TIP* tip = new TrigConf::TIP();
648  tip->setThresholdName( al["ThresholdName"].data<cool::String255>() );
649  tip->setSlot( static_cast<uint16_t>(al["CtpinSlot"].data<cool::UChar>()) );
650  tip->setConnector( static_cast<uint16_t>(al["CtpinConnector"].data<cool::UChar>()) );
651  tip->setThresholdBit( static_cast<uint16_t>(al["ThresholdBit"].data<cool::UChar>()) );
652  tip->setCableBit( static_cast<uint16_t>(al["CableBit"].data<cool::UChar>()) );
653  tip->setThresholdMapping( static_cast<uint16_t>(al["ThresholdMapping"].data<cool::UChar>()) );
654  tip->setThresholdActive( al["ThresholdActive"].data<cool::Bool>() );
655 
656  return tip;
657 }
658 
659 std::vector<TrigConf::ThresholdMonitor*>
661 {
662  vector<ThresholdMonitor*> vec;
663  vector<string> names = split(payload["ThresholdName"].data<cool::String255>(),":");
664  vector<string> slots = split(payload["CtpinSlot"].data<cool::String255>(),":");
665  vector<string> cons = split(payload["CtpinConnector"].data<cool::String255>(),":");
666  vector<string> mults = split(payload["Multiplicity"].data<cool::String255>(),":");
667  vector<string> starts = split(payload["ThresholdBitStart"].data<cool::String255>(),":");
668  vector<string> ends = split(payload["ThresholdBitEnd"].data<cool::String255>(),":");
669  vector<string> actives = split(payload["ThresholdActive"].data<cool::String255>(),":");
670 
671  string monname = payload["CounterName"].data<cool::String255>();
672  string type = payload["CounterType"].data<cool::String255>();
673  //std::string counterlogic = payload["CounterLogic"].data<cool::String255>();
674  unsigned char bgId = payload["BunchGroupId"].data<cool::UChar>();
675 
676  // check vectors are all the same size
677  if(
678  names.size() != slots.size() ||
679  names.size() != cons.size() ||
680  names.size() != mults.size() ||
681  names.size() != starts.size() ||
682  names.size() != ends.size() ||
683  names.size() != actives.size()
684  )
685  throw std::runtime_error("Inconsistent mon vector sizes!");
686 
687  for(size_t i = 0 ; i < names.size(); ++i) {
689  // Not possible yet. mon->setLogic(counterlogic[i]);
690  mon->setName(monname);
691  mon->setBunchGroupId( static_cast<int>(bgId) );
692  mon->setCounterType(type);
693 
694  mon->setThresholdName(names[i]);
695  mon->setCtpinSlot( lexical_cast<uint16_t,std::string>(slots[i]) );
696  mon->setCtpinConnector( lexical_cast<uint16_t,std::string>(cons[i]) );
697  mon->setThresholdStartBit( lexical_cast<int,std::string>(starts[i]) );
698  mon->setThresholdEndBit( lexical_cast<int,std::string>(ends[i]) );
699  mon->setMultiplicity( lexical_cast<int,std::string>(mults[i]) );
700  bool active = (actives[i]=="ENABLED");
701  mon->setThresholdActive( active );
702  vec.push_back(mon);
703  }
704  return vec;
705 }
706 
707 
708 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TrigConf::TriggerThresholdValue
Definition: TriggerThresholdValue.h:22
TrigConf::TrigConfData::setName
void setName(const std::string &name)
Definition: TrigConfData.h:30
TrigConf::BunchGroup
Definition: BunchGroup.h:17
TrigConf::BunchGroupSet
Definition: BunchGroupSet.h:19
TriggerItem.h
TrigConf::TriggerThresholdValue::setPtcut
void setPtcut(float pt)
Definition: TriggerThresholdValue.h:58
PrescaleSet.h
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1MonMapPayload
cool::Record createLvl1MonMapPayload(cool::IFolderPtr, const std::string &type, const uint16_t &bgId, const std::string &threshName, const std::string &slot, const std::string &con, const std::string &mult, const std::string &start, const std::string &end, const std::string &active, const std::string &monName=std::string(""), const std::string &CounterLogic=std::string(""))
build a COOL db record from a monitoring-mapping string value
Definition: TrigConfCoolL1PayloadConverters.cxx:368
TrigConf::TrigConfData::name
const std::string & name() const
Definition: TrigConfData.h:22
TrigConf::PIT
Definition: PIT.h:13
TrigConf::TrigConfCoolL1PayloadConverters::readLvl1BGDesc
std::pair< std::vector< std::string >, std::map< unsigned int, unsigned char > > readLvl1BGDesc(const coral::AttributeList &al)
build the LVL1 Bunchgroup descriptions from a coral::AttributeList
Definition: TrigConfCoolL1PayloadConverters.cxx:555
TrigConf::PIT::setThresholdName
void setThresholdName(const std::string &name)
Definition: PIT.h:21
TrigConf::TriggerThreshold::mapping
int mapping() const
Definition: TriggerThreshold.h:33
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
TrigConf::TriggerThreshold::cableName
const std::string & cableName() const
Definition: TriggerThreshold.h:34
TrigConf::METSigParam
Definition: METSigParam.h:12
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1PrescalesPayload
cool::Record createLvl1PrescalesPayload(cool::IFolderPtr, int prescale)
build a COOL db record from a LVL1 prescale value
Definition: TrigConfCoolL1PayloadConverters.cxx:190
StandaloneBunchgroupHandler.bg
bg
Definition: StandaloneBunchgroupHandler.py:243
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1ConfigKeyPayload
cool::Record createLvl1ConfigKeyPayload(cool::IFolderPtr, unsigned int lvl1PrescaleKey)
build a COOL db record from a LVL1 configuration key
Definition: TrigConfCoolL1PayloadConverters.cxx:182
TrigConf::TIP::setThresholdMapping
void setThresholdMapping(const int16_t &m)
Definition: TIP.h:45
TrigConf::TrigConfCoolL1PayloadConverters::readLvl1InputMap
TrigConf::PIT * readLvl1InputMap(const coral::AttributeList &al)
Build a LVL1 PIT object from COOL payload.
Definition: TrigConfCoolL1PayloadConverters.cxx:630
TrigConfCoolL1PayloadConverters.h
TrigConf::TIP::connector
uint16_t connector() const
Definition: TIP.h:26
TrigConf::TriggerThreshold::cableEnd
int cableEnd() const
Definition: TriggerThreshold.h:38
TrigConf::TIP::setThresholdName
void setThresholdName(const std::string &name)
Definition: TIP.h:21
TrigConf::TriggerThresholdValue::setPhiMax
void setPhiMax(int value)
Definition: TriggerThresholdValue.h:62
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
xAOD::char
char
Definition: TrigDecision_v1.cxx:38
TrigConf::TIP
Definition: TIP.h:13
DeMoUpdate.errorMsg
string errorMsg
Definition: DeMoUpdate.py:897
TrigConf::TrigConfCoolL1PayloadConverters::readLvl1BGContent
std::vector< TrigConf::BunchGroup > readLvl1BGContent(const coral::AttributeList &al)
build the LVL1 Bunchgroup code
Definition: TrigConfCoolL1PayloadConverters.cxx:518
TrigConf::TriggerThresholdValue::ptcut
float ptcut() const
Definition: TriggerThresholdValue.h:45
TrigConf::ClusterThresholdValue::setHadVeto
void setHadVeto(float v)
Definition: ClusterThresholdValue.h:40
TrigConf::TriggerThreshold::cableStart
int cableStart() const
Definition: TriggerThreshold.h:37
TrigConf::TrigConfCoolL1PayloadConverters::readLvl1BGKey
int readLvl1BGKey(const coral::AttributeList &al)
build the LVL1 Bunchgroup key value
Definition: TrigConfCoolL1PayloadConverters.cxx:623
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1METSigPayload
cool::Record createLvl1METSigPayload(cool::IFolderPtr, const METSigParam &metSigParams)
build a COOL db record from a L1 MET significance global parameters
Definition: TrigConfCoolL1PayloadConverters.cxx:91
TrigConf::TIP::thresholdActive
bool thresholdActive() const
Definition: TIP.h:47
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
TrigConf::TriggerThreshold::thresholdValueVector
const std::vector< TriggerThresholdValue * > & thresholdValueVector() const
Definition: TriggerThreshold.cxx:114
Menu.h
TrigConf::TIP::thresholdBit
uint16_t thresholdBit() const
Definition: TIP.h:32
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
TrigConf::TriggerItemNode
Definition: TriggerItemNode.h:22
ThresholdMonitor.h
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1ThresholdPayload
cool::Record createLvl1ThresholdPayload(cool::IFolderPtr, const TrigConf::TriggerThreshold &thr)
build a COOL db record from a LVL1 TriggerItem
Definition: TrigConfCoolL1PayloadConverters.cxx:108
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1Threshold
TriggerThreshold * createLvl1Threshold(const coral::AttributeList &al)
build a LVL1 TriggerThreshold from a COOL db record
Definition: TrigConfCoolL1PayloadConverters.cxx:417
TrigConf::TrigConfCoolL1PayloadConverters::addThresholdsToTriggerItem
void addThresholdsToTriggerItem(const coral::AttributeList &al, TriggerItem *item, const std::vector< TrigConf::TriggerThreshold * > &thrs)
build a TriggerThreshold definition from a COOL db record and add to the corresponding item
Definition: TrigConfCoolL1PayloadConverters.cxx:407
TrigConf::TriggerThresholdValue::setWindow
void setWindow(int value)
Definition: TriggerThresholdValue.h:60
find_tgc_unfilled_channelids.mapping
mapping
Definition: find_tgc_unfilled_channelids.py:17
TrigConf::TIP::cableBit
uint16_t cableBit() const
Definition: TIP.h:35
TrigConf::ClusterThresholdValue
Definition: ClusterThresholdValue.h:13
TrigConf::TriggerThreshold::active
bool active() const
Definition: TriggerThreshold.h:32
TrigConf::METSigParam::teSqrtMax
int teSqrtMax() const
Definition: METSigParam.h:35
HelperFunctions.h
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1BGDescPayload
cool::Record createLvl1BGDescPayload(cool::IFolderPtr fld, const TrigConf::BunchGroupSet &bgs, const TrigConf::Menu &lvl1Menu)
build a COOL db record from a bunch group description
Definition: TrigConfCoolL1PayloadConverters.cxx:283
cool
Definition: CoolTagInfo.h:12
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
XsThresholdValue.h
TrigConf::ThresholdMonitor
Definition: ThresholdMonitor.h:18
TrigConf::TIP::setConnector
void setConnector(const uint16_t &id)
Definition: TIP.h:27
MuonThresholdValue.h
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
PyPoolBrowser.item
item
Definition: PyPoolBrowser.py:129
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1ItemDefPayload
cool::Record createLvl1ItemDefPayload(cool::IFolderPtr, const TrigConf::TriggerItem &item)
build a COOL db record from a LVL1 TriggerItem (the conditions)
Definition: TrigConfCoolL1PayloadConverters.cxx:59
python.ExitCodes.codes
dictionary codes
helper to get a human-readable string
Definition: ExitCodes.py:49
TrigConf::PIT::setThresholdMapping
void setThresholdMapping(const int16_t &m)
Definition: PIT.h:45
TrigConf::TriggerThreshold::type
const std::string & type() const
Definition: TriggerThreshold.h:31
TrigConf::PIT::setCableBit
void setCableBit(const uint16_t &num)
Definition: PIT.h:36
TrigConf::Menu
Definition: Menu.h:49
TrigConf::METSigParam::xeMin
int xeMin() const
Definition: METSigParam.h:32
TrigConf::TrigConfCoolL1PayloadConverters::readLvl1ConfigKey
void readLvl1ConfigKey(const coral::AttributeList &al, unsigned int &lvl1PrescaleKey)
build the LVL1 configuration key from a coral::AttributeList
Definition: TrigConfCoolL1PayloadConverters.cxx:595
Trk::active
@ active
Definition: Layer.h:48
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
TrigConf::TriggerThresholdValue::phimax
int phimax() const
Definition: TriggerThresholdValue.h:52
lumiFormat.i
int i
Definition: lumiFormat.py:92
TrigConf::ClusterThresholdValue::setHadIsolation
void setHadIsolation(float v)
Definition: ClusterThresholdValue.h:39
TrigConf::ClusterThresholdValue::hadIsolation
float hadIsolation() const
Definition: ClusterThresholdValue.h:22
TrigConf::TriggerThreshold::cableConnector
const std::string & cableConnector() const
Definition: TriggerThreshold.h:36
TrigConf::TrigConfCoolL1PayloadConverters::readLvl1Prescale
void readLvl1Prescale(const coral::AttributeList &al, int &ps)
build the LVL1 prescale value from a coral::AttributeList
Definition: TrigConfCoolL1PayloadConverters.cxx:603
python.subdetectors.mmg.names
names
Definition: mmg.py:8
TrigConf::TriggerThresholdValue::etamax
int etamax() const
Definition: TriggerThresholdValue.h:54
TrigConf::Menu::thresholdConfig
const ThresholdConfig & thresholdConfig() const
Definition: Menu.h:73
TrigConf::ClusterThresholdValue::hadVeto
float hadVeto() const
Definition: ClusterThresholdValue.h:23
TrigConf::TrigConfData::version
unsigned int version() const
Definition: TrigConfData.h:24
TrigConf::METSigParam::teSqrtMin
int teSqrtMin() const
Definition: METSigParam.h:34
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1TriggerItem
TriggerItem * createLvl1TriggerItem(const coral::AttributeList &al)
build a LVL1 TriggerItem from a COOL db record
Definition: TrigConfCoolL1PayloadConverters.cxx:398
JetThresholdValue.h
TrigConf::ThresholdConfig::ctpVersion
unsigned int ctpVersion() const
Definition: ThresholdConfig.h:84
TrigConf::TriggerThresholdValue::type
const std::string & type() const
Definition: TriggerThresholdValue.h:44
Record
Definition: HephProf.cxx:56
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1JetWeightPayload
cool::Record createLvl1JetWeightPayload(cool::IFolderPtr, const std::vector< int > &jetweights)
build a COOL db record from a L1 Jet Weights vector
Definition: TrigConfCoolL1PayloadConverters.cxx:76
TrigConf::TriggerThresholdValue::phimin
int phimin() const
Definition: TriggerThresholdValue.h:51
TrigConf::PIT::setThresholdBit
void setThresholdBit(const uint16_t &num)
Definition: PIT.h:33
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1BGKeyPayload
cool::Record createLvl1BGKeyPayload(cool::IFolderPtr, unsigned int lvl1BunchgroupKey)
build a COOL db record from a LVL1 bunch group key
Definition: TrigConfCoolL1PayloadConverters.cxx:212
BunchGroup.h
LArConditions2Ntuple.fld
string fld
Definition: LArConditions2Ntuple.py:283
TrigConf::TriggerItemNode::getAllBunchGroups
void getAllBunchGroups(std::vector< bool > &) const
Definition: TriggerItemNode.cxx:144
TrigConf::BunchGroupSet::bunchGroups
const std::vector< BunchGroup > & bunchGroups() const
Definition: BunchGroupSet.h:27
BunchGroupSet.h
TrigConf::TriggerThresholdValue::etamin
int etamin() const
Definition: TriggerThresholdValue.h:53
NimThresholdValue.h
TrigConf::TIP::setThresholdActive
void setThresholdActive(const bool &a)
Definition: TIP.h:48
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
item
Definition: ItemListSvc.h:43
TrigConf::TriggerThresholdValue::setEtaMin
void setEtaMin(int value)
Definition: TriggerThresholdValue.h:63
TrigConf::PIT::setCtpinSlot
void setCtpinSlot(const uint16_t &id)
Definition: PIT.h:24
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
L1DataDef.h
TrigConf::METSigParam::xeMax
int xeMax() const
Definition: METSigParam.h:33
TrigConf::TriggerThreshold::cableCtpin
const std::string & cableCtpin() const
Definition: TriggerThreshold.h:35
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1BGContentPayload
cool::Record createLvl1BGContentPayload(cool::IFolderPtr fld, const TrigConf::BunchGroupSet &bgs)
build a COOL db record from a bunch group definition value
Definition: TrigConfCoolL1PayloadConverters.cxx:220
TrigConf::TriggerThresholdValue::setPhiMin
void setPhiMin(int value)
Definition: TriggerThresholdValue.h:61
EtThresholdValue.h
TrigConf::METSigParam::xsSigmaOffset
int xsSigmaOffset() const
Definition: METSigParam.h:31
TrigConf::TIP::setSlot
void setSlot(const uint16_t &id)
Definition: TIP.h:24
ClusterThresholdValue.h
PIT.h
TrigConf::TriggerThresholdValue::setPriority
void setPriority(float prio)
Definition: TriggerThresholdValue.h:59
TrigConf::ClusterThresholdValue::setEmIsolation
void setEmIsolation(float v)
Definition: ClusterThresholdValue.h:38
TrigConf::Menu::items
const ItemContainer & items() const
Definition: Menu.h:140
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1MenuPayload
cool::Record createLvl1MenuPayload(cool::IFolderPtr, const TrigConf::TriggerItem &item)
build a COOL db record from a LVL1 TriggerItem (the item name and version)
Definition: TrigConfCoolL1PayloadConverters.cxx:50
TrigConf::TIP::setCableBit
void setCableBit(const uint16_t &num)
Definition: TIP.h:36
TrigConf::TIP::setThresholdBit
void setThresholdBit(const uint16_t &num)
Definition: TIP.h:33
plotBeamSpotMon.mon
mon
Definition: plotBeamSpotMon.py:67
TrigConfCoolFolderSpec.h
TrigConf::PIT::setThresholdActive
void setThresholdActive(const bool &a)
Definition: PIT.h:48
TrigConf::TrigConfCoolL1PayloadConverters::readLvl1MonMap
std::vector< TrigConf::ThresholdMonitor * > readLvl1MonMap(const cool::IRecord &payload)
Build a LVL1 mon counter object from COOL payload.
Definition: TrigConfCoolL1PayloadConverters.cxx:660
TrigConf::TrigConfCoolL1PayloadConverters::createLvl1InputMapPayload
cool::Record createLvl1InputMapPayload(cool::IFolderPtr, const TrigConf::TIP &tip)
build a COOL db record from a PIT-mapping string value
Definition: TrigConfCoolL1PayloadConverters.cxx:351
TrigConf::TriggerThresholdValue::priority
float priority() const
Definition: TriggerThresholdValue.h:46
TrigConf::TIP::slot
uint16_t slot() const
Definition: TIP.h:23
METSigParam.h
TrigConf::TriggerThresholdValue::setEtaMax
void setEtaMax(int value)
Definition: TriggerThresholdValue.h:64
TrigConf::TIP::thresholdName
const std::string & thresholdName() const
Definition: TIP.h:20
TrigConf::TrigConfCoolL1PayloadConverters::readLvl1TIPMap
TrigConf::TIP * readLvl1TIPMap(const coral::AttributeList &al)
Definition: TrigConfCoolL1PayloadConverters.cxx:645
TrigConf::TriggerThreshold
Definition: TriggerThreshold.h:20
TrigConf::TIP::thresholdMapping
int16_t thresholdMapping() const
Definition: TIP.h:44
TrigConf::TriggerThresholdValue::setType
void setType(const std::string &type)
Definition: TriggerThresholdValue.h:57
TrigConf::METSigParam::xsSigmaScale
int xsSigmaScale() const
Definition: METSigParam.h:30
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
TrigConf::TriggerItem
Definition: TriggerItem.h:25
TrigConf::PIT::setCtpinConnector
void setCtpinConnector(const uint16_t &id)
Definition: PIT.h:27
TrigConf::ClusterThresholdValue::emIsolation
float emIsolation() const
Definition: ClusterThresholdValue.h:21
TriggerItemNode.h
TrigConf::TriggerThresholdValue::window
unsigned int window() const
Definition: TriggerThresholdValue.h:49