Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:45

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2023 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 #include <GaudiAlg/GaudiTupleAlg.h>
0014 #include <GaudiAlg/ITupleTool.h>
0015 #include <GaudiAlg/Tuple.h>
0016 #include <GaudiAlg/TupleID.h>
0017 #include <GaudiAlg/TupleObj.h>
0018 #include <GaudiAlg/Tuples.h>
0019 #include <GaudiKernel/GenericMatrixTypes.h>
0020 #include <GaudiKernel/GenericVectorTypes.h>
0021 #include <GaudiKernel/Point3DTypes.h>
0022 #include <GaudiKernel/Point4DTypes.h>
0023 #include <GaudiKernel/SymmetricMatrixTypes.h>
0024 #include <GaudiKernel/Time.h>
0025 #include <GaudiKernel/Vector3DTypes.h>
0026 #include <GaudiKernel/Vector4DTypes.h>
0027 #include <GaudiPython/Vector.h>
0028 
0029 namespace CLHEP {
0030   class HepGenMatrix;
0031   class HepVector;
0032 } // namespace CLHEP
0033 
0034 namespace GaudiPython {
0035   // ==========================================================================
0036   /** @class TupleDecorator TupleDecorator.h GaudiPython/TupleDecorator.h
0037    *  Simple class which performs the decoration of the standard N-Tuple
0038    *  @see Tuples::Tuple
0039    *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
0040    *  @date   2005-08-04
0041    */
0042   class GAUDI_API TupleDecorator {
0043   public:
0044     // ========================================================================
0045     /// accessors to internal
0046     static INTuple* nTuple( const Tuples::Tuple& tuple );
0047     // ========================================================================
0048     /// accessors to internal
0049     static NTuple::Tuple* ntuple( const Tuples::Tuple& tuple );
0050     // ========================================================================
0051     /// status of the tuple
0052     static bool valid( const Tuples::Tuple& tuple );
0053     // ========================================================================
0054     /// commit the row
0055     static StatusCode write( const Tuples::Tuple& tuple );
0056     // ========================================================================
0057   public: // primitives
0058     // ========================================================================
0059     /// more or less simple columns:    long
0060     static StatusCode column( const Tuples::Tuple& tuple, const std::string& name, const int value );
0061     // ========================================================================
0062     /// more or less simple columns:    long
0063     static StatusCode column( const Tuples::Tuple& tuple, const std::string& name, const int value, const int minv,
0064                               const int maxv );
0065     // ========================================================================
0066     /// more or less simple columns:    double
0067     static StatusCode column( const Tuples::Tuple& tuple, const std::string& name, const double value );
0068     // ========================================================================
0069     /// more or less simple columns:    bool
0070     static StatusCode column( const Tuples::Tuple& tuple, const std::string& name, const bool value );
0071     // ========================================================================
0072     /// more or less simple columns:    long long
0073     static StatusCode column_ll( const Tuples::Tuple& tuple, const std::string& name, const long long value );
0074     // ========================================================================
0075     /// more or less simple columns:    unsigned long long
0076     static StatusCode column_ull( const Tuples::Tuple& tuple, const std::string& name, const unsigned long long value );
0077     // ========================================================================
0078   public: // event tag collections
0079     // ========================================================================
0080     /// more or less simple columns:    IOpaqueAddress
0081     static StatusCode column( const Tuples::Tuple& tuple, const std::string& name, IOpaqueAddress* value );
0082     // ========================================================================
0083     /// more or less simple columns:    IOpaqueAddress
0084     static StatusCode column( const Tuples::Tuple& tuple, IOpaqueAddress* value );
0085     // ========================================================================
0086   public: // 4D kinematics
0087     // ========================================================================
0088     /// Advanced columns: LorentzVector
0089     static StatusCode column( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::LorentzVector& value );
0090     // ========================================================================
0091   public: // 3D geometry
0092     // ========================================================================
0093     /// Advanced columns: 3D-vector
0094     static StatusCode column( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::XYZVector& value );
0095     // ========================================================================
0096     /// Advanced columns: 3D-points
0097     static StatusCode column( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::XYZPoint& value );
0098     // ========================================================================
0099   public: // floating size arrays
0100     // ========================================================================
0101     /// Advanced columns: floating-size arrays
0102     static StatusCode farray( const Tuples::Tuple& tuple, const std::string& name, const std::vector<double>& data,
0103                               const std::string& length, const size_t maxv );
0104     // ========================================================================
0105   public: // floating-size matrices
0106     // ========================================================================
0107     /// Advanced columns: floating-size matrices
0108     static StatusCode fmatrix( const Tuples::Tuple& tuple, const std::string& name, const GaudiPython::Matrix& data,
0109                                const Tuples::TupleObj::MIndex cols, // fixed !!!
0110                                const std::string& length, const size_t maxv );
0111     // ========================================================================
0112     /// Advanced columns: floating-size matrices
0113     static StatusCode fmatrix( const Tuples::Tuple& tuple, const std::string& name,
0114                                const GaudiUtils::VectorMap<int, double>& info, const std::string& length,
0115                                const size_t maxv );
0116     // ========================================================================
0117   public: // fixed size arrays
0118     // ========================================================================
0119     /// Advanced columns: fixed size arrays
0120     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const std::vector<double>& data );
0121     // ========================================================================
0122     /// Advanced columns: fixed size arrays
0123     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Vector1& data );
0124     // ========================================================================
0125     /// Advanced columns: fixed size arrays
0126     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Vector2& data );
0127     // ========================================================================
0128     /// Advanced columns: fixed size arrays
0129     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Vector3& data );
0130     // ========================================================================
0131     /// Advanced columns: fixed size arrays
0132     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Vector4& data );
0133     // ========================================================================
0134     /// Advanced columns: fixed size arrays
0135     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Vector5& data );
0136     // ========================================================================
0137   public: // fixed size matrices
0138     // ========================================================================
0139     /// Advanced columns: fixed size arrays
0140     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Vector6& data );
0141     // ========================================================================
0142     /// Advanced columns: fixed size arrays
0143     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Vector7& data );
0144     // ========================================================================
0145     /// Advanced columns: fixed size arrays
0146     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Vector8& data );
0147     // ========================================================================
0148     /// Advanced columns: fixed size arrays
0149     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Vector9& data );
0150     // ========================================================================
0151     /// Advanced columns: fixed size matrices
0152     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const GaudiPython::Matrix& data,
0153                               const Tuples::TupleObj::MIndex cols ); // fixed !!!
0154     // ========================================================================
0155     /// Advanced columns: fixed size matrices: square matrices
0156     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix2x2& value );
0157     // ========================================================================
0158     /// Advanced columns: fixed size matrices: square matrices
0159     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix3x3& value );
0160     // ========================================================================
0161     /// Advanced columns: fixed size matrices: square matrices
0162     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix4x4& value );
0163     // ========================================================================
0164     /// Advanced columns: fixed size matrices: square matrices
0165     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix5x5& value );
0166     // ========================================================================
0167     /// Advanced columns: fixed size matrices: square matrices
0168     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix6x6& value );
0169     // ========================================================================
0170     /// Advanced columns: fixed size matrices: square matrices
0171     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix7x7& value );
0172     // ========================================================================
0173     /// Advanced columns: fixed size matrices: square matrices
0174     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix8x8& value );
0175     // ========================================================================
0176     /// Advanced columns: fixed size matrices: square matrices
0177     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix9x9& value );
0178     // ========================================================================
0179     /// Advanced columns: fixed size matrices: square matrices
0180     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix1x1& value );
0181     // ========================================================================
0182     /// Advanced columns: fixed size matrices: non-square matrices
0183     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix1x3& value );
0184     // ========================================================================
0185     /// Advanced columns: fixed size matrices: non-square matrices
0186     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix1x5& value );
0187     // ========================================================================
0188     /// Advanced columns: fixed size matrices: non-square matrices
0189     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix1x6& value );
0190     // ========================================================================
0191     /// Advanced columns: fixed size matrices: non-square matrices
0192     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix4x3& value );
0193     // ========================================================================
0194     /// Advanced columns: fixed size matrices: non-square matrices
0195     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix3x4& value );
0196     // ========================================================================
0197     /// Advanced columns: fixed size matrices: non-square matrices
0198     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix3x5& value );
0199     // ========================================================================
0200     /// Advanced columns: fixed size matrices: non-square matrices
0201     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix3x6& value );
0202     // ========================================================================
0203     /// Advanced columns: fixed size matrices: non-square matrices
0204     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix2x3& value );
0205     // ========================================================================
0206     /// Advanced columns: fixed size matrices: non-square matrices
0207     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Matrix3x2& value );
0208     // ========================================================================
0209     /// Advanced columns: fixed size matrices: symmetric matrices
0210     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::SymMatrix1x1& value );
0211     // ========================================================================
0212     /// Advanced columns: fixed size matrices: symmetric matrices
0213     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::SymMatrix2x2& value );
0214     // ========================================================================
0215     /// Advanced columns: fixed size matrices: symmetric matrices
0216     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::SymMatrix3x3& value );
0217     // ========================================================================
0218     /// Advanced columns: fixed size matrices: symmetric matrices
0219     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::SymMatrix4x4& value );
0220     // ========================================================================
0221     /// Advanced columns: fixed size matrices: symmetric matrices
0222     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::SymMatrix5x5& value );
0223     // ========================================================================
0224     /// Advanced columns: fixed size matrices: symmetric matrices
0225     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::SymMatrix6x6& value );
0226     // ========================================================================
0227     /// Advanced columns: fixed size matrices: symmetric matrices
0228     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::SymMatrix7x7& value );
0229     // ========================================================================
0230     /// Advanced columns: fixed size matrices: symmetric matrices
0231     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::SymMatrix8x8& value );
0232     // ========================================================================
0233     /// Advanced columns: fixed size matrices: symmetric matrices
0234     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::SymMatrix9x9& value );
0235     // ========================================================================
0236   public: // some auxillary  objects
0237     // ========================================================================
0238     /// advanced column: time
0239     static StatusCode column( const Tuples::Tuple& tuple, const std::string& name, const Gaudi::Time& value );
0240     /// advanced column: time
0241     static StatusCode column( const Tuples::Tuple& tuple, const Gaudi::Time& value );
0242     // ========================================================================
0243   public: // CLHEP: should we keep it ?
0244     // ========================================================================
0245     /// Advanced columns: fixed size arrays
0246     static StatusCode array( const Tuples::Tuple& tuple, const std::string& name, const CLHEP::HepVector& data );
0247     /// Advanced columns: floating-size arrays
0248     static StatusCode farray( const Tuples::Tuple& tuple, const std::string& name, const CLHEP::HepVector& data,
0249                               const std::string& length, const size_t maxv );
0250     /// Advanced columns: fixed size matrices
0251     static StatusCode matrix( const Tuples::Tuple& tuple, const std::string& name, const CLHEP::HepGenMatrix& data );
0252     /// Advanced columns: floating-size matrices
0253     static StatusCode fmatrix( const Tuples::Tuple& tuple, const std::string& name, const CLHEP::HepGenMatrix& data,
0254                                const Tuples::TupleObj::MIndex cols, // fixed !!!
0255                                const std::string& length, const size_t maxv );
0256     // ========================================================================
0257   };
0258   // ==========================================================================
0259   /** @class TupleAlgDecorator TupleDecorator.h GaudiPython/TupleDecorator.h
0260    *  Simple class to perform the "decoration" of Tuples in Python/ROOT
0261    *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
0262    *  @date   2005-08-17
0263    */
0264   class GAUDI_API TupleAlgDecorator {
0265   public:
0266     // ========================================================================
0267     /// get n-tuple (book-on-demand)
0268     static Tuples::Tuple nTuple( const GaudiTupleAlg& algo, const std::string& title,
0269                                  const CLID& clid = CLID_ColumnWiseTuple );
0270     // ========================================================================
0271     /// get n-tuple (book-on-demand)
0272     static Tuples::Tuple nTuple( const GaudiTupleAlg& algo, const GaudiAlg::TupleID& ID, const std::string& title,
0273                                  const CLID& clid = CLID_ColumnWiseTuple );
0274     // ========================================================================
0275     /// get n-tuple (book-on-demand)
0276     static Tuples::Tuple nTuple( const GaudiTupleAlg& algo, const int ID, const std::string& title,
0277                                  const CLID& clid = CLID_ColumnWiseTuple );
0278     // ========================================================================
0279     /// get n-tuple (book-on-demand)
0280     static Tuples::Tuple nTuple( const GaudiTupleAlg& algo, const std::string& ID, const std::string& title,
0281                                  const CLID& clid = CLID_ColumnWiseTuple );
0282     // ========================================================================
0283     /// get n-tuple (book-on-demand)
0284     static Tuples::Tuple evtCol( const GaudiTupleAlg& algo, const std::string& title,
0285                                  const CLID& clid = CLID_ColumnWiseTuple );
0286     // ========================================================================
0287     /// get n-tuple (book-on-demand)
0288     static Tuples::Tuple evtCol( const GaudiTupleAlg& algo, const GaudiAlg::TupleID& ID, const std::string& title,
0289                                  const CLID& clid = CLID_ColumnWiseTuple );
0290     // ========================================================================
0291     /// get n-tuple (book-on-demand)
0292     static Tuples::Tuple evtCol( const GaudiTupleAlg& algo, const int ID, const std::string& title,
0293                                  const CLID& clid = CLID_ColumnWiseTuple );
0294     // ========================================================================
0295     /// get n-tuple (book-on-demand)
0296     static Tuples::Tuple evtCol( const GaudiTupleAlg& algo, const std::string& ID, const std::string& title,
0297                                  const CLID& clid = CLID_ColumnWiseTuple );
0298     // ========================================================================
0299   };
0300   // ==========================================================================
0301   /** @class TupleToolDecorator TupleDecorator.h GaudiPython/TupleDecorator.h
0302    *  Simple class to perform the "decoration" of Tuples in Python/ROOT
0303    *  @author Vanya BELYAEV ibelyaev@physics.syr.edu
0304    *  @date   2005-08-17
0305    */
0306   class GAUDI_API TupleToolDecorator {
0307   public:
0308     // ========================================================================
0309     /// get n-tuple (book-on-demand)
0310     static Tuples::Tuple nTuple( const ITupleTool& tool, const std::string& title,
0311                                  const CLID& clid = CLID_ColumnWiseTuple ) {
0312       return tool.nTuple( title, clid );
0313     }
0314     // ========================================================================
0315     /// get n-tuple (book-on-demand)
0316     static Tuples::Tuple nTuple( const ITupleTool& tool, const GaudiAlg::TupleID& ID, const std::string& title,
0317                                  const CLID& clid = CLID_ColumnWiseTuple ) {
0318       return tool.nTuple( ID, title, clid );
0319     }
0320     // ========================================================================
0321     /// get n-tuple (book-on-demand)
0322     static Tuples::Tuple nTuple( const ITupleTool& tool, const int ID, const std::string& title,
0323                                  const CLID& clid = CLID_ColumnWiseTuple ) {
0324       return tool.nTuple( ID, title, clid );
0325     }
0326     // ========================================================================
0327     /// get n-tuple (book-on-demand)
0328     static Tuples::Tuple nTuple( const ITupleTool& tool, const std::string& ID, const std::string& title,
0329                                  const CLID& clid = CLID_ColumnWiseTuple ) {
0330       return tool.nTuple( ID, title, clid );
0331     }
0332     // ========================================================================
0333     /// get n-tuple (book-on-demand)
0334     static Tuples::Tuple evtCol( const ITupleTool& tool, const std::string& title,
0335                                  const CLID& clid = CLID_ColumnWiseTuple ) {
0336       return tool.evtCol( title, clid );
0337     }
0338     // ========================================================================
0339     /// get n-tuple (book-on-demand)
0340     static Tuples::Tuple evtCol( const ITupleTool& tool, const GaudiAlg::TupleID& ID, const std::string& title,
0341                                  const CLID& clid = CLID_ColumnWiseTuple ) {
0342       return tool.nTuple( ID, title, clid );
0343     }
0344     // ========================================================================
0345     /// get n-tuple (book-on-demand)
0346     static Tuples::Tuple evtCol( const ITupleTool& tool, const int ID, const std::string& title,
0347                                  const CLID& clid = CLID_ColumnWiseTuple ) {
0348       return tool.nTuple( ID, title, clid );
0349     }
0350     // ========================================================================
0351     /// get n-tuple (book-on-demand)
0352     static Tuples::Tuple evtCol( const ITupleTool& tool, const std::string& ID, const std::string& title,
0353                                  const CLID& clid = CLID_ColumnWiseTuple ) {
0354       return tool.nTuple( ID, title, clid );
0355     }
0356     // ========================================================================
0357   };
0358   // ==========================================================================
0359 } // namespace GaudiPython