Belle II Software  release-06-02-00
CDCStateTruthVarSet.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/states/CDCStateTruthVarSet.h>
9 
10 #include <tracking/ckf/cdc/entities/CDCCKFState.h>
11 
12 #include <mdst/dataobjects/MCParticle.h>
13 
14 #include <tracking/dataobjects/RecoTrack.h>
15 
16 using namespace std;
17 using namespace Belle2;
18 
19 bool CDCStateTruthVarSet::extract(const BaseCDCStateFilter::Object* pair)
20 {
21  const auto& path = pair->first;
22  const auto& state = pair->second;
23 
24  // check if hit belongs to same seed
25  const auto& seed = path->front();
26  const auto* seedRecoTrack = seed.getSeed();
27  const auto* seedMCTrack = seedRecoTrack->getRelated<RecoTrack>("MCRecoTracks");
28  const auto* seedMCParticle = seedMCTrack->getRelated<MCParticle>();
29 
30  const auto* wireHit = state->getWireHit();
31  const auto* cdcHit = wireHit->getHit();
32  const auto* hitMCTrack = cdcHit->getRelated<RecoTrack>("MCRecoTracks");
33 
34  // Bremsstrahlung etc (works for electron gun, check for other events later)
35  while (seedMCParticle->getMother()) {
36  seedMCParticle = seedMCParticle->getMother();
37  }
38 
39  // calculate the interesting quantities
40  var<named("match")>() = seedMCTrack == hitMCTrack ? true : false;
41  var<named("PDG")>() = seedMCParticle->getPDG();
42 
43  return true;
44 }
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
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:33
Abstract base class for different kinds of events.