37 #pragma warning(disable:2259)
39 #include "boost/format.hpp"
40 #include "boost/lexical_cast.hpp"
52 , m_trapType (
"DataFault")
53 , m_dataSvcName (
"EventDataSvc" )
54 , m_partialPath (
true )
57 , m_allowInitFailure(
false)
65 , m_updateRequired (
true )
66 , m_prefix (
"/Event/" )
76 , m_locked_nodes (
false )
77 , m_locked_algs (
false )
78 , m_locked_all (
false )
85 "The type of handled Incident" ) ;
87 declareProperty (
"DataSvc" , m_dataSvcName ) ;
89 declareProperty (
"UsePreceedingPath" , m_partialPath ) ;
93 "Dump the configuration and stastics" ) ->
99 "Flag to (pre)initialize all algorithms" ) ;
101 (
"AllowPreInitializeFailure" ,
103 "Allow (pre)initialization of algorithms to fail without stopping the application" ) ;
105 declareProperty (
"Algorithms" , m_algMapping ) ->
107 declareProperty (
"Nodes" , m_nodeMapping ) ->
110 declareProperty (
"AlgMap" , m_algMap ) ->
112 declareProperty (
"NodeMap" , m_nodeMap ) ->
115 declareProperty (
"Prefix" , m_prefix ) ;
117 declareProperty(
"NodeMappingTools", m_nodeMapTools,
118 "List of tools of type IDODNodeMapper");
119 declareProperty(
"AlgMappingTools", m_algMapTools,
120 "List of tools of type IDODAlgMapper");
138 <<
"The property 'Nodes' is obsolete, switch to map-like 'NodeMap' "
139 <<
" = { 'data' : 'type' } "
150 <<
"The property 'Algorithms' is obsolete, switch to map-like 'AlgMap' "
151 <<
" = { 'data' : 'algorithm' } "
182 !prefix.
empty() && 0 == value.find(prefix) ?
193 inline size_t add_prefix ( MAP& _map ,
const std::string& prefix )
196 if ( prefix.empty() ) {
return 0 ; }
198 for (
typename MAP::iterator it = _map.begin() ; _map.end() != it ; ++it )
200 if ( 0 != it->first.find(prefix) )
205 _map[ key ] = value ;
206 return 1 + add_prefix ( _map , prefix ) ;
219 inline size_t get_dir (
const std::string&
object , SET& _set )
223 if ( std::string::npos == ifind ) {
return 0 ; }
224 if ( 0 == ifind ) {
return 0 ; }
228 return 1 + get_dir ( top , _set ) ;
236 template <
class MAP,
class SET>
237 inline size_t get_dirs (
const MAP& _map, SET& _set )
239 size_t size = _set.size() ;
240 for (
typename MAP::const_iterator
item = _map.begin() ;
241 _map.end() !=
item ; ++
item ) { get_dir (
item->first , _set ) ; }
242 return _set.size() - size ;
248 ClassH cl = TClass::GetClass(type.c_str()) ;
251 <<
"Failed to access dictionary class for "
252 << name <<
" of type:" << type <<
endmsg;
258 Leaf leaf(alg.type(), alg.name());
266 leaf =
Leaf(alg.type(), alg.name());
307 Set::iterator _e = dirs.find(
"/Event") ;
308 if ( dirs.end() != _e ) { dirs.erase( _e ) ; }
310 for ( Set::const_iterator dir = dirs.begin() ; dirs.end() != dir ; ++dir )
369 <<
"Handled \"" <<
m_trapType <<
"\" incidents: "
377 (
"Algorithm timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " ,
System::milliSec )
382 (
"Nodes timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " ,
System::milliSec )
387 (
"Algs timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " ,
System::milliSec )
392 (
"All timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " ,
System::milliSec )
414 warning() <<
"ToolSvc already finalized: cannot release tools. Check options." <<
endmsg;
462 error() <<
"Failed to retrieve the IAlgManager interface." <<
endmsg;
468 error() <<
"Failed to retrieve Incident service." <<
endmsg;
476 <<
"Failed to retrieve the data provider interface of "
518 tok.
analyse(*j,
" ",
"",
"",
"=",
"'",
"'");
537 <<
"The obsolete property 'Nodes' redefines the action for '"
538 + tag +
"' to be '" +nam+
"'"
559 tok.
analyse(*j,
" ",
"",
"",
"=",
"'",
"'");
572 Gaudi::Utils::TypeNameString
item(typ);
578 <<
"The obsolete property 'Algorithms' redefines the action for '"
579 + tag +
"' to be '" +item.type() +
"/"+item.name()+
"'"
582 m_algMap[tag] = item.type() +
"/" + item.name() ;
602 <<
"Failed to create algorithm "
614 <<
"Failed to initialize algorithm "
627 <<
"Failed to 'run' algorithm "
649 inline Gaudi::Utils::TypeNameString operator() (
IDODAlgMapper *t)
const {
656 inline bool isGood(
const std::string& r) {
return !r.empty();}
657 inline bool isGood(
const Gaudi::Utils::TypeNameString& r) {
return !r.name().empty();}
663 const ToolGetter getter;
667 template <
class R,
class T>
671 R result = getter(*i);
672 if (isGood(result))
return result;
684 return find<std::string>(nodes);
687 inline Gaudi::Utils::TypeNameString alg()
const {
688 return find<Gaudi::Utils::TypeNameString>(algs);
707 if ( 0 == inc ) { return ; }
714 <<
"Incident: [" << incident.
type () <<
"] "
715 <<
" = " << incident.
source ()
716 <<
" Location:" << inc->tag() <<
endmsg;
720 Gaudi::StringKey tag ( inc->tag() ) ;
741 verbose() <<
"Try to find mapping with mapping tools" <<
endmsg;
755 Gaudi::Utils::TypeNameString alg = finder.alg();
791 <<
"Failed to get dictionary for class '"
793 <<
"' for location:" << tag <<
endmsg;
803 <<
"Failed to create an object of type:"
804 << n.
clazz->GetName() <<
" for location:" << tag
814 <<
MSG::ERROR <<
"Failed to register an object of type:"
815 << n.
name <<
" at location:" << tag
840 <<
"Failed to configure handler for: "
853 <<
"Failed to execute the algorithm:"
869 const bool mode )
const
871 if ( m_algs.empty() && m_nodes.empty() ) { return ; }
878 m_algs.end() != alg ; ++alg )
880 PMap::const_iterator
check = _m.find(alg->first) ;
881 if ( _m.end() !=
check )
885 <<
" The data item is activated for '"
886 << check->first <<
"' as '" << check->second.first <<
"'" <<
endmsg ;
888 const Leaf& l = alg->second ;
891 if ( !mode && 0 == l.
num ) { continue ; }
894 if ( mode ) { val = ( 0 == l.
algorithm ) ?
"F" :
"T" ; }
897 _m[ no_prefix ( alg->first , m_prefix ) ] =
std::make_pair ( nam , val ) ;
901 m_nodes.end() != node ; ++node )
903 PMap::const_iterator
check = _m.find(node->first) ;
904 if ( _m.end() !=
check )
908 <<
" The data item is already activated for '"
909 << check->first <<
"' as '" << check->second.first <<
"'" <<
endmsg ;
911 const Node&
n = node->second ;
916 if ( !mode && 0 == n.
num ) { continue ; }
918 if ( mode ) { val = ( 0 == n.
clazz ) ?
"F" :
"T" ; }
921 _m[ no_prefix ( node->first , m_prefix ) ] =
std::make_pair ( nam , val ) ;
924 if ( _m.empty() ) { return ; }
930 for ( PMap::const_iterator it = _m.begin() ; _m.end() != it ; ++it )
932 n1 =
std::max ( n1 , it->first.size() ) ;
933 n2 =
std::max ( n2 , it->second.first.size() ) ;
934 n3 =
std::max ( n3 , it->second.second.size() ) ;
936 if ( 10 > n1 ) { n1 = 10 ; }
937 if ( 10 > n2 ) { n2 = 10 ; }
938 if ( 60 < n1 ) { n1 = 60 ; }
939 if ( 60 < n2 ) { n2 = 60 ; }
942 const std::string _f =
" | %%1$-%1%.%1%s | %%2$-%2%.%2%s | %%3$%3%.%3%s |" ;
950 if ( mode ) { msg <<
"Data-On-Demand Actions enabled for:" ; }
951 else { msg <<
"Data-On-Demand Actions has been used for:" ; }
954 fmt1 %
"Address" %
"Creator" % ( mode ?
"S" :
"#" ) ;
965 for ( PMap::const_iterator
item = _m.begin() ;
970 ( fmt %
item->first %
item->second.first %
item->second.second ) ;