Belle II Software  release-06-01-15
CDCfromEclStateTruthVarSet.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/CDCfromEclStateTruthVarSet.h>
9 
10 #include <tracking/ckf/cdc/entities/CDCCKFState.h>
11 #include <ecl/dataobjects/ECLShower.h>
12 
13 #include <mdst/dataobjects/MCParticle.h>
14 
15 #include <tracking/dataobjects/RecoTrack.h>
16 
17 using namespace std;
18 using namespace Belle2;
19 
20 bool CDCfromEclStateTruthVarSet::extract(const BaseCDCStateFilter::Object* pair)
21 {
22  const auto& path = pair->first;
23  const auto& state = pair->second;
24 
25  // check if hit belongs to same seed
26  const auto& seed = path->front();
27  const auto* seedRecoTrack = seed.getSeed();
28  const auto* seedEclShower = seedRecoTrack->getRelated<ECLShower>("ECLShowers");
29  const auto* seedMCParticle = seedEclShower->getRelated<MCParticle>();
30 
31  const auto* wireHit = state->getWireHit();
32  const auto* cdcHit = wireHit->getHit();
33  const auto* hitMCParticle = cdcHit->getRelated<MCParticle>();
34 
35  // Bremsstrahlung etc (works for electron gun, check for other events later)
36  while (hitMCParticle->getMother()) {
37  hitMCParticle = hitMCParticle->getMother();
38  }
39 
40  // calculate the interesting quantities
41  var<named("match")>() = seedMCParticle == hitMCParticle ? true : false;
42  var<named("PDG")>() = seedMCParticle->getPDG();
43 
44  auto seedMom = seedMCParticle->getMomentum();
45  var<named("seed_p_truth")>() = seedMom.Mag();
46  var<named("seed_theta_truth")>() = seedMom.Theta() * 180. / M_PI;
47  var<named("seed_pt_truth")>() = seedMom.Perp();
48  var<named("seed_pz_truth")>() = seedMom.Z();
49  var<named("seed_px_truth")>() = seedMom.X();
50  var<named("seed_py_truth")>() = seedMom.Y();
51 
52  return true;
53 }
Class to store ECL Showers.
Definition: ECLShower.h:25
TVector3 getMomentum() const
The method to get return TVector3 Momentum.
Definition: ECLShower.h:419
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
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
MCParticle * getMother() const
Returns a pointer to the mother particle.
Definition: MCParticle.h:582
Abstract base class for different kinds of events.