Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:42

0001 #ifndef Geometry_CaloTopology_FastTimeTopology_h
0002 #define Geometry_CaloTopology_FastTimeTopology_h 1
0003 
0004 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0005 #include "DataFormats/ForwardDetId/interface/FastTimeDetId.h"
0006 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h"
0007 #include "Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h"
0008 #include <vector>
0009 #include <iostream>
0010 
0011 class FastTimeTopology : public CaloSubdetectorTopology {
0012 public:
0013   /// create a new Topology
0014   FastTimeTopology(const FastTimeDDDConstants& hdcons, ForwardSubdetector subdet, int type);
0015 
0016   /// virtual destructor
0017   ~FastTimeTopology() override {}
0018 
0019   /// move the Topology north (increment iy)
0020   DetId goNorth(const DetId& id) const override { return offsetBy(id, 0, +1); }
0021   std::vector<DetId> north(const DetId& id) const override {
0022     DetId nextId = goNorth(id);
0023     std::vector<DetId> vNeighborsDetId;
0024     if (!(nextId == DetId(0)))
0025       vNeighborsDetId.emplace_back(nextId);
0026     return vNeighborsDetId;
0027   }
0028 
0029   /// move the Topology south (decrement iy)
0030   DetId goSouth(const DetId& id) const override { return offsetBy(id, 0, -1); }
0031   std::vector<DetId> south(const DetId& id) const override {
0032     DetId nextId = goSouth(id);
0033     std::vector<DetId> vNeighborsDetId;
0034     if (!(nextId == DetId(0)))
0035       vNeighborsDetId.emplace_back(nextId);
0036     return vNeighborsDetId;
0037   }
0038 
0039   /// move the Topology east (positive ix)
0040   DetId goEast(const DetId& id) const override { return offsetBy(id, +1, 0); }
0041   std::vector<DetId> east(const DetId& id) const override {
0042     DetId nextId = goEast(id);
0043     std::vector<DetId> vNeighborsDetId;
0044     if (!(nextId == DetId(0)))
0045       vNeighborsDetId.emplace_back(nextId);
0046     return vNeighborsDetId;
0047   }
0048 
0049   /// move the Topology west (negative ix)
0050   DetId goWest(const DetId& id) const override { return offsetBy(id, -1, 0); }
0051   std::vector<DetId> west(const DetId& id) const override {
0052     DetId nextId = goWest(id);
0053     std::vector<DetId> vNeighborsDetId;
0054     if (!(nextId == DetId(0)))
0055       vNeighborsDetId.emplace_back(nextId);
0056     return vNeighborsDetId;
0057   }
0058 
0059   std::vector<DetId> up(const DetId& id) const override {
0060     std::vector<DetId> vNeighborsDetId;
0061     return vNeighborsDetId;
0062   }
0063 
0064   std::vector<DetId> down(const DetId& id) const override {
0065     std::vector<DetId> vNeighborsDetId;
0066     return vNeighborsDetId;
0067   }
0068 
0069   ///Dense indexing
0070   uint32_t detId2denseId(const DetId& id) const override;
0071   DetId denseId2detId(uint32_t denseId) const override;
0072   virtual uint32_t detId2denseGeomId(const DetId& id) const;
0073 
0074   ///Is this a valid cell id
0075   bool valid(const DetId& id) const override;
0076   bool validHashIndex(uint32_t ix) const { return (ix < kSizeForDenseIndexing); }
0077 
0078   unsigned int totalModules() const { return kSizeForDenseIndexing; }
0079   unsigned int totalGeomModules() const { return (unsigned int)(2 * kHGeomHalf_); }
0080   int numberCells() const { return kHGeomHalf_; }
0081 
0082   const FastTimeDDDConstants& dddConstants() const { return hdcons_; }
0083 
0084   DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY) const;
0085   DetId switchZSide(const DetId startId) const;
0086 
0087   struct DecodedDetId {
0088     DecodedDetId() : iPhi(0), iEtaZ(0), zside(0), iType(0), subdet(0) {}
0089     int iPhi, iEtaZ, zside, iType, subdet;
0090   };
0091 
0092   DecodedDetId geomDenseId2decId(const uint32_t& hi) const;
0093   DecodedDetId decode(const DetId& id) const;
0094   DetId encode(const DecodedDetId& id_) const;
0095 
0096   ForwardSubdetector subDetector() const { return subdet_; }
0097   int detectorType() const { return type_; }
0098 
0099 private:
0100   /// move the nagivator along x, y
0101   DetId changeXY(const DetId& id, int nrStepsX, int nrStepsY) const;
0102 
0103   const FastTimeDDDConstants& hdcons_;
0104   ForwardSubdetector subdet_;
0105   int type_, nEtaZ_, nPhi_, kHGhalf_, kHGeomHalf_;
0106   unsigned int kSizeForDenseIndexing;
0107 };
0108 
0109 #endif