Skip to content

Commit 960f272

Browse files
aphecetcheshahor02
authored andcommitted
✨ Add MID DCS Processor by sharing (most of) source code with MCH.
Given that both MCH and MID share most of their DCS -> CCDB workflow, the initial MCH-only code has been moved to a new MUON/Common subdirectory, and the few differences between MCH and MID are handled at compile time using compilation definition (`-DMUON_SUBSYSTEM_MCH` or `-DMUON_SUBSYSTEM_MID`), so both subsystems share the source code (for the dcs processor itself and the little dcs-ccdb program used to quickly inspect what is in the CCDB for that subsystem). From that single source code we do generate different executables : - o2-calibration-mch-dcs-processor-workflow - o2-calibration-mid-dcs-processor-workflow - o2-mch-dcs-ccdb - o2-mid-dcs-ccdb so that each subsystem can be used completely independently. Note that for testing there are also `o2-calibration-[mid|mch]-dcs-sim-workflow` executables. Those executables do not share their source code as they are merely creating aliases, which _are_ different for both subsystems.
1 parent 9125dfc commit 960f272

File tree

10 files changed

+293
-118
lines changed

10 files changed

+293
-118
lines changed

Detectors/MUON/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
# granted to it by virtue of its status as an Intergovernmental Organization or
99
# submit itself to any jurisdiction.
1010

11+
add_subdirectory(Common)
1112
add_subdirectory(MCH)
1213
add_subdirectory(MID)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright CERN and copyright holders of ALICE O2. This software is distributed
2+
# under the terms of the GNU General Public License v3 (GPL Version 3), copied
3+
# verbatim in the file "COPYING".
4+
#
5+
# See http://alice-o2.web.cern.ch/license for full licensing information.
6+
#
7+
# In applying this license CERN does not waive the privileges and immunities
8+
# granted to it by virtue of its status as an Intergovernmental Organization or
9+
# submit itself to any jurisdiction.
10+
11+
set(subsystems "mch;mid")
12+
13+
foreach(det IN LISTS subsystems)
14+
string(TOUPPER ${det} DET)
15+
o2_add_executable(dcs-ccdb
16+
COMPONENT_NAME ${det}
17+
SOURCES src/dcs-ccdb.cxx
18+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsDCS O2::CCDB O2::${DET}Conditions
19+
TARGETVARNAME exe-dcs-ccdb)
20+
target_compile_definitions(${exe-dcs-ccdb} PRIVATE "MUON_SUBSYSTEM_${DET}")
21+
22+
o2_add_executable(${det}-dcs-processor-workflow
23+
COMPONENT_NAME calibration
24+
SOURCES src/dcs-processor-workflow.cxx
25+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsDCS O2::${DET}Conditions
26+
TARGETVARNAME exe-dcs-processor-workflow)
27+
target_compile_definitions(${exe-dcs-processor-workflow} PRIVATE "MUON_SUBSYSTEM_${DET}")
28+
29+
o2_add_executable(${det}-dcs-sim-workflow
30+
COMPONENT_NAME calibration
31+
SOURCES src/${det}-dcs-sim-workflow.cxx
32+
PUBLIC_LINK_LIBRARIES O2::DCStestWorkflow O2::${DET}Conditions)
33+
endforeach()
34+

Detectors/MUON/Common/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!-- doxy
2+
\page refDetectorsMUONCommon Common
3+
/doxy -->
4+
5+
# Common code for MID and MCH
6+
7+
For the moment the only commonality stems from the DCS to CCDB part, as
8+
both subsystems only transmit DCS datapoints to CCDB, without any particular
9+
treatment. So we use almost the same source code, but generate separate
10+
executables, e.g. to ease the integration with `dcs-proxy`-based workflows.
11+
12+
Note that MCH transmit both the HV and LV values to CCDB, while MID only
13+
transmit HV values.
14+
15+
## DCS to CCDB
16+
17+
To test the DCS to CCDB route you can use the following 3 parts worfklow pipeline :
18+
19+
```shell
20+
o2-calibration-mch-dcs-sim-workflow --max-timeframes 600 --max-cycles-no-full-map 10 -b | \
21+
o2-calibration-mch-dcs-processor-workflow --hv-max-size 0 --hv-max-duration 300 --lv-max-size 0 --lv-max-duration 300 -b | \
22+
o2-calibration-ccdb-populator-workflow --ccdb-path="http://localhost:6464" -b
23+
```
24+
25+
```shell
26+
o2-calibration-mid-dcs-sim-workflow --max-timeframes 600 --max-cycles-no-full-map 10 -b | \
27+
o2-calibration-mid-dcs-processor-workflow --hv-max-size 0 --hv-max-duration 300 -b | \
28+
o2-calibration-ccdb-populator-workflow --ccdb-path="http://localhost:6464" -b
29+
```
30+
31+
Note that the only difference (besides the mid vs mch naming) is the set of
32+
options of the `processor` device (handling just hv for mid and hv+lv for mch).
33+
34+
- `o2-calibration-[mch|mid]-dcs-sim-worfklow` is just generating fake random MCH or MID DCS data points,
35+
- `o2-calibration-[mch|mid]-dcs-processor-workflow` gathers the received data points into a container object
36+
- `o2-calibration-ccdb-populator-workflow` uploads the container object to the CCDB (in this example a local dev ccdb).
37+
38+
The container object that groups the datapoints is considered ready to be shipped either when the data points span a long enough duration (see the `--xxx-max-duration` option(s) of the `o2-calibration-[mch|mid]-dcs-processor-workflow`) or is big enough (see the `--xxx-max-size` option(s)).
39+
40+
## MCH DCS Data Points
41+
42+
### HV
43+
44+
The MCH high voltage (HV) system is composed of 188 channels :
45+
46+
- 48 channels for stations 1 and 2 (3 HV channel per quadrant x 16 quadrants)
47+
- 140 channels for stations 3, 4, 5 (1 HV channel per slat x 140 slats)
48+
49+
### LV
50+
51+
The MCH low voltage (LV) system is composed of 328 channels :
52+
53+
- 216 channels (108 x 2 different voltage values) to power up the front-end
54+
electronics (dualsampas)
55+
- 112 channels to power up the readout crates hosting the solar (readout) cards
56+
57+
## MID DCS Data Points
58+
59+
### HV
60+
61+
The MID high voltage (HV) system is composed of 72 channels, one channel per RPC.
62+
63+
## CCDB quick check
64+
65+
Besides the web browsing of the CCDB, another quick check can be performed with
66+
the `o2-[mch|mid]-dcs-ccdb` program to dump the DCS datapoints (hv, lv, or both) or
67+
the datapoint config valid at a given timestamp.
68+
69+
```
70+
$ o2-mch-dcs-ccdb --help
71+
$ o2-mch-dcs-ccdb --ccdb http://localhost:6464 --query hv --query lv --query dpconf
72+
$ o2-mid-dcs-ccdb --ccdb http://localhost:6464 --query hv --query dpconf
73+
```
74+
75+
The same programs can be used to upload to CCDB the DCS data point configuration
76+
for the dcs-proxy :
77+
78+
```
79+
$ o2-mch-dcs-ccdb --put-datapoint-config --ccdb http://localhost:8080
80+
$ o2-mid-dcs-ccdb --put-datapoint-config --ccdb http://localhost:8080
81+
```
82+

Detectors/MUON/MCH/Conditions/src/dcs-ccdb.cxx renamed to Detectors/MUON/Common/src/dcs-ccdb.cxx

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
#include "CCDB/CcdbApi.h"
1212
#include "DetectorsDCS/DataPointIdentifier.h"
1313
#include "DetectorsDCS/DataPointValue.h"
14+
#if defined(MUON_SUBSYSTEM_MCH)
1415
#include "MCHConditions/DCSNamer.h"
16+
#elif defined(MUON_SUBSYSTEM_MID)
17+
#include "MIDConditions/DCSNamer.h"
18+
#endif
1519
#include <boost/program_options.hpp>
1620
#include <ctime>
1721
#include <iostream>
@@ -21,24 +25,28 @@
2125
#include <string>
2226
#include <unordered_map>
2327
#include <vector>
28+
#include "subsysname.h"
2429

2530
namespace po = boost::program_options;
2631
using DPID = o2::dcs::DataPointIdentifier;
2732
using DPVAL = o2::dcs::DataPointValue;
2833
using DPMAP = std::unordered_map<DPID, std::vector<DPVAL>>;
2934

30-
const char* CCDB_DPCONF_NAME = "MCH/DCSconfig";
35+
std::string CcdbDpConfName()
36+
{
37+
return fmt::format("{}/DCSconfig", o2::muon::subsysname());
38+
}
3139

3240
bool verbose;
3341

3442
void doQueryHVLV(const std::string ccdbUrl, uint64_t timestamp, bool hv, bool lv)
3543
{
3644
std::vector<std::string> what;
3745
if (hv) {
38-
what.emplace_back("MCH/HV");
46+
what.emplace_back(fmt::format("{}/HV", o2::muon::subsysname()));
3947
}
4048
if (lv) {
41-
what.emplace_back("MCH/LV");
49+
what.emplace_back(fmt::format("{}/LV", o2::muon::subsysname()));
4250
}
4351

4452
auto sum =
@@ -77,7 +85,7 @@ void doQueryDataPointConfig(const std::string ccdbUrl, uint64_t timestamp)
7785
api.init(ccdbUrl);
7886
using DPCONF = std::unordered_map<DPID, std::string>;
7987
std::map<std::string, std::string> metadata;
80-
auto* m = api.retrieveFromTFileAny<DPCONF>(CCDB_DPCONF_NAME, metadata, timestamp);
88+
auto* m = api.retrieveFromTFileAny<DPCONF>(CcdbDpConfName().c_str(), metadata, timestamp);
8189
std::cout << "size of dpconf map = " << m->size() << std::endl;
8290
if (verbose) {
8391
for (auto& i : *m) {
@@ -89,20 +97,26 @@ void doQueryDataPointConfig(const std::string ccdbUrl, uint64_t timestamp)
8997
void makeCCDBEntryForDCS(const std::string ccdbUrl, uint64_t timestamp)
9098
{
9199
std::unordered_map<DPID, std::string> dpid2DataDesc;
100+
#if defined(MUON_SUBSYSTEM_MCH)
92101
auto aliases = o2::mch::dcs::aliases();
102+
#elif defined(MUON_SUBSYSTEM_MID)
103+
auto aliases = o2::mid::dcs::aliases();
104+
#endif
93105

94106
DPID dpidtmp;
95107
for (const auto& a : aliases) {
96108
DPID::FILL(dpidtmp, a, o2::dcs::DeliveryType::RAW_DOUBLE);
97-
dpid2DataDesc[dpidtmp] = "MCHDATAPOINTS";
109+
dpid2DataDesc[dpidtmp] = fmt::format("{}DATAPOINTS", o2::muon ::subsysname());
98110
}
99111

100112
o2::ccdb::CcdbApi api;
101113
api.init(ccdbUrl);
102114
std::map<std::string, std::string> md;
103-
std::cout << "storing config of " << dpid2DataDesc.size() << " MCH data points to " << CCDB_DPCONF_NAME << "\n";
115+
std::cout << "storing config of " << dpid2DataDesc.size()
116+
<< o2::muon::subsysname() << " data points to "
117+
<< CcdbDpConfName() << "\n";
104118

105-
api.storeAsTFileAny(&dpid2DataDesc, CCDB_DPCONF_NAME, md, timestamp);
119+
api.storeAsTFileAny(&dpid2DataDesc, CcdbDpConfName(), md, timestamp);
106120
}
107121

108122
bool match(const std::vector<std::string>& queries, const char* pattern)
@@ -141,7 +155,8 @@ int main(int argc, char** argv)
141155
po::store(po::command_line_parser(argc, argv).options(cmdline).run(), vm);
142156

143157
if (vm.count("help")) {
144-
std::cout << "This program printout summary information from MCH DCS entries.\n";
158+
std::cout << "This program printout summary information from "
159+
<< o2::muon::subsysname() << " DCS entries.\n";
145160
std::cout << usage << "\n";
146161
return 2;
147162
}
@@ -157,12 +172,21 @@ int main(int argc, char** argv)
157172
auto query = vm["query"].as<std::vector<std::string>>();
158173

159174
hv = match(query, ".*(hv)");
175+
#if defined(MUON_SUBSYSTEM_MCH)
160176
lv = match(query, ".*(lv)");
177+
#else
178+
lv = false;
179+
#endif
161180
dpconf = match(query, ".*(dpconf)");
162181

163182
if (!hv && !lv && !dpconf) {
164-
std::cout << "Must specify at least one of --hv or --lv\n";
165-
std::cout << usage << "\n";
183+
std::cout << "Must specify at least one of dpconf,hv";
184+
#if defined(MUON_SUBSYSTEM_MCH)
185+
std::cout << ",lv";
186+
#endif
187+
std::cout << " parameter to --query option\n";
188+
std::cout
189+
<< usage << "\n";
166190
return 3;
167191
}
168192

0 commit comments

Comments
 (0)