Project
Loading...
Searching...
No Matches
DataPointGenerator.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
17#include "Framework/Logger.h"
18#include <fmt/format.h>
19#include <random>
20#include <utility>
21#include <type_traits>
22#include <cstdint>
23
24namespace
25{
26std::pair<uint32_t, uint16_t> getDate(const std::string& refDate)
27{
28
29 uint32_t seconds;
30 if (refDate.empty()) {
31 auto current = std::time(nullptr);
32 auto t = std::localtime(&current);
33 seconds = mktime(t);
34 } else {
35 std::tm t{};
36 std::istringstream ss(refDate);
37 ss >> std::get_time(&t, "%Y-%b-%d %H:%M:%S");
38 if (ss.fail()) { // let's see if it was passed as a TDatime, as SQL string
39 std::tm tt{};
40 std::istringstream sss(refDate);
41 sss >> std::get_time(&tt, "%Y-%m-%d %H:%M:%S");
42 if (sss.fail()) {
43 std::tm ttt{};
44 std::istringstream ssss(refDate);
45 ssss >> std::get_time(&tt, "%Y-%B-%d %H:%M:%S");
46 if (ssss.fail()) {
47 LOG(error) << "We cannot parse the date";
48 }
49 seconds = mktime(&ttt);
50 } else {
51 seconds = mktime(&tt);
52 }
53 } else {
54 seconds = mktime(&t);
55 }
56 }
57 uint16_t msec = 5;
58 return std::make_pair(seconds, msec);
59}
60
61} // namespace
62
63namespace o2::dcs
64{
65
66// std::enable_if_t<std::is_arithmetic<T>::value, bool> = true>
67
68template <typename T>
69std::vector<o2::dcs::DataPointCompositeObject>
70 generateRandomDataPoints(const std::vector<std::string>& aliases,
71 T minValue, T maxValue, std::string refDate)
72{
73 std::vector<o2::dcs::DataPointCompositeObject> dpcoms;
74 static_assert(std::is_arithmetic<T>::value, "T must be an arithmetic type");
75 using distType = std::conditional_t<std::is_integral<T>::value,
76 std::uniform_int_distribution<long long>,
77 std::uniform_real_distribution<T>>;
78 std::random_device rd;
79 std::mt19937 mt(rd());
80 distType dist{minValue, maxValue};
81 auto [seconds, msec] = getDate(refDate);
82 for (auto alias : expandAliases(aliases)) {
83 T value = dist(mt);
84 dpcoms.emplace_back(o2::dcs::createDataPointCompositeObject(alias, value, seconds, msec));
85 }
86 return dpcoms;
87}
88
89// only specialize the functions for the types we support :
90//
91// - double
92// - float
93// - uint32_t
94// - int32_t
95// - char
96// - bool
97//
98// - std::string
99
100template std::vector<o2::dcs::DataPointCompositeObject> generateRandomDataPoints<double>(const std::vector<std::string>& aliases, double minValue, double maxValue, std::string);
101
102template std::vector<o2::dcs::DataPointCompositeObject> generateRandomDataPoints<float>(const std::vector<std::string>& aliases, float minValue, float maxValue, std::string);
103
104template std::vector<o2::dcs::DataPointCompositeObject> generateRandomDataPoints<uint32_t>(const std::vector<std::string>& aliases, uint32_t minValue, uint32_t maxValue, std::string);
105
106template std::vector<o2::dcs::DataPointCompositeObject> generateRandomDataPoints<int32_t>(const std::vector<std::string>& aliases, int32_t minValue, int32_t maxValue, std::string);
107
108template std::vector<o2::dcs::DataPointCompositeObject> generateRandomDataPoints<long long>(const std::vector<std::string>& aliases, long long minValue, long long maxValue, std::string);
109
110template std::vector<o2::dcs::DataPointCompositeObject> generateRandomDataPoints<char>(const std::vector<std::string>& aliases, char minValue, char maxValue, std::string);
111
115template <>
116std::vector<o2::dcs::DataPointCompositeObject> generateRandomDataPoints<bool>(const std::vector<std::string>& aliases, bool minValue, bool maxValue, std::string refDate)
117{
118 std::vector<o2::dcs::DataPointCompositeObject> dpcoms;
119 std::random_device rd;
120 std::mt19937 mt(rd());
121 std::uniform_int_distribution dist{0, 1};
122 auto [seconds, msec] = getDate(refDate);
123 for (auto alias : expandAliases(aliases)) {
124 bool value = dist(mt);
125 dpcoms.emplace_back(o2::dcs::createDataPointCompositeObject(alias, value, seconds, msec));
126 }
127 return dpcoms;
128}
129
134template <>
135std::vector<o2::dcs::DataPointCompositeObject> generateRandomDataPoints<std::string>(const std::vector<std::string>& aliases, std::string minLength, std::string maxLength, std::string refDate)
136{
137 std::vector<o2::dcs::DataPointCompositeObject> dpcoms;
138 std::random_device rd;
139 std::mt19937 mt(rd());
140 std::uniform_int_distribution<std::string::size_type> dist{minLength.size(), maxLength.size()};
141 auto [seconds, msec] = getDate(refDate);
142 for (auto alias : expandAliases(aliases)) {
143 std::string value = o2::dcs::random_string2(dist(mt));
144 dpcoms.emplace_back(o2::dcs::createDataPointCompositeObject(alias, value, seconds, msec));
145 }
146 return dpcoms;
147}
148} // namespace o2::dcs
unsigned short int uint16_t
unsigned int uint32_t
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 ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
char error[CURL_ERROR_SIZE]
GLsizei const GLfloat * value
Definition glcorearb.h:819
std::string random_string2(const size_t length) noexcept
std::vector< o2::dcs::DataPointCompositeObject > generateRandomDataPoints< bool >(const std::vector< std::string > &aliases, bool minValue, bool maxValue, std::string refDate)
std::vector< std::string > expandAliases(const std::vector< std::string > &patternedAliases)
template std::vector< o2::dcs::DataPointCompositeObject > generateRandomDataPoints< char >(const std::vector< std::string > &aliases, char minValue, char maxValue, std::string)
o2::dcs::DataPointCompositeObject createDataPointCompositeObject(const std::string &alias, T val, uint32_t seconds, uint16_t msec, uint16_t flags=0)
std::vector< DataPointCompositeObject > generateRandomDataPoints(const std::vector< std::string > &aliases, T min, T max, std::string refDate="")
template std::vector< o2::dcs::DataPointCompositeObject > generateRandomDataPoints< int32_t >(const std::vector< std::string > &aliases, int32_t minValue, int32_t maxValue, std::string)
template std::vector< o2::dcs::DataPointCompositeObject > generateRandomDataPoints< long long >(const std::vector< std::string > &aliases, long long minValue, long long maxValue, std::string)
template std::vector< o2::dcs::DataPointCompositeObject > generateRandomDataPoints< double >(const std::vector< std::string > &aliases, double minValue, double maxValue, std::string)
template std::vector< o2::dcs::DataPointCompositeObject > generateRandomDataPoints< float >(const std::vector< std::string > &aliases, float minValue, float maxValue, std::string)
std::vector< o2::dcs::DataPointCompositeObject > generateRandomDataPoints< std::string >(const std::vector< std::string > &aliases, std::string minLength, std::string maxLength, std::string refDate)
template std::vector< o2::dcs::DataPointCompositeObject > generateRandomDataPoints< uint32_t >(const std::vector< std::string > &aliases, uint32_t minValue, uint32_t maxValue, std::string)
std::vector< std::string > aliases(std::vector< MeasurementType > types={ MeasurementType::HV_V, MeasurementType::HV_I, MeasurementType::LV_V_FEE_ANALOG, MeasurementType::LV_V_FEE_DIGITAL, MeasurementType::LV_V_SOLAR})
std::mt19937 mt(rd())
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::random_device rd