33 #include <trackermillepedealignment/HelicalFitter.h>
60 unsigned int nlayers_maps,
62 unsigned int nlayers_tpc,
63 unsigned int nlayers_mms)
69 , _do_vertex_eval(
true)
71 , _do_cluster_eval(
true)
72 , _do_clus_trk_eval(
true)
73 , _do_track_eval(
true)
74 , _do_tpcseed_eval(
false)
75 , _do_siseed_eval(
false)
76 , _nlayers_maps(nlayers_maps)
77 , _nlayers_intt(nlayers_intt)
78 , _nlayers_tpc(nlayers_tpc)
79 , _nlayers_mms(nlayers_mms)
81 , _ntp_vertex(nullptr)
83 , _ntp_cluster(nullptr)
84 , _ntp_clus_trk(nullptr)
86 , _ntp_tpcseed(nullptr)
87 , _ntp_siseed(nullptr)
89 , _trackmapname(trackmapname)
105 _tfile->SetCompressionLevel(7);
108 _ntp_info =
new TNtuple(
"ntp_info",
"event info",
110 "occ11:occ116:occ21:occ216:occ31:occ316:"
112 "nhitmvtx:nhitintt:nhittpot:"
113 "nhittpcall:nhittpcin:nhittpcmid:nhittpcout:nclusall:nclustpc:nclusintt:nclusmaps:nclusmms");
118 _ntp_vertex =
new TNtuple(
"ntp_vertex",
"vertex => max truth",
119 "event:seed:vertexID:vx:vy:vz:ntracks:chi2:ndof:"
120 "nhittpcall:nhittpcin:nhittpcmid:nhittpcout:nclusall:nclustpc:nclusintt:nclusmaps:nclusmms");
125 _ntp_hit =
new TNtuple(
"ntp_hit",
"svtxhit => max truth",
126 "event:seed:hitID:e:adc:layer:phielem:zelem:"
127 "cellID:ecell:phibin:tbin:phi:x:y:z:"
128 "nhitmvtx:nhitintt:nhittpot:"
129 "nhittpcall:nhittpcin:nhittpcmid:nhittpcout:nclusall:nclustpc:nclusintt:nclusmaps:nclusmms");
134 _ntp_cluster =
new TNtuple(
"ntp_cluster",
"svtxcluster => max truth",
135 "event:seed:hitID:locx:locy:x:y:z:r:phi:eta:theta:phibin:tbin:ex:ey:ez:ephi:pez:pephi:"
136 "e:adc:maxadc:layer:phielem:zelem:size:phisize:zsize:"
138 "nhitmvtx:nhitintt:nhittpot:"
139 "nhittpcall:nhittpcin:nhittpcmid:nhittpcout:nclusall:nclustpc:nclusintt:nclusmaps:nclusmms");
143 _ntp_clus_trk =
new TNtuple(
"ntp_clus_trk",
"cluster on track",
144 "event:seed:locx:locy:x:y:z:r:phi:eta:theta:phibin:tbin:ex:ey:ez:ephi:pez:pephi:"
145 "e:adc:maxadc:layer:phielem:zelem:size:phisize:zsize:"
147 "trackID:niter:pt:eta:phi:X0:Y0:Z0:charge:"
148 "nhitmvtx:nhitintt:nhittpot:"
149 "nhittpcall:nhittpcin:nhittpcmid:nhittpcout:nclusall:nclustpc:nclusintt:nclusmaps:nclusmms");
154 _ntp_track =
new TNtuple(
"ntp_track",
"svtxtrack => max truth",
155 "event:seed:trackID:crossing:px:py:pz:pt:eta:phi:deltapt:deltaeta:deltaphi:charge:"
156 "quality:chisq:ndf:nhits:nmaps:nintt:ntpc:nmms:ntpc1:ntpc11:ntpc2:ntpc3:nlmaps:nlintt:nltpc:nlmms:layers:"
157 "vertexID:vx:vy:vz:dca2d:dca2dsigma:dca3dxy:dca3dxysigma:dca3dz:dca3dzsigma:pcax:pcay:pcaz:"
158 "nhitmvtx:nhitintt:nhittpot:"
159 "nhittpcall:nhittpcin:nhittpcmid:nhittpcout:nclusall:nclustpc:nclusintt:nclusmaps:nclusmms");
164 _ntp_tpcseed =
new TNtuple(
"ntp_tpcseed",
"seeds from truth",
165 "event:seed:ntrk:gx:gy:gz:gr:geta:gphi:"
167 "gpx:gpy:gpz:gtpt:gtphi:gteta:"
169 "gembed:gprimary:gflav:"
171 "nhitmvtx:nhitintt:nhittpot:"
172 "nhittpcall:nhittpcin:nhittpcmid:nhittpcout:nclusall:nclustpc:nclusintt:nclusmaps:nclusmms");
176 _ntp_tpcseed =
new TNtuple(
"ntp_siseed",
"seeds from truth",
177 "event:seed:ntrk:gx:gy:gz:gr:geta:gphi:"
179 "gpx:gpy:gpz:gtpt:gtphi:gteta:"
181 "gembed:gprimary:gflav:"
183 "nhitmvtx:nhitintt:nhittpot:"
184 "nhittpcall:nhittpcin:nhittpcmid:nhittpcout:nclusall:nclustpc:nclusintt:nclusmaps:nclusmms");
201 cout <<
"TrkrNtuplizer::process_event - Event = " <<
_ievent << endl;
220 cout <<
"TrkrNtuplizer::process_event - Seed = " <<
_iseed << endl;
287 cout <<
"========================= TrkrNtuplizer::End() ============================" << endl;
288 cout <<
" " <<
_ievent <<
" events of output written to: " <<
_filename << endl;
289 cout <<
"===========================================================================" << endl;
299 cout <<
"TrkrNtuplizer::printInputInfo() entered" << endl;
310 cout <<
"---SVTXCLUSTERS-------------" << endl;
311 TrkrClusterContainer* clustermap = findNode::getClass<TrkrClusterContainer>(topNode,
"CORRECTED_TRKR_CLUSTER");
314 clustermap = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
317 if (clustermap !=
nullptr)
319 unsigned int icluster = 0;
323 for (
auto iter = range.first; iter != range.second; ++iter)
326 cout << icluster <<
" with key " << cluster_key <<
" of " << clustermap->
size();
327 cout <<
": SvtxCluster: " << endl;
328 iter->second->identify();
334 cout <<
"---SVXTRACKS-------------" << endl;
338 unsigned int itrack = 0;
345 cout <<
" : SvtxTrack:" << endl;
352 cout <<
"---SVXVERTEXES-------------" << endl;
354 vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMapActs");
358 unsigned int ivertex = 0;
360 iter != vertexmap->
end();
363 cout << ivertex <<
" of " << vertexmap->
size();
365 cout <<
" : SvtxVertex:" << endl;
379 cout <<
"TrkrNtuplizer::printOutputInfo() entered" << endl;
399 vertexmap = findNode::getClass<SvtxVertexMap>(topNode,
"SvtxVertexMapActs");
403 if (!vertexmap->
empty())
407 vx = vertex->
get_x();
408 vy = vertex->
get_y();
409 vz = vertex->
get_z();
413 cout <<
"===Vertex Reconstruction=======================" << endl;
414 cout <<
"vreco = (" << vx <<
"," << vy <<
"," << vz <<
")" << endl;
417 cout <<
"===Tracking Summary============================" << endl;
419 TrkrHitSetContainer* hitsetmap = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
421 TrkrClusterContainer* clustermap = findNode::getClass<TrkrClusterContainer>(topNode,
"CORRECTED_TRKR_CLUSTER");
424 clustermap = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
427 unsigned int nclusters[100] = {0};
428 unsigned int nhits[100] = {0};
430 ActsGeometry* tgeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
434 std::cout <<
PHWHERE <<
"No Acts geometry on node tree. Can't continue."
442 hitsetiter != all_hitsets.second;
451 hitr != hitrangei.second;
456 auto range = clustermap->getClusters(hitsetiter->first);
457 for (
auto clusIter = range.first; clusIter != range.second; ++clusIter)
459 const auto cluskey = clusIter->first;
468 findNode::getClass<PHG4TpcCylinderGeomContainer>(topNode,
"CYLINDERCELLGEOM_SVTX");
472 std::cout <<
PHWHERE <<
"ERROR: Can't find node CYLINDERCELLGEOM_SVTX" << std::endl;
481 cout <<
"layer " << ilayer
482 <<
" => nHits = " << nhits[ilayer]
483 <<
" => nClusters = " << nclusters[ilayer] << endl;
486 cout <<
"layer " << ilayer
494 cout <<
" => nTracks = ";
515 cout <<
"TrkrNtuplizer::fillOutputNtuples() entered" << endl;
518 ActsGeometry* tgeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
521 std::cout <<
"No Acts geometry on node tree. Can't continue."
526 float nhit_tpc_all = 0;
527 float nhit_tpc_in = 0;
528 float nhit_tpc_mid = 0;
529 float nhit_tpc_out = 0;
537 float nclus_intt = 0;
538 float nclus_maps = 0;
541 for (
float&
i : nhit)
i = 0;
549 TrkrHitSetContainer* hitmap_in = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
554 hitsetiter != all_hitsets.second;
562 hitr != hitrangei.second;
596 findNode::getClass<PHG4TpcCylinderGeomContainer>(topNode,
"CYLINDERCELLGEOM_SVTX");
599 std::cout <<
PHWHERE <<
"ERROR: Can't find node CYLINDERCELLGEOM_SVTX" << std::endl;
656 TrkrClusterContainer* clustermap_in = findNode::getClass<TrkrClusterContainer>(topNode,
"CORRECTED_TRKR_CLUSTER");
659 clustermap_in = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
664 nclus_all = clustermap_in->
size();
669 for (
auto iter_cin = range.first; iter_cin != range.second; ++iter_cin)
711 cout <<
"Filling ntp_info " << endl;
721 cout <<
"EVENTINFO SEED: " <<
m_fSeed << endl;
722 cout <<
"EVENTINFO NHIT: " << setprecision(9) << nhit_tpc_all << endl;
723 cout <<
"EVENTINFO CLUSTPC: " << nclus_tpc << endl;
724 cout <<
"EVENTINFO NTRKREC: " << ntrk << endl;
727 occ11, occ116, occ21, occ216, occ31, occ316,
735 nhit_tpc_out, nclus_all, nclus_tpc, nclus_intt, nclus_maps, nclus_mms};
748 cout <<
"Filling ntp_vertex " << endl;
764 std::cout <<
" adding vertex data " << std::endl;
778 nhit_tpc_out, nclus_all, nclus_tpc, nclus_intt, nclus_maps, nclus_mms};
791 auto m_tGeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
795 cout <<
"Filling ntp_hit " << endl;
799 TrkrHitSetContainer* hitmap = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
805 iter != all_hitsets.second;
813 hitr != hitrangei.second;
819 float hitID = hit_key;
821 float adc = hit->
getAdc();
826 float ecell = hit->
getAdc();
831 float phi_center = NAN;
844 double zdriftlength = tbin * m_tGeometry->get_drift_velocity() *
AdcClockPeriod;
847 unsigned short NTBins = (
unsigned short) GeoLayer_local->
get_zbins();
849 double clusz = (m_tdriftmax * m_tGeometry->get_drift_velocity()) - zdriftlength;
856 x = radius * cos(phi_center);
857 y = radius * sin(phi_center);
883 nhit_tpc_out, nclus_all, nclus_tpc, nclus_intt, nclus_maps, nclus_mms};
902 cout <<
"check for ntp_cluster" << endl;
910 cout <<
"Filling ntp_cluster (all of them) " << endl;
913 TrkrClusterContainer* clustermap = findNode::getClass<TrkrClusterContainer>(topNode,
"CORRECTED_TRKR_CLUSTER");
916 clustermap = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
919 TrkrHitSetContainer* hitsets = findNode::getClass<TrkrHitSetContainer>(topNode,
"TRKR_HITSET");
925 if (clustermap !=
nullptr)
927 cout <<
"got clustermap" << endl;
931 cout <<
"no clustermap" << endl;
934 if (hitsets !=
nullptr)
936 cout <<
"got hitsets" << endl;
940 cout <<
"no hitsets" << endl;
944 if (clustermap && hitsets)
950 for (
auto iter = range.first; iter != range.second; ++iter)
957 float hitID = (float) cluster_key;
966 TVector3
pos(x, y, z);
967 float r = pos.Perp();
968 float phi = pos.Phi();
969 float eta = pos.Eta();
970 float theta = pos.Theta();
983 auto para_errors = ClusErrPara.get_clusterv5_modified_error(cluster,r ,cluster_key);
988 ez = sqrt(para_errors.second);
989 ephi = sqrt(para_errors.first);
993 float adc = cluster->
getAdc();
1001 ez = sqrt(para_errors.second);
1002 ephi = sqrt(para_errors.first);
1007 if (hitsetlayer != layer_local)
1009 cout <<
"WARNING hitset layer " << hitsetlayer <<
"| " << hitsetlayer2 <<
" layer " << layer_local << endl;
1017 if (track !=
nullptr)
1019 trackID = track->
get_id();
1033 float cluster_data[] = {(float)
_ievent,
1070 nhit_tpc_out, nclus_all, nclus_tpc, nclus_intt, nclus_maps, nclus_mms};
1087 cout <<
"Filling ntp_clus_trk " << endl;
1090 TrkrClusterContainer* clustermap = findNode::getClass<TrkrClusterContainer>(topNode,
"CORRECTED_TRKR_CLUSTER");
1093 clustermap = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
1101 if (clustermap !=
nullptr) cout <<
"got clustermap" << endl;
1102 else cout <<
"no clustermap" << endl;
1106 TrackSeedContainer *_tpcseeds = findNode::getClass<TrackSeedContainer>(topNode,
"TpcTrackSeedContainer");
1107 TrackSeedContainer *_silseeds = findNode::getClass<TrackSeedContainer>(topNode,
"SiliconTrackSeedContainer");
1115 for (
unsigned int phtrk_iter = 0; phtrk_iter < _tpc_seeds->
size(); ++phtrk_iter){
1126 tpcseed = _tpcseeds->get(tpcindex);
1127 silseed = _silseeds->get(silindex);
1131 std::vector<Acts::Vector3> clusterPositions;
1132 std::vector<TrkrDefs::cluskey> clusterKeys;
1141 clusterPositions, clusterKeys);
1143 if(fitparams.size() == 0)
1147 nclus_all = clusterKeys.size();
1156 float tphi = tpcseed->
get_phi(clustermap,tgeometry);
1157 float tX0 = tpcseed->
get_X0();
1158 float tY0 = tpcseed->
get_Y0();
1159 float tZ0 = tpcseed->
get_Z0();
1161 float nhits_local = 0;
1172 for (
size_t i = 0;
i < clusterPositions.size();
i++)
1202 float pca_phi = atan2(pca(1), pca(0));
1203 float dphi = cluster_phi - pca_phi;
1206 dphi = 2 * M_PI -
dphi;
1210 dphi = 2 * M_PI +
dphi;
1222 TVector3
pos(x, y, z);
1223 float r = pos.Perp();
1224 float phi = pos.Phi();
1225 float eta = pos.Eta();
1226 float theta = pos.Theta();
1237 float maxadc = -999;
1244 ez = sqrt(para_errors.second);
1245 ephi = sqrt(para_errors.first);
1249 float adc = cluster->
getAdc();
1272 float clus_trk_data[] = {(float)
_ievent,
1318 nhit_tpc_out, nclus_all, nclus_tpc, nclus_intt, nclus_maps, nclus_mms};
1334 cout <<
"Filling ntp_track " << endl;
1340 GlobalVertexMap* vertexmap = findNode::getClass<GlobalVertexMap>(topNode,
"GlobalVertexMap");
1347 if(!track)
continue;
1353 if (crossing_int == SHRT_MAX)
1359 crossing = (float) crossing_int;
1365 float nhits_local = 0;
1374 unsigned int layers = 0x0;
1433 maps[layer_local] = 1;
1483 maps[layer_local] = 1;
1549 layers = nlmaps + nlintt + nltpc + nlmms;
1551 float dca3dxy = NAN, dca3dz = NAN,
1552 dca3dxysigma = NAN, dca3dzsigma = NAN;
1553 float dca2d = NAN, dca2dsigma = NAN;
1565 vx = vertex->
get_x();
1566 vy = vertex->
get_y();
1567 vz = vertex->
get_z();
1570 dca3dxy = dcapair.first.first;
1571 dca3dxysigma = dcapair.first.second;
1572 dca3dz = dcapair.second.first;
1573 dca3dzsigma = dcapair.second.second;
1576 float px = track->
get_px();
1577 float py = track->
get_py();
1578 float pz = track->
get_pz();
1579 TVector3
v(px, py, pz);
1581 float eta = v.Eta();
1582 float phi = v.Phi();
1589 float deltapt = sqrt((CVxx * px * px + 2 * CVxy * px * py + CVyy * py * py) / (px * px + py * py));
1590 float deltaeta = sqrt((CVzz * (px * px + py * py) * (px * px + py * py) + pz * (-2 * (CVxz * px + CVyz * py) * (px * px + py * py) + CVxx * px * px * pz + CVyy * py * py * pz + 2 * CVxy * px * py * pz)) / ((px * px + py * py) * (px * px + py * py) * (px * px + py * py + pz * pz)));
1591 float deltaphi = sqrt((CVyy * px * px - 2 * CVxy * px * py + CVxx * py * py) / ((px * px + py * py) * (px * px + py * py)));
1592 float pcax = track->
get_x();
1593 float pcay = track->
get_y();
1594 float pcaz = track->
get_z();
1612 nhits_local, nmaps, nintt, ntpc, nmms,
1613 ntpc1, ntpc11, ntpc2, ntpc3,
1614 nlmaps, nlintt, nltpc, nlmms,
1635 nhit_tpc_out, nclus_all, nclus_tpc, nclus_intt, nclus_maps, nclus_mms};
1640 <<
" trackID " << trackID
1641 <<
" nhits " << nhits
1666 cout <<
"Filling ntp_tpcseed " << endl;
1681 cout <<
"Filling ntp_tpcseed " << endl;
1696 std::vector<TrkrDefs::cluskey> cluster_keys;
1704 { cluster_keys.push_back(*iter); }
1711 { cluster_keys.push_back(*iter); }
1714 return cluster_keys;
1719 std::map<TrkrDefs::cluskey, SvtxTrack*>::iterator find_iter =
1723 return find_iter->second;
1727 float best_quality = FLT_MAX;
1731 for (std::set<SvtxTrack*>::iterator iter = tracks.begin();
1732 iter != tracks.end();
1739 best_track = candidate;
1749 std::set<SvtxTrack*>
tracks;
1752 std::map<TrkrDefs::cluskey, std::set<SvtxTrack*> >::iterator find_iter =
1756 return find_iter->second;
1772 for (
const auto& candidate : cluster_keys)
1785 if (cluster_key == candidate)
1787 tracks.insert(track);
1811 for (
const auto& candidate_key : cluster_keys)
1814 std::map<TrkrDefs::cluskey, std::set<SvtxTrack*> >::iterator cliter =
1818 cliter->second.insert(track);
1822 std::set<SvtxTrack*>
tracks;
1823 tracks.insert(track);
1835 TMatrixF localErr(3, 3);
1836 localErr[0][0] = 0.;
1837 localErr[0][1] = 0.;
1838 localErr[0][2] = 0.;
1839 localErr[1][0] = 0.;
1842 localErr[2][0] = 0.;
1847 ROT[0][0] = cos(clusphi);
1848 ROT[0][1] = -sin(clusphi);
1850 ROT[1][0] = sin(clusphi);
1851 ROT[1][1] = cos(clusphi);
1856 TMatrixF ROT_T(3, 3);
1857 ROT_T.Transpose(ROT);
1860 err = ROT * localErr * ROT_T;