Project
Loading...
Searching...
No Matches
testTPCGEMAmplification.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#define BOOST_TEST_MODULE Test TPC GEMAmplification
17#define BOOST_TEST_MAIN
18#define BOOST_TEST_DYN_LINK
19#include <boost/test/unit_test.hpp>
24
25#include "TH1D.h"
26#include "TF1.h"
27
28namespace o2
29{
30namespace tpc
31{
32
36BOOST_AUTO_TEST_CASE(GEMamplification_test)
37{
38 auto& cdb = CDBInterface::instance();
39 cdb.setUseDefaults();
40 auto& gemParam = ParameterGEM::Instance();
42 TH1D hTest("hTest", "", 10000, 0, 1000000);
43 TF1 gaus("gaus", "gaus");
44
45 const int nEleIn = 158;
46
47 for (int i = 0; i < 100000; ++i) {
48 hTest.Fill(gemStack.getStackAmplification(nEleIn));
49 }
50
51 hTest.Fit("gaus", "Q0");
52 float energyResolution = gaus.GetParameter(2) / gaus.GetParameter(1) * 100.f;
53
56 BOOST_CHECK_CLOSE(gaus.GetParameter(1) / static_cast<float>(nEleIn), (gemParam.getEffectiveGain(0) * gemParam.getEffectiveGain(1) * gemParam.getEffectiveGain(2) * gemParam.getEffectiveGain(3)), 20.f);
59 BOOST_CHECK_CLOSE(energyResolution, 12.1, 5);
60}
64BOOST_AUTO_TEST_CASE(GEMamplification_effective_test)
65{
66 auto& cdb = CDBInterface::instance();
67 cdb.setUseDefaults();
68 auto& gemParam = ParameterGEM::Instance();
70 TH1D hTest("hTest", "", 100000, 0, 1000000);
71 TF1 gaus("gaus", "gaus");
72
73 const int nEleIn = 158;
74
75 for (int i = 0; i < 500000; ++i) {
76 hTest.Fill(gemStack.getEffectiveStackAmplification(nEleIn));
77 }
78
79 hTest.Fit("gaus", "Q0");
80 float energyResolution = gaus.GetParameter(2) / gaus.GetParameter(1) * 100.f;
81
83 BOOST_CHECK_CLOSE(gaus.GetParameter(1) / static_cast<float>(nEleIn), (gemParam.TotalGainStack), 1.f);
86 BOOST_CHECK_CLOSE(energyResolution, 12.1, 5);
87}
88
91BOOST_AUTO_TEST_CASE(GEMamplification_singleGEM_test)
92{
93 auto& cdb = CDBInterface::instance();
94 cdb.setUseDefaults();
95 auto& gemParam = ParameterGEM::Instance();
97 TH1D hTest("hTest", "", 10000, 0, 10000);
98 TF1 gaus("gaus", "gaus");
99
100 for (int i = 0; i < 100000; ++i) {
101 hTest.Fill(gemStack.getSingleGEMAmplification(1000, 0));
102 }
103
104 hTest.Fit("gaus", "Q0");
105
107 const float multiplication = gemParam.getEffectiveGain(0);
108 BOOST_CHECK_CLOSE(gaus.GetParameter(1), multiplication * 1000.f, 0.1);
109}
110
115BOOST_AUTO_TEST_CASE(GEMamplification_singleGEMmultiplication_test)
116{
117 auto& cdb = CDBInterface::instance();
118 cdb.setUseDefaults();
119 auto& gemParam = ParameterGEM::Instance();
120 auto& gasParam = ParameterGas::Instance();
121 static GEMAmplification& gemStack = GEMAmplification::instance();
122 TH1D hTest("hTest", "", 10000, 0, 10000);
123 TH1D hTest2("hTest2", "", 10000, 0, 10000);
124 TF1 gaus("gaus", "gaus");
125
126 for (int i = 0; i < 100000; ++i) {
127 hTest.Fill(gemStack.getGEMMultiplication(1000, 1));
128 hTest2.Fill(gemStack.getGEMMultiplication(100, 2));
129 }
130
131 hTest.Fit("gaus", "Q0");
132
135 BOOST_CHECK(gemStack.getGEMMultiplication(0, 1) == 0);
137 BOOST_CHECK_CLOSE(gaus.GetParameter(1), gemParam.AbsoluteGain[1] * 1000.f, 0.1);
139 BOOST_CHECK_CLOSE(gaus.GetParameter(2), std::sqrt(1000.f) * gasParam.SigmaOverMu * gemParam.AbsoluteGain[1], 2.5);
141 BOOST_CHECK_CLOSE(hTest2.GetMean(), gemParam.AbsoluteGain[2] * 100.f, 5);
142}
143
148BOOST_AUTO_TEST_CASE(GEMamplification_losses_test)
149{
150 auto& cdb = CDBInterface::instance();
151 cdb.setUseDefaults();
152 static GEMAmplification& gemStack = GEMAmplification::instance();
153 TH1D hTest("hTest", "", 100, 0, 100);
154 TH1D hTest2("hTest2", "", 10, 0, 10);
155 TF1 gaus("gaus", "gaus");
156
157 for (int i = 0; i < 100000; ++i) {
158 hTest.Fill(gemStack.getElectronLosses(100, 0.6));
159 hTest2.Fill(gemStack.getElectronLosses(10, 0.2));
160 }
161
162 hTest.Fit("gaus", "Q0");
163
166 BOOST_CHECK(gemStack.getElectronLosses(1, 0.000001) == 0);
168 BOOST_CHECK(gemStack.getElectronLosses(100, 1) == 100);
170 BOOST_CHECK_CLOSE(gaus.GetParameter(1), 60, 1.5);
172 BOOST_CHECK_CLOSE(gaus.GetParameter(2), std::sqrt(100.f * 0.6 * (1 - 0.6)), 1.5);
174 BOOST_CHECK_CLOSE(hTest2.GetMean(), 2, 0.5);
175}
176} // namespace tpc
177} // namespace o2
Simple interface to the CDB manager.
Definition of the GEM amplification.
int32_t i
Definition of the parameter class for the GEM stack.
Definition of the parameter class for the detector gas.
static CDBInterface & instance()
int getElectronLosses(int nElectrons, float probability)
int getEffectiveStackAmplification(int nElectrons=1)
int getStackAmplification(int nElectrons=1)
int getSingleGEMAmplification(int nElectrons, int GEM)
int getGEMMultiplication(int nElectrons, int GEM)
static GEMAmplification & instance()
Default constructor.
BOOST_AUTO_TEST_CASE(ClusterHardware_test1)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_CHECK(tree)