Belle II Software  release-05-02-19
DATCONTrackingModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Michael Schnell, Christian Wessel *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <tracking/modules/DATCON/DATCONTrackingModule.h>
12 
13 using namespace std;
14 using namespace Belle2;
15 
16 //-----------------------------------------------------------------
17 // Register the Module
18 //-----------------------------------------------------------------
19 REG_MODULE(DATCONTracking)
20 
21 //-----------------------------------------------------------------
22 // Implementation
23 //-----------------------------------------------------------------
24 
26 {
27  //Set module properties
28  setDescription("DATCON: Data Acquisition Tracking Concentrator Online Node \n"
29  "Algorithm for online data reduction in the PXD. \n"
30  "DATCON takes SVD hits as input and performs track reconstruction based on these data. \n"
31  "The tracks are extrapolated from the origin in the x-y-plane to the PXD sensors. \n"
32  "Around each extrapolated hit (called Most Probable Hit, MPH), a Region of Interest (ROI) is created."
33  "The data of the ROIs (namely two opposing corners) are sent to the \n"
34  "Online Selector Node (ONSEN) which also receives ROIs of the Higher Level Trigger (HLT). \n"
35  "This C++ Implementation of DATCON is the development environment, the algorithms will later \n"
36  "be transferred to FPGA, as DATCON is a hardware based online data reduction system.");
37  setPropertyFlags(c_ParallelProcessingCertified);
38 
39  addParameter();
40 
41 }
42 
43 
44 void
45 DATCONTrackingModule::initialize()
46 {
47  storeDATCONTracks.registerInDataStore(m_storeDATCONTracksName, DataStore::c_DontWriteOut);
48  m_storeDATCONTracksName = storeDATCONTracks.getName();
49 
50  storeDATCONSVDCluster.isRequired(m_storeDATCONSVDClusterName);
51  storeDATCONSVDSpacePoints.isRequired(m_storeDATCONSVDSpacePointsName);
52 
53  m_storeDATCONSVDClusterName = storeDATCONSVDCluster.getName();
54  m_storeDATCONSVDSpacePointsName = storeDATCONSVDSpacePoints.getName();
55 
56  if (m_useSVDSpacePoints)
57  storeSVDSpacePoints.isRequired(m_storeSVDSpacePointsName);
58 
59  storeDATCONRecoTracks.registerInDataStore(m_storeDATCONRecoTracksName, DataStore::c_DontWriteOut);
60  m_storeDATCONRecoTracksName = storeDATCONRecoTracks.getName();
61 
62  storeRecoHitInformation.registerInDataStore(m_storeRecoHitInformationName, DataStore::c_DontWriteOut);
63  m_storeRecoHitInformationName = storeRecoHitInformation.getName();
64 
65  storeRecoHitInformation.registerRelationTo(storeDATCONSVDCluster, DataStore::c_Event, DataStore::c_DontWriteOut);
66  storeDATCONSVDCluster.registerRelationTo(storeRecoHitInformation, DataStore::c_Event, DataStore::c_DontWriteOut);
67 
68  storeDATCONRecoTracks.registerRelationTo(storeRecoHitInformation);
69 
70  RecoTrack::registerRequiredRelations(storeDATCONRecoTracks,
71  "", m_storeDATCONSVDClusterName, "",
72  "", "", m_storeRecoHitInformationName);
73 
74  storeMCParticles.isOptional();
75 
76  if (m_independentSectors) {
77  ArrayOfActiveSectorsPhiHS = new int* [m_nVertSectorsU];
78  for (int i = 0; i < m_nVertSectorsU; ++i) {
79  ArrayOfActiveSectorsPhiHS[i] = new int[m_nAngleSectorsU];
80  }
81 
82  ArrayOfActiveSectorsThetaHS = new int* [m_nVertSectorsV];
83  for (int i = 0; i < m_nVertSectorsV; ++i) {
84  ArrayOfActiveSectorsThetaHS[i] = new int[m_nAngleSectorsV];
85  }
86  } else {
87  ArrayOfActiveSectorsPhiHS = new int* [(int)pow(2, m_maxIterationsU + 1)];
88  for (int i = 0; i < (int)pow(2, m_maxIterationsU + 1); ++i) {
89  ArrayOfActiveSectorsPhiHS[i] = new int[(int)pow(2, m_maxIterationsU + 1)];
90  }
91 
92  ArrayOfActiveSectorsThetaHS = new int* [(int)pow(2, m_maxIterationsV + 1)];
93  for (int i = 0; i < (int)pow(2, m_maxIterationsV + 1); ++i) {
94  ArrayOfActiveSectorsThetaHS[i] = new int[(int)pow(2, m_maxIterationsV + 1)];
95  }
96  }
97 
98 }
99 
100 
101 void
102 DATCONTrackingModule::event()
103 {
104  uHough.clear();
105  uHoughCand.clear();
106  uTrackCand.clear();
107  vHough.clear();
108  vHoughCand.clear();
109  vTrackCand.clear();
110  uHoughSpaceClusterCand.clear();
111  vHoughSpaceClusterCand.clear();
112  DATCONTracks.clear();
113 
114  if (m_useHoughSpaceClustering) {
115 
116  if (m_independentSectors) {
117  for (int i = 0; i < m_nVertSectorsU; i++) {
118  for (int j = 0; j < m_nAngleSectorsU; j++) {
119  ArrayOfActiveSectorsPhiHS[i][j] = 0;
120  }
121  }
122  for (int i = 0; i < m_nVertSectorsV; i++) {
123  for (int j = 0; j < m_nAngleSectorsV; j++) {
124  ArrayOfActiveSectorsThetaHS[i][j] = 0;
125  }
126  }
127  } else {
128  for (int i = 0; i < (int)pow(2, m_maxIterationsU + 1); i++) {
129  for (int j = 0; j < (int)pow(2, m_maxIterationsU + 1); j++) {
130  ArrayOfActiveSectorsPhiHS[i][j] = 0;
131  }
132  }
133  for (int i = 0; i < (int)pow(2, m_maxIterationsV + 1); i++) {
134  for (int j = 0; j < (int)pow(2, m_maxIterationsV + 1); j++) {
135  ArrayOfActiveSectorsThetaHS[i][j] = 0;
136  }
137  }
138  }
139 
140  activeSectorVectorPhi.clear();
141  activeSectorVectorTheta.clear();
142  }
143 
144 
145  if (m_useDATCONSVDSpacePoints && m_useSVDSpacePoints) {
146  B2WARNING("Using both DATCONSVDSpacePoints and SVDSpacePoints is not possible! Using DATCONSVDSpacePoints.");
147  prepareDATCONSVDSpacePoints();
148  } else if (m_useDATCONSVDSpacePoints && !m_useSVDSpacePoints) {
149  prepareDATCONSVDSpacePoints();
150  } else if (!m_useDATCONSVDSpacePoints && m_useSVDSpacePoints) {
151  prepareSVDSpacePoints();
152  } else if (!m_useDATCONSVDSpacePoints && !m_useSVDSpacePoints) {
153  B2WARNING("You should use some SpacePoints at least... Using DATCONSVDSpacePoints.");
154  prepareDATCONSVDSpacePoints();
155  }
156 
157  if (m_usePhase2Simulation) {
158  // ATTENTION TODO FIXME : This still has to be implemented!!!
159  // So far no phase 2 specific algorithms have been implemented and tested!
160  B2WARNING("This mode is not yet implemented, nothing will happen! Return...");
161  return;
162  }
163 
164 
165  TVector2 v1_s, v2_s, v4_s;
166 
167  /* Hough transformation */
168  houghTrafo2d(uClusters, true); // with conformal transformation in r-phi
169  houghTrafo2d(vClusters, false); // no conformal transformation in z
170 
171  /*
172  * Run hough tracking on U-Side
173  */
174  /* Set start values */
175  v1_s.Set(-M_PI, m_rectSizeU);
176  v2_s.Set(M_PI, m_rectSizeU);
177  v4_s.Set(-M_PI, -m_rectSizeU);
178  /* Run intercept finder */
179  if (m_independentSectors) {
180  slowInterceptFinder2d(uHough, true);
181  } else {
182  fastInterceptFinder2d(uHough, true, v1_s, v2_s, v4_s, 0, m_maxIterationsU);
183  }
184 
185  /*
186  * Run hough tracking on V-Side
187  */
188  /* Set start values */
189  v1_s.Set(-M_PI, m_rectSizeV);
190  v2_s.Set(0., m_rectSizeV);
191  v4_s.Set(-M_PI, -m_rectSizeV);
192  /* Run intercept finder */
193  if (m_independentSectors) {
194  slowInterceptFinder2d(vHough, false);
195  } else {
196  fastInterceptFinder2d(vHough, false, v1_s, v2_s, v4_s, 0, m_maxIterationsV);
197  }
198 
199  if (m_useHoughSpaceClustering) {
200  FindHoughSpaceCluster(true);
201  FindHoughSpaceCluster(false);
202  }
203 
204  /* Purify candidates (when debug level >= 2) */
205  if (m_usePurifier) {
206  purifyTrackCandsList();
207  }
208 
209  /* Run trackCand merger */
210  if (m_useTrackCandMerger) {
211  trackCandMerger();
212  }
213 
214  /* Find and combine compatible sets and create real tracks */
215  findandcombine3d();
216 
217  /* Run trackCand merger */
218  if (m_useTrackMerger) {
219  trackMerger();
220  }
221 
222 }
223 
224 
225 void
226 DATCONTrackingModule::terminate()
227 {
228 
229  if (m_independentSectors) {
230  for (int i = 0; i < m_nVertSectorsU; ++i) {
231  delete [] ArrayOfActiveSectorsPhiHS[i];
232  }
233 
234  for (int i = 0; i < m_nVertSectorsV; ++i) {
235  delete [] ArrayOfActiveSectorsThetaHS[i];
236  }
237  } else {
238  for (int i = 0; i < (int)pow(2, m_maxIterationsU + 1); ++i) {
239  delete [] ArrayOfActiveSectorsPhiHS[i];
240  }
241 
242  for (int i = 0; i < (int)pow(2, m_maxIterationsV + 1); ++i) {
243  delete [] ArrayOfActiveSectorsThetaHS[i];
244  }
245  }
246 
247  delete [] ArrayOfActiveSectorsPhiHS;
248  delete [] ArrayOfActiveSectorsThetaHS;
249 
250 }
Belle2::DATCONTrackingModule
DATCONTrackingModule class.
Definition: DATCONTrackingModule.h:79
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19