Belle II Software development
BeamParametersModule.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/BeamParametersModule.h>
10#include <framework/database/Database.h>
11
12#include <Math/Vector3D.h>
13
14using namespace Belle2;
15
16//-----------------------------------------------------------------
17// Register the Module
18//-----------------------------------------------------------------
20
21//-----------------------------------------------------------------
22// Implementation
23//-----------------------------------------------------------------
24
26{
27 // Set module properties
28 setDescription("Setting of beam parameters. This module allows to set the "
29 "beamparameters to be used by generators and analyis. One can "
30 "either select from a list of predefined parameter sets or "
31 "manually set the parameters to use.");
32
33 // Parameter definitions
34 addParam("energyHER", m_energyHER, "Energy of the High Energy Ring", 7.0);
35 addParam("angleXHER", m_angleXHER, "angle of the High Energy Ring in the x-z plane. "
36 "Negative values are interpreted as pi - value", 0.0415);
37 addParam("angleYHER", m_angleYHER, "angle of the High Energy Ring in the y-z plane. "
38 "Negative values are interpreted as pi - value", 0.0);
39 addParam("covHER", m_covHER, "covariance matrix of the High Energy Ring. This "
40 "can either be one value which is the squared energy spread, three "
41 "values corresponding to the variances of energy and the horizontal "
42 "and vertial spread (E, theta_x, theta_y) or a full covariance "
43 "matrix with 9 elements", std::vector<double>(1, 0));
44 addParam("energyLER", m_energyLER, "Energy of the Low Energy Ring", 4.0);
45 addParam("angleXLER", m_angleXLER, "angle of the Low Energy Ring in the x-z plane. "
46 "Negative values are interpreted as pi - value", -0.0415);
47 addParam("angleYLER", m_angleYLER, "angle of the Low Energy Ring in the y-z plane. "
48 "Negative values are interpreted as pi - value", 0.0);
49 addParam("covLER", m_covLER, "covariance matrix of the Low Energy Ring. This "
50 "can either be one value which is the squared energy spread, three "
51 "values corresponding to the variances of energy and the horizontal "
52 "and vertial spread (E, theta_x, theta_y) or a full covariance "
53 "matrix with 9 elements", std::vector<double>(1, 0));
54 addParam("vertex", m_vertex, "nominal vertex position", std::vector<double>(3, 0));
55 addParam("covVertex", m_covVertex, "covariance matrix of the nominal vertex "
56 "position. Can be either one value which is the common variance for "
57 "all directions, three values for the variance of x, y and z or a "
58 "full covariance matrix", std::vector<double>(1, 0));
59 addParam("smearEnergy", m_smearEnergy, "if true, smear energy when generating "
60 "initial events", true);
61 addParam("smearDirection", m_smearDirection, "if true, smear beam direction "
62 "when generating initial events", true);
63 addParam("smearVertex", m_smearVertex, "if true, smear vertex position when "
64 "generating initial events", true);
65 addParam("generateCMS", m_generateCMS, "if true, generate events in CMS, not "
66 "lab system", false);
67 addParam("createPayload", m_createPayload, "if true create a database payload "
68 "with the iov given with the payloadIov parameter", false);
69 addParam("payloadIov", m_payloadIov, "iov of the payload to be created. List "
70 "of four numbers: first experiment, first run, last experiment, "
71 "last run", m_payloadIov);
72}
73
75{
78 ROOT::Math::XYZVector vertex;
79 if (m_vertex.size() == 3) {
80 vertex.SetXYZ(m_vertex[0], m_vertex[1], m_vertex[2]);
81 } else {
82 B2ERROR("Vertex position needs to have 3 entries");
83 }
85 int flags = 0;
91
92 // Now make sure the database interface always returns the values we just set
94
95 if (m_createPayload) {
98 }
99}
bool m_generateCMS
if true, generate events in CMS, not lab system
bool m_createPayload
if true create a new payload with the given parameters
bool m_smearEnergy
if true, smear energy when generating initial events
virtual void initialize() override
Create the Beamparameters.
std::vector< double > m_covHER
Covariance matrix for the High Energy Ring.
double m_angleXLER
theta angle of the Low Energy Ring in the x-z plane
std::vector< double > m_covLER
Covariance matrix for the Low Energy Ring.
double m_energyHER
Energy of the High Energy Ring.
bool m_smearVertex
if true, smear vertex position when generating initial events
BeamParametersModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::vector< int > m_payloadIov
iov when creating a database payload
bool m_smearDirection
if true, smear beam direction when generating initial events
std::vector< double > m_covVertex
covariance matrix for the vertex position
double m_energyLER
Energy of the Low Energy Ring.
BeamParameters m_beamParams
Copy of the beamparameters created from the parameters.
double m_angleYHER
theta angle of the High Energy Ring in the y-z plane
std::vector< double > m_vertex
nominal vertex position
double m_angleXHER
theta angle of the High Energy Ring in the x-z plane
double m_angleYLER
theta angle of the Low Energy Ring in the y-z plane
This class contains the nominal beam parameters and the parameters used for smearing of the primary v...
void setHER(double energy, double angleX, double angleY, const std::vector< double > &cov)
Set the HER FourVector and error matrix from beam energy, angle and covariance entries.
void setLER(double energy, double angleX, double angleY, const std::vector< double > &cov)
Set the LER FourVector and error matrix from beam energy, angle and covariance entries.
void setVertex(const ROOT::Math::XYZVector &vertex, const std::vector< double > &cov)
Set the vertex position and error matrix.
void setGenerationFlags(int flags) override
Set the generation flags to be used for event generation (ORed combination of EGenerationFlags).
A class that describes the interval of experiments/runs for which an object in the database is valid.
@ c_generateCMS
generate initial event in CMS instead of lab
@ c_smearBeamEnergy
smear energy of HER and LER (but not direction)
@ c_smearBeamDirection
smear direction of HER and LER (but not energy)
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:28
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Definition: Database.cc:141
void addConstantOverride(const std::string &name, TObject *obj, bool oneRun=false)
Add constant override payload.
Definition: DBStore.cc:204
#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.