Belle II Software  release-06-01-15
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 using namespace Belle2;
13 
14 //-----------------------------------------------------------------
15 // Register the Module
16 //-----------------------------------------------------------------
18 
19 //-----------------------------------------------------------------
20 // Implementation
21 //-----------------------------------------------------------------
22 
24 {
25  // Set module properties
26  setDescription("Setting of beam parameters. This module allows to set the "
27  "beamparameters to be used by generators and analyis. One can "
28  "either select from a list of predefined parameter sets or "
29  "manually set the parameters to use.");
30 
31  // Parameter definitions
32  addParam("energyHER", m_energyHER, "Energy of the High Energy Ring", 7.0);
33  addParam("angleXHER", m_angleXHER, "angle of the High Energy Ring in the x-z plane. "
34  "Negative values are interpreted as pi - value", 0.0415);
35  addParam("angleYHER", m_angleYHER, "angle of the High Energy Ring in the y-z plane. "
36  "Negative values are interpreted as pi - value", 0.0);
37  addParam("covHER", m_covHER, "covariance matrix of the High Energy Ring. This "
38  "can either be one value which is the squared energy spread, three "
39  "values corresponding to the variances of energy and the horizontal "
40  "and vertial spread (E, theta_x, theta_y) or a full covariance "
41  "matrix with 9 elements", std::vector<double>(1, 0));
42  addParam("energyLER", m_energyLER, "Energy of the Low Energy Ring", 4.0);
43  addParam("angleXLER", m_angleXLER, "angle of the Low Energy Ring in the x-z plane. "
44  "Negative values are interpreted as pi - value", -0.0415);
45  addParam("angleYLER", m_angleYLER, "angle of the Low Energy Ring in the y-z plane. "
46  "Negative values are interpreted as pi - value", 0.0);
47  addParam("covLER", m_covLER, "covariance matrix of the Low Energy Ring. This "
48  "can either be one value which is the squared energy spread, three "
49  "values corresponding to the variances of energy and the horizontal "
50  "and vertial spread (E, theta_x, theta_y) or a full covariance "
51  "matrix with 9 elements", std::vector<double>(1, 0));
52  addParam("vertex", m_vertex, "nominal vertex position", std::vector<double>(3, 0));
53  addParam("covVertex", m_covVertex, "covariance matrix of the nominal vertex "
54  "position. Can be either one value which is the common variance for "
55  "all directions, three values for the variance of x, y and z or a "
56  "full covariance matrix", std::vector<double>(1, 0));
57  addParam("smearEnergy", m_smearEnergy, "if true, smear energy when generating "
58  "initial events", true);
59  addParam("smearDirection", m_smearDirection, "if true, smear beam direction "
60  "when generating initial events", true);
61  addParam("smearVertex", m_smearVertex, "if true, smear vertex position when "
62  "generating initial events", true);
63  addParam("generateCMS", m_generateCMS, "if true, generate events in CMS, not "
64  "lab system", false);
65  addParam("createPayload", m_createPayload, "if true create a database payload "
66  "with the iov given with the payloadIov parameter", false);
67  addParam("payloadIov", m_payloadIov, "iov of the payload to be created. List "
68  "of four numbers: first experiment, first run, last experiment, "
69  "last run", m_payloadIov);
70 }
71 
73 {
76  TVector3 vertex;
77  if (m_vertex.size() == 3) {
78  vertex.SetXYZ(m_vertex[0], m_vertex[1], m_vertex[2]);
79  } else {
80  B2ERROR("Vertex position needs to have 3 entries");
81  }
83  int flags = 0;
89 
90  // Now make sure the database interface always returns the values we just set
92 
93  if (m_createPayload) {
96  }
97 }
Setting of beam parameters.
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
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 TVector3 &vertex, const std::vector< double > &cov)
Set the vertex position and error matrix.
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)
void setGenerationFlags(int flags)
Set the generation flags to be used for event generation (ORed combination of EGenerationFlags)
Base class for Modules.
Definition: Module.h:72
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:41
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:26
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Definition: Database.cc:140
void addConstantOverride(const std::string &name, TObject *obj, bool oneRun=false)
Add constant override payload.
Definition: DBStore.cc:194
#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.