Belle II Software development
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#include <analysis/dataobjects/Particle.h>
11#include <analysis/dataobjects/ParticleList.h>
12#include <framework/database/DBObjPtr.h>
13
14using namespace std;
15using namespace Belle2;
16
17//-----------------------------------------------------------------
18// Register module
19//-----------------------------------------------------------------
20
21REG_MODULE(PseudoVertexFitter);
22
23//-----------------------------------------------------------------
24// Implementation
25//-----------------------------------------------------------------
26
28{
29 // set module description (e.g. insert text)
30 setDescription("Pseudo fitter adds a covariance matrix which is sum of the daughter covariance matrices.");
32
33 // Add parameters
34 addParam("listName", m_listName, "name of particle list", string(""));
35}
36
38{
39 if (m_listName == "") {
40 B2ERROR("No list name specified! Please enter the list name of the particle you want to add a covariance matrix to.");
41 return;
42 }
43 B2INFO("PseudoVertexFitter: adding covariance matrix to " << m_listName);
44
45}
46
48{
50 if (!plist) {
51 B2ERROR("ParticleList " << m_listName << " not found");
52 return;
53 }
54
55 unsigned int n = plist->getListSize();
56 for (unsigned i = 0; i < n; i++) {
57 Particle* particle = plist->getParticle(i);
58
59 bool ok = add_matrix(particle);
60
61 if (!ok) particle->setPValue(-1);
62 }
63}
64
66{
67 // steering starts here
68 if (mother->getNDaughters() < 2) return false;
69
70 bool ok = false;
71
72 const std::vector<Particle*> daughters = mother->getDaughters();
73 std::vector<TMatrixFSym> daughter_matrices;
74 daughter_matrices.reserve(daughters.size());
75 for (auto daughter : daughters) {
76 daughter_matrices.push_back(daughter->getMomentumVertexErrorMatrix());
77 }
78
79 TMatrixFSym mother_errMatrix(7);
80 for (int i = 0; i < 7; i++) {
81 for (int j = 0; j < 7; j++) {
82 for (unsigned int k = 0; k < daughters.size(); k++) {
83 mother_errMatrix[i][j] += daughter_matrices[k][i][j];
84 }
85 }
86 }
87
88 mother->setMomentumVertexErrorMatrix(mother_errMatrix);
89 if (mother->getMomentumVertexErrorMatrix() == mother_errMatrix) {
90 ok = true;
91 }
92 if (!ok) return false;
93 return true;
94}
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:75
unsigned getNDaughters(void) const
Returns number of daughter particles.
Definition: Particle.h:727
std::vector< Belle2::Particle * > getDaughters() const
Returns a vector of pointers to daughter particles.
Definition: Particle.cc:637
void setMomentumVertexErrorMatrix(const TMatrixFSym &errMatrix)
Sets 7x7 error matrix.
Definition: Particle.cc:393
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
Definition: Particle.cc:420
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: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.
STL namespace.