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>
37 _svtxevalstack(nullptr),
40 _do_vertex_eval(
true),
41 _do_gpoint_eval(
true),
44 _do_cluster_eval(
true),
45 _do_gtrack_eval(
true),
47 _scan_for_embedded(
false),
52 _ntp_cluster(nullptr),
67 "event:vx:vy:vz:ntracks:"
68 "gvx:gvy:gvz:gvt:gntracks:"
72 "event:gvx:gvy:gvz:gvt:gntracks:"
77 "event:g4hitID:gx:gy:gz:gt:gedep:"
78 "glayer:gtrackID:gflavor:"
79 "gpx:gpy:gpz:gvx:gvy:gvz:"
80 "gfpx:gfpy:gfpz:gfx:gfy:gfz:"
81 "gembed:gprimary:nclusters:"
82 "clusID:x:y:z:e:adc:layer:size:"
83 "phisize:zsize:efromtruth");
86 "event:hitID:e:adc:layer:"
88 "g4hitID:gedep:gx:gy:gz:gt:"
90 "gpx:gpy:gpz:gvx:gvy:gvz:"
91 "gfpx:gfpy:gfpz:gfx:gfy:gfz:"
92 "gembed:gprimary:efromtruth");
95 "event:hitID:x:y:z:ex:ey:ez:ephi:"
96 "e:adc:layer:size:phisize:"
97 "zsize:trackID:g4hitID:gx:"
98 "gy:gz:gt:gtrackID:gflavor:"
99 "gpx:gpy:gpz:gvx:gvy:gvz:"
100 "gfpx:gfpy:gfpz:gfx:gfy:gfz:"
101 "gembed:gprimary:efromtruth");
104 "event:gtrackID:gflavor:gnhits:"
107 "gfpx:gfpy:gfpz:gfx:gfy:gfz:"
109 "trackID:px:py:pz:charge:quality:chisq:ndf:nhits:layers:"
110 "dca2d:dca2dsigma:pcax:pcay:pcaz:nfromtruth:layersfromtruth:"
114 "event:trackID:px:py:pz:charge:"
115 "quality:chisq:ndf:nhits:layers:"
116 "dca2d:dca2dsigma:pcax:pcay:pcaz:"
117 "presdphi:presdeta:prese3x3:prese:"
118 "cemcdphi:cemcdeta:cemce3x3:cemce:"
119 "hcalindphi:hcalindeta:hcaline3x3:hcaline:"
120 "hcaloutdphi:hcaloutdeta:hcaloute3x3:hcaloute:"
121 "gtrackID:gflavor:gnhits:"
124 "gfpx:gfpy:gfpz:gfx:gfy:gfz:"
125 "gembed:gprimary:nfromtruth:layersfromtruth:"
138 cout <<
"SvtxEvaluatorHaiwang::process_event - Event = " <<
_ievent << endl;
188 cout <<
"========================= SvtxEvaluatorHaiwang::End() ============================" << endl;
189 cout <<
" " <<
_ievent <<
" events of output written to: " <<
_filename << endl;
190 cout <<
"===========================================================================" << endl;
197 cout <<
"SvtxEvaluatorHaiwang::End() - Error Count: " <<
_errors << endl;
208 if (
verbosity > 1) cout <<
"SvtxEvaluatorHaiwang::printInputInfo() entered" << endl;
217 cout <<
"---PHG4HITS-------------" << endl;
220 unsigned int ig4hit = 0;
221 for(std::set<PHG4Hit*>::iterator iter = g4hits.begin();
222 iter != g4hits.end();
225 cout << ig4hit <<
" of " << g4hits.size();
226 cout <<
": PHG4Hit: " << endl;
231 cout <<
"---SVTXCLUSTERS-------------" << endl;
232 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
234 unsigned int icluster = 0;
236 iter != clustermap->end();
238 SvtxCluster* cluster = iter->second;
239 cout << icluster <<
" of " << clustermap->size();
240 cout <<
": SvtxCluster: " << endl;
246 cout <<
"---SVXTRACKS-------------" << endl;
247 SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
249 unsigned int itrack = 0;
251 iter != trackmap->
end();
253 cout << itrack <<
" of " << trackmap->
size();
255 cout <<
" : SvtxTrack:" << endl;
261 cout <<
"---SVXVERTEXES-------------" << endl;
262 SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
264 unsigned int ivertex = 0;
266 iter != vertexmap->
end();
268 cout << ivertex <<
" of " << vertexmap->
size();
270 cout <<
" : SvtxVertex:" << endl;
282 if (
verbosity > 1) cout <<
"SvtxEvaluatorHaiwang::printOutputInfo() entered" << endl;
302 float gvx = gvertex->
get_x();
303 float gvy = gvertex->get_y();
304 float gvz = gvertex->get_z();
310 SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
312 if (!vertexmap->
empty()) {
315 vx = vertex->
get_x();
316 vy = vertex->
get_y();
317 vz = vertex->
get_z();
321 cout <<
"===Vertex Reconstruction=======================" << endl;
322 cout <<
"vtrue = (" << gvx <<
"," << gvy <<
"," << gvz <<
") => vreco = (" << vx <<
"," << vy <<
"," << vz <<
")" << endl;
325 cout <<
"===Tracking Summary============================" << endl;
326 unsigned int ng4hits[100] = {0};
328 for (std::set<PHG4Hit*>::iterator iter = g4hits.begin();
329 iter != g4hits.end();
335 SvtxHitMap* hitmap = findNode::getClass<SvtxHitMap>(topNode,
"SvtxHitMap");
336 unsigned int nhits[100] = {0};
339 iter != hitmap->end();
341 SvtxHit* hit = iter->second;
342 ++nhits[hit->get_layer()];
346 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
347 unsigned int nclusters[100] = {0};
350 iter != clustermap->end();
352 SvtxCluster* cluster = iter->second;
353 ++nclusters[cluster->get_layer()];
357 for (
unsigned int ilayer = 0; ilayer < 100; ++ilayer) {
358 cout <<
"layer " << ilayer <<
": nG4hits = " << ng4hits[ilayer]
359 <<
" => nHits = " << nhits[ilayer]
360 <<
" => nClusters = " << nclusters[ilayer] << endl;
363 SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
367 cout <<
" => nTracks = ";
368 if (trackmap) cout << trackmap->
size() << endl;
369 else cout << 0 << endl;
374 for(std::set<PHG4Hit*>::iterator iter = g4hits.begin();
375 iter != g4hits.end();
380 cout <<
"===PHG4Hit===================================" << endl;
381 cout <<
" PHG4Hit: "; g4hit->
identify();
385 for (std::set<SvtxCluster*>::iterator jter = clusters.begin();
386 jter != clusters.end();
388 SvtxCluster *cluster = *jter;
389 cout <<
"===Created-SvtxCluster================" << endl;
390 cout <<
"SvtxCluster: "; cluster->identify();
396 iter != range.second;
404 cout <<
"=== Gtrack ===================================================" << endl;
405 cout <<
" PHG4Particle id = " << particle->
get_track_id() << endl;
407 cout <<
" ptrue = (";
408 cout.width(5); cout << particle->
get_px();
410 cout.width(5); cout << particle->
get_py();
412 cout.width(5); cout << particle->
get_pz();
415 cout <<
" vtrue = (";
423 cout <<
" pt = " << sqrt(pow(particle->
get_px(),2)+pow(particle->
get_py(),2)) << endl;
424 cout <<
" phi = " << atan2(particle->
get_py(),particle->
get_px()) << endl;
425 cout <<
" eta = " << asinh(particle->
get_pz()/sqrt(pow(particle->
get_px(),2)+pow(particle->
get_py(),2))) << endl;
429 cout <<
" ---Associated-PHG4Hits-----------------------------------------" << endl;
431 for(std::set<PHG4Hit*>::iterator jter = g4hits.begin();
432 jter != g4hits.end();
440 cout <<
" #" << g4hit->
get_hit_id() <<
" xtrue = (";
441 cout.width(5); cout <<
x;
443 cout.width(5); cout <<
y;
445 cout.width(5); cout <<
z;
449 for (std::set<SvtxCluster*>::iterator kter = clusters.begin();
450 kter != clusters.end();
453 SvtxCluster *cluster = *kter;
455 float x = cluster->get_x();
456 float y = cluster->get_y();
457 float z = cluster->get_z();
459 cout <<
" => #" << cluster->get_id();
460 cout <<
" xreco = (";
461 cout.width(5); cout <<
x;
463 cout.width(5); cout <<
y;
465 cout.width(5); cout <<
z;
472 if (trackmap&&clustermap) {
475 for (std::set<SvtxTrack*>::iterator jter = tracks.begin();
476 jter != tracks.end();
481 float px = track->
get_px();
482 float py = track->
get_py();
483 float pz = track->
get_pz();
485 cout <<
"===Created-SvtxTrack==========================================" << endl;
486 cout <<
" SvtxTrack id = " << track->
get_id() << endl;
487 cout <<
" preco = (";
488 cout.width(5); cout << px;
490 cout.width(5); cout << py;
492 cout.width(5); cout << pz;
494 cout <<
" quality = " << track->
get_quality() << endl;
497 cout <<
" ---Associated-SvtxClusters-to-PHG4Hits-------------------------" << endl;
502 unsigned int cluster_id = *iter;
503 SvtxCluster* cluster = clustermap->get(cluster_id);
505 float x = cluster->get_x();
506 float y = cluster->get_y();
507 float z = cluster->get_z();
509 cout <<
" #" << cluster->get_id() <<
" xreco = (";
510 cout.width(5); cout <<
x;
512 cout.width(5); cout <<
y;
514 cout.width(5); cout <<
z;
526 cout.width(5); cout <<
x;
528 cout.width(5); cout <<
y;
530 cout.width(5); cout <<
z;
531 cout <<
") => Gtrack id = " << g4hit->
get_trkid();
533 cout <<
" noise hit";
552 if (
verbosity > 1) cout <<
"SvtxEvaluatorHaiwang::fillOutputNtuples() entered" << endl;
566 SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
568 if (vertexmap && truthinfo) {
570 iter != vertexmap->
end();
584 float gntracks = truthinfo->GetNumPrimaryVertexParticles();
585 float nfromtruth = NAN;
588 gvx = point->
get_x();
589 gvy = point->
get_y();
590 gvz = point->
get_z();
591 gvt = point->
get_t();
592 gntracks = truthinfo->GetNumPrimaryVertexParticles();
596 float vertex_data[11] = {(float)
_ievent,
629 SvtxVertexMap* vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
632 if (vertexmap && truthinfo) {
634 PHG4VtxPoint*
point = truthinfo->GetPrimaryVtx(truthinfo->GetPrimaryVertexIndex());
640 float gvx = point->
get_x();
641 float gvy = point->
get_y();
642 float gvz = point->
get_z();
644 float gntracks = truthinfo->GetNumPrimaryVertexParticles();
649 float nfromtruth = NAN;
652 vx = vertex->
get_x();
653 vy = vertex->
get_y();
654 vz = vertex->
get_z();
659 float gpoint_data[11] = {(float)
_ievent,
684 for (std::set<PHG4Hit*>::iterator iter = g4hits.begin();
685 iter != g4hits.end();
723 if (trutheval->
get_embed(g4particle) <= 0)
continue;
726 gflavor = g4particle->
get_pid();
727 gpx = g4particle->
get_px();
728 gpy = g4particle->
get_py();
729 gpz = g4particle->
get_pz();
741 gfpx = outerhit->
get_px(1);
742 gfpy = outerhit->
get_py(1);
743 gfpz = outerhit->
get_pz(1);
744 gfx = outerhit->
get_x(1);
745 gfy = outerhit->
get_y(1);
746 gfz = outerhit->
get_z(1);
749 gembed = trutheval->
get_embed(g4particle);
754 float nclusters = clusters.size();
772 clusID = cluster->get_id();
773 x = cluster->get_x();
774 y = cluster->get_y();
775 z = cluster->get_z();
776 e = cluster->get_e();
777 adc = cluster->get_adc();
778 layer = cluster->get_layer();
779 size = cluster->size_hits();
780 phisize = cluster->get_phi_size();
781 zsize = cluster->get_z_size();
787 float g4hit_data[36] = {(float)
_ievent,
836 SvtxHitMap* hitmap = findNode::getClass<SvtxHitMap>(topNode,
"SvtxHitMap");
840 iter != hitmap->end();
843 SvtxHit* hit = iter->second;
845 PHG4Cell* g4cell = hiteval->get_cell(hit);
849 float hitID = hit->get_id();
850 float e = hit->get_e();
851 float adc = hit->get_adc();
852 float layer = hit->get_layer();
853 float cellID = hit->get_cellid();
892 if (trutheval->
get_embed(g4particle) <= 0)
continue;
896 gflavor = g4particle->
get_pid();
897 gpx = g4particle->
get_px();
898 gpy = g4particle->
get_py();
899 gpz = g4particle->
get_pz();
911 gfpx = outerhit->
get_px(1);
912 gfpy = outerhit->
get_py(1);
913 gfpz = outerhit->
get_pz(1);
914 gfx = outerhit->
get_x(1);
915 gfy = outerhit->
get_y(1);
916 gfz = outerhit->
get_z(1);
918 gembed = trutheval->
get_embed(g4particle);
927 float hit_data[33] = {
974 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
978 iter != clustermap->end();
981 SvtxCluster* cluster = iter->second;
987 float hitID = cluster->get_id();
988 float x = cluster->get_x();
989 float y = cluster->get_y();
990 float z = cluster->get_z();
992 float ex = sqrt(cluster->get_error(0,0));
993 float ey = sqrt(cluster->get_error(1,1));
994 float ez = cluster->get_z_error();
996 float ephi = cluster->get_rphi_error();
998 float e = cluster->get_e();
999 float adc = cluster->get_adc();
1000 float layer = cluster->get_layer();
1001 float size = cluster->size_hits();
1002 float phisize = cluster->get_phi_size();
1003 float zsize = cluster->get_z_size();
1006 if (track) trackID = track->
get_id();
1042 gflavor = g4particle->
get_pid();
1043 gpx = g4particle->
get_px();
1044 gpy = g4particle->
get_py();
1045 gpz = g4particle->
get_pz();
1056 gfpx = outerhit->
get_px(1);
1057 gfpy = outerhit->
get_py(1);
1058 gfpz = outerhit->
get_pz(1);
1059 gfx = outerhit->
get_x(1);
1060 gfy = outerhit->
get_y(1);
1061 gfz = outerhit->
get_z(1);
1064 gembed = trutheval->
get_embed(g4particle);
1065 gprimary = trutheval->
is_primary(g4particle);
1073 float cluster_data[38] = {(float)
_ievent,
1125 SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
1126 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
1130 iter != trackmap->
end();
1136 if (trutheval->
get_embed(truth) <= 0)
continue;
1143 unsigned int cluster_id = *iter;
1144 SvtxCluster* cluster = clustermap->get(cluster_id);
1149 float hitID = cluster->get_id();
1150 float x = cluster->get_x();
1151 float y = cluster->get_y();
1152 float z = cluster->get_z();
1154 float ex = sqrt(cluster->get_error(0,0));
1155 float ey = sqrt(cluster->get_error(1,1));
1156 float ez = cluster->get_z_error();
1158 float ephi = cluster->get_rphi_error();
1160 float e = cluster->get_e();
1161 float adc = cluster->get_adc();
1162 float layer = cluster->get_layer();
1163 float size = cluster->size_hits();
1164 float phisize = cluster->get_phi_size();
1165 float zsize = cluster->get_z_size();
1168 if (track) trackID = track->
get_id();
1204 gflavor = g4particle->
get_pid();
1205 gpx = g4particle->
get_px();
1206 gpy = g4particle->
get_py();
1207 gpz = g4particle->
get_pz();
1218 gfpx = outerhit->
get_px(1);
1219 gfpy = outerhit->
get_py(1);
1220 gfpz = outerhit->
get_pz(1);
1221 gfx = outerhit->
get_x(1);
1222 gfy = outerhit->
get_y(1);
1223 gfz = outerhit->
get_z(1);
1226 gembed = trutheval->
get_embed(g4particle);
1227 gprimary = trutheval->
is_primary(g4particle);
1235 float cluster_data[38] = {(float)
_ievent,
1292 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
1297 iter != range.second;
1303 if (trutheval->
get_embed(g4particle) <= 0)
continue;
1309 std::set<PHG4Hit*> g4hits = trutheval->
all_truth_hits(g4particle);
1310 float ng4hits = g4hits.size();
1316 float gvx = vtx->
get_x();
1317 float gvy = vtx->
get_y();
1318 float gvz = vtx->
get_z();
1330 gfpx = outerhit->
get_px(1);
1331 gfpy = outerhit->
get_py(1);
1332 gfpz = outerhit->
get_pz(1);
1333 gfx = outerhit->
get_x(1);
1334 gfy = outerhit->
get_y(1);
1335 gfz = outerhit->
get_z(1);
1338 float gembed = trutheval->
get_embed(g4particle);
1345 float quality = NAN;
1349 unsigned int layers = 0x0;
1351 float dca2dsigma = NAN;
1359 float nfromtruth = NAN;
1360 float layersfromtruth = NAN;
1367 trackID = track->
get_id();
1377 unsigned int cluster_id = *iter;
1378 SvtxCluster* cluster = clustermap->get(cluster_id);
1379 unsigned int layer = cluster->get_layer();
1380 if (layer < 32) layers |= (0x1 <<
layer);
1383 if(layer >= 0 and layer <= 2) ++nmaps;
1384 if(layer >= 3 and layer <= 6) ++nintt;
1385 if(layer >= 7 and layer <= 66) ++ntpc;
1393 pcax = track->
get_x();
1394 pcay = track->
get_y();
1395 pcaz = track->
get_z();
1401 float gtrack_data[39] = {(float)
_ievent,
1466 SvtxTrackMap* trackmap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxTrackMap");
1467 SvtxClusterMap* clustermap = findNode::getClass<SvtxClusterMap>(topNode,
"SvtxClusterMap");
1471 iter != trackmap->
end();
1487 unsigned int layers = 0x0;
1491 unsigned int cluster_id = *iter;
1492 SvtxCluster* cluster = clustermap->get(cluster_id);
1493 unsigned int layer = cluster->get_layer();
1494 if (layer < 31) layers |= (0x1 <<
layer);
1496 if(layer >= 0 and layer <= 2) ++nmaps;
1497 if(layer >= 3 and layer <= 6) ++nintt;
1498 if(layer >= 7 and layer <= 66) ++ntpc;
1503 float px = track->
get_px();
1504 float py = track->
get_py();
1505 float pz = track->
get_pz();
1506 float pcax = track->
get_x();
1507 float pcay = track->
get_y();
1508 float pcaz = track->
get_z();
1549 float nfromtruth = NAN;
1550 float layersfromtruth = NAN;
1557 if (trutheval->
get_embed(g4particle) <= 0)
continue;
1561 gflavor = g4particle->
get_pid();
1563 std::set<PHG4Hit*> g4hits = trutheval->
all_truth_hits(g4particle);
1564 ng4hits = g4hits.size();
1565 gpx = g4particle->
get_px();
1566 gpy = g4particle->
get_py();
1567 gpz = g4particle->
get_pz();
1577 gfpx = outerhit->
get_px(1);
1578 gfpy = outerhit->
get_py(1);
1579 gfpz = outerhit->
get_pz(1);
1580 gfx = outerhit->
get_x(1);
1581 gfy = outerhit->
get_y(1);
1582 gfz = outerhit->
get_z(1);
1584 gembed = trutheval->
get_embed(g4particle);
1585 gprimary = trutheval->
is_primary(g4particle);
1591 float track_data[55] = {(float)
_ievent,