Belle II Software  release-08-01-10
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 
61 {
62  if (m_commonData != nullptr)
63  delete m_commonData;
64 }
65 
66 void
68 {
69  // register DataStore elements
74  // register relations
78 
79 
82  //Fitter3DUtility::saveStereoXt(m_stXts, "stereoXt");
83  //Fitter3DUtility::loadStereoXt("TODOdata/stereoXt",4,m_stXts);
84 
87 
88  // get geometry constants for first priority layers
90  // TODO: avoid hard coding the priority layers here
91  vector<unsigned> iL = {10, 22, 34, 46};
92  for (int iSt = 0; iSt < 4; ++iSt) {
93  nWires.push_back(cdc.nWiresInLayer(iL[iSt]));
94  rr.push_back(cdc.senseWireR(iL[iSt]));
95  zToStraw.push_back(cdc.senseWireBZ(iL[iSt]));
96  nShift.push_back(cdc.nShifts(iL[iSt]));
97  angleSt.push_back(2 * rr.back() * sin(M_PI * nShift.back() / (2 * nWires.back())) /
98  (cdc.senseWireFZ(iL[iSt]) - zToStraw.back()));
99  vector<double> xt(512);
100  for (unsigned iTick = 0; iTick < xt.size(); ++iTick) {
101  double t = iTick * 2 * cdc.getTdcBinWidth();
102  if (m_xtSimple) {
103  xt[iTick] = cdc.getNominalDriftV() * t;
104  } else {
105  double driftLength_0 = cdc.getDriftLength(t, iL[iSt], 0);
106  double driftLength_1 = cdc.getDriftLength(t, iL[iSt], 1);
107  xt[iTick] = (driftLength_0 + driftLength_1) / 2;
108  }
109  }
110  xtTables.push_back(xt);
111  }
112 
113 }
114 
115 void
117 {
118  //cout<<"n2D tracks:"<<m_tracks2D.getEntries()<<endl;
119 
120  if (m_isVerbose) {
121  cout << "Event" << endl;
122  // stereo TS information
123  cout << "----Stereo TS----" << endl;
124  for (int iHit = 0; iHit < m_hits.getEntries(); ++iHit) {
125  if (m_hits[iHit]->getISuperLayer() % 2 != 0)
126  cout << "sl-iWire:" << m_hits[iHit]->getISuperLayer() << "-" << m_hits[iHit]->getIWire() << " pr:" <<
127  m_hits[iHit]->getPriorityPosition() << " lr:" << m_hits[iHit]->getLeftRight() << " rt:" << m_hits[iHit]->getTDCCount() << " dt:" <<
128  m_hits[iHit]->priorityTime() << endl;
129  }
130  cout << "----Stereo TS----" << endl;
131  cout << "----EventTime----" << endl;
132  // event time information
133  cout << "eventTimeValid: " << m_eventTime->hasBinnedEventT0(Const::CDC);
134  if (m_eventTime->hasBinnedEventT0(Const::CDC)) cout << " eventTime: " << m_eventTime->getBinnedEventT0(Const::CDC);
135  cout << endl;
136  cout << "----EventTime----" << endl;
137  cout << "----2D----" << endl;
138  // 2D information
139  for (int iTrack = 0; iTrack < m_tracks2D.getEntries(); ++iTrack) {
140  cout << "2D charge: " << m_tracks2D[iTrack]->getChargeSign() << " pt: " << 1. / abs(m_tracks2D[iTrack]->getOmega()) * 1.5 * 0.3 *
141  0.01 << " phi0_i: " << m_tracks2D[iTrack]->getPhi0() << endl;
142  }
143  cout << "----2D----" << endl;
144  }
145 
146  for (int itrack = 0; itrack < m_tracks2D.getEntries(); ++itrack) {
147  int charge = m_tracks2D[itrack]->getChargeSign();
148  double rho = 1. / abs(m_tracks2D[itrack]->getOmega());
149  double phi = m_tracks2D[itrack]->getPhi0() - charge * M_PI_2;
150 
151  // select stereo hits
152  vector<int> bestTSIndex(4, -1);
153  vector<double> bestTSPhi(4, 9999);
154  finder(charge, rho, phi, bestTSIndex, bestTSPhi);
155 
156  if (m_isVerbose) {
157  cout << "----Found Stereo TS----" << endl;
158  for (unsigned iSt = 0; iSt < 4; ++iSt) {
159  if (bestTSIndex[iSt] == -1) continue;
160  cout << "sl-iWire:" << iSt * 2 + 1 << "-" << m_hits[bestTSIndex[iSt]]->getIWire() << " pr:" <<
161  m_hits[bestTSIndex[iSt]]->getPriorityPosition() << " lr:" << m_hits[bestTSIndex[iSt]]->getLeftRight() << " rt:" <<
162  m_hits[bestTSIndex[iSt]]->getTDCCount() << " dt:" << m_hits[bestTSIndex[iSt]]->priorityTime() << endl;
163  }
164  cout << "----Found Stereo TS----" << endl;
165  cout << "----2D----" << endl;
166  cout << "charge: " << charge << " radius: " << rho << " phi0_c: " << phi << endl;
167  cout << "----2D----" << endl;
168  }
169 
170  // count the number of selected hits
171  unsigned nHits = 0;
172  for (unsigned iSt = 0; iSt < 4; ++iSt) {
173  if (bestTSIndex[iSt] != -1) {
174  nHits += 1;
175  }
176  }
177  if (nHits < m_minHits) {
178  B2DEBUG(100, "Not enough hits to do 3D fit (" << m_minHits << " needed, got " << nHits << ")");
179  continue;
180  }
181 
182  // do the fit and create a new track
183  double z0 = 0;
184  double cot = 0;
185  double chi2 = 0;
186  fitter(bestTSIndex, bestTSPhi, charge, rho, phi, z0, cot, chi2);
187 
188  //cout<<"nHits: "<<nHits<<" charge:"<<charge<<" rho:"<<rho<<" phi:"<<phi<<" z0:"<<z0<<" cot:"<<cot<<endl;
189 
190  // check if fit results are valid
191  if (isnan(z0) || isnan(cot) || isnan(chi2)) {
192  B2DEBUG(100, "3D fit failed");
193  continue;
194  }
195 
196  // save track
197  CDCTriggerTrack* fittedTrack =
198  m_tracks3D.appendNew(m_tracks2D[itrack]->getPhi0(), m_tracks2D[itrack]->getOmega(),
199  m_tracks2D[itrack]->getChi2D(),
200  z0, cot, chi2);
201  // make relation to 2D track
202  m_tracks2D[itrack]->addRelationTo(fittedTrack);
203  // make relation to hits
204  for (unsigned iSt = 0; iSt < 4; ++iSt) {
205  if (bestTSIndex[iSt] != -1)
206  fittedTrack->addRelationTo(m_hits[bestTSIndex[iSt]]);
207  }
208  // add axial relations from 2D track
210  m_tracks2D[itrack]->getRelationsTo<CDCTriggerSegmentHit>(m_hitCollectionName);
211  for (unsigned ihit = 0; ihit < axialHits.size(); ++ihit) {
212  fittedTrack->addRelationTo(axialHits[ihit]);
213  }
214  }
215 }
216 
217 void
218 CDCTrigger3DFitterModule::finder(int charge, double rho, double phi,
219  vector<int>& bestTSIndex, vector<double>& bestTSPhi)
220 {
221  vector<double> stAxPhi(4);
222  for (int iSt = 0; iSt < 4; ++iSt) {
223  stAxPhi[iSt] = Fitter3DUtility::calStAxPhi(charge, angleSt[iSt], zToStraw[iSt],
224  rr[iSt], rho, phi);
225  }
226  // get candidates
227  vector<vector<int>> candidatesIndex(4, vector<int>());
228  vector<vector<double>> candidatesPhi(4, vector<double>());
229  vector<vector<double>> candidatesDiffStWires(4, vector<double>());
230  for (int ihit = 0; ihit < m_hits.getEntries(); ++ihit) {
232  //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;
233  //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;
234  // Reject second priority TSs.
235  if (m_hits[ihit]->getPriorityPosition() != 3) continue;
236  // only stereo hits
237  unsigned iSL = m_hits[ihit]->getISuperLayer();
238  if (iSL % 2 == 0) continue;
239  // skip hits with too large radius
240  if (2 * rho < rr[iSL / 2]) continue;
241  // Find number of wire difference
242  double wirePhi = m_hits[ihit]->getIWire() * 2. * M_PI / nWires[iSL / 2];
243  double tsDiffSt = stAxPhi[iSL / 2] - wirePhi;
244  if (tsDiffSt > M_PI) tsDiffSt -= 2 * M_PI;
245  if (tsDiffSt < -M_PI) tsDiffSt += 2 * M_PI;
246  tsDiffSt = tsDiffSt / 2 / M_PI * nWires[iSL / 2];
247  // Save index if condition is in 10 wires
248  if ((iSL / 2) % 2 == 0) {
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  } else {
255  if (tsDiffSt < 0 && tsDiffSt >= -10) {
256  candidatesIndex[iSL / 2].push_back(ihit);
257  candidatesPhi[iSL / 2].push_back(wirePhi);
258  candidatesDiffStWires[iSL / 2].push_back(tsDiffSt);
259  }
260  } // End of saving index
261  } // Candidate loop
262 
263  // Pick middle candidate if multiple candidates
264  // mean wire diff
265  const double meanWireDiff[4] = { 3.68186, 3.3542, 3.9099, 4.48263 };
266  for (int iSt = 0; iSt < 4; ++iSt) {
267  //cout<<"iSt: "<<iSt<<" nCandidates:"<<candidatesIndex[iSt].size()<<endl;
268  //if (candidatesIndex[iSt].size() >1) continue;
269  double bestDiff = 9999;
270  for (int iTS = 0; iTS < int(candidatesIndex[iSt].size()); ++iTS) {
271  double diff = abs(abs(candidatesDiffStWires[iSt][iTS]) - meanWireDiff[iSt]);
272  // Pick the better TS
273  if (diff < bestDiff) {
274  bestDiff = diff;
275  bestTSPhi[iSt] = candidatesPhi[iSt][iTS];
276  bestTSIndex[iSt] = candidatesIndex[iSt][iTS];
277  }
278  } // TS loop
279  } // Layer loop
280 
281 
282  //StoreArray<Track> tracks;
283  //for (int iTrack = 0; iTrack < tracks.getEntries(); iTrack++)
284  //{
285  // cout<<tracks[iTrack].getTrackFitResults().size()<<endl;
286  //}
287 
288 }
289 
290 void
291 CDCTrigger3DFitterModule::fitter(const vector<int>& bestTSIndex, [[maybe_unused]] vector<double>& bestTSPhi,
292  int charge, double rho, double phi,
293  double& z0, double& cot, double& chi2)
294 {
295  // Find min timing [0, 511]
296 
297  // Convert format
298  // rawStTSs[iSt] = [TS ID, TS LR, TS driftTime]
299  vector<vector<int> > rawStTSs(4, vector<int> (3));
300  for (unsigned iSt = 0; iSt < 4; ++iSt) {
301  if (bestTSIndex[iSt] == -1) continue;
302  rawStTSs[iSt][0] = m_hits[bestTSIndex[iSt]]->getIWire();
303  rawStTSs[iSt][1] = m_hits[bestTSIndex[iSt]]->getLeftRight();
304  rawStTSs[iSt][2] = m_hits[bestTSIndex[iSt]]->priorityTime();
305  }
306  int eventTimeValid = 0;
307  int eventTime = 0;
308  if (m_eventTime->hasBinnedEventT0(Const::CDC)) {
309  eventTimeValid = 1;
310  eventTime = m_eventTime->getBinnedEventT0(Const::CDC);
311  //cout<<"eventTime: "<<eventTime<<endl;
312  }
313  double radius = rho;
314  double phi_c = phi;
315  if (phi_c > M_PI) phi_c -= 2 * M_PI;
316  if (phi_c < -M_PI) phi_c += 2 * M_PI;
317 
318  vector<double> arcS(4, 0);
319  vector<double> zz(4, 0);
320  vector<double> invZError2(4, 0);
321 
322  // Do fit
323  if (m_fitterMode == 1) Fitter3DUtility::fitter3D(m_stGeometry, m_stXts, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c,
324  z0, cot, chi2, arcS, zz, invZError2);
325 
326  if (m_fitterMode == 2) {
327  Fitter3DUtility::fitter3DFirm(m_mConstD, m_mConstV, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, m_commonData,
329  z0 = m_mSignalStorage["z0_r"].getRealInt();
330  cot = m_mSignalStorage["cot_r"].getRealInt();
331  chi2 = m_mSignalStorage["zChi2_r"].getRealInt();
332  for (int iSt = 0; iSt < 4; iSt++) {
333  invZError2[iSt] = m_mSignalStorage["iZError2_" + to_string(iSt)].getRealInt();
334  arcS[iSt] = m_mSignalStorage["arcS_" + to_string(iSt)].getRealInt();
335  zz[iSt] = m_mSignalStorage["zz_" + to_string(iSt)].getRealInt();
336  }
337  }
338 
339  if (m_isVerbose) {
340  cout << "----3D----" << endl;
341  cout << "arcS [0]: " << arcS[0] << " [1]: " << arcS[1] << " [2]: " << arcS[2] << " [3]: " << arcS[3] << endl;
342  cout << "zz [0]: " << zz[0] << " [1]: " << zz[1] << " [2]: " << zz[2] << " [3]: " << zz[3] << endl;
343  cout << "invZError2 [0]: " << invZError2[0] << " [1]: " << invZError2[1] << " [2]: " << invZError2[2] << " [3]: " << invZError2[3]
344  << endl;
345  cout << "z0: " << z0 << " cot: " << cot << " chi2: " << chi2 << endl;
346  cout << "----3D----" << endl;
347  }
348 
349  //double newZ0 = 0;
350  //double newCot = 0;
351  //double newChi2 = 0;
352  //{
353  // // Convert format
354  // // rawStTSs[iSt] = [TS ID, TS LR, TS driftTime]
355  // vector<vector<int> > rawStTSs (4, vector<int> (3));
356  // for(unsigned iSt = 0; iSt <4; ++iSt)
357  // {
358  // if (bestTSIndex[iSt] == -1) continue;
359  // rawStTSs[iSt][0] = m_hits[bestTSIndex[iSt]]->getIWire();
360  // rawStTSs[iSt][1] = m_hits[bestTSIndex[iSt]]->getLeftRight();
361  // rawStTSs[iSt][2] = m_hits[bestTSIndex[iSt]]->priorityTime();
362  // }
363  // int eventTimeValid = 0;
364  // int eventTime = 0;
365  // if (m_eventTime->hasBinnedEventT0(Const::CDC))
366  // {
367  // eventTimeValid = 1;
368  // eventTime = m_eventTime->getBinnedEventT0(Const::CDC);
369  // }
370  // double radius = rho;
371  // double phi_c = phi;
372  // Fitter3DUtility::fitter3D(m_stGeometry, m_stXts, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, newZ0, newCot, newChi2);
373  // //// Fit3D
374  // //vector<double> stTSs(4);
375  // //Fitter3DUtility::calPhiFast(m_stGeometry, m_stXts, eventTimeValid, eventTime, rawStTSs, stTSs);
376  // //vector<double> invZError2;
377  // //Fitter3DUtility::setErrorFast(rawStTSs, eventTimeValid, invZError2);
378  // //vector<double> zz(4, 0);
379  // //vector<double> arcS(4, 0);
380  // //for (unsigned iSt = 0; iSt < 4; iSt++) {
381  // // if (rawStTSs[iSt][1] != 0) {
382  // // zz[iSt] = Fitter3DUtility::calZ(charge, m_stGeometry["angleSt"][iSt], m_stGeometry["zToStraw"][iSt],
383  // // m_stGeometry["cdcRadius"][iSt], stTSs[iSt], radius, phi_c);
384  // // arcS[iSt] = Fitter3DUtility::calS(radius, m_stGeometry["cdcRadius"][iSt]);
385  // // }
386  // //}
387  // //double z0 = 0;
388  // //double cot = 0;
389  // //double chi2 = 0;
390  // //Fitter3DUtility::rSFit(&invZError2[0], &arcS[0], &zz[0], z0, cot, chi2);
391  // //newZ0 = z0;
392  // //newCot = cot;
393  // //newChi2 = chi2;
394  // ////cout<<"[Calculate fast]"<<endl;
395  // ////cout<<" [calPhi] "<<stTSs[0]<<" "<<stTSs[1]<<" "<<stTSs[2]<<" "<<stTSs[3]<<endl;
396  // ////cout<<" [invZError2] "<<invZError2[0]<<" "<<invZError2[1]<<" "<<invZError2[2]<<" "<<invZError2[3]<<endl;
397  // ////cout<<" [zz] "<<zz[0]<<" "<<zz[1]<<" "<<zz[2]<<" "<<zz[3]<<endl;
398  // ////cout<<" [arcS] "<<arcS[0]<<" "<<arcS[1]<<" "<<arcS[2]<<" "<<arcS[3]<<endl;
399  // ////cout<<" [z0] "<<z0<<" [cot] "<<cot<<" [chi2] "<<chi2<<endl;
400  //}
401 
402 
403  //int T0 = (m_eventTime->hasBinnedEventT0(Const::CDC))
404  // ? m_eventTime->getBinnedEventT0(Const::CDC)
405  // : 9999;
406  //
409 
411  //vector<double> wirePhi(4, 9999);
412  //vector<unsigned> LR(4, 0);
413  //vector<int> driftTime(4, 9999);
414  //for (unsigned iSt = 0; iSt < 4; ++iSt) {
415  // if (bestTSIndex[iSt] != -1) {
416  // wirePhi[iSt] = bestTSPhi[iSt];
417  // LR[iSt] = m_hits[bestTSIndex[iSt]]->getLeftRight();
418  // driftTime[iSt] = m_hits[bestTSIndex[iSt]]->priorityTime();
419  // }
420  //} // End superlayer loop
424 
426  //vector<double> phi3D(4, 9999);
427  //if (T0 == 9999) {
428  // for (unsigned iSt = 0; iSt < 4; iSt++) {
429  // phi3D[iSt] = wirePhi[iSt];
430  // }
431  //} else {
432  // for (unsigned iSt = 0; iSt < 4; iSt++) {
433  // if (bestTSIndex[iSt] != -1) {
434  // // Get drift length from table.
435  // int t = driftTime[iSt] - T0;
436  // if (t < 0) t = 0;
437  // if (t > 511) t = 511;
438  // double driftLength = xtTables[iSt][t];
439  // phi3D[iSt] = Fitter3DUtility::calPhi(wirePhi[iSt], driftLength, rr[iSt], LR[iSt]);
440  // }
441  // }
442  //}
444  //vector<double> driftZError({0.7676, 0.9753, 1.029, 1.372});
445  //vector<double> wireZError({0.7676, 0.9753, 1.029, 1.372});
446  //vector<double> zError(4, 9999);
447  //vector<double> invZError2(4, 0);
448  //for (unsigned iSt = 0; iSt < 4; ++iSt) {
449  // if (bestTSIndex[iSt] != -1) {
450  // // Check LR and eventTime
451  // if (LR[iSt] != 3 && T0 != 9999) zError[iSt] = driftZError[iSt];
452  // else zError[iSt] = wireZError[iSt];
453  // // Get inverse zerror ^ 2
454  // invZError2[iSt] = 1 / pow(zError[iSt], 2);
455  // }
456  //}
457 
459  //vector<double> zz(4, 0);
460  //vector<double> arcS(4, 0);
461  //for (unsigned iSt = 0; iSt < 4; iSt++) {
462  // if (bestTSIndex[iSt] != -1) {
463  // zz[iSt] = Fitter3DUtility::calZ(charge, angleSt[iSt], zToStraw[iSt],
464  // rr[iSt], phi3D[iSt], rho, phi);
465  // arcS[iSt] = Fitter3DUtility::calS(rho, rr[iSt]);
466  // }
467  //}
468 
470  //Fitter3DUtility::rSFit(&invZError2[0], &arcS[0], &zz[0], z0, cot, chi2);
471 
478 
482 }
bool hasBinnedEventT0(const Const::EDetector detector) const
Check if one of the detectors in the given set has a binned t0 estimation.
int getBinnedEventT0(const Const::EDetector detector) const
Return the stored binned event t0 for the given detector or 0 if nothing stored.
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.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool requireRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, const std::string &namedRelation="") const
Produce error if no relation from this array to 'toArray' has been registered.
Definition: StoreArray.h:155
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
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:140
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:1558
static void getStereoXt(std::vector< double > const &stPriorityLayer, std::vector< std::vector< double > > &stXts, bool isSimple=0)
Get stereo Xt.
Definition: Fitter3D.cc:1578
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:1596
Abstract base class for different kinds of events.