Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/ChargeExchangeMC/src/CexmcASTEval.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/ChargeExchangeMC/src/CexmcASTEval.cc (Version 11.3.0) and /examples/advanced/ChargeExchangeMC/src/CexmcASTEval.cc (Version 9.6.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /*                                                 26 /*
 27  * ===========================================     27  * =============================================================================
 28  *                                                 28  *
 29  *       Filename:  CexmcASTEval.cc                29  *       Filename:  CexmcASTEval.cc
 30  *                                                 30  *
 31  *    Description:  abstract syntax tree for c     31  *    Description:  abstract syntax tree for custom filter eval
 32  *                                                 32  *
 33  *        Version:  1.0                            33  *        Version:  1.0
 34  *        Created:  17.07.2010 15:46:01            34  *        Created:  17.07.2010 15:46:01
 35  *       Revision:  none                           35  *       Revision:  none
 36  *       Compiler:  gcc                            36  *       Compiler:  gcc
 37  *                                                 37  *
 38  *         Author:  Alexey Radkov (),              38  *         Author:  Alexey Radkov (), 
 39  *        Company:  PNPI                           39  *        Company:  PNPI
 40  *                                                 40  *
 41  * ===========================================     41  * =============================================================================
 42  */                                                42  */
 43                                                    43 
 44 #ifdef CEXMC_USE_CUSTOM_FILTER                     44 #ifdef CEXMC_USE_CUSTOM_FILTER
 45                                                    45 
 46 #include <numeric>                                 46 #include <numeric>
 47 #include <boost/variant/get.hpp>                   47 #include <boost/variant/get.hpp>
 48 #include <G4SystemOfUnits.hh>                  << 
 49 #include "CexmcASTEval.hh"                         48 #include "CexmcASTEval.hh"
 50                                                    49 
 51                                                    50 
 52 namespace                                          51 namespace
 53 {                                                  52 {
 54     const std::string  CexmcCFVarEvent( "event     53     const std::string  CexmcCFVarEvent( "event" );
 55     const std::string  CexmcCFVarOpCosThetaSCM     54     const std::string  CexmcCFVarOpCosThetaSCM( "op_cosTh_SCM" );
 56     const std::string  CexmcCFVarEDT( "edt" );     55     const std::string  CexmcCFVarEDT( "edt" );
 57     const std::string  CexmcCFVarTPT( "tpt" );     56     const std::string  CexmcCFVarTPT( "tpt" );
 58     const std::string  CexmcCFVarMon( "mon" );     57     const std::string  CexmcCFVarMon( "mon" );
 59     const std::string  CexmcCFVarMonED( "monED     58     const std::string  CexmcCFVarMonED( "monED" );
 60     const std::string  CexmcCFVarVclED( "vclED     59     const std::string  CexmcCFVarVclED( "vclED" );
 61     const std::string  CexmcCFVarVcrED( "vcrED     60     const std::string  CexmcCFVarVcrED( "vcrED" );
 62     const std::string  CexmcCFVarClED( "clED"      61     const std::string  CexmcCFVarClED( "clED" );
 63     const std::string  CexmcCFVarCrED( "crED"      62     const std::string  CexmcCFVarCrED( "crED" );
 64     const std::string  CexmcCFVarClEDCol( "clE     63     const std::string  CexmcCFVarClEDCol( "clEDcol" );
 65     const std::string  CexmcCFVarCrEDCol( "crE     64     const std::string  CexmcCFVarCrEDCol( "crEDcol" );
 66     const std::string  CexmcCFVarBpMonPosL( "b     65     const std::string  CexmcCFVarBpMonPosL( "bp_mon_posl" );
 67     const std::string  CexmcCFVarBpMonPosW( "b     66     const std::string  CexmcCFVarBpMonPosW( "bp_mon_posw" );
 68     const std::string  CexmcCFVarBpMonDirL( "b     67     const std::string  CexmcCFVarBpMonDirL( "bp_mon_dirl" );
 69     const std::string  CexmcCFVarBpMonDirW( "b     68     const std::string  CexmcCFVarBpMonDirW( "bp_mon_dirw" );
 70     const std::string  CexmcCFVarBpMonMom( "bp     69     const std::string  CexmcCFVarBpMonMom( "bp_mon_mom" );
 71     const std::string  CexmcCFVarBpMonTid( "bp     70     const std::string  CexmcCFVarBpMonTid( "bp_mon_tid" );
 72     const std::string  CexmcCFVarBpTgtPosL( "b     71     const std::string  CexmcCFVarBpTgtPosL( "bp_tgt_posl" );
 73     const std::string  CexmcCFVarBpTgtPosW( "b     72     const std::string  CexmcCFVarBpTgtPosW( "bp_tgt_posw" );
 74     const std::string  CexmcCFVarBpTgtDirL( "b     73     const std::string  CexmcCFVarBpTgtDirL( "bp_tgt_dirl" );
 75     const std::string  CexmcCFVarBpTgtDirW( "b     74     const std::string  CexmcCFVarBpTgtDirW( "bp_tgt_dirw" );
 76     const std::string  CexmcCFVarBpTgtMom( "bp     75     const std::string  CexmcCFVarBpTgtMom( "bp_tgt_mom" );
 77     const std::string  CexmcCFVarBpTgtTid( "bp     76     const std::string  CexmcCFVarBpTgtTid( "bp_tgt_tid" );
 78     const std::string  CexmcCFVarOpTgtPosL( "o     77     const std::string  CexmcCFVarOpTgtPosL( "op_tgt_posl" );
 79     const std::string  CexmcCFVarOpTgtPosW( "o     78     const std::string  CexmcCFVarOpTgtPosW( "op_tgt_posw" );
 80     const std::string  CexmcCFVarOpTgtDirL( "o     79     const std::string  CexmcCFVarOpTgtDirL( "op_tgt_dirl" );
 81     const std::string  CexmcCFVarOpTgtDirW( "o     80     const std::string  CexmcCFVarOpTgtDirW( "op_tgt_dirw" );
 82     const std::string  CexmcCFVarOpTgtMom( "op     81     const std::string  CexmcCFVarOpTgtMom( "op_tgt_mom" );
 83     const std::string  CexmcCFVarOpTgtTid( "op     82     const std::string  CexmcCFVarOpTgtTid( "op_tgt_tid" );
 84     const std::string  CexmcCFVarNpTgtPosL( "n     83     const std::string  CexmcCFVarNpTgtPosL( "np_tgt_posl" );
 85     const std::string  CexmcCFVarNpTgtPosW( "n     84     const std::string  CexmcCFVarNpTgtPosW( "np_tgt_posw" );
 86     const std::string  CexmcCFVarNpTgtDirL( "n     85     const std::string  CexmcCFVarNpTgtDirL( "np_tgt_dirl" );
 87     const std::string  CexmcCFVarNpTgtDirW( "n     86     const std::string  CexmcCFVarNpTgtDirW( "np_tgt_dirw" );
 88     const std::string  CexmcCFVarNpTgtMom( "np     87     const std::string  CexmcCFVarNpTgtMom( "np_tgt_mom" );
 89     const std::string  CexmcCFVarNpTgtTid( "np     88     const std::string  CexmcCFVarNpTgtTid( "np_tgt_tid" );
 90     const std::string  CexmcCFVarOpdp1TgtPosL(     89     const std::string  CexmcCFVarOpdp1TgtPosL( "opdp1_tgt_posl" );
 91     const std::string  CexmcCFVarOpdp1TgtPosW(     90     const std::string  CexmcCFVarOpdp1TgtPosW( "opdp1_tgt_posw" );
 92     const std::string  CexmcCFVarOpdp1TgtDirL(     91     const std::string  CexmcCFVarOpdp1TgtDirL( "opdp1_tgt_dirl" );
 93     const std::string  CexmcCFVarOpdp1TgtDirW(     92     const std::string  CexmcCFVarOpdp1TgtDirW( "opdp1_tgt_dirw" );
 94     const std::string  CexmcCFVarOpdp1TgtMom(      93     const std::string  CexmcCFVarOpdp1TgtMom( "opdp1_tgt_mom" );
 95     const std::string  CexmcCFVarOpdp1TgtTid(      94     const std::string  CexmcCFVarOpdp1TgtTid( "opdp1_tgt_tid" );
 96     const std::string  CexmcCFVarOpdp2TgtPosL(     95     const std::string  CexmcCFVarOpdp2TgtPosL( "opdp2_tgt_posl" );
 97     const std::string  CexmcCFVarOpdp2TgtPosW(     96     const std::string  CexmcCFVarOpdp2TgtPosW( "opdp2_tgt_posw" );
 98     const std::string  CexmcCFVarOpdp2TgtDirL(     97     const std::string  CexmcCFVarOpdp2TgtDirL( "opdp2_tgt_dirl" );
 99     const std::string  CexmcCFVarOpdp2TgtDirW(     98     const std::string  CexmcCFVarOpdp2TgtDirW( "opdp2_tgt_dirw" );
100     const std::string  CexmcCFVarOpdp2TgtMom(      99     const std::string  CexmcCFVarOpdp2TgtMom( "opdp2_tgt_mom" );
101     const std::string  CexmcCFVarOpdp2TgtTid(     100     const std::string  CexmcCFVarOpdp2TgtTid( "opdp2_tgt_tid" );
102     const std::string  CexmcCFVarOpdpVclPosL(     101     const std::string  CexmcCFVarOpdpVclPosL( "opdp_vcl_posl" );
103     const std::string  CexmcCFVarOpdpVclPosW(     102     const std::string  CexmcCFVarOpdpVclPosW( "opdp_vcl_posw" );
104     const std::string  CexmcCFVarOpdpVclDirL(     103     const std::string  CexmcCFVarOpdpVclDirL( "opdp_vcl_dirl" );
105     const std::string  CexmcCFVarOpdpVclDirW(     104     const std::string  CexmcCFVarOpdpVclDirW( "opdp_vcl_dirw" );
106     const std::string  CexmcCFVarOpdpVclMom( "    105     const std::string  CexmcCFVarOpdpVclMom( "opdp_vcl_mom" );
107     const std::string  CexmcCFVarOpdpVclTid( "    106     const std::string  CexmcCFVarOpdpVclTid( "opdp_vcl_tid" );
108     const std::string  CexmcCFVarOpdpVcrPosL(     107     const std::string  CexmcCFVarOpdpVcrPosL( "opdp_vcr_posl" );
109     const std::string  CexmcCFVarOpdpVcrPosW(     108     const std::string  CexmcCFVarOpdpVcrPosW( "opdp_vcr_posw" );
110     const std::string  CexmcCFVarOpdpVcrDirL(     109     const std::string  CexmcCFVarOpdpVcrDirL( "opdp_vcr_dirl" );
111     const std::string  CexmcCFVarOpdpVcrDirW(     110     const std::string  CexmcCFVarOpdpVcrDirW( "opdp_vcr_dirw" );
112     const std::string  CexmcCFVarOpdpVcrMom( "    111     const std::string  CexmcCFVarOpdpVcrMom( "opdp_vcr_mom" );
113     const std::string  CexmcCFVarOpdpVcrTid( "    112     const std::string  CexmcCFVarOpdpVcrTid( "opdp_vcr_tid" );
114     const std::string  CexmcCFVarOpdpClPosL( "    113     const std::string  CexmcCFVarOpdpClPosL( "opdp_cl_posl" );
115     const std::string  CexmcCFVarOpdpClPosW( "    114     const std::string  CexmcCFVarOpdpClPosW( "opdp_cl_posw" );
116     const std::string  CexmcCFVarOpdpClDirL( "    115     const std::string  CexmcCFVarOpdpClDirL( "opdp_cl_dirl" );
117     const std::string  CexmcCFVarOpdpClDirW( "    116     const std::string  CexmcCFVarOpdpClDirW( "opdp_cl_dirw" );
118     const std::string  CexmcCFVarOpdpClMom( "o    117     const std::string  CexmcCFVarOpdpClMom( "opdp_cl_mom" );
119     const std::string  CexmcCFVarOpdpClTid( "o    118     const std::string  CexmcCFVarOpdpClTid( "opdp_cl_tid" );
120     const std::string  CexmcCFVarOpdpCrPosL( "    119     const std::string  CexmcCFVarOpdpCrPosL( "opdp_cr_posl" );
121     const std::string  CexmcCFVarOpdpCrPosW( "    120     const std::string  CexmcCFVarOpdpCrPosW( "opdp_cr_posw" );
122     const std::string  CexmcCFVarOpdpCrDirL( "    121     const std::string  CexmcCFVarOpdpCrDirL( "opdp_cr_dirl" );
123     const std::string  CexmcCFVarOpdpCrDirW( "    122     const std::string  CexmcCFVarOpdpCrDirW( "opdp_cr_dirw" );
124     const std::string  CexmcCFVarOpdpCrMom( "o    123     const std::string  CexmcCFVarOpdpCrMom( "opdp_cr_mom" );
125     const std::string  CexmcCFVarOpdpCrTid( "o    124     const std::string  CexmcCFVarOpdpCrTid( "opdp_cr_tid" );
126     const std::string  CexmcCFVarIpSCM( "ipSCM    125     const std::string  CexmcCFVarIpSCM( "ipSCM" );
127     const std::string  CexmcCFVarIpLAB( "ipLAB    126     const std::string  CexmcCFVarIpLAB( "ipLAB" );
128     const std::string  CexmcCFVarNpSCM( "npSCM    127     const std::string  CexmcCFVarNpSCM( "npSCM" );
129     const std::string  CexmcCFVarNpLAB( "npLAB    128     const std::string  CexmcCFVarNpLAB( "npLAB" );
130     const std::string  CexmcCFVarOpSCM( "opSCM    129     const std::string  CexmcCFVarOpSCM( "opSCM" );
131     const std::string  CexmcCFVarOpLAB( "opLAB    130     const std::string  CexmcCFVarOpLAB( "opLAB" );
132     const std::string  CexmcCFVarNopSCM( "nopS    131     const std::string  CexmcCFVarNopSCM( "nopSCM" );
133     const std::string  CexmcCFVarNopLAB( "nopL    132     const std::string  CexmcCFVarNopLAB( "nopLAB" );
134     const std::string  CexmcCFVarIpId( "ipId"     133     const std::string  CexmcCFVarIpId( "ipId" );
135     const std::string  CexmcCFVarNpId( "npId"     134     const std::string  CexmcCFVarNpId( "npId" );
136     const std::string  CexmcCFVarOpId( "opId"     135     const std::string  CexmcCFVarOpId( "opId" );
137     const std::string  CexmcCFVarNopId( "nopId    136     const std::string  CexmcCFVarNopId( "nopId" );
138     const std::string  CexmcCFVarConst_eV( "eV    137     const std::string  CexmcCFVarConst_eV( "eV" );
139     const std::string  CexmcCFVarConst_keV( "k    138     const std::string  CexmcCFVarConst_keV( "keV" );
140     const std::string  CexmcCFVarConst_MeV( "M    139     const std::string  CexmcCFVarConst_MeV( "MeV" );
141     const std::string  CexmcCFVarConst_GeV( "G    140     const std::string  CexmcCFVarConst_GeV( "GeV" );
142     const std::string  CexmcCFVarConst_mm( "mm    141     const std::string  CexmcCFVarConst_mm( "mm" );
143     const std::string  CexmcCFVarConst_cm( "cm    142     const std::string  CexmcCFVarConst_cm( "cm" );
144     const std::string  CexmcCFVarConst_m( "m"     143     const std::string  CexmcCFVarConst_m( "m" );
145 }                                                 144 }
146                                                   145 
147                                                   146 
148 const G4double  CexmcASTEval::constants[] = {     147 const G4double  CexmcASTEval::constants[] = { eV, keV, MeV, GeV, mm, cm, m };
149                                                   148 
150                                                   149 
151 CexmcASTEval::CexmcASTEval( const CexmcEventFa << 150 CexmcASTEval::CexmcASTEval( const CexmcEventFastSObject *  evFastSObject,
152                             const CexmcEventSO << 151                             const CexmcEventSObject *  evSObject ) :
153     evFastSObject( evFastSObject_ ), evSObject << 152     evFastSObject( evFastSObject ), evSObject( evSObject )
154 {                                                 153 {
155 }                                                 154 }
156                                                   155 
157                                                   156 
158 CexmcAST::BasicEval::ScalarValueType  CexmcAST    157 CexmcAST::BasicEval::ScalarValueType  CexmcASTEval::GetFunScalarValue(
159                                         const     158                                         const CexmcAST::Subtree &  ast ) const
160 {                                                 159 {
161     const CexmcAST::Function &  fun( boost::ge    160     const CexmcAST::Function &  fun( boost::get< CexmcAST::Function >(
162                                                   161                                                                 ast.type ) );
163                                                   162 
164     if ( fun == "Sum" )                           163     if ( fun == "Sum" )
165     {                                             164     {
166         CexmcEnergyDepositCalorimeterCollectio    165         CexmcEnergyDepositCalorimeterCollection  edCol;
167         GetEDCollectionValue( ast.children[ 0     166         GetEDCollectionValue( ast.children[ 0 ], edCol );
168                                                   167 
169         G4double  result( 0. );                   168         G4double  result( 0. );
170                                                   169 
171         for ( CexmcEnergyDepositCalorimeterCol    170         for ( CexmcEnergyDepositCalorimeterCollection::iterator
172                                     k( edCol.b    171                                     k( edCol.begin() ); k != edCol.end(); ++k )
173         {                                         172         {
174             result += std::accumulate( k->begi    173             result += std::accumulate( k->begin(), k->end(), G4double( 0. ) );
175         }                                         174         }
176                                                   175 
177         return result;                            176         return result;
178     }                                             177     }
179                                                   178 
180     bool             evalResult( false );         179     bool             evalResult( false );
181     ScalarValueType  result( GetBasicFunScalar    180     ScalarValueType  result( GetBasicFunScalarValue( ast, evalResult ) );
182                                                   181 
183     if ( evalResult )                             182     if ( evalResult )
184         return result;                            183         return result;
185                                                   184 
186     throw CexmcException( CexmcCFUnexpectedFun    185     throw CexmcException( CexmcCFUnexpectedFunction );
187                                                   186 
188     return 0;                                     187     return 0;
189 }                                                 188 }
190                                                   189 
191                                                   190 
192 CexmcAST::BasicEval::ScalarValueType  CexmcAST    191 CexmcAST::BasicEval::ScalarValueType  CexmcASTEval::GetVarScalarValue(
193                                         const     192                                         const CexmcAST::Variable &  var ) const
194 {                                                 193 {
195     if ( evFastSObject == NULL || evSObject ==    194     if ( evFastSObject == NULL || evSObject == NULL )
196         throw CexmcException( CexmcCFUninitial    195         throw CexmcException( CexmcCFUninitialized );
197                                                   196 
198     /* Variables with initialized address */      197     /* Variables with initialized address */
199                                                   198 
200     /* bound to CexmcAST::Variable:addr */        199     /* bound to CexmcAST::Variable:addr */
201                                                   200 
202     const double * const *  addr( boost::get<     201     const double * const *  addr( boost::get< const double * >( &var.addr ) );
203                                                   202 
204     if ( addr )                                   203     if ( addr )
205     {                                             204     {
206         if ( *addr )                              205         if ( *addr )
207             return **addr;                        206             return **addr;
208     }                                             207     }
209     else                                          208     else
210     {                                             209     {
211         const int * const &  addr_( boost::get << 210         const int * const &  addr( boost::get< const int * >( var.addr ) );
212                                                   211 
213         if ( addr_ )                           << 212         if ( addr )
214             return *addr_;                     << 213             return *addr;
215     }                                             214     }
216                                                   215 
217     /* found in varAddrMap */                     216     /* found in varAddrMap */
218                                                   217 
219     VarAddrMap::const_iterator  found( varAddr    218     VarAddrMap::const_iterator  found( varAddrMap.find( var.name ) );
220                                                   219 
221     if ( found != varAddrMap.end() )              220     if ( found != varAddrMap.end() )
222     {                                             221     {
223         const CexmcEnergyDepositCalorimeterCol << 222         const CexmcEnergyDepositCalorimeterCollection * const *  addr(
224                 boost::get< const CexmcEnergyD    223                 boost::get< const CexmcEnergyDepositCalorimeterCollection * >(
225                                                   224                                                             &found->second ) );
226         if ( addr_ )                           << 225         if ( addr )
227         {                                         226         {
228             if ( *addr_ )                      << 227             if ( *addr )
229             {                                     228             {
230                 if ( ( *addr_ )->size() == 0 ) << 229                 if ( ( *addr )->size() == 0 )
231                     throw CexmcException( Cexm    230                     throw CexmcException( CexmcCFUninitializedVector );
232                 if ( var.index1 == 0 || var.in    231                 if ( var.index1 == 0 || var.index2 == 0 )
233                     throw CexmcException( Cexm    232                     throw CexmcException( CexmcCFUnexpectedVectorIndex );
234                 return ( *addr_ )->at( var.ind << 233                 return ( *addr )->at( var.index1 - 1 ).at( var.index2 - 1 );
235             }                                     234             }
236         }                                         235         }
237         else                                      236         else
238         {                                         237         {
239             const bool * const &  addr__( boos << 238             const bool * const &  addr( boost::get< const bool * >(
240                                                   239                                                             found->second ) );
241             if ( addr__ )                      << 240             if ( addr )
242                 return int( *addr__ );         << 241                 return int( *addr );
243         }                                         242         }
244     }                                             243     }
245                                                   244 
246     /* Variables without address */               245     /* Variables without address */
247                                                   246 
248     if ( var.name == CexmcCFVarTPT )              247     if ( var.name == CexmcCFVarTPT )
249     {                                             248     {
250         return int( evSObject->targetTPOutputP    249         return int( evSObject->targetTPOutputParticle.trackId !=
251                     CexmcInvalidTrackId );        250                     CexmcInvalidTrackId );
252     }                                             251     } 
253                                                   252 
254     throw CexmcException( CexmcCFUnexpectedVar    253     throw CexmcException( CexmcCFUnexpectedVariable );
255                                                   254 
256     return 0;                                     255     return 0;
257 }                                                 256 }
258                                                   257 
259                                                   258 
260 void  CexmcASTEval::GetEDCollectionValue( cons    259 void  CexmcASTEval::GetEDCollectionValue( const CexmcAST::Node &  node,
261                         CexmcEnergyDepositCalo    260                         CexmcEnergyDepositCalorimeterCollection &  edCol ) const
262 {                                                 261 {
263     if ( evSObject == NULL )                      262     if ( evSObject == NULL )
264         throw CexmcException( CexmcCFUninitial    263         throw CexmcException( CexmcCFUninitialized );
265                                                   264 
266     const CexmcAST::Subtree *  ast( boost::get    265     const CexmcAST::Subtree *  ast( boost::get< CexmcAST::Subtree >( &node ) );
267                                                   266 
268     if ( ast )                                    267     if ( ast )
269     {                                             268     {
270         const CexmcAST::Function &  fun( boost    269         const CexmcAST::Function &  fun( boost::get< CexmcAST::Function >(
271                                                   270                                                                 ast->type ) );
272                                                   271 
273         if ( fun == "Inner" )                     272         if ( fun == "Inner" )
274         {                                         273         {
275             GetEDCollectionValue( ast->childre    274             GetEDCollectionValue( ast->children[ 0 ], edCol );
276             edCol.pop_back();                     275             edCol.pop_back();
277             edCol.erase( edCol.begin() );         276             edCol.erase( edCol.begin() );
278             for ( CexmcEnergyDepositCalorimete    277             for ( CexmcEnergyDepositCalorimeterCollection::iterator
279                             k( edCol.begin() )    278                             k( edCol.begin() ); k != edCol.end(); ++k )
280             {                                     279             {
281                 k->pop_back();                    280                 k->pop_back();
282                 k->erase( k->begin() );           281                 k->erase( k->begin() );
283             }                                     282             }
284             return;                               283             return;
285         }                                         284         }
286         if ( fun == "Outer" )                     285         if ( fun == "Outer" )
287         {                                         286         {
288             GetEDCollectionValue( ast->childre    287             GetEDCollectionValue( ast->children[ 0 ], edCol );
289             if ( edCol.size() < 3 )               288             if ( edCol.size() < 3 )
290                 return;                           289                 return;
291             for ( CexmcEnergyDepositCalorimete    290             for ( CexmcEnergyDepositCalorimeterCollection::iterator
292                             k( edCol.begin() +    291                             k( edCol.begin() + 1 ); k != edCol.end() - 1; ++k )
293             {                                     292             {
294                 if ( k->size() < 3 )              293                 if ( k->size() < 3 )
295                     continue;                     294                     continue;
296                 k->erase( k->begin() + 1, k->e    295                 k->erase( k->begin() + 1, k->end() - 1 );
297             }                                     296             }
298             return;                               297             return;
299         }                                         298         }
300     }                                             299     }
301     else                                          300     else
302     {                                             301     {
303         const CexmcAST::Leaf &      leaf( boos    302         const CexmcAST::Leaf &      leaf( boost::get< CexmcAST::Leaf >(
304                                                   303                                                                     node ) );
305         const CexmcAST::Variable &  var( boost    304         const CexmcAST::Variable &  var( boost::get< CexmcAST::Variable >(
306                                                   305                                                                     leaf ) );
307                                                   306 
308         if ( var.index1 != 0 || var.index2 !=     307         if ( var.index1 != 0 || var.index2 != 0 )
309             throw CexmcException( CexmcCFUnexp    308             throw CexmcException( CexmcCFUnexpectedVariableUsage );
310                                                   309 
311         VarAddrMap::const_iterator  found( var    310         VarAddrMap::const_iterator  found( varAddrMap.find( var.name ) );
312                                                   311 
313         if ( found == varAddrMap.end() )          312         if ( found == varAddrMap.end() )
314             throw CexmcException( CexmcCFUnexp    313             throw CexmcException( CexmcCFUnexpectedVariable );
315                                                   314 
316         const CexmcEnergyDepositCalorimeterCol    315         const CexmcEnergyDepositCalorimeterCollection * const *  addr(
317                 boost::get< const CexmcEnergyD    316                 boost::get< const CexmcEnergyDepositCalorimeterCollection * >(
318                                                   317                                                             &found->second ) );
319         if ( ! addr )                             318         if ( ! addr )
320         {                                         319         {
321             throw CexmcException( CexmcCFUnexp    320             throw CexmcException( CexmcCFUnexpectedVariableUsage );
322         }                                         321         }
323         else                                      322         else
324         {                                         323         {
325             if ( *addr )                          324             if ( *addr )
326                 edCol = **addr;                   325                 edCol = **addr;
327             return;                               326             return;
328         }                                         327         }
329     }                                             328     }
330 }                                                 329 }
331                                                   330 
332                                                   331 
333 void  CexmcASTEval::BindAddresses( CexmcAST::S    332 void  CexmcASTEval::BindAddresses( CexmcAST::Subtree &  ast )
334 {                                                 333 {
335     if ( evFastSObject == NULL || evSObject ==    334     if ( evFastSObject == NULL || evSObject == NULL )
336         return;                                   335         return;
337                                                   336 
338     for ( std::vector< CexmcAST::Node >::itera    337     for ( std::vector< CexmcAST::Node >::iterator  k( ast.children.begin() );
339                                                   338                                                   k != ast.children.end(); ++k )
340     {                                             339     {
341         CexmcAST::Subtree *  subtree( boost::g    340         CexmcAST::Subtree *  subtree( boost::get< CexmcAST::Subtree >( &*k ) );
342                                                   341 
343         if ( subtree )                            342         if ( subtree )
344         {                                         343         {
345             BindAddresses( *subtree );            344             BindAddresses( *subtree );
346         }                                         345         }
347         else                                      346         else
348         {                                         347         {
349             CexmcAST::Leaf &      leaf( boost:    348             CexmcAST::Leaf &      leaf( boost::get< CexmcAST::Leaf >( *k ) );
350             CexmcAST::Variable *  var( boost::    349             CexmcAST::Variable *  var( boost::get< CexmcAST::Variable >(
351                                                   350                                                                     &leaf ) );
352             if ( ! var )                          351             if ( ! var )
353                 continue;                         352                 continue;
354                                                   353 
355             const int * const *   intVarAddr(     354             const int * const *   intVarAddr(
356                                     boost::get    355                                     boost::get< const int * >( &var->addr ) );
357             if ( intVarAddr )                     356             if ( intVarAddr )
358             {                                     357             {
359                 if ( *intVarAddr )                358                 if ( *intVarAddr )
360                     continue;                     359                     continue;
361             }                                     360             }
362             else                                  361             else
363             {                                     362             {
364                 const double * const &  double    363                 const double * const &  doubleVarAddr(
365                                     boost::get    364                                     boost::get< const double * >( var->addr ) );
366                 if ( doubleVarAddr )              365                 if ( doubleVarAddr )
367                     continue;                     366                     continue;
368             }                                     367             }
369                                                   368 
370             VarAddrMap::const_iterator  found(    369             VarAddrMap::const_iterator  found( varAddrMap.find( var->name ) );
371                                                   370 
372             if ( found != varAddrMap.end() )      371             if ( found != varAddrMap.end() )
373                 continue;                         372                 continue;
374                                                   373 
375             do                                    374             do
376             {                                     375             {
377                 if ( var->name == CexmcCFVarEv    376                 if ( var->name == CexmcCFVarEvent )
378                 {                                 377                 {
379                     var->addr = &evFastSObject    378                     var->addr = &evFastSObject->eventId;
380                     break;                        379                     break;
381                 }                                 380                 }
382                 if ( var->name == CexmcCFVarOp    381                 if ( var->name == CexmcCFVarOpCosThetaSCM )
383                 {                                 382                 {
384                     var->addr = &evFastSObject    383                     var->addr = &evFastSObject->opCosThetaSCM;
385                     break;                        384                     break;
386                 }                                 385                 }
387                 if ( var->name == CexmcCFVarED    386                 if ( var->name == CexmcCFVarEDT )
388                 {                                 387                 {
389                     varAddrMap.insert( VarAddr    388                     varAddrMap.insert( VarAddrMapData( var->name,
390                                    &evFastSObj    389                                    &evFastSObject->edDigitizerHasTriggered ) );
391                     break;                        390                     break;
392                 }                                 391                 } 
393                 if ( var->name == CexmcCFVarMo    392                 if ( var->name == CexmcCFVarMon )
394                 {                                 393                 {
395                     varAddrMap.insert( VarAddr    394                     varAddrMap.insert( VarAddrMapData( var->name,
396                            &evFastSObject->edD    395                            &evFastSObject->edDigitizerMonitorHasTriggered ) );
397                     break;                        396                     break;
398                 }                                 397                 }
399                 if ( var->name == CexmcCFVarMo    398                 if ( var->name == CexmcCFVarMonED )
400                 {                                 399                 {
401                     var->addr = &evSObject->mo    400                     var->addr = &evSObject->monitorED;
402                     break;                        401                     break;
403                 }                                 402                 }
404                 if ( var->name == CexmcCFVarVc    403                 if ( var->name == CexmcCFVarVclED )
405                 {                                 404                 {
406                     var->addr = &evSObject->ve    405                     var->addr = &evSObject->vetoCounterEDLeft;
407                     break;                        406                     break;
408                 }                                 407                 }
409                 if ( var->name == CexmcCFVarVc    408                 if ( var->name == CexmcCFVarVcrED )
410                 {                                 409                 {
411                     var->addr = &evSObject->ve    410                     var->addr = &evSObject->vetoCounterEDRight;
412                     break;                        411                     break;
413                 }                                 412                 }
414                 if ( var->name == CexmcCFVarCl    413                 if ( var->name == CexmcCFVarClED )
415                 {                                 414                 {
416                     var->addr = &evSObject->ca    415                     var->addr = &evSObject->calorimeterEDLeft;
417                     break;                        416                     break;
418                 }                                 417                 }
419                 if ( var->name == CexmcCFVarCr    418                 if ( var->name == CexmcCFVarCrED )
420                 {                                 419                 {
421                     var->addr = &evSObject->ca    420                     var->addr = &evSObject->calorimeterEDRight;
422                     break;                        421                     break;
423                 }                                 422                 }
424                 if ( var->name == CexmcCFVarCl    423                 if ( var->name == CexmcCFVarClEDCol )
425                 {                                 424                 {
426                     varAddrMap.insert( VarAddr    425                     varAddrMap.insert( VarAddrMapData( var->name,
427                                 &evSObject->ca    426                                 &evSObject->calorimeterEDLeftCollection ) );
428                     break;                        427                     break;
429                 }                                 428                 }
430                 if ( var->name == CexmcCFVarCr    429                 if ( var->name == CexmcCFVarCrEDCol )
431                 {                                 430                 {
432                     varAddrMap.insert( VarAddr    431                     varAddrMap.insert( VarAddrMapData( var->name,
433                                 &evSObject->ca    432                                 &evSObject->calorimeterEDRightCollection ) );
434                     break;                        433                     break;
435                 }                                 434                 }
436                 if ( var->name == CexmcCFVarBp    435                 if ( var->name == CexmcCFVarBpMonPosL )
437                 {                                 436                 {
438                     var->addr = GetThreeVector    437                     var->addr = GetThreeVectorElementAddrByIndex(
439                             evSObject->monitor    438                             evSObject->monitorTP.positionLocal, var->index1 );
440                     break;                        439                     break;
441                 }                                 440                 }
442                 if ( var->name == CexmcCFVarBp    441                 if ( var->name == CexmcCFVarBpMonPosW )
443                 {                                 442                 {
444                     var->addr = GetThreeVector    443                     var->addr = GetThreeVectorElementAddrByIndex(
445                             evSObject->monitor    444                             evSObject->monitorTP.positionWorld, var->index1 );
446                     break;                        445                     break;
447                 }                                 446                 }
448                 if ( var->name == CexmcCFVarBp    447                 if ( var->name == CexmcCFVarBpMonDirL )
449                 {                                 448                 {
450                     var->addr = GetThreeVector    449                     var->addr = GetThreeVectorElementAddrByIndex(
451                             evSObject->monitor    450                             evSObject->monitorTP.directionLocal, var->index1 );
452                     break;                        451                     break;
453                 }                                 452                 }
454                 if ( var->name == CexmcCFVarBp    453                 if ( var->name == CexmcCFVarBpMonDirW )
455                 {                                 454                 {
456                     var->addr = GetThreeVector    455                     var->addr = GetThreeVectorElementAddrByIndex(
457                             evSObject->monitor    456                             evSObject->monitorTP.directionWorld, var->index1 );
458                     break;                        457                     break;
459                 }                                 458                 }
460                 if ( var->name == CexmcCFVarBp    459                 if ( var->name == CexmcCFVarBpMonMom )
461                 {                                 460                 {
462                     var->addr = &evSObject->mo    461                     var->addr = &evSObject->monitorTP.momentumAmp;
463                     break;                        462                     break;
464                 }                                 463                 }
465                 if ( var->name == CexmcCFVarBp    464                 if ( var->name == CexmcCFVarBpMonTid )
466                 {                                 465                 {
467                     var->addr = &evSObject->mo    466                     var->addr = &evSObject->monitorTP.trackId;
468                     break;                        467                     break;
469                 }                                 468                 }
470                 if ( var->name == CexmcCFVarBp    469                 if ( var->name == CexmcCFVarBpTgtPosL )
471                 {                                 470                 {
472                     var->addr = GetThreeVector    471                     var->addr = GetThreeVectorElementAddrByIndex(
473                             evSObject->targetT    472                             evSObject->targetTPBeamParticle.positionLocal,
474                             var->index1 );        473                             var->index1 );
475                     break;                        474                     break;
476                 }                                 475                 }
477                 if ( var->name == CexmcCFVarBp    476                 if ( var->name == CexmcCFVarBpTgtPosW )
478                 {                                 477                 {
479                     var->addr = GetThreeVector    478                     var->addr = GetThreeVectorElementAddrByIndex(
480                             evSObject->targetT    479                             evSObject->targetTPBeamParticle.positionWorld,
481                             var->index1 );        480                             var->index1 );
482                     break;                        481                     break;
483                 }                                 482                 }
484                 if ( var->name == CexmcCFVarBp    483                 if ( var->name == CexmcCFVarBpTgtDirL )
485                 {                                 484                 {
486                     var->addr = GetThreeVector    485                     var->addr = GetThreeVectorElementAddrByIndex(
487                             evSObject->targetT    486                             evSObject->targetTPBeamParticle.directionLocal,
488                             var->index1 );        487                             var->index1 );
489                     break;                        488                     break;
490                 }                                 489                 }
491                 if ( var->name == CexmcCFVarBp    490                 if ( var->name == CexmcCFVarBpTgtDirW )
492                 {                                 491                 {
493                     var->addr = GetThreeVector    492                     var->addr = GetThreeVectorElementAddrByIndex(
494                             evSObject->targetT    493                             evSObject->targetTPBeamParticle.directionWorld,
495                             var->index1 );        494                             var->index1 );
496                     break;                        495                     break;
497                 }                                 496                 }
498                 if ( var->name == CexmcCFVarBp    497                 if ( var->name == CexmcCFVarBpTgtMom )
499                 {                                 498                 {
500                     var->addr = &evSObject->ta    499                     var->addr = &evSObject->targetTPBeamParticle.momentumAmp;
501                     break;                        500                     break;
502                 }                                 501                 }
503                 if ( var->name == CexmcCFVarBp    502                 if ( var->name == CexmcCFVarBpTgtTid )
504                 {                                 503                 {
505                     var->addr = &evSObject->ta    504                     var->addr = &evSObject->targetTPBeamParticle.trackId;
506                     break;                        505                     break;
507                 }                                 506                 }
508                 if ( var->name == CexmcCFVarOp    507                 if ( var->name == CexmcCFVarOpTgtPosL )
509                 {                                 508                 {
510                     var->addr = GetThreeVector    509                     var->addr = GetThreeVectorElementAddrByIndex(
511                             evSObject->targetT    510                             evSObject->targetTPOutputParticle.positionLocal,
512                             var->index1 );        511                             var->index1 );
513                     break;                        512                     break;
514                 }                                 513                 }
515                 if ( var->name == CexmcCFVarOp    514                 if ( var->name == CexmcCFVarOpTgtPosW )
516                 {                                 515                 {
517                     var->addr = GetThreeVector    516                     var->addr = GetThreeVectorElementAddrByIndex(
518                             evSObject->targetT    517                             evSObject->targetTPOutputParticle.positionWorld,
519                             var->index1 );        518                             var->index1 );
520                     break;                        519                     break;
521                 }                                 520                 }
522                 if ( var->name == CexmcCFVarOp    521                 if ( var->name == CexmcCFVarOpTgtDirL )
523                 {                                 522                 {
524                     var->addr = GetThreeVector    523                     var->addr = GetThreeVectorElementAddrByIndex(
525                             evSObject->targetT    524                             evSObject->targetTPOutputParticle.directionLocal,
526                             var->index1 );        525                             var->index1 );
527                     break;                        526                     break;
528                 }                                 527                 }
529                 if ( var->name == CexmcCFVarOp    528                 if ( var->name == CexmcCFVarOpTgtDirW )
530                 {                                 529                 {
531                     var->addr = GetThreeVector    530                     var->addr = GetThreeVectorElementAddrByIndex(
532                             evSObject->targetT    531                             evSObject->targetTPOutputParticle.directionWorld,
533                             var->index1 );        532                             var->index1 );
534                     break;                        533                     break;
535                 }                                 534                 }
536                 if ( var->name == CexmcCFVarOp    535                 if ( var->name == CexmcCFVarOpTgtMom )
537                 {                                 536                 {
538                     var->addr = &evSObject->ta    537                     var->addr = &evSObject->targetTPOutputParticle.momentumAmp;
539                     break;                        538                     break;
540                 }                                 539                 }
541                 if ( var->name == CexmcCFVarOp    540                 if ( var->name == CexmcCFVarOpTgtTid )
542                 {                                 541                 {
543                     var->addr = &evSObject->ta    542                     var->addr = &evSObject->targetTPOutputParticle.trackId;
544                     break;                        543                     break;
545                 }                                 544                 }
546                 if ( var->name == CexmcCFVarNp    545                 if ( var->name == CexmcCFVarNpTgtPosL )
547                 {                                 546                 {
548                     var->addr = GetThreeVector    547                     var->addr = GetThreeVectorElementAddrByIndex(
549                             evSObject->targetT    548                             evSObject->targetTPNucleusParticle.positionLocal,
550                             var->index1 );        549                             var->index1 );
551                     break;                        550                     break;
552                 }                                 551                 }
553                 if ( var->name == CexmcCFVarNp    552                 if ( var->name == CexmcCFVarNpTgtPosW )
554                 {                                 553                 {
555                     var->addr = GetThreeVector    554                     var->addr = GetThreeVectorElementAddrByIndex(
556                             evSObject->targetT    555                             evSObject->targetTPNucleusParticle.positionWorld,
557                             var->index1 );        556                             var->index1 );
558                     break;                        557                     break;
559                 }                                 558                 }
560                 if ( var->name == CexmcCFVarNp    559                 if ( var->name == CexmcCFVarNpTgtDirL )
561                 {                                 560                 {
562                     var->addr = GetThreeVector    561                     var->addr = GetThreeVectorElementAddrByIndex(
563                             evSObject->targetT    562                             evSObject->targetTPNucleusParticle.directionLocal,
564                             var->index1 );        563                             var->index1 );
565                     break;                        564                     break;
566                 }                                 565                 }
567                 if ( var->name == CexmcCFVarNp    566                 if ( var->name == CexmcCFVarNpTgtDirW )
568                 {                                 567                 {
569                     var->addr = GetThreeVector    568                     var->addr = GetThreeVectorElementAddrByIndex(
570                             evSObject->targetT    569                             evSObject->targetTPNucleusParticle.directionWorld,
571                             var->index1 );        570                             var->index1 );
572                     break;                        571                     break;
573                 }                                 572                 }
574                 if ( var->name == CexmcCFVarNp    573                 if ( var->name == CexmcCFVarNpTgtMom )
575                 {                                 574                 {
576                     var->addr = &evSObject->ta    575                     var->addr = &evSObject->targetTPNucleusParticle.momentumAmp;
577                     break;                        576                     break;
578                 }                                 577                 }
579                 if ( var->name == CexmcCFVarNp    578                 if ( var->name == CexmcCFVarNpTgtTid )
580                 {                                 579                 {
581                     var->addr = &evSObject->ta    580                     var->addr = &evSObject->targetTPNucleusParticle.trackId;
582                     break;                        581                     break;
583                 }                                 582                 }
584                 if ( var->name == CexmcCFVarOp    583                 if ( var->name == CexmcCFVarOpdp1TgtPosL )
585                 {                                 584                 {
586                     var->addr = GetThreeVector    585                     var->addr = GetThreeVectorElementAddrByIndex(
587                         evSObject->targetTPOut    586                         evSObject->targetTPOutputParticleDecayProductParticle1.
588                                                   587                                                                 positionLocal,
589                         var->index1 );            588                         var->index1 );
590                     break;                        589                     break;
591                 }                                 590                 }
592                 if ( var->name == CexmcCFVarOp    591                 if ( var->name == CexmcCFVarOpdp1TgtPosW )
593                 {                                 592                 {
594                     var->addr = GetThreeVector    593                     var->addr = GetThreeVectorElementAddrByIndex(
595                         evSObject->targetTPOut    594                         evSObject->targetTPOutputParticleDecayProductParticle1.
596                                                   595                                                                 positionWorld,
597                         var->index1 );            596                         var->index1 );
598                     break;                        597                     break;
599                 }                                 598                 }
600                 if ( var->name == CexmcCFVarOp    599                 if ( var->name == CexmcCFVarOpdp1TgtDirL )
601                 {                                 600                 {
602                     var->addr = GetThreeVector    601                     var->addr = GetThreeVectorElementAddrByIndex(
603                         evSObject->targetTPOut    602                         evSObject->targetTPOutputParticleDecayProductParticle1.
604                                                   603                                                                 directionLocal,
605                         var->index1 );            604                         var->index1 );
606                     break;                        605                     break;
607                 }                                 606                 }
608                 if ( var->name == CexmcCFVarOp    607                 if ( var->name == CexmcCFVarOpdp1TgtDirW )
609                 {                                 608                 {
610                     var->addr = GetThreeVector    609                     var->addr = GetThreeVectorElementAddrByIndex(
611                         evSObject->targetTPOut    610                         evSObject->targetTPOutputParticleDecayProductParticle1.
612                                                   611                                                                 directionWorld,
613                         var->index1 );            612                         var->index1 );
614                     break;                        613                     break;
615                 }                                 614                 }
616                 if ( var->name == CexmcCFVarOp    615                 if ( var->name == CexmcCFVarOpdp1TgtMom )
617                 {                                 616                 {
618                     var->addr = &evSObject->      617                     var->addr = &evSObject->
619                         targetTPOutputParticle    618                         targetTPOutputParticleDecayProductParticle1.momentumAmp;
620                     break;                        619                     break;
621                 }                                 620                 }
622                 if ( var->name == CexmcCFVarOp    621                 if ( var->name == CexmcCFVarOpdp1TgtTid )
623                 {                                 622                 {
624                     var->addr = &evSObject->      623                     var->addr = &evSObject->
625                         targetTPOutputParticle    624                         targetTPOutputParticleDecayProductParticle1.trackId;
626                     break;                        625                     break;
627                 }                                 626                 }
628                 if ( var->name == CexmcCFVarOp    627                 if ( var->name == CexmcCFVarOpdp2TgtPosL )
629                 {                                 628                 {
630                     var->addr = GetThreeVector    629                     var->addr = GetThreeVectorElementAddrByIndex(
631                         evSObject->targetTPOut    630                         evSObject->targetTPOutputParticleDecayProductParticle2.
632                                                   631                                                                 positionLocal,
633                         var->index1 );            632                         var->index1 );
634                     break;                        633                     break;
635                 }                                 634                 }
636                 if ( var->name == CexmcCFVarOp    635                 if ( var->name == CexmcCFVarOpdp2TgtPosW )
637                 {                                 636                 {
638                     var->addr = GetThreeVector    637                     var->addr = GetThreeVectorElementAddrByIndex(
639                         evSObject->targetTPOut    638                         evSObject->targetTPOutputParticleDecayProductParticle2.
640                                                   639                                                                 positionWorld,
641                         var->index1 );            640                         var->index1 );
642                     break;                        641                     break;
643                 }                                 642                 }
644                 if ( var->name == CexmcCFVarOp    643                 if ( var->name == CexmcCFVarOpdp2TgtDirL )
645                 {                                 644                 {
646                     var->addr = GetThreeVector    645                     var->addr = GetThreeVectorElementAddrByIndex(
647                         evSObject->targetTPOut    646                         evSObject->targetTPOutputParticleDecayProductParticle2.
648                                                   647                                                                 directionLocal,
649                         var->index1 );            648                         var->index1 );
650                     break;                        649                     break;
651                 }                                 650                 }
652                 if ( var->name == CexmcCFVarOp    651                 if ( var->name == CexmcCFVarOpdp2TgtDirW )
653                 {                                 652                 {
654                     var->addr = GetThreeVector    653                     var->addr = GetThreeVectorElementAddrByIndex(
655                         evSObject->targetTPOut    654                         evSObject->targetTPOutputParticleDecayProductParticle2.
656                                                   655                                                                 directionWorld,
657                         var->index1 );            656                         var->index1 );
658                     break;                        657                     break;
659                 }                                 658                 }
660                 if ( var->name == CexmcCFVarOp    659                 if ( var->name == CexmcCFVarOpdp2TgtMom )
661                 {                                 660                 {
662                     var->addr = &evSObject->      661                     var->addr = &evSObject->
663                         targetTPOutputParticle    662                         targetTPOutputParticleDecayProductParticle2.momentumAmp;
664                     break;                        663                     break;
665                 }                                 664                 }
666                 if ( var->name == CexmcCFVarOp    665                 if ( var->name == CexmcCFVarOpdp2TgtTid )
667                 {                                 666                 {
668                     var->addr = &evSObject->      667                     var->addr = &evSObject->
669                         targetTPOutputParticle    668                         targetTPOutputParticleDecayProductParticle2.trackId;
670                     break;                        669                     break;
671                 }                                 670                 }
672                 if ( var->name == CexmcCFVarOp    671                 if ( var->name == CexmcCFVarOpdpVclPosL )
673                 {                                 672                 {
674                     var->addr = GetThreeVector    673                     var->addr = GetThreeVectorElementAddrByIndex(
675                             evSObject->vetoCou    674                             evSObject->vetoCounterTPLeft.positionLocal,
676                             var->index1 );        675                             var->index1 );
677                     break;                        676                     break;
678                 }                                 677                 }
679                 if ( var->name == CexmcCFVarOp    678                 if ( var->name == CexmcCFVarOpdpVclPosW )
680                 {                                 679                 {
681                     var->addr = GetThreeVector    680                     var->addr = GetThreeVectorElementAddrByIndex(
682                             evSObject->vetoCou    681                             evSObject->vetoCounterTPLeft.positionWorld,
683                             var->index1 );        682                             var->index1 );
684                     break;                        683                     break;
685                 }                                 684                 }
686                 if ( var->name == CexmcCFVarOp    685                 if ( var->name == CexmcCFVarOpdpVclDirL )
687                 {                                 686                 {
688                     var->addr = GetThreeVector    687                     var->addr = GetThreeVectorElementAddrByIndex(
689                             evSObject->vetoCou    688                             evSObject->vetoCounterTPLeft.directionLocal,
690                             var->index1 );        689                             var->index1 );
691                     break;                        690                     break;
692                 }                                 691                 }
693                 if ( var->name == CexmcCFVarOp    692                 if ( var->name == CexmcCFVarOpdpVclDirW )
694                 {                                 693                 {
695                     var->addr = GetThreeVector    694                     var->addr = GetThreeVectorElementAddrByIndex(
696                             evSObject->vetoCou    695                             evSObject->vetoCounterTPLeft.directionWorld,
697                             var->index1 );        696                             var->index1 );
698                     break;                        697                     break;
699                 }                                 698                 }
700                 if ( var->name == CexmcCFVarOp    699                 if ( var->name == CexmcCFVarOpdpVclMom )
701                 {                                 700                 {
702                     var->addr = &evSObject->ve    701                     var->addr = &evSObject->vetoCounterTPLeft.momentumAmp;
703                     break;                        702                     break;
704                 }                                 703                 }
705                 if ( var->name == CexmcCFVarOp    704                 if ( var->name == CexmcCFVarOpdpVclTid )
706                 {                                 705                 {
707                     var->addr = &evSObject->ve    706                     var->addr = &evSObject->vetoCounterTPLeft.trackId;
708                     break;                        707                     break;
709                 }                                 708                 }
710                 if ( var->name == CexmcCFVarOp    709                 if ( var->name == CexmcCFVarOpdpVcrPosL )
711                 {                                 710                 {
712                     var->addr = GetThreeVector    711                     var->addr = GetThreeVectorElementAddrByIndex(
713                             evSObject->vetoCou    712                             evSObject->vetoCounterTPRight.positionLocal,
714                             var->index1 );        713                             var->index1 );
715                     break;                        714                     break;
716                 }                                 715                 }
717                 if ( var->name == CexmcCFVarOp    716                 if ( var->name == CexmcCFVarOpdpVcrPosW )
718                 {                                 717                 {
719                     var->addr = GetThreeVector    718                     var->addr = GetThreeVectorElementAddrByIndex(
720                             evSObject->vetoCou    719                             evSObject->vetoCounterTPRight.positionWorld,
721                             var->index1 );        720                             var->index1 );
722                     break;                        721                     break;
723                 }                                 722                 }
724                 if ( var->name == CexmcCFVarOp    723                 if ( var->name == CexmcCFVarOpdpVcrDirL )
725                 {                                 724                 {
726                     var->addr = GetThreeVector    725                     var->addr = GetThreeVectorElementAddrByIndex(
727                             evSObject->vetoCou    726                             evSObject->vetoCounterTPRight.directionLocal,
728                             var->index1 );        727                             var->index1 );
729                     break;                        728                     break;
730                 }                                 729                 }
731                 if ( var->name == CexmcCFVarOp    730                 if ( var->name == CexmcCFVarOpdpVcrDirW )
732                 {                                 731                 {
733                     var->addr = GetThreeVector    732                     var->addr = GetThreeVectorElementAddrByIndex(
734                             evSObject->vetoCou    733                             evSObject->vetoCounterTPRight.directionWorld,
735                             var->index1 );        734                             var->index1 );
736                     break;                        735                     break;
737                 }                                 736                 }
738                 if ( var->name == CexmcCFVarOp    737                 if ( var->name == CexmcCFVarOpdpVcrMom )
739                 {                                 738                 {
740                     var->addr = &evSObject->ve    739                     var->addr = &evSObject->vetoCounterTPRight.momentumAmp;
741                     break;                        740                     break;
742                 }                                 741                 }
743                 if ( var->name == CexmcCFVarOp    742                 if ( var->name == CexmcCFVarOpdpVcrTid )
744                 {                                 743                 {
745                     var->addr = &evSObject->ve    744                     var->addr = &evSObject->vetoCounterTPRight.trackId;
746                     break;                        745                     break;
747                 }                                 746                 }
748                 if ( var->name == CexmcCFVarOp    747                 if ( var->name == CexmcCFVarOpdpClPosL )
749                 {                                 748                 {
750                     var->addr = GetThreeVector    749                     var->addr = GetThreeVectorElementAddrByIndex(
751                             evSObject->calorim    750                             evSObject->calorimeterTPLeft.positionLocal,
752                             var->index1 );        751                             var->index1 );
753                     break;                        752                     break;
754                 }                                 753                 }
755                 if ( var->name == CexmcCFVarOp    754                 if ( var->name == CexmcCFVarOpdpClPosW )
756                 {                                 755                 {
757                     var->addr = GetThreeVector    756                     var->addr = GetThreeVectorElementAddrByIndex(
758                             evSObject->calorim    757                             evSObject->calorimeterTPLeft.positionWorld,
759                             var->index1 );        758                             var->index1 );
760                     break;                        759                     break;
761                 }                                 760                 }
762                 if ( var->name == CexmcCFVarOp    761                 if ( var->name == CexmcCFVarOpdpClDirL )
763                 {                                 762                 {
764                     var->addr = GetThreeVector    763                     var->addr = GetThreeVectorElementAddrByIndex(
765                             evSObject->calorim    764                             evSObject->calorimeterTPLeft.directionLocal,
766                             var->index1 );        765                             var->index1 );
767                     break;                        766                     break;
768                 }                                 767                 }
769                 if ( var->name == CexmcCFVarOp    768                 if ( var->name == CexmcCFVarOpdpClDirW )
770                 {                                 769                 {
771                     var->addr = GetThreeVector    770                     var->addr = GetThreeVectorElementAddrByIndex(
772                             evSObject->calorim    771                             evSObject->calorimeterTPLeft.directionWorld,
773                             var->index1 );        772                             var->index1 );
774                     break;                        773                     break;
775                 }                                 774                 }
776                 if ( var->name == CexmcCFVarOp    775                 if ( var->name == CexmcCFVarOpdpClMom )
777                 {                                 776                 {
778                     var->addr = &evSObject->ca    777                     var->addr = &evSObject->calorimeterTPLeft.momentumAmp;
779                     break;                        778                     break;
780                 }                                 779                 }
781                 if ( var->name == CexmcCFVarOp    780                 if ( var->name == CexmcCFVarOpdpClTid )
782                 {                                 781                 {
783                     var->addr = &evSObject->ca    782                     var->addr = &evSObject->calorimeterTPLeft.trackId;
784                     break;                        783                     break;
785                 }                                 784                 }
786                 if ( var->name == CexmcCFVarOp    785                 if ( var->name == CexmcCFVarOpdpCrPosL )
787                 {                                 786                 {
788                     var->addr = GetThreeVector    787                     var->addr = GetThreeVectorElementAddrByIndex(
789                             evSObject->calorim    788                             evSObject->calorimeterTPRight.positionLocal,
790                             var->index1 );        789                             var->index1 );
791                     break;                        790                     break;
792                 }                                 791                 }
793                 if ( var->name == CexmcCFVarOp    792                 if ( var->name == CexmcCFVarOpdpCrPosW )
794                 {                                 793                 {
795                     var->addr = GetThreeVector    794                     var->addr = GetThreeVectorElementAddrByIndex(
796                             evSObject->calorim    795                             evSObject->calorimeterTPRight.positionWorld,
797                             var->index1 );        796                             var->index1 );
798                     break;                        797                     break;
799                 }                                 798                 }
800                 if ( var->name == CexmcCFVarOp    799                 if ( var->name == CexmcCFVarOpdpCrDirL )
801                 {                                 800                 {
802                     var->addr = GetThreeVector    801                     var->addr = GetThreeVectorElementAddrByIndex(
803                             evSObject->calorim    802                             evSObject->calorimeterTPRight.directionLocal,
804                             var->index1 );        803                             var->index1 );
805                     break;                        804                     break;
806                 }                                 805                 }
807                 if ( var->name == CexmcCFVarOp    806                 if ( var->name == CexmcCFVarOpdpCrDirW )
808                 {                                 807                 {
809                     var->addr = GetThreeVector    808                     var->addr = GetThreeVectorElementAddrByIndex(
810                             evSObject->calorim    809                             evSObject->calorimeterTPRight.directionWorld,
811                             var->index1 );        810                             var->index1 );
812                     break;                        811                     break;
813                 }                                 812                 }
814                 if ( var->name == CexmcCFVarOp    813                 if ( var->name == CexmcCFVarOpdpCrMom )
815                 {                                 814                 {
816                     var->addr = &evSObject->ca    815                     var->addr = &evSObject->calorimeterTPRight.momentumAmp;
817                     break;                        816                     break;
818                 }                                 817                 }
819                 if ( var->name == CexmcCFVarOp    818                 if ( var->name == CexmcCFVarOpdpCrTid )
820                 {                                 819                 {
821                     var->addr = &evSObject->ca    820                     var->addr = &evSObject->calorimeterTPRight.trackId;
822                     break;                        821                     break;
823                 }                                 822                 }
824                 if ( var->name == CexmcCFVarIp    823                 if ( var->name == CexmcCFVarIpSCM )
825                 {                                 824                 {
826                     var->addr = GetLorentzVect    825                     var->addr = GetLorentzVectorElementAddrByIndex(
827                         evSObject->productionM    826                         evSObject->productionModelData.incidentParticleSCM,
828                         var->index1 );            827                         var->index1 );
829                     break;                        828                     break;
830                 }                                 829                 }
831                 if ( var->name == CexmcCFVarIp    830                 if ( var->name == CexmcCFVarIpLAB )
832                 {                                 831                 {
833                     var->addr = GetLorentzVect    832                     var->addr = GetLorentzVectorElementAddrByIndex(
834                         evSObject->productionM    833                         evSObject->productionModelData.incidentParticleLAB,
835                         var->index1 );            834                         var->index1 );
836                     break;                        835                     break;
837                 }                                 836                 }
838                 if ( var->name == CexmcCFVarNp    837                 if ( var->name == CexmcCFVarNpSCM )
839                 {                                 838                 {
840                     var->addr = GetLorentzVect    839                     var->addr = GetLorentzVectorElementAddrByIndex(
841                         evSObject->productionM    840                         evSObject->productionModelData.nucleusParticleSCM,
842                         var->index1 );            841                         var->index1 );
843                     break;                        842                     break;
844                 }                                 843                 }
845                 if ( var->name == CexmcCFVarNp    844                 if ( var->name == CexmcCFVarNpLAB )
846                 {                                 845                 {
847                     var->addr = GetLorentzVect    846                     var->addr = GetLorentzVectorElementAddrByIndex(
848                         evSObject->productionM    847                         evSObject->productionModelData.nucleusParticleLAB,
849                         var->index1 );            848                         var->index1 );
850                     break;                        849                     break;
851                 }                                 850                 }
852                 if ( var->name == CexmcCFVarOp    851                 if ( var->name == CexmcCFVarOpSCM )
853                 {                                 852                 {
854                     var->addr = GetLorentzVect    853                     var->addr = GetLorentzVectorElementAddrByIndex(
855                         evSObject->productionM    854                         evSObject->productionModelData.outputParticleSCM,
856                         var->index1 );            855                         var->index1 );
857                     break;                        856                     break;
858                 }                                 857                 }
859                 if ( var->name == CexmcCFVarOp    858                 if ( var->name == CexmcCFVarOpLAB )
860                 {                                 859                 {
861                     var->addr = GetLorentzVect    860                     var->addr = GetLorentzVectorElementAddrByIndex(
862                         evSObject->productionM    861                         evSObject->productionModelData.outputParticleLAB,
863                         var->index1 );            862                         var->index1 );
864                     break;                        863                     break;
865                 }                                 864                 }
866                 if ( var->name == CexmcCFVarNo    865                 if ( var->name == CexmcCFVarNopSCM )
867                 {                                 866                 {
868                     var->addr = GetLorentzVect    867                     var->addr = GetLorentzVectorElementAddrByIndex(
869                         evSObject->productionM    868                         evSObject->productionModelData.nucleusOutputParticleSCM,
870                         var->index1 );            869                         var->index1 );
871                     break;                        870                     break;
872                 }                                 871                 }
873                 if ( var->name == CexmcCFVarNo    872                 if ( var->name == CexmcCFVarNopLAB )
874                 {                                 873                 {
875                     var->addr = GetLorentzVect    874                     var->addr = GetLorentzVectorElementAddrByIndex(
876                         evSObject->productionM    875                         evSObject->productionModelData.nucleusOutputParticleLAB,
877                         var->index1 );            876                         var->index1 );
878                     break;                        877                     break;
879                 }                                 878                 }
880                 if ( var->name == CexmcCFVarIp    879                 if ( var->name == CexmcCFVarIpId )
881                 {                                 880                 {
882                     var->addr =                   881                     var->addr =
883                         &evSObject->production    882                         &evSObject->productionModelData.incidentParticle;
884                     break;                        883                     break;
885                 }                                 884                 }
886                 if ( var->name == CexmcCFVarNp    885                 if ( var->name == CexmcCFVarNpId )
887                 {                                 886                 {
888                     var->addr = &evSObject->pr    887                     var->addr = &evSObject->productionModelData.nucleusParticle;
889                     break;                        888                     break;
890                 }                                 889                 }
891                 if ( var->name == CexmcCFVarOp    890                 if ( var->name == CexmcCFVarOpId )
892                 {                                 891                 {
893                     var->addr = &evSObject->pr    892                     var->addr = &evSObject->productionModelData.outputParticle;
894                     break;                        893                     break;
895                 }                                 894                 }
896                 if ( var->name == CexmcCFVarNo    895                 if ( var->name == CexmcCFVarNopId )
897                 {                                 896                 {
898                     var->addr =                   897                     var->addr =
899                         &evSObject->production    898                         &evSObject->productionModelData.nucleusOutputParticle;
900                     break;                        899                     break;
901                 }                                 900                 }
902                 if ( var->name == CexmcCFVarCo    901                 if ( var->name == CexmcCFVarConst_eV )
903                 {                                 902                 {
904                     var->addr = &constants[ 0     903                     var->addr = &constants[ 0 ];
905                     break;                        904                     break;
906                 }                                 905                 }
907                 if ( var->name == CexmcCFVarCo    906                 if ( var->name == CexmcCFVarConst_keV )
908                 {                                 907                 {
909                     var->addr = &constants[ 1     908                     var->addr = &constants[ 1 ];
910                     break;                        909                     break;
911                 }                                 910                 }
912                 if ( var->name == CexmcCFVarCo    911                 if ( var->name == CexmcCFVarConst_MeV )
913                 {                                 912                 {
914                     var->addr = &constants[ 2     913                     var->addr = &constants[ 2 ];
915                     break;                        914                     break;
916                 }                                 915                 }
917                 if ( var->name == CexmcCFVarCo    916                 if ( var->name == CexmcCFVarConst_GeV )
918                 {                                 917                 {
919                     var->addr = &constants[ 3     918                     var->addr = &constants[ 3 ];
920                     break;                        919                     break;
921                 }                                 920                 }
922                 if ( var->name == CexmcCFVarCo    921                 if ( var->name == CexmcCFVarConst_mm )
923                 {                                 922                 {
924                     var->addr = &constants[ 4     923                     var->addr = &constants[ 4 ];
925                     break;                        924                     break;
926                 }                                 925                 }
927                 if ( var->name == CexmcCFVarCo    926                 if ( var->name == CexmcCFVarConst_cm )
928                 {                                 927                 {
929                     var->addr = &constants[ 5     928                     var->addr = &constants[ 5 ];
930                     break;                        929                     break;
931                 }                                 930                 }
932                 if ( var->name == CexmcCFVarCo    931                 if ( var->name == CexmcCFVarConst_m )
933                 {                                 932                 {
934                     var->addr = &constants[ 6     933                     var->addr = &constants[ 6 ];
935                     break;                        934                     break;
936                 }                                 935                 }
937             } while ( false );                    936             } while ( false );
938         }                                         937         }
939     }                                             938     }
940 }                                                 939 }
941                                                   940 
942                                                   941 
943 void  CexmcASTEval::ResetAddressBinding( Cexmc    942 void  CexmcASTEval::ResetAddressBinding( CexmcAST::Subtree &  ast )
944 {                                                 943 {
945     for ( std::vector< CexmcAST::Node >::itera    944     for ( std::vector< CexmcAST::Node >::iterator  k( ast.children.begin() );
946                                                   945                                                   k != ast.children.end(); ++k )
947     {                                             946     {
948         CexmcAST::Subtree *  subtree( boost::g    947         CexmcAST::Subtree *  subtree( boost::get< CexmcAST::Subtree >( &*k ) );
949                                                   948 
950         if ( subtree )                            949         if ( subtree )
951         {                                         950         {
952             ResetAddressBinding( *subtree );      951             ResetAddressBinding( *subtree );
953         }                                         952         }
954         else                                      953         else
955         {                                         954         {
956             CexmcAST::Leaf &      leaf( boost:    955             CexmcAST::Leaf &      leaf( boost::get< CexmcAST::Leaf >( *k ) );
957             CexmcAST::Variable *  var( boost::    956             CexmcAST::Variable *  var( boost::get< CexmcAST::Variable >(
958                                                   957                                                                     &leaf ) );
959             if ( var )                            958             if ( var )
960                 var->addr = ( const int * ) NU    959                 var->addr = ( const int * ) NULL;
961         }                                         960         }
962     }                                             961     }
963 }                                                 962 }
964                                                   963 
965 #endif                                            964 #endif
966                                                   965 
967                                                   966