Belle II Software  release-05-02-19
BeamDigitizerModule.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/beamabort/modules/BeamDigitizerModule.h>
12 #include <beast/beamabort/dataobjects/BeamabortSimHit.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 beamabort;
25 
26 
27 //-----------------------------------------------------------------
28 // Register the Module
29 //-----------------------------------------------------------------
30 REG_MODULE(BeamDigitizer)
31 
32 //-----------------------------------------------------------------
33 // Implementation
34 //-----------------------------------------------------------------
35 
37 {
38  // Set module properties
39  setDescription("Beamabort digitizer module");
40 
41  //Default values are set here. New values can be in BEAMABORT.xml.
42  addParam("WorkFunction", m_WorkFunction, "Convert eV to e [e/eV] ", 1.12);
43  addParam("FanoFactor", m_FanoFactor, "e resolution ", 0.1);
44 
45 }
46 
47 BeamDigitizerModule::~BeamDigitizerModule()
48 {
49 }
50 
51 void BeamDigitizerModule::initialize()
52 {
53  B2INFO("BeamDigitizer: Initializing");
54  m_beamabortHit.registerInDataStore();
55 
56 }
57 
58 void BeamDigitizerModule::beginRun()
59 {
60 }
61 
62 void BeamDigitizerModule::event()
63 {
64 
65  StoreArray<BeamabortSimHit> BeamSimHits;
66  StoreArray<BeamabortHit> BeamHits;
67  //Skip events with no BeamSimHits, but continue the event counter
68  if (BeamSimHits.getEntries() == 0)
69  return;
70 
71 
72  int nentries = BeamSimHits.getEntries();
73  for (int i = 0; i < nentries; i++) {
74  BeamabortSimHit* aHit = BeamSimHits[i];
75  int detNb = aHit->getCellId();
76  double edep = aHit->getEnergyDep();
77  double time = aHit->getFlightTime();
78  int pdg = aHit->getPDGCode();
79  double meanEl = edep / m_WorkFunction * 1e9; //GeV to eV
80  double sigma = sqrt(m_FanoFactor * meanEl); //sigma in electron
81  int NbEle = (int)gRandom->Gaus(meanEl, sigma); //electron number
82  double fedep = ((double) NbEle) * m_WorkFunction * 1e-3; //eV to keV
83  double Amp = NbEle / (6.25 * 1e18); // A x s
84  //if ((fedep * 1e3) > m_WorkFunction)
85  BeamHits.appendNew(BeamabortHit(fedep, Amp, time, detNb, pdg));
86  }
87 
88 }
89 
90 void BeamDigitizerModule::endRun()
91 {
92 }
93 
94 void BeamDigitizerModule::terminate()
95 {
96 }
97 
98 
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::BeamabortSimHit::getFlightTime
double getFlightTime() const
Get Flight time from IP.
Definition: BeamabortSimHit.h:121
Belle2::BeamabortHit
ClassBeamabortHit - digitization simulated hit for the Beamabort detector.
Definition: BeamabortHit.h:36
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
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BeamabortSimHit::getPDGCode
int getPDGCode() const
Get Particle PDG (can be one of secondaries)
Definition: BeamabortSimHit.h:116
Belle2::BeamabortSimHit::getEnergyDep
double getEnergyDep() const
Get Deposit energy.
Definition: BeamabortSimHit.h:126
Belle2::BeamabortSimHit::getCellId
int getCellId() const
Get Cell ID.
Definition: BeamabortSimHit.h:106
Belle2::beamabort::BeamDigitizerModule
Beam tube digitizer.
Definition: BeamDigitizerModule.h:38
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::BeamabortSimHit
ClassBeamabortSimHit - Geant4 simulated hit for the Beamabort crystal in beast.
Definition: BeamabortSimHit.h:41