ATLAS Offline Software
TriggerThreshold.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 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
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;
135  if (type == L1DataDef::muonType()) {
136  ttv = new MuonThresholdValue();
137  } else if (type == L1DataDef::emType() ||
138  type == L1DataDef::tauType()) {
139  ttv = new ClusterThresholdValue();
140  } else if (type == L1DataDef::jetType() ||
141  type == L1DataDef::jbType() ||
142  type == L1DataDef::jfType()) {
143  ttv = new JetThresholdValue();
144  } else if (type == L1DataDef::xeType() ||
145  type == L1DataDef::jeType() ||
146  type == L1DataDef::teType()) {
147  ttv = new EtThresholdValue();
148  } else if ( type== L1DataDef::xsType() ) {
149  ttv = new XsThresholdValue();
150  } else if (type == L1DataDef::nimType() || type == L1DataDef::mbtsType() || type == L1DataDef::mbtssiType() ||
151  type == L1DataDef::bcmType() || type == L1DataDef::bcmcmbType() || type == L1DataDef::lucidType() ||
152  type == L1DataDef::calreqType() || type == L1DataDef::zdcType() || type == L1DataDef::trtType() ||
153  type == L1DataDef::bptxType() ) {
154  ttv = new NimThresholdValue();
155  } else {
156  cout << "TriggerThreshold::createThresholdValue: ERROR Unknown trigger value type: " << type << endl;
157  throw std::runtime_error("TriggerThreshold::createThresholdValue: Unknown trigger value type.");
158  }
159  return ttv;
160 }
161 
162 
164  for(TriggerThresholdValue* thrV : m_TriggerThresholdValueVector)
165  delete thrV;
166  m_TriggerThresholdValueVector.clear();
167 }
168 
169 void TrigConf::TriggerThreshold::print(const std::string& indent, unsigned int detail) const {
170  if(detail==2) {
171  cout << indent << "TriggerThreshold " << name() << endl;
172  }
173  if(detail>=3) {
174  if(detail>=4)
175  cout << indent << "==================================" << endl;
176  cout << indent << "TriggerThreshold "; printNameIdV(indent);
177  if(detail>=4) {
178  cout << indent << " Type: " << type() << endl;
179  if(ttype()==L1DataDef::ZB) {
180  cout << indent << " seed: " << m_ZBSeedingThresholdName << endl;
181  cout << indent << " seed multi: " << m_ZBSeedingThresholdMulti << endl;
182  cout << indent << " BC delay: " << m_BCDelay << endl;
183  }
184  cout << indent << " active: " << m_Active << endl;
185  cout << indent << " mapping " << m_Mapping << endl;
186  cout << indent << " number of values: " << numberofValues() << endl;
187  cout << indent << " cable name: " << m_CableName << endl;
188  cout << indent << " cable ctpin: " << m_CableCtpin << endl;
189  cout << indent << " cable connector: " << m_CableConnector << endl;
190  cout << indent << " cable start: " << m_CableStart << endl;
191  cout << indent << " cable end: " << m_CableEnd << endl;
192  cout << indent << " threshold number: " << m_ThresholdNumber << endl;
193  for(unsigned int i=0; i < m_TriggerThresholdValueVector.size();i++)
194  m_TriggerThresholdValueVector[i]->print(indent + " ");
195  }
196  }
197 }
198 
199 
200 namespace {
201 
202  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
203  if(x->priority() != y->priority())
204  return x->priority() < y->priority();
205  if(x->etamin() != y->etamin())
206  return x->etamin() < y->etamin();
207  return x->name() < y->name();
208  }
209 
210 }
211 
212 
213 void
214 TrigConf::TriggerThreshold::writeXML(std::ostream & xmlfile, int indentLevel, int indentWidth) const {
215  indent(xmlfile, indentLevel, indentWidth)
216  << "<TriggerThreshold active=\"" << m_Active
217  << "\" bitnum=\"" << bitnum()
218  << "\" id=\"" << id()
219  << "\" mapping=\"" << m_Mapping
220  << "\" name=\"" << name()
221  << "\" type=\"" << type()
222  << "\" input=\"" << input();
223 
224  if(ttype()==L1DataDef::ZB)
225  xmlfile << "\" seed=\"" << m_ZBSeedingThresholdName
226  << "\" seed_multi=\"" << m_ZBSeedingThresholdMulti
227  << "\" bcdelay=\"" << m_BCDelay;
228 
229  xmlfile << "\" version=\"" << version() <<"\">" << endl;
230 
231  auto sortedThresholdValues = m_TriggerThresholdValueVector;
232  sort(sortedThresholdValues.begin(),sortedThresholdValues.end(),compThrValues);
233 
234  for(TriggerThresholdValue* thrV : sortedThresholdValues)
235  thrV->writeXML(xmlfile, indentLevel+1, indentWidth);
236 
237  if(m_CableName!="") {
238  if(input()=="ctpin") {
239  indent(xmlfile, indentLevel+1, indentWidth)
240  << "<Cable connector=\"" << m_CableConnector << "\" input=\"" << m_CableCtpin << "\" name=\"" << m_CableName << "\">" << endl;
241  indent(xmlfile, indentLevel+2, indentWidth)
242  << "<Signal range_begin=\"" << m_CableStart << "\" range_end=\"" << m_CableEnd <<"\"/>" << endl;
243  } else {
244  indent(xmlfile, indentLevel+1, indentWidth)
245  << "<Cable connector=\"" << m_CableConnector << "\" input=\"" << m_CableCtpin << "\" name=\"" << m_CableName << "\">" << endl;
246  indent(xmlfile, indentLevel+2, indentWidth)
247  << "<Signal range_begin=\"" << m_CableStart << "\" range_end=\"" << m_CableEnd <<"\" clock=\"" << m_Clock << "\"/>" << endl;
248  }
249  indent(xmlfile, indentLevel+1, indentWidth) << "</Cable>" << endl;
250  }
251 
252  indent(xmlfile, indentLevel, indentWidth)
253  << "</TriggerThreshold>" << endl;
254 }
255 
TrigConf::TriggerThresholdValue
Definition: TriggerThresholdValue.h:22
TrigConf::L1DataDef::typeConfig
static TriggerTypeConfig & typeConfig(TriggerType tt)
Definition: L1DataDef.cxx:145
TrigConf::TriggerThreshold::setInput
void setInput(const std::string &input)
Definition: TriggerThreshold.cxx:69
TrigConf::NimThresholdValue
Definition: NimThresholdValue.h:11
TrigConf::TriggerThreshold::isInternal
bool isInternal() const
Definition: TriggerThreshold.cxx:77
TrigConf::TriggerThreshold::print
virtual void print(const std::string &indent="", unsigned int detail=1) const override
Definition: TriggerThreshold.cxx:169
TrigConf::TriggerThreshold::TriggerThreshold
TriggerThreshold()
Definition: TriggerThreshold.cxx:22
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
TrigConf::L1DataDef::mbtssiType
static std::string mbtssiType()
Definition: L1DataDef.h:114
x
#define x
TrigConf::ClusterThresholdValue
Definition: ClusterThresholdValue.h:13
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
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:62
geometry_dat_to_json.indent
indent
Definition: geometry_dat_to_json.py:36
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigConf::TriggerThreshold::addThresholdValue
void addThresholdValue(TriggerThresholdValue *value)
Definition: TriggerThreshold.cxx:119
CaloInfo.h
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TrigConf::TriggerThreshold::writeXML
virtual void writeXML(std::ostream &xmlfile, int indentLevel=0, int indentWidth=2) const
Definition: TriggerThreshold.cxx:214
JetThresholdValue.h
TriggerThreshold.h
TriggerThresholdValue.h
TrigConf::MuonThresholdValue
Definition: MuonThresholdValue.h:11
TrigConf::L1DataDef::typeAsString
static std::string & typeAsString(TriggerType tt)
Definition: L1DataDef.h:64
NimThresholdValue.h
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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:163
TrigConf::TriggerThreshold::~TriggerThreshold
virtual ~TriggerThreshold() override
Definition: TriggerThreshold.cxx:50
L1DataDef.h
get_generator_info.version
version
Definition: get_generator_info.py:33
TrigConf::L1DataDef::bcmcmbType
static std::string bcmcmbType()
Definition: L1DataDef.h:113
EtThresholdValue.h
ConvertOldUJHistosToNewHistos.jetType
string jetType
Definition: ConvertOldUJHistosToNewHistos.py:121
TrigConf::L1DataDef::TriggerType
TriggerType
Definition: L1DataDef.h:30
y
#define y
ClusterThresholdValue.h
TrigConf::JetThresholdValue
Definition: JetThresholdValue.h:12
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigConf::L1DataDef::calreqType
static std::string calreqType()
Definition: L1DataDef.h:115
TrigConf::L1DataBaseclass
Definition: L1DataBaseclass.h:22
TrigConf::TriggerThresholdValue::priority
float priority() const
Definition: TriggerThresholdValue.h:46
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
TrigConf::L1DataDef::ZB
@ ZB
Definition: L1DataDef.h:35
TrigConf::TriggerThreshold
Definition: TriggerThreshold.h:20
TrigConf::L1DataDef::TriggerTypeConfig::internal
bool internal
Definition: L1DataDef.h:48
readCCLHist.float
float
Definition: readCCLHist.py:83
TrigConf::TriggerThreshold::createThresholdValue
static TriggerThresholdValue * createThresholdValue(const std::string &type)
Definition: TriggerThreshold.cxx:133