Skip to content

Commit

Permalink
Merge pull request #125 from bonventre/wireoffsets
Browse files Browse the repository at this point in the history
Remove tracker position dependency, add wire/straw position info
  • Loading branch information
AndrewEdmonds11 authored May 21, 2024
2 parents c2fc70b + 0aca35c commit d2538c2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 31 deletions.
3 changes: 3 additions & 0 deletions inc/TrkStrawHitInfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions inc/TrkStrawHitInfoMC.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
};
}
Expand Down
31 changes: 13 additions & 18 deletions src/InfoMCStructHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ namespace mu2e {
}

void InfoMCStructHelper::fillHitInfoMC(const KalSeedMC& kseedmc, TrkStrawHitInfoMC& tshinfomc, const TrkStrawHitMC& tshmc) {
const Tracker& tracker = *GeomHandle<Tracker>();

const SimPartStub& simPart = kseedmc.simParticle(tshmc._spindex);
tshinfomc.pdg = simPart._pdg;
tshinfomc.startCode = simPart._proc;
Expand All @@ -134,22 +132,19 @@ 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.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;
}

void InfoMCStructHelper::fillAllSimInfos(const KalSeedMC& kseedmc, const PrimaryParticle& primary, std::vector<std::vector<SimInfo>>& all_siminfos, int n_generations, int n_match) {
Expand Down
18 changes: 5 additions & 13 deletions src/InfoStructHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cmath>
#include <limits>
Expand Down Expand Up @@ -241,10 +240,8 @@ namespace mu2e {
std::vector<TrkStrawHitInfo> tshinfos;
// loop over hits
static StrawHitFlag active(StrawHitFlag::active);
const Tracker& tracker = *GeomHandle<Tracker>();
for(std::vector<TrkStrawHitSeed>::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);
Expand Down Expand Up @@ -300,16 +297,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
Expand Down

0 comments on commit d2538c2

Please sign in to comment.