32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
35 #pragma GCC diagnostic pop
56 template<
class T>
inline constexpr
T square(
const T&
x ) {
return x*
x; }
64 return phi - 2. * M_PI;
65 else if (phi <= -M_PI)
66 return phi + 2.* M_PI;
73 inline constexpr
double get_sector_phi(
int isec )
74 {
return isec*M_PI/6; }
77 static const std::vector<float> phi_rec = { get_sector_phi(9) };
78 static const std::vector<float> z_rec = { 5. };
83 std::vector<TrkrDefs::cluskey>
out;
87 { std::copy(
seed->begin_cluster_keys(),
seed->end_cluster_keys(), std::back_inserter( out ) ); }
94 int count_clusters(
const std::vector<TrkrDefs::cluskey>& keys )
96 return std::count_if( keys.begin(), keys.end(),
113 std::cout <<
"PHTpcResiduals::Init - m_maxTAlpha: " <<
m_maxTAlpha << std::endl;
114 std::cout <<
"PHTpcResiduals::Init - m_maxTBeta: " <<
m_maxTBeta << std::endl;
115 std::cout <<
"PHTpcResiduals::Init - m_maxResidualDrphi: " <<
m_maxResidualDrphi <<
" cm" << std::endl;
116 std::cout <<
"PHTpcResiduals::Init - m_maxResidualDz: " <<
m_maxResidualDz <<
" cm" << std::endl;
117 std::cout <<
"PHTpcResiduals::Init - m_minPt: " <<
m_minPt <<
" GeV/c" << std::endl;
153 std::cout <<
"PHTpcResiduals::End - writing matrices to " <<
m_outputfile << std::endl;
158 std::unique_ptr<TFile> outputfile( TFile::Open(
m_outputfile.c_str(),
"RECREATE" ) );
165 <<
"PHTpcResiduals::End -"
172 <<
"PHTpcResiduals::End -"
186 { std::cout <<
"PHTpcResiduals::processTracks - proto track size " <<
m_trackMap->
size() <<std::endl; }
188 for(
const auto &[trackKey, track] : *
m_trackMap)
191 { std::cout <<
"PHTpcResiduals::processTracks - Processing track key " << trackKey << std::endl; }
208 { std::cout <<
"PHTpcResiduals::checkTrack - pt: " << track->
get_pt() << std::endl; }
215 if( count_clusters<TrkrDefs::mvtxId>(cluster_keys) < 2 )
return false;
216 if( count_clusters<TrkrDefs::inttId>(cluster_keys) < 2 )
return false;
217 if(
m_useMicromegas && count_clusters<TrkrDefs::micromegasId>(cluster_keys) < 2 )
return false;
231 double p = track->
get_p();
241 const auto perigee = Acts::Surface::makeShared<Acts::PerigeeSurface>(
position);
256 std::cout <<
"PHTpcResiduals::processTrack -"
257 <<
" track momentum: " << track->
get_p()
258 <<
" position: (" << track->
get_x() <<
", " << track->
get_y() <<
", " << track->
get_z() <<
")"
288 std::cout <<
"Starting track params position/momentum: "
292 <<
"Track params phi/eta "
293 << std::atan2(trackParams.momentum().y(),
294 trackParams.momentum().x())
296 << std::atanh(trackParams.momentum().z()/trackParams.momentum().norm())
304 auto& [
pathLength, trackStateParams] = result.value();
309 std::cout <<
"PHTpcResiduals::processTrack -"
311 <<
" track momentum : "
312 << trackParams.momentum()
313 <<
" propagator momentum : "
314 << trackStateParams.momentum()
324 const double clusR =
get_r(globClusPos(0),globClusPos(1));
325 const double clusPhi = std::atan2(globClusPos(1), globClusPos(0));
326 const double clusZ = globClusPos(2);
329 double clusRPhiErr = 0;
332 clusRPhiErr = cluster->getRPhiError();
333 clusZErr = cluster->getZError();
338 std::cout <<
"PHTpcResiduals::processTrack -"
340 <<
" clusR: " << clusR
341 <<
" clusPhi: " << clusPhi <<
"+/-" << clusRPhiErr
342 <<
" clusZ: " << clusZ <<
"+/-" << clusZErr
352 const auto globalStateMom = trackStateParams.momentum();
353 const auto globalStateCov = *trackStateParams.covariance();
362 const double trackR = std::sqrt(
square(globStateX) +
square(globStateY));
364 const double dr = clusR - trackR;
365 const double trackDrDt = (globStateX * globalStateMom(0) + globStateY * globalStateMom(1)) / trackR;
366 const double trackDxDr = globalStateMom(0) / trackDrDt;
367 const double trackDyDr = globalStateMom(1) / trackDrDt;
368 const double trackDzDr = globalStateMom(2) / trackDrDt;
370 const double trackX = globStateX + dr * trackDxDr;
371 const double trackY = globStateY + dr * trackDyDr;
372 const double trackZ = globStateZ + dr * trackDzDr;
373 const double trackPhi = std::atan2(trackY, trackX);
377 std::cout <<
"PHTpcResiduals::processTrack -"
378 <<
" trackR: " << trackR
380 <<
" trackDrDt: " << trackDrDt
381 <<
" trackDxDr: " << trackDxDr
382 <<
" trackDyDr: " << trackDyDr
383 <<
" trackDzDr: " << trackDzDr
384 <<
" trackPhi: " << trackPhi <<
"+/-" << trackRPhiErr
385 <<
" track position: (" << trackX <<
", " << trackY <<
", " << trackZ <<
")"
389 const double erp =
square(clusRPhiErr) +
square(trackRPhiErr);
393 const double drphi = clusR *
deltaPhi(clusPhi - trackPhi);
394 const double dz = clusZ - trackZ;
398 std::cout <<
"PHTpcResiduals::processTrack -"
399 <<
" drphi: " << drphi
404 const double trackPPhi = -trackStateParams.momentum()(0) * std::sin(trackPhi) + trackStateParams.momentum()(1) * std::cos(trackPhi);
405 const double trackPR = trackStateParams.momentum()(0) * std::cos(trackPhi) + trackStateParams.momentum()(1) * std::sin(trackPhi);
406 const double trackPZ = trackStateParams.momentum()(2);
408 const double trackAlpha = -trackPPhi / trackPR;
409 const double trackBeta = -trackPZ / trackPR;
414 <<
"PHTpcResiduals::processTrack -"
415 <<
" trackPPhi: " << trackPPhi
416 <<
" trackPR: " << trackPR
417 <<
" trackPZ: " << trackPZ
418 <<
" trackAlpha: " << trackAlpha
419 <<
" trackBeta: " << trackBeta
426 { std::cout <<
"Bin index found is " <<
index << std::endl; }
428 if(
index < 0 )
continue;
433 std::cout <<
"PHTpcResiduals::processTrack -"
434 <<
" cluster: (" << clusR <<
", " << clusR*clusPhi <<
", " << clusZ <<
")"
435 <<
" (" << clusRPhiErr <<
", " << clusZErr <<
")"
438 std::cout <<
"PHTpcResiduals::processTrack -"
439 <<
" track: (" << trackR <<
", " << clusR*trackPhi <<
", " << trackZ <<
")"
440 <<
" (" << trackAlpha <<
", " << trackBeta <<
")"
441 <<
" (" << trackRPhiErr <<
", " << trackZErr <<
")"
443 std::cout << std::endl;
503 for (
int i = 0;
i < 6; ++
i)
504 for (
int j = 0;
j < 6; ++
j)
523 float phi = std::atan2(
loc(1),
loc(0));
524 while( phi <
m_phiMin ) phi += 2.*M_PI;
525 while( phi >=
m_phiMax ) phi -= 2.*M_PI;
530 if( r < m_rMin || r >=
m_rMax )
return -1;
534 const auto z =
loc(2);
535 if( z < m_zMin || z >=
m_zMax )
return -1;
550 m_clusterContainer = findNode::getClass<TrkrClusterContainer>(topNode,
"TRKR_CLUSTER");
553 std::cout <<
PHWHERE <<
"No TRKR_CLUSTER node on node tree. Exiting." << std::endl;
557 m_tGeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
560 std::cout <<
"ActsTrackingGeometry not on node tree. Exiting." << std::endl;
564 m_trackMap = findNode::getClass<SvtxTrackMap>(topNode,
"SvtxSiliconMMTrackMap");
567 std::cout <<
PHWHERE <<
"SvtxSiliconMMTrackMap not on node tree. Exiting." << std::endl;
572 m_dcc_static = findNode::getClass<TpcDistortionCorrectionContainer>(topNode,
"TpcDistortionCorrectionContainerStatic");
573 m_dcc_average = findNode::getClass<TpcDistortionCorrectionContainer>(topNode,
"TpcDistortionCorrectionContainerAverage");
574 m_dcc_fluctuation = findNode::getClass<TpcDistortionCorrectionContainer>(topNode,
"TpcDistortionCorrectionContainerFluctuation");
609 return globalPosition;