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
61{
62 //---------------------------------------------------------------------
63 // Merge the hits in the same cell and save them into ECL signal map.
64 //---------------------------------------------------------------------
65
66 int const Nbin = 80;
67 int const interval = 8000 / Nbin;
68 static float E_cell[ECLElementNumbers::c_NCrystals][Nbin];
69 static float Tof_ave[ECLElementNumbers::c_NCrystals][Nbin];
70 memset(E_cell, 0, sizeof(float) * ECLElementNumbers::c_NCrystals * Nbin);
71 memset(Tof_ave, 0, sizeof(float) * ECLElementNumbers::c_NCrystals * Nbin);
72
73 // Get instance of ecl geometry parameters
75 // Loop over all hits of steps
76 for (int iHits = 0; iHits < m_eclSimArray.getEntries(); iHits++) {
77 // Get a hit
78 const ECLSimHit* aECLSimHit = m_eclSimArray[iHits];
79
80 // Hit geom. info
81 int hitCellId = aECLSimHit->getCellId() - 1;
82 double hitE = aECLSimHit->getEnergyDep() * Unit::GeV;
83 double hitTOF = aECLSimHit->getFlightTime() * Unit::ns;
84 G4ThreeVector t = aECLSimHit->getPosIn();
85 ROOT::Math::XYZVector HitInPos(t.x(), t.y(), t.z());
86
87 const ROOT::Math::XYZVector& PosCell = eclp->GetCrystalPos(hitCellId);
88 const ROOT::Math::XYZVector& VecCell = eclp->GetCrystalVec(hitCellId);
89 double local_pos = (15. - (HitInPos - PosCell).Dot(VecCell));
90
91 if (hitTOF < 8000) {
92 int iECLCell = hitCellId;
93 int TimeIndex = (int) hitTOF / interval;
94 E_cell[iECLCell][TimeIndex] = E_cell[iECLCell][TimeIndex] + hitE;
95 Tof_ave[iECLCell][TimeIndex] += (6.05 + 0.0749 * local_pos - 0.00112 * local_pos * local_pos + hitTOF) * hitE ;
96 }
97
98 }//for nHit
99
100
101 for (int iECLCell = 0; iECLCell < ECLElementNumbers::c_NCrystals; iECLCell++) {
102 for (int TimeIndex = 0; TimeIndex < Nbin; TimeIndex++) {
103
104 if (E_cell[iECLCell][TimeIndex] > 0) {
105 m_eclDebugHits.appendNew();
106 m_hitNum = m_eclDebugHits.getEntries() - 1;
107 m_eclDebugHits[m_hitNum]->setCellId(iECLCell + 1);
108 m_eclDebugHits[m_hitNum]->setEnergyDep(E_cell[iECLCell][TimeIndex]);
109 m_eclDebugHits[m_hitNum]->setTimeAve(Tof_ave[iECLCell][TimeIndex] / E_cell[iECLCell][TimeIndex]);
110 }//if Energy > 0
111 }//16 Time interval 16x 500 ns
112 } //store each crystal hit
113
114 m_nEvent++;
115}
116
117
119{
120 m_nRun++;
121}
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 ~ECLHitDebugModule() override
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.