Commit f88b01eb authored by cvs2svn's avatar cvs2svn
Browse files

This commit was manufactured by cvs2svn to create branch 'GAUDI_v18r6b'.

git-svn-id: svn+ssh://svn.cern.ch/reps/gaudi/distribution/branches/GAUDI/GAUDI_v18r6b@3075 53ecefc3-a64d-0410-9bdf-b8581fa3287e
parent f76fcb5a
// $Id: CheckForNaN.h,v 1.3 2005/11/18 17:28:31 mato Exp $
// ============================================================================
#ifndef GAUDIALG_CHECKFORNAN_H
#define GAUDIALG_CHECKFORNAN_H 1
// ============================================================================
// Include files
// ============================================================================
// ============================================================================
#if defined (__GNUG__) || defined (__GNUC__)
// Problem with -ansi option of g++: those prototypes are not taken.
extern "C" {
int isnan ( double ) throw();
int finite ( double ) throw();
}
#endif
// ============================================================================
// ============================================================================
#if defined (_WIN32)
#include <float.h>
#endif
// ============================================================================
namespace
{
#if defined (_WIN32)
inline int lfin ( double x ) { return _finite( x ) ; }
inline int lnan ( double x ) { return _isnan ( x ) ; }
#else
inline int lfin ( double x ) { return finite( x ) ; }
inline int lnan ( double x ) { return isnan ( x ) ; }
#endif
};
#endif // GAUDIALG_CHECKFORNAN_H
#include "GaudiKernel/Algorithm.h"
#include "GaudiKernel/Property.h"
class EventCounter : public Algorithm {
public:
/**
** Constructor(s)
**/
EventCounter( const std::string& name, ISvcLocator* pSvcLocator );
/**
** Destructor
**/
~EventCounter( );
/*****************************
** Public Function Members **
*****************************/
StatusCode initialize();
StatusCode execute();
StatusCode finalize();
private:
/**************************
** Private Data Members **
**************************/
/**
** The frequency with which the number of events
** should be reported. The default is 1, corresponding
** to every event.
**/
IntegerProperty m_frequency;
/**
** The number of events skipped since the last time
** the count was reported.
**/
int m_skip;
/**
** The total events seen.
**/
int m_total;
};
// $Id: GaudiAlg.h,v 1.4 2006/03/09 10:28:14 hmd Exp $
// ============================================================================
#ifndef GAUDIALG_GAUDIALG_H
#define GAUDIALG_GAUDIALG_H 1
// ============================================================================
// Include files
// ============================================================================
// STD & STL
// ============================================================================
#include <string>
// ============================================================================
/** @namespace GaudiAlg GaudiAlg.h GaudiAlg/GaudiAlg.h
* Namespace with defintion of useful constants, types and function,
* common for all classes from GaudiAlg package
* @author Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr
* @date 2005-08-06
*/
namespace GaudiAlg
{
/** convers number into teh string
* (remove the actual code duplication from namespaces
* GaudiAlgLocal and GaudiToolLocal
* @param number value
* @return string representation
*/
std::string fileLine( const int number ) ;
} // end of namespace GaudiAlg
#endif // GAUDIALG_GAUDIALG_H
// $Id: GaudiAlgorithm.h,v 1.13 2006/03/15 15:18:44 hmd Exp $
// ============================================================================
#ifndef GAUDIALG_GaudiAlgorithm_H
#define GAUDIALG_GaudiAlgorithm_H 1
// ============================================================================
// Include files
// ============================================================================
// GaudiKernel
// ============================================================================
#include "GaudiKernel/Algorithm.h"
// ============================================================================
// GaudiAlg
// ============================================================================
#include "GaudiAlg/GaudiAlg.h"
#include "GaudiAlg/GaudiCommon.h"
// ============================================================================
// forward declarations
class INTupleSvc ;
// ============================================================================
/* @file GaudiAlgorithm.h
*
* Header file for class GaudiAlgorithm.
* The actual code is mainly imported from
* - LHCb Calorimeter software and
* - LHCb C++ toolkit for smart and friendly physics analysis "LoKi"
*
* This base class allows "easy"(=="1 line") access to tools
* and services. This access is safe in the sense that there
* is no need to worry about the reference counts for tools
* and services.
*
* The base class allows "easy" (=="1 line") access to data in
* Gaudi Transient Stores. The functionality includes the checking
* of the presence of the data at the given location, checking the
* validity of the data, retrieval of valid data and "forced" retrive
* of valid data (create if there is no data).
*
* The base class allows to perform an easy error, warning and exception
* treatments, including the accumulated statistics of exceptions, errors
* and warnings.
*
* The base class also includes utilities for general statistical counters.
*
* It has been reported that usage of this base class results in
* significant shrinkage of existing code lines.
*
* @attention
* See also the class GaudiCommon, which implements some of the common
* functionality between GaudiTool and GaudiAlgorithm.
*
* @author Vanya BELYAEV Ivan.Belyaev@itep.ru
* @author Chris Jones Christopher.Rob.Jones@cern.ch
* @date 30/06/2001
*/
// ============================================================================
// Forward declarations
template<class T> class AlgFactory; // GaudiKernel
// ============================================================================
/** @class GaudiAlgorithm GaudiAlgorithm.h GaudiAlg/GaudiAlgorithm.h
*
* The useful base class for data processing algorithms.
* Small extension of ordinary the Algorithm base class.
*
* This base class allows "easy"(=="1 line") access to tools
* and services. This access is safe in the sense that there
* is no need to worry about the reference counts for tools
* and services.
*
* The base class allows "easy" (=="1 line") access to data in
* Gaudi Transient Stores. The functionality includes the checking
* of the presence of the data at the given location, checking the
* validity of the data, retrieval of valid data and "forced" retrive
* of valid data (create if there is no data).
*
* The base class allows to perform an easy error, warning and exception
* treatments, including the accumulated statistics of exceptions, errors
* and warnings.
*
* The base class also includes utilities for general statistical counters.
*
* It has been reported that usage of this base class results in
* significant shrinkage of existing code lines.
*
* @attention
* See also the class GaudiCommon, which implements some of the common
* functionality between GaudiTool and GaudiAlgorithm.
*
* @author Vanya BELYAEV Ivan.Belyaev@itep.ru
* @author Chris Jones Christopher.Rob.Jones@cern.ch
* @date 30/06/2001
*/
// ============================================================================
class GaudiAlgorithm : public GaudiCommon<Algorithm>
{
// friend factory for instantiation
friend class AlgFactory<GaudiAlgorithm>;
public:
/** standard initialization method
* @see Algorithm
* @see IAlgorithm
* @return status code
*/
virtual StatusCode initialize();
/** standard execution method
* @see Algorithm
* @see IAlgorithm
* @return status code
*/
virtual StatusCode execute ();
/** standard finalization method
* @see Algorithm
* @see IAlgorithm
* @return status code
*/
virtual StatusCode finalize ();
public:
// following methods cannot go in GaudiCommon since they use methods ( evtSvc()
// and detDvc() ) that are not members of AlgTool.
// Also some methods seem which are members of the base class do not seem
// to be found unless forwarding methods are put here ??
/** @brief Register a data object or container into Gaudi Event Transient Store
*
* @code
*
* MCHits * hits = new MCHits();
* put( evtSvc(), hits, "/Event/MC/Hits" );
*
* @endcode
*
* @see IDataProviderSvc
*
* @param svc Pointer to data provider service
* @param object Data object or container to be registered
* @param address Address in Gaudi Event Transient Store ("/Event" could be omitted )
* @exception GaudiException for invalid event data service
* @exception GaudiException for invalid object
* @exception GaudiException for error result from event data service
* @return StatusCode
* @retval StatusCode::SUCCESS Data was successfully placed in the TES.
* @retval StatusCode::FAILURE Failed to store data in the TES.
*/
inline void put ( IDataProviderSvc* svc ,
DataObject* object ,
const std::string& address ) const
{
GaudiCommon<Algorithm>::put ( svc , object , address ) ;
}
/** @brief Register a data object or container into Gaudi Event Transient Store
*
* @see IDataProviderSvc
*
* @code
*
* MCHits * hits = new MCHits();
* put( hits, "/Event/MC/Hits" );
*
* @endcode
*
* @param object Data object or container to be registered
* @param address Address in Gaudi Event Transient Store ("/Event" could be omitted )
* @exception GaudiException for invalid event data service
* @exception GaudiException for invalid object
* @exception GaudiException for error result from event data service
* @return StatusCode
* @retval StatusCode::SUCCESS Data was successfully placed in the TES.
* @retval StatusCode::FAILURE Failed to store data in the TES.
*/
inline void put ( DataObject* object ,
const std::string& address ) const
{
GaudiCommon<Algorithm>::put ( evtSvc() , object , address ) ;
}
/** @brief Templated access to the data in Gaudi Transient Store
*
* Quick and safe access to the data in Gaudi transient store.
* The method located the data at given address and perform the
* debug printout about located data
*
* @code
*
* MCHits* hits = get<MCHits>( evtSvc() , "/Event/MC/Hits" );
*
* @endcode
*
* @see IDataProviderSvc
* @see SmartDataPtr
*
* @exception GaudiException for Invalid Data Provider Service
* @exception GaudiException for invalid/unavailable data
*
* @param svc Pointer to data service (data provider)
* @param location data location/address in Gaudi Transient Store
* @return pointer to the data object
*/
template < class TYPE >
inline TYPE* get ( IDataProviderSvc* svc ,
const std::string& location ) const
{
return GaudiCommon<Algorithm>::get<TYPE> ( svc , location ) ;
}
/** @brief Templated access to the data from Gaudi Event Transient Store
*
* Quick and safe access to the data in Gaudi transient store.
*
* The method located the data at the given address and perform the
* debug printout about located data.
*
* @code
*
* MCParticles* mcps = get<MCParticles>( MCParticleLocation::Default );
*
* @endcode
*
* @param location Data location/address in Gaudi Transient Store
* @return Pointer to the data object
*/
template < class TYPE >
inline TYPE* get ( const std::string& location ) const
{
return GaudiCommon<Algorithm>::get<TYPE> ( evtSvc() , location ) ;
}
/** @brief Templated access to the detector data from the
* Gaudi Detector Transient Store
*
* Quick and safe access to the detector data in Gaudi transient store.
*
* The method located the detector at the given address and perform the
* debug printout about located detector.
*
* @code
*
* MyDet* mdet = getDet<MyDet>( detSvc() , "/dd/Structure/LHCb/MyDet" );
*
* @endcode
*
* @param svc Pointer to data service (data provider)
* @param location Detector location/address in Gaudi Transient Store
* @return Pointer to the detector object
*/
template < class TYPE >
inline TYPE* getDet ( IDataProviderSvc* svc ,
const std::string& location ) const
{
return GaudiCommon<Algorithm>::get<TYPE> ( svc , location ) ;
}
/** @brief Templated access to the detector data from the
* Gaudi Detector Transient Store
*
* Quick and safe access to the detector data in Gaudi transient store.
*
* The method located the detector at the given address and perform the
* debug printout about located detector.
*
* @code
*
* MyDet* mdet = getDet<MyDet>( "/dd/Structure/LHCb/MyDet" );
*
* @endcode
*
* @param location Detector location/address in Gaudi Transient Store
* @return Pointer to the detector object
*/
template < class TYPE >
inline TYPE* getDet ( const std::string& location ) const
{
return GaudiCommon<Algorithm>::get<TYPE> ( detSvc() , location ) ;
}
/** @brief Check the existence of a data object or container
* in the Gaudi Transient Event Store
*
* @code
*
* bool a1 = exist<DataObject>( evtSvc(), "/Event/MyObject" ) ;
* bool a2 = exist<MyHits> ( evtSvc(), "/Event/MyHits" ) ;
*
* @endcode
*
* @param svc Pointer to data service (data provider)
* @param location Address in Gaudi Transient Event Store
* @return Boolean indicating status of the request
* @retval true Data object or container exists and implements a proper interface
* @retval true Failed to locate the data object or container
*/
template < class TYPE >
inline bool exist ( IDataProviderSvc* svc ,
const std::string& location ) const
{
return GaudiCommon<Algorithm>::exist<TYPE> ( svc , location ) ;
}
/** @brief Check the existence of a data object or container
* in the Gaudi Transient Event Store
*
* @code
*
* bool a1 = exist<DataObject>( "/Event/MyObject" ) ;
* bool a2 = exist<MyHits> ( "/Event/MyHits" ) ;
*
* @endcode
*
* @param location Address in Gaudi Transient Event Store
* @return Boolean indicating status of the request
* @retval true Data object or container exists and implements a proper interface
* @retval true Failed to locate the data object or container
*/
template < class TYPE >
inline bool exist ( const std::string& location ) const
{
return GaudiCommon<Algorithm>::exist<TYPE> ( evtSvc() , location ) ;
}
/** @brief Check the existence of detector objects in the Gaudi
* Transient Detector Store
*
* @code
*
* bool a1 = existDet<DataObject> ( detSvc(), "/dd/Structure/MyObject" ) ;
* bool a2 = existDet<Material> ( detSvc(), "/dd/Structure/Material/Air" ) ;
*
* @endcode
*
* @param svc Pointer to data service (data provider)
* @param location Address in Gaudi Transient Detector Store
* @return Boolean indicating status of the request
* @retval true Detector object exists and implements a proper interface
* @retval false Failed to locate the data object
*/
template < class TYPE >
inline bool existDet ( IDataProviderSvc* svc ,
const std::string& location ) const
{
return GaudiCommon<Algorithm>::exist<TYPE> ( svc , location ) ;
}
/** @brief Check the existence of detector objects in the Gaudi
* Transient Detector Store
*
* @code
*
* bool a1 = existDet<DataObject> ( "/dd/Structure/MyObject" ) ;
* bool a2 = existDet<Material> ( "/dd/Structure/Material/Air" ) ;
*
* @endcode
*
* @param location Address in Gaudi Transient Detector Store
* @return Boolean indicating status of the request
* @retval true Detector object exists and implements a proper interface
* @retval false Failed to locate the data object
*/
template < class TYPE >
inline bool existDet ( const std::string& location ) const
{
return GaudiCommon<Algorithm>::exist<TYPE> ( detSvc() , location ) ;
}
/** @brief Get the existing data object from Gaudi Event Transient store.
* Alternatively, create new object and register it in TES
* and return if object does not exist.
*
* @code
*
* MyHits* hits = getOrCreate<MyHits,MyHits>( evtSvc() , "/Event/MyHits" ) ;
*
* @endcode
*
* @exception GaudiException for Invalid Data Provider Service
* @exception GaudiException for invalid/unavailable data
*
* @param svc Pointer to data service (data provider)
* @param location Location in Gaudi Transient Event Store
* @return A valid pointer to the object
*/
template < class TYPE , class TYPE2 >
inline TYPE* getOrCreate ( IDataProviderSvc* svc ,
const std::string& location ) const
{
return GaudiCommon<Algorithm>::getOrCreate<TYPE,TYPE2> ( svc , location ) ;
}
/** @brief Get the existing data object from Gaudi Event Transient store.
* Alternatively, create new object and register it in TES
* and return if object does not exist.
*
* @code
*
* MyHits* hits = getOrCreate<MyHits,MyHits>( "/Event/MyHits" ) ;
*
* @endcode
*
* @exception GaudiException for Invalid Data Provider Service
* @exception GaudiException for invalid/unavailable data
*
* @param location Location in Gaudi Transient Event Store
* @return A valid pointer to the object
*/
template < class TYPE , class TYPE2 >
inline TYPE* getOrCreate ( const std::string& location ) const
{
return GaudiCommon<Algorithm>::getOrCreate<TYPE,TYPE2> ( evtSvc() , location ) ;
}
protected:
/** Standard constructor (protected)
* @see Algorithm
* @param name name of the algorithm
* @param pSvcLocator poinetr to Service Locator
*/
GaudiAlgorithm ( const std::string& name ,
ISvcLocator* pSvcLocator );
/// destructor, virtual and protected
virtual ~GaudiAlgorithm();
public:
/** Access the standard event collection service
* @return pointer to the event collection service
*/
INTupleSvc* GaudiAlgorithm::evtColSvc() const;
private:
/// no public default constructor
GaudiAlgorithm();
/// no public copy constructor
GaudiAlgorithm ( const GaudiAlgorithm& );
/// no public assignment operator
GaudiAlgorithm& operator = ( const GaudiAlgorithm& );
private:
/// Pointer to the event tag collection service
mutable INTupleSvc* m_evtColSvc ;
};
// ============================================================================
// ============================================================================
// The END
// ============================================================================
#endif // GAUDIALG_GaudiAlgorithm_H
// ============================================================================
This diff is collapsed.
// $Id: GaudiCommonImp.h,v 1.7 2006/05/31 16:17:53 hmd Exp $
// ============================================================================
#ifndef GAUDIALG_GAUDICOMMONIMP_H
#define GAUDIALG_GAUDICOMMONIMP_H 1
// ============================================================================
// Include files
// ============================================================================
// GaudiAlg
// ============================================================================
#include "GaudiAlg/GaudiCommon.h"
// ============================================================================
// ============================================================================
/** @file
* The implementation of inline/templated methods for class GaudiCommon
* @see GaudiCommon
* @author Vanya BELYAEV Ivan.Belyaev@itep.ru
* @author Chris Jones Christopher.Rob.Jones@cern.ch
* @date 2004-01-19
*/
// ============================================================================
// ============================================================================
// Templated access to the data in Gaudi Transient Store
// ============================================================================
template < class PBASE >
template < class TYPE >
inline TYPE* GaudiCommon<PBASE>::get
( IDataProviderSvc* service ,
const std::string& location ) const
{
// check the environment
Assert( 0 != service , "get():: IDataProvider* points to NULL!" ) ;
SmartDataPtr<TYPE> obj( service , location ) ;
if ( !obj ) { Exception ( "get():: No valid data at '" + location + "'" ) ; }
TYPE* aux = obj ;
if ( !aux ) { Exception ( "get():: No valid data at '" + location + "'" ) ; }