9#include <svd/modules/svdReconstruction/SVDShaperDigitSorterModule.h>
11#include <framework/datastore/StoreArray.h>
12#include <framework/datastore/RelationArray.h>
13#include <framework/logging/Logger.h>
15#include <mdst/dataobjects/MCParticle.h>
16#include <svd/dataobjects/SVDTrueHit.h>
38 setDescription(
"This module sorts an existing SVDShaperDigits collection and also "
39 "updates the corresponding relations to MCParticles and TrueHits. This is "
40 "needed for background overlay as the Clusterizer expects sorted input. "
41 "The module is otherwise not required for simulation or reconstruction, "
42 "as both SVDDigitzer ond SVDUnpacker output sorted digit collections.");
81 if (!storeShaperDigits || !storeShaperDigits.
getEntries())
return;
82 B2DEBUG(29,
"Initial size of StoreShaperDigits array: " << storeShaperDigits.
getEntries());
88 std::vector<RelationArray::consolidation_type> relationIndices(storeShaperDigits.
getEntries());
91 typedef std::pair<size_t, unsigned int> indexElement;
93 std::vector<indexElement> digitIndex;
95 const unsigned int nSamples = storeShaperDigits.
getEntries();
96 for (
size_t i = 0; i < nSamples; i++)
97 digitIndex.emplace_back(i, storeShaperDigits[i]->getUniqueChannelID());
99 std::sort(digitIndex.begin(), digitIndex.end(),
100 [](
const indexElement & a,
const indexElement & b)->bool { return (a.second < b.second);}
108 for (
size_t i = 0; i < nSamples; ++i) {
109 *storeShaperDigits[i] =
m_digitcopy[digitIndex[i].first];
110 relationIndices[digitIndex[i].first] = std::make_pair(i,
false);
118 B2DEBUG(29,
"Final size of StoreShaperDigits store array: " << storeShaperDigits.
getEntries());
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...
Struct to replace indices based on a sequential container.
Low-level class to create/modify relations between StoreArrays.
void consolidate()
Consolidate Relation Elements.
@ c_deleteElement
Delete the whole relation element if the original element got re-attributed.
std::string m_relShaperDigitMCParticleName
Name of the relation between SVDShaperDigits and MCParticles.
virtual void initialize() override
Initialize the module.
std::string m_storeShaperDigitsName
Name of the collection to use for the SVDShaperDigits.
virtual void event() override
do the sorting
std::string m_storeTrueHitsName
Name of the collection to use for the SVDTrueHits.
std::string m_storeMCParticlesName
Name of the collection to use for the MCParticles.
std::string m_relShaperDigitTrueHitName
Name of the relation between SVDShaperDigits and SVDTrueHits.
std::vector< SVDShaperDigit > m_digitcopy
Copy of the ShaperDigits needed for sorting.
SVDShaperDigitSorterModule()
Constructor defining the parameters.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
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.
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Abstract base class for different kinds of events.
Struct for identity transformation on indices.