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