CMS 3D CMS Logo

AlignableObjectId.cc
Go to the documentation of this file.
2 
3 #include <algorithm>
4 
7 
10  const char *name;
11 };
12 
13 namespace {
14 
15  constexpr AlignableObjectId::entry entries_RunI[]{{align::invalid, "invalid"},
16  {align::AlignableDetUnit, "DetUnit"},
17  {align::AlignableDet, "Det"},
18 
19  {align::TPBModule, "TPBModule"},
20  {align::TPBLadder, "TPBLadder"},
21  {align::TPBLayer, "TPBLayer"},
22  {align::TPBHalfBarrel, "TPBHalfBarrel"},
23  {align::TPBBarrel, "TPBBarrel"},
24 
25  {align::TPEModule, "TPEModule"},
26  {align::TPEPanel, "TPEPanel"},
27  {align::TPEBlade, "TPEBlade"},
28  {align::TPEHalfDisk, "TPEHalfDisk"},
29  {align::TPEHalfCylinder, "TPEHalfCylinder"},
30  {align::TPEEndcap, "TPEEndcap"},
31 
32  {align::TIBModule, "TIBModule"},
33  {align::TIBString, "TIBString"},
34  {align::TIBSurface, "TIBSurface"},
35  {align::TIBHalfShell, "TIBHalfShell"},
36  {align::TIBLayer, "TIBLayer"},
37  {align::TIBHalfBarrel, "TIBHalfBarrel"},
38  {align::TIBBarrel, "TIBBarrel"},
39 
40  {align::TIDModule, "TIDModule"},
41  {align::TIDSide, "TIDSide"},
42  {align::TIDRing, "TIDRing"},
43  {align::TIDDisk, "TIDDisk"},
44  {align::TIDEndcap, "TIDEndcap"},
45 
46  {align::TOBModule, "TOBModule"},
47  {align::TOBRod, "TOBRod"},
48  {align::TOBLayer, "TOBLayer"},
49  {align::TOBHalfBarrel, "TOBHalfBarrel"},
50  {align::TOBBarrel, "TOBBarrel"},
51 
52  {align::TECModule, "TECModule"},
53  {align::TECRing, "TECRing"},
54  {align::TECPetal, "TECPetal"},
55  {align::TECSide, "TECSide"},
56  {align::TECDisk, "TECDisk"},
57  {align::TECEndcap, "TECEndcap"},
58 
59  {align::Pixel, "Pixel"},
60  {align::Strip, "Strip"},
61  {align::Tracker, "Tracker"},
62 
63  {align::AlignableDTBarrel, "DTBarrel"},
64  {align::AlignableDTWheel, "DTWheel"},
65  {align::AlignableDTStation, "DTStation"},
66  {align::AlignableDTChamber, "DTChamber"},
67  {align::AlignableDTSuperLayer, "DTSuperLayer"},
68  {align::AlignableDTLayer, "DTLayer"},
69  {align::AlignableCSCEndcap, "CSCEndcap"},
70  {align::AlignableCSCStation, "CSCStation"},
71  {align::AlignableCSCRing, "CSCRing"},
72  {align::AlignableCSCChamber, "CSCChamber"},
73  {align::AlignableCSCLayer, "CSCLayer"},
74  {align::AlignableMuon, "Muon"},
75 
76  {align::BeamSpot, "BeamSpot"},
77  {align::notfound, nullptr}};
78 
79  constexpr AlignableObjectId::entry entries_PhaseI[]{{align::invalid, "invalid"},
80  {align::AlignableDetUnit, "DetUnit"},
81  {align::AlignableDet, "Det"},
82 
83  {align::TPBModule, "P1PXBModule"},
84  {align::TPBLadder, "P1PXBLadder"},
85  {align::TPBLayer, "P1PXBLayer"},
86  {align::TPBHalfBarrel, "P1PXBHalfBarrel"},
87  {align::TPBBarrel, "P1PXBBarrel"},
88 
89  {align::TPEModule, "P1PXECModule"},
90  {align::TPEPanel, "P1PXECPanel"},
91  {align::TPEBlade, "P1PXECBlade"},
92  {align::TPEHalfDisk, "P1PXECHalfDisk"},
93  {align::TPEHalfCylinder, "P1PXECHalfCylinder"},
94  {align::TPEEndcap, "P1PXECEndcap"},
95 
96  {align::TIBModule, "TIBModule"},
97  {align::TIBString, "TIBString"},
98  {align::TIBSurface, "TIBSurface"},
99  {align::TIBHalfShell, "TIBHalfShell"},
100  {align::TIBLayer, "TIBLayer"},
101  {align::TIBHalfBarrel, "TIBHalfBarrel"},
102  {align::TIBBarrel, "TIBBarrel"},
103 
104  {align::TIDModule, "TIDModule"},
105  {align::TIDSide, "TIDSide"},
106  {align::TIDRing, "TIDRing"},
107  {align::TIDDisk, "TIDDisk"},
108  {align::TIDEndcap, "TIDEndcap"},
109 
110  {align::TOBModule, "TOBModule"},
111  {align::TOBRod, "TOBRod"},
112  {align::TOBLayer, "TOBLayer"},
113  {align::TOBHalfBarrel, "TOBHalfBarrel"},
114  {align::TOBBarrel, "TOBBarrel"},
115 
116  {align::TECModule, "TECModule"},
117  {align::TECRing, "TECRing"},
118  {align::TECPetal, "TECPetal"},
119  {align::TECSide, "TECSide"},
120  {align::TECDisk, "TECDisk"},
121  {align::TECEndcap, "TECEndcap"},
122 
123  {align::Pixel, "Pixel"},
124  {align::Strip, "Strip"},
125  {align::Tracker, "Tracker"},
126 
127  {align::AlignableDTBarrel, "DTBarrel"},
128  {align::AlignableDTWheel, "DTWheel"},
129  {align::AlignableDTStation, "DTStation"},
130  {align::AlignableDTChamber, "DTChamber"},
131  {align::AlignableDTSuperLayer, "DTSuperLayer"},
132  {align::AlignableDTLayer, "DTLayer"},
133  {align::AlignableCSCEndcap, "CSCEndcap"},
134  {align::AlignableCSCStation, "CSCStation"},
135  {align::AlignableCSCRing, "CSCRing"},
136  {align::AlignableCSCChamber, "CSCChamber"},
137  {align::AlignableCSCLayer, "CSCLayer"},
138  {align::AlignableGEMEndcap, "GEMEndcap"},
139  {align::AlignableGEMStation, "GEMStation"},
140  {align::AlignableGEMRing, "GEMRing"},
141  {align::AlignableGEMSuperChamber, "GEMSuperChamber"},
142  {align::AlignableGEMChamber, "GEMChamber"},
143  {align::AlignableGEMEtaPartition, "GEMEtaPartition"},
144  {align::AlignableMuon, "Muon"},
145 
146  {align::BeamSpot, "BeamSpot"},
147  {align::notfound, nullptr}};
148 
149  constexpr AlignableObjectId::entry entries_PhaseII[]{{align::invalid, "invalid"},
150  {align::AlignableDetUnit, "DetUnit"},
151  {align::AlignableDet, "Det"},
152 
153  {align::TPBModule, "P2PXBModule"},
154  {align::TPBLadder, "P2PXBLadder"},
155  {align::TPBLayer, "P2PXBLayer"},
156  {align::TPBHalfBarrel, "P2PXBHalfBarrel"},
157  {align::TPBBarrel, "P2PXBBarrel"},
158 
159  {align::TPEModule, "P2PXECModule"},
160  {align::TPEPanel, "P2PXECPanel"},
161  {align::TPEBlade, "P2PXECBlade"},
162  {align::TPEHalfDisk, "P2PXECHalfDisk"},
163  {align::TPEHalfCylinder, "P2PXECHalfCylinder"},
164  {align::TPEEndcap, "P2PXECEndcap"},
165 
166  // TIB doesn't exit in PhaseII
167  {align::TIBModule, "TIBModule-INVALID"},
168  {align::TIBString, "TIBString-INVALID"},
169  {align::TIBSurface, "TIBSurface-INVALID"},
170  {align::TIBHalfShell, "TIBHalfShell-INVALID"},
171  {align::TIBLayer, "TIBLayer-INVALID"},
172  {align::TIBHalfBarrel, "TIBHalfBarrel-INVALID"},
173  {align::TIBBarrel, "TIBBarrel-INVALID"},
174 
175  {align::TIDModule, "P2OTECModule"},
176  {align::TIDSide, "P2OTECSide"},
177  {align::TIDRing, "P2OTECRing"},
178  {align::TIDDisk, "P2OTECDisk"},
179  {align::TIDEndcap, "P2OTECEndcap"},
180 
181  {align::TOBModule, "P2OTBModule"},
182  {align::TOBRod, "P2OTBRod"},
183  {align::TOBLayer, "P2OTBLayer"},
184  {align::TOBHalfBarrel, "P2OTBHalfBarrel"},
185  {align::TOBBarrel, "P2OTBBarrel"},
186 
187  // TEC doesn't exit in PhaseII
188  {align::TECModule, "TECModule-INVALID"},
189  {align::TECRing, "TECRing-INVALID"},
190  {align::TECPetal, "TECPetal-INVALID"},
191  {align::TECSide, "TECSide-INVALID"},
192  {align::TECDisk, "TECDisk-INVALID"},
193  {align::TECEndcap, "TECEndcap-INVALID"},
194 
195  {align::Pixel, "Pixel"},
196  {align::Strip, "Strip"},
197  {align::Tracker, "Tracker"},
198 
199  {align::AlignableDTBarrel, "DTBarrel"},
200  {align::AlignableDTWheel, "DTWheel"},
201  {align::AlignableDTStation, "DTStation"},
202  {align::AlignableDTChamber, "DTChamber"},
203  {align::AlignableDTSuperLayer, "DTSuperLayer"},
204  {align::AlignableDTLayer, "DTLayer"},
205  {align::AlignableCSCEndcap, "CSCEndcap"},
206  {align::AlignableCSCStation, "CSCStation"},
207  {align::AlignableCSCRing, "CSCRing"},
208  {align::AlignableCSCChamber, "CSCChamber"},
209  {align::AlignableCSCLayer, "CSCLayer"},
210  {align::AlignableGEMEndcap, "GEMEndcap"},
211  {align::AlignableGEMStation, "GEMStation"},
212  {align::AlignableGEMRing, "GEMRing"},
213  {align::AlignableGEMSuperChamber, "GEMSuperChamber"},
214  {align::AlignableGEMChamber, "GEMChamber"},
215  {align::AlignableGEMEtaPartition, "GEMEtaPartition"},
216  {align::AlignableMuon, "Muon"},
217 
218  {align::BeamSpot, "BeamSpot"},
219  {align::notfound, nullptr}};
220 
221  constexpr bool same(char const *x, char const *y) { return !*x && !*y ? true : (*x == *y && same(x + 1, y + 1)); }
222 
223  constexpr char const *objectIdToString(align::StructureType type, AlignableObjectId::entry const *entries) {
224  return !entries->name ? nullptr : entries->type == type ? entries->name : objectIdToString(type, entries + 1);
225  }
226 
227  constexpr enum align::StructureType stringToObjectId(char const *name, AlignableObjectId::entry const *entries) {
228  return !entries->name ? align::invalid
229  : same(entries->name, name) ? entries->type
230  : stringToObjectId(name, entries + 1);
231  }
232 } // namespace
233 
234 //_____________________________________________________________________________
236  switch (geometry) {
238  entries_ = entries_RunI;
239  break;
241  entries_ = entries_PhaseI;
242  break;
244  entries_ = entries_PhaseII;
245  break;
247  entries_ = entries_RunI;
248  break;
250  entries_ = nullptr;
251  break;
252  }
253  if (!entries_) {
254  throw cms::Exception("LogicError") << "@SUB=AlignableObjectId::ctor\n"
255  << "trying to create AlignableObjectId with unspecified geometry";
256  }
257 }
258 
259 //_____________________________________________________________________________
261  const DTGeometry *muonDt,
262  const CSCGeometry *muonCsc,
263  const GEMGeometry *muonGem)
264  : AlignableObjectId(commonGeometry(trackerGeometry(tracker), muonGeometry(muonDt, muonCsc, muonGem))) {}
265 
266 //_____________________________________________________________________________
268 
269 //_____________________________________________________________________________
271 
272 //_____________________________________________________________________________
274  const char *result = objectIdToString(type, entries_);
275 
276  if (result == nullptr) {
277  throw cms::Exception("AlignableObjectIdError") << "Unknown alignableObjectId " << type;
278  }
279 
280  return result;
281 }
282 
283 //_____________________________________________________________________________
285  auto result = stringToObjectId(name, entries_);
286  if (result == -1) {
287  throw cms::Exception("AlignableObjectIdError") << "Unknown alignableObjectId " << name;
288  }
289 
290  return result;
291 }
292 
293 //______________________________________________________________________________
295  if (!geometry)
296  return Geometry::General;
297 
298  if (geometry->isThere(GeomDetEnumerators::P2PXEC)) {
299  // use structure-type <-> name translation for PhaseII geometry
300  return Geometry::PhaseII;
301 
302  } else if (geometry->isThere(GeomDetEnumerators::P1PXEC)) {
303  // use structure-type <-> name translation for PhaseI geometry
304  return Geometry::PhaseI;
305 
306  } else if (geometry->isThere(GeomDetEnumerators::PixelEndcap)) {
307  // use structure-type <-> name translation for RunI geometry
308  return Geometry::RunI;
309 
310  } else {
311  throw cms::Exception("AlignableObjectIdError") << "@SUB=AlignableObjectId::trackerGeometry\n"
312  << "unknown version of TrackerGeometry";
313  }
314 }
315 
317  const CSCGeometry *,
318  const GEMGeometry *) {
319  // muon alignment structure types are identical for all kinds of geometries
320  return Geometry::General;
321 }
322 
324  if (first == Geometry::General)
325  return second;
326  if (second == Geometry::General)
327  return first;
328  if (first == second)
329  return first;
330 
331  throw cms::Exception("AlignableObjectIdError") << "@SUB=AlignableObjectId::commonGeometry\n"
332  << "impossible to find common geometry because the two geometries are "
333  << "different and none of them is 'General'";
334 }
335 
337  const AlignableObjectId &second) {
338  return AlignableObjectId{commonGeometry(first.geometry(), second.geometry())};
339 }
DTGeometry
Definition: DTGeometry.h:28
AlignableObjectId
Allows conversion between type and name, and vice-versa.
Definition: AlignableObjectId.h:13
align::TPBHalfBarrel
Definition: StructureType.h:26
AlignableObjectId::Geometry::RunI
align::TPEHalfDisk
Definition: StructureType.h:33
AlignableObjectId::typeToName
std::string typeToName(align::StructureType type) const
Convert type to name.
Definition: AlignableObjectId.cc:270
align::TPBBarrel
Definition: StructureType.h:27
align::TPEBlade
Definition: StructureType.h:32
TrackerGeometry.h
align::TECEndcap
Definition: StructureType.h:66
align::BeamSpot
Definition: StructureType.h:95
align::TOBBarrel
Definition: StructureType.h:58
align::TPBLayer
Definition: StructureType.h:25
geometry
Definition: geometry.py:1
align::TIBSurface
Definition: StructureType.h:40
align::TOBModule
Definition: StructureType.h:54
align::AlignableGEMChamber
Definition: StructureType.h:88
align::TPEEndcap
Definition: StructureType.h:35
align::TIBModule
Definition: StructureType.h:38
AlignableObjectId::commonObjectIdProvider
static AlignableObjectId commonObjectIdProvider(const AlignableObjectId &, const AlignableObjectId &)
Definition: AlignableObjectId.cc:336
align::TIBString
Definition: StructureType.h:39
align::notfound
Definition: StructureType.h:17
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
AlignableObjectId::Geometry::PhaseII
align::AlignableCSCStation
Definition: StructureType.h:80
AlignableObjectId::Geometry::General
AlignableObjectId::muonGeometry
static Geometry muonGeometry(const DTGeometry *, const CSCGeometry *, const GEMGeometry *)
Definition: AlignableObjectId.cc:316
align::AlignableDTChamber
Definition: StructureType.h:76
align::TOBLayer
Definition: StructureType.h:56
align::Tracker
Definition: StructureType.h:70
AlignableObjectId::nameToType
align::StructureType nameToType(const std::string &name) const
Convert name to type.
Definition: AlignableObjectId.cc:267
CSCGeometry
Definition: CSCGeometry.h:24
align::AlignableMuon
Definition: StructureType.h:90
AlignableObjectId::AlignableObjectId
AlignableObjectId(Geometry)
AlignableObjectId::Geometry::Unspecified
align::AlignableCSCLayer
Definition: StructureType.h:83
AlignableObjectId::Geometry
Geometry
Definition: AlignableObjectId.h:16
align::AlignableGEMRing
Definition: StructureType.h:86
align::AlignableDTSuperLayer
Definition: StructureType.h:77
align::AlignableCSCEndcap
Definition: StructureType.h:79
GeomDetEnumerators::P1PXEC
Definition: GeomDetEnumerators.h:26
align::AlignableGEMStation
Definition: StructureType.h:85
align::TECSide
Definition: StructureType.h:64
align::TOBHalfBarrel
Definition: StructureType.h:57
align::TIBLayer
Definition: StructureType.h:42
align::TIBHalfBarrel
Definition: StructureType.h:43
align::TIDRing
Definition: StructureType.h:49
align::TPBLadder
Definition: StructureType.h:24
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
align::StructureType
StructureType
Definition: StructureType.h:16
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
funct::true
true
Definition: Factorize.h:173
align::AlignableGEMEndcap
Definition: StructureType.h:84
align::AlignableDetUnit
Definition: StructureType.h:19
align::AlignableDTStation
Definition: StructureType.h:75
align::AlignableGEMEtaPartition
Definition: StructureType.h:89
align::invalid
Definition: StructureType.h:18
align::TPEHalfCylinder
Definition: StructureType.h:34
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
AlignableObjectId::entry::type
align::StructureType type
Definition: AlignableObjectId.cc:9
AlignableObjectId::entry::name
const char * name
Definition: AlignableObjectId.cc:10
AlignableObjectId::entries_
const entry * entries_
Definition: AlignableObjectId.h:49
align::TIDModule
Definition: StructureType.h:47
align::AlignableCSCChamber
Definition: StructureType.h:82
align::TIDEndcap
Definition: StructureType.h:51
align::TECPetal
Definition: StructureType.h:63
AlignableObjectId::entry
Definition: AlignableObjectId.cc:8
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
align::AlignableDTBarrel
Definition: StructureType.h:73
AlignableObjectId.h
align::AlignableDet
Definition: StructureType.h:20
align::TIDDisk
Definition: StructureType.h:50
align::AlignableDTWheel
Definition: StructureType.h:74
align::AlignableGEMSuperChamber
Definition: StructureType.h:87
align::TPEModule
Definition: StructureType.h:30
align::TIBBarrel
Definition: StructureType.h:44
Exception
Definition: hltDiff.cc:245
genVertex_cff.x
x
Definition: genVertex_cff.py:13
align::Strip
Definition: StructureType.h:69
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
align::AlignableDTLayer
Definition: StructureType.h:78
AlignableObjectId::stringToId
align::StructureType stringToId(const char *) const
Definition: AlignableObjectId.cc:284
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
align::Pixel
Definition: StructureType.h:68
GeomDetEnumerators::PixelEndcap
Definition: GeomDetEnumerators.h:12
AlignableObjectId::idToString
const char * idToString(align::StructureType type) const
Definition: AlignableObjectId.cc:273
GEMGeometry
Definition: GEMGeometry.h:24
mps_fire.result
result
Definition: mps_fire.py:311
align::TECRing
Definition: StructureType.h:62
AlignableObjectId::commonGeometry
static Geometry commonGeometry(Geometry, Geometry)
Definition: AlignableObjectId.cc:323
align::TIBHalfShell
Definition: StructureType.h:41
align::AlignableCSCRing
Definition: StructureType.h:81
align::TECDisk
Definition: StructureType.h:65
AlignableObjectId::Geometry::PhaseI
AlignableObjectId::trackerGeometry
static Geometry trackerGeometry(const TrackerGeometry *)
Definition: AlignableObjectId.cc:294
Geometry
Class Geometry Contains vector for fit parameters (mean, sigma, etc.) obtained from multiple IOVs See...
Definition: DMRtrends.cc:182
align::TIDSide
Definition: StructureType.h:48
align::TECModule
Definition: StructureType.h:61
align::TOBRod
Definition: StructureType.h:55
GeomDetEnumerators::P2PXEC
Definition: GeomDetEnumerators.h:28
TrackerGeometry
Definition: TrackerGeometry.h:14
align::TPBModule
Definition: StructureType.h:23
align::TPEPanel
Definition: StructureType.h:31