Skip to content

Commit 83c27f8

Browse files
mleschmlesch
andauthored
TPC: Reductor for DCS Temperatures (#2466)
* TPC: Reductor for DCS Temperatures * clean-up * Implementing changes --------- Co-authored-by: mlesch <ga94pez@mytum.de>
1 parent aaf01a6 commit 83c27f8

7 files changed

Lines changed: 297 additions & 1 deletion

File tree

Modules/TPC/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ target_sources(O2QcTPC PRIVATE src/PID.cxx
3838
src/TrackClusters.cxx
3939
src/VDriftCalibReductor.cxx
4040
src/SeparationPowerReductor.cxx
41-
src/TimeGainCalibReductor.cxx)
41+
src/TimeGainCalibReductor.cxx
42+
src/DCSPTempReductor.cxx)
4243

4344
target_include_directories(
4445
O2QcTPC
@@ -97,6 +98,7 @@ add_root_dictionary(O2QcTPC
9798
include/TPC/VDriftCalibReductor.h
9899
include/TPC/SeparationPowerReductor.h
99100
include/TPC/TimeGainCalibReductor.h
101+
include/TPC/DCSPTempReductor.h
100102
LINKDEF include/TPC/LinkDef.h)
101103

102104
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/TPC
@@ -180,4 +182,5 @@ install(FILES run/tpcQCPID_sampled.json
180182
run/tpcQCvDriftTrending.json
181183
run/tpcQCTrending_separationpower.json
182184
run/tpcQCTimeGainCalibTrending.json
185+
run/tpcDCSPTempTrending.json
183186
DESTINATION etc)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
///
13+
/// \file DCSPTempReductor.h
14+
/// \author Marcel Lesch
15+
///
16+
17+
#ifndef QUALITYCONTROL_DCSPTEMPREDUCTOR_H
18+
#define QUALITYCONTROL_DCSPTEMPREDUCTOR_H
19+
20+
#include "QualityControl/ReductorConditionAny.h"
21+
#include <DataFormatsTPC/Defs.h>
22+
23+
namespace o2::quality_control_modules::tpc
24+
{
25+
26+
/// \brief A Reductor for calibration objects of the TPC DCS temperatures
27+
///
28+
/// A Reductor for TPC DCS temperatures.
29+
/// It produces a branch in the format:
30+
/// "tempSensor[18]/F:tempSensorErr[18]:tempMeanPerSide[2]:tempMeanPerSideErr[2]:tempGradXPerSide[2]:tempGradXPerSideErr[2]:tempGradYPerSide[2]:tempGradYPerSideErr[2]"
31+
/// tempSensor[i] is the raw sensor temperature for each of the 18 sensores
32+
/// tempMeanPerSide[i] is the mean temperature per TPC-Side (0: A-Side, 1: C-Side)
33+
/// tempGradXPerSide[i] is the temperature gradient in x direction per TPC-Side (0: A-Side, 1: C-Side)
34+
/// tempGradYPerSide[i] is the temperature gradient in y direction per TPC-Side (0: A-Side, 1: C-Side)
35+
36+
class DCSPTempReductor : public quality_control::postprocessing::ReductorConditionAny
37+
{
38+
public:
39+
DCSPTempReductor() = default;
40+
~DCSPTempReductor() = default;
41+
42+
void* getBranchAddress() override;
43+
const char* getBranchLeafList() override;
44+
bool update(ConditionRetriever& retriever) override;
45+
46+
private:
47+
struct {
48+
Float_t tempSensor[18];
49+
Float_t tempSensorErr[18]; // uncertainties
50+
51+
Float_t tempMeanPerSide[2];
52+
Float_t tempMeanPerSideErr[2]; // uncertainties
53+
54+
Float_t tempGradXPerSide[2];
55+
Float_t tempGradXPerSideErr[2]; // uncertainties
56+
57+
Float_t tempGradYPerSide[2];
58+
Float_t tempGradYPerSideErr[2]; // uncertainties
59+
} mStats;
60+
};
61+
62+
} // namespace o2::quality_control_modules::tpc
63+
64+
#endif // QUALITYCONTROL_DCSPTEMPREDUCTOR_H

Modules/TPC/include/TPC/LinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#pragma link C++ class o2::quality_control_modules::tpc::VDriftCalibReductor + ;
4444
#pragma link C++ class o2::quality_control_modules::tpc::SeparationPowerReductor + ;
4545
#pragma link C++ class o2::quality_control_modules::tpc::TimeGainCalibReductor + ;
46+
#pragma link C++ class o2::quality_control_modules::tpc::DCSPTempReductor + ;
4647

4748
#pragma link C++ function o2::quality_control_modules::tpc::addAndPublish + ;
4849
#pragma link C++ function o2::quality_control_modules::tpc::toVector + ;

Modules/TPC/include/TPC/Utility.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,11 @@ void calculateStatistics(const double* yValues, const double* yErrors, bool useE
107107
/// \param mean double&, reference to double that should store mean
108108
/// \param stddevOfMean double&, reference to double that should store stddev of mean
109109
void retrieveStatistics(std::vector<double>& values, std::vector<double>& errors, bool useErrors, double& mean, double& stddevOfMean);
110+
111+
/// \brief Calculates mean and stddev from a vector
112+
/// \param values std::vector<values>& vector that contains the data points
113+
/// \param mean float&, reference to float that should store mean
114+
/// \param stddev float&, reference to float that should store stddev of mean
115+
void calcMeanAndStddev(const std::vector<float>& values, float& mean, float& stddev);
110116
} // namespace o2::quality_control_modules::tpc
111117
#endif // QUALITYCONTROL_TPCUTILITY_H
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
"qc": {
3+
"config": {
4+
"database": {
5+
"implementation": "CCDB",
6+
"host": "ccdb-test.cern.ch:8080",
7+
"username": "not_applicable",
8+
"password": "not_applicable",
9+
"name": "not_applicable"
10+
},
11+
"Activity": {
12+
"number": "",
13+
"type": "",
14+
"start": "",
15+
"end": ""
16+
},
17+
"monitoring": {
18+
"url": "infologger:///debug?qc"
19+
},
20+
"consul": {
21+
"url": ""
22+
},
23+
"conditionDB": {
24+
"url": "ccdb-test.cern.ch:8080"
25+
},
26+
"postprocessing": {
27+
"periodSeconds": "10"
28+
}
29+
},
30+
"postprocessing": {
31+
"TemperatureQC": {
32+
"active": "true",
33+
"resumeTrend": "false",
34+
"className": "o2::quality_control::postprocessing::TrendingTask",
35+
"moduleName": "QualityControl",
36+
"detectorName": "TPC",
37+
"producePlotsOnUpdate": "true",
38+
"dataSources": [
39+
{
40+
"type": "condition",
41+
"path": "TPC/Calib/",
42+
"names": [ "Temperature" ],
43+
"reductorName": "o2::quality_control_modules::tpc::DCSPTempReductor",
44+
"moduleName": "QcTPC"
45+
}
46+
],
47+
"plots": [
48+
{
49+
"name": "Temp_Mean_ASide",
50+
"title": "Mean Temperature A Side",
51+
"varexp": "Temperature.tempMeanPerSide[0]:time",
52+
"selection": "",
53+
"option": "*L",
54+
"graphAxisLabel": "mean temp A Side:time",
55+
"graphErrors": "Temperature.tempMeanPerSideErr[0]:0"
56+
},
57+
{
58+
"name": "Temp_GradX_ASide",
59+
"title": "GradX Temperature A Side",
60+
"varexp": "Temperature.tempGradXPerSide[0]:time",
61+
"selection": "",
62+
"option": "*L",
63+
"graphAxisLabel": "gradX temp A Side:time",
64+
"graphErrors": "Temperature.tempGradXPerSideErr[0]:0"
65+
},
66+
{
67+
"name": "Temp_GradY_ASide",
68+
"title": "GradY Temperature A Side",
69+
"varexp": "Temperature.tempGradYPerSide[0]:time",
70+
"selection": "",
71+
"option": "*L",
72+
"graphAxisLabel": "gradY temp A Side:time",
73+
"graphErrors": "Temperature.tempGradYPerSideErr[0]:0"
74+
},
75+
{
76+
"name": "Temp_Mean_CSide",
77+
"title": "Mean Temperature C Side",
78+
"varexp": "Temperature.tempMeanPerSide[1]:time",
79+
"selection": "",
80+
"option": "*L",
81+
"graphAxisLabel": "mean temp C Side:time",
82+
"graphErrors": "Temperature.tempMeanPerSideErr[1]:0"
83+
},
84+
{
85+
"name": "Temp_GradX_CSide",
86+
"title": "GradX Temperature C Side",
87+
"varexp": "Temperature.tempGradXPerSide[1]:time",
88+
"selection": "",
89+
"option": "*L",
90+
"graphAxisLabel": "gradX temp C Side:time",
91+
"graphErrors": "Temperature.tempGradXPerSideErr[1]:0"
92+
},
93+
{
94+
"name": "Temp_GradY_CSide",
95+
"title": "GradY Temperature C Side",
96+
"varexp": "Temperature.tempGradYPerSide[1]:time",
97+
"selection": "",
98+
"option": "*L",
99+
"graphAxisLabel": "gradY temp C Side:time",
100+
"graphErrors": "Temperature.tempGradYPerSideErr[1]:0"
101+
}
102+
],
103+
"initTrigger": [
104+
"userorcontrol"
105+
],
106+
"updateTrigger": [
107+
"foreachlatest:ccdb:TPC/Calib/Temperature/"
108+
],
109+
"stopTrigger": [
110+
"userorcontrol"
111+
]
112+
}
113+
}
114+
}
115+
}
116+
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
///
13+
/// \file DCSPTempReductor.cxx
14+
/// \author Marcel Lesch
15+
///
16+
17+
#include "TPC/DCSPTempReductor.h"
18+
#include "DataFormatsTPC/DCS.h"
19+
#include "TPC/Utility.h"
20+
21+
namespace o2::quality_control_modules::tpc
22+
{
23+
24+
void* DCSPTempReductor::getBranchAddress()
25+
{
26+
return &mStats;
27+
}
28+
29+
const char* DCSPTempReductor::getBranchLeafList()
30+
{
31+
return "tempSensor[18]/F:tempSensorErr[18]:tempMeanPerSide[2]:tempMeanPerSideErr[2]:tempGradXPerSide[2]:tempGradXPerSideErr[2]:tempGradYPerSide[2]:tempGradYPerSideErr[2]";
32+
}
33+
34+
bool DCSPTempReductor::update(ConditionRetriever& retriever)
35+
{
36+
if (auto dcstemp = retriever.retrieve<o2::tpc::dcs::Temperature>()) {
37+
38+
int sensorCounter = 0;
39+
std::vector<float> sensorData[18];
40+
for (const auto& sensor : dcstemp->raw) {
41+
for (const auto& value : sensor.data) {
42+
sensorData[sensorCounter].emplace_back(value.value);
43+
}
44+
calcMeanAndStddev(sensorData[sensorCounter], mStats.tempSensor[sensorCounter], mStats.tempSensorErr[sensorCounter]);
45+
sensorCounter++;
46+
if (sensorCounter > 17)
47+
break;
48+
}
49+
50+
std::vector<float> sideData[3]; // 0 mean, 1 gradX, 2 gradY
51+
52+
// A-Side
53+
for (const auto& value : dcstemp->statsA.data) {
54+
sideData[0].emplace_back(value.value.mean);
55+
sideData[1].emplace_back(value.value.gradX);
56+
sideData[2].emplace_back(value.value.gradY);
57+
}
58+
59+
calcMeanAndStddev(sideData[0], mStats.tempMeanPerSide[0], mStats.tempMeanPerSideErr[0]);
60+
calcMeanAndStddev(sideData[1], mStats.tempGradXPerSide[0], mStats.tempGradXPerSideErr[0]);
61+
calcMeanAndStddev(sideData[2], mStats.tempGradYPerSide[0], mStats.tempGradYPerSideErr[0]);
62+
63+
for (int iCount = 0; iCount < 3; iCount++) {
64+
sideData[iCount].clear();
65+
}
66+
67+
// C-Side
68+
for (const auto& value : dcstemp->statsC.data) {
69+
sideData[0].emplace_back(value.value.mean);
70+
sideData[1].emplace_back(value.value.gradX);
71+
sideData[2].emplace_back(value.value.gradY);
72+
}
73+
74+
calcMeanAndStddev(sideData[0], mStats.tempMeanPerSide[1], mStats.tempMeanPerSideErr[1]);
75+
calcMeanAndStddev(sideData[1], mStats.tempGradXPerSide[1], mStats.tempGradXPerSideErr[1]);
76+
calcMeanAndStddev(sideData[2], mStats.tempGradYPerSide[1], mStats.tempGradYPerSideErr[1]);
77+
78+
return true;
79+
}
80+
return false;
81+
}
82+
83+
} // namespace o2::quality_control_modules::tpc

Modules/TPC/src/Utility.cxx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,27 @@ void retrieveStatistics(std::vector<double>& values, std::vector<double>& errors
341341
}
342342
}
343343

344+
void calcMeanAndStddev(const std::vector<float>& values, float& mean, float& stddev)
345+
{
346+
if (values.size() == 0) {
347+
mean = 0.;
348+
stddev = 0.;
349+
return;
350+
}
351+
352+
// Mean
353+
const float sum = std::accumulate(values.begin(), values.end(), 0.0);
354+
mean = sum / values.size();
355+
356+
// Stddev
357+
if (values.size() == 1) { // we only have one point -> no stddev
358+
stddev = 0.;
359+
} else { // for >= 2 points, we calculate the spread
360+
std::vector<float> diff(values.size());
361+
std::transform(values.begin(), values.end(), diff.begin(), [mean](auto x) { return x - mean; });
362+
const auto sq_sum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.f);
363+
stddev = std::sqrt(sq_sum / (values.size() * (values.size() - 1.)));
364+
}
365+
}
366+
344367
} // namespace o2::quality_control_modules::tpc

0 commit comments

Comments
 (0)