ATLAS Offline Software
Loading...
Searching...
No Matches
TriggerItem.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10#include <iostream>
11#include <iomanip>
12#include <stdexcept>
13#include <algorithm>
14
15using namespace std;
16using namespace TrigConf;
17
20 m_Definition( "" ),
21 m_CtpId( -1 ),
22 m_TriggerType( 0 ),
23 m_Partition( 0 ),
24 m_Monitor( 0 )
25{}
26
29
30
31uint16_t
33 uint16_t bgmask(0);
34 if( m_TopNode ) {
35 m_TopNode->getBunchGroupsMask(bgmask);
36 }
37 return bgmask;
38}
39
40
43 DiffStruct * ds = new DiffStruct("TriggerItem");
44 ds->check("ctpid", ctpId(), o->ctpId());
45 ds->check("definition", definition(), o->definition());
46 ds->check("complex_deadtime", complex_deadtime(), o->complex_deadtime());
47 ds->check("triggertype", triggerType(), o->triggerType());
48 if(!ds->empty()) {
49 ds->name = name();
50 } else {
51 delete ds; ds=0;
52 }
53 return ds;
54}
55
56
57void
58TriggerItem::writeXML(std::ostream & xmlfile, int indentLevel, int indentWidth) const {
59
60
61
62
63 string final_def = m_Definition;
64 bool end=false;
65 string::size_type index=0;
66 while(!end){
67 std::string::size_type pos=final_def.find('&',index);
68 if(pos!= std::string::npos){
69 end=false;
70 index = pos+1;
71 //do the replace
72 final_def.replace(pos, 1, "&amp;");
73 }else{
74 end=true;
75 index=0;
76 }
77 }
78
79 indent(xmlfile, indentLevel, indentWidth)
80 << "<TriggerItem ctpid=\"" << m_CtpId
81 << "\" partition=\"" << partition()
82 << "\" name=\"" << name()
83 << "\" complex_deadtime=\"" << complex_deadtime()
84 << "\" definition=\"" << final_def
85 << "\" trigger_type=\"" << TrigConf::uint2bin(m_TriggerType, partition()==1 ? 8 : 4) << "\"";
86 if(monitor()!=0) {
87 string s("LF:");
88 s += (monitor() & 0x04 ? '1' : '0');
89 s += (monitor() & 0x02 ? '1' : '0');
90 s += (monitor() & 0x01 ? '1' : '0');
91 s += "|HF:";
92 s += (monitor() & 0x20 ? '1' : '0');
93 s += (monitor() & 0x10 ? '1' : '0');
94 s += (monitor() & 0x08 ? '1' : '0');
95 xmlfile << " monitor=\"" << s << "\"";
96 }
97 xmlfile << ">" << endl;
98
99 if (m_TopNode)
100 m_TopNode->writeXML(xmlfile, indentLevel+1, indentWidth);
101
102 indent(xmlfile, indentLevel, indentWidth) << "</TriggerItem>" << endl;
103}
104
105
106void
107TriggerItem::buildLogic(std::string & logic, std::vector<std::string> & conditionList) const {
108 if (m_TopNode)
109 m_TopNode->buildLogic(conditionList, logic);
110}
111
112
113void
114TriggerItem::setCondition(const string& logic,
115 const vector<string>& conditions,
116 const vector<TriggerThreshold*>& thrs) {
117 // logic is a string like "!(1|2)&(3|4)"
118 // vector of conditions of length equal the largest number in logic string (e.g 4)
119 // a condition can be either a single name for internal triggers or a komma separated list of multiplicity, conditions name and threshold name
120 // thrs is a list of thresholds
121
122 m_Definition = "("+logic+")";
123
124 try {
125 m_TopNode.reset (TrigConf::parse(logic, conditions, thrs));
126 }
127 catch(const exception& e) {
128 cout << "WARNING: Could not set condition of triggeritem " << name() << " because: " << e.what() << endl;
129 }
130}
131
132
133void
134TriggerItem::print(const std::string& indent, unsigned int detail) const {
135 if(detail<3) {
136 cout << indent << "TriggerItem ctpid = " << m_CtpId << " ";
137 printNameIdV();
138 } else {
139 cout << indent << "==================================" << endl;
140 cout << indent << "TriggerItem:";
142 cout << indent << "Complex Deadtime: " << m_ComplexDeadtime << endl;
143 cout << indent << "Definition: " << m_Definition << endl;
144 cout << indent << "CTP_id : " << m_CtpId << endl;
145 cout << indent << "TriggerType(hex): 0x" << std::hex << m_TriggerType << std::dec << endl;
146 cout << indent << "Bunchgroup mask : " << uint2bin(bunchgroupMask(), 16) << endl;
147 cout << indent << "Monitor : " << monitor() << endl;
148 if(detail>=4) {
149 if (m_TopNode) m_TopNode->print(indent,detail);
150 else cout << indent << "TopNode is NULL pointer" << endl;
151 }
152 }
153}
154
155
156std::ostream &
157TrigConf::operator<<(std::ostream & o, const TrigConf::TriggerItem & item) {
158 o << "TriggerItem: " << (const TrigConfData&)item;
159 o << " Complex Deadtime: " << item.m_ComplexDeadtime << endl;
160 o << " Definition: " << item.m_Definition << endl;
161 o << " CTP_id: " << item.m_CtpId << endl;
162 o << " TriggerType(hex): " << hex << item.m_TriggerType << dec << endl;
163 if (item.topNode()) o << *item.topNode();
164 else o << " No TopNode" << endl;
165 return o;
166}
167
168
169string
171 stringstream s;
172 s << *this;
173 return s.str();
174}
std::ostream & indent(std::ostream &o, int lvl, int size) const
const std::string & name() const
void printNameIdV(const std::string &indent="") const
TrigConfData(const std::string &name="")
std::string m_Definition
Definition TriggerItem.h:71
std::unique_ptr< TriggerItemNode > m_TopNode
Definition TriggerItem.h:72
unsigned short m_Monitor
Definition TriggerItem.h:76
unsigned int complex_deadtime() const
Definition TriggerItem.h:32
virtual void print(const std::string &indent="", unsigned int detail=1) const override
void buildLogic(std::string &logic, std::vector< std::string > &conditionList) const
DiffStruct * compareTo(const TriggerItem *o) const
unsigned int m_ComplexDeadtime
Definition TriggerItem.h:70
uint16_t bunchgroupMask() const
std::string __str__() const override
void writeXML(std::ostream &xmlfile, int indentLevel=0, int indentWidth=2) const
const std::string & definition() const
Definition TriggerItem.h:33
unsigned int m_TriggerType
Definition TriggerItem.h:74
void setCondition(const std::string &logic, const std::vector< std::string > &conditions, const std::vector< TrigConf::TriggerThreshold * > &thrs)
unsigned int partition() const
Definition TriggerItem.h:36
unsigned short monitor() const
Definition TriggerItem.h:38
unsigned int m_Partition
Definition TriggerItem.h:75
virtual ~TriggerItem() override
unsigned int triggerType() const
Definition TriggerItem.h:34
static std::vector< std::string > xmlfile
Definition iLumiCalc.h:29
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
std::string uint2bin(uint32_t uinteger, uint16_t width)
std::ostream & operator<<(std::ostream &os, const TrigConf::IsolationLegacy &iso)
std::vector< std::string > parse(std::string names)
Definition index.py:1
STL namespace.