LDMX Software
SeedFinderProcessor.cxx
1#include "Tracking/Reco/SeedFinderProcessor.h"
2
3#include <set>
4#include <sstream>
5
6#include "Acts/Definitions/TrackParametrization.hpp"
7#include "Acts/Seeding/EstimateTrackParamsFromSeed.hpp"
8#include "Eigen/Dense"
9#include "Tracking/Sim/TrackingUtils.h"
10
11/* This processor takes in input a set of 3D space points and builds seedTracks
12 * using the ACTS algorithm which is based on the ATLAS 3-space point conformal
13 * fit.
14 *
15 */
16
17using Eigen::MatrixXd;
18using Eigen::VectorXd;
19
20namespace tracking {
21namespace reco {
22
24 framework::Process& process)
25 : TrackingGeometryUser(name, process) {
26 // TODO REMOVE FROM DEFAULT
27 /*
28 output_file_ = new TFile("seeder.root", "RECREATE");
29 output_tree_ = new TTree("seeder", "seeder");
30
31 output_tree_->Branch("nevents", &nevents_);
32 output_tree_->Branch("xhit", &xhit_);
33 output_tree_->Branch("yhit", &yhit_);
34 output_tree_->Branch("zhit", &zhit_);
35
36 output_tree_->Branch("b0", &b0_);
37 output_tree_->Branch("b1", &b1_);
38 output_tree_->Branch("b2", &b2_);
39 output_tree_->Branch("b3", &b3_);
40 output_tree_->Branch("b4", &b4_);
41 */
42}
43
45 truth_matching_tool_ = std::make_shared<tracking::sim::TruthMatchingTool>();
46}
47
49 // Output seed name
50 out_seed_collection_ = parameters.get<std::string>("out_seed_collection",
51 getName() + "SeedTracks");
52
53 // Input strip hits
55 parameters.get<std::string>("input_hits_collection", "TaggerSimHits");
56
57 // Tagger tracks - only for Recoil Seed finding
59 parameters.get<std::string>("tagger_trks_collection", "TaggerTracks");
60
62 parameters.get<std::vector<double>>("perigee_location", {-700, 0., 0.});
63 pmin_ = parameters.get<double>("pmin", 0.05 * Acts::UnitConstants::GeV);
64 pmax_ = parameters.get<double>("pmax", 8 * Acts::UnitConstants::GeV);
65 d0max_ = parameters.get<double>("d0max", -15. * Acts::UnitConstants::mm);
66 d0min_ = parameters.get<double>("d0min", -45. * Acts::UnitConstants::mm);
67 z0max_ = parameters.get<double>("z0max", 60. * Acts::UnitConstants::mm);
68 phicut_ = parameters.get<double>("phicut", 0.1);
69 thetacut_ = parameters.get<double>("thetacut", 0.2);
70 loc0cut_ = parameters.get<double>("loc0cut", 0.1);
71 loc1cut_ = parameters.get<double>("loc1cut", 0.3);
73 parameters.get<std::vector<std::string>>("strategies", {"0,1,2,3,4"});
74
75 // parse each "l0,l1,..." string into a layer list
76 strategy_layers_.clear();
77 for (const auto& strategy : strategies_) {
78 std::vector<int> layers;
79 std::stringstream ss(strategy);
80 std::string token;
81 while (std::getline(ss, token, ',')) {
82 if (!token.empty()) layers.push_back(std::stoi(token));
83 }
84 // the line+parabola fit needs at least 5 distinct layers
85 std::set<int> distinct(layers.begin(), layers.end());
86 if (distinct.size() < 5) {
87 EXCEPTION_RAISE("BadConf", "Seeding strategy '" + strategy +
88 "' has fewer than 5 distinct layers");
89 }
90 strategy_layers_.push_back(layers);
91 }
92 inflate_factors_ = parameters.get<std::vector<double>>(
93 "inflate_factors", {10., 10., 10., 10., 10., 10.});
94 bfield_ = parameters.get<double>("bfield", 1.5);
95 input_pass_name_ = parameters.get<std::string>("input_pass_name");
96 sim_particles_coll_name_ =
97 parameters.get<std::string>("sim_particles_coll_name");
98 sim_particles_passname_ =
99 parameters.get<std::string>("sim_particles_passname");
100 tagger_trks_event_collection_passname_ =
101 parameters.get<std::string>("tagger_trks_event_collection_passname");
102 sim_particles_event_passname_ =
103 parameters.get<std::string>("sim_particles_event_passname");
104 u_error_ = parameters.get<double>("u_error");
105 v_error_ = parameters.get<double>("v_error");
106}
107
109 // tg is unused, should it be? FIXME
110 // const auto& tg{geometry()};
111 auto start = std::chrono::high_resolution_clock::now();
112 std::vector<ldmx::Track> seed_tracks;
113
114 nevents_++;
115
116 // check if SimParticleMap is available for truth matching
117 std::map<int, ldmx::SimParticle> particle_map;
118
119 const auto& measurements = event.getCollection<ldmx::Measurement>(
120 input_hits_collection_, input_pass_name_);
121
122 std::vector<ldmx::Track> tagger_tracks;
124 tagger_trks_event_collection_passname_)) {
125 tagger_tracks = event.getCollection<ldmx::Track>(tagger_trks_collection_,
126 input_pass_name_);
127 }
128
129 // Create an unbound surface at the target
130 std::shared_ptr<Acts::Surface> tgt_surf =
131 tracking::sim::utils::unboundSurface(0.);
132
133 // Create the pseudomeasurements at the target
134
135 ldmx::Measurements target_pseudo_meas;
136
137 for (auto tagtrk : tagger_tracks) {
138 // For Track, the perigee parameters are stored at the target surface.
139 // Use d0/z0 as local position and the perigee covariance for the
140 // pseudo measurement. Only create the pseudo measurement if cov is
141 // available.
142
143 // The covariance matrix passed to the pseudo measurement is considered as
144 // uncorrelated. This is an approx that considers that loc-u and loc-v from
145 // the track have small correlation.
146
147 const auto& perigee_cov = tagtrk.getPerigeeCov();
148 if (!perigee_cov.empty()) {
149 Acts::BoundMatrix cov = tracking::sim::utils::unpackCov(perigee_cov);
150 double locu = tagtrk.getD0();
151 double locv = tagtrk.getZ0();
152 double covuu =
153 cov(Acts::BoundIndices::eBoundLoc0, Acts::BoundIndices::eBoundLoc0);
154 double covvv =
155 cov(Acts::BoundIndices::eBoundLoc1, Acts::BoundIndices::eBoundLoc1);
156
157 ldmx::Measurement pseudo_meas;
158 pseudo_meas.setLocalPosition(locu, locv);
159 Acts::Vector3 dummy{0., 0., 0.};
160 Acts::Vector2 local_pos{locu, locv};
161 Acts::Vector3 global_pos =
162 tgt_surf->localToGlobal(geometryContext(), local_pos, dummy);
163
164 pseudo_meas.setGlobalPosition(global_pos(0), global_pos(1),
165 global_pos(2));
166 pseudo_meas.setTime(0.);
167 pseudo_meas.setLocalCovariance(covuu, covvv);
168
169 target_pseudo_meas.push_back(pseudo_meas);
170 }
171 }
172
173 if (event.exists(sim_particles_coll_name_, sim_particles_event_passname_)) {
174 particle_map = event.getMap<int, ldmx::SimParticle>(
175 sim_particles_coll_name_, sim_particles_passname_);
176 truth_matching_tool_->setup(particle_map, measurements);
177 }
178
179 ldmx_log(debug) << "Preparing the strategies";
180
181 // a strategy is a list of layers from which to make the seed
182 // layer_ numbering starts at 0
183 for (const auto& strategy : strategy_layers_) {
184 groups_map_.clear();
185 if (groupStrips(measurements, strategy))
186 findSeedsFromMap(seed_tracks, target_pseudo_meas);
187 }
188
189 groups_map_.clear();
190 // output_tree_->Fill();
191 ntracks_ += seed_tracks.size();
192 event.add(out_seed_collection_, seed_tracks);
193
194 auto end = std::chrono::high_resolution_clock::now();
195
196 // long long microseconds =
197 // std::chrono::duration_cast<std::chrono::microseconds>(end-start).count();
198
199 auto diff = end - start;
200 processing_time_ += std::chrono::duration<double, std::milli>(diff).count();
201
202 // Seed finding using 2D Hits
203 // - The hits should keep track if they are already associated to a track or
204 // not. This can be used for subsequent passes of seed-finding
205
206 // This should go into a digitization producer, which takes care of producing
207 // measurements from:
208 // - raw hits in data
209 // - sim hits in MC
210 // Step 0: Get the sim hits and project them on the surfaces to mimic 2d
211 // hits Step 1: Smear the hits and associate an uncertainty to those
212 // measurements.
213
214 xhit_.clear();
215 yhit_.clear();
216 zhit_.clear();
217
218 b0_.clear();
219 b1_.clear();
220 b2_.clear();
221 b3_.clear();
222 b4_.clear();
223
224} // produce
225
226// Seed finder from Robert's in HPS
227// https://github.com/JeffersonLab/hps-java/blob/47712878302eb0c0374d077a208a6f8f0e2c3dc6/tracking/src/main/java/org/hps/recon/tracking/kalman/SeedTrack.java
228// Adapted to possible 3D hit points.
229
230// yOrigin is the location along the beam about which we fit the seed helix
231// perigee_location is where the track parameters will be extracted
232
233// while this takes in a target measurement (from tagger, this is pmeas_tgt)
234// this code doesn't do anything with it yet.
235
236ldmx::Track SeedFinderProcessor::seedTracker(
237 const ldmx::Measurements& vmeas, double xOrigin,
238 const Acts::Vector3& perigee_location,
239 const ldmx::Measurements& pmeas_tgt) {
240 // Fit a straight line in the non-bending plane and a parabola in the bending
241 // plane
242
243 // Each measurement is treated as a 3D point, where the v direction is in the
244 // center of the strip with sigma equal to the length of the strip / sqrt(12).
245 // In this way it's easier to incorporate the tagger track extrapolation to
246 // the fit
247
248 Acts::Matrix<5, 5> a = Acts::Matrix<5, 5>::Zero();
249 Acts::Vector<5> y = Acts::Vector<5>::Zero();
250
251 for (auto meas : vmeas) {
252 double xmeas = meas.getGlobalPosition()[0] - xOrigin;
253
254 // Get the surface
255 const Acts::Surface* hit_surface = geometry().getSurface(meas.getLayerID());
256
257 // Get the global to local transformation
258 auto rot =
259 hit_surface->localToGlobalTransform(geometryContext()).rotation();
260 auto tr =
261 hit_surface->localToGlobalTransform(geometryContext()).translation();
262
263 auto rotl2g = rot.transpose();
264
265 // Only for saving purposes
266 Acts::Vector2 loc{meas.getLocalPosition()[0], 0.};
267
268 xhit_.push_back(xmeas);
269 yhit_.push_back(meas.getGlobalPosition()[1]);
270 zhit_.push_back(meas.getGlobalPosition()[2]);
271
272 Acts::Matrix<2, 5> a_i;
273
274 a_i(0, 0) = rotl2g(0, 1);
275 a_i(0, 1) = rotl2g(0, 1) * xmeas;
276 a_i(0, 2) = rotl2g(0, 1) * xmeas * xmeas;
277 a_i(0, 3) = rotl2g(0, 2);
278 a_i(0, 4) = rotl2g(0, 2) * xmeas;
279
280 a_i(1, 0) = rotl2g(1, 1);
281 a_i(1, 1) = rotl2g(1, 1) * xmeas;
282 a_i(1, 2) = rotl2g(1, 1) * xmeas * xmeas;
283 a_i(1, 3) = rotl2g(1, 2);
284 a_i(1, 4) = rotl2g(1, 2) * xmeas;
285
286 // Fill the yprime vector
287 Acts::Vector2 offset = (rot.transpose() * tr).topRows<2>();
288 Acts::Vector2 xoffset = {rotl2g(0, 0) * xmeas, rotl2g(1, 0) * xmeas};
289
290 loc(0) = meas.getLocalPosition()[0];
291 loc(1) = 0.;
292 // weight matrix
293 Acts::Matrix<2, 2> w_i = Acts::Matrix<2, 2>::Zero();
294
295 w_i(0, 0) = 1. / (u_error_ * u_error_);
296 w_i(1, 1) = 1. / (v_error_ * v_error_);
297
298 Acts::Vector2 yprime_i = loc + offset - xoffset;
299 y += (a_i.transpose()) * w_i * yprime_i;
300
301 Acts::Matrix<2, 5> wa_i = (w_i * a_i);
302 a += a_i.transpose() * wa_i;
303 }
304
305 Acts::Vector<5> b;
306 b = a.inverse() * y;
307
308 b0_.push_back(b(0));
309 b1_.push_back(b(1));
310 b2_.push_back(b(2));
311 b3_.push_back(b(3));
312 b4_.push_back(b(4));
313
314 // Acts::Vector<5> hlx = Acts::Vector<5>::Zero();
315 Acts::Vector<3> ref{0., 0., 0.};
316
317 // relative_perigee_x is the perigee position in the fit frame (fit-x = ACTS x
318 // - xOrigin). It is used only for evaluating the fitted curve (y, z, slopes).
319 // The PerigeeSurface and seed_pos must use the absolute ACTS x coordinate,
320 // which is perigee_location(0) directly.
321 double relative_perigee_x = perigee_location(0) - xOrigin;
322
323 std::shared_ptr<const Acts::PerigeeSurface> seed_perigee =
324 Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3(
325 perigee_location(0), perigee_location(1), perigee_location(2)));
326
327 // in mm — x is absolute ACTS x; y and z evaluated at fit-x =
328 // relative_perigee_x
329 Acts::Vector3 seed_pos{perigee_location(0),
330 b(0) + b(1) * relative_perigee_x +
331 b(2) * relative_perigee_x * relative_perigee_x,
332 b(3) + b(4) * relative_perigee_x};
333 Acts::Vector3 dir{1, b(1) + 2 * b(2) * relative_perigee_x, b(4)};
334 dir /= dir.norm();
335
336 // Momentum at xmeas
337 // R in meters, p in GeV
338 double p = 0.3 * bfield_ * (1. / (2. * abs(b(2)))) * 0.001;
339 // std::cout<<"Momentum "<< p*dir << std::endl;
340
341 // Convert it to MeV since that's what TrackUtils assumes
342 Acts::Vector3 seed_mom = p * dir / Acts::UnitConstants::MeV;
343 double q =
344 b(2) < 0 ? -1 * Acts::UnitConstants::e : +1 * Acts::UnitConstants::e;
345
346 // Linear intersection with the perigee line. TODO:: Use propagator instead
347 // Project the position on the surface.
348 // This is mainly necessary for the perigee surface, where
349 // the mean might not fulfill the perigee condition.
350
351 // mg Aug 2024 .. interect has changed, but just remove boundary check
352 // and change intersection to intersections
353 // auto intersection =
354 // (*seed_perigee).intersect(geometry_context(), seed_pos, dir, false);
355
356 // Acts::FreeVector seed_free = tracking::sim::utils::toFreeParameters(
357 // intersection.intersection.position, seed_mom, q);
358
359 auto intersection =
360 (*seed_perigee).intersect(geometryContext(), seed_pos, dir);
361
362 Acts::FreeVector seed_free = tracking::sim::utils::toFreeParameters(
363 intersection[0].position(), seed_mom, q);
364
365 auto bound_params = Acts::transformFreeToBoundParameters(
366 seed_free, *seed_perigee, geometryContext())
367 .value();
368
369 ldmx_log(trace) << "bound parameters at perigee location" << bound_params;
370
371 Acts::BoundVector stddev;
372 // sigma set to 75% of momentum
373 double sigma_p = 0.75 * p * Acts::UnitConstants::GeV;
374 stddev[Acts::eBoundLoc0] =
375 inflate_factors_[Acts::eBoundLoc0] * 2 * Acts::UnitConstants::mm;
376 stddev[Acts::eBoundLoc1] =
377 inflate_factors_[Acts::eBoundLoc1] * 5 * Acts::UnitConstants::mm;
378 stddev[Acts::eBoundPhi] =
379 inflate_factors_[Acts::eBoundPhi] * 5 * Acts::UnitConstants::degree;
380 stddev[Acts::eBoundTheta] =
381 inflate_factors_[Acts::eBoundTheta] * 5 * Acts::UnitConstants::degree;
382 stddev[Acts::eBoundQOverP] =
383 inflate_factors_[Acts::eBoundQOverP] * (1. / p) * (1. / p) * sigma_p;
384 stddev[Acts::eBoundTime] =
385 inflate_factors_[Acts::eBoundTime] * 1000 * Acts::UnitConstants::ns;
386
387 ldmx_log(debug)
388 << "Making covariance matrix as diagonal matrix with inflated terms";
389 Acts::BoundMatrix bound_cov = stddev.cwiseProduct(stddev).asDiagonal();
390
391 ldmx_log(debug) << "...now putting together the seed track ...";
392
393 ldmx::Track trk = ldmx::Track();
394 // Store the perigee surface position (absolute ACTS coordinates) converted to
395 // LDMX frame so CKFProcessor can reconstruct the same surface.
396 Acts::Vector3 perigee_ldmx =
397 tracking::sim::utils::acts2Ldmx(perigee_location);
398 trk.setPerigeeLocation(perigee_ldmx(0), perigee_ldmx(1), perigee_ldmx(2));
399 trk.setChi2(0.);
400 trk.setNhits(5);
401 trk.setNdf(0);
402 trk.setNsharedHits(0);
403 trk.setCharge(q < 0 ? -1 : 1);
404 std::vector<double> v_seed_params(
405 (bound_params).data(),
406 bound_params.data() + bound_params.rows() * bound_params.cols());
407 std::vector<double> v_seed_cov;
408 tracking::sim::utils::flatCov(bound_cov, v_seed_cov);
409 trk.setPerigeeParameters(v_seed_params);
410 trk.setPerigeeCov(v_seed_cov);
411
412 ldmx_log(debug)
413 << "...making the ParticleHypothesis ...assume electron for now";
414 auto part_hypo{Acts::ParticleHypothesis::electron()};
415
416 ldmx_log(debug) << "Making BoundTrackParameters seedParameters";
417 Acts::BoundTrackParameters seed_parameters(
418 seed_perigee, std::move(bound_params), bound_cov, part_hypo);
419
420 ldmx_log(debug) << "Returning seed track";
421 return trk;
422}
423
425 // output_file_->cd();
426 // output_tree_->Write();
427 // output_file_->Close();
428 ldmx_log(info) << "AVG Time/Event: " << std::fixed << std::setprecision(1)
429 << processing_time_ / nevents_ << " ms";
430 ldmx_log(info) << "Total Seeds/Events: " << ntracks_ << "/" << nevents_;
431 ldmx_log(info) << "Seeds discarded due to multiple hits on layers "
432 << ndoubles_;
433 ldmx_log(info) << "not enough seed points " << nmissing_;
434 ldmx_log(info) << " nfailpmin=" << nfailpmin_;
435 ldmx_log(info) << " nfailpmax=" << nfailpmax_;
436 ldmx_log(info) << " nfaild0max=" << nfaild0max_;
437 ldmx_log(info) << " nfaild0min=" << nfaild0min_;
438 ldmx_log(info) << " nfailphicut=" << nfailphi_;
439 ldmx_log(info) << " nfailthetacut=" << nfailtheta_;
440 ldmx_log(info) << " nfailz0max=" << nfailz0max_;
441}
442
443// Given a strategy, group the hits according to some options
444// Not a good algorithm. The best would be to organize all the hits in sensors
445// *first* then only select the hits that we are interested into. TODO!
446
447bool SeedFinderProcessor::groupStrips(
448 const std::vector<ldmx::Measurement>& measurements,
449 const std::vector<int> strategy) {
450 // std::cout<<"Using stratedy"<<std::endl;
451 // for (auto& e : strategy) {
452 // std::cout<<e<<" ";
453 //}
454 // std::cout<<std::endl;
455
456 for (auto& meas : measurements) {
457 ldmx_log(trace) << meas;
458
459 if (std::find(strategy.begin(), strategy.end(), meas.getLayer()) !=
460 strategy.end()) {
461 ldmx_log(debug) << "Adding measurement from layer_ = " << meas.getLayer();
462 groups_map_[meas.getLayer()].push_back(&meas);
463 }
464
465 } // loop meas
466
467 if (groups_map_.size() < strategy.size())
468 return false;
469 else
470 return true;
471}
472
473// For each strategy, form all the possible combinatorics and form a seedTrack
474// for each of those This will reshuffle all points. (issue?) Will sort the
475// meas_for_seed vector
476
477void SeedFinderProcessor::findSeedsFromMap(std::vector<ldmx::Track>& seeds,
478 const ldmx::Measurements& pmeas) {
479 std::map<int, std::vector<const ldmx::Measurement*>>::iterator groups_iter =
480 groups_map_.begin();
481 // Vector of iterators, one per grouped layer
482 const int k = groups_map_.size();
483 if (k < 1) return;
484 std::vector<std::vector<const ldmx::Measurement*>::iterator> it;
485 it.resize(k);
486
487 unsigned int ikey = 0;
488 for (auto& key : groups_map_) {
489 it[ikey] = key.second.begin();
490 ikey++;
491 }
492
493 // K vectors in an array v[0],v[1].... v[K-1]
494
495 // Loop over all combinations
496 while (it[0] != groups_iter->second.end()) {
497 // process the pointed-to elements
498
499 /*
500 for (int j=0; j<K; j++) {
501 const ldmx::Measurement* meas = (*(it[j]));
502 std::cout<<meas->getGlobalPosition()[0]<<","
503 <<meas->getGlobalPosition()[1]<<","
504 <<meas->getGlobalPosition()[2]<<","<<std::endl;
505 }
506 */
507
508 std::vector<ldmx::Measurement> meas_for_seeds;
509 meas_for_seeds.reserve(k);
510
511 ldmx_log(debug) << " Grouping ";
512
513 for (int j = 0; j < k; j++) {
514 const ldmx::Measurement* meas = (*(it[j]));
515 meas_for_seeds.push_back(*meas);
516 }
517
518 std::sort(meas_for_seeds.begin(), meas_for_seeds.end(),
519 [](const ldmx::Measurement& m1, const ldmx::Measurement& m2) {
520 return m1.getGlobalPosition()[0] < m2.getGlobalPosition()[0];
521 });
522
523 if (meas_for_seeds.size() < k) {
524 nmissing_++;
525 return;
526 }
527
528 ldmx_log(debug) << "making seedTrack";
529
530 Acts::Vector3 perigee{perigee_location_[0], perigee_location_[1],
532
533 ldmx::Track seed_track = seedTracker(
534 meas_for_seeds, meas_for_seeds.at(k / 2).getGlobalPosition()[0],
535 perigee, pmeas);
536
537 bool fail = false;
538
539 // Remove failed fits
540 if (1. / abs(seed_track.getQoP()) < pmin_) {
541 nfailpmin_++;
542 fail = true;
543 } else if (1. / abs(seed_track.getQoP()) > pmax_) {
544 nfailpmax_++;
545 fail = true;
546 }
547
548 // Remove large part of fake tracks and duplicates with the following cuts
549 // for various compatibility checks.
550
551 else if (abs(seed_track.getZ0()) > z0max_) {
552 nfailz0max_++;
553 fail = true;
554 } else if (seed_track.getD0() < d0min_) {
555 nfaild0min_++;
556 fail = true;
557 } else if (seed_track.getD0() > d0max_) {
558 nfaild0max_++;
559 fail = true;
560 } else if (abs(seed_track.getPhi()) > phicut_) {
561 fail = true;
562 nfailphi_++;
563 } else if (abs(seed_track.getTheta() - piover2_) > thetacut_) {
564 fail = true;
565 nfailtheta_++;
566 }
567
568 // If I didn't use the target pseudo measurements in the track finding
569 // I can use them for compatibility with the tagger track
570
571 // TODO this should protect against running this check on tagger seeder.
572 // This is true only if this seeder is not run twice on the tagger after
573 // already having tagger tracks available.
574 if (pmeas.size() > 0) {
575 // I can have multiple target pseudo measurements
576 // A seed is rejected if it is found incompatible with all the target
577 // extrapolations
578
579 // This is set but unused, eventually we will use tagger track position at
580 // target to inform recoil tracking bool tgt_compatible = false;
581 for (auto tgt_pseudomeas : pmeas) {
582 // The d0/z0 are in a frame with the same orientation of the target
583 // surface
584 double delta_loc0 =
585 seed_track.getD0() - tgt_pseudomeas.getLocalPosition()[0];
586 double delta_loc1 =
587 seed_track.getZ0() - tgt_pseudomeas.getLocalPosition()[1];
588
589 if (abs(delta_loc0) < loc0cut_ && abs(delta_loc1) < loc1cut_) {
590 // found at least 1 compatible target location
591 // tgt_compatible = true;
592 break;
593 }
594 }
595 } // pmeas > 0
596
597 if (!fail) {
598 if (truth_matching_tool_->configured()) {
599 auto truth_info = truth_matching_tool_->truthMatch(meas_for_seeds);
600 seed_track.setTrackID(truth_info.track_id_);
601 seed_track.setPdgID(truth_info.pdg_id_);
602 seed_track.setTruthProb(truth_info.truth_prob_);
603 }
604
605 seeds.push_back(seed_track);
606 }
607
608 else {
609 b0_.pop_back();
610 b1_.pop_back();
611 b2_.pop_back();
612 b3_.pop_back();
613 b4_.pop_back();
614 }
615
616 // Go to next combination
617 ldmx_log(debug) << "Go to the next combination";
618
619 ++it[k - 1];
620 for (int i = k - 1;
621 (i > 0) && (it[i] == (std::next(groups_iter, i))->second.end()); --i) {
622 it[i] = std::next(groups_iter, i)->second.begin();
623 ++it[i - 1];
624 }
625 }
626} // find seeds
627
628} // namespace reco
629} // namespace tracking
630
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
std::string getName() const
Get the processor name.
Implements an event buffer system for storing event data.
Definition Event.h:42
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Definition Event.cxx:105
Class which represents the process under execution.
Definition Process.h:37
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
void setLocalPosition(const float &meas_u, const float &meas_v)
Set the local position i.e.
Definition Measurement.h:60
void setGlobalPosition(const float &meas_x, const float &meas_y, const float &meas_z)
Set the global position i.e.
Definition Measurement.h:41
void setLocalCovariance(const float &cov_uu, const float &cov_vv)
Set cov(U,U) and cov(V, V).
Definition Measurement.h:76
void setTime(const float &meas_t)
Set the measurement time in ns.
Definition Measurement.h:92
Class representing a simulated particle.
Definition SimParticle.h:24
Implementation of a track object.
Definition Track.h:53
std::vector< std::vector< int > > strategy_layers_
Layer lists parsed from strategies_, one per strategy.
SeedFinderProcessor(const std::string &name, framework::Process &process)
Constructor.
std::string out_seed_collection_
The name of the output collection of seeds to be stored.
double pmax_
Maximum cut on the momentum of the seeds.
std::vector< std::string > strategies_
List of stragies for seed finding.
std::string input_hits_collection_
The name of the input hits collection to use in finding seeds..
void onProcessEnd() override
Callback for the EventProcessor to take any necessary action when the processing of events finishes,...
void produce(framework::Event &event) override
Run the processor and create a collection of results which indicate if a charge particle can be found...
void onProcessStart() override
Callback for the EventProcessor to take any necessary action when the processing of events starts,...
double pmin_
Minimum cut on the momentum of the seeds.
std::string tagger_trks_collection_
The name of the tagger Tracks (only for Recoil Seeding)
std::vector< double > perigee_location_
Location of the perigee for the helix track parameters.
double d0max_
Max d0 allowed for the seeds.
void configure(framework::config::Parameters &parameters) override
Configure the processor using the given user specified parameters.
double d0min_
Min d0 allowed for the seeds.
double z0max_
Max z0 allowed for the seeds.
a helper base class providing some methods to shorten access to common conditions used within the tra...
The measurement calibrator can be a function or a class/struct able to retrieve the sim hits containe...