Belle II Software  release-05-01-25
CDCStateTruthVarSet.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2019 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Simon Kurz, Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/ckf/cdc/filters/states/CDCStateTruthVarSet.h>
11 
12 #include <tracking/ckf/cdc/entities/CDCCKFState.h>
13 
14 #include <mdst/dataobjects/MCParticle.h>
15 
16 #include <tracking/dataobjects/RecoTrack.h>
17 
18 using namespace std;
19 using namespace Belle2;
20 
21 bool CDCStateTruthVarSet::extract(const BaseCDCStateFilter::Object* pair)
22 {
23  const auto& path = pair->first;
24  const auto& state = pair->second;
25 
26  // check if hit belongs to same seed
27  const auto& seed = path->front();
28  const auto* seedRecoTrack = seed.getSeed();
29  const auto* seedMCTrack = seedRecoTrack->getRelated<RecoTrack>("MCRecoTracks");
30  const auto* seedMCParticle = seedMCTrack->getRelated<MCParticle>();
31 
32  const auto* wireHit = state->getWireHit();
33  const auto* cdcHit = wireHit->getHit();
34  const auto* hitMCTrack = cdcHit->getRelated<RecoTrack>("MCRecoTracks");
35 
36  // Bremsstrahlung etc (works for electron gun, check for other events later)
37  while (seedMCParticle->getMother()) {
38  seedMCParticle = seedMCParticle->getMother();
39  }
40 
41  // calculate the interesting quantities
42  var<named("match")>() = seedMCTrack == hitMCTrack ? true : false;
43  var<named("PDG")>() = seedMCParticle->getPDG();
44 
45  return true;
46 }
Belle2::RelationsInterface::getRelated
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
Definition: RelationsObject.h:280
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::TrackFindingCDC::Filter::Object
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:43