Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:48

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /*
0027  * =============================================================================
0028  *
0029  *       Filename:  CexmcASTEval.hh
0030  *
0031  *    Description:  abstract syntax tree for custom filter eval
0032  *
0033  *        Version:  1.0
0034  *        Created:  17.07.2010 15:43:09
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * =============================================================================
0042  */
0043 
0044 #ifndef CEXMC_AST_EVAL_HH
0045 #define CEXMC_AST_EVAL_HH
0046 
0047 #ifdef CEXMC_USE_CUSTOM_FILTER
0048 
0049 #include <map>
0050 #include <string>
0051 #include <boost/variant/variant.hpp>
0052 #include "CexmcAST.hh"
0053 #include "CexmcEventSObject.hh"
0054 #include "CexmcEventFastSObject.hh"
0055 #include "CexmcException.hh"
0056 #include "CexmcCommon.hh"
0057 
0058 
0059 class  CexmcASTEval : public CexmcAST::BasicEval
0060 {
0061     private:
0062         typedef boost::variant< const CexmcEnergyDepositCalorimeterCollection *,
0063                                 const bool * >    VarAddr;
0064 
0065         typedef std::map< std::string, VarAddr >  VarAddrMap;
0066 
0067         typedef VarAddrMap::value_type            VarAddrMapData;
0068 
0069     public:
0070         explicit CexmcASTEval(
0071                         const CexmcEventFastSObject *  evFastSObject = NULL,
0072                         const CexmcEventSObject *  evSObject = NULL );
0073 
0074     public:
0075         void  SetAddressedData(
0076                         const CexmcEventFastSObject *  evFastSObject_ = NULL,
0077                         const CexmcEventSObject *  evSObject_ = NULL );
0078 
0079         void  BindAddresses( CexmcAST::Subtree &  ast );
0080 
0081         void  ResetAddressBinding( CexmcAST::Subtree &  ast );
0082 
0083     private:
0084         ScalarValueType  GetFunScalarValue( const CexmcAST::Subtree &  ast )
0085                                                                         const;
0086 
0087         ScalarValueType  GetVarScalarValue( const CexmcAST::Variable &  var )
0088                                                                         const;
0089 
0090         void             GetEDCollectionValue( const CexmcAST::Node &  node,
0091                     CexmcEnergyDepositCalorimeterCollection &  edCol ) const;
0092 
0093     private:
0094         const G4double *  GetThreeVectorElementAddrByIndex(
0095                                     const CexmcSimpleThreeVectorStore &  vect,
0096                                     G4int  index ) const;
0097 
0098         const G4double *  GetLorentzVectorElementAddrByIndex(
0099                                     const CexmcSimpleLorentzVectorStore &  vect,
0100                                     G4int  index ) const;
0101 
0102     private:
0103         const CexmcEventFastSObject *  evFastSObject;
0104 
0105         const CexmcEventSObject *      evSObject;
0106 
0107     private:
0108         VarAddrMap                     varAddrMap;
0109 
0110     private:
0111         static const G4double          constants[];
0112 };
0113 
0114 
0115 inline void  CexmcASTEval::SetAddressedData(
0116                                 const CexmcEventFastSObject *  evFastSObject_,
0117                                 const CexmcEventSObject *  evSObject_ )
0118 {
0119     varAddrMap.clear();
0120     evFastSObject = evFastSObject_;
0121     evSObject = evSObject_;
0122 }
0123 
0124 
0125 inline const G4double *  CexmcASTEval::GetThreeVectorElementAddrByIndex(
0126                                 const CexmcSimpleThreeVectorStore &  vect,
0127                                 G4int  index ) const
0128 {
0129     switch ( index )
0130     {
0131     case 1 :
0132         return &vect.x;
0133     case 2 :
0134         return &vect.y;
0135     case 3 :
0136         return &vect.z;
0137     default :
0138         throw CexmcException( CexmcCFUnexpectedVectorIndex );
0139         return NULL;
0140     }
0141 }
0142 
0143 
0144 inline const G4double *  CexmcASTEval::GetLorentzVectorElementAddrByIndex(
0145                                 const CexmcSimpleLorentzVectorStore &  vect,
0146                                 G4int  index ) const
0147 {
0148     switch ( index )
0149     {
0150     case 1 :
0151         return &vect.px;
0152     case 2 :
0153         return &vect.py;
0154     case 3 :
0155         return &vect.pz;
0156     case 4 :
0157         return &vect.e;
0158     default :
0159         throw CexmcException( CexmcCFUnexpectedVectorIndex );
0160         return NULL;
0161     }
0162 }
0163 
0164 #endif
0165 
0166 #endif
0167