ATLAS Offline Software
WZPolarization.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
5 #include "UserHooksUtils.h"
6 #include "UserSetting.h"
7 #include "Pythia8/PhaseSpace.h"
8 
9 namespace Pythia8 {
10 
11 
13  //
14  // Polarisation state set via Main:spareMode1 = 0,1,2,3,4
15  // for isotropic, longitudinal, transverse, and trans+, trans-.
16  struct WZPolarization : public UserHooks {
17 
18  WZPolarization() : m_polmode("WZPolarization:mode", 1) { }
19 
20  bool canVetoResonanceDecays() { return true; }
21 
23  const int polmode = m_polmode(settingsPtr);
24 
25  for (int i = 1; i < process.size(); ++i) {
26  // Select vector bosons
27  Particle& v = process[i];
28  if (v.id() != 23 && v.idAbs() != 24) continue;
29  const Vec4 pv = v.p();
30 
31  // Find W/Z daughter particles
32  Particle& d1 = process[v.daughter1()];
33  Particle& d2 = process[v.daughter2()];
34 
35  // Get daughter momenta in the boson rest frame
36  Vec4 pd1 = d1.p();
37  Vec4 pd2 = d2.p();
38  pd1.bstback(pv);
39  pd2.bstback(pv);
40 
41  // Randomly reorient and rejection-sample decay configuration
42  // (done inline here, rather than reboosting to the W/Z frame on each decay-hook iteration)
43  while (true) {
44 
45  // Random reorientation
46  const double dtheta = std::acos(2*rand01() - 1);
47  const double dphi = 2*M_PI*rand01();
48  pd1.rot(dtheta, dphi);
49  pd2.rot(dtheta, dphi);
50 
51  // Angle w.r.t. W/Z flight direction, in rest-frame
52  const double th = theta(pv, pd1);
53 
54  // Accept/reject the angle according to the polarisation being modelled
55  if (polmode == 0) { // Isotropic
56  break; // it's already been isotropically randomised
57  } else if (polmode == 1) { // Longitudinal
58  if (rand01() < sqr(std::sin(th))) break;
59  } else if (polmode == 2) { // Trans-sum
60  if (rand01() < (1 + sqr(std::cos(th)))/2) break;
61  } else if (polmode == 3) { // Trans+
62  if (rand01() < sqr(1 + std::cos(th))/4) break;
63  } else if (polmode == 4) { // Trans-
64  if (rand01() < sqr(1 - std::cos(th))/4) break;
65  }
66  }
67 
68  // Boost the vectors back to the lab frame
69  pd1.bst(pv); d1.p(pd1);
70  pd2.bst(pv); d2.p(pd2);
71 
72  }
73 
74  return false;
75  }
76 
77  double sqr(double x) { return x*x; }
78 
79  double rand01() { return rndmPtr->flat(); }
80 
82 
83  };
84 
85 
87 
88 }
Pythia8::WZPolarization::WZPolarization
WZPolarization()
Definition: WZPolarization.cxx:18
Pythia8::WZPolarization::canVetoResonanceDecays
bool canVetoResonanceDecays()
Definition: WZPolarization.cxx:20
Pythia8::WZPolarization::sqr
double sqr(double x)
Definition: WZPolarization.cxx:77
Event
Definition: trigbs_orderedMerge.cxx:42
Pythia8::WZPolarization::doVetoResonanceDecays
bool doVetoResonanceDecays(Event &process)
Definition: WZPolarization.cxx:22
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:71
M_PI
#define M_PI
Definition: ActiveFraction.h:11
dq_defect_virtual_defect_validation.d1
d1
Definition: dq_defect_virtual_defect_validation.py:79
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Pythia8::WZPolarization
Convert all resonant W/Z boson decays to the angular distribution of a pure polarisation state.
Definition: WZPolarization.cxx:16
Pythia8_UserHooks::UserHooksFactory::Creator
Definition: UserHooksFactory.h:54
x
#define x
SUSY_SimplifiedModel_PostInclude.process
string process
Definition: SUSY_SimplifiedModel_PostInclude.py:42
xAOD::Particle
Particle_v1 Particle
Define the latest version of the particle class.
Definition: Event/xAOD/xAODParticleEvent/xAODParticleEvent/Particle.h:17
UserHooksFactory.h
Pythia8
Author: James Monk (jmonk@cern.ch)
Definition: IPythia8Custom.h:13
Pythia8_UserHooks::UserSetting< int >
python.TriggerHandler.th
th
Definition: TriggerHandler.py:296
lumiFormat.i
int i
Definition: lumiFormat.py:92
UserSetting.h
Pythia8::WZPOL
Pythia8_UserHooks::UserHooksFactory::Creator< Pythia8::WZPolarization > WZPOL("WZPolarization")
Pythia8::WZPolarization::rand01
double rand01()
Definition: WZPolarization.cxx:79
python.PyAthena.v
v
Definition: PyAthena.py:157
UserHooksUtils.h
dq_defect_virtual_defect_validation.d2
d2
Definition: dq_defect_virtual_defect_validation.py:81
python.changerun.pv
pv
Definition: changerun.py:81
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Pythia8::WZPolarization::m_polmode
Pythia8_UserHooks::UserSetting< int > m_polmode
Definition: WZPolarization.cxx:81