File indexing completed on 2024-06-13 03:24:02
0001
0002
0003
0004 #ifndef __RecoHGCal_TICL_PRbyCLUE3D_H__
0005 #define __RecoHGCal_TICL_PRbyCLUE3D_H__
0006 #include <memory> // unique_ptr
0007 #include "RecoHGCal/TICL/interface/PatternRecognitionAlgoBase.h"
0008 #include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"
0009
0010 namespace ticl {
0011 template <typename TILES>
0012 class PatternRecognitionbyCLUE3D final : public PatternRecognitionAlgoBaseT<TILES> {
0013 public:
0014 PatternRecognitionbyCLUE3D(const edm::ParameterSet& conf, edm::ConsumesCollector);
0015 ~PatternRecognitionbyCLUE3D() override = default;
0016
0017 void makeTracksters(const typename PatternRecognitionAlgoBaseT<TILES>::Inputs& input,
0018 std::vector<Trackster>& result,
0019 std::unordered_map<int, std::vector<int>>& seedToTracksterAssociation) override;
0020
0021 void energyRegressionAndID(const std::vector<reco::CaloCluster>& layerClusters,
0022 const tensorflow::Session*,
0023 std::vector<Trackster>& result);
0024
0025 static void fillPSetDescription(edm::ParameterSetDescription& iDesc);
0026
0027 private:
0028 struct ClustersOnLayer {
0029 std::vector<float> x;
0030 std::vector<float> y;
0031 std::vector<float> z;
0032 std::vector<float> r_over_absz;
0033 std::vector<float> radius;
0034 std::vector<float> eta;
0035 std::vector<float> phi;
0036 std::vector<int> cells;
0037 std::vector<int> algoId;
0038 std::vector<uint8_t> isSilicon;
0039
0040 std::vector<float> energy;
0041 std::vector<float> rho;
0042 std::vector<float> z_extension;
0043
0044 std::vector<std::pair<float, int>> delta;
0045 std::vector<std::pair<int, int>> nearestHigher;
0046 std::vector<int> clusterIndex;
0047 std::vector<unsigned int> layerClusterOriginalIdx;
0048 std::vector<std::vector<std::pair<int, int>>> followers;
0049 std::vector<bool> isSeed;
0050
0051 void clear() {
0052 x.clear();
0053 y.clear();
0054 z.clear();
0055 r_over_absz.clear();
0056 radius.clear();
0057 eta.clear();
0058 phi.clear();
0059 cells.clear();
0060 algoId.clear();
0061 isSilicon.clear();
0062 energy.clear();
0063 rho.clear();
0064 z_extension.clear();
0065 delta.clear();
0066 nearestHigher.clear();
0067 clusterIndex.clear();
0068 layerClusterOriginalIdx.clear();
0069 followers.clear();
0070 isSeed.clear();
0071 }
0072
0073 void shrink_to_fit() {
0074 x.shrink_to_fit();
0075 y.shrink_to_fit();
0076 z.shrink_to_fit();
0077 r_over_absz.shrink_to_fit();
0078 radius.shrink_to_fit();
0079 eta.shrink_to_fit();
0080 phi.shrink_to_fit();
0081 cells.shrink_to_fit();
0082 algoId.shrink_to_fit();
0083 isSilicon.shrink_to_fit();
0084 energy.shrink_to_fit();
0085 rho.shrink_to_fit();
0086 z_extension.shrink_to_fit();
0087 delta.shrink_to_fit();
0088 nearestHigher.shrink_to_fit();
0089 clusterIndex.shrink_to_fit();
0090 layerClusterOriginalIdx.shrink_to_fit();
0091 followers.shrink_to_fit();
0092 isSeed.shrink_to_fit();
0093 }
0094 };
0095
0096 void reset() {
0097 for (auto& c : clusters_) {
0098 c.clear();
0099 c.shrink_to_fit();
0100 }
0101 }
0102 void calculateLocalDensity(const TILES&, const int layerId, const std::vector<std::pair<int, int>>&);
0103 void calculateDistanceToHigher(const TILES&, const int layerId, const std::vector<std::pair<int, int>>&);
0104 int findAndAssignTracksters(const TILES&, const std::vector<std::pair<int, int>>&);
0105 void dumpClusters(const TILES& tiles,
0106 const std::vector<std::pair<int, int>>& layerIdx2layerandSoa,
0107 const int) const;
0108 void dumpTracksters(const std::vector<std::pair<int, int>>& layerIdx2layerandSoa,
0109 const int,
0110 const std::vector<Trackster>&) const;
0111 void dumpTiles(const TILES&) const;
0112
0113 std::vector<ClustersOnLayer> clusters_;
0114 std::vector<float> layersPosZ_;
0115 std::vector<int> tracksterSeedAlgoId_;
0116
0117 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
0118 const std::vector<double> criticalDensity_;
0119 const std::vector<double> criticalSelfDensity_;
0120 const std::vector<int> densitySiblingLayers_;
0121 const std::vector<double> densityEtaPhiDistanceSqr_;
0122 const std::vector<double> densityXYDistanceSqr_;
0123 const std::vector<double> kernelDensityFactor_;
0124 const bool densityOnSameLayer_;
0125 const bool nearestHigherOnSameLayer_;
0126 const bool useAbsoluteProjectiveScale_;
0127 const bool useClusterDimensionXY_;
0128 const bool rescaleDensityByZ_;
0129 const std::vector<double> criticalEtaPhiDistance_;
0130 const std::vector<double> criticalXYDistance_;
0131 const std::vector<int> criticalZDistanceLyr_;
0132 const std::vector<double> outlierMultiplier_;
0133 const std::vector<int> minNumLayerCluster_;
0134 const bool doPidCut_;
0135 const float cutHadProb_;
0136 const std::vector<int> filter_on_categories_;
0137 const std::string eidInputName_;
0138 const std::string eidOutputNameEnergy_;
0139 const std::string eidOutputNameId_;
0140 const float eidMinClusterEnergy_;
0141 const int eidNLayers_;
0142 const int eidNClusters_;
0143 const bool computeLocalTime_;
0144
0145 hgcal::RecHitTools rhtools_;
0146 tensorflow::Session* eidSession_;
0147
0148 static const int eidNFeatures_ = 3;
0149 };
0150
0151 }
0152 #endif