Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**
0002   * \file
0003   * A test for EEDetId::hashedIndex()
0004   *
0005   */
0006 
0007 #include <iostream>
0008 #include <fstream>
0009 #include <string>
0010 #include <stdexcept>
0011 #include <assert.h>
0012 
0013 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
0014 
0015 int main(int argc, char* argv[]) {
0016   const char* filename = "sc.txt";
0017   std::ofstream out(filename);
0018   try {
0019     out << "iX\tiY\tiZ\thashed\tERR\tERR\tiX\tiY\tiZ\n";
0020     for (int iZ = -1; iZ <= +1; iZ += 2) {
0021       for (int iY = EcalScDetId::IY_MIN; iY <= EcalScDetId::IY_MAX; ++iY) {
0022         for (int iX = EcalScDetId::IX_MIN; iX <= EcalScDetId::IX_MAX; ++iX) {
0023           if (!EcalScDetId::validDetId(iX, iY, iZ))
0024             continue;
0025           EcalScDetId sc1(iX, iY, iZ);
0026           int ih = sc1.hashedIndex();
0027           out << iX << "\t" << iY << "\t" << iZ << "\t" << ih;
0028           EcalScDetId sc2 = EcalScDetId::unhashIndex(ih);
0029           out << "\t" << (sc1.rawId() == sc2.rawId() ? "OK" : "ERROR");
0030           out << "\t" << (sc1 == sc2 ? "OK" : "ERROR");
0031           out << "\t" << sc2.ix() << "\t" << sc2.iy() << "\t" << sc2.zside();
0032           out << "\n";
0033         }
0034       }
0035     }
0036     std::cout << "Supercystal indices have been dumped in file " << filename << std::endl;
0037   } catch (std::exception& e) {
0038     std::cerr << e.what();
0039   }
0040 }