Belle II Software development
ECLShowerShapeModule.h
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#pragma once
9
10//STL
11#include <complex>
12
13//ROOT
14#include <TGraph.h>
15
16// FRAMEWORK
17#include <framework/core/Module.h>
18#include <framework/database/DBArray.h>
19#include <framework/database/DBObjPtr.h>
20#include <framework/datastore/StoreArray.h>
21#include <framework/gearbox/Unit.h>
22
23namespace Belle2 {
29 class DatabaseRepresentationOfWeightfile;
30 class ECLConnectedRegion;
31 class ECLShower;
32 class ECLShowerShapeSecondMomentCorrection;
33
34 namespace MVA {
35 class Expert;
36 class SingleDataset;
37 }
38
39 namespace ECL {
40 class ECLNeighbours;
41 }
42
45
46 public:
47
49 enum {
52 };
53
54
57
60
62 virtual void initialize() override;
63
65 virtual void beginRun() override;
66
68 virtual void event() override;
69
71 virtual void endRun() override;
72
74 virtual void terminate() override;
75
76 private:
77
80
82 double energy;
83
85 double rho;
86
88 double alpha;
89 };
90
93
94 // Module Parameters
100 const double m_BRLthetaMin = 32.2 * Unit::deg;
101 const double m_BRLthetaMax = 128.7 * Unit::deg;
103 const unsigned int m_numZernikeMVAvariables = 22;
108 std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>
110 std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>
112 std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>
114 std::unique_ptr<MVA::Expert> m_expert_FWD;
115 std::unique_ptr<MVA::Expert> m_expert_BRL;
116 std::unique_ptr<MVA::Expert> m_expert_BWD;
117 std::unique_ptr<MVA::SingleDataset>
121 std::unique_ptr<ECL::ECLNeighbours> m_neighbourMap9;
122
124 std::unique_ptr<ECL::ECLNeighbours> m_neighbourMap21;
125
128 void initializeMVAweightFiles(const std::string& identifier,
129 std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>& weightFileRepresentation);
130
134 void initializeMVA(const std::string& identifier,
135 std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>& weightFileRepresentation, std::unique_ptr<MVA::Expert>& expert);
136
143 void setShowerShapeVariables(ECLShower* eclShower, const bool calculateZernikeMVA) const;
144
146 double computeLateralEnergy(const std::vector<ProjectedECLDigit>& projectedDigits, const double avgCrystalDimension) const;
147
162 double computeAbsZernikeMoment(const std::vector<ProjectedECLDigit>& projectedDigits, const double totalEnergy, const int n,
163 const int m,
164 const double rho) const;
165
169 double computeSecondMoment(const std::vector<ProjectedECLDigit>& shower, const double totalEnergy) const;
170
172 std::vector<ProjectedECLDigit> projectECLDigits(const ECLShower& shower) const;
173
177 double Rnm(const int n, const int m, const double rho) const;
178
183 std::complex<double> zernikeValue(const double rho, const double alpha, const int n, const int m) const;
184
188 double computeE9oE21(const ECLShower&) const;
189
193 double computeE1oE9(const ECLShower&) const;
194
200
206
209 double getSecondMomentCorrection(const double theta, const double phi, const int hypothesis) const;
210
211 public:
215 virtual const char* eclShowerArrayName() const
216 { return "ECLShowers" ; }
217
219 virtual const char* eclCalDigitArrayName() const
220 { return "ECLCalDigits" ; }
221
223 virtual const char* eclConnectedRegionArrayName() const
224 { return "ECLConnectedRegions" ; }
225
226 }; // end of ECLShowerShapeModule
227
228
231 public:
232
234 virtual const char* eclShowerArrayName() const override
235 { return "ECLShowersPureCsI" ; }
236
238 virtual const char* eclCalDigitArrayName() const override
239 { return "ECLCalDigitsPureCsI" ; }
240
242 virtual const char* eclConnectedRegionArrayName() const override
243 { return "ECLConnectedRegionsPureCsI" ; }
244
245 }; // end of ECLShowerShapePureCsIModule
246
248} // end of Belle2 namespace
Class for accessing arrays of objects in the database.
Definition: DBArray.h:26
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Class to perform the shower correction.
std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > m_weightfile_representation_BWD
Database pointer to the Database representation of the Zernike moment MVA weightfile for BWD.
double computeAbsZernikeMoment(const std::vector< ProjectedECLDigit > &projectedDigits, const double totalEnergy, const int n, const int m, const double rho) const
Compute the absolute value of the complex Zernike moment Znm.
const double m_BRLthetaMin
Minimum theta of barrel used for choosing which Zernike MVA to apply.
virtual const char * eclShowerArrayName() const
We need names for the data objects to differentiate between PureCsI and default.
DBArray< ECLShowerShapeSecondMomentCorrection > m_secondMomentCorrectionArray
Shower shape corrections from DB.
std::string m_zernike_MVAidentifier_FWD
Zernike moment MVA - FWD endcap weight-file.
std::unique_ptr< MVA::Expert > m_expert_BRL
Pointer to the current MVA Expert for BRL.
StoreArray< ECLConnectedRegion > m_eclConnectedRegions
StoreArray ECLConnectedRegion.
std::unique_ptr< MVA::SingleDataset > m_dataset
Pointer to the current dataset.
virtual void initialize() override
Initialize.
double computeE1oE9(const ECLShower &) const
Shower shape variable: E1oE9 The energy ratio is calculated taking the weighted central (=1) and the ...
std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > m_weightfile_representation_BRL
Database pointer to the Database representation of the Zernike moment MVA weightfile for BRL.
virtual void event() override
Event.
std::unique_ptr< ECL::ECLNeighbours > m_neighbourMap9
Neighbour map 9 neighbours, for E9oE21 and E1oE9.
double getSecondMomentCorrection(const double theta, const double phi, const int hypothesis) const
Get corrections for second moment.
bool m_zernike_useFarCrystals
Determines if to include or ignore crystals with rho > rho0 in perpendicular plane,...
virtual void endRun() override
End run.
std::vector< ProjectedECLDigit > projectECLDigits(const ECLShower &shower) const
Compute projections of the ECLCalDigits to the perpendicular plane.
virtual void terminate() override
Terminate.
std::unique_ptr< MVA::Expert > m_expert_FWD
Pointer to the current MVA Expert for FWD.
const double m_BRLthetaMax
Maximum theta of barrel used for choosing which Zernike MVA to apply.
void initializeMVAweightFiles(const std::string &identifier, std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > &weightFileRepresentation)
initialize MVA weight files from DB
const unsigned int m_numZernikeMVAvariables
number of variables expected in the Zernike MVA weightfile
std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > m_weightfile_representation_FWD
Database pointer to the Database representation of the Zernike moment MVA weightfile for FWD.
double computeSecondMoment(const std::vector< ProjectedECLDigit > &shower, const double totalEnergy) const
Compute the second moment in the plane perpendicular to the direction of the shower.
virtual void beginRun() override
Begin run.
std::complex< double > zernikeValue(const double rho, const double alpha, const int n, const int m) const
Return the complex value of the Zernike polynomial of rank n,m.
TGraph m_secondMomentCorrections[2][10]
TGraphs that hold the corrections.
std::unique_ptr< ECL::ECLNeighbours > m_neighbourMap21
Neighbour map 21 neighbours, for E9oE21.
@ c_phiType
type of phi identifier
@ c_thetaType
type of theta identifier
double Rnm(const int n, const int m, const double rho) const
The radial part of the Zernike polynomial n,m - Zernike polynomial rank rho - radial distance
double m_zernike_n1_rho0
Scaling factor for radial distances in perpendicular plane, used in Zernike moment calculation for N1...
void prepareSecondMomentCorrectionsCallback()
Prepare corrections for second moment Will be called whenever the m_secondMomentCorrectionArray get u...
void setShowerShapeVariables(ECLShower *eclShower, const bool calculateZernikeMVA) const
Set showr shape variables.
virtual const char * eclConnectedRegionArrayName() const
Default name ECLConnectedRegions.
double m_zernike_n2_rho0
Scaling factor for radial distances in perpendicular plane, used in Zernike moment calculation for N2...
std::string m_zernike_MVAidentifier_BRL
Zernike moment MVA - Barrel weight-file.
double m_avgCrystalDimension
Average crystal dimension [cm].
virtual const char * eclCalDigitArrayName() const
Default name ECLCalDigits.
std::string m_zernike_MVAidentifier_BWD
Zernike moment MVA - BWD endcap weight-file.
double computeLateralEnergy(const std::vector< ProjectedECLDigit > &projectedDigits, const double avgCrystalDimension) const
Shower shape variable: Lateral energy.
std::unique_ptr< MVA::Expert > m_expert_BWD
Pointer to the current MVA Expert for BWD.
double computeE9oE21(const ECLShower &) const
Shower shape variable: E9oE21 The energy ratio is calculated taking the weighted 3x3 (=9) and the wei...
void initializeMVA(const std::string &identifier, std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > &weightFileRepresentation, std::unique_ptr< MVA::Expert > &expert)
Load MVA weight file and set pointer of expert.
The very same module but for PureCsI.
virtual const char * eclCalDigitArrayName() const override
PureCsI name ECLCalDigitsPureCsI.
virtual const char * eclShowerArrayName() const override
PureCsI name ECLShowersPureCsI.
virtual const char * eclConnectedRegionArrayName() const override
PureCsI name ECLConnectedRegionsPureCsI.
Class to store ECL Showers.
Definition: ECLShower.h:30
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
static const double deg
degree to radians
Definition: Unit.h:109
Abstract base class for different kinds of events.
Struct used to hold information of the digits projected to a plane perpendicular to the shower direct...