Belle II Software  release-08-01-10
eclShower.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 /* ECL headers. */
10 #include <ecl/dataobjects/ECLShower.h>
11 
12 /* Gtest headers. */
13 #include <gtest/gtest.h>
14 
15 using namespace std;
16 
17 namespace Belle2 {
24  class ECLShowerTest : public ::testing::Test {
25  };
26 
28  TEST_F(ECLShowerTest, Constructors)
29  {
30  ECLShower myECLShower;
31  EXPECT_EQ(myECLShower.getIsTrack(), 0);
32 
33  EXPECT_EQ(myECLShower.getStatus(), 0);
34  EXPECT_EQ(myECLShower.getShowerId(), 0);
35  EXPECT_EQ(myECLShower.getConnectedRegionId(), 0);
36  EXPECT_EQ(myECLShower.getHypothesisId(), 0);
37  EXPECT_EQ(myECLShower.getEnergy(), 0);
38  EXPECT_EQ(myECLShower.getTheta(), 0);
39  EXPECT_EQ(myECLShower.getPhi(), 0);
40  EXPECT_EQ(myECLShower.getR(), 0);
41  EXPECT_EQ(myECLShower.getUncertaintyEnergy(), 0);
42  EXPECT_EQ(myECLShower.getUncertaintyTheta(), 0);
43  EXPECT_EQ(myECLShower.getUncertaintyPhi(), 0);
44  EXPECT_EQ(myECLShower.getTime(), 0);
45  EXPECT_EQ(myECLShower.getDeltaTime99(), 0);
46  EXPECT_EQ(myECLShower.getEnergyHighestCrystal(), 0);
47  EXPECT_EQ(myECLShower.getLateralEnergy(), 0);
48  EXPECT_EQ(myECLShower.getMinTrkDistance(), 0);
49  EXPECT_EQ(myECLShower.getTrkDepth(), 0);
50  EXPECT_EQ(myECLShower.getShowerDepth(), 0);
51  EXPECT_EQ(myECLShower.getNumberOfCrystals(), 0);
52  EXPECT_EQ(myECLShower.getAbsZernikeMoment(4, 0), 0);
53  EXPECT_EQ(myECLShower.getAbsZernikeMoment(5, 1), 0);
54  EXPECT_EQ(myECLShower.getZernikeMVA(), 0);
55  EXPECT_EQ(myECLShower.getSecondMoment(), 0);
56  EXPECT_EQ(myECLShower.getE1oE9(), 0);
57  EXPECT_EQ(myECLShower.getE9oE21(), 0);
58 
59  double errorArray[6];
60  myECLShower.getCovarianceMatrixAsArray(errorArray);
61  EXPECT_EQ(errorArray[0], 0);
62  EXPECT_EQ(errorArray[1], 0);
63  EXPECT_EQ(errorArray[2], 0);
64  EXPECT_EQ(errorArray[3], 0);
65  EXPECT_EQ(errorArray[4], 0);
66  EXPECT_EQ(errorArray[5], 0);
67 
68  ROOT::Math::XYZVector momentum(myECLShower.getMomentum());
69  EXPECT_EQ(momentum.X(), 0);
70  EXPECT_EQ(momentum.Y(), 0);
71  EXPECT_EQ(momentum.Z(), 0);
72  } // Testcases for Something
73 
75  TEST_F(ECLShowerTest, SettersAndGetters)
76  {
77  const bool isTrk = true;
78 
79  const int status = 5;
80  const int showerId = 6;
81  const int connectedRegionId = 7;
82  const int hypothesisId = 8;
83 
84  const double energy = 1.1;
85  const double theta = 1.2;
86  const double phi = 1.3;
87  const double r = 1.4;
88  double error[6] = {2.1, 2.2, 2.3, 2.4, 2.5, 2.6};
89  const double time = 1.5;
90  const double timeResolution = 1.6;
91  const double highestEnergy = 1.7;
92  const double lateralEnergy = 1.8;
93  const double minTrkDistance = 1.9;
94  const double trkDepth = 4.1;
95  const double showerDepth = 3.1;
96  const double NofCrystals = 3.2;
97  const double absZernike40 = 1.1;
98  const double absZernike51 = 0.1;
99  const double zernikeMVA = 0.5;
100  const double secondMoment = 5.1;
101  const double E1oE9 = 3.8;
102  const double E9oE21 = 3.9;
103 
104  ECLShower myECLShower;
105  myECLShower.setIsTrack(isTrk);
106  myECLShower.setStatus(status);
107  myECLShower.setShowerId(showerId);
108  myECLShower.setConnectedRegionId(connectedRegionId);
109  myECLShower.setHypothesisId(hypothesisId);
110  myECLShower.setEnergy(energy);
111  myECLShower.setTheta(theta);
112  myECLShower.setPhi(phi);
113  myECLShower.setR(r);
114  myECLShower.setCovarianceMatrix(error);
115  myECLShower.setTime(time);
116  myECLShower.setDeltaTime99(timeResolution);
117  myECLShower.setEnergyHighestCrystal(highestEnergy);
118  myECLShower.setLateralEnergy(lateralEnergy);
119  myECLShower.setMinTrkDistance(minTrkDistance);
120  myECLShower.setTrkDepth(trkDepth);
121  myECLShower.setShowerDepth(showerDepth);
122  myECLShower.setNumberOfCrystals(NofCrystals);
123  myECLShower.setAbsZernikeMoment(4, 0, absZernike40);
124  myECLShower.setAbsZernikeMoment(5, 1, absZernike51);
125  myECLShower.setZernikeMVA(zernikeMVA);
126  myECLShower.setSecondMoment(secondMoment);
127  myECLShower.setE1oE9(E1oE9);
128  myECLShower.setE9oE21(E9oE21);
129 
130  EXPECT_EQ(myECLShower.getIsTrack(), isTrk);
131  EXPECT_EQ(myECLShower.getStatus(), status);
132  EXPECT_EQ(myECLShower.getShowerId(), showerId);
133  EXPECT_EQ(myECLShower.getConnectedRegionId(), connectedRegionId);
134  EXPECT_EQ(myECLShower.getHypothesisId(), hypothesisId);
135  EXPECT_EQ(myECLShower.getEnergy(), energy);
136  EXPECT_EQ(myECLShower.getTheta(), theta);
137  EXPECT_EQ(myECLShower.getPhi(), phi);
138  EXPECT_EQ(myECLShower.getUncertaintyEnergy(), sqrt(error[0]));
139  EXPECT_EQ(myECLShower.getUncertaintyTheta(), sqrt(error[5]));
140  EXPECT_EQ(myECLShower.getUncertaintyPhi(), sqrt(error[2]));
141  EXPECT_EQ(myECLShower.getTime(), time);
142  EXPECT_EQ(myECLShower.getDeltaTime99(), timeResolution);
143  EXPECT_EQ(myECLShower.getEnergyHighestCrystal(), highestEnergy);
144  EXPECT_EQ(myECLShower.getLateralEnergy(), lateralEnergy);
145  EXPECT_EQ(myECLShower.getMinTrkDistance(), minTrkDistance);
146  EXPECT_EQ(myECLShower.getTrkDepth(), trkDepth);
147  EXPECT_EQ(myECLShower.getShowerDepth(), showerDepth);
148  EXPECT_EQ(myECLShower.getMinTrkDistance(), minTrkDistance);
149  EXPECT_EQ(myECLShower.getTrkDepth(), trkDepth);
150  EXPECT_EQ(myECLShower.getNumberOfCrystals(), NofCrystals);
151  EXPECT_EQ(myECLShower.getAbsZernikeMoment(4, 0), absZernike40);
152  EXPECT_EQ(myECLShower.getAbsZernikeMoment(5, 1), absZernike51);
153  EXPECT_EQ(myECLShower.getZernikeMVA(), zernikeMVA);
154  EXPECT_EQ(myECLShower.getSecondMoment(), secondMoment);
155  EXPECT_EQ(myECLShower.getE1oE9(), E1oE9);
156  EXPECT_EQ(myECLShower.getE9oE21(), E9oE21);
157 
158 
159  double errorArray[6];
160  myECLShower.getCovarianceMatrixAsArray(errorArray);
161  EXPECT_EQ(errorArray[0], error[0]);
162  EXPECT_EQ(errorArray[1], error[1]);
163  EXPECT_EQ(errorArray[2], error[2]);
164  EXPECT_EQ(errorArray[3], error[3]);
165  EXPECT_EQ(errorArray[4], error[4]);
166  EXPECT_EQ(errorArray[5], error[5]);
167 
168  ROOT::Math::XYZVector momentum(myECLShower.getMomentum());
169  EXPECT_FLOAT_EQ(momentum.X(), energy * sin(theta) * cos(phi));
170  EXPECT_FLOAT_EQ(momentum.Y(), energy * sin(theta) * sin(phi));
171  EXPECT_FLOAT_EQ(momentum.Z(), energy * cos(theta));
172  } // Testcases for Setters and Getters
173 
175 } // namespace
Set up a few arrays and objects in the datastore.
Definition: eclShower.cc:24
Class to store ECL Showers.
Definition: ECLShower.h:30
int getStatus() const
Get Status.
Definition: ECLShower.h:262
void setE9oE21(double E9oE21)
Set energy ration E9 over E21.
Definition: ECLShower.h:211
void setLateralEnergy(double lateralEnergy)
Set Lateral Energy.
Definition: ECLShower.h:175
void setShowerId(int ShowerId)
Set Shower ID.
Definition: ECLShower.h:115
double getAbsZernikeMoment(unsigned int n, unsigned int m) const
Get absolute value of Zernike Moment nm.
Definition: ECLShower.h:377
void setEnergy(double Energy)
Set Energy.
Definition: ECLShower.h:131
void setPhi(double Phi)
Set Phi (rad)
Definition: ECLShower.h:143
int getHypothesisId() const
Get Hypothesis Id.
Definition: ECLShower.h:277
void setConnectedRegionId(int connectedRegionId)
Set Connected region ID.
Definition: ECLShower.h:119
void setNumberOfCrystals(double nofCrystals)
Set sum of weights of crystals.
Definition: ECLShower.h:191
void setEnergyHighestCrystal(double HighestEnergy)
Set Highest Energy.
Definition: ECLShower.h:171
double getPhi() const
Get Phi.
Definition: ECLShower.h:302
double getLateralEnergy() const
Get Lateral Energy in Shower.
Definition: ECLShower.h:352
double getE1oE9() const
Get energy ratio E1oE9.
Definition: ECLShower.h:392
void setShowerDepth(double showerDepth)
Set path on the average cluster direction.
Definition: ECLShower.h:187
int getShowerId() const
Get Shower Id.
Definition: ECLShower.h:267
double getEnergy() const
Get Energy.
Definition: ECLShower.h:287
void getCovarianceMatrixAsArray(double covArray[6]) const
Get Error Array for Energy->[0], Phi->[2], Theta->[5].
Definition: ECLShower.h:312
void setSecondMoment(double secondMoment)
Set second moment.
Definition: ECLShower.h:203
double getShowerDepth() const
path on track extrapolation to POCA to average cluster direction
Definition: ECLShower.h:367
void setCovarianceMatrix(double covArray[6])
Set symmetric Error Array(3x3) for [0]->Error on Energy [2]->Error on Phi [5]->Error on Theta.
Definition: ECLShower.h:154
int getConnectedRegionId() const
Get Connected region Id.
Definition: ECLShower.h:272
double getR() const
Get R.
Definition: ECLShower.h:307
void setHypothesisId(int hypothesisId)
Set Hypothesis identifier.
Definition: ECLShower.h:123
void setTheta(double Theta)
Set Theta (rad)
Definition: ECLShower.h:139
double getUncertaintyTheta() const
Get Error of theta.
Definition: ECLShower.h:327
void setIsTrack(bool val)
Set Match with Track.
Definition: ECLShower.h:107
double getE9oE21() const
Get energy ratio E9oE21.
Definition: ECLShower.h:397
void setTrkDepth(double trkDepth)
Set path on track extrapolation line to POCA to average cluster direction.
Definition: ECLShower.h:183
void setAbsZernikeMoment(unsigned int n, unsigned int m, double absZernikeMoment)
Set absolute value of Zernike Moment nm, for nm between 10 and 55.
Definition: ECLShower.h:195
void setR(double R)
Set R.
Definition: ECLShower.h:147
void setDeltaTime99(double TimeReso)
Set Time Resolution.
Definition: ECLShower.h:167
double getUncertaintyEnergy() const
Get Error of Energy.
Definition: ECLShower.h:322
ROOT::Math::XYZVector getMomentum() const
The method to get return ROOT::Math::XYZVector Momentum.
Definition: ECLShower.h:452
double getTrkDepth() const
path on track extrapolation to POCA to average cluster direction
Definition: ECLShower.h:362
double getMinTrkDistance() const
Get distance to closest Track.
Definition: ECLShower.h:357
double getNumberOfCrystals() const
Get NofCrystals.
Definition: ECLShower.h:372
double getEnergyHighestCrystal() const
Get Highest Energy in Shower.
Definition: ECLShower.h:347
double getZernikeMVA() const
Get Zernike MVA.
Definition: ECLShower.h:382
bool getIsTrack() const
Get if matched with a Track.
Definition: ECLShower.h:257
double getUncertaintyPhi() const
Get Error of phi.
Definition: ECLShower.h:332
void setTime(double Time)
Set Time.
Definition: ECLShower.h:163
void setE1oE9(double E1oE9)
Set energy ration E1 over E9.
Definition: ECLShower.h:207
void setStatus(int Status)
Set Status.
Definition: ECLShower.h:111
double getSecondMoment() const
Get second moment.
Definition: ECLShower.h:387
void setZernikeMVA(double zernikeMVA)
SetZernike MVA value.
Definition: ECLShower.h:199
double getTheta() const
Get Theta.
Definition: ECLShower.h:297
double getDeltaTime99() const
Get Time Resolution.
Definition: ECLShower.h:342
void setMinTrkDistance(double dist)
Set Distance to closest track.
Definition: ECLShower.h:179
double getTime() const
Get Time.
Definition: ECLShower.h:337
TEST_F(ECLShowerTest, SettersAndGetters)
Test Setters and Getter.
Definition: eclShower.cc:75
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.