9#include <analysis/modules/InclusiveBtagReconstruction/InclusiveBtagReconstructionModule.h>
11#include <analysis/DecayDescriptor/ParticleListName.h>
13#include <unordered_set>
16#include <Math/Vector4D.h>
36 addParam(
"upsilonListName",
m_upsilonListName,
"Name of the ParticleList to be filled with Upsilon(4S) -> B:sig anti-B:tag",
37 std::string(
"Upsilon(4S)"));
40 addParam(
"inputListsNames",
m_inputListsNames,
"List of names of the ParticleLists which are used to reconstruct Btag from");
51 inputList.isRequired();
78 const unsigned int n =
m_bsigList->getListSize();
79 for (
unsigned i = 0; i < n; i++) {
82 std::unordered_set<int> mdstSourcesOfBsigFinalStateDaughters;
83 std::map<int, std::vector<int>> btagDaughtersMap;
85 for (
const Particle* daughter : bsigFinalStateDaughters) {
86 mdstSourcesOfBsigFinalStateDaughters.insert(daughter->getMdstSource());
88 auto mdstSourcesEnd = mdstSourcesOfBsigFinalStateDaughters.end();
93 const unsigned int m = inputList->getListSize();
94 for (
unsigned j = 0; j < m; j++) {
95 const Particle* particle = inputList->getParticle(j);
96 const std::vector<const Particle*>& particleFinalStateDaughters = particle->getFinalStateDaughters();
99 for (
const Particle* daughter : particleFinalStateDaughters) {
100 int mdstSource = daughter->getMdstSource();
101 if (mdstSourcesOfBsigFinalStateDaughters.find(mdstSource) != mdstSourcesEnd) {
104 auto it = btagDaughtersMap.find(mdstSource);
105 if (it != btagDaughtersMap.end()) {
106 it->second.push_back(particle->getArrayIndex());
108 btagDaughtersMap[mdstSource] = {particle->getArrayIndex()};
116 std::vector<std::vector<int>> btagCandidates;
117 map2vector.
convert(btagDaughtersMap, btagCandidates);
119 for (std::vector<int> daughterIndices : btagCandidates) {
120 std::map<int, size_t> nonFinalStateIndicesCount;
121 ROOT::Math::PxPyPzEVector momentum;
122 for (
int index : daughterIndices) {
124 if ((
m_particles[index]->getFinalStateDaughters()).size() > 1) {
125 auto it = nonFinalStateIndicesCount.find(index);
126 if (it != nonFinalStateIndicesCount.end()) {
127 nonFinalStateIndicesCount[index]++;
130 nonFinalStateIndicesCount[index] = 1;
136 bool rightDaughtersCount =
true;
137 for (
auto& it : nonFinalStateIndicesCount) {
138 if (it.second != (
m_particles[(it.first)]->getFinalStateDaughters()).size()) {
139 rightDaughtersCount =
false;
143 if (rightDaughtersCount ==
false) {
148 std::vector<int>::iterator it;
149 std::sort(daughterIndices.begin(), daughterIndices.end());
150 it = std::unique(daughterIndices.begin(), daughterIndices.end());
151 daughterIndices.resize(std::distance(daughterIndices.begin(), it));
166 makeEntries(input.begin(), input.end(), 0, output);
170 const std::map<
int, std::vector<int>>::const_iterator& end,
171 unsigned i, std::vector<std::vector<int>>& output)
173 if (positionOnTheMap == end) {
176 std::vector<int>& v = positionOnTheMap->second;
Represents a particle in the DecayDescriptor.
int getPDGCode() const
Return PDG code.
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
const DecayDescriptorParticle * getMother() const
return mother.
virtual void initialize() override
initialize the module (setup the data store)
virtual void event() override
process event
StoreObjPtr< ParticleList > m_btagList
particle list of tag B
StoreArray< Particle > m_particles
StoreArray of Particles.
virtual ~InclusiveBtagReconstructionModule()
Destructor.
StoreObjPtr< ParticleList > m_upsilonList
particle list of Y(4S)
std::vector< std::string > m_inputListsNames
Names of the ParticleLists to be used to reconstruct Btag.
StoreObjPtr< ParticleList > m_bsigList
particle list of signal B
DecayDescriptor m_decaydescriptor
Decay descriptor for parsing the user specified DecayString.
std::string m_upsilonListName
Name of the ParticleList to be filled with Upsilon(4S) -> B:sig anti-B:tag
std::string m_bsigListName
Name of the Bsig ParticleList.
std::string m_btagListName
Name of the Btag ParticleList.
StoreObjPtr< ParticleList > m_antiBtagList
particle list of tag anti-B
InclusiveBtagReconstructionModule()
Constructor.
Helper class to make a vector of all possible combinations of int numbers contained in the input vect...
void convert(std::map< int, std::vector< int > > &input, std::vector< std::vector< int > > &output)
Do the conversion using makeEntries().
void makeEntries(std::map< int, std::vector< int > >::iterator positionOnTheMap, const std::map< int, std::vector< int > >::const_iterator &end, unsigned i, std::vector< std::vector< int > > &output)
Recursively iterates over a map until the end is reached, then the output is ready.
std::vector< int > m_combination
Vector containing current combination of numbers (e.g.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Class to store reconstructed particles.
std::vector< const Belle2::Particle * > getFinalStateDaughters() const
Returns a vector of pointers to Final State daughter particles.
EFlavorType getFlavorType() const
Returns flavor type of the decay (for FS particles: flavor type of particle)
int getPDGCode(void) const
Returns PDG code.
TClonesArray * getArrayPointer() const
Returns the pointer to the store array which holds the daughter particles.
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
@ c_Unflavored
Is its own antiparticle or we don't know whether it is a particle/antiparticle.
T * appendNew()
Construct a new T object at the end of the array.
Type-safe access to single objects in the data store.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
std::string antiParticleListName(const std::string &listName)
Returns name of anti-particle-list corresponding to listName.
Abstract base class for different kinds of events.