gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
DarkBit_types.cpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
45 
46 
47 #include <cmath>
48 #include <algorithm>
49 #include <string>
50 #include <vector>
51 #include <map>
52 #include <array>
53 #include <cmath>
54 #include <sstream>
55 
56 #include "gambit/Backends/backend_types/nulike.hpp"
58 #include "gambit/cmake/cmake_variables.hpp"
59 
60 #include <boost/enable_shared_from_this.hpp>
61 #include <boost/shared_ptr.hpp>
62 #include <gsl/gsl_integration.h>
63 
64 namespace Gambit
65 {
66  namespace DarkBit
67  {
68 
70  SimYieldChannel::SimYieldChannel(daFunk::Funk dNdE, std::string p1, std::string p2, std::string finalState, double Ecm_min, double Ecm_max)
71  : dNdE(dNdE)
72  , p1(p1)
73  , p2(p2)
74  , finalState(finalState)
75  , Ecm_min(Ecm_min)
76  , Ecm_max(Ecm_max)
77  {
78  std::ostringstream msg;
79  msg << "SimYieldChannel for " << p1 << " " << p2 <<
80  " final state(s): Requested center-of-mass energy out of range (";
81  msg << Ecm_min << "-" << Ecm_max << " GeV).";
82  auto error = daFunk::raiseInvalidPoint(msg.str());
83  auto Ecm = daFunk::var("Ecm");
84  this->dNdE = daFunk::ifelse(Ecm - Ecm_min, daFunk::ifelse(Ecm_max - Ecm, dNdE, error), error);
85  dNdE_bound = this->dNdE->bind("E", "Ecm");
86  }
87 
89  SimYieldTable::SimYieldTable() : dummy_channel(daFunk::zero("E", "Ecm"), "", "", "", 0.0, 0.0) {}
90 
91  void SimYieldTable::addChannel(daFunk::Funk dNdE, std::string p1, std::string p2, std::string finalState, double Ecm_min, double Ecm_max)
92  {
93  if ( hasChannel(p1, p2) )
94  {
95  DarkBit_warning().raise(LOCAL_INFO, "addChanel: Channel already exists --> ignoring new one.");
96  return;
97  }
98  channel_list.push_back(SimYieldChannel(dNdE, p1, p2, finalState, Ecm_min, Ecm_max));
99  }
100 
101  void SimYieldTable::addChannel(daFunk::Funk dNdE, std::string p1, std::string finalState, double Ecm_min, double Ecm_max)
102  {
103  addChannel(dNdE, p1, "", finalState, Ecm_min, Ecm_max);
104  }
105 
106  bool SimYieldTable::hasChannel(std::string p1, std::string p2, std::string finalState) const
107  {
108  return ( findChannel(p1, p2, finalState) != -1 );
109  }
110 
111  bool SimYieldTable::hasChannel(std::string p1, std::string finalState) const
112  {
113  return hasChannel(p1, "", finalState);
114  }
115 
116  bool SimYieldTable::hasAnyChannel(std::string p1) const
117  {
118  return hasAnyChannel(p1, "");
119  }
120 
121  bool SimYieldTable::hasAnyChannel(std::string p1, std::string p2) const
122  {
123  const std::vector<SimYieldChannel> &cl = channel_list;
124  for ( unsigned int i = 0; i < channel_list.size(); i++ )
125  {
126  if ((p1==cl[i].p1 and p2==cl[i].p2) or (p1==cl[i].p2 and p2==cl[i].p1) )
127  {
128  return true;
129  }
130  }
131  return false;
132  }
133 
134  const SimYieldChannel& SimYieldTable::getChannel(std::string p1, std::string p2, std::string finalState) const
135  {
136  int index = findChannel(p1, p2, finalState);
137  if ( index == -1 )
138  {
139  DarkBit_warning().raise(LOCAL_INFO, "getChannel: Channel unknown, returning dummy.");
140  return dummy_channel;
141  }
142  return channel_list[index];
143  }
144 
146  daFunk::Funk SimYieldTable::operator()(std::string p1, std::string p2, std::string finalState, double Ecm) const
147  {
148  return this->operator()(p1, p2, finalState)->set("Ecm", Ecm);
149  }
150 
152  daFunk::Funk SimYieldTable::operator()(std::string p1, std::string finalState, double Ecm) const
153  {
154  return this->operator()(p1,finalState)->set("Ecm", Ecm);
155  }
156 
158  daFunk::Funk SimYieldTable::operator()(std::string p1, std::string p2, std::string finalState) const
159  {
160  int index = findChannel(p1, p2, finalState);
161  if ( index == -1 )
162  {
163  DarkBit_warning().raise(LOCAL_INFO, "SimYieldTable(): Channel not known, returning zero spectrum.");
164  return daFunk::zero("E", "Ecm");
165  }
166  return channel_list[index].dNdE;
167  }
168 
169  daFunk::Funk SimYieldTable::operator()(std::string p1, std::string finalState) const
170  {
171  return this->operator()(p1, "", finalState);
172  }
173 
174  int SimYieldTable::findChannel(std::string p1, std::string p2, std::string finalState) const
175  {
176  const std::vector<SimYieldChannel> &cl = channel_list;
177  for ( unsigned int i = 0; i < channel_list.size(); i++ )
178  {
179  if ((p1==cl[i].p1 and p2==cl[i].p2 and finalState==cl[i].finalState) or (p1==cl[i].p2 and p2==cl[i].p1 and finalState==cl[i].finalState) )
180  {
181  return i;
182  }
183  }
184  return -1;
185  }
186 
187  }
188 }
#define LOCAL_INFO
Definition: local_info.hpp:34
Annihilation/decay channel.
SimYieldTable()
Sim yield table dummy constructor.
void addChannel(daFunk::Funk dNdE, std::string p1, std::string p2, std::string finalState, double Ecm_min, double Ecm_max)
Funk var(std::string arg)
Definition: daFunk.hpp:921
int findChannel(std::string p1, std::string p2, std::string finalState) const
bool hasChannel(std::string p1, std::string p2, std::string finalState) const
GAMBIT error class.
Definition: exceptions.hpp:136
SimYieldChannel(daFunk::Funk dNdE, std::string p1, std::string p2, std::string finalState, double Ecm_min, double Ecm_max)
General annihilation/decay channel for sim yield tables.
daFunk::Funk operator()(std::string p1, std::string p2, std::string finalState, double Ecm) const
Retrieve simyield table entries at given center of mass energy (GeV)
bool hasAnyChannel(std::string p1) const
warning & DarkBit_warning()
Funk zero(Args... argss)
Definition: daFunk.hpp:604
const SimYieldChannel & getChannel(std::string p1, std::string p2, std::string finalState) const
Funk ifelse(Funk f, Funk g, Funk h)
Definition: daFunk.hpp:1373
shared_ptr< FunkBase > Funk
Definition: daFunk.hpp:113
TODO: see if we can use this one:
Definition: Analysis.hpp:33
std::vector< SimYieldChannel > channel_list
Type definition header for module DarkBit.