ATLAS Offline Software
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 
14 namespace 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 
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 
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
JiveXML::Event
struct Event_t Event
Definition: ONCRPCServer.h:65
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
Pythia8_UserHooks::pT2Leg
double pT2Leg(const Pythia8::Particle &leg, const Pythia8::Particle &comparison)
Definition: UserHooksUtils.h:34
xAOD::Particle
Particle_v1 Particle
Define the latest version of the particle class.
Definition: Event/xAOD/xAODParticleEvent/xAODParticleEvent/Particle.h:17
Pythia8_UserHooks
Some common functions for determining pTs and navigating event records for the PoWHEG + Pythia user h...
Definition: UserHooksFactory.h:30
Pythia8_UserHooks::findLastFSRRadiator
size_t findLastFSRRadiator(const Pythia8::Event &evt)
Definition: UserHooksUtils.h:109
Pythia8_UserHooks::pTProj
double pTProj(const Pythia8::Particle &leg, const Pythia8::Particle &comparison)
Definition: UserHooksUtils.h:19
compute_lumi.leg
leg
Definition: compute_lumi.py:95
Pythia8_UserHooks::findLastEmission
size_t findLastEmission(const Pythia8::Event &evt, int status)
Return the index of the most recent emission in a.
Definition: UserHooksUtils.h:65
make_coralServer_rep.proj
proj
Definition: make_coralServer_rep.py:48
Pythia8_UserHooks::pTLeg
double pTLeg(const Pythia8::Particle &leg, const Pythia8::Particle &comparison)
Definition: UserHooksUtils.h:50
Pythia8_UserHooks::findLastISREmission
size_t findLastISREmission(const Pythia8::Event &evt)
Definition: UserHooksUtils.h:80
merge.status
status
Definition: merge.py:17
Pythia8_UserHooks::findLastISRRadiator
size_t findLastISRRadiator(const Pythia8::Event &evt)
Definition: UserHooksUtils.h:99
Pythia8_UserHooks::findLastFSREmission
size_t findLastFSREmission(const Pythia8::Event &evt)
Definition: UserHooksUtils.h:89