Belle II Software development
TrackFitResultEstimator.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 <analysis/modules/TrackFitResultEstimator/TrackFitResultEstimator.h>
10
11#include <framework/geometry/BFieldManager.h>
12
13#include <analysis/DecayDescriptor/DecayDescriptor.h>
14
15#include <TDatabasePDG.h>
16#include <Math/Vector3D.h>
17
18#include <cmath>
19
20using namespace Belle2;
21using namespace ROOT::Math;
22
23//-----------------------------------------------------------------
24// Register the Module
25//-----------------------------------------------------------------
26REG_MODULE(TrackFitResultEstimator);
27
28//-----------------------------------------------------------------
29// Implementation
30//-----------------------------------------------------------------
31
33{
34 // Set module properties
35 setDescription(R"DOC(
36Create a TrackFitResult from the momentum of the Particle assuming it originates from the IP and make a relation between them. The
37covariance, detector hit information, and fit-related information (pValue, NDF) are assigned meaningless values. The input
38Particles must not have already Track or TrackFitResult and thus are supposed to be composite particles, recoil, dummy particles,
39and so on. Since the source type is not overwritten as Track, not all track-related variables are guaranteed to be available.
40)DOC");
42
43 // Parameter definitions
44 addParam("inputListName", m_inputListName,
45 "The name of input ParticleList.",
46 std::string(""));
47}
48
50{
51 DecayDescriptor decaydescriptor;
52 bool valid = decaydescriptor.init(m_inputListName);
53 if (!valid)
54 B2ERROR("Invalid input ParticleList name: " << m_inputListName);
55
56 const int pdg = decaydescriptor.getMother()->getPDGCode();
57 if (std::abs(TDatabasePDG::Instance()->GetParticle(pdg)->Charge()) > 3)
58 B2WARNING("The absolute value of charge of input ParticleList is greater than 1. Helix requires abs(charge) <= 1. "
59 "The sign of charge will be used instead.");
60
62 m_particles.registerRelationTo(m_trackfitresults);
63}
64
66{
67
68 TMatrixDSym dummyCovariance(6);
69 for (int row = 0; row < 6; ++row) {
70 dummyCovariance(row, row) = 10000;
71 }
72
73 XYZVector position(0,0,0);
74 if (m_beamSpotDB)
75 position = m_beamSpotDB->getIPPosition();
76
77 const double bfield = BFieldManager::getFieldInTesla(position).Z();
78
79 for (unsigned i = 0; i < m_inputparticleList->getListSize(); i++) {
80 Particle* part = m_inputparticleList->getParticle(i);
81
82 if (part->getTrack() or part->getTrackFitResult())
83 B2ERROR("Particle is already related to the Track or TrackFitResult object.");
84
85 int charge = part->getCharge();
86 if (std::abs(charge)>1)
87 charge = charge / std::abs(charge);
88
89 TrackFitResult* trkfit = m_trackfitresults.appendNew(position,
90 part->getMomentum(),
91 dummyCovariance,
92 charge,
94 -1, // pValue
95 bfield,
96 0, 0, // CDC, VXD hit-pattern
97 0 // NDF
98 );
99 part->addRelationTo(trkfit);
100 }
101
102}
static ROOT::Math::XYZVector getFieldInTesla(const ROOT::Math::XYZVector &pos)
return the magnetic field at a given position in Tesla.
The ParticleType class for identifying different particle types.
Definition Const.h:408
int getPDGCode() const
Return PDG code.
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
const DecayDescriptorParticle * getMother() const
return mother.
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
Module()
Constructor.
Definition Module.cc:30
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
Class to store reconstructed particles.
Definition Particle.h:76
const Track * getTrack() const
Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Trac...
Definition Particle.cc:916
int getPDGCode(void) const
Returns PDG code.
Definition Particle.h:465
double getCharge(void) const
Returns particle charge.
Definition Particle.cc:653
ROOT::Math::XYZVector getMomentum() const
Returns momentum vector.
Definition Particle.h:580
const TrackFitResult * getTrackFitResult() const
Returns the pointer to the TrackFitResult that was used to create this Particle (ParticleType == c_Tr...
Definition Particle.cc:925
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).
StoreArray< TrackFitResult > m_trackfitresults
StoreArray of TrackFitResult objects.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
StoreArray< Particle > m_particles
StoreArray of Particle objects.
DBObjPtr< BeamSpot > m_beamSpotDB
Beam spot database object.
StoreObjPtr< ParticleList > m_inputparticleList
StoreObjptr for input charged ParticleList.
std::string m_inputListName
The name of input ParticleList.
Values of the result of a track fit with a given particle hypothesis.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.