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 for (const auto& listName : m_motherListNames) {
46 StoreObjPtr<ParticleList> list(listName);
47 auto listSize = list->getListSize(false);
48 for (unsigned int iParticle = 0; iParticle < listSize; ++iParticle) {
49 auto mother = list->getParticle(iParticle, false);
50 for (auto daughter : mother->getDaughters()) {
51 auto particle = daughter;
52 auto track = particle->getTrack();
53 auto trackFitResult = track->getTrackFitResult(Const::pion);
54 if (not trackFitResult) {
55 B2WARNING("Skipping track without valid pion hypothesis.");
56 continue;
57 }
58 auto trackCand = trackFitResult->getRelatedFrom<genfit::TrackCand>();
59
61 genfit::TrackCand copyCand(*trackCand);
62 trackCand->reset();
63 for (unsigned int iCandHit = 0; iCandHit < copyCand.getNHits(); ++iCandHit) {
64 int hitID, detID;
65 double sortingParameter;
66 copyCand.getHit(iCandHit, detID, hitID, sortingParameter);
67
68 if (m_removePXD && detID == Const::PXD) continue;
69 if (m_removeSVD && detID == Const::SVD) continue;
70 if (m_removeCDC && detID == Const::CDC) continue;
71 if (m_removeBKLM && detID == Const::KLM) continue;
72
73 trackCand->addHit(detID, hitID, -1, sortingParameter);
74 }
75 }
76
77 B2Vector3D vertexPos = particle->getVertex();
78 B2Vector3D vertexMom = particle->getMomentum();
79 trackCand->setPosMomSeed(vertexPos, vertexMom, particle->getCharge());
80 trackCand->setPdgCode(particle->getPDGCode());
81 }
82 }
83 }
84}
85
static const ChargedStable pion
charged pion particle
Definition Const.h:661
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Module()
Constructor.
Definition Module.cc:30
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition B2Vector3.h:516
Abstract base class for different kinds of events.