Belle II Software development
PurityCalculatorToolsTest Class Reference

class for testing the purity calculator tools (i.e. More...

Inheritance diagram for PurityCalculatorToolsTest:

Protected Member Functions

virtual void SetUp ()
 set up the mockup that is needed by the tests
 
virtual void TearDown ()
 tear down environment after test -> clear datastore
 

Protected Attributes

StoreArray< Belle2::PXDTrueHitm_pxdTrueHits
 some PXDTrueHits for testing
 
StoreArray< Belle2::SVDTrueHitm_svdTrueHits
 some SVDTrueHits for testing
 
StoreArray< Belle2::SpacePointm_spacePoints
 some SpacePoints for testing
 
StoreArray< Belle2::MCParticlem_mcParticles
 some MCParticles for testing
 
std::vector< short > m_assignedClusters
 store the expected number of assigned Clusters in vector to be able to loop over it
 

Detailed Description

class for testing the purity calculator tools (i.e.

functions) defined in the spacePointCreation includes

Definition at line 133 of file purityCalculatorTools.cc.

Member Function Documentation

◆ SetUp()

virtual void SetUp ( )
inlineprotectedvirtual

set up the mockup that is needed by the tests

  • a mini StoreArray with SpacePoints, TrueHits and MCParticles
  • relations between TrueHits and MCparticles and between SpacePoints and TrueHits

Definition at line 140 of file purityCalculatorTools.cc.

141 {
143
144 // register everything necessary in the datastore
145 m_pxdTrueHits.registerInDataStore("PXDTHs");
146 m_svdTrueHits.registerInDataStore("SVDTHs");
147 m_spacePoints.registerInDataStore("SPs");
148 m_mcParticles.registerInDataStore("MCPs");
149
150 // register the needed relations
151 m_spacePoints.registerRelationTo(m_svdTrueHits);
152 m_spacePoints.registerRelationTo(m_pxdTrueHits);
153 m_mcParticles.registerRelationTo(m_svdTrueHits);
154 m_mcParticles.registerRelationTo(m_pxdTrueHits);
155
157
158 // populate datastore
159 MCParticle* mcPart1 = m_mcParticles.appendNew(createMCParticle());
160 MCParticle* mcPart2 = m_mcParticles.appendNew(createMCParticle());
161
162 // add a PXD (ideal case: one TrueHit -> one MCParticle)
163 VxdID pxdId(1, 1, 1);
164 PXDTrueHit* pTrueHit = m_pxdTrueHits.appendNew(createTrueHit<PXDTrueHit>(pxdId));
165 mcPart1->addRelationTo(pTrueHit);
166 SpacePoint* spacePoint = m_spacePoints.appendNew(createSpacePoint(pxdId, true));
167 spacePoint->addRelationTo(pTrueHit, 1); // PXD has only one Cluster
168 m_assignedClusters.push_back(1);
169
170 // add a PXD (non-ideal case: no TrueHit)
171 m_spacePoints.appendNew(createSpacePoint(pxdId, true));
172 m_assignedClusters.push_back(1);
173
174 // add a PXD (non-ideal case: more than one (i.e. two for the test) TrueHits -> 2 MCParticles)
175 PXDTrueHit* pTrueHit2 = m_pxdTrueHits.appendNew(createTrueHit<PXDTrueHit>(pxdId));
176 mcPart2->addRelationTo(pTrueHit2);
177 spacePoint = m_spacePoints.appendNew(createSpacePoint(pxdId, true));
178 spacePoint->addRelationTo(pTrueHit, 1);
179 spacePoint->addRelationTo(pTrueHit2, 1);
180 m_assignedClusters.push_back(1);
181
182 // add a PXD (non-ideal case: more than one (i.e. two for the test) TrueHits -> 1 MCParticles)
183 // -> both TrueHits are related with the same MCParticle (probably a very rare corner case, but this is what testing is for)
184 PXDTrueHit* pTrueHit3 = m_pxdTrueHits.appendNew(createTrueHit<PXDTrueHit>(pxdId));
185 mcPart2->addRelationTo(pTrueHit3);
186 spacePoint = m_spacePoints.appendNew(createSpacePoint(pxdId, true));
187 spacePoint->addRelationTo(pTrueHit3, 1);
188 spacePoint->addRelationTo(pTrueHit2, 1);
189 m_assignedClusters.push_back(1);
190
191 // NOTE: SVD only testing two Clusters SpacePoints since single Clusters are essentially the same as PXDs!
192 // SVD: first set up some SVDTrueHits with differing relations to MCParticles
193 VxdID svdId(3, 1, 1);
194 SVDTrueHit* sTH2MC1 = m_svdTrueHits.appendNew(createTrueHit<SVDTrueHit>(svdId)); // related to mcParticle1
195 mcPart1->addRelationTo(sTH2MC1);
196 SVDTrueHit* sTH2MC2 = m_svdTrueHits.appendNew(createTrueHit<SVDTrueHit>(svdId)); // related to mcParticle2
197 mcPart2->addRelationTo(sTH2MC2);
198 SVDTrueHit* sTH2None = m_svdTrueHits.appendNew(createTrueHit<SVDTrueHit>(svdId)); // related to no MCParticle
199
200 // add a SVD (ideal case: two Clusters -> 1 TrueHit -> 1 MCParticle)
201 spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
202 spacePoint->addRelationTo(sTH2MC1, 2); // both Clusters to one TrueHit
203 m_assignedClusters.push_back(2);
204
205 // add a SVD (non-ideal case: twoClusters -> 2 TrueHits -> 2 MCParticles)
206 spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
207 m_assignedClusters.push_back(2);
208 spacePoint->addRelationTo(sTH2MC1, 11); // U-Cluster
209 spacePoint->addRelationTo(sTH2MC2, 21); // V-Cluster
210
211 // add a SVD (non-ideal case: no related TrueHits)
212 m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
213 m_assignedClusters.push_back(2);
214
215 // add a SVD (non-ideal case: twoClusters -> 2 TrueHits -> 2 MCParticles with different numbers of related Clusters
216 // for TrueHits)
217 spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
218 m_assignedClusters.push_back(2);
219 spacePoint->addRelationTo(sTH2MC1, 2); // both Clusters related to this TrueHit
220 spacePoint->addRelationTo(sTH2MC2, 11); // only one Cluster related to TrueHit (U-Cluster in this case)
221
222 // add a SVD (non-ideal case: only one Cluster with relation to ONE TrueHit: V-Cluster related)
223 spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
224 m_assignedClusters.push_back(2);
225 spacePoint->addRelationTo(sTH2MC1, 21); // one V-Cluster with relation to TrueHit with relation to MCParticle
226
227 // add a SVD (non-ideal case: only one Cluster with relation to ONE TrueHit: U-Cluster related)
228 spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
229 m_assignedClusters.push_back(2);
230 spacePoint->addRelationTo(sTH2MC2, 11); // one U-Cluster with relation to TrueHit with relation to MCParticle
231
232 // add a SVD (non-ideal case: only one TrueHit has a relation to a MCParticle)
233 spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
234 m_assignedClusters.push_back(2);
235 spacePoint->addRelationTo(sTH2MC1, 11); // U-Cluster
236 spacePoint->addRelationTo(sTH2None, 21); // V-Cluster without relation to MCParticle
237
238 // add a SVD (non-ideal case: one Cluster has relations to more than one TrueHit, while the other has not)
239 spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
240 m_assignedClusters.push_back(2);
241 spacePoint->addRelationTo(sTH2MC1, 11); // U-Cluster
242 spacePoint->addRelationTo(sTH2MC2, 11); // U-Cluster, no relation for V-Cluster
243
244 // add singleCluster SpacePoints for testing the increaseCounterMethod. Do not need any relations!
245 // NOTE: these shall not be included in the testing of the other methods!
246 m_spacePoints.appendNew(createSpacePoint(svdId, false, -1)); // add V-Cluster set only
247 m_assignedClusters.push_back(1);
248 m_spacePoints.appendNew(createSpacePoint(svdId, false, 1)); // add U-Cluster set only
249 m_assignedClusters.push_back(1);
250 }
static DataStore & Instance()
Instance of singleton Store.
Definition DataStore.cc:53
void setInitializeActive(bool active)
Setter for m_initializeActive.
Definition DataStore.cc:93
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).

◆ TearDown()

virtual void TearDown ( )
inlineprotectedvirtual

tear down environment after test -> clear datastore

Definition at line 253 of file purityCalculatorTools.cc.

void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
Definition DataStore.cc:85

Member Data Documentation

◆ m_assignedClusters

std::vector<short> m_assignedClusters
protected

store the expected number of assigned Clusters in vector to be able to loop over it

Definition at line 261 of file purityCalculatorTools.cc.

◆ m_mcParticles

StoreArray<Belle2::MCParticle> m_mcParticles
protected

some MCParticles for testing

Definition at line 259 of file purityCalculatorTools.cc.

◆ m_pxdTrueHits

StoreArray<Belle2::PXDTrueHit> m_pxdTrueHits
protected

some PXDTrueHits for testing

Definition at line 256 of file purityCalculatorTools.cc.

◆ m_spacePoints

StoreArray<Belle2::SpacePoint> m_spacePoints
protected

some SpacePoints for testing

Definition at line 258 of file purityCalculatorTools.cc.

◆ m_svdTrueHits

StoreArray<Belle2::SVDTrueHit> m_svdTrueHits
protected

some SVDTrueHits for testing

Definition at line 257 of file purityCalculatorTools.cc.


The documentation for this class was generated from the following file: