 |
Belle II Software
release-05-02-19
|
11 #include <svd/modules/svdReconstruction/SVDShaperDigitSorterModule.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/datastore/RelationArray.h>
15 #include <framework/logging/Logger.h>
17 #include <mdst/dataobjects/MCParticle.h>
18 #include <svd/dataobjects/SVDTrueHit.h>
36 SVDShaperDigitSorterModule::SVDShaperDigitSorterModule() :
Module()
40 setDescription(
"This module sorts an existing SVDShaperDigits collection and also "
41 "updates the corresponding relations to MCParticles and TrueHits. This is "
42 "needed for background overlay as the Clusterizer expects sorted input. "
43 "The module is otherwise not required for simulation or reconstruction, "
44 "as both SVDDigitzer ond SVDUnpacker output sorted digit collections.");
61 storeShaperDigits.isRequired();
62 storeMCParticles.isOptional();
63 storeTrueHits.isOptional();
83 if (!storeShaperDigits || !storeShaperDigits.
getEntries())
return;
84 B2DEBUG(89,
"Initial size of StoreShaperDigits array: " << storeShaperDigits.
getEntries());
90 std::vector<RelationArray::consolidation_type> relationIndices(storeShaperDigits.
getEntries());
93 typedef std::pair<size_t, unsigned int> indexElement;
95 std::vector<indexElement> digitIndex;
97 const unsigned int nSamples = storeShaperDigits.
getEntries();
98 for (
size_t i = 0; i < nSamples; i++)
99 digitIndex.emplace_back(i, storeShaperDigits[i]->getUniqueChannelID());
101 std::sort(digitIndex.begin(), digitIndex.end(),
102 [](
const indexElement & a,
const indexElement & b)->bool { return (a.second < b.second);}
110 for (
size_t i = 0; i < nSamples; ++i) {
111 *storeShaperDigits[i] =
m_digitcopy[digitIndex[i].first];
112 relationIndices[digitIndex[i].first] = std::make_pair(i,
false);
120 B2DEBUG(89,
"Final size of StoreShaperDigits store array: " << storeShaperDigits.
getEntries());
std::string m_storeShaperDigitsName
Name of the collection to use for the SVDShaperDigits.
Low-level class to create/modify relations between StoreArrays.
void setDescription(const std::string &description)
Sets the description of the module.
void consolidate()
Consolidate Relation Elements.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Struct for identity transformation on indices.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
std::string m_storeMCParticlesName
Name of the collection to use for the MCParticles.
std::string m_storeTrueHitsName
Name of the collection to use for the SVDTrueHits.
virtual void event() override
do the sorting
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Abstract base class for different kinds of events.
@ c_deleteElement
Delete the whole relation element if the original element got re-attributed.
std::string m_relShaperDigitTrueHitName
Name of the relation between SVDShaperDigits and SVDTrueHits.
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
virtual void initialize() override
Initialize the module.
Struct to replace indices based on a sequential container.
std::string m_relShaperDigitMCParticleName
Name of the relation between SVDShaperDigits and MCParticles.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Accessor to arrays stored in the data store.
std::vector< SVDShaperDigit > m_digitcopy
Copy of the ShaperDigits needed for sorting.
int getEntries() const
Get the number of objects in the array.