9#include <analysis/modules/UdstListFilter/UdstListFilterModule.h>
11#include <framework/logging/Logger.h>
12#include <unordered_set>
24void storeRelatedToTrack(
const Track* p,
28 indicesToKeep[Particle::EParticleSourceObject::c_ECLCluster].insert(cluster.getArrayIndex());
31 indicesToKeep[Particle::EParticleSourceObject::c_KLMCluster].insert(cluster.getArrayIndex());
41 auto source = p->getParticleSource();
42 if (source == Particle::EParticleSourceObject::c_Track ||
43 source == Particle::EParticleSourceObject::c_KLMCluster ||
44 source == Particle::EParticleSourceObject::c_ECLCluster ||
45 source == Particle::EParticleSourceObject::c_V0) {
46 unsigned mdstIndex = p->getMdstArrayIndex();
47 indicesToKeep[source].insert(mdstIndex);
49 if (source == Particle::EParticleSourceObject::c_Track) {
50 storeRelatedToTrack(p->getTrack(), indicesToKeep);
55 unsigned int n = p->getNDaughters();
56 for (
unsigned int i = 0; i < n; i++) {
57 keepObject(p->getDaughter(i), indicesToKeep);
67 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.");
70 "if true, keep mdst objects which are not used in the particle list, otherwise keep objects which are used in the list.",
false);
97 std::map < Particle::EParticleSourceObject, std::unordered_set<unsigned int>> mdstIndices;
100 keepObject(&p, mdstIndices);
103 for (
const auto& mI : mdstIndices) {
106 const auto& source = mI.first;
107 const auto& indices = mI.second;
111 int idx = p->getArrayIndex();
112 return (indices.count(idx) == 1)^
m_reverse;
116 if (source == Particle::EParticleSourceObject::c_Track) {
124 else if (source == Particle::EParticleSourceObject::c_V0) {
128 else if (source == Particle::EParticleSourceObject::c_ECLCluster) {
132 else if (source == Particle::EParticleSourceObject::c_KLMCluster) {
140 for (
auto& v0 :
m_v0s) {
141 const auto tracks = v0.getTracks();
142 const auto fitResults = v0.getTrackFitResults();
143 const Track* r1 = tracks.first->getRelated<
Track>(
"myudst_tracks");
144 const Track* r2 = tracks.second->getRelated<
Track>(
"myudst_tracks");
145 if ((r1 !=
nullptr) and (r2 !=
nullptr)) {
147 m_selectedV0s->appendNew(std::make_pair(r1, fitResults.first), std::make_pair(r2, fitResults.second),
148 v0.getFittedVertexX(), v0.getFittedVertexY(), v0.getFittedVertexZ());
154 if (!fromEntry->
ptr) {
157 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.
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 wether the object ...
TClonesArray * getPtrAsArray() const
Return ptr cast to TClonesArray.
bool isArray
Flag that indicates whether the object is a TClonesArray.