 |
Belle II Software
release-05-02-19
|
11 #include <pxd/modules/pxdReconstruction/PXDClusterCheckModule.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/datastore/RelationArray.h>
15 #include <framework/datastore/RelationIndex.h>
16 #include <framework/logging/Logger.h>
18 #include <mdst/dataobjects/MCParticle.h>
19 #include <pxd/dataobjects/PXDDigit.h>
20 #include <pxd/dataobjects/PXDCluster.h>
21 #include <pxd/dataobjects/PXDTrueHit.h>
28 #define assert_float(A,B) if(!isClose((A),(B)))\
29 B2FATAL("Assertion failed: " << #A << " (" << (A) << ") != " << #B << " (" << (B) << ")");
30 #define assert_eq(A,B) if((A)!=(B))\
31 B2FATAL("Assertion failed: " << #A << " (" << (A) << ") != " << #B << " (" << (B) << ")");
35 bool isClose(
double a,
double b,
double epsilon = 1e-6)
37 return a == b || fabs(a - b) < epsilon || (fabs(a / b) - 1.0) < epsilon;
41 template<
class range>
void checkRelation(range a, range b)
44 assert_eq(std::distance(begin(a), end(a)), std::distance(begin(b), end(b)));
46 for (decltype(begin(a)) ita = begin(a), itb = begin(b); ita != end(a) && itb != end(b); ++ita, ++itb) {
47 assert_eq(ita->indexTo, itb->indexTo);
48 assert_float(ita->weight, itb->weight);
62 PXDClusterCheckModule::PXDClusterCheckModule() :
Module()
65 setDescription(
"This Modules compares to sets of clusters and their relations "
66 "to make sure they are identical. Intended to cross check Clusterizer. "
67 "Default Collection names are assumed for MCParticles, PXDTrueHits and "
82 storeMCParticles.isRequired();
83 storeDigits.isRequired();
84 storeTrueHits.isRequired();
85 storeClustersOld.isRequired();
86 storeClustersNew.isRequired();
89 RelationArray relClustersMCParticlesOld(storeClustersOld, storeMCParticles);
90 RelationArray relClustersTrueHitsOld(storeClustersOld, storeTrueHits);
91 RelationArray relClustersDigitsOld(storeClustersOld, storeDigits);
96 RelationArray relClustersMCParticlesNew(storeClustersNew, storeMCParticles);
97 RelationArray relClustersTrueHitsNew(storeClustersNew, storeTrueHits);
98 RelationArray relClustersDigitsNew(storeClustersNew, storeDigits);
126 const unsigned int nCls = storeClustersOld.
getEntries();
130 for (
unsigned int i = 0; i < nCls; ++i) {
134 const PXDCluster& clsOld = *storeClustersOld[i];
135 const PXDCluster& clsNew = *storeClustersNew[i];
137 assert_float(clsOld.
getU(), clsNew.
getU());
138 assert_float(clsOld.
getV(), clsNew.
getV());
160 for (
unsigned int j = 0; j < reOld.
getSize(); ++j) {
float getUSigma() const
Get error of u coordinate of hit position.
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.
virtual void event() override
do the clustering
#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 getU() const
Get u coordinate of hit position.
Provides access to fast ( O(log n) ) bi-directional lookups on a specified relation.
std::string m_clustersOld
Name of the first PXDCluster StoreArray.
unsigned short getSeedCharge() const
Get seed charge.
Class to store a single element of a relation.
virtual void initialize() override
Initialize the module.
unsigned short getCharge() const
Get collected charge.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
float getRho() const
Get hit position error covariance coefficient.
unsigned short getSize() const
Get cluster size.
range_from getElementsFrom(const FROM *from) const
Return a range of all elements pointing from the given object.
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
Abstract base class for different kinds of events.
std::string m_clustersNew
Name of the second PXDCluster StoreArray.
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
size_t getSize() const
Get number of indices we points to.
VxdID getSensorID() const
Get the sensor ID.
index_type getToIndex(size_t n=0) const
Get nth index we point to.
int getEntries() const
Get the number of elements.
float getVSigma() const
Get error in v coordinate of hit position.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
index_type getFromIndex() const
Get index we point from.
weight_type getWeight(size_t n=0) const
Get nth weight we point to.
unsigned short getUStart() const
Get cluster start cell in u direction.
unsigned short getVSize() const
Get cluster size in v direction.
float getV() const
Get v coordinate of hit position.
unsigned short getVStart() const
Get cluster start cell in v direction.
int getEntries() const
Get the number of objects in the array.
unsigned short getUSize() const
Get cluster size in u direction.