Belle II Software development
CDCTrigger3DFitterModule.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#ifndef CDCTRIGGER3DFITTERModule_H
9#define CDCTRIGGER3DFITTERModule_H
10
11#include "framework/core/Module.h"
12#include <framework/datastore/StoreArray.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <trg/cdc/dataobjects/CDCTriggerSegmentHit.h>
15#include <trg/cdc/dataobjects/CDCTriggerTrack.h>
16#include <framework/dataobjects/BinnedEventT0.h>
17
18namespace Belle2 {
25
26 public:
27
30
31 // /** Destructor */
32 // virtual ~CDCTrigger3DFitterModule();
33
35 virtual void initialize() override;
36
38 virtual void event() override;
39
40 private:
41 // major functions
42
44 std::vector<std::vector<CDCHit*>> preselector(double phi0, double omega);
45
47 std::vector<std::vector<double>> sConverter(const std::vector<std::vector<CDCHit*>>& preselectedHits, double omega);
48
50 std::vector<std::vector<double>> zConverter(const std::vector<std::vector<CDCHit*>>& preselectedHits, double phi0, double omega);
51
53 class HoughVoter {
54 private:
55 const int nCellZ0 = 16;
56 const int nCellCot = 16;
57 const double minZ0 = -50;
58 const double maxZ0 = 78;
59 const double minCot = -0.8;
60 const double maxCot = 1.5;
61 const double cellWidthZ0 = (maxZ0 - minZ0) / nCellZ0;
62 const double cellWidthCot = (maxCot - minCot) / nCellCot;
63
64 // n-th layer's info is at n-th bit from LSB
65 std::vector<std::vector<int>> votingCell;
66
67 inline int digitizeZ0(double z0) {return floor((maxZ0 - z0) / cellWidthZ0);}
68 inline int digitizeCot(double cot) {return floor((cot - minCot) / cellWidthCot);}
69 // get value at the center of parameter cell
70 inline double getZ0CellValue(double iZ0) {return maxZ0 - (iZ0 + 0.5) * cellWidthZ0;}
71 inline double getCotCellValue(double iCot) {return minCot + (iCot + 0.5) * cellWidthCot;}
72
73 public:
74 HoughVoter();
75 void vote(const std::vector<std::vector<double>>& sCand, const std::vector<std::vector<double>>& zCand);
76 std::tuple<double, double, int> findPeak();
77 };
78
80 std::pair<std::vector<double>, std::vector<double>> selector(const std::vector<std::vector<double>>& sCand,
81 const std::vector<std::vector<double>>& zCand, double z0, double cot);
82
84 std::pair<double, double> fitter(const std::vector<double>& s, const std::vector<double>& z);
85
86
87 // minor functions
88
90 int getIStereoLayer(int iContinuousLayer);
91
93 double normalizeAngle(double angle);
94
96 double calPhiCross(double r, double phi0, double omega);
97
99 std::vector<int> getIWireBegin(double phi0, double omega);
100
103 std::vector<int> select5Cells(const CDCTriggerSegmentHit* TS);
104
106 double getDriftLength(const CDCHit hit);
107
108
109 // 3D Fitter parameter arguments
115 std::string m_EventTimeName;
122
123
124 // dataobjects
133
134
135 // 3D Fitter constants
136 const int m_maxDriftTime = 512; // unit: TRGCLK ~ 2ns
137 static const int m_nStereoLayer = 20;
138 const int m_nCellInTS = 11;
139 const int m_nLayerInSuperLayer = 5; // 5 layers out of 6 are used in trigger
140 const double m_maxZSelection = 25; // cm
141
143 std::vector<std::vector<double>> m_xtCurve;
144 std::vector<int> m_nWire;
145 std::vector<double> m_rWire;
146 std::vector<std::vector<double>> m_phiBW;
147 std::vector<double> m_zBW;
148 std::vector<double> m_stereoAngle;
149 std::map<std::pair<int, int>, int> m_cellIDInTS = {
150 {std::make_pair(-2, -1), 0},
151 {std::make_pair(-2, 0), 1},
152 {std::make_pair(-2, 1), 2},
153 {std::make_pair(-1, -1), 3},
154 {std::make_pair(-1, 0), 4},
155 {std::make_pair(0, 0), 5},
156 {std::make_pair(1, -1), 6},
157 {std::make_pair(1, 0), 7},
158 {std::make_pair(2, -1), 8},
159 {std::make_pair(2, 0), 9},
160 {std::make_pair(2, 1), 10}
161 };
162 };
164} // namespace Belle2
165
166#endif // CDCTrigger3DFitterModule_H
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
Module for the 3D Fitter of the CDC trigger.
std::string m_EventTimeName
name of the event time StoreObjPtr
std::pair< double, double > fitter(const std::vector< double > &s, const std::vector< double > &z)
Performance linear fitting with the selected s and z.
StoreArray< CDCTriggerTrack > m_tracks2D
list of 2D input tracks
std::vector< std::vector< double > > m_xtCurve
CDC geometry constants.
std::vector< std::vector< CDCHit * > > preselector(double phi0, double omega)
Select 10 wires which crosses with the given 2D track.
std::string m_CDCHitCollectionName
Name of the StoreArray containing the input CDChits.
virtual void initialize() override
Initialize the module and register DataStore arrays.
CDCTrigger3DFitterModule()
Constructor, for setting module description and parameters.
virtual void event() override
Run the 3D fitter for an event.
std::string m_outputCollectionName
Name of the StoreArray containing the resulting 3D tracks.
std::vector< std::vector< double > > zConverter(const std::vector< std::vector< CDCHit * > > &preselectedHits, double phi0, double omega)
Calculate z at the hit position.
StoreArray< CDCTriggerSegmentHit > m_TSHits
list of track segment hits
double getDriftLength(const CDCHit hit)
Get drift length.
double calPhiCross(double r, double phi0, double omega)
Calculate phi coordinate of the crossing point of the given radius and the given 2D track.
std::string m_inputCollectionName
Name of the StoreArray containing the input tracks from the 2D fitter.
double normalizeAngle(double angle)
Convert the given angle(rad) to the range [-pi, pi].
int getIStereoLayer(int iContinuousLayer)
Convert continuous layer ID (0–55) -> stereo layer ID (0–19).
std::string m_TSHitCollectionName
Name of the StoreArray containing the input track segment hits.
StoreArray< CDCTriggerTrack > m_tracks3D
list of 3D output tracks
std::vector< int > select5Cells(const CDCTriggerSegmentHit *TS)
1 cell is selected in each layer to reduce LUT comsumption.
int m_minVoteCount
Minimal number of votes in Hough voting.
StoreObjPtr< BinnedEventT0 > m_eventTime
StoreObjPtr containing the event time.
std::vector< std::vector< double > > sConverter(const std::vector< std::vector< CDCHit * > > &preselectedHits, double omega)
Calculate s(arc length of the 2D track) at the hit position.
std::pair< std::vector< double >, std::vector< double > > selector(const std::vector< std::vector< double > > &sCand, const std::vector< std::vector< double > > &zCand, double z0, double cot)
Select the nearest hits from the voter result.
std::vector< int > getIWireBegin(double phi0, double omega)
Get the beginning wire ID of the preselection range(10 wires) for each layer.
Combination of several CDCHits to a track segment hit for the trigger.
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.