56 unsigned int x_pos, y_pos,
z_pos;
74 for (
unsigned int i = 0; i < 2; ++i)
76 for (
unsigned int j = 0; j < 2; ++j)
78 for (
unsigned int k = 0;
k < 2; ++
k)
80 containers[i][j][
k] =
nullptr;
87 for (
unsigned int i = 0; i < 2; ++i)
89 for (
unsigned int j = 0; j < 2; ++j)
91 for (
unsigned int k = 0;
k < 2; ++
k)
93 if (containers[i][j][
k] !=
nullptr)
95 delete containers[i][j][
k];
111 if (containers[x_pos][y_pos][z_pos] ==
nullptr)
144 return containers[x_pos][y_pos][z_pos]->begin();
151 bool block_changed =
false;
154 if (containers[x_pos][y_pos][z_pos] ==
nullptr)
156 block_changed =
true;
187 if (block_changed ==
true)
189 val = containers[x_pos][y_pos][z_pos]->begin();
193 val = containers[x_pos][y_pos][z_pos]->next();
198 block_changed =
true;
235 virtual void append_list(vector<TrivialTrack*>& track_list,
float PX_LO,
float PX_HI,
float PY_LO,
float PY_HI,
float PZ_LO,
float PZ_HI)
237 for (
unsigned int i = 0; i < 2; ++i)
239 for (
unsigned int j = 0; j < 2; ++j)
241 for (
unsigned int k = 0;
k < 2; ++
k)
243 if (containers[i][j][
k] ==
nullptr)
248 if ((containers[i][j][
k]->px_hi < PX_LO) || (containers[i][j][
k]->px_lo > PX_HI) || (containers[i][j][
k]->py_hi < PY_LO) || (containers[i][j][
k]->py_lo > PY_HI) || (containers[i][j][
k]->pz_hi < PZ_LO) || (containers[i][j][
k]->pz_lo > PZ_HI))
253 containers[i][j][
k]->append_list(track_list, PX_LO, PX_HI, PY_LO, PY_HI, PZ_LO, PZ_HI);
274 tracks.push_back(track);
281 return (&(tracks.at(0)));
286 if (x_pos >= (tracks.size() - 1))
293 return (&(tracks[x_pos]));
297 void append_list(vector<TrivialTrack*>& track_list,
float PX_LO,
float PX_HI,
float PY_LO,
float PY_HI,
float PZ_LO,
float PZ_HI)
override
299 for (
unsigned int i = 0; i < tracks.size(); ++i)
301 if ((tracks[i].px < PX_LO) || (tracks[i].px > PX_HI) || (tracks[i].py < PY_LO) || (tracks[i].py > PY_HI) || (tracks[i].pz < PZ_LO) || (tracks[i].pz > PZ_HI))
305 track_list.push_back(&(tracks[i]));
315 if ((track.
px < px_lo) || (track.
py < py_lo) || (track.
pz < pz_lo) || (track.
px > px_hi) || (track.
py > py_hi) || (track.
pz > pz_hi))
321 if (track.
px > (px_lo + 0.5 * (px_hi - px_lo)))
326 if (track.
py > (py_lo + 0.5 * (py_hi - py_lo)))
331 if (track.
pz > (pz_lo + 0.5 * (pz_hi - pz_lo)))
336 if (containers[x_ind][y_ind][z_ind] ==
nullptr)
338 float px_lo_new = px_lo + (float(x_ind)) * 0.5 * (px_hi - px_lo);
339 float px_hi_new = px_lo_new + 0.5 * (px_hi - px_lo);
341 float py_lo_new = py_lo + (float(y_ind)) * 0.5 * (py_hi - py_lo);
342 float py_hi_new = py_lo_new + 0.5 * (py_hi - py_lo);
344 float pz_lo_new = pz_lo + (float(z_ind)) * 0.5 * (pz_hi - pz_lo);
345 float pz_hi_new = pz_lo_new + 0.5 * (pz_hi - pz_lo);
347 if (level < maxlevel)
349 containers[x_ind][y_ind][z_ind] =
new RecursiveMomentumContainer(px_lo_new, px_hi_new, py_lo_new, py_hi_new, pz_lo_new, pz_hi_new, maxlevel, level + 1);
353 containers[x_ind][y_ind][z_ind] =
new RecursiveMomentumContainerEnd(px_lo_new, px_hi_new, py_lo_new, py_hi_new, pz_lo_new, pz_hi_new, maxlevel, level + 1);
356 return containers[x_ind][y_ind][z_ind]->insert(track);
362 , pt_search_scale(pt_s)
363 , pz_search_scale(pz_s)
366 , n_inner_layers(n_i)
367 , n_required_layers(n_r)
368 , inner_z_length(i_z)
369 , outer_z_length(o_z)
395 ntp_true =
new TNtuple(
"ntp_true",
"true simulated tracks",
"event:px:py:pz:dcax:dcay:dcaz:r_px:r_py:r_pz:r_dcax:r_dcay:r_dcaz:quality");
396 ntp_reco =
new TNtuple(
"ntp_reco",
"reconstructed tracks",
"event:px:py:pz:dcax:dcay:dcaz:t_px:t_py:t_pz:t_dcax:t_dcay:t_dcaz:quality");
406 PHG4HitContainer* g4hits = findNode::getClass<PHG4HitContainer>(topNode,
"G4HIT_SVTX");
407 if (g4hits ==
nullptr)
409 cout <<
"can't find PHG4HitContainer" << endl;
415 map<int, pair<unsigned int, unsigned int> > trkids;
427 if (fabs(hit->
get_z(0)) > length)
433 if (trkids.find(trk_id) == trkids.end())
435 trkids[trk_id].first = 0;
436 trkids[trk_id].second = 0;
440 trkids[trk_id].first = (trkids[trk_id].first | (1 << (hit->
get_layer())));
444 trkids[trk_id].second = (trkids[trk_id].second | (1 << (hit->
get_layer() - 32)));
453 SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
456 float gvx = gvertex->
get_x();
457 float gvy = gvertex->get_y();
458 float gvz = gvertex->get_z();
479 if (trkids.find(particle->
get_track_id()) == trkids.end())
500 reco_sorted.
insert(ttrack);
504 vector<TrivialTrack*> pointer_list;
505 while (t_track !=
nullptr)
507 pointer_list.clear();
509 float pt = sqrt((t_track->
px * t_track->
px) + (t_track->
py * t_track->
py));
511 float px_lo = t_track->
px - pt_diff;
512 float px_hi = t_track->
px + pt_diff;
513 float py_lo = t_track->
py - pt_diff;
514 float py_hi = t_track->
py + pt_diff;
516 float pz_lo = t_track->
pz - pz_diff;
517 float pz_hi = t_track->
pz + pz_diff;
519 reco_sorted.
append_list(pointer_list, px_lo, px_hi, py_lo, py_hi, pz_lo, pz_hi);
521 if (pointer_list.size() > 0)
523 float mom_true = sqrt(pt * pt + (t_track->
pz) * (t_track->
pz));
525 float mom_reco = sqrt((pointer_list[0]->px) * (pointer_list[0]->px) + (pointer_list[0]->py) * (pointer_list[0]->py) + (pointer_list[0]->pz) * (pointer_list[0]->pz));
526 float best_mom = mom_reco;
527 for (
unsigned int i = 1; i < pointer_list.size(); ++i)
529 mom_reco = sqrt((pointer_list[i]->px) * (pointer_list[i]->px) + (pointer_list[i]->py) * (pointer_list[i]->py) + (pointer_list[i]->pz) * (pointer_list[i]->pz));
530 if (fabs(mom_true - mom_reco) < fabs(mom_true - best_mom))
537 float ntp_data[14] = {(float)
event_counter, t_track->
px, t_track->
py, t_track->
pz, t_track->
dcax, t_track->
dcay, t_track->
dcaz, pointer_list[best_ind]->px, pointer_list[best_ind]->py, pointer_list[best_ind]->pz, pointer_list[best_ind]->dcax, pointer_list[best_ind]->dcay, pointer_list[best_ind]->dcaz, pointer_list[best_ind]->quality};
542 float ntp_data[14] = {(float)
event_counter, t_track->
px, t_track->
py, t_track->
pz, t_track->
dcax, t_track->
dcay, t_track->
dcaz, -9999., -9999., -9999., -9999., -9999., -9999., -9999.};
546 t_track = true_sorted.
next();
550 while (r_track !=
nullptr)
552 pointer_list.clear();
554 float pt = sqrt((r_track->
px * r_track->
px) + (r_track->
py * r_track->
py));
556 float px_lo = r_track->
px - pt_diff;
557 float px_hi = r_track->
px + pt_diff;
558 float py_lo = r_track->
py - pt_diff;
559 float py_hi = r_track->
py + pt_diff;
561 float pz_lo = r_track->
pz - pz_diff;
562 float pz_hi = r_track->
pz + pz_diff;
564 true_sorted.
append_list(pointer_list, px_lo, px_hi, py_lo, py_hi, pz_lo, pz_hi);
566 if (pointer_list.size() > 0)
568 float mom_reco = sqrt(pt * pt + (r_track->
pz) * (r_track->
pz));
570 float mom_true = sqrt((pointer_list[0]->px) * (pointer_list[0]->px) + (pointer_list[0]->py) * (pointer_list[0]->py) + (pointer_list[0]->pz) * (pointer_list[0]->pz));
571 float best_mom = mom_true;
572 for (
unsigned int i = 1; i < pointer_list.size(); ++i)
574 mom_true = sqrt((pointer_list[i]->px) * (pointer_list[i]->px) + (pointer_list[i]->py) * (pointer_list[i]->py) + (pointer_list[i]->pz) * (pointer_list[i]->pz));
575 if (fabs(mom_reco - mom_true) < fabs(mom_reco - best_mom))
582 float ntp_data[14] = {(float)
event_counter, r_track->
px, r_track->
py, r_track->
pz, r_track->
dcax, r_track->
dcay, r_track->
dcaz, pointer_list[best_ind]->px, pointer_list[best_ind]->py, pointer_list[best_ind]->pz, pointer_list[best_ind]->dcax, pointer_list[best_ind]->dcay, pointer_list[best_ind]->dcaz, r_track->
quality};
587 float ntp_data[14] = {(float)
event_counter, r_track->
px, r_track->
py, r_track->
pz, r_track->
dcax, r_track->
dcay, r_track->
dcaz, -9999., -9999., -9999., -9999., -9999., -9999., r_track->
quality};
591 r_track = reco_sorted.
next();
600 TFile outfile(
file_name.c_str(),
"recreate");