Project
Loading...
Searching...
No Matches
testTimeCalibration.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
12#define BOOST_TEST_MODULE Test_EMCAL_Calib
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15
16#include <boost/test/unit_test.hpp>
17#include "EMCALCalib/TimeCalibrationParams.h" // local header
18#include "TFile.h"
19#include "TH1S.h"
20#include "TCanvas.h"
21#include <iostream>
22#include <fstream>
23
25
26namespace o2
27{
28namespace emcal
29{
30
31BOOST_AUTO_TEST_CASE(testTimeCalibration)
32{
33
34 // Single channel test
35 //
36 // For each channel test set and update, and compare read value
37 // against set value
38 for (unsigned short c = 0; c < 17664; c++) {
39 TimeCalibrationParams singletest;
40 singletest.addTimeCalibParam(c, 0, 0); //HG
41 BOOST_CHECK_EQUAL(singletest.getTimeCalibParam(c, 0), 0);
42
43 singletest.addTimeCalibParam(c, 600, 0); //HG
44 BOOST_CHECK_EQUAL(singletest.getTimeCalibParam(c, 0), 600);
45
46 singletest.addTimeCalibParam(c, 0, 1); //LG
47 BOOST_CHECK_EQUAL(singletest.getTimeCalibParam(c, 1), 0);
48
49 singletest.addTimeCalibParam(c, 600, 1); //LG
50 BOOST_CHECK_EQUAL(singletest.getTimeCalibParam(c, 1), 600);
51 }
52
53 // Pattern test
54 //
55 // For each channel check the wheather the time calibration coeffcient is correctly written
56 // Test data obtained from LHC18b
57 TimeCalibrationParams parameter;
58
59 const char* aliceO2env = std::getenv("O2_ROOT");
60 std::string inputDir = " ";
61 if (aliceO2env) {
62 inputDir = aliceO2env;
63 }
64 inputDir += "/share/Detectors/EMC/files/";
65
66 std::string fileHG = inputDir + "TimeCalibCoeffHG.txt";
67 std::ifstream allTimeAvHG(fileHG, std::ifstream::in);
68 if (!allTimeAvHG.is_open()) {
69 std::cout << "The file TimeCalibCoeffHG was not opened\n";
70 }
71
72 std::string fileLG = inputDir + "TimeCalibCoeffLG.txt";
73 std::ifstream allTimeAvLG(fileLG, std::ifstream::in);
74 if (!allTimeAvLG.is_open()) {
75 std::cout << "The file TimeCalibCoeffLG was not opened\n";
76 }
77
78 unsigned short TimeHG[17664], TimeLG[17664];
79
80 unsigned short icell = 0;
81 while (1) {
82 allTimeAvHG >> TimeHG[icell];
83 if (!allTimeAvHG.good()) {
84 break;
85 }
86 parameter.addTimeCalibParam(icell, TimeHG[icell], 0); //HG
87 icell++;
88 }
89
90 icell = 0;
91 while (1) {
92 allTimeAvLG >> TimeLG[icell];
93 if (!allTimeAvLG.good()) {
94 break;
95 }
96 parameter.addTimeCalibParam(icell, TimeLG[icell], 1); //LG
97 icell++;
98 }
99
100 for (int icell = 0; icell < 17664; icell++) {
101 BOOST_CHECK_EQUAL(parameter.getTimeCalibParam(icell, 0), TimeHG[icell]);
102
103 BOOST_CHECK_EQUAL(parameter.getTimeCalibParam(icell, 1), TimeLG[icell]);
104 }
105
106 // Writing to the other container which will be used for comparison
107 TimeCalibrationParams parameterLHC17g;
108
109 std::string fileHG_LHC17g = inputDir + "TimeCalibCoeffHG_LHC17g.txt";
110 std::ifstream allTimeAvHG_LHC17g(fileHG_LHC17g, std::ifstream::in);
111 if (!allTimeAvHG_LHC17g.is_open()) {
112 std::cout << "The file TimeCalibCoeffHG_LHC17g was not opened\n";
113 }
114
115 std::string fileLG_LHC17g = inputDir + "TimeCalibCoeffLG_LHC17g.txt";
116 std::ifstream allTimeAvLG_LHC17g(fileLG_LHC17g, std::ifstream::in);
117 if (!allTimeAvLG_LHC17g.is_open()) {
118 std::cout << "The file TimeCalibCoeffLG_LHC17g was not opened\n";
119 }
120
121 unsigned short TimeHG_LHC17g, TimeLG_LHC17g;
122
123 icell = 0;
124 while (0) {
125 allTimeAvHG_LHC17g >> TimeHG_LHC17g;
126 if (!allTimeAvHG_LHC17g.good()) {
127 break;
128 }
129 parameterLHC17g.addTimeCalibParam(icell, TimeHG_LHC17g, 0); //HG
130 icell++;
131 }
132
133 icell = 0;
134 while (0) {
135 allTimeAvLG_LHC17g >> TimeLG_LHC17g;
136 if (!allTimeAvLG_LHC17g.good()) {
137 break;
138 }
139 parameterLHC17g.addTimeCalibParam(icell, TimeLG_LHC17g, 1); //LG
140 icell++;
141 }
142
143 // Equal
144 //
145 // - Compare time calibration for LHC18b with itself. The result must be true.
146 // - Compare time calibration for LHC18b with time calibration for LHC17g. The result must be false
147 BOOST_CHECK_EQUAL(parameter == parameter, true);
148 BOOST_CHECK_EQUAL(parameter == parameterLHC17g, false);
149
150 allTimeAvHG.close();
151 allTimeAvLG.close();
152 allTimeAvHG_LHC17g.close();
153 allTimeAvLG_LHC17g.close();
154}
155} // namespace emcal
156} // namespace o2
uint32_t c
Definition RawData.h:2
void addTimeCalibParam(unsigned short cellID, short time, bool isLowGain)
Add time calibration coefficients to the container.
short getTimeCalibParam(unsigned short cellID, bool isLowGain) const
Get the time calibration coefficient for a certain cell.
BOOST_AUTO_TEST_CASE(asynch_schedule_test)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())