23 #include "Tauola/Tauola.h" 24 #include "TauSpinner/SimpleParticle.h" 25 #include "TauSpinner/tau_reweight_lib.h" 38 desc.add<
std::string>(
"name")->setComment(
"name of the TauSpinner weights table");
39 desc.add<std::vector<double>>(
"theta")->setComment(
"values of CP-even and CP-odd tau Yukawa mixing angle");
41 ->setComment(
"boson pdgId, default: 25");
42 desc.add<
double>(
"defaultWeight", 1)
43 ->setComment(
"default weight stored in case of presence of a tau decay unsupported by TauSpinner");
53 return TauSpinner::SimpleParticle(
54 input_part.
px(), input_part.
py(), input_part.
pz(), input_part.
energy(), input_part.
pdgId());
57 static std::vector<std::pair<std::string, double>>
nameAndValue(
const std::vector<double> &val_vec) {
58 std::vector<std::pair<std::string, double>>
out;
59 for (
auto val : val_vec) {
61 name.erase(
name.find_last_not_of(
'0') + 1, std::string::npos);
62 name.erase(
name.find_last_not_of(
'.') + 1, std::string::npos);
64 if (
pos != std::string::npos)
67 if (
pos != std::string::npos)
82 thetaStr +=
theta.first +
",";
83 std::cout <<
"Theta: " << thetaStr << std::endl;
88 const std::vector<std::pair<std::string, double>>
theta_vec_;
105 theta_vec_(nameAndValue(
config.getParameter<
std::
vector<double>>(
"theta"))),
106 bosonPdgId_(
config.getParameter<
int>(
"bosonPdgId")),
108 "NNPDF31_nnlo_hessian_pdfas"),
115 default_weight_(
config.getParameter<double>(
123 produces<nanoaod::FlatTable>();
132 bosons.push_back(partRef);
139 if (
part->statusFlags().isLastCopy())
141 for (
const auto &daughter :
part->daughterRefVector()) {
142 if (daughter->pdgId() ==
part->pdgId() && daughter->statusFlags().fromHardProcess()) {
146 throw std::runtime_error(
"getLastCopy: no last copy found");
151 if (
std::abs(daughterRef->pdgId()) == 15)
157 static const std::set<int> directTauProducts = {11, 12, 13, 14, 16, 22};
158 static const std::set<int> finalHadrons = {111, 130, 211, 310, 311, 321};
159 static const std::set<int> intermediateHadrons = {221, 223, 323};
160 for (
auto daughterRef :
tau.daughterRefVector()) {
161 const int daughter_pdgId =
std::abs(daughterRef->pdgId());
162 if ((
std::abs(
tau.pdgId()) == 15 && directTauProducts.count(daughter_pdgId)) ||
163 finalHadrons.count(daughter_pdgId)) {
165 }
else if (intermediateHadrons.count(daughter_pdgId)) {
170 <<
"Unsupported decay with " << daughter_pdgId <<
" being daughter of " <<
std::abs(
tau.pdgId()) <<
"\n";
179 Tauolapp::Tauola::setNewCurrents(0);
190 auto wtTable = std::make_unique<nanoaod::FlatTable>(1,
name_,
true);
191 wtTable->setDoc(
"TauSpinner weights");
200 <<
"Current event has " << bosons.
size()
201 <<
" Higgs bosons while there must be exactly one; table with default weights is produced.\n";
204 wtTable->addColumnValue<
double>(
206 wtTable->addColumnValue<
double>(
207 "weight_cp_" +
theta.first +
"_alt",
209 "TauSpinner weight for theta_CP = " +
theta.first +
" (alternative hadronic currents)");
222 <<
"Current event has " <<
taus.size()
223 <<
" taus from boson decay while there must be exactly one pair; table with default weights is produced.\n";
226 wtTable->addColumnValue<
double>(
228 wtTable->addColumnValue<
double>(
229 "weight_cp_" +
theta.first +
"_alt",
231 "TauSpinner weight for theta_CP = " +
theta.first +
" (alternative hadronic currents)");
239 std::array<TauSpinner::SimpleParticle, 2> simple_taus;
240 std::array<std::vector<TauSpinner::SimpleParticle>, 2> simple_tau_daughters;
241 bool supportedDecays =
true;
242 for (
size_t tau_idx = 0; tau_idx < 2; ++tau_idx) {
246 for (
const auto &daughterRef : tau_daughters)
254 TauSpinner::setHiggsParametersTR(-
cos(2 *
M_PI *
theta.second),
259 Tauolapp::Tauola::setNewCurrents(
i);
262 ? TauSpinner::calculateWeightFromParticlesH(
263 simple_boson, simple_taus[0], simple_taus[1], simple_tau_daughters[0], simple_tau_daughters[1])
267 wtTable->addColumnValue<
double>(
268 "weight_cp_" +
theta.first,
weights[0],
"TauSpinner weight for theta_CP=" +
theta.first);
270 wtTable->addColumnValue<
double>(
271 "weight_cp_" +
theta.first +
"_alt",
273 "TauSpinner weight for theta_CP=" +
theta.first +
" (alternative hadronic currents)");
TauSpinner::SimpleParticle convertToSimplePart(const reco::GenParticle &input_part) const
static AlgebraicMatrix initialize()
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void printModuleInfo(edm::ParameterSet const &config) const
double pz() const final
z coordinate of momentum vector
static void getTaus(reco::GenParticleRefVector &taus, const reco::GenParticle &boson)
Sin< T >::type sin(const T &t)
static const std::string kTauola
const daughters & daughterRefVector() const
references to daughtes
static std::vector< std::pair< std::string, double > > nameAndValue(const std::vector< double > &val_vec)
static std::string to_string(const XMLCh *ch)
int pdgId() const final
PDG identifier.
double px() const final
x coordinate of momentum vector
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
static bool getTauDaughters(reco::GenParticleRefVector &tau_daughters, const reco::GenParticle &tau)
const double default_weight_
TauSpinnerTableProducer(const edm::ParameterSet &)
double py() const final
y coordinate of momentum vector
const std::string tauSpinnerPDF_
const edm::EDGetTokenT< edm::View< reco::GenParticle > > genPartsToken_
void getBosons(edm::RefVector< edm::View< reco::GenParticle >> &bosons, const edm::View< reco::GenParticle > &parts) const
size_type size() const
Size of the RefVector.
const std::vector< std::pair< std::string, double > > theta_vec_
std::atomic< unsigned int > nWarnings
static reco::GenParticleRef getLastCopy(const reco::GenParticleRef &part)
static const unsigned int nMaxWarnings
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Log< level::Warning, false > LogWarning
void produce(edm::Event &, const edm::EventSetup &) final
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double energy() const final
energy