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
18using namespace Belle2;
19using namespace ROOT::Math;
20
21//-----------------------------------------------------------------
22// Register the Module
23//-----------------------------------------------------------------
24REG_MODULE(TrackFitResultEstimator);
25
26//-----------------------------------------------------------------
27// Implementation
28//-----------------------------------------------------------------
29
31{
32 // Set module properties
33 setDescription(R"DOC(
34Create a TrackFitResult from the momentum of the Particle assuming it originates from the IP and make a relation between them. The
35covariance, detector hit information, and fit-related information (pValue, NDF) are assigned meaningless values. The input
36Particles must not have already Track or TrackFitResult and thus are supposed to be composite particles, recoil, dummy particles,
37and so on. Since the source type is not overwritten as Track, not all track-related variables are guaranteed to be available.
38)DOC");
40
41 // Parameter definitions
42 addParam("inputListName", m_inputListName,
43 "The name of input ParticleList.",
44 std::string(""));
45}
46
48{
49 DecayDescriptor decaydescriptor;
50 bool valid = decaydescriptor.init(m_inputListName);
51 if (!valid)
52 B2ERROR("Invalid input ParticleList name: " << m_inputListName);
53
54 const int pdg = decaydescriptor.getMother()->getPDGCode();
55 if (abs(TDatabasePDG::Instance()->GetParticle(pdg)->Charge()) > 3)
56 B2WARNING("The absolute value of charge of input ParticleList is grater than 1. Helix requires abs(charge) <= 1. "
57 "The sign of charge will be used instead.");
58
61}
62
64{
65
66 TMatrixDSym dummyCovariance(6);
67 for (int row = 0; row < 6; ++row) {
68 dummyCovariance(row, row) = 10000;
69 }
70
71 XYZVector position(0,0,0);
72 if (m_beamSpotDB)
73 position = XYZVector(m_beamSpotDB->getIPPosition().X(), m_beamSpotDB->getIPPosition().Y(), m_beamSpotDB->getIPPosition().Z());
74
75 const double bfield = BFieldManager::getFieldInTesla(position).Z();
76
77 for (unsigned i = 0; i < m_inputparticleList->getListSize(); i++) {
78 Particle* part = m_inputparticleList->getParticle(i);
79
80 if (part->getTrack() or part->getTrackFitResult())
81 B2ERROR("Particle is already related to the Track or TrackFitResult object.");
82
83 int charge = part->getCharge();
84 if (abs(charge)>1)
85 charge = charge / abs(charge);
86
87 TrackFitResult* trkfit = m_trackfitresults.appendNew(position,
88 part->getMomentum(),
89 dummyCovariance,
90 charge,
92 -1, // pValue
93 bfield,
94 0, 0, // CDC, VXD hit-pattern
95 0 // NDF
96 );
97 part->addRelationTo(trkfit);
98 }
99
100}
static ROOT::Math::XYZVector getFieldInTesla(const ROOT::Math::XYZVector &pos)
return the magnetic field at a given position in Tesla.
Definition: BFieldManager.h:60
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.
Base class for Modules.
Definition: Module.h:72
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
@ 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).
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:140
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.