Belle II Software prerelease-11-00-00a
CDCTrackDeadBoardFilter.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#include <tracking/trackFindingCDC/filters/track/CDCTrackDeadBoardFilter.h>
9
10#include <cdc/dataobjects/CDCHit.h>
11#include <cdc/geometry/CDCGeometryPar.h>
12#include <cdc/topology/CDCWire.h>
13#include <cdc/topology/CDCWireLayer.h>
14
15#include <tracking/trackingUtilities/rootification/StoreWrappedObjPtr.h>
16#include <tracking/trackingUtilities/eventdata/tracks/CDCTrack.h>
17#include <tracking/trackingUtilities/eventdata/hits/CDCRecoHit3D.h>
18
19// TODO: decide if this is the correct place to put this function
20
21namespace Belle2 {
26 namespace TrackFindingCDC {
27
28 void addBoardCandsAtLayer(std::vector<unsigned int>& boardCands, const Belle2::TrackingUtilities::Helix& globalHelix,
29 Belle2::CDC::ILayer iclayer, const CDC::CDCGeometryPar& geometryPar)
30 {
31
33 if (rLayer <= 0) return;
34
35 double arcLength = globalHelix.arcLength2DToCylindricalR(rLayer);
36 if (std::isnan(arcLength)) return;
37
38 TVector3 pos3D = globalHelix.atArcLength2D(arcLength);
39
40 // +/- deltaPhi corresponding to 2cm left and right (on circle)
41 double deltaPhi = 2. / rLayer;
42
43 for (int i = -1; i <= 1; i++) {
44 TVector3 thisPos = pos3D;
45 thisPos.SetPhi(pos3D.Phi() + i * deltaPhi);
46 const Belle2::CDC::IWire iWire = geometryPar.cellId(iclayer, thisPos);
47 const auto board = geometryPar.getBoardID(WireID(iclayer, iWire));
48 boardCands.push_back(board);
49 }
50 }
51
52
53 bool cdcTrackDeadBoardFilter(const Belle2::TrackingUtilities::CDCTrack& aCDCTrack, int minJump)
54 {
55 // first check if dead boards are present
56 Belle2::TrackingUtilities::StoreWrappedObjPtr< std::vector<unsigned int> > deadBoardsVectorPtr("CDCDeadBoardsVector");
57 // nothing to do if no dead boards have been assigned
58 if (not deadBoardsVectorPtr.isValid() || (*deadBoardsVectorPtr).size() == 0) return false;
59 // for better readability
60 const std::vector<unsigned int>& deadBoardsVector = *deadBoardsVectorPtr;
61
62 const CDC::CDCGeometryPar& geometryPar = CDC::CDCGeometryPar::Instance();
63
64 auto& trajectory = aCDCTrack.getStartTrajectory3D();
65
66 Belle2::TrackingUtilities::Helix globalHelix = trajectory.getLocalHelix().helix();
67 auto localOrigin = trajectory.getLocalOrigin();
68 globalHelix.passiveMoveBy(-localOrigin);
69
70 // Detect if several layers are jumped. The minimum amount of wires jumped is defined by the minJump variable
71 const Belle2::TrackingUtilities::CDCRecoHit3D* prevHitPtr = nullptr;
72 for (const Belle2::TrackingUtilities::CDCRecoHit3D& thisHit : aCDCTrack) {
73 if (not prevHitPtr) {
74 prevHitPtr = &thisHit;
75 continue;
76 }
77
78 Belle2::CDC::ILayer iclayerPrev = ((const CDCHit*)*prevHitPtr)->getICLayer(); // signed short
79 Belle2::CDC::ILayer iclayerThis = ((const CDCHit*)thisHit)->getICLayer();
80
81 if (abs(iclayerPrev - iclayerThis) >= minJump) {
82
83 // direction in case of backcurling tracks
84 int dir = (iclayerThis - iclayerPrev) < 0 ? -1 : 1;
85 // jump 3 layers to get the onto next board (1 board covers 3 layers)
86 unsigned int newlayerThis = iclayerThis - dir * 3;
87 unsigned int newlayerPrev = iclayerPrev + dir * 3;
88
89 std::vector<unsigned int> boardCands;
90 boardCands.reserve(6);
91 addBoardCandsAtLayer(boardCands, globalHelix, newlayerThis, geometryPar);
92 addBoardCandsAtLayer(boardCands, globalHelix, newlayerPrev, geometryPar);
93
94 for (auto iboard : boardCands) {
95 if (std::find(deadBoardsVector.begin(), deadBoardsVector.end(), iboard) != deadBoardsVector.end()) return true;
96 }
97 }
98
99 prevHitPtr = &thisHit;
100 }
101
102 return false;
103
104 }
105
106
107
108 }
110}
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
double getRefCylindricalR() const
Getter for the common (averaged) cylindrical radius at the wire reference point.
static const CDCWireLayer * getInstance(ILayer iCLayer)
Getter from the the continuous layer id. Does not construct a new object.
const CDCTrajectory3D & getStartTrajectory3D() const
Getter for the two dimensional trajectory.
Definition CDCTrack.h:110
double arcLength2DToCylindricalR(double cylindricalR) const
Calculates the two dimensional arc length that first reaches a cylindrical radius on the helix Return...
Definition Helix.h:112
Vector3D atArcLength2D(double s) const
Calculates the point, which lies at the give perpendicular travel distance (counted from the perigee)
Definition Helix.h:174
double passiveMoveBy(const Vector3D &by)
Moves the coordinates system by the given vector.
Definition Helix.h:147
signed short IWire
The type of the wire ids enumerating wires within a given layer.
Definition IWire.h:20
signed short ILayer
The type of the layer ids enumerating layers within a superlayer.
Definition ILayer.h:18
Abstract base class for different kinds of events.