Belle II Software  release-06-02-00
SPTCvirtualIPRemoverModule.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #include <tracking/modules/spacePointCreator/SPTCvirtualIPRemoverModule.h>
10 #include <framework/logging/Logger.h>
11 
12 using namespace std;
13 using namespace Belle2;
14 
15 
16 REG_MODULE(SPTCvirtualIPRemover)
17 
19 {
20  InitializeCounters();
21 
22  //Set module properties
23  setDescription("The quality estimator module for SpacePointTrackCandidates using a circleFit.");
24  setPropertyFlags(c_ParallelProcessingCertified);
25 
26  addParam("tcArrayName", m_PARAMtcArrayName, " sets the name of expected StoreArray with SpacePointTrackCand in it", string(""));
27 
28  addParam("doCheckOnly", m_PARAMdoCheckOnly, " if true, no vIP is removed, but only nVIPs are counted.", bool(false));
29 
30  addParam("maxTCLengthForVIPKeeping", m_PARAMmaxTCLengthForVIPKeeping,
31  "If you want to keep the vIP only for short TCs, then set this value to the number of hits a TC is maximally allowed to have to not loose its vIP (number of hits without counting the vIP).",
32  unsigned(3));
33 }
34 
35 
36 void SPTCvirtualIPRemoverModule::event()
37 {
38  m_eventCounter++;
39  B2DEBUG(1, "\n" << "SPTCvirtualIPRemoverModule:event: event " << m_eventCounter << "\n");
40  m_nTCsTotal += m_spacePointTrackCands.getEntries();
41 
42  unsigned nTC = 0;
43  // assign a QI computed using a circleFit for each given SpacePointTrackCand
44  for (SpacePointTrackCand& aTC : m_spacePointTrackCands) {
45 
46  unsigned nHits = aTC.size();
47  bool hasVIP = false;
48 
49  // search for first vIP in SPTC and remove if parameter doCheckOnly == false. all further VIPs are ignored!
50  const std::vector<const SpacePoint*>& spacePoints = aTC.getHits();
51  for (unsigned int iSp = 0; iSp < spacePoints.size(); ++iSp) {
52  const SpacePoint* aHit = spacePoints[iSp];
53  if (aHit->getType() == VXD::SensorInfoBase::SensorType::VXD) { // vIP found
54  m_nVIPsTotal++;
55  hasVIP = true;
56  if (m_PARAMdoCheckOnly or (m_PARAMmaxTCLengthForVIPKeeping + 1 >= nHits)) continue;
57 
58  aTC.removeSpacePoint(iSp);
59  m_nVIPsRemoved++;
60  break; // stopping here, since now the list of SpacePoint* do not anymore more with actual Spacepoints in SPTC!
61  }
62  }
63 
64  B2DEBUG(1, "SPTCvirtualIPRemoverModule:event: event " << m_eventCounter
65  << ": TC " << nTC
66  << " with " << nHits
67  << " hits has vIP: " << (hasVIP ? "true" : "false")
68  << " and was removed " << (m_PARAMdoCheckOnly ? "false" : "true")
69  );
70  ++nTC;
71  }
72 
73 }
74 
75 
76 void SPTCvirtualIPRemoverModule::endRun()
77 {
78  if (m_eventCounter == 0) { m_eventCounter++; } // prevents division by zero
79  double invEvents = 1. / m_eventCounter;
80 
81  B2DEBUG(1, "SPTCvirtualIPRemoverModule:endRun: events: " << m_eventCounter
82  << ", nSPTCsPerEvent: " << invEvents * float(m_nTCsTotal)
83  << ", nVIPsPerEvent: " << invEvents * float(m_nVIPsTotal)
84  << ", nVIPsRemovedPerEvent: " << invEvents * float(m_nVIPsRemoved)
85  );
86 }
Base class for Modules.
Definition: Module.h:72
A module for checking and removing the virtual IP if wanted.
Storage for (VXD) SpacePoint-based track candidates.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
Belle2::VXD::SensorInfoBase::SensorType getType() const
Return SensorType (PXD, SVD, ...) on which the SpacePoint lives.
Definition: SpacePoint.h:145
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.