ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1CTP
src
ItemMap.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// local includes
6
#include "
./ItemMap.h
"
7
8
// TrigT1 configuration includes
9
#include "
TrigConfL1Data/TriggerItem.h
"
10
#include "
TrigConfL1Data/PrescaleSet.h
"
11
12
13
// random number generator
14
#include "CLHEP/Random/RandomEngine.h"
15
#include "CLHEP/Random/RandFlat.h"
16
17
#include "boost/algorithm/string.hpp"
18
#include <boost/tokenizer.hpp>
19
#include <charconv>
20
#include <string_view>
21
22
LVL1CTP::ItemMap::ItemMap
(
const
TrigConf::L1Menu
* l1menu )
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
}
43
44
45
LVL1CTP::ItemMap::~ItemMap
() {
46
for
(
auto
& entry :
m_map
) {
47
delete
entry.second;
48
}
49
}
50
51
52
LVL1CTP::ItemMap::ItemMap
(
const
TrigConf::ItemContainer
& item_vector,
53
const
TrigConf::PrescaleSet
& prescales )
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
}
75
76
77
/*
78
e.g for the item L1_EM15VHI_2TAU12IM_J25_3J12
79
the definition that is stored in COOL is (1&2&3&4&5&6)
80
and the list of thresholds is 1,EM15VHI_x1,EM15VHI 2,HA12IM_x2,HA12IM 1,J25_x1,J25 3,J12_x3,J12 BGRP0 BGRP1
81
82
In this function this information is used to create a definition string
83
"(EM15VHI[x1]&HA12IM[x2]&J25[x1]&J12[x3]&BGRP0&BGRP1)"
84
*/
85
std::string
86
LVL1CTP::ItemMap::getDefinition
(
const
TrigConf::TriggerItem
* item )
const
{
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
}
ItemMap.h
res
std::pair< std::vector< unsigned int >, bool > res
Definition
JetGroupProductTest.cxx:11
PrescaleSet.h
TriggerItem.h
LVL1CTP::CTPTriggerItem
Class storing information helping to make the CTP decision.
Definition
CTPTriggerItem.h:23
LVL1CTP::CTPTriggerItem::setPrescale
void setPrescale(int prescale)
Definition
CTPTriggerItem.cxx:18
LVL1CTP::CTPTriggerItem::setBunchGroups
void setBunchGroups(const std::vector< std::string > &bunchGroups)
Definition
CTPTriggerItem.cxx:72
LVL1CTP::CTPTriggerItem::setCtpId
void setCtpId(unsigned int ctpid)
Definition
CTPTriggerItem.cxx:45
LVL1CTP::CTPTriggerItem::setName
void setName(const std::string &name)
Definition
CTPTriggerItem.cxx:29
LVL1CTP::CTPTriggerItem::setLogic
void setLogic(const std::string &logicExpr)
Definition
CTPTriggerItem.cxx:60
LVL1CTP::CTPTriggerItem::setTriggerType
void setTriggerType(unsigned char triggerType)
Definition
CTPTriggerItem.cxx:50
LVL1CTP::ItemMap::m_itemNames
std::set< std::string > m_itemNames
Definition
ItemMap.h:65
LVL1CTP::ItemMap::~ItemMap
~ItemMap()
default destructor
Definition
ItemMap.cxx:45
LVL1CTP::ItemMap::ItemMap
ItemMap(const TrigConf::L1Menu *l1menu)
Definition
ItemMap.cxx:22
LVL1CTP::ItemMap::getDefinition
std::string getDefinition(const TrigConf::TriggerItem *item) const
Definition
ItemMap.cxx:86
LVL1CTP::ItemMap::m_map
std::map< std::string, const CTPTriggerItem * > m_map
map from item name to CTPTriggerItem
Definition
ItemMap.h:63
TrigConf::L1Item
L1 threshold configuration.
Definition
L1Item.h:18
TrigConf::L1Menu
L1 menu configuration.
Definition
L1Menu.h:29
TrigConf::PrescaleSet
Definition
PrescaleSet.h:22
TrigConf::TriggerItem
Definition
TriggerItem.h:26
TrigConf::TriggerItem::buildLogic
void buildLogic(std::string &logic, std::vector< std::string > &conditionList) const
Definition
TriggerItem.cxx:107
TrigConf::TriggerItem::definition
const std::string & definition() const
Definition
TriggerItem.h:33
TrigConf::ItemContainer
boost::multi_index::multi_index_container< TriggerItem *, boost::multi_index::indexed_by< boost::multi_index::random_access<>, boost::multi_index::ordered_unique< boost::multi_index::identity< TriggerItem > >, boost::multi_index::ordered_unique< boost::multi_index::tag< tag_ctpid >, boost::multi_index::const_mem_fun< TriggerItem, int, &TriggerItem::ctpId > >, boost::multi_index::hashed_unique< boost::multi_index::tag< tag_name_hash >, boost::multi_index::const_mem_fun< TrigConfData, const std::string &, &TrigConfData::name > > > > ItemContainer
Definition
Menu.h:39
Generated on
for ATLAS Offline Software by
1.17.0