9#include <analysis/modules/InclusiveBtagReconstruction/InclusiveBtagReconstructionModule.h>
11#include <analysis/DecayDescriptor/ParticleListName.h>
13#include <unordered_set>
16#include <Math/Vector4D.h>
35 addParam(
"upsilonListName",
m_upsilonListName,
"Name of the ParticleList to be filled with Upsilon(4S) -> B:sig anti-B:tag",
36 std::string(
"Upsilon(4S)"));
39 addParam(
"inputListsNames",
m_inputListsNames,
"List of names of the ParticleLists which are used to reconstruct Btag from");
50 inputList.isRequired();
77 const unsigned int n =
m_bsigList->getListSize();
78 for (
unsigned i = 0; i < n; i++) {
81 std::unordered_set<int> mdstSourcesOfBsigFinalStateDaughters;
82 std::map<int, std::vector<int>> btagDaughtersMap;
84 for (
const Particle* daughter : bsigFinalStateDaughters) {
85 mdstSourcesOfBsigFinalStateDaughters.insert(daughter->getMdstSource());
87 auto mdstSourcesEnd = mdstSourcesOfBsigFinalStateDaughters.end();
92 const unsigned int m = inputList->getListSize();
93 for (
unsigned j = 0; j < m; j++) {
94 const Particle* particle = inputList->getParticle(j);
98 for (
const Particle* daughter : particleFinalStateDaughters) {
99 int mdstSource = daughter->getMdstSource();
100 if (mdstSourcesOfBsigFinalStateDaughters.find(mdstSource) != mdstSourcesEnd) {
103 auto it = btagDaughtersMap.find(mdstSource);
104 if (it != btagDaughtersMap.end()) {
115 std::vector<std::vector<int>> btagCandidates;
116 map2vector.
convert(btagDaughtersMap, btagCandidates);
118 for (std::vector<int> daughterIndices : btagCandidates) {
119 std::map<int, size_t> nonFinalStateIndicesCount;
120 ROOT::Math::PxPyPzEVector momentum;
121 for (
int index : daughterIndices) {
123 if ((
m_particles[index]->getFinalStateDaughters()).size() > 1) {
124 auto it = nonFinalStateIndicesCount.find(index);
125 if (it != nonFinalStateIndicesCount.end()) {
126 nonFinalStateIndicesCount[index]++;
129 nonFinalStateIndicesCount[index] = 1;
135 bool rightDaughtersCount =
true;
136 for (
auto& it : nonFinalStateIndicesCount) {
137 if (it.second != (
m_particles[(it.first)]->getFinalStateDaughters()).size()) {
138 rightDaughtersCount =
false;
142 if (rightDaughtersCount ==
false) {
147 std::vector<int>::iterator it;
148 std::sort(daughterIndices.begin(), daughterIndices.end());
149 it = std::unique(daughterIndices.begin(), daughterIndices.end());
150 daughterIndices.resize(std::distance(daughterIndices.begin(), it));
165 makeEntries(input.begin(), input.end(), 0, output);
169 const std::map<
int, std::vector<int>>::const_iterator& end,
170 unsigned i, std::vector<std::vector<int>>& output)
172 if (positionOnTheMap == end) {
175 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.
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.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
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.