|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #define BOOST_BIND_GLOBAL_PLACEHOLDERS // silence Boost pragma message (fixed in Boost 1.76)
6 #include <boost/property_tree/json_parser.hpp>
8 #include "GaudiKernel/ThreadLocalContext.h"
28 m_metadataTree(nullptr),
48 ATH_MSG_DEBUG(
"No EnhancedBiasTool. Not doing additional weighting.");
50 ATH_MSG_FATAL(
"Configured to use Enhanced Bias weights. Must supply weighting tool.");
51 return StatusCode::FAILURE;
59 if (hashFile.empty()) {
68 ATH_CHECK(
m_histSvc->regTree(
"/COSTSTREAM/metadata", std::make_unique<TTree>(
"metadata",
"metadata")) );
71 return StatusCode::SUCCESS;
83 const ptree& menuData = hltMenuHandle->
data();
84 for (
const auto& sequencer : menuData.get_child(
"sequencers")) {
86 for (
const auto&
alg : sequencer.second) {
88 size_t breakPoint =
alg.second.data().find(
'/');
89 std::string algType =
alg.second.data().substr(0, breakPoint);
90 std::string
algName =
alg.second.data().substr(breakPoint+1,
alg.second.data().size());
95 if (algType.find(
"EventViewCreatorAlgorithm") != std::string::npos) {
103 std::vector<TrigConf::Chain>
chains;
110 const size_t legsSize {
chain.legMultiplicities().size()};
120 size_t breakPoint =
entry.find(
'/');
121 if (breakPoint != std::string::npos){
122 std::string algType =
entry.substr(0, breakPoint);
134 return StatusCode::SUCCESS;
140 return StatusCode::SUCCESS;
148 std::stringstream
ss;
149 ss <<
store <<
"_view_" << viewID;
153 std::stringstream
ss;
154 ss << viewID <<
"_StoreGateSvc_Impl";
157 return StatusCode::SUCCESS;
162 double ebWeight = 1.0;
173 std::string bookingString =
"/COSTSTREAM/" + tDir +
"/" +
histName;
175 if (!((
m_histSvc->regHist(bookingString,
hist)).isSuccess())) {
185 const EventContext& context = Gaudi::Hive::currentContext();
193 return StatusCode::SUCCESS;
197 ATH_MSG_DEBUG(
"Monitoring event " << context.eventID().event_number() <<
" in LB " << context.eventID().lumi_block() <<
" in range " <<
range->getName());
208 if (metadataDataHandle.
isValid()){
212 const std::string hostname = tc->getDetail<std::string>(
"hostname");
213 m_hostnames.insert(hostname);
215 ATH_MSG_WARNING(
"Missing HLT_RuntimeMetadata EDM hostname for event " << context.eventID().event_number());
221 ATH_MSG_DEBUG(
"Not valid HLT_RuntimeMetadata handle for the event " << context.eventID().event_number());
226 std::map<std::string, std::set<size_t>> chainToAlgIdx;
227 std::map<std::string, std::set<size_t>> chainToUniqAlgs;
228 std::map<std::string, std::map<int16_t, std::set<size_t>>> seqToAlgIdx;
229 std::map<std::string, std::set<std::string>> algToChain;
234 std::map<std::string, std::string> algToSeq;
243 chainToAlgIdx[
chain].insert(tc->index());
249 chainToUniqAlgs[*algToChain[
algName].begin()].insert(tc->index());
254 seqToAlgIdx[algToSeq[
algName]][
view].insert(tc->index());
258 const std::set<TrigCompositeUtils::DecisionID> seededChains =
m_algToChainTool->retrieveActiveChains(context,
"HLTNav_L1");
259 std::vector<TrigCompositeUtils::AlgToChainTool::ChainInfo> seededChainsInfo;
262 bool skipMonitoringThisEvent =
false;
265 skipMonitoringThisEvent =
true;
268 for (
auto id : seededChains){
271 seededChainsInfo.push_back(chainInfo);
276 ATH_CHECK( costData.
set(costDataHandle.get(), rosDataHandle.
get(), onlineSlot) );
282 costData.
setLb( context.eventID().lumi_block() );
286 bool liveTimeIsPerEvent =
true;
287 if (liveTime == 0.0) {
289 liveTimeIsPerEvent =
false;
291 costData.
setLivetime( liveTime, liveTimeIsPerEvent );
300 return StatusCode::SUCCESS;
319 ATH_CHECK(
range->addMonitor(std::make_unique<MonitorAlgorithm>(
"Algorithm_HLT",
range)) );
320 ATH_MSG_DEBUG(
"Registering Algorithm_HLT Monitor for range " <<
range->getName() <<
". Size:" <<
range->getMonitors().size());
323 ATH_CHECK(
range->addMonitor(std::make_unique<MonitorAlgorithmClass>(
"Algorithm_Class_HLT",
range)) );
324 ATH_MSG_DEBUG(
"Registering Algorithm_Class_HLT Monitor for range " <<
range->getName() <<
". Size:" <<
range->getMonitors().size());
328 ATH_MSG_DEBUG(
"Registering Global_HLT Monitor for range " <<
range->getName() <<
". Size:" <<
range->getMonitors().size());
331 ATH_CHECK(
range->addMonitor(std::make_unique<MonitorThreadOccupancy>(
"Thread_Occupancy_HLT",
range)) );
332 ATH_MSG_DEBUG(
"Registering Thread_Occupancy_HLT Monitor for range " <<
range->getName() <<
". Size:" <<
range->getMonitors().size());
336 ATH_MSG_DEBUG(
"Registering ROS_HLT Monitor for range " <<
range->getName() <<
". Size:" <<
range->getMonitors().size());
340 ATH_MSG_DEBUG(
"Registering Chain_HLT Monitor for range " <<
range->getName() <<
". Size:" <<
range->getMonitors().size());
343 ATH_CHECK(
range->addMonitor(std::make_unique<MonitorChainAlgorithm>(
"Chain_Algorithm_HLT",
range)) );
344 ATH_MSG_DEBUG(
"Registering Chain_Algorihtm_HLT Monitor for range " <<
range->getName() <<
". Size:" <<
range->getMonitors().size());
348 ATH_MSG_DEBUG(
"Registering Sequence_HLT Monitor for range " <<
range->getName() <<
". Size:" <<
range->getMonitors().size());
353 for (
const std::unique_ptr<MonitorBase>& monitor :
range->getMonitors()){
354 monitor->msg().setLevel(
msg().
level());
357 return StatusCode::SUCCESS;
362 std::string rangeName;
364 bool includeEndOfLB =
false;
372 std::stringstream
ss;
373 ss <<
"LumiBlock_" << std::setfill(
'0') << std::setw(5) << lumiBlockRangeStart;
374 if (includeEndOfLB && lumiBlockRangeStop != lumiBlockRangeStart) {
375 ss <<
"_" << lumiBlockRangeStop;
377 rangeName =
ss.str();
380 std::unordered_map<std::string, std::unique_ptr<MonitoredRange>>
::iterator it;
387 std::make_pair(rangeName, std::make_unique<MonitoredRange>(rangeName,
this))
393 return StatusCode::SUCCESS;
398 return StatusCode::SUCCESS;
406 if (costCollection->
size() == 0) {
412 if (algSlot == 0 or algSlot != initialSlot) {
425 std::stringstream
ss;
436 ss <<
"{id:" << algID++;
437 ss <<
", group:" << threadID;
438 ss <<
", className:'slot" << slot <<
"'";
442 ss <<
", start:" << start_ms_round;
443 if (stop_ms_round > start_ms_round) {
444 ss <<
", end:" << stop_ms_round;
446 ss <<
", type:'point'";
448 ss <<
"}," << std::endl;
451 ATH_MSG_DEBUG(
"Full Event Summary for event " << context.eventID().event_number());
455 return StatusCode::SUCCESS;
463 return StatusCode::SUCCESS;
475 std::string hostnamesList =
"";
476 if (m_hostnames.size() > 1){
478 for (
const auto&
name : m_hostnames) hostnamesList +=
name +
",";
479 hostnamesList.pop_back();
480 }
else if (m_hostnames.size() == 1) {
481 hostnamesList = *m_hostnames.begin();
487 if ( hltMenuHandle.
isValid() ){
488 std::stringstream
ss;
489 boost::property_tree::json_parser::write_json(
ss, hltMenuHandle->
data());
503 m_metadataTree->Branch(
"ChainAlgorithmMonitor", &ChainAlgorithmMonitor);
505 m_metadataTree->Branch(
"AlgorithmClassMonitor", &AlgorithmClassMonitor);
518 std::string atlasProject =
std::getenv(
"AtlasProject");
519 std::string atlasVersion =
std::getenv(
"AtlasVersion");
524 std::string processedRanges;
529 std::stringstream
ss;
531 ss << rangePair.first <<
": ";
532 std::string
lbrange = rangePair.first.substr(strlen(
"LumiBlock_"));
535 processedRanges =
ss.str();
virtual StatusCode finalize() final
Currently a noop for this algorithm.
JetConstituentVector::iterator iterator
const ptree & data() const
Access to the underlying data, if needed.
Gaudi::Property< std::string > m_additionalHashMap
ServiceHandle< ITHistSvc > m_histSvc
std::string replace(std::string s, const std::string &s2, const std::string &s3)
virtual StatusCode execute() final
Monitor event, unless max range limit reached and event outside of all ranges.
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_costDataKey
std::atomic< size_t > m_fullEventDumps
Counter to keep track of how many events have been full-dumped.
void setSequencersMap(const std::map< std::string, std::map< int16_t, std::set< size_t >>> &seqToAlg)
Set the sequence to alg idx map.
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_rosDataKey
std::set< std::string > m_storeIdentifiers
Identifiers of object stores, needed to cache STORE string-hash values.
std::atomic< size_t > m_maxViewsNumber
What is the maximum number of View instances we've so far cached string hashes to cover?
void writeMetadata()
Write to outpute tree (if any) the metadata needed downstream.
virtual StatusCode initialize() final
Retrieve tools and initialise read handles.
bool isMasterSlot() const
Gaudi::Property< size_t > m_maxFullEventDumps
uint32_t getOnlineSlot(const xAOD::TrigCompositeContainer *costCollection) const
Return the slot used to process the event online.
Gaudi::Property< bool > m_doMonitorROS
Gaudi::Property< bool > m_doMonitorChain
void initialize(const std::map< std::string, std::vector< uint32_t >> &rosToRobMap)
Create object based on ROS to ROB mapping.
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Public method forwarded to this class' AthHistogramAlgorithm::bookGetPointer base.
Gaudi::Property< uint64_t > m_fullEventDumpProbability
const std::string & algName(ID id)
Converts a JetAlgorithmType::ID into a string.
void setTypeMap(const std::unordered_map< uint32_t, std::string > &typeMap)
Set internal type map pointer.
std::unordered_map< uint32_t, std::string > m_algTypeMap
Cache of algorithm's type, read from configuration data.
ToolHandle< TrigCompositeUtils::AlgToChainTool > m_algToChainTool
TrigCostAnalysis(const std::string &name, ISvcLocator *pSvcLocator)
Construct TrigCostAnalysis.
StatusCode checkUpdateMaxView(const size_t max)
High watermark for pre-cached string hashes for the SLOT category.
#define ATH_MSG_VERBOSE(x)
const std::string & key() const
Return the StoreGate ID for the referenced object.
Gaudi::Property< bool > m_useEBWeights
setScaleOne setStatusOne setSaturated int16_t
StatusCode set(const xAOD::TrigCompositeContainer *costCollection, const xAOD::TrigCompositeContainer *rosCollection, uint32_t onlineSlot)
Cache the cost and ros collections, after formally requesting it from storegate.
ToolHandle< IEnhancedBiasWeighter > m_enhancedBiasTool
void setLb(uint32_t lb)
Setter of effective P1 walltime represented by the current event.
Gaudi::Property< float > m_baseEventWeight
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
std::mutex m_addHostnameMutex
Mutex to update set below.
static HLTHash string2hash(const std::string &, const std::string &category="TE")
hash function translating TE names into identifiers
::StatusCode StatusCode
StatusCode definition for legacy code.
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
Gaudi::Property< bool > m_singleTimeRange
CostROSData m_costROSData
Cached CostROSData class with details needed for ROS monitoring.
TTree * m_metadataTree
Used to write out some metadata needed by post-processing (e.g.
void setSeededChains(const std::vector< TrigCompositeUtils::AlgToChainTool::ChainInfo > &seededChains)
Set the seeded chains set.
Gaudi::Property< std::vector< std::string > > m_additionalHashList
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Gaudi::Property< bool > m_doMonitorThreadOccupancy
Gaudi::Property< bool > m_doMonitorGlobal
Class used to describe composite objects in the HLT.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode registerMonitors(MonitoredRange *range)
Populate a newly minted Range object with all configured Monitors.
std::unordered_map< std::string, std::unique_ptr< MonitoredRange > > m_monitoredRanges
Owned storage of Ranges.
boost::property_tree::ptree ptree
Gaudi::Property< bool > m_doMonitorSequence
Gaudi::Property< bool > m_doMonitorAlgorithm
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_metadataDataKey
static const std::string hash2string(HLTHash, const std::string &category="TE")
hash function translating identifiers into names (via internal dictionary)
Gaudi::Property< bool > m_doMonitorChainAlgorithm
HLT::Identifier createLegName(const HLT::Identifier &chainIdentifier, size_t counter)
Generate the HLT::Identifier which corresponds to a specific leg of a given chain.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
virtual StatusCode start()
Retrieve menu handle.
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
Gaudi::Property< size_t > m_TimeRangeLengthLB
Container which represents a time range and holds a collection of Monitors which monitor this range.
std::string getenv(const std::string &variableName)
get an environment variable
Gaudi::Property< std::string > m_singleTimeRangeName
#define ATH_MSG_WARNING(x)
void setCostROSData(const CostROSData &costROSData)
Set ROS to ROB map.
Gaudi::Property< bool > m_doMonitorAlgorithmClass
void setChainToAlgMap(const std::map< std::string, std::set< size_t >> &algToChains)
Set the alg name to chains map.
const T * at(size_type n) const
Access an element, as an rvalue.
void setLivetime(float time, bool liveTimeIsPerEvent)
Setter of effective P1 walltime represented by the current event, or the current lumi block.
float getWeight(const EventContext &context)
Compute global event weight to correct for online prescales.
static void file2hashes(const std::string &fileName="hashes2string.txt")
debugging output of internal dictionary
Gaudi::Property< size_t > m_maxTimeRange
void setChainToUniqAlgMap(const std::map< std::string, std::set< size_t >> &algToChains)
Set the chain to its unique alg names map.
Gaudi::Property< std::map< std::string, std::vector< uint32_t > > > m_rosToRob
StatusCode getRange(const EventContext &context, MonitoredRange *&range)
Return or construct and return a Range for the Context.
size_type size() const noexcept
Returns the number of elements in the collection.
Caches and propagates event data to be used by monitoring algorithms.
StatusCode dumpEvent(const EventContext &context) const
Dump event algorithm execution data in ASCII format.
bool checkDoFullEventDump(const EventContext &context, const CostData &costData)
Check if event dumping should be performed for the current event.