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>
57 , _truth_trace_embed_flags()
58 , _truth_e_threshold(0.0)
60 _reco_e_threshold(0.0)
62 _caloevalstack(nullptr)
64 , _do_gpoint_eval(
true)
65 , _do_gshower_eval(
true)
66 , _do_tower_eval(
true)
67 , _do_cluster_eval(
true)
68 , _ntp_gpoint(nullptr)
69 , _ntp_gshower(nullptr)
71 , _tower_debug(nullptr)
72 , _ntp_cluster(nullptr)
89 "event:gparticleID:gflavor:gnhits:"
90 "geta:gphi:ge:gpt:gvx:gvy:gvz:gembed:gedep:"
91 "clusterID:ntowers:eta:x:y:z:phi:e:efromtruth");
96 _ntp_tower =
new TNtuple(
"ntp_tower",
"tower => max truth primary",
97 "event:towerID:ieta:iphi:eta:phi:e:x:y:z:"
98 "gparticleID:gflavor:gnhits:"
99 "geta:gphi:ge:gpt:gvx:gvy:gvz:"
104 _tower_debug =
new TTree(
"tower_debug",
"tower => max truth primary");
119 "event:clusterID:ntowers:eta:x:y:z:phi:e:"
120 "gparticleID:gflavor:gnhits:"
121 "geta:gphi:ge:gpt:gvx:gvy:gvz:"
183 cout <<
"========================= " <<
Name() <<
"::End() ============================" << endl;
184 cout <<
" " <<
_ievent <<
" events of output written to: " <<
_filename << endl;
185 cout <<
"===========================================================================" << endl;
195 if (
Verbosity() > 2) cout <<
"CaloEvaluator::printInputInfo() entered" << endl;
209 cerr <<
PHWHERE <<
" ERROR: Can't find G4TruthInfo" << endl;
213 cout <<
Name() <<
": PHG4TruthInfoContainer contents: " << endl;
217 truthiter != truthrange.second;
222 cout << truthiter->first <<
" => pid: " << particle->
get_pid()
223 <<
" pt: " << sqrt(pow(particle->
get_px(), 2) + pow(particle->
get_py(), 2)) << endl;
232 if (
Verbosity() > 2) cout <<
"CaloEvaluator::printOutputInfo() entered" << endl;
252 cerr <<
PHWHERE <<
" ERROR: Can't find G4TruthInfo" << endl;
257 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
260 float gvx = gvertex->
get_x();
261 float gvy = gvertex->get_y();
262 float gvz = gvertex->get_z();
269 if (!vertexmap->
empty())
273 vx = vertex->
get_x();
274 vy = vertex->
get_y();
275 vz = vertex->
get_z();
279 cout <<
"vtrue = (" << gvx <<
"," << gvy <<
"," << gvz <<
") => vreco = (" << vx <<
"," << vy <<
"," << vz <<
")" << endl;
283 iter != range.second;
290 cout <<
"===Primary PHG4Particle=========================================" << endl;
291 cout <<
" particle id = " << primary->
get_track_id() << endl;
292 cout <<
" flavor = " << primary->
get_pid() << endl;
293 cout <<
" (px,py,pz,e) = (";
295 float gpx = primary->
get_px();
296 float gpy = primary->
get_py();
297 float gpz = primary->
get_pz();
298 float ge = primary->
get_e();
313 float gpt = sqrt(gpx * gpx + gpy * gpy);
315 if (gpt != 0.0) geta = asinh(gpz / gpt);
316 float gphi = atan2(gpy, gpx);
318 cout <<
"(eta,phi,e,pt) = (";
333 float gvx = vtx->
get_x();
334 float gvy = vtx->
get_y();
335 float gvz = vtx->
get_z();
337 cout <<
" vtrue = (";
348 cout <<
" embed = " << trutheval->
get_embed(primary) << endl;
352 for (std::set<RawCluster*>::iterator clusiter = clusters.begin();
353 clusiter != clusters.end();
359 float x = cluster->
get_x();
360 float y = cluster->
get_y();
361 float z = cluster->
get_z();
367 cout <<
" => #" << cluster->
get_id() <<
" (x,y,z,phi,e) = (";
382 cout <<
"), ntowers = " << ntowers <<
", efromtruth = " << efromtruth << endl;
393 if (
Verbosity() > 2) cout <<
"CaloEvaluator::fillOutputNtuples() entered" << endl;
409 cerr <<
PHWHERE <<
" ERROR: Can't find G4TruthInfo" << 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,
453 if (
Verbosity() > 1) cout <<
Name() <<
" CaloEvaluator::filling gshower ntuple..." << endl;
455 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
460 cerr <<
PHWHERE <<
" ERROR: Can't find G4TruthInfo" << endl;
466 iter != range.second;
480 float gflavor = primary->
get_pid();
488 float gpx = primary->
get_px();
489 float gpy = primary->
get_py();
490 float gpz = primary->
get_pz();
491 float ge = primary->
get_e();
493 float gpt = sqrt(gpx * gpx + gpy * gpy);
495 if (gpt != 0.0) geta = asinh(gpz / gpt);
496 float gphi = atan2(gpy, gpx);
499 float gvx = vtx->
get_x();
500 float gvy = vtx->
get_y();
501 float gvz = vtx->
get_z();
503 float gembed = trutheval->
get_embed(primary);
508 float clusterID = NAN;
517 float efromtruth = NAN;
521 clusterID = cluster->
get_id();
523 x = cluster->
get_x();
524 y = cluster->
get_y();
525 z = cluster->
get_z();
534 if (!vertexmap->
empty())
546 float shower_data[] = {(float)
_ievent,
579 if (
Verbosity() > 1) cout <<
"CaloEvaluator::filling tower ntuple..." << endl;
581 string towernode =
"TOWER_CALIB_" +
_caloname;
582 RawTowerContainer* towers = findNode::getClass<RawTowerContainer>(topNode, towernode.c_str());
585 cerr <<
PHWHERE <<
" ERROR: Can't find " << towernode << endl;
589 string towergeomnode =
"TOWERGEOM_" +
_caloname;
590 RawTowerGeomContainer* towergeom = findNode::getClass<RawTowerGeomContainer>(topNode, towergeomnode.c_str());
593 cerr <<
PHWHERE <<
" ERROR: Can't find " << towergeomnode << endl;
599 for (rtiter = begin_end.first; rtiter != begin_end.second; ++rtiter)
608 cerr <<
PHWHERE <<
" ERROR: Can't find tower geometry for this tower hit: ";
614 const float towerid = tower->
get_id();
637 float gparticleID = NAN;
656 float efromtruth = NAN;
671 ge = primary->
get_e();
673 gpt = sqrt(gpx * gpx + gpy * gpy);
674 if (gpt != 0.0) geta = asinh(gpz / gpt);
675 gphi = atan2(gpy, gpx);
692 float tower_data[] = {(float)
_ievent,
727 if (
Verbosity() > 1) cout <<
"CaloEvaluator::filling gcluster ntuple..." << endl;
729 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
731 string clusternode =
"CLUSTER_" +
_caloname;
732 RawClusterContainer* clusters = findNode::getClass<RawClusterContainer>(topNode, clusternode.c_str());
735 cerr <<
PHWHERE <<
" ERROR: Can't find " << clusternode << endl;
751 float clusterID = cluster->
get_id();
753 float x = cluster->
get_x();
754 float y = cluster->
get_y();
755 float z = cluster->
get_z();
763 if (!vertexmap->
empty())
776 float gparticleID = NAN;
796 float efromtruth = NAN;
811 ge = primary->
get_e();
813 gpt = sqrt(gpx * gpx + gpy * gpy);
814 if (gpt != 0.0) geta = asinh(gpz / gpt);
815 gphi = atan2(gpy, gpx);
833 float cluster_data[] = {(float)
_ievent,