AmpTools
Amplitude.h
Go to the documentation of this file.
1 #if !defined( AMPLITUDE )
2 #define AMPLITUDE
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 #include <map>
41 #include <complex>
42 #include <vector>
43 #include <string>
44 #include <cassert>
45 
46 #include "IUAmpTools/Kinematics.h"
48 
49 #ifdef GPU_ACCELERATION
50 #include "cuda_runtime.h"
51 #include "GPUManager/CUDA-Complex.cuh"
52 class GPUManager;
53 #endif //GPU_ACCELERATION
54 
55 using std::complex;
56 using namespace std;
57 
58 class Kinematics;
59 class AmpParameter;
60 
86 class Amplitude
87 {
88 
89 public:
90 
95  Amplitude( ) : m_isDefault(true) { }
96 
102  Amplitude( const vector< string >& args ) : m_isDefault(false),
103  m_args(args){ }
104 
108  virtual ~Amplitude(){}
109 
115  virtual string name() const = 0;
116 
121  bool containsFreeParameters() const;
122 
136  virtual Amplitude* newAmplitude( const vector< string >& args ) const = 0;
137 
148  virtual Amplitude* clone() const = 0;
149 
154  bool isDefault() const { return ( m_isDefault == true ); }
155 
159  vector<string> arguments() const { return m_args; }
160 
167  virtual void init(){}
168 
184  bool setParPtr( const string& name, const double* ptr ) const;
185 
199  bool setParValue( const string& name, double val ) const;
200 
210  virtual void updatePar( const AmpParameter& par ) {}
211 
224  bool updatePar( const string& name ) const;
225 
226  // speed may be enhanced if the two functions below are combined
227  // as this avoids an extra function call, but puts more complicated
228  // calcAllAmplitudes loops in user code
229 
256  virtual void calcAmplitudeAll( GDouble* pdData, GDouble* pdAmps, int iNEvents,
257  const vector< vector< int > >* pvPermutations ) const;
258 
259 
270  virtual complex< GDouble > calcAmplitude( GDouble** pKin ) const = 0;
271 
272 
285  complex< GDouble > calcAmplitude( const Kinematics* pKin ) const;
286 
287 
303  complex< GDouble > calcAmplitude( const Kinematics* pKin,
304  const vector < int >& permutation ) const;
305 
306 
307 #ifdef GPU_ACCELERATION
308 
314  virtual void calcAmplitudeGPU( dim3 dimGrid, dim3 dimBlock, GPU_AMP_PROTO,
315  const vector< int >& perm ) const;
316 
321  virtual void launchGPUKernel( dim3 dimGrid, dim3 dimBlock, GPU_AMP_PROTO ) const {
322 
323  cout << "\nNo GPU function for calculating " << name() << " is defined." << endl;
324  assert( false );
325  }
326 
327 #endif //GPU_ACCELERATION
328 
329 protected:
330 
339  void registerParameter( AmpParameter& par );
340 
353  inline const vector< int >& getCurrentPermutation() const { return m_currentPermutation; }
354 
355 
356 private:
357 
358  bool m_isDefault;
359 
360  vector<string> m_args;
361 
362  vector< AmpParameter* > m_registeredParams;
363 
364  mutable vector< int > m_currentPermutation;
365 };
366 
367 
368 #endif
virtual ~Amplitude()
Definition: Amplitude.h:108
virtual void launchGPUKernel(dim3 dimGrid, dim3 dimBlock, GPU_AMP_PROTO) const
Definition: Amplitude.h:321
const vector< int > & getCurrentPermutation() const
Definition: Amplitude.h:353
bool isDefault() const
Definition: Amplitude.h:154
Amplitude(const vector< string > &args)
Definition: Amplitude.h:102
double GDouble
virtual void updatePar(const AmpParameter &par)
Definition: Amplitude.h:210
virtual void init()
Definition: Amplitude.h:167
#define GPU_AMP_PROTO
Amplitude()
Definition: Amplitude.h:95
vector< string > arguments() const
Definition: Amplitude.h:159