Skip to content

Commit

Permalink
Merge pull request #11 from dglazier/ampblend
Browse files Browse the repository at this point in the history
Ampblend
  • Loading branch information
dglazier authored Jun 9, 2021
2 parents 42fb9f0 + 55a1abb commit 41cf150
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ROOT_GENERATE_DICTIONARY(G__${ELSPECTRO}
FunctionsForJpac.h
Manager.h
Interface.h
amplitude_blend.hpp
LINKDEF ElSpectroLinkDef.h
)

Expand Down Expand Up @@ -89,6 +90,7 @@ add_library(${ELSPECTRO} SHARED
LundWriter.cpp
Manager.cpp
FunctionsForJpac.cpp
amplitude_blend.cpp
G__${ELSPECTRO}.cxx
)

Expand Down
4 changes: 2 additions & 2 deletions core/DistVirtPhotFlux_xy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ namespace elSpectro{
_lnxmax=0;

//Finally, Integrate over photon flux
auto xvar = RooRealVar("x","x",(_lnxmax-_lnxmin)/2,_lnxmin,_lnxmax,"");
auto yvar = RooRealVar("y","y",(_lnymax-_lnymin)/2,_lnymin,_lnymax,"");
auto xvar = RooRealVar("x","x",-(_lnxmax-_lnxmin)/2,_lnxmin,_lnxmax,"");
auto yvar = RooRealVar("y","y",-(_lnymax-_lnymin)/2,_lnymin,_lnymax,"");
// auto xvar = RooRealVar("x","x",TMath::Exp((_lnxmax-_lnxmin)/2),TMath::Exp(_lnxmin),TMath::Exp(_lnxmax),"");
//auto yvar = RooRealVar("y","y",TMath::Exp((_lnymax-_lnymin)/2),TMath::Exp(_lnymin),TMath::Exp(_lnymax),"");
xvar.Print();
Expand Down
38 changes: 38 additions & 0 deletions core/amplitude_blend.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Class to sum up any number of generic amplitudes and build observables.
// Amplitudes are loaded up in a vector and summed incoherently
//
// Author: Daniel Winney (2020)
// Affiliation: Joint Physics Analysis Center (JPAC)
// Email: [email protected]
// ---------------------------------------------------------------------------

#include "amplitude_blend.hpp"

// Evaluate the sum for given set of helicites, and mandelstam invariant s and t
std::complex<double> jpacPhoto::amplitude_blend::helicity_amplitude(std::array<int, 4> helicities, double s, double t)
{

int index = find_helicity(helicities, _kinematics->_jp[0], _kinematics->_mB);

if(s<_low_max){
_amp_low->check_cache(s, t);
return _amp_low->_cached_helicity_amplitude[index];
}
else if(s>_high_min){
_amp_high->check_cache(s, t);
return _amp_high->_cached_helicity_amplitude[index];
}
else{

_amp_low->check_cache(s, t);
_amp_high->check_cache(s, t);

double blend_range= _high_min - _low_max;
double fraction_low = 1 - (s-_low_max)/blend_range;

auto low_contrib = _amp_low->_cached_helicity_amplitude[index] * fraction_low;
auto high_contrib = _amp_high->_cached_helicity_amplitude[index] * (1 - fraction_low);

return low_contrib + high_contrib ;
}
};
57 changes: 57 additions & 0 deletions core/amplitude_blend.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Class to sum up any number of generic amplitudes and build observables.
// Amplitudes are loaded up in a vector and summed incoherently
//
// Author: Daniel Winney (2020)
// Affiliation: Joint Physics Analysis Center (JPAC)
// Email: [email protected]
// ---------------------------------------------------------------------------
#pragma once

#include "amplitudes/amplitude.hpp"

// ---------------------------------------------------------------------------
// The amplitude_blend class can take a vector of the above amplitude objects
// and add them together to get observables!
// ---------------------------------------------------------------------------

namespace jpacPhoto
{
class amplitude_blend : public amplitude
{
private:
// Store a vector of all the amplitudes you want to sum incoherently
amplitude* _amp_low={nullptr};
amplitude* _amp_high={nullptr};

double _low_max = {0};
double _high_min = {0};

public:
// Empty constructor
amplitude_blend(reaction_kinematics * xkinem, amplitude* amp_low, double lowTo, amplitude* amp_high,double highFrom,std::string identifer = "amplitude_blend")
: amplitude(xkinem, identifer),
_amp_low{amp_low},_amp_high{amp_high},
_low_max{lowTo},_high_min{highFrom}
{
if(lowTo>highFrom){
std::cerr<<"Error : amplitude_blend low limit "<<lowTo<<" greater then high"<<highFrom<<std::endl;
exit(0);
}
_isSum = true; //kind of. Actually for cache purposes.
};

//assume low amp allowedJP,
inline std::vector<std::array<int,2>> allowedJP()
{
return _amp_low->allowedJP();
};

// TODO: Add a set_params which timesi in one vector and allocates approriaten number of
// params to each sub amplitude

// Evaluate the sum for given set of helicites, energy, and cos
std::complex<double> helicity_amplitude(std::array<int, 4> helicities, double s, double t);

};
}

0 comments on commit 41cf150

Please sign in to comment.