ATLAS Offline Software
Loading...
Searching...
No Matches
PixelConvert.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef PIXELCALIBALGS_PIXELCONVERT_H
6#define PIXELCALIBALGS_PIXELCONVERT_H
7
8#include <string>
9#include <sstream>
10#include <iostream>
11#include <fstream>
12#include <map>
13#include <memory>
14
15
16/*
17 This set of functions provide conversions tools between different
18 conventions of the Pixel modle ID:
19 - online module ID, described in ATL-IP-ES-0007
20 - offline module ID, described in ATL-SOFT-2001-004
21 - hash ID, 32 bits integer word, used internally in Athena
22
23 All functions are defined in PixelConvert namespace,
24 therefore can be accessed by prefixing them with PixelConvert::
25 or by using the PixelConvert namespace.
26
27 Some of the funtions provide a consistency check of the input,
28 signalling an illegal module ID.
29 */
30
31namespace PixelConvert {
32
33 extern const int NLayer;
34 extern const int BSMax[];
35 extern const int EtaMax;
36 extern const int NinSector;
37 extern const int NinDisk;
38 extern const std::string Error;
39
40 /*
41 UTILITY FUNCTIONS
42 to encode and decode the integers described in ATL-SOFT-2001-004
43 and the corresponding string the "/" separators.
44
45 No consistency check is performed on the arguments to this fuctions.
46
47 PixelConvert::UnpackOfflineID return 0 if an error occurs while
48 decoding the string (too few fields), and 1 if decoding succeeds.
49 Since no consistency check is performed, this indicates only
50 that the string was decoded, not that the unpacked content
51 correspond to a real channel.
52 */
53
54 std::string PackOfflineID(int system,
55 int subSystem,
56 int endcap,
57 int layer,
58 int phi,
59 int eta);
60
61 int UnpackOfflineID(const std::string& offlineID,
62 int& system,
63 int& subSystem,
64 int& endcap,
65 int& layer,
66 int& phi,
67 int& eta);
68
69 /*
70 ONLINE ID
71 All the PixelConvert::OnlineID functions provide the string
72 defined according to ATL-IP-ES-0007 which defines a certain
73 module.
74
75 A consistency check on the input data is performed and
76 all these functions return the string PixelConvert::Error
77 if the input data do not correspond to a real channel.
78
79 The conversion from the offline ID to the online ID can be
80 performed by using either the unpacked or packed forms.
81 */
82
83 std::string OnlineID(int system,
84 int subSystem,
85 int endcap,
86 int layer,
87 int phi,
88 int eta);
89
90 std::string OnlineID(const std::string& offlineID);
91
92 std::string OnlineID(int hashID);
93
94 std::string OnlineIDfromDCSID(const std::string& DCSID);
95
96 /*
97 OFFLINE ID
98 All the PixelConvert::OfflineID functions provide either the
99 string defined according to ATL-SOFT-2001-004 which defines a
100 certain module, or the corresponding set of unpacked integer
101 values.
102
103
104 A consistency check on the input data is performed for all
105 the functions that translate the online ID.
106 If the requested return value is a string, the sring
107 PixelConvert::Error is given back
108 if the input data do not correspond to a real channel.
109 If the set of unpacked integers is used, a 0 return value
110 is provided if the input data do not correspond to a
111 real channel.
112
113 No consistency check is performed if the conversion start from the
114 hash ID.
115 */
116
117 int OfflineID(const std::string& onlineID,
118 int& system,
119 int& subSystem,
120 int& endcap,
121 int& layer,
122 int& phi,
123 int& eta);
124
125 std::string OfflineID(const std::string& onlineID);
126
127 int OfflineID(int hashID,
128 int& system,
129 int& subSystem,
130 int& endcap,
131 int& layer,
132 int& phi,
133 int& eta);
134
135 std::string OfflineID(int hashID);
136
137 /*
138 HASH ID
139 All the PixelConvert::HashID functions provide 32-bits hash code
140 which defines a certain module internally in Athena.
141
142 If the conversion start from a string, either the online ID or
143 offline ID can be provided, and the function will try to decode
144 the one used. A failure is detected by a return code of -1.
145 A consistency check on the input data is performed if the online ID
146 is used. If an offline ID string is provided, this is simply unpacked
147 and a return code of -1 happens only if the string cannot be unpacked,
148 but does not provide any check on the consistency of the provided
149 module identifiers.
150
151 If the conversion starts from the unpacked offline ID, no consistency
152 check is performed.
153 */
154
155 int HashID(const std::string& ID);
156
157 int HashID(int system,
158 int subSystem,
159 int endcap,
160 int layer,
161 int phi,
162 int eta);
163
164 /*
165 DCSID
166
167 This is the internal format of channel ID used in DCS.
168 With respect to the OnlineID, sector labelling is changed:
169 S01 -> B01_S02
170 S02 -> B02_S01
171 S03 -> B02_S02
172 S04 -> B03_S01
173 S05 -> B03_S02
174 S06 -> B04_S01
175 S07 -> B04_S02
176 S08 -> B01_S01
177
178 Moreover '-' characters, which are illegal in DCS, are replaced by
179 a '_' character.
180
181 Conversion to DCSID is provided only from OnlineID and a compatibility
182 check is done on sector number, returning a PixelConvert::Error in
183 case the range cheching fails.
184
185 */
186 std::string DCSID(const std::string& OnlineID);
187
188
189 struct Map
190 {
191 typedef std::map<unsigned int,unsigned int> modulemap;
192 std::unique_ptr<modulemap> m_hashIndex;
193 std::unique_ptr<modulemap> m_SNIndex;
194 };
195 int ReadMap(const std::string& filename, Map& map);
196 unsigned int GetID(const Map& map, const unsigned int moduleID);
197
198}
199
200#endif
struct _DCSID DCSID
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::vector< Identifier > ID
STL class.
unsigned int GetID(const Map &map, const unsigned int moduleID)
const int NLayer
const int NinSector
int UnpackOfflineID(const std::string &offlineID, int &system, int &subSystem, int &endcap, int &layer, int &phi, int &eta)
const std::string Error
const int EtaMax
std::string OnlineIDfromDCSID(const std::string &DCSID)
std::string DCSID(const std::string &OnlineID)
const int NinDisk
int HashID(const std::string &ID)
std::string PackOfflineID(int system, int subSystem, int endcap, int layer, int phi, int eta)
int OfflineID(const std::string &onlineID, int &system, int &subSystem, int &endcap, int &layer, int &phi, int &eta)
int ReadMap(const std::string &filename, Map &map)
std::string OnlineID(int system, int subSystem, int endcap, int layer, int phi, int eta)
const int BSMax[]
std::map< unsigned int, unsigned int > modulemap
std::unique_ptr< modulemap > m_hashIndex
std::unique_ptr< modulemap > m_SNIndex