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 22 of file JsonFileWriterHLT.h.

Constructor & Destructor Documentation

◆ JsonFileWriterHLT()

TrigConf::JsonFileWriterHLT::JsonFileWriterHLT ( )

Constructor.

Definition at line 16 of file JsonFileWriterHLT.cxx.

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

◆ ~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 48 of file JsonFileWriterHLT.cxx.

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

◆ writeJsonFile() [2/2]

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

Definition at line 114 of file JsonFileWriterHLT.cxx.

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

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