Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement in charge calculation in trackseeding #1281

Merged
merged 13 commits into from
Feb 21, 2024
32 changes: 13 additions & 19 deletions src/algorithms/tracking/TrackSeeding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "TrackSeeding.h"

#include "TVector2.h"
Jeet-bhai marked this conversation as resolved.
Show resolved Hide resolved
#include <Acts/Definitions/Algebra.hpp>
#include <Acts/Seeding/Seed.hpp>
#include <Acts/Seeding/SeedConfirmationRangeConfig.hpp>
Expand Down Expand Up @@ -188,15 +189,12 @@ std::unique_ptr<edm4eic::TrackParametersCollection> eicrecon::TrackSeeding::make
auto slopeZ0 = lineFit(rzHitPositions);
const auto xypos = findPCA(RX0Y0);

//Determine charge
std::vector<std::pair<float,float>> xyrelPos;
auto xpos = xypos.first;
auto ypos = xypos.second;
veprbl marked this conversation as resolved.
Show resolved Hide resolved

for ( const auto& spptr : seed.sp() )
{
xyrelPos.emplace_back(spptr->x()-xypos.first, spptr->y()-xypos.second);
}
//Determine charge

int charge = determineCharge(xyrelPos);
int charge = determineCharge(xyHitPositions, X0, Y0, xpos, ypos);
Jeet-bhai marked this conversation as resolved.
Show resolved Hide resolved

float theta = atan(1./std::get<0>(slopeZ0));
// normalize to 0<theta<pi
Expand All @@ -208,9 +206,6 @@ std::unique_ptr<edm4eic::TrackParametersCollection> eicrecon::TrackSeeding::make
float qOverP = charge / p;

//Calculate phi at xypos
auto xpos = xypos.first;
auto ypos = xypos.second;

auto vxpos = -1.*charge*(ypos-Y0);
auto vypos = charge*(xpos-X0);

Expand Down Expand Up @@ -276,19 +271,18 @@ std::pair<float, float> eicrecon::TrackSeeding::findPCA(std::tuple<float,float,f
return std::make_pair(xmin,ymin);
}

int eicrecon::TrackSeeding::determineCharge(std::vector<std::pair<float,float>>& positions) const
int eicrecon::TrackSeeding::determineCharge(std::vector<std::pair<float,float>>& positions, float X0, float Y0, float xpos, float ypos) const
{
// determine the charge by the bend angle of the first two hits
int charge = 1;
const auto& firstpos = positions.at(0);
const auto& secondpos = positions.at(1);

const auto firstphi = atan2(firstpos.second, firstpos.first);
const auto secondphi = atan2(secondpos.second, secondpos.first);
auto dphi = secondphi - firstphi;
if(dphi > M_PI) dphi -= 2.*M_PI;
if(dphi < -M_PI) dphi += 2*M_PI;
if(dphi < 0) charge = -1;

TVector2 radial_vector( (X0-xpos), (Y0-ypos) );
TVector2 first_hit_vector(firstpos.first-xpos,firstpos.second-ypos);

auto del_phi = first_hit_vector.DeltaPhi(radial_vector);
Jeet-bhai marked this conversation as resolved.
Show resolved Hide resolved

if (del_phi > 0) charge = -1;

return charge;
}
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/tracking/TrackSeeding.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace eicrecon {
Acts::SeedFinderOptions m_seedFinderOptions;
Acts::SeedFinderOrthogonalConfig<SpacePoint> m_seedFinderConfig;

int determineCharge(std::vector<std::pair<float,float>>& positions) const;
int determineCharge(std::vector<std::pair<float,float>>& positions, float X0, float Y0, float xpos, float ypos) const;
std::pair<float,float> findPCA(std::tuple<float,float,float>& circleParams) const;
std::vector<const eicrecon::SpacePoint*> getSpacePoints(const edm4eic::TrackerHitCollection& trk_hits);
std::unique_ptr<edm4eic::TrackParametersCollection> makeTrackParams(SeedContainer& seeds);
Expand Down
Loading