CMS 3D CMS Logo

TrackstersPCA.h
Go to the documentation of this file.
1 #ifndef RECOHGCAL_TICL_TRACKSTERSPCA_H
2 #define RECOHGCAL_TICL_TRACKSTERSPCA_H
3 
6 #include <vector>
8 
9 namespace ticl {
21  void assignPCAtoTracksters(std::vector<Trackster> &tracksters,
22  const std::vector<reco::CaloCluster> &layerClusters,
23  const edm::ValueMap<std::pair<float, float>> &layerClustersTime,
24  double z_limit_em,
25  hgcal::RecHitTools const &rhTools,
26  bool computeLocalTime = false,
27  bool energyWeight = true,
28  bool clean = false,
29  int minLayer = 10,
30  int maxLayer = 10);
31  std::pair<float, float> computeLocalTracksterTime(const Trackster &trackster,
32  const std::vector<reco::CaloCluster> &layerClusters,
33  const edm::ValueMap<std::pair<float, float>> &layerClustersTime,
34  const Eigen::Vector3f &barycenter,
35  size_t N);
36  std::pair<float, float> computeTracksterTime(const Trackster &trackster,
37  const edm::ValueMap<std::pair<float, float>> &layerClustersTime,
38  size_t N);
39 
40  inline unsigned getLayerFromLC(const reco::CaloCluster &LC, const hgcal::RecHitTools &rhtools) {
41  std::vector<std::pair<DetId, float>> thisclusterHits = LC.hitsAndFractions();
42  auto layer = rhtools.getLayerWithOffset(thisclusterHits[0].first);
43  return layer;
44  }
45 
46  // Sort the layer clusters in the given trackster in bins of layer. Returns : vector[index=layer, value=vector[LC index]]]
47  inline std::vector<std::vector<unsigned>> sortByLayer(const Trackster &ts,
48  const std::vector<reco::CaloCluster> &layerClusters,
49  const hgcal::RecHitTools &rhtools) {
50  size_t N = ts.vertices().size();
51 
52  std::vector<std::vector<unsigned>> result;
53  result.resize(rhtools.lastLayer() + 1);
54 
55  for (unsigned i = 0; i < N; ++i) {
56  const auto &thisLC = layerClusters[ts.vertices(i)];
57  auto layer = getLayerFromLC(thisLC, rhtools);
58  result[layer].push_back(i);
59  }
60  return result;
61  }
62 } // namespace ticl
63 #endif
std::vector< std::vector< unsigned > > sortByLayer(const Trackster &ts, const std::vector< reco::CaloCluster > &layerClusters, const hgcal::RecHitTools &rhtools)
Definition: TrackstersPCA.h:47
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
unsigned getLayerFromLC(const reco::CaloCluster &LC, const hgcal::RecHitTools &rhtools)
Definition: TrackstersPCA.h:40
void assignPCAtoTracksters(std::vector< Trackster > &tracksters, const std::vector< reco::CaloCluster > &layerClusters, const edm::ValueMap< std::pair< float, float >> &layerClustersTime, double z_limit_em, hgcal::RecHitTools const &rhTools, bool computeLocalTime=false, bool energyWeight=true, bool clean=false, int minLayer=10, int maxLayer=10)
static void clean(char *s)
std::pair< float, float > computeLocalTracksterTime(const Trackster &trackster, const std::vector< reco::CaloCluster > &layerClusters, const edm::ValueMap< std::pair< float, float >> &layerClustersTime, const Eigen::Vector3f &barycenter, size_t N)
std::pair< float, float > computeTracksterTime(const Trackster &trackster, const edm::ValueMap< std::pair< float, float >> &layerClustersTime, size_t N)
std::vector< unsigned int > & vertices()
Definition: Trackster.h:57
#define N
Definition: blowfish.cc:9
Definition: Common.h:10
Eigen::Vector3f Vector3f
Definition: FitUtils.h:52
unsigned int lastLayer(bool nose=false) const
Definition: RecHitTools.h:80
unsigned int getLayerWithOffset(const DetId &) const
Definition: RecHitTools.cc:381