9#include <pxd/modules/pxdReconstruction/PXDDigitSorterModule.h>
10#include <framework/datastore/StoreArray.h>
11#include <framework/datastore/RelationArray.h>
12#include <framework/logging/Logger.h>
13#include <vxd/geometry/GeoCache.h>
15#include <mdst/dataobjects/MCParticle.h>
16#include <pxd/dataobjects/PXDTrueHit.h>
17#include <pxd/reconstruction/Pixel.h>
18#include <pxd/reconstruction/PXDPixelMasker.h>
23using namespace boost::python;
38 setDescription(
"This module sorts the existing PXDDigits collection and also "
39 "updates the corresponding Relation to MCParticles and TrueHits. This is "
40 "needed for unsorted pixel data as the Clusterizer expects sorted input.");
42 addParam(
"merge",
m_mergeDuplicates,
"If true, merge Pixel information if more than one digit exists for the same address",
true);
43 addParam(
"trimDigits",
m_trimDigits,
"If true, pixel data will be checked to detect malformed pixels. Such pixels will be scarded.",
81 if (!storeDigits || !storeDigits.
getEntries())
return;
89 std::vector<RelationArray::consolidation_type> relationIndices(storeDigits.
getEntries());
91 std::map<VxdID, std::multiset<Pixel>> sensors;
95 for (
int i = 0; i < nPixels; i++) {
96 const PXDDigit*
const storeDigit = storeDigits[i];
99 B2DEBUG(20,
"Malformed PXDDigit, VxdID $" << hex << sensorID.
getID() <<
", dropping. (" << sensorID <<
")");
109 Pixel px(storeDigit, i);
110 sensors[sensorID].insert(px);
112 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];
146 relationIndices[px.
getIndex()] = std::make_pair(index - 1,
false);
149 relationIndices[px.
getIndex()] = std::make_pair(0,
true);
156 storeDigits.
getPtr()->ExpandCreate(index);
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...
unsigned short getVCellID() const
Get cell ID in v.
unsigned short getUCellID() const
Get cell ID in u.
unsigned short getCharge() const
Get collected charge.
VxdID getSensorID() const
Get the sensor ID.
PXDDigitSorterModule()
Constructor defining the parameters.
virtual void initialize() override
Initialize the module.
bool m_mergeDuplicates
Mode: if true, merge duplicate pixels, otherwise delete all but the first occurence.
std::string m_relDigitMCParticleName
Name of the relation between PXDDigits and MCParticles.
virtual void event() override
do the sorting
std::string m_storeTrueHitsName
Name of the collection to use for the PXDTrueHits.
std::string m_storeMCParticlesName
Name of the collection to use for the MCParticles.
std::vector< PXDDigit > m_digitcopy
Copy of the Digits needed for sorting.
std::string m_storeDigitsName
Name of the collection to use for the PXDDigits.
bool goodDigit(const PXDDigit *const digit) const
Utility function to check pixel coordinates.
std::string m_relDigitTrueHitName
Name of the relation between PXDDigits and PXDTrueHits.
bool m_trimDigits
if true, check digit data and discard malformed digits.
bool pixelOK(VxdID id, unsigned int uid, unsigned int vid) const
Check whether a pixel on a given sensor is OK or not.
static PXDPixelMasker & getInstance()
Main (and only) way to access the PXDPixelMasker.
Class to represent one pixel, used in clustering for fast access.
unsigned int getIndex() const
Return the Index of the digit.
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.
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.
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
int getEntries() const
Get the number of objects in the array.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
static GeoCache & getInstance()
Return a reference to the singleton instance.
bool validSensorID(Belle2::VxdID id) const
Check that id is a valid sensor number.
Class to uniquely identify a any structure of the PXD and SVD.
baseType getID() const
Get the unique id.
baseType getSensorNumber() const
Get the sensor id.
baseType getLadderNumber() const
Get the ladder id.
baseType getLayerNumber() const
Get the layer id.
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 PXD.
Abstract base class for different kinds of events.
Struct for identity transformation on indices.