Belle II Software  release-06-02-00
PXDInterceptor.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 <framework/logging/Logger.h>
11 #include <framework/datastore/StoreArray.h>
12 #include <tracking/pxdDataReductionClasses/PXDInterceptor.h>
13 #include <vxd/geometry/GeoCache.h>
14 #include <vxd/geometry/SensorInfoBase.h>
15 
16 using namespace std;
17 using namespace Belle2;
18 
19 PXDInterceptor::PXDInterceptor(const ROIinfo* theROIinfo, double toleranceZ, double tolerancePhi):
20  m_theROIinfo(*theROIinfo)
21 {
22  m_theROIGeometry.fillPlaneList(toleranceZ, tolerancePhi);
23 }
24 
26 {
27 }
28 
29 void
31  RelationArray* recoTrackToPXDIntercepts)
32 {
33 
35  std::set<Belle2::VxdID> pxdLayers = vxdGeometry.getLayers(VXD::SensorInfoBase::PXD);
36 
37  for (int i = 0; i < trackList.getEntries(); ++i) { //loop over all tracks
38 
39  B2DEBUG(20, " %%%%% track candidate Nr. : " << i + 1);
40 
41  if (! trackList[i] ->wasFitSuccessful()) {
42  B2DEBUG(20, "%%%%% Fit not successful! discard this RecoTrack");
43  continue;
44  }
45 
46  // extrapolate track to cylinders (PXD layers 1 and 2)
47  for (unsigned int pxdLayer = 0; pxdLayer < pxdLayers.size(); pxdLayer++) {
48 
49  B2DEBUG(20, " fill intercept List, Layer: " << pxdLayer);
50  // get current state of track
51  genfit::MeasuredStateOnPlane gfTrackState = trackList[i]->getMeasuredStateOnPlaneFromFirstHit();
52 
53  try {
54  gfTrackState.extrapolateToCylinder(m_pxdLayerRadius[pxdLayer]);
55  } catch (...) {
56  B2DEBUG(20, "extrapolation to cylinder failed");
57  continue;
58  }
59 
60  std::list<ROIDetPlane> selectedPlanes;
61  B2DEBUG(20, " append selected planes, position " << gfTrackState.getPos().X() << ", " << gfTrackState.getPos().Y() << ", " <<
62  gfTrackState.getPos().Z());
63  m_theROIGeometry.appendSelectedPlanes(&selectedPlanes, gfTrackState.getPos(), pxdLayer + 1);
64 
65  B2DEBUG(20, " append intercepts for track " << i);
66  appendIntercepts(interceptList, selectedPlanes, trackList[i], i, recoTrackToPXDIntercepts);
67  } //loop on layers
68  } //loop on the track list
69 
70 } //fillInterceptList
71 
72 void
73 PXDInterceptor::appendIntercepts(StoreArray<PXDIntercept>* interceptList, std::list<ROIDetPlane> planeList, RecoTrack* recoTrack,
74  int recoTrackIndex, RelationArray* recoTrackToPXDIntercepts)
75 {
76 
77 
78  PXDIntercept tmpPXDIntercept;
79 
81 
82  std::list<ROIDetPlane>::iterator itPlanes = planeList.begin();
83 
84  B2DEBUG(20, "appendIntercepts, checking " << planeList.size() << " planes");
85 
86  double lambda = 0;
87 
88 
89  while (itPlanes != planeList.end()) {
90 
92 
93  try {
94  state = gfTrack.getFittedState();
95  lambda = state.extrapolateToPlane(itPlanes->getSharedPlanePtr());
96  } catch (...) {
97  B2DEBUG(20, "extrapolation to plane failed");
98  ++itPlanes;
99  continue;
100  }
101 
102  const TVectorD& predictedIntersect = state.getState();
103  const TMatrixDSym& covMatrix = state.getCov();
104 
105  tmpPXDIntercept.setCoorU(predictedIntersect[3]);
106  tmpPXDIntercept.setCoorV(predictedIntersect[4]);
107  tmpPXDIntercept.setSigmaU(sqrt(covMatrix(3, 3)));
108  tmpPXDIntercept.setSigmaV(sqrt(covMatrix(4, 4)));
109  tmpPXDIntercept.setSigmaUprime(sqrt(covMatrix(1, 1)));
110  tmpPXDIntercept.setSigmaVprime(sqrt(covMatrix(2, 2)));
111  tmpPXDIntercept.setLambda(lambda);
112  tmpPXDIntercept.setVxdID(itPlanes->getVxdID());
113 
114  interceptList->appendNew(tmpPXDIntercept);
115 
116  recoTrackToPXDIntercepts->add(recoTrackIndex, interceptList->getEntries() - 1);
117 
118  ++itPlanes;
119 
120  }
121 
122 }
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
Definition: PXDIntercept.h:22
ROIGeometry m_theROIGeometry
the geometry of the Region Of Interest
virtual ~PXDInterceptor()
Destructor.
void appendIntercepts(StoreArray< PXDIntercept > *interceptList, std::list< ROIDetPlane > planeList, RecoTrack *recoTrack, int recoTrackIndex, RelationArray *recoTrackToPXDIntercepts)
Append the PXDIntercept infos related to the track theTrack to the listToBeFilled.
const float m_pxdLayerRadius[2]
mean PXD layer radius for both layers
void fillInterceptList(StoreArray< PXDIntercept > *listToBeFilled, const StoreArray< RecoTrack > &trackList, RelationArray *recoTrackToPXDIntercepts)
Fill the list of PXD intecepts corresponding to the list of track candidates.
void appendSelectedPlanes(std::list< ROIDetPlane > *selectedPlanes, TVector3 recoTrackPosition, int layer)
Append to selectedPlanes those in the internal list for which a sensor is near the RecoTrack position...
Definition: ROIGeometry.cc:76
void fillPlaneList(double toleranceZ, double tolerancePhi)
fill the list of planes
Definition: ROIGeometry.cc:33
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
Definition: RecoTrack.cc:396
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
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.
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:175
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
#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:285
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