Belle II Software  release-05-02-19
UpdateParticleTrackCandModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: tadeas *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <alignment/modules/UpdateParticleTrackCand/UpdateParticleTrackCandModule.h>
12 
13 #include <analysis/dataobjects/ParticleList.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <framework/geometry/B2Vector3.h>
16 #include <mdst/dataobjects/Track.h>
17 
18 #include <genfit/TrackCand.h>
19 
20 using namespace Belle2;
21 
22 //-----------------------------------------------------------------
23 // Register the Module
24 //-----------------------------------------------------------------
25 REG_MODULE(UpdateParticleTrackCand)
26 
27 //-----------------------------------------------------------------
28 // Implementation
29 //-----------------------------------------------------------------
30 
32 {
33  // Set module properties
34  setDescription("Updates the seed in TrackCand based on fitted state (at vertex)");
35 
36  // Parameter definitions
37  addParam("motherListNames", m_motherListNames, "Names of particle list which daughters have to be updated");
38 
39  addParam("removePXD", m_removePXD, "Remove PXD hits from TrackCand?", bool(false));
40  addParam("removeSVD", m_removeSVD, "Remove SVD hits from TrackCand?", bool(false));
41  addParam("removeCDC", m_removeCDC, "Remove CDC hits from TrackCand?", bool(false));
42  addParam("removeBKLM", m_removeBKLM, "Remove BKLM hits from TrackCand?", bool(false));
43 }
44 
46 {
47 }
48 
50 {
51  for (auto listName : m_motherListNames) {
52  StoreObjPtr<ParticleList> list(listName);
53  auto listSize = list->getListSize(false);
54  for (unsigned int iParticle = 0; iParticle < listSize; ++iParticle) {
55  auto mother = list->getParticle(iParticle, false);
56  for (auto daughter : mother->getDaughters()) {
57  auto particle = daughter;
58  auto track = particle->getTrack();
59  auto trackFitResult = track->getTrackFitResult(Const::pion);
60  if (not trackFitResult) {
61  B2WARNING("Skipping track without valid pion hypothesis.");
62  continue;
63  }
64  auto trackCand = trackFitResult->getRelatedFrom<genfit::TrackCand>();
65 
67  genfit::TrackCand copyCand(*trackCand);
68  trackCand->reset();
69  for (unsigned int iCandHit = 0; iCandHit < copyCand.getNHits(); ++iCandHit) {
70  int hitID, detID;
71  double sortingParameter;
72  copyCand.getHit(iCandHit, detID, hitID, sortingParameter);
73 
74  if (m_removePXD && detID == Const::PXD) continue;
75  if (m_removeSVD && detID == Const::SVD) continue;
76  if (m_removeCDC && detID == Const::CDC) continue;
77  if (m_removeBKLM && detID == Const::KLM) continue;
78 
79  trackCand->addHit(detID, hitID, -1, sortingParameter);
80  }
81  }
82 
83  B2Vector3D vertexPos = particle->getVertex();
84  B2Vector3D vertexMom = particle->getMomentum();
85  trackCand->setPosMomSeed(vertexPos, vertexMom, particle->getCharge());
86  trackCand->setPdgCode(particle->getPDGCode());
87  }
88  }
89  }
90 }
91 
92 
93 
Belle2::UpdateParticleTrackCandModule::initialize
virtual void initialize() override
init
Definition: UpdateParticleTrackCandModule.cc:45
Belle2::UpdateParticleTrackCandModule::m_motherListNames
std::vector< std::string > m_motherListNames
Names of particle list which tracks should be updated.
Definition: UpdateParticleTrackCandModule.h:56
genfit::TrackCand
Track candidate – seed values and indices.
Definition: TrackCand.h:69
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::UpdateParticleTrackCandModule::m_removePXD
bool m_removePXD
Remove PXD hits from TrackCand.
Definition: UpdateParticleTrackCandModule.h:57
Belle2::UpdateParticleTrackCandModule
Updates the seed in TrackCand based on fitted state (at vertex)
Definition: UpdateParticleTrackCandModule.h:38
Belle2::UpdateParticleTrackCandModule::event
virtual void event() override
update candidates
Definition: UpdateParticleTrackCandModule.cc:49
Belle2::B2Vector3< double >
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::Const::pion
static const ChargedStable pion
charged pion particle
Definition: Const.h:535
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::UpdateParticleTrackCandModule::m_removeSVD
bool m_removeSVD
Remove SVD hits from TrackCand.
Definition: UpdateParticleTrackCandModule.h:58
Belle2::UpdateParticleTrackCandModule::m_removeCDC
bool m_removeCDC
Remove CDC hits from TrackCand.
Definition: UpdateParticleTrackCandModule.h:59
Belle2::UpdateParticleTrackCandModule::m_removeBKLM
bool m_removeBKLM
Remove BKLM hits from TrackCand.
Definition: UpdateParticleTrackCandModule.h:60