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