Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:21

0001 #ifndef RecoParticleFlow_PFClusterProducer_PFRecHitCaloNavigator_h
0002 #define RecoParticleFlow_PFClusterProducer_PFRecHitCaloNavigator_h
0003 
0004 #include "RecoParticleFlow/PFClusterProducer/interface/PFRecHitNavigatorBase.h"
0005 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0006 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0007 
0008 #include "RecoCaloTools/Navigation/interface/CaloNavigator.h"
0009 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0010 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0011 #include "DataFormats/EcalDetId/interface/ESDetId.h"
0012 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0013 
0014 #include "Geometry/CaloTopology/interface/EcalEndcapTopology.h"
0015 #include "Geometry/CaloTopology/interface/EcalBarrelTopology.h"
0016 #include "Geometry/CaloTopology/interface/EcalPreshowerTopology.h"
0017 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0018 
0019 #include "Geometry/CaloTopology/interface/CaloTowerTopology.h"
0020 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
0021 
0022 template <typename DET, typename TOPO, bool ownsTopo = true>
0023 class PFRecHitCaloNavigator : public PFRecHitNavigatorBase {
0024 public:
0025   ~PFRecHitCaloNavigator() override {
0026     if (!ownsTopo) {
0027       topology_.release();
0028     }
0029   }
0030 
0031   void associateNeighbours(reco::PFRecHit& hit,
0032                            std::unique_ptr<reco::PFRecHitCollection>& hits,
0033                            edm::RefProd<reco::PFRecHitCollection>& refProd) override {
0034     DetId detid(hit.detId());
0035 
0036     CaloNavigator<DET> navigator(detid, topology_.get());
0037 
0038     DetId N(0);
0039     DetId E(0);
0040     DetId S(0);
0041     DetId W(0);
0042     DetId NW(0);
0043     DetId NE(0);
0044     DetId SW(0);
0045     DetId SE(0);
0046 
0047     N = navigator.north();
0048     associateNeighbour(N, hit, hits, refProd, 0, 1, 0);
0049 
0050     if (N != DetId(0)) {
0051       NE = navigator.east();
0052     } else {
0053       navigator.home();
0054       E = navigator.east();
0055       NE = navigator.north();
0056     }
0057     associateNeighbour(NE, hit, hits, refProd, 1, 1, 0);
0058     navigator.home();
0059 
0060     S = navigator.south();
0061     associateNeighbour(S, hit, hits, refProd, 0, -1, 0);
0062 
0063     if (S != DetId(0)) {
0064       SW = navigator.west();
0065     } else {
0066       navigator.home();
0067       W = navigator.west();
0068       SW = navigator.south();
0069     }
0070     associateNeighbour(SW, hit, hits, refProd, -1, -1, 0);
0071     navigator.home();
0072 
0073     E = navigator.east();
0074     associateNeighbour(E, hit, hits, refProd, 1, 0, 0);
0075 
0076     if (E != DetId(0)) {
0077       SE = navigator.south();
0078     } else {
0079       navigator.home();
0080       S = navigator.south();
0081       SE = navigator.east();
0082     }
0083     associateNeighbour(SE, hit, hits, refProd, 1, -1, 0);
0084     navigator.home();
0085 
0086     W = navigator.west();
0087     associateNeighbour(W, hit, hits, refProd, -1, 0, 0);
0088 
0089     if (W != DetId(0)) {
0090       NW = navigator.north();
0091     } else {
0092       navigator.home();
0093       N = navigator.north();
0094       NW = navigator.west();
0095     }
0096     associateNeighbour(NW, hit, hits, refProd, -1, 1, 0);
0097   }
0098 
0099 protected:
0100   std::unique_ptr<const TOPO> topology_;
0101 };
0102 
0103 #endif