7 #include <g4hough/SvtxVertexMap.h>
8 #include <g4hough/SvtxVertex.h>
9 #include <g4hough/SvtxTrackMap.h>
10 #include <g4hough/SvtxTrack.h>
11 #include <g4hough/SvtxClusterMap.h>
12 #include <g4hough/SvtxCluster.h>
13 #include <g4hough/SvtxHitMap.h>
14 #include <g4hough/SvtxHit.h>
31 #include "../../psTOF/psTOFTimezeroEval/psTOFTimezeroEval.h"
38 _svtxevalstack(nullptr),
41 _do_vertex_eval(
true),
42 _do_gpoint_eval(
true),
45 _do_cluster_eval(
true),
46 _do_gtrack_eval(
true),
48 _scan_for_embedded(
false),
53 _ntp_cluster(nullptr),
68 "event:vx:vy:vz:ntracks:"
69 "gvx:gvy:gvz:gvt:gntracks:"
73 "event:gvx:gvy:gvz:gvt:gntracks:"
78 "event:g4hitID:gx:gy:gz:gt:gedep:"
79 "glayer:gtrackID:gflavor:"
80 "gpx:gpy:gpz:gvx:gvy:gvz:"
81 "gfpx:gfpy:gfpz:gfx:gfy:gfz:"
82 "gembed:gprimary:nclusters:"
83 "clusID:x:y:z:e:adc:layer:size:"
84 "phisize:zsize:efromtruth");
87 "event:hitID:e:adc:layer:"
89 "g4hitID:gedep:gx:gy:gz:gt:"
91 "gpx:gpy:gpz:gvx:gvy:gvz:"
92 "gfpx:gfpy:gfpz:gfx:gfy:gfz:"
93 "gembed:gprimary:efromtruth");
96 "event:hitID:x:y:z:ex:ey:ez:ephi:"
97 "e:adc:layer:size:phisize:"
98 "zsize:trackID:g4hitID:gx:"
99 "gy:gz:gt:gtrackID:gflavor:"
100 "gpx:gpy:gpz:gvx:gvy:gvz:"
101 "gfpx:gfpy:gfpz:gfx:gfy:gfz:"
102 "gembed:gprimary:efromtruth");
105 "event:gtrackID:gflavor:gnhits:"
108 "gfpx:gfpy:gfpz:gfx:gfy:gfz:"
110 "trackID:px:py:pz:charge:quality:chisq:ndf:nhits:layers:"
111 "dca2d:dca2dsigma:pcax:pcay:pcaz:nfromtruth:layersfromtruth:"
115 "event:trackID:px:py:pz:charge:"
116 "quality:chisq:ndf:nhits:layers:"
117 "dca2d:dca2dsigma:pcax:pcay:pcaz:"
118 "presdphi:presdeta:prese3x3:prese:"
119 "cemcdphi:cemcdeta:cemce3x3:cemce:"
120 "hcalindphi:hcalindeta:hcaline3x3:hcaline:"
121 "hcaloutdphi:hcaloutdeta:hcaloute3x3:hcaloute:"
122 "gtrackID:gflavor:gnhits:"
125 "gfpx:gfpy:gfpz:gfx:gfy:gfz:"
126 "gembed:gprimary:nfromtruth:layersfromtruth:"
139 cout <<
"psTOFTimezeroEval::process_event - Event = " <<
_ievent << endl;
189 cout <<
"========================= psTOFTimezeroEval::End() ============================" << endl;
190 cout <<
" " <<
_ievent <<
" events of output written to: " <<
_filename << endl;
191 cout <<
"===========================================================================" << endl;
198 cout <<
"psTOFTimezeroEval::End() - Error Count: " <<
_errors << endl;
209 if (
verbosity > 1) cout <<
"psTOFTimezeroEval::printInputInfo() entered" << endl;
218 cout <<
"---PHG4HITS-------------" << endl;
221 unsigned int ig4hit = 0;
222 for(std::set<PHG4Hit*>::iterator iter = g4hits.begin();
223 iter != g4hits.end();
226 cout << ig4hit <<
" of " << g4hits.size();
227 cout <<
": PHG4Hit: " << endl;
232 cout <<
"---SVTXCLUSTERS-------------" << endl;
233 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
235 unsigned int icluster = 0;
237 iter != clustermap->end();
239 SvtxCluster* cluster = iter->second;
240 cout << icluster <<
" of " << clustermap->size();
241 cout <<
": SvtxCluster: " << endl;
247 cout <<
"---SVXTRACKS-------------" << endl;
248 SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
250 unsigned int itrack = 0;
252 iter != trackmap->
end();
254 cout << itrack <<
" of " << trackmap->
size();
256 cout <<
" : SvtxTrack:" << endl;
262 cout <<
"---SVXVERTEXES-------------" << endl;
263 SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
265 unsigned int ivertex = 0;
267 iter != vertexmap->
end();
269 cout << ivertex <<
" of " << vertexmap->
size();
271 cout <<
" : SvtxVertex:" << endl;
283 if (
verbosity > 1) cout <<
"psTOFTimezeroEval::printOutputInfo() entered" << endl;
303 float gvx = gvertex->
get_x();
304 float gvy = gvertex->get_y();
305 float gvz = gvertex->get_z();
311 SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
313 if (!vertexmap->
empty()) {
316 vx = vertex->
get_x();
317 vy = vertex->
get_y();
318 vz = vertex->
get_z();
322 cout <<
"===Vertex Reconstruction=======================" << endl;
323 cout <<
"vtrue = (" << gvx <<
"," << gvy <<
"," << gvz <<
") => vreco = (" << vx <<
"," << vy <<
"," << vz <<
")" << endl;
326 cout <<
"===Tracking Summary============================" << endl;
327 unsigned int ng4hits[100] = {0};
329 for (std::set<PHG4Hit*>::iterator iter = g4hits.begin();
330 iter != g4hits.end();
336 SvtxHitMap* hitmap = findNode::getClass<SvtxHitMap>(topNode,
"SvtxHitMap");
337 unsigned int nhits[100] = {0};
340 iter != hitmap->end();
342 SvtxHit* hit = iter->second;
343 ++nhits[hit->get_layer()];
347 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
348 unsigned int nclusters[100] = {0};
351 iter != clustermap->end();
353 SvtxCluster* cluster = iter->second;
354 ++nclusters[cluster->get_layer()];
358 for (
unsigned int ilayer = 0; ilayer < 100; ++ilayer) {
359 cout <<
"layer " << ilayer <<
": nG4hits = " << ng4hits[ilayer]
360 <<
" => nHits = " << nhits[ilayer]
361 <<
" => nClusters = " << nclusters[ilayer] << endl;
364 SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
368 cout <<
" => nTracks = ";
369 if (trackmap) cout << trackmap->
size() << endl;
370 else cout << 0 << endl;
375 for(std::set<PHG4Hit*>::iterator iter = g4hits.begin();
376 iter != g4hits.end();
381 cout <<
"===PHG4Hit===================================" << endl;
382 cout <<
" PHG4Hit: "; g4hit->
identify();
386 for (std::set<SvtxCluster*>::iterator jter = clusters.begin();
387 jter != clusters.end();
389 SvtxCluster *cluster = *jter;
390 cout <<
"===Created-SvtxCluster================" << endl;
391 cout <<
"SvtxCluster: "; cluster->identify();
397 iter != range.second;
405 cout <<
"=== Gtrack ===================================================" << endl;
406 cout <<
" PHG4Particle id = " << particle->
get_track_id() << endl;
408 cout <<
" ptrue = (";
409 cout.width(5); cout << particle->
get_px();
411 cout.width(5); cout << particle->
get_py();
413 cout.width(5); cout << particle->
get_pz();
416 cout <<
" vtrue = (";
424 cout <<
" pt = " << sqrt(pow(particle->
get_px(),2)+pow(particle->
get_py(),2)) << endl;
425 cout <<
" phi = " << atan2(particle->
get_py(),particle->
get_px()) << endl;
426 cout <<
" eta = " << asinh(particle->
get_pz()/sqrt(pow(particle->
get_px(),2)+pow(particle->
get_py(),2))) << endl;
430 cout <<
" ---Associated-PHG4Hits-----------------------------------------" << endl;
432 for(std::set<PHG4Hit*>::iterator jter = g4hits.begin();
433 jter != g4hits.end();
441 cout <<
" #" << g4hit->
get_hit_id() <<
" xtrue = (";
442 cout.width(5); cout <<
x;
444 cout.width(5); cout <<
y;
446 cout.width(5); cout <<
z;
450 for (std::set<SvtxCluster*>::iterator kter = clusters.begin();
451 kter != clusters.end();
454 SvtxCluster *cluster = *kter;
456 float x = cluster->get_x();
457 float y = cluster->get_y();
458 float z = cluster->get_z();
460 cout <<
" => #" << cluster->get_id();
461 cout <<
" xreco = (";
462 cout.width(5); cout <<
x;
464 cout.width(5); cout <<
y;
466 cout.width(5); cout <<
z;
473 if (trackmap&&clustermap) {
476 for (std::set<SvtxTrack*>::iterator jter = tracks.begin();
477 jter != tracks.end();
482 float px = track->
get_px();
483 float py = track->
get_py();
484 float pz = track->
get_pz();
486 cout <<
"===Created-SvtxTrack==========================================" << endl;
487 cout <<
" SvtxTrack id = " << track->
get_id() << endl;
488 cout <<
" preco = (";
489 cout.width(5); cout << px;
491 cout.width(5); cout << py;
493 cout.width(5); cout << pz;
495 cout <<
" quality = " << track->
get_quality() << endl;
498 cout <<
" ---Associated-SvtxClusters-to-PHG4Hits-------------------------" << endl;
503 unsigned int cluster_id = *iter;
504 SvtxCluster* cluster = clustermap->get(cluster_id);
506 float x = cluster->get_x();
507 float y = cluster->get_y();
508 float z = cluster->get_z();
510 cout <<
" #" << cluster->get_id() <<
" xreco = (";
511 cout.width(5); cout <<
x;
513 cout.width(5); cout <<
y;
515 cout.width(5); cout <<
z;
527 cout.width(5); cout <<
x;
529 cout.width(5); cout <<
y;
531 cout.width(5); cout <<
z;
532 cout <<
") => Gtrack id = " << g4hit->
get_trkid();
534 cout <<
" noise hit";
553 if (
verbosity > 1) cout <<
"psTOFTimezeroEval::fillOutputNtuples() entered" << endl;
567 SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
569 if (vertexmap && truthinfo) {
571 iter != vertexmap->
end();
585 float gntracks = truthinfo->GetNumPrimaryVertexParticles();
586 float nfromtruth = NAN;
589 gvx = point->
get_x();
590 gvy = point->
get_y();
591 gvz = point->
get_z();
592 gvt = point->
get_t();
593 gntracks = truthinfo->GetNumPrimaryVertexParticles();
597 float vertex_data[11] = {(float)
_ievent,
630 SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
633 if (vertexmap && truthinfo) {
635 PHG4VtxPoint*
point = truthinfo->GetPrimaryVtx(truthinfo->GetPrimaryVertexIndex());
641 float gvx = point->
get_x();
642 float gvy = point->
get_y();
643 float gvz = point->
get_z();
645 float gntracks = truthinfo->GetNumPrimaryVertexParticles();
650 float nfromtruth = NAN;
653 vx = vertex->
get_x();
654 vy = vertex->
get_y();
655 vz = vertex->
get_z();
660 float gpoint_data[11] = {(float)
_ievent,
685 for (std::set<PHG4Hit*>::iterator iter = g4hits.begin();
686 iter != g4hits.end();
724 if (trutheval->
get_embed(g4particle) <= 0)
continue;
727 gflavor = g4particle->
get_pid();
728 gpx = g4particle->
get_px();
729 gpy = g4particle->
get_py();
730 gpz = g4particle->
get_pz();
742 gfpx = outerhit->
get_px(1);
743 gfpy = outerhit->
get_py(1);
744 gfpz = outerhit->
get_pz(1);
745 gfx = outerhit->
get_x(1);
746 gfy = outerhit->
get_y(1);
747 gfz = outerhit->
get_z(1);
750 gembed = trutheval->
get_embed(g4particle);
755 float nclusters = clusters.size();
773 clusID = cluster->get_id();
774 x = cluster->get_x();
775 y = cluster->get_y();
776 z = cluster->get_z();
777 e = cluster->get_e();
778 adc = cluster->get_adc();
779 layer = cluster->get_layer();
780 size = cluster->size_hits();
781 phisize = cluster->get_phi_size();
782 zsize = cluster->get_z_size();
788 float g4hit_data[36] = {(float)
_ievent,
837 SvtxHitMap* hitmap = findNode::getClass<SvtxHitMap>(topNode,
"SvtxHitMap");
841 iter != hitmap->end();
844 SvtxHit* hit = iter->second;
846 PHG4Cell* g4cell = hiteval->get_cell(hit);
850 float hitID = hit->get_id();
851 float e = hit->get_e();
852 float adc = hit->get_adc();
853 float layer = hit->get_layer();
854 float cellID = hit->get_cellid();
893 if (trutheval->
get_embed(g4particle) <= 0)
continue;
897 gflavor = g4particle->
get_pid();
898 gpx = g4particle->
get_px();
899 gpy = g4particle->
get_py();
900 gpz = g4particle->
get_pz();
912 gfpx = outerhit->
get_px(1);
913 gfpy = outerhit->
get_py(1);
914 gfpz = outerhit->
get_pz(1);
915 gfx = outerhit->
get_x(1);
916 gfy = outerhit->
get_y(1);
917 gfz = outerhit->
get_z(1);
919 gembed = trutheval->
get_embed(g4particle);
928 float hit_data[33] = {
975 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
979 iter != clustermap->end();
982 SvtxCluster* cluster = iter->second;
988 float hitID = cluster->get_id();
989 float x = cluster->get_x();
990 float y = cluster->get_y();
991 float z = cluster->get_z();
993 float ex = sqrt(cluster->get_error(0,0));
994 float ey = sqrt(cluster->get_error(1,1));
995 float ez = cluster->get_z_error();
997 float ephi = cluster->get_rphi_error();
999 float e = cluster->get_e();
1000 float adc = cluster->get_adc();
1001 float layer = cluster->get_layer();
1002 float size = cluster->size_hits();
1003 float phisize = cluster->get_phi_size();
1004 float zsize = cluster->get_z_size();
1007 if (track) trackID = track->
get_id();
1043 gflavor = g4particle->
get_pid();
1044 gpx = g4particle->
get_px();
1045 gpy = g4particle->
get_py();
1046 gpz = g4particle->
get_pz();
1057 gfpx = outerhit->
get_px(1);
1058 gfpy = outerhit->
get_py(1);
1059 gfpz = outerhit->
get_pz(1);
1060 gfx = outerhit->
get_x(1);
1061 gfy = outerhit->
get_y(1);
1062 gfz = outerhit->
get_z(1);
1065 gembed = trutheval->
get_embed(g4particle);
1066 gprimary = trutheval->
is_primary(g4particle);
1074 float cluster_data[38] = {(float)
_ievent,
1126 SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
1127 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
1131 iter != trackmap->
end();
1137 if (trutheval->
get_embed(truth) <= 0)
continue;
1144 unsigned int cluster_id = *iter;
1145 SvtxCluster* cluster = clustermap->get(cluster_id);
1150 float hitID = cluster->get_id();
1151 float x = cluster->get_x();
1152 float y = cluster->get_y();
1153 float z = cluster->get_z();
1155 float ex = sqrt(cluster->get_error(0,0));
1156 float ey = sqrt(cluster->get_error(1,1));
1157 float ez = cluster->get_z_error();
1159 float ephi = cluster->get_rphi_error();
1161 float e = cluster->get_e();
1162 float adc = cluster->get_adc();
1163 float layer = cluster->get_layer();
1164 float size = cluster->size_hits();
1165 float phisize = cluster->get_phi_size();
1166 float zsize = cluster->get_z_size();
1169 if (track) trackID = track->
get_id();
1205 gflavor = g4particle->
get_pid();
1206 gpx = g4particle->
get_px();
1207 gpy = g4particle->
get_py();
1208 gpz = g4particle->
get_pz();
1219 gfpx = outerhit->
get_px(1);
1220 gfpy = outerhit->
get_py(1);
1221 gfpz = outerhit->
get_pz(1);
1222 gfx = outerhit->
get_x(1);
1223 gfy = outerhit->
get_y(1);
1224 gfz = outerhit->
get_z(1);
1227 gembed = trutheval->
get_embed(g4particle);
1228 gprimary = trutheval->
is_primary(g4particle);
1236 float cluster_data[38] = {(float)
_ievent,
1293 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
1298 iter != range.second;
1304 if (trutheval->
get_embed(g4particle) <= 0)
continue;
1310 std::set<PHG4Hit*> g4hits = trutheval->
all_truth_hits(g4particle);
1311 float ng4hits = g4hits.size();
1317 float gvx = vtx->
get_x();
1318 float gvy = vtx->
get_y();
1319 float gvz = vtx->
get_z();
1331 gfpx = outerhit->
get_px(1);
1332 gfpy = outerhit->
get_py(1);
1333 gfpz = outerhit->
get_pz(1);
1334 gfx = outerhit->
get_x(1);
1335 gfy = outerhit->
get_y(1);
1336 gfz = outerhit->
get_z(1);
1339 float gembed = trutheval->
get_embed(g4particle);
1346 float quality = NAN;
1350 unsigned int layers = 0x0;
1352 float dca2dsigma = NAN;
1360 float nfromtruth = NAN;
1361 float layersfromtruth = NAN;
1368 trackID = track->
get_id();
1378 unsigned int cluster_id = *iter;
1379 SvtxCluster* cluster = clustermap->get(cluster_id);
1380 unsigned int layer = cluster->get_layer();
1381 if (layer < 32) layers |= (0x1 <<
layer);
1384 if(layer >= 0 and layer <= 2) ++nmaps;
1385 if(layer >= 3 and layer <= 6) ++nintt;
1386 if(layer >= 7 and layer <= 66) ++ntpc;
1394 pcax = track->
get_x();
1395 pcay = track->
get_y();
1396 pcaz = track->
get_z();
1402 float gtrack_data[39] = {(float)
_ievent,
1467 SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
1468 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
1472 iter != trackmap->
end();
1488 unsigned int layers = 0x0;
1492 unsigned int cluster_id = *iter;
1493 SvtxCluster* cluster = clustermap->get(cluster_id);
1494 unsigned int layer = cluster->get_layer();
1495 if (layer < 31) layers |= (0x1 <<
layer);
1497 if(layer >= 0 and layer <= 2) ++nmaps;
1498 if(layer >= 3 and layer <= 6) ++nintt;
1499 if(layer >= 7 and layer <= 66) ++ntpc;
1504 float px = track->
get_px();
1505 float py = track->
get_py();
1506 float pz = track->
get_pz();
1507 float pcax = track->
get_x();
1508 float pcay = track->
get_y();
1509 float pcaz = track->
get_z();
1550 float nfromtruth = NAN;
1551 float layersfromtruth = NAN;
1558 if (trutheval->
get_embed(g4particle) <= 0)
continue;
1562 gflavor = g4particle->
get_pid();
1564 std::set<PHG4Hit*> g4hits = trutheval->
all_truth_hits(g4particle);
1565 ng4hits = g4hits.size();
1566 gpx = g4particle->
get_px();
1567 gpy = g4particle->
get_py();
1568 gpz = g4particle->
get_pz();
1578 gfpx = outerhit->
get_px(1);
1579 gfpy = outerhit->
get_py(1);
1580 gfpz = outerhit->
get_pz(1);
1581 gfx = outerhit->
get_x(1);
1582 gfy = outerhit->
get_y(1);
1583 gfz = outerhit->
get_z(1);
1585 gembed = trutheval->
get_embed(g4particle);
1586 gprimary = trutheval->
is_primary(g4particle);
1592 float track_data[55] = {(float)
_ievent,