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