Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-24 05:59:38

0001 // Author: Marco Rovere - marco.rovere@cern.ch
0002 // Date: 04/2021
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<uint8_t> isSilicon;
0038 
0039       std::vector<float> energy;
0040       std::vector<float> rho;
0041       std::vector<float> z_extension;
0042 
0043       std::vector<std::pair<float, int>> delta;
0044       std::vector<std::pair<int, int>> nearestHigher;
0045       std::vector<int> clusterIndex;
0046       std::vector<unsigned int> layerClusterOriginalIdx;
0047       std::vector<std::vector<std::pair<int, int>>> followers;
0048       std::vector<bool> isSeed;
0049 
0050       void clear() {
0051         x.clear();
0052         y.clear();
0053         z.clear();
0054         r_over_absz.clear();
0055         radius.clear();
0056         eta.clear();
0057         phi.clear();
0058         cells.clear();
0059         isSilicon.clear();
0060         energy.clear();
0061         rho.clear();
0062         z_extension.clear();
0063         delta.clear();
0064         nearestHigher.clear();
0065         clusterIndex.clear();
0066         layerClusterOriginalIdx.clear();
0067         followers.clear();
0068         isSeed.clear();
0069       }
0070 
0071       void shrink_to_fit() {
0072         x.shrink_to_fit();
0073         y.shrink_to_fit();
0074         z.shrink_to_fit();
0075         r_over_absz.shrink_to_fit();
0076         radius.shrink_to_fit();
0077         eta.shrink_to_fit();
0078         phi.shrink_to_fit();
0079         cells.shrink_to_fit();
0080         isSilicon.shrink_to_fit();
0081         energy.shrink_to_fit();
0082         rho.shrink_to_fit();
0083         z_extension.shrink_to_fit();
0084         delta.shrink_to_fit();
0085         nearestHigher.shrink_to_fit();
0086         clusterIndex.shrink_to_fit();
0087         layerClusterOriginalIdx.shrink_to_fit();
0088         followers.shrink_to_fit();
0089         isSeed.shrink_to_fit();
0090       }
0091     };
0092 
0093     void reset() {
0094       for (auto& c : clusters_) {
0095         c.clear();
0096         c.shrink_to_fit();
0097       }
0098     }
0099     void calculateLocalDensity(const TILES&, const int layerId, const std::vector<std::pair<int, int>>&);
0100     void calculateDistanceToHigher(const TILES&, const int layerId, const std::vector<std::pair<int, int>>&);
0101     int findAndAssignTracksters(const TILES&, const std::vector<std::pair<int, int>>&);
0102     void dumpClusters(const TILES& tiles,
0103                       const std::vector<std::pair<int, int>>& layerIdx2layerandSoa,
0104                       const int) const;
0105     void dumpTracksters(const std::vector<std::pair<int, int>>& layerIdx2layerandSoa,
0106                         const int,
0107                         const std::vector<Trackster>&) const;
0108     void dumpTiles(const TILES&) const;
0109 
0110     std::vector<ClustersOnLayer> clusters_;
0111     std::vector<float> layersPosZ_;
0112 
0113     edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
0114     const double criticalDensity_;
0115     const double criticalSelfDensity_;
0116     const int densitySiblingLayers_;
0117     const double densityEtaPhiDistanceSqr_;
0118     const double densityXYDistanceSqr_;
0119     const double kernelDensityFactor_;
0120     const bool densityOnSameLayer_;
0121     const bool nearestHigherOnSameLayer_;
0122     const bool useAbsoluteProjectiveScale_;
0123     const bool useClusterDimensionXY_;
0124     const bool rescaleDensityByZ_;
0125     const double criticalEtaPhiDistance_;
0126     const double criticalXYDistance_;
0127     const int criticalZDistanceLyr_;
0128     const double outlierMultiplier_;
0129     const int minNumLayerCluster_;
0130     const std::vector<int> filter_on_categories_;
0131     const std::string eidInputName_;
0132     const std::string eidOutputNameEnergy_;
0133     const std::string eidOutputNameId_;
0134     const float eidMinClusterEnergy_;
0135     const int eidNLayers_;
0136     const int eidNClusters_;
0137 
0138     hgcal::RecHitTools rhtools_;
0139     tensorflow::Session* eidSession_;
0140 
0141     static const int eidNFeatures_ = 3;
0142   };
0143 
0144 }  // namespace ticl
0145 #endif