Project
Loading...
Searching...
No Matches
Quadrant.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 "Quadrant.h"
13
14#include "LV.h"
17#include "MCHConditions/Side.h"
18#include <array>
19#include <fmt/core.h>
20#include <fmt/format.h>
21#include <set>
22#include <stdexcept>
23
25{
26Cathode lvAliasToCathode(std::string_view alias)
27{
28 const auto chamber = aliasToChamber(alias);
29 const auto side = aliasToSide(alias);
30 const auto number = aliasToNumber(alias);
31 int base = (1 + toInt(chamber)) * 100;
32 if (isStation1(chamber)) {
33 // Station 1
34 if (side == Side::Left) {
35 switch (number) {
36 case 4:
37 return {Cathode{base + 1, Plane::NonBending}};
38 case 2:
39 return {Cathode{base + 1, Plane::Bending}};
40 case 3:
41 return {Cathode{base + 2, Plane::Bending}};
42 case 1:
43 return {Cathode{base + 2, Plane::NonBending}};
44 default:
45 throw std::invalid_argument(fmt::format("wrong alias {}", alias));
46 }
47 } else {
48 switch (number) {
49 case 4:
50 return {Cathode{base + 0, Plane::Bending}};
51 case 2:
52 return {Cathode{base + 0, Plane::NonBending}};
53 case 3:
54 return {Cathode{base + 3, Plane::NonBending}};
55 case 1:
56 return {Cathode{base + 3, Plane::Bending}};
57 default:
58 throw std::invalid_argument(fmt::format("wrong alias {}", alias));
59 }
60 }
61 } else if (isStation2(chamber)) {
62 // Station 2
63 if (side == Side::Left) {
64 switch (number) {
65 case 2:
66 return {Cathode{base + 1, Plane::NonBending}};
67 case 1:
68 return {Cathode{base + 1, Plane::Bending}};
69 case 4:
70 return {Cathode{base + 2, Plane::Bending}};
71 case 3:
72 return {Cathode{base + 2, Plane::NonBending}};
73 default:
74 throw std::invalid_argument(fmt::format("wrong alias {}", alias));
75 }
76 } else {
77 switch (number) {
78 case 2:
79 return {Cathode{base + 0, Plane::Bending}};
80 case 1:
81 return {Cathode{base + 0, Plane::NonBending}};
82 case 4:
83 return {Cathode{base + 3, Plane::NonBending}};
84 case 3:
85 return {Cathode{base + 3, Plane::Bending}};
86 default:
87 throw std::invalid_argument(fmt::format("wrong alias {}", alias));
88 }
89 }
90 } else {
91 throw std::invalid_argument(fmt::format("wrong alias {} (expecting station12 one", alias));
92 }
93}
94
95std::set<DsIndex> solarAliasToDsIndices(std::string_view alias)
96{
102 // lvid.type = dcs::MeasurementType::LV_V_FEE_ANALOG;
103 static const std::array<int, 4> crateToGroupSt1 = {4, 2, 3, 1};
104 static const std::array<int, 4> crateToGroupSt2 = {2, 1, 4, 3};
105
106 auto chamber = aliasToChamber(alias);
107 auto solarCrate = aliasToNumber(alias);
108
109 int group;
110 if (isStation1(chamber)) {
111 group = crateToGroupSt1[solarCrate - 1];
112 } else {
113 group = crateToGroupSt2[solarCrate - 1];
114 }
115
116 auto side = aliasToSide(alias);
117 auto lvAlias = fmt::format("MchHvLv{}/Chamber{}{}/Group{}an",
118 name(side),
119 toInt(chamber),
120 name(side),
121 group);
122
123 return lvAliasToDsIndices(lvAlias);
124}
125} // namespace o2::mch::dcs::quadrant
uint32_t side
Definition RawData.h:0
GLuint const GLchar * name
Definition glcorearb.h:781
GLboolean GLuint group
Definition glcorearb.h:3991
std::set< DsIndex > solarAliasToDsIndices(std::string_view alias)
Definition Quadrant.cxx:95
Cathode lvAliasToCathode(std::string_view alias)
Definition Quadrant.cxx:26
int toInt(Chamber chamber)
Definition Chamber.cxx:69
bool isStation1(Chamber chamber)
Definition Chamber.cxx:59
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
std::set< DsIndex > lvAliasToDsIndices(std::string_view alias)
Definition LV.cxx:35
bool isStation2(Chamber chamber)
Definition Chamber.cxx:64