AmpTools
AmplitudeManager.h
Go to the documentation of this file.
1 #if !defined( AMPLITUDEMANAGER )
2 #define AMPLITUDEMANAGER
3 
4 //******************************************************************************
5 // This file is part of AmpTools, a package for performing Amplitude Analysis
6 //
7 // Copyright Trustees of Indiana University 2010, all rights reserved
8 //
9 // This software written by Matthew Shepherd, Ryan Mitchell, and
10 // Hrayr Matevosyan at Indiana University, Bloomington
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions
14 // are met:
15 // 1. Redistributions of source code must retain the above copyright
16 // notice and author attribution, this list of conditions and the
17 // following disclaimer.
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice and author attribution, this list of conditions and the
20 // following disclaimer in the documentation and/or other materials
21 // provided with the distribution.
22 // 3. Neither the name of the University nor the names of its contributors
23 // may be used to endorse or promote products derived from this software
24 // without specific prior written permission.
25 //
26 // Creation of derivative forms of this software for commercial
27 // utilization may be subject to restriction; written permission may be
28 // obtained from the Trustees of Indiana University.
29 //
30 // INDIANA UNIVERSITY AND THE AUTHORS MAKE NO REPRESENTATIONS OR WARRANTIES,
31 // EXPRESS OR IMPLIED. By way of example, but not limitation, INDIANA
32 // UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCANTABILITY OR
33 // FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THIS SOFTWARE OR
34 // DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS,
35 // OR OTHER RIGHTS. Neither Indiana University nor the authors shall be
36 // held liable for any liability with respect to any claim by the user or
37 // any other party arising from use of the program.
38 //******************************************************************************
39 
40 
41 #include <map>
42 #include <iostream>
43 #include <vector>
44 #include <string>
45 #include <complex>
46 
48 #include "IUAmpTools/Amplitude.h"
50 #include "IUAmpTools/DataReader.h"
51 #include "IUAmpTools/AmpVecs.h"
53 
55 
56 #ifdef GPU_ACCELERATION
57 #include "GPUManager/GPUManager.h"
58 #endif //GPU_ACCELERATION
59 
60 class Kinematics;
61 class NormIntInterface;
62 
63 using namespace std;
64 
86 {
87 
88 public:
89 
102  AmplitudeManager( const vector< string >& finalState,
103  const string& reactionName = "");
104 
107  ~AmplitudeManager();
108 
113  Type type() const { return kAmplitude; }
114 
121  unsigned int maxFactorStoragePerEvent() const;
122 
129  unsigned int termStoragePerEvent() const;
130 
145  bool calcTerms( AmpVecs& ampVecs ) const;
146 
161  double calcIntensities( AmpVecs& ampVecs ) const;
162 
176  double calcSumLogIntensity( AmpVecs& ampVecs ) const;
177 
203  void calcIntegrals( AmpVecs& ampVecs, int iNGenEvents ) const;
204 
218  const vector< vector< int > >& getPermutations( const string& name ) const;
219 
230  const vector< const Amplitude* >& getFactors( const string& name ) const;
231 
241  bool hasTermWithFreeParam() const;
242 
243  //
244  // The functions below modify the state of the AmplitudeManager
245  //
246 
255  void setupFromConfigurationInfo( const ConfigurationInfo* configInfo );
256 
291  void addAmpFactor( const string& ampName, const string& factorName,
292  const vector< string >& args, const string& sum = "",
293  const string& scale = "1.0" );
294 
317  void addAmpPermutation( const string& ampName, const vector< int >& permutation );
318 
335  void registerAmplitudeFactor( const Amplitude& defaultAmplitude );
336 
358  void setParPtr( const string& termName, const string& parName,
359  const double* ampParPtr );
360 
381  void setParValue( const string& termName, const string& parName,
382  double ampParValue );
383 
389  void updatePar( const string& parName ) const;
390 
403  void setOptimizeParIteration( bool flag ) { m_optimizeParIteration = flag; }
404 
405 
406 private:
407 
408  // recursive routine to symmetrize final state
409  void generateSymmetricCombos( const vector< pair< int, int > >& prevSwaps,
410  vector< vector< pair< int, int > > > remainingSwaps,
411  const vector< int >& defaultOrder );
412 
413  // amplitude name -> vector of amplitude factors
414  map< string, vector< const Amplitude* > > m_mapNameToAmps;
415 
416  // amplitude name -> vector of particle permutations
417  // by default this starts as m_symmCombos for each amp
418  map< string, vector< vector< int > > > m_ampPermutations;
419 
420  // a vector to hold all of the symmetric combinations of final
421  // state particles
422  vector< vector< int > > m_symmCombos;
423 
424  // check to see if amplitudes have already been symmetrized so user can
425  // be warned if additional amplitudes are added after symmetrization is done
426  bool m_symmetrizeCalled;
427 
428  // this holds "default" amplitudes for all registered amplitudes
429  map< string, Amplitude* > m_registeredFactors;
430 
431  // the sum that each amplitude belongs to indexed on amplitude index
432  vector< string > m_ampSum;
433 
434  // a 2-D vector to track whether or not the two particular amplitudes interfere
435  vector< vector< bool > > m_sumCoherently;
436 
437  // vector to short-cut recomputation of terms with all fixed factors
438  vector< bool > m_vbIsAmpFixed;
439 
440  // some internal members to optimize amplitude recalculation
441  bool m_optimizeParIteration;
442  mutable map< const Amplitude*, int > m_ampIteration;
443  mutable map< AmpVecs*, map< const Amplitude*, int > > m_dataAmpIteration;
444 };
445 
446 #endif
void setOptimizeParIteration(bool flag)