39 #define LogDebug(exp) std::cout << "DEBUG: " << __FILE__ << ": " << __LINE__ << ": " << exp << std::endl
40 #define LogError(exp) std::cout << "ERROR: " << __FILE__ << ": " << __LINE__ << ": " << exp << std::endl
41 #define LogWarning(exp) std::cout << "WARNING: " << __FILE__ << ": " << __LINE__ << ": " << exp << std::endl
47 template<
class T>
inline constexpr
T square(
const T&
x ) {
return x*
x; }
63 std::cout <<
"Enter PHSiliconTruthTrackSeeding:: Setup" << std::endl;
66 std::string track_map_node_name = {
"SvtxSiliconTrackMap"};
89 using TrkrClusterSet = std::set<TrkrDefs::cluskey>;
90 using TrkClustersMap = std::map<int, TrkrClusterSet>;
91 TrkClustersMap m_trackID_clusters;
97 for(
auto clusIter = range.first; clusIter != range.second; ++clusIter )
107 std::cout <<
PHWHERE <<
" Warning: layer is screwed up - layer = " << layer << std::endl;
111 std::cout <<
PHWHERE <<
" process cluster " << cluskey << std::endl;
117 for (
auto clushititer = hitrange.first; clushititer != hitrange.second; ++clushititer)
125 cout <<
PHWHERE <<
" --- process hit with hitkey " << hitkey <<
" hitsetkey " << hitsetkey << std::endl;
129 std::multimap<TrkrDefs::hitsetkey, std::pair<TrkrDefs::hitkey, PHG4HitDefs::keytype> > temp_map;
131 for(
auto htiter = temp_map.begin(); htiter != temp_map.end(); ++htiter)
138 cout <<
PHWHERE <<
" --- process g4hit with key " << g4hitkey << std::endl;
155 std::cout<<
PHWHERE<<
" unable to find g4hit from key " << g4hitkey << std::endl;
167 cout <<
PHWHERE <<
" - validity check failed: missing truth particle with ID of "<<particle_id<<
". Exiting..."<<endl;
170 const double monentum2 =
177 cout <<
PHWHERE <<
" --- check momentum for g4particle "<<particle_id<<
" -> cluster "<<cluskey
178 <<
" = "<<sqrt(monentum2)<<endl;;
186 cout <<
PHWHERE <<
" ignore low momentum g4particle "<<particle_id<<
" -> cluster "<<cluskey<<endl;;
194 TrkClustersMap::iterator
it = m_trackID_clusters.find(particle_id);
196 if (it != m_trackID_clusters.end())
199 it->second.insert(cluskey);
202 cout <<
PHWHERE <<
" --- appended to g4particle"<<particle_id<<
" new cluster "<<cluskey<<endl;;
208 m_trackID_clusters.insert(std::make_pair(particle_id, TrkrClusterSet({cluskey})));
212 cout <<
PHWHERE <<
" --- added new g4particle "<<particle_id<<
" and inserted cluster "<<cluskey<<endl;;
226 cout <<__PRETTY_FUNCTION__
233 for (
const auto& [
id, cluster_keyset] : m_trackID_clusters )
239 for(
const auto& key : cluster_keyset)
242 layers.insert(layer);
246 cout <<__PRETTY_FUNCTION__<<
" particle "<<
id<<
" -> "
247 <<cluster_keyset.size()<<
" clusters covering "<<layers.size()<<
" layers."
255 auto svtx_track = std::make_unique<TrackSeed_FastSim_v1>();
256 svtx_track->set_truth_track_id(
id);
266 for (
auto iter = vrange.first; iter != vrange.second; ++iter)
268 const int point_id = iter->first;
270 if(vert_embed == track_embed)
271 vertexId = point_id - 1;
273 std::cout <<
" track_embed " << track_embed <<
" vert_embed " << vert_embed <<
" G4 point id " << point_id <<
" SvtxMap vertexId " << vertexId << std::endl;
280 std::cout <<
" truth track G4 point id " << particle->
get_vtx_id() <<
" becomes SvtxMap id " << vertexId
287 std::cout <<
PHWHERE <<
"Failed to get vertex with ID " << vertexId <<
" from _vertex_map, cannot proceed - skipping this silicon track" << std::endl;
291 svtx_track->set_X0(svtxVertex->
get_x());
292 svtx_track->set_Y0(svtxVertex->
get_y());
293 svtx_track->set_Z0(svtxVertex->
get_z());
297 std::cout <<
" truth track SvtxMap vertexid is " << vertexId <<
" for truth particle " <<
id << std::endl;
298 std::cout <<
" track position x,y,z = " << svtxVertex->
get_x() <<
", " << svtxVertex->
get_y() <<
", " << svtxVertex->
get_z() << std::endl;
303 float px = particle->
get_px();
304 float py = particle->
get_py();
305 float pz = particle->
get_pz();
306 float pt = sqrt(px*px+py*py);
308 float eta = atanh(pz/sqrt(px*px+py*py+pz*pz));
309 float theta = 2*atan(exp(-1*eta));
310 svtx_track->set_qOverR(charge * 0.3*1.4/(100*pt));
311 svtx_track->set_slope(1./tan(theta));
314 std::cout <<
PHWHERE <<
"Truth track ID is " << svtx_track->get_truth_track_id() <<
" particle ID is " << particle->
get_pid() << std::endl;
317 for(
const auto& key:cluster_keyset)
319 svtx_track->insert_cluster_key(key);
326 cout <<__PRETTY_FUNCTION__<<
" particle "<<
id<<
" -> "
327 <<cluster_keyset.size()<<
" clusters"
336 cout <<
"Loop over SvtxSiliconTrackMap entries " << endl;
341 auto svtx_track = *iter;
343 cout <<
"Track ID: " <<
id <<
", Track pT: "
344 << svtx_track->get_pt() <<
", Truth Track/Particle ID: "
345 << svtx_track->get_truth_track_id() << endl;
346 cout <<
" (pt, pz) = " <<
"("<< svtx_track->get_pt() <<
", " << svtx_track->get_pz() <<
")" << endl;
347 cout <<
" (x, y, z) = " <<
"("<< svtx_track->get_x() <<
", " << svtx_track->get_y() <<
", " << svtx_track->get_z() <<
")" << endl;
353 svtx_track->begin_cluster_keys();
354 iter != svtx_track->end_cluster_keys(); ++iter)
360 cout <<
" cluster ID: "
361 << cluster_key <<
", cluster radius: " << radius
386 _g4truth_container = findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo");
389 cerr <<
PHWHERE <<
" ERROR: Can't find node G4TruthInfo" << endl;
393 clusterhitassoc = findNode::getClass<TrkrClusterHitAssoc>(topNode,
"TRKR_CLUSTERHITASSOC");
396 cout <<
PHWHERE <<
"Failed to find TRKR_CLUSTERHITASSOC node, quit!" << endl;
400 hittruthassoc = findNode::getClass<TrkrHitTruthAssoc>(topNode,
"TRKR_HITTRUTHASSOC");
403 cout <<
PHWHERE <<
"Failed to find TRKR_HITTRUTHASSOC node, quit!" << endl;
407 using nodePair = std::pair<std::string, PHG4HitContainer*&>;
408 std::initializer_list<nodePair> nodes =
416 for(
auto&&
node: nodes )
418 if( !(
node.second = findNode::getClass<PHG4HitContainer>( topNode,
node.first ) ) )
419 { std::cerr <<
PHWHERE <<
" PHG4HitContainer " <<
node.first <<
" not found" << std::endl; }