FlatTransferFunctionOnTheta.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 #include <momemta/ParameterSet.h>
20 #include <momemta/Module.h>
21 #include <momemta/Types.h>
22 #include <momemta/Utils.h>
23 
57  public:
58 
59  FlatTransferFunctionOnTheta(PoolPtr pool, const ParameterSet& parameters): Module(pool, parameters.getModuleName()) {
60  m_ps_point = get<double>(parameters.get<InputTag>("ps_point"));
61  m_input = get<LorentzVector>(parameters.get<InputTag>("reco_particle"));
62  };
63 
64  virtual Status work() override {
65 
66  const double& ps_point = *m_ps_point;
67  const LorentzVector& reco_particle = *m_input;
68 
69  const double new_theta = M_PI*ps_point;
70 
71  // Set the output vector's theta angle using the generated value, keeping the input's |P|, phi and E
72  output->SetCoordinates(
73  reco_particle.P() * std::sin(new_theta) * std::cos(reco_particle.Phi()),
74  reco_particle.P() * std::sin(new_theta) * std::sin(reco_particle.Phi()),
75  reco_particle.P() * std::cos(new_theta),
76  reco_particle.E());
77 
78  // Compute TF*jacobian, ie the jacobian of the transformation of [0,1]->[0,pi]
79  *TF_times_jacobian = M_PI;
80 
81  return Status::OK;
82  }
83 
84  private:
85 
86  // Inputs
87  Value<double> m_ps_point;
88  Value<LorentzVector> m_input;
89 
90  // Outputs
91  std::shared_ptr<LorentzVector> output = produce<LorentzVector>("output");
92  std::shared_ptr<double> TF_times_jacobian = produce<double>("TF_times_jacobian");
93 };
94 
95 REGISTER_MODULE(FlatTransferFunctionOnTheta)
96  .Input("ps_point")
97  .Input("reco_particle")
98  .Output("output")
99  .Output("TF_times_jacobian");
An identifier of a module&#39;s output.
Definition: InputTag_fwd.h:37
Parent class for all the modules.
Definition: Module.h:37
A class encapsulating a lua table.
Definition: ParameterSet.h:82
Module(PoolPtr pool, const std::string &name)
Constructor.
Definition: Module.h:61
Flat transfer function on Theta (mainly for testing purposes).
virtual Status work() override
Main function.