Go to the documentation of this file.
20 #include <nlohmann/json.hpp>
44 setProperty(
"TypesToSave", std::vector<std::string>{
"histogram:.*" } )
45 .orThrow(
"Unable to set typesToSaveProperty",
"Histograming::Sink::Base" );
49 return BaseSink::initialize().
andThen( [&] {
52 info() <<
"Writing ROOT histograms to: " << m_fileName.value() <<
" ("
53 << m_fileSvc->getFile( m_fileName )->GetName() <<
')' << endmsg;
58 std::filesystem::remove( m_fileName.value() );
59 info() <<
"Writing ROOT histograms to: " << m_fileName.value() << endmsg;
65 std::shared_ptr<TFile> histoFile;
73 histoFile = std::make_shared<TFile>(
m_fileName.
value().c_str(),
"UPDATE" );
82 binSaver->second( *histoFile, component, name, ent );
87 auto dim =
j.at(
"dimension" ).template get<unsigned int>();
88 auto type =
j.at(
"type" ).template get<std::string>();
93 if ( saver !=
m_registry.end() ) ( saver->second )( *histoFile, component,
name,
j );
99 m_binRegistry.emplace( std::piecewise_construct, std::make_tuple(
id ), std::make_tuple(
func ) );
103 m_registry.emplace( std::piecewise_construct, std::make_tuple(
id ), std::make_tuple(
func ) );
113 "Name of file where to save histograms" };
Gaudi::Property< std::string > m_fileName
Base class for all Sinks registering to the Monitoring Hub Should be extended by actual Sinks.
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
StatusCode initialize() override
void flush(bool) override
pure virtual method to be defined by children and responsible for flushing current data of the Sink.
std::pair< std::string, int > HistoIdentification
std::type_index HistoBinIdentification
std::map< HistoIdentification, HistoHandler > HistoRegistry
T * get() const
Allow non const access to the service, even from a const handle...
const std::string & name() const override
Retrieve name of the service
void registerHandler(HistoBinIdentification const &id, HistoBinHandler const &func)
void registerHandler(HistoIdentification const &id, HistoHandler const &func)
const ValueType & value() const
std::type_index typeIndex() const
function to get internal type
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
void applyToAllSortedEntities(Callable func) const
applies a callable to all monitoring entities ordered by component the callable will be called once p...
StatusCode retrieve(T *&service) const override
Do the real retrieval of the Service.
HistoRegistry m_registry
map of supported type and the way to handle them
std::function< void(TFile &file, std::string, std::string, nlohmann::json const &)> HistoHandler
std::function< void(TFile &file, std::string, std::string, Monitoring::Hub::Entity const &)> HistoBinHandler
virtual bool hasIdentifier(const std::string &identifier) const =0
Check if a given identifier is known to the service.
std::map< HistoBinIdentification, HistoBinHandler > HistoBinRegistry
ServiceHandle< Gaudi::Interfaces::IFileSvc > m_fileSvc
virtual std::shared_ptr< TFile > getFile(const std::string &identifier)=0
Get a shared pointer to a TFile based on an identifier.
Wrapper class for arbitrary monitoring objects.
HistoBinRegistry m_binRegistry
map of supported type and the way to handle them
Base(const std::string &name, ISvcLocator *svcloc)