Belle II Software prerelease-11-00-00a
CDCfromEclPathTruthVarSet.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/CDCfromEclPathTruthVarSet.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 const auto* seedRecoTrack = seed.getSeed();
24 const auto* seedEclShower = seedRecoTrack->getRelated<ECLShower>("ECLShowers");
25 const auto* seedMCParticle = seedEclShower->getRelated<MCParticle>();
26 const auto* seedMCTrack = seedRecoTrack->getRelated<RecoTrack>("MCRecoTracks");
27
28 int daughters = 0;
29 int matched = 0;
30
31 for (auto const& state : *path) {
32 if (state.isSeed()) {
33 continue;
34 }
35
36 const auto wireHit = state.getWireHit();
37 const auto cdcHit = wireHit->getHit();
38 auto* hitMCTrack = cdcHit->getRelated<RecoTrack>("MCRecoTracks");
39
40 if (seedMCTrack != 0 && seedMCTrack == hitMCTrack) {
41 matched += 1;
42 }
43 }
44
45
46 var<named("matched")>() = matched;
47 var<named("daughters")>() = daughters;
48 var<named("PDG")>() = seedMCParticle->getPDG();
49
50 auto seedMom = seedMCParticle->getMomentum();
51 var<named("seed_p_truth")>() = seedMom.R();
52 var<named("seed_theta_truth")>() = seedMom.Theta() * 180. / M_PI;
53 var<named("seed_pt_truth")>() = seedMom.Rho();
54 var<named("seed_pz_truth")>() = seedMom.Z();
55 var<named("seed_px_truth")>() = seedMom.X();
56 var<named("seed_py_truth")>() = seedMom.Y();
57
58 // before, I used "RecoTracks" instead so I could get the msop.
59 // Gets track of mother particle (be careful, eg for photon guns)
60 const auto* particleMCTrack = seedMCParticle->getRelated<RecoTrack>("MCRecoTracks");
61 int mcTrackHits = -1;
62 if (particleMCTrack) {
63 mcTrackHits = particleMCTrack->getNumberOfCDCHits();
64 }
65 var<named("mcTrackHits")>() = mcTrackHits;
66
67 return true;
68}
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
ROOT::Math::XYZVector getMomentum() const
The method to get return ROOT::Math::XYZVector Momentum.
Definition ECLShower.h:452
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
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.
static constexpr int named(const char *name)
Definition VarSet.h:78
Abstract base class for different kinds of events.