Belle II Software  release-08-01-10
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 130 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 137 of file purityCalculatorTools.cc.

138  {
139  DataStore::Instance().setInitializeActive(true);
140 
141  // register everything necessary in the datastore
146 
147  // register the needed relations
152 
153  DataStore::Instance().setInitializeActive(false);
154 
155  // populate datastore
156  MCParticle* mcPart1 = m_mcParticles.appendNew(createMCParticle());
157  MCParticle* mcPart2 = m_mcParticles.appendNew(createMCParticle());
158 
159  // add a PXD (ideal case: one TrueHit -> one MCParticle)
160  VxdID pxdId(1, 1, 1);
161  PXDTrueHit* pTrueHit = m_pxdTrueHits.appendNew(createTrueHit<PXDTrueHit>(pxdId));
162  mcPart1->addRelationTo(pTrueHit);
163  SpacePoint* spacePoint = m_spacePoints.appendNew(createSpacePoint(pxdId, true));
164  spacePoint->addRelationTo(pTrueHit, 1); // PXD has only one Cluster
165  m_assignedClusters.push_back(1);
166 
167  // add a PXD (non-ideal case: no TrueHit)
168  m_spacePoints.appendNew(createSpacePoint(pxdId, true));
169  m_assignedClusters.push_back(1);
170 
171  // add a PXD (non-ideal case: more than one (i.e. two for the test) TrueHits -> 2 MCParticles)
172  PXDTrueHit* pTrueHit2 = m_pxdTrueHits.appendNew(createTrueHit<PXDTrueHit>(pxdId));
173  mcPart2->addRelationTo(pTrueHit2);
174  spacePoint = m_spacePoints.appendNew(createSpacePoint(pxdId, true));
175  spacePoint->addRelationTo(pTrueHit, 1);
176  spacePoint->addRelationTo(pTrueHit2, 1);
177  m_assignedClusters.push_back(1);
178 
179  // add a PXD (non-ideal case: more than one (i.e. two for the test) TrueHits -> 1 MCParticles)
180  // -> both TrueHits are related with the same MCParticle (probably a very rare corner case, but this is what testing is for)
181  PXDTrueHit* pTrueHit3 = m_pxdTrueHits.appendNew(createTrueHit<PXDTrueHit>(pxdId));
182  mcPart2->addRelationTo(pTrueHit3);
183  spacePoint = m_spacePoints.appendNew(createSpacePoint(pxdId, true));
184  spacePoint->addRelationTo(pTrueHit3, 1);
185  spacePoint->addRelationTo(pTrueHit2, 1);
186  m_assignedClusters.push_back(1);
187 
188  // NOTE: SVD only testing two Clusters SpacePoints since single Clusters are essentially the same as PXDs!
189  // SVD: first set up some SVDTrueHits with differing relations to MCParticles
190  VxdID svdId(3, 1, 1);
191  SVDTrueHit* sTH2MC1 = m_svdTrueHits.appendNew(createTrueHit<SVDTrueHit>(svdId)); // related to mcParticle1
192  mcPart1->addRelationTo(sTH2MC1);
193  SVDTrueHit* sTH2MC2 = m_svdTrueHits.appendNew(createTrueHit<SVDTrueHit>(svdId)); // related to mcParticle2
194  mcPart2->addRelationTo(sTH2MC2);
195  SVDTrueHit* sTH2None = m_svdTrueHits.appendNew(createTrueHit<SVDTrueHit>(svdId)); // related to no MCParticle
196 
197  // add a SVD (ideal case: two Clusters -> 1 TrueHit -> 1 MCParticle)
198  spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
199  spacePoint->addRelationTo(sTH2MC1, 2); // both Clusters to one TrueHit
200  m_assignedClusters.push_back(2);
201 
202  // add a SVD (non-ideal case: twoClusters -> 2 TrueHits -> 2 MCParticles)
203  spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
204  m_assignedClusters.push_back(2);
205  spacePoint->addRelationTo(sTH2MC1, 11); // U-Cluster
206  spacePoint->addRelationTo(sTH2MC2, 21); // V-Cluster
207 
208  // add a SVD (non-ideal case: no related TrueHits)
209  m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
210  m_assignedClusters.push_back(2);
211 
212  // add a SVD (non-ideal case: twoClusters -> 2 TrueHits -> 2 MCParticles with different numbers of related Clusters
213  // for TrueHits)
214  spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
215  m_assignedClusters.push_back(2);
216  spacePoint->addRelationTo(sTH2MC1, 2); // both Clusters related to this TrueHit
217  spacePoint->addRelationTo(sTH2MC2, 11); // only one Cluster related to TrueHit (U-Cluster in this case)
218 
219  // add a SVD (non-ideal case: only one Cluster with relation to ONE TrueHit: V-Cluster related)
220  spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
221  m_assignedClusters.push_back(2);
222  spacePoint->addRelationTo(sTH2MC1, 21); // one V-Cluster with relation to TrueHit with relation to MCParticle
223 
224  // add a SVD (non-ideal case: only one Cluster with relation to ONE TrueHit: U-Cluster related)
225  spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
226  m_assignedClusters.push_back(2);
227  spacePoint->addRelationTo(sTH2MC2, 11); // one U-Cluster with relation to TrueHit with relation to MCParticle
228 
229  // add a SVD (non-ideal case: only one TrueHit has a relation to a MCParticle)
230  spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
231  m_assignedClusters.push_back(2);
232  spacePoint->addRelationTo(sTH2MC1, 11); // U-Cluster
233  spacePoint->addRelationTo(sTH2None, 21); // V-Cluster without relation to MCParticle
234 
235  // add a SVD (non-ideal case: one Cluster has relations to more than one TrueHit, while the other has not)
236  spacePoint = m_spacePoints.appendNew(createSpacePoint(svdId, false, 0)); // add twoCluster SP
237  m_assignedClusters.push_back(2);
238  spacePoint->addRelationTo(sTH2MC1, 11); // U-Cluster
239  spacePoint->addRelationTo(sTH2MC2, 11); // U-Cluster, no relation for V-Cluster
240 
241  // add singleCluster SpacePoints for testing the increaseCounterMethod. Do not need any relations!
242  // NOTE: these shall not be included in the testing of the other methods!
243  m_spacePoints.appendNew(createSpacePoint(svdId, false, -1)); // add V-Cluster set only
244  m_assignedClusters.push_back(1);
245  m_spacePoints.appendNew(createSpacePoint(svdId, false, 1)); // add U-Cluster set only
246  m_assignedClusters.push_back(1);
247  }
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Class PXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition: PXDTrueHit.h:31
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).
Class SVDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition: SVDTrueHit.h:33
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
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:140
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
StoreArray< Belle2::MCParticle > m_mcParticles
some MCParticles for testing
StoreArray< Belle2::SpacePoint > m_spacePoints
some SpacePoints for testing
std::vector< short > m_assignedClusters
store the expected number of assigned Clusters in vector to be able to loop over it
StoreArray< Belle2::PXDTrueHit > m_pxdTrueHits
some PXDTrueHits for testing
StoreArray< Belle2::SVDTrueHit > m_svdTrueHits
some SVDTrueHits for testing

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