Belle II Software  release-05-02-19
CosmicsModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Sergey Yashchenko *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <generators/modules/CosmicsModule.h>
12 #include <framework/datastore/StoreArray.h>
13 #include <boost/assign/std/vector.hpp>
14 
15 using namespace std;
16 using namespace Belle2;
17 using namespace boost::assign;
18 
19 //-----------------------------------------------------------------
20 // Register the Module
21 //-----------------------------------------------------------------
22 REG_MODULE(Cosmics)
23 
24 //-----------------------------------------------------------------
25 // Implementation
26 //-----------------------------------------------------------------
27 
29 {
30  // Set module properties
31  setDescription("cosmics generator to generate cosmic ray tracks");
32  setPropertyFlags(c_Input);
33  // Set default values for parameters
34  m_parameters.level = 1;
35  m_parameters.ipRequirement = 0;
36  m_parameters.ipdr = 3.; // Only relevant for ipRequirement = 1
37  m_parameters.ipdz = 3.; // Only relevant for ipRequirement = 1
38  m_parameters.ptmin = 0.7;
39  m_parameters.cylindricalR = 125.0;
40 
41  // Parameter definition
42  addParam("level", m_parameters.level,
43  "level of the generator (1 or 2 with slightly different kinematic distributions and mu+/mu- ratio), default is 1",
44  m_parameters.level);
45  addParam("ipRequirement", m_parameters.ipRequirement,
46  "Radial and longitudinal constraints near the Interaction Point can be required (ipRequirement == 1), default is 0 (no additional IP requirements)",
47  m_parameters.ipRequirement);
48  addParam("ipdr", m_parameters.ipdr,
49  "Constraint on the radial distance from the IP in cm, default is 3.", m_parameters.ipdr);
50  addParam("ipdz", m_parameters.ipdz,
51  "Constraint on the longitudinal distance from the IP in cm, default is 3, default is 3.", m_parameters.ipdz);
52  addParam("ptmin", m_parameters.ptmin,
53  "Minimal value of the transverse momentum in GeV, default is 0.7", m_parameters.ptmin);
54  addParam("cylindricalR", m_parameters.cylindricalR,
55  "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!",
56  m_parameters.cylindricalR);
57 }
58 
59 void CosmicsModule::initialize()
60 {
61  // Initialize MCParticle collection
62  StoreArray<MCParticle> mcparticle;
63  mcparticle.registerInDataStore();
64 
65  m_cosmics.setParameters(m_parameters);
66 }
67 
68 
69 void CosmicsModule::event()
70 {
71  try {
72  m_particleGraph.clear();
73  m_cosmics.generateEvent(m_particleGraph);
74  m_particleGraph.generateList();
75  } catch (runtime_error& e) {
76  B2ERROR(e.what());
77  }
78 }
79 
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::ProcType::c_Input
@ c_Input
Input Process.
Belle2::StoreArray::clear
void clear() override
Delete all entries in this array.
Definition: StoreArray.h:217
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreArray< MCParticle >
Belle2::CosmicsModule
The Cosmics module Generates tracks with the cosmics generator and store them into the MCParticle cla...
Definition: CosmicsModule.h:40