CMS 3D CMS Logo

PatternRecognitionbyRecovery.cc
Go to the documentation of this file.
1 // Author: Felice Pantaleo - felice.pantaleo@cern.ch
2 // Date: 05/2024
3 
4 #include <vector>
14 #include "TrackstersPCA.h"
15 
16 using namespace ticl;
17 
18 template <typename TILES>
21  : PatternRecognitionAlgoBaseT<TILES>(conf, iC), caloGeomToken_(iC.esConsumes<CaloGeometry, CaloGeometryRecord>()) {}
22 
23 template <typename TILES>
26  std::vector<Trackster> &result,
27  std::unordered_map<int, std::vector<int>> &seedToTracksterAssociation) {
28  // Get the geometry setup
29  edm::EventSetup const &es = input.es;
30  const CaloGeometry &geom = es.getData(caloGeomToken_);
31  rhtools_.setGeometry(geom);
32  const auto z_limit_em = rhtools_.getPositionLayer(rhtools_.lastLayerEE(false), false).z();
33  // Clear the result vector
34  result.clear();
35 
36  // Iterate over all layer clusters
37  for (size_t i = 0; i < input.layerClusters.size(); ++i) {
38  if (input.mask[i] == 0.f) {
39  continue; // Skip masked clusters
40  }
41 
42  // Create a new trackster for each layer cluster
43  Trackster trackster;
44  trackster.vertices().push_back(i);
45  trackster.vertex_multiplicity().push_back(1);
46  const auto &lc = input.layerClusters[i];
47  trackster.setTimeAndError(input.layerClustersTime.get(i).first, input.layerClustersTime.get(i).second);
48  trackster.setRawEnergy(lc.energy());
49  trackster.setBarycenter({float(lc.x()), float(lc.y()), float(lc.z())});
50  float invcosh = 1.f / std::cosh(lc.position().eta());
51  trackster.setRawPt(lc.energy() * invcosh);
52 
53  if (std::abs(lc.z()) <= z_limit_em) {
54  trackster.setRawEmEnergy(lc.energy());
55  trackster.setRawEmPt(lc.energy() * invcosh);
56  }
57 
58  // Add the trackster to the result vector
59  result.push_back(trackster);
60  }
61 
62  // Log the number of tracksters created
64  edm::LogVerbatim("PatternRecognitionbyRecovery") << "Created " << result.size() << " tracksters";
65  }
66 }
67 
68 template <typename TILES>
70  const std::vector<Trackster> &inTracksters,
72  std::unordered_map<int, std::vector<int>> &seedToTracksterAssociation) {
73  output = inTracksters;
74 }
75 
76 template <typename TILES>
78  iDesc.add<int>("algo_verbosity", 0);
79 }
80 
81 // Explicitly instantiate the templates
Log< level::Info, true > LogVerbatim
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void setRawPt(float value)
Definition: Trackster.h:73
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void filter(std::vector< Trackster > &output, const std::vector< Trackster > &inTracksters, const typename PatternRecognitionAlgoBaseT< TILES >::Inputs &input, std::unordered_map< int, std::vector< int >> &seedToTracksterAssociation) override
void setRawEnergy(float value)
Definition: Trackster.h:69
static std::string const input
Definition: EdmProvDump.cc:50
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< unsigned int > & vertices()
Definition: Trackster.h:57
void setRawEmPt(float value)
Definition: Trackster.h:74
std::vector< float > & vertex_multiplicity()
Definition: Trackster.h:58
void setRawEmEnergy(float value)
Definition: Trackster.h:71
PatternRecognitionbyRecovery(const edm::ParameterSet &conf, edm::ConsumesCollector)
Definition: Common.h:10
void setTimeAndError(float t, float tError)
Definition: Trackster.h:64
Definition: output.py:1
void makeTracksters(const typename PatternRecognitionAlgoBaseT< TILES >::Inputs &input, std::vector< Trackster > &result, std::unordered_map< int, std::vector< int >> &seedToTracksterAssociation) override
void setBarycenter(Vector value)
Definition: Trackster.h:75