ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1CTP::ItemMap Class Reference

Map associating item name to CTPTriggerItem objects. More...

#include <ItemMap.h>

Collaboration diagram for LVL1CTP::ItemMap:

Public Member Functions

 ItemMap (const TrigConf::L1Menu *l1menu)
 ItemMap (const TrigConf::ItemContainer &item_vector, const TrigConf::PrescaleSet &prescales)
 constructor setting list of trigger items and associated prescales (random prescale offset if randEngine is given)
 ~ItemMap ()
 default destructor
const CTPTriggerItemgetItem (const std::string &itemName) const
const std::set< std::string > & itemNames () const

Private Member Functions

std::string getDefinition (const TrigConf::TriggerItem *item) const

Private Attributes

std::map< std::string, const CTPTriggerItem * > m_map
 map from item name to CTPTriggerItem
std::set< std::string > m_itemNames {}

Detailed Description

Map associating item name to CTPTriggerItem objects.

Definition at line 37 of file ItemMap.h.

Constructor & Destructor Documentation

◆ ItemMap() [1/2]

LVL1CTP::ItemMap::ItemMap ( const TrigConf::L1Menu * l1menu)

Definition at line 22 of file ItemMap.cxx.

23{
24 for( const TrigConf::L1Item & item : *l1menu ) {
25 const std::string & itemName( item.name() );
26
27 // get postion from ctp id
28 unsigned int ctpId = item.ctpId();
29
30 CTPTriggerItem * ctpItem = new CTPTriggerItem();
31 ctpItem->setPrescale( 1 );
32 ctpItem->setCtpId( ctpId );
33 ctpItem->setName(itemName);
34 ctpItem->setLogic(item.definition());
35 ctpItem->setTriggerType(item.triggerTypeAsUChar());
36 ctpItem->setBunchGroups(item.bunchgroups());
37
38 m_map[ itemName ] = ctpItem;
39 m_itemNames.insert( itemName );
40
41 }
42}
std::set< std::string > m_itemNames
Definition ItemMap.h:65
std::map< std::string, const CTPTriggerItem * > m_map
map from item name to CTPTriggerItem
Definition ItemMap.h:63

◆ ItemMap() [2/2]

LVL1CTP::ItemMap::ItemMap ( const TrigConf::ItemContainer & item_vector,
const TrigConf::PrescaleSet & prescales )

constructor setting list of trigger items and associated prescales (random prescale offset if randEngine is given)

Definition at line 52 of file ItemMap.cxx.

54{
55 for( const TrigConf::TriggerItem * item : item_vector ) {
56
57 std::string definition = getDefinition(item);
58
59 const std::string & itemName( item->name() );
60
61 // get postion from ctp id
62 unsigned int ctpId = item->ctpId();
63
64 CTPTriggerItem * ctpItem = new CTPTriggerItem();
65 ctpItem->setPrescale( prescales.prescales_float()[ ctpId ] );
66 ctpItem->setCtpId( ctpId );
67 ctpItem->setName(itemName);
68 ctpItem->setLogic(definition);
69 ctpItem->setTriggerType(item->triggerType());
70
71 m_map[ itemName ] = ctpItem;
72 m_itemNames.insert( itemName );
73 }
74}
std::string getDefinition(const TrigConf::TriggerItem *item) const
Definition ItemMap.cxx:86

◆ ~ItemMap()

LVL1CTP::ItemMap::~ItemMap ( )

default destructor

Definition at line 45 of file ItemMap.cxx.

45 {
46 for( auto & entry : m_map ) {
47 delete entry.second;
48 }
49}

Member Function Documentation

◆ getDefinition()

std::string LVL1CTP::ItemMap::getDefinition ( const TrigConf::TriggerItem * item) const
private

Definition at line 86 of file ItemMap.cxx.

86 {
87
88
89 std::vector<std::string> thresholdlist;
90 std::string logic, conditions;
91 item->buildLogic(logic, thresholdlist); // get's the list of thresholds, e.g. 1,EM15VHI_x1,EM15VHI 2,HA12IM_x2,HA12IM 1,J25_x1,J25 3,J12_x3,J12 BGRP0 BGRP1
92
93 std::map<unsigned int, std::string> thrNames;
94 size_t idx = 1;
95 for(const std::string & thrmult : thresholdlist) {
96 std::vector<std::string> res;
97 boost::split(res, thrmult, boost::is_any_of(",")); // split 1,EM15VHI_x1,EM15VHI into multiplicity,name_mult, and name
98
99 std::string name_mult("");
100 if(res.size() == 1) {
101 name_mult=res[0]; // for thresholds without multiplicity requirement like RNDM0 or BGRP0,...
102 } else {
103 name_mult = res[2]+"[x"+res[0]+"]"; // build "EM15VHI[x1]"
104 }
105 thrNames[idx++] = std::move(name_mult);
106 }
107
108 // now take the logic (1&2&3&4&5&6) apart and replace the numbers with names "thr[xmult]"
109 std::string def = item->definition();
110 std::vector<std::string> tokens;
111 // build tokens with separators ()&|! and <space>. Keeps all separators except <space> in the list of tokens
112 for ( auto & tok : boost::tokenizer<boost::char_separator<char> > (item->definition(), boost::char_separator<char>(" ", "()&|!")) ) {
113 int n;
114 auto [ptr, ec] = std::from_chars(tok.data(), tok.data() + tok.size(), n);
115 if (ec == std::errc()) {
116 tokens.emplace_back(thrNames[n]);//AV: Note that this might be out of bounds
117 } else {
118 tokens.emplace_back(tok);
119 }
120 }
121
122 // and reassemble the logic definition string
123 std::string definition("");
124 for( auto & tok : tokens ) {
125 definition += tok;
126 }
127
128 return definition;
129}
std::pair< std::vector< unsigned int >, bool > res
void * ptr(T *p)
Definition SGImplSvc.cxx:74

◆ getItem()

const CTPTriggerItem * LVL1CTP::ItemMap::getItem ( const std::string & itemName) const
inline

Definition at line 50 of file ItemMap.h.

51 { return m_map.find( itemName )->second; }

◆ itemNames()

const std::set< std::string > & LVL1CTP::ItemMap::itemNames ( ) const
inline

Definition at line 53 of file ItemMap.h.

54 { return m_itemNames; }

Member Data Documentation

◆ m_itemNames

std::set<std::string> LVL1CTP::ItemMap::m_itemNames {}
private

Definition at line 65 of file ItemMap.h.

65{};

◆ m_map

std::map< std::string, const CTPTriggerItem* > LVL1CTP::ItemMap::m_map
private

map from item name to CTPTriggerItem

Definition at line 63 of file ItemMap.h.


The documentation for this class was generated from the following files: