9#include <analysis/modules/UdstListFilter/UdstListFilterModule.h>
10#include <unordered_set>
22void storeRelatedToTrack(
const Track* p,
26 indicesToKeep[Particle::EParticleSourceObject::c_ECLCluster].insert(cluster.getArrayIndex());
29 indicesToKeep[Particle::EParticleSourceObject::c_KLMCluster].insert(cluster.getArrayIndex());
39 auto source = p->getParticleSource();
40 if (source == Particle::EParticleSourceObject::c_Track ||
41 source == Particle::EParticleSourceObject::c_KLMCluster ||
42 source == Particle::EParticleSourceObject::c_ECLCluster ||
43 source == Particle::EParticleSourceObject::c_V0) {
44 unsigned mdstIndex = p->getMdstArrayIndex();
45 indicesToKeep[source].insert(mdstIndex);
47 if (source == Particle::EParticleSourceObject::c_Track) {
48 storeRelatedToTrack(p->getTrack(), indicesToKeep);
53 unsigned int n = p->getNDaughters();
54 for (
unsigned int i = 0; i < n; i++) {
55 keepObject(p->getDaughter(i), indicesToKeep);
65 setDescription(
"Filter udst file content based on a particle list. As a result of the module, all object which are (not) associated with the list are removed. The module is used for signal embedding.");
69 "if true, keep mdst objects which are not used in the particle list, otherwise keep objects which are used in the list.",
false);
96 std::map < Particle::EParticleSourceObject, std::unordered_set<unsigned int>> mdstIndices;
99 keepObject(&p, mdstIndices);
102 for (
const auto& mI : mdstIndices) {
105 const auto& source = mI.first;
106 const auto& indices = mI.second;
110 int idx = p->getArrayIndex();
111 return (indices.count(idx) == 1)^
m_reverse;
115 if (source == Particle::EParticleSourceObject::c_Track) {
123 else if (source == Particle::EParticleSourceObject::c_V0) {
127 else if (source == Particle::EParticleSourceObject::c_ECLCluster) {
131 else if (source == Particle::EParticleSourceObject::c_KLMCluster) {
139 for (
auto& v0 :
m_v0s) {
140 const auto tracks = v0.getTracks();
141 const auto fitResults = v0.getTrackFitResults();
142 const Track* r1 = tracks.first->getRelated<
Track>(
"myudst_tracks");
143 const Track* r2 = tracks.second->getRelated<
Track>(
"myudst_tracks");
144 if ((r1 !=
nullptr) and (r2 !=
nullptr)) {
146 m_selectedV0s->appendNew(std::make_pair(r1, fitResults.first), std::make_pair(r2, fitResults.second),
147 v0.getFittedVertexX(), v0.getFittedVertexY(), v0.getFittedVertexZ());
153 if (!fromEntry->
ptr) {
156 toEntry->
ptr =
nullptr;
@ c_WriteOut
Object/array should be saved by output modules.
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
static DataStore & Instance()
Instance of singleton Store.
StoreEntry * getEntry(const StoreAccessorBase &accessor)
Check whether an entry with the correct type is registered in the DataStore map and return it.
void replaceData(const StoreAccessorBase &from, const StoreAccessorBase &to)
For two StoreAccessors of same type, move all data in 'from' into 'to', discarding previous contents ...
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
Defines interface for accessing relations of objects in StoreArray.
Accessor to arrays stored in the data store.
Class that bundles various TrackFitResults.
StoreArray< V0 > * m_selectedV0s
New selected V0 array.
void swapV0s()
Update V0 mdst datastore object.
virtual void initialize() override
Initialize the Module.
StoreArray< KLMCluster > m_klmclusters
StoreArray of KLMCluster.
StoreArray< V0 > m_v0s
StoreArray of V0s.
virtual void event() override
Event processor.
std::string m_listName
Breco particle list name.
UdstListFilterModule()
Constructor.
SelectSubset< Track > m_track_selector
Selector of sub-set of tracks.
SelectSubset< KLMCluster > m_klm_selector
Selector of sub-set of KLM clusters.
StoreArray< Track > m_tracks
StoreArray of Tracks.
SelectSubset< ECLCluster > m_ecl_selector
Selector of sub-set of ECL clusters.
SelectSubset< V0 > m_v0_selector
Selector of sub-set of V0s.
StoreArray< ECLCluster > m_eclclusters
StoreArray of ECLCluster.
StoreObjPtr< ParticleList > m_plist
list used for cleaning
bool m_reverse
Reverse selection: keep objects NOT mentioned in the list.
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.
Wraps a stored array/object, stored under unique (name, durability) key.
TObject * ptr
The pointer to the returned object, either equal to 'object' or null, depending on whether the object...
TClonesArray * getPtrAsArray() const
Return ptr cast to TClonesArray.
bool isArray
Flag that indicates whether the object is a TClonesArray.