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