Belle II Software  release-06-02-00
SPTCmomentumSeedRetrieverModule.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/SPTCmomentumSeedRetrieverModule.h>
10 #include <framework/logging/Logger.h>
11 #include <framework/geometry/BFieldManager.h>
12 
13 // using namespace std;
14 using namespace Belle2;
15 
16 
17 REG_MODULE(SPTCmomentumSeedRetriever)
18 
20 {
21  //Set module properties
22  setDescription("A module for creating momentum seeds for spacepoint track candidates.");
23  setPropertyFlags(c_ParallelProcessingCertified);
24 
25  addParam("tcArrayName", m_PARAMtcArrayName, " sets the name of expected StoreArray with SpacePointTrackCand in it.",
26  std::string(""));
27 }
28 
29 
31 {
33 
34  // BField is required by all QualityEstimators
35  double bFieldZ = BFieldManager::getField(0, 0, 0).Z() / Unit::T;
36 
39 
40  B2DEBUG(1, "SPTCmomentumSeedRetrieverModule:beginRun: B-Field z-component: " << m_bFieldZ);
41 }
42 
43 
45 {
48  B2DEBUG(1, "\n" << "SPTCmomentumSeedRetrieverModule:event: event " << m_eventCounter << ", got " <<
49  m_spacePointTrackCands.getEntries() << " TCs\n");
50 
51  // create momentum seed for each given SpacePointTrackCand
52  B2DEBUG(1, "Number of TCs in Event = " << m_spacePointTrackCands.getEntries()); // demoted to a B2DEBUG, has been a warning
54  if (!aTC.hasRefereeStatus(SpacePointTrackCand::c_isActive)) continue;
55  B2DEBUG(1, "\n" << "SPTCmomentumSeedRetrieverModule:event: this TC has got " << aTC.size() << " hits\n");
57  }
58 
59 }
60 
61 
63 {
64  if (m_eventCounter == 0) { m_eventCounter++; } // prevents division by zero
65  double invEvents = 1. / m_eventCounter;
66 
67  B2DEBUG(1, "SPTCmomentumSeedRetrieverModule:endRun: events: " << m_eventCounter
68  << ", nSPTCsPerEvent: " << invEvents * float(m_nTCsTotal)
69  );
70 }
71 
72 
74 {
75  TVectorD stateSeed(6); //(x,y,z,px,py,pz)
76  TMatrixDSym covSeed(6);
77  // TODO: find out where these numbers come from!
78  covSeed(0, 0) = 0.01 ; covSeed(1, 1) = 0.01 ; covSeed(2, 2) = 0.04 ; // 0.01 = 0.1^2 = dx*dx =dy*dy. 0.04 = 0.2^2 = dz*dz
79  covSeed(3, 3) = 0.01 ; covSeed(4, 4) = 0.01 ; covSeed(5, 5) = 0.04 ;
80 
81  auto sortedHits = aTC.getSortedHits();
82 
84 
85  stateSeed(0) = (sortedHits.front()->X());
86  stateSeed(1) = (sortedHits.front()->Y());
87  stateSeed(2) = (sortedHits.front()->Z());
88  if (results.p) {
89  auto momentumSeed = *(results.p);
90  stateSeed(3) = momentumSeed.X();
91  stateSeed(4) = momentumSeed.Y();
92  stateSeed(5) = momentumSeed.Z();
93  } else {
94  stateSeed(3) = 0;
95  stateSeed(4) = 0;
96  stateSeed(5) = 0;
97  }
98 
99  aTC.set6DSeed(stateSeed);
100  aTC.setCovSeed(covSeed);
101 
102  double chargeSeed = results.curvatureSign ? -1 * (*(results.curvatureSign)) : 0;
103  aTC.setChargeSeed(chargeSeed);
104 
105  return (results.p && results.curvatureSign);
106 }
Base class for Modules.
Definition: Module.h:72
void setMagneticFieldStrength(double magneticFieldZ=1.5)
Setter for z component of magnetic field.
virtual QualityEstimationResults estimateQualityAndProperties(std::vector< SpacePoint const * > const &measurements)
Quality estimation providing additional quantities Calculates quality indicator in range [0,...
A module for creating momentum seeds for spacepoint track candidates.
QualityEstimatorRiemannHelixFit m_estimator
the QualityEstimator used to determine momentum seed.
unsigned int m_eventCounter
knows current event number.
bool createSPTCmomentumSeed(SpacePointTrackCand &aTC)
Generates momentum seed at the position of innermost hit of given TC.
void event() override
Applies the circleFit at given sets of TCs.
void InitializeCounters()
initialize variables to avoid nondeterministic behavior
void endRun() override
Prints a footer for each run which ended.
void beginRun() override
Prints a header for each new run.
double m_bFieldZ
Bz component of the magnetic field, will be updated runwise.
unsigned int m_nTCsTotal
total number of TCs found in SpacePointTrackCand-container.
StoreArray< SpacePointTrackCand > m_spacePointTrackCands
the storeArray for SpacePointTrackCands as member, is faster than recreating link for each event.
Storage for (VXD) SpacePoint-based track candidates.
void set6DSeed(const TVectorD &state6D)
set the 6D state seed
void setCovSeed(const TMatrixDSym &cov)
set the covariance matrix seed
@ c_isActive
bit 11: SPTC is active (i.e.
const std::vector< const Belle2::SpacePoint * > getSortedHits() const
get hits (space points) sorted by their respective sorting parameter
void setChargeSeed(double charge)
Setter for assumed charge of tracked particle.
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
static const double T
[tesla]
Definition: Unit.h:120
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Abstract base class for different kinds of events.
Container for complete fit/estimation results.