BreitWignerGenerator.cc
1 /*
2  * MoMEMta: a modular implementation of the Matrix Element Method
3  * Copyright (C) 2016 Universite catholique de Louvain (UCL), Belgium
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 
20 #include <momemta/ParameterSet.h>
21 #include <momemta/Module.h>
22 
23 #include <cmath>
24 
72  public:
73 
74  BreitWignerGenerator(PoolPtr pool, const ParameterSet& parameters): Module(pool, parameters.getModuleName()),
75  mass(parameters.get<double>("mass")),
76  width(parameters.get<double>("width")) {
77 
78  m_ps_point = get<double>(parameters.get<InputTag>("ps_point"));
79  };
80 
81  virtual Status work() override {
82 
83  double psPoint = *m_ps_point;
84  const double range = M_PI / 2. + std::atan(mass / width);
85  const double y = - std::atan(mass / width) + range * psPoint;
86 
87  *s = mass * width * std::tan(y) + (mass * mass);
88  *jacobian = range * mass * width / (std::cos(y) * std::cos(y));
89 
90  return Status::OK;
91  }
92 
93  private:
94  const double mass;
95  const double width;
96 
97  // Inputs
98  Value<double> m_ps_point;
99 
100  // Outputs
101  std::shared_ptr<double> s = produce<double>("s");
102  std::shared_ptr<double> jacobian = produce<double>("jacobian");
103 
104 
105 };
106 
107 REGISTER_MODULE(BreitWignerGenerator)
108  .Input("ps_point")
109  .Output("s")
110  .Output("jacobian")
111  .Attr("mass:double")
112  .Attr("width:double");
virtual Status work() override
Main function.
An identifier of a module&#39;s output.
Definition: InputTag_fwd.h:37
Parent class for all the modules.
Definition: Module.h:37
Generate points distributed according to a Breit-Wigner.
A class encapsulating a lua table.
Definition: ParameterSet.h:82
Module(PoolPtr pool, const std::string &name)
Constructor.
Definition: Module.h:61