File indexing completed on 2025-01-31 09:21:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
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