Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:46:11

0001 #if !defined(__CINT__) && !defined(__MAKECINT__)
0002 #define CondFormats_Alignment_Definitions_H // avoid including this header
0003 
0004 namespace align { typedef unsigned int ID; }
0005 
0006 #include "Alignment/TrackerAlignment/interface/TPBNameSpace.h"
0007 #include "Alignment/TrackerAlignment/interface/TPENameSpace.h"
0008 #include "Alignment/TrackerAlignment/interface/TIBNameSpace.h"
0009 #include "Alignment/TrackerAlignment/interface/TIDNameSpace.h"
0010 #include "Alignment/TrackerAlignment/interface/TOBNameSpace.h"
0011 #include "Alignment/TrackerAlignment/interface/TECNameSpace.h"
0012 #endif
0013 
0014 #include <sstream>
0015 #include <string>
0016 #include <vector>
0017 #include <utility>
0018 
0019 namespace align
0020 {
0021   namespace trk
0022   {
0023     enum { TPB = 1, TPE = 2, TIB = 3, TID = 4, TOB = 5, TEC = 6, MAX = 7 };
0024 
0025     unsigned int subdetId(unsigned int id)
0026     {
0027       return (id >> 25) & 0x7;
0028     }
0029   }
0030 }
0031 
0032 // Extract the id from histogram's title
0033 
0034 unsigned int getId(const std::string& title)
0035 {
0036   unsigned int id;
0037 
0038   std::stringstream ss(title.substr(title.find_last_of(' ')));
0039 
0040   ss >> id;
0041 
0042   return id;
0043 }
0044 
0045 typedef unsigned int (*Counter)(unsigned int);
0046 typedef std::pair<Counter, std::string> CounterName;
0047 typedef std::vector<CounterName> CounterNames;
0048 
0049 class Helper
0050 {
0051   public:
0052 
0053   inline static const CounterNames& counterNames(unsigned int subdetId);
0054 
0055   static std::string name(unsigned int id);
0056 
0057   private:
0058 
0059   Helper(); // init counters and names
0060 
0061   CounterNames theCounterNames[align::trk::MAX];
0062 };
0063 
0064 const CounterNames& Helper::counterNames(unsigned int subdetId)
0065 {
0066   static const Helper helper;
0067 
0068   return helper.theCounterNames[subdetId];
0069 }
0070 
0071 std::string Helper::name(unsigned int id)
0072 {
0073   std::ostringstream os;
0074 
0075   const CounterNames& cn = counterNames(align::trk::subdetId(id));
0076 
0077   for (unsigned int i = 0; i < cn.size(); ++i)
0078   {
0079     os << cn[i].second << ' ' << cn[i].first(id) << ' ';
0080   }
0081 
0082   return os.str();
0083 }
0084 
0085 Helper::Helper()
0086 {
0087   using namespace align;
0088 
0089   // Barrel Pixel
0090   theCounterNames[trk::TPB].push_back(std::make_pair(trk::          subdetId, "TPB"         ));
0091   theCounterNames[trk::TPB].push_back(std::make_pair(tpb::  halfBarrelNumber, "HalfBarrel"  ));
0092   theCounterNames[trk::TPB].push_back(std::make_pair(tpb::       layerNumber, "Layer"       ));
0093   theCounterNames[trk::TPB].push_back(std::make_pair(tpb::      ladderNumber, "Ladder"      ));
0094   theCounterNames[trk::TPB].push_back(std::make_pair(tpb::      moduleNumber, "Module"      ));
0095 
0096   // Forward Pixel
0097   theCounterNames[trk::TPE].push_back(std::make_pair(trk::          subdetId, "TPE"         ));
0098   theCounterNames[trk::TPE].push_back(std::make_pair(tpe::      endcapNumber, "Endcap"      ));
0099   theCounterNames[trk::TPE].push_back(std::make_pair(tpe::halfCylinderNumber, "HalfCylinder"));
0100   theCounterNames[trk::TPE].push_back(std::make_pair(tpe::    halfDiskNumber, "HalfDisk"    ));
0101   theCounterNames[trk::TPE].push_back(std::make_pair(tpe::       bladeNumber, "Blade"       ));
0102   theCounterNames[trk::TPE].push_back(std::make_pair(tpe::       panelNumber, "Panel"       ));
0103   theCounterNames[trk::TPE].push_back(std::make_pair(tpe::      moduleNumber, "Module"      ));
0104 
0105   // Tracker Inner Barrel
0106   theCounterNames[trk::TIB].push_back(std::make_pair(trk::          subdetId, "TIB"         ));
0107   theCounterNames[trk::TIB].push_back(std::make_pair(tib::  halfBarrelNumber, "HalfBarrel"  ));
0108   theCounterNames[trk::TIB].push_back(std::make_pair(tib::       layerNumber, "Layer"       ));
0109   theCounterNames[trk::TIB].push_back(std::make_pair(tib::   halfShellNumber, "HalfShell"   ));
0110   theCounterNames[trk::TIB].push_back(std::make_pair(tib::     surfaceNumber, "Surface"     ));
0111   theCounterNames[trk::TIB].push_back(std::make_pair(tib::      stringNumber, "String"      ));
0112   theCounterNames[trk::TIB].push_back(std::make_pair(tib::      moduleNumber, "Module"      ));
0113 
0114   // Tracker Inner Disks
0115   theCounterNames[trk::TID].push_back(std::make_pair(trk::          subdetId, "TID"         ));
0116   theCounterNames[trk::TID].push_back(std::make_pair(tid::      endcapNumber, "Endcap"      ));
0117   theCounterNames[trk::TID].push_back(std::make_pair(tid::        diskNumber, "Disk"        ));
0118   theCounterNames[trk::TID].push_back(std::make_pair(tid::        ringNumber, "Ring"        ));
0119   theCounterNames[trk::TID].push_back(std::make_pair(tid::        sideNumber, "Side"        ));
0120   theCounterNames[trk::TID].push_back(std::make_pair(tid::      moduleNumber, "Module"      ));
0121 
0122   // Tracker Outer Barrel
0123   theCounterNames[trk::TOB].push_back(std::make_pair(trk::          subdetId, "TOB"         ));
0124   theCounterNames[trk::TOB].push_back(std::make_pair(tob::  halfBarrelNumber, "HalfBarrel"  ));
0125   theCounterNames[trk::TOB].push_back(std::make_pair(tob::       layerNumber, "Layer"       ));
0126   theCounterNames[trk::TOB].push_back(std::make_pair(tob::         rodNumber, "Rod"         ));
0127   theCounterNames[trk::TOB].push_back(std::make_pair(tob::      moduleNumber, "Module"      ));
0128 
0129   // Tracker Endcaps
0130   theCounterNames[trk::TEC].push_back(std::make_pair(trk::          subdetId, "TEC"         ));
0131   theCounterNames[trk::TEC].push_back(std::make_pair(tec::      endcapNumber, "Endcap"      ));
0132   theCounterNames[trk::TEC].push_back(std::make_pair(tec::        diskNumber, "Disk"        ));
0133   theCounterNames[trk::TEC].push_back(std::make_pair(tec::        sideNumber, "Side"        ));
0134   theCounterNames[trk::TEC].push_back(std::make_pair(tec::       petalNumber, "Petal"       ));
0135   theCounterNames[trk::TEC].push_back(std::make_pair(tec::        ringNumber, "Ring"        ));
0136   theCounterNames[trk::TEC].push_back(std::make_pair(tec::      moduleNumber, "Module"      ));
0137 }