Belle II Software  release-06-00-14
PinDigitizerModule.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/pindiode/modules/PinDigitizerModule.h>
10 #include <beast/pindiode/dataobjects/PindiodeSimHit.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 
20 using namespace std;
21 using namespace Belle2;
22 using namespace pindiode;
23 
24 
25 //-----------------------------------------------------------------
26 // Register the Module
27 //-----------------------------------------------------------------
28 REG_MODULE(PinDigitizer)
29 
30 //-----------------------------------------------------------------
31 // Implementation
32 //-----------------------------------------------------------------
33 
35 {
36  // Set module properties
37  setDescription("Pindiode digitizer module");
38 
39  //Default values are set here. New values can be in PINDIODE.xml.
40  addParam("CrematGain", m_CrematGain, "Charge sensitive preamplifier gain [volts/C] ", 1.4);
41  addParam("WorkFunction", m_WorkFunction, "Convert eV to e [e/eV] ", 1.12);
42  addParam("FanoFactor", m_FanoFactor, "e resolution ", 0.1);
43 
44 }
45 
46 PinDigitizerModule::~PinDigitizerModule()
47 {
48 }
49 
50 void PinDigitizerModule::initialize()
51 {
52  B2INFO("PinDigitizer: Initializing");
53  m_pindiodeHit.registerInDataStore();
54 
55 }
56 
57 void PinDigitizerModule::beginRun()
58 {
59 }
60 
61 void PinDigitizerModule::event()
62 {
63 
64 
65  StoreArray<PindiodeSimHit> PinSimHits;
67  //Skip events with no PinSimHits, but continue the event counter
68  if (PinSimHits.getEntries() == 0)
69  return;
70 
71  int nentries = PinSimHits.getEntries();
72  for (int i = 0; i < nentries; i++) {
73  PindiodeSimHit* aHit = PinSimHits[i];
74  int detNb = aHit->getCellId();
75  double edep = aHit->getEnergyDep();
76  double time = aHit->getFlightTime();
77  int pdg = aHit->getPDGCode();
78  double meanEl = edep / m_WorkFunction * 1e9; //GeV to eV
79  double sigma = sqrt(m_FanoFactor * meanEl); //sigma in electron
80  int NbEle = (int)gRandom->Gaus(meanEl, sigma); //electron number
81  double fedep = ((double) NbEle) * m_WorkFunction * 1e-3; //eV to keV
82  double volt = NbEle * 1.602176565e-19 * m_CrematGain * 1e12; // volt
83  //if ((fedep * 1e3) > m_WorkFunction)
84  PinHits.appendNew(PindiodeHit(fedep, volt, time, detNb, pdg));
85  }
86 
87 }
88 
89 void PinDigitizerModule::endRun()
90 {
91 }
92 
93 void PinDigitizerModule::terminate()
94 {
95 }
96 
97 
Base class for Modules.
Definition: Module.h:72
ClassPindiodeHit - digitization simulated hit for the Pindiode detector.
Definition: PindiodeHit.h:26
ClassPindiodeSimHit - Geant4 simulated hit for the Pindiode 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.
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
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.