 |
Belle II Software
release-05-01-25
|
11 #include <pxd/modules/pxdReconstruction/PXDClusterizerModule.h>
13 #include <framework/datastore/DataStore.h>
14 #include <framework/datastore/StoreArray.h>
15 #include <framework/datastore/RelationArray.h>
16 #include <framework/logging/Logger.h>
18 #include <vxd/geometry/GeoCache.h>
20 #include <mdst/dataobjects/MCParticle.h>
21 #include <pxd/dataobjects/PXDDigit.h>
22 #include <pxd/dataobjects/PXDCluster.h>
23 #include <pxd/dataobjects/PXDTrueHit.h>
24 #include <pxd/geometry/SensorInfo.h>
26 #include <pxd/reconstruction/PXDClusterPositionEstimator.h>
41 PXDClusterizerModule::PXDClusterizerModule() :
Module()
42 , m_elNoise(0.7), m_cutSeed(5.0), m_cutAdjacent(3.0), m_cutCluster(8.0)
43 , m_cutAdjacentSignal(0), m_sizeHeadTail(3), m_clusterCacheSize(0)
50 "Noise added by the electronics, set in ADU",
m_elNoise);
52 "SN for digits to be considered for clustering",
m_cutAdjacent);
57 "Maximum desired number of sensor rows", 0);
59 "Minimum cluster size to switch to Analog head tail algorithm for cluster center",
80 storeDigits.isRequired();
81 storeTrueHits.isOptional();
82 storeMCParticles.isOptional();
85 RelationArray relClusterTrueHits(storeClusters, storeTrueHits);
86 RelationArray relClusterMCParticles(storeClusters, storeMCParticles);
87 RelationArray relDigitMCParticles(storeDigits, storeMCParticles);
113 "PXDClusterizer Parameters (in default system units, *=cannot be set directly):");
114 B2DEBUG(20,
" --> ElectronicNoise: " <<
m_elNoise);
116 B2DEBUG(20,
" --> SeedSN: " <<
m_cutSeed);
148 storeClusters.
clear();
150 RelationArray relClusterMCParticle(storeClusters, storeMCParticles,
152 if (relClusterMCParticle) relClusterMCParticle.
clear();
156 if (relClusterDigit) relClusterDigit.
clear();
158 RelationArray relClusterTrueHit(storeClusters, storeTrueHits,
160 if (relClusterTrueHit) relClusterTrueHit.
clear();
179 for (
int i = 0; i < nPixels; i++) {
180 const PXDDigit*
const storeDigit = storeDigits[i];
181 Pixel px(storeDigit, i);
188 }
else if (px <= lastPixel) {
190 B2FATAL(
"Pixels are not sorted correctly, please include the "
191 "PXDDigitSorter module before running the Clusterizer or fix "
192 "the input to be ordered by v,u in ascending order");
220 }
catch (std::out_of_range& e) {
221 B2WARNING(
"PXD clustering: Ignoring pixel " << px.
getU() <<
"," << px.
getV() <<
": " << e.what());
231 if (!relation)
return;
233 lookup.resize(digits);
235 lookup[element.getFromIndex()] = &element;
243 if (!lookup.empty() && lookup[index]) {
245 const unsigned int size = element.getSize();
247 for (
unsigned int i = 0; i < size; ++i) {
250 if (element.getWeight(i) < 0)
continue;
251 relation[element.getToIndex(i)] += element.getWeight(i);
266 RelationArray relClusterMCParticle(storeClusters, storeMCParticles,
270 RelationArray relClusterTrueHit(storeClusters, storeTrueHits,
277 map<unsigned int, float> mc_relations;
278 map<unsigned int, float> truehit_relations;
279 vector<pair<unsigned int, float> > digit_weights;
288 mc_relations.clear();
289 truehit_relations.clear();
290 digit_weights.clear();
291 digit_weights.reserve(cls.size());
293 const Pixel& seed = cls.getSeed();
297 projU.
add(px.getU(), info.getUCellPosition(px.getU()), px.getCharge());
298 projV.
add(px.getV(), info.getVCellPosition(px.getV()), px.getCharge());
305 digit_weights.emplace_back(px.getIndex(), px.getCharge());
310 const double pitchU = info.getUPitch();
311 const double pitchV = info.getVPitch(projV.
getPos());
315 double posUU = cls.getCharge() * pitchU * pitchU / 12.0;
316 double posVV = cls.getCharge() * pitchV * pitchV / 12.0;
318 for (
const Pixel& px : cls.pixels()) {
319 const double du = info.getUCellPosition(px.getU()) - projU.
getPos();
320 const double dv = info.getVCellPosition(px.getV()) - projV.
getPos();
321 posUU += px.getCharge() * du * du;
322 posVV += px.getCharge() * dv * dv;
323 posUV += px.getCharge() * du * dv;
325 rho = posUV / sqrt(posUU * posVV);
333 TVector3 lorentzShift = info.getLorentzShift(projU.
getPos(), projV.
getPos());
336 B2DEBUG(20,
"Lorentz shift: " << lorentzShift.X() <<
" " << lorentzShift.Y());
343 set<Pixel> pixelSet(cls.pixels().begin(), cls.pixels().end());
346 vector<float> sectorEtaValues = {0, 0, 0, 0};
356 vector<int> sectorShapeIndices = { -1, -1, -1, -1};
369 rho, cls.getCharge(), seed.getCharge(),
371 sectorEtaValues, sectorShapeIndices
375 if (!mc_relations.empty()) relClusterMCParticle.
add(clsIndex, mc_relations.begin(), mc_relations.end());
376 if (!truehit_relations.empty()) relClusterTrueHit.
add(clsIndex, truehit_relations.begin(), truehit_relations.end());
377 relClusterDigit.
add(clsIndex, digit_weights.begin(), digit_weights.end());
384 const ClusterProjection& secondary,
double minPitch,
double centerPitch,
double maxPitch)
392 + (maxCharge * maxPitch - minCharge * minPitch) / centerCharge));
395 const double landauHead = minCharge / centerCharge * minPitch;
396 const double landauTail = maxCharge / centerCharge * maxPitch;
397 primary.
setError(0.5 * sqrt(1.0 / snHead / snHead + 1.0 / snTail / snTail
398 + 0.5 * landauHead * landauHead + 0.5 * landauTail * landauTail));
399 }
else if (primary.
getSize() <= 2) {
404 primary.
setError(2.0 * centerPitch / sn);
T * appendNew()
Construct a new T object at the end of the array.
void clear() override
Clear all elements from the relation.
Low-level class to create/modify relations between StoreArrays.
std::unique_ptr< ClusterCache > m_cache
cache of the last seen clusters to speed up clustering
Class to uniquely identify a any structure of the PXD and SVD.
double m_cutAdjacent
Noise cut in sigma.
void setDescription(const std::string &description)
Sets the description of the module.
Class representing a possible cluster during clustering of the PXD It supports merging of different c...
std::string m_relDigitTrueHitName
Name of the relation between PXDDigits and PXDTrueHits.
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
virtual void setSensorID(VxdID)
Set the sensorID currently used.
double getMinPos() const
Return the position of the minimum cell of the cluster.
double m_elNoise
Noise in ADU.
#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...
float getSeedCharge() const
get the seed charge of the cluster
std::string m_relClusterMCParticleName
Name of the relation between PXDClusters and MCParticles.
double getMinCharge() const
Return the charge in the minimum cell of the cluster.
std::vector< const RelationElement * > RelationLookup
Container for a RelationArray Lookup table.
double m_cutAdjacentSignal
Signal in ADU for Adjacent cut, basically m_elNoise*m_cutAdjacent.
int computeShapeIndex(const std::set< Pixel > &pixels, int uStart, int vStart, int vSize, double thetaU, double thetaV) const
Return the shape index of the pixels.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Class to represent one pixel, used in clustering for fast access.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
double getMaxCharge() const
Return the charge in the maximum cell of the cluster.
void calculatePositionError(const ClusterCandidate &cls, ClusterProjection &primary, const ClusterProjection &secondary, double minPitch, double centerPitch, double maxPitch)
Calculate position and error for a given cluster.
std::string m_relClusterDigitName
Name of the relation between PXDClusters and PXDDigits.
unsigned int getMinCell() const
Return the minimum cell part of the cluster.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
void setError(double error)
Set the error of the cluster.
std::string m_storeTrueHitsName
Name of the collection to use for the PXDTrueHits.
RelationLookup m_mcRelation
Lookup table for PXDDigit->MCParticle relation.
unsigned int getSize() const
Return the projected size of the cluster.
std::string m_relDigitMCParticleName
Name of the relation between PXDDigits and MCParticles.
static PXDClusterPositionEstimator & getInstance()
Main (and only) way to access the PXDClusterPositionEstimator.
Class to store a single element of a relation.
double m_cutCluster
Cluster cut in sigma.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
void setNoiseLevel(float noise)
Set the noise level.
VxdID getSensorID() const
Get the sensor ID.
double getCenterCharge() const
Return the center charge of the cluster, that is total charge minus minimum and maximum cell charge.
void writeClusters(VxdID sensorID)
Write clusters to collection.
void add(unsigned int cell, float position, float charge)
Add Pixel information to the projection.
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
double getPos() const
Return the projected position of the cluster.
double m_cutSeed
Seed cut in sigma.
void clear() override
Delete all entries in this array.
Abstract base class for different kinds of events.
int getClusterkind(const PXDCluster &cluster) const
Return kind of cluster needed to find cluster position correction.
int m_clusterCacheSize
Size of cluster Cache (0 = default)
double getMaxPos() const
Return the position of the maximum cell of the cluster.
Class to remember recently assigned clusters This class will remember the current and the last pixel ...
std::string m_storeDigitsName
Name of the collection to use for the PXDDigits.
void createRelationLookup(const RelationArray &relation, RelationLookup &lookup, size_t digits)
Create lookup maps for Relations We do not use the RelationIndex as we know much more about the relat...
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
virtual void initialize() override
Initialize the module.
unsigned short getV() const
Return the CellID in v.
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
double getError() const
Return the error of the cluster.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
void finalize()
Finish calculation of center of gravity and set correct cluster size.
Helper struct to collect information about the 1D projection of a Pixel cluster.
unsigned short getU() const
Return the CellID in u.
float computeEta(const std::set< Pixel > &pixels, int vStart, int vSize, double thetaU, double thetaV) const
Return the normed charge ratio between head and tail pixels (size>=2) or the charge of the seed (size...
RelationLookup m_trueRelation
Lookup table for PXDDigit->PXDTrueHit relation.
void setPos(double pos)
Set the position of the cluster.
virtual void event() override
do the clustering
NoiseMap m_noiseMap
Noise map for the currently active sensor.
int m_sizeHeadTail
Size of the cluster at which we switch from Center of Gravity to Analog Head Tail.
double getCharge() const
Return the total charge of the cluster.
void fillRelationMap(const RelationLookup &lookup, std::map< unsigned int, float > &relation, unsigned int index)
Add the relation from a given PXDDigit index to a map.
int getEntries() const
Get the number of objects in the array.
std::string m_storeMCParticlesName
Name of the collection to use for the MCParticles.
std::string m_storeClustersName
Name of the collection to use for the PXDClusters.
std::string m_relClusterTrueHitName
Name of the relation between PXDClusters and PXDTrueHits.