ATLAS Offline Software
HLTChainList.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 
13 #include "TrigConfL1Data/Menu.h"
14 
15 #include <iostream>
16 #include <algorithm>
17 #include <iterator>
18 
19 using namespace std;
20 
22 {}
23 
24 
25 TrigConf::HLTChainList::HLTChainList( const vector<HLTChain*>& chainList ) {
26  copy(chainList.begin(), chainList.end(), std::inserter(*this, begin()));
27 }
28 
29 
31  clear();
32 }
33 
35  for(HLTChain* ch : *this) {
36  delete ch;
37  }
39 }
40 
41 bool
43  pair<iterator, bool> ins = insert(chain);
44  if(!ins.second)
45  throw runtime_error("Can't insert chain '" + chain->name() + "', because a uniqueness constraint is violated");
46  return ins.second;
47 }
48 
49 
50 
52 TrigConf::HLTChainList::chain( const std::string& name ) const {
53  const index<name_hash>::type& byname = get<name_hash>();
54  index<name_hash>::type::const_iterator ch = byname.find(name);
55  if(ch == byname.end()) return 0;
56  return *ch;
57 }
58 
59 
61 TrigConf::HLTChainList::chain( unsigned int chaincounter, HLTLevel level ) const {
62  const index<counter>::type& bycounter = get<counter>();
63  index<counter>::type::const_iterator ch = bycounter.find(boost::make_tuple(chaincounter,level));
64  if(ch == bycounter.end()) return 0;
65  return *ch;
66 }
67 
68 
69 void
71  for(HLTChain *ch: *this) {
72  if(ch->level_enum() == HLTLevel::HLT ) {
73  // merged menu
74  if (pss->hasPrescale( ch->chain_counter(), HLTLevel::HLT ) ) {
75  // merged prescales (Run 2)
76  const HLTPrescale& sc = pss->getPrescale( ch->chain_counter(), HLTLevel::HLT );
77  ch->set_prescales( sc );
78  } else {
79  // prescale set has not been merged yet (LS 1)
80  if(ch->mergeCounter.l2==0 && ch->mergeCounter.ef==0) {
81  throw runtime_error("Merged HLT chain has no info about L2 or EF counter");
82  } else if(ch->mergeCounter.l2==0) {
83  const HLTPrescale& efps = pss->getPrescale( ch->mergeCounter.ef, HLTLevel::EF );
84  ch->set_prescales( efps );
85  } else if(ch->mergeCounter.ef==0) {
86  const HLTPrescale& l2ps = pss->getPrescale( ch->mergeCounter.ef, HLTLevel::L2 );
87  ch->set_prescales( l2ps );
88  } else {
89  const HLTPrescale& l2ps = pss->getPrescale( ch->mergeCounter.l2, HLTLevel::L2 );
90  const HLTPrescale& efps = pss->getPrescale( ch->mergeCounter.ef, HLTLevel::EF );
91  HLTTEUtils::mergeL2EFPrescales( ch, l2ps, efps);
92  }
93  }
94  } else {
95  // menu not merged
96  const HLTPrescale& sc = pss->getPrescale( ch->chain_counter(), str2lvl(ch->level()) );
97  ch->set_prescales( sc );
98  }
99  }
100 }
101 
102 
105  HLTPrescaleSet* pss = new HLTPrescaleSet();
106  for(HLTChain *ch : *this)
107  pss->setPrescale(ch->prescales(), ch->chain_counter(), ch->level_enum());
108  return pss;
109 }
110 
111 
112 
113 //________________________________________________________________________________
114 void
116  if(ctpcfg==0)
117  throw runtime_error("setL2LowerChainCounter: no CTPConfig object available");
118 
119  const TrigConf::Menu& menu = ctpcfg->menu();
120 
121  std::map<std::string,int> ctpFromName;
122  for(const TriggerItem* item : menu.itemVector())
123  ctpFromName[item->name()] = item->ctpId();
124 
125  for(HLTChain* ch : *this) {
126  if(ch->level() == "EF") continue;
127  std::string low_chain_names = ch->lower_chain_name();
128  TrigConf::removeAllSpaces(low_chain_names);
129  vector<string> low_chain_names_V = split(low_chain_names,",");
130  std::vector<int> lccs;
131  for(string lowerChainName : low_chain_names_V)
132  lccs.push_back(ctpFromName[lowerChainName]);
133  ch->set_lower_chain_counter(low_chain_names_V.size()==1 ? lccs[0] : -1);
134  ch->set_lower_chain_counters(lccs);
135  }
136 }
137 
138 
139 // fill the lower chain counter for all EF chains
140 void
142  for(HLTChain *ch : *this) {
143  if(ch->level()!="EF" || ch->lower_chain_name()=="") continue;
144  HLTChain * l2ch = chain(ch->lower_chain_name());
145  if(l2ch==0) {
146  cerr << "ERROR: Did not find lower chain name '" << ch->lower_chain_name() << "' for chain '" << ch->chain_name() << "'" << endl;
147  continue;
148  }
149  ch->set_lower_chain_counter( l2ch->chain_counter() );
150  }
151 }
152 
155  DiffStruct * ds = new DiffStruct("CHAIN_LIST");
156  for(HLTChain* ch : *this) {
157  HLTChain *o_ch = o->chain(ch->name());
158  if(o_ch) {
159  ds->addSub( ch->compareTo(o_ch) );
160  } else {
161  ds->addLeftOnlySub( "CHAIN", ch->name() );
162  }
163  }
164  for(HLTChain* o_ch : *o) {
165  const HLTChain *ch = chain(o_ch->name());
166  if(!ch)
167  ds->addRightOnlySub( "CHAIN", o_ch->name() );
168  }
169  if(ds->empty()) {
170  delete ds; ds=0;
171  }
172  return ds;
173 }
174 
175 
176 void
177 TrigConf::HLTChainList::print(const std::string& indent, unsigned int detail) const {
178  if(detail>=1) {
179  cout << indent << "HLTChainList has " << size() << " chains" << endl;
180  if(detail>=2) {
181  for(HLTChain* ch : *this)
182  ch->print(indent + " ", detail);
183  cout << indent << "- ---------------------------------------------------------- " << endl;
184  }
185  }
186 }
187 
188 
189 std::ostream &
190 TrigConf::operator<<(std::ostream & o, const TrigConf::HLTChainList & cl) {
191  o << "- -- HLTChainList [" << cl.size() << " chains] -------------------------------- " << std::endl;
192  for(TrigConf::HLTChain* ch : cl)
193  o << *ch;
194  o << "- ---------------------------------------------------------- " << std::endl;
195  return o;
196 }
197 
TrigConf::HLTPrescale
Definition: HLTPrescale.h:26
CTPConfig.h
checkxAOD.ds
ds
Definition: Tools/PyUtils/bin/checkxAOD.py:257
Trk::L2
@ L2
Definition: AlignModuleList.h:32
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
TrigConf::operator<<
std::ostream & operator<<(std::ostream &os, const TrigConf::IsolationLegacy &iso)
Definition: L1ThresholdBase.cxx:339
HLTChainList.h
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
TrigConf::HLTChainList::compareTo
DiffStruct * compareTo(const HLTChainList *o) const
Definition: HLTChainList.cxx:154
TrigConf::HLTPrescaleSet::hasPrescale
bool hasPrescale(unsigned int counter, TrigConf::HLTLevel level=HLT) const
Definition: HLTPrescaleSet.cxx:35
HLTChain.h
TrigConf::DiffStruct
Definition: DiffStruct.h:14
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
detail
Definition: extract_histogram_tag.cxx:14
Menu.h
TrigConf::HLTPrescaleSet::setPrescale
HLTPrescale & setPrescale(const HLTPrescale &sc, unsigned int chain_counter, HLTLevel level=HLT)
Definition: HLTPrescaleSet.cxx:22
TRT_PAI_gasdata::EF
const float EF[NF]
Energy levels for Fluor.
Definition: TRT_PAI_gasdata.h:271
DiffStruct.h
TrigConf::HLTChain
HLT chain configuration information.
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:35
TrigConf::str2lvl
HLTLevel str2lvl(const std::string &level)
Definition: HLTLevel.h:14
HelperFunctions.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TrigConf::HLT
@ HLT
Definition: HLTLevel.h:12
HLTUtils.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TrigConf::HLTChain::chain_counter
int chain_counter() const
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:73
menu
make the sidebar many part of the config
Definition: hcg.cxx:551
TrigConf::Menu
Definition: Menu.h:49
TrigConf::HLTChainList::print
void print(const std::string &indent="", unsigned int detail=1) const
accessors to list of chains, for backward compatibility, use HLTChainList directly
Definition: HLTChainList.cxx:177
geometry_dat_to_json.indent
indent
Definition: geometry_dat_to_json.py:18
TrigConf::HLTChainList
list of all HLT chains in a trigger menu
Definition: HLTChainList.h:56
TrigConf::HLTChainList::chain
HLTChain * chain(const std::string &chainname) const
access the chain by name returns null-pointer if chain not found
Definition: HLTChainList.cxx:52
TrigConf::HLTPrescaleSet::getPrescale
const HLTPrescale & getPrescale(unsigned int chain_counter, HLTLevel level=HLT) const
Definition: HLTPrescaleSet.cxx:42
TrigConf::HLTChainList::~HLTChainList
~HLTChainList()
default destructor
Definition: HLTChainList.cxx:30
TrigConf::HLTLevel
HLTLevel
Definition: HLTLevel.h:12
TrigConf::HLTChainList::extractPrescaleSet
HLTPrescaleSet * extractPrescaleSet() const
extract prescales from all chains
Definition: HLTChainList.cxx:104
TrigConf::HLTPrescaleSet
HLT chain configuration information.
Definition: HLTPrescaleSet.h:31
TrigConf::HLTChainList::addHLTChain
bool addHLTChain(HLTChain *ch)
adds an HLTChain to the menu
Definition: HLTChainList.cxx:42
TrigConf::name
Definition: HLTChainList.h:35
TrigConf::HLTChainList::applyPrescaleSet
void applyPrescaleSet(const HLTPrescaleSet *pss)
set prescales of all chains
Definition: HLTChainList.cxx:70
TrigConf::HLTChainList::HLTChainList
HLTChainList()
default constructor
Definition: HLTChainList.cxx:21
TrigConf::HLTChainList::setEFLowerChainCounter
void setEFLowerChainCounter()
Definition: HLTChainList.cxx:141
TrigConf::HLTChainList::clear
void clear()
Definition: HLTChainList.cxx:34
item
Definition: ItemListSvc.h:43
TrigConf::HLTChainList::setL2LowerChainCounter
void setL2LowerChainCounter(const CTPConfig *ctpcfg)
Definition: HLTChainList.cxx:115
HLTPrescaleSet.h
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
TrigConf::CTPConfig::menu
const Menu & menu() const
Definition: CTPConfig.h:38
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigConf::CTPConfig
Definition: CTPConfig.h:27
calibdata.copy
bool copy
Definition: calibdata.py:27
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
TrigConf::TriggerItem
Definition: TriggerItem.h:25
TrigConf::removeAllSpaces
void removeAllSpaces(std::string &)
Definition: Trigger/TrigConfiguration/TrigConfL1Data/Root/HelperFunctions.cxx:40