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