ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConfCoolL1PayloadConverters.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
41using boost::lexical_cast;
42
43using namespace std;
44using namespace cool;
45using namespace TrigConf;
46
47
48
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
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
76TrigConfCoolL1PayloadConverters::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 += std::to_string(*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
91TrigConfCoolL1PayloadConverters::createLvl1METSigPayload( cool::IFolderPtr fld, const METSigParam& metSigParams ) {
92 Record payload(fld->payloadSpecification());
93 string thrValDef("");
94 thrValDef += std::to_string(metSigParams.xsSigmaScale()) + ",";
95 thrValDef += std::to_string(metSigParams.xsSigmaOffset()) + ",";
96 thrValDef += std::to_string(metSigParams.xeMin()) + ",";
97 thrValDef += std::to_string(metSigParams.xeMax()) + ",";
98 thrValDef += std::to_string(metSigParams.teSqrtMin()) + ",";
99 thrValDef += std::to_string(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
107Record
109 Record payload(fld->payloadSpecification());
110 // TriggerThreshold
111 string thrDef("");
112 thrDef += thr.name(); thrDef += ",";
113 thrDef += std::to_string(thr.version()); thrDef += ",";
114 thrDef += thr.type(); thrDef += ",";
115 thrDef += std::to_string(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 = std::to_string(thrVal->ptcut());
129 string valEtamin = std::to_string(thrVal->etamin());
130 string valEtamax = std::to_string(thrVal->etamax());
131 string valPhimin = std::to_string(thrVal->phimin());
132 string valPhimax = std::to_string(thrVal->phimax());
133 string valWindow = std::to_string(thrVal->window());
134 string valEm_isolation = "63";
135 string valHad_isolation = "63";
136 string valHad_veto = "63";
137 string valPriority = std::to_string(thrVal->priority());
138
139 if ( thr.type()==L1DataDef::typeAsString(L1DataDef::EM) ||
141 ClusterThresholdValue* cluThrVal = dynamic_cast<ClusterThresholdValue*>(thrVal);
142 if(cluThrVal) {
143 valEm_isolation = std::to_string(cluThrVal->emIsolation());
144 valHad_isolation = std::to_string(cluThrVal->hadIsolation());
145 valHad_veto = std::to_string(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 += std::to_string(thr.cableStart()); cableDef += ",";
171 cableDef += std::to_string(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
181Record
182TrigConfCoolL1PayloadConverters::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
189Record
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
200Record
201TrigConfCoolL1PayloadConverters::createLvl1PrescalesPayload( cool::IFolderPtr fld, int64_t prescale) {
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
211Record
212TrigConfCoolL1PayloadConverters::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
219Record
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()) {
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;
257 coral::Blob blob;
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
282Record
283TrigConfCoolL1PayloadConverters::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" + std::to_string(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>();
332 coral::Blob 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// ------------------------------------------------------------
350cool::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// ------------------------------------------------------------
367cool::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
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
406void
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
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(std::stoi(thrDefV[1]));
436 thr->setType(thrDefV[2]);
437 thr->setMapping(std::stoi(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 = std::stoi(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 = std::stof(thrValDefV[2]);
460 int valEtamin = std::stoi(thrValDefV[3]);
461 int valEtamax = std::stoi(thrValDefV[4]);
462 int valPhimin = std::stoi(thrValDefV[5]);
463 int valPhimax = std::stoi(thrValDefV[6]);
464 float valEm_isolation = std::stof(thrValDefV[7]);
465 float valHad_isolation = std::stof(thrValDefV[8]);
466 float valHad_veto = std::stof(thrValDefV[9]);
467 int valWindow = std::stoi(thrValDefV[10]);
468 float valPriority = std::stof(thrValDefV[11]);
469
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 = std::stoi(cableDefV[3]);
499 int cableEnd = std::stoi(cableDefV[4]);
500 thr->setCableName ( cableName );
501 thr->setCableCtpin ( cableCtpin);
502 string ctpin(std::move(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
517vector<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
554pair< 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
594void
596 unsigned int & lvl1PrescaleKey )
597{
598 lvl1PrescaleKey = al["Lvl1PrescaleConfigurationKey"].data<cool::UInt32>();
599}
600
601
602void
603TrigConfCoolL1PayloadConverters::readLvl1Prescale( const coral::AttributeList& al, int & prescaleValue)
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
612void
613TrigConfCoolL1PayloadConverters::readLvl1Prescale( const coral::AttributeList& al, int64_t & prescaleValue)
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
622int
624{
625 return al["Lvl1BunchGroupConfigurationKey"].data<cool::UInt32>();
626}
627
628
629PIT*
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
644TIP*
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
659std::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( static_cast<uint16_t>(std::stoul(slots[i])) );
696 mon->setCtpinConnector( static_cast<uint16_t>(std::stoul(cons[i])) );
697 mon->setThresholdStartBit( std::stoi(starts[i]) );
698 mon->setThresholdEndBit( std::stoi(ends[i]) );
699 mon->setMultiplicity( std::stoi(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
std::vector< size_t > vec
static std::string to_string(const std::vector< T > &v)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t al
const std::vector< BunchGroup > & bunchGroups() const
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
int xsSigmaOffset() const
Definition METSigParam.h:31
int teSqrtMax() const
Definition METSigParam.h:35
int xsSigmaScale() const
Definition METSigParam.h:30
int teSqrtMin() const
Definition METSigParam.h:34
const ThresholdConfig & thresholdConfig() const
Definition Menu.h:73
const ItemContainer & items() const
Definition Menu.h:140
void setCtpinConnector(const uint16_t &id)
Definition PIT.h:27
void setThresholdActive(const bool &a)
Definition PIT.h:48
void setCableBit(const uint16_t &num)
Definition PIT.h:36
void setThresholdBit(const uint16_t &num)
Definition PIT.h:33
void setThresholdName(const std::string &name)
Definition PIT.h:21
void setCtpinSlot(const uint16_t &id)
Definition PIT.h:24
void setThresholdMapping(const int16_t &m)
Definition PIT.h:45
uint16_t connector() const
Definition TIP.h:26
uint16_t slot() const
Definition TIP.h:23
void setThresholdName(const std::string &name)
Definition TIP.h:21
void setThresholdMapping(const int16_t &m)
Definition TIP.h:45
void setConnector(const uint16_t &id)
Definition TIP.h:27
const std::string & thresholdName() const
Definition TIP.h:20
void setThresholdActive(const bool &a)
Definition TIP.h:48
void setSlot(const uint16_t &id)
Definition TIP.h:24
uint16_t thresholdBit() const
Definition TIP.h:32
void setThresholdBit(const uint16_t &num)
Definition TIP.h:33
uint16_t cableBit() const
Definition TIP.h:35
void setCableBit(const uint16_t &num)
Definition TIP.h:36
int16_t thresholdMapping() const
Definition TIP.h:44
bool thresholdActive() const
Definition TIP.h:47
unsigned int ctpVersion() const
void setName(const std::string &name)
const std::string & name() const
void getAllBunchGroups(std::vector< bool > &) const
void setType(const std::string &type)
const std::string & type() const
static TriggerThresholdValue * createThresholdValue(const std::string &type)
std::vector< TrigConf::ThresholdMonitor * > readLvl1MonMap(const cool::IRecord &payload)
Build a LVL1 mon counter object from COOL payload.
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
cool::Record createLvl1METSigPayload(cool::IFolderPtr, const METSigParam &metSigParams)
build a COOL db record from a L1 MET significance global parameters
cool::Record createLvl1ConfigKeyPayload(cool::IFolderPtr, unsigned int lvl1PrescaleKey)
build a COOL db record from a LVL1 configuration key
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
cool::Record createLvl1BGKeyPayload(cool::IFolderPtr, unsigned int lvl1BunchgroupKey)
build a COOL db record from a LVL1 bunch group key
cool::Record createLvl1MenuPayload(cool::IFolderPtr, const TrigConf::TriggerItem &item)
build a COOL db record from a LVL1 TriggerItem (the item name and version)
cool::Record createLvl1PrescalesPayload(cool::IFolderPtr, int prescale)
build a COOL db record from a LVL1 prescale value
TrigConf::PIT * readLvl1InputMap(const coral::AttributeList &al)
Build a LVL1 PIT object from COOL payload.
TrigConf::TIP * readLvl1TIPMap(const coral::AttributeList &al)
void readLvl1Prescale(const coral::AttributeList &al, int &ps)
build the LVL1 prescale value from a coral::AttributeList
cool::Record createLvl1BGDescPayload(cool::IFolderPtr fld, const TrigConf::BunchGroupSet &bgs, const TrigConf::Menu &lvl1Menu)
build a COOL db record from a bunch group description
cool::Record createLvl1BGContentPayload(cool::IFolderPtr fld, const TrigConf::BunchGroupSet &bgs)
build a COOL db record from a bunch group definition value
cool::Record createLvl1ItemDefPayload(cool::IFolderPtr, const TrigConf::TriggerItem &item)
build a COOL db record from a LVL1 TriggerItem (the conditions)
void readLvl1ConfigKey(const coral::AttributeList &al, unsigned int &lvl1PrescaleKey)
build the LVL1 configuration key from a coral::AttributeList
std::vector< TrigConf::BunchGroup > readLvl1BGContent(const coral::AttributeList &al)
build the LVL1 Bunchgroup code
TriggerItem * createLvl1TriggerItem(const coral::AttributeList &al)
build a LVL1 TriggerItem from a COOL db record
cool::Record createLvl1InputMapPayload(cool::IFolderPtr, const TrigConf::TIP &tip)
build a COOL db record from a PIT-mapping string value
cool::Record createLvl1ThresholdPayload(cool::IFolderPtr, const TrigConf::TriggerThreshold &thr)
build a COOL db record from a LVL1 TriggerItem
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
TriggerThreshold * createLvl1Threshold(const coral::AttributeList &al)
build a LVL1 TriggerThreshold from a COOL db record
cool::Record createLvl1JetWeightPayload(cool::IFolderPtr, const std::vector< int > &jetweights)
build a COOL db record from a L1 Jet Weights vector
int readLvl1BGKey(const coral::AttributeList &al)
build the LVL1 Bunchgroup key value
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
std::vector< std::string > split(const std::string &line, const std::string &del=" ")
STL namespace.