107 if(
Verbosity() > 1) cout <<
" Si track " << trackid <<
" crossing " << crossing << endl;
112 std::multimap<unsigned int, unsigned int> tpc_matches;
113 std::set<unsigned int> tpc_matched_set;
114 std::set<unsigned int> tpc_unmatched_set;
123 for(
auto [tpcid, si_id] : tpc_matches)
125 auto svtxseed = std::make_unique<SvtxTrackSeed_v2>();
126 svtxseed->set_silicon_seed_index(si_id);
127 svtxseed->set_tpc_seed_index(tpcid);
131 svtxseed->set_crossing_estimate(crossing_estimate);
134 if(
Verbosity() > 1) std::cout <<
" combined seed id " <<
_svtx_seed_map->
size()-1 <<
" si id " << si_id <<
" tpc id " << tpcid <<
" crossing estimate " << crossing_estimate << std::endl;
138 for(
auto tpcid : tpc_unmatched_set)
140 auto svtxseed = std::make_unique<SvtxTrackSeed_v2>();
141 svtxseed->set_tpc_seed_index(tpcid);
144 if(
Verbosity() > 1) std::cout <<
" converted unmatched TPC seed id " <<
_svtx_seed_map->
size()-1 <<
" tpc id " << tpcid << std::endl;
157 cout <<
"PHSiliconTpcTrackMatching::process_event(PHCompositeNode *topNode) Leaving process_event" << endl;
170 double si_z = si_track->
get_z();
172 double tpc_z = tpc_track->
get_z();
175 short int crossing_estimate = (
short int)
getBunchCrossing(tpcid, tpc_z - si_z);
179 std::cout <<
"findCrossing: " <<
" tpcid " << tpcid <<
" si_id " << si_id <<
" tpc_z " << tpc_z <<
" si_z " << si_z <<
" dz " << tpc_z - si_z
180 <<
" INTT crossing " << crossing <<
" crossing_estimate " << crossing_estimate << std::endl;
183 return crossing_estimate;
198 double crossings = z_mismatch / z_bunch_separation;
201 unsigned int side = 10;
202 std::set<short int> side_set;
212 side_set.insert(side);
216 if(side == 10)
return SHRT_MAX;
218 if(side_set.size() == 2 &&
Verbosity() > 1)
219 std::cout <<
" WARNING: tpc seed " << trid <<
" changed TPC sides, " <<
" final side " << side << std::endl;
228 std::cout <<
" gettrackid " << trid <<
" side " << side <<
" z_mismatch " << z_mismatch <<
" crossings " << crossings << std::endl;
246 _cluster_crossing_map = findNode::getClass<TrkrClusterCrossingAssoc>(topNode,
"TRKR_CLUSTERCROSSINGASSOC");
249 cerr <<
PHWHERE <<
" ERROR: Can't find TRKR_CLUSTERCROSSINGASSOC " << endl;
256 cerr <<
PHWHERE <<
" ERROR: Can't find SiliconTrackSeedContainer " << endl;
267 _svtx_seed_map = findNode::getClass<TrackSeedContainer>(topNode,
"SvtxTrackSeedContainer");
270 std::cout <<
"Creating node SvtxTrackSeedContainer" << std::endl;
278 std::cerr <<
"DST Node missing, quitting" << std::endl;
279 throw std::runtime_error(
"failed to find DST node in PHActsSourceLinks::createNodes");
300 _cluster_map = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
303 std::cout <<
PHWHERE <<
" ERROR: Can't find node TRKR_CLUSTER" << std::endl;
307 _tGeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
310 std::cout <<
PHWHERE <<
"Error, can't find acts tracking geometry" << std::endl;
318 std::set<unsigned int> &tpc_matched_set,
319 std::set<unsigned int> &tpc_unmatched_set,
320 std::multimap<unsigned int, unsigned int> &tpc_matches )
323 for (
unsigned int phtrk_iter = 0;
331 unsigned int tpcid = phtrk_iter;
336 <<
": Processing seed itrack: " << tpcid
347 std::cout <<
" tpc stub: " << tpcid <<
" eta " << tpc_eta <<
" pt " << tpc_pt <<
" tpc z " <<
_tracklet_tpc->
get_z() << std::endl;
353 if(tpc_pt < 6.0) mag = 2;
354 if(tpc_pt < 3.0) mag = 4.0;
355 if(tpc_pt < 1.5) mag = 6.0;
359 cout <<
"TPC tracklet:" << endl;
367 bool matched =
false;
370 for (
unsigned int phtrk_iter_si = 0;
378 bool eta_match =
false;
381 if(!eta_match)
continue;
382 unsigned int siid = phtrk_iter_si;
386 bool position_match =
false;
393 position_match =
true;
402 position_match =
true;
408 bool phi_match =
false;
411 if( fabs( fabs(tpc_phi - si_phi) - 2.0 * M_PI) <
_phi_search_win * mag ) phi_match =
true;
412 if(!phi_match)
continue;
415 cout <<
" testing for a match for TPC track " << tpcid <<
" with pT " <<
_tracklet_tpc->
get_pt()
417 cout <<
" tpc_phi " << tpc_phi <<
" si_phi " << si_phi <<
" dphi " << tpc_phi-si_phi <<
" phi search " <<
_phi_search_win*mag <<
" tpc_eta " << tpc_eta
418 <<
" si_eta " << si_eta <<
" deta " << tpc_eta-si_eta <<
" eta search " <<
_eta_search_win*mag << endl;
419 std::cout <<
" tpc x " << tpc_x <<
" si x " << si_x <<
" tpc y " << tpc_y <<
" si y " << si_y <<
" tpc_z " << tpc_z <<
" si z " << si_z << std::endl;
426 tpc_matches.insert(std::make_pair(tpcid, siid));
427 tpc_matched_set.insert(tpcid);
431 cout <<
" found a match for TPC track " << tpcid <<
" with Si track " << siid << endl;
432 cout <<
" tpc_phi " << tpc_phi <<
" si_phi " << si_phi <<
" phi_match " << phi_match
433 <<
" tpc_eta " << tpc_eta <<
" si_eta " << si_eta <<
" eta_match " << eta_match << endl;
434 std::cout <<
" tpc x " << tpc_x <<
" si x " << si_x <<
" tpc y " << tpc_y <<
" si y " << si_y <<
" tpc_z " << tpc_z <<
" si z " << si_z << std::endl;
439 cout <<
" Try_silicon: pt " << tpc_pt <<
" tpc_phi " << tpc_phi <<
" si_phi " << si_phi <<
" dphi " << tpc_phi-si_phi
440 <<
" tpc_eta " << tpc_eta <<
" si_eta " << si_eta <<
" deta " << tpc_eta-si_eta <<
" tpc_x " << tpc_x <<
" tpc_y " << tpc_y <<
" tpc_z " << tpc_z
441 <<
" dx " << tpc_x - si_x <<
" dy " << tpc_y - si_y <<
" dz " << tpc_z - si_z
448 if(
Verbosity() > 1) cout <<
"inserted unmatched tpc seed " << tpcid << endl;
449 tpc_unmatched_set.insert(tpcid);
463 short int crossing_keep = 0;
464 if(intt_crossings.size() == 0)
470 crossing_keep = intt_crossings[0];
471 for(
unsigned int ic=1; ic<intt_crossings.size(); ++ic)
473 if(intt_crossings[ic] != crossing_keep)
477 std::cout <<
" Warning: INTT crossings not all the same " <<
" crossing_keep " << crossing_keep <<
" new crossing " << intt_crossings[ic] <<
" keep the first one in the list" << std::endl;
485 return crossing_keep;
493 std::vector<short int> intt_crossings;
512 if( !cluster )
continue;
517 <<
" in layer " << layer <<
" position " << global(0) <<
" " << global(1) <<
" " << global(2)
518 <<
" eta " << si_track->
get_eta() << std::endl;
522 <<
" in layer " << layer <<
" with eta " << si_track->
get_eta() << std::endl;
528 if( !cluster )
continue;
534 for(
auto iter = crossings.first; iter != crossings.second; ++iter)
537 std::cout <<
" si Track " <<
_track_map_silicon->
find(si_track) <<
" cluster " << iter->first <<
" layer " << layer <<
" crossing " << iter->second << std::endl;
538 intt_crossings.push_back(iter->second);
543 return intt_crossings;
553 std::multimap<unsigned int, unsigned int> bad_map;
555 for(
auto [tpcid, si_id] : tpc_matches)
561 if(crossing == SHRT_MAX)
564 std::cout <<
" drop si_track " << si_id <<
" with eta " << si_track->
get_eta() <<
" and z " << si_track->
get_z() <<
" because crossing is undefined " << std::endl;
569 float z_si = si_track->
get_z();
570 float z_tpc = tpc_track->
get_z();
571 float z_mismatch = z_tpc-z_si;
573 float mag_crossing_z_mismatch = fabs(crossing) *
crossing_period * vdrift;
578 if( fabs( fabs(z_mismatch) - mag_crossing_z_mismatch ) < 3.0)
581 std::cout <<
" Success: crossing " << crossing <<
" tpcid " << tpcid <<
" si id " << si_id
582 <<
" tpc z " << z_tpc <<
" si z " << z_si <<
" z_mismatch " << z_mismatch
583 <<
" mag_crossing_z_mismatch " << mag_crossing_z_mismatch <<
" drift velocity " << vdrift << std::endl;
588 std::cout <<
" FAILURE: crossing " << crossing <<
" tpcid " << tpcid <<
" si id " << si_id
589 <<
" tpc z " << z_tpc <<
" si z " << z_si <<
" z_mismatch " << z_mismatch
590 <<
" mag_crossing_z_mismatch " << mag_crossing_z_mismatch << std::endl;
592 bad_map.insert(std::make_pair(tpcid, si_id));
597 for(
auto [tpcid, si_id] : bad_map)
602 auto ret = tpc_matches.equal_range(tpcid);
603 for(
auto it = ret.first;
it != ret.second; ++
it)
605 if(
it->first == tpcid &&
it->second == si_id)
608 std::cout <<
" erasing tpc_matches entry for tpcid " << tpcid <<
" si_id " << si_id << std::endl;
609 tpc_matches.erase(
it);