Line Code
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
#include "Geometry/TrackerGeometryBuilder/interface/trackerHierarchy.h"
#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"

#include <string>
#include <vector>

std::string trackerHierarchy(const TrackerTopology* tTopo, unsigned int rawid) {
  DetId id(rawid);
  int subdetid = id.subdetId();
  switch (subdetid) {
      // PXB
    case PixelSubdetector::PixelBarrel: {
      char theLayer = tTopo->pxbLayer(id);
      char theLadder = tTopo->pxbLadder(id);
      char theModule = tTopo->pxbModule(id);
      char key[] = {1, theLayer, theLadder, theModule};
      return std::string(key, 4);
    }

      // P1XF
    case PixelSubdetector::PixelEndcap: {
      char thePanel = tTopo->pxfPanel(id);
      char theDisk = tTopo->pxfDisk(id);
      char theBlade = tTopo->pxfBlade(id);
      char theModule = tTopo->pxfModule(id);
      char key[] = {2, char(tTopo->pxfSide(id)), thePanel, theDisk, theBlade, theModule};
      return std::string(key, 6);
    }

    // TIB
    case StripSubdetector::TIB: {
      char theLayer = tTopo->tibLayer(id);
      std::vector<unsigned int> theString = tTopo->tibStringInfo(id);
      char theModule = tTopo->tibModule(id);
      //side = (theString[0] == 1 ) ? "-" : "+";
      //part = (theString[1] == 1 ) ? "int" : "ext";
      char key[] = {3,
                    theLayer,
                    char(theString[0]),
                    char(theString[1]),
                    char(theString[2]),
                    theModule,
                    char(tTopo->tibGlued(id) ? tTopo->tibIsStereo(id) + 1 : 0)};
      return std::string(key, tTopo->tibGlued(id) ? 7 : 6);
    }

      // TID
    case StripSubdetector::TID: {
      unsigned int theDisk = tTopo->tidWheel(id);
      unsigned int theRing = tTopo->tidRing(id);
      // side = (tTopo->tidSide(id) == 1 ) ? "-" : "+";
      // part = (tTopo->tidOrder(id) == 1 ) ? "back" : "front";
      char key[] = {4,
                    char(tTopo->tidSide(id)),
                    char(theDisk),
                    char(theRing),
                    char(tTopo->tidOrder(id)),
                    char(tTopo->tidModule(id)),
                    char(tTopo->tidGlued(id) ? tTopo->tidIsStereo(id) + 1 : 0)};
      return std::string(key, tTopo->tidGlued(id) ? 7 : 6);
    }

      // TOB
    case StripSubdetector::TOB: {
      unsigned int theLayer = tTopo->tobLayer(id);
      unsigned int theModule = tTopo->tobModule(id);
      //	side = (tTopo->side(id) == 1 ) ? "-" : "+";
      char key[] = {5,
                    char(theLayer),
                    char(tTopo->tobSide(id)),
                    char(tTopo->tobRod(id)),
                    char(theModule),
                    char(tTopo->tobGlued(id) ? tTopo->tobIsStereo(id) + 1 : 0)};
      return std::string(key, tTopo->tobGlued(id) ? 6 : 5);
    }

      // TEC
    case StripSubdetector::TEC: {
      unsigned int theWheel = tTopo->tecWheel(id);
      unsigned int theModule = tTopo->tecModule(id);
      unsigned int theRing = tTopo->tecRing(id);
      //	side  = (tTopo->tecSide(id) == 1 ) ? "-" : "+";
      //	petal = (tTopo->tecOrder(id) == 1 ) ? "back" : "front";
      // int out_side  = (tTopo->tecSide(id) == 1 ) ? -1 : 1;

      char key[] = {6,
                    char(tTopo->tecSide(id)),
                    char(theWheel),
                    char(tTopo->tecOrder(id)),
                    char(tTopo->tecPetalNumber(id)),
                    char(theRing),
                    char(theModule),
                    char(tTopo->tecGlued(id) ? tTopo->tecIsStereo(id) + 1 : 0)};
      return std::string(key, tTopo->tecGlued(id) ? 8 : 7);
    }
    default:
      return std::string();
  }
}