Project
Loading...
Searching...
No Matches
Plane.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
12#include "MCHConditions/Plane.h"
13
17#include "MCHConditions/Side.h"
18#include <algorithm>
19#include <fmt/core.h>
20#include <fmt/format.h>
21#include <stdexcept>
22
23namespace o2::mch::dcs
24{
25
26Plane aliasToPlane(std::string_view alias)
27{
28 auto chamber = aliasToChamber(alias);
29 if (isQuadrant(chamber)) {
30 // only in St12 can we get a dcs alias that is plane-dependent
31 // and only if the alias is for FEE LV
32 auto type = aliasToMeasurementType(alias);
33 if (type != MeasurementType::LV_V_FEE_ANALOG &&
34 type != MeasurementType::LV_V_FEE_DIGITAL) {
35 return Plane::Both;
36 }
37 auto number = aliasToNumber(alias);
38 auto side = aliasToSide(alias);
39 if (side == Side::Left) {
40 switch (number) {
41 case 1:
42 case 4:
43 return Plane::Bending;
44 case 2:
45 case 3:
46 return Plane::NonBending;
47 default:
48 throw std::invalid_argument(fmt::format("invalid number {} in alias={}", number, alias));
49 };
50 } else {
51 switch (number) {
52 case 2:
53 case 3:
54 return Plane::Bending;
55 case 1:
56 case 4:
57 return Plane::NonBending;
58 default:
59 throw std::invalid_argument(fmt::format("invalid number {} in alias={}", number, alias));
60 };
61 }
62 }
63 return Plane::Both;
64}
65
66std::string name(Plane p)
67{
68 switch (p) {
69 case Plane::Bending:
70 return "B";
71 case Plane::NonBending:
72 return "NB";
73 case Plane::Both:
74 return "";
75 }
76 return "INVALID";
77}
78} // namespace o2::mch::dcs
uint32_t side
Definition RawData.h:0
GLuint const GLchar * name
Definition glcorearb.h:781
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
MeasurementType aliasToMeasurementType(std::string_view alias)
Side aliasToSide(std::string_view alias)
Definition Side.cxx:23
Chamber aliasToChamber(std::string_view alias)
Definition Chamber.cxx:101
std::optional< Chamber > chamber(int chamberId)
Definition Chamber.cxx:18
int aliasToNumber(std::string_view dcsAlias)
Definition Number.cxx:31
Plane aliasToPlane(std::string_view alias)
Definition Plane.cxx:26
bool isQuadrant(Chamber chamber)
Definition Chamber.cxx:45