14 #include <sys/types.h>
16 #include <boost/lexical_cast.hpp>
58 static const std::string typelabel[] = {
"OBJ",
"NOT",
"AND",
"OR",
"UNDEF"};
59 return typelabel[
type];
77 setInternalTrigger(thr->
name());
80 m_InternalTrigger.second = 0;
83 m_ThresholdName = thr->
name();
88 unsigned int thresholdNumber) {
89 m_InternalTrigger.first =
x;
90 m_InternalTrigger.second = thresholdNumber;
98 string::size_type
pos =
name.find_first_of(
"0123456789");
103 cerr <<
"TriggerItemNode::setInternalTrigger: type " <<
name <<
" is not an internal trigger" << endl;
104 throw runtime_error(
"TriggerItemNode::setInternalTrigger: type is not an internal trigger");
106 m_InternalTrigger.first =
tt;
107 m_InternalTrigger.second = boost::lexical_cast<unsigned int,string>(
name.substr(
pos));
108 m_ThresholdName =
name;
116 throw std::runtime_error(
"TriggerItemNode::addChild: trying to add child to leaf node");
117 m_Children.push_back(
node);
133 if(!isInternalTrigger()) {
134 if(m_Threshold)
vec.push_back(m_Threshold);
146 if(
vec.size() < max_bgrp)
vec.resize( max_bgrp );
149 vec[m_InternalTrigger.second] =
true;
162 bgmask |= (
mask << m_InternalTrigger.second);
166 node->getBunchGroupsMask(bgmask);
174 vec.push_back(m_InternalTrigger.second);
185 vec.push_back(m_InternalTrigger.second);
188 node->getAllRandomTriggers(
vec);
196 vec.push_back(m_InternalTrigger.second);
199 node->getAllPrescaledClockTriggers(
vec);
206 if (m_NodeType == OBJ) {
208 if(isInternalTrigger()) {
209 indent(xmlfile, indentLevel, indentWidth)
210 <<
"<InternalTrigger name=\"" << m_ThresholdName <<
"\"/>" << endl;
212 indent(xmlfile, indentLevel, indentWidth)
213 <<
"<TriggerCondition multi=\"" << m_Multiplicity
214 <<
"\" name=\"" << m_ThresholdName <<
"_x" << m_Multiplicity
215 <<
"\" triggerthreshold=\"" << m_ThresholdName <<
"\"/>" << endl;
218 }
else if (m_NodeType ==
AND || m_NodeType ==
OR) {
220 std::string logic = (m_NodeType==
AND?
"AND":
"OR");
221 indent(xmlfile, indentLevel, indentWidth) <<
"<" << logic <<
">" << endl;
223 node->writeXML(xmlfile, indentLevel+1, indentWidth);
224 indent(xmlfile, indentLevel, indentWidth) <<
"</"<<logic<<
">" << endl;
226 }
else if (m_NodeType == NOT) {
228 indent(xmlfile, indentLevel, indentWidth) <<
"<NOT>" << endl;
229 children()[0]->writeXML(xmlfile, indentLevel+1, indentWidth);
230 indent(xmlfile, indentLevel, indentWidth) <<
"</NOT>" << endl;
238 std::string & logic)
const {
240 if (m_NodeType == OBJ) {
243 if( m_Threshold->type() != L1DataDef::rndmType() &&
244 m_Threshold->type() != L1DataDef::pclkType() &&
245 m_Threshold->type() != L1DataDef::bgrpType()) {
246 std::string
name = m_Threshold->name();
258 if(
pos>9) logic +=
'0'+
pos/10;
261 }
else if (m_NodeType ==
AND || m_NodeType ==
OR) {
265 if(!
first) { logic += (m_NodeType==
AND?
"&":
"|"); }
else {
first=
false; }
266 node->buildLogic(conditionList, logic);
269 }
else if (m_NodeType == NOT) {
271 children()[0]->buildLogic(conditionList, logic);
279 cout <<
indent <<
"TriggerItemNode: " << endl;
281 cout <<
indent <<
" position : " << m_Position << endl;
283 if (m_NodeType == OBJ) {
284 cout <<
indent <<
" multiplicity: " << m_Multiplicity << endl;
286 cout <<
indent <<
" threshold : " << m_Threshold->name() << endl;
288 }
else if(isInternalTrigger()) {
289 cout <<
indent <<
" InternalTrigger: "
290 << thresholdName() << endl;
292 cout <<
indent << thresholdName() << endl;
297 cout <<
indent <<
" subnode : " << endl;
304 if(lvl*
size==0)
return o;
305 o << std::setw(lvl*
size) <<
" ";
312 o <<
" TriggerItemNode: " << endl;
314 o <<
" position : " <<
node.position() << endl;
317 o <<
" multiplicity: " <<
node.multiplicity() << endl;
318 if (
node.triggerThreshold() ) {
319 o <<
" threshold : " <<
node.thresholdName() << endl
320 <<
node.triggerThreshold();
321 }
else if(
node.isInternalTrigger() ) {
322 o <<
" InternalTrigger: " <<
node.thresholdName() << endl;
324 o <<
node.thresholdName() << endl;
329 o <<
" subnodes : " << *
subnode << endl;