Search Results
GaussianTransferFunctionOnEnergy.cc
/*
* MoMEMta: a modular implementation of the Matrix Element Method
* Copyright (C) 2016 Universite catholique de Louvain (UCL), Belgium
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <momemta/Logging.h>
#include <momemta/Module.h>
#include <momemta/ParameterSet.h>
#include <momemta/Types.h>
#include <momemta/Math.h>
#include <Math/DistFunc.h>
class GaussianTransferFunctionOnEnergyBase: public Module {
public:
GaussianTransferFunctionOnEnergyBase(PoolPtr pool, const ParameterSet& parameters): Module(pool, parameters.getModuleName()) {
m_reco_input = get<LorentzVector>(parameters.get<InputTag>("reco_particle"));
m_sigma = parameters.get<double>("sigma", 0.10);
m_sigma_range = parameters.get<double>("sigma_range", 5);
m_min_E = parameters.get<double>("min_E", 0.);
}
protected:
double m_min_E;
double m_sigma;
double m_sigma_range;
// Input
Value<LorentzVector> m_reco_input;
};
class GaussianTransferFunctionOnEnergy: public GaussianTransferFunctionOnEnergyBase {
public:
GaussianTransferFunctionOnEnergy(PoolPtr pool, const ParameterSet& parameters): GaussianTransferFunctionOnEnergyBase(pool, parameters) {
m_ps_point = get<double>(parameters.get<InputTag>("ps_point"));
}
virtual Status work() override {
// Estimate the width over which to integrate using the width of the TF at E_rec ...
const double sigma_E_rec = m_reco_input->E() * m_sigma;
double range_min = std::max( { m_min_E, m_reco_input->M(), m_reco_input->E() - (m_sigma_range * sigma_E_rec) } );
double range_max = m_reco_input->E() + (m_sigma_range * sigma_E_rec);
double range = (range_max - range_min);
double gen_E = range_min + range * (*m_ps_point);
double gen_pt = std::sqrt(SQ(gen_E) - SQ(m_reco_input->M())) / std::cosh(m_reco_input->Eta());
output->SetCoordinates(
gen_pt * std::cos(m_reco_input->Phi()),
gen_pt * std::sin(m_reco_input->Phi()),
gen_pt * std::sinh(m_reco_input->Eta()),
gen_E);
// ... but compute the width of the TF at E_gen!
const double sigma_E_gen = gen_E * m_sigma;
// Compute TF*jacobian, where the jacobian includes the transformation of [0,1]->[range_min,range_max] and d|P|/dE
*TF_times_jacobian = ROOT::Math::normal_pdf(gen_E, sigma_E_gen, m_reco_input->E()) * range * dP_over_dE(*output);
return Status::OK;
}
private:
// Input
Value<double> m_ps_point;
// Outputs
std::shared_ptr<LorentzVector> output = produce<LorentzVector>("output");
std::shared_ptr<double> TF_times_jacobian = produce<double>("TF_times_jacobian");
};
class GaussianTransferFunctionOnEnergyEvaluator: public GaussianTransferFunctionOnEnergyBase {
public:
GaussianTransferFunctionOnEnergyEvaluator(PoolPtr pool, const ParameterSet& parameters): GaussianTransferFunctionOnEnergyBase(pool, parameters) {
m_gen_input = get<LorentzVector>(parameters.get<InputTag>("gen_particle"));
}
virtual Status work() override {
// Compute TF value
*TF_value = ROOT::Math::normal_pdf(m_gen_input->E(), m_gen_input->E() * m_sigma, m_reco_input->E());
return Status::OK;
}
private:
// Input
Value<LorentzVector> m_gen_input;
// Outputs
std::shared_ptr<double> TF_value = produce<double>("TF");
};
REGISTER_MODULE(GaussianTransferFunctionOnEnergy)
.Input("ps_point")
.Input("reco_particle")
.Output("output")
.Output("TF_times_jacobian")
.Attr("sigma:double=0.10")
.Attr("sigma_range:double=5")
.Attr("min_E:double=0");
REGISTER_MODULE(GaussianTransferFunctionOnEnergyEvaluator)
.Input("gen_particle")
.Input("reco_particle")
.Output("TF")
.Attr("sigma:double=0.10")
.Attr("sigma_range:double=5")
.Attr("min_E:double=0");