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