Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 33 additions & 9 deletions offline/packages/HFTrackEfficiency/HFTrackEfficiency.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,39 @@ bool HFTrackEfficiency::findTracks(PHCompositeNode *topNode, Decay decay)
m_reco_track_eta[index] = m_dst_track->get_eta();
m_reco_track_phi[index] = m_dst_track->get_phi();
m_reco_track_chi2nDoF[index] = m_dst_track->get_chisq() / m_dst_track->get_ndf();
if (m_dst_track->get_silicon_seed())
{
m_reco_track_silicon_seeds[index] = static_cast<int>(m_dst_track->get_silicon_seed()->size_cluster_keys());
}
else
m_reco_track_silicon_seeds[index] = 0;
m_reco_track_tpc_seeds[index] = 0;

for (auto state_iter = m_dst_track->begin_states();
state_iter != m_dst_track->end_states();
++state_iter)
{
m_reco_track_silicon_seeds[index] = 0;
SvtxTrackState *tstate = state_iter->second;
if (tstate->get_pathlength() != 0) // The first track state is an extrapolation so has no cluster
{
auto stateckey = tstate->get_cluskey();
if (stateckey == TrkrDefs::CLUSKEYMAX)
{
continue;
}
uint8_t id = TrkrDefs::getTrkrId(stateckey);

switch (id)
{
case TrkrDefs::mvtxId:
[[fallthrough]];
case TrkrDefs::inttId:
++m_reco_track_silicon_seeds[index];
break;
case TrkrDefs::tpcId:
++m_reco_track_tpc_seeds[index];
break;
default:
break;
}
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
m_reco_track_tpc_seeds[index] = static_cast<int>(m_dst_track->get_tpc_seed()->size_cluster_keys());

m_min_reco_track_pT = std::min(m_reco_track_pT[index], m_min_reco_track_pT);
m_max_reco_track_pT = std::max(m_reco_track_pT[index], m_max_reco_track_pT);

Expand Down Expand Up @@ -513,8 +537,8 @@ void HFTrackEfficiency::resetBranches()
m_reco_track_phi[iTrack] = std::numeric_limits<float>::quiet_NaN();
m_true_track_PID[iTrack] = std::numeric_limits<float>::quiet_NaN();
m_reco_track_chi2nDoF[iTrack] = std::numeric_limits<float>::quiet_NaN();
m_reco_track_silicon_seeds[iTrack] = 0;
m_reco_track_tpc_seeds[iTrack] = 0;
m_reco_track_silicon_seeds[iTrack] = -1;
m_reco_track_tpc_seeds[iTrack] = -1;
}

m_primary_vtx_x = std::numeric_limits<float>::quiet_NaN();
Expand Down
154 changes: 151 additions & 3 deletions offline/packages/KFParticle_sPHENIX/KFParticle_Tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,14 @@ std::vector<KFParticle> KFParticle_Tools::makeAllDaughterParticles(PHCompositeNo
}
}

if (m_verbosity > 100)
{
printSelectionCheck("MVTX states", m_nMVTXStates, MVTX_states, 5);
printSelectionCheck("INTT states", m_nINTTStates, INTT_states, 5);
printSelectionCheck("TPC states", m_nTPCStates, TPC_states, 100);
printSelectionCheck("TPOT states", m_nTPOTStates, TPOT_states, 5);
}

if (MVTX_states < m_nMVTXStates)
{
continue;
Expand Down Expand Up @@ -460,6 +468,23 @@ int KFParticle_Tools::getTracksFromVertex(PHCompositeNode *topNode, const KFPart
{
goodTrack = true;
}


if (m_verbosity >= 10)
{
printSelectionCheck("This track", "passed", "failed", "the selection", goodTrack);
if (m_verbosity >= 11)
{
printSelectionCheck("Track pT", m_track_min_pt, pt, m_track_max_pt);
printSelectionCheck("Track pT chi^2", 0, ptchi2, m_track_ptchi2);
printSelectionCheck("IP", m_track_ip, min_ip, FLT_MAX);
printSelectionCheck("IP chi^2", m_track_ipchi2, min_ipchi2, FLT_MAX);
printSelectionCheck("IP xy", m_track_ip_xy, min_ip_xy, FLT_MAX);
printSelectionCheck("IP xy chi^2", m_track_ipchi2_xy, min_ipchi2_xy, FLT_MAX);
printSelectionCheck("Track chi^2/nDoF", 0, trackchi2ndof, m_track_chi2ndof);
}
}

return goodTrack;
}

Expand Down Expand Up @@ -513,7 +538,7 @@ std::vector<int> KFParticle_Tools::findAllGoodTracks(const std::vector<KFParticl
return goodTrackIndex;
}

std::vector<std::vector<int>> KFParticle_Tools::findTwoProngs(std::vector<KFParticle> daughterParticles, std::vector<int> goodTrackIndex, int nTracks) const
std::vector<std::vector<int>> KFParticle_Tools::findTwoProngs(std::vector<KFParticle> daughterParticles, std::vector<int> goodTrackIndex, int nTracks)
{
std::vector<std::vector<int>> goodTracksThatMeet;

Expand All @@ -526,6 +551,16 @@ std::vector<std::vector<int>> KFParticle_Tools::findTwoProngs(std::vector<KFPart
float dca = daughterParticles[*i_it].GetDistanceFromParticle(daughterParticles[*j_it]);
float dca_xy = abs(daughterParticles[*i_it].GetDistanceFromParticleXY(daughterParticles[*j_it]));

if (m_verbosity >= 10)
{
printSelectionCheck("This track pair", "passed", "failed", "the DCA selection", (dca <= m_comb_DCA) && (dca_xy <= m_comb_DCA_xy));
if (m_verbosity >= 11)
{
printSelectionCheck("Pair DCA", 0., dca, m_comb_DCA);
printSelectionCheck("Pair DCA xy", 0., dca_xy, m_comb_DCA_xy);
}
}

if (dca <= m_comb_DCA && dca_xy <= m_comb_DCA_xy)
{
KFVertex twoParticleVertex;
Expand All @@ -535,6 +570,16 @@ std::vector<std::vector<int>> KFParticle_Tools::findTwoProngs(std::vector<KFPart
float sv_radial_position = sqrt(pow(twoParticleVertex.GetX(), 2) + pow(twoParticleVertex.GetY(), 2));
std::vector<int> combination = {*i_it, *j_it};

if (nTracks == 2 && m_verbosity >= 10)
{
printSelectionCheck("This track pair", "passed", "failed", "the quality and radius selection", (vertexchi2ndof <= m_vertex_chi2ndof) && (sv_radial_position >= m_min_radial_SV));
if (m_verbosity >= 11)
{
printSelectionCheck("SV chi^2/nDoFA", 0., vertexchi2ndof, m_vertex_chi2ndof);
printSelectionCheck("SV radius", m_min_radial_SV, sv_radial_position, FLT_MAX);
}
}

if (nTracks == 2 && vertexchi2ndof > m_vertex_chi2ndof)
{
continue;
Expand Down Expand Up @@ -581,6 +626,16 @@ std::vector<std::vector<int>> KFParticle_Tools::findNProngs(std::vector<KFPartic
float dca = daughterParticles[i_it].GetDistanceFromParticle(daughterParticles[goodTracksThatMeet[i_prongs][i]]);
float dca_xy = abs(daughterParticles[i_it].GetDistanceFromParticleXY(daughterParticles[goodTracksThatMeet[i_prongs][i]]));

if (m_verbosity >= 10)
{
printSelectionCheck("This track", "combined", "did not combine", "with a SV set", (dca <= m_comb_DCA) && (dca_xy <= m_comb_DCA_xy));
if (m_verbosity >= 11)
{
printSelectionCheck("Pair DCA", 0., dca, m_comb_DCA);
printSelectionCheck("Pair DCA xy", 0., dca_xy, m_comb_DCA_xy);
}
}

if (dca > m_comb_DCA || dca_xy > m_comb_DCA_xy)
{
dcaMet = false;
Expand All @@ -601,6 +656,16 @@ std::vector<std::vector<int>> KFParticle_Tools::findNProngs(std::vector<KFPartic
float vertexchi2ndof = particleVertex.GetChi2() / particleVertex.GetNDF();
float sv_radial_position = sqrt(pow(particleVertex.GetX(), 2) + pow(particleVertex.GetY(), 2));

if ((unsigned int) nRequiredTracks == nProngs && m_verbosity >= 10)
{
printSelectionCheck("This SV combination", "passed", "failed", "the quality and radius selection", (vertexchi2ndof <= m_vertex_chi2ndof) && (sv_radial_position >= m_min_radial_SV));
if (m_verbosity >= 11)
{
printSelectionCheck("SV chi^2/nDoFA", 0., vertexchi2ndof, m_vertex_chi2ndof);
printSelectionCheck("SV radius", m_min_radial_SV, sv_radial_position, FLT_MAX);
}
}

if ((unsigned int) nRequiredTracks == nProngs && vertexchi2ndof > m_vertex_chi2ndof)
{
continue;
Expand Down Expand Up @@ -825,6 +890,12 @@ std::tuple<KFParticle, bool> KFParticle_Tools::buildMother(KFParticle vDaughters
float calculated_dEdx_value = get_dEdx(topNode, vDaughters[i]);
double expected_dEdx_value = get_dEdx_fitValue((Int_t) vDaughters[i].GetQ() * vDaughters[i].GetP(), track_PDG_ID);
bool accept_dEdx = isInRange((1 - m_dEdx_band_width) * expected_dEdx_value, calculated_dEdx_value, (1 + m_dEdx_band_width) * expected_dEdx_value);

if (m_verbosity >= 11)
{
printSelectionCheck("dE/dx check", (1 - m_dEdx_band_width) * expected_dEdx_value, calculated_dEdx_value, (1 + m_dEdx_band_width) * expected_dEdx_value);
}

if (!accept_dEdx)
{
delete[] inputTracks;
Expand Down Expand Up @@ -875,7 +946,9 @@ std::tuple<KFParticle, bool> KFParticle_Tools::buildMother(KFParticle vDaughters
float calculated_mass;
float calculated_mass_err;
mother.GetMass(calculated_mass, calculated_mass_err);
float calculated_pt = mother.GetPt();
float calculated_pt;
float calculated_pt_err;
mother.GetPt(calculated_pt, calculated_pt_err);

float min_mass = isIntermediate ? m_intermediate_mass_range[intermediateNumber].first : m_min_mass;
float max_mass = isIntermediate ? m_intermediate_mass_range[intermediateNumber].second : m_max_mass;
Expand Down Expand Up @@ -909,6 +982,12 @@ std::tuple<KFParticle, bool> KFParticle_Tools::buildMother(KFParticle vDaughters
{
goodCandidate = false;
}

if (m_verbosity >= 11)
{
bool accept = crossings.size() == 1;
printSelectionCheck("", "All tracks are from the same BC", "Tracks are from different BC", "", accept);
}
}

// Check the requirements of an intermediate states against this mother and re-do goodCandidate
Expand All @@ -923,6 +1002,28 @@ std::tuple<KFParticle, bool> KFParticle_Tools::buildMother(KFParticle vDaughters
{
goodCandidate = false;
}

if (m_verbosity >= 10)
{
printSelectionCheck("", "Accepted", "Rejected", "the intermediate selection", goodCandidate);
if (m_verbosity >= 11)
{
printSelectionCheck("Intermediate DIRA", m_intermediate_min_dira[k], intermediate_DIRA, FLT_MAX);
printSelectionCheck("Intermediate FD chi^2", m_intermediate_min_fdchi2[k], intermediate_FDchi2, FLT_MAX);
}
}
}
}

if (m_verbosity >= 10)
{
printSelectionCheck("", "Accepted", "Rejected", "the mother selection", goodCandidate);
if (m_verbosity >= 11)
{
printSelectionCheck("Vertex charge is", "right", "wrong", "", chargeCheck);
printSelectionCheck("Invariant Mass", min_mass, calculated_mass, max_mass);
printSelectionCheck("Mother pT", min_pt, calculated_pt, FLT_MAX);
printSelectionCheck("Mother SV volume", 0., calculateEllipsoidVolume(mother), max_vertex_volume);
}
}
delete[] inputTracks;
Expand Down Expand Up @@ -970,6 +1071,28 @@ void KFParticle_Tools::constrainToVertex(KFParticle &particle, bool &goodCandida
{
goodCandidate = true;
}

if (m_verbosity >= 10)
{
printSelectionCheck("", "Passed", "Failed", "the PV constraint", goodCandidate);
if (m_verbosity >= 11)
{
printSelectionCheck("Mother DIRA", m_dira_min, calculated_dira, m_dira_max);
printSelectionCheck("Mother DIRA xy", m_dira_xy_min, calculated_dira_xy, m_dira_xy_max);
printSelectionCheck("Mother FD chi^2", m_fdchi2, calculated_fdchi2, FLT_MAX);
printSelectionCheck("Mother IP", 0, calculated_ip, m_mother_ip);
printSelectionCheck("Mother IP chi^2", 0., calculated_ipchi2, m_mother_ipchi2);
printSelectionCheck("Mother IP xy", 0., calculated_ip_xy, m_mother_ip_xy);
printSelectionCheck("Mother IP xy chi^2", 0., calculated_ipchi2_xy, m_mother_ipchi2_xy);
printSelectionCheck("Mother Decay Time", m_min_decayTime, calculated_decayTime, m_max_decayTime);
printSelectionCheck("Mother Decay Time Significance", m_mother_min_decay_time_significance, calculated_decay_time_significance, FLT_MAX);
printSelectionCheck("Mother Decay Time xy", m_min_decayTime_xy, calculated_decayTime_xy, m_max_decayTime_xy);
printSelectionCheck("Mother Decay Length", m_min_decayLength, calculated_decayLength, m_max_decayLength);
printSelectionCheck("Mother Decay Length Significance", m_mother_min_decay_length_significance, calculated_decay_length_significance, FLT_MAX);
printSelectionCheck("Mother Decay Length xy", m_min_decayLength_xy, calculated_decayLength_xy, m_max_decayLength_xy);
printSelectionCheck("Mother Decay Length xy Significance", m_mother_min_decay_length_xy_significance, calculated_decay_length_xy_significance, FLT_MAX);
}
}
}

std::tuple<KFParticle, bool> KFParticle_Tools::getCombination(KFParticle vDaughters[], int daughterOrder[], KFParticle vertex, bool constrain_to_vertex, bool isIntermediate, int intermediateNumber, int nTracks, bool constrainMass, float required_vertexID, PHCompositeNode *topNode)
Expand Down Expand Up @@ -1210,7 +1333,10 @@ void KFParticle_Tools::init_dEdx_fits()

if (m_use_local_PID_file)
{
std::cout << PHWHERE << " using local file " << m_local_PID_filename << std::endl;
if (m_verbosity > 4)
{
std::cout << PHWHERE << " using local file " << m_local_PID_filename << std::endl;
}
// new method is independent of charge
filefit->GetObject("pi_band",f_pion_plus);
filefit->GetObject("K_band",f_kaon_plus);
Expand Down Expand Up @@ -1299,3 +1425,25 @@ bool KFParticle_Tools::checkTrackAndVertexMatch(KFParticle vDaughters[], int nTr

return vertexAndTrackMatch;
}

void KFParticle_Tools::printSelectionCheck(const std::string &parameter, float min, float val, float max)
{
std::string trailer = "the " + parameter + " requirement\033[0m";
std::string passOrFail = isInRange(min, val, max) ? "\033[1;" + accept_colour + "mPassed " + trailer
: "\033[1;" + reject_colour + "mFailed " + trailer;
std::cout << passOrFail << ". Lower bound = " << min << ", measured value = " << val << ", upper bound = " << max << std::endl;
}

void KFParticle_Tools::printSelectionCheck(const std::string &start, const std::string &accept, const std::string &reject, const std::string &end, bool equality)
{
std::string decision = equality ? accept : reject;
std::string colour = equality ? accept_colour : reject_colour;
std::string spacing = start.empty() ? "" : " ";
std::cout << "\033[1;" << colour << "m" << start << spacing << decision << " " << end << "\033[0m" << std::endl;
}

void KFParticle_Tools::printSelectionCheck(const std::string &info, unsigned int value)
{
std::string colour = value > 0 ? accept_colour : reject_colour;
std::cout << info << " = \033[1;" << colour << "m" << value << "\033[0m" << std::endl;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
10 changes: 9 additions & 1 deletion offline/packages/KFParticle_sPHENIX/KFParticle_Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class KFParticle_Tools : protected KFParticle_MVA

std::vector<int> findAllGoodTracks(const std::vector<KFParticle> &daughterParticles, const std::vector<KFParticle> &primaryVertices);

std::vector<std::vector<int>> findTwoProngs(std::vector<KFParticle> daughterParticles, std::vector<int> goodTrackIndex, int nTracks) const;
std::vector<std::vector<int>> findTwoProngs(std::vector<KFParticle> daughterParticles, std::vector<int> goodTrackIndex, int nTracks);

std::vector<std::vector<int>> findNProngs(std::vector<KFParticle> daughterParticles,
const std::vector<int> &goodTrackIndex,
Expand Down Expand Up @@ -126,6 +126,8 @@ class KFParticle_Tools : protected KFParticle_MVA
void set_dont_use_global_vertex(bool set_variable) { m_dont_use_global_vertex = set_variable; }

protected:
int m_verbosity = 0;

std::string m_mother_name_Tools;
int m_num_intermediate_states{-1};
std::vector<int> m_num_tracks_from_intermediate;
Expand Down Expand Up @@ -281,6 +283,12 @@ class KFParticle_Tools : protected KFParticle_MVA
void removeDuplicates(std::vector<int> &v);
void removeDuplicates(std::vector<std::vector<int>> &v);
void removeDuplicates(std::vector<std::vector<std::string>> &v);

void printSelectionCheck(const std::string &parameter, float min, float val, float max);
void printSelectionCheck(const std::string &start, const std::string &accept, const std::string &reject, const std::string &end, bool equality);
void printSelectionCheck(const std::string &info, unsigned int value);
std::string accept_colour = "32";
std::string reject_colour = "31";
};

#endif // KFPARTICLESPHENIX_KFPARTICLETOOLS_H
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ void KFParticle_eventReconstruction::createDecay(PHCompositeNode* topNode, std::

std::vector<int> goodTrackIndex = findAllGoodTracks(daughterParticles, primaryVertices);

if (m_verbosity >= 10)
{
printSelectionCheck("Number of daughters passing state selection", daughterParticles.size());
printSelectionCheck("Number of daughters passing track selection", goodTrackIndex.size());
printSelectionCheck("Number of PVs passing selection", primaryVertices.size());
}

if (!m_has_intermediates)
{
buildBasicChain(selectedMother, selectedVertex, selectedDaughters, daughterParticles, goodTrackIndex, primaryVertices, topNode);
Expand All @@ -102,6 +109,11 @@ void KFParticle_eventReconstruction::buildBasicChain(std::vector<KFParticle>& se
goodTracksThatMeet = findNProngs(daughterParticlesBasic, goodTrackIndexBasic, goodTracksThatMeet, m_num_tracks, p);
}

if (m_verbosity >= 10)
{
printSelectionCheck("Number of SVs passing selection", goodTracksThatMeet.size());
}

getCandidateDecay(selectedMotherBasic, selectedVertexBasic, selectedDaughtersBasic, daughterParticlesBasic,
goodTracksThatMeet, primaryVerticesBasic, 0, m_num_tracks, false, 0, true, topNode);
}
Expand Down Expand Up @@ -136,6 +148,12 @@ void KFParticle_eventReconstruction::buildChain(std::vector<KFParticle>& selecte
goodTracksThatMeet,
m_num_tracks_from_intermediate[i], p);
}

if (m_verbosity >= 10)
{
printSelectionCheck("Number of SVs passing selection", goodTracksThatMeet.size());
}

getCandidateDecay(potentialIntermediates[i], vertices, potentialDaughters[i], daughterParticlesAdv,
goodTracksThatMeet, primaryVerticesAdv, track_start, track_stop, true, i, m_constrain_int_mass, topNode);
track_start += track_stop;
Expand Down
6 changes: 3 additions & 3 deletions offline/packages/KFParticle_sPHENIX/KFParticle_nTuple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ void KFParticle_nTuple::initializeBranches(PHCompositeNode* topNode)

m_tree->Branch("runNumber", &m_runNumber, "runNumber/I");
m_tree->Branch("eventNumber", &m_evtNumber, "eventNumber/I");
m_tree->Branch("event_bco", &m_event_bco, "event_bco/L"); //adding for the current event BCO, not shifted
m_tree->Branch("BCO", &m_bco, "BCO/L"); //already there, this is shifted BCO
m_tree->Branch("last_event_bco", &m_last_event_bco, "last_event_bco/L"); //BCO for the last event
m_tree->Branch("Collision_BCO", &m_bco, "Collision_BCO/L"); //already there, this is shifted BCO
m_tree->Branch("GL1_BCO", &m_event_bco, "GL1_BCO/L"); //adding for the current event BCO, not shifted
m_tree->Branch("last_GL1_BCO", &m_last_event_bco, "last_GL1_BCO/L"); //BCO for the last event

if (m_get_trigger_info)
{
Expand Down
Loading