Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TriggerThreshold.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
15 
16 #include <stdexcept>
17 #include <iostream>
18 #include <algorithm>
19 
20 using namespace std;
21 
24 {}
25 
27  L1DataBaseclass(thr),
28  m_type(thr.m_type),
29  m_SType(thr.m_SType),
30  m_Active(thr.m_Active),
31  m_Mapping(thr.m_Mapping),
32  m_CableName(thr.m_CableName),
33  m_CableCtpin(thr.m_CableCtpin),
34  m_CableConnector(thr.m_CableConnector),
35  m_CableStart(thr.m_CableStart),
36  m_CableEnd(thr.m_CableEnd),
37  m_Clock(thr.m_Clock),
38  m_ThresholdNumber(thr.m_ThresholdNumber),
39  m_ZBSeedingThresholdName(thr.m_ZBSeedingThresholdName),
40  m_ZBSeedingThresholdMulti(thr.m_ZBSeedingThresholdMulti),
41  m_BCDelay(thr.m_BCDelay),
42  m_Bitnum(thr.m_Bitnum),
43  m_Input(thr.m_Input)
44 {
45  // deep copy of the threshold values
47  addThresholdValue( thrV->createCopy() );
48 }
49 
51  clearThresholdValues();
52 }
53 
54 
55 void
57  m_type = type;
59 }
60 
61 void
63  m_SType = type;
65 }
66 
67 
68 void
69 TrigConf::TriggerThreshold::setInput(const std::string& input) {
70  if(input!="ctpin" && input!="ctpcore")
71  throw runtime_error( "Threshold input must be either 'ctpin' or 'ctpcore' but value was '"+input+"'" );
72  m_Input = input;
73 }
74 
75 
76 bool
78  return L1DataDef::typeConfig(ttype()).internal;
79 }
80 
83 
84  TriggerThresholdValue* ttv=0;
85 
86  float eta = float(eta_i)+0.5;
87  float phi = float(phi_i)+0.5;
88 
89  for(TriggerThresholdValue* thrV : m_TriggerThresholdValueVector) {
90 
91  if( thrV->contains(eta, phi) ) {
92 
93  if( ttv != 0 && ttv->priority()==thrV->priority() ) {
94  cerr << "TriggerThreshold '" << name() << "' has overlapping values of same priority at eta = "
95  << eta << ", phi = " << phi << endl;
96  throw runtime_error( "Overlapping thresholdValues of the same priority" );
97  }
98  if( ttv==0 || ttv->priority()<thrV->priority() ) {
99  ttv = thrV;
100  }
101  }
102  }
103  if(ttv==0) {
104  cerr << "TriggerThreshold::triggerThresholdValue: did not find threshold value at eta = "
105  << eta << ", phi = " << phi << " for threshold " << name() << endl;
106  throw runtime_error( "Did not find threshold value" );
107  }
108  return ttv;
109 }
110 
111 
112 const
113 std::vector<TrigConf::TriggerThresholdValue*>&
115  return m_TriggerThresholdValueVector;
116 }
117 
118 void
120  m_TriggerThresholdValueVector.push_back(value);
121 }
122 
123 
126  TriggerThresholdValue *thrV = createThresholdValue(type);
127  addThresholdValue(thrV);
128  return thrV;
129 }
130 
131 
134  TriggerThresholdValue* ttv = 0;
136  ttv = new MuonThresholdValue();
137  } else if (type == L1DataDef::typeAsString(L1DataDef::EM) ||
139  ttv = new ClusterThresholdValue();
143  ttv = new JetThresholdValue();
144  } else if (type == L1DataDef::typeAsString(L1DataDef::XE) ||
147  ttv = new EtThresholdValue();
148  } else if ( type== L1DataDef::typeAsString(L1DataDef::XS) ) {
149  ttv = new XsThresholdValue();
160  ttv = new NimThresholdValue();
161  } else {
162  cout << "TriggerThreshold::createThresholdValue: ERROR Unknown trigger value type: " << type << endl;
163  throw std::runtime_error("TriggerThreshold::createThresholdValue: Unknown trigger value type.");
164  }
165  return ttv;
166 }
167 
168 
170  for(TriggerThresholdValue* thrV : m_TriggerThresholdValueVector)
171  delete thrV;
172  m_TriggerThresholdValueVector.clear();
173 }
174 
175 void TrigConf::TriggerThreshold::print(const std::string& indent, unsigned int detail) const {
176  if(detail==2) {
177  cout << indent << "TriggerThreshold " << name() << endl;
178  }
179  if(detail>=3) {
180  if(detail>=4)
181  cout << indent << "==================================" << endl;
182  cout << indent << "TriggerThreshold "; printNameIdV(indent);
183  if(detail>=4) {
184  cout << indent << " Type: " << type() << endl;
185  if(ttype()==L1DataDef::ZB) {
186  cout << indent << " seed: " << m_ZBSeedingThresholdName << endl;
187  cout << indent << " seed multi: " << m_ZBSeedingThresholdMulti << endl;
188  cout << indent << " BC delay: " << m_BCDelay << endl;
189  }
190  cout << indent << " active: " << m_Active << endl;
191  cout << indent << " mapping " << m_Mapping << endl;
192  cout << indent << " number of values: " << numberofValues() << endl;
193  cout << indent << " cable name: " << m_CableName << endl;
194  cout << indent << " cable ctpin: " << m_CableCtpin << endl;
195  cout << indent << " cable connector: " << m_CableConnector << endl;
196  cout << indent << " cable start: " << m_CableStart << endl;
197  cout << indent << " cable end: " << m_CableEnd << endl;
198  cout << indent << " threshold number: " << m_ThresholdNumber << endl;
199  for(unsigned int i=0; i < m_TriggerThresholdValueVector.size();i++)
200  m_TriggerThresholdValueVector[i]->print(indent + " ");
201  }
202  }
203 }
204 
205 
206 namespace {
207 
208  bool compThrValues(TrigConf::TriggerThresholdValue *x, TrigConf::TriggerThresholdValue *y) { // strict weak ordering: x and y are equivalent if compMon(x,y) and compMon(y,x) are false
209  if(x->priority() != y->priority())
210  return x->priority() < y->priority();
211  if(x->etamin() != y->etamin())
212  return x->etamin() < y->etamin();
213  return x->name() < y->name();
214  }
215 
216 }
217 
218 
219 void
220 TrigConf::TriggerThreshold::writeXML(std::ostream & xmlfile, int indentLevel, int indentWidth) const {
221  indent(xmlfile, indentLevel, indentWidth)
222  << "<TriggerThreshold active=\"" << m_Active
223  << "\" bitnum=\"" << bitnum()
224  << "\" id=\"" << id()
225  << "\" mapping=\"" << m_Mapping
226  << "\" name=\"" << name()
227  << "\" type=\"" << type()
228  << "\" input=\"" << input();
229 
230  if(ttype()==L1DataDef::ZB)
231  xmlfile << "\" seed=\"" << m_ZBSeedingThresholdName
232  << "\" seed_multi=\"" << m_ZBSeedingThresholdMulti
233  << "\" bcdelay=\"" << m_BCDelay;
234 
235  xmlfile << "\" version=\"" << version() <<"\">" << endl;
236 
237  auto sortedThresholdValues = m_TriggerThresholdValueVector;
238  sort(sortedThresholdValues.begin(),sortedThresholdValues.end(),compThrValues);
239 
240  for(TriggerThresholdValue* thrV : sortedThresholdValues)
241  thrV->writeXML(xmlfile, indentLevel+1, indentWidth);
242 
243  if(m_CableName!="") {
244  if(input()=="ctpin") {
245  indent(xmlfile, indentLevel+1, indentWidth)
246  << "<Cable connector=\"" << m_CableConnector << "\" input=\"" << m_CableCtpin << "\" name=\"" << m_CableName << "\">" << endl;
247  indent(xmlfile, indentLevel+2, indentWidth)
248  << "<Signal range_begin=\"" << m_CableStart << "\" range_end=\"" << m_CableEnd <<"\"/>" << endl;
249  } else {
250  indent(xmlfile, indentLevel+1, indentWidth)
251  << "<Cable connector=\"" << m_CableConnector << "\" input=\"" << m_CableCtpin << "\" name=\"" << m_CableName << "\">" << endl;
252  indent(xmlfile, indentLevel+2, indentWidth)
253  << "<Signal range_begin=\"" << m_CableStart << "\" range_end=\"" << m_CableEnd <<"\" clock=\"" << m_Clock << "\"/>" << endl;
254  }
255  indent(xmlfile, indentLevel+1, indentWidth) << "</Cable>" << endl;
256  }
257 
258  indent(xmlfile, indentLevel, indentWidth)
259  << "</TriggerThreshold>" << endl;
260 }
261 
TrigConf::TriggerThresholdValue
Definition: TriggerThresholdValue.h:22
TrigConf::L1DataDef::typeConfig
static TriggerTypeConfig & typeConfig(TriggerType tt)
Definition: L1DataDef.cxx:140
TrigConf::L1DataDef::LUCID
@ LUCID
Definition: L1DataDef.h:23
TrigConf::TriggerThreshold::setInput
void setInput(const std::string &input)
Definition: TriggerThreshold.cxx:69
TrigConf::L1DataDef::JE
@ JE
Definition: L1DataDef.h:21
TrigConf::L1DataDef::BPTX
@ BPTX
Definition: L1DataDef.h:24
TrigConf::NimThresholdValue
Definition: NimThresholdValue.h:11
TrigConf::TriggerThreshold::isInternal
bool isInternal() const
Definition: TriggerThreshold.cxx:77
TrigConf::L1DataDef::MBTSSI
@ MBTSSI
Definition: L1DataDef.h:23
TrigConf::L1DataDef::BCMCMB
@ BCMCMB
Definition: L1DataDef.h:24
TrigConf::L1DataDef::JF
@ JF
Definition: L1DataDef.h:21
TrigConf::L1DataDef::MUON
@ MUON
Definition: L1DataDef.h:20
TrigConf::TriggerThreshold::print
virtual void print(const std::string &indent="", unsigned int detail=1) const override
Definition: TriggerThreshold.cxx:175
TrigConf::TriggerThreshold::TriggerThreshold
TriggerThreshold()
Definition: TriggerThreshold.cxx:22
TrigConf::L1DataDef::ZDC
@ ZDC
Definition: L1DataDef.h:23
TrigConf::TriggerThreshold::thresholdValueVector
const std::vector< TriggerThresholdValue * > & thresholdValueVector() const
Definition: TriggerThreshold.cxx:114
athena.value
value
Definition: athena.py:124
TrigConf::XsThresholdValue
Definition: XsThresholdValue.h:11
detail
Definition: extract_histogram_tag.cxx:14
x
#define x
TrigConf::ClusterThresholdValue
Definition: ClusterThresholdValue.h:13
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:554
XsThresholdValue.h
TrigConf::TriggerThreshold::setType
void setType(L1DataDef::TriggerType type)
Definition: TriggerThreshold.cxx:56
TrigConf::L1DataDef::XE
@ XE
Definition: L1DataDef.h:22
MuonThresholdValue.h
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
TrigConf::L1DataDef::stringAsType
static TriggerType stringAsType(const std::string &type)
Definition: L1DataDef.h:51
geometry_dat_to_json.indent
indent
Definition: geometry_dat_to_json.py:37
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigConf::TriggerThreshold::addThresholdValue
void addThresholdValue(TriggerThresholdValue *value)
Definition: TriggerThreshold.cxx:119
TrigConf::L1DataDef::NIM
@ NIM
Definition: L1DataDef.h:23
CaloInfo.h
TrigConf::TriggerThreshold::writeXML
virtual void writeXML(std::ostream &xmlfile, int indentLevel=0, int indentWidth=2) const
Definition: TriggerThreshold.cxx:220
JetThresholdValue.h
TriggerThreshold.h
TrigConf::L1DataDef::MBTS
@ MBTS
Definition: L1DataDef.h:23
TriggerThresholdValue.h
TrigConf::MuonThresholdValue
Definition: MuonThresholdValue.h:11
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TrigConf::L1DataDef::BCM
@ BCM
Definition: L1DataDef.h:23
TrigConf::L1DataDef::TE
@ TE
Definition: L1DataDef.h:22
TrigConf::L1DataDef::typeAsString
static std::string & typeAsString(TriggerType tt)
Definition: L1DataDef.h:53
NimThresholdValue.h
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigConf::EtThresholdValue
Definition: EtThresholdValue.h:11
TrigConf::TriggerThreshold::triggerThresholdValue
TriggerThresholdValue * triggerThresholdValue(int eta, int phi) const
Definition: TriggerThreshold.cxx:82
TrigConf::TriggerThreshold::clearThresholdValues
void clearThresholdValues()
Definition: TriggerThreshold.cxx:169
TrigConf::TriggerThreshold::~TriggerThreshold
virtual ~TriggerThreshold() override
Definition: TriggerThreshold.cxx:50
L1DataDef.h
TrigConf::L1DataDef::JB
@ JB
Definition: L1DataDef.h:21
TrigConf::L1DataDef::JET
@ JET
Definition: L1DataDef.h:21
TrigConf::L1DataDef::CALREQ
@ CALREQ
Definition: L1DataDef.h:24
get_generator_info.version
version
Definition: get_generator_info.py:33
EtThresholdValue.h
TrigConf::L1DataDef::TAU
@ TAU
Definition: L1DataDef.h:20
TrigConf::L1DataDef::TriggerType
TriggerType
Definition: L1DataDef.h:19
y
#define y
ClusterThresholdValue.h
TrigConf::JetThresholdValue
Definition: JetThresholdValue.h:12
TrigConf::L1DataDef::XS
@ XS
Definition: L1DataDef.h:22
TrigConf::L1DataDef::TRT
@ TRT
Definition: L1DataDef.h:23
TrigConf::L1DataBaseclass
Definition: L1DataBaseclass.h:22
TrigConf::TriggerThresholdValue::priority
float priority() const
Definition: TriggerThresholdValue.h:46
TrigConf::L1DataDef::ZB
@ ZB
Definition: L1DataDef.h:24
TrigConf::TriggerThreshold
Definition: TriggerThreshold.h:20
TrigConf::L1DataDef::TriggerTypeConfig::internal
bool internal
Definition: L1DataDef.h:37
TrigConf::TriggerThreshold::createThresholdValue
static TriggerThresholdValue * createThresholdValue(const std::string &type)
Definition: TriggerThreshold.cxx:133
TrigConf::L1DataDef::EM
@ EM
Definition: L1DataDef.h:20
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65