Belle II Software light-2501-betelgeuse
PseudoVertexFitterModule.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/PseudoVertexFitter/PseudoVertexFitterModule.h>
10
11#include <analysis/dataobjects/Particle.h>
12#include <analysis/dataobjects/ParticleList.h>
13
14#include <framework/datastore/StoreObjPtr.h>
15
16using namespace std;
17using namespace Belle2;
18
19//-----------------------------------------------------------------
20// Register module
21//-----------------------------------------------------------------
22
23REG_MODULE(PseudoVertexFitter);
24
25//-----------------------------------------------------------------
26// Implementation
27//-----------------------------------------------------------------
28
30{
31 // set module description (e.g. insert text)
32 setDescription("Pseudo fitter adds a covariance matrix which is sum of the daughter covariance matrices.");
34
35 // Add parameters
36 addParam("listName", m_listName, "name of particle list", string(""));
37}
38
40{
41 if (m_listName == "") {
42 B2ERROR("No list name specified! Please enter the list name of the particle you want to add a covariance matrix to.");
43 return;
44 }
45 B2INFO("PseudoVertexFitter: adding covariance matrix to " << m_listName);
46
47}
48
50{
52 if (!plist) {
53 B2ERROR("ParticleList " << m_listName << " not found");
54 return;
55 }
56
57 unsigned int n = plist->getListSize();
58 for (unsigned i = 0; i < n; i++) {
59 Particle* particle = plist->getParticle(i);
60
61 bool ok = add_matrix(particle);
62
63 if (!ok) particle->setPValue(-1);
64 }
65}
66
68{
69 // steering starts here
70 if (mother->getNDaughters() < 2) return false;
71
72 bool ok = false;
73
74 const std::vector<Particle*> daughters = mother->getDaughters();
75 std::vector<TMatrixFSym> daughter_matrices;
76 daughter_matrices.reserve(daughters.size());
77 for (auto daughter : daughters) {
78 daughter_matrices.push_back(daughter->getMomentumVertexErrorMatrix());
79 }
80
81 TMatrixFSym mother_errMatrix(7);
82 for (int i = 0; i < 7; i++) {
83 for (int j = 0; j < 7; j++) {
84 for (unsigned int k = 0; k < daughters.size(); k++) {
85 mother_errMatrix[i][j] += daughter_matrices[k][i][j];
86 }
87 }
88 }
89
90 mother->setMomentumVertexErrorMatrix(mother_errMatrix);
91 if (mother->getMomentumVertexErrorMatrix() == mother_errMatrix) {
92 ok = true;
93 }
94 if (!ok) return false;
95 return true;
96}
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
unsigned getNDaughters(void) const
Returns number of daughter particles.
Definition: Particle.h:747
std::vector< Belle2::Particle * > getDaughters() const
Returns a vector of pointers to daughter particles.
Definition: Particle.cc:667
void setMomentumVertexErrorMatrix(const TMatrixFSym &errMatrix)
Sets 7x7 error matrix.
Definition: Particle.cc:423
void setPValue(double pValue)
Sets chi^2 probability of fit.
Definition: Particle.h:377
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
Definition: Particle.cc:450
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
std::string m_listName
particle list name
bool add_matrix(Particle *p)
Main steering routine.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
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.
Definition: ClusterUtils.h:24
STL namespace.