Belle II Software  release-08-01-10
SVDStateTruthVarSet.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/svd/filters/states/SVDStateTruthVarSet.h>
9 
10 #include <tracking/mcMatcher/TrackMatchLookUp.h>
11 #include <tracking/dataobjects/RecoTrack.h>
12 
13 using namespace Belle2;
14 using namespace TrackFindingCDC;
15 
17 {
18  const std::vector<TrackFindingCDC::WithWeight<const CKFToSVDState*>>& previousStates = pair->first;
19  CKFToSVDState* state = pair->second;
20 
21  std::vector<TrackFindingCDC::WithWeight<const CKFToSVDState*>> allStates = previousStates;
22  allStates.emplace_back(state, 0);
23 
24  const RecoTrack* seedTrack = previousStates.front()->getSeed();
25  B2ASSERT("Path without seed?", seedTrack);
26 
27  var<named("truth_event_id")>() = m_eventMetaData->getEvent();
28  var<named("truth_seed_number")>() = seedTrack->getArrayIndex();
29 
30  // Default to 0
31  var<named("truth_position_x")>() = 0;
32  var<named("truth_position_y")>() = 0;
33  var<named("truth_position_z")>() = 0;
34  var<named("truth_momentum_x")>() = 0;
35  var<named("truth_momentum_y")>() = 0;
36  var<named("truth_momentum_z")>() = 0;
37  var<named("truth")>() = 0;
38 
39  if (not m_mcUtil.allStatesCorrect(allStates)) {
40  // Keep all variables set to false and return.
41  return true;
42  }
43 
44  const std::string& seedTrackStoreArrayName = seedTrack->getArrayName();
45 
46  TrackMatchLookUp mcCDCMatchLookUp("MCRecoTracks", seedTrackStoreArrayName);
47  const RecoTrack* cdcMCTrack = mcCDCMatchLookUp.getRelatedMCRecoTrack(*seedTrack);
48 
49  var<named("truth")>() = 1;
50 
51  var<named("truth_position_x")>() = cdcMCTrack->getPositionSeed().X();
52  var<named("truth_position_y")>() = cdcMCTrack->getPositionSeed().Y();
53  var<named("truth_position_z")>() = cdcMCTrack->getPositionSeed().Z();
54  var<named("truth_momentum_x")>() = cdcMCTrack->getMomentumSeed().X();
55  var<named("truth_momentum_y")>() = cdcMCTrack->getMomentumSeed().Y();
56  var<named("truth_momentum_z")>() = cdcMCTrack->getMomentumSeed().Z();
57 
58  return true;
59 }
Specialized CKF State for extrapolating into the SVD.
Definition: CKFToSVDState.h:27
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
ROOT::Math::XYZVector getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
Definition: RecoTrack.h:480
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
Definition: RecoTrack.h:487
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
virtual bool extract(const BaseSVDStateFilter::Object *result) override
Generate and assign the variables from the object.
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:33
Class to provide convenient methods to look up matching information between pattern recognition and M...
const RecoTrack * getRelatedMCRecoTrack(const RecoTrack &prRecoTrack) const
Looks for a related Monte Carlo track for the given pattern recognition track and return it if found.
Abstract base class for different kinds of events.