]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TEvtGen/EvtGenBase/EvtAmpAmpPdf.hh
AliDecayer realisation for the EvtGen code and EvtGen itself.
[u/mrichter/AliRoot.git] / TEvtGen / EvtGenBase / EvtAmpAmpPdf.hh
1 /*******************************************************************************
2  * Project: BaBar detector at the SLAC PEP-II B-factory
3  * Package: EvtGenBase
4  *    File: $Id: EvtAmpAmpPdf.hh,v 1.2 2003/06/20 17:19:59 dvoretsk Exp $
5  *  Author: Alexei Dvoretskii, dvoretsk@slac.stanford.edu, 2001-2002
6  *
7  * Copyright (C) 2002 Caltech
8  *******************************************************************************/
9
10 #ifndef EVT_AMP_AMP_PDF_HH
11 #define EVT_AMP_AMP_PDF_HH
12
13 // From the product A1A2* four PDF terms can be constructed, by taking the positive
14 // and the negative parts or the real and imaginary part of the product.
15
16 #include <assert.h>
17 #include "EvtGenBase/EvtMacros.hh"
18 #include "EvtGenBase/EvtAmplitude.hh"
19 #include "EvtGenBase/EvtPdf.hh"
20
21 enum {POSRE=0,NEGRE,POSIM,NEGIM};
22
23 template <class T>
24 class EvtAmpAmpPdf : public EvtPdf<T> {  
25 public:
26
27   EvtAmpAmpPdf() {}
28   EvtAmpAmpPdf(int type, const EvtAmplitude<T>& amp1, const EvtAmplitude<T>& amp2) 
29     : EvtPdf<T>(), _type(type), _amp1(amp1.clone()), _amp2(amp2.clone()) 
30   {}
31   EvtAmpAmpPdf(const EvtAmpAmpPdf<T>& other) 
32     : EvtPdf<T>(other), _type(other._type), COPY_PTR(_amp1), COPY_PTR(_amp2) 
33   {}
34   virtual ~EvtAmpAmpPdf() 
35   { 
36     delete _amp1; 
37     delete _amp2; 
38   }
39     
40   virtual EvtAmpAmpPdf<T>* clone() const { return new EvtAmpAmpPdf(*this); }
41
42   virtual double pdf(const T& p) const
43   {
44     EvtComplex amp1 = _amp1->evaluate(p);
45     EvtComplex amp2 = _amp2->evaluate(p);
46     EvtComplex pr = amp1 * conj(amp2);
47
48     if(_type == POSRE) return real(pr) > 0 ? real(pr) : 0.;
49     if(_type == NEGRE) return real(pr) < 0 ? -real(pr) : 0.;
50     if(_type == POSIM) return imag(pr) > 0 ? imag(pr) : 0.;
51     if(_type == NEGIM) return imag(pr) < 0 ? -imag(pr) : 0.;
52     
53     assert(0);
54   }
55   
56 private:
57   
58   int _type;
59   EvtAmplitude<T>* _amp1;
60   EvtAmplitude<T>* _amp2;
61 };
62
63 #endif
64