Belle II Software development
BeamDigitizerModule.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 <beast/beamabort/modules/BeamDigitizerModule.h>
10#include <beast/beamabort/dataobjects/BeamabortSimHit.h>
11
12#include <framework/logging/Logger.h>
13#include <framework/core/RandomNumbers.h>
14
15//c++
16#include <cmath>
17#include <string>
18#include <fstream>
19
20using namespace std;
21using namespace Belle2;
22using namespace beamabort;
23
24
25//-----------------------------------------------------------------
26// Register the Module
27//-----------------------------------------------------------------
28REG_MODULE(BeamDigitizer);
29
30//-----------------------------------------------------------------
31// Implementation
32//-----------------------------------------------------------------
33
35{
36 // Set module properties
37 setDescription("Beamabort digitizer module");
38
39 //Default values are set here. New values can be in BEAMABORT.xml.
40 addParam("WorkFunction", m_WorkFunction, "Convert eV to e [e/eV] ", 1.12);
41 addParam("FanoFactor", m_FanoFactor, "e resolution ", 0.1);
42
43}
44
46{
47}
48
50{
51 B2INFO("BeamDigitizer: Initializing");
52 m_beamabortHit.registerInDataStore();
53
54}
55
57{
58}
59
61{
62
65 //Skip events with no BeamSimHits, but continue the event counter
66 if (BeamSimHits.getEntries() == 0)
67 return;
68
69
70 int nentries = BeamSimHits.getEntries();
71 for (int i = 0; i < nentries; i++) {
72 BeamabortSimHit* aHit = BeamSimHits[i];
73 int detNb = aHit->getCellId();
74 double edep = aHit->getEnergyDep();
75 double time = aHit->getFlightTime();
76 int pdg = aHit->getPDGCode();
77 double meanEl = edep / m_WorkFunction * 1e9; //GeV to eV
78 double sigma = sqrt(m_FanoFactor * meanEl); //sigma in electron
79 int NbEle = (int)gRandom->Gaus(meanEl, sigma); //electron number
80 double fedep = ((double) NbEle) * m_WorkFunction * 1e-3; //eV to keV
81 double Amp = NbEle / (6.25 * 1e18); // A x s
82 //if ((fedep * 1e3) > m_WorkFunction)
83 BeamHits.appendNew(BeamabortHit(fedep, Amp, time, detNb, pdg));
84 }
85
86}
87
89{
90}
91
93{
94}
95
96
ClassBeamabortHit - digitization simulated hit for the Beamabort detector.
Definition: BeamabortHit.h:26
ClassBeamabortSimHit - Geant4 simulated hit for the Beamabort crystal in beast.
int getPDGCode() const
Get Particle PDG (can be one of secondaries)
int getCellId() const
Get Cell ID.
double getFlightTime() const
Get Flight time from IP.
double getEnergyDep() const
Get Deposit energy.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void endRun() override
End-of-run action.
virtual void terminate() override
Termination action.
BeamDigitizerModule()
Constructor: Sets the description, the properties and the parameters of the module.
virtual void beginRun() override
Called when entering a new run.
StoreArray< BeamabortHit > m_beamabortHit
Array for BemaabortHit.
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:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.
STL namespace.