Project
Loading...
Searching...
No Matches
DeviceSpec.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#include "../src/WorkflowHelpers.h"
16#include <vector>
17#include <algorithm>
18#include <unordered_set>
19
20using namespace o2::framework;
21
22namespace o2
23{
24namespace framework
25{
26
27using LogicalChannelsMap = std::map<LogicalChannelRange, size_t>;
28
29// This calculates the distance between two strings. See:
30//
31// https://en.wikipedia.org/wiki/Levenshtein_distance
32//
33// For the full description
34size_t levenshteinDistance(const char* s, int len_s, const char* t, int len_t)
35{
36 size_t cost;
37
38 /* base case: empty strings */
39 if (len_s == 0) {
40 return len_t;
41 }
42 if (len_t == 0) {
43 return len_s;
44 }
45
46 /* test if last characters of the strings match */
47 if (s[len_s - 1] == t[len_t - 1]) {
48 cost = 0;
49 } else {
50 cost = 1;
51 }
52
53 return std::min(std::min(levenshteinDistance(s, len_s - 1, t, len_t) + 1,
54 levenshteinDistance(s, len_s, t, len_t - 1) + 1),
55 levenshteinDistance(s, len_s - 1, t, len_t - 1) + cost);
56}
57
58std::string findBestCandidate(const std::string& candidate, const LogicalChannelsMap& map)
59{
60 std::string result;
61 size_t score = -1;
62 for (const auto& pair : map) {
63 auto newScore = levenshteinDistance(candidate.c_str(), candidate.size(),
64 pair.first.name.c_str(), pair.first.name.size());
65 if (newScore < score) {
66 result = pair.first.name;
67 }
68 }
69 return result;
70}
71
72} // namespace framework
73} // namespace o2
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
GLuint64EXT * result
Definition glcorearb.h:5662
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
size_t levenshteinDistance(const char *s, int len_s, const char *t, int len_t)
std::string findBestCandidate(const std::string &candidate, const LogicalChannelsMap &map)
std::map< LogicalChannelRange, size_t > LogicalChannelsMap
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...