Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FixTESPath.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIALG_FIXTESPATH_H
12 #define GAUDIALG_FIXTESPATH_H
13 #include <memory>
14 #include <string>
15 #include <string_view>
16 #include <type_traits>
17 
18 #include "GaudiKernel/AlgTool.h"
19 #include "GaudiKernel/Algorithm.h"
21 #include "GaudiKernel/MsgStream.h"
22 #include <Gaudi/Property.h>
23 
24 namespace FixTESPathDetails {
25  std::unique_ptr<IDataHandleVisitor> fixDataHandlePath( std::string_view rit, std::string rootName, MsgStream* dbg );
26  std::string fullTESLocation( std::string_view location, std::string_view rit );
27 } // namespace FixTESPathDetails
28 
29 template <class BASE>
30 class FixTESPath : public BASE {
31 public:
34  template <typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, BASE>, U>>
35  FixTESPath( std::string name, ISvcLocator* pSvcLocator ) : BASE( std::move( name ), pSvcLocator ) {}
36 
39  template <typename U = BASE, typename = std::enable_if_t<std::is_base_of_v<AlgTool, BASE>, U>>
41  : BASE( std::move( type ), std::move( name ), ancestor ) {
42  // setup RootInTES from parent if available
43  if ( const IProperty* ancestorProp = dynamic_cast<const IProperty*>( ancestor );
44  ancestorProp && ancestorProp->hasProperty( "RootInTES" ) ) {
45  this->setProperty( ancestorProp->getProperty( "RootInTES" ) ).ignore();
46  }
47  }
48 
49  StatusCode initialize() override {
50  return BASE::initialize().andThen( [&] {
51  // TODO: just call 'acceptDHVisitor` and remove m_updateDataHandles...
52  SmartIF<IDataManagerSvc> dataMgrSvc{ BASE::evtSvc() };
53  this->m_updateDataHandles = FixTESPathDetails::fixDataHandlePath(
54  rootInTES(), dataMgrSvc->rootName(), BASE::msgLevel( MSG::DEBUG ) ? &this->debug() : nullptr );
55  } );
56  }
57 
61  const std::string& rootInTES() const { return m_rootInTES; }
62  // ==========================================================================
64  std::string fullTESLocation( std::string_view location, bool useRootInTES ) const {
65  return FixTESPathDetails::fullTESLocation( location, useRootInTES ? rootInTES() : std::string_view{} );
66  }
67  // ==========================================================================
68 private:
70  "RootInTES",
71  {},
72  [this]( Gaudi::Details::PropertyBase& ) { // Check rootInTES ends with a '/'
73  auto& rit = this->m_rootInTES.value();
74  if ( !rit.empty() && rit.back() != '/' ) rit += '/';
75  },
76  "note: overridden by parent settings" };
77 };
78 
79 #endif
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: PropertyBase.h:35
GaudiPython.HistoUtils.location
location
Definition: HistoUtils.py:965
std::string
STL class.
setProperty
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:244
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition: StatusCode.h:163
ISvcLocator
Definition: ISvcLocator.h:46
Algorithm.h
FixTESPathDetails::fullTESLocation
std::string fullTESLocation(std::string_view location, std::string_view rit)
Definition: FixTESPath.cpp:56
IProperty
Definition: IProperty.h:33
TimingHistograms.name
name
Definition: TimingHistograms.py:25
StatusCode
Definition: StatusCode.h:65
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:239
IProperty::hasProperty
virtual bool hasProperty(std::string_view name) const =0
Return true if we have a property with the given name.
FixTESPath::FixTESPath
FixTESPath(std::string name, ISvcLocator *pSvcLocator)
Algorithm constructor - the SFINAE constraint below ensures that this is constructor is only defined ...
Definition: FixTESPath.h:35
SmartIF< IDataManagerSvc >
FixTESPathDetails
Definition: FixTESPath.h:24
FixTESPath::initialize
StatusCode initialize() override
Definition: FixTESPath.h:49
FixTESPath::m_rootInTES
Gaudi::Property< std::string > m_rootInTES
Definition: FixTESPath.h:69
MsgStream
Definition: MsgStream.h:34
gaudirun.type
type
Definition: gaudirun.py:162
std
STL namespace.
IInterface
Definition: IInterface.h:237
FixTESPath::rootInTES
const std::string & rootInTES() const
Returns the "rootInTES" string.
Definition: FixTESPath.h:61
AlgTool.h
FixTESPath::FixTESPath
FixTESPath(std::string type, std::string name, const IInterface *ancestor)
Tool constructor - SFINAE-ed to insure this constructor is only defined if BASE derives from AlgTool.
Definition: FixTESPath.h:40
FixTESPath
Definition: FixTESPath.h:30
std::unique_ptr< IDataHandleVisitor >
FixTESPath::fullTESLocation
std::string fullTESLocation(std::string_view location, bool useRootInTES) const
Returns the full correct event location given the rootInTes settings.
Definition: FixTESPath.h:64
FixTESPathDetails::fixDataHandlePath
std::unique_ptr< IDataHandleVisitor > fixDataHandlePath(std::string_view rit, std::string rootName, MsgStream *dbg)
Definition: FixTESPath.cpp:74
Gaudi::Property< std::string >
IDataManagerSvc.h
Property.h
MsgStream.h