15 #include <analysis/modules/DuplicateVertexMarker/DuplicateVertexMarkerModule.h>
17 #include <analysis/dataobjects/Particle.h>
18 #include <analysis/dataobjects/ParticleList.h>
20 #include <framework/datastore/StoreObjPtr.h>
21 #include <framework/logging/Logger.h>
35 setDescription(
"Identify duplicate vertices (distinct particles, but built from the same daughters) and mark the one with best chi2. Only works if the particle has exactly two daughters. Mainly used to deal when merging V0 vertices with hand-built ones.");
36 setPropertyFlags(c_ParallelProcessingCertified);
39 addParam(
"particleList", m_particleList,
"Input ParticleList name");
40 addParam(
"extraInfoName", m_extraInfoName,
41 "Extra-info field added to all particles in the input list. 1 for the best vertex, 0 for lower ranked ones.",
42 string(
"highQualityVertex"));
43 addParam(
"prioritiseV0", m_prioritiseV0,
44 "If a vertex is a V0, select it over its duplicate even if chi2 is worse.",
48 void DuplicateVertexMarkerModule::initialize()
53 m_targetVar = manager.getVariable(
"chiProb");
54 if (m_targetVar ==
nullptr) {
55 B2ERROR(
"DuplicateVertexMarker: Variable::Manager doesn't have variable chiProb");
59 void DuplicateVertexMarkerModule::event()
65 const int size = inPList->getListSize();
66 for (
int i = 0; i < size; i++) {
67 Particle* part = inPList->getParticle(i);
68 if (part->getNDaughters() != 2) {
69 B2WARNING(
"Vertex does not have exactly 2 daughters! SKIP.");
72 if (part->hasExtraInfo(
74 B2DEBUG(10,
"Extra Info with given name is already set!");
77 for (
int j = 0; j < size; j++) {
78 Particle* cloneCand = inPList->getParticle(j);
79 bool particleFight =
false;
81 if (part == cloneCand)
continue;
83 B2DEBUG(10,
"part has daughters (" << part->getDaughter(0)->getTrack() <<
") and (" << part->getDaughter(1)->getTrack() <<
")");
96 bool partNotV0 = part->hasExtraInfo(
"decayModeID");
97 bool cloneNotV0 = cloneCand->
hasExtraInfo(
"decayModeID");
98 if (partNotV0 != cloneNotV0) {
99 (partNotV0) ? (part->addExtraInfo(m_extraInfoName, 0.0)) : (cloneCand->
addExtraInfo(m_extraInfoName, 0.0));
101 B2DEBUG(10,
"V0: Discarding Particle.");
102 }
else B2DEBUG(10,
"V0: Discarding Clone");
105 if (!(part->hasExtraInfo(m_extraInfoName) || cloneCand->
hasExtraInfo(m_extraInfoName))) {
107 B2DEBUG(10, m_targetVar->function(part) <<
" vs " << m_targetVar->function(cloneCand));
108 if (m_targetVar->function(part) > m_targetVar->function(cloneCand)) {
111 part->addExtraInfo(m_extraInfoName, 0.0);
117 if (!(part->hasExtraInfo(m_extraInfoName))) {
118 part->addExtraInfo(m_extraInfoName, 1.0);