CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PixelTrackProducerFromSoA.cc
Go to the documentation of this file.
23 
28 
32 
33 #include "storeTracks.h"
35 
41 public:
42  using IndToEdm = std::vector<uint16_t>;
43 
45  ~PixelTrackProducerFromSoA() override = default;
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
48 
49  // using HitModuleStart = std::array<uint32_t, gpuClustering::maxNumModules + 1>;
51 
52 private:
53  void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override;
54 
55  // Event Data tokens
60  // Event Setup tokens
63 
64  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  minQuality_(pixelTrack::qualityByName(iConfig.getParameter<std::string>("minQuality"))) {
78  throw cms::Exception("PixelTrackConfiguration")
79  << iConfig.getParameter<std::string>("minQuality") + " is not a pixelTrack::Quality";
80  }
82  throw cms::Exception("PixelTrackConfiguration")
83  << iConfig.getParameter<std::string>("minQuality") + " not supported";
84  }
85  produces<reco::TrackCollection>();
86  produces<TrackingRecHitCollection>();
87  produces<reco::TrackExtraCollection>();
88  produces<IndToEdm>();
89 }
90 
93  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
94  desc.add<edm::InputTag>("trackSrc", edm::InputTag("pixelTracksSoA"));
95  desc.add<edm::InputTag>("pixelRecHitLegacySrc", edm::InputTag("siPixelRecHitsPreSplittingLegacy"));
96  desc.add<int>("minNumberOfHits", 0);
97  desc.add<std::string>("minQuality", "loose");
98  descriptions.addWithDefaultLabel(desc);
99 }
100 
103  const edm::EventSetup &iSetup) const {
104  // enum class Quality : uint8_t { bad = 0, edup, dup, loose, strict, tight, highPurity };
113 
114  // std::cout << "Converting gpu helix in reco tracks" << std::endl;
115 
116  auto indToEdmP = std::make_unique<IndToEdm>();
117  auto &indToEdm = *indToEdmP;
118 
119  auto const &idealField = iSetup.getData(idealMagneticFieldToken_);
120 
122 
123  auto const &httopo = iSetup.getData(ttTopoToken_);
124 
125  const auto &bsh = iEvent.get(tBeamSpot_);
126  GlobalPoint bs(bsh.x0(), bsh.y0(), bsh.z0());
127 
128  auto const &rechits = iEvent.get(cpuHits_);
129  std::vector<TrackingRecHit const *> hitmap;
130  auto const &rcs = rechits.data();
131  auto nhits = rcs.size();
132  hitmap.resize(nhits, nullptr);
133 
134  auto const *hitsModuleStart = iEvent.get(hmsToken_).get();
135  auto fc = hitsModuleStart;
136 
137  for (auto const &h : rcs) {
138  auto const &thit = static_cast<BaseTrackerRecHit const &>(h);
139  auto detI = thit.det()->index();
140  auto const &clus = thit.firstClusterRef();
141  assert(clus.isPixel());
142  auto i = fc[detI] + clus.pixelCluster().originalId();
143  if (i >= hitmap.size())
144  hitmap.resize(i + 256, nullptr); // only in case of hit overflow in one module
145  assert(nullptr == hitmap[i]);
146  hitmap[i] = &h;
147  }
148 
149  std::vector<const TrackingRecHit *> hits;
150  hits.reserve(5);
151 
152  const auto &tsoa = *iEvent.get(tokenTrack_);
153 
154  auto const *quality = tsoa.qualityData();
155  auto const &fit = tsoa.stateAtBS;
156  auto const &hitIndices = tsoa.hitIndices;
157  auto nTracks = tsoa.nTracks();
158 
159  tracks.reserve(nTracks);
160 
161  int32_t nt = 0;
162 
163  for (int32_t it = 0; it < nTracks; ++it) {
164  auto nHits = tsoa.nHits(it);
165  assert(nHits >= 3);
166  indToEdm.push_back(-1);
167  auto q = quality[it];
168  if (q < minQuality_)
169  continue;
170  if (nHits < minNumberOfHits_)
171  continue;
172  indToEdm.back() = nt;
173  ++nt;
174 
175  hits.resize(nHits);
176  auto b = hitIndices.begin(it);
177  for (int iHit = 0; iHit < nHits; ++iHit)
178  hits[iHit] = hitmap[*(b + iHit)];
179 
180  // mind: this values are respect the beamspot!
181 
182  float chi2 = tsoa.chi2(it);
183  float phi = tsoa.phi(it);
184 
185  riemannFit::Vector5d ipar, opar;
186  riemannFit::Matrix5d icov, ocov;
187  fit.copyToDense(ipar, icov, it);
188  riemannFit::transformToPerigeePlane(ipar, icov, opar, ocov);
189 
190  LocalTrajectoryParameters lpar(opar(0), opar(1), opar(2), opar(3), opar(4), 1.);
192  for (int i = 0; i < 5; ++i)
193  for (int j = i; j < 5; ++j)
194  m(i, j) = ocov(i, j);
195 
196  float sp = std::sin(phi);
197  float cp = std::cos(phi);
198  Surface::RotationType rot(sp, -cp, 0, 0, 0, -1.f, cp, sp, 0);
199 
200  Plane impPointPlane(bs, rot);
202  impPointPlane.toGlobal(lpar.position()), impPointPlane.toGlobal(lpar.momentum()), lpar.charge(), &idealField);
203  JacobianLocalToCurvilinear jl2c(impPointPlane, lpar, idealField);
204 
205  AlgebraicSymMatrix55 mo = ROOT::Math::Similarity(jl2c.jacobian(), m);
206 
207  int ndof = 2 * hits.size() - 5;
208  chi2 = chi2 * ndof;
209  GlobalPoint vv = gp.position();
210  math::XYZPoint pos(vv.x(), vv.y(), vv.z());
211  GlobalVector pp = gp.momentum();
212  math::XYZVector mom(pp.x(), pp.y(), pp.z());
213 
214  auto track = std::make_unique<reco::Track>(chi2, ndof, pos, mom, gp.charge(), CurvilinearTrajectoryError(mo));
215 
216  // bad and edup not supported as fit not present or not reliable
217  auto tkq = recoQuality[int(q)];
218  track->setQuality(tkq);
219  // loose,tight and HP are inclusive
220  if (reco::TrackBase::highPurity == tkq) {
221  track->setQuality(reco::TrackBase::tight);
222  track->setQuality(reco::TrackBase::loose);
223  } else if (reco::TrackBase::tight == tkq) {
224  track->setQuality(reco::TrackBase::loose);
225  }
226  track->setQuality(tkq);
227  // filter???
228  tracks.emplace_back(track.release(), hits);
229  }
230  // std::cout << "processed " << nt << " good tuples " << tracks.size() << "out of " << indToEdm.size() << std::endl;
231 
232  // store tracks
233  storeTracks(iEvent, tracks, httopo);
234  iEvent.put(std::move(indToEdmP));
235 }
236 
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
tuple pp
Definition: createTree.py:17
Quality qualityByName(std::string const &name)
void storeTracks(Ev &ev, const TWH &tracksWithHits, const TrackerTopology &ttopo)
Definition: storeTracks.h:19
TrackQuality
track quality
Definition: TrackBase.h:150
LocalPoint position() const
Local x and y position coordinates.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T y() const
Definition: PV3DBase.h:60
auto const & tracks
cannot be loose
string quality
assert(be >=bs)
Definition: Plane.h:16
const edm::EDGetTokenT< SiPixelRecHitCollectionNew > cpuHits_
const edm::EDGetTokenT< HMSstorage > hmsToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
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
const GeomDet * det() const
auto const & fit
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttTopoToken_
T z() const
Definition: PV3DBase.h:61
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def move
Definition: eostools.py:511
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
LocalVector momentum() const
Momentum vector in the local frame.
int index() const
Definition: GeomDet.h:83
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< uint16_t > IndToEdm
int nt
Definition: AMPTWrapper.h:42
void produce(edm::StreamID streamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const edm::EDGetTokenT< reco::BeamSpot > tBeamSpot_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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
TrackCharge charge() const
Charge (-1, 0 or 1)
PixelTrackProducerFromSoA(const edm::ParameterSet &iConfig)
~PixelTrackProducerFromSoA() override=default
Eigen::Matrix< double, 5, 5 > Matrix5d
Definition: FitResult.h:20
const edm::EDGetTokenT< PixelTrackHeterogeneous > tokenTrack_
std::vector< TrackWithRecHits > TracksWithRecHits
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > idealMagneticFieldToken_
pixelTrack::Quality const minQuality_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
T x() const
Definition: PV3DBase.h:59
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283