From 826925883ab7b4665c0a1ff3416406f9b2280616 Mon Sep 17 00:00:00 2001 From: Richard Bonventre Date: Thu, 29 Feb 2024 15:03:09 -0800 Subject: [PATCH 1/2] Remove tracker position dependency, add wire/straw position info --- inc/TrkStrawHitInfo.hh | 3 +++ inc/TrkStrawHitInfoMC.hh | 4 ++++ src/InfoMCStructHelper.cc | 30 ++++++++++++------------------ src/InfoStructHelper.cc | 18 +++++------------- 4 files changed, 24 insertions(+), 31 deletions(-) diff --git a/inc/TrkStrawHitInfo.hh b/inc/TrkStrawHitInfo.hh index e30d96a..d744832 100644 --- a/inc/TrkStrawHitInfo.hh +++ b/inc/TrkStrawHitInfo.hh @@ -36,6 +36,9 @@ namespace mu2e float rdresid = 0, rdresidmvar = -1.0, rdresidpvar = -1.0; // reference distance residual and associated measurement and parameter variances float wdot = 0; // cosine of the angle between the track and wire XYZVectorF poca; // POCA + float uwirephi = 0; // cylindrical phi around wire of uPOCA + float ustrawdist = 0; // unsigned uDOCA to straw center + float ustrawphi = 0; // cylindrical phi around straw center of uPOCA // not sure if we still want these bool dhit = false; bool dactive = false; diff --git a/inc/TrkStrawHitInfoMC.hh b/inc/TrkStrawHitInfoMC.hh index 72ca31c..c7e4478 100644 --- a/inc/TrkStrawHitInfoMC.hh +++ b/inc/TrkStrawHitInfoMC.hh @@ -26,6 +26,10 @@ namespace mu2e float twdot = -1000.0; // dot product between track and wire directions float tau = -1000.0; // threshold cluster distance to the wire along the perpedicular particle path float cdist = -1000.0; // threshold cluster distance to the wire + float phi = -1000.0; // cylindrical phi around wire of POCA + float lang = -1000.0; // lorentz angle of drift direction from POCA to wire + float strawdoca = -1000.0; // true transverse distance at POCA of the particle to the straw center + float strawphi = -1000.0; // cylindrical phi around straw center of POCA XYZVectorF cpos; // threshold cluster position }; } diff --git a/src/InfoMCStructHelper.cc b/src/InfoMCStructHelper.cc index ac2add5..03c1dbc 100644 --- a/src/InfoMCStructHelper.cc +++ b/src/InfoMCStructHelper.cc @@ -119,8 +119,6 @@ namespace mu2e { } void InfoMCStructHelper::fillHitInfoMC(const KalSeedMC& kseedmc, TrkStrawHitInfoMC& tshinfomc, const TrkStrawHitMC& tshmc) { - const Tracker& tracker = *GeomHandle(); - const SimPartStub& simPart = kseedmc.simParticle(tshmc._spindex); tshinfomc.pdg = simPart._pdg; tshinfomc.startCode = simPart._proc; @@ -134,22 +132,18 @@ namespace mu2e { tshinfomc.edep = tshmc._energySum; tshinfomc.mom = std::sqrt(tshmc._mom.mag2()); tshinfomc.cpos = tshmc._cpos; - - // find the step midpoint - const Straw& straw = tracker.getStraw(tshmc._strawId); - auto mcsep = tshmc._cpos-XYZVectorF(straw.getMidPoint()); - auto wdir = XYZVectorF(straw.getDirection()); - tshinfomc.len = mcsep.Dot(wdir); - auto mdir = tshmc._mom.Unit(); - auto mcperp = mdir.Cross(wdir).Unit(); - double dperp = mcperp.Dot(mcsep); - tshinfomc.twdot = mdir.Dot(wdir); - tshinfomc.dist = fabs(dperp); - auto wperp = wdir.Cross(mcperp); - tshinfomc.tau = mcsep.Dot(wperp); - tshinfomc.cdist = sqrt(tshinfomc.dist*tshinfomc.dist+tshinfomc.tau*tshinfomc.tau); - tshinfomc.ambig = dperp > 0 ? -1 : 1; // follow TrkPoca convention - tshinfomc.doca = -1*dperp; + tshinfomc.len = tshmc._wireLen; + tshinfomc.twdot = tshmc._wireDot; + tshinfomc.doca = tshmc._wireDOCA; + tshinfomc.dist = fabs(tshmc._wireDOCA); + tshinfomc.strawdoca = tshmc._strawDOCA; + tshinfomc.phi = tshmc._wirePhi; + tshinfomc.strawphi = tshmc._strawPhi; + tshinfomc.lang = fabs(fmod(tshmc._wirePhi,M_PI)); + if (tshinfomc.lang > M_PI_2) tshinfomc.lang = M_PI - tshinfomc.lang; + tshinfomc.tau = tshmc._wireTau; + tshinfomc.cdist = sqrt(tshinfomc.doca*tshinfomc.doca+tshinfomc.tau*tshinfomc.tau); + tshinfomc.ambig = tshmc._wireDOCA > 0 ? 1 : -1; } void InfoMCStructHelper::fillAllSimInfos(const KalSeedMC& kseedmc, const PrimaryParticle& primary, std::vector>& all_siminfos, int n_generations, int n_match) { diff --git a/src/InfoStructHelper.cc b/src/InfoStructHelper.cc index 6700cca..fd83063 100644 --- a/src/InfoStructHelper.cc +++ b/src/InfoStructHelper.cc @@ -5,7 +5,6 @@ #include "TrkAna/inc/InfoStructHelper.hh" #include "Offline/RecoDataProducts/inc/TrkStrawHitSeed.hh" #include "KinKal/Trajectory/CentralHelix.hh" -#include "Offline/TrackerGeom/inc/Tracker.hh" #include "Offline/Mu2eKinKal/inc/WireHitState.hh" #include #include @@ -237,10 +236,8 @@ namespace mu2e { std::vector tshinfos; // loop over hits static StrawHitFlag active(StrawHitFlag::active); - const Tracker& tracker = *GeomHandle(); for(std::vector::const_iterator ihit=kseed.hits().begin(); ihit != kseed.hits().end(); ++ihit) { TrkStrawHitInfo tshinfo; - auto const& straw = tracker.getStraw(ihit->strawId()); tshinfo.state = ihit->_ambig; tshinfo.usetot = ihit->_kkshflag.hasAnyProperty(KKSHFlag::tot); @@ -296,16 +293,11 @@ namespace mu2e { tshinfo.rdresidmvar = ihit->_rdresidmvar; tshinfo.rdresidpvar = ihit->_rdresidpvar; - // find nearest segment - auto ikseg = kseed.nearestSegment(ihit->_ptoca); - if(ikseg != kseed.segments().end()){ - auto tdir(ikseg->momentum3().Unit()); - tshinfo.wdot = tdir.Dot(straw.getDirection()); - } - auto const& wiredir = straw.getDirection(); - auto const& mid = straw.getMidPoint(); - auto hpos = mid + wiredir*ihit->_wdist; - tshinfo.poca = XYZVectorF(hpos); + tshinfo.wdot = ihit->_wdot; + tshinfo.poca = ihit->_upoca; + tshinfo.ustrawdist = ihit->_ustrawdist; + tshinfo.ustrawphi = ihit->_ustrawphi; + tshinfo.uwirephi = ihit->_uwirephi; // count correlations with other TSH // OBSOLETE: replace this with a test for KinKal StrawHitClusters From 0aca35cbd216cb72f87687733e2ab815791fbf51 Mon Sep 17 00:00:00 2001 From: Richard Bonventre Date: Fri, 19 Apr 2024 12:25:58 -0500 Subject: [PATCH 2/2] Revert mc lang to match data definition --- inc/TrkStrawHitInfoMC.hh | 2 +- src/InfoMCStructHelper.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/TrkStrawHitInfoMC.hh b/inc/TrkStrawHitInfoMC.hh index c7e4478..b5e1816 100644 --- a/inc/TrkStrawHitInfoMC.hh +++ b/inc/TrkStrawHitInfoMC.hh @@ -27,7 +27,7 @@ namespace mu2e float tau = -1000.0; // threshold cluster distance to the wire along the perpedicular particle path float cdist = -1000.0; // threshold cluster distance to the wire float phi = -1000.0; // cylindrical phi around wire of POCA - float lang = -1000.0; // lorentz angle of drift direction from POCA to wire + float lang = -1000.0; // lorentz angle float strawdoca = -1000.0; // true transverse distance at POCA of the particle to the straw center float strawphi = -1000.0; // cylindrical phi around straw center of POCA XYZVectorF cpos; // threshold cluster position diff --git a/src/InfoMCStructHelper.cc b/src/InfoMCStructHelper.cc index 03c1dbc..86e7679 100644 --- a/src/InfoMCStructHelper.cc +++ b/src/InfoMCStructHelper.cc @@ -141,6 +141,7 @@ namespace mu2e { tshinfomc.strawphi = tshmc._strawPhi; tshinfomc.lang = fabs(fmod(tshmc._wirePhi,M_PI)); if (tshinfomc.lang > M_PI_2) tshinfomc.lang = M_PI - tshinfomc.lang; + tshinfomc.lang = M_PI_2 - tshinfomc.lang; // currently in tshinfo lang is calculated perpendicular to drift direction tshinfomc.tau = tshmc._wireTau; tshinfomc.cdist = sqrt(tshinfomc.doca*tshinfomc.doca+tshinfomc.tau*tshinfomc.tau); tshinfomc.ambig = tshmc._wireDOCA > 0 ? 1 : -1;