Belle II Software development
UpdateParticleTrackCandModule.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 <alignment/modules/UpdateParticleTrackCand/UpdateParticleTrackCandModule.h>
10
11#include <analysis/dataobjects/ParticleList.h>
12#include <framework/datastore/StoreObjPtr.h>
13#include <framework/geometry/B2Vector3.h>
14#include <mdst/dataobjects/Track.h>
15
16#include <genfit/TrackCand.h>
17
18using namespace Belle2;
19
20//-----------------------------------------------------------------
21// Register the Module
22//-----------------------------------------------------------------
23REG_MODULE(UpdateParticleTrackCand);
24
25//-----------------------------------------------------------------
26// Implementation
27//-----------------------------------------------------------------
28
30{
31 // Set module properties
32 setDescription("Updates the seed in TrackCand based on fitted state (at vertex)");
33
34 // Parameter definitions
35 addParam("motherListNames", m_motherListNames, "Names of particle list which daughters have to be updated");
36
37 addParam("removePXD", m_removePXD, "Remove PXD hits from TrackCand?", bool(false));
38 addParam("removeSVD", m_removeSVD, "Remove SVD hits from TrackCand?", bool(false));
39 addParam("removeCDC", m_removeCDC, "Remove CDC hits from TrackCand?", bool(false));
40 addParam("removeBKLM", m_removeBKLM, "Remove BKLM hits from TrackCand?", bool(false));
41}
42
44{
45}
46
48{
49 for (auto listName : m_motherListNames) {
50 StoreObjPtr<ParticleList> list(listName);
51 auto listSize = list->getListSize(false);
52 for (unsigned int iParticle = 0; iParticle < listSize; ++iParticle) {
53 auto mother = list->getParticle(iParticle, false);
54 for (auto daughter : mother->getDaughters()) {
55 auto particle = daughter;
56 auto track = particle->getTrack();
57 auto trackFitResult = track->getTrackFitResult(Const::pion);
58 if (not trackFitResult) {
59 B2WARNING("Skipping track without valid pion hypothesis.");
60 continue;
61 }
62 auto trackCand = trackFitResult->getRelatedFrom<genfit::TrackCand>();
63
65 genfit::TrackCand copyCand(*trackCand);
66 trackCand->reset();
67 for (unsigned int iCandHit = 0; iCandHit < copyCand.getNHits(); ++iCandHit) {
68 int hitID, detID;
69 double sortingParameter;
70 copyCand.getHit(iCandHit, detID, hitID, sortingParameter);
71
72 if (m_removePXD && detID == Const::PXD) continue;
73 if (m_removeSVD && detID == Const::SVD) continue;
74 if (m_removeCDC && detID == Const::CDC) continue;
75 if (m_removeBKLM && detID == Const::KLM) continue;
76
77 trackCand->addHit(detID, hitID, -1, sortingParameter);
78 }
79 }
80
81 B2Vector3D vertexPos = particle->getVertex();
82 B2Vector3D vertexMom = particle->getMomentum();
83 trackCand->setPosMomSeed(vertexPos, vertexMom, particle->getCharge());
84 trackCand->setPdgCode(particle->getPDGCode());
85 }
86 }
87 }
88}
89
90
91
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
virtual void event() override
update candidates
bool m_removeCDC
Remove CDC hits from TrackCand.
bool m_removePXD
Remove PXD hits from TrackCand.
bool m_removeBKLM
Remove BKLM hits from TrackCand.
bool m_removeSVD
Remove SVD hits from TrackCand.
std::vector< std::string > m_motherListNames
Names of particle list which tracks should be updated.
UpdateParticleTrackCandModule()
Constructor: Sets the description, the properties and the parameters of the module.
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.