CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SeedProducerFromSoA.cc
Go to the documentation of this file.
32 
33 /*
34  produces seeds directly from cuda produced tuples
35 */
37 public:
39  ~SeedProducerFromSoA() override = default;
40 
41  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
42 
43 private:
44  void produce(edm::StreamID streamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
45 
46  // Event data tokens
49  // Event setup tokens
54 };
55 
57  : tBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
58  tokenTrack_(consumes<PixelTrackHeterogeneous>(iConfig.getParameter<edm::InputTag>("src"))),
59  idealMagneticFieldToken_(esConsumes()),
60  trackerDigiGeometryToken_(esConsumes()),
61  trackerPropagatorToken_(esConsumes(edm::ESInputTag("PropagatorWithMaterial"))),
62  minNumberOfHits_(iConfig.getParameter<int>("minNumberOfHits"))
63 
64 {
65  produces<TrajectorySeedCollection>();
66 }
67 
70  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
71  desc.add<edm::InputTag>("src", edm::InputTag("pixelTrackSoA"));
72  desc.add<int>("minNumberOfHits", 0);
73 
74  descriptions.addWithDefaultLabel(desc);
75 }
76 
78  // std::cout << "Converting gpu helix to trajectory seed" << std::endl;
79  auto result = std::make_unique<TrajectorySeedCollection>();
80 
81  auto const& fieldESH = iSetup.getHandle(idealMagneticFieldToken_);
82  auto const& tracker = iSetup.getHandle(trackerDigiGeometryToken_);
83  auto const& dus = tracker->detUnits();
84 
85  auto const& propagatorHandle = iSetup.getHandle(trackerPropagatorToken_);
86  const Propagator* propagator = &(*propagatorHandle);
87 
88  const auto& bsh = iEvent.get(tBeamSpot_);
89  // std::cout << "beamspot " << bsh.x0() << ' ' << bsh.y0() << ' ' << bsh.z0() << std::endl;
90  GlobalPoint bs(bsh.x0(), bsh.y0(), bsh.z0());
91 
92  const auto& tsoa = *(iEvent.get(tokenTrack_));
93 
94  auto const* quality = tsoa.qualityData();
95  auto const& fit = tsoa.stateAtBS;
96  auto const& detIndices = tsoa.detIndices;
97  auto maxTracks = tsoa.stride();
98 
99  int32_t nt = 0;
100  for (int32_t it = 0; it < maxTracks; ++it) {
101  auto nHits = tsoa.nHits(it);
102  if (nHits == 0)
103  break; // this is a guard: maybe we need to move to nTracks...
104 
105  auto q = quality[it];
107  continue; // FIXME
108  if (nHits < minNumberOfHits_)
109  continue;
110  ++nt;
111 
112  // fill hits with invalid just to hold the detId
113  auto b = detIndices.begin(it);
115  for (int iHit = 0; iHit < nHits; ++iHit) {
116  auto const* det = dus[*(b + iHit)];
117  // FIXME at some point get a proper type ...
119  }
120 
121  // mind: this values are respect the beamspot!
122 
123  float phi = tsoa.phi(it);
124 
125  riemannFit::Vector5d ipar, opar;
126  riemannFit::Matrix5d icov, ocov;
127  fit.copyToDense(ipar, icov, it);
128  riemannFit::transformToPerigeePlane(ipar, icov, opar, ocov);
129 
130  LocalTrajectoryParameters lpar(opar(0), opar(1), opar(2), opar(3), opar(4), 1.);
132  for (int i = 0; i < 5; ++i)
133  for (int j = i; j < 5; ++j)
134  m(i, j) = ocov(i, j);
135 
136  float sp = std::sin(phi);
137  float cp = std::cos(phi);
138  Surface::RotationType rot(sp, -cp, 0, 0, 0, -1.f, cp, sp, 0);
139 
140  Plane impPointPlane(bs, rot);
141  GlobalTrajectoryParameters gp(impPointPlane.toGlobal(lpar.position()),
142  impPointPlane.toGlobal(lpar.momentum()),
143  lpar.charge(),
144  fieldESH.product());
145 
146  JacobianLocalToCurvilinear jl2c(impPointPlane, lpar, *fieldESH.product());
147 
148  AlgebraicSymMatrix55 mo = ROOT::Math::Similarity(jl2c.jacobian(), m);
149 
151 
152  auto const& lastHit = hits.back();
153 
154  TrajectoryStateOnSurface outerState = propagator->propagate(fts, *lastHit.surface());
155 
156  if (!outerState.isValid()) {
157  edm::LogError("SeedFromGPU") << " was trying to create a seed from:\n"
158  << fts << "\n propagating to: " << lastHit.geographicalId().rawId();
159  continue;
160  }
161 
162  auto const& pTraj = trajectoryStateTransform::persistentState(outerState, lastHit.geographicalId().rawId());
163 
164  result->emplace_back(pTraj, hits, alongMomentum);
165  }
166 
167  iEvent.put(std::move(result));
168 }
169 
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
tuple propagator
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
reference back()
Definition: OwnVector.h:431
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::ESGetToken< Propagator, TrackingComponentsRecord > trackerPropagatorToken_
LocalPoint position() const
Local x and y position coordinates.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
uint32_t const *__restrict__ Quality * quality
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
~SeedProducerFromSoA() override=default
Log< level::Error, false > LogError
Definition: Plane.h:16
tuple result
Definition: mps_fire.py:311
Eigen::Matrix< double, 5, 1 > Vector5d
Definition: FitResult.h:16
void push_back(D *&d)
Definition: OwnVector.h:326
int iEvent
Definition: GenABIO.cc:224
__host__ __device__ void transformToPerigeePlane(VI5 const &ip, MI5 const &icov, VO5 &op, MO5 &ocov)
Definition: FitUtils.h:218
auto const & fit
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def move
Definition: eostools.py:511
SeedProducerFromSoA(const edm::ParameterSet &iConfig)
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
LocalVector momentum() const
Momentum vector in the local frame.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
int nt
Definition: AMPTWrapper.h:42
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
double b
Definition: hdecay.h:118
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t nHits
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerDigiGeometryToken_
TrackCharge charge() const
Charge (-1, 0 or 1)
const edm::EDGetTokenT< reco::BeamSpot > tBeamSpot_
Eigen::Matrix< double, 5, 5 > Matrix5d
Definition: FitResult.h:20
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > idealMagneticFieldToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
const edm::EDGetTokenT< PixelTrackHeterogeneous > tokenTrack_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283