ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
TrigConf::JsonFileWriterHLT Class Reference

Loader of trigger configurations from Json files. More...

#include <JsonFileWriterHLT.h>

Inheritance diagram for TrigConf::JsonFileWriterHLT:
Collaboration diagram for TrigConf::JsonFileWriterHLT:

Public Member Functions

 JsonFileWriterHLT ()
 Constructor. More...
 
virtual ~JsonFileWriterHLT () override=default
 Destructor. More...
 
bool writeJsonFile (const std::string &filename, const HLTMenu &menu) const
 
bool writeJsonFile (const std::string &filename, const HLTMenu &menu, const HLTPrescalesSet &ps) const
 
bool msgLvl (const MSGTC::Level lvl) const
 Test the output level. More...
 
MsgStreamTCmsg () const
 The standard message stream. More...
 
MsgStreamTCmsg (const MSGTC::Level lvl) const
 The standard message stream. More...
 

Private Attributes

boost::thread_specific_ptr< MsgStreamTCm_msg_tls
 MsgStreamTC instance (a std::cout like with print-out levels) More...
 
std::string m_name
 

Detailed Description

Loader of trigger configurations from Json files.

Definition at line 23 of file JsonFileWriterHLT.h.

Constructor & Destructor Documentation

◆ JsonFileWriterHLT()

TrigConf::JsonFileWriterHLT::JsonFileWriterHLT ( )

Constructor.

Definition at line 17 of file JsonFileWriterHLT.cxx.

17  :
18  TrigConfMessaging( "JsonFileWriterHLT")
19 {}

◆ ~JsonFileWriterHLT()

virtual TrigConf::JsonFileWriterHLT::~JsonFileWriterHLT ( )
overridevirtualdefault

Destructor.

Member Function Documentation

◆ msg() [1/2]

MsgStreamTC & TrigConf::TrigConfMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 81 of file TrigConfMessaging.h.

82  {
83  MsgStreamTC* ms = m_msg_tls.get();
84  if (!ms) {
85  ms = new MsgStreamTC(m_name);
86  m_msg_tls.reset(ms);
87  }
88  return *ms;
89  }

◆ msg() [2/2]

MsgStreamTC & TrigConf::TrigConfMessaging::msg ( const MSGTC::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 91 of file TrigConfMessaging.h.

92  {
93  return msg() << lvl;
94  }

◆ msgLvl()

bool TrigConf::TrigConfMessaging::msgLvl ( const MSGTC::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 70 of file TrigConfMessaging.h.

71  {
72  if (msg().level() <= lvl) {
73  msg() << lvl;
74  return true;
75  }
76  else {
77  return false;
78  }
79  }

◆ writeJsonFile() [1/2]

bool TrigConf::JsonFileWriterHLT::writeJsonFile ( const std::string &  filename,
const HLTMenu menu 
) const

Definition at line 49 of file JsonFileWriterHLT.cxx.

50 {
51  json chains({});
52  for ( const auto & chain : menu ) {
53  json jChain({});
54  jChain["counter"] = chain.counter();
55  jChain["nameHash"] = chain.namehash();
56  jChain["l1item"] = chain.l1item();
57  jChain["legMultiplicities"] = chain.legMultiplicities();
58  jChain["l1thresholds"] = chain.l1thresholds();
59  jChain["groups"] = chain.groups();
60  jChain["streams"] = chain.streams();
61  jChain["seqeuncers"] = chain.sequencers();
62 
63  // Optional Run2 payload
64  if (chain.hasChild("signature")) {
65  json jSig({});
66  jSig["counters"] = ToVector<uint32_t>(chain, "signature.counters");
67  jSig["logics"] = ToVector<int>(chain, "signature.logics");
68  jSig["labels"] = ToVector<std::string>(chain, "signature.labels");
69  jSig["outputTEs"] = ToVectorVector<std::string>(chain, "signature.outputTEs");
70  jChain["signature"] = std::move(jSig);
71  }
72 
73  chains[chain.name()] = std::move(jChain);
74  }
75 
76  json sequencers({});
77  for ( const auto& [seqName, algsList]: menu.sequencers() ) {
78  json jSeq( algsList );
79  sequencers[seqName] = std::move(jSeq);
80  }
81  json streams({});
82  for ( const auto& stream: menu.streams() ) {
83  json jStream({});
84  jStream["name"] = stream["name"];
85  jStream["type"] = stream["type"];
86  jStream["obeyLB"] = stream.getAttribute<bool>("obeyLB");
87  jStream["forceFullEventBuilding"] = stream.getAttribute<bool>("forceFullEventBuilding");
88  streams[stream["name"]] = std::move(jStream);
89  }
90 
91 
92  json j({});
93  j["filetype"] = "hltmenu";
94  j["name"] = menu.name();
95  j["chains"] = std::move(chains);
96  j["sequencers"] = std::move(sequencers);
97  j["streams"] = std::move(streams);
98 
99  // Optional Run2 payload
100  if (menu.hasChild("sequence_run2")) {
101  json jSequence({});
102  jSequence["outputTEs"] = ToVector<std::string>(menu, "sequence_run2.outputTEs");
103  jSequence["inputTEs"] = ToVectorVector<std::string>(menu, "sequence_run2.inputTEs");
104  jSequence["algorithms"] = ToVectorVector<std::string>(menu, "sequence_run2.algorithms");
105  j["sequence_run2"] = std::move(jSequence);
106  }
107 
108  std::ofstream outfile(filename);
109  outfile << std::setw(4) << j << std::endl;
110 
111  TRG_MSG_INFO("Saved file " << filename);
112  return true;
113 }

◆ writeJsonFile() [2/2]

bool TrigConf::JsonFileWriterHLT::writeJsonFile ( const std::string &  filename,
const HLTMenu menu,
const HLTPrescalesSet ps 
) const

Definition at line 115 of file JsonFileWriterHLT.cxx.

116 {
117  json chains({});
118  for ( const auto & chain : menu ) {
119  json jChain({});
120  jChain["name"] = chain.name();
121  jChain["counter"] = chain.counter();
122  jChain["hash"] = chain.namehash();
123  jChain["prescale"] = ps.prescale(chain.name()).prescale;
124  jChain["enabled"] = ps.prescale(chain.name()).enabled;
125  chains[chain.name()] = std::move(jChain);
126  }
127  json j({});
128  j["filetype"] = "hltprescale";
129  j["name"] = ps.name();
130  j["prescales"] = std::move(chains);
131  std::ofstream outfile(filename);
132  outfile << std::setw(4) << j << std::endl;
133 
134  TRG_MSG_INFO("Saved file " << filename);
135  return true;
136 }

Member Data Documentation

◆ m_msg_tls

boost::thread_specific_ptr<MsgStreamTC> TrigConf::TrigConfMessaging::m_msg_tls
mutableprivateinherited

MsgStreamTC instance (a std::cout like with print-out levels)

Definition at line 66 of file TrigConfMessaging.h.

◆ m_name

std::string TrigConf::TrigConfMessaging::m_name
privateinherited

Definition at line 67 of file TrigConfMessaging.h.


The documentation for this class was generated from the following files:
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
TrigConf::TrigConfMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStreamTC > m_msg_tls
MsgStreamTC instance (a std::cout like with print-out levels)
Definition: TrigConfMessaging.h:66
json
nlohmann::json json
Definition: HistogramDef.cxx:9
python.outputTest_v2.streams
streams
Definition: outputTest_v2.py:55
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
menu
make the sidebar many part of the config
Definition: hcg.cxx:551
TrigConf::TrigConfMessaging::m_name
std::string m_name
Definition: TrigConfMessaging.h:67
TrigConf::TrigConfMessaging::msg
MsgStreamTC & msg() const
The standard message stream.
Definition: TrigConfMessaging.h:81
TrigConf::TrigConfMessaging::TrigConfMessaging
TrigConfMessaging()=delete
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
python.copyTCTOutput.chains
chains
Definition: copyTCTOutput.py:81
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42