Belle II Software development
VXDInterceptor.templateDetails.h
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/roiFinding/VXDInterceptor.h>
10#include <tracking/roiFinding/ROIDetPlane.h>
11#include <tracking/dataobjects/RecoTrack.h>
12#include <framework/logging/Logger.h>
13#include <framework/datastore/StoreArray.h>
14#include <vxd/geometry/GeoCache.h>
15#include <vxd/geometry/SensorInfoBase.h>
16
17#include <genfit/MeasuredStateOnPlane.h>
18
19namespace Belle2 {
25 template<class aIntercept>
27 const StoreArray<RecoTrack>& trackList,
28 RelationArray* recoTrackToIntercepts)
29 {
30 for (int i = 0; i < trackList.getEntries(); ++i) { //loop over all tracks
31
32 B2DEBUG(20, " %%%%% track candidate Nr. : " << i + 1);
33
34 if (! trackList[i] ->wasFitSuccessful()) {
35 B2DEBUG(20, "%%%%% Fit not successful! discard this RecoTrack");
36 continue;
37 }
38
39 // extrapolate track to cylinders (VXD layers)
40 for (unsigned int layer = 0; layer < m_layerRadii.size(); layer++) {
41 const unsigned int layerOffset = (m_detector == VXD::SensorInfoBase::SVD ? 3 : 1);
42
43 B2DEBUG(20, " .fill intercept List, Layer: " << layer + layerOffset);
44 // if this ROI / intercept finding is for DQM, only extrapolate backwards, starting from first hit
45 // if it's for actual ROI finding (or any other case), extrapolate in both directions, once starting
46 // from the first hit extrapolating backwards, and once starting from the last hit extrapolating forwards
47 for (short direction : (m_ForDQM ? c_backwards : c_both)) {
48 std::list<ROIDetPlane> selectedPlanes;
49 genfit::MeasuredStateOnPlane gfTrackState;
50 switch (direction) {
51 case -1:
52 gfTrackState = trackList[i]->getMeasuredStateOnPlaneFromFirstHit();
53 break;
54 case 1:
55 gfTrackState = trackList[i]->getMeasuredStateOnPlaneFromLastHit();
56 gfTrackState.setPosMom(gfTrackState.getPos(), -gfTrackState.getMom());
57 gfTrackState.setChargeSign(-gfTrackState.getCharge());
58 break;
59 default:
60 break;
61 }
62
63 try {
64 gfTrackState.extrapolateToCylinder(m_layerRadii[layer]);
65 } catch (...) {
66 B2DEBUG(20, " .-extrapolation to cylinder failed");
67 continue;
68 }
69
70 B2DEBUG(20, " ..append selected planes, position " << gfTrackState.getPos().X() << ", " << gfTrackState.getPos().Y() << ", " <<
71 gfTrackState.getPos().Z());
72
73 m_theROIGeometry.appendSelectedPlanes(&selectedPlanes, ROOT::Math::XYZVector(gfTrackState.getPos()), layer + layerOffset);
74 B2DEBUG(20, " ...append intercepts for track " << i << "\n"\
75 " ...the size of the selectedPlanes : " << selectedPlanes.size() << "\n"\
76 " ...extrapolating in direction " << direction << " (-1 for backwards from first hit, +1 for forwards from last hit)");
77 appendIntercepts(interceptList, selectedPlanes, gfTrackState, i, recoTrackToIntercepts);
78 }
79
80 } //loop on layers
81 } //loop on the track list
82
83 } //fillInterceptList
84
85
86 template<class aIntercept>
88 std::list<ROIDetPlane> planeList,
89 genfit::MeasuredStateOnPlane state,
90 int recoTrackIndex,
91 RelationArray* recoTrackToIntercepts)
92 {
93 aIntercept tmpIntercept;
94
95 B2DEBUG(20, " ...-appendIntercepts, checking " << planeList.size() << " planes");
96
97 double lambda = 0;
98
99 std::list<ROIDetPlane>::iterator itPlanes = planeList.begin();
100 while (itPlanes != planeList.end()) {
101 B2DEBUG(20, " searching in appendIntercepts : " << (itPlanes->getVxdID()));
102
103 try {
104 lambda = state.extrapolateToPlane(itPlanes->getSharedPlanePtr());
105 } catch (...) {
106 B2DEBUG(20, " ...-extrapolation to plane failed");
107 ++itPlanes;
108 continue;
109 }
110
111 const TVectorD& predictedIntersect = state.getState();
112 const TMatrixDSym& covMatrix = state.getCov();
113
114 tmpIntercept.setCoorU(predictedIntersect[3]);
115 tmpIntercept.setCoorV(predictedIntersect[4]);
116 tmpIntercept.setSigmaU(sqrt(covMatrix(3, 3)));
117 tmpIntercept.setSigmaV(sqrt(covMatrix(4, 4)));
118 tmpIntercept.setSigmaUprime(sqrt(covMatrix(1, 1)));
119 tmpIntercept.setSigmaVprime(sqrt(covMatrix(2, 2)));
120 tmpIntercept.setLambda(lambda);
121 tmpIntercept.setVxdID(itPlanes->getVxdID());
122 tmpIntercept.setUprime(predictedIntersect[1]);
123 tmpIntercept.setVprime(predictedIntersect[2]);
124
125 B2DEBUG(20, "extrapolate to plane!!! >>> coordinates with getPos = " << state.getPos().X()
126 << ", " << state.getPos().Y()
127 << ", " << state.getPos().Z());
128 B2DEBUG(20, "coordinates with predInter = " << predictedIntersect[3]
129 << ", " << predictedIntersect[4]);
130 B2DEBUG(20, "momentum with getMom = " << state.getMom().X()
131 << ", " << state.getMom().Y()
132 << ", " << state.getMom().Z());
133 B2DEBUG(20, "U/V prime momentum with getMom = " << state.getMom().Z() / state.getMom().X()
134 << ", " << state.getMom().Z() / state.getMom().Y());
135 B2DEBUG(20, "U/V prime momentum with predInter = " << predictedIntersect[1]
136 << ", " << predictedIntersect[2]);
137
138 interceptList->appendNew(tmpIntercept);
139
140 recoTrackToIntercepts->add(recoTrackIndex, interceptList->getEntries() - 1);
141
142 ++itPlanes;
143
144 }
145
146 }
147
149} // namespace Belle2
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
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
void fillInterceptList(StoreArray< aIntercept > *listToBeFilled, const StoreArray< RecoTrack > &trackList, RelationArray *recoTrackToIntercepts)
Fill the list of PXD intecepts corresponding to the list of track candidates.
void appendIntercepts(StoreArray< aIntercept > *interceptList, std::list< ROIDetPlane > planeList, genfit::MeasuredStateOnPlane state, int recoTrackIndex, RelationArray *recoTrackToIntercepts)
Append the Intercept infos related to the track theTrack to the listToBeFilled.
Abstract base class for different kinds of events.