22 #include <pdbcalbase/PdbParameterMap.h>
23 #include <phparameter/PHParameters.h>
43 #define LogDebug(exp) std::cout << "DEBUG: " << __FILE__ << ": " << __LINE__ << ": " << exp << "\n"
44 #define LogError(exp) std::cout << "ERROR: " << __FILE__ << ": " << __LINE__ << ": " << exp << "\n"
45 #define LogWarning(exp) std::cout << "WARNING: " << __FILE__ << ": " << __LINE__ << ": " << exp << "\n"
49 const string xyzt[] = {
"x",
"y",
"z",
"t"};
57 , m_TruthInfoContainer(nullptr)
59 , m_VertexMap(nullptr)
60 , m_TracksEvalTree(nullptr)
61 , m_VertexEvalTree(nullptr)
62 , m_H2D_DeltaMomVsTruthMom(nullptr)
63 , m_H2D_DeltaMomVsTruthEta(nullptr)
65 , m_OutFileName(filename)
66 , m_TrackMapName(trackmapname)
114 PHParameters PHG4TrackFastSim_Parameter(
"PHG4TrackFastSim");
116 PdbParameterMap *nodeparams = findNode::getClass<PdbParameterMap>(topNode,
117 "PHG4TrackFastSim_Parameter");
120 cout << __PRETTY_FUNCTION__ <<
" : Warning, missing PHG4TrackFastSim_Parameter node and skip saving hits"
125 PHG4TrackFastSim_Parameter.
FillFrom(nodeparams);
128 cout << __PRETTY_FUNCTION__ <<
" PHG4TrackFastSim_Parameter : ";
129 PHG4TrackFastSim_Parameter.
Print();
133 for (
auto iter = range.first; iter != range.second; ++iter)
135 const string &phg4hit_node_name = iter->first;
136 const int &phg4hit_node_id = iter->second;
138 cout << __PRETTY_FUNCTION__ <<
" Prepare PHG4Hit node name " << phg4hit_node_name
139 <<
" with ID = " << phg4hit_node_id << endl;
141 string branch_name =
string(
"nHit_") + phg4hit_node_name;
144 (branch_name +
"/I").c_str());
149 "#frac{#Delta p}{truth p} vs. truth #eta", 54, -4.5, +4.5, 1000, -1,
153 "#frac{#Delta p}{truth p} vs. truth p", 41, -0.5, 40.5, 1000, -1,
176 for (
int i = 0;
i < 4;
i++)
178 string bname = iter->first +
"_proj_" +
xyzt[
i];
179 string bdef = bname +
"/F";
184 bdef = iter->first +
"_proj_path_length" +
"/F";
190 for (
int i = 0;
i < 3;
i++)
192 string bname = iter->first +
"_proj_p" +
xyzt[
i];
193 string bdef = bname +
"/F";
196 string nodename =
"G4HIT_" + iter->first;
197 PHG4HitContainer *hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
200 for (
int i = 0;
i < 4;
i++)
202 string bname = iter->first +
"_" +
xyzt[
i];
203 string bdef = bname +
"/F";
206 for (
int i = 0;
i < 3;
i++)
208 string bname = iter->first +
"_p" +
xyzt[
i];
209 string bdef = bname +
"/F";
216 cout <<
"InitRun: could not find " << nodename << endl;
274 LogError(
"m_TruthInfoContainer not found!");
287 truth_itr != range.second; ++truth_itr)
312 std::cout <<
"PHG4TrackFastSimEval::fill_track_tree - ignore track that is not a SvtxTrack_FastSim:";
317 if (
Verbosity()) cout << __PRETTY_FUNCTION__ <<
" PARTICLE!" << std::endl;
372 if (
Verbosity()) cout << __PRETTY_FUNCTION__ <<
" checking " << trkstates->second->get_name() << endl;
373 map<string, unsigned int>::const_iterator iter =
m_ProjectionNameMap.find(trkstates->second->get_name());
376 if (
Verbosity()) cout << __PRETTY_FUNCTION__ <<
" found " << trkstates->second->get_name() << endl;
378 for (
int i = 0;
i < 3;
i++)
386 string nodename =
"G4HIT_" + trkstates->second->get_name();
387 PHG4HitContainer *hits = findNode::getClass<PHG4HitContainer>(topNode, nodename);
390 if (
Verbosity()) cout << __PRETTY_FUNCTION__ <<
" could not find " << nodename << endl;
393 if (
Verbosity()) cout << __PRETTY_FUNCTION__ <<
" number of hits: " << hits->
size() << endl;
397 if (
Verbosity()) cout << __PRETTY_FUNCTION__ <<
" checking hit id " << hit_iter->second->get_trkid() <<
" against " << track->
get_truth_track_id() << endl;
400 if (
Verbosity()) cout << __PRETTY_FUNCTION__ <<
" found hit with id " << hit_iter->second->get_trkid() << endl;
403 cout <<
"bad index: " << iter->second << endl;
420 for (
const auto &g4hit_id_hitset : track->
g4hit_ids())
422 const int &g4hit_id = g4hit_id_hitset.first;
423 const set<PHG4HitDefs::keytype> &g4hit_set = g4hit_id_hitset.second;
428 nhit_iter->second = g4hit_set.size();
447 LogError(
"m_TruthInfoContainer not found!");
492 int best_n_match = -1;
493 map<PHG4VtxPoint *, int> vertex_match_map;
496 const auto &trackid = *iterA;
510 int n_match = ++vertex_match_map[vtx];
512 if (n_match > best_n_match)
514 best_n_match = n_match;
576 for (
auto &elem :
m_TTree_proj_vec) std::fill(elem.begin(), elem.end(), -9999);
578 for (
auto &elem :
m_TTree_ref_vec) std::fill(elem.begin(), elem.end(), -9999);
595 cout <<
PHWHERE <<
" PHG4TruthInfoContainer node not found on node tree"
600 m_TrackMap = findNode::getClass<SvtxTrackMap>(topNode,
605 cout <<
PHWHERE <<
"SvtxTrackMap node with name "
607 <<
" not found on node tree"
612 m_VertexMap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMap");
615 cout <<
PHWHERE <<
"SvtxTrackMap node with name SvtxVertexMap not found on node tree. Will not build the vertex eval tree"
624 vector<float> floatvec{-9999, -9999, -9999, -9999};