Belle II Software  release-06-00-14
CDCTrigger3DFitterModule.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 "trg/cdc/modules/fitting/CDCTrigger3DFitterModule.h"
9 
10 #include <framework/datastore/RelationVector.h>
11 
12 #include <cdc/geometry/CDCGeometryPar.h>
13 #include <trg/cdc/Fitter3DUtility.h>
14 #include <trg/cdc/Fitter3D.h>
15 #include <trg/cdc/JSignal.h>
16 #include <trg/cdc/JSignalData.h>
17 
18 using namespace std;
19 using namespace Belle2;
20 
21 //this line registers the module with the framework and actually makes it available
22 //in steering files or the the module list (basf2 -m).
23 REG_MODULE(CDCTrigger3DFitter);
24 
25 CDCTrigger3DFitterModule::CDCTrigger3DFitterModule() : Module::Module()
26 {
28  "The 3D fitter module of the CDC trigger.\n"
29  "Selects stereo hits around a given 2D track and performs a linear fit "
30  "in the s-z plane (s: 2D arclength).\n"
31  );
33  addParam("hitCollectionName", m_hitCollectionName,
34  "Name of the input StoreArray of CDCTriggerSegmentHits.",
35  string(""));
36  addParam("EventTimeName", m_EventTimeName,
37  "Name of the event time object.",
38  string(""));
39  addParam("inputCollectionName", m_inputCollectionName,
40  "Name of the StoreArray holding the input tracks from the 2D fitter.",
41  string("TRGCDC2DFitterTracks"));
42  addParam("outputCollectionName", m_outputCollectionName,
43  "Name of the StoreArray holding the 3D output tracks.",
44  string("TRGCDC3DFitterTracks"));
45  addParam("fitterMode", m_fitterMode,
46  "Fitter mode: 1: fast, 2: firmware",
47  unsigned(1));
48  addParam("minHits", m_minHits,
49  "Minimal number of hits required for the fitting.",
50  unsigned(2));
51  addParam("xtSimple", m_xtSimple,
52  "If true, use nominal drift velocity, otherwise use table "
53  "for non-linear xt.",
54  false);
55  addParam("isVerbose", m_isVerbose,
56  "If true, prints detail information.",
57  false);
58 }
59 
60 void
62 {
63  // register DataStore elements
64  m_tracks3D.registerInDataStore(m_outputCollectionName);
66  m_hits.isRequired(m_hitCollectionName);
67  m_eventTime.isRequired(m_EventTimeName);
68  // register relations
69  m_tracks2D.registerRelationTo(m_tracks3D);
70  m_tracks2D.requireRelationTo(m_hits);
71  m_tracks3D.registerRelationTo(m_hits);
72 
73 
76  //Fitter3DUtility::saveStereoXt(m_stXts, "stereoXt");
77  //Fitter3DUtility::loadStereoXt("TODOdata/stereoXt",4,m_stXts);
78 
81 
82  // get geometry constants for first priority layers
84  // TODO: avoid hard coding the priority layers here
85  vector<unsigned> iL = {10, 22, 34, 46};
86  for (int iSt = 0; iSt < 4; ++iSt) {
87  nWires.push_back(cdc.nWiresInLayer(iL[iSt]));
88  rr.push_back(cdc.senseWireR(iL[iSt]));
89  zToStraw.push_back(cdc.senseWireBZ(iL[iSt]));
90  nShift.push_back(cdc.nShifts(iL[iSt]));
91  angleSt.push_back(2 * rr.back() * sin(M_PI * nShift.back() / (2 * nWires.back())) /
92  (cdc.senseWireFZ(iL[iSt]) - zToStraw.back()));
93  vector<double> xt(512);
94  for (unsigned iTick = 0; iTick < xt.size(); ++iTick) {
95  double t = iTick * 2 * cdc.getTdcBinWidth();
96  if (m_xtSimple) {
97  xt[iTick] = cdc.getNominalDriftV() * t;
98  } else {
99  double driftLength_0 = cdc.getDriftLength(t, iL[iSt], 0);
100  double driftLength_1 = cdc.getDriftLength(t, iL[iSt], 1);
101  xt[iTick] = (driftLength_0 + driftLength_1) / 2;
102  }
103  }
104  xtTables.push_back(xt);
105  }
106 
107 }
108 
109 void
111 {
112  //cout<<"n2D tracks:"<<m_tracks2D.getEntries()<<endl;
113 
114  if (m_isVerbose) {
115  cout << "Event" << endl;
116  // stereo TS information
117  cout << "----Stereo TS----" << endl;
118  for (int iHit = 0; iHit < m_hits.getEntries(); ++iHit) {
119  if (m_hits[iHit]->getISuperLayer() % 2 != 0)
120  cout << "sl-iWire:" << m_hits[iHit]->getISuperLayer() << "-" << m_hits[iHit]->getIWire() << " pr:" <<
121  m_hits[iHit]->getPriorityPosition() << " lr:" << m_hits[iHit]->getLeftRight() << " rt:" << m_hits[iHit]->getTDCCount() << " dt:" <<
122  m_hits[iHit]->priorityTime() << endl;
123  }
124  cout << "----Stereo TS----" << endl;
125  cout << "----EventTime----" << endl;
126  // event time information
127  cout << "eventTimeValid: " << m_eventTime->hasBinnedEventT0(Const::CDC);
128  if (m_eventTime->hasBinnedEventT0(Const::CDC)) cout << " eventTime: " << m_eventTime->getBinnedEventT0(Const::CDC);
129  cout << endl;
130  cout << "----EventTime----" << endl;
131  cout << "----2D----" << endl;
132  // 2D information
133  for (int iTrack = 0; iTrack < m_tracks2D.getEntries(); ++iTrack) {
134  cout << "2D charge: " << m_tracks2D[iTrack]->getChargeSign() << " pt: " << 1. / abs(m_tracks2D[iTrack]->getOmega()) * 1.5 * 0.3 *
135  0.01 << " phi0_i: " << m_tracks2D[iTrack]->getPhi0() << endl;
136  }
137  cout << "----2D----" << endl;
138  }
139 
140  for (int itrack = 0; itrack < m_tracks2D.getEntries(); ++itrack) {
141  int charge = m_tracks2D[itrack]->getChargeSign();
142  double rho = 1. / abs(m_tracks2D[itrack]->getOmega());
143  double phi = m_tracks2D[itrack]->getPhi0() - charge * M_PI_2;
144 
145  // select stereo hits
146  vector<int> bestTSIndex(4, -1);
147  vector<double> bestTSPhi(4, 9999);
148  finder(charge, rho, phi, bestTSIndex, bestTSPhi);
149 
150  if (m_isVerbose) {
151  cout << "----Found Stereo TS----" << endl;
152  for (unsigned iSt = 0; iSt < 4; ++iSt) {
153  if (bestTSIndex[iSt] == -1) continue;
154  cout << "sl-iWire:" << iSt * 2 + 1 << "-" << m_hits[bestTSIndex[iSt]]->getIWire() << " pr:" <<
155  m_hits[bestTSIndex[iSt]]->getPriorityPosition() << " lr:" << m_hits[bestTSIndex[iSt]]->getLeftRight() << " rt:" <<
156  m_hits[bestTSIndex[iSt]]->getTDCCount() << " dt:" << m_hits[bestTSIndex[iSt]]->priorityTime() << endl;
157  }
158  cout << "----Found Stereo TS----" << endl;
159  cout << "----2D----" << endl;
160  cout << "charge: " << charge << " radius: " << rho << " phi0_c: " << phi << endl;
161  cout << "----2D----" << endl;
162  }
163 
164  // count the number of selected hits
165  unsigned nHits = 0;
166  for (unsigned iSt = 0; iSt < 4; ++iSt) {
167  if (bestTSIndex[iSt] != -1) {
168  nHits += 1;
169  }
170  }
171  if (nHits < m_minHits) {
172  B2DEBUG(100, "Not enough hits to do 3D fit (" << m_minHits << " needed, got " << nHits << ")");
173  continue;
174  }
175 
176  // do the fit and create a new track
177  double z0 = 0;
178  double cot = 0;
179  double chi2 = 0;
180  fitter(bestTSIndex, bestTSPhi, charge, rho, phi, z0, cot, chi2);
181 
182  //cout<<"nHits: "<<nHits<<" charge:"<<charge<<" rho:"<<rho<<" phi:"<<phi<<" z0:"<<z0<<" cot:"<<cot<<endl;
183 
184  // check if fit results are valid
185  if (isnan(z0) || isnan(cot) || isnan(chi2)) {
186  B2DEBUG(100, "3D fit failed");
187  continue;
188  }
189 
190  // save track
191  CDCTriggerTrack* fittedTrack =
192  m_tracks3D.appendNew(m_tracks2D[itrack]->getPhi0(), m_tracks2D[itrack]->getOmega(),
193  m_tracks2D[itrack]->getChi2D(),
194  z0, cot, chi2);
195  // make relation to 2D track
196  m_tracks2D[itrack]->addRelationTo(fittedTrack);
197  // make relation to hits
198  for (unsigned iSt = 0; iSt < 4; ++iSt) {
199  if (bestTSIndex[iSt] != -1)
200  fittedTrack->addRelationTo(m_hits[bestTSIndex[iSt]]);
201  }
202  // add axial relations from 2D track
204  m_tracks2D[itrack]->getRelationsTo<CDCTriggerSegmentHit>(m_hitCollectionName);
205  for (unsigned ihit = 0; ihit < axialHits.size(); ++ihit) {
206  fittedTrack->addRelationTo(axialHits[ihit]);
207  }
208  }
209 }
210 
211 void
212 CDCTrigger3DFitterModule::finder(int charge, double rho, double phi,
213  vector<int>& bestTSIndex, vector<double>& bestTSPhi)
214 {
215  vector<double> stAxPhi(4);
216  for (int iSt = 0; iSt < 4; ++iSt) {
217  stAxPhi[iSt] = Fitter3DUtility::calStAxPhi(charge, angleSt[iSt], zToStraw[iSt],
218  rr[iSt], rho, phi);
219  }
220  // get candidates
221  vector<vector<int>> candidatesIndex(4, vector<int>());
222  vector<vector<double>> candidatesPhi(4, vector<double>());
223  vector<vector<double>> candidatesDiffStWires(4, vector<double>());
224  for (int ihit = 0; ihit < m_hits.getEntries(); ++ihit) {
226  //cout<<"id:"<<m_hits[ihit]->getSegmentID()<<" pr:"<<m_hits[ihit]->getPriorityPosition()<<" lr:"<<m_hits[ihit]->getLeftRight()<<" rt:"<<m_hits[ihit]->priorityTime()<<" fastestTime:"<<m_hits[ihit]->fastestTime()<<" foundTime:"<<m_hits[ihit]->foundTime()<<endl;
227  //cout<<"tdc:"<<m_hits[ihit]->getTDCCount()<<" adc:"<<m_hits[ihit]->getADCCount()<<" isl:"<<m_hits[ihit]->getISuperLayer()<<" ilayer:"<<m_hits[ihit]->getILayer()<<" iwire:"<<m_hits[ihit]->getIWire()<<endl;
228  // Reject second priority TSs.
229  if (m_hits[ihit]->getPriorityPosition() != 3) continue;
230  // only stereo hits
231  unsigned iSL = m_hits[ihit]->getISuperLayer();
232  if (iSL % 2 == 0) continue;
233  // skip hits with too large radius
234  if (2 * rho < rr[iSL / 2]) continue;
235  // Find number of wire difference
236  double wirePhi = m_hits[ihit]->getIWire() * 2. * M_PI / nWires[iSL / 2];
237  double tsDiffSt = stAxPhi[iSL / 2] - wirePhi;
238  if (tsDiffSt > M_PI) tsDiffSt -= 2 * M_PI;
239  if (tsDiffSt < -M_PI) tsDiffSt += 2 * M_PI;
240  tsDiffSt = tsDiffSt / 2 / M_PI * nWires[iSL / 2];
241  // Save index if condition is in 10 wires
242  if ((iSL / 2) % 2 == 0) {
243  if (tsDiffSt > 0 && tsDiffSt <= 10) {
244  candidatesIndex[iSL / 2].push_back(ihit);
245  candidatesPhi[iSL / 2].push_back(wirePhi);
246  candidatesDiffStWires[iSL / 2].push_back(tsDiffSt);
247  }
248  } else {
249  if (tsDiffSt < 0 && tsDiffSt >= -10) {
250  candidatesIndex[iSL / 2].push_back(ihit);
251  candidatesPhi[iSL / 2].push_back(wirePhi);
252  candidatesDiffStWires[iSL / 2].push_back(tsDiffSt);
253  }
254  } // End of saving index
255  } // Candidate loop
256 
257  // Pick middle candidate if multiple candidates
258  // mean wire diff
259  double meanWireDiff[4] = { 3.68186, 3.3542, 3.9099, 4.48263 };
260  for (int iSt = 0; iSt < 4; ++iSt) {
261  //cout<<"iSt: "<<iSt<<" nCandidates:"<<candidatesIndex[iSt].size()<<endl;
262  //if (candidatesIndex[iSt].size() >1) continue;
263  double bestDiff = 9999;
264  for (int iTS = 0; iTS < int(candidatesIndex[iSt].size()); ++iTS) {
265  double diff = abs(abs(candidatesDiffStWires[iSt][iTS]) - meanWireDiff[iSt]);
266  // Pick the better TS
267  if (diff < bestDiff) {
268  bestDiff = diff;
269  bestTSPhi[iSt] = candidatesPhi[iSt][iTS];
270  bestTSIndex[iSt] = candidatesIndex[iSt][iTS];
271  }
272  } // TS loop
273  } // Layer loop
274 
275 
276  //StoreArray<Track> tracks;
277  //for (int iTrack = 0; iTrack < tracks.getEntries(); iTrack++)
278  //{
279  // cout<<tracks[iTrack].getTrackFitResults().size()<<endl;
280  //}
281 
282 }
283 
284 void
285 CDCTrigger3DFitterModule::fitter(const vector<int>& bestTSIndex, [[maybe_unused]] vector<double>& bestTSPhi,
286  int charge, double rho, double phi,
287  double& z0, double& cot, double& chi2)
288 {
289  // Find min timing [0, 511]
290 
291  // Convert format
292  // rawStTSs[iSt] = [TS ID, TS LR, TS driftTime]
293  vector<vector<int> > rawStTSs(4, vector<int> (3));
294  for (unsigned iSt = 0; iSt < 4; ++iSt) {
295  if (bestTSIndex[iSt] == -1) continue;
296  rawStTSs[iSt][0] = m_hits[bestTSIndex[iSt]]->getIWire();
297  rawStTSs[iSt][1] = m_hits[bestTSIndex[iSt]]->getLeftRight();
298  rawStTSs[iSt][2] = m_hits[bestTSIndex[iSt]]->priorityTime();
299  }
300  int eventTimeValid = 0;
301  int eventTime = 0;
302  if (m_eventTime->hasBinnedEventT0(Const::CDC)) {
303  eventTimeValid = 1;
304  eventTime = m_eventTime->getBinnedEventT0(Const::CDC);
305  //cout<<"eventTime: "<<eventTime<<endl;
306  }
307  double radius = rho;
308  double phi_c = phi;
309  if (phi_c > M_PI) phi_c -= 2 * M_PI;
310  if (phi_c < -M_PI) phi_c += 2 * M_PI;
311 
312  vector<double> arcS(4, 0);
313  vector<double> zz(4, 0);
314  vector<double> invZError2(4, 0);
315 
316  // Do fit
317  if (m_fitterMode == 1) Fitter3DUtility::fitter3D(m_stGeometry, m_stXts, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c,
318  z0, cot, chi2, arcS, zz, invZError2);
319 
320  if (m_fitterMode == 2) {
321  Fitter3DUtility::fitter3DFirm(m_mConstD, m_mConstV, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, m_commonData,
323  z0 = m_mSignalStorage["z0_r"].getRealInt();
324  cot = m_mSignalStorage["cot_r"].getRealInt();
325  chi2 = m_mSignalStorage["zChi2_r"].getRealInt();
326  for (int iSt = 0; iSt < 4; iSt++) {
327  invZError2[iSt] = m_mSignalStorage["iZError2_" + to_string(iSt)].getRealInt();
328  arcS[iSt] = m_mSignalStorage["arcS_" + to_string(iSt)].getRealInt();
329  zz[iSt] = m_mSignalStorage["zz_" + to_string(iSt)].getRealInt();
330  }
331  }
332 
333  if (m_isVerbose) {
334  cout << "----3D----" << endl;
335  cout << "arcS [0]: " << arcS[0] << " [1]: " << arcS[1] << " [2]: " << arcS[2] << " [3]: " << arcS[3] << endl;
336  cout << "zz [0]: " << zz[0] << " [1]: " << zz[1] << " [2]: " << zz[2] << " [3]: " << zz[3] << endl;
337  cout << "invZError2 [0]: " << invZError2[0] << " [1]: " << invZError2[1] << " [2]: " << invZError2[2] << " [3]: " << invZError2[3]
338  << endl;
339  cout << "z0: " << z0 << " cot: " << cot << " chi2: " << chi2 << endl;
340  cout << "----3D----" << endl;
341  }
342 
343  //double newZ0 = 0;
344  //double newCot = 0;
345  //double newChi2 = 0;
346  //{
347  // // Convert format
348  // // rawStTSs[iSt] = [TS ID, TS LR, TS driftTime]
349  // vector<vector<int> > rawStTSs (4, vector<int> (3));
350  // for(unsigned iSt = 0; iSt <4; ++iSt)
351  // {
352  // if (bestTSIndex[iSt] == -1) continue;
353  // rawStTSs[iSt][0] = m_hits[bestTSIndex[iSt]]->getIWire();
354  // rawStTSs[iSt][1] = m_hits[bestTSIndex[iSt]]->getLeftRight();
355  // rawStTSs[iSt][2] = m_hits[bestTSIndex[iSt]]->priorityTime();
356  // }
357  // int eventTimeValid = 0;
358  // int eventTime = 0;
359  // if (m_eventTime->hasBinnedEventT0(Const::CDC))
360  // {
361  // eventTimeValid = 1;
362  // eventTime = m_eventTime->getBinnedEventT0(Const::CDC);
363  // }
364  // double radius = rho;
365  // double phi_c = phi;
366  // Fitter3DUtility::fitter3D(m_stGeometry, m_stXts, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, newZ0, newCot, newChi2);
367  // //// Fit3D
368  // //vector<double> stTSs(4);
369  // //Fitter3DUtility::calPhiFast(m_stGeometry, m_stXts, eventTimeValid, eventTime, rawStTSs, stTSs);
370  // //vector<double> invZError2;
371  // //Fitter3DUtility::setErrorFast(rawStTSs, eventTimeValid, invZError2);
372  // //vector<double> zz(4, 0);
373  // //vector<double> arcS(4, 0);
374  // //for (unsigned iSt = 0; iSt < 4; iSt++) {
375  // // if (rawStTSs[iSt][1] != 0) {
376  // // zz[iSt] = Fitter3DUtility::calZ(charge, m_stGeometry["angleSt"][iSt], m_stGeometry["zToStraw"][iSt],
377  // // m_stGeometry["cdcRadius"][iSt], stTSs[iSt], radius, phi_c);
378  // // arcS[iSt] = Fitter3DUtility::calS(radius, m_stGeometry["cdcRadius"][iSt]);
379  // // }
380  // //}
381  // //double z0 = 0;
382  // //double cot = 0;
383  // //double chi2 = 0;
384  // //Fitter3DUtility::rSFit(&invZError2[0], &arcS[0], &zz[0], z0, cot, chi2);
385  // //newZ0 = z0;
386  // //newCot = cot;
387  // //newChi2 = chi2;
388  // ////cout<<"[Calculate fast]"<<endl;
389  // ////cout<<" [calPhi] "<<stTSs[0]<<" "<<stTSs[1]<<" "<<stTSs[2]<<" "<<stTSs[3]<<endl;
390  // ////cout<<" [invZError2] "<<invZError2[0]<<" "<<invZError2[1]<<" "<<invZError2[2]<<" "<<invZError2[3]<<endl;
391  // ////cout<<" [zz] "<<zz[0]<<" "<<zz[1]<<" "<<zz[2]<<" "<<zz[3]<<endl;
392  // ////cout<<" [arcS] "<<arcS[0]<<" "<<arcS[1]<<" "<<arcS[2]<<" "<<arcS[3]<<endl;
393  // ////cout<<" [z0] "<<z0<<" [cot] "<<cot<<" [chi2] "<<chi2<<endl;
394  //}
395 
396 
397  //int T0 = (m_eventTime->hasBinnedEventT0(Const::CDC))
398  // ? m_eventTime->getBinnedEventT0(Const::CDC)
399  // : 9999;
400  //
403 
405  //vector<double> wirePhi(4, 9999);
406  //vector<unsigned> LR(4, 0);
407  //vector<int> driftTime(4, 9999);
408  //for (unsigned iSt = 0; iSt < 4; ++iSt) {
409  // if (bestTSIndex[iSt] != -1) {
410  // wirePhi[iSt] = bestTSPhi[iSt];
411  // LR[iSt] = m_hits[bestTSIndex[iSt]]->getLeftRight();
412  // driftTime[iSt] = m_hits[bestTSIndex[iSt]]->priorityTime();
413  // }
414  //} // End superlayer loop
418 
420  //vector<double> phi3D(4, 9999);
421  //if (T0 == 9999) {
422  // for (unsigned iSt = 0; iSt < 4; iSt++) {
423  // phi3D[iSt] = wirePhi[iSt];
424  // }
425  //} else {
426  // for (unsigned iSt = 0; iSt < 4; iSt++) {
427  // if (bestTSIndex[iSt] != -1) {
428  // // Get drift length from table.
429  // int t = driftTime[iSt] - T0;
430  // if (t < 0) t = 0;
431  // if (t > 511) t = 511;
432  // double driftLength = xtTables[iSt][t];
433  // phi3D[iSt] = Fitter3DUtility::calPhi(wirePhi[iSt], driftLength, rr[iSt], LR[iSt]);
434  // }
435  // }
436  //}
438  //vector<double> driftZError({0.7676, 0.9753, 1.029, 1.372});
439  //vector<double> wireZError({0.7676, 0.9753, 1.029, 1.372});
440  //vector<double> zError(4, 9999);
441  //vector<double> invZError2(4, 0);
442  //for (unsigned iSt = 0; iSt < 4; ++iSt) {
443  // if (bestTSIndex[iSt] != -1) {
444  // // Check LR and eventTime
445  // if (LR[iSt] != 3 && T0 != 9999) zError[iSt] = driftZError[iSt];
446  // else zError[iSt] = wireZError[iSt];
447  // // Get inverse zerror ^ 2
448  // invZError2[iSt] = 1 / pow(zError[iSt], 2);
449  // }
450  //}
451 
453  //vector<double> zz(4, 0);
454  //vector<double> arcS(4, 0);
455  //for (unsigned iSt = 0; iSt < 4; iSt++) {
456  // if (bestTSIndex[iSt] != -1) {
457  // zz[iSt] = Fitter3DUtility::calZ(charge, angleSt[iSt], zToStraw[iSt],
458  // rr[iSt], phi3D[iSt], rho, phi);
459  // arcS[iSt] = Fitter3DUtility::calS(rho, rr[iSt]);
460  // }
461  //}
462 
464  //Fitter3DUtility::rSFit(&invZError2[0], &arcS[0], &zz[0], z0, cot, chi2);
465 
472 
476 }
std::string m_EventTimeName
name of the event time StoreObjPtr
StoreArray< CDCTriggerTrack > m_tracks2D
list of 2D input tracks
std::map< std::string, std::vector< double > > m_stGeometry
map of geometry constants
Belle2::TRGCDCJSignalData * m_commonData
Datastore for firmware simulation.
std::map< std::string, double > m_mConstD
Constants for firmware simulation.
virtual void initialize() override
Initialize the module and register DataStore arrays.
virtual void event() override
Run the 3D fitter for an event.
std::string m_outputCollectionName
Name of the StoreArray containing the resulting 3D tracks.
StoreArray< CDCTriggerSegmentHit > m_hits
list of track segment hits
std::vector< double > angleSt
geometry constants: stereo angle
std::map< std::string, std::vector< double > > m_mConstV
Constants for firmware simulation.
void finder(int charge, double rho, double phi, std::vector< int > &bestTSIndex, std::vector< double > &bestTSPhi)
Select stereo hits.
std::map< std::string, Belle2::TRGCDCJSignal > m_mSignalStorage
Signalstore for firmware simulation.
bool m_isVerbose
Switch printing detail information.
std::string m_inputCollectionName
Name of the StoreArray containing the input tracks from the 2D fitter.
std::vector< std::vector< double > > xtTables
geometry constants: drift length - drift time relation
unsigned m_fitterMode
Fitter mode: 1: fast, 2: firmware.
bool m_xtSimple
Switch between nominal drift velocity and xt table.
unsigned m_minHits
Minimal number of hits required for fitting.
StoreArray< CDCTriggerTrack > m_tracks3D
list of 3D output tracks
StoreObjPtr< BinnedEventT0 > m_eventTime
StoreObjPtr containing the event time.
std::vector< int > nShift
geometry constants: wire shift of stereo layers
std::vector< double > nWires
geometry constants: number of wires per super layer
std::vector< double > rr
geometry constants: radius of priority layers
std::vector< double > zToStraw
geometry constants: backward z of priority layers
void fitter(const std::vector< int > &bestTSIndex, std::vector< double > &bestTSPhi, int charge, double rho, double phi, double &z0, double &cot, double &chi2)
Perform the 3D fit.
std::string m_hitCollectionName
Name of the StoreArray containing the input track segment hits.
std::map< std::string, Belle2::TRGCDCJLUT * > m_mLutStorage
Lutstore for firmware simulation.
std::vector< std::vector< double > > m_stXts
stereo xt tables
Combination of several CDCHits to a track segment hit for the trigger.
Track created by the CDC trigger.
The Class for CDC Geometry Parameters.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
A class to hold common data for JSignals.
Definition: JSignalData.h:33
static double calStAxPhi(int charge, double anglest, double ztostraw, double rr, double rho, double phi0)
Calculates the fitted axial phi for the stereo super layer.
static void fitter3DFirm(std::map< std::string, double > &mConstD, const std::map< std::string, std::vector< double > > &mConstV, int eventTimeValid, int eventTime, std::vector< std::vector< int > > const &rawStTSs, int charge, double radius, double phi_c, Belle2::TRGCDCJSignalData *commonData, std::map< std::string, Belle2::TRGCDCJSignal > &mSignalStorage, std::map< std::string, Belle2::TRGCDCJLUT * > &mLutStorage)
Combines several functions for fitter3D firmware.
static void fitter3D(std::map< std::string, std::vector< double > > &stGeometry, std::vector< std::vector< double > > const &stXts, int eventTimeValid, int eventTime, std::vector< std::vector< int > > const &rawStTSs, int charge, double radius, double phi_c, double &z0, double &cot, double &chi2)
Combines several functions for fitter3D.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
static void getStereoGeometry(std::map< std::string, std::vector< double > > &stGeometry)
Get stereo geometry.
Definition: Fitter3D.cc:1555
static void getStereoXt(std::vector< double > const &stPriorityLayer, std::vector< std::vector< double > > &stXts, bool isSimple=0)
Get stereo Xt.
Definition: Fitter3D.cc:1575
static void getConstants(std::map< std::string, double > &mConstD, std::map< std::string, std::vector< double > > &mConstV, bool isXtSimple=0)
Get constants for firmwareFit.
Definition: Fitter3D.cc:1593
Abstract base class for different kinds of events.