Belle II Software  release-05-02-19
ECLShowerShapeModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * This module calculates shower shape variables. *
6  * *
7  * Author: The Belle II Collaboration *
8  * Contributors: Torben Ferber (ferber@physics.ubc.ca) *
9  * Guglielmo De Nardo (denardo@na.infn.it) *
10  * Alon Hershenhorn (hershen@phas.ubc.ca) *
11  * *
12  * This software is provided "as is" without any warranty. *
13  **************************************************************************/
14 #pragma once
15 
16 //STL
17 #include <complex>
18 
19 //ROOT
20 #include <TGraph.h>
21 
22 // FRAMEWORK
23 #include <framework/core/Module.h>
24 #include <framework/database/DBArray.h>
25 #include <framework/database/DBObjPtr.h>
26 #include <framework/datastore/StoreArray.h>
27 #include <framework/gearbox/Unit.h>
28 
29 namespace Belle2 {
35  class DatabaseRepresentationOfWeightfile;
36  class ECLConnectedRegion;
37  class ECLShower;
38  class ECLShowerShapeSecondMomentCorrection;
39 
40  namespace MVA {
41  class Expert;
42  class SingleDataset;
43  }
44 
45  namespace ECL {
46  class ECLNeighbours;
47  }
48 
53  class ECLShowerShapeModule : public Module {
54 
55  public:
56 
58  enum {
59  c_thetaType = 0,
60  c_phiType = 1,
61  };
62 
63 
66 
69 
71  virtual void initialize() override;
72 
74  virtual void beginRun() override;
75 
77  virtual void event() override;
78 
80  virtual void endRun() override;
81 
83  virtual void terminate() override;
84 
85  private:
86 
88  struct ProjectedECLDigit {
89 
91  double energy;
92 
94  double rho;
95 
97  double alpha;
98  };
99 
102 
103  // Module Parameters
104  double m_zernike_n1_rho0;
105  double m_zernike_n2_rho0;
107  double m_avgCrystalDimension;
109  const double m_BRLthetaMin = 32.2 * Unit::deg;
110  const double m_BRLthetaMax = 128.7 * Unit::deg;
112  const unsigned int m_numZernikeMVAvariables = 22;
114  std::string m_zernike_MVAidentifier_FWD;
115  std::string m_zernike_MVAidentifier_BRL;
117  std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>
119  std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>
121  std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>
123  std::unique_ptr<MVA::Expert> m_expert_FWD;
124  std::unique_ptr<MVA::Expert> m_expert_BRL;
125  std::unique_ptr<MVA::Expert> m_expert_BWD;
126  std::unique_ptr<MVA::SingleDataset>
130  std::unique_ptr<ECL::ECLNeighbours> m_neighbourMap9;
131 
133  std::unique_ptr<ECL::ECLNeighbours> m_neighbourMap21;
134 
137  void initializeMVAweightFiles(const std::string& identifier,
138  std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>& weightFileRepresentation);
139 
143  void initializeMVA(const std::string& identifier,
144  std::unique_ptr<DBObjPtr<DatabaseRepresentationOfWeightfile>>& weightFileRepresentation, std::unique_ptr<MVA::Expert>& expert);
145 
152  void setShowerShapeVariables(ECLShower* eclShower, const bool calculateZernikeMVA) const;
153 
155  double computeLateralEnergy(const std::vector<ProjectedECLDigit>& projectedDigits, const double avgCrystalDimension) const;
156 
171  double computeAbsZernikeMoment(const std::vector<ProjectedECLDigit>& projectedDigits, const double totalEnergy, const int n,
172  const int m,
173  const double rho) const;
174 
178  double computeSecondMoment(const std::vector<ProjectedECLDigit>& shower, const double totalEnergy) const;
179 
181  std::vector<ProjectedECLDigit> projectECLDigits(const ECLShower& shower) const;
182 
186  double Rnm(const int n, const int m, const double rho) const;
187 
192  std::complex<double> zernikeValue(const double rho, const double alpha, const int n, const int m) const;
193 
197  double computeE9oE21(const ECLShower&) const;
198 
202  double computeE1oE9(const ECLShower&) const;
203 
208  TGraph m_secondMomentCorrections[2][10];
209 
215 
218  double getSecondMomentCorrection(const double theta, const double phi, const int hypothesis) const;
219 
220  public:
224  virtual const char* eclShowerArrayName() const
225  { return "ECLShowers" ; }
226 
228  virtual const char* eclCalDigitArrayName() const
229  { return "ECLCalDigits" ; }
230 
232  virtual const char* eclConnectedRegionArrayName() const
233  { return "ECLConnectedRegions" ; }
234 
235  }; // end of ECLShowerShapeModule
236 
237 
240  public:
241 
243  virtual const char* eclShowerArrayName() const override
244  { return "ECLShowersPureCsI" ; }
245 
247  virtual const char* eclCalDigitArrayName() const override
248  { return "ECLCalDigitsPureCsI" ; }
249 
251  virtual const char* eclConnectedRegionArrayName() const override
252  { return "ECLConnectedRegionsPureCsI" ; }
253 
254  }; // end of ECLShowerShapePureCsIModule
255 
257 } // end of Belle2 namespace
Belle2::ECLShowerShapeModule::c_thetaType
@ c_thetaType
type of theta identifier
Definition: ECLShowerShapeModule.h:71
Belle2::ECLShowerShapePureCsIModule::eclConnectedRegionArrayName
virtual const char * eclConnectedRegionArrayName() const override
PureCsI name ECLConnectedRegionsPureCsI.
Definition: ECLShowerShapeModule.h:263
Belle2::ECLShowerShapeModule::zernikeValue
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.
Definition: ECLShowerShapeModule.cc:431
Belle2::ECLShowerShapeModule::m_neighbourMap21
std::unique_ptr< ECL::ECLNeighbours > m_neighbourMap21
Neighbour map 21 neighbours, for E9oE21.
Definition: ECLShowerShapeModule.h:145
Belle2::ECLShowerShapeModule::ProjectedECLDigit::rho
double rho
radial distance
Definition: ECLShowerShapeModule.h:106
Belle2::ECLShowerShapeModule::m_expert_BRL
std::unique_ptr< MVA::Expert > m_expert_BRL
Pointer to the current MVA Expert for BRL.
Definition: ECLShowerShapeModule.h:136
Belle2::ECLShowerShapeModule::ProjectedECLDigit
Struct used to hold information of the digits projected to a plane perpendicular to the shower direct...
Definition: ECLShowerShapeModule.h:100
Belle2::ECLShowerShapeModule::computeSecondMoment
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.
Definition: ECLShowerShapeModule.cc:466
Belle2::ECLShowerShapeModule::endRun
virtual void endRun() override
End run.
Definition: ECLShowerShapeModule.cc:357
Belle2::ECLShowerShapeModule::initialize
virtual void initialize() override
Initialize.
Definition: ECLShowerShapeModule.cc:103
Belle2::ECLShowerShapeModule::event
virtual void event() override
Event.
Definition: ECLShowerShapeModule.cc:246
Belle2::ECLShowerShapePureCsIModule::eclCalDigitArrayName
virtual const char * eclCalDigitArrayName() const override
PureCsI name ECLCalDigitsPureCsI.
Definition: ECLShowerShapeModule.h:259
Belle2::ECLShowerShapeModule::setShowerShapeVariables
void setShowerShapeVariables(ECLShower *eclShower, const bool calculateZernikeMVA) const
Set showr shape variables.
Definition: ECLShowerShapeModule.cc:176
Belle2::DBArray
Class for accessing arrays of objects in the database.
Definition: DBArray.h:36
Belle2::ECLShowerShapeModule::computeE1oE9
double computeE1oE9(const ECLShower &) const
Shower shape variable: E1oE9 The energy ratio is calculated taking the weighted central (=1) and the ...
Definition: ECLShowerShapeModule.cc:479
Belle2::ECLShowerShapeModule::m_dataset
std::unique_ptr< MVA::SingleDataset > m_dataset
Pointer to the current dataset.
Definition: ECLShowerShapeModule.h:139
Belle2::ECLShowerShapeModule::m_zernike_MVAidentifier_BWD
std::string m_zernike_MVAidentifier_BWD
Zernike moment MVA - BWD endcap weight-file.
Definition: ECLShowerShapeModule.h:128
Belle2::ECLShowerShapeModule::m_BRLthetaMin
const double m_BRLthetaMin
Minimum theta of barrel used for choosing which Zernike MVA to apply.
Definition: ECLShowerShapeModule.h:121
Belle2::ECLShowerShapeModule::initializeMVA
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.
Definition: ECLShowerShapeModule.cc:122
Belle2::ECLShowerShapeModule::m_secondMomentCorrectionArray
DBArray< ECLShowerShapeSecondMomentCorrection > m_secondMomentCorrectionArray
Shower shape corrections from DB.
Definition: ECLShowerShapeModule.h:216
Belle2::ECLShowerShapeModule::beginRun
virtual void beginRun() override
Begin run.
Definition: ECLShowerShapeModule.cc:162
Belle2::ECLShowerShapeModule::m_weightfile_representation_BRL
std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > m_weightfile_representation_BRL
Database pointer to the Database representation of the Zernike moment MVA weightfile for BRL.
Definition: ECLShowerShapeModule.h:132
Belle2::ECLShowerShapeModule::eclConnectedRegionArrayName
virtual const char * eclConnectedRegionArrayName() const
Default name ECLConnectedRegions.
Definition: ECLShowerShapeModule.h:244
Belle2::ECLShowerShapeModule::prepareSecondMomentCorrectionsCallback
void prepareSecondMomentCorrectionsCallback()
Prepare corrections for second moment Will be called whenever the m_secondMomentCorrectionArray get u...
Definition: ECLShowerShapeModule.cc:557
Belle2::ECLShowerShapeModule::m_zernike_MVAidentifier_BRL
std::string m_zernike_MVAidentifier_BRL
Zernike moment MVA - Barrel weight-file.
Definition: ECLShowerShapeModule.h:127
Belle2::ECLShowerShapeModule::eclShowerArrayName
virtual const char * eclShowerArrayName() const
We need names for the data objects to differentiate between PureCsI and default.
Definition: ECLShowerShapeModule.h:236
Belle2::DBObjPtr
Class for accessing objects in the database.
Definition: DBObjPtr.h:31
Belle2::ECLShowerShapeModule::ProjectedECLDigit::energy
double energy
weighted energy
Definition: ECLShowerShapeModule.h:103
Belle2::ECLShowerShapeModule::initializeMVAweightFiles
void initializeMVAweightFiles(const std::string &identifier, std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile >> &weightFileRepresentation)
initialize MVA weight files from DB
Definition: ECLShowerShapeModule.cc:93
Belle2::ECLShowerShapeModule
Class to perform the shower correction.
Definition: ECLShowerShapeModule.h:65
Belle2::ECLShowerShapeModule::m_avgCrystalDimension
double m_avgCrystalDimension
Average crystal dimension [cm].
Definition: ECLShowerShapeModule.h:119
Belle2::ECLShowerShapePureCsIModule::eclShowerArrayName
virtual const char * eclShowerArrayName() const override
PureCsI name ECLShowersPureCsI.
Definition: ECLShowerShapeModule.h:255
Belle2::ECLShowerShapeModule::m_zernike_useFarCrystals
bool m_zernike_useFarCrystals
Determines if to include or ignore crystals with rho > rho0 in perpendicular plane,...
Definition: ECLShowerShapeModule.h:118
Belle2::ECLShowerShapeModule::~ECLShowerShapeModule
~ECLShowerShapeModule()
Destructor.
Definition: ECLShowerShapeModule.cc:89
Belle2::ECLShowerShapeModule::ECLShowerShapeModule
ECLShowerShapeModule()
Constructor.
Definition: ECLShowerShapeModule.cc:56
Belle2::ECLShowerShapeModule::computeE9oE21
double computeE9oE21(const ECLShower &) const
Shower shape variable: E9oE21 The energy ratio is calculated taking the weighted 3x3 (=9) and the wei...
Definition: ECLShowerShapeModule.cc:517
Belle2::ECLShowerShapeModule::m_expert_BWD
std::unique_ptr< MVA::Expert > m_expert_BWD
Pointer to the current MVA Expert for BWD.
Definition: ECLShowerShapeModule.h:137
Belle2::ECLShowerShapeModule::m_neighbourMap9
std::unique_ptr< ECL::ECLNeighbours > m_neighbourMap9
Neighbour map 9 neighbours, for E9oE21 and E1oE9.
Definition: ECLShowerShapeModule.h:142
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ECLShowerShapeModule::computeLateralEnergy
double computeLateralEnergy(const std::vector< ProjectedECLDigit > &projectedDigits, const double avgCrystalDimension) const
Shower shape variable: Lateral energy.
Definition: ECLShowerShapeModule.cc:366
Belle2::ECLShowerShapeModule::m_zernike_n1_rho0
double m_zernike_n1_rho0
Scaling factor for radial distances in perpendicular plane, used in Zernike moment calculation for N1...
Definition: ECLShowerShapeModule.h:116
Belle2::ECLShowerShapeModule::eclCalDigitArrayName
virtual const char * eclCalDigitArrayName() const
Default name ECLCalDigits.
Definition: ECLShowerShapeModule.h:240
Belle2::Unit::deg
static const double deg
degree to radians
Definition: Unit.h:119
Belle2::ECLShowerShapeModule::computeAbsZernikeMoment
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.
Definition: ECLShowerShapeModule.cc:442
Belle2::ECLShowerShapeModule::m_zernike_n2_rho0
double m_zernike_n2_rho0
Scaling factor for radial distances in perpendicular plane, used in Zernike moment calculation for N2...
Definition: ECLShowerShapeModule.h:117
Belle2::ECLShowerShapeModule::m_numZernikeMVAvariables
const unsigned int m_numZernikeMVAvariables
number of variables expected in the Zernike MVA weightfile
Definition: ECLShowerShapeModule.h:124
Belle2::ECLShowerShapeModule::m_weightfile_representation_FWD
std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > m_weightfile_representation_FWD
Database pointer to the Database representation of the Zernike moment MVA weightfile for FWD.
Definition: ECLShowerShapeModule.h:130
Belle2::ECLShowerShapeModule::m_weightfile_representation_BWD
std::unique_ptr< DBObjPtr< DatabaseRepresentationOfWeightfile > > m_weightfile_representation_BWD
Database pointer to the Database representation of the Zernike moment MVA weightfile for BWD.
Definition: ECLShowerShapeModule.h:134
Belle2::ECLShowerShapeModule::projectECLDigits
std::vector< ProjectedECLDigit > projectECLDigits(const ECLShower &shower) const
Compute projections of the ECLCalDigits to the perpendicular plane.
Definition: ECLShowerShapeModule.cc:284
Belle2::ECLShowerShapeModule::m_BRLthetaMax
const double m_BRLthetaMax
Maximum theta of barrel used for choosing which Zernike MVA to apply.
Definition: ECLShowerShapeModule.h:122
Belle2::ECLShowerShapeModule::m_secondMomentCorrections
TGraph m_secondMomentCorrections[2][10]
TGraphs that hold the corrections.
Definition: ECLShowerShapeModule.h:220
Belle2::ECLShowerShapeModule::getSecondMomentCorrection
double getSecondMomentCorrection(const double theta, const double phi, const int hypothesis) const
Get corrections for second moment.
Definition: ECLShowerShapeModule.cc:584
Belle2::ECLShowerShapeModule::m_expert_FWD
std::unique_ptr< MVA::Expert > m_expert_FWD
Pointer to the current MVA Expert for FWD.
Definition: ECLShowerShapeModule.h:135
Belle2::ECLShowerShapeModule::m_zernike_MVAidentifier_FWD
std::string m_zernike_MVAidentifier_FWD
Zernike moment MVA - FWD endcap weight-file.
Definition: ECLShowerShapeModule.h:126
Belle2::ECLShowerShapeModule::terminate
virtual void terminate() override
Terminate.
Definition: ECLShowerShapeModule.cc:361
Belle2::ECLShowerShapeModule::ProjectedECLDigit::alpha
double alpha
polar angel
Definition: ECLShowerShapeModule.h:109
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::ECLShowerShapeModule::c_phiType
@ c_phiType
type of phi identifier
Definition: ECLShowerShapeModule.h:72
Belle2::ECLShowerShapeModule::Rnm
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
Definition: ECLShowerShapeModule.cc:407
Belle2::ECLShowerShapePureCsIModule
The very same module but for PureCsI.
Definition: ECLShowerShapeModule.h:251
Belle2::ECLShowerShapeModule::m_eclConnectedRegions
StoreArray< ECLConnectedRegion > m_eclConnectedRegions
StoreArray ECLConnectedRegion.
Definition: ECLShowerShapeModule.h:113
Belle2::ECLShower
Class to store ECL Showers.
Definition: ECLShower.h:42