9#include <analysis/modules/RestOfEventUpdater/RestOfEventUpdaterModule.h>
11#include <framework/datastore/StoreArray.h>
12#include <framework/datastore/StoreObjPtr.h>
14#include <analysis/dataobjects/RestOfEvent.h>
15#include <analysis/dataobjects/Particle.h>
17#include <framework/logging/Logger.h>
35 setDescription(
"Updates an existing mask (map of boolean values) for tracks or eclClusters in RestOfEvent with an available property (e.g. after performing training).");
39 std::vector<std::string> emptyMaskVector;
40 std::string emptyCutString;
42 addParam(
"particleList",
m_inputListName,
"Name of the ParticleList which contains information that will be used for updating");
44 addParam(
"cutString",
m_selection,
"Cut string which will be used for updating masks", emptyCutString);
46 "Update the ROE mask by passing or discarding particles in the provided particle list, default is to pass",
false);
56 B2INFO(
"RestOfEventUpdater updated track/eclCluster ROEMask(s) with infoList: " <<
m_inputListName <<
" and cut: " <<
m_selection);
62 B2WARNING(
"Input list " <<
m_inputList.getName() <<
" was not created?");
67 B2WARNING(
"ROE list is not valid somehow, ROE masks are not updated!");
70 std::set<Particle::EParticleSourceObject> encounteredSources;
74 std::vector<const Particle*> particlesFromTracksToUpdate;
75 std::vector<const Particle*> particlesFromECLClustersToUpdate;
76 std::vector<const Particle*> particlesFromKLMClustersToUpdate;
77 std::vector<const Particle*> compositeParticlesToUpdate;
78 for (
unsigned j = 0; j <
m_inputList->getListSize(); j++) {
81 encounteredSources.insert(mdstSource);
82 if (
m_cut->check(partWithInfo)) {
83 if (mdstSource == Particle::EParticleSourceObject::c_Track) {
84 particlesFromTracksToUpdate.push_back(partWithInfo);
85 }
else if (mdstSource == Particle::EParticleSourceObject::c_ECLCluster) {
86 particlesFromECLClustersToUpdate.push_back(partWithInfo);
87 }
else if (mdstSource == Particle::EParticleSourceObject::c_KLMCluster) {
88 particlesFromKLMClustersToUpdate.push_back(partWithInfo);
89 }
else if (mdstSource == Particle::EParticleSourceObject::c_Composite or
90 mdstSource == Particle::EParticleSourceObject::c_V0) {
91 compositeParticlesToUpdate.push_back(partWithInfo);
95 if (encounteredSources.count(Particle::EParticleSourceObject::c_Track) > 0) {
98 if (encounteredSources.count(Particle::EParticleSourceObject::c_ECLCluster) > 0) {
101 if (encounteredSources.count(Particle::EParticleSourceObject::c_KLMCluster) > 0) {
109 const std::vector<const Particle*>& particlesToUpdate)
111 if (particlesToUpdate.size() == 0) {
112 B2DEBUG(10,
"No particles in list provided, nothing to do");
116 if (maskToUpdate ==
"") {
117 B2FATAL(
"Cannot update ROE mask with no name!");
119 for (
auto* particleV0 : particlesToUpdate) {
120 if (!roe->checkCompatibilityOfMaskAndV0(maskToUpdate, particleV0)) {
123 roe->updateMaskWithV0(maskToUpdate, particleV0);
132 if (maskToUpdate ==
"") {
133 B2FATAL(
"Cannot update ROE mask with no name!");
135 if (!roe->hasMask(maskToUpdate)) {
137 roe->initializeMask(maskToUpdate,
"ROEUpdaterModule");
139 roe->excludeParticlesFromMask(maskToUpdate, particlesToUpdate, listType,
m_discard);
static std::unique_ptr< GeneralCut > compile(const std::string &cut)
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.
EParticleSourceObject
particle source enumerators
EParticleSourceObject getParticleSource() const
Returns particle source as defined with enum EParticleSourceObject.
std::string m_selection
Cut string which will be used for updating masks.
virtual void initialize() override
Overridden initialize method.
virtual void event() override
Overridden event method.
std::shared_ptr< Variable::Cut > m_cut
Cut object which performs the cuts.
std::vector< std::string > m_maskNamesForUpdating
Container for all mask names which will be updated.
StoreObjPtr< ParticleList > m_inputList
ParticleList which contains information that will be used for updating.
void updateMasksWithParticles(const StoreObjPtr< RestOfEvent > &roe, std::vector< const Particle * > &particlesToUpdate, Particle::EParticleSourceObject listType)
Update ROE masks by excluding or keeping particles.
void updateMasksWithV0(const StoreObjPtr< RestOfEvent > &roe, const std::vector< const Particle * > &particlesToUpdate)
Update ROE masks with provided composite particle collection.
RestOfEventUpdaterModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::string m_inputListName
Name of the ParticleList which contains information that will be used for updating.
bool m_discard
Update the ROE mask by passing or discarding particles in the provided particle list.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
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.
Abstract base class for different kinds of events.