Project
Loading...
Searching...
No Matches
testGainCalibration.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/GainCalibrationFactors.h" // local header
18#include "EMCALBase/Geometry.h"
19#include <iostream>
20#include <fstream>
21
23
24namespace o2
25{
26namespace emcal
27{
28
29BOOST_AUTO_TEST_CASE(testGainCalibration)
30{
31
33
34 // Single channel test
35 //
36 // For each channel test set and update, and compare read value
37 // against set value
38 Int_t sms = geo->GetNumberOfSuperModules();
39
40 for (unsigned short icell = 0; icell < 17664; icell++) {
41 GainCalibrationFactors singletest;
42 singletest.addGainCalibFactor(icell, 0);
43 BOOST_CHECK_EQUAL(singletest.getGainCalibFactors(icell), 0);
44
45 singletest.addGainCalibFactor(icell, 1);
46 BOOST_CHECK_EQUAL(singletest.getGainCalibFactors(icell), 1);
47 }
48
49 // Pattern test
50 //
51 // For each channel check the wheather the gain calibration factor is correctly written
52 // Test data obtained from LHC18b
54
55 const char* aliceO2env = std::getenv("O2_ROOT");
56 std::string inputDir = " ";
57 if (aliceO2env) {
58 inputDir = aliceO2env;
59 }
60 inputDir += "/share/Detectors/EMC/files/";
61
62 std::string fileNameGainCalib = inputDir + "GainCalibrationFactors_LHC18q.txt";
63 std::ifstream fileGainCalib(fileNameGainCalib, std::ifstream::in);
64 if (!fileGainCalib.is_open()) {
65 std::cout << "The file GainCalibrationFactors_LHC18q was not opened\n";
66 }
67
68 float GainCalibFactors[17664];
69
70 unsigned short icell = 0;
71 std::string line;
72
73 // Write to the container
74 while (std::getline(fileGainCalib, line)) {
75 std::stringstream streamLine(line);
76 unsigned short iSM, iCol, iRow;
77 float Gain;
78 streamLine >> iSM >> iCol >> iRow >> Gain;
79 GainCalibFactors[icell] = Gain;
80 parameter.addGainCalibFactor(icell, Gain);
81 icell++;
82 }
83
84 for (unsigned short icell = 0; icell < 17664; icell++) {
85 BOOST_CHECK_EQUAL(parameter.getGainCalibFactors(icell), GainCalibFactors[icell]);
86 }
87
88 // Writing to the other container which will be used for comparison
89 GainCalibrationFactors parameterLHC15;
90
91 std::string fileNameGainCalib_LHC15 = inputDir + "GainCalibrationFactors_LHC15.txt";
92 std::ifstream fileGainCalib_LHC15(fileNameGainCalib_LHC15, std::ifstream::in);
93 if (!fileGainCalib_LHC15.is_open()) {
94 std::cout << "The file GainCalibrationFactors_LHC15 was not opened\n";
95 }
96
97 // Write to the container
98 icell = 0;
99 while (std::getline(fileGainCalib_LHC15, line)) {
100 std::stringstream streamLine(line);
101 Int_t iSM, iCol, iRow;
102 float GainCalib;
103 streamLine >> iSM >> iCol >> iRow >> GainCalib;
104 parameterLHC15.addGainCalibFactor(icell, GainCalib);
105 icell++;
106 }
107
108 // Equal
109 //
110 // - Compare gain calibration factors for LHC18q with itself. The result must be true.
111 // - Compare gain calibration factors for LHC18q with the gain calibration for LHC15. The result must be false
113 BOOST_CHECK_EQUAL(parameter == parameterLHC15, false);
114
115 fileGainCalib.close();
116 fileGainCalib_LHC15.close();
117}
118} // namespace emcal
119} // namespace o2
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this parameter(fixed during CTF decoding)") AddOptionRTC(defaultZOffsetOverR
CCDB container for the gain calibration factors.
float getGainCalibFactors(unsigned short iCell) const
Get the gain calibration factor for a certain cell.
void addGainCalibFactor(unsigned short iCell, float gainFactor)
Add gain calibration factors to the container.
static Geometry * GetInstanceFromRunNumber(Int_t runNumber, const std::string_view="", const std::string_view mcname="TGeant3", const std::string_view mctitle="")
Instanciate geometry depending on the run number. Mostly used in analysis and MC anchors.
Definition Geometry.cxx:182
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())