 |
Belle II Software
release-05-01-25
|
11 #include <pxd/modules/pxdReconstruction/PXDDigitSorterModule.h>
12 #include <framework/datastore/StoreArray.h>
13 #include <framework/datastore/RelationArray.h>
14 #include <framework/logging/Logger.h>
15 #include <vxd/geometry/GeoCache.h>
17 #include <mdst/dataobjects/MCParticle.h>
18 #include <pxd/dataobjects/PXDTrueHit.h>
19 #include <pxd/reconstruction/Pixel.h>
20 #include <pxd/reconstruction/PXDPixelMasker.h>
25 using namespace boost::python;
37 PXDDigitSorterModule::PXDDigitSorterModule() :
Module()
40 setDescription(
"This module sorts the existing PXDDigits collection and also "
41 "updates the corresponding Relation to MCParticles and TrueHits. This is "
42 "needed for unsorted pixel data as the Clusterizer expects sorted input.");
44 addParam(
"merge",
m_mergeDuplicates,
"If true, merge Pixel information if more than one digit exists for the same address",
true);
45 addParam(
"trimDigits",
m_trimDigits,
"If true, pixel data will be checked to detect malformed pixels. Such pixels will be scarded.",
62 storeDigits.isRequired();
63 storeMCParticles.isOptional();
64 storeTrueHits.isOptional();
83 if (!storeDigits || !storeDigits.
getEntries())
return;
91 std::vector<RelationArray::consolidation_type> relationIndices(storeDigits.
getEntries());
93 std::map<VxdID, std::multiset<Pixel>> sensors;
97 for (
int i = 0; i < nPixels; i++) {
98 const PXDDigit*
const storeDigit = storeDigits[i];
101 B2DEBUG(20,
"Malformed PXDDigit, VxdID $" << hex << sensorID.
getID() <<
", dropping. (" << sensorID <<
")");
108 Pixel px(storeDigit, i);
109 sensors[sensorID].insert(px);
111 B2DEBUG(20,
"Encountered a malformed digit in PXDDigit sorter: " << endl
125 unsigned int index(0);
127 for (
const auto& sensor : sensors) {
131 if (!lastpx || px > *lastpx) {
135 relationIndices[px.
getIndex()] = std::make_pair(index,
false);
142 const PXDDigit& old = *storeDigits[index - 1];
144 *storeDigits[index - 1] =
PXDDigit(old.getSensorID(), old.getUCellID(), old.getVCellID(),
146 relationIndices[px.
getIndex()] = std::make_pair(index - 1,
false);
149 relationIndices[px.
getIndex()] = std::make_pair(0,
true);
156 storeDigits.
getPtr()->ExpandCreate(index);
Low-level class to create/modify relations between StoreArrays.
virtual void initialize() override
Initialize the module.
Class to uniquely identify a any structure of the PXD and SVD.
void setDescription(const std::string &description)
Sets the description of the module.
void consolidate()
Consolidate Relation Elements.
std::string m_relDigitMCParticleName
Name of the relation between PXDDigits and MCParticles.
#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.
std::string m_storeTrueHitsName
Name of the collection to use for the PXDTrueHits.
baseType getLadderNumber() const
Get the ladder id.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Class to represent one pixel, used in clustering for fast access.
baseType getID() const
Get the unique id.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
std::string m_storeDigitsName
Name of the collection to use for the PXDDigits.
std::string m_relDigitTrueHitName
Name of the relation between PXDDigits and PXDTrueHits.
bool goodDigit(const PXDDigit *const digit) const
Utility function to check pixel coordinates.
std::vector< PXDDigit > m_digitcopy
Copy of the Digits needed for sorting.
bool validSensorID(Belle2::VxdID id) const
Check that id is a valid sensor number.
unsigned short getUCellID() const
Get cell ID in u.
virtual void event() override
do the sorting
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
VxdID getSensorID() const
Get the sensor ID.
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Abstract base class for different kinds of events.
@ c_deleteElement
Delete the whole relation element if the original element got re-attributed.
bool m_trimDigits
if true, check digit data and discard malformed digits.
unsigned int getIndex() const
Return the Index of the digit.
Struct to replace indices based on a sequential container.
bool m_mergeDuplicates
Mode: if true, merge duplicate pixels, otherwise delete all but the first occurence.
baseType getSensorNumber() const
Get the sensor id.
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Accessor to arrays stored in the data store.
baseType getLayerNumber() const
Get the layer id.
std::string m_storeMCParticlesName
Name of the collection to use for the MCParticles.
int getEntries() const
Get the number of objects in the array.
unsigned short getVCellID() const
Get cell ID in v.
static PXDPixelMasker & getInstance()
Main (and only) way to access the PXDPixelMasker.