File indexing completed on 2024-11-23 03:28:57
0001 #ifndef RecoECAL_ECALClusters_Multi5x5ClusterAlgo_h
0002 #define RecoECAL_ECALClusters_Multi5x5ClusterAlgo_h
0003
0004 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0005
0006 #include "DataFormats/Math/interface/Point3D.h"
0007 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
0008 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0009 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0010 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
0011 #include "DataFormats/Math/interface/RectangularEtaPhiRegion.h"
0012
0013 #include "RecoCaloTools/Navigation/interface/CaloNavigator.h"
0014 #include "RecoCaloTools/Navigation/interface/EcalBarrelNavigator.h"
0015 #include "RecoCaloTools/Navigation/interface/EcalEndcapNavigator.h"
0016 #include "Geometry/CaloTopology/interface/EcalBarrelHardcodedTopology.h"
0017 #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h"
0018 #include "DataFormats/CaloRecHit/interface/CaloID.h"
0019
0020
0021 #include <string>
0022 #include <vector>
0023 #include <set>
0024 #include <optional>
0025
0026 typedef std::map<DetId, EcalRecHit> RecHitsMap;
0027
0028 class Multi5x5ClusterAlgo {
0029 public:
0030
0031
0032
0033
0034 class ProtoBasicCluster {
0035 std::vector<std::pair<DetId, float> > hits_;
0036 EcalRecHit seed_;
0037 float energy_;
0038 bool containsSeed_;
0039
0040 public:
0041 ProtoBasicCluster();
0042 ProtoBasicCluster(float iEnergy, const EcalRecHit &iSeed, std::vector<std::pair<DetId, float> > iHits)
0043 : hits_(std::move(iHits)), seed_(iSeed), energy_(iEnergy), containsSeed_{isSeedCrysInHits_()} {}
0044
0045 float energy() const { return energy_; }
0046 const EcalRecHit &seed() const { return seed_; }
0047 const std::vector<std::pair<DetId, float> > &hits() const { return hits_; }
0048 bool containsSeed() const { return containsSeed_; }
0049
0050 bool removeHit(const EcalRecHit &hitToRM);
0051 bool addSeed();
0052
0053 private:
0054 bool isSeedCrysInHits_() const;
0055 };
0056
0057 Multi5x5ClusterAlgo() {}
0058
0059 Multi5x5ClusterAlgo(double ebst,
0060 double ecst,
0061 const std::vector<int> &v_chstatus,
0062 const PositionCalc &posCalc,
0063 bool reassignSeedCrysToClusterItSeeds = false)
0064 : ecalBarrelSeedThreshold_(ebst),
0065 ecalEndcapSeedThreshold_(ecst),
0066 v_chstatus_(v_chstatus),
0067 reassignSeedCrysToClusterItSeeds_(reassignSeedCrysToClusterItSeeds) {
0068 posCalculator_ = posCalc;
0069 std::sort(v_chstatus_.begin(), v_chstatus_.end());
0070 }
0071
0072 virtual ~Multi5x5ClusterAlgo() {}
0073
0074
0075 std::vector<reco::BasicCluster> makeClusters(
0076 const EcalRecHitCollection *hits,
0077 const CaloSubdetectorGeometry *geometry,
0078 const CaloSubdetectorTopology *topology_p,
0079 const CaloSubdetectorGeometry *geometryES_p,
0080 reco::CaloID::Detectors detector,
0081 bool regional = false,
0082 const std::vector<RectangularEtaPhiRegion> ®ions = std::vector<RectangularEtaPhiRegion>());
0083
0084
0085 typedef math::XYZPoint Point;
0086
0087 private:
0088
0089 PositionCalc posCalculator_;
0090
0091
0092 reco::CaloID::Detectors detector_;
0093
0094
0095 double ecalBarrelSeedThreshold_;
0096 double ecalEndcapSeedThreshold_;
0097
0098
0099 std::vector<int> v_chstatus_;
0100
0101 bool reassignSeedCrysToClusterItSeeds_;
0102
0103 std::vector<reco::BasicCluster> mainSearch(const EcalRecHitCollection *hits,
0104 const CaloSubdetectorGeometry *geometry_p,
0105 const CaloSubdetectorTopology *topology_p,
0106 const CaloSubdetectorGeometry *geometryES_p,
0107 const std::vector<EcalRecHit> &seeds);
0108
0109
0110
0111 bool checkMaxima(CaloNavigator<DetId> &navigator, const EcalRecHitCollection *hits) const;
0112
0113
0114
0115
0116 std::vector<std::pair<DetId, float> > prepareCluster(CaloNavigator<DetId> &navigator,
0117 const EcalRecHitCollection *hits,
0118 const CaloSubdetectorGeometry *geometry,
0119 std::set<DetId> &used_seeds,
0120 std::set<DetId> &canSeed_s) const;
0121
0122
0123
0124 static bool addCrystal(const DetId &det, const EcalRecHitCollection &recHits);
0125
0126
0127
0128
0129 std::optional<ProtoBasicCluster> makeCluster(const EcalRecHitCollection *hits,
0130 const CaloSubdetectorGeometry *geometry_p,
0131 const CaloSubdetectorGeometry *geometryES_p,
0132 const EcalRecHitCollection::const_iterator &seedIt,
0133 bool seedOutside,
0134 std::vector<std::pair<DetId, float> > ¤t_v);
0135 };
0136
0137 #endif