ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConf::TriggerItemNode Class Reference

#include <TriggerItemNode.h>

Collaboration diagram for TrigConf::TriggerItemNode:

Public Types

enum  NodeType {
  OBJ , NOT , AND , OR ,
  UNDEF
}
typedef std::pair< L1DataDef::TriggerType, unsigned int > InternalType_t

Public Member Functions

 TriggerItemNode (NodeType)
virtual ~TriggerItemNode ()
bool isThreshold () const
bool isInternalTrigger () const
void addChild (TriggerItemNode *node)
const std::vector< TriggerItemNode * > & children () const
void setThresholdName (const std::string &thrname)
void setPosition (int pos)
void setMultiplicity (int mult)
void setTriggerThreshold (TriggerThreshold *thr)
void setInternalTrigger (L1DataDef::TriggerType x, unsigned int thresholdNumber)
void setInternalTrigger (const std::string &name)
NodeType type () const
const std::string & thresholdName () const
int position () const
int multiplicity () const
const TriggerThresholdtriggerThreshold () const
L1DataDef::TriggerType internalTriggerType () const
unsigned int internalTriggerNumber () const
void getAllFinalNodes (std::vector< const TriggerItemNode * > &) const
void getAllThresholds (std::vector< const TriggerThreshold * > &) const
void getAllBunchGroups (std::vector< bool > &) const
void getBunchGroupsMask (uint16_t &bgmask) const
void getAllBunchGroups (std::vector< unsigned int > &) const
void getAllRandomTriggers (std::vector< unsigned int > &) const
void getAllPrescaledClockTriggers (std::vector< unsigned int > &) const
void print (const std::string &indent="", unsigned int detail=1) const
void writeXML (std::ostream &xmlfile, int indentLevel=0, int indentWidth=2, bool omitDelimiter=false) const
void buildLogic (std::vector< std::string > &conditionList, std::string &logic) const
virtual std::string __str__ () const

Static Public Member Functions

static NodeType typeFromString (const std::string &)
static NodeType typeFromChar (const char &c)
static std::string typeAsString (NodeType)

Private Member Functions

std::ostream & indent (std::ostream &o, int lvl, int size) const

Private Attributes

NodeType m_NodeType
std::vector< TriggerItemNode * > m_Children
std::string m_ThresholdName
int m_Position
int m_Multiplicity
TriggerThresholdm_Threshold
InternalType_t m_InternalTrigger

Detailed Description

Definition at line 22 of file TriggerItemNode.h.

Member Typedef Documentation

◆ InternalType_t

Definition at line 32 of file TriggerItemNode.h.

Member Enumeration Documentation

◆ NodeType

Constructor & Destructor Documentation

◆ TriggerItemNode()

TrigConf::TriggerItemNode::TriggerItemNode ( NodeType type)

Definition at line 20 of file TriggerItemNode.cxx.

◆ ~TriggerItemNode()

TrigConf::TriggerItemNode::~TriggerItemNode ( )
virtual

Definition at line 30 of file TriggerItemNode.cxx.

30 {
31 for(TriggerItemNode * node : m_Children)
32 delete node;
33}
std::vector< TriggerItemNode * > m_Children

Member Function Documentation

◆ __str__()

string TriggerItemNode::__str__ ( ) const
virtual

Definition at line 334 of file TriggerItemNode.cxx.

334 {
335 stringstream s;
336 s << *this;
337 return s.str();
338}

◆ addChild()

void TrigConf::TriggerItemNode::addChild ( TriggerItemNode * node)

Definition at line 112 of file TriggerItemNode.cxx.

112 {
113 if(type() == OBJ)
114 throw std::runtime_error("TriggerItemNode::addChild: trying to add child to leaf node");
115 m_Children.push_back(node);
116}

◆ buildLogic()

void TrigConf::TriggerItemNode::buildLogic ( std::vector< std::string > & conditionList,
std::string & logic ) const

Definition at line 235 of file TriggerItemNode.cxx.

236 {
237
238 if (m_NodeType == OBJ) {
239 std::string condition("");
240 if (m_Threshold) {
244 std::string name = m_Threshold->name();
245 name += "_x" + std::to_string(m_Multiplicity);
246 condition += '0' + m_Multiplicity;
247 condition += "," + name;
248 condition += "," + m_Threshold->name();
249 } else {
250 condition = m_Threshold->name();
251 }
252 } else {
254 }
255 uint32_t pos = conditionList.size()+1;
256 if(pos>9) logic += '0'+pos/10;
257 logic += '0'+pos%10;
258 conditionList.push_back(std::move(condition));
259 } else if (m_NodeType == AND || m_NodeType == OR) {
260 logic += "(";
261 bool first = true;
262 for(TriggerItemNode *node : children()) {
263 if(!first) { logic += (m_NodeType==AND?"&":"|"); } else { first=false; }
264 node->buildLogic(conditionList, logic);
265 }
266 logic += ")";
267 } else if (m_NodeType == NOT) {
268 logic += "!";
269 children()[0]->buildLogic(conditionList, logic);
270 }
271
272}
static TriggerTypeConfig & typeConfig(TriggerType tt)
const std::vector< TriggerItemNode * > & children() const
const std::string & thresholdName() const
bool first
Definition DeMoScan.py:534
setEventNumber uint32_t

◆ children()

const std::vector< TriggerItemNode * > & TrigConf::TriggerItemNode::children ( ) const
inline

Definition at line 39 of file TriggerItemNode.h.

39{ return m_Children; }

◆ getAllBunchGroups() [1/2]

void TrigConf::TriggerItemNode::getAllBunchGroups ( std::vector< bool > & vec) const

Definition at line 142 of file TriggerItemNode.cxx.

142 {
143 unsigned int max_bgrp = L1DataDef::typeConfig(L1DataDef::BGRP).max;
144 if(vec.size() < max_bgrp) vec.resize( max_bgrp );
145 if(type() == OBJ) {
147 vec[m_InternalTrigger.second] = true;
148 } else {
149 for(TriggerItemNode * node : m_Children)
150 node->getAllBunchGroups(vec);
151 }
152}
std::vector< size_t > vec
L1DataDef::TriggerType internalTriggerType() const

◆ getAllBunchGroups() [2/2]

void TrigConf::TriggerItemNode::getAllBunchGroups ( std::vector< unsigned int > & vec) const

Definition at line 169 of file TriggerItemNode.cxx.

169 {
170 if(type() == OBJ) {
172 vec.push_back(m_InternalTrigger.second);
173 } else {
174 for(TriggerItemNode * node : m_Children)
175 node->getAllBunchGroups(vec);
176 }
177}

◆ getAllFinalNodes()

void TrigConf::TriggerItemNode::getAllFinalNodes ( std::vector< const TriggerItemNode * > & vec) const

Definition at line 119 of file TriggerItemNode.cxx.

119 {
120 if(type() == OBJ) {
121 vec.push_back(this);
122 } else {
123 for(TriggerItemNode * node : m_Children)
124 node->getAllFinalNodes(vec);
125 }
126}

◆ getAllPrescaledClockTriggers()

void TrigConf::TriggerItemNode::getAllPrescaledClockTriggers ( std::vector< unsigned int > & vec) const

Definition at line 191 of file TriggerItemNode.cxx.

191 {
192 if(type() == OBJ) {
194 vec.push_back(m_InternalTrigger.second);
195 } else {
196 for(TriggerItemNode * node : m_Children)
197 node->getAllPrescaledClockTriggers(vec);
198 }
199 return;
200}

◆ getAllRandomTriggers()

void TrigConf::TriggerItemNode::getAllRandomTriggers ( std::vector< unsigned int > & vec) const

Definition at line 180 of file TriggerItemNode.cxx.

180 {
181 if(type() == OBJ) {
183 vec.push_back(m_InternalTrigger.second);
184 } else {
185 for(TriggerItemNode * node : m_Children)
186 node->getAllRandomTriggers(vec);
187 }
188}

◆ getAllThresholds()

void TrigConf::TriggerItemNode::getAllThresholds ( std::vector< const TriggerThreshold * > & vec) const

Definition at line 129 of file TriggerItemNode.cxx.

129 {
130 if(type() == OBJ) {
131 if(!isInternalTrigger()) {
132 if(m_Threshold) vec.push_back(m_Threshold);
133 }
134 } else {
135 for(TriggerItemNode * node : m_Children)
136 node->getAllThresholds(vec);
137 }
138}

◆ getBunchGroupsMask()

void TrigConf::TriggerItemNode::getBunchGroupsMask ( uint16_t & bgmask) const

Definition at line 156 of file TriggerItemNode.cxx.

156 {
157 if(type() == OBJ) {
159 uint16_t mask(0x1);
160 bgmask |= (mask << m_InternalTrigger.second);
161 }
162 } else {
163 for(TriggerItemNode * node : m_Children)
164 node->getBunchGroupsMask(bgmask);
165 }
166}
setWord1 uint16_t

◆ indent()

std::ostream & TrigConf::TriggerItemNode::indent ( std::ostream & o,
int lvl,
int size ) const
private

Definition at line 301 of file TriggerItemNode.cxx.

301 {
302 if(lvl*size==0) return o;
303 o << std::setw(lvl*size) << " ";
304 return o;
305}

◆ internalTriggerNumber()

unsigned int TrigConf::TriggerItemNode::internalTriggerNumber ( ) const
inline

Definition at line 56 of file TriggerItemNode.h.

56{ return m_InternalTrigger.second; }

◆ internalTriggerType()

L1DataDef::TriggerType TrigConf::TriggerItemNode::internalTriggerType ( ) const
inline

Definition at line 55 of file TriggerItemNode.h.

55{ return m_InternalTrigger.first; }

◆ isInternalTrigger()

bool TrigConf::TriggerItemNode::isInternalTrigger ( ) const

Definition at line 67 of file TriggerItemNode.cxx.

67 {
68 return m_InternalTrigger.first != L1DataDef::UNDEF;
69}

◆ isThreshold()

bool TrigConf::TriggerItemNode::isThreshold ( ) const

Definition at line 62 of file TriggerItemNode.cxx.

62 {
63 return m_InternalTrigger.first == L1DataDef::UNDEF;
64}

◆ multiplicity()

int TrigConf::TriggerItemNode::multiplicity ( ) const
inline

Definition at line 53 of file TriggerItemNode.h.

53{ return m_Multiplicity; }

◆ position()

int TrigConf::TriggerItemNode::position ( ) const
inline

Definition at line 52 of file TriggerItemNode.h.

52{ return m_Position; }

◆ print()

void TrigConf::TriggerItemNode::print ( const std::string & indent = "",
unsigned int detail = 1 ) const

Definition at line 276 of file TriggerItemNode.cxx.

276 {
277 cout << indent << "TriggerItemNode: " << endl;
278 cout << indent << " type : " << (type()==OBJ?"OBJ":(type()==AND?"AND":(type()==OR?"OR":"NOT"))) << endl;
279 cout << indent << " position : " << m_Position << endl;
280
281 if (m_NodeType == OBJ) {
282 cout << indent << " multiplicity: " << m_Multiplicity << endl;
283 if (m_Threshold) {
284 cout << indent << " threshold : " << m_Threshold->name() << endl;
285 m_Threshold->print(indent + indent, detail);
286 } else if(isInternalTrigger()) {
287 cout << indent << " InternalTrigger: "
288 << thresholdName() << endl;
289 } else {
290 cout << indent << thresholdName() << endl;
291 }
292 }
293 else {
294 for(TriggerItemNode * node : m_Children) {
295 cout << indent << " subnode : " << endl;
296 node->print(indent + indent);
297 }
298 }
299}
std::ostream & indent(std::ostream &o, int lvl, int size) const

◆ setInternalTrigger() [1/2]

void TrigConf::TriggerItemNode::setInternalTrigger ( const std::string & name)

Definition at line 94 of file TriggerItemNode.cxx.

94 {
95
96 string::size_type pos = name.find_first_of("0123456789");
97
99
100 if( ! L1DataDef::typeConfig(tt).internal ) {
101 cerr << "TriggerItemNode::setInternalTrigger: type " << name << " is not an internal trigger" << endl;
102 throw runtime_error("TriggerItemNode::setInternalTrigger: type is not an internal trigger");
103 }
104 m_InternalTrigger.first = tt;
105 m_InternalTrigger.second = static_cast<unsigned int>(std::stoul(name.substr(pos)));
107 m_Threshold = 0;
108}
static TriggerType stringAsType(const std::string &type)
Definition L1DataDef.h:51

◆ setInternalTrigger() [2/2]

void TrigConf::TriggerItemNode::setInternalTrigger ( L1DataDef::TriggerType x,
unsigned int thresholdNumber )

Definition at line 85 of file TriggerItemNode.cxx.

86 {
87 m_InternalTrigger.first = x;
88 m_InternalTrigger.second = thresholdNumber;
89 m_ThresholdName = L1DataDef::typeConfig(x).name + std::to_string(thresholdNumber);
90 m_Threshold = 0;
91}
#define x

◆ setMultiplicity()

void TrigConf::TriggerItemNode::setMultiplicity ( int mult)
inline

Definition at line 44 of file TriggerItemNode.h.

44{ m_Multiplicity = mult; }

◆ setPosition()

void TrigConf::TriggerItemNode::setPosition ( int pos)
inline

Definition at line 43 of file TriggerItemNode.h.

43{ m_Position = pos; }

◆ setThresholdName()

void TrigConf::TriggerItemNode::setThresholdName ( const std::string & thrname)
inline

Definition at line 42 of file TriggerItemNode.h.

42{ m_ThresholdName = thrname; }

◆ setTriggerThreshold()

void TrigConf::TriggerItemNode::setTriggerThreshold ( TriggerThreshold * thr)

Definition at line 72 of file TriggerItemNode.cxx.

72 {
73 if(thr->isInternal()) {
74 // from the database internal triggers are also loaded as TriggerThresholds
75 setInternalTrigger(thr->name());
76 } else {
78 m_InternalTrigger.second = 0;
79 }
81 m_ThresholdName = thr->name();
82}
void setInternalTrigger(L1DataDef::TriggerType x, unsigned int thresholdNumber)

◆ thresholdName()

const std::string & TrigConf::TriggerItemNode::thresholdName ( ) const
inline

Definition at line 51 of file TriggerItemNode.h.

51{ return m_ThresholdName; }

◆ triggerThreshold()

const TriggerThreshold * TrigConf::TriggerItemNode::triggerThreshold ( ) const
inline

Definition at line 54 of file TriggerItemNode.h.

54{ return m_Threshold; }

◆ type()

NodeType TrigConf::TriggerItemNode::type ( ) const
inline

Definition at line 50 of file TriggerItemNode.h.

50{ return m_NodeType; };

◆ typeAsString()

std::string TrigConf::TriggerItemNode::typeAsString ( NodeType type)
static

Definition at line 55 of file TriggerItemNode.cxx.

55 {
56 static const std::string typelabel[] = {"OBJ", "NOT", "AND", "OR", "UNDEF"};
57 return typelabel[type];
58}

◆ typeFromChar()

TriggerItemNode::NodeType TriggerItemNode::typeFromChar ( const char & c)
static

Definition at line 47 of file TriggerItemNode.cxx.

47 {
48 if(c=='&') return TriggerItemNode::AND;
49 if(c=='|') return TriggerItemNode::OR;
50 if(c=='!') return TriggerItemNode::NOT;
52}

◆ typeFromString()

TrigConf::TriggerItemNode::NodeType TrigConf::TriggerItemNode::typeFromString ( const std::string & type)
static

Definition at line 36 of file TriggerItemNode.cxx.

36 {
37 if(type=="AND") return TriggerItemNode::AND;
38 if(type=="OR") return TriggerItemNode::OR;
39 if(type=="NOT") return TriggerItemNode::NOT;
40 if(type=="OBJ") return TriggerItemNode::OBJ;
41 if(type=="TriggerCondition") return TriggerItemNode::OBJ;
42 if(type=="InternalTrigger") return TriggerItemNode::OBJ;
44}

◆ writeXML()

void TrigConf::TriggerItemNode::writeXML ( std::ostream & xmlfile,
int indentLevel = 0,
int indentWidth = 2,
bool omitDelimiter = false ) const

Definition at line 203 of file TriggerItemNode.cxx.

203 {
204 if (m_NodeType == OBJ) {
205
206 if(isInternalTrigger()) {
207 indent(xmlfile, indentLevel, indentWidth)
208 << "<InternalTrigger name=\"" << m_ThresholdName << "\"/>" << endl;
209 } else {
210 indent(xmlfile, indentLevel, indentWidth)
211 << "<TriggerCondition multi=\"" << m_Multiplicity
212 << "\" name=\"" << m_ThresholdName << "_x" << m_Multiplicity
213 << "\" triggerthreshold=\"" << m_ThresholdName << "\"/>" << endl;
214 }
215
216 } else if (m_NodeType == AND || m_NodeType == OR) {
217
218 std::string logic = (m_NodeType==AND?"AND":"OR");
219 indent(xmlfile, indentLevel, indentWidth) << "<" << logic << ">" << endl;
220 for(TriggerItemNode *node : children())
221 node->writeXML(xmlfile, indentLevel+1, indentWidth);
222 indent(xmlfile, indentLevel, indentWidth) << "</"<<logic<<">" << endl;
223
224 } else if (m_NodeType == NOT) {
225
226 indent(xmlfile, indentLevel, indentWidth) << "<NOT>" << endl;
227 children()[0]->writeXML(xmlfile, indentLevel+1, indentWidth);
228 indent(xmlfile, indentLevel, indentWidth) << "</NOT>" << endl;
229
230 }
231}
static std::vector< std::string > xmlfile
Definition iLumiCalc.h:29

Member Data Documentation

◆ m_Children

std::vector<TriggerItemNode*> TrigConf::TriggerItemNode::m_Children
private

Definition at line 78 of file TriggerItemNode.h.

◆ m_InternalTrigger

InternalType_t TrigConf::TriggerItemNode::m_InternalTrigger
private

Definition at line 87 of file TriggerItemNode.h.

◆ m_Multiplicity

int TrigConf::TriggerItemNode::m_Multiplicity
private

Definition at line 83 of file TriggerItemNode.h.

◆ m_NodeType

NodeType TrigConf::TriggerItemNode::m_NodeType
private

Definition at line 75 of file TriggerItemNode.h.

◆ m_Position

int TrigConf::TriggerItemNode::m_Position
private

Definition at line 82 of file TriggerItemNode.h.

◆ m_Threshold

TriggerThreshold* TrigConf::TriggerItemNode::m_Threshold
private

Definition at line 84 of file TriggerItemNode.h.

◆ m_ThresholdName

std::string TrigConf::TriggerItemNode::m_ThresholdName
private

Definition at line 81 of file TriggerItemNode.h.


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