Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:20:01

0001 
0002 /***********************************************************************
0003 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors       *
0004 *                                                                      *
0005 * This file is part of EvtGen.                                         *
0006 *                                                                      *
0007 * EvtGen is free software: you can redistribute it and/or modify       *
0008 * it under the terms of the GNU General Public License as published by *
0009 * the Free Software Foundation, either version 3 of the License, or    *
0010 * (at your option) any later version.                                  *
0011 *                                                                      *
0012 * EvtGen is distributed in the hope that it will be useful,            *
0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
0015 * GNU General Public License for more details.                         *
0016 *                                                                      *
0017 * You should have received a copy of the GNU General Public License    *
0018 * along with EvtGen.  If not, see <https://www.gnu.org/licenses/>.     *
0019 ***********************************************************************/
0020 
0021 #ifndef EVT_AMP_AMP_PDF_HH
0022 #define EVT_AMP_AMP_PDF_HH
0023 
0024 // From the product A1A2* four PDF terms can be constructed, by taking the positive
0025 // and the negative parts or the real and imaginary part of the product.
0026 
0027 #include "EvtGenBase/EvtAmplitude.hh"
0028 #include "EvtGenBase/EvtMacros.hh"
0029 #include "EvtGenBase/EvtPdf.hh"
0030 
0031 #include <assert.h>
0032 
0033 enum
0034 {
0035     POSRE = 0,
0036     NEGRE,
0037     POSIM,
0038     NEGIM
0039 };
0040 
0041 template <class T>
0042 class EvtAmpAmpPdf : public EvtPdf<T> {
0043   public:
0044     EvtAmpAmpPdf() {}
0045     EvtAmpAmpPdf( int type, const EvtAmplitude<T>& amp1,
0046                   const EvtAmplitude<T>& amp2 ) :
0047         EvtPdf<T>(), _type( type ), _amp1( amp1.clone() ), _amp2( amp2.clone() )
0048     {
0049     }
0050     EvtAmpAmpPdf( const EvtAmpAmpPdf<T>& other ) :
0051         EvtPdf<T>( other ),
0052         _type( other._type ),
0053         COPY_PTR( _amp1 ),
0054         COPY_PTR( _amp2 )
0055     {
0056     }
0057     virtual ~EvtAmpAmpPdf()
0058     {
0059         delete _amp1;
0060         delete _amp2;
0061     }
0062 
0063     virtual EvtAmpAmpPdf<T>* clone() const { return new EvtAmpAmpPdf( *this ); }
0064 
0065     virtual double pdf( const T& p ) const
0066     {
0067         EvtComplex amp1 = _amp1->evaluate( p );
0068         EvtComplex amp2 = _amp2->evaluate( p );
0069         EvtComplex pr = amp1 * conj( amp2 );
0070 
0071         if ( _type == POSRE )
0072             return real( pr ) > 0 ? real( pr ) : 0.;
0073         if ( _type == NEGRE )
0074             return real( pr ) < 0 ? -real( pr ) : 0.;
0075         if ( _type == POSIM )
0076             return imag( pr ) > 0 ? imag( pr ) : 0.;
0077         if ( _type == NEGIM )
0078             return imag( pr ) < 0 ? -imag( pr ) : 0.;
0079 
0080         assert( 0 );
0081     }
0082 
0083   private:
0084     int _type;
0085     EvtAmplitude<T>* _amp1;
0086     EvtAmplitude<T>* _amp2;
0087 };
0088 
0089 #endif