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  int32_t nt = 0;
107  for (int32_t it = 0; it < maxTracks; ++it) {
108  auto nHits = trackHelper::nHits(tsoa.view(), it);
109  if (nHits == 0)
110  break; // this is a guard: maybe we need to move to nTracks...
111 
112  auto q = quality[it];
114  continue; // FIXME
115  if (nHits < minNumberOfHits_)
116  continue;
117  ++nt;
118 
119  // fill hits with invalid just to hold the detId
120  auto b = detIndices.begin(it);
122  for (int iHit = 0; iHit < nHits; ++iHit) {
123  auto const* det = dus[*(b + iHit)];
124  // FIXME at some point get a proper type ...
125  hits.push_back(new InvalidTrackingRecHit(*det, TrackingRecHit::bad));
126  }
127 
128  // mind: this values are respect the beamspot!
129 
130  float phi = trackHelper::nHits(tsoa.view(), it);
131 
132  riemannFit::Vector5d ipar, opar;
133  riemannFit::Matrix5d icov, ocov;
134  trackHelper::copyToDense(tsoa.view(), ipar, icov, it);
135  riemannFit::transformToPerigeePlane(ipar, icov, opar, ocov);
136 
137  LocalTrajectoryParameters lpar(opar(0), opar(1), opar(2), opar(3), opar(4), 1.);
139  for (int i = 0; i < 5; ++i)
140  for (int j = i; j < 5; ++j)
141  m(i, j) = ocov(i, j);
142 
143  float sp = std::sin(phi);
144  float cp = std::cos(phi);
145  Surface::RotationType rot(sp, -cp, 0, 0, 0, -1.f, cp, sp, 0);
146 
147  Plane impPointPlane(bs, rot);
148  GlobalTrajectoryParameters gp(impPointPlane.toGlobal(lpar.position()),
149  impPointPlane.toGlobal(lpar.momentum()),
150  lpar.charge(),
151  fieldESH.product());
152 
153  JacobianLocalToCurvilinear jl2c(impPointPlane, lpar, *fieldESH.product());
154 
155  AlgebraicSymMatrix55 mo = ROOT::Math::Similarity(jl2c.jacobian(), m);
156 
158 
159  auto const& lastHit = hits.back();
160 
161  TrajectoryStateOnSurface outerState = propagator->propagate(fts, *lastHit.surface());
162 
163  if (!outerState.isValid()) {
164  edm::LogError("SeedFromGPU") << " was trying to create a seed from:\n"
165  << fts << "\n propagating to: " << lastHit.geographicalId().rawId();
166  continue;
167  }
168 
169  auto const& pTraj = trajectoryStateTransform::persistentState(outerState, lastHit.geographicalId().rawId());
170 
171  result->emplace_back(pTraj, hits, alongMomentum);
172  }
173 
174  iEvent.put(std::move(result));
175 }
176 
179 
const edm::ESGetToken< Propagator, TrackingComponentsRecord > trackerPropagatorToken_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
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_
Log< level::Error, false > LogError
Definition: Plane.h:16
string quality
Eigen::Matrix< double, 5, 1 > Vector5d
Definition: FitResult.h:16
int iEvent
Definition: GenABIO.cc:224
__host__ __device__ void transformToPerigeePlane(VI5 const &ip, MI5 const &icov, VO5 &op, MO5 &ocov)
Definition: FitUtils.h:218
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
int nt
Definition: AMPTWrapper.h:42
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:118
~SeedProducerFromSoAT() override=default
maxTracks
Definition: DMR_cfg.py:158
Eigen::Matrix< double, 5, 5 > Matrix5d
Definition: FitResult.h:20
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_