ATLAS Offline Software
Loading...
Searching...
No Matches
ThresholdConfig.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11#include <stdexcept>
12#include <iostream>
13#include <sys/types.h>
14#include <stdio.h>
15
16using namespace std;
17using namespace TrigConf;
18
21 m_ctpVersion( 0 ),
22 m_l1Version( 0 )
23{
24 // create a vector for each trigger type registered in L1DataDef.cxx
25 // size of vector is 0 and grows while being filled
26 for( L1DataDef::TypeConfigMap_t::value_type tc: L1DataDef::typeConfigs() )
27 m_thresholdVectors.insert( thrVecMap_t::value_type(tc.first , thrVec_t(0) ) );
28}
29
35
36const vector<TriggerThreshold*>&
38 thrVecMap_t::const_iterator res = m_thresholdVectors.find(type);
39 if(res == m_thresholdVectors.end()) {
40 cerr << "Unknown triggertype '" << L1DataDef::typeAsString(type) << "' in ThresholdConfig::getThresholdVector encountered" << endl;
41 throw std::runtime_error("Unknown triggertype in ThresholdConfig::getThresholdVector encountered" );
42 }
43 return res->second;
44}
45
46const std::vector<TrigConf::TriggerThreshold*>&
50
51
52bool
53TrigConf::ThresholdConfig::insertInPosition(std::vector<TriggerThreshold*>& thrVec, TriggerThreshold* thr, unsigned int pos) {
54 thr->print();
55
56 // extend if necessary (filled with 0)
57 if(pos >= thrVec.size()) thrVec.resize(pos+1, 0);
58
59 if(thrVec[pos] != 0) {
60 cerr << "ThresholdConfig::insertInPosition: position " << pos
61 << " already filled for type " << thr->type() << " [" << thr->ttype() << "]" << ", abort!!" << endl;
62 cerr << endl << "Existing threshold" << endl;
63 thrVec[pos]->print("",5);
64 cerr << endl << "New threshold" << endl;
65 thr->print("",5);
66 throw runtime_error("ThresholdConfig::insertInPosition position already filled" );
67 }
68 thrVec[pos] = thr;
69
70 return true;
71}
72
73
74bool
76
77 // put the threshold into the vector of all thresholds
78 m_TriggerThresholdVector.push_back(thr);
79
80 // put the threshold to the correct vector
81 L1DataDef::TriggerType ttype = thr->ttype();
82
83 const auto& res = m_thresholdVectors.find(ttype);
84 if(res == m_thresholdVectors.end()) {
85 cerr << "Unknown triggertype '" << L1DataDef::typeAsString(ttype) << "' in ThresholdConfig::getThresholdVector encountered" << endl;
86 throw runtime_error("Unknown triggertype in ThresholdConfig::getThresholdVector encountered" );
87 }
88 vector<TriggerThreshold*>& thrVec = res->second;
89
90 // check if maximum is exceeded
91 unsigned int max_thr = L1DataDef::typeConfig(ttype).max;
92 if(thr->mapping()>0 && (unsigned int)thr->mapping() >= max_thr) {
93 cerr << "ThresholdConfig::addTriggerThreshold: threshold mapping " << thr->mapping()
94 << " exceeds maximum for type '" << thr->type() << "' , abort!" << endl;
95 throw runtime_error( "ThresholdConfig::addTriggerThreshold: threshold mapping exceeds limit" );
96 }
97
98 thr->setThresholdNumber(thr->mapping());
99 insertInPosition(thrVec, thr, thr->mapping() );
100
101
102 // BPTX threshold is type NIM but gets inserted as BPTX as well (in run 2 not anymore) - no easy way to make this backward compatible
103// if(thr->name().find("BPTX")!=string::npos) {
104// string::size_type pos = thr->name().find_first_of("0123456789");
105// int mapping = boost::lexical_cast<int,string>(thr->name().substr(pos));
106// insertInPosition( thresholdVector(L1DataDef::BPTX), thr, mapping );
107// }
108
109 // for backward compatibility a copy of all EM and TAU thresholds
110 // is safed in the cluster threshold vector
111
112 if(l1Version()==0) {
113 if(ttype==L1DataDef::EM) {
114 insertInPosition( m_ClusterThresholdVector, thr, thr->mapping() );
115 }
116 if(ttype==L1DataDef::TAU) {
117 unsigned int max_em = L1DataDef::typeConfig(L1DataDef::EM).max;
118 unsigned int max_tau = 0; //L1DataDef::typeConfig(L1DataDef::TAU).max;
119 unsigned int pos = max_em + max_tau - thr->mapping() - 1;
121 }
122 }
123 return true;
124}
125
126
127
128string
130 TriggerThreshold* thr = getThresholdVector(L1DataDef::EM)[thresholdnumber];
131 return thr?thr->type():"EM";
132}
133
134
135/********************************
136 * cluster isolation and veto
137 ********************************/
138float TrigConf::ThresholdConfig::getClusterEmIsolation ( int eta, int phi, int thresholdnumber ) const {
139 ClusterThresholdValue* ctv = dynamic_cast<ClusterThresholdValue*>
140 (getThresholdVector(L1DataDef::EM)[thresholdnumber]->triggerThresholdValue(eta,phi));
141 return ctv?ctv->emIsolation():0;
142}
143
144float TrigConf::ThresholdConfig::getClusterHadIsolation ( int eta, int phi, int thresholdnumber ) const {
145 ClusterThresholdValue* ctv = dynamic_cast<ClusterThresholdValue*>
146 (getThresholdVector(L1DataDef::EM)[thresholdnumber]->triggerThresholdValue(eta,phi));
147 return ctv?ctv->hadIsolation():0;
148}
149
150float TrigConf::ThresholdConfig::getClusterHadVeto ( int eta, int phi, int thresholdnumber ) const {
151 ClusterThresholdValue* ctv = dynamic_cast<ClusterThresholdValue*>
152 (getThresholdVector(L1DataDef::EM)[thresholdnumber]->triggerThresholdValue(eta,phi));
153 return ctv?ctv->hadVeto():0;
154}
155
156
157/****************
158 * get window
159 ****************/
161 return getThresholdVector(type)[thresholdnumber]->triggerThresholdValue(eta,phi)->window();
162}
163
164int TrigConf::ThresholdConfig::getJetWindow( int eta, int phi, int thresholdnumber ) const {
165 return getThreshold(TrigConf::L1DataDef::JET, eta, phi, thresholdnumber);
166}
167
168int TrigConf::ThresholdConfig::getJfWindow( int eta, int phi, int thresholdnumber ) const {
169 return getThreshold(TrigConf::L1DataDef::JF, eta, phi, thresholdnumber);
170}
171
172int TrigConf::ThresholdConfig::getJbWindow( int eta, int phi, int thresholdnumber ) const {
173 return getThreshold(TrigConf::L1DataDef::JB, eta, phi, thresholdnumber);
174}
175
176
177
178/****************
179 * get ptcut()
180 ****************/
182 return getThresholdVector(type)[thresholdnumber]->triggerThresholdValue(eta,phi)->ptcut();
183}
184
185float TrigConf::ThresholdConfig::getClusterThreshold(int eta, int phi, int thresholdnumber) const {
186 return getThreshold(TrigConf::L1DataDef::EM, eta, phi, thresholdnumber);
187}
188
189float TrigConf::ThresholdConfig::getMuonThreshold( int eta, int phi, int thresholdnumber ) const {
190 return getThreshold(TrigConf::L1DataDef::MUON, eta, phi, thresholdnumber);
191}
192
193float TrigConf::ThresholdConfig::getJetEtThreshold( int eta, int phi, int thresholdnumber ) const {
194 return getThreshold(TrigConf::L1DataDef::JE, eta, phi, thresholdnumber);
195}
196
197float TrigConf::ThresholdConfig::getMissEtThreshold( int eta, int phi, int thresholdnumber ) const {
198 return getThreshold(TrigConf::L1DataDef::XE, eta, phi, thresholdnumber);
199}
200
201float TrigConf::ThresholdConfig::getMissEtSigThreshold( int eta, int phi, int thresholdnumber ) const {
202 return getThreshold(TrigConf::L1DataDef::XS, eta, phi, thresholdnumber);
203}
204
205float TrigConf::ThresholdConfig::getJetThreshold( int eta, int phi, int thresholdnumber ) const {
206 return getThreshold(TrigConf::L1DataDef::JET, eta, phi, thresholdnumber);
207}
208
209float TrigConf::ThresholdConfig::getJbThreshold(int eta, int phi, int thresholdnumber) const {
210 return getThreshold(TrigConf::L1DataDef::JB, eta, phi, thresholdnumber);
211}
212
213float TrigConf::ThresholdConfig::getJfThreshold ( int eta, int phi, int thresholdnumber ) const {
214 return getThreshold(TrigConf::L1DataDef::JF, eta, phi, thresholdnumber);
215}
216
217float TrigConf::ThresholdConfig::getTotEtThreshold( int eta, int phi, int thresholdnumber ) const {
218 return getThreshold(TrigConf::L1DataDef::TE, eta, phi, thresholdnumber);
219}
220
221
222
223void
225 // set the thresholdnumber for each threshold
226
227 // Run 2:
228 // this has been changed, the thresholdnumbers now correspond to the position in the vector (the index)
229
230 // Run 1:
231 // EM/TAU thresholds were an exception:
232
233 // The EM and TAU vector are related,
234 //
235 // the total number of EM and TAU thresholds is less than EM.max, the maximum number of
236 // tau thresholds is TAU.max
237 //
238 // the arrangement is such that the EM thresholds above 7 are after the TAU thresholds in reverse order
239
240 // for instance if there would be 6 TAU thresholds and 10 EM thresholds
241 // EM-TAU vector : [EM0,EM1,...,EM7,TAU0,TAU1,...,TAU5,EM9,EM8]
242 // thresholdNumber: [ 0, 1,..., 7, 8, 9,..., 13, 14, 15]
243
244
246 if(p==0) continue;
247 const unsigned int max_em = L1DataDef::typeConfig(L1DataDef::EM).max;
248
249 if ( p->mapping()>=8 )
250 p->setThresholdNumber(max_em - 1 - (p->mapping()-8) );
251 }
252
254 if(p==0) continue;
255 if( p->ttype()==L1DataDef::TAU )
256 p->setThresholdNumber(p->mapping() + 8);
257 }
258
259}
260
261
262
266 if(thr->id()==id) return thr;
267 return 0;
268}
269
270
272 const string& name, const string& indent, unsigned int detail) {
273 cout << indent << "=========================================" << endl
274 << indent << " The " << name << ": " << vec.size() << " elements" << endl
275 << indent << "=========================================" << endl;
277 if(thr) thr->print(indent + " ", detail);
278 else cout << indent << " " << 0 << endl;
279}
280
281void
282TrigConf::ThresholdConfig::print(const string& indent, unsigned int detail) const {
283 if(detail>=2) {
284 cout << indent << "Threshold configuration: " << getThresholdVector().size() << " thresholds" << endl;
286 cout << indent << " " << L1DataDef::typeConfig(tt).name << " thresholds: "
287 << getThresholdVector(tt).size() << " thresholds" << endl;
288 }
289 cout << "Threshold configuration: " << getThresholdVector().size() << " thresholds" << endl;
290 }
291 if(detail>=3) {
292 cout << indent << "=========================================" << endl
293 << indent << "== ThresholdConfig for MT_id = " << lvl1MasterTableId() << endl
294 << indent << "=========================================" << endl;
297 printVectorSummary(m_ClusterThresholdVector, "ClusterThresholdVector", indent, detail);
306 }
307 m_CaloInfo.print(indent, detail);
308}
309
310void
312 printVectorSummary(getThresholdVector(),"complete threshold vector", indent, 5);
313}
314
315
316
317void
319 cout << "#=========================================" << endl
320 << "# " << name << ":" << endl
321 << "#=========================================" << endl;
322 for(TriggerThreshold* thr: vec) printTtvMap(thr);
323}
324
325void
327 printTtvSummary(getThresholdVector(L1DataDef::EM), "EM threshold values");
328 printTtvSummary(getThresholdVector(L1DataDef::TAU), "Tau threshold values");
329 printTtvSummary(m_ClusterThresholdVector, "Cluster threshold values (EM + Tau)");
330 printTtvSummary(getThresholdVector(L1DataDef::JET), "JetThreshold values");
331 printTtvSummary(getThresholdVector(L1DataDef::FJET), "FJetThreshold values");
335 printTtvSummary(getThresholdVector(L1DataDef::MUON), "MuonThreshold values");
336 printTtvSummary(getThresholdVector(L1DataDef::NIM), "NimThreshold values");
337}
338
339
341 char line[1000];
342
343 cout << "#---------------------------------------------------------" << endl
344 << "# TTV(type,name) eta phi : pt window emIsol hadIsol hadVeto" << endl
345 << "# Number of theshold values: " << thr->thresholdValueVector().size() << endl
346 << "#---------------------------------------------------------" << endl;
347 for (int ieta = -49; ieta <= 49; ++ieta) {
348 for (int iphi = 0; iphi < 64; ++iphi) {
349 TriggerThresholdValue* ttv = thr->triggerThresholdValue(ieta, iphi);
350 float emiso(-1), hadiso(-1), hadveto(-1);
351 const ClusterThresholdValue* ctv = dynamic_cast<const ClusterThresholdValue*>(ttv);
352 if(ctv) {
353 emiso = ctv->emIsolation();
354 hadiso = ctv->hadIsolation();
355 hadveto = ctv->hadVeto();
356 }
357 sprintf(line, "TTV(%-4s,%-10s) eta[%2d] phi[%2d]: %3f %6u %6f %6f %6f",
358 thr->type().c_str(), thr->name().c_str(), ieta, iphi,
359 ttv->ptcut(), ttv->window(), emiso, hadiso, hadveto);
360 cout << line << endl;
361 }
362 }
363 return;
364}
365
366vector<TrigConf::TriggerThreshold*>
368 vector<TriggerThreshold*> v;
370 if ( thr->type() == type ) v.push_back(thr);
371 return v;
372}
373
374void
376
377 for(TriggerThreshold* thr: m_TriggerThresholdVector) delete thr;
379
380 for(thrVecMap_t::value_type & p: m_thresholdVectors)
381 p.second.clear();
382
383 m_CaloInfo.clear();
384}
385
386
387
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::vector< size_t > vec
std::pair< std::vector< unsigned int >, bool > res
static Double_t tc
CP::CorrectionCode getThreshold(Int_t &threshold, const std::string &trigger)
void printVectorSummary(const TrigConf::ThresholdConfig::thrVec_t &vec, const string &name, const string &indent, unsigned int detail)
unsigned int lvl1MasterTableId() const
static const TypeConfigMap_t & typeConfigs()
Definition L1DataDef.h:57
static TriggerTypeConfig & typeConfig(TriggerType tt)
static const std::vector< TriggerType > & types()
Definition L1DataDef.h:55
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
void printTtvMap(const TriggerThreshold *thr) const
int getWindow(L1DataDef::TriggerType type, int eta, int phi, int thresholdnumber) const
float getClusterHadIsolation(int eta, int phi, int thresholdnumber) const
const std::vector< TriggerThreshold * > & getThresholdVector(L1DataDef::TriggerType) const
int getJfWindow(int eta, int phi, int thresholdnumber) const
void printTtvSummary(const thrVec_t &vec, const std::string &name) const
float getTotEtThreshold(int eta, int phi, int thresholdnumber) const
float getJetThreshold(int eta, int phi, int thresholdnumber) const
void printTriggerThresholdVector(const std::string &indent="") const
int getJetWindow(int eta, int phi, int thresholdnumber) const
float getThreshold(L1DataDef::TriggerType type, int eta, int phi, int thresholdnumber) const
float getMissEtThreshold(int eta, int phi, int thresholdnumber) const
const std::vector< TriggerThreshold * > & thresholdVector() const
TriggerThreshold * findTriggerThreshold(unsigned int id)
std::vector< TriggerThreshold * > getNimThresholdVectorByType(const std::string &type) const
bool addTriggerThreshold(TriggerThreshold *value)
float getMuonThreshold(int eta, int phi, int thresholdnumber) const
int getJbWindow(int eta, int phi, int thresholdnumber) const
virtual ~ThresholdConfig() override
float getMissEtSigThreshold(int eta, int phi, int thresholdnumber) const
std::string getClusterThresholdType(int thresholdnumber) const
virtual void print(const std::string &indent="", unsigned int detail=1) const override
bool insertInPosition(std::vector< TriggerThreshold * > &thrVec, TriggerThreshold *tt, unsigned int pos)
float getJetEtThreshold(int eta, int phi, int thresholdnumber) const
float getJfThreshold(int eta, int phi, int thresholdnumber) const
float getClusterThreshold(int eta, int phi, int thresholdnumber) const
std::vector< TriggerThreshold * > thrVec_t
const std::vector< TriggerThreshold * > & getThresholdVector() const
const std::vector< TriggerThreshold * > & thresholdVector(L1DataDef::TriggerType) const
unsigned int l1Version() const
float getClusterEmIsolation(int eta, int phi, int thresholdnumber) const
float getJbThreshold(int eta, int phi, int thresholdnumber) const
float getClusterHadVeto(int eta, int phi, int thresholdnumber) const
std::ostream & indent(std::ostream &o, int lvl, int size) const
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
STL namespace.