Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RateBase.cc
Go to the documentation of this file.
1 ///
2 /// @file RateBase.cc
3 /// @brief Hammer base rate class
4 ///
5 
6 //**** This file is a part of the HAMMER library
7 //**** Copyright (C) 2016 - 2020 The HAMMER Collaboration
8 //**** HAMMER is licensed under version 3 of the GPL; see COPYING for details
9 //**** Please note the MCnet academic guidelines; see GUIDELINES for details
10 
11 // -*- C++ -*-
12 #include "Hammer/RateBase.hh"
15 #include <string>
16 
17 using namespace std;
18 
19 namespace Hammer {
20 
21  RateBase::RateBase() : _integ{}, _PSRanges{}, _nPoints{
22  _integ.getPointsNumber()}, _tensorList{} {
23  }
24 
25  // RateBase::RateBase(const RateBase& other)
26  // : ParticleData(other),
27  // SettingsConsumer(other),
28  // _integ(other._integ),
29  // _PSRanges(other._PSRanges),
30  // _nPoints(other._nPoints) {
31  // for (auto& elem : other._tensorList) {
32  // addTensor(Tensor{elem});
33  // }
34  // }
35 
36  // RateBase& RateBase::operator=(const RateBase& other) {
37  // ParticleData::operator=(other);
38  // SettingsConsumer::operator=(other);
39  // _integ = other._integ;
40  // _PSRanges = other._PSRanges;
41  // _nPoints = other._nPoints;
42  // _tensorList.clear();
43  // for (auto& elem : other._tensorList) {
44  // addTensor(Tensor{elem});
45  // }
46  // return *this;
47  // }
48 
49 
50  // RateBase::~RateBase() {
51  // _PSRanges.clear();
52  // _tensorList.clear();
53  // }
54 
55  void RateBase::init() {
56  // initSettings();
57  ///@todo anything else?
58  }
59 
62  }
63 
64  const string RateBase::getPdgIdString() {
65  auto sig = _signatures[_signatureIndex];
66  string ds;
67  for(auto& daughter : sig.daughters){
68  ds = ds + " " + to_string(daughter);
69  }
70  return to_string(sig.parent) + " ->" + ds;
71  }
72 
73  const Tensor& RateBase::getTensor() const {
75  }
76 
78  return _PSRanges[_signatureIndex];
79  }
80 
82  // _PSRanges.push_back({std::pow(qMin, 2.), std::pow(qMax, 2.)});
83  _PSRanges.push_back(boundaries);
84  }
85 
86  void RateBase::eval(const Particle&, const ParticleList&, const ParticleList&) {
87  }
88 
90  }
91 
93  return _integ.getEvaluationPoints();
94  }
95 
97  auto& boundaries = getIntegrationBoundaries();
98  _integ.applyRange(boundaries);
99  const EvaluationGrid& points = _integ.getEvaluationPoints();
100  const EvaluationWeights& weights = _integ.getEvaluationWeights();
101  Tensor& t = getTensor();
102  MSG_INFO("Integrating rate " + getPdgIdString());
103  t.clearData();
104  for (IndexType i = 0; i < points.size(); ++i) {
105  t.addAt(evalAtPSPoint(points[i])*weights[i], INTEGRATION_INDEX, i);
106  }
107  }
108 
109  void RateBase::addTensor(Tensor&& tensor) {
110  _tensorList.push_back(move(tensor));
111  }
112 
114  return Log::getLog("Hammer.RateBase");
115  }
116 
117 } // namespace Hammer
virtual Tensor evalAtPSPoint(const std::vector< double > &point)=0
evaluates the rate at a specific point in as a rank N Tensor
const EvaluationWeights & getEvaluationWeights() const
Definition: Integrator.cc:111
Tensor & addAt(const Tensor &t, IndexLabel coord, IndexType position)
add a tensor of rank N-1 to a specific position in a specific coordinate the dimension of the tensor ...
Definition: Tensor.cc:259
Hammer base rate class.
const EvaluationGrid & getEvaluationPoints() const
returns the position of the evaluation points given an integration range
Definition: Integrator.cc:107
uint16_t IndexType
virtual void eval(const Particle &parent, const ParticleList &daughters, const ParticleList &references)
method to evaluate the object on a specific particle set.
Definition: RateBase.cc:86
void addIntegrationBoundaries(const IntegrationBoundaries &boundaries)
adds the integration limits for a specific signature to the range list.
Definition: RateBase.cc:81
std::vector< BoundaryFunction > IntegrationBoundaries
Definition: Integrator.fhh:25
void calcTensor()
evaluates the rate by computing the (rank N) rate tensor at different points using evalAtPSPoint on ...
Definition: RateBase.cc:96
void init()
initializes the rate (defines settings associated to this rate, computes the rate tensor) ...
Definition: RateBase.cc:55
static Log & getLog(const std::string &name)
Get a logger with the given name.
Definition: Logging.cc:139
void addTensor(Tensor &&tensor)
adds the index labels for the amplitude tensor for a specific signature to the index labels signature...
Definition: RateBase.cc:109
Interface class for tensor container data structure.
std::vector< Particle > ParticleList
Definition: Particle.fhh:20
std::vector< IntegrationBoundaries > _PSRanges
list of integration limits (one for each signature)
Definition: RateBase.hh:115
Logging class.
Definition: Logging.hh:33
Particle class.
Definition: Particle.hh:30
Multidimensional tensor class with complex numbers as elements.
Definition: Tensor.hh:33
Tensor & getTensor()
returns a reference to itself as a Tensor
Definition: RateBase.cc:60
void clearData()
sets all the elements to 0
Definition: Tensor.cc:229
std::vector< Signature > _signatures
the list of signatures
Hammer numerical integration classes.
const IntegrationBoundaries & getIntegrationBoundaries() const
return the physical range of for this process (to be used set the integration limits) ...
Definition: RateBase.cc:77
virtual void defineSettings()
defines new settings for this class
Definition: RateBase.cc:89
size_t _signatureIndex
the index of the current signature
Integrator _integ
Definition: RateBase.hh:114
const std::string getPdgIdString()
returns string of pdg ids in the process
Definition: RateBase.cc:64
void applyRange(const IntegrationBoundaries &boundaries)
apply rescaling factor for the size of the interval from the canonical [-1,1] interval to the actual ...
Definition: Integrator.cc:120
const EvaluationGrid & getEvaluationPoints() const
Definition: RateBase.cc:92
std::vector< double > EvaluationWeights
Definition: Integrator.fhh:27
#define MSG_INFO(x)
Definition: Logging.hh:365
std::vector< std::vector< double >> EvaluationGrid
Definition: Integrator.fhh:26
Log & getLog() const
logging facility
Definition: RateBase.cc:113
std::vector< Tensor > _tensorList
list of (list of) labels for the tensor indices (one for each signature)
Definition: RateBase.hh:117