1 //--------------------------------------------------------------------------
4 // This software is part of the EvtGen package developed jointly
5 // for the BaBar and CLEO collaborations. If you use all or part
6 // of it, please give an appropriate acknowledgement.
8 // Copyright Information:
9 // Copyright (C) 1998 Caltech, UCSB
11 // Alexei Dvoretskii 2001-2002
12 //------------------------------------------------------------------------
14 // Abstract amplitude factory parameterized by a vector of
15 // strings. Derived classes construct the amplitude, and PDFs for sampling
18 #ifndef EVT_AMP_FACTORY_HH
19 #define EVT_AMP_FACTORY_HH
24 #include "EvtGenBase/EvtAmplitudeSum.hh"
25 #include "EvtGenBase/EvtPdfSum.hh"
26 #include "EvtGenBase/EvtMultiChannelParser.hh"
27 #include "EvtGenBase/EvtAmpPdf.hh"
28 #include "EvtGenBase/EvtPdfMax.hh"
29 #include "EvtGenBase/EvtMacros.hh"
36 : _amp(0), _ampConj(0), _pc(0), _dm(0.), _verbose(false)
39 EvtAmpFactory(const EvtAmpFactory<T>& other)
41 _amp(other._amp ? (EvtAmplitudeSum<T>*) other._amp : 0),
42 _ampConj(other._ampConj ? (EvtAmplitudeSum<T>*) other._ampConj : 0),
43 _pc(other._pc ? (EvtPdfSum<T>*) other._pc : 0),
45 _verbose(other._verbose)
48 virtual ~EvtAmpFactory()
51 if(_ampConj) delete _ampConj;
55 virtual EvtAmpFactory<T>* clone() const = 0;
57 virtual void build(const EvtMultiChannelParser& parser, int nItg)
59 _amp = new EvtAmplitudeSum<T>();
60 _ampConj = new EvtAmplitudeSum<T>();
61 _pc = new EvtPdfSum<T>();
63 _mixAmpli = parser.mixAmpli();
64 _mixPhase = parser.mixPhase();
66 printf("Amplitude with %d terms\n",parser.getNAmp());
68 for(i=0;i<parser.getNAmp();i++) {
70 std::vector<std::string> v = parser.amp(i);
71 EvtComplex c = parser.ampCoef(i);
75 printf("Conj. amplitude with %d terms\n",parser.getNAmpConj());
76 for(i=0;i<parser.getNAmpConj();i++) {
78 std::vector<std::string> v = parser.ampConj(i);
79 EvtComplex c = parser.ampConjCoef(i);
83 printf("Calculating pole compensator integrals %d steps\n",nItg);
84 if(nItg > 0) _pc->getItg(nItg);
86 printf("End build\n");
89 virtual void processAmp(EvtComplex c, std::vector<std::string> v, bool conj = false) = 0;
91 inline bool isCPModel() const { return (_ampConj->nTerms() > 0 ? true : false); }
92 inline double dm() const { return _dm; }
93 inline double mixAmpli() const { return _mixAmpli; }
94 inline double mixPhase() const { return _mixPhase; }
96 void setVerbose() { _verbose = true; }
99 EvtAmplitudeSum<T>* getAmp() const { return _amp; }
100 EvtAmplitudeSum<T>* getAmpConj() const { return _ampConj; }
101 EvtPdfSum<T>* getPC() const { return _pc; }
102 EvtAmplitude<T>* getAmp(int i) const { return _amp->getTerm(i); }
103 EvtPdf<T>* getPC(int i) const { return _pc->getPdf(i); }
104 const char* compName(int i) const { return _names[i].c_str(); }
106 EvtComplex getCoeff(int i) const { return _amp->c(i); }
108 double getTermCoeff(int i) const { return abs2(_amp->c(i)); }
109 double getTermCoeff(int type, int i, int j) const
113 case 0: return 2*real(_amp->c(i)*conj(_amp->c(j))); //posre
114 case 1: return -2*real(_amp->c(i)*conj(_amp->c(j))); //negre
115 case 2: return -2*imag(_amp->c(i)*conj(_amp->c(j))); //posim
116 case 3: return 2*imag(_amp->c(i)*conj(_amp->c(j))); //negim
123 EvtAmplitudeSum<T> *_amp; // _owned_ amplitude
124 EvtAmplitudeSum<T> *_ampConj; // _owned_ conjugate amplitude
125 EvtPdfSum<T> *_pc; // _owned_ pole compensator
126 std::vector<std::string> _names; // names of partial amplitudes
128 double _dm; // Mass difference for conjugate amplitude
129 double _mixPhase;// mixing phase
130 double _mixAmpli;// cpv in mixing