Project
Loading...
Searching...
No Matches
testTPCElectronTransport.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 ElectronTransport
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
39BOOST_AUTO_TEST_CASE(ElectronDiffusion_test1)
40{
41 auto& gasParam = ParameterGas::Instance();
42 auto& detParam = ParameterDetector::Instance();
43 const GlobalPosition3D posEle(10.f, 10.f, 10.f);
44 TH1D hTestDiffX("hTestDiffX", "", 500, posEle.X() - 10., posEle.X() + 10.);
45 TH1D hTestDiffY("hTestDiffY", "", 500, posEle.Y() - 10., posEle.Y() + 10.);
46 TH1D hTestDiffZ("hTestDiffZ", "", 500, posEle.Z() - 10., posEle.Z() + 10.);
47
48 TF1 gausX("gausX", "gaus");
49 TF1 gausY("gausY", "gaus");
50 TF1 gausZ("gausZ", "gaus");
51
52 static ElectronTransport& electronTransport = ElectronTransport::instance();
53 float driftTime = 0.f;
54
55 for (int i = 0; i < 500000; ++i) {
56 const GlobalPosition3D posEleDiff = electronTransport.getElectronDrift(posEle, driftTime);
57 hTestDiffX.Fill(posEleDiff.X());
58 hTestDiffY.Fill(posEleDiff.Y());
59 hTestDiffZ.Fill(posEleDiff.Z());
60 }
61
62 hTestDiffX.Fit("gausX", "Q0");
63 hTestDiffY.Fit("gausY", "Q0");
64 hTestDiffZ.Fit("gausZ", "Q0");
65
66 // check whether the mean of the gaussian fit matches the starting point
67 BOOST_CHECK_CLOSE(gausX.GetParameter(1), posEle.X(), 0.5);
68 BOOST_CHECK_CLOSE(gausY.GetParameter(1), posEle.Y(), 0.5);
69 BOOST_CHECK_CLOSE(gausZ.GetParameter(1), posEle.Z(), 0.5);
70
71 // check whether the width of the distribution matches the expected one
72 const float sigT = std::sqrt(detParam.TPClength - posEle.Z()) * gasParam.DiffT;
73 const float sigL = std::sqrt(detParam.TPClength - posEle.Z()) * gasParam.DiffL;
74
75 BOOST_CHECK_CLOSE(gausX.GetParameter(2), sigT, 0.5);
76 BOOST_CHECK_CLOSE(gausY.GetParameter(2), sigT, 0.5);
77 BOOST_CHECK_CLOSE(gausZ.GetParameter(2), sigL, 0.5);
78}
79
86BOOST_AUTO_TEST_CASE(ElectronDiffusion_test2)
87{
88 auto& gasParam = ParameterGas::Instance();
89 auto& detParam = ParameterDetector::Instance();
90 const GlobalPosition3D posEle(1.f, 1.f, detParam.TPClength - 1.f);
91 TH1D hTestDiffX("hTestDiffX", "", 500, posEle.X() - 1., posEle.X() + 1.);
92 TH1D hTestDiffY("hTestDiffY", "", 500, posEle.Y() - 1., posEle.Y() + 1.);
93 TH1D hTestDiffZ("hTestDiffZ", "", 500, posEle.Z() - 1., posEle.Z() + 1.);
94
95 TF1 gausX("gausX", "gaus");
96 TF1 gausY("gausY", "gaus");
97 TF1 gausZ("gausZ", "gaus");
98
99 static ElectronTransport& electronTransport = ElectronTransport::instance();
100 float driftTime = 0.f;
101
102 for (int i = 0; i < 500000; ++i) {
103 const GlobalPosition3D posEleDiff = electronTransport.getElectronDrift(posEle, driftTime);
104 hTestDiffX.Fill(posEleDiff.X());
105 hTestDiffY.Fill(posEleDiff.Y());
106 hTestDiffZ.Fill(posEleDiff.Z());
107 }
108
109 hTestDiffX.Fit("gausX", "Q0");
110 hTestDiffY.Fit("gausY", "Q0");
111 hTestDiffZ.Fit("gausZ", "Q0");
112
113 // check whether the mean of the gaussian fit matches the starting point
114 BOOST_CHECK_CLOSE(gausX.GetParameter(1), posEle.X(), 0.5);
115 BOOST_CHECK_CLOSE(gausY.GetParameter(1), posEle.Y(), 0.5);
116 BOOST_CHECK_CLOSE(gausZ.GetParameter(1), posEle.Z(), 0.5);
117
118 // check whether the width of the distribution matches the expected one
119 BOOST_CHECK_CLOSE(gausX.GetParameter(2), gasParam.DiffT, 0.5);
120 BOOST_CHECK_CLOSE(gausY.GetParameter(2), gasParam.DiffT, 0.5);
121 BOOST_CHECK_CLOSE(gausZ.GetParameter(2), gasParam.DiffL, 0.5);
122}
123
129BOOST_AUTO_TEST_CASE(ElectronAttatchment_test_1)
130{
131 auto& gasParam = ParameterGas::Instance();
132 static ElectronTransport& electronTransport = ElectronTransport::instance();
133
134 const float driftTime = 100.f;
135 float lostElectrons = 0;
136 const float nEvents = 1000000;
137 for (int i = 0; i < nEvents; ++i) {
138 if (electronTransport.isElectronAttachment(driftTime)) {
139 ++lostElectrons;
140 }
141 }
142
143 BOOST_CHECK_CLOSE(lostElectrons / nEvents,
144 gasParam.AttCoeff * gasParam.OxygenCont * driftTime, 0.5);
145}
146} // namespace tpc
147} // namespace o2
Simple interface to the CDB manager.
Definition of the electron transport.
int32_t i
Definition of the parameter class for the detector.
Definition of the parameter class for the detector gas.
bool isElectronAttachment(float driftTime)
GlobalPosition3D getElectronDrift(GlobalPosition3D posEle, float &driftTime)
static ElectronTransport & instance()
BOOST_AUTO_TEST_CASE(ClusterHardware_test1)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
const int nEvents
Definition test_Fifo.cxx:27