Loading [MathJax]/extensions/tex2jax.js

Search Results

 /*
  *  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/ParameterSet.h>
 #include <momemta/Module.h>
 #include <momemta/Types.h>
 
 #include <algorithm>
 #include <cmath>
 #include <numeric>
 
 #include <TMath.h>
 
 class Permutator: public Module {
     public:
 
         Permutator(PoolPtr pool, const ParameterSet& parameters): Module(pool, parameters.getModuleName()) {
 
             m_ps_point = get<double>(parameters.get<InputTag>("ps_point"));
 
             auto particle_tags = parameters.get<std::vector<InputTag>>("inputs");
             for (auto& t: particle_tags)
                 m_inputs.push_back(get<LorentzVector>(t));
 
             std::vector<uint32_t> tmp(m_inputs.size());
             std::iota(tmp.begin(), tmp.end(), 0);
 
             do {
                 perm_indices.push_back(tmp);
             } while (std::next_permutation(tmp.begin(), tmp.end()));
 
             (*m_output).resize(m_inputs.size());
         };
 
         virtual Status work() override {
             double psPoint = *m_ps_point;
 
             size_t chosen_perm = std::lround(psPoint * (perm_indices.size() - 1));
 
             for (size_t i = 0; i < m_inputs.size(); i++)
                 (*m_output)[i] = *m_inputs[perm_indices[chosen_perm][i]];
 
             return Status::OK;
         }
 
     private:
         std::vector<std::vector<uint32_t>> perm_indices;
 
         // Inputs
         Value<double> m_ps_point;
         std::vector<Value<LorentzVector>> m_inputs;
 
         // Outputs
         std::shared_ptr<std::vector<LorentzVector>> m_output = produce<std::vector<LorentzVector>>("output");
 };
 
 REGISTER_MODULE(Permutator)
     .Input("ps_point")
     .Inputs("inputs")
     .Output("output");
 
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages