Belle II Software  release-08-01-10
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 Belle2;
17 
18 PXDInterceptor::PXDInterceptor(const ROIinfo* theROIinfo, double toleranceZ, double tolerancePhi):
19  m_theROIinfo(*theROIinfo)
20 {
21  m_theROIGeometry.fillPlaneList(toleranceZ, tolerancePhi);
22 }
23 
25 {
26 }
27 
28 void
30  RelationArray* recoTrackToPXDIntercepts)
31 {
32 
34  std::set<Belle2::VxdID> pxdLayers = vxdGeometry.getLayers(VXD::SensorInfoBase::PXD);
35 
36  for (int i = 0; i < trackList.getEntries(); ++i) { //loop over all tracks
37 
38  B2DEBUG(20, " %%%%% track candidate Nr. : " << i + 1);
39 
40  if (! trackList[i] ->wasFitSuccessful()) {
41  B2DEBUG(20, "%%%%% Fit not successful! discard this RecoTrack");
42  continue;
43  }
44 
45  // extrapolate track to cylinders (PXD layers 1 and 2)
46  for (unsigned int pxdLayer = 0; pxdLayer < pxdLayers.size(); pxdLayer++) {
47 
48  B2DEBUG(20, " fill intercept List, Layer: " << pxdLayer);
49  // get current state of track
50  genfit::MeasuredStateOnPlane gfTrackState = trackList[i]->getMeasuredStateOnPlaneFromFirstHit();
51 
52  try {
53  gfTrackState.extrapolateToCylinder(m_pxdLayerRadius[pxdLayer]);
54  } catch (...) {
55  B2DEBUG(20, "extrapolation to cylinder failed");
56  continue;
57  }
58 
59  std::list<ROIDetPlane> selectedPlanes;
60  B2DEBUG(20, " append selected planes, position " << gfTrackState.getPos().X() << ", " << gfTrackState.getPos().Y() << ", " <<
61  gfTrackState.getPos().Z());
62  m_theROIGeometry.appendSelectedPlanes(&selectedPlanes, ROOT::Math::XYZVector(gfTrackState.getPos()), pxdLayer + 1);
63 
64  B2DEBUG(20, " append intercepts for track " << i);
65  appendIntercepts(interceptList, selectedPlanes, trackList[i], i, recoTrackToPXDIntercepts);
66  } //loop on layers
67  } //loop on the track list
68 
69 } //fillInterceptList
70 
71 void
72 PXDInterceptor::appendIntercepts(StoreArray<PXDIntercept>* interceptList, std::list<ROIDetPlane> planeList, RecoTrack* recoTrack,
73  int recoTrackIndex, RelationArray* recoTrackToPXDIntercepts)
74 {
75 
76 
77  PXDIntercept tmpPXDIntercept;
78 
79  const genfit::Track& gfTrack = RecoTrackGenfitAccess::getGenfitTrack(*recoTrack);
80 
81  std::list<ROIDetPlane>::iterator itPlanes = planeList.begin();
82 
83  B2DEBUG(20, "appendIntercepts, checking " << planeList.size() << " planes");
84 
85  double lambda = 0;
86 
87 
88  while (itPlanes != planeList.end()) {
89 
91 
92  try {
93  state = gfTrack.getFittedState();
94  lambda = state.extrapolateToPlane(itPlanes->getSharedPlanePtr());
95  } catch (...) {
96  B2DEBUG(20, "extrapolation to plane failed");
97  ++itPlanes;
98  continue;
99  }
100 
101  const TVectorD& predictedIntersect = state.getState();
102  const TMatrixDSym& covMatrix = state.getCov();
103 
104  tmpPXDIntercept.setCoorU(predictedIntersect[3]);
105  tmpPXDIntercept.setCoorV(predictedIntersect[4]);
106  tmpPXDIntercept.setSigmaU(sqrt(covMatrix(3, 3)));
107  tmpPXDIntercept.setSigmaV(sqrt(covMatrix(4, 4)));
108  tmpPXDIntercept.setSigmaUprime(sqrt(covMatrix(1, 1)));
109  tmpPXDIntercept.setSigmaVprime(sqrt(covMatrix(2, 2)));
110  tmpPXDIntercept.setLambda(lambda);
111  tmpPXDIntercept.setVxdID(itPlanes->getVxdID());
112 
113  interceptList->appendNew(tmpPXDIntercept);
114 
115  recoTrackToPXDIntercepts->add(recoTrackIndex, interceptList->getEntries() - 1);
116 
117  ++itPlanes;
118 
119  }
120 
121 }
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.
PXDInterceptor(const ROIinfo *user_theROIinfo, double toleranceZ, double tolerancePhi)
Class Constructor.
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, ROOT::Math::XYZVector recoTrackPosition, int layer)
Append to selectedPlanes those in the internal list for which a sensor is near the RecoTrack position...
Definition: ROIGeometry.cc:75
void fillPlaneList(double toleranceZ, double tolerancePhi)
fill the list of planes
Definition: ROIGeometry.cc:32
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.
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
#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
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