Belle II Software  release-05-02-19
PinDigitizerModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Igal Jaegle *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <beast/pindiode/modules/PinDigitizerModule.h>
12 #include <beast/pindiode/dataobjects/PindiodeSimHit.h>
13 
14 #include <framework/logging/Logger.h>
15 #include <framework/core/RandomNumbers.h>
16 
17 //c++
18 #include <cmath>
19 #include <string>
20 #include <fstream>
21 
22 using namespace std;
23 using namespace Belle2;
24 using namespace pindiode;
25 
26 
27 //-----------------------------------------------------------------
28 // Register the Module
29 //-----------------------------------------------------------------
30 REG_MODULE(PinDigitizer)
31 
32 //-----------------------------------------------------------------
33 // Implementation
34 //-----------------------------------------------------------------
35 
37 {
38  // Set module properties
39  setDescription("Pindiode digitizer module");
40 
41  //Default values are set here. New values can be in PINDIODE.xml.
42  addParam("CrematGain", m_CrematGain, "Charge sensitive preamplifier gain [volts/C] ", 1.4);
43  addParam("WorkFunction", m_WorkFunction, "Convert eV to e [e/eV] ", 1.12);
44  addParam("FanoFactor", m_FanoFactor, "e resolution ", 0.1);
45 
46 }
47 
48 PinDigitizerModule::~PinDigitizerModule()
49 {
50 }
51 
52 void PinDigitizerModule::initialize()
53 {
54  B2INFO("PinDigitizer: Initializing");
55  m_pindiodeHit.registerInDataStore();
56 
57 }
58 
59 void PinDigitizerModule::beginRun()
60 {
61 }
62 
63 void PinDigitizerModule::event()
64 {
65 
66 
67  StoreArray<PindiodeSimHit> PinSimHits;
69  //Skip events with no PinSimHits, but continue the event counter
70  if (PinSimHits.getEntries() == 0)
71  return;
72 
73  int nentries = PinSimHits.getEntries();
74  for (int i = 0; i < nentries; i++) {
75  PindiodeSimHit* aHit = PinSimHits[i];
76  int detNb = aHit->getCellId();
77  double edep = aHit->getEnergyDep();
78  double time = aHit->getFlightTime();
79  int pdg = aHit->getPDGCode();
80  double meanEl = edep / m_WorkFunction * 1e9; //GeV to eV
81  double sigma = sqrt(m_FanoFactor * meanEl); //sigma in electron
82  int NbEle = (int)gRandom->Gaus(meanEl, sigma); //electron number
83  double fedep = ((double) NbEle) * m_WorkFunction * 1e-3; //eV to keV
84  double volt = NbEle * 1.602176565e-19 * m_CrematGain * 1e12; // volt
85  //if ((fedep * 1e3) > m_WorkFunction)
86  PinHits.appendNew(PindiodeHit(fedep, volt, time, detNb, pdg));
87  }
88 
89 }
90 
91 void PinDigitizerModule::endRun()
92 {
93 }
94 
95 void PinDigitizerModule::terminate()
96 {
97 }
98 
99 
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::PindiodeSimHit::getCellId
int getCellId() const
Get Cell ID.
Definition: PindiodeSimHit.h:106
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::PindiodeHit
ClassPindiodeHit - digitization simulated hit for the Pindiode detector.
Definition: PindiodeHit.h:36
Belle2::PindiodeSimHit::getPDGCode
int getPDGCode() const
Get Particle PDG (can be one of secondaries)
Definition: PindiodeSimHit.h:116
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::pindiode::PinDigitizerModule
Pin tube digitizer.
Definition: PinDigitizerModule.h:41
Belle2::PindiodeSimHit::getEnergyDep
double getEnergyDep() const
Get Deposit energy.
Definition: PindiodeSimHit.h:126
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226
Belle2::PindiodeSimHit::getFlightTime
double getFlightTime() const
Get Flight time from IP.
Definition: PindiodeSimHit.h:121
Belle2::PindiodeSimHit
ClassPindiodeSimHit - Geant4 simulated hit for the Pindiode crystal in beast.
Definition: PindiodeSimHit.h:41