CMS 3D CMS Logo

convertHits.h
Go to the documentation of this file.
1 #ifndef RecoTracker_MkFit_plugins_convertHits_h
2 #define RecoTracker_MkFit_plugins_convertHits_h
3 
5 
7 
10 
12 
14 
15 // ROOT
16 #include "Math/SVector.h"
17 #include "Math/SMatrix.h"
18 
19 // mkFit includes
22 
23 namespace mkfit {
24  template <typename Traits, typename HitCollection>
26  const HitCollection& hits,
27  mkfit::HitVec& mkFitHits,
28  std::vector<TrackingRecHit const*>& clusterIndexToHit,
29  std::vector<float>& clusterChargeVec,
30  const TrackerTopology& ttopo,
31  const TransientTrackingRecHitBuilder& ttrhBuilder,
32  const MkFitGeometry& mkFitGeom) {
33  if (hits.empty())
34  return edm::ProductID{};
35 
36  edm::ProductID clusterID;
37  {
38  const auto& lastClusterRef = hits.data().back().firstClusterRef();
39  clusterID = lastClusterRef.id();
40  if (lastClusterRef.index() >= mkFitHits.size()) {
41  auto const size = lastClusterRef.index();
42  mkFitHits.resize(size);
43  clusterIndexToHit.resize(size, nullptr);
44  if constexpr (Traits::applyCCC()) {
45  clusterChargeVec.resize(size, -1.f);
46  }
47  }
48  }
49 
50  for (const auto& detset : hits) {
51  const DetId detid = detset.detId();
52  const auto ilay = mkFitGeom.mkFitLayerNumber(detid);
53 
54  for (const auto& hit : detset) {
55  const auto charge = traits.clusterCharge(hit, detid);
56  if (!traits.passCCC(charge))
57  continue;
58 
59  const auto& gpos = hit.globalPosition();
60  SVector3 pos(gpos.x(), gpos.y(), gpos.z());
61  const auto& gerr = hit.globalPositionError();
63  err.At(0, 0) = gerr.cxx();
64  err.At(1, 1) = gerr.cyy();
65  err.At(2, 2) = gerr.czz();
66  err.At(0, 1) = gerr.cyx();
67  err.At(0, 2) = gerr.czx();
68  err.At(1, 2) = gerr.czy();
69 
70  auto clusterRef = hit.firstClusterRef();
71  if UNLIKELY (clusterRef.id() != clusterID) {
72  throw cms::Exception("LogicError")
73  << "Input hit collection has Refs to many cluster collections. Last hit had Ref to product " << clusterID
74  << ", but encountered Ref to product " << clusterRef.id() << " on detid " << detid.rawId();
75  }
76  const auto clusterIndex = clusterRef.index();
77  LogTrace("MkFitHitConverter") << "Adding hit detid " << detid.rawId() << " subdet " << detid.subdetId()
78  << " layer " << ttopo.layer(detid) << " isStereo " << ttopo.isStereo(detid)
79  << " zplus "
80  << " index " << clusterIndex << " ilay " << ilay;
81 
82  if UNLIKELY (clusterIndex >= mkFitHits.size()) {
83  mkFitHits.resize(clusterIndex + 1);
84  clusterIndexToHit.resize(clusterIndex + 1, nullptr);
85  if constexpr (Traits::applyCCC()) {
86  clusterChargeVec.resize(clusterIndex + 1, -1.f);
87  }
88  }
89  mkFitHits[clusterIndex] = mkfit::Hit(pos, err);
90  clusterIndexToHit[clusterIndex] = &hit;
91  if constexpr (Traits::applyCCC()) {
92  clusterChargeVec[clusterIndex] = charge;
93  }
94 
95  const auto uniqueIdInLayer = mkFitGeom.uniqueIdInLayer(ilay, detid.rawId());
96  traits.setDetails(mkFitHits[clusterIndex], *(hit.cluster()), uniqueIdInLayer, charge);
97  }
98  }
99  return clusterID;
100  }
101 } // namespace mkfit
102 
103 #endif
size
Write out results.
ROOT::Math::SVector< float, 3 > SVector3
Definition: MatrixSTypes.h:14
unsigned int uniqueIdInLayer(int layer, unsigned int detId) const
Definition: MkFitGeometry.h:36
bool isStereo(const DetId &id) const
unsigned int layer(const DetId &id) const
#define LogTrace(id)
edm::ProductID convertHits(const Traits &traits, const HitCollection &hits, mkfit::HitVec &mkFitHits, std::vector< TrackingRecHit const *> &clusterIndexToHit, std::vector< float > &clusterChargeVec, const TrackerTopology &ttopo, const TransientTrackingRecHitBuilder &ttrhBuilder, const MkFitGeometry &mkFitGeom)
Definition: convertHits.h:25
double f[11][100]
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
SeedingHitSet::ConstRecHitPointer Hit
std::vector< Hit > HitVec
ProductIndex id() const
Definition: ProductID.h:35
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
int mkFitLayerNumber(DetId detId) const
std::vector< Hit > HitCollection
Definition: HitCollection.h:35
#define UNLIKELY(x)
Definition: Likely.h:21
ROOT::Math::SMatrix< float, 3, 3, ROOT::Math::MatRepSym< float, 3 > > SMatrixSym33
Definition: MatrixSTypes.h:13