Belle II Software light-2406-ragdoll
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/datastore/RelationArray.h>
12#include <framework/geometry/BFieldManager.h>
13
14#include <analysis/DecayDescriptor/DecayDescriptor.h>
15#include <analysis/ClusterUtility/ClusterUtils.h>
16
17#include <TDatabasePDG.h>
18#include <Math/Vector3D.h>
19#include <vector>
20
21using namespace Belle2;
22using namespace ROOT::Math;
23
24//-----------------------------------------------------------------
25// Register the Module
26//-----------------------------------------------------------------
27REG_MODULE(TrackFitResultEstimator);
28
29//-----------------------------------------------------------------
30// Implementation
31//-----------------------------------------------------------------
32
34{
35 // Set module properties
36 setDescription(R"DOC(
37Create a TrackFitResult from the momentum of the Particle assuming it originates from the IP and make a relation between them. The
38covariance, detector hit information, and fit-related information (pValue, NDF) are assigned meaningless values. The input
39Particles must not have already Track or TrackFitResult and thus are supposed to be composite particles, recoil, dummy particles,
40and so on. Since the source type is not overwritten as Track, not all track-related variables are guaranteed to be available.
41)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 (abs(TDatabasePDG::Instance()->GetParticle(pdg)->Charge()) > 3)
58 B2WARNING("The absolute value of charge of input ParticleList is grater than 1. Helix requires abs(charge) <= 1. "
59 "The sign of charge will be used instead.");
60
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 = XYZVector(m_beamSpotDB->getIPPosition().X(), m_beamSpotDB->getIPPosition().Y(), m_beamSpotDB->getIPPosition().Z());
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 (abs(charge)>1)
87 charge = charge / 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.
Definition: BFieldManager.h:61
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
Class to store reconstructed particles.
Definition: Particle.h:75
const Track * getTrack() const
Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Trac...
Definition: Particle.cc:845
int getPDGCode(void) const
Returns PDG code.
Definition: Particle.h:454
double getCharge(void) const
Returns particle charge.
Definition: Particle.cc:622
ROOT::Math::XYZVector getMomentum() const
Returns momentum vector.
Definition: Particle.h:560
const TrackFitResult * getTrackFitResult() const
Returns the pointer to the TrackFitResult that was used to create this Particle (ParticleType == c_Tr...
Definition: Particle.cc:854
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:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24