Belle II Software  release-08-01-10
SVDInterceptor.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 
9 #include <tracking/dataobjects/RecoTrack.h>
10 #include <genfit/AbsTrackRep.h>
11 #include <framework/logging/Logger.h>
12 #include <framework/datastore/StoreArray.h>
13 #include <tracking/svdROIFinder/SVDInterceptor.h>
14 #include <vxd/geometry/GeoCache.h>
15 #include <vxd/geometry/SensorInfoBase.h>
16 
17 using namespace std;
18 using namespace Belle2;
19 
20 SVDInterceptor::SVDInterceptor(const ROIinfo* theROIinfo, double toleranceZ, double tolerancePhi):
21  m_theROIinfo(*theROIinfo)
22 {
23  m_theROIGeometry.fillPlaneList(toleranceZ, tolerancePhi);
24 }
25 
27 {
28 }
29 
30 void
32  RelationArray* recoTrackToSVDIntercepts)
33 {
34 
36  std::set<Belle2::VxdID> svdLayers = vxdGeometry.getLayers(VXD::SensorInfoBase::SVD);
37 
38  for (int i = 0; i < trackList.getEntries(); ++i) { //loop over all tracks
39 
40  B2DEBUG(20, " %%%%% track candidate Nr. : " << i + 1);
41 
42  if (! trackList[i] ->wasFitSuccessful()) {
43  B2DEBUG(20, "%%%%% Fit not successful! discard this RecoTrack");
44  continue;
45  }
46 
47  // extrapolate track to cylinders (SVD layers)
48  for (unsigned int svdLayer = 0; svdLayer < svdLayers.size(); svdLayer++) {
49 
50  B2DEBUG(20, " .fill intercept List, Layer: " << svdLayer + 3);
51  // get current state of track
52  genfit::MeasuredStateOnPlane gfTrackState = trackList[i]->getMeasuredStateOnPlaneFromFirstHit();
53 
54  try {
55  gfTrackState.extrapolateToCylinder(m_svdLayerRadius[svdLayer]);
56  } catch (...) {
57  B2DEBUG(20, " .-extrapolation to cylinder failed");
58  continue;
59  }
60 
61  std::list<ROIDetPlane> selectedPlanes;
62  B2DEBUG(20, " ..append selected planes, position " << gfTrackState.getPos().X() << ", " << gfTrackState.getPos().Y() << ", " <<
63  gfTrackState.getPos().Z());
64  m_theROIGeometry.appendSelectedPlanes(&selectedPlanes, ROOT::Math::XYZVector(gfTrackState.getPos()), svdLayer + 3);
65 
66  B2DEBUG(20, " ...append intercepts for track " << i);
67  appendIntercepts(interceptList, selectedPlanes, trackList[i], i, recoTrackToSVDIntercepts);
68  } //loop on layers
69  } //loop on the track list
70 
71 } //fillInterceptList
72 
73 
74 void
75 SVDInterceptor::appendIntercepts(StoreArray<SVDIntercept>* interceptList, std::list<ROIDetPlane> planeList, RecoTrack* recoTrack,
76  int recoTrackIndex, RelationArray* recoTrackToSVDIntercepts)
77 {
78 
79 
80  SVDIntercept tmpSVDIntercept;
81 
82  const genfit::Track& gfTrack = RecoTrackGenfitAccess::getGenfitTrack(*recoTrack);
83 
84  std::list<ROIDetPlane>::iterator itPlanes = planeList.begin();
85 
86  B2DEBUG(20, " ...-appendIntercepts, checking " << planeList.size() << " planes");
87 
88  double lambda = 0;
89 
90 
91  for (int propDir = -1; propDir <= 1; propDir += 2) {
92  gfTrack.getCardinalRep()->setPropDir(propDir);
93 
94  while (itPlanes != planeList.end()) {
95 
97 
98  try {
99  state = gfTrack.getFittedState();
100  lambda = state.extrapolateToPlane(itPlanes->getSharedPlanePtr());
101  } catch (...) {
102  B2DEBUG(20, " ...-extrapolation to plane failed");
103  ++itPlanes;
104  continue;
105  }
106 
107  const TVectorD& predictedIntersect = state.getState();
108  const TMatrixDSym& covMatrix = state.getCov();
109 
110  tmpSVDIntercept.setCoorU(predictedIntersect[3]);
111  tmpSVDIntercept.setCoorV(predictedIntersect[4]);
112  tmpSVDIntercept.setSigmaU(sqrt(covMatrix(3, 3)));
113  tmpSVDIntercept.setSigmaV(sqrt(covMatrix(4, 4)));
114  tmpSVDIntercept.setSigmaUprime(sqrt(covMatrix(1, 1)));
115  tmpSVDIntercept.setSigmaVprime(sqrt(covMatrix(2, 2)));
116  tmpSVDIntercept.setLambda(lambda);
117  tmpSVDIntercept.setVxdID(itPlanes->getVxdID());
118  tmpSVDIntercept.setUprime(predictedIntersect[1]);
119  tmpSVDIntercept.setVprime(predictedIntersect[2]);
120 
121  B2DEBUG(20, "coordinates with getPos = " << state.getPos().X()
122  << ", " << state.getPos().Y()
123  << ", " << state.getPos().Z());
124  B2DEBUG(20, "coordinates with predInter = " << predictedIntersect[3]
125  << ", " << predictedIntersect[4]);
126  B2DEBUG(20, "momentum with getMom = " << state.getMom().X()
127  << ", " << state.getMom().Y()
128  << ", " << state.getMom().Z());
129  B2DEBUG(20, "U/V prime momentum with getMom = " << state.getMom().Z() / state.getMom().X()
130  << ", " << state.getMom().Z() / state.getMom().Y());
131  B2DEBUG(20, "U/V prime momentum with predInter = " << predictedIntersect[1]
132  << ", " << predictedIntersect[2]);
133 
134  interceptList->appendNew(tmpSVDIntercept);
135 
136  recoTrackToSVDIntercepts->add(recoTrackIndex, interceptList->getEntries() - 1);
137 
138  ++itPlanes;
139 
140  }
141  }
142 
143 
144 }
145 
146 
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
Definition: RecoTrack.cc:404
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
Low-level class to create/modify relations between StoreArrays.
Definition: RelationArray.h:62
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
SVDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an SVD ...
Definition: SVDIntercept.h:22
void setUprime(double user_Uprime)
set the U direction tangent of the track extrapolated to the sensor
Definition: SVDIntercept.h:31
void setVprime(double user_Vprime)
set the V direction tangent of the track extrapolated to the sensor
Definition: SVDIntercept.h:32
virtual ~SVDInterceptor()
Destructor.
void fillInterceptList(StoreArray< SVDIntercept > *listToBeFilled, const StoreArray< RecoTrack > &trackList, RelationArray *recoTrackToSVDIntercepts)
Fill the list of PXD intecepts corresponding to the list of track candidates.
const float m_svdLayerRadius[4]
mean SVD layer radius for both layers
SVDROIGeometry m_theROIGeometry
the geometry of the Region Of Interest
void appendIntercepts(StoreArray< SVDIntercept > *interceptList, std::list< ROIDetPlane > planeList, RecoTrack *recoTrack, int recoTrackIndex, RelationArray *recoTrackToSVDIntercepts)
Append the SVDIntercept infos related to the track theTrack to the listToBeFilled.
void appendSelectedPlanes(std::list< ROIDetPlane > *selectedPlanes, ROOT::Math::XYZVector recoTrackPosition, int layer)
appends the interesting planes
void fillPlaneList(double toleranceZ, double tolerancePhi)
fill the list of planes
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
void setLambda(double user_lambda)
set the length of the track
Definition: VXDIntercept.h:74
void setVxdID(VxdID::baseType user_vxdID)
set the sensor ID
Definition: VXDIntercept.h:75
void setSigmaVprime(double user_sigmaVprime)
set the statistical error of the extrapolation of V prime
Definition: VXDIntercept.h:73
void setSigmaU(double user_sigmaU)
set the statistical error on the U coordinate of the intercept
Definition: VXDIntercept.h:70
void setCoorU(double user_coorU)
set the U coordinate of the intercept
Definition: VXDIntercept.h:68
void setCoorV(double user_coorV)
set the V coordinate of the intercept
Definition: VXDIntercept.h:69
void setSigmaV(double user_sigmaV)
set the statistical error on the V coordinate of the intercept
Definition: VXDIntercept.h:71
void setSigmaUprime(double user_sigmaUprime)
set the statistical error of the extrapolation of U prime
Definition: VXDIntercept.h:72
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
const std::set< Belle2::VxdID > getLayers(SensorInfoBase::SensorType sensortype=SensorInfoBase::VXD)
Return a set of all known Layers.
Definition: GeoCache.cc:176
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
void setPropDir(int dir)
Set propagation direction. (-1, 0, 1) -> (backward, auto, forward).
Definition: AbsTrackRep.h:336
#StateOnPlane with additional covariance matrix.
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:71
const MeasuredStateOnPlane & getFittedState(int id=0, const AbsTrackRep *rep=nullptr, bool biased=true) const
Shortcut to get FittedStates.
Definition: Track.cc:294
AbsTrackRep * getCardinalRep() const
Get cardinal track representation.
Definition: Track.h:145
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.
ROIinfo contains the parameters that can be changed by the user in the python script.
Definition: ROIinfo.h:15