Skip to content

Commit cd1e614

Browse files
aphecetcheshahor02
authored andcommitted
MCH: introduce DCS data point processor
1 parent f515f50 commit cd1e614

File tree

7 files changed

+446
-3
lines changed

7 files changed

+446
-3
lines changed

Detectors/DCS/src/DetectorsDCSLinkDef.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#pragma link C++ struct o2::dcs::DataPointValue + ;
2020
#pragma link C++ class o2::dcs::DCSProcessor + ;
2121
#pragma link C++ class std::unordered_map < o2::dcs::DataPointIdentifier, o2::dcs::DataPointValue> + ;
22+
#pragma link C++ class std::unordered_map < o2::dcs::DataPointIdentifier, std::vector < o2::dcs::DataPointValue>> + ;
2223
#pragma link C++ function o2::dcs::expandAlias(const std::string&);
23-
#pragma link C++ function o2::dcs::expandAliases(const std::vector<std::string>&);
24+
#pragma link C++ function o2::dcs::expandAliases(const std::vector <std::string>&);
2425
#pragma link C++ class std::unordered_map < o2::dcs::DataPointIdentifier, std::string> + ;
2526

2627
#endif

Detectors/DCS/testWorkflow/src/DCSRandomDataGeneratorSpec.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ std::vector<int> generateIntegers(size_t size, int min, int max)
4747
}
4848
std::shuffle(begin(data), end(data), generator);
4949
for (auto i = 0; i < data.size(); ++i) {
50-
LOG(INFO) << "Generating randomly DP at index " << data[i];
50+
LOG(DEBUG) << "Generating randomly DP at index " << data[i];
5151
}
5252
return data;
5353
}
@@ -147,7 +147,7 @@ void DCSRandomDataGenerator::run(o2::framework::ProcessingContext& pc)
147147
TDatime d;
148148
auto dpcoms = generate(mDataPointHints, fraction, tfid);
149149

150-
LOG(INFO) << "***************** TF " << tfid << " has generated " << dpcoms.size() << " DPs for TOF";
150+
LOG(INFO) << "***************** TF " << tfid << " has generated " << dpcoms.size() << " DPs";
151151
pc.outputs().snapshot(Output{"DCS", mDataDescription, 0, Lifetime::Timeframe}, dpcoms);
152152
mTFs++;
153153
}

Detectors/MUON/MCH/Conditions/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,19 @@ if(BUILD_TESTING)
2222
PUBLIC_LINK_LIBRARIES O2::MCHConditions)
2323
endif()
2424

25+
o2_add_executable(dcs-check-ccdb
26+
COMPONENT_NAME mch
27+
SOURCES src/dcs-check-ccdb.cxx
28+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsDCS O2::MCHConditions O2::CCDB)
29+
30+
o2_add_executable(mch-dcs-processor-workflow
31+
COMPONENT_NAME calibration
32+
SOURCES workflow/dcs-processor-workflow.cxx
33+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsDCS O2::MCHConditions)
34+
35+
36+
o2_add_executable(mch-dcs-sim-workflow
37+
COMPONENT_NAME calibration
38+
SOURCES workflow/dcs-sim-workflow.cxx
39+
PUBLIC_LINK_LIBRARIES O2::DCStestWorkflow O2::MCHConditions)
40+

Detectors/MUON/MCH/Conditions/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66

77
## From DCS
88

9+
To test the DCS to CCDB route you can use the following 3 parts worfklow pipeline :
10+
11+
```shell
12+
o2-calibration-mch-dcs-sim-workflow --max-timeframes 10000 --max-cycles-no-full-map 100 -b | \
13+
o2-calibration-mch-dcs-processor-workflow -b | \
14+
o2-calibration-ccdb-populator-workflow --ccdb-path="http://localhost:6464" -b
15+
```
16+
17+
- `o2-calibration-mch-dcs-sim-worfklow` is just generating fake random MCH DCS data points,
18+
- `o2-calibration-mch-dcs-processor-workflow` gathers the received data points into a container object
19+
- `o2-calibration-ccdb-populator-workflow` uploads the container object to the CCDB (in this example a local dev ccdb).
20+
21+
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 `--calib-object-max-duration` option of the `o2-calibration-mch-dcs-processor-workflow`) or is big enough (see the `--calib-object-max-size` option).
22+
923
### HV
1024

1125
The MCH high voltage (HV) system is composed of 188 channels :
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied 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
9+
// or submit itself to any jurisdiction.
10+
11+
#include "CCDB/CcdbApi.h"
12+
#include "DetectorsDCS/DataPointIdentifier.h"
13+
#include "DetectorsDCS/DataPointValue.h"
14+
#include <boost/program_options.hpp>
15+
#include <ctime>
16+
#include <iostream>
17+
#include <numeric>
18+
#include <string>
19+
#include <unordered_map>
20+
#include <vector>
21+
22+
namespace po = boost::program_options;
23+
using DPID = o2::dcs::DataPointIdentifier;
24+
using DPVAL = o2::dcs::DataPointValue;
25+
using DPMAP = std::unordered_map<DPID, std::vector<DPVAL>>;
26+
27+
int main(int argc, char** argv)
28+
{
29+
po::variables_map vm;
30+
po::options_description usage("Usage");
31+
32+
std::string ccdbUrl;
33+
uint64_t timestamp;
34+
bool lv;
35+
bool hv;
36+
bool verbose;
37+
38+
std::time_t now = std::time(nullptr);
39+
40+
// clang-format off
41+
usage.add_options()
42+
("help,h", "produce help message")
43+
("ccdb",po::value<std::string>(&ccdbUrl)->default_value("http://localhost:6464"),"ccdb url")
44+
("timestamp,t",po::value<uint64_t>(&timestamp)->default_value(now),"timestamp to query")
45+
("hv",po::bool_switch(&hv),"query HV")
46+
("lv",po::bool_switch(&lv),"query LV")
47+
("verbose,v",po::bool_switch(&verbose),"verbose output")
48+
;
49+
// clang-format on
50+
51+
po::options_description cmdline;
52+
cmdline.add(usage);
53+
54+
po::store(po::command_line_parser(argc, argv).options(cmdline).run(), vm);
55+
56+
if (vm.count("help")) {
57+
std::cout << "This program printout summary information from MCH DCS entries.\n";
58+
std::cout << usage << "\n";
59+
return 2;
60+
}
61+
62+
try {
63+
po::notify(vm);
64+
} catch (boost::program_options::error& e) {
65+
std::cout << "Error: " << e.what() << "\n";
66+
exit(1);
67+
}
68+
69+
if (!hv && !lv) {
70+
std::cout << "Must specify at least one of --hv or --lv\n";
71+
std::cout << usage << "\n";
72+
return 3;
73+
}
74+
75+
std::vector<std::string> what;
76+
if (hv) {
77+
what.emplace_back("MCH/HV");
78+
}
79+
if (lv) {
80+
what.emplace_back("MCH/LV");
81+
}
82+
83+
// union Converter {
84+
// uint64_t raw_data;
85+
// T t_value;
86+
// };
87+
// if (dpcom.id.get_type() != dt) {
88+
// throw std::runtime_error("DPCOM is of unexpected type " + o2::dcs::show(dt));
89+
// }
90+
// Converter converter;
91+
// converter.raw_data = dpcom.data.payload_pt1;
92+
93+
auto sum =
94+
[](float s, o2::dcs::DataPointValue v) {
95+
union Converter {
96+
uint64_t raw_data;
97+
double value;
98+
} converter;
99+
converter.raw_data = v.payload_pt1;
100+
return s + converter.value;
101+
};
102+
103+
o2::ccdb::CcdbApi api;
104+
api.init(ccdbUrl);
105+
for (auto w : what) {
106+
std::map<std::string, std::string> metadata;
107+
auto* m = api.retrieveFromTFileAny<DPMAP>(w, metadata, timestamp);
108+
std::cout << "size of " << w << " map = " << m->size() << std::endl;
109+
if (verbose) {
110+
for (auto& i : *m) {
111+
auto v = i.second;
112+
auto mean = std::accumulate(v.begin(), v.end(), 0.0, sum);
113+
if (v.size()) {
114+
mean /= v.size();
115+
}
116+
std::cout << fmt::format("{:64s} {:4d} values of mean {:7.2f}\n", i.first.get_alias(), v.size(),
117+
mean);
118+
}
119+
}
120+
}
121+
return 0;
122+
}

0 commit comments

Comments
 (0)