Belle II Software development
ECLHitDebugModule.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/* Own header. */
10#include <ecl/modules/eclHitDebug/ECLHitDebugModule.h>
11
12/* ECL headers. */
13#include <ecl/dataobjects/ECLDebugHit.h>
14#include <ecl/dataobjects/ECLElementNumbers.h>
15#include <ecl/dataobjects/ECLSimHit.h>
16#include <ecl/geometry/ECLGeometryPar.h>
17
18/* Basf2 headers. */
19#include <framework/gearbox/Unit.h>
20
21/* ROOT headers. */
22#include <Math/Vector3D.h>
23
24using namespace std;
25using namespace Belle2;
26using namespace ECL;
27
28//-----------------------------------------------------------------
29// Register the Module
30//-----------------------------------------------------------------
31REG_MODULE(ECLHitDebug);
32
33//-----------------------------------------------------------------
34// Implementation
35//-----------------------------------------------------------------
36
38{
39 // Set description
40 setDescription("ECLHitDebugModule");
42
43}
44
48
50{
51 // Initialize variables
52 m_nRun = 0 ;
53 m_nEvent = 0 ;
54 m_hitNum = 0;
55 // CPU time start
56 m_timeCPU = clock() * Unit::us;
57 m_eclDebugHits.registerInDataStore();
58}
59
63
65{
66 //---------------------------------------------------------------------
67 // Merge the hits in the same cell and save them into ECL signal map.
68 //---------------------------------------------------------------------
69
70 int const Nbin = 80;
71 int const interval = 8000 / Nbin;
72 static float E_cell[ECLElementNumbers::c_NCrystals][Nbin];
73 static float Tof_ave[ECLElementNumbers::c_NCrystals][Nbin];
74 memset(E_cell, 0, sizeof(float) * ECLElementNumbers::c_NCrystals * Nbin);
75 memset(Tof_ave, 0, sizeof(float) * ECLElementNumbers::c_NCrystals * Nbin);
76
77 // Get instance of ecl geometry parameters
79 // Loop over all hits of steps
80 for (int iHits = 0; iHits < m_eclSimArray.getEntries(); iHits++) {
81 // Get a hit
82 ECLSimHit* aECLSimHit = m_eclSimArray[iHits];
83
84 // Hit geom. info
85 int hitCellId = aECLSimHit->getCellId() - 1;
86 double hitE = aECLSimHit->getEnergyDep() * Unit::GeV;
87 double hitTOF = aECLSimHit->getFlightTime() * Unit::ns;
88 G4ThreeVector t = aECLSimHit->getPosIn();
89 ROOT::Math::XYZVector HitInPos(t.x(), t.y(), t.z());
90
91 const ROOT::Math::XYZVector& PosCell = eclp->GetCrystalPos(hitCellId);
92 const ROOT::Math::XYZVector& VecCell = eclp->GetCrystalVec(hitCellId);
93 double local_pos = (15. - (HitInPos - PosCell).Dot(VecCell));
94
95 int iECLCell = hitCellId;
96 if (hitTOF < 8000) {
97 int TimeIndex = (int) hitTOF / interval;
98 E_cell[iECLCell][TimeIndex] = E_cell[iECLCell][TimeIndex] + hitE;
99 Tof_ave[iECLCell][TimeIndex] += (6.05 + 0.0749 * local_pos - 0.00112 * local_pos * local_pos + hitTOF) * hitE ;
100 }
101
102 }//for nHit
103
104
105 for (int iECLCell = 0; iECLCell < ECLElementNumbers::c_NCrystals; iECLCell++) {
106 for (int TimeIndex = 0; TimeIndex < Nbin; TimeIndex++) {
107
108 if (E_cell[iECLCell][TimeIndex] > 0) {
109 m_eclDebugHits.appendNew();
110 m_hitNum = m_eclDebugHits.getEntries() - 1;
111 m_eclDebugHits[m_hitNum]->setCellId(iECLCell + 1);
112 m_eclDebugHits[m_hitNum]->setEnergyDep(E_cell[iECLCell][TimeIndex]);
113 m_eclDebugHits[m_hitNum]->setTimeAve(Tof_ave[iECLCell][TimeIndex] / E_cell[iECLCell][TimeIndex]);
114 }//if Energy > 0
115 }//16 Time interval 16x 500 ns
116 } //store each crystal hit
117
118 m_nEvent++;
119}
120
121
123{
124 m_nRun++;
125}
126
StoreArray< ECLDebugHit > m_eclDebugHits
ECLDebugHit datastore object.
virtual void initialize() override
Initialize variables, print info, and start CPU clock.
StoreArray< ECLSimHit > m_eclSimArray
StoreArray ECLSimHit.
int m_hitNum
The current number of created hits in an event.
virtual void event() override
Actual digitization of all hits in the ECL.
virtual void endRun() override
Nothing so far.
virtual void terminate() override
Stopping of CPU clock.
virtual void beginRun() override
Nothing so far.
virtual ~ECLHitDebugModule()
Destructor.
ClassECLSimHit - Geant4 simulated hit for the ECL.
Definition ECLSimHit.h:29
int getCellId() const
Get Cell ID.
Definition ECLSimHit.h:86
double getFlightTime() const
Get Flight time from IP.
Definition ECLSimHit.h:101
double getEnergyDep() const
Get Deposit energy.
Definition ECLSimHit.h:106
G4ThreeVector getPosIn() const
Get Position.
Definition ECLSimHit.h:121
The Class for ECL Geometry Parameters.
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
ROOT::Math::XYZVector GetCrystalPos(int cid)
The Position of crystal.
ROOT::Math::XYZVector GetCrystalVec(int cid)
The direction of crystal.
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
Module()
Constructor.
Definition Module.cc:30
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
static const double us
[microsecond]
Definition Unit.h:97
static const double ns
Standard of [time].
Definition Unit.h:48
static const double GeV
Standard of [energy, momentum, mass].
Definition Unit.h:51
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.
STL namespace.