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