Belle II Software  release-05-02-19
ECLCluster.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Torben Ferber (ferber@physics.ubc.ca) *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 /* External headers. */
12 #include <TMatrixD.h>
13 #include <bitset>
14 
15 /* Belle2 headers. */
16 #include <mdst/dataobjects/ECLCluster.h>
17 #include <framework/logging/Logger.h>
18 
19 using namespace Belle2;
20 
21 double ECLCluster::getEnergy(const ECLCluster::EHypothesisBit& hypothesis) const
22 {
23  // check if cluster has the requested hypothesis
24  if (!hasHypothesis(hypothesis)) {
25  B2ERROR("This cluster does not support the requested hypothesis,"
26  << LogVar(" it has the nPhotons hypothesis (y/n = 1/0): ", hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons))
27  << LogVar(" and it has the neutralHadron hypothesis (y/n = 1/0): ", hasHypothesis(ECLCluster::EHypothesisBit::c_neutralHadron))
28  << LogVar(" You requested the hypothesis bitmask: ", std::bitset<16>(static_cast<unsigned short>(hypothesis)).to_string()));
29  return std::numeric_limits<double>::quiet_NaN();
30  }
31 
32  // return the sensible answers
33  if (hypothesis == ECLCluster::EHypothesisBit::c_nPhotons) return exp(m_logEnergy);
34  else if (hypothesis == ECLCluster::EHypothesisBit::c_neutralHadron) return exp(m_logEnergyRaw);
35  else {
36  // throw error if the cluster is not supported
37  B2ERROR("EHypothesisBit is not supported yet: " << static_cast<unsigned short>(hypothesis));
38  return std::numeric_limits<double>::quiet_NaN();
39  };
40 }
41 
43 {
44  const double cluster_x = getR() * sin(getTheta()) * cos(getPhi());
45  const double cluster_y = getR() * sin(getTheta()) * sin(getPhi());
46  const double cluster_z = getR() * cos(getTheta());
47  return TVector3(cluster_x, cluster_y, cluster_z);
48 }
49 
51 {
52  TMatrixDSym covmatecl(3);
53  covmatecl(0, 0) = m_sqrtcovmat_00 * m_sqrtcovmat_00;
54  covmatecl(1, 0) = m_covmat_10;
55  covmatecl(1, 1) = m_sqrtcovmat_11 * m_sqrtcovmat_11;
56  covmatecl(2, 0) = m_covmat_20;
57  covmatecl(2, 1) = m_covmat_21;
58  covmatecl(2, 2) = m_sqrtcovmat_22 * m_sqrtcovmat_22;
59 
60  //make symmetric
61  for (int i = 0; i < 3; i++)
62  for (int j = 0; j < i ; j++)
63  covmatecl(j, i) = covmatecl(i, j);
64  return covmatecl;
65 }
66 
67 
69 {
70  const double theta = getTheta();
71 
72  if (theta < 0.2164208) return 0; // < 12.4deg
73  if (theta < 0.5480334) return 1; // < 31.4deg
74  if (theta < 0.561996) return 11; // < 32.2deg
75  if (theta < 2.2462387) return 2; // < 128.7
76  if (theta < 2.2811453) return 13; // < 130.7
77  if (theta < 2.7070057) return 3; // < 155.1
78  else return 0;
79 }
80 
82 {
83  const int crid = getConnectedRegionId();
84  const int showerid = getClusterId();
85 #pragma GCC diagnostic push
86 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
87  const int hypoid = getHypothesisId();
88 #pragma GCC diagnostic pop
89 
90  return 100000 * crid + 1000 * hypoid + showerid;
91 }
Belle2::ECLCluster::getClusterPosition
TVector3 getClusterPosition() const
Return TVector3 on cluster position (x,y,z)
Definition: ECLCluster.cc:42
Belle2::ECLCluster::EHypothesisBit
EHypothesisBit
The hypothesis bits for this ECLCluster (Connected region (CR) is split using this hypothesis.
Definition: ECLCluster.h:43
Belle2::ECLCluster::getTheta
double getTheta() const
Return Corrected Theta of Shower (radian).
Definition: ECLCluster.h:326
Belle2::ECLCluster::getPhi
double getPhi() const
Return Corrected Phi of Shower (radian).
Definition: ECLCluster.h:323
Belle2::ECLCluster::EHypothesisBit::c_nPhotons
@ c_nPhotons
CR is split into n photons (N1)
Belle2::ECLCluster::getHypothesisId
int getHypothesisId() const
Return hypothesis id.
Definition: ECLCluster.h:266
Belle2::ECLCluster::getR
double getR() const
Return R.
Definition: ECLCluster.h:329
Belle2::ECLCluster::getUniqueId
int getUniqueId() const
Return (pseudo) unique Id based on CRId, ShowerId and HypothesisID.
Definition: ECLCluster.cc:81
Belle2::ECLCluster::hasHypothesis
bool hasHypothesis(EHypothesisBit bitmask) const
Return if specific hypothesis bit is set.
Definition: ECLCluster.h:374
Belle2::ECLCluster::getEnergy
double getEnergy(const EHypothesisBit &hypothesis) const
Return Energy (GeV).
Definition: ECLCluster.cc:21
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
LogVar
Class to store variables with their name which were sent to the logging service.
Definition: LogVariableStream.h:24
Belle2::ECLCluster::m_sqrtcovmat_22
Double32_t m_sqrtcovmat_22
Covariance matrix 22, sigma_theta, between 0 and 50 mrad.
Definition: ECLCluster.h:433
Belle2::ECLCluster::EHypothesisBit::c_neutralHadron
@ c_neutralHadron
CR is reconstructed as a neutral hadron (N2)
Belle2::ECLCluster::m_sqrtcovmat_00
Double32_t m_sqrtcovmat_00
Covariance entry 00 sigma_E (1% to 25% between 10 MeV and 8 GeV)
Definition: ECLCluster.h:418
Belle2::ECLCluster::m_covmat_21
Double32_t m_covmat_21
Covariance matrix 21, not used yet.
Definition: ECLCluster.h:430
Belle2::ECLCluster::m_logEnergy
Double32_t m_logEnergy
< Log.
Definition: ECLCluster.h:481
Belle2::ECLCluster::m_covmat_20
Double32_t m_covmat_20
Covariance matrix 20, not used yet.
Definition: ECLCluster.h:427
Belle2::ECLCluster::getCovarianceMatrix3x3
TMatrixDSym getCovarianceMatrix3x3() const
Return TMatrixDsym 3x3 covariance matrix for E, Phi and Theta.
Definition: ECLCluster.cc:50
Belle2::ECLCluster::getDetectorRegion
int getDetectorRegion() const
Return detector region: 0: below acceptance, 1: FWD, 2: BRL, 3: BWD, 11: FWDGAP, 13: BWDGAP.
Definition: ECLCluster.cc:68
Belle2::ECLCluster::m_covmat_10
Double32_t m_covmat_10
Covariance matrix 10, not used yet.
Definition: ECLCluster.h:421
Belle2::ECLCluster::getConnectedRegionId
int getConnectedRegionId() const
Return connected region id.
Definition: ECLCluster.h:262
Belle2::ECLCluster::m_sqrtcovmat_11
Double32_t m_sqrtcovmat_11
Covariance matrix 11, sigma_phi, between 0 and 50 mrad.
Definition: ECLCluster.h:424
Belle2::ECLCluster::getClusterId
int getClusterId() const
Return cluster id.
Definition: ECLCluster.h:274
Belle2::ECLCluster::m_logEnergyRaw
Double32_t m_logEnergyRaw
Log.
Definition: ECLCluster.h:484