CMS 3D CMS Logo

PixelTrackProducerFromSoA.cc
Go to the documentation of this file.
24 
29 
33 
34 #include "storeTracks.h"
36 
42 public:
43  using IndToEdm = std::vector<uint16_t>;
44 
45  explicit PixelTrackProducerFromSoA(const edm::ParameterSet &iConfig);
46  ~PixelTrackProducerFromSoA() override = default;
47 
48  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
49 
50  // using HitModuleStart = std::array<uint32_t, gpuClustering::maxNumModules + 1>;
52 
53 private:
54  void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override;
55 
56  // Event Data tokens
61  // Event Setup tokens
64 
65  int32_t const minNumberOfHits_;
66 };
67 
69  : tBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
70  tokenTrack_(consumes<PixelTrackHeterogeneous>(iConfig.getParameter<edm::InputTag>("trackSrc"))),
71  cpuHits_(consumes<SiPixelRecHitCollectionNew>(iConfig.getParameter<edm::InputTag>("pixelRecHitLegacySrc"))),
72  hmsToken_(consumes<HMSstorage>(iConfig.getParameter<edm::InputTag>("pixelRecHitLegacySrc"))),
73  idealMagneticFieldToken_(esConsumes()),
74  ttTopoToken_(esConsumes()),
75  minNumberOfHits_(iConfig.getParameter<int>("minNumberOfHits")) {
76  produces<reco::TrackCollection>();
77  produces<TrackingRecHitCollection>();
78  produces<reco::TrackExtraCollection>();
79  produces<IndToEdm>();
80 }
81 
84  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
85  desc.add<edm::InputTag>("trackSrc", edm::InputTag("pixelTracksSoA"));
86  desc.add<edm::InputTag>("pixelRecHitLegacySrc", edm::InputTag("siPixelRecHitsPreSplittingLegacy"));
87  desc.add<int>("minNumberOfHits", 0);
88 
89  descriptions.addWithDefaultLabel(desc);
90 }
91 
94  const edm::EventSetup &iSetup) const {
95  // std::cout << "Converting gpu helix in reco tracks" << std::endl;
96 
97  auto indToEdmP = std::make_unique<IndToEdm>();
98  auto &indToEdm = *indToEdmP;
99 
100  auto const &idealField = iSetup.getData(idealMagneticFieldToken_);
101 
103 
104  auto const &httopo = iSetup.getData(ttTopoToken_);
105 
106  const auto &bsh = iEvent.get(tBeamSpot_);
107  GlobalPoint bs(bsh.x0(), bsh.y0(), bsh.z0());
108 
109  auto const &rechits = iEvent.get(cpuHits_);
110  std::vector<TrackingRecHit const *> hitmap;
111  auto const &rcs = rechits.data();
112  auto nhits = rcs.size();
113  hitmap.resize(nhits, nullptr);
114 
115  auto const *hitsModuleStart = iEvent.get(hmsToken_).get();
116  auto fc = hitsModuleStart;
117 
118  for (auto const &h : rcs) {
119  auto const &thit = static_cast<BaseTrackerRecHit const &>(h);
120  auto detI = thit.det()->index();
121  auto const &clus = thit.firstClusterRef();
122  assert(clus.isPixel());
123  auto i = fc[detI] + clus.pixelCluster().originalId();
124  if (i >= hitmap.size())
125  hitmap.resize(i + 256, nullptr); // only in case of hit overflow in one module
126  assert(nullptr == hitmap[i]);
127  hitmap[i] = &h;
128  }
129 
130  std::vector<const TrackingRecHit *> hits;
131  hits.reserve(5);
132 
133  const auto &tsoa = *iEvent.get(tokenTrack_);
134 
135  auto const *quality = tsoa.qualityData();
136  auto const &fit = tsoa.stateAtBS;
137  auto const &hitIndices = tsoa.hitIndices;
138  auto maxTracks = tsoa.stride();
139 
140  int32_t nt = 0;
141 
142  for (int32_t it = 0; it < maxTracks; ++it) {
143  auto nHits = tsoa.nHits(it);
144  if (nHits == 0)
145  break; // this is a guard: maybe we need to move to nTracks...
146  indToEdm.push_back(-1);
147  auto q = quality[it];
149  continue;
150  if (nHits < minNumberOfHits_)
151  continue;
152  indToEdm.back() = nt;
153  ++nt;
154 
155  hits.resize(nHits);
156  auto b = hitIndices.begin(it);
157  for (int iHit = 0; iHit < nHits; ++iHit)
158  hits[iHit] = hitmap[*(b + iHit)];
159 
160  // mind: this values are respect the beamspot!
161 
162  float chi2 = tsoa.chi2(it);
163  float phi = tsoa.phi(it);
164 
165  riemannFit::Vector5d ipar, opar;
166  riemannFit::Matrix5d icov, ocov;
167  fit.copyToDense(ipar, icov, it);
168  riemannFit::transformToPerigeePlane(ipar, icov, opar, ocov);
169 
170  LocalTrajectoryParameters lpar(opar(0), opar(1), opar(2), opar(3), opar(4), 1.);
172  for (int i = 0; i < 5; ++i)
173  for (int j = i; j < 5; ++j)
174  m(i, j) = ocov(i, j);
175 
176  float sp = std::sin(phi);
177  float cp = std::cos(phi);
178  Surface::RotationType rot(sp, -cp, 0, 0, 0, -1.f, cp, sp, 0);
179 
180  Plane impPointPlane(bs, rot);
182  impPointPlane.toGlobal(lpar.position()), impPointPlane.toGlobal(lpar.momentum()), lpar.charge(), &idealField);
183  JacobianLocalToCurvilinear jl2c(impPointPlane, lpar, idealField);
184 
185  AlgebraicSymMatrix55 mo = ROOT::Math::Similarity(jl2c.jacobian(), m);
186 
187  int ndof = 2 * hits.size() - 5;
188  chi2 = chi2 * ndof;
189  GlobalPoint vv = gp.position();
190  math::XYZPoint pos(vv.x(), vv.y(), vv.z());
191  GlobalVector pp = gp.momentum();
192  math::XYZVector mom(pp.x(), pp.y(), pp.z());
193 
194  auto track = std::make_unique<reco::Track>(chi2, ndof, pos, mom, gp.charge(), CurvilinearTrajectoryError(mo));
195  // filter???
196  tracks.emplace_back(track.release(), hits);
197  }
198  // std::cout << "processed " << nt << " good tuples " << tracks.size() << "out of " << indToEdm.size() << std::endl;
199 
200  // store tracks
201  storeTracks(iEvent, tracks, httopo);
202  iEvent.put(std::move(indToEdmP));
203 }
204 
Vector3DBase
Definition: Vector3DBase.h:8
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
TrackExtra.h
TkRotation< float >
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
PixelTrackProducerFromSoA
Definition: PixelTrackProducerFromSoA.cc:41
GlobalTrajectoryParameters.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
align::BeamSpot
Definition: StructureType.h:95
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
nt
int nt
Definition: AMPTWrapper.h:42
edm::EDGetTokenT< reco::BeamSpot >
edm
HLT enums.
Definition: AlignableModifier.h:19
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
PixelTrackProducerFromSoA::PixelTrackProducerFromSoA
PixelTrackProducerFromSoA(const edm::ParameterSet &iConfig)
Definition: PixelTrackProducerFromSoA.cc:68
pos
Definition: PixelAliasList.h:18
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
riemannFit::Vector5d
Eigen::Matrix< double, 5, 1 > Vector5d
Definition: FitResult.h:16
cms::cuda::assert
assert(be >=bs)
HostProduct.h
HeterogeneousSoA
Definition: HeterogeneousSoA.h:13
hgcal_conditions::parameters
Definition: HGCConditions.h:86
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
PixelTrackProducerFromSoA::produce
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
Definition: PixelTrackProducerFromSoA.cc:92
PixelTrackProducerFromSoA::tBeamSpot_
const edm::EDGetTokenT< reco::BeamSpot > tBeamSpot_
Definition: PixelTrackProducerFromSoA.cc:57
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:109
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
ndof
Definition: HIMultiTrackSelector.h:49
LocalTrajectoryParameters
Definition: LocalTrajectoryParameters.h:25
Plane.h
LocalTrajectoryParameters.h
MakerMacros.h
TrackerTopology.h
cms::cuda::bs
bs
Definition: HistoContainer.h:127
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
h
TrackerTopologyRcd.h
Track.h
riemannFit::transformToPerigeePlane
__host__ __device__ void transformToPerigeePlane(VI5 const &ip, MI5 const &icov, VO5 &op, MO5 &ocov)
Definition: FitUtils.h:218
TrackFwd.h
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
JacobianLocalToCurvilinear.h
BeamSpot.h
LocalTrajectoryParameters::position
LocalPoint position() const
Local x and y position coordinates.
Definition: LocalTrajectoryParameters.h:85
PixelTrackProducerFromSoA::tokenTrack_
const edm::EDGetTokenT< PixelTrackHeterogeneous > tokenTrack_
Definition: PixelTrackProducerFromSoA.cc:58
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
CurvilinearTrajectoryError.h
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
OrphanHandle.h
PixelTrackProducerFromSoA::ttTopoToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttTopoToken_
Definition: PixelTrackProducerFromSoA.cc:63
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
IdealMagneticFieldRecord.h
benchmark_cfg.fc
fc
Definition: benchmark_cfg.py:15
PixelTrackProducerFromSoA::minNumberOfHits_
const int32_t minNumberOfHits_
Definition: PixelTrackProducerFromSoA.cc:65
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
LocalTrajectoryParameters::charge
TrackCharge charge() const
Charge (-1, 0 or 1)
Definition: LocalTrajectoryParameters.h:110
Point3DBase< float, GlobalTag >
ParameterSetDescription.h
nhits
Definition: HIMultiTrackSelector.h:42
b
double b
Definition: hdecay.h:118
EDGetToken.h
PixelTrackProducerFromSoA::idealMagneticFieldToken_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > idealMagneticFieldToken_
Definition: PixelTrackProducerFromSoA.cc:62
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
PixelTrackProducerFromSoA::IndToEdm
std::vector< uint16_t > IndToEdm
Definition: PixelTrackProducerFromSoA.cc:43
pixeltrackfitting::TracksWithRecHits
std::vector< TrackWithRecHits > TracksWithRecHits
Definition: TracksWithHits.h:13
SiPixelRecHitCollection.h
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
HostProduct
Definition: HostProduct.h:8
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
storeTracks.h
HLT_FULL_cff.maxTracks
maxTracks
Definition: HLT_FULL_cff.py:33252
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
ModuleDef.h
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
gpuClusteringConstants.h
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
edm::EventSetup
Definition: EventSetup.h:58
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord >
InputTag.h
storeTracks
void storeTracks(Ev &ev, const TWH &tracksWithHits, const TrackerTopology &ttopo)
Definition: storeTracks.h:20
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
DDAxes::phi
PixelTrackProducerFromSoA::cpuHits_
const edm::EDGetTokenT< SiPixelRecHitCollectionNew > cpuHits_
Definition: PixelTrackProducerFromSoA.cc:59
edmNew::DetSetVector
Definition: DetSetNew.h:13
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
PixelTrackProducerFromSoA::hmsToken_
const edm::EDGetTokenT< HMSstorage > hmsToken_
Definition: PixelTrackProducerFromSoA.cc:60
LocalTrajectoryParameters::momentum
LocalVector momentum() const
Momentum vector in the local frame.
Definition: LocalTrajectoryParameters.h:88
Plane
Definition: Plane.h:16
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
riemannFit::Matrix5d
Eigen::Matrix< double, 5, 5 > Matrix5d
Definition: FitResult.h:20
EventSetup.h
PixelTrackHeterogeneous.h
FitUtils.h
ConsumesCollector.h
ParameterSet.h
createTree.pp
pp
Definition: createTree.py:17
EDProducer.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PixelTrackProducerFromSoA::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PixelTrackProducerFromSoA.cc:82
JacobianLocalToCurvilinear
Definition: JacobianLocalToCurvilinear.h:21
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
pixelTrack::Quality::loose
edm::Event
Definition: Event.h:73
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
edm::InputTag
Definition: InputTag.h:15
fit
Definition: CombinedChiSquaredLikelihood.h:6
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87
PixelTrackProducerFromSoA::~PixelTrackProducerFromSoA
~PixelTrackProducerFromSoA() override=default