Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-26 05:07:08

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 filter(std::vector<Trackster>& output,
0022                 const std::vector<Trackster>& inTracksters,
0023                 const typename PatternRecognitionAlgoBaseT<TILES>::Inputs& input,
0024                 std::unordered_map<int, std::vector<int>>& seedToTracksterAssociation) override;
0025 
0026     void energyRegressionAndID(const std::vector<reco::CaloCluster>& layerClusters,
0027                                const tensorflow::Session*,
0028                                std::vector<Trackster>& result);
0029 
0030     static void fillPSetDescription(edm::ParameterSetDescription& iDesc);
0031 
0032   private:
0033     struct ClustersOnLayer {
0034       std::vector<float> x;
0035       std::vector<float> y;
0036       std::vector<float> z;
0037       std::vector<float> r_over_absz;
0038       std::vector<float> radius;
0039       std::vector<float> eta;
0040       std::vector<float> phi;
0041       std::vector<int> cells;
0042       std::vector<int> algoId;  // hgcal_em = 6, hgcal_had = 7, hgcal_scintillator = 8, hfnose = 9
0043       std::vector<uint8_t> isSilicon;
0044 
0045       std::vector<float> energy;
0046       std::vector<float> rho;
0047       std::vector<float> z_extension;
0048 
0049       std::vector<std::pair<float, int>> delta;
0050       std::vector<std::pair<int, int>> nearestHigher;
0051       std::vector<int> clusterIndex;
0052       std::vector<unsigned int> layerClusterOriginalIdx;
0053       std::vector<std::vector<std::pair<int, int>>> followers;
0054       std::vector<bool> isSeed;
0055 
0056       void clear() {
0057         x.clear();
0058         y.clear();
0059         z.clear();
0060         r_over_absz.clear();
0061         radius.clear();
0062         eta.clear();
0063         phi.clear();
0064         cells.clear();
0065         algoId.clear();
0066         isSilicon.clear();
0067         energy.clear();
0068         rho.clear();
0069         z_extension.clear();
0070         delta.clear();
0071         nearestHigher.clear();
0072         clusterIndex.clear();
0073         layerClusterOriginalIdx.clear();
0074         followers.clear();
0075         isSeed.clear();
0076       }
0077 
0078       void shrink_to_fit() {
0079         x.shrink_to_fit();
0080         y.shrink_to_fit();
0081         z.shrink_to_fit();
0082         r_over_absz.shrink_to_fit();
0083         radius.shrink_to_fit();
0084         eta.shrink_to_fit();
0085         phi.shrink_to_fit();
0086         cells.shrink_to_fit();
0087         algoId.shrink_to_fit();
0088         isSilicon.shrink_to_fit();
0089         energy.shrink_to_fit();
0090         rho.shrink_to_fit();
0091         z_extension.shrink_to_fit();
0092         delta.shrink_to_fit();
0093         nearestHigher.shrink_to_fit();
0094         clusterIndex.shrink_to_fit();
0095         layerClusterOriginalIdx.shrink_to_fit();
0096         followers.shrink_to_fit();
0097         isSeed.shrink_to_fit();
0098       }
0099     };
0100 
0101     void reset() {
0102       for (auto& c : clusters_) {
0103         c.clear();
0104         c.shrink_to_fit();
0105       }
0106     }
0107     void calculateLocalDensity(const TILES&, const int layerId, const std::vector<std::pair<int, int>>&);
0108     void calculateDistanceToHigher(const TILES&, const int layerId, const std::vector<std::pair<int, int>>&);
0109     int findAndAssignTracksters(const TILES&, const std::vector<std::pair<int, int>>&);
0110     void dumpClusters(const TILES& tiles,
0111                       const std::vector<std::pair<int, int>>& layerIdx2layerandSoa,
0112                       const int) const;
0113     void dumpTracksters(const std::vector<std::pair<int, int>>& layerIdx2layerandSoa,
0114                         const int,
0115                         const std::vector<Trackster>&) const;
0116     void dumpTiles(const TILES&) const;
0117 
0118     std::vector<ClustersOnLayer> clusters_;
0119     std::vector<float> layersPosZ_;
0120     std::vector<int> tracksterSeedAlgoId_;
0121 
0122     edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
0123     const std::vector<double> criticalDensity_;
0124     const std::vector<double> criticalSelfDensity_;
0125     const std::vector<int> densitySiblingLayers_;
0126     const std::vector<double> densityEtaPhiDistanceSqr_;
0127     const std::vector<double> densityXYDistanceSqr_;
0128     const std::vector<double> kernelDensityFactor_;
0129     const bool densityOnSameLayer_;
0130     const bool nearestHigherOnSameLayer_;
0131     const bool useAbsoluteProjectiveScale_;
0132     const bool useClusterDimensionXY_;
0133     const bool rescaleDensityByZ_;
0134     const std::vector<double> criticalEtaPhiDistance_;
0135     const std::vector<double> criticalXYDistance_;
0136     const std::vector<int> criticalZDistanceLyr_;
0137     const std::vector<double> outlierMultiplier_;
0138     const std::vector<int> minNumLayerCluster_;
0139     const bool doPidCut_;
0140     const float cutHadProb_;
0141     const std::vector<int> filter_on_categories_;
0142     const bool computeLocalTime_;
0143     const bool usePCACleaning_;
0144 
0145     hgcal::RecHitTools rhtools_;
0146   };
0147 
0148 }  // namespace ticl
0149 #endif