Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:07:01

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #pragma once
0012 
0013 /**
0014  * @brief Header file for std:chrono::duration-based Counters
0015  *
0016  * Include this header file (instead of GaudiKernel/Counters.h) if you want to
0017  * use std::chrono::duration-based Counters. It includes support for the required
0018  * arithmetic and stream operations.
0019  */
0020 #include <chrono>
0021 #include <cmath>
0022 
0023 namespace Gaudi {
0024   namespace Accumulators {
0025     /*
0026      * std::chrono::duration only supports arithmetic operations that preserve the unit
0027      * of time, e.g. there are no operations that would result in units of ms^2. This can
0028      * be inconvenient for the use in general purpose libraries like Gaudi::Accumulators.
0029      * This header provides the missing operators.
0030      */
0031 
0032     /// sqrt for std::chrono::duration
0033     template <class Rep, class Period>
0034     auto sqrt( std::chrono::duration<Rep, Period> d ) {
0035       return std::chrono::duration<Rep, Period>( static_cast<Rep>( std::round( std::sqrt( d.count() ) ) ) );
0036     }
0037 
0038     /// Multiplication of two std::chrono::duration objects with same Period
0039     template <class Rep1, class Rep2, class Period>
0040     auto operator*( const std::chrono::duration<Rep1, Period>& lhs, const std::chrono::duration<Rep2, Period>& rhs ) {
0041       return std::chrono::duration<std::common_type_t<Rep1, Rep2>, Period>( lhs.count() * rhs.count() );
0042     }
0043   } // namespace Accumulators
0044 } // namespace Gaudi
0045 
0046 #include <Gaudi/Accumulators.h>
0047 #include <Gaudi/Chrono/ChronoIO.h>