16 #include <calobase/RawCluster.h>
17 #include <calobase/RawClusterContainer.h>
18 #include <calobase/RawClusterUtility.h>
19 #include <calobase/RawTower.h>
20 #include <calobase/RawTowerContainer.h>
21 #include <calobase/RawTowerGeom.h>
22 #include <calobase/RawTowerGeomContainer.h>
34 #include <CLHEP/Vector/ThreeVector.h>
56 _ntp_gpoint =
new TNtuple(
"ntp_gpoint",
"primary vertex => best (first) vertex",
63 _ntp_gshower =
new TNtuple(
"ntp_gshower",
"truth shower => best cluster",
64 "event:gparticleID:gflavor:gnhits:"
65 "geta:gphi:ge:gpt:gvx:gvy:gvz:gembed:gedep:"
66 "clusterID:ntowers:eta:x:y:z:phi:e:efromtruth");
72 _ntp_tower =
new TNtuple(
"ntp_tower",
"tower => max truth primary",
73 "event:towerID:ieta:iphi:eta:phi:e:x:y:z:"
74 "gparticleID:gflavor:gnhits:"
75 "geta:gphi:ge:gpt:gvx:gvy:gvz:"
80 _tower_debug =
new TTree(
"tower_debug",
"tower => max truth primary");
96 _ntp_cluster =
new TNtuple(
"ntp_cluster",
"cluster => max truth primary",
97 "event:clusterID:ntowers:eta:x:y:z:phi:e:"
98 "gparticleID:gflavor:gnhits:"
99 "geta:gphi:ge:gpt:gvx:gvy:gvz:"
172 std::cout <<
"========================= " <<
Name() <<
"::End() ============================" << std::endl;
174 std::cout <<
"===========================================================================" << std::endl;
189 std::cout <<
"CaloEvaluator::printInputInfo() entered" << std::endl;
196 std::cout << std::endl;
197 std::cout <<
PHWHERE <<
" NEW INPUT FOR EVENT " <<
_ievent << std::endl;
198 std::cout << std::endl;
204 std::cout <<
PHWHERE <<
" ERROR: Can't find G4TruthInfo" << std::endl;
208 std::cout <<
Name() <<
": PHG4TruthInfoContainer contents: " << std::endl;
212 truthiter != truthrange.second;
217 std::cout << truthiter->first <<
" => pid: " << particle->
get_pid()
218 <<
" pt: " << sqrt(pow(particle->
get_px(), 2) + pow(particle->
get_py(), 2)) << std::endl;
229 std::cout <<
"CaloEvaluator::printOutputInfo() entered" << std::endl;
242 std::cout << std::endl;
243 std::cout <<
PHWHERE <<
" NEW OUTPUT FOR EVENT " <<
_ievent << std::endl;
244 std::cout << std::endl;
250 std::cout <<
PHWHERE <<
" ERROR: Can't find G4TruthInfo" << std::endl;
255 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
258 float gvx = gvertex->
get_x();
259 float gvy = gvertex->get_y();
260 float gvz = gvertex->get_z();
267 if (!vertexmap->
empty())
271 vx = vertex->
get_x();
272 vy = vertex->
get_y();
273 vz = vertex->
get_z();
277 std::cout <<
"vtrue = (" << gvx <<
"," << gvy <<
"," << gvz <<
") => vreco = (" << vx <<
"," << vy <<
"," << vz <<
")" << std::endl;
281 iter != range.second;
286 std::cout << std::endl;
288 std::cout <<
"===Primary PHG4Particle=========================================" << std::endl;
289 std::cout <<
" particle id = " << primary->
get_track_id() << std::endl;
290 std::cout <<
" flavor = " << primary->
get_pid() << std::endl;
291 std::cout <<
" (px,py,pz,e) = (";
296 float ge = primary->
get_e();
309 std::cout <<
")" << std::endl;
311 float gpt = std::sqrt(gpx * gpx + gpy * gpy);
315 geta = std::asinh(gpz / gpt);
317 float gphi = std::atan2(gpy, gpx);
319 std::cout <<
"(eta,phi,e,pt) = (";
331 std::cout <<
")" << std::endl;
334 float local_gvx = vtx->
get_x();
335 float local_gvy = vtx->
get_y();
336 float local_gvz = vtx->
get_z();
338 std::cout <<
" vtrue = (";
340 std::cout << local_gvx;
343 std::cout << local_gvy;
346 std::cout << local_gvz;
347 std::cout <<
")" << std::endl;
349 std::cout <<
" embed = " << trutheval->
get_embed(primary) << std::endl;
353 for (
auto cluster : clusters)
355 float ntowers = cluster->getNTowers();
356 float x = cluster->get_x();
357 float y = cluster->get_y();
358 float z = cluster->get_z();
359 float phi = cluster->get_phi();
360 float e = cluster->get_energy();
364 std::cout <<
" => #" << cluster->get_id() <<
" (x,y,z,phi,e) = (";
379 std::cout <<
"), ntowers = " << ntowers <<
", efromtruth = " << efromtruth << std::endl;
382 std::cout << std::endl;
392 std::cout <<
"CaloEvaluator::fillOutputNtuples() entered" << std::endl;
409 std::cout <<
PHWHERE <<
" ERROR: Can't find G4TruthInfo" << std::endl;
414 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
417 float gvx = gvertex->
get_x();
418 float gvy = gvertex->get_y();
419 float gvz = gvertex->get_z();
426 if (!vertexmap->
empty())
430 vx = vertex->
get_x();
431 vy = vertex->
get_y();
432 vz = vertex->
get_z();
436 float gpoint_data[7] = {(float)
_ievent,
455 std::cout <<
Name() <<
" CaloEvaluator::filling gshower ntuple..." << std::endl;
458 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
463 std::cout <<
PHWHERE <<
" ERROR: Can't find G4TruthInfo" << std::endl;
469 iter != range.second;
501 float gpx = primary->
get_px();
502 float gpy = primary->
get_py();
503 float gpz = primary->
get_pz();
504 float ge = primary->
get_e();
506 float gpt = std::sqrt(gpx * gpx + gpy * gpy);
510 geta = std::asinh(gpz / gpt);
512 float gphi = std::atan2(gpy, gpx);
515 float gvx = vtx->
get_x();
516 float gvy = vtx->
get_y();
517 float gvz = vtx->
get_z();
519 float gembed = trutheval->
get_embed(primary);
524 float clusterID = NAN;
533 float efromtruth = NAN;
537 clusterID = cluster->
get_id();
539 x = cluster->
get_x();
540 y = cluster->
get_y();
541 z = cluster->
get_z();
550 if (!vertexmap->
empty())
562 float shower_data[] = {(float)
_ievent,
597 std::cout <<
"CaloEvaluator::filling tower ntuple..." << std::endl;
601 RawTowerContainer* towers = findNode::getClass<RawTowerContainer>(topNode, towernode.c_str());
604 std::cout <<
PHWHERE <<
" ERROR: Can't find " << towernode << std::endl;
609 RawTowerGeomContainer* towergeom = findNode::getClass<RawTowerGeomContainer>(topNode, towergeomnode.c_str());
612 std::cout <<
PHWHERE <<
" ERROR: Can't find " << towergeomnode << std::endl;
618 for (rtiter = begin_end.first; rtiter != begin_end.second; ++rtiter)
630 std::cout <<
PHWHERE <<
" ERROR: Can't find tower geometry for this tower hit: ";
639 const float eta = tower_geom->
get_eta();
640 const float phi = tower_geom->
get_phi();
659 float gparticleID = NAN;
678 float efromtruth = NAN;
697 ge = primary->
get_e();
699 gpt = std::sqrt(gpx * gpx + gpy * gpy);
702 geta = std::asinh(gpz / gpt);
704 gphi = std::atan2(gpy, gpx);
721 float tower_data[] = {(float)
_ievent,
758 std::cout <<
"CaloEvaluator::filling gcluster ntuple..." << std::endl;
761 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
764 RawClusterContainer* clusters = findNode::getClass<RawClusterContainer>(topNode, clusternode.c_str());
767 std::cout << PHWHERE <<
" ERROR: Can't find " << clusternode << std::endl;
786 float clusterID = cluster->
get_id();
788 float x = cluster->
get_x();
789 float y = cluster->
get_y();
790 float z = cluster->
get_z();
792 float phi = cluster->
get_phi();
798 if (!vertexmap->
empty())
811 float gparticleID = NAN;
831 float efromtruth = NAN;
850 ge = primary->
get_e();
852 gpt = std::sqrt(gpx * gpx + gpy * gpy);
855 geta = std::asinh(gpz / gpt);
857 gphi = std::atan2(gpy, gpx);
875 float cluster_data[] = {(float)
_ievent,