Belle II Software development
ECLCovarianceMatrixModule.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// THIS MODULE
10#include <ecl/modules/eclCovarianceMatrix/ECLCovarianceMatrixModule.h>
11
12// ROOT
13#include "TMath.h"
14
15// MDST
16#include <mdst/dataobjects/EventLevelClusteringInfo.h>
17
18// ECL
19#include <ecl/dataobjects/ECLShower.h>
20
21// NAMESPACES
22using namespace Belle2;
23
24//-----------------------------------------------------------------
25// Register the Module
26//-----------------------------------------------------------------
27REG_MODULE(ECLCovarianceMatrix);
28REG_MODULE(ECLCovarianceMatrixPureCsI);
29
30//-----------------------------------------------------------------
31// Implementation
32//-----------------------------------------------------------------
34 m_eclShowers(eclShowerArrayName()),
35 m_eventLevelClusteringInfo(eventLevelClusteringInfoName())
36{
37 // Set description
38 setDescription("ECLCovarianceMatrix: Sets the ECL photon shower covariance matrix.");
40
41}
42
44{
45}
46
48{
49 m_eclShowers.isRequired(eclShowerArrayName());
51}
52
54{
55 // TODO: callback
56 ;
57}
58
60{
61
62 // Get the event background level
63 const int bkgdcount = m_eventLevelClusteringInfo->getNECLCalDigitsOutOfTime();
64 double background = 0.0; // from out of time digit counting
65 if (m_fullBkgdCount > 0) {
66 background = static_cast<double>(bkgdcount) / m_fullBkgdCount;
67 }
68
69 // loop over all ECLShowers
70 for (auto& eclShower : m_eclShowers) {
71
72 // Only calculate for photon showers
73 if (eclShower.getHypothesisId() == ECLShower::c_nPhotons) {
74
75 const double energy = eclShower.getEnergy();
76
77 // 1/energy
78 double invEnergy = 0;
79 if (energy > 0.) invEnergy = 1. / energy;
80
81 //1/energy^0.5
82 double invRoot2Energy = 0;
83 if (energy > 0.) invRoot2Energy = 1. / TMath::Power(energy, 0.5);
84
85 //1/energy^0.25
86 double invRoot4Energy = 0;
87 if (energy > 0.) invRoot4Energy = 1. / TMath::Power(energy, 0.25);
88
89 int detregion = eclShower.getDetectorRegion(); // FWD: 1, Barrel: 2, BWD: 3
90 if (detregion == 11 or detregion == 13) detregion = 2;
91
92 double sigmaEnergy = 0.;
93 double sigmaTheta = 0.;
94 double sigmaPhi = 0.;
95
96 // three background levels, three detector regions, energy, theta and phi (needs to be revisited soon!)
97 if (detregion == 1 and background < 0.05) {
98 if (energy <= 0.022) {sigmaEnergy = energy * (0.0449188); }
99 else {sigmaEnergy = energy * (-0.0912379 * invEnergy + 1.91849 * invRoot2Energy + -2.82169 * invRoot4Energy + 3.03119) / 100.;}
100 } else if (detregion == 1 and background <= 0.3) {
101 if (energy <= 0.022) {sigmaEnergy = energy * (0.100769); }
102 else {sigmaEnergy = energy * (-0.0725928 * invEnergy + 3.4685 * invRoot2Energy + -5.44127 * invRoot4Energy + 4.12045) / 100.;}
103 } else if (detregion == 1 and background > 0.3) {
104 if (energy <= 0.022) {sigmaEnergy = energy * (0.148462); }
105 else {sigmaEnergy = energy * (-0.239931 * invEnergy + 6.94958 * invRoot2Energy + -10.4085 * invRoot4Energy + 5.92412) / 100.;}
106 }
107
108 if (detregion == 1 and background < 0.05) {
109 if (energy <= 0.0289609) { sigmaTheta = 1e-3 * (6.4008);}
110 else {sigmaTheta = 1e-3 * (-0.110397 * invEnergy + 0.753603 * invRoot2Energy + 2.63652 * invRoot4Energy + -0.606703);}
111 } else if (detregion == 1 and background <= 0.3) {
112 if (energy <= 0.0274562) { sigmaTheta = 1e-3 * (7.39868);}
113 else {sigmaTheta = 1e-3 * (-0.207278 * invEnergy + 2.68616 * invRoot2Energy + -0.905487 * invRoot4Energy + 0.961485);}
114 } else if (detregion == 1 and background > 0.3) {
115 if (energy <= 0.022) { sigmaTheta = 1e-3 * (8.83505);}
116 else {sigmaTheta = 1e-3 * (-0.160921 * invEnergy + 2.35311 * invRoot2Energy + -0.107975 * invRoot4Energy + 0.565367);}
117 }
118
119 if (detregion == 1 and background < 0.05) {
120 if (energy <= 0.0391279) {sigmaPhi = 1e-3 * (15.4147);}
121 else {sigmaPhi = 1e-3 * (-0.35934 * invEnergy + 2.01807 * invRoot2Energy + 7.26313 * invRoot4Energy + -1.93438);}
122 } else if (detregion == 1 and background <= 0.3) {
123 if (energy <= 0.022) {sigmaPhi = 1e-3 * (18.1096);}
124 else {sigmaPhi = 1e-3 * (-0.178258 * invEnergy + 1.39155 * invRoot2Energy + 6.97462 * invRoot4Energy + -1.2795);}
125 } else if (detregion == 1 and background > 0.3) {
126 if (energy <= 0.0224565) {sigmaPhi = 1e-3 * (20.1605);}
127 else {sigmaPhi = 1e-3 * (-0.344617 * invEnergy + 3.80823 * invRoot2Energy + 4.08729 * invRoot4Energy + -0.464714);}
128 }
129
130 if (detregion == 2 and background < 0.05) {
131 if (energy <= 0.022) {sigmaEnergy = energy * (0.0466552); }
132 else {sigmaEnergy = energy * (-0.0473491 * invEnergy + 1.02015 * invRoot2Energy + -0.705164 * invRoot4Energy + 1.77086) / 100.;}
133 } else if (detregion == 2 and background <= 0.3) {
134 if (energy <= 0.022) {sigmaEnergy = energy * (0.112299); }
135 else {sigmaEnergy = energy * (0.0469588 * invEnergy + 1.81959 * invRoot2Energy + -2.13666 * invRoot4Energy + 2.37568) / 100.;}
136 } else if (detregion == 2 and background > 0.3) {
137 if (energy <= 0.022) {sigmaEnergy = energy * (0.164881); }
138 else {sigmaEnergy = energy * (-0.267069 * invEnergy + 7.6176 * invRoot2Energy + -11.0341 * invRoot4Energy + 5.9203) / 100.;}
139 }
140
141 if (detregion == 2 and background < 0.05) {
142 if (energy <= 0.0309077) { sigmaTheta = 1e-3 * (9.31098);}
143 else {sigmaTheta = 1e-3 * (-0.221073 * invEnergy + 2.19876 * invRoot2Energy + 1.50833 * invRoot4Energy + 0.359609);}
144 } else if (detregion == 2 and background <= 0.3) {
145 if (energy <= 0.022) { sigmaTheta = 1e-3 * (11.6166);}
146 else {sigmaTheta = 1e-3 * (-0.126603 * invEnergy + 1.81898 * invRoot2Energy + 1.85132 * invRoot4Energy + 0.300728);}
147 } else if (detregion == 2 and background > 0.3) {
148 if (energy <= 0.022) { sigmaTheta = 1e-3 * (13.159);}
149 else {sigmaTheta = 1e-3 * (-0.316561 * invEnergy + 4.94686 * invRoot2Energy + -3.12199 * invRoot4Energy + 2.30275);}
150 }
151
152 if (detregion == 2 and background < 0.05) {
153 if (energy <= 0.0381178) {sigmaPhi = 1e-3 * (10.7661);}
154 else {sigmaPhi = 1e-3 * (-0.21842 * invEnergy + 0.648976 * invRoot2Energy + 7.1901 * invRoot4Energy + -3.10025);}
155 } else if (detregion == 2 and background <= 0.3) {
156 if (energy <= 0.022237) {sigmaPhi = 1e-3 * (12.6804);}
157 else {sigmaPhi = 1e-3 * (-0.141507 * invEnergy + 0.488293 * invRoot2Energy + 7.30055 * invRoot4Energy + -3.13591);}
158 } else if (detregion == 2 and background > 0.3) {
159 if (energy <= 0.024905) {sigmaPhi = 1e-3 * (14.8726);}
160 else {sigmaPhi = 1e-3 * (-0.323752 * invEnergy + 3.60933 * invRoot2Energy + 2.48526 * invRoot4Energy + -1.25493);}
161 }
162
163 if (detregion == 3 and background < 0.05) {
164 if (energy <= 0.022) {sigmaEnergy = energy * (0.0466662); }
165 else {sigmaEnergy = energy * (-0.106729 * invEnergy + 2.38163 * invRoot2Energy + -4.11299 * invRoot4Energy + 4.14056) / 100.;}
166 } else if (detregion == 3 and background <= 0.3) {
167 if (energy <= 0.022) {sigmaEnergy = energy * (0.128851); }
168 else {sigmaEnergy = energy * (-0.204362 * invEnergy + 6.43 * invRoot2Energy + -10.8673 * invRoot4Energy + 7.04059) / 100.;}
169 } else if (detregion == 3 and background > 0.3) {
170 if (energy <= 0.022) {sigmaEnergy = energy * (0.255153); }
171 else {sigmaEnergy = energy * (-0.316245 * invEnergy + 11.5211 * invRoot2Energy + -18.3626 * invRoot4Energy + 9.89422) / 100.;}
172 }
173
174 if (detregion == 3 and background < 0.05) {
175 if (energy <= 0.0318079) { sigmaTheta = 1e-3 * (10.4446);}
176 else {sigmaTheta = 1e-3 * (-0.295827 * invEnergy + 3.37748 * invRoot2Energy + -0.284446 * invRoot4Energy + 1.48098);}
177 } else if (detregion == 3 and background <= 0.3) {
178 if (energy <= 0.022) { sigmaTheta = 1e-3 * (13.828);}
179 else {sigmaTheta = 1e-3 * (-0.252479 * invEnergy + 4.18833 * invRoot2Energy + -2.04822 * invRoot4Energy + 2.38486);}
180 } else if (detregion == 3 and background > 0.3) {
181 if (energy <= 0.022) { sigmaTheta = 1e-3 * (17.0354);}
182 else {sigmaTheta = 1e-3 * (-0.420215 * invEnergy + 7.08904 * invRoot2Energy + -5.88269 * invRoot4Energy + 3.61643);}
183 }
184
185 if (detregion == 3 and background < 0.05) {
186 if (energy <= 0.022) {sigmaPhi = 1e-3 * (15.129);}
187 else {sigmaPhi = 1e-3 * (-0.0534441 * invEnergy + -1.72466 * invRoot2Energy + 12.8625 * invRoot4Energy + -4.21203);}
188 } else if (detregion == 3 and background <= 0.3) {
189 if (energy <= 0.022) {sigmaPhi = 1e-3 * (20.1408);}
190 else {sigmaPhi = 1e-3 * (0.0869293 * invEnergy + -1.93352 * invRoot2Energy + 12.8105 * invRoot4Energy + -4.03756);}
191 } else if (detregion == 3 and background > 0.3) {
192 if (energy <= 0.022) {sigmaPhi = 1e-3 * (23.2771);}
193 else {sigmaPhi = 1e-3 * (-0.439611 * invEnergy + 5.74196 * invRoot2Energy + 1.76693 * invRoot4Energy + -0.0407866);}
194 }
195
196 B2DEBUG(175, "energy=" << energy << ", detector region=" << detregion);
197 B2DEBUG(175, "sigmaEnergy=" << sigmaEnergy << ", sigmaPhi=" << sigmaPhi << ", sigmaTheta=" << sigmaTheta);
198
199 double covMatrix[6] = {sigmaEnergy * sigmaEnergy, 0.0, sigmaPhi * sigmaPhi, 0.0, 0.0, sigmaTheta * sigmaTheta};
200 eclShower.setCovarianceMatrix(covMatrix);
201 }
202 }
203}
204
206{
207 ;
208}
209
211{
212 ;
213}
virtual const char * eclShowerArrayName() const
Default name ECLShowers.
virtual const char * eventLevelClusteringInfoName() const
Name to be used for default option: EventLevelClusteringInfo.
const double m_fullBkgdCount
Nominal Background at BGx1.0 (MC12)
StoreArray< ECLShower > m_eclShowers
Store array: ECLShower.
virtual void initialize() override
Initialize.
virtual void endRun() override
End run.
virtual void terminate() override
Terminate.
virtual void beginRun() override
Begin run.
StoreObjPtr< EventLevelClusteringInfo > m_eventLevelClusteringInfo
Store object pointer: EventLevelClusteringInfo.
@ c_nPhotons
CR is split into n photons (N1)
Definition: ECLShower.h:42
Base class for Modules.
Definition: Module.h:72
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
@ 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
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.