Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:25

0001 #ifndef SiPixelCoordinates_h
0002 #define SiPixelCoordinates_h
0003 // -*- C++ -*-
0004 //
0005 // Class:      SiPixelCoordinates
0006 //
0007 // This class provides floating point numbers for
0008 // digis, clusters and hits that can be used to
0009 // easily plot various geometry related histograms
0010 //
0011 // Online and Offline conventions are kept for the variables
0012 // An additional ]0, +1[ or ]-0.5, +0.5[ is added depending on
0013 // the location of digi/cluster/hit on the module, so
0014 // the variables provided are roughly monotonic vs. global
0015 // coordinates (except that overlaps are removed), eg:
0016 // global     z: module, disk, disk_ring (large division)
0017 // global r-phi: ladder, blade, blade_panel
0018 // global     r:         ring, disk_ring (small division)
0019 //
0020 // Original Author: Janos Karancsi
0021 
0022 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0023 #include "DataFormats/DetId/interface/DetId.h"
0024 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0025 #include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
0026 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0027 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
0028 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0029 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
0030 
0031 #include <cstdint>
0032 #include <unordered_map>
0033 #include <utility>
0034 
0035 class SiPixelCoordinates {
0036 public:
0037   SiPixelCoordinates();
0038   SiPixelCoordinates(int);
0039   virtual ~SiPixelCoordinates();
0040 
0041   void init(const TrackerTopology*, const TrackerGeometry*, const SiPixelFedCablingMap*);
0042 
0043   // Integers
0044   int quadrant(const DetId&);
0045   int side(const DetId&);
0046   int module(const DetId&);
0047   // barrel specific
0048   int layer(const DetId&);
0049   int sector(const DetId&);
0050   int ladder(const DetId&);
0051   int signed_ladder(const DetId&);
0052   int signed_module(const DetId&);
0053   int half(const DetId&);
0054   int outer(const DetId&);
0055   int flipped(const DetId&);
0056   // endcap specific
0057   int disk(const DetId&);
0058   int signed_disk(const DetId&);
0059   int panel(const DetId&);
0060   int ring(const DetId&);
0061   int blade(const DetId&);
0062   int signed_blade(const DetId&);
0063 
0064   unsigned int fedid(const DetId&);
0065 
0066   int channel(const DetId&, const std::pair<int, int>&);
0067   int channel(const DetId&, const PixelDigi*);
0068   int channel(const DetId&, const SiPixelCluster*);
0069   int channel(const SiPixelRecHit*);
0070   int channel(const TrackingRecHit*);
0071 
0072   int roc(const DetId&, const std::pair<int, int>&);
0073   int roc(const DetId&, const PixelDigi*);
0074   int roc(const DetId&, const SiPixelCluster*);
0075   int roc(const SiPixelRecHit*);
0076   int roc(const TrackingRecHit*);
0077 
0078   // Floats (coordinates)
0079   float module_coord(const DetId&, const std::pair<int, int>&);
0080   float module_coord(const DetId&, const PixelDigi*);
0081   float module_coord(const DetId&, const SiPixelCluster*);
0082   float module_coord(const SiPixelRecHit*);
0083   float module_coord(const TrackingRecHit*);
0084 
0085   float signed_module_coord(const DetId&, const std::pair<int, int>&);
0086   float signed_module_coord(const DetId&, const PixelDigi*);
0087   float signed_module_coord(const DetId&, const SiPixelCluster*);
0088   float signed_module_coord(const SiPixelRecHit*);
0089   float signed_module_coord(const TrackingRecHit*);
0090 
0091   float ladder_coord(const DetId&, const std::pair<int, int>&);
0092   float ladder_coord(const DetId&, const PixelDigi*);
0093   float ladder_coord(const DetId&, const SiPixelCluster*);
0094   float ladder_coord(const SiPixelRecHit*);
0095   float ladder_coord(const TrackingRecHit*);
0096 
0097   float signed_ladder_coord(const DetId&, const std::pair<int, int>&);
0098   float signed_ladder_coord(const DetId&, const PixelDigi*);
0099   float signed_ladder_coord(const DetId&, const SiPixelCluster*);
0100   float signed_ladder_coord(const SiPixelRecHit*);
0101   float signed_ladder_coord(const TrackingRecHit*);
0102 
0103   float ring_coord(const DetId&, const std::pair<int, int>&);
0104   float ring_coord(const DetId&, const PixelDigi*);
0105   float ring_coord(const DetId&, const SiPixelCluster*);
0106   float ring_coord(const SiPixelRecHit*);
0107   float ring_coord(const TrackingRecHit*);
0108 
0109   float disk_coord(const DetId&, const std::pair<int, int>&);
0110   float disk_coord(const DetId&, const PixelDigi*);
0111   float disk_coord(const DetId&, const SiPixelCluster*);
0112   float disk_coord(const SiPixelRecHit*);
0113   float disk_coord(const TrackingRecHit*);
0114 
0115   float signed_disk_coord(const DetId&, const std::pair<int, int>&);
0116   float signed_disk_coord(const DetId&, const PixelDigi*);
0117   float signed_disk_coord(const DetId&, const SiPixelCluster*);
0118   float signed_disk_coord(const SiPixelRecHit*);
0119   float signed_disk_coord(const TrackingRecHit*);
0120 
0121   float disk_ring_coord(const DetId&, const std::pair<int, int>&);
0122   float disk_ring_coord(const DetId&, const PixelDigi*);
0123   float disk_ring_coord(const DetId&, const SiPixelCluster*);
0124   float disk_ring_coord(const SiPixelRecHit*);
0125   float disk_ring_coord(const TrackingRecHit*);
0126 
0127   float signed_disk_ring_coord(const DetId&, const std::pair<int, int>&);
0128   float signed_disk_ring_coord(const DetId&, const PixelDigi*);
0129   float signed_disk_ring_coord(const DetId&, const SiPixelCluster*);
0130   float signed_disk_ring_coord(const SiPixelRecHit*);
0131   float signed_disk_ring_coord(const TrackingRecHit*);
0132 
0133   float blade_coord(const DetId&, const std::pair<int, int>&);
0134   float blade_coord(const DetId&, const PixelDigi*);
0135   float blade_coord(const DetId&, const SiPixelCluster*);
0136   float blade_coord(const SiPixelRecHit*);
0137   float blade_coord(const TrackingRecHit*);
0138 
0139   float signed_blade_coord(const DetId&, const std::pair<int, int>&);
0140   float signed_blade_coord(const DetId&, const PixelDigi*);
0141   float signed_blade_coord(const DetId&, const SiPixelCluster*);
0142   float signed_blade_coord(const SiPixelRecHit*);
0143   float signed_blade_coord(const TrackingRecHit*);
0144 
0145   float blade_panel_coord(const DetId&, const std::pair<int, int>&);
0146   float blade_panel_coord(const DetId&, const PixelDigi*);
0147   float blade_panel_coord(const DetId&, const SiPixelCluster*);
0148   float blade_panel_coord(const SiPixelRecHit*);
0149   float blade_panel_coord(const TrackingRecHit*);
0150 
0151   float signed_blade_panel_coord(const DetId&, const std::pair<int, int>&);
0152   float signed_blade_panel_coord(const DetId&, const PixelDigi*);
0153   float signed_blade_panel_coord(const DetId&, const SiPixelCluster*);
0154   float signed_blade_panel_coord(const SiPixelRecHit*);
0155   float signed_blade_panel_coord(const TrackingRecHit*);
0156 
0157   float signed_shifted_blade_panel_coord(const DetId&, const std::pair<int, int>&);
0158   float signed_shifted_blade_panel_coord(const DetId&, const PixelDigi*);
0159   float signed_shifted_blade_panel_coord(const DetId&, const SiPixelCluster*);
0160   float signed_shifted_blade_panel_coord(const SiPixelRecHit*);
0161   float signed_shifted_blade_panel_coord(const TrackingRecHit*);
0162 
0163 private:
0164   int phase_;
0165 
0166   const TrackerTopology* tTopo_;
0167   const TrackerGeometry* tGeom_;
0168   const SiPixelFedCablingMap* cablingMap_;
0169 
0170   // Internal containers for optimal speed
0171   // - only calculate things once per DetId
0172   std::unordered_map<uint32_t, int> quadrant_;
0173   std::unordered_map<uint32_t, int> side_;
0174   std::unordered_map<uint32_t, int> module_;
0175   std::unordered_map<uint32_t, int> layer_;
0176   std::unordered_map<uint32_t, int> sector_;
0177   std::unordered_map<uint32_t, int> ladder_;
0178   std::unordered_map<uint32_t, int> signed_ladder_;
0179   std::unordered_map<uint32_t, int> signed_module_;
0180   std::unordered_map<uint32_t, int> half_;
0181   std::unordered_map<uint32_t, int> outer_;
0182   std::unordered_map<uint32_t, int> flipped_;
0183   std::unordered_map<uint32_t, int> disk_;
0184   std::unordered_map<uint32_t, int> signed_disk_;
0185   std::unordered_map<uint32_t, int> panel_;
0186   std::unordered_map<uint32_t, int> ring_;
0187   std::unordered_map<uint32_t, int> blade_;
0188   std::unordered_map<uint32_t, int> signed_blade_;
0189 
0190   std::unordered_map<uint32_t, unsigned int> fedid_;
0191   std::unordered_map<uint64_t, unsigned int> channel_;
0192   std::unordered_map<uint64_t, unsigned int> roc_;
0193 
0194   // Internal methods used for pixel coordinates
0195   bool isPixel_(const DetId&);
0196   bool isBPix_(const DetId&);
0197   bool isFPix_(const DetId&);
0198   std::pair<int, int> pixel_(const PixelDigi*);
0199   std::pair<int, int> pixel_(const SiPixelCluster*);
0200   std::pair<int, int> pixel_(const SiPixelRecHit*);
0201   float xcoord_on_module_(const DetId&, const std::pair<int, int>&);
0202   float ycoord_on_module_(const DetId&, const std::pair<int, int>&);
0203 };
0204 
0205 #endif