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