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