Project
Loading...
Searching...
No Matches
testTempCalibrationSM.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/TempCalibParamSM.h" // local header
18#include <iostream>
19#include <fstream>
20
22
23namespace o2
24{
25namespace emcal
26{
27
28BOOST_AUTO_TEST_CASE(testTempCalibrationSM)
29{
30
31 // Single channel test
32 //
33 // For each channel test set and update, and compare read value
34 // against set value
35 for (unsigned short iSM = 0; iSM < 20; iSM++) {
36 TempCalibParamSM singletest;
37
38 singletest.addTempCalibParamPerSM(iSM, 0.);
39 BOOST_CHECK_EQUAL(singletest.getTempCalibParamPerSM(iSM), 0.);
40
41 singletest.addTempCalibParamPerSM(iSM, 1.);
42 BOOST_CHECK_EQUAL(singletest.getTempCalibParamPerSM(iSM), 1.);
43 }
44
45 // Pattern test
46 //
47 // For each channel check the wheather the temperature calibration coeffcient per SM are correctly written
48 // Test data obtained from LHC18k run 289165
49 TempCalibParamSM parameter;
50
51 const char* aliceO2env = std::getenv("O2_ROOT");
52 std::string inputDir = " ";
53 if (aliceO2env) {
54 inputDir = aliceO2env;
55 }
56 inputDir += "/share/Detectors/EMC/files/";
57
58 std::string file = inputDir + "TempCalibSM_LHC18k_289166.txt";
59 std::ifstream fileTempCalibSM(file, std::ifstream::in);
60 if (!fileTempCalibSM.is_open()) {
61 std::cout << "The file TempCalibSM_LHC18k_289166.txt was not opened\n";
62 }
63
64 float TempCalibSM[20];
65
66 unsigned short iSM = 0;
67 std::string line;
68
69 // Write to the container
70 while (std::getline(fileTempCalibSM, line)) {
71 std::stringstream streamLine(line);
72 unsigned short sm;
73 streamLine >> sm >> TempCalibSM[iSM];
74 parameter.addTempCalibParamPerSM(sm, TempCalibSM[iSM]);
75 iSM++;
76 }
77
78 for (unsigned short ism = 0; ism < 20; ism++) {
79 BOOST_CHECK_EQUAL(parameter.getTempCalibParamPerSM(ism), TempCalibSM[ism]);
80 }
81
82 // Comparison test
83
84 //comparison file
85 TempCalibParamSM parameterLHC18k;
86
87 std::string fileLHC18k = inputDir + "TempCalibSM_LHC18k_289201.txt";
88 std::ifstream fileTempCalibSM_LHC18k(fileLHC18k, std::ifstream::in);
89 if (!fileTempCalibSM_LHC18k.is_open()) {
90 std::cout << "The file TempCalibSM_LHC18k_289201.txt was not opened\n";
91 }
92
93 unsigned char TempCalibSM_LHC18k;
94
95 iSM = 0;
96 // Write to the container
97 while (std::getline(fileTempCalibSM_LHC18k, line)) {
98 std::stringstream streamLine(line);
99 unsigned short sm;
100 streamLine >> sm >> TempCalibSM_LHC18k;
101 parameterLHC18k.addTempCalibParamPerSM(sm, TempCalibSM_LHC18k);
102 iSM++;
103 }
104
105 // Equal
106 //
107 // - Compare L1 phase shifts for LHC18k run 289165 with itself. The result must be true.
108 // - Compare L1 phase shifts for LHC18k run 289165 with L1 phase shifts for LHC18k run 289166. The result must be false
109 BOOST_CHECK_EQUAL(parameter == parameter, true);
110 BOOST_CHECK_EQUAL(parameter == parameterLHC18k, false);
111
112 fileTempCalibSM.close();
113 fileTempCalibSM_LHC18k.close();
114}
115} // namespace emcal
116} // namespace o2
float getTempCalibParamPerSM(unsigned short iSM) const
Get the temperature calibration coefficient for a certain SM.
void addTempCalibParamPerSM(unsigned short iSM, float TempSM)
Add temperature coefficients to the container.
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())