00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EVT_AMP_FACTORY_HH
00019 #define EVT_AMP_FACTORY_HH
00020
00021 #include <vector>
00022 #include <string>
00023 #include <stdio.h>
00024 #include "EvtGenBase/EvtAmplitudeSum.hh"
00025 #include "EvtGenBase/EvtPdfSum.hh"
00026 #include "EvtGenBase/EvtMultiChannelParser.hh"
00027 #include "EvtGenBase/EvtAmpPdf.hh"
00028 #include "EvtGenBase/EvtPdfMax.hh"
00029 #include "EvtGenBase/EvtMacros.hh"
00030
00031 template <class T>
00032 class EvtAmpFactory {
00033 public:
00034
00035 EvtAmpFactory()
00036 : _amp(0), _ampConj(0), _pc(0), _dm(0.), _verbose(false)
00037 {}
00038
00039 EvtAmpFactory(const EvtAmpFactory<T>& other)
00040 :
00041 _amp(other._amp ? (EvtAmplitudeSum<T>*) other._amp : 0),
00042 _ampConj(other._ampConj ? (EvtAmplitudeSum<T>*) other._ampConj : 0),
00043 _pc(other._pc ? (EvtPdfSum<T>*) other._pc : 0),
00044 _dm(other._dm),
00045 _verbose(other._verbose)
00046 {}
00047
00048 virtual ~EvtAmpFactory()
00049 {
00050 if(_amp) delete _amp;
00051 if(_ampConj) delete _ampConj;
00052 if(_pc) delete _pc;
00053 }
00054
00055 virtual EvtAmpFactory<T>* clone() const = 0;
00056
00057 virtual void build(const EvtMultiChannelParser& parser, int nItg)
00058 {
00059 _amp = new EvtAmplitudeSum<T>();
00060 _ampConj = new EvtAmplitudeSum<T>();
00061 _pc = new EvtPdfSum<T>();
00062
00063 printf("Amplitude with %d terms\n",parser.getNAmp());
00064 int i;
00065 for(i=0;i<parser.getNAmp();i++) {
00066
00067 std::vector<std::string> v = parser.amp(i);
00068 EvtComplex c = parser.ampCoef(i);
00069 processAmp(c,v);
00070 }
00071
00072 printf("Conj. amplitude with %d terms\n",parser.getNAmpConj());
00073 for(i=0;i<parser.getNAmpConj();i++) {
00074
00075 std::vector<std::string> v = parser.ampConj(i);
00076 EvtComplex c = parser.ampConjCoef(i);
00077 processAmp(c,v,true);
00078 }
00079
00080 printf("Calculating pole compensator integrals %d steps\n",nItg);
00081 if(nItg > 0) _pc->getItg(nItg);
00082
00083 printf("End build\n");
00084 }
00085
00086 virtual void processAmp(EvtComplex c, std::vector<std::string> v, bool conj = false) = 0;
00087
00088 inline bool isCPModel() const { return (_ampConj->nTerms() > 0 ? true : false); }
00089 inline double dm() const { return _dm; }
00090
00091 void setVerbose() { _verbose = true; }
00092
00093
00094 EvtAmplitudeSum<T>* getAmp() const { return _amp; }
00095 EvtAmplitudeSum<T>* getAmpConj() const { return _ampConj; }
00096 EvtPdfSum<T>* getPC() const { return _pc; }
00097 EvtAmplitude<T>* getAmp(int i) const { return _amp->getTerm(i); }
00098 EvtPdf<T>* getPC(int i) const { return _pc->getPdf(i); }
00099 const char* compName(int i) const { return _names[i].c_str(); }
00100
00101 EvtComplex getCoeff(int i) const { return _amp->c(i); }
00102
00103 double getTermCoeff(int i) const { return abs2(_amp->c(i)); }
00104 double getTermCoeff(int type, int i, int j) const
00105 {
00106 switch(type) {
00107
00108 case 0: return 2*real(_amp->c(i)*conj(_amp->c(j)));
00109 case 1: return -2*real(_amp->c(i)*conj(_amp->c(j)));
00110 case 2: return -2*imag(_amp->c(i)*conj(_amp->c(j)));
00111 case 3: return 2*imag(_amp->c(i)*conj(_amp->c(j)));
00112 default: assert(0);
00113 }
00114 }
00115
00116 protected:
00117
00118 EvtAmplitudeSum<T> *_amp;
00119 EvtAmplitudeSum<T> *_ampConj;
00120 EvtPdfSum<T> *_pc;
00121 std::vector<std::string> _names;
00122
00123 double _dm;
00124 bool _verbose;
00125 };
00126
00127
00128 #endif
00129
00130
00131
00132
00133