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