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_;
67 };
68 
70  : tBeamSpot_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"))),
71  tokenTrack_(consumes<PixelTrackHeterogeneous>(iConfig.getParameter<edm::InputTag>("trackSrc"))),
72  cpuHits_(consumes<SiPixelRecHitCollectionNew>(iConfig.getParameter<edm::InputTag>("pixelRecHitLegacySrc"))),
73  hmsToken_(consumes<HMSstorage>(iConfig.getParameter<edm::InputTag>("pixelRecHitLegacySrc"))),
74  idealMagneticFieldToken_(esConsumes()),
75  ttTopoToken_(esConsumes()),
76  minNumberOfHits_(iConfig.getParameter<int>("minNumberOfHits")),
77  minQuality_(pixelTrack::qualityByName(iConfig.getParameter<std::string>("minQuality"))) {
79  throw cms::Exception("PixelTrackConfiguration")
80  << iConfig.getParameter<std::string>("minQuality") + " is not a pixelTrack::Quality";
81  }
83  throw cms::Exception("PixelTrackConfiguration")
84  << iConfig.getParameter<std::string>("minQuality") + " not supported";
85  }
86  produces<reco::TrackCollection>();
87  produces<TrackingRecHitCollection>();
88  produces<reco::TrackExtraCollection>();
89  produces<IndToEdm>();
90 }
91 
94  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
95  desc.add<edm::InputTag>("trackSrc", edm::InputTag("pixelTracksSoA"));
96  desc.add<edm::InputTag>("pixelRecHitLegacySrc", edm::InputTag("siPixelRecHitsPreSplittingLegacy"));
97  desc.add<int>("minNumberOfHits", 0);
98  desc.add<std::string>("minQuality", "loose");
99  descriptions.addWithDefaultLabel(desc);
100 }
101 
104  const edm::EventSetup &iSetup) const {
105  // enum class Quality : uint8_t { bad = 0, edup, dup, loose, strict, tight, highPurity };
114 
115  // std::cout << "Converting gpu helix in reco tracks" << std::endl;
116 
117  auto indToEdmP = std::make_unique<IndToEdm>();
118  auto &indToEdm = *indToEdmP;
119 
120  auto const &idealField = iSetup.getData(idealMagneticFieldToken_);
121 
123 
124  auto const &httopo = iSetup.getData(ttTopoToken_);
125 
126  const auto &bsh = iEvent.get(tBeamSpot_);
127  GlobalPoint bs(bsh.x0(), bsh.y0(), bsh.z0());
128 
129  auto const &rechits = iEvent.get(cpuHits_);
130  std::vector<TrackingRecHit const *> hitmap;
131  auto const &rcs = rechits.data();
132  auto nhits = rcs.size();
133  hitmap.resize(nhits, nullptr);
134 
135  auto const *hitsModuleStart = iEvent.get(hmsToken_).get();
136  auto fc = hitsModuleStart;
137 
138  for (auto const &h : rcs) {
139  auto const &thit = static_cast<BaseTrackerRecHit const &>(h);
140  auto detI = thit.det()->index();
141  auto const &clus = thit.firstClusterRef();
142  assert(clus.isPixel());
143  auto i = fc[detI] + clus.pixelCluster().originalId();
144  if (i >= hitmap.size())
145  hitmap.resize(i + 256, nullptr); // only in case of hit overflow in one module
146  assert(nullptr == hitmap[i]);
147  hitmap[i] = &h;
148  }
149 
150  std::vector<const TrackingRecHit *> hits;
151  hits.reserve(5);
152 
153  const auto &tsoa = *iEvent.get(tokenTrack_);
154 
155  auto const *quality = tsoa.qualityData();
156  auto const &fit = tsoa.stateAtBS;
157  auto const &hitIndices = tsoa.hitIndices;
158  auto maxTracks = tsoa.stride();
159 
160  tracks.reserve(maxTracks);
161 
162  int32_t nt = 0;
163 
164  for (int32_t it = 0; it < maxTracks; ++it) {
165  auto nHits = tsoa.nHits(it);
166  if (nHits == 0)
167  break; // this is a guard: maybe we need to move to nTracks...
168  indToEdm.push_back(-1);
169  auto q = quality[it];
170  if (q < minQuality_)
171  continue;
172  if (nHits < minNumberOfHits_)
173  continue;
174  indToEdm.back() = nt;
175  ++nt;
176 
177  hits.resize(nHits);
178  auto b = hitIndices.begin(it);
179  for (int iHit = 0; iHit < nHits; ++iHit)
180  hits[iHit] = hitmap[*(b + iHit)];
181 
182  // mind: this values are respect the beamspot!
183 
184  float chi2 = tsoa.chi2(it);
185  float phi = tsoa.phi(it);
186 
187  riemannFit::Vector5d ipar, opar;
188  riemannFit::Matrix5d icov, ocov;
189  fit.copyToDense(ipar, icov, it);
190  riemannFit::transformToPerigeePlane(ipar, icov, opar, ocov);
191 
192  LocalTrajectoryParameters lpar(opar(0), opar(1), opar(2), opar(3), opar(4), 1.);
194  for (int i = 0; i < 5; ++i)
195  for (int j = i; j < 5; ++j)
196  m(i, j) = ocov(i, j);
197 
198  float sp = std::sin(phi);
199  float cp = std::cos(phi);
200  Surface::RotationType rot(sp, -cp, 0, 0, 0, -1.f, cp, sp, 0);
201 
202  Plane impPointPlane(bs, rot);
204  impPointPlane.toGlobal(lpar.position()), impPointPlane.toGlobal(lpar.momentum()), lpar.charge(), &idealField);
205  JacobianLocalToCurvilinear jl2c(impPointPlane, lpar, idealField);
206 
207  AlgebraicSymMatrix55 mo = ROOT::Math::Similarity(jl2c.jacobian(), m);
208 
209  int ndof = 2 * hits.size() - 5;
210  chi2 = chi2 * ndof;
211  GlobalPoint vv = gp.position();
212  math::XYZPoint pos(vv.x(), vv.y(), vv.z());
213  GlobalVector pp = gp.momentum();
214  math::XYZVector mom(pp.x(), pp.y(), pp.z());
215 
216  auto track = std::make_unique<reco::Track>(chi2, ndof, pos, mom, gp.charge(), CurvilinearTrajectoryError(mo));
217 
218  // bad and edup not supported as fit not present or not reliable
219  auto tkq = recoQuality[int(q)];
220  track->setQuality(tkq);
221  // loose,tight and HP are inclusive
222  if (reco::TrackBase::highPurity == tkq) {
223  track->setQuality(reco::TrackBase::tight);
224  track->setQuality(reco::TrackBase::loose);
225  } else if (reco::TrackBase::tight == tkq) {
226  track->setQuality(reco::TrackBase::loose);
227  }
228  track->setQuality(tkq);
229  // filter???
230  tracks.emplace_back(track.release(), hits);
231  }
232  // std::cout << "processed " << nt << " good tuples " << tracks.size() << "out of " << indToEdm.size() << std::endl;
233 
234  // store tracks
235  storeTracks(iEvent, tracks, httopo);
236  iEvent.put(std::move(indToEdmP));
237 }
238 
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:11724
PixelTrackProducerFromSoA
Definition: PixelTrackProducerFromSoA.cc:41
GlobalTrajectoryParameters.h
PixelTrackProducerFromSoA::minQuality_
const pixelTrack::Quality minQuality_
Definition: PixelTrackProducerFromSoA.cc:66
reco::TrackBase::tight
Definition: TrackBase.h:153
reco::TrackBase::loose
Definition: TrackBase.h:152
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
reco::TrackBase::undefQuality
Definition: TrackBase.h:151
PixelTrackProducerFromSoA::PixelTrackProducerFromSoA
PixelTrackProducerFromSoA(const edm::ParameterSet &iConfig)
Definition: PixelTrackProducerFromSoA.cc:69
pos
Definition: PixelAliasList.h:18
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
riemannFit::Vector5d
Eigen::Matrix< double, 5, 1 > Vector5d
Definition: FitResult.h:16
cms::cuda::assert
assert(be >=bs)
reco::TrackBase::TrackQuality
TrackQuality
track quality
Definition: TrackBase.h:150
HostProduct.h
HeterogeneousSoA
Definition: HeterogeneousSoA.h:13
hgcal_conditions::parameters
Definition: HGCConditions.h:86
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
h
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
PixelTrackProducerFromSoA::produce
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
Definition: PixelTrackProducerFromSoA.cc:102
pixelTrack::Quality::dup
PixelTrackProducerFromSoA::tBeamSpot_
const edm::EDGetTokenT< reco::BeamSpot > tBeamSpot_
Definition: PixelTrackProducerFromSoA.cc:57
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:122
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:76
pixelTrack::Quality
Quality
Definition: TrackSoAHeterogeneousT.h:13
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:79
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
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
reco::TrackBase::discarded
Definition: TrackBase.h:159
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
storeTracks.h
HLT_FULL_cff.maxTracks
maxTracks
Definition: HLT_FULL_cff.py:33266
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
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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
std
Definition: JetResolutionObject.h:76
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
Exception
Definition: hltDiff.cc:245
pixelTrack::Quality::highPurity
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
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
pixelTrack
Definition: TrackSoAHeterogeneousT.h:12
PixelTrackHeterogeneous.h
pixelTrack::qualityByName
Quality qualityByName(std::string const &name)
Definition: TrackSoAHeterogeneousT.h:16
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:92
JacobianLocalToCurvilinear
Definition: JacobianLocalToCurvilinear.h:21
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
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
pixelTrack::Quality::notQuality
PixelTrackProducerFromSoA::~PixelTrackProducerFromSoA
~PixelTrackProducerFromSoA() override=default
reco::TrackBase::highPurity
Definition: TrackBase.h:154