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::PIT * readLvl1InputMap (const coral::AttributeList &al)
 Build a LVL1 PIT object from COOL payload.
TrigConf::TIP * readLvl1TIPMap (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::BunchGroup > readLvl1BGContent (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
TriggerItem * createLvl1TriggerItem (const coral::AttributeList &al)
 build a LVL1 TriggerItem from a COOL db record
TriggerThreshold * createLvl1Threshold (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 402 of file TrigConfCoolL1PayloadConverters.cxx.

403 {
404 string logic = al["Logic"].data<cool::String255>();
405 vector<string> condList = split(al["ConditionsList"].data<cool::String4k>(), ";");
406
407 item->setCondition(logic, condList, thrs);
408}
static Double_t al
void setCondition(const std::string &logic, const std::vector< std::string > &conditions, const std::vector< TrigConf::TriggerThreshold * > &thrs)
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 215 of file TrigConfCoolL1PayloadConverters.cxx.

215 {
216
217 Record payload(fld->payloadSpecification());
218
219 // the output vector
220 vector<unsigned char> codes(2 * TrigConfCoolFolderSpec::mBGContentBlobSize, 0 );
221
222 std::vector<const BunchGroup*> bgOrdered(16,(const BunchGroup*)0);
223
224 for(const BunchGroup & bgp: bgs.bunchGroups())
225 bgOrdered.at(bgp.internalNumber()) = &bgp;
226
227
228
229
230 for(int bgC=0; bgC<16; ++bgC) {
231 const BunchGroup* bg = bgOrdered[bgC];
232 if(bg==0) continue;
233
234 // mask describes the current bunchgroup (BG1: 1, BG2: 2, BG3: 4, ..., BG8: 128)
235
236 unsigned char mask = (1 << (bgC % 8) );
237 unsigned int bgOffset = bgC < 8 ? 0 : TrigConfCoolFolderSpec::mBGContentBlobSize; // for BG 8-15 we use the higher part of the blob
238
239 for(int b : bg->bunches()) {
241 // this is a serious error which can't be ignored
242 std::string errorMsg =
243 "Bunch group " + to_string(bgC) + " contains bunch number "
244 + to_string(b) + " which is outside the range [0,3563]";
245 throw std::runtime_error(errorMsg);
246 }
247 codes[static_cast<unsigned int>(b) + bgOffset] |= mask;
248 }
249 }
250
251 std::cout << "LVL1 bunchgroups [list 16 bunches per line]:" << std::endl;
252 coral::Blob blob;
253
254 blob.resize( codes.size() );
255
256 unsigned char* p = static_cast<unsigned char*>(blob.startingAddress());
257
258 for (size_t i=0; i < codes.size() ; ++i,++p) {
259 *p = codes[i];
260
261 cout << string(std::bitset<8>(codes[i]).to_string<char,std::char_traits<char>,std::allocator<char> >());
262 if((i+1)%16==0) cout << endl;
263 else cout << " ";
264 }
265 cout << endl;
266
267 payload["BunchCode"].setValue<coral::Blob>( blob );
268
269
270 return payload;
271}
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 278 of file TrigConfCoolL1PayloadConverters.cxx.

278 {
279
280 CTPdataformatVersion ctpDataformat(lvl1Menu.thresholdConfig().ctpVersion());
281
282 Record payload(fld->payloadSpecification());
283
284
285 for(const BunchGroup& bunchgroup: bgs.bunchGroups()) {
286
287 unsigned int internalNumber = bunchgroup.internalNumber();
288
289 const string bgname = bunchgroup.name();
290
291 std::string payloadKey = "BunchGroup" + std::to_string(internalNumber);
292
293 if(payload.specification().exists(payloadKey)) {
294 std::cout << "Write bunch group " << payloadKey << ": '"<< bgname <<"'" << std::endl;
295 payload[payloadKey].setValue<cool::String255>( bgname );
296 } else {
297 std::cout << "WARNING: COOL DB schema has not yet made fields for bunchgroup " << internalNumber << " (" << bgname << ")" << endl;
298 }
299 }
300
301 cout << "Writing bunch group description with size " << ctpDataformat.getMaxTrigItems() << endl;
302
303 vector<unsigned char> codes( ctpDataformat.getMaxTrigItems() ,0);
304 for(TriggerItem* item: lvl1Menu.items() ) {
305
306 unsigned int ctpid = item->ctpId();
307 if(ctpid >= codes.size())
308 throw runtime_error("Item ctpid exceeds blob size!");
309 const TriggerItemNode* topNode = item->topNode();
310 if(topNode==0)
311 throw runtime_error("Item " + item->name() + " has no definition nodes attached");
312 vector<bool> v1;
313 // get a vector of size 8, element true means the bunch group is
314 // in the item definition - assumes AND logic only!
315 topNode->getAllBunchGroups(v1);
316 for(size_t i = 0; i<v1.size();++i) {
317 if(v1[i]) codes[ctpid] |= (1<<i);
318 }
319
320 cout << "Item " << setw(3) << setfill(' ') << ctpid << " bunch-group code "
321 << string(bitset<8>(codes[ctpid]).to_string<char,char_traits<char>,allocator<char> >())
322 << endl;
323 }
324
325 // Get the blob, resize it to actual size, and push codes into it
326 // coral::Blob& blob = payload["ItemToBunchGroupMap"].data<coral::Blob>();
327 coral::Blob blob;
328 blob.resize( codes.size() );
329 unsigned char* p = static_cast<unsigned char*>(blob.startingAddress());
330 for (size_t i=0; i < codes.size(); ++i,++p) {
331 *p = codes[i];
332 }
333
334 payload["ItemToBunchGroupMap"].setValue<coral::Blob>( blob );
335
336 return payload;
337}
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
End of vector before end of string
Definition Arrayrep.cxx:228

◆ 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 207 of file TrigConfCoolL1PayloadConverters.cxx.

207 {
208 Record payload(fld->payloadSpecification());
209 payload["Lvl1BunchGroupConfigurationKey"].setValue<cool::UInt32>(lvl1BunchgroupKey);
210 return payload;
211}

◆ createLvl1ConfigKeyPayload()

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

build a COOL db record from a LVL1 configuration key

Definition at line 177 of file TrigConfCoolL1PayloadConverters.cxx.

177 {
178 Record payload(fld->payloadSpecification());
179 payload["Lvl1PrescaleConfigurationKey"].setValue<cool::UInt32>(lvl1PrescaleKey);
180 return payload;
181}

◆ 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 346 of file TrigConfCoolL1PayloadConverters.cxx.

347{
348 Record payload(fld->payloadSpecification());
349 payload["ThresholdName"].setValue<cool::String255>(tip.thresholdName());
350 payload["CtpinSlot"].setValue<cool::UChar>(static_cast<unsigned char>(tip.slot()));
351 payload["CtpinConnector"].setValue<cool::UChar>(static_cast<unsigned char>(tip.connector()));
352 payload["ThresholdBit"].setValue<cool::UChar>(static_cast<unsigned char>(tip.thresholdBit()));
353 payload["CableBit"].setValue<cool::UChar>(static_cast<unsigned char>(tip.cableBit()));
354 payload["ThresholdMapping"].setValue<cool::UChar>(static_cast<unsigned char>(tip.thresholdMapping()));
355 payload["ThresholdActive"].setValue<cool::Bool>(tip.thresholdActive());
356 return payload;
357}
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 54 of file TrigConfCoolL1PayloadConverters.cxx.

54 {
55 Record payload(fld->payloadSpecification());
56 vector<string> thresholdlist;
57 string logic, conditions;
58 item.buildLogic(logic, thresholdlist);
59 vector<string>::iterator thrIt = thresholdlist.begin();
60 for(;thrIt!=thresholdlist.end();++thrIt) {
61 if(thrIt!=thresholdlist.begin()) conditions += ";";
62 conditions += *thrIt;
63 }
64 payload["Logic"].setValue<cool::String255>(logic);
65 payload["ConditionsList"].setValue<cool::String4k>(conditions);
66 return payload;
67}
void buildLogic(std::string &logic, std::vector< std::string > &conditionList) const

◆ 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 71 of file TrigConfCoolL1PayloadConverters.cxx.

71 {
72 Record payload(fld->payloadSpecification());
73 std::string thrValDef("");
74 for(std::vector<int>::const_iterator wIt = jetweights.begin(); wIt!=jetweights.end(); ++wIt) {
75 if(wIt != jetweights.begin()) thrValDef += ",";
76 thrValDef += std::to_string(*wIt);
77 }
78 payload["Threshold"].setValue<cool::String255>("JetWeights");
79 payload["ThresholdValue"].setValue<cool::String4k>(thrValDef);
80 payload["Cable"].setValue<cool::String255>("");
81 return payload;
82}

◆ 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 45 of file TrigConfCoolL1PayloadConverters.cxx.

45 {
46 Record payload(fld->payloadSpecification());
47 payload["ItemName"].setValue<cool::String255>(item.name());
48 payload["ItemVersion"].setValue<cool::UInt32>(item.version());
49 return payload;
50}
const std::string & name() const
unsigned int version() const

◆ 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 86 of file TrigConfCoolL1PayloadConverters.cxx.

86 {
87 Record payload(fld->payloadSpecification());
88 string thrValDef("");
89 thrValDef += std::to_string(metSigParams.xsSigmaScale()) + ",";
90 thrValDef += std::to_string(metSigParams.xsSigmaOffset()) + ",";
91 thrValDef += std::to_string(metSigParams.xeMin()) + ",";
92 thrValDef += std::to_string(metSigParams.xeMax()) + ",";
93 thrValDef += std::to_string(metSigParams.teSqrtMin()) + ",";
94 thrValDef += std::to_string(metSigParams.teSqrtMax());
95 payload["Threshold"].setValue<cool::String255>("METSigParams");
96 payload["ThresholdValue"].setValue<cool::String4k>(thrValDef);
97 payload["Cable"].setValue<cool::String255>("");
98 return payload;
99}
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 363 of file TrigConfCoolL1PayloadConverters.cxx.

375{
376 Record payload(fld->payloadSpecification());
377 payload["CounterType"].setValue<cool::String255>(type);
378 payload["BunchGroupId"].setValue<cool::UChar>(static_cast<unsigned char>(bgId));
379 payload["ThresholdName"].setValue<cool::String255>(threshName);
380 payload["CtpinSlot"].setValue<cool::String255>(slot);
381 payload["CtpinConnector"].setValue<cool::String255>(con);
382 payload["Multiplicity"].setValue<cool::String255>(mult);
383 payload["ThresholdBitStart"].setValue<cool::String255>(start);
384 payload["ThresholdBitEnd"].setValue<cool::String255>(end);
385 payload["ThresholdActive"].setValue<cool::String255>(active);
386 payload["CounterName"].setValue<cool::String255>(monName);
387 payload["CounterLogic"].setValue<cool::String255>(CounterLogic);
388 return payload;
389}

◆ 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 185 of file TrigConfCoolL1PayloadConverters.cxx.

185 {
186 Record payload(fld->payloadSpecification());
187 if(payload["Lvl1Prescale"].storageType()==cool::StorageType::Int32)
188 payload["Lvl1Prescale"].setValue<cool::Int32>(prescale);
189 else
190 payload["Lvl1Prescale"].setValue<cool::Int64>(prescale);
191 return payload;
192}

◆ createLvl1PrescalesPayload() [2/2]

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

Definition at line 196 of file TrigConfCoolL1PayloadConverters.cxx.

196 {
197 Record payload(fld->payloadSpecification());
198 if(payload["Lvl1Prescale"].storageType()==cool::StorageType::Int32)
199 payload["Lvl1Prescale"].setValue<cool::Int32>(prescale);
200 else
201 payload["Lvl1Prescale"].setValue<cool::Int64>(prescale);
202 return payload;
203}

◆ createLvl1Threshold()

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

build a LVL1 TriggerThreshold from a COOL db record

Definition at line 412 of file TrigConfCoolL1PayloadConverters.cxx.

412 {
413 string thrDef = al["Threshold"].data<cool::String255>();
414 string thrValDef = al["ThresholdValue"].data<cool::String4k>();
415 string cableDef = al["Cable"].data<cool::String255>();
416
417 // TriggerThreshold
419 vector<string> thrDefV = split(thrDef,",");
420 thr->setName(thrDefV[0]);
421
422 // there was a late request for adding the JetWeights to COOL since
423 // we don't want to add new folders to the schema, we added the
424 // twelve jetweights as a special Threshold to the COOL/Threshold folder
425 if(thr->name()=="JetWeights" || thr->name()=="METSigParams") {
426 thr->setCableName(thrValDef);
427 return thr;
428 }
429
430 thr->setVersion(std::stoi(thrDefV[1]));
431 thr->setType(thrDefV[2]);
432 thr->setMapping(std::stoi(thrDefV[3]));
433 thr->setActive(thrDefV[4] == "1" || thrDefV[4] == "true");
434
435 // internal triggers have no mapping (and are usually not stored in COOL, except by the online L1)
436 // in order to insert them in the threshold vector at the right position they get a mapping according to their name
437 // BGRP0,BGRP1,BGRP2,BGRP3,BGRP4...
438 // RNDM0,RNDM1,RNDM2,...
439 // PCLK0,...
440 if(thr->isInternal()) {
441 string::size_type pos = thr->name().find_first_of("0123456789");
442 int mapping = std::stoi(thr->name().substr(pos));
443 thr->setMapping( mapping );
444 }
445
446 // TriggerThresholdValues
447 vector<string> thrAllValDefV = split(thrValDef,";");
448 for(const string& thrAllVal: thrAllValDefV) {
449 if(thrAllVal=="") continue;
450 vector<string> thrValDefV = split(thrAllVal,",");
451
452 string valName = thrValDefV[0];
453 string valType = thrValDefV[1];
454 float valThresholdval = std::stof(thrValDefV[2]);
455 int valEtamin = std::stoi(thrValDefV[3]);
456 int valEtamax = std::stoi(thrValDefV[4]);
457 int valPhimin = std::stoi(thrValDefV[5]);
458 int valPhimax = std::stoi(thrValDefV[6]);
459 float valEm_isolation = std::stof(thrValDefV[7]);
460 float valHad_isolation = std::stof(thrValDefV[8]);
461 float valHad_veto = std::stof(thrValDefV[9]);
462 int valWindow = std::stoi(thrValDefV[10]);
463 float valPriority = std::stof(thrValDefV[11]);
464
466 if(thrv) {
467 thrv->setName(valName);
468 thrv->setType(valType);
469 thrv->setName(valName);
470 thrv->setType(valType);
471 thrv->setPtcut(valThresholdval);
472 thrv->setPriority(valPriority);
473 thrv->setEtaMin(valEtamin);
474 thrv->setEtaMax(valEtamax);
475 thrv->setPhiMin(valPhimin);
476 thrv->setPhiMax(valPhimax);
477 thrv->setWindow(valWindow);
478 ClusterThresholdValue* cluthrval = dynamic_cast<ClusterThresholdValue*>(thrv);
479 if(cluthrval) {
480 cluthrval->setEmIsolation(valEm_isolation);
481 cluthrval->setHadIsolation(valHad_isolation);
482 cluthrval->setHadVeto(valHad_veto);
483 }
484 }
485 thr->addThresholdValue(thrv);
486 }
487
488 // add the cable information
489 vector<string> cableDefV = split(cableDef,",");
490 string cableName = cableDefV[0];
491 string cableCtpin = cableDefV[1];
492 string cableConnector = cableDefV[2];
493 int cableStart = std::stoi(cableDefV[3]);
494 int cableEnd = std::stoi(cableDefV[4]);
495 thr->setCableName ( cableName );
496 thr->setCableCtpin ( cableCtpin);
497 string ctpin(std::move(cableCtpin));
498 std::transform(ctpin.begin(), ctpin.end(), ctpin.begin(), ::tolower);
499 if( ctpin == "ctpcore" ) {
500 thr->setInput( "ctpcore" );
501 } else {
502 thr->setInput( "ctpin" );
503 }
504 thr->setCableConnector( cableConnector);
505 thr->setCableStart ( cableStart );
506 thr->setCableEnd ( cableEnd );
507
508 return thr;
509}
void tolower(std::string &s)
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 103 of file TrigConfCoolL1PayloadConverters.cxx.

103 {
104 Record payload(fld->payloadSpecification());
105 // TriggerThreshold
106 string thrDef("");
107 thrDef += thr.name(); thrDef += ",";
108 thrDef += std::to_string(thr.version()); thrDef += ",";
109 thrDef += thr.type(); thrDef += ",";
110 thrDef += std::to_string(thr.mapping()); thrDef += ",";
111 thrDef += std::to_string(thr.active());
112
113
114 // TriggerThresholdValue
115 string thrValDef("");
116 vector<TriggerThresholdValue*>::const_iterator thrValIt = thr.thresholdValueVector().begin();
117 vector<TriggerThresholdValue*>::const_iterator thrValEnd = thr.thresholdValueVector().end();
118 for(;thrValIt!=thrValEnd;++thrValIt) {
119 TriggerThresholdValue* thrVal = *thrValIt;
120
121 string valName = thrVal->name();
122 string valType = thrVal->type();
123 string valThresholdval = std::to_string(thrVal->ptcut());
124 string valEtamin = std::to_string(thrVal->etamin());
125 string valEtamax = std::to_string(thrVal->etamax());
126 string valPhimin = std::to_string(thrVal->phimin());
127 string valPhimax = std::to_string(thrVal->phimax());
128 string valWindow = std::to_string(thrVal->window());
129 string valEm_isolation = "63";
130 string valHad_isolation = "63";
131 string valHad_veto = "63";
132 string valPriority = std::to_string(thrVal->priority());
133
134 if ( thr.type()==L1DataDef::typeAsString(L1DataDef::EM) ||
136 ClusterThresholdValue* cluThrVal = dynamic_cast<ClusterThresholdValue*>(thrVal);
137 if(cluThrVal) {
138 valEm_isolation = std::to_string(cluThrVal->emIsolation());
139 valHad_isolation = std::to_string(cluThrVal->hadIsolation());
140 valHad_veto = std::to_string(cluThrVal->hadVeto());
141 }
142 } // for the other types nothing needs to be done
143
144 if(thrValIt!=thr.thresholdValueVector().begin()) thrValDef += ";"; // separation between TTV's
145 thrValDef += valName; thrValDef += ",";
146 thrValDef += valType; thrValDef += ",";
147 thrValDef += valThresholdval; thrValDef += ",";
148 thrValDef += valEtamin; thrValDef += ",";
149 thrValDef += valEtamax; thrValDef += ",";
150 thrValDef += valPhimin; thrValDef += ",";
151 thrValDef += valPhimax; thrValDef += ",";
152 thrValDef += valEm_isolation; thrValDef += ",";
153 thrValDef += valHad_isolation; thrValDef += ",";
154 thrValDef += valHad_veto; thrValDef += ",";
155 thrValDef += valWindow; thrValDef += ",";
156 thrValDef += valPriority;
157 }
158
159
160 // Cable info
161 std::string cableDef("");
162 cableDef += thr.cableName(); cableDef += ",";
163 cableDef += thr.cableCtpin(); cableDef += ",";
164 cableDef += thr.cableConnector(); cableDef += ",";
165 cableDef += std::to_string(thr.cableStart()); cableDef += ",";
166 cableDef += std::to_string(thr.cableEnd());
167
168 // fill the payload
169 payload["Threshold"].setValue<cool::String255>(thrDef);
170 payload["ThresholdValue"].setValue<cool::String4k>(thrValDef);
171 payload["Cable"].setValue<cool::String255>(cableDef);
172 return payload;
173}
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
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 393 of file TrigConfCoolL1PayloadConverters.cxx.

393 {
394 TriggerItem * item = new TriggerItem();
395 item->setName ( al["ItemName"]. data<cool::String255>() );
396 item->setVersion( al["ItemVersion"].data<cool::UInt32>() );
397 return item;
398}
void setVersion(unsigned int version)

◆ readLvl1BGContent()

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

build the LVL1 Bunchgroup code

Definition at line 513 of file TrigConfCoolL1PayloadConverters.cxx.

513 {
514 const coral::Blob& blob = al["BunchCode"].data<coral::Blob>();
515
516 // check blob size - if we ever change the blob size, we have to work with schema versions here
517 if(blob.size() != 3564 && blob.size() != 2 * 3564)
518 throw runtime_error("Read BLOB for BunchCode of unexpected size!");
519
520
521 unsigned int numberBG = (blob.size() == 3564) ? 8 : 16;
522
523 vector<BunchGroup> bgV(numberBG);
524 unsigned int bgIdx(0);
525 for(BunchGroup & bg : bgV) {
526 bg.setInternalNumber(bgIdx++);
527 }
528
529 const unsigned char* p = static_cast<const unsigned char*>(blob.startingAddress());
530
531 for (size_t bunch = 0; bunch < 3564; ++bunch, ++p) {
532 unsigned char mask = *p;
533 for(int i=0; i<8;i++) {
534 if( (mask>>i) & 0x1) bgV[i].addBunch(bunch);
535 }
536 }
537
538 if(blob.size() == 2 * 3564) { // Run 2 with have 8 more BG
539 for (size_t bunch = 0; bunch < 3564; ++bunch, ++p) {
540 unsigned char mask = *p;
541 for(int i=0; i<8;i++)
542 if( (mask>>i) & 0x1) bgV[8+i].addBunch(bunch);
543 }
544 }
545 return bgV;
546}

◆ 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 550 of file TrigConfCoolL1PayloadConverters.cxx.

550 {
551 vector<string> names;
552 names.push_back(al["BunchGroup0"].data<cool::String255>());
553 names.push_back(al["BunchGroup1"].data<cool::String255>());
554 names.push_back(al["BunchGroup2"].data<cool::String255>());
555 names.push_back(al["BunchGroup3"].data<cool::String255>());
556 names.push_back(al["BunchGroup4"].data<cool::String255>());
557 names.push_back(al["BunchGroup5"].data<cool::String255>());
558 names.push_back(al["BunchGroup6"].data<cool::String255>());
559 names.push_back(al["BunchGroup7"].data<cool::String255>());
560 try {
561 names.push_back(al["BunchGroup8"].data<cool::String255>());
562 names.push_back(al["BunchGroup9"].data<cool::String255>());
563 names.push_back(al["BunchGroup10"].data<cool::String255>());
564 names.push_back(al["BunchGroup11"].data<cool::String255>());
565 names.push_back(al["BunchGroup12"].data<cool::String255>());
566 names.push_back(al["BunchGroup13"].data<cool::String255>());
567 names.push_back(al["BunchGroup14"].data<cool::String255>());
568 names.push_back(al["BunchGroup15"].data<cool::String255>());
569 }
570 catch(const coral::AttributeListException &) {} // run2
571
572 std::map<unsigned int,unsigned char> codes;
573 const coral::Blob& blob = al["ItemToBunchGroupMap"].data<coral::Blob>();
574 // check blob size - if we ever change the blob size, have to work
575 // with schema versions here
576
577 if(blob.size() != 256 && blob.size() != 512)
578 throw runtime_error("Read BLOB for ItemToBunchGroupMap of unexpected size!");
579
580 const unsigned char* p = static_cast<const unsigned char*>(blob.startingAddress());
581 for (long i = 0; i < blob.size(); ++i,++p) {
582 unsigned char mask = (*p);
583 codes.insert( make_pair(i,mask) );
584 }
585 return make_pair(names,codes);
586}

◆ readLvl1BGKey()

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

build the LVL1 Bunchgroup key value

Definition at line 618 of file TrigConfCoolL1PayloadConverters.cxx.

619{
620 return al["Lvl1BunchGroupConfigurationKey"].data<cool::UInt32>();
621}

◆ readLvl1ConfigKey()

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

build the LVL1 configuration key from a coral::AttributeList

Definition at line 590 of file TrigConfCoolL1PayloadConverters.cxx.

592{
593 lvl1PrescaleKey = al["Lvl1PrescaleConfigurationKey"].data<cool::UInt32>();
594}

◆ readLvl1InputMap()

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

Build a LVL1 PIT object from COOL payload.

Definition at line 625 of file TrigConfCoolL1PayloadConverters.cxx.

626{
627 TrigConf::PIT* pit = new TrigConf::PIT();
628 pit->setThresholdName( al["ThresholdName"].data<cool::String255>() );
629 pit->setCtpinSlot( static_cast<uint16_t>(al["CtpinSlot"].data<cool::UChar>()) );
630 pit->setCtpinConnector( static_cast<uint16_t>(al["CtpinConnector"].data<cool::UChar>()) );
631 pit->setThresholdBit( static_cast<uint16_t>(al["ThresholdBit"].data<cool::UChar>()) );
632 pit->setCableBit( static_cast<uint16_t>(al["CableBit"].data<cool::UChar>()) );
633 pit->setThresholdMapping( static_cast<uint16_t>(al["ThresholdMapping"].data<cool::UChar>()) );
634 pit->setThresholdActive( al["ThresholdActive"].data<cool::Bool>() );
635
636 return pit;
637}
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 655 of file TrigConfCoolL1PayloadConverters.cxx.

656{
657 vector<ThresholdMonitor*> vec;
658 vector<string> names = split(payload["ThresholdName"].data<cool::String255>(),":");
659 vector<string> slots = split(payload["CtpinSlot"].data<cool::String255>(),":");
660 vector<string> cons = split(payload["CtpinConnector"].data<cool::String255>(),":");
661 vector<string> mults = split(payload["Multiplicity"].data<cool::String255>(),":");
662 vector<string> starts = split(payload["ThresholdBitStart"].data<cool::String255>(),":");
663 vector<string> ends = split(payload["ThresholdBitEnd"].data<cool::String255>(),":");
664 vector<string> actives = split(payload["ThresholdActive"].data<cool::String255>(),":");
665
666 string monname = payload["CounterName"].data<cool::String255>();
667 string type = payload["CounterType"].data<cool::String255>();
668 //std::string counterlogic = payload["CounterLogic"].data<cool::String255>();
669 unsigned char bgId = payload["BunchGroupId"].data<cool::UChar>();
670
671 // check vectors are all the same size
672 if(
673 names.size() != slots.size() ||
674 names.size() != cons.size() ||
675 names.size() != mults.size() ||
676 names.size() != starts.size() ||
677 names.size() != ends.size() ||
678 names.size() != actives.size()
679 )
680 throw std::runtime_error("Inconsistent mon vector sizes!");
681
682 for(size_t i = 0 ; i < names.size(); ++i) {
684 // Not possible yet. mon->setLogic(counterlogic[i]);
685 mon->setName(monname);
686 mon->setBunchGroupId( static_cast<int>(bgId) );
687 mon->setCounterType(type);
688
689 mon->setThresholdName(names[i]);
690 mon->setCtpinSlot( static_cast<uint16_t>(std::stoul(slots[i])) );
691 mon->setCtpinConnector( static_cast<uint16_t>(std::stoul(cons[i])) );
692 mon->setThresholdStartBit( std::stoi(starts[i]) );
693 mon->setThresholdEndBit( std::stoi(ends[i]) );
694 mon->setMultiplicity( std::stoi(mults[i]) );
695 bool active = (actives[i]=="ENABLED");
696 mon->setThresholdActive( active );
697 vec.push_back(mon);
698 }
699 return vec;
700}
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 598 of file TrigConfCoolL1PayloadConverters.cxx.

599{
600 if ( al["Lvl1Prescale"].specification().type() == typeid(cool::Int32) )
601 prescaleValue = al["Lvl1Prescale"].data<cool::Int32>();
602 else
603 prescaleValue = al["Lvl1Prescale"].data<cool::Int64>();
604}

◆ readLvl1Prescale() [2/2]

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

Definition at line 608 of file TrigConfCoolL1PayloadConverters.cxx.

609{
610 if ( al["Lvl1Prescale"].specification().type() == typeid(cool::Int32) )
611 prescaleValue = al["Lvl1Prescale"].data<cool::Int32>();
612 else
613 prescaleValue = al["Lvl1Prescale"].data<cool::Int64>();
614}

◆ readLvl1TIPMap()

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

Definition at line 640 of file TrigConfCoolL1PayloadConverters.cxx.

641{
642 TrigConf::TIP* tip = new TrigConf::TIP();
643 tip->setThresholdName( al["ThresholdName"].data<cool::String255>() );
644 tip->setSlot( static_cast<uint16_t>(al["CtpinSlot"].data<cool::UChar>()) );
645 tip->setConnector( static_cast<uint16_t>(al["CtpinConnector"].data<cool::UChar>()) );
646 tip->setThresholdBit( static_cast<uint16_t>(al["ThresholdBit"].data<cool::UChar>()) );
647 tip->setCableBit( static_cast<uint16_t>(al["CableBit"].data<cool::UChar>()) );
648 tip->setThresholdMapping( static_cast<uint16_t>(al["ThresholdMapping"].data<cool::UChar>()) );
649 tip->setThresholdActive( al["ThresholdActive"].data<cool::Bool>() );
650
651 return tip;
652}
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