Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:15

0001 /**
0002   * \file
0003   * A test for EEDetId::hashedIndex()
0004   *
0005   */
0006 
0007 #include <iostream>
0008 #include <string>
0009 #include <stdexcept>
0010 #include <assert.h>
0011 #include <cstdio>
0012 
0013 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0014 
0015 int main(int argc, char *argv[]) {
0016   FILE *ofile = fopen("eb_next_to_boundary.dat", "w");
0017   int hi = -1;
0018   try {
0019     for (int ieta = EBDetId::MIN_IETA; ieta <= EBDetId::MAX_IETA; ieta++) {
0020       for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; iphi++) {
0021         if (EBDetId::validDetId(ieta, iphi)) {
0022           EBDetId id = EBDetId(ieta, iphi);
0023           if (EBDetId::isNextToBoundary(id)) {
0024             fprintf(ofile, "%d %d %d %d\n", id.ieta(), id.iphi(), hi, 1);
0025           } else {
0026             fprintf(ofile, "%d %d %d %d\n", id.ieta(), id.iphi(), hi, 0);
0027           }
0028         }
0029         if (EBDetId::validDetId(-ieta, iphi)) {
0030           EBDetId id = EBDetId(-ieta, iphi);
0031           if (EBDetId::isNextToBoundary(id)) {
0032             fprintf(ofile, "%d %d %d %d\n", id.ieta(), id.iphi(), hi, 1);
0033           } else {
0034             fprintf(ofile, "%d %d %d %d\n", id.ieta(), id.iphi(), hi, 0);
0035           }
0036         }
0037       }
0038     }
0039   } catch (std::exception &e) {
0040     std::cerr << e.what();
0041   }
0042   fclose(ofile);
0043 }
0044 
0045 // to plot the output file:
0046 //gnuplot> set terminal postscript enhanced eps color colourtext dl 1.0 lw 1.5 "Helvetica" 21
0047 //gnuplot> set out 'ee_numbering.eps'
0048 //gnuplot> set size square
0049 //gnuplot> set xlabel 'ix'
0050 //gnuplot> set ylabel 'iy'
0051 //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