StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EvtAmpFactory.hh
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  EvtAmpFactory()
36  : _amp(0), _ampConj(0), _pc(0), _dm(0.), _verbose(false)
37  {}
38 
39  EvtAmpFactory(const EvtAmpFactory<T>& other)
40  :
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),
44  _dm(other._dm),
45  _verbose(other._verbose)
46  {}
47 
48  virtual ~EvtAmpFactory()
49  {
50  if(_amp) delete _amp;
51  if(_ampConj) delete _ampConj;
52  if(_pc) delete _pc;
53  }
54 
55  virtual EvtAmpFactory<T>* clone() const = 0;
56 
57  virtual void build(const EvtMultiChannelParser& parser, int nItg)
58  {
59  _amp = new EvtAmplitudeSum<T>();
60  _ampConj = new EvtAmplitudeSum<T>();
61  _pc = new EvtPdfSum<T>();
62  _dm = parser.dm();
63  _mixAmpli = parser.mixAmpli();
64  _mixPhase = parser.mixPhase();
65 
66  printf("Amplitude with %d terms\n",parser.getNAmp());
67  int i;
68  for(i=0;i<parser.getNAmp();i++) {
69 
70  std::vector<std::string> v = parser.amp(i);
71  EvtComplex c = parser.ampCoef(i);
72  processAmp(c,v);
73  }
74 
75  printf("Conj. amplitude with %d terms\n",parser.getNAmpConj());
76  for(i=0;i<parser.getNAmpConj();i++) {
77 
78  std::vector<std::string> v = parser.ampConj(i);
79  EvtComplex c = parser.ampConjCoef(i);
80  processAmp(c,v,true);
81  }
82 
83  printf("Calculating pole compensator integrals %d steps\n",nItg);
84  if(nItg > 0) _pc->getItg(nItg);
85 
86  printf("End build\n");
87  }
88 
89  virtual void processAmp(EvtComplex c, std::vector<std::string> v, bool conj = false) = 0;
90 
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; }
95 
96  void setVerbose() { _verbose = true; }
97 
98 
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(); }
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 
Definition: EvtPdf.hh:57