Belle II Software  release-05-02-19
PurityCalculatorToolsTest Class Reference

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

Inheritance diagram for PurityCalculatorToolsTest:
Collaboration diagram for PurityCalculatorToolsTest:

Protected Member Functions

virtual void SetUp ()
 set up the mockup that is needed by the tests More...
 
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 132 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 139 of file purityCalculatorTools.cc.

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

The documentation for this class was generated from the following file:
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::StoreArray::registerRelationTo
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:150
Belle2::PXDTrueHit
Class PXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition: PXDTrueHit.h:35
Belle2::SVDTrueHit
Class SVDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition: SVDTrueHit.h:35
Belle2::RelationsInterface::addRelationTo
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).
Definition: RelationsObject.h:144
PurityCalcTests::PurityCalculatorToolsTest::m_pxdTrueHits
StoreArray< Belle2::PXDTrueHit > m_pxdTrueHits
some PXDTrueHits for testing
Definition: purityCalculatorTools.cc:255
PurityCalcTests::PurityCalculatorToolsTest::m_svdTrueHits
StoreArray< Belle2::SVDTrueHit > m_svdTrueHits
some SVDTrueHits for testing
Definition: purityCalculatorTools.cc:256
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
PurityCalcTests::PurityCalculatorToolsTest::m_spacePoints
StoreArray< Belle2::SpacePoint > m_spacePoints
some SpacePoints for testing
Definition: purityCalculatorTools.cc:257
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
PurityCalcTests::PurityCalculatorToolsTest::m_mcParticles
StoreArray< Belle2::MCParticle > m_mcParticles
some MCParticles for testing
Definition: purityCalculatorTools.cc:258
PurityCalcTests::PurityCalculatorToolsTest::m_assignedClusters
std::vector< short > m_assignedClusters
store the expected number of assigned Clusters in vector to be able to loop over it
Definition: purityCalculatorTools.cc:260