CMS 3D CMS Logo

SeedProducerFromSoA.cc
Go to the documentation of this file.
32 
33 /*
34  produces seeds directly from cuda produced tuples
35 */
36 template <typename TrackerTraits>
38 public:
39  explicit SeedProducerFromSoAT(const edm::ParameterSet& iConfig);
40  ~SeedProducerFromSoAT() override = default;
41 
42  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
43 
44 private:
45  void produce(edm::StreamID streamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
46 
47  // Event data tokens
50  // Event setup tokens
55 };
56 
57 template <typename TrackerTraits>
59  : tBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
60  tokenTrack_(consumes(iConfig.getParameter<edm::InputTag>("src"))),
61  idealMagneticFieldToken_(esConsumes()),
62  trackerDigiGeometryToken_(esConsumes()),
63  trackerPropagatorToken_(esConsumes(edm::ESInputTag("PropagatorWithMaterial"))),
64  minNumberOfHits_(iConfig.getParameter<int>("minNumberOfHits"))
65 
66 {
67  produces<TrajectorySeedCollection>();
68 }
69 
70 template <typename TrackerTraits>
73  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
74  desc.add<edm::InputTag>("src", edm::InputTag("pixelTrackSoA"));
75  desc.add<int>("minNumberOfHits", 0);
76 
77  descriptions.addWithDefaultLabel(desc);
78 }
79 
80 template <typename TrackerTraits>
83  const edm::EventSetup& iSetup) const {
84  // std::cout << "Converting gpu helix to trajectory seed" << std::endl;
85  auto result = std::make_unique<TrajectorySeedCollection>();
86 
87  using trackHelper = TracksUtilities<TrackerTraits>;
88 
89  auto const& fieldESH = iSetup.getHandle(idealMagneticFieldToken_);
90  auto const& tracker = iSetup.getHandle(trackerDigiGeometryToken_);
91  auto const& dus = tracker->detUnits();
92 
93  auto const& propagatorHandle = iSetup.getHandle(trackerPropagatorToken_);
94  const Propagator* propagator = &(*propagatorHandle);
95 
96  const auto& bsh = iEvent.get(tBeamSpot_);
97  // std::cout << "beamspot " << bsh.x0() << ' ' << bsh.y0() << ' ' << bsh.z0() << std::endl;
98  GlobalPoint bs(bsh.x0(), bsh.y0(), bsh.z0());
99 
100  auto const& tsoa = iEvent.get(tokenTrack_);
101 
102  auto const* quality = tsoa.view().quality();
103  auto const& detIndices = tsoa.view().detIndices();
104  auto maxTracks = tsoa.view().metadata().size();
105 
106  for (int32_t it = 0; it < maxTracks; ++it) {
107  auto nHits = trackHelper::nHits(tsoa.view(), it);
108  if (nHits == 0)
109  break; // this is a guard: maybe we need to move to nTracks...
110 
111  auto q = quality[it];
113  continue; // FIXME
114  if (nHits < minNumberOfHits_)
115  continue;
116 
117  // fill hits with invalid just to hold the detId
118  auto b = detIndices.begin(it);
120  for (int iHit = 0; iHit < nHits; ++iHit) {
121  auto const* det = dus[*(b + iHit)];
122  // FIXME at some point get a proper type ...
123  hits.push_back(new InvalidTrackingRecHit(*det, TrackingRecHit::bad));
124  }
125 
126  // mind: this values are respect the beamspot!
127 
128  float phi = trackHelper::nHits(tsoa.view(), it);
129 
130  riemannFit::Vector5d ipar, opar;
131  riemannFit::Matrix5d icov, ocov;
132  trackHelper::copyToDense(tsoa.view(), ipar, icov, it);
133  riemannFit::transformToPerigeePlane(ipar, icov, opar, ocov);
134 
135  LocalTrajectoryParameters lpar(opar(0), opar(1), opar(2), opar(3), opar(4), 1.);
137  for (int i = 0; i < 5; ++i)
138  for (int j = i; j < 5; ++j)
139  m(i, j) = ocov(i, j);
140 
141  float sp = std::sin(phi);
142  float cp = std::cos(phi);
143  Surface::RotationType rot(sp, -cp, 0, 0, 0, -1.f, cp, sp, 0);
144 
145  Plane impPointPlane(bs, rot);
146  GlobalTrajectoryParameters gp(impPointPlane.toGlobal(lpar.position()),
147  impPointPlane.toGlobal(lpar.momentum()),
148  lpar.charge(),
149  fieldESH.product());
150 
151  JacobianLocalToCurvilinear jl2c(impPointPlane, lpar, *fieldESH.product());
152 
153  AlgebraicSymMatrix55 mo = ROOT::Math::Similarity(jl2c.jacobian(), m);
154 
156 
157  auto const& lastHit = hits.back();
158 
159  TrajectoryStateOnSurface outerState = propagator->propagate(fts, *lastHit.surface());
160 
161  if (!outerState.isValid()) {
162  edm::LogError("SeedFromGPU") << " was trying to create a seed from:\n"
163  << fts << "\n propagating to: " << lastHit.geographicalId().rawId();
164  continue;
165  }
166 
167  auto const& pTraj = trajectoryStateTransform::persistentState(outerState, lastHit.geographicalId().rawId());
168 
169  result->emplace_back(pTraj, hits, alongMomentum);
170  }
171 
172  iEvent.put(std::move(result));
173 }
174 
177 
const edm::ESGetToken< Propagator, TrackingComponentsRecord > trackerPropagatorToken_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Eigen::Matrix< double, 5, 5 > Matrix5d
Definition: FitResult.h:19
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
const edm::EDGetTokenT< reco::BeamSpot > tBeamSpot_
Eigen::Matrix< double, 5, 1 > Vector5d
Definition: FitResult.h:15
Log< level::Error, false > LogError
void transformToPerigeePlane(VI5 const &ip, MI5 const &icov, VO5 &op, MO5 &ocov)
Definition: FitUtils.h:54
Definition: Plane.h:16
string quality
int iEvent
Definition: GenABIO.cc:224
LocalVector momentum() const
Momentum vector in the local frame.
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double f[11][100]
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
TrackCharge charge() const
Charge (-1, 0 or 1)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > idealMagneticFieldToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerDigiGeometryToken_
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
double b
Definition: hdecay.h:120
~SeedProducerFromSoAT() override=default
maxTracks
Definition: DMR_cfg.py:158
fixed size matrix
HLT enums.
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
SeedProducerFromSoAT(const edm::ParameterSet &iConfig)
LocalPoint position() const
Local x and y position coordinates.
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< TrackSoAHeterogeneousHost< TrackerTraits > > tokenTrack_