9#include <pxd/modules/pxdReconstruction/PXDClusterCheckModule.h>
11#include <framework/datastore/StoreArray.h>
12#include <framework/datastore/RelationArray.h>
13#include <framework/datastore/RelationIndex.h>
14#include <framework/logging/Logger.h>
16#include <mdst/dataobjects/MCParticle.h>
17#include <pxd/dataobjects/PXDDigit.h>
18#include <pxd/dataobjects/PXDCluster.h>
19#include <pxd/dataobjects/PXDTrueHit.h>
26#define assert_float(A,B) if(!isClose((A),(B)))\
27 B2FATAL("Assertion failed: " << #A << " (" << (A) << ") != " << #B << " (" << (B) << ")");
28#define assert_eq(A,B) if((A)!=(B))\
29 B2FATAL("Assertion failed: " << #A << " (" << (A) << ") != " << #B << " (" << (B) << ")");
33 bool isClose(
double a,
double b,
double epsilon = 1e-6)
35 return a == b || fabs(a - b) < epsilon || (fabs(a / b) - 1.0) < epsilon;
39 template<
class range>
void checkRelation(range a, range b)
42 assert_eq(std::distance(begin(a), end(a)), std::distance(begin(b), end(b)));
44 for (
decltype(begin(a)) ita = begin(a), itb = begin(b); ita != end(a) && itb != end(b); ++ita, ++itb) {
45 assert_eq(ita->indexTo, itb->indexTo);
46 assert_float(ita->weight, itb->weight);
63 setDescription(
"This Modules compares to sets of clusters and their relations "
64 "to make sure they are identical. Intended to cross check Clusterizer. "
65 "Default Collection names are assumed for MCParticles, PXDTrueHits and "
87 RelationArray relClustersMCParticlesOld(storeClustersOld, storeMCParticles);
88 RelationArray relClustersTrueHitsOld(storeClustersOld, storeTrueHits);
89 RelationArray relClustersDigitsOld(storeClustersOld, storeDigits);
94 RelationArray relClustersMCParticlesNew(storeClustersNew, storeMCParticles);
95 RelationArray relClustersTrueHitsNew(storeClustersNew, storeTrueHits);
96 RelationArray relClustersDigitsNew(storeClustersNew, storeDigits);
124 const unsigned int nCls = storeClustersOld.
getEntries();
128 for (
unsigned int i = 0; i < nCls; ++i) {
132 const PXDCluster& clsOld = *storeClustersOld[i];
133 const PXDCluster& clsNew = *storeClustersNew[i];
135 assert_float(clsOld.
getU(), clsNew.
getU());
136 assert_float(clsOld.
getV(), clsNew.
getV());
158 for (
unsigned int j = 0; j < reOld.
getSize(); ++j) {
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...
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
float getV() const
Get v coordinate of hit position.
float getUSigma() const
Get error of u coordinate of hit position.
unsigned short getSeedCharge() const
Get seed charge.
float getVSigma() const
Get error in v coordinate of hit position.
unsigned short getVSize() const
Get cluster size in v direction.
unsigned short getSize() const
Get cluster size.
unsigned short getCharge() const
Get collected charge.
float getRho() const
Get hit position error covariance coefficient.
unsigned short getUSize() const
Get cluster size in u direction.
VxdID getSensorID() const
Get the sensor ID.
unsigned short getVStart() const
Get cluster start cell in v direction.
float getU() const
Get u coordinate of hit position.
unsigned short getUStart() const
Get cluster start cell in u direction.
std::string m_clustersNew
Name of the second PXDCluster StoreArray.
virtual void initialize() override
Initialize the module.
virtual void event() override
do the clustering
std::string m_clustersOld
Name of the first PXDCluster StoreArray.
PXDClusterCheckModule()
Constructor defining the parameters.
Low-level class to create/modify relations between StoreArrays.
void consolidate()
Consolidate Relation Elements.
int getEntries() const
Get the number of elements.
Class to store a single element of a relation.
index_type getFromIndex() const
Get index we point from.
index_type getToIndex(size_t n=0) const
Get nth index we point to.
size_t getSize() const
Get number of indices we points to.
weight_type getWeight(size_t n=0) const
Get nth weight we point to.
Provides access to fast ( O(log n) ) bi-directional lookups on a specified relation.
range_from getElementsFrom(const FROM *from) const
Return a range of all elements pointing from the given object.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
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.