Belle II Software development
CDCPathTruthVarSet.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#include <tracking/ckf/cdc/filters/paths/CDCPathTruthVarSet.h>
9
10#include <tracking/ckf/cdc/entities/CDCCKFState.h>
11
12#include <ecl/dataobjects/ECLShower.h>
13#include <mdst/dataobjects/MCParticle.h>
14
15#include <tracking/dataobjects/RecoTrack.h>
16
17using namespace Belle2;
18
20{
21 // check if hit belongs to same seed
22 const auto& seed = path->front();
23 auto* seedRecoTrack = seed.getSeed();
24 auto* seedMCTrack = seedRecoTrack->getRelated<RecoTrack>("MCRecoTracks");
25
26 MCParticle* seedMCParticle;
27 if (seedMCTrack) {
28 seedMCParticle = seedMCTrack->getRelated<MCParticle>();
29 }
30 // maybe used track from Ecl seeding?
31 else {
32 seedRecoTrack = seedRecoTrack->getRelated<RecoTrack>("EclSeedRecoTracks");
33 seedMCTrack = seedRecoTrack->getRelated<RecoTrack>("MCRecoTracks");
34 const auto* seedEclShower = seedRecoTrack->getRelated<ECLShower>("ECLShowers");
35 seedMCParticle = seedEclShower->getRelated<MCParticle>();
36 }
37
38 int daughters = 0;
39 std::vector<MCParticle*> daughterMCParticles;
40 if (seedMCParticle->getNDaughters() > 0) {
41 daughterMCParticles = seedMCParticle->getDaughters();
42
43 while (daughterMCParticles.size() == 1) {
44 daughterMCParticles = daughterMCParticles.at(0)->getDaughters();
45 }
46 if (daughterMCParticles.size() > 1) {
47 daughters = daughterMCParticles.size();
48 }
49 }
50
51 while (seedMCParticle->getMother()) {
52 seedMCParticle = seedMCParticle->getMother();
53 }
54
55 int mcTrackHits = 0;
56
57 if (seedMCTrack) {
58 mcTrackHits = seedMCTrack->getNumberOfCDCHits();
59 }
60 var<named("mcTrackHits")>() = mcTrackHits;
61
62 var<named("daughters")>() = daughters;
63 var<named("PDG")>() = seedMCParticle->getPDG();
64
65 auto seedMom = seedMCParticle->getMomentum();
66 var<named("seed_p_truth")>() = seedMom.R();
67 var<named("seed_theta_truth")>() = seedMom.Theta() * 180. / M_PI;
68 var<named("seed_pt_truth")>() = seedMom.Rho();
69 var<named("seed_pz_truth")>() = seedMom.Z();
70 var<named("seed_px_truth")>() = seedMom.X();
71 var<named("seed_py_truth")>() = seedMom.Y();
72
73 return true;
74}
virtual bool extract(const BaseCDCPathFilter::Object *path) override
Generate and assign the variables from the object.
Class to store ECL Showers.
Definition: ECLShower.h:30
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
Definition: MCParticle.cc:52
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:35
static constexpr int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:78
Float_t & var()
Reference getter for the value of the ith variable. Static version.
Definition: VarSet.h:93
Abstract base class for different kinds of events.