Belle II Software  release-06-01-15
PXDStateTruthVarSet.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/pxd/filters/states/PXDStateTruthVarSet.h>
9 
10 #include <tracking/mcMatcher/TrackMatchLookUp.h>
11 #include <tracking/dataobjects/RecoTrack.h>
12 
13 using namespace std;
14 using namespace Belle2;
15 using namespace TrackFindingCDC;
16 
17 bool PXDStateTruthVarSet::extract(const BasePXDStateFilter::Object* pair)
18 {
19  const std::vector<TrackFindingCDC::WithWeight<const CKFToPXDState*>>& previousStates = pair->first;
20  const CKFToPXDState* state = pair->second;
21 
22  std::vector<TrackFindingCDC::WithWeight<const CKFToPXDState*>> allStates = previousStates;
23  allStates.emplace_back(state, 0);
24 
25  const RecoTrack* seedTrack = previousStates.front()->getSeed();
26  B2ASSERT("Path without seed?", seedTrack);
27 
28  var<named("truth_event_id")>() = m_eventMetaData->getEvent();
29  var<named("truth_seed_number")>() = seedTrack->getArrayIndex();
30 
31  // Default to 0
32  var<named("truth_position_x")>() = 0;
33  var<named("truth_position_y")>() = 0;
34  var<named("truth_position_z")>() = 0;
35  var<named("truth_momentum_x")>() = 0;
36  var<named("truth_momentum_y")>() = 0;
37  var<named("truth_momentum_z")>() = 0;
38  var<named("truth")>() = 0;
39 
40  if (not m_mcUtil.allStatesCorrect(allStates)) {
41  // Keep all variables set to false and return.
42  return true;
43  }
44 
45  const std::string& seedTrackStoreArrayName = seedTrack->getArrayName();
46 
47  TrackMatchLookUp mcCDCMatchLookUp("MCRecoTracks", seedTrackStoreArrayName);
48  const RecoTrack* cdcMCTrack = mcCDCMatchLookUp.getRelatedMCRecoTrack(*seedTrack);
49 
50  var<named("truth")>() = 1;
51 
52  var<named("truth_position_x")>() = cdcMCTrack->getPositionSeed().X();
53  var<named("truth_position_y")>() = cdcMCTrack->getPositionSeed().Y();
54  var<named("truth_position_z")>() = cdcMCTrack->getPositionSeed().Z();
55  var<named("truth_momentum_x")>() = cdcMCTrack->getMomentumSeed().X();
56  var<named("truth_momentum_y")>() = cdcMCTrack->getMomentumSeed().Y();
57  var<named("truth_momentum_z")>() = cdcMCTrack->getMomentumSeed().Z();
58 
59  return true;
60 }
Specialized CKF State for extrapolating into the PXD.
Definition: CKFToPXDState.h:27
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
TVector3 getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
Definition: RecoTrack.h:483
TVector3 getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
Definition: RecoTrack.h:476
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.
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.