Skip to content

Commit 2c56fab

Browse files
martenoleshahor02
authored andcommitted
TRD DCS processing for more DPs
1 parent 83f9412 commit 2c56fab

12 files changed

Lines changed: 756 additions & 214 deletions

File tree

DataFormats/Detectors/TRD/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ o2_add_library(DataFormatsTRD
1313
SOURCES src/TriggerRecord.cxx
1414
src/LinkRecord.cxx
1515
src/AngularResidHistos.cxx
16+
src/DcsCcdbObjects.cxx
1617
src/Tracklet64.cxx
1718
src/RawData.cxx
1819
src/RawDataStats.cxx
@@ -31,6 +32,7 @@ o2_target_root_dictionary(DataFormatsTRD
3132
include/DataFormatsTRD/RawData.h
3233
include/DataFormatsTRD/Constants.h
3334
include/DataFormatsTRD/CalibratedTracklet.h
35+
include/DataFormatsTRD/DcsCcdbObjects.h
3436
include/DataFormatsTRD/AngularResidHistos.h
3537
include/DataFormatsTRD/HelperMethods.h
3638
include/DataFormatsTRD/Hit.h
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
/// \file DcsCcdbObjects.h
13+
/// \brief Objects which are created from DCS DPs and stored in the CCDB
14+
/// \author Ole Schmidt, ole.schmidt@cern.ch
15+
16+
#ifndef ALICEO2_DCSCCDBOBJECTSTRD_H
17+
#define ALICEO2_DCSCCDBOBJECTSTRD_H
18+
19+
#include "DataFormatsTRD/Constants.h"
20+
#include "Rtypes.h"
21+
#include <array>
22+
23+
namespace o2
24+
{
25+
namespace trd
26+
{
27+
28+
struct TRDDCSMinMaxMeanInfo {
29+
float minValue{0.f}; // min value seen by the TRD DCS processor
30+
float maxValue{0.f}; // max value seen by the TRD DCS processor
31+
float meanValue{0.f}; // mean value seen by the TRD DCS processor
32+
int nPoints{0}; // number of values seen by the TRD DCS processor
33+
34+
void print() const;
35+
void addPoint(float value);
36+
37+
ClassDefNV(TRDDCSMinMaxMeanInfo, 1);
38+
};
39+
40+
} // namespace trd
41+
} // namespace o2
42+
43+
#endif // ALICEO2_DCSCCDBOBJECTSTRD_H

DataFormats/Detectors/TRD/src/DataFormatsTRDLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@
4747
#pragma link C++ struct o2::trd::CTF + ;
4848
#pragma link C++ class o2::ctf::EncodedBlocks < o2::trd::CTFHeader, 15, uint32_t> + ;
4949

50+
#pragma link C++ struct o2::trd::TRDDCSMinMaxMeanInfo + ;
51+
5052
#endif
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
/// \file DcsCcdbObjects.cxx
13+
/// \brief Objects which are created from DCS DPs and stored in the CCDB
14+
/// \author Ole Schmidt, ole.schmidt@cern.ch
15+
16+
#include "DataFormatsTRD/DcsCcdbObjects.h"
17+
#include <fairlogger/Logger.h>
18+
19+
using namespace o2::trd;
20+
21+
void TRDDCSMinMaxMeanInfo::print() const
22+
{
23+
LOG(info) << "Min value: " << minValue;
24+
LOG(info) << "Max value: " << maxValue;
25+
LOG(info) << "Mean value: " << meanValue;
26+
LOG(info) << "Number of points added: " << nPoints;
27+
}
28+
29+
void TRDDCSMinMaxMeanInfo::addPoint(float value)
30+
{
31+
if (nPoints == 0) {
32+
minValue = value;
33+
maxValue = value;
34+
meanValue = value;
35+
} else {
36+
if (value < minValue) {
37+
minValue = value;
38+
}
39+
if (value > maxValue) {
40+
maxValue = value;
41+
}
42+
meanValue += (value - meanValue) / (nPoints + 1);
43+
}
44+
++nPoints;
45+
}

Detectors/TRD/calibration/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ If you want to run the calibration from a local file with residuals, trdangreshi
1616
o2-calibration-trd-vdrift-exb -b --enable-root-input --calib-vdexb-calibration '--tf-per-slot 1 --min-entries 50000'
1717

1818
## DCS data points
19+
20+
To process the DCS data points for the TRD the list of aliases as for example "trd_gaschromatographXe" has to be available in the CCDB. This can be achieved with the macro `Detectors/TRD/calibration/macros/makeTRDCCDBEntryForDCS.C`. The full list of aliases is available in jira (https://alice.its.cern.ch/jira/browse/TRD-109).
21+
With the list of aliases defined one can run the `o2-calibration-trd-dcs-sim-workflow` which provides DCS DPs for all possible aliases and sends them on via DPL. Attaching the `o2-calibration-trd-dcs-workflow` will include the processing of these data points. For testing purposes this is sufficient. In case also the CCDB should be populated the `o2-calibration-ccdb-populator-workflow` has to be appended. Via the `--ccdb-path` flag this can also be configured to write to a local CCDB for testing.
22+
23+
So, in order to test the workflow independent of the actual CCDB using a local instance one can do:
24+
25+
root $O2_ROOT/share/macro/makeTRDCCDBEntryForDCS.C+
26+
o2-calibration-trd-dcs-sim-workflow -b --delta-fraction 0.5 --max-timeframes 10 | o2-calibration-trd-dcs-workflow -b --ccdb-path http://localhost:8080 --use-ccdb-to-configure --processor-verbosity 1 | o2-calibration-ccdb-populator-workflow -b --ccdb-path http://localhost:8080

Detectors/TRD/calibration/include/TRDCalibration/DCSProcessor.h

Lines changed: 81 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
#include "DetectorsDCS/DeliveryType.h"
2020
#include "CCDB/CcdbObjectInfo.h"
2121
#include "CommonUtils/MemFileHelper.h"
22+
#include "DataFormatsTRD/DcsCcdbObjects.h"
23+
#include "DataFormatsTRD/Constants.h"
24+
2225
#include "CCDB/CcdbApi.h"
2326
#include <Rtypes.h>
2427
#include <unordered_map>
2528
#include <string>
29+
#include <bitset>
2630
#include <gsl/gsl>
2731

2832
/// @brief Class to process TRD DCS data points
@@ -36,18 +40,6 @@ using DPID = o2::dcs::DataPointIdentifier;
3640
using DPVAL = o2::dcs::DataPointValue;
3741
using DPCOM = o2::dcs::DataPointCompositeObject;
3842

39-
struct TRDDCSMinMaxMeanInfo {
40-
float minValue{0.f}; // min value seen by the TRD DCS processor
41-
float maxValue{0.f}; // max value seen by the TRD DCS processor
42-
float meanValue{0.f}; // mean value seen by the TRD DCS processor
43-
int nPoints{0}; // number of values seen by the TRD DCS processor
44-
45-
void print() const;
46-
void addPoint(float value);
47-
48-
ClassDefNV(TRDDCSMinMaxMeanInfo, 1);
49-
};
50-
5143
class DCSProcessor
5244
{
5345

@@ -58,44 +50,91 @@ class DCSProcessor
5850
DCSProcessor() = default;
5951
~DCSProcessor() = default;
6052

53+
// initialization based on configured DP IDs
6154
void init(const std::vector<DPID>& pids);
6255

56+
// processing methods
6357
int process(const gsl::span<const DPCOM> dps);
6458
int processDP(const DPCOM& dpcom);
6559
int processFlags(uint64_t flag, const char* pid);
6660

67-
void updateDPsCCDB();
68-
69-
const CcdbObjectInfo& getccdbDPsInfo() const { return mCcdbDPsInfo; }
70-
CcdbObjectInfo& getccdbDPsInfo() { return mCcdbDPsInfo; }
71-
const std::unordered_map<DPID, TRDDCSMinMaxMeanInfo>& getTRDDPsInfo() const { return mTRDDCS; }
72-
73-
template <typename T>
74-
void prepareCCDBobjectInfo(T& obj, CcdbObjectInfo& info, const std::string& path, TFType tf,
75-
const std::map<std::string, std::string>& md);
76-
77-
void setStartValidity(TFType tf) { mStartValidity = tf; }
78-
void useVerboseMode() { mVerbose = true; }
79-
80-
void clearDPsinfo()
81-
{
82-
mDpsDoublesmap.clear();
83-
mTRDDCS.clear();
84-
}
61+
// these functions prepare the CCDB objects
62+
bool updateGasDPsCCDB();
63+
bool updateVoltagesDPsCCDB();
64+
bool updateCurrentsDPsCCDB();
65+
bool updateEnvDPsCCDB();
66+
bool updateRunDPsCCDB();
67+
68+
// signal that the CCDB object for the voltages should be updated due to change exceeding threshold
69+
bool shouldUpdateVoltages() const { return mShouldUpdateVoltages; }
70+
bool shouldUpdateRun() const { return mShouldUpdateRun; }
71+
72+
// allow access to the CCDB objects from DPL processor
73+
CcdbObjectInfo& getccdbGasDPsInfo() { return mCcdbGasDPsInfo; }
74+
CcdbObjectInfo& getccdbVoltagesDPsInfo() { return mCcdbVoltagesDPsInfo; }
75+
CcdbObjectInfo& getccdbCurrentsDPsInfo() { return mCcdbCurrentsDPsInfo; }
76+
CcdbObjectInfo& getccdbEnvDPsInfo() { return mCcdbEnvDPsInfo; }
77+
CcdbObjectInfo& getccdbRunDPsInfo() { return mCcdbRunDPsInfo; }
78+
const std::unordered_map<DPID, TRDDCSMinMaxMeanInfo>& getTRDGasDPsInfo() const { return mTRDDCSGas; }
79+
const std::unordered_map<DPID, float>& getTRDVoltagesDPsInfo() const { return mTRDDCSVoltages; }
80+
const std::unordered_map<DPID, TRDDCSMinMaxMeanInfo>& getTRDCurrentsDPsInfo() const { return mTRDDCSCurrents; }
81+
const std::unordered_map<DPID, TRDDCSMinMaxMeanInfo>& getTRDEnvDPsInfo() const { return mTRDDCSEnv; }
82+
const std::unordered_map<DPID, int>& getTRDRunDPsInfo() const { return mTRDDCSRun; }
83+
84+
// settings
85+
void setCurrentTS(TFType tf) { mCurrentTS = tf; }
86+
void setVerbosity(int v) { mVerbosity = v; }
87+
88+
// reset methods
89+
void clearGasDPsInfo();
90+
void clearVoltagesDPsInfo();
91+
void clearCurrentsDPsInfo();
92+
void clearEnvDPsInfo();
93+
void clearRunDPsInfo();
94+
95+
// helper functions
96+
int getChamberIdFromAlias(const char* alias) const;
8597

8698
private:
87-
std::unordered_map<DPID, TRDDCSMinMaxMeanInfo> mTRDDCS; // this is the object that will go to the CCDB
88-
std::unordered_map<DPID, bool> mPids; // contains all PIDs for the processor, the bool
89-
// will be true if the DP was processed at least once
90-
std::unordered_map<DPID, std::vector<DPCOM>> mDpsDoublesmap; // this is the map that will hold the DPs for the
91-
// double type
92-
93-
CcdbObjectInfo mCcdbDPsInfo;
94-
TFType mStartTF; // TF index for processing of first processed TF, used to store CCDB object
95-
TFType mStartValidity = 0; // TF index for processing, used to store CCDB object
96-
bool mStartTFset = false;
97-
98-
bool mVerbose = false;
99+
// the CCDB objects
100+
std::unordered_map<DPID, TRDDCSMinMaxMeanInfo> mTRDDCSGas; ///< gas DPs (CO2, O2, H20 and from the chromatograph CO2, N2, Xe)
101+
std::unordered_map<DPID, TRDDCSMinMaxMeanInfo> mTRDDCSCurrents; ///< anode and drift currents
102+
std::unordered_map<DPID, float> mTRDDCSVoltages; ///< anode and drift voltages
103+
std::unordered_map<DPID, TRDDCSMinMaxMeanInfo> mTRDDCSEnv; ///< environment parameters (temperatures, pressures)
104+
std::unordered_map<DPID, int> mTRDDCSRun; ///< run number and run type
105+
// TODO
106+
// Possibly add CFG tag and chamber status here?
107+
// Or send errors to the InfoLogger in case CFG tag mismatches are detected for chamber which have the same FSM state?
108+
// For this I need more information on the chamber status - which status indicates all good and included in data taking?
109+
// not TODO
110+
// I don't think the FED ENV temperature is needed at analysis level at any point in time so I am leaving it out for now
111+
112+
// helper variables
113+
std::unordered_map<DPID, bool> mPids; ///< flag for each DP whether it has been processed at least once
114+
std::unordered_map<DPID, uint64_t> mLastDPTimeStamps; ///< for each DP keep here the time stamp of the DP processed last
115+
CcdbObjectInfo mCcdbGasDPsInfo;
116+
CcdbObjectInfo mCcdbVoltagesDPsInfo;
117+
CcdbObjectInfo mCcdbCurrentsDPsInfo;
118+
CcdbObjectInfo mCcdbEnvDPsInfo;
119+
CcdbObjectInfo mCcdbRunDPsInfo;
120+
TFType mGasStartTS; ///< the time stamp of the first TF which was processesd for the current GAS CCDB object
121+
TFType mVoltagesStartTS; ///< the time stamp of the first TF which was processesd for the current voltages CCDB object
122+
TFType mCurrentsStartTS; ///< the time stamp of the first TF which was processesd for the current voltages CCDB object
123+
TFType mEnvStartTS;
124+
TFType mRunStartTS;
125+
TFType mRunEndTS;
126+
TFType mCurrentTS{0}; ///< the time stamp of the TF currently being processed
127+
bool mGasStartTSset{false};
128+
bool mVoltagesStartTSSet{false};
129+
bool mCurrentsStartTSSet{false};
130+
bool mEnvStartTSSet{false};
131+
bool mRunStartTSSet{false};
132+
std::bitset<constants::MAXCHAMBER> mVoltageSet{};
133+
bool mShouldUpdateVoltages{false};
134+
bool mShouldUpdateRun{false};
135+
136+
// settings
137+
int mVerbosity{0};
99138

100139
ClassDefNV(DCSProcessor, 0);
101140
};

Detectors/TRD/calibration/macros/makeTRDCCDBEntryForDCS.C

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,29 @@ int makeTRDCCDBEntryForDCS(const std::string url = "http://localhost:8080")
2828
// macro to populate CCDB for TRD with the configuration for DCS
2929
std::unordered_map<DPID, std::string> dpid2DataDesc;
3030
std::vector<std::string> aliasesFloat;
31+
std::vector<std::string> aliasesInt;
32+
std::vector<std::string> aliasesString;
3133
aliasesFloat.insert(aliasesFloat.end(), {"trd_gasCO2", "trd_gasH2O", "trd_gasO2"});
3234
aliasesFloat.insert(aliasesFloat.end(), {"trd_gaschromatographCO2", "trd_gaschromatographN2", "trd_gaschromatographXe"});
33-
// aliasesFloat.insert(aliasesFloat.end(), {"trd_hvAnodeImon[00..539]", "trd_hvAnodeUmon[00..539]", "trd_hvDriftImon[00..539]", "trd_hvDriftImon[00..539]"});
34-
// std::vector<std::string> aliasesInt = {"trd_fedChamberStatus[00..539]", "trd_runNo", "trd_runType"};
35-
std::vector<std::string> aliasesInt = {"trd_runNo", "trd_runType"};
36-
std::vector<std::string> expAliasesFloat = o2::dcs::expandAliases(aliasesFloat);
37-
std::vector<std::string> expAliasesInt = o2::dcs::expandAliases(aliasesInt);
35+
aliasesFloat.insert(aliasesFloat.end(), {"trd_hvAnodeImon[00..539]", "trd_hvAnodeUmon[00..539]", "trd_hvDriftImon[00..539]", "trd_hvDriftUmon[00..539]"});
36+
aliasesFloat.insert(aliasesFloat.end(), {"trd_aliEnvTempCavern", "trd_aliEnvTempP2"});
37+
aliasesFloat.insert(aliasesFloat.end(), {"trd_aliEnvPressure00", "trd_aliEnvPressure01", "trd_aliEnvPressure02"});
38+
aliasesInt.insert(aliasesInt.end(), {"trd_runNo", "trd_runType"});
39+
// aliasesFloat.insert(aliasesFloat.end(), {"trd_cavernHumidity", "trd_fedEnvTemp[00..539]"});
40+
// aliasesInt.insert(aliasesInt.end(), {"trd_fedChamberStatus[00..539]"});
41+
// aliasesString.insert(aliasesString.end(), {"trd_fedCFGtag[00..539]"});
3842

3943
DPID dpidTmp;
40-
for (size_t i = 0; i < expAliasesFloat.size(); ++i) {
41-
DPID::FILL(dpidTmp, expAliasesFloat[i], o2::dcs::DeliveryType::DPVAL_DOUBLE);
44+
for (const auto& ali : o2::dcs::expandAliases(aliasesFloat)) {
45+
DPID::FILL(dpidTmp, ali, o2::dcs::DeliveryType::DPVAL_DOUBLE);
4246
dpid2DataDesc[dpidTmp] = "TRDDATAPOINTS";
4347
}
44-
for (size_t i = 0; i < expAliasesInt.size(); ++i) {
45-
DPID::FILL(dpidTmp, expAliasesInt[i], o2::dcs::DeliveryType::DPVAL_INT);
48+
for (const auto& ali : o2::dcs::expandAliases(aliasesInt)) {
49+
DPID::FILL(dpidTmp, ali, o2::dcs::DeliveryType::DPVAL_INT);
50+
dpid2DataDesc[dpidTmp] = "TRDDATAPOINTS";
51+
}
52+
for (const auto& ali : o2::dcs::expandAliases(aliasesString)) {
53+
DPID::FILL(dpidTmp, ali, o2::dcs::DeliveryType::DPVAL_STRING);
4654
dpid2DataDesc[dpidTmp] = "TRDDATAPOINTS";
4755
}
4856

0 commit comments

Comments
 (0)