1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
|
#include "DQM/HcalCommon/interface/HashFunctions.h"
#include "DQM/HcalCommon/interface/Utilities.h"
namespace hcaldqm {
using namespace constants;
namespace hashfunctions {
/**
* HcalDetId
*/
uint32_t hash_Subdet(HcalDetId const &did) { return utilities::hash(HcalDetId(did.subdet(), 1, 1, 1)); }
uint32_t hash_Subdetiphi(HcalDetId const &did) {
return utilities::hash(HcalDetId(did.subdet(), 1, did.iphi(), 1));
}
uint32_t hash_Subdetieta(HcalDetId const &did) {
return utilities::hash(HcalDetId(did.subdet(), did.ieta(), 1, 1));
}
uint32_t hash_Subdetdepth(HcalDetId const &did) {
return utilities::hash(HcalDetId(did.subdet(), 1, 1, did.depth()));
}
uint32_t hash_SubdetPM(HcalDetId const &did) {
return utilities::hash(HcalDetId(did.subdet(), did.ieta() > 0 ? 1 : -1, 1, 1));
}
uint32_t hash_SubdetPMiphi(HcalDetId const &did) {
return utilities::hash(HcalDetId(did.subdet(), did.ieta() > 0 ? 1 : -1, did.iphi(), 1));
}
uint32_t hash_iphi(HcalDetId const &did) { return utilities::hash(HcalDetId(HcalBarrel, 1, did.iphi(), 1)); }
uint32_t hash_ieta(HcalDetId const &did) { return utilities::hash(HcalDetId(HcalBarrel, did.ieta(), 1, 1)); }
uint32_t hash_depth(HcalDetId const &did) {
if (did.subdet() == HcalOuter)
return 9; // key of map, can be any uint32_t valure that is not a raw hcal detid
else
return utilities::hash(HcalDetId(HcalBarrel, 1, 1, did.depth()));
}
uint32_t hash_HFPMiphi(HcalDetId const &did) {
return utilities::hash(HcalDetId(HcalForward, did.ieta() > 0 ? 1 : -1, did.iphi(), 1));
}
uint32_t hash_HBHEPartition(HcalDetId const &did) {
int iphi = did.iphi();
uint32_t hash = 0;
if (iphi >= 3 && iphi <= 26)
hash = utilities::hash(HcalDetId(HcalBarrel, 1, 3, 1));
else if (iphi >= 27 && iphi <= 50)
hash = utilities::hash(HcalDetId(HcalBarrel, 1, 27, 1));
else
hash = utilities::hash(HcalDetId(HcalBarrel, 1, 1, 1));
return hash;
}
uint32_t hash_DChannel(HcalDetId const &did) { return utilities::hash(did); }
std::string name_Subdet(HcalDetId const &did) { return constants::SUBDET_NAME[did.subdet() - 1]; }
uint32_t hash_Subdet(std::string const &name) {
for (int i = 0; i < constants::SUBDET_NUM; i++)
if (constants::SUBDET_NAME[i] == name)
return (HcalDetId((HcalSubdetector)(i + 1), 1, 1, 1).rawId());
return HcalDetId().rawId();
}
std::string name_SubdetPM(HcalDetId const &did) {
char name[10];
sprintf(name, "%s%s", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.ieta() > 0 ? "P" : "M");
return std::string(name);
}
uint32_t hash_SubdetPM(std::string const &name) {
for (int i = 0; i < constants::SUBDET_NUM * 2; i++)
if (constants::SUBDETPM_NAME[i] == name)
return HcalDetId((HcalSubdetector)(i / 2 + 1), i % 2 == 0 ? -1 : 1, 1, 1).rawId();
return HcalDetId().rawId();
}
std::string name_Subdetiphi(HcalDetId const &did) {
char name[10];
sprintf(name, "%siphi%d", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.iphi());
return std::string(name);
}
uint32_t hash_Subdetiphi(std::string const &name) {
std::string sub = name.substr(0, 2);
int iphi = std::stoi(name.substr(6, name.length() - 6), nullptr);
for (int i = 0; i < constants::SUBDET_NUM; i++)
if (constants::SUBDET_NAME[i] == sub)
return HcalDetId((HcalSubdetector)(i + 1), 1, iphi, 1).rawId();
// default
return HcalDetId().rawId();
}
std::string name_Subdetieta(HcalDetId const &did) {
char name[20];
sprintf(name, "%sieta%d", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.ieta());
return std::string(name);
}
uint32_t hash_Subdetieta(std::string const &name) {
std::string sub = name.substr(0, 2);
int ieta = std::stoi(name.substr(6, name.length() - 6), nullptr);
for (int i = 0; i < constants::SUBDET_NUM; i++)
if (constants::SUBDET_NAME[i] == sub)
return HcalDetId((HcalSubdetector)(i + 1), ieta, 1, 1).rawId();
// default
return HcalDetId().rawId();
}
std::string name_Subdetdepth(HcalDetId const &did) {
char name[20];
sprintf(name, "%sdepth%d", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.depth());
return std::string(name);
}
uint32_t hash_Subdetdepth(std::string const &name) {
std::string sub = name.substr(0, 2);
int depth = std::stoi(name.substr(7, name.length() - 7), nullptr);
for (int i = 0; i < constants::SUBDET_NUM; i++)
if (constants::SUBDET_NAME[i] == sub)
return HcalDetId((HcalSubdetector)(i + 1), 1, 1, depth).rawId();
return HcalDetId().rawId();
}
std::string name_SubdetPMiphi(HcalDetId const &did) {
char name[20];
sprintf(
name, "%s%siphi%d", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.ieta() > 0 ? "P" : "M", did.iphi());
return std::string(name);
}
uint32_t hash_SubdetPMiphi(std::string const &name) {
std::string sub = name.substr(0, 3);
int iphi = std::stoi(name.substr(7, name.length() - 7), nullptr);
for (int i = 0; i < constants::SUBDET_NUM * 2; i++)
if (constants::SUBDETPM_NAME[i] == sub)
return HcalDetId((HcalSubdetector)(i / 2 + 1), i % 2 == 0 ? -1 : 1, iphi, 1).rawId();
return HcalDetId().rawId();
}
std::string name_iphi(HcalDetId const &did) {
char name[10];
sprintf(name, "iphi%d", did.iphi());
return std::string(name);
}
uint32_t hash_iphi(std::string const &name) {
int iphi = std::stoi(name.substr(4, name.length() - 4), nullptr);
return HcalDetId(HcalBarrel, 1, iphi, 1).rawId();
}
std::string name_ieta(HcalDetId const &did) {
char name[10];
sprintf(name, "ieta%d", did.ieta());
return std::string(name);
}
uint32_t hash_ieta(std::string const &name) {
int ieta = std::stoi(name.substr(4, name.length() - 4), nullptr);
return HcalDetId(HcalBarrel, ieta, 1, 1).rawId();
}
std::string name_depth(HcalDetId const &did) {
char name[10];
if (did.subdet() == HcalOuter)
sprintf(name, "depthHO");
else
sprintf(name, "depth%d", did.depth());
return std::string(name);
}
uint32_t hash_depth(std::string const &name) {
int depth = std::stoi(name.substr(5, name.length() - 5), nullptr);
if (name.find("HO") != std::string::npos)
return 9; // must match the value in method hash_depth(& digi)
else
return HcalDetId(HcalBarrel, 1, 1, depth).rawId();
}
std::string name_HFPMiphi(HcalDetId const &did) {
char name[12];
snprintf(name, sizeof(name), "HF%ciphi%d", did.ieta() > 0 ? 'P' : 'M', did.iphi());
return std::string(name);
}
uint32_t hash_HFPMiphi(std::string const &name) {
int iphi = std::stoi(name.substr(7, name.length() - 7), nullptr);
int ieta = name[2] == 'P' ? 1 : -1;
return HcalDetId(HcalForward, ieta, iphi, 1).rawId();
}
std::string name_HBHEPartition(HcalDetId const &did) {
char c;
if (did.iphi() >= 3 && did.iphi() <= 26)
c = 'a';
else if (did.iphi() >= 27 && did.iphi() <= 50)
c = 'b';
else
c = 'c';
char name[10];
sprintf(name, "HBHE%c", c);
return std::string(name);
}
uint32_t hash_HBHEPartition(std::string const &name) {
if (name[4] == 'a')
return HcalDetId(HcalBarrel, 1, 5, 1).rawId();
else if (name[4] == 'b')
return HcalDetId(HcalBarrel, 1, 29, 1).rawId();
else
return HcalDetId(HcalBarrel, 1, 55, 1).rawId();
return HcalDetId().rawId();
}
std::string name_DChannel(HcalDetId const &did) {
char name[40];
sprintf(
name, "%s-%d-%d-%d", constants::SUBDET_NAME[did.subdet() - 1].c_str(), did.ieta(), did.iphi(), did.depth());
return std::string(name);
}
// TODO: Make it work here
// Not neccessary right now!
uint32_t hash_DChannel(std::string const &name) { return HcalDetId(HcalBarrel, 1, 1, 1).rawId(); }
/**
* by ElectronicsId
*/
uint32_t hash_FED(HcalElectronicsId const &eid) {
if (eid.isVMEid())
return utilities::hash(HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, eid.dccid()));
else {
// HO and HO are dual-FED
bool isHF = eid.crateId() == 22 || eid.crateId() == 29 || eid.crateId() == 32;
bool isHO = eid.crateId() == 23 || eid.crateId() == 27 || eid.crateId() == 26 || eid.crateId() == 38;
// for HF, slot number is either
int slotToUse = 1;
if (isHF || isHO)
slotToUse = eid.slot() > 6 ? SLOT_uTCA_MIN + 6 : SLOT_uTCA_MIN;
else
slotToUse = eid.slot() > 8 ? SLOT_uTCA_MIN + 8 : (eid.slot() > 4 ? SLOT_uTCA_MIN + 4 : SLOT_uTCA_MIN);
return utilities::hash(HcalElectronicsId(eid.crateId(), slotToUse, FIBER_uTCA_MIN1, FIBERCH_MIN, false));
}
}
uint32_t hash_FEDSpigot(HcalElectronicsId const &eid) {
// note that hashing of uTCA is done by FED-Slot...
return eid.isVMEid()
? utilities::hash(HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, eid.spigot(), eid.dccid()))
: utilities::hash(HcalElectronicsId(eid.crateId(), eid.slot(), FIBER_uTCA_MIN1, FIBERCH_MIN, false));
}
uint32_t hash_FEDSlot(HcalElectronicsId const &eid) {
// note that hashing of VME is done with
return eid.isVMEid()
? utilities::hash(HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, eid.spigot(), eid.dccid()))
: utilities::hash(HcalElectronicsId(eid.crateId(), eid.slot(), FIBER_uTCA_MIN1, FIBERCH_MIN, false));
}
uint32_t hash_Crate(HcalElectronicsId const &eid) {
// note hashing of VME is done with dccId
// note 2: there are two dccids per crate, <even> and <even+1>. We don't
// care about this, so use the even one.
return eid.isVMEid()
? utilities::hash(HcalElectronicsId(
FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, (eid.dccid() % 2 == 0 ? eid.dccid() : eid.dccid() - 1)))
: utilities::hash(
HcalElectronicsId(eid.crateId(), SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false));
}
uint32_t hash_CrateSpigot(HcalElectronicsId const &eid) {
// note hashing of VME is done with dccid and
// uTCA with Slots
return eid.isVMEid()
? utilities::hash(HcalElectronicsId(
FIBERCH_MIN, FIBER_VME_MIN, eid.spigot(), (eid.dccid() % 2 == 0 ? eid.dccid() : eid.dccid() - 1)))
: utilities::hash(HcalElectronicsId(eid.crateId(), eid.slot(), FIBER_uTCA_MIN1, FIBERCH_MIN, false));
}
uint32_t hash_CrateSlot(HcalElectronicsId const &eid) {
return eid.isVMEid()
? utilities::hash(HcalElectronicsId(
FIBERCH_MIN, FIBER_VME_MIN, eid.spigot(), (eid.dccid() % 2 == 0 ? eid.dccid() : eid.dccid() - 1)))
: utilities::hash(HcalElectronicsId(eid.crateId(), eid.slot(), FIBER_uTCA_MIN1, FIBERCH_MIN, false));
}
uint32_t hash_Fiber(HcalElectronicsId const &) { return 0; }
uint32_t hash_FiberFiberCh(HcalElectronicsId const &) { return 0; }
uint32_t hash_FiberCh(HcalElectronicsId const &eid) { return 0; }
uint32_t hash_Electronics(HcalElectronicsId const &eid) {
return eid.isVMEid() ? utilities::hash(HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, CRATE_VME_MIN))
: utilities::hash(
HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false));
/* NOTE: as an update - should separate Trigger Eid and Det
Eid * return eid.isVMEid() ? eid.isTriggerChainId()?
utilities::hash(HcalElectronicsId(SLBCH_MIN,
SLB_MIN, SPIGOT_MIN,
CRATE_VME_MIN, CRATE_VME_MIN, SLOT_VME_MIN1, 0)):
utilities::hash(HcalElectronicsId(FIBERCH_MIN,
FIBER_VME_MIN, SPIGOT_MIN,
CRATE_VME_MIN))
:
eid.isTriggerChainId()?
utilities::hash(HcalElectronicsId(CRATE_uTCA_MIN,
SLOT_uTCA_MIN, TPFIBER_MIN,
TPFIBERCH_MIN, true)): utilities::hash(HcalElectronicsId(CRATE_uTCA_MIN,
SLOT_uTCA_MIN, FIBER_uTCA_MIN1,
FIBERCH_MIN, false));
*/
}
uint32_t hash_EChannel(HcalElectronicsId const &eid) {
return eid.isVMEid()
? utilities::hash(HcalElectronicsId(eid.fiberChanId(), eid.fiberIndex(), eid.spigot(), eid.dccid()))
: utilities::hash(
HcalElectronicsId(eid.crateId(), eid.slot(), eid.fiberIndex(), eid.fiberChanId(), false));
}
std::string name_FED(HcalElectronicsId const &eid) {
char name[15];
sprintf(name, "FED%d", eid.isVMEid() ? eid.dccid() + 700 : utilities::crate2fed(eid.crateId(), eid.slot()));
return std::string(name);
}
uint32_t hash_FED(std::string const &name) {
int fed = std::stoi(name.substr(3, name.length() - 3), nullptr);
if (fed >= constants::FED_uTCA_MIN) {
std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(fed);
return HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId();
} else
return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, fed - FED_VME_MIN).rawId();
return HcalElectronicsId().rawId();
}
std::string name_FEDSpigot(HcalElectronicsId const &eid) {
char name[20];
sprintf(name,
"FED%dS%d",
eid.isVMEid() ? eid.dccid() + 700 : utilities::crate2fed(eid.crateId(), eid.slot()),
eid.isVMEid() ? eid.spigot() : eid.slot());
return std::string(name);
}
uint32_t hash_FEDSpigot(std::string const &name) {
int pos = name.find('S');
int fed = std::stoi(name.substr(3, pos - 3), nullptr);
int s = std::stoi(name.substr(pos + 1, name.length() - pos - 1), nullptr);
if (fed >= FED_uTCA_MIN) {
std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(fed);
return HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId();
} else
return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, s, fed - FED_VME_MIN).rawId();
return HcalElectronicsId().rawId();
}
std::string name_FEDSlot(HcalElectronicsId const &eid) {
char name[20];
sprintf(name,
"FED%dS%d",
eid.isVMEid() ? eid.dccid() + 700 : utilities::crate2fed(eid.crateId(), eid.slot()),
eid.isVMEid() ? eid.spigot() : eid.slot());
return std::string(name);
}
uint32_t hash_FEDSlot(std::string const &name) {
int pos = name.find('S');
int fed = std::stoi(name.substr(3, pos - 3), nullptr);
int s = std::stoi(name.substr(pos + 1, name.length() - pos - 1), nullptr);
if (fed >= FED_uTCA_MIN) {
std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(fed);
return HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId();
} else
return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, s, fed - FED_VME_MIN).rawId();
return HcalElectronicsId().rawId();
}
std::string name_Crate(HcalElectronicsId const &eid) {
char name[16];
sprintf(name, "Crate%d", eid.crateId());
// Note: previous, different hashes were returned for the two dccids in a VME
// crate. These now count as one crate.
// if (eid.isVMEid()) {
// sprintf(name, "Crate%d_VME_DCC%d", eid.crateId(), eid.dccid());
//} else {
// sprintf(name, "Crate%d", eid.crateId());
//}
return std::string(name);
}
// TODO: implement - not used at this point
uint32_t hash_Crate(std::string const &) { return HcalElectronicsId().rawId(); }
std::string name_CrateSpigot(HcalElectronicsId const &eid) {
char name[20];
sprintf(name, "Crate%dS%d", eid.crateId(), eid.isVMEid() ? eid.spigot() : eid.slot());
return std::string(name);
}
// TODO: implement - not used at this point
uint32_t hash_CrateSpigot(std::string const &) { return HcalElectronicsId().rawId(); }
std::string name_CrateSlot(HcalElectronicsId const &eid) {
char name[20];
sprintf(name, "Crate%dS%d", eid.crateId(), eid.isVMEid() ? eid.spigot() : eid.slot());
return std::string(name);
}
// TODO: implement - not used at this point
uint32_t hash_CrateSlot(std::string const &) { return HcalElectronicsId().rawId(); }
std::string name_Fiber(HcalElectronicsId const &) { return "None"; }
// TODO: implement - not used at this point
uint32_t hash_Fiber(std::string const &) { return HcalElectronicsId().rawId(); }
std::string name_FiberFiberCh(HcalElectronicsId const &) { return "None"; }
// TODO: implement - not used at this point
uint32_t hash_FiberFiberCh(std::string const &) { return HcalElectronicsId().rawId(); }
std::string name_FiberCh(HcalElectronicsId const &) { return "None"; }
// TODO: implement - not used at this point
uint32_t hash_FiberCh(std::string const &) { return HcalElectronicsId().rawId(); }
std::string name_Electronics(HcalElectronicsId const &eid) {
return eid.isVMEid() ? std::string("VME") : std::string("uTCA");
}
uint32_t hash_Electronics(std::string const &name) {
if (name == "VME")
return HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, CRATE_VME_MIN).rawId();
else
return HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId();
return HcalElectronicsId().rawId();
}
std::string name_EChannel(HcalElectronicsId const &eid) {
char name[20];
if (eid.isVMEid())
sprintf(name, "%d-%d-%d-%d", eid.dccid(), eid.spigot(), eid.fiberIndex(), eid.fiberChanId());
else
sprintf(name, "%d-%d-%d-%d", eid.crateId(), eid.slot(), eid.fiberIndex(), eid.fiberChanId());
return std::string(name);
}
// TODO: implement - not used at this point
uint32_t hash_EChannel(std::string const &) { return HcalElectronicsId().rawId(); }
/**
* by TrigTowerDetId
*/
uint32_t hash_TTSubdet(HcalTrigTowerDetId const &tid) {
return utilities::hash(HcalTrigTowerDetId(tid.ietaAbs() >= 29 ? 29 : 1, 1));
}
uint32_t hash_TTSubdetPM(HcalTrigTowerDetId const &tid) {
return utilities::hash(
HcalTrigTowerDetId(tid.ietaAbs() < 29 ? (tid.ieta() < 0 ? -1 : 1) : (tid.ieta() < 0 ? -29 : 29), 1));
}
uint32_t hash_TTSubdetPMiphi(HcalTrigTowerDetId const &tid) {
return utilities::hash(
HcalTrigTowerDetId(tid.ietaAbs() < 29 ? (tid.ieta() < 0 ? 0 : 1) : (tid.ieta() < 0 ? 2 : 3), tid.iphi()));
}
uint32_t hash_TTSubdetieta(HcalTrigTowerDetId const &tid) { return 0; }
uint32_t hash_TTdepth(HcalTrigTowerDetId const &tid) {
return utilities::hash(HcalTrigTowerDetId(1, 1, tid.depth()));
}
uint32_t hash_TChannel(HcalTrigTowerDetId const &tid) {
return utilities::hash(HcalTrigTowerDetId(tid.ieta(), tid.iphi(), tid.depth()));
}
std::string name_TTSubdet(HcalTrigTowerDetId const &tid) {
return constants::TPSUBDET_NAME[tid.ietaAbs() < 29 ? 0 : 1];
}
uint32_t hash_TTSubdet(std::string const &name) {
if (name == "HBHE")
return HcalTrigTowerDetId(1, 1).rawId();
else
return HcalTrigTowerDetId(29, 1).rawId();
return HcalTrigTowerDetId().rawId();
}
std::string name_TTSubdetPM(HcalTrigTowerDetId const &tid) {
return constants::TPSUBDETPM_NAME[tid.ietaAbs() < 29 ? (tid.ieta() < 0 ? 0 : 1) : (tid.ieta() < 0 ? 2 : 3)];
}
uint32_t hash_TTSubdetPM(std::string const &name) {
if (name == "HBHEM")
return HcalTrigTowerDetId(-1, 1).rawId();
else if (name == "HBHEP")
return HcalTrigTowerDetId(1, 1).rawId();
else if (name == "HFM")
return HcalTrigTowerDetId(-29, 1).rawId();
else
return HcalTrigTowerDetId(29, 1).rawId();
return HcalTrigTowerDetId().rawId();
}
std::string name_TTSubdetPMiphi(HcalTrigTowerDetId const &tid) {
char name[10];
sprintf(name, "%siphi%d", name_TTSubdetPM(tid).c_str(), tid.iphi());
return std::string(name);
}
uint32_t hash_TTSubdetPMiphi(std::string const &name) {
int pos = name.find("iphi");
std::string sub = name.substr(0, pos);
int iphi = std::stoi(name.substr(pos + 4, name.length() - pos - 4), nullptr);
if (name == "HBHEM")
return HcalTrigTowerDetId(-1, iphi).rawId();
else if (name == "HBHEP")
return HcalTrigTowerDetId(1, iphi).rawId();
else if (name == "HFM")
return HcalTrigTowerDetId(-29, iphi).rawId();
else
return HcalTrigTowerDetId(29, iphi).rawId();
return HcalTrigTowerDetId().rawId();
}
std::string name_TTSubdetieta(HcalTrigTowerDetId const &tid) { return "None"; }
// TODO: implement - not used right now
uint32_t hash_TTSubdetieta(std::string const &) { return HcalTrigTowerDetId().rawId(); }
std::string name_TTdepth(HcalTrigTowerDetId const &tid) {
char name[10];
sprintf(name, "depth%d", tid.depth());
return std::string(name);
}
uint32_t hash_TTdepth(std::string const &name) {
int depth = std::stoi(name.substr(5, name.length() - 5), nullptr);
return HcalTrigTowerDetId(1, 1, depth);
}
std::string name_TChannel(HcalTrigTowerDetId const &tid) {
std::ostringstream stream;
stream << tid;
return std::string(stream.str());
}
// TODO: implement - not used right now
uint32_t hash_TChannel(std::string const &) { return HcalTrigTowerDetId().rawId(); }
/**
* by Mixed Id
*/
uint32_t hash_TTSubdetFW(HcalTrigTowerDetId const &tid, HcalElectronicsId const &eid) {
if (tid.ietaAbs() < 29) {
if (eid.slot() % 3 == 1)
return utilities::hash(HcalTrigTowerDetId(1, 1));
else if (eid.slot() % 3 == 2)
return utilities::hash(HcalTrigTowerDetId(17, 1));
else if (eid.slot() % 3 == 0)
return utilities::hash(HcalTrigTowerDetId(19, 1));
} else
return utilities::hash(HcalTrigTowerDetId(29, 1));
return HcalTrigTowerDetId().rawId();
}
std::string name_TTSubdetFW(HcalTrigTowerDetId const &tid, HcalElectronicsId const &eid) {
int idx = -1;
if (tid.ietaAbs() < 29) {
if (eid.slot() % 3 == 1)
idx = 0;
else if (eid.slot() % 3 == 2)
idx = 1;
else if (eid.slot() % 3 == 0)
idx = 2;
} else
idx = 3;
return constants::TPSUBDETFW_NAME[idx];
}
uint32_t hash_TTSubdetFW(std::string const &name) {
if (name == "HB")
return HcalTrigTowerDetId(1, 1).rawId();
else if (name == "HBHE")
return HcalTrigTowerDetId(17, 1).rawId();
else if (name == "HE")
return HcalTrigTowerDetId(19, 1).rawId();
else
return HcalTrigTowerDetId(29, 1).rawId();
return HcalTrigTowerDetId().rawId();
}
} // namespace hashfunctions
} // namespace hcaldqm
|