Belle II Software development
CosmicsModule.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/CosmicsModule.h>
10#include <framework/datastore/StoreArray.h>
11
12using namespace std;
13using namespace Belle2;
14
15//-----------------------------------------------------------------
16// Register the Module
17//-----------------------------------------------------------------
18REG_MODULE(Cosmics);
19
20//-----------------------------------------------------------------
21// Implementation
22//-----------------------------------------------------------------
23
25{
26 // Set module properties
27 setDescription("cosmics generator to generate cosmic ray tracks");
29 // Set default values for parameters
30 m_parameters.level = 1;
31 m_parameters.ipRequirement = 0;
32 m_parameters.ipdr = 3.; // Only relevant for ipRequirement = 1
33 m_parameters.ipdz = 3.; // Only relevant for ipRequirement = 1
34 m_parameters.ptmin = 0.7;
35 m_parameters.cylindricalR = 125.0;
36
37 // Parameter definition
38 addParam("level", m_parameters.level,
39 "level of the generator (1 or 2 with slightly different kinematic distributions and mu+/mu- ratio), default is 1",
40 m_parameters.level);
41 addParam("ipRequirement", m_parameters.ipRequirement,
42 "Radial and longitudinal constraints near the Interaction Point can be required (ipRequirement == 1), default is 0 (no additional IP requirements)",
43 m_parameters.ipRequirement);
44 addParam("ipdr", m_parameters.ipdr,
45 "Constraint on the radial distance from the IP in cm, default is 3.", m_parameters.ipdr);
46 addParam("ipdz", m_parameters.ipdz,
47 "Constraint on the longitudinal distance from the IP in cm, default is 3, default is 3.", m_parameters.ipdz);
48 addParam("ptmin", m_parameters.ptmin,
49 "Minimal value of the transverse momentum in GeV, default is 0.7", m_parameters.ptmin);
50 addParam("cylindricalR", m_parameters.cylindricalR,
51 "Radius of tube around detector at whose surface particles are generated (in cm), default is 125, but this does not include whole Belle 2 detector!",
52 m_parameters.cylindricalR);
53}
54
56{
57 // Initialize MCParticle collection
58 StoreArray<MCParticle> mcparticle;
59 mcparticle.registerInDataStore();
60
61 m_cosmics.setParameters(m_parameters);
62}
63
64
66{
67 try {
68 m_particleGraph.clear();
69 m_cosmics.generateEvent(m_particleGraph);
70 m_particleGraph.generateList();
71 } catch (runtime_error& e) {
72 B2ERROR(e.what());
73 }
74}
75
SGCosmic m_cosmics
Instance of the cosmics generator.
CosmicsModule()
Constructor.
MCParticleGraph m_particleGraph
Particle graph to generate MCParticle list.
void initialize() override
Initializes the module.
void event() override
Method is called for each event.
SGCosmic::Parameters m_parameters
Instance of parameters.
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
Module()
Constructor.
Definition Module.cc:30
@ c_Input
This module is an input module (reads data).
Definition Module.h:78
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.