10 #include <KFParticle.h>
26 : m_has_intermediates_nTuple(
false)
27 , m_constrain_to_vertex_nTuple(
false)
28 , m_get_all_PVs(
false)
29 , m_truth_matching(
false)
30 , m_detector_info(
false)
32 , m_use_intermediate_name(
true)
33 , m_get_charge_conjugate_nTuple(
true)
46 m_tree =
new TTree(
"DecayTree",
"DecayTree");
50 std::string mother_name;
52 mother_name =
"mother";
57 std::string undrscr =
"_";
58 std::string nothing =
"";
59 std::map<std::string, std::string> forbiddenStrings;
60 forbiddenStrings[
"/"] = undrscr;
61 forbiddenStrings[
"("] = undrscr;
62 forbiddenStrings[
")"] = nothing;
63 forbiddenStrings[
"+"] =
"plus";
64 forbiddenStrings[
"-"] =
"minus";
65 forbiddenStrings[
"*"] =
"star";
66 for (
auto const& [badString, goodString] : forbiddenStrings)
68 while ((pos = mother_name.find(badString)) != std::string::npos) mother_name.replace(pos, 1, goodString);
113 std::vector<std::string> intermediateNameMapping;
118 std::string intermediate_name;
125 for (
auto const& [badString, goodString] : forbiddenStrings)
127 while ((pos = intermediate_name.find(badString)) != std::string::npos) intermediate_name.replace(pos, 1, goodString);
174 intermediateNameMapping.push_back(intermediate_name +
"_");
179 int num_intermediate_tracks = 0;
240 std::string dca_leaf_name = dca_branch_name +
"/F";
266 m_tree->Branch(
"secondary_vertex_mass_pionPID", &
m_sv_mass,
"secondary_vertex_mass_pionPID/F");
268 m_tree->Branch(
"nPrimaryVertices", &
m_nPVs,
"nPrimaryVertices/I");
276 KFParticle motherParticle,
278 std::vector<KFParticle> daughters,
279 std::vector<KFParticle> intermediates,
280 int nPVs,
int multiplicity)
282 const float speedOfLight = 2.99792458e-1;
285 KFParticle* daughterArray = &daughters[0];
287 bool switchTrackPosition;
289 int num_tracks_used_by_intermediates = 0;
294 for (
int j = i + 1; j < m_num_tracks_from_intermediate_nTuple[
k]; ++j)
296 int particleAElement = i + num_tracks_used_by_intermediates;
297 int particleBElement = j + num_tracks_used_by_intermediates;
298 int particleAPID = daughterArray[particleAElement].GetPDG();
299 int particleBPID = daughterArray[particleBElement].GetPDG();
303 float daughterA_mass = 0, daughterB_mass = 0;
304 for (
const auto& key : particleMasses_nTuple)
306 if (key.second.first ==
abs(particleAPID))
307 daughterA_mass = key.second.second;
308 if (key.second.first ==
abs(particleBPID))
309 daughterB_mass = key.second.second;
311 switchTrackPosition = daughterA_mass > daughterB_mass;
314 switchTrackPosition = particleAPID > particleBPID;
315 if (switchTrackPosition)
317 temp = daughterArray[particleAElement];
318 daughterArray[particleAElement] = daughterArray[particleBElement];
319 daughterArray[particleBElement] = temp;
323 num_tracks_used_by_intermediates += m_num_tracks_from_intermediate_nTuple[
k];
328 for (
int i = 0; i < num_remaining_tracks; i++)
330 for (
int j = i + 1; j < num_remaining_tracks; j++)
332 int particleAElement = i + num_tracks_used_by_intermediates;
333 int particleBElement = j + num_tracks_used_by_intermediates;
334 int particleAPID = daughterArray[particleAElement].GetPDG();
335 int particleBPID = daughterArray[particleBElement].GetPDG();
339 float daughterA_mass = 0, daughterB_mass = 0;
340 for (
const auto& key : particleMasses_nTuple)
342 if (key.second.first ==
abs(particleAPID))
343 daughterA_mass = key.second.second;
344 if (key.second.first ==
abs(particleBPID))
345 daughterB_mass = key.second.second;
347 switchTrackPosition = daughterA_mass > daughterB_mass;
350 switchTrackPosition = particleAPID > particleBPID;
351 if (switchTrackPosition)
353 temp = daughterArray[particleAElement];
354 daughterArray[particleAElement] = daughterArray[particleBElement];
355 daughterArray[particleBElement] = temp;
394 KFParticle* intermediateArray = &intermediates[0];
433 intermediateArray[i].SetProductionVertex(motherParticle);
491 for (
int k = 0;
k < num_remaining_tracks;
k++)
502 m_daughter_dca[iter] = daughterArray[i].GetDistanceFromParticle(daughterArray[j]);
508 std::vector<KFParticle> sortedDaughterVector;
509 for (
int i = 0; i <
m_num_tracks_nTuple; ++i) sortedDaughterVector.push_back(daughterArray[i]);
510 allPVInfo(topNode,
m_tree, motherParticle, sortedDaughterVector, intermediates);
515 motherParticle.SetProductionVertex(vertex);
545 EventHeaderv1* evtHeader = findNode::getClass<EventHeaderv1>(topNode,
"EventHeader");
561 KFParticle mother_noPID;
562 KFParticle* daughterArray = &kfp_daughters[0];
566 KFParticle daughter_noPID;
567 float f_trackParameters[6], f_trackCovariance[21];
568 for (
int j = 0; j < 6; ++j) f_trackParameters[j] = daughterArray[i].GetParameter(j);
569 for (
int j = 0; j < 21; ++j) f_trackCovariance[j] = daughterArray[i].GetCovariance(j);
570 daughter_noPID.Create(f_trackParameters, f_trackCovariance, daughterArray[i].
Q(), -1);
571 mother_noPID.AddDaughter(daughter_noPID);
574 return mother_noPID.GetMass();