Belle II Software  release-08-01-10
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 Belle2;
18 
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* seedEclShower = seedRecoTrack->getRelated<ECLShower>("ECLShowers");
28  const auto* seedMCParticle = seedEclShower->getRelated<MCParticle>();
29 
30  const auto* wireHit = state->getWireHit();
31  const auto* cdcHit = wireHit->getHit();
32  const auto* hitMCParticle = cdcHit->getRelated<MCParticle>();
33 
34  // Bremsstrahlung etc (works for electron gun, check for other events later)
35  while (hitMCParticle->getMother()) {
36  hitMCParticle = hitMCParticle->getMother();
37  }
38 
39  // calculate the interesting quantities
40  var<named("match")>() = seedMCParticle == hitMCParticle ? true : false;
41  var<named("PDG")>() = seedMCParticle->getPDG();
42 
43  auto seedMom = seedMCParticle->getMomentum();
44  var<named("seed_p_truth")>() = seedMom.R();
45  var<named("seed_theta_truth")>() = seedMom.Theta() * 180. / M_PI;
46  var<named("seed_pt_truth")>() = seedMom.Rho();
47  var<named("seed_pz_truth")>() = seedMom.Z();
48  var<named("seed_px_truth")>() = seedMom.X();
49  var<named("seed_py_truth")>() = seedMom.Y();
50 
51  return true;
52 }
virtual bool extract(const BaseCDCStateFilter::Object *result) 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
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
constexpr static 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
MCParticle * getMother() const
Returns a pointer to the mother particle.
Definition: MCParticle.h:600
Abstract base class for different kinds of events.