ATLAS Offline Software
Loading...
Searching...
No Matches
UserHooksUtils.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef PYTHIA8_USERHOOKS_USERHOOKSUTILS_H
6#define PYTHIA8_USERHOOKS_USERHOOKSUTILS_H
7#include "Pythia8/Event.h"
8#include <stdexcept>
9
13
14namespace Pythia8_UserHooks{
15
19 inline double pTProj(const Pythia8::Particle &leg, const Pythia8::Particle &comparison){
20 return leg.px()*comparison.px() + leg.py()*comparison.py() + leg.pz()*comparison.pz();
21 }
22
27 inline double pTProj(size_t legIndex, size_t comparedIndex, const Pythia8::Event &evt){
28 return pTProj(evt[legIndex], evt[comparedIndex]);
29 }
30
34 inline double pT2Leg(const Pythia8::Particle &leg, const Pythia8::Particle &comparison){
35 double proj = pTProj(leg, comparison);
36 return leg.pAbs2() - (proj*proj) / comparison.pAbs2();
37 }
38
43 inline double pT2Leg(size_t legIndex, size_t comparedIndex, const Pythia8::Event &evt){
44 return pT2Leg(evt[legIndex], evt[comparedIndex]);
45 }
46
50 inline double pTLeg(const Pythia8::Particle &leg, const Pythia8::Particle &comparison){
51 return std::sqrt(pT2Leg(leg, comparison));
52 }
53
58 inline double pTLeg(size_t legIndex, size_t comparedIndex, const Pythia8::Event &evt){
59 return std::sqrt(pT2Leg(legIndex, comparedIndex, evt));
60 }
61
65 inline size_t findLastEmission(const Pythia8::Event &evt, int status){
66 size_t emission = evt.size() - 1;
67
68 while(emission != 0){
69 if (evt[emission].isFinal() && evt[emission].status() == status) return emission;
70
71 --emission;
72 }
73
74 return 0;
75 }
76
80 inline size_t findLastISREmission(const Pythia8::Event &evt){
81 size_t emission = findLastEmission(evt, 43);
82 if(emission == 0) throw std::runtime_error("findLastISREmission:: Could not find ISR emission");
83 return emission;
84 }
85
89 inline size_t findLastFSREmission(const Pythia8::Event &evt){
90 size_t emission = findLastEmission(evt, 51);
91 if(emission == 0) throw std::runtime_error("findLastFSREmission:: Could not find FSR emission");
92 return emission;
93 }
94
98
99 inline size_t findLastISRRadiator(const Pythia8::Event &evt){
100 size_t radiator = findLastEmission(evt, -41);
101 if(radiator == 0) throw std::runtime_error("findLastISRRadiator:: Could not find ISR radiator");
102 return radiator;
103 }
104
108
109 inline size_t findLastFSRRadiator(const Pythia8::Event &evt){
110 size_t emitted = findLastFSREmission(evt);
111 return evt[emitted].mother1();
112 }
113
114}
115
116#endif
Some common functions for determining pTs and navigating event records for the PoWHEG + Pythia user h...
size_t findLastISRRadiator(const Pythia8::Event &evt)
size_t findLastFSRRadiator(const Pythia8::Event &evt)
size_t findLastISREmission(const Pythia8::Event &evt)
size_t findLastEmission(const Pythia8::Event &evt, int status)
Return the index of the most recent emission in a.
double pTProj(const Pythia8::Particle &leg, const Pythia8::Particle &comparison)
double pT2Leg(const Pythia8::Particle &leg, const Pythia8::Particle &comparison)
size_t findLastFSREmission(const Pythia8::Event &evt)
double pTLeg(const Pythia8::Particle &leg, const Pythia8::Particle &comparison)