Project
Loading...
Searching...
No Matches
testTPCSAMPAProcessing.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 SAMPAProcessing
17#define BOOST_TEST_MAIN
18#define BOOST_TEST_DYN_LINK
19#include <boost/test/unit_test.hpp>
22
23#include <fstream>
24#include <iostream>
25#include <sstream>
26#include <string>
27#include <fairlogger/Logger.h>
28
29namespace o2
30{
31namespace tpc
32{
33
35BOOST_AUTO_TEST_CASE(SAMPA_ADC_test)
36{
37 auto& cdb = CDBInterface::instance();
38 cdb.setUseDefaults();
39 auto& eleParam = ParameterElectronics::Instance();
41 BOOST_CHECK_CLOSE(sampa.getADCvalue(1000.f),
42 1000.f * eleParam.ElectronCharge * 1.e15 * eleParam.ChipGain *
43 eleParam.ADCsaturation / eleParam.ADCdynamicRange,
44 1E-5);
45}
46
50BOOST_AUTO_TEST_CASE(SAMPA_saturation_test)
51{
52 auto& cdb = CDBInterface::instance();
53 cdb.setUseDefaults();
55
56 std::vector<float> ADCin = {{1.f, 50.f, 100.f, 1000.f, 1023.f, 1024.f, 2000.f, 10000.f}};
57 std::vector<float> ADCout = {{1.f, 50.f, 100.f, 1000.f, 1023.f, 1023.f, 1023.f, 1023.f}};
58
59 for (size_t i = 0; i < ADCin.size(); ++i) {
60 BOOST_CHECK(sampa.getADCSaturation(ADCin[i]) == ADCout[i]);
61 }
62}
63
64// On non-x86_64 architectures, the vectorization code doesn't work and triggers
65// an assertion error in Vc at runtime.
66#ifdef __x86_64__
68BOOST_AUTO_TEST_CASE(SAMPA_Gamma4_test)
69{
70 auto& cdb = CDBInterface::instance();
71 cdb.setUseDefaults();
72 auto& eleParam = ParameterElectronics::Instance();
73 const SAMPAProcessing& sampa = SAMPAProcessing::instance();
74 float timeInit[4] = {0.1, 3.3, 1.f, 90.5};
75 float startTimeInit[4] = {0.f, 3.f, 0.f, 90.f};
76 float ADCinit[4] = {1.f, 50.f, 100.f, 100.f};
77 Vc::float_v time;
78 Vc::float_v startTime;
79 Vc::float_v ADC;
80 for (int i = 0; i < 4; ++i) {
81 time[i] = timeInit[i];
82 startTime[i] = startTimeInit[i];
83 ADC[i] = ADCinit[i];
84 }
87 Vc::float_v adcValue = 55.f * ADC * Vc::exp(-4.f * (time - startTime) / eleParam.PeakingTime) *
88 (time - startTime) / eleParam.PeakingTime * (time - startTime) /
89 eleParam.PeakingTime * (time - startTime) / eleParam.PeakingTime *
90 (time - startTime) / eleParam.PeakingTime;
91 Vc::float_v signal = sampa.getGamma4(time, startTime, ADC);
92 for (int i = 0; i < 4; ++i) {
93 float currentSignal = signal[i];
94 float currentADC = adcValue[i];
95 BOOST_CHECK_CLOSE(currentSignal, currentADC, 1E-3);
96 }
97}
98#endif
99
101BOOST_AUTO_TEST_CASE(SAMPA_Conversion_test)
102{
103 auto& cdb = CDBInterface::instance();
104 cdb.setUseDefaults();
105 auto& eleParam = ParameterElectronics::Instance();
106 auto& detParam = ParameterDetector::Instance();
108 BOOST_CHECK(sampa.getTimeBin(detParam.TPClength) == 0);
109 BOOST_CHECK_CLOSE(sampa.getZfromTimeBin(0, Side::A), detParam.TPClength, 1E-6);
110}
111} // namespace tpc
112} // namespace o2
Simple interface to the CDB manager.
int16_t time
Definition RawEventData.h:4
int32_t i
Definition of the SAMPA response.
static CDBInterface & instance()
T getADCvalue(T nElectrons) const
static SAMPAProcessing & instance()
float getZfromTimeBin(float timeBin, Side s) const
TimeBin getTimeBin(float zPos) const
float getADCSaturation(const float signal) const
BOOST_AUTO_TEST_CASE(ClusterHardware_test1)
@ A
Definition Defs.h:35
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_CHECK(tree)