Belle II Software  release-05-02-19
BHWideInputModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2011 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Andreas Moll, Torben Ferber *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <generators/modules/bhwideinput/BHWideInputModule.h>
12 
13 #include <framework/datastore/StoreArray.h>
14 
15 using namespace std;
16 using namespace Belle2;
17 
18 //-----------------------------------------------------------------
19 // Register the Module
20 //-----------------------------------------------------------------
21 REG_MODULE(BHWideInput)
22 
23 //-----------------------------------------------------------------
24 // Implementation
25 //-----------------------------------------------------------------
26 
27 BHWideInputModule::BHWideInputModule() : Module(), m_initial(BeamParameters::c_smearVertex)
28 {
29  //Set module properties
30  setDescription("Generates radiative BhaBha scattering events with BHWide.");
31 
32  //Parameter definition
33  addParam("ScatteringAngleRangePositron", m_ScatteringAngleRangePositron,
34  "Min [0] and Max [1] value for the scattering angle [deg] of the positron.", make_vector(15.0, 165.0));
35  addParam("ScatteringAngleRangeElectron", m_ScatteringAngleRangeElectron,
36  "Min [0] and Max [1] value for the scattering angle [deg] of the electron.", make_vector(15.0, 165.0));
37  addParam("MaxAcollinearity", m_maxAcollinearity, "Maximum acollinearity angle between finale state leptons/photons [degree]",
38  180.0);
39  addParam("MinEnergy", m_eMin, "Minimum energy for electrons in the final state [GeV] (default: 0.2 GeV)", 0.2);
40  addParam("VacuumPolarization", m_vacPolString,
41  "Vacuum polarization: off (off - EW off, too), Burkhardt89 (bhlumi), Eidelman/Jegerlehner95 (eidelman) or Burkhardt/Pietrzyk95 (burkhardt)",
42  std::string("burkhardt"));
43  addParam("WtMax", m_wtMax, "Maximum of weight (wtmax, default: 3.0), if <0: internal maximum search", 3.);
44  addParam("WeakCorrections", m_weakCorrections, "EW correction ON/OFF", true);
45 
46  //initialize member variables
47  m_vacPol = BHWide::PhotonVacPolarization::PP_BURKHARDT;
48 
49 }
50 
51 
52 BHWideInputModule::~BHWideInputModule()
53 {
54 
55 }
56 
57 
58 void BHWideInputModule::initialize()
59 {
60  StoreArray<MCParticle> mcparticle;
61  mcparticle.registerInDataStore();
62 
63  //Beam Parameters, initial particle - BHWIDE cannot handle beam energy spread
64  m_initial.initialize();
65 
66 }
67 
68 
69 void BHWideInputModule::event()
70 {
71  // Check if the BeamParameters have changed (if they do, abort the job! otherwise cross section calculation will be a nightmare.)
72  if (m_beamParams.hasChanged()) {
73  if (!m_initialized) {
74  initializeGenerator();
75  } else {
76  B2FATAL("BHWideInputModule::event(): BeamParameters have changed within a job, this is not supported for BHWide!");
77  }
78  }
79 
80  // initial particle from beam parameters
81  const MCInitialParticles& initial = m_initial.generate();
82 
83  // true boost
84  TLorentzRotation boost = initial.getCMSToLab();
85 
86  // vertex
87  TVector3 vertex = initial.getVertex();
88 
89  m_mcGraph.clear();
90  m_generator.generateEvent(m_mcGraph, vertex, boost);
91  m_mcGraph.generateList("", MCParticleGraph::c_setDecayInfo | MCParticleGraph::c_checkCyclic);
92 }
93 
94 
95 
96 void BHWideInputModule::terminate()
97 {
98  m_generator.term();
99 
100  B2RESULT("BHWideInputModule: Total cross section: " << m_generator.getCrossSection() * 0.001 << " nb +- " <<
101  m_generator.getCrossSection() *
102  m_generator.getCrossSectionError() * 0.001 << " nb");
103 }
104 
105 void BHWideInputModule::initializeGenerator()
106 {
107  const BeamParameters& nominal = m_initial.getBeamParameters();
108  double ecm = nominal.getMass();
109 
110  m_generator.setScatAnglePositron(vectorToPair(m_ScatteringAngleRangePositron, "ScatteringAngleRangePositron"));
111  m_generator.setScatAngleElectron(vectorToPair(m_ScatteringAngleRangeElectron, "ScatteringAngleRangeElectron"));
112 
113  m_generator.setMinEnergyFinalStatePos(m_eMin);
114  m_generator.setMinEnergyFinalStateElc(m_eMin);
115  m_generator.setMaxAcollinearity(m_maxAcollinearity);
116  m_generator.setMaxRejectionWeight(m_wtMax);
117 
118  if (m_weakCorrections == 0) {
119  m_generator.enableWeakCorrections(0);
120  } else {
121  m_generator.enableWeakCorrections(1);
122  }
123 
124  //vacuum polarization (BHWide::PhotonVacPolarization)
125  if (m_vacPolString == "off") {
126  m_vacPol = BHWide::PhotonVacPolarization::PP_OFF;
127  //need to switch off weak correction, otherwise BHWide will abort
128  if (m_weakCorrections == 1) {
129  B2INFO("BHWideInputModule: Switching OFF EW corrections");
130  }
131  m_generator.enableWeakCorrections(0);
132  } else if (m_vacPolString == "bhlumi") m_vacPol = BHWide::PhotonVacPolarization::PP_BHLUMI;
133  else if (m_vacPolString == "burkhardt") m_vacPol = BHWide::PhotonVacPolarization::PP_BURKHARDT;
134  else if (m_vacPolString == "eidelman") m_vacPol = BHWide::PhotonVacPolarization::PP_EIDELMAN;
135  else B2FATAL("BHWideInputModule: Vacuum Polarization option does not exist: " << m_vacPolString);
136  m_generator.setPhotonVacPolarization(m_vacPol);
137 
138  m_generator.setCMSEnergy(ecm);
139 
140  m_generator.init();
141 
142  m_initialized = true;
143 
144 }
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::MCInitialParticles
This class contains the initial state for the given event.
Definition: MCInitialParticles.h:35
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MCInitialParticles::getVertex
const TVector3 & getVertex() const
Get the position of the collision.
Definition: MCInitialParticles.h:143
Belle2::BHWideInputModule
The BHWide Generator module.
Definition: BHWideInputModule.h:43
Belle2::MCInitialParticles::getCMSToLab
const TLorentzRotation & getCMSToLab() const
Return the LorentzRotation to convert from CMS to lab frame.
Definition: MCInitialParticles.h:161
Belle2::StoreArray< MCParticle >
Belle2::BeamParameters
This class contains the nominal beam parameters and the parameters used for smearing of the primary v...
Definition: BeamParameters.h:33