ATLAS Offline Software
Macros | Functions
Run2toRun3ConvertersHLT.cxx File Reference
#include <numeric>
#include "TrigConfData/HLTMenu.h"
#include "TrigConfData/DataStructure.h"
#include "TrigCompositeUtils/HLTIdentifier.h"
#include <boost/property_tree/json_parser.hpp>
#include "TrigConfHLTData/HLTFrame.h"
#include "TrigConfHLTData/HLTChain.h"
#include "TrigConfHLTData/HLTStreamTag.h"
#include "TrigConfHLTData/HLTSignature.h"
#include "TrigConfHLTData/HLTTriggerElement.h"
#include "TrigCompositeUtils/ChainNameParser.h"
#include "TrigConfIO/JsonFileWriterHLT.h"

Go to the source code of this file.

Macros

#define BOOST_BIND_GLOBAL_PLACEHOLDERS
 

Functions

template<typename COLL >
boost::property_tree::ptree asArray (const COLL &data)
 
std::vector< int > legMult (const TrigConf::HLTChain *cptr)
 
std::vector< std::string > l1thresholds (const TrigConf::HLTFrame *frame, const TrigConf::HLTChain *cptr)
 
void printJSON (boost::property_tree::ptree &p)
 
bool convertHLTMenu (const TrigConf::HLTFrame *frame, TrigConf::HLTMenu &menu)
 
void convertRun2HLTMenuToRun3 (const TrigConf::HLTFrame *frame, const std::string &filename)
 
void convertRun2HLTPrescalesToRun3 (const TrigConf::HLTFrame *frame, const std::string &filename)
 

Macro Definition Documentation

◆ BOOST_BIND_GLOBAL_PLACEHOLDERS

#define BOOST_BIND_GLOBAL_PLACEHOLDERS

Definition at line 10 of file Run2toRun3ConvertersHLT.cxx.

Function Documentation

◆ asArray()

template<typename COLL >
boost::property_tree::ptree asArray ( const COLL &  data)

Definition at line 20 of file Run2toRun3ConvertersHLT.cxx.

20  {
22  ptree array;
23  for ( const auto& el: data ) {
24  ptree one;
25  one.put("", el);
26  array.push_back(std::make_pair("", one));
27  }
28  return array;
29 }

◆ convertHLTMenu()

bool convertHLTMenu ( const TrigConf::HLTFrame frame,
TrigConf::HLTMenu menu 
)

Definition at line 57 of file Run2toRun3ConvertersHLT.cxx.

57  {
59  ptree top;
60  top.put("filetype", "hltmenu");
61  top.put("name", frame->name());
62  ptree pChains;
63 
64  std::map<std::string, const TrigConf::HLTStreamTag*> allStreams;
65 
66  for ( auto cptr : frame->getHLTChainList() ) {
67  ptree pChain;
68  pChain.put("counter", cptr->chain_counter());
69  pChain.put("nameHash", cptr->chain_hash_id());
70  pChain.put("l1item", cptr->lower_chain_name());
71  pChain.add_child("l1thresholds", asArray(l1thresholds(frame, cptr)));
72  pChain.add_child("legMultiplicities", asArray(legMult(cptr)) );
73  pChain.add_child("sequencers", asArray(std::vector<std::string>({"missing"})));
74 
75  std::vector<std::string> strNames;
76  for ( const auto st: cptr->streams()) {
77  strNames.push_back(st->stream());
78  allStreams[st->stream()] = st;
79  }
80  pChain.add_child("streams", asArray(strNames));
81 
82  pChain.add_child("groups", asArray(cptr->groups()));
83 
84  // Signature data
85  // Note: This is run-2 only.
86  // It is propagated here to allow legacy trigger feature access.
87  std::vector<uint32_t> counters;
88  std::vector<int> logics;
89  std::vector<std::string> labels;
90  ptree outputTEs_outerArray; // outputTEs is a std::vector<std::vector<std::string>>
91 
92  for(auto& signature : cptr->signatureList() ){
93  uint32_t cntr = signature->signature_counter();
94  counters.push_back(cntr);
95  logics.push_back(signature->logic());
96  labels.push_back(signature->label());
97  ptree outputTEs_innerArray;
98  for(auto& outputTE : signature->outputTEs()){
99  outputTEs_innerArray.push_back( ptree::value_type("", outputTE->name()) );
100  }
101  outputTEs_outerArray.push_back( ptree::value_type("", outputTEs_innerArray) );
102  }
103 
104  ptree pSig;
105  pSig.add_child("counters", asArray(counters));
106  pSig.add_child("logics", asArray(logics));
107  pSig.add_child("outputTEs", outputTEs_outerArray);
108  pSig.add_child("labels", asArray(labels));
109 
110  pChain.add_child("signature", pSig);
111  // End of signature data
112 
113  pChains.push_back(std::make_pair(cptr->chain_name(), pChain));
114  }
115  ptree pStreams;
116  for ( auto [sname, stream]: allStreams ) {
117  ptree pStream;
118  pStream.put("name", sname);
119  pStream.put("type", stream->type());
120  pStream.put("obeyLB", stream->obeyLB());
121  pStream.put("forceFullEventBuilding", true); // TODO understand how to get this information from old menu
122  pStreams.push_back(std::make_pair(sname, pStream));
123  }
124 
125  top.add_child("chains", pChains);
126 
127  top.add_child("streams", pStreams);
128  ptree pSequencers;
129  pSequencers.add_child("missing", asArray(std::vector<std::string>({""})));
130  top.add_child("sequencers", pSequencers);
131 
132  // Set run2 sequence information:
133  const TrigConf::HLTSequenceList& sequenceList = frame->getHLTSequenceList();
134  std::vector<std::string> outputTEs;
135  ptree inputTEs_outerArray; // sequenceInputTEs is a std::vector<std::vector<std::string>>
136  ptree algorithms_outerArray; // sequenceAlgorithms is a std::vector<std::vector<std::string>>
137  for(auto& seq : sequenceList){
138  outputTEs.push_back(seq->outputTE()->name());
139 
140  ptree inputTEs_innerArray;
141  for(auto& input : seq->inputTEs()) {
142  inputTEs_innerArray.push_back( ptree::value_type("", input->name()) );
143  }
144  inputTEs_outerArray.push_back( ptree::value_type("", inputTEs_innerArray) );
145 
146  ptree algorithms_innerArray;
147  for(const std::string& alg : seq->algorithms()) {
148  algorithms_innerArray.push_back( ptree::value_type("", alg) );
149  }
150  algorithms_outerArray.push_back( ptree::value_type("", algorithms_innerArray) );
151  }
152  ptree pSequence;
153  pSequence.add_child("outputTEs", asArray(outputTEs));
154  pSequence.add_child("inputTEs", inputTEs_outerArray);
155  pSequence.add_child("algorithms", algorithms_outerArray);
156  top.add_child("sequence_run2", pSequence);
157 
158  menu.setData(std::move(top));
159  menu.setSMK(frame->smk());
160  return true;
161 }

◆ convertRun2HLTMenuToRun3()

void convertRun2HLTMenuToRun3 ( const TrigConf::HLTFrame frame,
const std::string &  filename 
)

Definition at line 163 of file Run2toRun3ConvertersHLT.cxx.

163  {
165  convertHLTMenu(frame, menu);
166 
168  writer.writeJsonFile(filename, menu);
169 
170 }

◆ convertRun2HLTPrescalesToRun3()

void convertRun2HLTPrescalesToRun3 ( const TrigConf::HLTFrame frame,
const std::string &  filename 
)

Definition at line 172 of file Run2toRun3ConvertersHLT.cxx.

172  {
174  ptree top;
175  top.put("filetype", "hltprescale");
176  top.put("name", frame->name());
177  ptree pChains;
178  for ( auto cptr : frame->getHLTChainList() ) {
179  ptree pChain;
180  pChain.put("name", cptr->chain_name());
181  pChain.put("counter", cptr->chain_counter());
182  pChain.put("hash", cptr->chain_hash_id());
183  pChain.put("prescale", cptr->prescale());
184  pChain.put("enabled", (cptr->prescale()>0 ? true: false));
185 
186  pChains.push_back(std::make_pair(cptr->chain_name(), pChain));
187  }
188  top.add_child("prescales", pChains);
189  TrigConf::HLTPrescalesSet psk(std::move(top));
190 
192  convertHLTMenu(frame, menu);
193 
195  writer.writeJsonFile(filename, menu, psk);
196 }

◆ l1thresholds()

std::vector<std::string> l1thresholds ( const TrigConf::HLTFrame frame,
const TrigConf::HLTChain cptr 
)

Definition at line 35 of file Run2toRun3ConvertersHLT.cxx.

35  {
36  std::set<std::string> names;
37  for ( const auto sig: cptr->signatures() ) {
38  for ( const auto te: sig->outputTEs() ) {
39  auto sequence = frame->getHLTSequenceList().getSequence(te->name());
40  for ( const auto inTE: sequence->inputTEs() ) {
41  if ( not ( inTE->name().find("L2_") == 0 or inTE->name().find("EF_") == 0 or inTE->name().find("HLT_") == 0 ) ) {
42  names.insert(inTE->name());
43  }
44  }
45  }
46  }
47  return std::vector<std::string>( names.begin(), names.end() );
48 }

◆ legMult()

std::vector<int> legMult ( const TrigConf::HLTChain cptr)

Definition at line 31 of file Run2toRun3ConvertersHLT.cxx.

31  {
33 }

◆ printJSON()

void printJSON ( boost::property_tree::ptree p)

Definition at line 50 of file Run2toRun3ConvertersHLT.cxx.

50  {
51  // this code is useful to debug JSON before it is pushed to menu objects expecting certain structure in place
52  std::stringstream ss;
53  boost::property_tree::json_parser::write_json(ss, p);
54  std::cout << ss.str() << std::endl;
55 }
test_athena_ntuple_filter.seq
seq
filter configuration ## -> we use the special sequence 'AthMasterSeq' which is run before any other a...
Definition: test_athena_ntuple_filter.py:18
TrigConf::JsonFileWriterHLT
Loader of trigger configurations from Json files.
Definition: JsonFileWriterHLT.h:22
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
TrigConf::TrigConfData::name
const std::string & name() const
Definition: TrigConfData.h:22
SGout2dot.alg
alg
Definition: SGout2dot.py:243
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
TrigConf::HLTMenu
HLT menu configuration.
Definition: HLTMenu.h:21
TrigConf::HLTChain::chain_name
const std::string & chain_name() const
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:72
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
convertHLTMenu
bool convertHLTMenu(const TrigConf::HLTFrame *frame, TrigConf::HLTMenu &menu)
Definition: Run2toRun3ConvertersHLT.cxx:57
TrigConf::HLTSequenceList::getSequence
HLTSequence * getSequence(unsigned int id) const
counts the number of sequences in the menu
Definition: HLTSequenceList.cxx:45
python.TriggerConfig.menu
menu
Definition: TriggerConfig.py:836
Trk::one
@ one
Definition: TrkDetDescr/TrkSurfaces/TrkSurfaces/RealQuadraticEquation.h:22
TrigConf::HLTChain::signatures
const std::vector< HLTSignature * > & signatures() const
Definition: TrigConfHLTData/TrigConfHLTData/HLTChain.h:109
TrigConf::HLTFrame::getHLTSequenceList
const HLTSequenceList & getHLTSequenceList() const
const accessor to the list of HLT sequences
Definition: HLTFrame.h:50
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
menu
make the sidebar many part of the config
Definition: hcg.cxx:551
beamspotnt.labels
list labels
Definition: bin/beamspotnt.py:1447
legMult
std::vector< int > legMult(const TrigConf::HLTChain *cptr)
Definition: Run2toRun3ConvertersHLT.cxx:31
python.subdetectors.mmg.names
names
Definition: mmg.py:8
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
python.BuildSignatureFlags.sig
sig
Definition: BuildSignatureFlags.py:215
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
asArray
boost::property_tree::ptree asArray(const COLL &data)
Definition: Run2toRun3ConvertersHLT.cxx:20
lumiFormat.array
array
Definition: lumiFormat.py:98
TrigConf::TrigConfData::smk
unsigned int smk() const
Definition: TrigConfData.h:20
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
ChainNameParser::multiplicities
std::vector< int > multiplicities(const std::string &chain)
Definition: ChainNameParser.cxx:202
TrigConf::HLTFrame::getHLTChainList
const HLTChainList & getHLTChainList() const
const accessor to the list of HLT chains
Definition: HLTFrame.h:49
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
top
@ top
Definition: TruthClasses.h:64
l1thresholds
std::vector< std::string > l1thresholds(const TrigConf::HLTFrame *frame, const TrigConf::HLTChain *cptr)
Definition: Run2toRun3ConvertersHLT.cxx:35
TrigConf::HLTPrescalesSet
HLT menu configuration.
Definition: HLTPrescalesSet.h:19
example.writer
writer
show summary of content
Definition: example.py:36
TrigConf::HLTSequenceList
list of HLT sequences
Definition: HLTSequenceList.h:40