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
|
/**
* \file
* A test for EEDetId::hashedIndex()
*
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include <assert.h>
#include <cstdio>
#include "DataFormats/EcalDetId/interface/EEDetId.h"
const int nBegin[EEDetId::IX_MAX] = {41, 41, 41, 36, 36, 26, 26, 26, 21, 21, 21, 21, 21, 16, 16, 14, 14, 14, 14, 14,
9, 9, 9, 9, 9, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 4, 4, 4, 4,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 9, 9, 9, 9, 9,
14, 14, 14, 14, 14, 16, 16, 21, 21, 21, 21, 21, 26, 26, 26, 36, 36, 41, 41, 41};
int main(int argc, char *argv[]) {
FILE *ofile = fopen("ee_numbering.dat", "w");
FILE *ofile_2 = fopen("ee_next_to_boundary.dat", "w");
int hi = -1;
try {
for (int iz = -1; iz < 2; iz += 2) {
for (int ix = EEDetId::IX_MIN; ix <= EEDetId::IX_MAX; ix++) {
for (int iy = nBegin[ix - 1]; iy <= 100 - nBegin[ix - 1] + 1; iy++) {
hi = -1;
if (EEDetId::validDetId(ix, iy, iz)) {
EEDetId id = EEDetId(ix, iy, iz);
hi = id.hashedIndex();
assert(EEDetId::unhashIndex(hi) == id);
//std::cout << id << " " << hi << " " << EEDetId::unhashIndex( hi ) << std::endl;
fprintf(ofile, "%d %d %d %d %d\n", ix, iy, iz, hi, 1);
if (EEDetId::isNextToBoundary(id)) {
fprintf(ofile_2, "%d %d %d %d %d\n", ix, iy, iz, hi, 1);
} else {
fprintf(ofile_2, "%d %d %d %d %d\n", ix, iy, iz, hi, 0);
}
} else {
fprintf(ofile, "%d %d %d %d %d\n", ix, iy, iz, hi, 0);
//std::cout << "Invalid detId " << ix << " " << iy << " " << iz << std::endl;
}
}
}
}
for (int i = 0; i < 15480; i++) {
EEDetId id = EEDetId::unhashIndex(hi);
assert(EEDetId::validDetId(id.ix(), id.iy(), id.zside()));
}
} catch (std::exception &e) {
std::cerr << e.what();
}
fclose(ofile);
fclose(ofile_2);
}
// to plot the output file:
//gnuplot> set terminal postscript enhanced eps color colourtext dl 1.0 lw 1.5 "Helvetica" 21
//gnuplot> set out 'ee_numbering.eps'
//gnuplot> set size square
//gnuplot> set xlabel 'ix'
//gnuplot> set ylabel 'iy'
//gnuplot> p [0:101][0:101] 'ee_numbering.dat' u 1:($5>0 ? $2 : 1/0) not, '' u 1:($5==0 ? $2 : 1/0) not
|