Belle II Software  release-05-02-19
BeamParametersModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <generators/modules/BeamParametersModule.h>
12 #include <framework/database/Database.h>
13 
14 using 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("angleHER", m_angleHER, "angle of the High Energy Ring. "
36  "Negative values are interpreted as pi - value", 0.0415);
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("angleLER", m_angleLER, "angle of the Low Energy Ring. "
44  "Negative values are interpreted as pi - value", -0.0415);
45  addParam("covLER", m_covLER, "covariance matrix of the Low Energy Ring. This "
46  "can either be one value which is the squared energy spread, three "
47  "values corresponding to the variances of energy and the horizontal "
48  "and vertial spread (E, theta_x, theta_y) or a full covariance "
49  "matrix with 9 elements", std::vector<double>(1, 0));
50  addParam("vertex", m_vertex, "nominal vertex position", std::vector<double>(3, 0));
51  addParam("covVertex", m_covVertex, "covariance matrix of the nominal vertex "
52  "position. Can be either one value which is the common variance for "
53  "all directions, three values for the variance of x, y and z or a "
54  "full covariance matrix", std::vector<double>(1, 0));
55  addParam("smearEnergy", m_smearEnergy, "if true, smear energy when generating "
56  "initial events", true);
57  addParam("smearDirection", m_smearDirection, "if true, smear beam direction "
58  "when generating initial events", true);
59  addParam("smearVertex", m_smearVertex, "if true, smear vertex position when "
60  "generating initial events", true);
61  addParam("generateCMS", m_generateCMS, "if true, generate events in CMS, not "
62  "lab system", false);
63  addParam("createPayload", m_createPayload, "if true create a database payload "
64  "with the iov given with the payloadIov parameter", false);
65  addParam("payloadIov", m_payloadIov, "iov of the payload to be created. List "
66  "of four numbers: first experiment, first run, last experiment, "
67  "last run", m_payloadIov);
68 }
69 
71 {
74  TVector3 vertex;
75  if (m_vertex.size() == 3) {
76  vertex.SetXYZ(m_vertex[0], m_vertex[1], m_vertex[2]);
77  } else {
78  B2ERROR("Vertex position needs to have 3 entries");
79  }
81  int flags = 0;
87 
88  // Now make sure the database interface always returns the values we just set
90 
91  if (m_createPayload) {
94  }
95 }
Belle2::IntervalOfValidity
A class that describes the interval of experiments/runs for which an object in the database is valid.
Definition: IntervalOfValidity.h:35
Belle2::BeamParametersModule::m_beamParams
BeamParameters m_beamParams
Copy of the beamparameters created from the parameters.
Definition: BeamParametersModule.h:44
Belle2::MCInitialParticles::c_smearBeamEnergy
@ c_smearBeamEnergy
smear energy of HER and LER (but not direction)
Definition: MCInitialParticles.h:44
Belle2::DBStore::addConstantOverride
void addConstantOverride(const std::string &name, TObject *obj, bool oneRun=false)
Add constant override payload.
Definition: DBStore.cc:204
Belle2::BeamParametersModule
Setting of beam parameters.
Definition: BeamParametersModule.h:31
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::MCInitialParticles::c_smearBeamDirection
@ c_smearBeamDirection
smear direction of HER and LER (but not energy)
Definition: MCInitialParticles.h:46
Belle2::Database::storeData
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Definition: Database.cc:152
Belle2::BeamParametersModule::m_createPayload
bool m_createPayload
if true create a new payload with the given parameters
Definition: BeamParametersModule.h:59
Belle2::BeamParametersModule::m_vertex
std::vector< double > m_vertex
nominal vertex position
Definition: BeamParametersModule.h:51
Belle2::BeamParametersModule::m_covVertex
std::vector< double > m_covVertex
covariance matrix for the vertex position
Definition: BeamParametersModule.h:52
Belle2::BeamParametersModule::initialize
virtual void initialize() override
Create the Beamparameters.
Definition: BeamParametersModule.cc:70
Belle2::BeamParametersModule::m_payloadIov
std::vector< int > m_payloadIov
iov when creating a database payload
Definition: BeamParametersModule.h:53
Belle2::MCInitialParticles::setGenerationFlags
void setGenerationFlags(int flags)
Set the generation flags to be used for event generation (ORed combination of EGenerationFlags)
Definition: MCInitialParticles.h:134
Belle2::MCInitialParticles::c_smearVertex
@ c_smearVertex
smear vertex
Definition: MCInitialParticles.h:50
Belle2::BeamParametersModule::m_angleLER
double m_angleLER
theta angle of the Low Energy Ring
Definition: BeamParametersModule.h:49
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::BeamParameters::setVertex
void setVertex(const TVector3 &vertex, const std::vector< double > &cov)
Set the vertex position and error matrix.
Belle2::BeamParametersModule::m_covHER
std::vector< double > m_covHER
Covariance matrix for the High Energy Ring.
Definition: BeamParametersModule.h:47
Belle2::MCInitialParticles::c_generateCMS
@ c_generateCMS
generate initial event in CMS instead of lab
Definition: MCInitialParticles.h:42
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BeamParametersModule::m_energyLER
double m_energyLER
Energy of the Low Energy Ring.
Definition: BeamParametersModule.h:48
Belle2::BeamParameters::setHER
void setHER(double energy, double angle, const std::vector< double > &cov)
Set the HER FourVector and error matrix from beam energy, angle and covariance entries.
Belle2::BeamParametersModule::m_smearVertex
bool m_smearVertex
if true, smear vertex position when generating initial events
Definition: BeamParametersModule.h:57
Belle2::BeamParametersModule::m_generateCMS
bool m_generateCMS
if true, generate events in CMS, not lab system
Definition: BeamParametersModule.h:58
Belle2::DBStore::Instance
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:36
Belle2::BeamParametersModule::m_smearEnergy
bool m_smearEnergy
if true, smear energy when generating initial events
Definition: BeamParametersModule.h:55
Belle2::Database::Instance
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:54
Belle2::BeamParameters::setLER
void setLER(double energy, double angle, const std::vector< double > &cov)
Set the LER FourVector and error matrix from beam energy, angle and covariance entries.
Belle2::BeamParametersModule::m_covLER
std::vector< double > m_covLER
Covariance matrix for the Low Energy Ring.
Definition: BeamParametersModule.h:50
Belle2::BeamParametersModule::m_smearDirection
bool m_smearDirection
if true, smear beam direction when generating initial events
Definition: BeamParametersModule.h:56
Belle2::BeamParameters
This class contains the nominal beam parameters and the parameters used for smearing of the primary v...
Definition: BeamParameters.h:33
Belle2::BeamParametersModule::m_energyHER
double m_energyHER
Energy of the High Energy Ring.
Definition: BeamParametersModule.h:45
Belle2::BeamParametersModule::m_angleHER
double m_angleHER
theta angle of the High Energy Ring
Definition: BeamParametersModule.h:46