ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConf::TrigConfCoolL1PayloadConverters Namespace Reference

Functions

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 createLvl1ItemDefPayload (cool::IFolderPtr, const TrigConf::TriggerItem &item)
 build a COOL db record from a LVL1 TriggerItem (the conditions)
cool::Record createLvl1JetWeightPayload (cool::IFolderPtr, const std::vector< int > &jetweights)
 build a COOL db record from a L1 Jet Weights vector
cool::Record createLvl1METSigPayload (cool::IFolderPtr, const METSigParam &metSigParams)
 build a COOL db record from a L1 MET significance global parameters
cool::Record createLvl1ThresholdPayload (cool::IFolderPtr, const TrigConf::TriggerThreshold &thr)
 build a COOL db record from a LVL1 TriggerItem
cool::Record createLvl1ConfigKeyPayload (cool::IFolderPtr, unsigned int lvl1PrescaleKey)
 build a COOL db record from a LVL1 configuration key
cool::Record createLvl1PrescalesPayload (cool::IFolderPtr, int prescale)
 build a COOL db record from a LVL1 prescale value
cool::Record createLvl1PrescalesPayload (cool::IFolderPtr, int64_t prescale)
cool::Record createLvl1BGKeyPayload (cool::IFolderPtr, unsigned int lvl1BunchgroupKey)
 build a COOL db record from a LVL1 bunch group key
cool::Record createLvl1BGContentPayload (cool::IFolderPtr fld, const TrigConf::BunchGroupSet &bgs)
 build a COOL db record from a bunch group definition value
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 createLvl1InputMapPayload (cool::IFolderPtr, const TrigConf::TIP &tip)
 build a COOL db record from a PIT-mapping string value
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
void readLvl1ConfigKey (const coral::AttributeList &al, unsigned int &lvl1PrescaleKey)
 build the LVL1 configuration key from a coral::AttributeList
void readLvl1Prescale (const coral::AttributeList &al, int &ps)
 build the LVL1 prescale value from a coral::AttributeList
void readLvl1Prescale (const coral::AttributeList &al, int64_t &ps)
int readLvl1BGKey (const coral::AttributeList &al)
 build the LVL1 Bunchgroup key value
TrigConf::PITreadLvl1InputMap (const coral::AttributeList &al)
 Build a LVL1 PIT object from COOL payload.
TrigConf::TIPreadLvl1TIPMap (const coral::AttributeList &al)
std::vector< TrigConf::ThresholdMonitor * > readLvl1MonMap (const cool::IRecord &payload)
 Build a LVL1 mon counter object from COOL payload.
std::vector< TrigConf::BunchGroupreadLvl1BGContent (const coral::AttributeList &al)
 build the LVL1 Bunchgroup code
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
TriggerItemcreateLvl1TriggerItem (const coral::AttributeList &al)
 build a LVL1 TriggerItem from a COOL db record
TriggerThresholdcreateLvl1Threshold (const coral::AttributeList &al)
 build a LVL1 TriggerThreshold from a COOL db record
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

Function Documentation

◆ addThresholdsToTriggerItem()

void TrigConf::TrigConfCoolL1PayloadConverters::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

Parameters
payloadCOOL db record
Returns
the LVL1 trigger item

Definition at line 407 of file TrigConfCoolL1PayloadConverters.cxx.

408 {
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}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t al
std::vector< std::string > split(const std::string &line, const std::string &del=" ")

◆ createLvl1BGContentPayload()

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1BGContentPayload ( cool::IFolderPtr fld,
const TrigConf::BunchGroupSet & bgs )

build a COOL db record from a bunch group definition value

Parameters
bunchgroupthe bunchgroup object
Returns
a COOL db record

Definition at line 220 of file TrigConfCoolL1PayloadConverters.cxx.

220 {
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}
static std::string to_string(const std::vector< T > &v)
const std::vector< BunchGroup > & bunchGroups() const
dict codes
helper to get a human-readable string
Definition ExitCodes.py:49

◆ createLvl1BGDescPayload()

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1BGDescPayload ( cool::IFolderPtr fld,
const TrigConf::BunchGroupSet & bgs,
const TrigConf::Menu & lvl1Menu )

build a COOL db record from a bunch group description

Parameters
bunch_descstring describing a bunch group
Returns
a COOL db record

Definition at line 283 of file TrigConfCoolL1PayloadConverters.cxx.

283 {
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}
const ThresholdConfig & thresholdConfig() const
Definition Menu.h:73
const ItemContainer & items() const
Definition Menu.h:140
unsigned int ctpVersion() const
void getAllBunchGroups(std::vector< bool > &) const

◆ createLvl1BGKeyPayload()

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1BGKeyPayload ( cool::IFolderPtr fld,
unsigned int lvl1BunchgroupKey )

build a COOL db record from a LVL1 bunch group key

Parameters
lvl1BunchgroupKeythe bunch group key
Returns
a COOL db record

Definition at line 212 of file TrigConfCoolL1PayloadConverters.cxx.

212 {
213 Record payload(fld->payloadSpecification());
214 payload["Lvl1BunchGroupConfigurationKey"].setValue<cool::UInt32>(lvl1BunchgroupKey);
215 return payload;
216}

◆ createLvl1ConfigKeyPayload()

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1ConfigKeyPayload ( cool::IFolderPtr fld,
unsigned int lvl1PrescaleKey )

build a COOL db record from a LVL1 configuration key

Definition at line 182 of file TrigConfCoolL1PayloadConverters.cxx.

182 {
183 Record payload(fld->payloadSpecification());
184 payload["Lvl1PrescaleConfigurationKey"].setValue<cool::UInt32>(lvl1PrescaleKey);
185 return payload;
186}

◆ createLvl1InputMapPayload()

cool::Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1InputMapPayload ( cool::IFolderPtr fld,
const TrigConf::TIP & tip )

build a COOL db record from a PIT-mapping string value

Definition at line 351 of file TrigConfCoolL1PayloadConverters.cxx.

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}
uint16_t connector() const
Definition TIP.h:26
uint16_t slot() const
Definition TIP.h:23
const std::string & thresholdName() const
Definition TIP.h:20
uint16_t thresholdBit() const
Definition TIP.h:32
uint16_t cableBit() const
Definition TIP.h:35
int16_t thresholdMapping() const
Definition TIP.h:44
bool thresholdActive() const
Definition TIP.h:47

◆ createLvl1ItemDefPayload()

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1ItemDefPayload ( cool::IFolderPtr fld,
const TrigConf::TriggerItem & item )

build a COOL db record from a LVL1 TriggerItem (the conditions)

Definition at line 59 of file TrigConfCoolL1PayloadConverters.cxx.

59 {
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}

◆ createLvl1JetWeightPayload()

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1JetWeightPayload ( cool::IFolderPtr fld,
const std::vector< int > & jetweights )

build a COOL db record from a L1 Jet Weights vector

Definition at line 76 of file TrigConfCoolL1PayloadConverters.cxx.

76 {
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}

◆ createLvl1MenuPayload()

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1MenuPayload ( cool::IFolderPtr fld,
const TrigConf::TriggerItem & item )

build a COOL db record from a LVL1 TriggerItem (the item name and version)

Definition at line 50 of file TrigConfCoolL1PayloadConverters.cxx.

50 {
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}

◆ createLvl1METSigPayload()

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1METSigPayload ( cool::IFolderPtr fld,
const METSigParam & metSigParams )

build a COOL db record from a L1 MET significance global parameters

Definition at line 91 of file TrigConfCoolL1PayloadConverters.cxx.

91 {
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}
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

◆ createLvl1MonMapPayload()

cool::Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1MonMapPayload ( cool::IFolderPtr fld,
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

Parameters
monMonitoring counter object
threshNameString with concatenated threshold names
slotString with concatenated CTPIN slots
conString with concatenated CTPIN connectors
multString with concatenated multiplicities
startString with start bits
endString with end bits
activeString with active flags
Returns
a COOL db record

Definition at line 368 of file TrigConfCoolL1PayloadConverters.cxx.

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}

◆ createLvl1PrescalesPayload() [1/2]

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1PrescalesPayload ( cool::IFolderPtr fld,
int prescale )

build a COOL db record from a LVL1 prescale value

Note that the prescale values are inserted in the same order as the trigger items, the matching between them depends on their position in the list (COOL channel ID)

Definition at line 190 of file TrigConfCoolL1PayloadConverters.cxx.

190 {
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}

◆ createLvl1PrescalesPayload() [2/2]

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1PrescalesPayload ( cool::IFolderPtr fld,
int64_t prescale )

Definition at line 201 of file TrigConfCoolL1PayloadConverters.cxx.

201 {
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}

◆ createLvl1Threshold()

TriggerThreshold * TrigConf::TrigConfCoolL1PayloadConverters::createLvl1Threshold ( const coral::AttributeList & al)

build a LVL1 TriggerThreshold from a COOL db record

Definition at line 417 of file TrigConfCoolL1PayloadConverters.cxx.

417 {
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}
void setName(const std::string &name)
void setType(const std::string &type)
static TriggerThresholdValue * createThresholdValue(const std::string &type)

◆ createLvl1ThresholdPayload()

Record TrigConf::TrigConfCoolL1PayloadConverters::createLvl1ThresholdPayload ( cool::IFolderPtr fld,
const TrigConf::TriggerThreshold & thr )

build a COOL db record from a LVL1 TriggerItem

Definition at line 108 of file TrigConfCoolL1PayloadConverters.cxx.

108 {
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}
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
const std::string & name() const
const std::string & type() const

◆ createLvl1TriggerItem()

TriggerItem * TrigConf::TrigConfCoolL1PayloadConverters::createLvl1TriggerItem ( const coral::AttributeList & al)

build a LVL1 TriggerItem from a COOL db record

Definition at line 398 of file TrigConfCoolL1PayloadConverters.cxx.

398 {
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}

◆ readLvl1BGContent()

vector< BunchGroup > TrigConf::TrigConfCoolL1PayloadConverters::readLvl1BGContent ( const coral::AttributeList & al)

build the LVL1 Bunchgroup code

Definition at line 518 of file TrigConfCoolL1PayloadConverters.cxx.

518 {
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}

◆ readLvl1BGDesc()

pair< vector< string >, map< unsigned int, unsigned char > > TrigConf::TrigConfCoolL1PayloadConverters::readLvl1BGDesc ( const coral::AttributeList & al)

build the LVL1 Bunchgroup descriptions from a coral::AttributeList

Parameters
althe AttributeList
Returns
a pair, first element is a vector of 8 bunch group names, second is a map; the key is the ctpid of the item, the value the 8-bit mask indicating which bunch group is used in AND in the item definition

Definition at line 555 of file TrigConfCoolL1PayloadConverters.cxx.

555 {
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}

◆ readLvl1BGKey()

int TrigConf::TrigConfCoolL1PayloadConverters::readLvl1BGKey ( const coral::AttributeList & al)

build the LVL1 Bunchgroup key value

Definition at line 623 of file TrigConfCoolL1PayloadConverters.cxx.

624{
625 return al["Lvl1BunchGroupConfigurationKey"].data<cool::UInt32>();
626}

◆ readLvl1ConfigKey()

void TrigConf::TrigConfCoolL1PayloadConverters::readLvl1ConfigKey ( const coral::AttributeList & al,
unsigned int & lvl1PrescaleKey )

build the LVL1 configuration key from a coral::AttributeList

Definition at line 595 of file TrigConfCoolL1PayloadConverters.cxx.

597{
598 lvl1PrescaleKey = al["Lvl1PrescaleConfigurationKey"].data<cool::UInt32>();
599}

◆ readLvl1InputMap()

PIT * TrigConf::TrigConfCoolL1PayloadConverters::readLvl1InputMap ( const coral::AttributeList & al)

Build a LVL1 PIT object from COOL payload.

Definition at line 630 of file TrigConfCoolL1PayloadConverters.cxx.

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}
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

◆ readLvl1MonMap()

std::vector< TrigConf::ThresholdMonitor * > TrigConf::TrigConfCoolL1PayloadConverters::readLvl1MonMap ( const cool::IRecord & payload)

Build a LVL1 mon counter object from COOL payload.

Definition at line 660 of file TrigConfCoolL1PayloadConverters.cxx.

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}
std::vector< size_t > vec

◆ readLvl1Prescale() [1/2]

void TrigConf::TrigConfCoolL1PayloadConverters::readLvl1Prescale ( const coral::AttributeList & al,
int & ps )

build the LVL1 prescale value from a coral::AttributeList

Definition at line 603 of file TrigConfCoolL1PayloadConverters.cxx.

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}

◆ readLvl1Prescale() [2/2]

void TrigConf::TrigConfCoolL1PayloadConverters::readLvl1Prescale ( const coral::AttributeList & al,
int64_t & ps )

Definition at line 613 of file TrigConfCoolL1PayloadConverters.cxx.

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}

◆ readLvl1TIPMap()

TIP * TrigConf::TrigConfCoolL1PayloadConverters::readLvl1TIPMap ( const coral::AttributeList & al)

Definition at line 645 of file TrigConfCoolL1PayloadConverters.cxx.

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}
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
void setThresholdActive(const bool &a)
Definition TIP.h:48
void setSlot(const uint16_t &id)
Definition TIP.h:24
void setThresholdBit(const uint16_t &num)
Definition TIP.h:33
void setCableBit(const uint16_t &num)
Definition TIP.h:36