Project
Loading...
Searching...
No Matches
testTempCalibration.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/TempCalibrationParams.h" // local header
18#include "TFile.h"
19#include "TH1.h"
20#include "TCanvas.h"
21#include <iostream>
22#include <fstream>
23
25
26namespace o2
27{
28namespace emcal
29{
30
31BOOST_AUTO_TEST_CASE(testTempCalibration)
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 TempCalibrationParams singletest;
40
41 singletest.addTempCalibParam(c, 0., 1.);
42 BOOST_CHECK_EQUAL(singletest.getTempCalibParamSlope(c), 0.); //Slope
43 BOOST_CHECK_EQUAL(singletest.getTempCalibParamA0(c), 1.); //A0 param
44
45 singletest.addTempCalibParam(c, -1., 1.5);
47 BOOST_CHECK_EQUAL(singletest.getTempCalibParamA0(c), 1.5);
48 }
49
50 // Pattern test
51 //
52 // For each channel check the wheather the temperature calibration coeffcient (slope and A0 param) are correctly written
53 // Test data obtained from LHC18
54 TempCalibrationParams parameter;
55
56 const char* aliceO2env = std::getenv("O2_ROOT");
57 std::string inputDir = " ";
58 if (aliceO2env) {
59 inputDir = aliceO2env;
60 }
61 inputDir += "/share/Detectors/EMC/files/";
62
63 std::string file = inputDir + "TempCalibCoeff.txt";
64 std::ifstream fileTemp(file, std::ifstream::in);
65 if (!fileTemp.is_open()) {
66 std::cout << "The file TempCalibCoeff was not opened\n";
67 }
68
69 float Slope[17664], A0[17664];
70
71 unsigned short icell = 0;
72 std::string line;
73
74 // Write to the container
75 while (std::getline(fileTemp, line)) {
76 std::stringstream streamLine(line);
77 streamLine >> Slope[icell] >> A0[icell];
78 parameter.addTempCalibParam(icell, Slope[icell], A0[icell]);
79 icell++;
80 }
81
82 for (unsigned short icell = 0; icell < 17664; icell++) {
83 BOOST_CHECK_EQUAL(parameter.getTempCalibParamSlope(icell), Slope[icell]);
84
85 BOOST_CHECK_EQUAL(parameter.getTempCalibParamA0(icell), A0[icell]);
86 }
87
88 // Comparison test
89
90 //comparison file
91 TempCalibrationParams parameterLHC17;
92
93 std::string fileLHC17 = inputDir + "TempCalibCoeff_LHC17.txt";
94 std::ifstream fileTempLHC17(fileLHC17, std::ifstream::in);
95 if (!fileTempLHC17.is_open()) {
96 std::cout << "The file TempCalibCoeff_LHC17 was not opened\n";
97 }
98
99 float Slope_LHC17, A0_LHC17;
100
101 icell = 0;
102 // Write to the container
103 while (std::getline(fileTempLHC17, line)) {
104 std::stringstream streamLine(line);
105 streamLine >> Slope_LHC17 >> A0_LHC17;
106 parameterLHC17.addTempCalibParam(icell, Slope_LHC17, A0_LHC17);
107 icell++;
108 }
109
110 // Equal
111 //
112 // - Compare temperature calibration for LHC18 with itself. The result must be true.
113 // - Compare temperature calibration for LHC18 with time calibration for LHC17. The result must be false
114 BOOST_CHECK_EQUAL(parameter == parameter, true);
115 BOOST_CHECK_EQUAL(parameter == parameterLHC17, false);
116
117 fileTemp.close();
118 fileTempLHC17.close();
119}
120} // namespace emcal
121} // namespace o2
uint32_t c
Definition RawData.h:2
void addTempCalibParam(unsigned short cellID, float Slope, float ParamA0)
Add temperature calibration coefficients to the container.
float getTempCalibParamA0(unsigned short cellID) const
Get the temperature calibration coefficient (A0 param) for a certain cell.
float getTempCalibParamSlope(unsigned short cellID) const
Get the temperature calibration coefficient (slope) 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())