GaudiCommon.icpp
Go to the documentation of this file.
1 // ============================================================================
2 // include files
3 // ============================================================================
4 // STL & STD
5 // ============================================================================
6 #include <algorithm>
7 #include <cstdlib>
8 // ============================================================================
9 /* @file GaudiCommon.cpp
10  *
11  * Implementation file for class : GaudiCommon
12  *
13  * @author Chris Jones Christopher.Rob.Jones@cern.ch
14  * @author Vanya BELYAEV Ivan.Belyaev@itep.ru
15  * @author Rob Lambert Rob.Lambert@cern.ch
16  * @date 2009-08-04
17  */
18 // GaudiKernel
19 // ============================================================================
20 #include "GaudiKernel/IDataProviderSvc.h"
21 #include "GaudiKernel/IToolSvc.h"
22 #include "GaudiKernel/IProperty.h"
23 #include "GaudiKernel/Property.h"
24 #include "GaudiKernel/ISvcLocator.h"
25 #include "GaudiKernel/MsgStream.h"
26 #include "GaudiKernel/ObjectVector.h"
27 #include "GaudiKernel/SmartDataPtr.h"
28 #include "GaudiKernel/SmartRef.h"
29 #include "GaudiKernel/Stat.h"
30 #include "GaudiKernel/System.h"
31 #include "GaudiKernel/IJobOptionsSvc.h"
32 #include "GaudiKernel/StatEntity.h"
33 #include "GaudiKernel/Algorithm.h"
34 #include "GaudiKernel/AlgTool.h"
35 #include "GaudiKernel/reverse.h"
36 // ============================================================================
37 // GaudiAlg
38 // ============================================================================
39 #include "GaudiAlg/Print.h"
40 #include "GaudiAlg/GaudiCommon.h"
41 #include "GaudiAlg/GaudiAlgorithm.h"
42 #include "GaudiAlg/GaudiTool.h"
43 // ============================================================================
44 // GaudiUtils
45 // ============================================================================
46 #include "GaudiUtils/RegEx.h"
47 // ============================================================================
48 // Boost
49 // ============================================================================
50 #include "boost/format.hpp"
51 // ============================================================================
52 // Disable warning on windows
53 #ifdef _WIN32
54 #pragma warning ( disable:4661 ) // incomplete explicit templates
55 #endif
56 // ============================================================================
57 
58 // ============================================================================
59 // constructor initialisation
60 // ============================================================================
61 template <class PBASE>
62 void
64 {
65  // initialise data members
66 
67  // the header row for counters printout
68  m_header = " | Counter | # | sum | mean/eff^* | rms/err^* | min | max |" ;
69  // format for regular statistical printout rows
70  m_format1 = " | %|-48.48s|%|50t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" ;
71  // format for "efficiency" statistical printout rows
72  m_format2 = " |*%|-48.48s|%|50t||%|10d| |%|11.5g| |(%|#9.6g| +- %|-#9.6g|)%%| ------- | ------- |" ;
73  // flag to use the special "efficiency" format
74  m_useEffFormat = true ;
75 
76  // job options
77  // print error counters at finalization ?
78  this->declareProperty
79  ( "ErrorsPrint" , m_errorsPrint ,
80  "Print the statistics of errors/warnings/exceptions")
81  -> declareUpdateHandler
83  // print properties at initialization?
84  this->declareProperty
85  ( "PropertiesPrint" , m_propsPrint ,
86  "Print the properties of the component ")
87  -> declareUpdateHandler
89  // print statistical counters at finalization ?
90  this->declareProperty
91  ( "StatPrint" , m_statPrint ,
92  "Print the table of counters" )
93  -> declareUpdateHandler
95  // insert the actual C++ type of the algorithm or tool in the messages?
96  this->declareProperty
97  ( "TypePrint" , m_typePrint ,
98  "Add the actal C++ component type into the messages" ) ;
99  // context
100  this->declareProperty ( "Context" , m_context ) ;
101  // root in TES
102  this->declareProperty ( "RootInTES" , m_rootInTES ) ;
103  // root on TES ( temporary )
104  this->declareProperty ( "RootOnTES" , m_rootOnTES ) ;
105  // global time offset
106  this->declareProperty ( "GlobalTimeOffset", m_globalTimeOffset ) ;
107 
108 
109  // the header row for counters printout
110  this->declareProperty
111  ( "StatTableHeader" , m_header ,
112  "The header row for the output Stat-table" ) ;
113  // format for regular statistical printout rows
114  this->declareProperty
115  ( "RegularRowFormat" , m_format1 ,
116  "The format for the regular row in the output Stat-table" ) ;
117  // format for "efficiency" statistical printout rows
118  this->declareProperty
119  ( "EfficiencyRowFormat" , m_format2 ,
120  "The format for the regular row in the output Stat-table" ) ;
121  // flag to use the special "efficiency" format
122  this->declareProperty
123  ( "UseEfficiencyRowFormat" , m_useEffFormat ,
124  "Use the special format for printout of efficiency counters" ) ;
125 
126 
127  //declare the list of simple counters to write.
128  this->declareProperty(
129  "CounterList",
130  m_counterList=std::vector<std::string>(1,".*"),
131  "RegEx list, of simple integer counters for CounterSummary.");
132  //declare the list of stat entities to write.
133  this->declareProperty(
134  "StatEntityList",
135  m_statEntityList=std::vector<std::string>(0),
136  "RegEx list, of StatEntity counters for CounterSummary.");
137 
138  // add handler for message level changes
139  this->outputLevelProperty().declareUpdateHandler( &GaudiCommon<PBASE>::msgLevelHandler, this );
140 
141  // setup context from parent if available
142  if ( parent )
143  {
144  if ( const GaudiAlgorithm* gAlg = dynamic_cast<const GaudiAlgorithm*>(parent) )
145  {
146  m_context = gAlg->context();
147  m_rootInTES = gAlg->rootInTES();
148  m_globalTimeOffset = gAlg->globalTimeOffset();
149  }
150  else if ( const GaudiTool* gTool = dynamic_cast<const GaudiTool*> (parent) )
151  {
152  m_context = gTool->context();
153  m_rootInTES = gTool->rootInTES();
154  m_globalTimeOffset = gTool->globalTimeOffset();
155  }
156  }
157 
158  // Get the job option service
159  auto jos = this->template service<IJobOptionsSvc>("JobOptionsSvc");
160  if (!jos) Exception("Cannot get JobOptionsSvc");
161 
162  // Get the "Context" option if in the file...
163  const auto myList = jos->getProperties( this->name() );
164  if ( myList )
165  {
166  // Iterate over the list to set the options
167  for ( const auto& iter : *myList )
168  {
169  const StringProperty* sp = dynamic_cast<const StringProperty*>(iter);
170  if ( sp )
171  {
172  if ( iter->name() == "Context" ) {
173  m_context = sp->value();
174  } else if ( iter->name() == "RootInTES" ) {
175  m_rootInTES = sp->value();
176  } else if ( iter->name() == "GlobalTimeOffset" ) {
177  m_globalTimeOffset = std::stod( sp->value() );
178  }
179  }
180  }
181  }
182 
183 }
184 //=============================================================================
185 
186 //=============================================================================
187 // Initialise the common functionality
188 //=============================================================================
189 template < class PBASE >
191 #ifdef __ICC
192  i_gcInitialize
193 #else
194  initialize
195 #endif
196  ()
197 {
198 
199  // initialize base class
200  const StatusCode sc = PBASE::initialize();
201  if ( sc.isFailure() )
202  { return Error ( "Failed to initialise base class PBASE", sc ) ; }
203 
204 
205  // some debug printout
206  if ( this->msgLevel(MSG::DEBUG) )
207  {
208  this->debug() << "Initialize base class GaudiCommon<" << System::typeinfoName(typeid(PBASE)) << ">" << endmsg;
209  if ( !context().empty() )
210  this->debug() << "Created with context = '" << context() << "'" << endmsg;
211  }
212 
213  // some temporary checks to see if people are using RootOnTES and warn if so
214  // TO BE REMOVED ASAP ...
215  if ( m_rootInTES.empty() && !m_rootOnTES.empty() )
216  {
217  m_rootInTES = m_rootOnTES;
218  Warning( "RootOnTES option is OBSOLETE -> Use RootInTES instead. RootInTES has been updated to "
219  + m_rootInTES, StatusCode::SUCCESS ).ignore();
220  }
221  else if ( !m_rootInTES.empty() && !m_rootOnTES.empty() )
222  {
223  Warning( "Options RootOnTES AND RootInTES are defined ! Use RootInTES. RootOnTES is ignored",
224  StatusCode::SUCCESS ).ignore();
225  }
226 
227  // Check rootInTES ends with a /
228  if ( !m_rootInTES.empty() &&
229  m_rootInTES.substr(m_rootInTES.size()-1) != "/" ) m_rootInTES += "/";
230 
231  //Set up the CounterSummarySvc May need to be changed
232  m_counterSummarySvc = this->svcLoc()->service("CounterSummarySvc",false);
233  if (this->msgLevel(MSG::DEBUG))
234  {
235  if (!m_counterSummarySvc)
236  this->debug() << "could not locate CounterSummarySvc, no counter summary will be made" << endmsg;
237  else this->debug() << "found CounterSummarySvc OK" << endmsg;
238  }
239 
240  // properties will be printed if asked for or in "MSG::DEBUG" mode
241  if ( propsPrint() ) { printProps(MSG::ALWAYS); }
242  else if ( this->msgLevel(MSG::DEBUG) ) { printProps(MSG::DEBUG); }
243 
244  return sc;
245 }
246 //=============================================================================
247 
248 //=============================================================================
249 // Finalize the common functionality
250 //=============================================================================
251 template < class PBASE >
253 #ifdef __ICC
254  i_gcFinalize
255 #else
256  finalize
257 #endif
258  ()
259 {
261 
262  // print the general information about statistical counters
263  if ( this->msgLevel(MSG::DEBUG) || (statPrint() && !counters().empty()) )
264  {
265  // print general statistical counters
266  printStat ( statPrint() ? MSG::ALWAYS : MSG::DEBUG ) ;
267  }
268  //add all counters to the CounterSummarySvc
269  if(m_counterSummarySvc && this->svcLoc()->existsService("CounterSummarySvc"))
270  {
271  if ( this->msgLevel(MSG::DEBUG) ) this->debug() << "adding counters to CounterSummarySvc" << endmsg;
272 
273  Gaudi::Utils::RegEx::matchList statList{ m_statEntityList };
274  Gaudi::Utils::RegEx::matchList counterList{ m_counterList };
275 
276  for( const auto& i : this->counters() )
277  {
278  if (statList.Or(i.first) )
279  m_counterSummarySvc->addCounter(this->name(),i.first,i.second,
281  else if (counterList.Or(i.first))
282  m_counterSummarySvc->addCounter(this->name(),i.first,i.second);
283  }
284  }
285  // release all located tools and services
286  if ( this->msgLevel(MSG::DEBUG) )
287  {
288  this->debug() << "Tools to release :";
289  for ( const auto& i : m_tools )
290  {
291  this->debug() << " " << i->name();
292  }
293  this->debug() << endmsg;
294  }
295  while ( !m_tools.empty() ) { sc = releaseTool( m_tools.back() ) && sc; }
296 
297  // release all located services
298  if ( this->msgLevel(MSG::DEBUG) )
299  {
300  this->debug() << "Services to release :";
301  for ( const auto& i : m_services )
302  {
303  this->debug() << " " << i->name();
304  }
305  this->debug() << endmsg;
306  }
307  while ( !m_services.empty() ) { sc = releaseSvc( m_services.front() ) && sc; }
308 
309  //release the CounterSummarySvc manually
310  m_counterSummarySvc.reset();
311 
312  // format printout
313  if ( !m_errors.empty() || !m_warnings.empty() || !m_exceptions.empty() )
314  {
315  this->always() << "Exceptions/Errors/Warnings/Infos Statistics : "
316  << m_exceptions .size () << "/"
317  << m_errors .size () << "/"
318  << m_warnings .size () << "/"
319  << m_infos .size () << endmsg ;
320  if ( errorsPrint() ) { printErrors () ; }
321  }
322 
323  // delete the MsgStream
324  resetMsgStream();
325 
326  // clear *ALL* counters explicitly
327  m_counters .clear() ;
328  m_exceptions .clear() ;
329  m_infos .clear() ;
330  m_warnings .clear() ;
331  m_errors .clear() ;
332  m_counterList.clear() ;
333  m_statEntityList.clear() ;
334 
335  // finalize base class
336  return sc && PBASE::finalize();
337 }
338 //=============================================================================
339 
340 //=============================================================================
341 // Methods related to tools and services
342 //=============================================================================
343 
344 // ============================================================================
345 // manual forced (and 'safe') release of the active tool or service
346 // ============================================================================
347 template < class PBASE >
349 {
350  if ( !interface )
351  { return Error ( "release(IInterface):: IInterface* points to NULL!" ) ; }
352  // dispatch between tools and services
353  const IAlgTool* algTool = dynamic_cast<const IAlgTool*>( interface ) ;
354  // perform the actual release
355  return algTool ? releaseTool( algTool ) : releaseSvc( interface ) ;
356 }
357 // ============================================================================
358 
359 // ============================================================================
360 // manual forced (and 'save') release of the tool
361 // ============================================================================
362 template < class PBASE >
364 {
365  if( !algTool )
366  { return Error ( "releaseTool(IAlgTool):: IAlgTool* points to NULL!" ) ; }
367  if( !this->toolSvc() )
368  { return Error ( "releaseTool(IAlgTool):: IToolSvc* points to NULL!" ) ; }
369  // find a tool in the list of active tools
370  auto it = std::find( m_tools.rbegin() , m_tools.rend() , algTool ) ;
371  if( m_tools.rend() == it )
372  { return Warning("releaseTool(IAlgTool):: IAlgTool* is not active" ) ; }
373  // get the tool
374  IAlgTool* t = *it ;
375  // cache name
376  const std::string name = t->name();
377  if ( this->msgLevel(MSG::DEBUG) )
378  { this->debug() << "Releasing tool '" << name << "'" << endmsg; }
379  // remove the tool from the lists
380  m_tools.erase( --it.base() ) ;
381  // release tool
382  if ( this->msgLevel(MSG::DEBUG) ) {
383  this->debug() << "The tool '" << t->name() << "' of type '"
384  << System::typeinfoName(typeid(*t))
385  << "' is released" << endmsg;
386  }
387  const StatusCode sc = this->toolSvc()->releaseTool( t ) ;
388  return sc.isSuccess() ?
389  sc :
390  Warning( "releaseTool(IAlgTool):: error from IToolSvc releasing "+name , sc ) ;
391 }
392 // ============================================================================
393 
394 // ============================================================================
395 // manual forced (and 'safe') release of the service
396 // ============================================================================
397 template < class PBASE >
399 {
400  if( !Svc ) return Error ( "releaseSvc(IInterface):: IInterface* points to NULL!" ) ;
401  SmartIF<IService> svc{const_cast<IInterface*>(Svc)};
402  if (!svc) return Warning( "releaseSvc(IInterface):: IInterface* is not a service" );
403  auto it = std::lower_bound( std::begin(m_services), std::end(m_services), svc, GaudiCommon_details::svc_lt );
404  if (it == m_services.end() || !GaudiCommon_details::svc_eq(*it,svc)) {
405  return Warning( "releaseSvc(IInterface):: IInterface* is not active" );
406  }
407  if ( this->msgLevel(MSG::DEBUG) ) {
408  this->debug() << "Releasing service '" << (*it)->name() << "'" << endmsg;
409  }
410  m_services.erase(it);
411  return StatusCode::SUCCESS;
412 }
413 // ============================================================================
414 
415 // ============================================================================
416 // Add the given tool to the list of active tools
417 // ============================================================================
418 template < class PBASE >
420 {
421  if( tool ) {
422  if ( this->msgLevel ( MSG::DEBUG ) ) {
423  this->debug() << "The tool of type '"
424  << System::typeinfoName(typeid(*tool))
425  << "' has been added with the name '"
426  << tool->name() << "'" << endmsg ;
427  }
428  m_tools.push_back( tool ) ;
429  }
430 }
431 // ============================================================================
432 
433 // ============================================================================
434 // Add the given service to the list of active services
435 // ============================================================================
436 template < class PBASE >
438 {
439  if (svc) {
440  auto i = std::lower_bound( std::begin(m_services), std::end(m_services), svc, GaudiCommon_details::svc_lt );
441  if ( i == std::end(m_services) || !GaudiCommon_details::svc_eq(*i,svc) ) {
442  m_services.insert( i, std::move(svc) );
443  } else {
444  this->warning() << "Service " << svc->name() << " already present -- skipping" << endmsg;
445  }
446  }
447 }
448 // ============================================================================
449 
450 //=============================================================================
451 // Methods related to messaging
452 //=============================================================================
453 
454 // ============================================================================
455 // Print the error message and return status code
456 // ============================================================================
457 template < class PBASE >
459  const StatusCode st ,
460  const size_t mx ) const
461 {
462  // increase local counter of errors
463  const size_t num = ++m_errors[msg] ;
464  // If suppressed, just return
465  if ( num > mx ) { return st ; }
466  else if ( UNLIKELY(num == mx) ) // issue one-time suppression message
467  { return Print ( "The ERROR message is suppressed : '" +
468  msg + "'" , st , MSG::ERROR ) ; }
469  // return message
470  return Print ( msg , st , MSG::ERROR ) ;
471 }
472 // ============================================================================
473 
474 // ============================================================================
475 // Print the warning message and return status code
476 // ============================================================================
477 template < class PBASE >
479 ( const std::string& msg ,
480  const StatusCode st ,
481  const size_t mx ) const
482 {
483  // increase local counter of warnings
484  const size_t num = ++m_warnings[msg] ;
485  // If suppressed, just return
486  if ( num > mx ) { return st ; }
487  else if ( UNLIKELY(num == mx) ) // issue one-time suppression message
488  { return Print ( "The WARNING message is suppressed : '" +
489  msg + "'" , st , MSG::WARNING ) ; }
490  // return message
491  return Print ( msg , st , MSG::WARNING ) ;
492 }
493 // ============================================================================
494 
495 // ============================================================================
496 // Print the info message and return status code
497 // ============================================================================
498 template < class PBASE >
500 ( const std::string& msg ,
501  const StatusCode st ,
502  const size_t mx ) const
503 {
504  // increase local counter of warnings
505  const size_t num = ++m_infos[msg] ;
506  // If suppressed, just return
507  if ( num > mx ) { return st ; }
508  else if ( UNLIKELY(num == mx) ) // issue one-time suppression message
509  { return Print ( "The INFO message is suppressed : '" +
510  msg + "'" , st , MSG::INFO ) ; }
511  // return message
512  return Print ( msg , st , MSG::INFO ) ;
513 }
514 // ============================================================================
515 
516 // ============================================================================
517 // Print the message and return status code
518 // ============================================================================
519 template < class PBASE >
520 StatusCode GaudiCommon<PBASE>::Print( const std::string& msg ,
521  const StatusCode st ,
522  const MSG::Level lvl ) const
523 {
524  // perform printout ?
525  if ( !this->msgLevel( lvl ) ) { return st ; } // RETURN
526 
527  // use the predefined stream
528  MsgStream& str = this->msgStream( lvl ) ;
529  if ( typePrint() ) { str << System::typeinfoName(typeid(*this)) << ":: " ; }
530 
531  // print the message
532  str << msg ;
533 
534  // test status code
535  if ( st.isSuccess() ) { }
536  else if ( StatusCode::FAILURE != st.getCode() )
537  { str << " StatusCode=" << st.getCode() ; }
538  else
539  { str << " StatusCode=FAILURE" ; }
540 
541  // perform print operation
542  str << endmsg ;
543 
544  // return
545  return st;
546 }
547 // ============================================================================
548 
549 // ============================================================================
550 // Create and (re)-throw the exception
551 // ============================================================================
552 template < class PBASE >
553 void GaudiCommon<PBASE>::Exception( const std::string & msg ,
554  const GaudiException & exc ,
555  const StatusCode sc ) const
556 {
557  // increase local counter of exceptions
558  ++m_exceptions[ msg ];
559  Print ( "Exception (re)throw: " + msg , sc , MSG::FATAL ).ignore();
560  throw GaudiException( this->name() + ":: " + msg , this->name() , sc, exc);
561 }
562 // ============================================================================
563 
564 // ============================================================================
565 // Create and (re)-throw the exception
566 // ============================================================================
567 template < class PBASE >
568 void GaudiCommon<PBASE>::Exception( const std::string & msg ,
569  const std::exception & exc ,
570  const StatusCode sc ) const
571 {
572  // increase local counter of exceptions
573  ++m_exceptions[ msg ];
574  Print ( "Exception (re)throw: " + msg , sc , MSG::FATAL ).ignore();
575  throw GaudiException( this->name() + ":: " + msg+"("+exc.what()+")", "", sc );
576 }
577 // ============================================================================
578 
579 // ============================================================================
580 // Create and throw the exception
581 // ============================================================================
582 template < class PBASE >
583 void GaudiCommon<PBASE>::Exception( const std::string & msg ,
584  const StatusCode sc ) const
585 {
586  // increase local counter of exceptions
587  ++m_exceptions[ msg ];
588  Print ( "Exception throw: " + msg , sc , MSG::FATAL ).ignore();
589  throw GaudiException( this->name() + ":: " + msg , "", sc );
590 }
591 // ============================================================================
592 
593 // ============================================================================
594 // perform the actual printout of counters
595 // ============================================================================
596 template < class PBASE >
598 {
599  // print statistics
600  if ( counters().empty() ) { return 0 ; }
601  MsgStream& msg = this->msgStream ( level ) ;
602  //
603  msg << "Number of counters : " << counters().size() ;
604  //
605  if ( !counters().empty() ) { msg << std::endl << m_header ; }
606  //
607  for ( const auto& entry : counters() )
608  {
609  msg << std::endl
611  ( entry.first ,
612  entry.second ,
613  m_useEffFormat ,
614  m_format1 , m_format2 );
615  }
616  //
617  msg << endmsg ;
618  //
619  return counters().size() ;
620 }
621 // ============================================================================
622 
623 // ============================================================================
624 // perform the actual printout of error counters
625 // ============================================================================
626 template < class PBASE >
628 {
629  // format for printout
630  boost::format ftm ( " #%|-10s| = %|.8s| %|23t| Message = '%s'" );
631 
632  auto print = [&](const Counter& c, const std::string& label) {
633  for (const auto& i : c ) {
634  this->msgStream(level)
635  << ( ftm % label % i.second % i.first )
636  << endmsg;
637  }
638  };
639 
640  print( m_exceptions, "EXCEPTIONS" );
641  print( m_errors, "ERRORS" );
642  print( m_warnings, "WARNINGS" );
643  print( m_infos, "INFOS" );
644 
645  // return total number of errors+warnings+exceptions
646  return
647  m_exceptions .size () +
648  m_errors .size () +
649  m_warnings .size () +
650  m_infos .size () ;
651 }
652 // ============================================================================
653 
654 // ============================================================================
658 // ============================================================================
659 template < class PBASE >
661 {
662 
663  // print ALL properties
664  MsgStream& msg = this->msgStream ( level );
665  const auto& properties = this->getProperties() ;
666  msg << "List of ALL properties of "
667  << System::typeinfoName( typeid( *this ) ) << "/" << this->name()
668  << " #properties = " << properties.size() << endmsg ;
669  for ( const auto& property : reverse(properties) )
670  {
671  msg << "Property ['Name': Value] = " << *property << endmsg ;
672  }
673  return properties.size() ;
674 }
675 // ============================================================================
676 
677 // ============================================================================
678 // Handle method for changes in the Messaging levels
679 // ============================================================================
680 template < class PBASE >
682 {
683  // Force a new MsgStream object, to pick up the new settings
684  resetMsgStream();
685 
686  // adjust internal message level
687  m_msgLevel =
688  this->outputLevel() < (int) MSG::NIL ? MSG::NIL :
689  this->outputLevel() >= (int) MSG::NUM_LEVELS ? MSG::ALWAYS :
690  MSG::Level( this->outputLevel() ) ;
691 
692  // Keep MessageSvc up to date if needed
693  if ( this->msgSvc()->outputLevel(this->name()) != this->outputLevel() )
694  {
695  this->msgSvc()->setOutputLevel( this->name(), this->outputLevel() );
696  }
697 
698  // printout message
699  if ( this->msgLevel(MSG::DEBUG) )
700  {
701  this->debug() << "Property update for "
702  << theProp.name() << " : new value = " << this->outputLevel() << endmsg;
703  }
704 }
705 // ============================================================================
706 
707 // ============================================================================
708 // Methods for dealing with the TES and TDS
709 // ============================================================================
710 
711 // ============================================================================
712 // put results into Gaudi Event Transient Store
713 // ============================================================================
714 template < class PBASE >
716  DataObject* object ,
717  const std::string& location ,
718  const bool useRootInTES ) const
719 {
720  // check arguments
721  Assert ( svc , "put():: Invalid 'service'!" ) ;
722  Assert ( object , "put():: Invalid 'Object'!" ) ;
723  Assert ( !location.empty() , "put():: Invalid 'address' = '' " ) ;
724  // final data location
725  const std::string & fullLocation = fullTESLocation( location, useRootInTES );
726  // register the object!
727  const StatusCode status = '/' == fullLocation[0] ?
728  svc -> registerObject( fullLocation , object ) :
729  svc -> registerObject( "/Event/" + fullLocation , object ) ;
730  // check the result!
731  if ( status.isFailure() )
732  { Exception ( "put():: could not register '" +
733  System::typeinfoName( typeid( *object ) ) +
734  "' at address '" + fullLocation + "'" , status ) ; }
735  if ( this->msgLevel( MSG::DEBUG ) )
736  { Print( "The object of type '" +
737  System::typeinfoName( typeid( *object ) ) +
738  "' is registered in TS at address '"
739  + fullLocation + "'" , status , MSG::DEBUG ).ignore() ; }
740  return object;
741 }
742 // ============================================================================
743 
744 // ============================================================================
745 // Handle method for changes in the 'ErrorsPrint'
746 // ============================================================================
747 template < class PBASE >
749 {
750  // no action if not yet initialized
751  if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
752  if ( this -> errorsPrint() ) { this -> printErrors () ; }
753 }
754 // ============================================================================
755 // Handle method for changes in the 'PropertiesPrint'
756 // ============================================================================
757 template < class PBASE >
759 {
760  // no action if not yet initialized
761  if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
762  if ( this -> propsPrint() ) { this -> printProps ( MSG::ALWAYS ) ; }
763 }
764 // ============================================================================
765 // Handle method for changes in the 'StatPrint'
766 // ============================================================================
767 template < class PBASE >
769 {
770  // no action if not yet initialized
771  if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
772  if ( this -> statPrint() ) { this -> printStat ( MSG::ALWAYS ) ; }
773 }
774 // ============================================================================
775 
776 // ============================================================================
777 // The END
778 // ============================================================================
tuple c
Definition: gaudirun.py:392
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Define general base for Gaudi exception.
reverse_wrapper< T > reverse(T &&iterable)
Definition: reverse.h:30
def initialize()
Definition: AnalysisTest.py:12
StatusCode releaseSvc(const IInterface *svc) const
manual forced (and 'safe') release of the service
DataObject * put(IDataProviderSvc *svc, DataObject *object, const std::string &location, const bool useRootInTES=true) const
Register a data object or container into Gaudi Event Transient Store.
std::map< std::string, unsigned int > Counter
the actual type error/warning counter
Definition: GaudiCommon.h:104
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:93
const std::string & name() const
property name
Definition: Property.h:45
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void addToServiceList(SmartIF< IService > svc) const
Add the given service to the list of acquired services.
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
StatusCode Error(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the error message and return with the given StatusCode.
void initGaudiCommonConstructor(const IInterface *parent=0)
Constructor initializations.
Data provider interface definition.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Definition of the basic interface.
Definition: IInterface.h:234
void printStatHandler(Property &)
handler for "StatPrint" property
StatusCode Print(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const
Print the message and return with the given StatusCode.
The useful base class for data processing algorithms.
StatusCode Warning(const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const
Print the warning message and return with the given StatusCode.
void msgLevelHandler(Property &theProp)
Handle method for changes in the Messaging levels.
const TYPE & value() const
explicit conversion
Definition: Property.h:341
constexpr const struct GaudiCommon_details::svc_eq_t svc_eq
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
StatusCode releaseTool(const IAlgTool *tool) const
manual forced (and 'safe') release of the tool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:22
GAUDI_API std::string formatAsTableRow(const StatEntity &counter, const bool flag, const std::string &format1=" |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |", const std::string &format2="*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |")
print the counter in a form of the table row
Definition: StatEntity.cpp:299
The useful base class for tools.
Definition: GaudiTool.h:97
Implements the common functionality between GaudiTools and GaudiAlgorithms.
Definition: GaudiCommon.h:73
void printPropsHandler(Property &)
handler for "PropertiesPrint" property
StatusCode Info(const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const size_t mx=10) const
Print the info message and return with the given StatusCode.
#define UNLIKELY(x)
Definition: Kernel.h:126
long printStat(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of statistical counters
void addToToolList(IAlgTool *tool) const
Add the given tool to the list of acquired tools.
constexpr const struct GaudiCommon_details::svc_lt_t svc_lt
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
list i
Definition: ana.py:128
StatusCode release(const IInterface *interface) const
Manual forced (and 'safe') release of the active tool or service.
long printProps(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of properties
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
void printErrorHandler(Property &)
handler for "ErrorPrint" property
long printErrors(const MSG::Level level=MSG::ALWAYS) const
perform the actual printout of error counters
void Exception(const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const
Create and (re)-throw a given GaudiException.