Line data Source code
1 : //--------------------------------------------------------------------------
2 : //
3 : // Environment:
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.
7 : //
8 : // Copyright Information:
9 : // Copyright (C) 1998 Caltech, UCSB
10 : //
11 : // Alexei Dvoretskii 2001-2002
12 : //------------------------------------------------------------------------
13 :
14 : // Abstract amplitude factory parameterized by a vector of
15 : // strings. Derived classes construct the amplitude, and PDFs for sampling
16 : // points.
17 :
18 : #ifndef EVT_AMP_FACTORY_HH
19 : #define EVT_AMP_FACTORY_HH
20 :
21 : #include <vector>
22 : #include <string>
23 : #include <stdio.h>
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"
30 :
31 : template <class T>
32 : class EvtAmpFactory {
33 : public:
34 :
35 0 : EvtAmpFactory()
36 0 : : _amp(0), _ampConj(0), _pc(0), _dm(0.), _verbose(false)
37 0 : {}
38 :
39 0 : EvtAmpFactory(const EvtAmpFactory<T>& other)
40 : :
41 0 : _amp(other._amp ? (EvtAmplitudeSum<T>*) other._amp : 0),
42 0 : _ampConj(other._ampConj ? (EvtAmplitudeSum<T>*) other._ampConj : 0),
43 0 : _pc(other._pc ? (EvtPdfSum<T>*) other._pc : 0),
44 0 : _dm(other._dm),
45 0 : _verbose(other._verbose)
46 0 : {}
47 :
48 : virtual ~EvtAmpFactory()
49 0 : {
50 0 : if(_amp) delete _amp;
51 0 : if(_ampConj) delete _ampConj;
52 0 : if(_pc) delete _pc;
53 0 : }
54 :
55 : virtual EvtAmpFactory<T>* clone() const = 0;
56 :
57 : virtual void build(const EvtMultiChannelParser& parser, int nItg)
58 : {
59 0 : _amp = new EvtAmplitudeSum<T>();
60 0 : _ampConj = new EvtAmplitudeSum<T>();
61 0 : _pc = new EvtPdfSum<T>();
62 0 : _dm = parser.dm();
63 0 : _mixAmpli = parser.mixAmpli();
64 0 : _mixPhase = parser.mixPhase();
65 :
66 0 : printf("Amplitude with %d terms\n",parser.getNAmp());
67 : int i;
68 0 : for(i=0;i<parser.getNAmp();i++) {
69 :
70 0 : std::vector<std::string> v = parser.amp(i);
71 0 : EvtComplex c = parser.ampCoef(i);
72 0 : processAmp(c,v);
73 0 : }
74 :
75 0 : printf("Conj. amplitude with %d terms\n",parser.getNAmpConj());
76 0 : for(i=0;i<parser.getNAmpConj();i++) {
77 :
78 0 : std::vector<std::string> v = parser.ampConj(i);
79 0 : EvtComplex c = parser.ampConjCoef(i);
80 0 : processAmp(c,v,true);
81 0 : }
82 :
83 0 : printf("Calculating pole compensator integrals %d steps\n",nItg);
84 0 : if(nItg > 0) _pc->getItg(nItg);
85 :
86 0 : printf("End build\n");
87 0 : }
88 :
89 : virtual void processAmp(EvtComplex c, std::vector<std::string> v, bool conj = false) = 0;
90 :
91 0 : inline bool isCPModel() const { return (_ampConj->nTerms() > 0 ? true : false); }
92 0 : inline double dm() const { return _dm; }
93 0 : inline double mixAmpli() const { return _mixAmpli; }
94 0 : inline double mixPhase() const { return _mixPhase; }
95 :
96 : void setVerbose() { _verbose = true; }
97 :
98 :
99 0 : EvtAmplitudeSum<T>* getAmp() const { return _amp; }
100 0 : EvtAmplitudeSum<T>* getAmpConj() const { return _ampConj; }
101 0 : 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(); }
105 :
106 : EvtComplex getCoeff(int i) const { return _amp->c(i); }
107 :
108 : double getTermCoeff(int i) const { return abs2(_amp->c(i)); }
109 : double getTermCoeff(int type, int i, int j) const
110 : {
111 : switch(type) {
112 :
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
117 : default: assert(0);
118 : }
119 : }
120 :
121 : protected:
122 :
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
127 :
128 : double _dm; // Mass difference for conjugate amplitude
129 : double _mixPhase;// mixing phase
130 : double _mixAmpli;// cpv in mixing
131 : bool _verbose;
132 : };
133 :
134 :
135 : #endif
136 :
137 :
138 :
139 :
140 :
|