Belle II Software  release-05-02-19
TRGCDC.cc
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : TRGCDC.cc
5 // Section : TRG CDC
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : A class to represent CDC.
10 //-----------------------------------------------------------------------------
11 // $Log$
12 //-----------------------------------------------------------------------------
13 
14 #define TRG_SHORT_NAMES
15 #define TRGCDC_SHORT_NAMES
16 
17 #include <math.h>
18 #include <iostream>
19 #include <fstream>
20 #include "framework/datastore/StoreArray.h"
21 #include "framework/datastore/RelationArray.h"
22 #include "rawdata/dataobjects/RawDataBlock.h"
23 #include "rawdata/dataobjects/RawCOPPER.h"
24 #include <rawdata/dataobjects/RawTRG.h>
25 #include "cdc/geometry/CDCGeometryPar.h"
26 #include "cdc/dataobjects/CDCHit.h"
27 #include "cdc/dataobjects/CDCSimHit.h"
28 #include "mdst/dataobjects/MCParticle.h"
29 #include "trg/trg/Debug.h"
30 #include "trg/trg/Time.h"
31 #include "trg/trg/State.h"
32 #include "trg/trg/Signal.h"
33 #include "trg/trg/Channel.h"
34 #include "trg/trg/Utilities.h"
35 #include "trg/cdc/dataobjects/CDCTriggerSegmentHit.h"
36 #include "trg/cdc/dataobjects/CDCTriggerTrack.h"
37 #include "trg/trg/dataobjects/TRGTiming.h"
38 #include "trg/cdc/TRGCDC.h"
39 #include "trg/cdc/Wire.h"
40 #include "trg/cdc/Layer.h"
41 #include "trg/cdc/WireHit.h"
42 #include "trg/cdc/WireHitMC.h"
43 #include "trg/cdc/TrackMC.h"
44 #include "trg/cdc/Relation.h"
45 #include "trg/cdc/Track.h"
46 #include "trg/cdc/Segment.h"
47 #include "trg/cdc/SegmentHit.h"
48 #include "trg/cdc/LUT.h"
49 #include "trg/cdc/FrontEnd.h"
50 #include "trg/cdc/Merger.h"
51 #include "trg/cdc/TrackSegmentFinder.h"
52 #include "trg/cdc/Tracker2D.h"
53 #include "trg/cdc/PerfectFinder.h"
54 #include "trg/cdc/HoughFinder.h"
55 #include "trg/cdc/Hough3DFinder.h"
56 #include "trg/cdc/Fitter3D.h"
57 #include "trg/cdc/Fitter3DUtility.h"
58 #include "trg/cdc/Link.h"
59 #include "trg/cdc/EventTime.h"
60 #include <framework/gearbox/Const.h>
61 
62 #define NOT_USE_SOCKETLIB
63 //#define NOT_SEND
64 //#define DUMMY_DATA
65 #define TIME_MONITOR
66 //#define MULTIPLE_SEND
67 //#define MEMCPY_TO_ONE_BUFFER
68 #define SEND_BY_WRITEV
69 
70 #ifdef TRGCDC_DISPLAY
71 #include "trg/cdc/DisplayRphi.h"
72 #include "trg/cdc/DisplayHough.h"
73 namespace Belle2_TRGCDC {
74  Belle2::TRGCDCDisplayRphi* D = 0;
75 }
76 using namespace Belle2_TRGCDC;
77 #endif
78 
79 #define P3D HepGeom::Point3D<double>
80 
81 using namespace std;
82 
83 namespace Belle2 {
89  string
90  TRGCDC::name(void) const
91  {
92  return "TRGCDC";
93  }
94 
95  string
96  TRGCDC::version(void) const
97  {
98  return string("TRGCDC 5.39");
99  }
100 
101  TRGCDC*
102  TRGCDC::_cdc = 0;
103 
104  TRGCDC*
105  TRGCDC::getTRGCDC(const string& configFile,
106  unsigned simulationMode,
107  unsigned fastSimulationMode,
108  unsigned firmwareSimulationMode,
109  int firmwareSimulationStart,
110  int firmwareSimulationStop,
111  bool makeRootFile,
112  bool perfect2DFinder,
113  bool perfect3DFinder,
114  const string& innerTSLUTFile,
115  const string& outerTSLUTFile,
116  const string& rootTRGCDCFile,
117  const string& rootFitter3DFile,
118  unsigned houghFinderPeakMin,
119  const string& houghMappingFilePlus,
120  const string& houghMappingFileMinus,
121  unsigned houghDoit,
122  bool fLogicLUTTSF,
123  bool fLRLUT,
124  bool fFitter3Dsmclr,
125  bool fFitter3Ds2DFit,
126  bool fFitter3Ds2DFitDrift,
127  double inefficiency,
128  bool fileTSF,
129  bool fileETF,
130  int fverETF,
131  bool fprintFirmETF,
132  bool fileHough3D,
133  int finder3DMode,
134  bool fileFitter3D,
135  bool fXtSimpleFitter3D,
136  double TdcBinWidth,
137  int trgCDCDataInputMode,
138  const string& cdchitCollectionName)
139  {
140  if (_cdc) {
141  //delete _cdc;
142  _cdc = 0;
143  }
144 
145  if (configFile != "good-bye") {
146  _cdc = new TRGCDC(configFile,
147  simulationMode,
148  fastSimulationMode,
149  firmwareSimulationMode,
150  firmwareSimulationStart,
151  firmwareSimulationStop,
152  makeRootFile,
153  perfect2DFinder,
154  perfect3DFinder,
155  innerTSLUTFile,
156  outerTSLUTFile,
157  rootTRGCDCFile,
158  rootFitter3DFile,
159  houghFinderPeakMin,
160  houghMappingFilePlus,
161  houghMappingFileMinus,
162  houghDoit,
163  fLogicLUTTSF,
164  fLRLUT,
165  fFitter3Dsmclr,
166  fFitter3Ds2DFit,
167  fFitter3Ds2DFitDrift,
168  inefficiency,
169  fileTSF,
170  fileETF,
171  fverETF,
172  fprintFirmETF,
173  fileHough3D,
174  finder3DMode,
175  fileFitter3D,
176  fXtSimpleFitter3D,
177  TdcBinWidth,
178  trgCDCDataInputMode,
179  cdchitCollectionName);
180  } else {
181  cout << "TRGCDC::getTRGCDC ... good-bye" << endl;
182  // delete _cdc;
183  _cdc = 0;
184  }
185 
186  return _cdc;
187  }
188 
189  TRGCDC*
190  TRGCDC::getTRGCDC(void)
191  {
192  if (! _cdc)
193  cout << "TRGCDC::getTRGCDC !!! TRGCDC is not created yet" << endl;
194  return _cdc;
195  }
196 
197  vector<TCTrack*>
198  TRGCDC::getTrackList2D(void)
199  {
200  return _trackList2D;
201  }
202 
203  vector<TCTrack*>
204  TRGCDC::getTrackList2DFitted(void)
205  {
206  return _trackList2DFitted;
207  }
208 
209  vector<TCTrack*>
210  TRGCDC::getTrackList3D(void)
211  {
212  return _trackList3D;
213  }
214 
215  TRGCDC::TRGCDC(const string& configFile,
216  unsigned simulationMode,
217  unsigned fastSimulationMode,
218  unsigned firmwareSimulationMode,
219  int firmwareSimulationStart,
220  int firmwareSimulationStop,
221  bool makeRootFile,
222  bool perfect2DFinder,
223  bool perfect3DFinder,
224  const string& innerTSLUTFile,
225  const string& outerTSLUTFile,
226  const string& rootTRGCDCFile,
227  const string& rootFitter3DFile,
228  unsigned houghFinderPeakMin,
229  const string& houghMappingFilePlus,
230  const string& houghMappingFileMinus,
231  unsigned houghDoit,
232  bool fLogicLUTTSF,
233  bool fLRLUT,
234  bool fFitter3Dsmclr,
235  bool fFitter3Ds2DFit,
236  bool fFitter3Ds2DFitDrift,
237  double inefficiency,
238  bool fileTSF,
239  bool fileETF,
240  int fverETF,
241  bool fprintFirmETF,
242  bool fileHough3D,
243  int finder3DMode,
244  bool fileFitter3D,
245  bool fXtSimpleFitter3D,
246  double TdcBinWidth,
247  int trgCDCDataInputMode,
248  const string& cdchitCollectionName):
249  _debugLevel(0),
250  _configFilename(configFile),
251  _simulationMode(simulationMode),
252  _fastSimulationMode(fastSimulationMode),
253  _firmwareSimulationMode(firmwareSimulationMode),
254  _firmwareSimulationStart(firmwareSimulationStart),
255  _firmwareSimulationStop(firmwareSimulationStop),
256  _returnValue(0),
257  _makeRootFile(makeRootFile),
258  _perfect2DFinder(perfect2DFinder),
259  _perfect3DFinder(perfect3DFinder),
260  _innerTSLUTFilename(innerTSLUTFile),
261  _outerTSLUTFilename(outerTSLUTFile),
262  _rootTRGCDCFilename(rootTRGCDCFile),
263  _rootFitter3DFilename(rootFitter3DFile),
264  _fLogicLUTTSF(fLogicLUTTSF),
265  _fLRLUT(fLRLUT),
266  _fFitter3Dsmclr(fFitter3Dsmclr),
267  _fFitter3Ds2DFit(fFitter3Ds2DFit),
268  _fFitter3Ds2DFitDrift(fFitter3Ds2DFitDrift),
269  _inefficiency(inefficiency),
270  _fileTSF(fileTSF),
271  _fileETF(fileETF),
272  _fverETF(fverETF),
273  _fprintFirmETF(fprintFirmETF),
274  _fileHough3D(fileHough3D),
275  _finder3DMode(finder3DMode),
276  _fileFitter3D(fileFitter3D),
277  _fXtSimpleFitter3D(fXtSimpleFitter3D),
278  _fudgeFactor(1.),
279  _width(0),
280  _r(0),
281  _r2(0),
282  _clock("CDCTrigger system clock", 0, 125. / TdcBinWidth),
283  _clockFE("CDCFE TDC clock", _clock, 8),
284  _clockTDC("CDCTrigger TDC clock (after mergers)", _clock, 4),
285  _clockD("CDCTrigger data clock", _clock, 1, 4),
286  _clockUser3125("CDCTrigger Aurora user clock (3.125Gbps)",
287  _clock, 25, 20),
288  _clockUser6250("CDCTrigger Aurora user clock (6.250Gbps)",
289  _clock, 50, 20),
290  _offset(5.3),
291  _pFinder(0),
292  _hFinder(0),
293  _h3DFinder(0),
294  _fitter3D(0),
295  _eventTime(0),
296  _trgCDCDataInputMode(trgCDCDataInputMode),
297  _cdchitCollectionName(cdchitCollectionName)
298  {
299 
300  TRGDebug::enterStage("TRGCDC constructor");
301 
302 #ifdef TRGCDC_DISPLAY
303  int argc = 0;
304  char** argv = 0;
305  Gtk::Main main_instance(argc, argv);
306  if (! D)
307  D = new TCDisplayRphi();
308  D->clear();
309  D->show();
310  cout << "TRGCDC ... GTK initialized" << endl;
311 #endif
312 
313  //...Clock summary...
314  _clock.dump();
315  _clockFE.dump();
316  _clockTDC.dump();
317  _clockD.dump();
318 
319  //...Firmware simulation time window...
321  TRGTime fall = rise;
323  _firmwareSimulationWindow = TRGSignal(rise & fall);
324  _firmwareSimulationWindow.name("Firmware simulation window in FE clock");
326 
327  //...Time window in other clocks...
332 
333  cout << "In " << _clock.name() << endl;
334  cout << " Start : "
336  << endl;
337  cout << " Stop : "
339  << endl;
340  cout << "In " << _clockTDC.name() << endl;
341  cout << " Start : "
343  << endl;
344  cout << " Stop : "
346  << endl;
347  cout << "In " << _clockD.name() << endl;
348  cout << " Start : " << _firmwareSimulationStartDataClock << endl;
349  cout << " Stop : " << _firmwareSimulationStopDataClock << endl;
350 
351  if (TRGDebug::level()) {
352  cout << "TRGCDC ... TRGCDC initializing with " << _configFilename
353  << endl
354  << "mode=0x" << hex << _simulationMode << dec << endl;
355  }
356 
357  initialize(houghFinderPeakMin,
358  houghMappingFilePlus,
359  houghMappingFileMinus,
360  houghDoit);
361 
362  if (TRGDebug::level()) {
363  cout << "TRGCDC ... TRGCDC created with " << _configFilename << endl;
364  }
365 
366  TRGDebug::leaveStage("TRGCDC constructor");
367  }
368 
369  void
370  TRGCDC::initialize(unsigned houghFinderPeakMin,
371  const string& houghMappingFilePlus,
372  const string& houghMappingFileMinus,
373  unsigned houghDoit)
374  {
375 
376  TRGDebug::enterStage("TRGCDC initialize");
377 
378  //...CDC...
380  const unsigned nLayers = m_cdcp->nWireLayers();
381 
382  //...Loop over layers...
383  int superLayerId = -1;
384  vector<TRGCDCLayer*>* superLayer;
385  unsigned lastNWires = 0;
386  int lastShifts = -1000;
387  int ia = -1;
388  int is = -1;
389  int ias = -1;
390  int iss = -1;
391  unsigned nWires = 0;
392  float fwr = 0;
393  unsigned axialStereoSuperLayerId = 0;
394  for (unsigned i = 0; i < nLayers; i++) {
395  const unsigned nWiresInLayer = m_cdcp->nWiresInLayer(i);
396 
397  //...Axial or stereo?...
398  int nShifts = m_cdcp->nShifts(i);
399  bool axial = true;
400  if (nShifts != 0)
401  axial = false;
402 
403  unsigned axialStereoLayerId = 0;
404  if (axial) {
405  ++ia;
406  axialStereoLayerId = ia;
407  } else {
408  ++is;
409  axialStereoLayerId = is;
410  }
411 
412  if (TRGDebug::level() > 1) {
413  cout << TRGDebug::tab() << "No " << i << " nWiresInLayer: "
414  << nWiresInLayer << " axial: " << axial << " nShifts: "
415  << nShifts << endl;
416  }
417 
418  //...Is this in a new super layer?...
419  if ((lastNWires != nWiresInLayer) || (lastShifts != nShifts)) {
420  ++superLayerId;
421  superLayer = new vector<TRGCDCLayer*>;
422  _superLayers.push_back(superLayer);
423  if (axial) {
424  ++ias;
426  _axialSuperLayers.push_back(superLayer);
427  } else {
428  ++iss;
430  _stereoSuperLayers.push_back(superLayer);
431  }
432  lastNWires = nWiresInLayer;
433  lastShifts = nShifts;
434  }
435 
436  if (TRGDebug::level() > 1) {
437  cout << TRGDebug::tab() << "(lastNWires,nWiresInLayer) "
438  << lastNWires << " " << nWiresInLayer << endl;
439  cout << TRGDebug::tab() << "(lastShifts,nShifts) " << lastShifts
440  << " " << nShifts << endl;
441  cout << "superLayerId: " << superLayerId << endl;
442  cout << "ia: " << ia << " is: " << is << " ias: " << ias
443  << " iss: " << iss << endl;
444  }
445 
446  //...Calculate radius...
447  const float swr = m_cdcp->senseWireR(i);
448  if (i < nLayers - 1)
449  fwr = m_cdcp->fieldWireR(i);
450  else
451  fwr = swr + (swr - m_cdcp->fieldWireR(i - 1));
452  const float innerRadius = swr - (fwr - swr);
453  const float outerRadius = swr + (fwr - swr);
454 
455  if (TRGDebug::level() > 1)
456  cout << TRGDebug::tab() << "lyr " << i << ", in=" << innerRadius
457  << ", out=" << outerRadius << ", swr=" << swr << ", fwr"
458  << fwr << endl;
459 
460  //...New layer...
461  TRGCDCLayer* layer = new TRGCDCLayer(i,
462  superLayerId,
463  _superLayers[superLayerId]->size(),
464  axialStereoLayerId,
467  nShifts,
468  M_PI * m_cdcp->senseWireR(i)
469  * m_cdcp->senseWireR(i)
470  / double(nWiresInLayer),
471  nWiresInLayer,
472  innerRadius,
473  outerRadius);
474  _layers.push_back(layer);
475  superLayer->push_back(layer);
476  if (axial)
477  _axialLayers.push_back(layer);
478  else
479  _stereoLayers.push_back(layer);
480 
481  //...Loop over all wires in a layer...
482  for (unsigned j = 0; j < nWiresInLayer; j++) {
483  const P3D fp = P3D(m_cdcp->wireForwardPosition(i, j).x(),
484  m_cdcp->wireForwardPosition(i, j).y(),
485  m_cdcp->wireForwardPosition(i, j).z());
486  const P3D bp = P3D(m_cdcp->wireBackwardPosition(i, j).x(),
487  m_cdcp->wireBackwardPosition(i, j).y(),
488  m_cdcp->wireBackwardPosition(i, j).z());
489  TCWire* tw = new TCWire(nWires++, j, *layer, fp, bp, _clockFE);
490  if (_simulationMode & 1)
491  tw->_signal.clock(_clockTDC);
492  _wires.push_back(tw);
493  layer->push_back(tw);
494  }
495  }
496 
497  //...event Time...
498  _eventTime.push_back(new TCEventTime(*this, _fileETF));
499  _eventTime.back()->initialize();
500 
501  //...Make TSF's...
502  const unsigned nWiresInTS[2] = {15, 11};
503  const int shape[2][30] = {
504  {
505  -2, 0, // relative layer id, relative wire id
506  -1, -1, // assuming layer offset 0.0, not 0.5
507  -1, 0,
508  0, -1,
509  0, 0,
510  0, 1,
511  1, -2,
512  1, -1,
513  1, 0,
514  1, 1,
515  2, -2,
516  2, -1,
517  2, 0,
518  2, 1,
519  2, 2
520  //-2, 0, // relative layer id, relative wire id
521  //-1, 0, // assuming layer offset 0.5, not 0.0
522  //-1, 1,
523  //0, -1,
524  //0, 0,
525  //0, 1,
526  //1, -1,
527  //1, -0,
528  //1, 1,
529  //1, 2,
530  //2, -2,
531  //2, -1,
532  //2, 0,
533  //2, 1,
534  //2, 2
535  },
536  {
537  -2, -1,
538  -2, 0,
539  -2, 1,
540  -1, -1,
541  -1, 0,
542  0, 0,
543  1, -1,
544  1, 0,
545  2, -1,
546  2, 0,
547  2, 1,
548  0, 0,
549  0, 0,
550  0, 0,
551  0, 0
552  }
553  };
554  const int layerOffset[2] = {5, 2};
555  unsigned id = 0;
556  unsigned idTS = 0;
557  for (unsigned i = 0; i < nSuperLayers(); i++) {
558  unsigned tsType = 0;
559  if (i)
560  tsType = 1;
561 
562 // const unsigned nLayers = _superLayers[i]->size(); //'nLayers' shadows a previous local
563 // if (nLayers < 5) {
564  if (_superLayers[i]->size() < 5) {
565  cout << "TRGCDC !!! can not create TS because "
566  << "#layers is less than 5 in super layer " << i
567  << endl;
568  continue;
569  }
570 
571  //...TS layer... w is a central wire
572  const TCCell& ww = *(*_superLayers[i])[layerOffset[tsType]]->front();
573  TRGCDCLayer* layer = new TRGCDCLayer(id++, ww);
574  _tsLayers.push_back(layer);
575 
576  //...Loop over all wires in a central wire layer...
577  const unsigned nWiresInLayer = ww.layer().nCells();
578  for (unsigned j = 0; j < nWiresInLayer; j++) {
579  const TCWire& w =
580  *(TCWire*)(*(*_superLayers[i])[layerOffset[tsType]])[j];
581 
582  const unsigned localId = w.localId();
583  const unsigned layerId = w.layerId();
584  vector<const TCWire*> cells;
585 
586  for (unsigned k = 0; k < nWiresInTS[tsType]; k++) {
587  const unsigned laid = layerId + shape[tsType][k * 2];
588  const unsigned loid = localId + shape[tsType][k * 2 + 1];
589 
590  const TCWire* c = wire(laid, loid);
591  if (! c)
592  cout << "TRGCDC !!! no such a wire for TS : "
593  << "layer id=" << laid << ", local id=" << loid
594  << endl;
595 
596  cells.push_back(c);
597  }
598 
599  TRGCDCSegment* ts;
600  if (w.superLayerId()) {
601  ts = new TRGCDCSegment(idTS++,
602  *layer,
603  w,
604  _clockD,
606  cells);
607  } else {
608  ts = new TRGCDCSegment(idTS++,
609  *layer,
610  w,
611  _clockD,
613  cells);
614  }
615  ts->initialize();
616 
617  //...Store it...
618  _tss.push_back(ts);
619  _tsSL[i].push_back(ts);
620  layer->push_back(ts);
621  }
622  }
623 
624  //...Fill caches...
625  if (_width) delete [] _width;
626  if (_r) delete [] _r;
627  if (_r2) delete [] _r2;
628  _width = new float[nSuperLayers()];
629  _r = new float[nSuperLayers() + 1];
630  _r2 = new float[nSuperLayers() + 1];
631  for (unsigned i = 0; i < nSuperLayers(); i++) {
632  const vector<TRGCDCLayer*>& slayer = *_superLayers[i];
633  _width[i] = M_PI * 2 / float(slayer.back()->nCells());
634  _r[i] = slayer[0]->innerRadius();
635  _r2[i] = _r[i] * _r[i];
636  if (i == (nSuperLayers() - 1)) {
637  _r[i + 1] = slayer.back()->outerRadius();
638  _r2[i + 1] = _r[i + 1] * _r[i + 1];
639  }
640 
641  if (TRGDebug::level() > 9) {
642  const TCCell& wi = *slayer[0]->front();
643  const unsigned layerId = wi.layerId();
644  cout << layerId << "," << m_cdcp->senseWireR(layerId) << ","
645  << m_cdcp->fieldWireR(layerId) << endl;
646  cout << " super layer " << i << " radius=" << _r[i]
647  << "(r^2=" << _r2[i] << ")" << endl;
648  }
649  }
650 
651  //...Track Segment Finder...
652  _tsFinder = new TSFinder(*this, _fileTSF, _fLogicLUTTSF);
653 
654  //...Perfect 2D Finder...
655  _pFinder = new TCPFinder("Perfect2DFinder", *this);
656 
657  //...Perfect 3D Finder...
658  _p3DFinder = 0;
659 
660  //...Hough 2D Finder...
661  _hFinder = new TCHFinder("HoughFinder",
662  *this,
663  houghFinderPeakMin,
664  houghMappingFilePlus,
665  houghMappingFileMinus,
666  houghDoit);
667 
668  //...Hough 3D Finder...
669  _h3DFinder = new TCH3DFinder(*this, _fileHough3D, _finder3DMode);
670 
671  //...3D fitter...
672  map<string, bool> flags = {
673  {"fLRLUT", _fLRLUT},
674  {"fmcLR", _fFitter3Dsmclr},
675  {"f2DFit", _fFitter3Ds2DFit},
676  {"f2DFitDrift", _fFitter3Ds2DFitDrift},
677  {"fRootFile", _fileFitter3D},
678  {"fXtSimple", _fXtSimpleFitter3D}
679  };
680  _fitter3D = new TCFitter3D("Fitter3D",
682  *this,
683  flags);
685 
686  //...For module simulation (Front-end)...
687  configure();
688 
689  //...Initialize root file...
690  if (_makeRootFile) {
691  m_file = new TFile((char*)_rootTRGCDCFilename.c_str(), "RECREATE");
692  //m_file = new TFile("TRGCDC.root", "RECREATE");
693  m_tree = new TTree("m_tree", "tree");
694  m_treeAllTracks = new TTree("m_treeAllTracks", "treeAllTracks");
695 
696  m_fitParameters = new TClonesArray("TVectorD");
697  m_mcParameters = new TClonesArray("TVectorD");
698  m_mcTrack4Vector = new TClonesArray("TLorentzVector");
699  m_mcTrackVertexVector = new TClonesArray("TVector3");
700  m_mcTrackStatus = new TClonesArray("TVectorD");
701  // m_parameters2D = new TClonesArray("TVectorD");
702 
703  m_tree->Branch("fitParameters", &m_fitParameters, 32000, 0);
704  m_tree->Branch("mcParameters", &m_mcParameters, 32000, 0);
705  m_treeAllTracks->Branch("mcTrack4Vector", &m_mcTrack4Vector, 32000, 0);
706  m_treeAllTracks->Branch("mcTrackVertexVector", &m_mcTrackVertexVector, 32000, 0);
707  m_treeAllTracks->Branch("mcTrackStatus", &m_mcTrackStatus, 32000, 0);
708 
709  m_evtTime = new TClonesArray("TVectorD");
710  m_treeAllTracks->Branch("evtTime", &m_evtTime, 32000, 0);
711 
712  _tree2D = new TTree("tree2D", "2D Tracks");
713  _tracks2D = new TClonesArray("TVectorD");
714  _tree2D->Branch("track parameters", & _tracks2D, 32000, 0);
715 
716  //...Initialize firmware ROOT input
717  //m_minCDCTdc = 9999;
718  //m_maxCDCTdc = 0;
719  //m_minTRGTdc = 9999;
720  //m_maxTRGTdc = 0;
721 
722  m_treeROOTInput = new TTree("m_treeROOTInput", "treeRootInput");
723  //m_CDCTRGTimeMatch = new TClonesArray("TVectorD");
724  m_rootCDCHitInformation = new TClonesArray("TVectorD");
725  m_rootTRGHitInformation = new TClonesArray("TVectorD");
726  m_rootTRGRawInformation = new TClonesArray("TObjString");
727  //m_treeROOTInput->Branch("CDCTRGTimeMatch", &m_CDCTRGTimeMatch,32000,0);
728  m_treeROOTInput->Branch("rootCDCHitInformation", &m_rootCDCHitInformation, 32000, 0);
729  m_treeROOTInput->Branch("rootTRGHitInformation", &m_rootTRGHitInformation, 32000, 0);
730  m_treeROOTInput->Branch("rootTRGRawInformation", &m_rootTRGRawInformation, 32000, 0);
731  }
732 
733  TRGDebug::leaveStage("TRGCDC initialize");
734  }
735 
736  void
738  {
739  TRGDebug::enterStage("TRGCDC terminate");
740 
741  if (_tsFinder) {
742  _tsFinder->terminate();
743  }
744  if (_eventTime.back()) {
745  _eventTime.back()->terminate();
746  }
747  if (_fitter3D) {
748  _fitter3D->terminate();
749  }
750  if (_hFinder) {
751  _hFinder->terminate();
752  }
753  if (_h3DFinder) {
755  }
756  if (_makeRootFile) {
757  m_file->Write();
758  m_file->Close();
759  }
760 
761  TRGDebug::leaveStage("TRGCDC terminate");
762  }
763 
764  void
765  TRGCDC::dump(const string& msg) const
766  {
767  TRGDebug::enterStage("TRGCDC dump");
768 
769  if (msg.find("name") != string::npos ||
770  msg.find("version") != string::npos ||
771  msg.find("detail") != string::npos ||
772  msg == "") {
773  cout << name() << "(CDC version=" << versionCDC() << ", "
774  << version() << ") ";
775  }
776  if (msg.find("detail") != string::npos ||
777  msg.find("state") != string::npos) {
778  cout << "Debug Level=" << _debugLevel;
779  }
780  cout << endl;
781 
782  string tab(" ");
783 
784  if (msg == "" || msg.find("geometry") != string::npos) {
785  //...Get information..."
786  unsigned nLayer = _layers.size();
787  cout << " version : " << version() << endl;
788  cout << " cdc version: " << versionCDC() << endl;
789  cout << " # of wires : " << _wires.size() << endl;
790  cout << " # of layers: " << nLayer << endl;
791  cout << " super layer information" << endl;
792  cout << " # of super layers() = "
793  << nSuperLayers() << endl;
794  cout << " # of Axial super layers = "
795  << nAxialSuperLayers() << endl;
796  cout << " # of Stereo super layers = "
797  << nStereoSuperLayers() << endl;
798 
799  if (msg.find("superLayers") != string::npos) {
800  cout << " super layer detail" << endl;
801  cout << " id #layers (stereo type)" << endl;
802  for (unsigned i = 0; i < nSuperLayers(); ++i) {
803  const unsigned n = _superLayers[i]->size();
804  cout << " " << i << " " << n << " (";
805  for (unsigned j = 0; j < n; j++) {
806  cout << (* _superLayers[i])[0]->stereoType();
807  }
808  cout << ")" << endl;
809  }
810  }
811 
812  cout << " layer information" << endl;
813  cout << " # of Axial layers = "
814  << nAxialLayers() << endl;
815  cout << " # of Stereo layers = "
816  << nStereoLayers() << endl;
817 
818  if (msg.find("layers") != string::npos) {
819  cout << " layer detail" << endl;
820  cout << " id type sId #wires lId asId assId"
821  << endl;
822  for (unsigned int i = 0; i < nLayers(); ++i) {
823  const TRGCDCLayer& l = *_layers[i];
824  cout << " " << i
825  << " " << l.stereoType()
826  << " " << l.superLayerId()
827  << " " << l.nCells()
828  << " " << l.localLayerId()
829  << " " << l.axialStereoLayerId()
830  << " " << l.axialStereoSuperLayerId()
831  << endl;
832  }
833  }
834 
835  if (msg.find("wires") != string::npos) {
836  cout << " wire information" << endl;
837  for (unsigned i = 0; i < nWires(); i++)
838  (_wires[i])->dump("neighbor", tab);
839  }
840 
841  return;
842  }
843  if (msg.find("hits") != string::npos) {
844  cout << " hits : " << _hits.size() << endl;
845  for (unsigned i = 0; i < (unsigned) _hits.size(); i++)
846  _hits[i]->dump("mc drift", tab);
847  }
848  if (msg.find("axialHits") != string::npos) {
849  cout << " hits : " << _axialHits.size() << endl;
850  for (unsigned i = 0; i < (unsigned) _axialHits.size(); i++)
851  _axialHits[i]->dump("mc drift", tab);
852  }
853  if (msg.find("stereoHits") != string::npos) {
854  cout << " hits : " << _stereoHits.size() << endl;
855  for (unsigned i = 0; i < (unsigned) _stereoHits.size(); i++)
856  _stereoHits[i]->dump("mc drift", tab);
857  }
858  if (msg.find("trgWireHits") != string::npos) {
859  const string dumpOption = "trigger detail";
860  cout << " wire hits" << endl;
861  for (unsigned i = 0; i < nWires(); i++) {
862  const TCWire& w = *wire(i);
863  if (w.signal().active())
864  w.dump(dumpOption, TRGDebug::tab(4));
865  }
866  }
867  if (msg.find("trgWireCentralHits") != string::npos) {
868  const string dumpOption = "trigger detail";
869  cout << " wire hits" << endl;
870  for (unsigned i = 0; i < nSegments(); i++) {
871  const TCSegment& s = segment(i);
872  if (s.wires()[5]->signal().active())
873  s.wires()[5]->dump(dumpOption, TRGDebug::tab(4));
874  }
875  }
876  if (msg.find("trgTSHits") != string::npos) {
877  const string dumpOption = "trigger detail";
878  cout << " TS hits" << endl;
879  for (unsigned i = 0; i < nSegments(); i++) {
880  const TCSegment& s = segment(i);
881  if (s.signal().active())
882  s.dump(dumpOption, TRGDebug::tab(4));
883  }
884  }
885 
886  TRGDebug::leaveStage("TRGCDC dump");
887  }
888 
889  const TCWire*
890  TRGCDC::wire(unsigned id) const
891  {
892  if (id < nWires())
893  return _wires[id];
894  return 0;
895  }
896 
897  const TCWire*
898  TRGCDC::wire(unsigned layerId, int localId) const
899  {
900  if (layerId < nLayers())
901  return (TCWire*) & _layers[layerId]->cell(localId);
902  return 0;
903  }
904 
905 // const TCWire *
906 // TRGCDC::wire(const HepGeom::Point3D<double> & p) const {
907 // float r = p.mag();
908 // float phi = p.phi();
909 // return wire(r, phi);
910 // }
911 
912  const TCWire*
913  TRGCDC::wire(float , float) const
914  {
915  //...Not implemented yet...
916  return _wires[0];
917 
918  // // cout << "r,phi = " << r << "," << p << endl;
919 
920  // // unsigned id = 25;
921  // // bool ok = false;
922  // // const TRGCDCLayer * l;
923  // // while (! ok) {
924  // // l = layer(id);
925  // // if (! l) return 0;
926 
927  // // const geocdc_layer * geo = l->geocdc();
928  // // if (geo->m_r + geo->m_rcsiz2 < r) ++id;
929  // // else if (geo->m_r - geo->m_rcsiz1 > r) --id;
930  // // else ok = true;
931  // // }
932  // // float dPhi = 2. * M_PI / float(l->nCells());
933  // // if (l->geocdc()->m_offset > 0.) p -= dPhi / 2.;
934  // // unsigned localId = unsigned(phi(p) / dPhi);
935  // // return l->wire(localId);
936  // }
937  }
938 
939  void
941  {
942  TRGDebug::enterStage("TRGCDC clear");
943 
944  TCWHit::removeAll();
945  TCSHit::removeAll();
946  TCLink::removeAll();
947 
948  // for (unsigned i = 0; i < _hits.size(); i++)
949  // delete _hits[i];
950  for (unsigned i = 0; i < _hitsMC.size(); i++)
951  delete _hitsMC[i];
952  // for (unsigned i = 0; i < _badHits.size(); i++)
953  // delete _badHits[i];
954  // for (unsigned i = 0; i < _segmentHits.size(); i++)
955  // delete _segmentHits[i];
956 
957  for (unsigned i = 0; i < _wires.size(); i++) {
958  TCWire* w = _wires[i];
959  w->clear();
960  }
961  for (unsigned i = 0; i < _tss.size(); i++) {
962  TCSegment* s = _tss[i];
963  s->clear();
964  }
965  _hitWires.clear();
966  _hits.clear();
967  _axialHits.clear();
968  _stereoHits.clear();
969  _badHits.clear();
970  _hitsMC.clear();
971  _segmentHits.clear();
972  for (unsigned i = 0; i < 9; i++)
973  _segmentHitsSL[i].clear();
974 
975  TRGDebug::leaveStage("TRGCDC clear");
976  }
977 
978  void
980 
981  void
983  {
984  _trackList2D.clear();
985  _trackList2DFitted.clear();
986  _trackList3D.clear();
987 
988  TRGDebug::enterStage("TRGCDC update");
989 
990  if (_trgCDCDataInputMode != 0) {
992  } else {
993 
994  //...Clear old information...
995  // fastClear();
996  clear();
997 
998  //...CDCSimHit...
999  StoreArray<CDCSimHit> SimHits;
1000  if (! SimHits) {
1001  if (TRGDebug::level())
1002  cout << "TRGCDC !!! can not access to CDCSimHits" << endl;
1003  TRGDebug::leaveStage("TRGCDC update");
1004  return;
1005  }
1006  const unsigned n = SimHits.getEntries();
1007 
1008  //...CDCHit...
1010  if (! CDCHits) {
1011  if (TRGDebug::level())
1012  cout << "TRGCDC !!! can not access to CDCHits" << endl;
1013  TRGDebug::leaveStage("TRGCDC update");
1014  return;
1015  }
1016  const unsigned nHits = CDCHits.getEntries();
1017 
1018  //...MCParticle...
1019  StoreArray<MCParticle> mcParticles;
1020  if (! mcParticles) {
1021  if (TRGDebug::level())
1022  cout << "TRGCDC !!! can not access to MCParticles" << endl;
1023  TRGDebug::leaveStage("TRGCDC update");
1024  return;
1025  }
1026 
1027  //...Relations...
1028  RelationArray rels(SimHits, CDCHits);
1029  const unsigned nRels = rels.getEntries();
1030  RelationArray relsMC(mcParticles, CDCHits);
1031  const unsigned nRelsMC = relsMC.getEntries();
1032 
1033  //...Loop over CDCHits...
1034  for (unsigned i = 0; i < nHits; i++) {
1035  const CDCHit& h = *CDCHits[i];
1036  double tmp = rand() / (double(RAND_MAX));
1037  if (tmp < _inefficiency)
1038  continue;
1039 
1040  // //...Check validity (skip broken channel)...
1041  // if (! (h->m_stat & CellHitFindingValid)) continue;
1042 
1043  //...Get CDCSimHit... This is expensive. Should be moved outside.
1044  unsigned iSimHit = 0;
1045  for (unsigned j = 0; j < nRels; j++) {
1046  const unsigned k = rels[j].getToIndices().size();
1047  for (unsigned l = 0; l < k; l++) {
1048  if (rels[j].getToIndex(l) == i)
1049  iSimHit = rels[j].getFromIndex();
1050  }
1051 
1052  if (TRGDebug::level())
1053  if (k > 1)
1054  cout << "TRGCDC::update !!! CDCSimHit[" << iSimHit
1055  << "] has multiple CDCHit(" << k << " hits)" << endl;
1056  }
1057 
1058  //...Get MCParticle... This is expensive, again.
1059  // (Getting the first MCParticle only)
1060  unsigned iMCPart = 0;
1061  for (unsigned j = 0; j < nRelsMC; j++) {
1062  const unsigned k = relsMC[j].getToIndices().size();
1063  for (unsigned l = 0; l < k; l++) {
1064  if (relsMC[j].getToIndex(l) == i) {
1065  iMCPart = relsMC[j].getFromIndex();
1066  break;
1067  }
1068  }
1069 
1070  if (TRGDebug::level())
1071  if (k > 1)
1072  cout << "TRGCDC::update !!! MCParticle[" << iMCPart
1073  << "] has multiple CDCHit(" << k << " hits)" << endl;
1074  }
1075 
1076  //...Wire...
1077  int t_layerId;
1078  if (h.getISuperLayer() == 0) t_layerId = h.getILayer();
1079  else t_layerId = h.getILayer() + 6 * h.getISuperLayer() + 2;
1080  const unsigned layerId = t_layerId;
1081  const unsigned wireId = h.getIWire();
1082  TCWire& w = *(TCWire*) wire(layerId, wireId);
1083 
1084  //...TDC count...
1085  B2INFO("t0:" << m_cdcp->getT0(WireID(h.getID())) <<
1086  "binwidth:" << m_cdcp->getTdcBinWidth() <<
1087  "tdc count:" << h.getTDCCount());
1088  const int tdcCount = floor(m_cdcp->getT0(WireID(h.getID())) / m_cdcp->getTdcBinWidth()
1089  - h.getTDCCount() + 0.5);
1090 
1091  //...Drift length from TDC...
1092  const float driftLength = tdcCount * m_cdcp->getTdcBinWidth() * m_cdcp->getNominalDriftV();
1093  const float driftLengthError = 0.013;
1094 
1095  //...Trigger timing...
1096  TRGTime rise = TRGTime(tdcCount, true, _clockFE, w.name());
1097  if (_simulationMode & 1)
1098  rise.clock(_clockTDC);
1099  TRGTime fall = rise;
1100  fall.shift(1).reverse();
1101  if (_simulationMode & 1)
1102  w._signal |= TRGSignal(rise & fall);
1103  else
1104  w._signal |= (TRGSignal(rise & fall) & _firmwareSimulationWindow);
1105  w._signal.name(w.name());
1106 
1107  //...Left/right...
1108  const int LRflag = SimHits[iSimHit]->getPosFlag();
1109 
1110  //...TCWireHit...
1111  TCWHit* hit = new TCWHit(w,
1112  i,
1113  iSimHit,
1114  iMCPart,
1115  driftLength,
1116  driftLengthError,
1117  driftLength,
1118  driftLengthError,
1119  LRflag,
1120  1);
1121  hit->state(CellHitFindingValid | CellHitFittingValid);
1122 
1123  //...Store a hit...
1124  if (!(*_layers[layerId])[wireId]->hit())
1125  ((TCWire*)(*_layers[layerId])[wireId])->hit(hit);
1126  _hits.push_back(hit);
1127  if (w.axial()) _axialHits.push_back(hit);
1128  else _stereoHits.push_back(hit);
1129 
1130  //...Debug...
1131  if (TRGDebug::level() > 2) {
1132  w._signal.dump("", TRGDebug::tab());
1133  cout << TRGDebug::tab(4) << "CDCHit TDC count="
1134  << h.getTDCCount() << std::endl;
1135  }
1136  }
1137 
1138  //...Track segment... This part is moved to ::simulate().
1139 
1140  //...Hit classification...
1141  // _hits.sort(TCWHit::sortByWireId);
1142  classification();
1143 
1144  if (TRGDebug::level()) {
1145  cout << TRGDebug::tab() << "#CDCSimHit=" << n << ",#CDCHit="
1146  << nHits << endl;
1147  }
1148 
1149  if (TRGDebug::level() > 2) {
1150  StoreArray<CDCSimHit> simHits("CDCSimHits");
1151  _clock.dump("detail", TRGDebug::tab());
1152  _clockFE.dump("detail", TRGDebug::tab());
1153  if (TRGDebug::level() > 10) {
1154  for (unsigned i = 0; i < _hits.size(); i++) {
1155  const TCWHit& h = *_hits[i];
1156  h.dump("detail", TRGDebug::tab(4));
1157  }
1158  } else {
1159  unsigned nh = 10;
1160  if (nh > _hits.size()) nh = _hits.size();
1161  cout << TRGDebug::tab() << "Dump of the first " << n
1162  << " hits of a wire" << endl;
1163  for (unsigned i = 0; i < n; i++) {
1164  const TCWHit& h = *_hits[i];
1165  h.dump("detail", TRGDebug::tab(4));
1166  }
1167  }
1168  }
1169 
1170  }
1171 
1172  TRGDebug::leaveStage("TRGCDC update");
1173  }
1174 
1175 
1176  void
1177  TRGCDC::updateByData(int inputMode)
1178  {
1179  TRGDebug::enterStage("TRGCDC updateByData");
1180 
1181  //...Clear old information...
1182  clear();
1183 
1184  // There is a 1 window difference between slow control parameter and actual data.
1185  // For SPrint-8 data
1186  int cdcDelay = 101;
1187  int nCDCWindows = 28 + 1;
1188  // For Fuji hall data
1189  //int cdcDelay = 87;
1190  //int nCDCWindows = 32+1;
1191  // For Fuji hall matching data
1192  //int cdcDelay = 79;
1193  //int nCDCWindows = 47+1;
1194 
1195  // For TRG parameters
1196  unsigned nTRGWindows = 48;
1197  int nTrgBitsInWindow = 352;
1198 
1199  vector<string> trgInformations;
1200 
1201  // ##### Store data into a common binary format #####
1202  // inBinaryData[iBoard][iWord]
1203  vector<vector<unsigned> > inBinaryData;
1204  // Get data using Belle2Link
1205  if (inputMode == 1) {
1206 
1207  int nCdcBitsInWindow = 1536;
1208  //[FIXME] Getting data from ROOT file is fixed to 2 CDC FE, 1 TRG board.
1209  // Data should be in CDCFE0, CDCFE1, TRG sequence.
1210 
1211  // For Fuji data
1212  // Get data from root file.
1213  StoreArray<RawDataBlock> raw_datablkarray;
1214  // One block is one event. Take only first block = event.
1215  // Copper board 0 is for two CDC FE and one TRG.
1216  int iBlock = 0;
1217  int iCopper = 0;
1218  //cout<<"Number of blocks: "<<raw_cdcarray.getEntries()<<endl;
1219  //cout<<"Number of Copper: "<<raw_cdcarray[iBlock]->GetNumEntries()<<endl;
1220  int* temp_buf = raw_datablkarray[ iBlock ]->GetBuffer(iCopper);
1221  int nwords = raw_datablkarray[ iBlock ]->GetBlockNwords(iCopper);
1222  int malloc_flag = 0;
1223  int num_nodes = 1;
1224  int num_events = 1;
1225  RawCOPPER* raw_copper;
1226  RawCOPPER raw_copper_buf;
1227  raw_copper_buf.SetBuffer(temp_buf, nwords, malloc_flag, num_nodes, num_events);
1228  raw_copper = &raw_copper_buf;
1229 
1231  //StoreArray<RawCDC> raw_cdcarray;
1232  //int iBlock = 0;
1233  //int iCopper = 0;
1234  //RawCOPPER* raw_copper = raw_cdcarray[iBlock];
1235 
1237  //printf("*******Start of BODY**********\n");
1238  //printf("\n%.8d : ", 0);
1239  //for (int j = 0; j < raw_copper->GetBlockNwords(iCopper); j++) {
1240  // printf("0x%.8x ", (raw_copper->GetBuffer(iCopper))[ j ]);
1241  // if ((j + 1) % 10 == 0) {
1242  // printf("\n%.8d : ", j + 1);
1243  // }
1244  //}
1245  //printf("*******End of BODY**********\n");
1246 
1247  // Number of words for data
1248  int daqHeader = 32;
1249  int cdcHeader = 5;
1250  int cdcTrailer = 2;
1251  int trgHeader = 1;
1252  //int trgTrailer = 1;
1253  // 3 for event data. -1 for lost word in DAQ. Each window is 48 words.
1254  int widthCDCFEData = 3 - 1 + nCdcBitsInWindow / 32 * nCDCWindows;
1255  int widthTRGData = nTrgBitsInWindow / 32 * nTRGWindows;
1256 
1257  // Remove headers and trailer from data.
1258  // rawBinaryData[iBoard][iWord]
1259  // CDCFE0, CDCFE1, TSF sequence.
1260  vector<vector<unsigned> > rawBinaryData;
1261  for (int iFe = 0; iFe < 2; iFe++) {
1262  int startCDCData = daqHeader + cdcHeader + (iFe * (widthCDCFEData + cdcTrailer + cdcHeader)) + 1;
1263  // 1 is due to missing data.
1264  vector<unsigned> t_feData(widthCDCFEData + 1);
1265  // Loop over all the words for CDC FE data
1266  for (int iWord = 0; iWord < widthCDCFEData; iWord++) {
1267  t_feData[iWord] = (raw_copper->GetBuffer(iCopper))[iWord + startCDCData];
1268  }
1269  // Fill with 0 for last missing data
1270  t_feData[widthCDCFEData] = 0;
1271  rawBinaryData.push_back(t_feData);
1272  }
1273  vector<unsigned> t_trgData(widthTRGData);
1274  // Loop over all the words for TRG data
1275  int startTRGData = daqHeader + 2 * (cdcHeader + widthCDCFEData + cdcTrailer) + trgHeader + 1;
1276  for (int iWord = 0; iWord < widthTRGData; iWord++) {
1277  t_trgData[iWord] = (raw_copper->GetBuffer(iCopper))[iWord + startTRGData];
1278  }
1279  rawBinaryData.push_back(t_trgData);
1281  //for(unsigned iBoard=0; iBoard<rawBinaryData.size(); iBoard++){
1282  // cout<<"Board"<<iBoard<<endl;
1283  // for(unsigned iWord=0; iWord<rawBinaryData[iBoard].size(); iWord++){
1284  // cout<<setfill('0')<<setw(8)<<hex<<rawBinaryData[iBoard][iWord];
1285  // }
1286  // cout<<dec<<endl;
1287  //}
1288 
1289  // Shift all binary data by 8 bits to the right for two CDC FE data
1290  for (unsigned iBoard = 0; iBoard < 2; iBoard++) {
1291  unsigned t_buf = 0;
1292  // 1 is due to missing data
1293  vector<unsigned> t_feData(widthCDCFEData + 1);
1294  for (unsigned iWord = 0; iWord < rawBinaryData[iBoard].size(); iWord++) {
1295  unsigned t_value = t_buf + (rawBinaryData[iBoard][iWord] >> 8);
1296  t_buf = rawBinaryData[iBoard][iWord] << 24;
1297  t_feData[iWord] = t_value;
1298  }
1299  inBinaryData.push_back(t_feData);
1300  }
1301  inBinaryData.push_back(rawBinaryData[2]);
1303  //for(unsigned iBoard=0; iBoard<inBinaryData.size(); iBoard++){
1304  // cout<<"Board"<<iBoard<<endl;
1305  // for(unsigned iWord=0; iWord<inBinaryData[iBoard].size(); iWord++){
1306  // cout<<setfill('0')<<setw(8)<<hex<<inBinaryData[iBoard][iWord];
1307  // }
1308  // cout<<dec<<endl;
1309  //}
1310  } else if (inputMode == 2) {
1311  // get data from Belle2Link
1312  StoreArray<RawTRG> raw_trgarray;
1313  for (int i = 0; i < raw_trgarray.getEntries(); i++) {
1314  cout << "\n===== DataBlock(RawTRG) : Block # " << i << endl;
1315  for (int j = 0; j < raw_trgarray[ i ]->GetNumEntries(); j++) {
1316  RawCOPPER* raw_copper = raw_trgarray[ i ];
1317  vector<vector<unsigned> > rawBinaryData;
1318  // Loop over 4 FINESSEs
1319  for (int iFinesse = 0; iFinesse < 4; iFinesse++) {
1320  int bufferNwords = raw_copper->GetDetectorNwords(j, iFinesse);
1321  if (bufferNwords > 0) {
1322  printf("===== Detector Buffer(FINESSE # %i) 0x%x words \n", iFinesse, bufferNwords);
1323  vector<unsigned> t_copperData(raw_copper->GetDetectorNwords(j, iFinesse));
1324  // Loop over all the words for board data
1325  for (int iWord = 0; iWord < bufferNwords; iWord++) {
1326  t_copperData[iWord] = (raw_copper->GetDetectorBuffer(j, iFinesse))[iWord];
1327  }
1328  rawBinaryData.push_back(t_copperData);
1329  inBinaryData.push_back(t_copperData);
1330 
1331  }
1332  }
1333  }
1334  }
1335 
1337  //for(unsigned iBoard=0; iBoard<inBinaryData.size(); iBoard++){
1338  // cout<<"Board"<<iBoard<<endl;
1339  // for(unsigned iWord=0; iWord<inBinaryData[iBoard].size(); iWord++){
1340  // cout<<setfill('0')<<setw(8)<<hex<<inBinaryData[iBoard][iWord];
1341  // }
1342  // cout<<dec<<endl;
1343  //}
1344  } else {
1345  cout << "[ERROR} TRGCDCDataInputMode is incorrect! No simulation will be done." << endl;
1346  return;
1347  }
1348 
1349  // #####Separate binary into meaningful data#####
1350  // CDC
1351  // cdcTrgTiming[iFE]
1352  vector<unsigned> cdcTrgTiming(2);
1353  for (unsigned iFe = 0; iFe < 2; iFe++) {
1354  cdcTrgTiming[iFe] = (inBinaryData[iFe][1]) >> 16;
1355  if (cdcTrgTiming[iFe] >= 32768) cout << "CDC trigger timing error. TDC is larger than 0x8000" << endl;
1356  }
1358  //for(unsigned iFe=0; ieE<2; iFe++){
1359  // cout<<"FE"<<iFe<<" TRG Timing: "<<setfill('0')<<setw(8)<<hex<<cdcTrgTiming[0]<<dec<<endl;
1360  //}
1361  // [iHit] [0]: layerId, [1]: wireId, [2]: adc, [3]: tdc, [4]: FE trg timing
1362  vector<vector<unsigned>> hitCdcData;
1363  // Store information according to window,FE,Wire
1364  for (int iWindow = 0; iWindow < nCDCWindows; iWindow++) {
1365  for (int iFE = 0; iFE < 2; iFE++) {
1366  for (int iWire = 0; iWire < 48; iWire++) {
1367  unsigned t_adc;
1368  unsigned t_tdc;
1369  unsigned t_layerId = 3 * iFE + ((iWire / 8) % 3);
1370  unsigned t_wireId = 8 * (iWire / 24) + iWire % 8;
1371  // Take 16 bits according to wire.
1372  t_adc = ((inBinaryData[iFE][iWire / 2 + iWindow * 48 + 3] << (16 * (iWire % 2))) >> 16);
1373  t_tdc = ((inBinaryData[iFE][iWire / 2 + iWindow * 48 + 24 + 3] << (16 * (iWire % 2))) >> 16);
1374  if (t_tdc != 0) {
1375  if (t_tdc >= 32768) {
1376  // Calculate TDC.
1377  t_tdc -= 32768;
1378  // Round down and go back cdcDelay+nCDCWindows windows
1379  unsigned startTiming;
1380  if (unsigned(cdcTrgTiming[iFE] / 32) * 32 > (unsigned)(cdcDelay + nCDCWindows) * 32) {
1381  startTiming = unsigned(cdcTrgTiming[iFE] / 32) * 32 - (cdcDelay + nCDCWindows) * 32;
1382  } else {
1383  startTiming = unsigned(cdcTrgTiming[iFE] / 32) * 32 + 32768 - (cdcDelay + nCDCWindows) * 32;
1384  }
1385  if (t_tdc > startTiming) t_tdc -= startTiming;
1386  else t_tdc += 32768 - startTiming;
1387  // Fill data
1388  vector<unsigned> t_hitCdcData(5);
1389  t_hitCdcData[0] = t_layerId;
1390  t_hitCdcData[1] = t_wireId;
1391  t_hitCdcData[2] = t_adc;
1392  t_hitCdcData[3] = t_tdc;
1393  t_hitCdcData[4] = cdcTrgTiming[iFE];
1394  hitCdcData.push_back(t_hitCdcData);
1395  } else {
1396  cout << "CDC TDC data error. TDC is smaller than 0x8000. " << hex << t_tdc << dec << endl;
1397  continue;
1398  }
1399  } // end tdc hit
1400  } // wire loop
1401  } // fe loop
1402  } // window loop
1404  //for(unsigned iHit=0; iHit<hitCdcData.size(); iHit++){
1405  // cout<<"["<<hitCdcData[iHit][0]<<"]["<<hitCdcData[iHit][1]<<"]: "<<hitCdcData[iHit][2]<<", "<<hitCdcData[iHit][3]<<endl;
1406  //}
1407  // TRG
1408  // Save data into string
1409  stringstream t_trgWindow;
1410  for (unsigned iWord = 0; iWord < inBinaryData[2].size(); iWord++) {
1411  t_trgWindow << setw(8) << setfill('0') << hex << inBinaryData[2][iWord];
1412  if (iWord % 11 == 10) {
1413  trgInformations.push_back(t_trgWindow.str());
1414  t_trgWindow.str("");
1415  }
1416  }
1417  // Save data into hits
1418  // [iHit] [0]: layerId, [1]: wireId, [2]: window timing, [3]: priority timing
1419  // priority timing = -1 : No timing
1420  vector<vector<int> > hitTrgData;
1421  for (unsigned iWindow = 0; iWindow < nTRGWindows; iWindow++) {
1422  // Change binary into TRGState
1423  vector<unsigned> t_trgData(inBinaryData[2].begin() + 11 * iWindow, inBinaryData[2].begin() + 11 * iWindow + 11);
1424  TRGState t_trgState(t_trgData, 1);
1425  TRGState t_mergerState = t_trgState.subset(96, 256);
1426  TRGState t_hitMap = t_mergerState.subset(0, 80);
1427  TRGState t_priorityMap = t_mergerState.subset(32, 16);
1428  TRGState t_secondPriorityMap = t_mergerState.subset(48, 16);
1429  TRGState t_secondHitFlag = t_mergerState.subset(208, 16);
1430  TRGState t_priorityTiming = t_mergerState.subset(80, 64);
1431  TRGState t_fastestTiming = t_mergerState.subset(144, 64);
1432  //cout<<"["<<iWindow<<"] HM: "<<t_hitMap<<endl;
1433  //cout<<"["<<iWindow<<"] PHM: "<<t_priorityMap<<endl;
1434  //cout<<"["<<iWindow<<"] SHM: "<<t_secondPriorityMap<<endl;
1435  //cout<<"["<<iWindow<<"] SPF: "<<t_secondHitFlag<<endl;
1436  //cout<<"["<<iWindow<<"] PT: "<<setfill('0')<<setw(16)<<hex<<(unsigned long long) (t_priorityTiming)<<dec<<endl;
1437  //cout<<"["<<iWindow<<"] FT: "<<setfill('0')<<setw(16)<<hex<<(unsigned long long) (t_fastestTiming)<<dec<<endl;
1438  for (unsigned iWire = 0; iWire < t_hitMap.size(); iWire++) {
1439  unsigned t_layerId = iWire / 16;
1440  unsigned t_wireId = iWire % 16;
1441  if (t_hitMap[iWire] == 1) {
1442  vector<int> t_hitTrgData(4);
1443  t_hitTrgData[0] = t_layerId;
1444  t_hitTrgData[1] = t_wireId;
1445  t_hitTrgData[2] = iWindow;
1446  // Calculate priority timing
1447  if (t_layerId == 2) {
1448  t_hitTrgData[3] = (unsigned)t_priorityTiming.subset(4 * t_wireId, 4);
1449  //cout<<"["<<t_layerId<<"]["<<t_wireId<<"]: "<<iWindow<<", "<<t_hitTrgData[3]<<endl;
1450  } else if (t_layerId == 3) {
1451  // [1] Priority hit, [0] secondaryLR
1452  TRGState t_leftInformation(2);
1453  TRGState t_rightInformation(2);
1454  TRGState t_priorityHits(2);
1455  TRGState t_secondaryLR(2);
1456  if (t_wireId != 15) {
1457  t_priorityHits = t_priorityMap.subset(t_wireId, 2);
1458  t_secondaryLR = t_secondHitFlag.subset(t_wireId, 2);
1459  t_leftInformation.set(1, t_priorityMap.subset(t_wireId + 1, 1));
1460  t_leftInformation.set(0, t_secondHitFlag.subset(t_wireId + 1, 1));
1461  t_rightInformation.set(1, t_priorityMap.subset(t_wireId, 1));
1462  t_rightInformation.set(0, t_secondHitFlag.subset(t_wireId, 1));
1463  } else {
1464  t_priorityHits.set(0, t_priorityMap.subset(t_wireId, 1));
1465  t_priorityHits.set(1, 0);
1466  t_secondaryLR.set(0, t_secondHitFlag.subset(t_wireId, 1));
1467  t_secondaryLR.set(1, 0);
1468  t_leftInformation.set(1, 1);
1469  t_leftInformation.set(0, 0);
1470  t_rightInformation.set(1, t_priorityMap.subset(t_wireId, 1));
1471  t_rightInformation.set(0, t_secondHitFlag.subset(t_wireId, 1));
1472  }
1473  //cout<<"["<<iWindow<<"]["<<t_layerId<<"]["<<t_wireId<<"] PriorityHits: "<<t_priorityHits<<endl;
1474  //cout<<"["<<iWindow<<"]["<<t_layerId<<"]["<<t_wireId<<"] SecondaryLR: "<<t_secondaryLR<<endl;
1475  //cout<<"["<<iWindow<<"]["<<t_layerId<<"]["<<t_wireId<<"] Combine0: "<<t_leftInformation<<endl;
1476  //cout<<"["<<iWindow<<"]["<<t_layerId<<"]["<<t_wireId<<"] Combine1: "<<t_rightInformation<<endl;
1477  int secondaryFlag = -1;
1478  if ((unsigned)t_leftInformation == (unsigned)TRGState("00", 0)) secondaryFlag = 0;
1479  if ((unsigned)t_leftInformation == (unsigned)TRGState("01", 0)) secondaryFlag = 1;
1480  //cout<<"["<<iWindow<<"]["<<t_layerId<<"]["<<t_wireId<<"] SecondaryFlag: "<<secondaryFlag<<" timing: ";
1481  if (secondaryFlag != -1) {
1482  if (t_wireId + (1 - secondaryFlag) < 16) {
1483  //int t_priorityTiming = strtol(priorityTiming.substr(15-t_wireId-(1-secondaryFlag),1).c_str(),0,16);
1484  unsigned t_secondaryTiming = (unsigned)t_priorityTiming.subset(4 * (t_wireId + (1 - secondaryFlag)), 4);
1485  t_hitTrgData[3] = t_secondaryTiming;
1486  //cout<<t_secondaryTiming<<endl;
1487  } else {
1488  cout << "Error in TRGDATA for secondary priority hits" << endl;
1489  }
1490  //cout<<"Layer3end"<<endl;
1491  } else {
1492  t_hitTrgData[3] = -1;
1493  //cout<<"-1"<<endl;
1494  }
1495  } else {
1496  t_hitTrgData[3] = -1;
1497  }
1498  hitTrgData.push_back(t_hitTrgData);
1499  } // wire is hit
1500  } // wire loop
1501  } // window loop
1503  //if(hitTrgData.size()) cout<<"TRG: "<<endl;
1504  //for(unsigned iHit=0; iHit<hitTrgData.size(); iHit++){
1505  // cout<<"["<<hitTrgData[iHit][0]<<"]["<<hitTrgData[iHit][1]<<"]: "<<hitTrgData[iHit][2]*32+hitTrgData[iHit][3]*2<<"("<<hitTrgData[iHit][2]<<","<<hitTrgData[iHit][3]<<")"<<endl;;
1506  //}
1507  //if(hitTrgData.size()) {
1508  // for(unsigned iWindow=0; iWindow<nTRGWindows; iWindow++){
1509  // vector<unsigned> t_trgData(inBinaryData[2].begin()+11*iWindow, inBinaryData[2].begin()+11*iWindow+11);
1510  // TRGState t_trgState(t_trgData,1);
1511  // TRGState t_mergerState = t_trgState.subset(96, 256);
1512  // TRGState t_hitMap = t_mergerState.subset(0,80);
1513  // TRGState t_priorityMap = t_mergerState.subset(32,16);
1514  // TRGState t_secondPriorityMap = t_mergerState.subset(48,16);
1515  // TRGState t_secondHitFlag= t_mergerState.subset(208,16);
1516  // TRGState t_priorityTiming = t_mergerState.subset(80,64);
1517  // TRGState t_fastestTiming = t_mergerState.subset(144,64);
1518  // cout<<"["<<iWindow<<"] HM: "<<t_hitMap<<endl;
1519  // cout<<"["<<iWindow<<"] PHM: "<<t_priorityMap<<endl;
1520  // cout<<"["<<iWindow<<"] SHM: "<<t_secondPriorityMap<<endl;
1521  // cout<<"["<<iWindow<<"] SPF: "<<t_secondHitFlag<<endl;
1522  // cout<<"["<<iWindow<<"] PT: "<<setfill('0')<<setw(16)<<hex<<(unsigned long long) (t_priorityTiming)<<dec<<endl;
1523  // cout<<"["<<iWindow<<"] FT: "<<setfill('0')<<setw(16)<<hex<<(unsigned long long) (t_fastestTiming)<<dec<<endl;
1524  // }
1525  //}
1526 
1527  /* cppcheck-suppress variableScope */
1528  int trgOutput = 2;
1529  // Store TRG data to TRGSignalBundle.
1530  // 1 is FE output. 2 is Merger output. 3 is TRG output.
1531  //...Clock...
1532  const TRGClock& dClock = TRGCDC::getTRGCDC()->dataClock();
1533  // Create signal bundle
1534  TRGSignalBundle* allTrgData;
1535  allTrgData = new TRGSignalBundle(string("TRGData"), dClock);
1536  // Create signal vector. Need to create signals for of signal vector.
1537  TRGSignalVector* trgData;
1538  trgData = new TRGSignalVector(string("TRGData"), dClock, nTrgBitsInWindow);
1539  // Loop over data and fill TRGSignalVector
1540  for (unsigned iWindow = 0; iWindow < nTRGWindows; iWindow++) {
1541  vector<unsigned> t_trgData(inBinaryData[2].begin() + 11 * iWindow, inBinaryData[2].begin() + 11 * iWindow + 11);
1542  TRGState t_trgState(t_trgData, 1);
1543  trgData->set(t_trgState, iWindow);
1544  }
1545  allTrgData->push_back(trgData);
1546  // Clean up memory
1547  if (allTrgData) {
1548  for (unsigned i = 0; i < allTrgData->size(); i++) delete(*allTrgData)[i];
1549  delete allTrgData;
1550  }
1551 
1552 
1553  // Save CDC hit data and TRG hit data to ROOT file.
1554  if (_makeRootFile) {
1555  saveTRGRawInformation(trgInformations);
1556  saveCDCHitInformation(hitCdcData);
1557  if (trgOutput == 2) {
1558  saveTRGHitInformation(hitTrgData);
1559  }
1560  m_treeROOTInput->Fill();
1561  }
1562 
1563  // Update CDC wires using data. Start from layer 50.
1564  for (unsigned iHit = 0; iHit < hitCdcData.size(); iHit++) {
1565  unsigned t_layerId = hitCdcData[iHit][0] + 50;
1566  unsigned t_wireId = hitCdcData[iHit][1];
1567  int t_rawTdc = hitCdcData[iHit][2];
1568  TCWire& currentWire = *(TCWire*) wire(t_layerId, t_wireId);
1569 
1570  // Update currentWire._signal
1571  TRGTime rise = TRGTime(t_rawTdc, true, _clockFE, currentWire.name());
1572  TRGTime fall = rise;
1573  fall.shift(1).reverse();
1574  if (currentWire._signal.active()) {
1575  currentWire._signal = currentWire.signal() | TRGSignal(rise & fall);
1576  currentWire._signal.name(currentWire.name());
1577  } else {
1578  currentWire._signal = TRGSignal(rise & fall);
1579  currentWire._signal.name(currentWire.name());
1580 
1581  // Make TCWireHit and store in _layers.
1582  // [FIXME] TCWireHit can not accept wire being hit two times.
1583  TCWHit* hit = new TCWHit(currentWire, 0, 0, 0, t_rawTdc, 0, t_rawTdc, 0, 0, 1);
1584  hit->state(CellHitFindingValid | CellHitFittingValid);
1585  ((TCWire*)(*_layers[t_layerId])[t_wireId])->hit(hit);
1586  _hits.push_back(hit);
1587  if (currentWire.axial()) _axialHits.push_back(hit);
1588  else _stereoHits.push_back(hit);
1589  }
1590  //cout<<"iLayer, iWire, iHit: "<<t_layerId<<" "<<t_wireId<<" "<<iHit<<endl;
1591  //currentWire.signal().dump();
1592 
1593  } // End updating CDC wires
1594 
1595  //...Hit classification...
1596  classification();
1597 
1598  TRGDebug::leaveStage("TRGCDC updateByData");
1599  }
1600 
1601  void
1603  {
1604  TRGDebug::enterStage("TRGCDC classification");
1605 
1606  unsigned n = _hits.size();
1607 
1608  for (unsigned i = 0; i < n; i++) {
1609  TCWHit* h = _hits[i];
1610  const TCWire& w = h->wire();
1611  unsigned state = h->state();
1612 
1613  //...Cache pointers to a neighbor...
1614  const TCWire* neighbor[7];
1615  for (unsigned j = 0; j < 7; j++) neighbor[j] = w.neighbor(j);
1616 
1617  //...Decide hit pattern...
1618  unsigned pattern = 0;
1619  for (unsigned j = 0; j < 7; j++) {
1620  if (neighbor[j])
1621  if (neighbor[j]->hit())
1622  pattern += (1 << j);
1623  }
1624  state |= (pattern << CellHitNeighborHit);
1625 
1626  //...Check isolation...
1627  const TCWHit* hr1 = neighbor[2]->hit();
1628  const TCWHit* hl1 = neighbor[3]->hit();
1629  if ((hr1 == 0) && (hl1 == 0)) {
1630  state |= CellHitIsolated;
1631  } else {
1632  const TCWHit* hr2 = neighbor[2]->neighbor(2)->hit();
1633  const TCWHit* hl2 = neighbor[3]->neighbor(3)->hit();
1634  if (((hr2 == 0) && (hr1 != 0) && (hl1 == 0)) ||
1635  ((hl2 == 0) && (hl1 != 0) && (hr1 == 0)))
1636  state |= CellHitIsolated;
1637  }
1638 
1639  //...Check continuation...
1640  // unsigned superLayer = w.superLayerId();
1641  bool previous = false;
1642  bool next = false;
1643  if (neighbor[0] == 0) previous = true;
1644  else {
1645  if ((neighbor[0]->hit()) || neighbor[1]->hit())
1646  previous = true;
1647  // if (m_smallcell && w.layerId() == 3)
1648  // if (neighbor[6]->hit())
1649  // previous = true;
1650  }
1651  if (neighbor[5] == 0) next = true;
1652  else {
1653  if ((neighbor[4]->hit()) || neighbor[5]->hit())
1654  next = true;
1655  }
1656  // if (previous && next) state |= CellHitContinuous;
1657  if (previous || next) state |= CellHitContinuous;
1658 
1659  //...Solve LR locally...
1660  if ((pattern == 34) || (pattern == 42) ||
1661  (pattern == 40) || (pattern == 10) ||
1662  (pattern == 35) || (pattern == 50))
1663  state |= CellHitPatternRight;
1664  else if ((pattern == 17) || (pattern == 21) ||
1665  (pattern == 20) || (pattern == 5) ||
1666  (pattern == 19) || (pattern == 49))
1667  state |= CellHitPatternLeft;
1668 
1669  //...Store it...
1670  h->state(state);
1671  }
1672 
1673  TRGDebug::leaveStage("TRGCDC classification");
1674  }
1675 
1676  vector<const TCWHit*>
1677  TRGCDC::axialHits(void) const
1678  {
1679  vector<const TCWHit*> t;
1680  t.assign(_axialHits.begin(), _axialHits.end());
1681  return t;
1682 
1683  // if (! mask) return _axialHits;
1684  // else if (mask == CellHitFindingValid) return _axialHits;
1685  // cout << "TRGCDC::axialHits !!! unsupported mask given" << endl;
1686  // return _axialHits;
1687  }
1688 
1689  vector<const TCWHit*>
1691  {
1692  vector<const TCWHit*> t;
1693  t.assign(_stereoHits.begin(), _stereoHits.end());
1694  return t;
1695 
1696  // if (! mask) return _stereoHits;
1697  // else if (mask == CellHitFindingValid) return _stereoHits;
1698  // cout << "TRGCDC::stereoHits !!! unsupported mask given" << endl;
1699  // return _stereoHits;
1700  }
1701 
1702  vector<const TCWHit*>
1703  TRGCDC::hits(void) const
1704  {
1705  vector<const TCWHit*> t;
1706  t.assign(_hits.begin(), _hits.end());
1707  return t;
1708 
1709  // if (! mask) return _hits;
1710  // else if (mask == CellHitFindingValid) return _hits;
1711  // cout << "TRGCDC::hits !!! unsupported mask given" << endl;
1712  // return _hits;
1713  }
1714 
1715 // vector<const TCWHit *>
1716 // TRGCDC::badHits(void) const {
1717 // vector<const TCWHit *> t;
1718 // t.assign(_badHits.begin(), _badHits.end());
1719 // return t;
1720 
1721 // //cnv if (! updated()) update();
1722 // // if (_badHits.length()) return _badHits;
1723 
1724 // // //...Loop over RECCDC_WIRHIT bank...
1725 // // x unsigned nReccdc = BsCouTab(RECCDC_WIRHIT);
1726 // // for (unsigned i = 0; i < nReccdc; i++) {
1727 // // x struct reccdc_wirhit * h =
1728 // // (struct reccdc_wirhit *)
1729 // // BsGetEnt(RECCDC_WIRHIT, i + 1, BBS_No_Index);
1730 
1731 // // //...Check validity...
1732 // // if (h->m_stat & CellHitFindingValid) continue;
1733 
1734 // // //...Obtain a pointer to GEOCDC...
1735 // // x geocdc_wire * g =
1736 // // (geocdc_wire *) BsGetEnt(GEOCDC_WIRE, h->m_geo, BBS_No_Index);
1737 
1738 // // //...Get a pointer to a TRGCDCWire...
1739 // // TCWire * w = _wires[g->m_ID - 1];
1740 
1741 // // //...Create TCWHit...
1742 // // _badHits.append(new TCWHit(w, h, _fudgeFactor));
1743 // // }
1744 
1745 // // return _badHits;
1746 // }
1747 
1748  vector<const TCWHitMC*>
1749  TRGCDC::hitsMC(void) const
1750  {
1751  vector<const TCWHitMC*> t;
1752  t.assign(_hitsMC.begin(), _hitsMC.end());
1753  return t;
1754  }
1755 
1756  string
1757  TRGCDC::wireName(unsigned wireId) const
1758  {
1759  string as = "-";
1760  const TCWire* const w = wire(wireId);
1761  if (w) {
1762  if (w->stereo())
1763  as = "=";
1764  } else {
1765  return "invalid_wire(" + TRGUtil::itostring(wireId) + ")";
1766  }
1767  return TRGUtil::itostring(layerId(wireId)) + as + TRGUtil::itostring(localId(wireId));
1768  }
1769 
1770  unsigned
1771  TRGCDC::localId(unsigned id) const
1772  {
1773  cout << "TRGCDC::localId !!! this function is not tested yet"
1774  << endl;
1775  unsigned iLayer = 0;
1776  unsigned nW = 0;
1777  bool nextLayer = true;
1778  while (nextLayer) {
1779  unsigned nWLast = nW;
1780  nW += layer(iLayer++)->nCells();
1781  if (id < (nW - 1))
1782  return id - nWLast;
1783  if (nW >= nWires())
1784  nextLayer = false;
1785  }
1786  cout << "TRGCDC::localId !!! no such a wire (id=" << id << endl;
1787  return TRGCDC_UNDEFINED;
1788  }
1789 
1790  unsigned
1791  TRGCDC::layerId(unsigned id) const
1792  {
1793  cout << "TRGCDC::layerId !!! this function is not tested yet"
1794  << endl;
1795  unsigned iLayer = 0;
1796  unsigned nW = 0;
1797  bool nextLayer = true;
1798  while (nextLayer) {
1799  nW += layer(iLayer++)->nCells();
1800  if (id < (nW - 1))
1801  return iLayer - 1;
1802  if (nW >= nWires())
1803  nextLayer = false;
1804  }
1805  cout << "TRGCDC::layerId !!! no such a wire (id=" << id << endl;
1806  return TRGCDC_UNDEFINED;
1807  }
1808 
1809  unsigned
1810  TRGCDC::layerId(unsigned, unsigned) const
1811  {
1812  cout << "TRGCDC::layerId !!! this function is not implemented yet"
1813  << endl;
1814  return TRGCDC_UNDEFINED;
1815  }
1816 
1817  unsigned
1818  TRGCDC::superLayerId(unsigned id) const
1819  {
1820  unsigned iLayer = 0;
1821  unsigned nW = 0;
1822  bool nextLayer = true;
1823  while (nextLayer) {
1824  const vector<TRGCDCLayer*>& sl = *superLayer(iLayer);
1825  const unsigned nLayers = sl.size();
1826  for (unsigned i = 0; i < nLayers; i++)
1827  nW += sl[i]->nCells();
1828 
1829  if (id < (nW - 1))
1830  return iLayer;
1831  if (nW >= nWires())
1832  nextLayer = false;
1833  }
1834  cout << "TRGCDC::superLayerId !!! no such a wire (id=" << id
1835  << endl;
1836  return TRGCDC_UNDEFINED;
1837  }
1838 
1839  unsigned
1840  TRGCDC::localLayerId(unsigned id) const
1841  {
1842  unsigned iLayer = 0;
1843  unsigned nW = 0;
1844  bool nextLayer = true;
1845  while (nextLayer) {
1846  const vector<TRGCDCLayer*>& sl = *superLayer(iLayer);
1847  const unsigned nLayers = sl.size();
1848  for (unsigned i = 0; i < nLayers; i++) {
1849  nW += sl[i]->nCells();
1850  if (id < (nW - 1))
1851  return i;
1852  }
1853 
1854  if (nW >= nWires())
1855  nextLayer = false;
1856  }
1857  cout << "TRGCDC::localLayerId !!! no such a wire (id=" << id
1858  << endl;
1859  return TRGCDC_UNDEFINED;
1860  }
1861 
1862  unsigned
1863  TRGCDC::axialStereoSuperLayerId(unsigned aors, unsigned i) const
1864  {
1865  unsigned is = 99;
1866  // cout << "aors,i= " << aors <<" "<< i << std::endl;
1867  if (aors == 0) { //axial
1868  if (i <= 7) {
1869  is = 0;
1870  } else if (i <= 13) {
1871  is = 1;
1872  } else if (i <= 19) {
1873  is = 2;
1874  } else if (i <= 25) {
1875  is = 3;
1876  } else if (i <= 31) {
1877  is = 4;
1878  }
1879  } else if (aors == 1) { //stereo
1880  if (i <= 5) {
1881  is = 0;
1882  } else if (i <= 11) {
1883  is = 1;
1884  } else if (i <= 17) {
1885  is = 2;
1886  } else if (i <= 23) {
1887  is = 3;
1888  }
1889  }
1890 
1891  assert(is != 99);
1892  return is;
1893  }
1894 
1895 // void
1896 // TRGCDC::driftDistance(TLink & l,
1897 // const TTrack & t,
1898 // unsigned flag,
1899 // float t0Offset) {
1900 
1901 // //...No correction...
1902 // if (flag == 0) {
1903 // if (l.hit()) {
1904 // // l.drift(0, l.hit()->drift(0));
1905 // // l.drift(1, l.hit()->drift(1));
1906 // // l.dDrift(0, l.hit()->dDrift(0));
1907 // // l.dDrift(1, l.hit()->dDrift(1));
1908 // l.drift(l.hit()->drift(0), 0);
1909 // l.drift(l.hit()->drift(1), 1);
1910 // l.dDrift(l.hit()->dDrift(0), 0);
1911 // l.dDrift(l.hit()->dDrift(1), 1);
1912 // }
1913 // else {
1914 // // l.drift(0, 0.);
1915 // // l.drift(1, 0.);
1916 // // l.dDrift(0, 0.);
1917 // // l.dDrift(1, 0.);
1918 // l.drift(0., 0);
1919 // l.drift(0., 1);
1920 // l.dDrift(0., 0);
1921 // l.dDrift(0., 1);
1922 // }
1923 
1924 // return;
1925 // }
1926 
1927 // //...TOF correction...
1928 // float tof = 0.;
1929 // if (flag && 1) {
1930 // int imass = 3;
1931 // float tl = t.helix().a()[4];
1932 // float f = sqrt(1. + tl * tl);
1933 // float s = fabs(t.helix().curv()) * fabs(l.dPhi()) * f;
1934 // float p = f / fabs(t.helix().a()[2]);
1935 // calcdc_tof2_(& imass, & p, & s, & tof);
1936 // }
1937 
1938 // //...T0 correction....
1939 // if (! (flag && 2)) t0Offset = 0.;
1940 
1941 // //...Propagation corrections...
1942 // const TCWHit & h = * l.hit();
1943 // int wire = h.wire()->id();
1944 // HepGeom::Vector3D<double> tp = t.helix().momentum(l.dPhi());
1945 // float p[3] = {tp.x(), tp.y(), tp.z()};
1946 // const HepGeom::Point3D<double> & onWire = l.positionOnWire();
1947 // float x[3] = {onWire.x(), onWire.y(), onWire.z()};
1948 // //cnv float time = h.reccdc()->m_tdc + t0Offset - tof;
1949 // float time = 0;
1950 // float dist;
1951 // float edist;
1952 // int prop = (flag & 4);
1953 
1954 // //...Calculation with left side...
1955 // int side = -1;
1956 // if (side == 0) side = -1;
1957 // calcdc_driftdist_(& prop,
1958 // & wire,
1959 // & side,
1960 // p,
1961 // x,
1962 // & time,
1963 // & dist,
1964 // & edist);
1965 // // l.drift(0, dist);
1966 // // l.dDrift(0, edist);
1967 // l.drift(dist, 0);
1968 // l.dDrift(edist, 0);
1969 
1970 // //...Calculation with left side...
1971 // side = 1;
1972 // calcdc_driftdist_(& prop,
1973 // & wire,
1974 // & side,
1975 // p,
1976 // x,
1977 // & time,
1978 // & dist,
1979 // & edist);
1980 // // l.drift(1, dist);
1981 // // l.dDrift(1, edist);
1982 // l.drift(dist, 1);
1983 // l.dDrift(edist, 1);
1984 
1985 // //...tan(lambda) correction...
1986 // if (flag && 8) {
1987 // float tanl = abs(p[2]) / tp.perp();
1988 // float c;
1989 // if ((tanl >= 0.0) && (tanl < 0.5)) c = -0.48 * tanl + 1.3;
1990 // else if ((tanl >= 0.5) && (tanl < 1.0)) c = -0.28 * tanl + 1.2;
1991 // else if ((tanl >= 1.0) && (tanl < 1.5)) c = -0.16 * tanl + 1.08;
1992 // else c = 0.84;
1993 
1994 // // l.dDrift(0, l.dDrift(0) * c);
1995 // // l.dDrift(1, l.dDrift(1) * c);
1996 // l.dDrift(l.dDrift(0) * c, 0);
1997 // l.dDrift(l.dDrift(1) * c, 1);
1998 // }
1999 // }
2000 
2002  {
2003  TRGDebug::enterStage("TRGCDC destructor");
2004  clear();
2005 
2006  delete [] _width;
2007  delete [] _r;
2008  delete [] _r2;
2009 
2010  if (_tsFinder) delete _tsFinder;
2011  if (_hFinder)
2012  delete _hFinder;
2013  if (_h3DFinder)
2014  delete _h3DFinder;
2015  if (_fitter3D)
2016  delete _fitter3D;
2017 
2018 #ifdef TRGCDC_DISPLAY
2019  if (D)
2020  delete D;
2021  cout << "TRGCDC ... rphi displays deleted" << endl;
2022 #endif
2023 
2024  TRGDebug::leaveStage("TRGCDC destructor");
2025  }
2026 
2027  bool
2028  TRGCDC::neighbor(const TCWire& w0, const TCWire& w1) const
2029  {
2030  const int lyr0 = w0.layerId();
2031  const int lyr1 = w1.layerId();
2032  const int lyr = lyr0 - lyr1;
2033 
2034  if (abs(lyr) > 1) return false;
2035  if (w0.superLayerId() != w1.superLayerId()) return false;
2036 
2037  for (unsigned i = 0; i < 7; i++) {
2038  if (w0.neighbor(i)) {
2039  if (w0.neighbor(i)->id() == w1.id())
2040  return true;
2041  }
2042  }
2043  return false;
2044  }
2045 
2046  void
2048  {
2049  TRGDebug::enterStage("TRGCDC simulate");
2050 
2051  const bool fast = (_simulationMode & 1);
2052  const bool firm = (_simulationMode & 2);
2053  if (fast)
2054  fastSimulation();
2055  if (firm)
2057 
2058  TRGDebug::leaveStage("TRGCDC simulate");
2059  }
2060 
2061  void
2063  {
2064  TRGDebug::enterStage("TRGCDC fastSimulation");
2065 
2066 #ifdef TRGCDC_DISPLAY
2067  D->beginningOfEvent();
2068 #endif
2069 
2070  //...Options...
2071  const bool trackSegmentSimulationOnly = _fastSimulationMode & 1;
2072  const bool trackSegmentClockSimulation = _fastSimulationMode & 2;
2073 
2074  //...TSF simulation...
2075  _tsFinder->doit(_tss,
2076  trackSegmentClockSimulation,
2077  _segmentHits,
2078  _segmentHitsSL);
2079  _eventTime.back()->doit(_fverETF, _fprintFirmETF);
2080 
2081  if (_segmentHits.size() == 0) setReturnValue(TSF, 1);
2082 
2083  if (trackSegmentSimulationOnly) {
2084  TRGDebug::leaveStage("TRGCDC fastSimulation");
2085  return;
2086  }
2087 
2088 #ifdef TRGCDC_DISPLAY
2089  // dump("hits");
2090  string stg = "fast simulation results";
2091  string inf = "#segments=" + TRGUtilities::itostring(segmentHits().size());
2092  D->clear();
2093  D->stage(stg);
2094  D->information(inf);
2095  D->area().append(hits());
2096  D->area().append(segmentHits());
2097  D->show();
2098  D->run();
2099 #endif
2100 
2101  //...2D finder and fitter...
2102  if (_perfect2DFinder)
2104  else
2106  if (_trackList2D.size() == 0) setReturnValue(find2D, 1);
2107  if (_trackList2DFitted.size() == 0) setReturnValue(fit2D, 1);
2108 
2109  //cout<<"s3D"<<endl;
2110  //...Stereo finder...
2112 
2113  //...Check tracks...
2114  if (TRGDebug::level()) {
2115  for (unsigned i = 0; i < _trackList3D.size(); i++) {
2116  const TCTrack& t = *_trackList3D[i];
2117  cout << "> links=" << t.links().size() << endl;
2118  t.dump();
2119  }
2120  }
2121 
2122  //...Check relations...
2123  if (TRGDebug::level()) {
2124  for (unsigned i = 0; i < _trackList3D.size(); i++) {
2125  // trackList[i]->relation().dump();
2126  _trackList3D[i]->dump();
2127  }
2128  }
2129 
2130  //...Event Time... In ns scale.
2131  // [FIXME] This does nothing.
2132  _eventTime.back()->getT0();
2133 
2134  //...3D tracker...
2136  //_fitter3D->doitComplex(_trackList3D);
2137  //cout<<"e3D"<<endl;
2138 
2139  // Notify if track's debugValue is not 0
2140  {
2141  // For any track
2142  int t_debugValue = 0;
2143  for (unsigned iTrack = 0; iTrack < _trackList3D.size(); iTrack++) {
2144  t_debugValue |= _trackList3D[iTrack]->getDebugValue(TRGCDCTrack::EDebugValueType::any);
2145  }
2147  //int t_debugValue = TRGCDCTrack::EDebugValueType::any;
2148  //for(unsigned iTrack = 0; iTrack<_trackList3D.size(); iTrack++) {
2149  // t_debugValue &= _trackList3D[iTrack]->getDebugValue(TRGCDCTrack::EDebugValueType::any);
2150  //}
2151  setReturnValue(t_debugValue | getReturnValue());
2152  }
2153 
2154  if (TRGDebug::level() > 1) {
2155  for (unsigned iTrack = 0; iTrack < _trackList3D.size(); iTrack++) {
2156  const TCTrack& aTrack = *_trackList3D[iTrack];
2157  if (aTrack.fitted()) {
2158  double fitPt = aTrack.pt();
2159  double fitPhi0 = aTrack.helix().phi0();
2160  int fitCharge = aTrack.charge();
2161  if (fitCharge < 0) {
2162  fitPhi0 -= M_PI;
2163  if (fitPhi0 < 0) fitPhi0 += 2 * M_PI;
2164  }
2165  double fitZ0 = aTrack.helix().dz();
2166  double fitCot = aTrack.helix().tanl();
2167  cout << TRGDebug::tab() << "Track[" << iTrack << "]: charge=" << fitCharge
2168  << " pt=" << fitPt << " phi_c=" << fitPhi0
2169  << " z0=" << fitZ0 << " cot=" << fitCot << endl;
2170  const TCRelation& trackRelation = aTrack.relation();
2171  const MCParticle& trackMCParticle = trackRelation.mcParticle(0);
2172  int mcCharge = trackMCParticle.getCharge();
2173  double mcPt = trackMCParticle.getMomentum().Pt();
2174  double mcPhi0 = 0.0;
2175  if (mcCharge > 0) mcPhi0 = trackMCParticle.getMomentum().Phi() - M_PI / 2;
2176  if (mcCharge < 0) mcPhi0 = trackMCParticle.getMomentum().Phi() + M_PI / 2;
2177  // Change range to [0,2pi]
2178  if (mcPhi0 < 0) mcPhi0 += 2 * M_PI;
2179  // Calculated impact position
2180  TVector3 vertex = trackMCParticle.getVertex();
2181  TLorentzVector vector4 = trackMCParticle.get4Vector();
2182  TVector2 helixCenter;
2183  TVector3 impactPosition;
2184  Fitter3DUtility::findImpactPosition(&vertex, &vector4, mcCharge, helixCenter, impactPosition);
2185  double mcZ0 = impactPosition.Z();
2186  double mcCot = trackMCParticle.getMomentum().Pz() / trackMCParticle.getMomentum().Pt();
2187  cout << TRGDebug::tab() << "Track[" << iTrack << "]: mcCharge=" << mcCharge
2188  << " mcPt=" << mcPt << " mcPhi_c=" << mcPhi0
2189  << " mcZ0=" << mcZ0 << " mcCot=" << mcCot << endl;
2190  }
2191  }
2192  }
2193 
2194  if (TRGDebug::level()) {
2195  cout << TRGDebug::tab() << "Number of 2D tracks : "
2196  << _trackList2D.size() << endl;
2197  cout << TRGDebug::tab() << "Number of 2D fitted tracks : "
2198  << _trackList2DFitted.size() << endl;
2199  cout << TRGDebug::tab() << "Number of 3D tracks : "
2200  << _trackList3D.size() << endl;
2201  }
2202 
2203 #ifdef TRGCDC_DISPLAY
2204  // dump("hits");
2205  vector<const TCTrack*> t2;
2206  t2.assign(_trackList2D.begin(), _trackList2D.end());
2207  vector<const TCTrack*> t2f;
2208  t2f.assign(_trackList2DFitted.begin(), _trackList2DFitted.end());
2209  vector<const TCTrack*> t3;
2210  t3.assign(_trackList3D.begin(), _trackList3D.end());
2211  D->endOfEvent();
2212  stg = "fast simulation results";
2213  inf = "red:2D, blue:2DF, green:3D";
2214  D->clear();
2215  D->stage(stg);
2216  D->information(inf);
2217  D->area().append(hits());
2218  D->area().append(segmentHits());
2219  D->area().append(t2, Gdk::Color("red"));
2220  D->area().append(t2f, Gdk::Color("blue"));
2221  D->area().append(t3, Gdk::Color("green"));
2222  D->show();
2223  D->run();
2224 
2225  // unsigned iFront = 0;
2226  // while (const TCFrontEnd * f = _cdc.frontEnd(iFront++)) {
2227  // D->clear();
2228  // D->beginEvent();
2229  // D->area().append(* f);
2230  // D->run();
2231  // }
2232  // unsigned iMerger = 0;
2233  // while (const TCMerger * f = _cdc.merger(iMerger++)) {
2234  // D->clear();
2235  // D->beginEvent();
2236  // D->area().append(* f);
2237  // D->run();
2238  // }
2239 #endif
2240 
2241  TRGDebug::leaveStage("TRGCDC fastSimulation");
2242  return;
2243  }
2244 
2245  void
2246  TRGCDC::storeSimulationResults(string collection2Dfinder,
2247  string collection2Dfitter,
2248  string collection3Dfitter)
2249  {
2250  TRGDebug::enterStage("TRGCDC storeSimulationResults");
2251 
2252  // hits
2253  if (!(_fastSimulationMode & 2)) {
2254  StoreArray<CDCTriggerSegmentHit> storeSegmentHits;
2256  for (unsigned its = 0; its < _segmentHits.size(); ++its) {
2257  const TCSHit* segmentHit = _segmentHits[its];
2258  const CDCHit* priorityHit = cdcHits[segmentHit->iCDCHit()];
2259  const TCSegment* segment = static_cast<const TCSegment*>(&segmentHit->cell());
2260  const CDCTriggerSegmentHit* storeHit =
2261  storeSegmentHits.appendNew(*priorityHit,
2262  segment->id(),
2265  segment->priorityTime(),
2266  segment->fastestTime(),
2267  segment->foundTime());
2268  _tss[segment->id()]->addStoreHit(storeHit);
2269  // relation to all CDCHits in segment
2270  for (unsigned iw = 0; iw < segment->wires().size(); ++iw) {
2271  const TRGCDCWire* wire = (TRGCDCWire*)(*segment)[iw];
2272  if (wire->signal().active()) {
2273  // priority wire has relation weight 2
2274  double weight = (wire == &(segment->priority())) ? 2. : 1.;
2275  storeHit->addRelationTo(cdcHits[wire->hit()->iCDCHit()], weight);
2276  }
2277  }
2278  // relation to MCParticles (same as priority hit)
2279  RelationVector<MCParticle> mcrel = priorityHit->getRelationsFrom<MCParticle>();
2280  for (unsigned imc = 0; imc < mcrel.size(); ++imc) {
2281  mcrel[imc]->addRelationTo(storeHit, mcrel.weight(imc));
2282  }
2283  }
2284  }
2285  // event time
2286  StoreObjPtr<TRGTiming> eventTime("CDCTriggerEventTime");
2287  eventTime.construct(Const::CDC, getEventTime());
2288  // 2D finder tracks
2289  StoreArray<CDCTriggerTrack> storeTracks2Dfinder(collection2Dfinder);
2290  for (unsigned itr = 0; itr < _trackList2D.size(); ++itr) {
2291  const TCTrack* track2D = _trackList2D[itr];
2292  double phi0 = remainder(track2D->helix().phi0() + M_PI_2, 2. * M_PI);
2293  double omega = track2D->charge() / track2D->helix().radius();
2294  const CDCTriggerTrack* track =
2295  storeTracks2Dfinder.appendNew(phi0, omega, 0.);
2296  // relation to SegmentHits
2297  vector<TRGCDCLink*> links = track2D->links();
2298  for (unsigned its = 0; its < links.size(); ++its) {
2299  TRGCDCSegment* segment = (TRGCDCSegment*)links[its]->cell();
2300  const vector<const CDCTriggerSegmentHit*> storeHits = segment->storeHits();
2301  for (unsigned ihit = 0; ihit < storeHits.size(); ++ihit) {
2302  track->addRelationTo(storeHits[ihit]);
2303  }
2304  }
2305  }
2306  // 2D fitter tracks
2307  StoreArray<CDCTriggerTrack> storeTracks2Dfitter(collection2Dfitter);
2308  for (unsigned itr = 0; itr < _trackList2DFitted.size(); ++itr) {
2309  const TCTrack* track2D = _trackList2DFitted[itr];
2310  if (!track2D->fitted()) continue;
2311  double phi0 = remainder(track2D->helix().phi0() + M_PI_2, 2. * M_PI);
2312  double omega = track2D->charge() / track2D->helix().radius();
2313  double chi2 = track2D->get2DFitChi2();
2314  const CDCTriggerTrack* track =
2315  storeTracks2Dfitter.appendNew(phi0, omega, chi2);
2316  // relation to SegmentHits
2317  vector<TRGCDCLink*> links = track2D->links();
2318  for (unsigned its = 0; its < links.size(); ++its) {
2319  TRGCDCSegment* segment = (TRGCDCSegment*)links[its]->cell();
2320  const vector<const CDCTriggerSegmentHit*> storeHits = segment->storeHits();
2321  for (unsigned ihit = 0; ihit < storeHits.size(); ++ihit) {
2322  track->addRelationTo(storeHits[ihit]);
2323  }
2324  }
2325  // relation to 2D finder, assuming same order in tracklist
2326  if (storeTracks2Dfinder.getEntries() > 0)
2327  storeTracks2Dfinder[itr]->addRelationTo(track);
2328  }
2329  // 3D tracks
2330  StoreArray<CDCTriggerTrack> storeTracks3Dfitter(collection3Dfitter);
2331  for (unsigned itr = 0; itr < _trackList3D.size(); ++itr) {
2332  const TCTrack* track3D = _trackList3D[itr];
2333  if (!track3D->fitted()) continue;
2334  double phi0 = remainder(track3D->helix().phi0() + M_PI_2, 2. * M_PI);
2335  double omega = 1. / track3D->helix().radius();
2336  double chi2 = track3D->get2DFitChi2();
2337  double z = track3D->helix().dz();
2338  double cot = track3D->helix().tanl();
2339  double chi3 = track3D->get3DFitChi2();
2340  const CDCTriggerTrack* track =
2341  storeTracks3Dfitter.appendNew(phi0, omega, chi2, z, cot, chi3);
2342  // relation to SegmentHits
2343  vector<TRGCDCLink*> links = track3D->links();
2344  for (unsigned its = 0; its < links.size(); ++its) {
2345  TRGCDCSegment* segment = (TRGCDCSegment*)links[its]->cell();
2346  const vector<const CDCTriggerSegmentHit*> storeHits = segment->storeHits();
2347  for (unsigned ihit = 0; ihit < storeHits.size(); ++ihit) {
2348  track->addRelationTo(storeHits[ihit]);
2349  }
2350  }
2351  // relation to 2D finder, assuming same order in tracklist
2352  if (storeTracks2Dfinder.getEntries() > 0)
2353  storeTracks2Dfinder[itr]->addRelationTo(track);
2354  }
2355 
2356  TRGDebug::leaveStage("TRGCDC storeSimulationResults");
2357  return;
2358  }
2359 
2360  void
2362  {
2363 #ifdef TRGCDC_DISPLAY
2364  D->beginningOfEvent();
2365 #endif
2366 
2367  TRGDebug::enterStage("TRGCDC firmwareSimulation");
2368 
2369  //...Wire level simulation is in update().
2370 
2371  //...Front ends...
2372  const unsigned nFronts = _fronts.size();
2373  for (unsigned i = 0; i < nFronts; i++) {
2374  //...Skip inner-most FE because they have no contribution to TRG
2375  if (i < 10)
2376  continue;
2377 
2378  //...FE simulation...
2379  _fronts[i]->simulate();
2380  }
2381 
2382  //...Mergers...
2383  const unsigned nMergers = _mergers.size();
2384  for (unsigned i = 0; i < nMergers; i++) {
2385  _mergers[i]->simulate();
2386  }
2387 
2388  //...TSFs...
2389  const unsigned nTSFBoards = _tsfboards.size();
2390  for (unsigned i = 0; i < nTSFBoards; i++) {
2391  //iw _tsfboards[i]->simulateBoard();
2392  // _tsfboards[i]->simulate();
2393  _tsfboards[i]->simulate2();
2394  }
2395 
2396  //...Event Time... In ns scale.
2397  // [FIXME] Not really firmware mode. Just for display.
2398  int t_eventTime = _eventTime.back()->getT0();
2399  // Update WireHit driftTime using eventTime
2400  // [FIXME] This method is a temorary method. Next time change everything inside EventTime class.
2401  //cout<<"Hit timing ";
2402  for (unsigned iHits = 0; iHits < _hits.size(); iHits++) {
2403  //cout<<"["<<_hits[iHits]->wire().layerId()<<"]["<<_hits[iHits]->wire().localId()<<"]: "<<(_hits[iHits]->drift(0))<<" ";
2404  _hits[iHits]->setDriftTime((_hits[iHits]->drift(0) - t_eventTime) / 250, 0);
2405  _hits[iHits]->setDriftTime((_hits[iHits]->drift(1) - t_eventTime) / 250, 1);
2406  }
2407  //cout<< endl;
2408  //cout<<"Event timing: "<<t_eventTime<<endl;
2409 
2410  //...Tracker2D...
2411  const unsigned nTracker2Ds = _tracker2Ds.size();
2412  for (unsigned i = 0; i < nTracker2Ds; i++) {
2413  _tracker2Ds[i]->simulate();
2414  }
2415 
2416 #ifdef TRGCDC_DISPLAY
2417  dump("hits");
2418  D->endOfEvent();
2419  string stg = "Firmware simulation";
2420  string inf = " ";
2421  D->clear();
2422  D->stage(stg);
2423  D->information(inf);
2424  D->area().append(hits());
2425  D->area().append(segmentHits());
2426  D->show();
2427  D->run();
2428  // unsigned iFront = 0;
2429  // while (const TCFrontEnd * f = _cdc.frontEnd(iFront++)) {
2430  // D->clear();
2431  // D->beginEvent();
2432  // D->area().append(* f);
2433  // D->run();
2434  // }
2435  // unsigned iMerger = 0;
2436  // while (const TCMerger * f = _cdc.merger(iMerger++)) {
2437  // D->clear();
2438  // D->beginEvent();
2439  // D->area().append(* f);
2440  // D->run();
2441  // }
2442 #endif
2443 
2444  TRGDebug::leaveStage("TRGCDC firmwareSimulation");
2445  }
2446 
2447  void
2449  {
2450  TRGDebug::enterStage("TRGCDC configure");
2451 
2452  //...Open configuration file...
2453  ifstream infile(_configFilename.c_str(), ios::in);
2454  if (infile.fail()) {
2455  cout << "TRGCDC !!! can not open file" << endl
2456  << " " << _configFilename << endl;
2457  return;
2458  }
2459 
2460  //...Read configuration data...
2461  char b[800];
2462  unsigned lines = 0;
2463  unsigned lastSl = 0;
2464  unsigned lastMergerLocalId = 0;
2465  while (! infile.eof()) {
2466  infile.getline(b, 800);
2467  const string l(b);
2468  string cdr = l;
2469 
2470  bool skip = false;
2471  unsigned wid = 0;
2472  unsigned lid = 0;
2473  unsigned fid = 0;
2474  unsigned mid = 0;
2475  unsigned tid = 0;
2476  if (lid != 0) mid = lid + tid; //jb
2477  for (unsigned i = 0; i < 5; i++) {
2478  const string car = TRGUtil::carstring(cdr);
2479  cdr = TRGUtil::cdrstring(cdr);
2480 
2481  if (car == "#") {
2482  skip = true;
2483  break;
2484  } else if (car == "CDC") {
2485  skip = true;
2486  break;
2487  }
2488 
2489  if (i == 0) {
2490  wid = atoi(car.c_str());
2491  } else if (i == 1) {
2492  lid = atoi(car.c_str());
2493  } else if (i == 2) {
2494  fid = atoi(car.c_str());
2495  } else if (i == 3) {
2496  mid = atoi(car.c_str());
2497  } else if (i == 4) {
2498  tid = atoi(car.c_str());
2499  }
2500  }
2501 
2502  if (skip)
2503  continue;
2504  if (lines != wid)
2505  continue;
2506 
2507  //...Super layer ID...
2508  const unsigned sl = _wires[wid]->superLayerId();
2509  if (sl != lastSl)
2510  lastMergerLocalId = 0;
2511 
2512  //...Make a front-end board if necessary...
2513  bool newFrontEnd = false;
2514  TCFrontEnd* f = 0;
2515  if (fid < _fronts.size())
2516  f = _fronts[fid];
2517  if (! f) {
2518  newFrontEnd = true;
2519  const string name = "CDCFrontEnd" + TRGUtil::itostring(fid);
2520  TCFrontEnd::boardType t = TCFrontEnd::unknown;
2521  if (sl == 0) {
2522  if (_wires[wid]->localLayerId() < 5)
2523  t = TCFrontEnd::innerInside;
2524  else
2525  t = TCFrontEnd::innerOutside;
2526  } else {
2527  if (_wires[wid]->localLayerId() < 3)
2528  t = TCFrontEnd::outerInside;
2529  else
2530  t = TCFrontEnd::outerOutside;
2531  }
2532  f = new TCFrontEnd(name, t, _clock, _clockD, _clockUser3125);
2533 
2534  _fronts.push_back(f);
2535  }
2536  f->push_back(_wires[wid]);
2537 
2538  //...Make a merger board if necessary... 2013,0908: physjg: I
2539  // think this should be done only when a new frontboard is
2540  // created. i.e., inlcuded in the if(!f) { .... } block.
2541  // Or I can put this part inside the new FrontEnd creation
2542  // part, well, seems not good in coding
2543  //
2544  bool newMerger = false;
2545  TCMerger* m = 0;
2546  if (newFrontEnd) {
2547  if (mid != 99999) {
2548  if (mid < _mergers.size())
2549  m = _mergers[mid];
2550  if (! m) {
2551  newMerger = true;
2552  const string name = "CDCMerger" + TRGUtil::itostring(sl) +
2553  "-" + TRGUtil::itostring(lastMergerLocalId);
2554  TCMerger::unitType mt = TCMerger::unknown;
2555  if (sl == 0)
2556  mt = TCMerger::innerType;
2557  else
2558  mt = TCMerger::outerType;
2559  m = new TCMerger(name,
2560  mt,
2561  _clock,
2562  _clockD,
2564  _clockUser6250);
2565  _mergers.push_back(m);
2566  ++lastMergerLocalId;
2567  lastSl = sl;
2568  //cout << "new merger : " << name << endl;
2569  }
2570  m->push_back(f);
2571  }
2572 
2573  //...Make Aurora channel...
2574  if (f && m) {
2575  const string n = f->name() + string("-") + m->name();
2576  TRGChannel* ch = new TRGChannel(n, *f, *m);
2577  f->appendOutput(ch);
2578  m->appendInput(ch);
2579  }
2580  }
2581 
2582  //...Make a TSF board if necessary...
2583  if (newMerger) {
2584  TSFinder* t = 0;
2585  if (tid != 99999) {
2586  if (tid < _tsfboards.size())
2587  t = _tsfboards[tid];
2588  if (!t) {
2589  const string name = "CDCTSFBoard" + TRGUtil::itostring(tid);
2590  TSFinder::boardType tt = TSFinder::unknown;
2591  if (_wires[wid]->superLayerId() == 0)
2592  tt = TSFinder::innerType;
2593  else
2594  tt = TSFinder::outerType;
2595  t = new TSFinder(*this,
2596  name,
2597  tt,
2598  _clock,
2599  _clockD,
2602  _tsSL[tid]);
2603  _tsfboards.push_back(t);
2604  }
2605  t->push_back(m);
2606  }
2607 
2608  if (m && t) {
2609  const string n = m->name() + string("-") + t->name();
2610  TRGChannel* chmt = new TRGChannel(n, *m, *t);
2611  m->appendOutput(chmt);
2612  t->appendInput(chmt);
2613  }
2614  }
2615 
2616  ++lines;
2617  }
2618  infile.close();
2619 
2620  //...Make a 2D finder...
2621  for (unsigned i = 0; i < 4; i++) {
2622  const string name = "CDC2DBoard" + TRGUtil::itostring(i);
2623  TCTracker2D* t = new TCTracker2D(name,
2624  _clock,
2625  _clockD,
2627  _clockUser6250);
2628  _tracker2Ds.push_back(t);
2629  for (unsigned j = 0; j < 9; j++) {
2630  TCTSFinder* tsf = _tsfboards[j];
2631  const string n = tsf->name() + string("-") + t->name();
2632  TRGChannel* ch = new TRGChannel(n, *tsf, *t);
2633  tsf->appendOutput(ch);
2634  t->appendInput(ch);
2635  }
2636  const string n = t->name() + string("-") + "CDC3DBoard" + TRGUtil::itostring(i);
2637  TRGChannel* ch = new TRGChannel(n, *t, *t);
2638  // last (* t) should be 3D tracker in future
2639  t->appendOutput(ch);
2640  }
2641 
2642  //...For debug...
2643  if (TRGDebug::level()) {
2644  cout << TRGDebug::tab() << "TSF configuration" << endl;
2645  for (unsigned i = 0; i < _tsfboards.size(); i++) {
2646  const TSFinder& t = *_tsfboards[i];
2647  t.dump("detail", TRGDebug::tab() + " ");
2648  }
2649  cout << TRGDebug::tab() << "Tracker2D configuration" << endl;
2650  for (unsigned i = 0; i < _tracker2Ds.size(); i++) {
2651  const TCTracker2D& t = *_tracker2Ds[i];
2652  t.dump("detail", TRGDebug::tab() + " ");
2653  }
2654  }
2655 
2656  TRGDebug::leaveStage("TRGCDC configure");
2657  }
2658 
2659  const TRGCDCSegment&
2660  TRGCDC::segment(unsigned lid, unsigned id) const
2661  {
2662  return *(const TRGCDCSegment*)(* _tsLayers[lid])[id];
2663  }
2664 
2665 //jb void
2666 //jb TRGCDC::perfect3DFinder(vector<TCTrack*> trackList) const {
2667 //jb
2668 //jb TRGDebug::enterStage("Perfect 3D Finder");
2669 //jb if (TRGDebug::level())
2670 //jb cout << TRGDebug::tab() << "givenTrk#=" << trackList.size() << endl;
2671 //jb
2672 //jb //...Track loop....
2673 //jb for (unsigned j = 0; j < trackList.size(); j++) {
2674 //jb
2675 //jb //...G4 trackID...
2676 //jb TCTrack * trk = trackList[j];
2677 //jb unsigned id = trackList[j]->relation().contributor(0);
2678 //jb vector<const TCSHit*> tsList[9];
2679 //jb
2680 //jb //...Segment loop...
2681 //jb const vector<const TCSHit*> hits = segmentHits();
2682 //jb for (unsigned i = 0; i < hits.size(); i++) {
2683 //jb const TCSHit & ts = * hits[i];
2684 //jb if (ts.segment().axial()) continue;
2685 //jb if (! ts.signal().active()) continue;
2686 //jb const TCWHit * wh = ts.segment().center().hit();
2687 //jb if (! wh) continue;
2688 //jb const unsigned trackId = wh->iMCParticle();
2689 //jb
2690 //jb if (id == trackId)
2691 //jb tsList[wh->wire().superLayerId()].push_back(& ts);
2692 //jb }
2693 //jb
2694 //jb if (TRGDebug::level()) {
2695 //jb cout << TRGDebug::tab() << "trk#" << j << endl;
2696 //jb for (unsigned k = 0; k < 9; k++) {
2697 //jb if (k % 2) {
2698 //jb cout << TRGDebug::tab(4) << "superlayer " << k << ":";
2699 //jb for (unsigned l = 0; l < tsList[k].size(); l++) {
2700 //jb if (l)
2701 //jb cout << ",";
2702 //jb cout << tsList[k][l]->cell().name();
2703 //jb }
2704 //jb cout << endl;
2705 //jb }
2706 //jb }
2707 //jb }
2708 //jb
2709 //jb //...Select best one in each super layer...
2710 //jb for (unsigned i = 0; i < 9; i++) {
2711 //jb const TCSHit * best = 0;
2712 //jb if (tsList[i].size() == 0) {
2713 //jb continue;
2714 //jb } else if (tsList[i].size() == 1) {
2715 //jb best = tsList[i][0];
2716 //jb } else {
2717 //jb int timeMin = 99999;
2718 //jb for (unsigned k = 0; k < tsList[i].size(); k++) {
2719 //jb const TRGSignal & signal = tsList[i][k]->signal();
2720 //jb const TRGTime & t = * signal[0];
2721 //jb if (t.time() < timeMin) {
2722 //jb timeMin = t.time();
2723 //jb best = tsList[i][k];
2724 //jb }
2725 //jb }
2726 //jb }
2727 //jb //trk->append(new TCLink(0,
2728 //jb // best,
2729 //jb // best->cell().xyPosition()));
2730 //jb }
2731 //jb
2732 //jb if (TRGDebug::level())
2733 //jb trk->dump("", "> ");
2734 //jb
2735 //jb }
2736 //jb
2737 //jb TRGDebug::leaveStage("Perfect 3D Finder");
2738 //jb }
2739 
2740  int TRGCDC::getEventTime(void) const
2741  {
2742  return _eventTime.back()->getT0();
2743  }
2744 
2745  void TRGCDC::setReturnValue(EReturnValueType const& moduleName, bool flag)
2746  {
2747  if (flag) _returnValue |= moduleName;
2748  else _returnValue &= ~moduleName;
2749  }
2750 
2751  int TRGCDC::getReturnValue(EReturnValueType const& moduleName) const
2752  {
2753  return _returnValue & moduleName;
2754  }
2755 
2756 
2757  void TRGCDC::saveCDCHitInformation(vector<vector<unsigned>>& hitWiresFromCDC)
2758  {
2759  TClonesArray& rootCDCHitInformation = *m_rootCDCHitInformation;
2760  rootCDCHitInformation.Clear();
2761  for (unsigned iHit = 0; iHit < hitWiresFromCDC.size(); iHit++) {
2762  TVectorD t_rootCDCHitInformation(5);
2763  t_rootCDCHitInformation[0] = hitWiresFromCDC[iHit][0];
2764  t_rootCDCHitInformation[1] = hitWiresFromCDC[iHit][1];
2765  t_rootCDCHitInformation[2] = hitWiresFromCDC[iHit][2];
2766  t_rootCDCHitInformation[3] = hitWiresFromCDC[iHit][3];
2767  t_rootCDCHitInformation[4] = hitWiresFromCDC[iHit][4];
2768  new(rootCDCHitInformation[iHit]) TVectorD(t_rootCDCHitInformation);
2769  } // End of hit loop
2770  }
2771 
2772  void TRGCDC::saveTRGHitInformation(vector<vector<int>>& hitWiresFromTRG)
2773  {
2774  TClonesArray& rootTRGHitInformation = *m_rootTRGHitInformation;
2775  rootTRGHitInformation.Clear();
2776  for (unsigned iHit = 0; iHit < hitWiresFromTRG.size(); iHit++) {
2777  TVectorD t_rootTRGHitInformation(4);
2778  t_rootTRGHitInformation[0] = hitWiresFromTRG[iHit][0];
2779  t_rootTRGHitInformation[1] = hitWiresFromTRG[iHit][1];
2780  t_rootTRGHitInformation[2] = hitWiresFromTRG[iHit][2];
2781  t_rootTRGHitInformation[3] = hitWiresFromTRG[iHit][3];
2782  new(rootTRGHitInformation[iHit]) TVectorD(t_rootTRGHitInformation);
2783  } // End of hit loop
2784  }
2785 
2786  void TRGCDC::saveTRGRawInformation(vector<string >& trgInformations)
2787  {
2788  TClonesArray& rootTRGRawInformation = *m_rootTRGRawInformation;
2789  rootTRGRawInformation.Clear();
2790  for (unsigned iWindow = 0; iWindow < trgInformations.size(); iWindow++) {
2791  TObjString t_rootTRGRawInformation;
2792  t_rootTRGRawInformation.SetString(trgInformations[iWindow].c_str());
2793  new(rootTRGRawInformation[iWindow]) TObjString(t_rootTRGRawInformation);
2794  } // End of hit loop
2795  }
2796 
2797 //void TRGCDC::saveCDCTRGTimeMatchInformation(vector<vector<map<int, int> > >& hitTimingComp) {
2798 //
2799 // TClonesArray& CDCTRGTimeMatch = *m_CDCTRGTimeMatch;
2800 // CDCTRGTimeMatch.Clear();
2801 // int nTotalHits = 0;
2802 // for(unsigned iLayer=0; iLayer<5; iLayer++){
2803 // for(unsigned iWire=0; iWire<16; iWire++){
2804 // for(map<int, int>::iterator it = hitTimingComp[iLayer][iWire].begin(); it != hitTimingComp[iLayer][iWire].end(); it++){
2805 // TVectorD t_CDCTRGTimeMatch(4);
2806 // t_CDCTRGTimeMatch[0] = iLayer;
2807 // t_CDCTRGTimeMatch[1] = iWire;
2808 // t_CDCTRGTimeMatch[2] = (*it).first;
2809 // t_CDCTRGTimeMatch[3] = (*it).second;
2810 // new(CDCTRGTimeMatch[nTotalHits++]) TVectorD(t_CDCTRGTimeMatch);
2811 // }
2812 // } // End of wire loop
2813 // } // End of layer loop
2814 //
2815 //}
2816 
2817  unsigned
2818  TRGCDC::nSegments(unsigned id) const
2819  {
2820  if (id < _tsLayers.size())
2821  return _tsLayers[id]->size();
2822  return 0;
2823  }
2824 
2826 } // namespace Belle2
2827 
Belle2::RawCOPPER
The Raw COPPER class This class stores data received by COPPER via belle2linkt Data from all detector...
Definition: RawCOPPER.h:52
Belle2::RelationVector::size
size_t size() const
Get number of relations.
Definition: RelationVector.h:98
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::TRGCDC::_configFilename
std::string _configFilename
CDC trigger configuration filename.
Definition: TRGCDC.h:500
Belle2::TRGCDC::_clockUser6250
const TRGClock _clockUser6250
CDC trigger user clock for Aurora 6.250 Gbps.
Definition: TRGCDC.h:691
Belle2::TRGCDC::localId
unsigned localId(unsigned wireId) const
returns local ID in a layer. This function is expensive.
Definition: TRGCDC.cc:1771
Belle2::TRGCDC::_wires
std::vector< TRGCDCWire * > _wires
All wires.
Definition: TRGCDC.h:627
Belle2::TRGSignal
A class to represent a digitized signal. Unit is nano second.
Definition: Signal.h:28
Belle2::RelationArray
Low-level class to create/modify relations between StoreArrays.
Definition: RelationArray.h:72
Belle2::WireID
Class to identify a wire inside the CDC.
Definition: WireID.h:44
Belle2::TRGCDC::_width
float * _width
Cell width in radian.
Definition: TRGCDC.h:666
Belle2::MCParticle::getCharge
float getCharge() const
Return the particle charge defined in TDatabasePDG.
Definition: MCParticle.cc:35
Belle2::CDC::CDCGeometryPar::nWireLayers
unsigned nWireLayers() const
Returns a number of wire layers.
Definition: CDCGeometryPar.h:1311
Belle2::TRGCDCLayer::nCells
unsigned nCells(void) const
returns # of cells.
Definition: Layer.h:192
Belle2::TRGTime::shift
TRGTime & shift(int unit)
delays by clock unit.
Definition: Time.h:168
Belle2::CDC::CDCGeometryPar::wireForwardPosition
const TVector3 wireForwardPosition(int layerId, int cellId, EWirePosition set=c_Base) const
Returns the forward position of the input sense wire.
Definition: CDCGeometryPar.cc:1625
Belle2::TRGCDC::m_treeROOTInput
TTree * m_treeROOTInput
Debugging members for firmware ROOT input.
Definition: TRGCDC.h:780
Belle2::TRGCDC::_outerTSLUTFilename
std::string _outerTSLUTFilename
The filename of LUT for outer track segments.
Definition: TRGCDC.h:558
Fitter3DUtility::findImpactPosition
static void findImpactPosition(TVector3 *mcPosition, TLorentzVector *mcMomentum, int charge, TVector2 &helixCenter, TVector3 &impactPosition)
MC calculation functions Calculates the impact position of track.
Definition: Fitter3DUtility.cc:1924
Belle2::TRGCDC::_hFinder
TRGCDCHoughFinder * _hFinder
Hough finder.
Definition: TRGCDC.h:721
Belle2::TRGCDC::_tsfboards
std::vector< TRGCDCTrackSegmentFinder * > _tsfboards
CDC trigger tsf boards.
Definition: TRGCDC.h:706
Belle2::TRGCDC::segmentHits
std::vector< const TRGCDCSegmentHit * > segmentHits(void) const
returns a list of TRGCDCSegmentHit.
Definition: TRGCDC.h:997
Belle2::TRGCDC::_axialSuperLayers
std::vector< std::vector< TRGCDCLayer * > * > _axialSuperLayers
Axial super layers.
Definition: TRGCDC.h:612
Belle2::TRGCDC::_fLogicLUTTSF
bool _fLogicLUTTSF
Switch for logic or LUT TSF.
Definition: TRGCDC.h:567
Belle2::TRGCDC::_fitter3D
TRGCDCFitter3D * _fitter3D
3D fitter.
Definition: TRGCDC.h:727
Belle2::TRGCDC::firmwareSimulation
void firmwareSimulation(void)
Firmware simulation.
Definition: TRGCDC.cc:2361
Belle2::TRGDebug::level
static int level(void)
returns the debug level.
Definition: Debug.cc:72
Belle2::TRGCDC::storeSimulationResults
void storeSimulationResults(std::string collection2Dfinder, std::string collection2Dfitter, std::string collection3Dfitter)
Save results of fast simulation to data store (segment hits & tracks).
Definition: TRGCDC.cc:2246
Belle2::TRGCDC::_tracker2Ds
std::vector< TRGCDCTracker2D * > _tracker2Ds
CDC 2D finder boards.
Definition: TRGCDC.h:709
Belle2::TRGCDC::_clockD
const TRGClock _clockD
CDC trigger data clock.
Definition: TRGCDC.h:685
Belle2::TRGState::subset
TRGState subset(unsigned i, unsigned n) const
returns subset from i with n bits.
Definition: State.cc:362
Belle2::RawCOPPER::GetDetectorBuffer
int * GetDetectorBuffer(int n, int finesse_num)
get Detector buffer
Definition: RawCOPPER.h:676
Belle2::TRGCDC::_tsLayers
std::vector< TRGCDCLayer * > _tsLayers
Track Segment layers.
Definition: TRGCDC.h:654
Belle2::TRGCDC::nAxialLayers
unsigned nAxialLayers(void) const
return # of axial layers.
Definition: TRGCDC.h:885
Belle2::TRGCDC::_rootFitter3DFilename
std::string _rootFitter3DFilename
The filename of root file for Fitter3D.
Definition: TRGCDC.h:564
Belle2::TRGChannel
A class to represent a serial link between trigger hardware modules.
Definition: Channel.h:30
Belle2::TRGCDC::nLayers
unsigned nLayers(void) const
return # of layers.
Definition: TRGCDC.h:906
Belle2::TRGCDC::_clockUser3125
const TRGClock _clockUser3125
CDC trigger user clock for Aurora 3.125 Gbps.
Definition: TRGCDC.h:688
Belle2::CDCHit
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:51
Belle2::TRGCDC::_tracks2D
TClonesArray * _tracks2D
2D track information
Definition: TRGCDC.h:766
Belle2::RawCOPPER::GetDetectorNwords
int GetDetectorNwords(int n, int finesse_num)
get Detector buffer length
Definition: RawCOPPER.h:652
Belle2::TRGCDC::_segmentHits
std::vector< TRGCDCSegmentHit * > _segmentHits
Track Segments with hits.
Definition: TRGCDC.h:657
Belle2::TRGCDC::m_treeAllTracks
TTree * m_treeAllTracks
root tree for MC tracks
Definition: TRGCDC.h:742
Belle2::TRGCDCFitter3D::terminate
void terminate()
Termination.
Definition: Fitter3D.cc:1528
Belle2::TRGCDC::dump
void dump(const std::string &message) const
dumps debug information.
Definition: TRGCDC.cc:765
Belle2::TRGCDC::_fLRLUT
bool _fLRLUT
Switch for the LR LUT in Fitter3D.
Definition: TRGCDC.h:570
Belle2::TRGCDC::_r
float * _r
R of cell.
Definition: TRGCDC.h:669
Belle2::CDCTriggerTSFFirmwareModule
This class is the interface between TSim/Basf2 TSF module and the firmware simulation core of XSim/IS...
Definition: CDCTriggerTSFFirmwareModule.h:48
Belle2::TRGCDC::simulate
void simulate(void)
fast trigger simulation.
Definition: TRGCDC.cc:2047
Belle2::TRGCDC::_eventTime
std::vector< TRGCDCEventTime * > _eventTime
EventTime.
Definition: TRGCDC.h:730
Belle2::TRGCDC::_layers
std::vector< TRGCDCLayer * > _layers
All layers.
Definition: TRGCDC.h:618
Belle2::TRGCDC::fastClear
void fastClear(void)
clears TRGCDC information.
Definition: TRGCDC.cc:979
Belle2::CDCTriggerTrack
Track created by the CDC trigger.
Definition: CDCTriggerTrack.h:15
Belle2::TRGCDCSegment::priority
const TRGCDCWire & priority(void) const
returns priority wire.
Belle2::TRGCDCSegment::priorityTime
float priorityTime(void) const
return priority time in TSHit.
Belle2::RelationsInterface::addRelationTo
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
Definition: RelationsObject.h:144
Belle2::TRGCDC::_hits
std::vector< TRGCDCWireHit * > _hits
CDC hits.
Definition: TRGCDC.h:633
Belle2::TRGState
A class to represent a state of multi bits.
Definition: State.h:29
Belle2::TRGCDC::superLayer
const std::vector< TRGCDCLayer * > * superLayer(unsigned id) const
returns a pointer to a super-layer.
Definition: TRGCDC.h:836
Belle2::TRGCDC::m_mcTrackStatus
TClonesArray * m_mcTrackStatus
MC track status.
Definition: TRGCDC.h:760
Belle2::CDC::CDCGeometryPar::getTdcBinWidth
double getTdcBinWidth() const
Return TDC bin width (nsec).
Definition: CDCGeometryPar.h:732
Belle2::TRGCDCWire
A class to represent a wire in CDC.
Definition: Wire.h:57
Belle2::TRGCDC::_firmwareSimulationWindow
TRGSignal _firmwareSimulationWindow
Firmware simulation time window in FE.
Definition: TRGCDC.h:525
Belle2::TRGCDC::_innerTSLUTFilename
std::string _innerTSLUTFilename
The filename of LUT for the inner-most track segments.
Definition: TRGCDC.h:555
Belle2::TRGCDC::_h3DFinder
TRGCDCHough3DFinder * _h3DFinder
Hough 3D finder.
Definition: TRGCDC.h:724
Belle2::TRGCDC::updateByData
void updateByData(int inputMode)
updates TRGCDC wire information by Hardware data 0: From CDC FE ASCII file (Implementing) 1: From CDC...
Definition: TRGCDC.cc:1177
Belle2::TRGCDC::_fileFitter3D
bool _fileFitter3D
Switch for Fitter3D.root file.
Definition: TRGCDC.h:603
Belle2::TRGCDC::m_evtTime
TClonesArray * m_evtTime
Event time.
Definition: TRGCDC.h:763
Belle2::TRGCDCPerfectFinder::doit
int doit(std::vector< TRGCDCTrack * > &trackListClone, std::vector< TRGCDCTrack * > &trackList)
do track finding.
Definition: PerfectFinder.cc:66
Belle2::TRGCDCLUT::getValue
int getValue(unsigned) const
get LUT Values
Definition: LUT.cc:48
Belle2::TRGCDC::m_mcParameters
TClonesArray * m_mcParameters
MC.
Definition: TRGCDC.h:751
Belle2::TRGCDC::_cdchitCollectionName
std::string _cdchitCollectionName
name of the CDCHit DataStore array used as input
Definition: TRGCDC.h:772
Belle2::TRGCDCSegment::foundTime
float foundTime(void) const
return found time in TSHit.
Belle2::TRGCDC::name
std::string name(void) const
simulates track segment decisions.
Definition: TRGCDC.cc:90
Belle2::TRGCDC::m_mcTrack4Vector
TClonesArray * m_mcTrack4Vector
MC track.
Definition: TRGCDC.h:754
Belle2::TRGCDC::axialHits
std::vector< const TRGCDCWireHit * > axialHits(void) const
returns a list of axial hits.
Definition: TRGCDC.cc:1677
Belle2::TRGCDC::_fprintFirmETF
bool _fprintFirmETF
Switch for printing Firmware inputs for ETF.
Definition: TRGCDC.h:594
Belle2::TRGCDC::_r2
float * _r2
R^2 of cell.
Definition: TRGCDC.h:672
Belle2::TRGCDC::nWires
unsigned nWires(void) const
return # of wires.
Definition: TRGCDC.h:864
Belle2::TRGCDC::stereoHits
std::vector< const TRGCDCWireHit * > stereoHits(void) const
returns a list of stereo hits.
Definition: TRGCDC.cc:1690
Belle2::TRGCDC::dataClock
const TRGClock & dataClock(void) const
returns the data clock.
Definition: TRGCDC.h:983
Belle2::TRGSignalBundle
A class to represent a bundle of SignalVectors.
Definition: SignalBundle.h:31
Belle2::TRGSignal::name
const std::string & name(void) const
returns name.
Definition: Signal.h:190
Belle2::TRGCDC::layer
const TRGCDCLayer * layer(unsigned id) const
returns a pointer to a layer. 0 will be returned if 'id' is invalid.
Definition: TRGCDC.h:829
Belle2::TRGCDC::_debugLevel
int _debugLevel
Debug level.
Definition: TRGCDC.h:494
Belle2::TRGCDC::neighbor
bool neighbor(const TRGCDCWire &w0, const TRGCDCWire &w1) const
returns true if w0 and w1 are neighbor.
Definition: TRGCDC.cc:2028
Belle2::TRGCDCLayer
A class to represent a cell layer.
Definition: Layer.h:34
Belle2::TRGCDC::hitsMC
std::vector< const TRGCDCWireHitMC * > hitsMC(void) const
returns a list of TRGCDCWireHitMC.
Definition: TRGCDC.cc:1749
Belle2::TRGCDC::_firmwareSimulationStartDataClock
int _firmwareSimulationStartDataClock
Firmware simulation start clock in CDCTRG data clock.
Definition: TRGCDC.h:528
Belle2::TRGCDC::_finder3DMode
int _finder3DMode
Sets mode of 3DFinder.
Definition: TRGCDC.h:600
Belle2::TRGCDC::_clockFE
const TRGClock _clockFE
CDC front end clock. Resolution is CDC TdcBinWidth.
Definition: TRGCDC.h:678
Belle2::TRGCDC::initialize
void initialize(unsigned houghFinderPeakMin, const std::string &houghMappingFilePlus, const std::string &houghMappingFileMinus, unsigned houghDoit)
initializes CDC geometry.
Definition: TRGCDC.cc:370
Belle2::TRGCDC::_hitsMC
std::vector< TRGCDCWireHitMC * > _hitsMC
MC info. of CDC hits.
Definition: TRGCDC.h:645
Belle2::TRGCDCSegment::fastestTime
float fastestTime(void) const
return fastest time in TSHit.
Belle2::TRGCDC::_tsFinder
TRGCDCTrackSegmentFinder * _tsFinder
Track Segement Finder.
Definition: TRGCDC.h:712
Belle2::TRGSignal::active
bool active(void) const
returns true if there is a signal.
Definition: Signal.h:279
Belle2::TRGCDC::_returnValue
int _returnValue
Return value for trg cdc module;.
Definition: TRGCDC.h:534
Belle2::TRGClock::dump
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Definition: Clock.cc:93
Belle2::TRGCDC::m_fitParameters
TClonesArray * m_fitParameters
3D fit
Definition: TRGCDC.h:748
Belle2::TRGCDCSegment::storeHits
const std::vector< const CDCTriggerSegmentHit * > storeHits(void) const
returns a pointer to a CDCTriggerSegmentHit.
Definition: Segment.h:236
Belle2::TRGCDC::classification
void classification(void)
classify hits.
Definition: TRGCDC.cc:1602
Belle2::TRGCDC::_fastSimulationMode
unsigned _fastSimulationMode
Fast simulation mode.
Definition: TRGCDC.h:506
Belle2::TRGCDC::superLayerId
unsigned superLayerId(unsigned wireId) const
returns super layer ID. This function is expensive.
Definition: TRGCDC.cc:1818
Belle2::TRGCDC::nSuperLayers
unsigned nSuperLayers(void) const
returns # of super layers.
Definition: TRGCDC.h:871
Belle2::TRGCDC::_p3DFinder
TRGCDCPerfectFinder * _p3DFinder
Perfect 3D finder.
Definition: TRGCDC.h:718
Belle2::TRGTime::clock
const TRGClock & clock(void) const
returns clock.
Definition: Time.h:154
Belle2::TRGState::set
const TRGState & set(unsigned position, bool state=true)
sets state at bit i.
Definition: State.h:309
Belle2::TRGCDC::layerId
unsigned layerId(unsigned wireId) const
returns layer ID. This function is expensive.
Definition: TRGCDC.cc:1791
Belle2::TRGCDC::_clock
const TRGClock _clock
CDC trigger system clock.
Definition: TRGCDC.h:675
Belle2::TRGCDCCellHit::iCDCHit
unsigned iCDCHit(void) const
returns an index to CDCHit.
Definition: CellHit.h:361
Belle2::TRGCDC::getReturnValue
int getReturnValue(void) const
gets return value for trg cdc module.
Definition: TRGCDC.h:1099
Belle2::TRGCDC::_trgCDCDataInputMode
int _trgCDCDataInputMode
Switch for TRG CDC input mode.
Definition: TRGCDC.h:769
Belle2::RelationVector
Class for type safe access to objects that are referred to in relations.
Definition: DataStore.h:38
Belle2::CDC::CDCGeometryPar::senseWireR
double senseWireR(int layerId) const
Returns radius of sense wire in each layer.
Definition: CDCGeometryPar.h:1231
Belle2::TRGCDC::_fFitter3Ds2DFitDrift
bool _fFitter3Ds2DFitDrift
Switch to us wire 2D fit or drift 2D fit.
Definition: TRGCDC.h:579
Belle2::CDC::CDCGeometryPar::wireBackwardPosition
const TVector3 wireBackwardPosition(int layerId, int cellId, EWirePosition set=c_Base) const
Returns the backward position of the input sense wire.
Definition: CDCGeometryPar.cc:1662
Belle2::TRGCDC::_mergers
std::vector< TRGCDCMerger * > _mergers
CDC trigger merger boards.
Definition: TRGCDC.h:703
Belle2::CDC::CDCGeometryPar::Instance
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
Definition: CDCGeometryPar.cc:41
Belle2::TRGCDC::wireName
std::string wireName(unsigned wireId) const
returns wire name.
Definition: TRGCDC.cc:1757
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::MCParticle::getVertex
TVector3 getVertex() const
Return production vertex position, shorthand for getProductionVertex().
Definition: MCParticle.h:194
Belle2::TRGCDC::m_rootCDCHitInformation
TClonesArray * m_rootCDCHitInformation
[0]: iLayer, [1]: iWire, [2]: CDCADC, [3]: CDCTDC, [4]: CDC FE TRG timing
Definition: TRGCDC.h:782
Belle2::TRGCDC::_fileTSF
bool _fileTSF
Switch for TSF.root file.
Definition: TRGCDC.h:585
Belle2::TRGCDC::EReturnValueType
EReturnValueType
Enum for returnValue types.
Definition: TRGCDC.h:75
Belle2::TRGCDC::_fverETF
int _fverETF
Switch for selecting ETF version.
Definition: TRGCDC.h:591
Belle2::TRGCDC::getTRGCDC
static TRGCDC * getTRGCDC(void)
returns TRGCDC object.
Definition: TRGCDC.cc:190
Belle2::TRGCDC::localLayerId
unsigned localLayerId(unsigned wireId) const
returns local layer ID in a super layer. This function is expensive.
Definition: TRGCDC.cc:1840
Belle2::TRGCDC::m_file
TFile * m_file
root file
Definition: TRGCDC.h:736
Belle2::TRGCDCFitter3D::doit
int doit(std::vector< TRGCDCTrack * > &trackList)
Does track fitting.
Definition: Fitter3D.cc:211
Belle2::TRGCDCHoughFinder::FindAndFit
int FindAndFit(std::vector< TRGCDCTrack * > &trackList2D, std::vector< TRGCDCTrack * > &trackList2DFitted)
do track finding and fitting (wrapper that can choose between different versions).
Definition: HoughFinder.cc:756
Belle2::TRGCDC::_segmentHitsSL
std::vector< TRGCDCSegmentHit * > _segmentHitsSL[9]
Track Segments with hits in each super layer.
Definition: TRGCDC.h:660
Belle2::TRGCDC::_fronts
std::vector< TRGCDCFrontEnd * > _fronts
CDC front-end boards.
Definition: TRGCDC.h:700
Belle2::CDC::CDCGeometryPar::fieldWireR
double fieldWireR(int layerId) const
Returns radius of field wire in each layer.
Definition: CDCGeometryPar.h:1246
Belle2::RelationsInterface::getRelationsFrom
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
Definition: RelationsObject.h:214
Belle2::TRGCDC::_fileHough3D
bool _fileHough3D
Switch for Hough3D.root file.
Definition: TRGCDC.h:597
Belle2::CDC::CDCGeometryPar::nShifts
int nShifts(int layerId) const
Returns number shift.
Definition: CDCGeometryPar.h:1201
Belle2::TRGCDC::_axialHits
std::vector< TRGCDCWireHit * > _axialHits
CDC hits on axial wires.
Definition: TRGCDC.h:636
Belle2::TRGCDC::_clockTDC
const TRGClock _clockTDC
CDC trigger TDC clock.
Definition: TRGCDC.h:682
Belle2::CDC::CDCGeometryPar::getNominalDriftV
double getNominalDriftV() const
Return the nominal drift velocity of He-ethane gas (default: 4.0x10^-3 cm/nsec).
Definition: CDCGeometryPar.h:742
Belle2::TRGCDC::getEventTime
int getEventTime(void) const
returns bad hits(finding invalid hits).
Definition: TRGCDC.cc:2740
Belle2::RawCOPPER::SetBuffer
void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes) OVERRIDE_CPP17
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
Definition: RawCOPPER.cc:141
Belle2::TRGCDC::_hitWires
std::vector< TRGCDCWire * > _hitWires
Wires with a hit.
Definition: TRGCDC.h:630
Belle2::TRGCDC::_tsSL
std::vector< TRGCDCSegment * > _tsSL[9]
Track Segments.
Definition: TRGCDC.h:651
Belle2::TRGCDC::m_rootTRGHitInformation
TClonesArray * m_rootTRGHitInformation
[0]: iLayer, [1]: iWire, [2]: window number, [3]: priority timing
Definition: TRGCDC.h:784
Belle2::TRGCDC::segment
const TRGCDCSegment & segment(unsigned id) const
returns a track segment.
Definition: TRGCDC.h:934
Belle2::TRGCDC::_firmwareSimulationStop
int _firmwareSimulationStop
Fimrware simulation stop clock in FE.
Definition: TRGCDC.h:522
Belle2::TRGState::size
unsigned size(void) const
returns bit size.
Definition: State.h:153
Belle2::TRGCDCSegment::priorityPosition
int priorityPosition(void) const
return priority cell position in TSHit. 0: no hit, 3: 1st priority, 1: 2nd right, 2: 2nd left
Belle2::TRGCDC::version
std::string version(void) const
returns version.
Definition: TRGCDC.cc:96
Belle2::TRGCDC::setReturnValue
void setReturnValue(EReturnValueType const &moduleName, bool flag)
sets return value for trg cdc module.
Definition: TRGCDC.cc:2745
Belle2::TRGCDC::_tree2D
TTree * _tree2D
root tree for 2D tracks
Definition: TRGCDC.h:745
Belle2::TRGClock::position
int position(double timing) const
returns clock position.
Definition: Clock.cc:119
Belle2::CDC::CDCGeometryPar::zOffsetWireLayer
double zOffsetWireLayer(unsigned i) const
Returns the offset of z of the wire layer i.
Definition: CDCGeometryPar.h:1326
Belle2::TRGCDC::_stereoSuperLayers
std::vector< std::vector< TRGCDCLayer * > * > _stereoSuperLayers
Stereo super layers.
Definition: TRGCDC.h:615
Belle2::TRGCDCCell::id
unsigned id(void) const
returns id.
Definition: Cell.h:198
Belle2::TRGCDCWire::hit
const TRGCDCWireHit * hit(void) const
returns a pointer to a TRGCDCWireHit.
Definition: Wire.h:144
Belle2::TRGCDC
The instance of TRGCDC is a singleton.
Definition: TRGCDC.h:70
Belle2::TRGCDC::_fXtSimpleFitter3D
bool _fXtSimpleFitter3D
Switch for using simple x-t curve or non-linear x-t curve. 0: non-linear 1: simple.
Definition: TRGCDC.h:606
Belle2::TRGCDC::m_cdcp
CDC::CDCGeometryPar * m_cdcp
returns a pointer to CDCGeometryPar
Definition: TRGCDC.h:253
Belle2::CDC::CDCGeometryPar::getT0
float getT0(const WireID &wireID) const
Returns t0 parameter of the specified sense wire.
Definition: CDCGeometryPar.h:565
Belle2::TRGCDC::nStereoLayers
unsigned nStereoLayers(void) const
returns # of stereo layers.
Definition: TRGCDC.h:878
Belle2::RelationArray::getEntries
int getEntries() const
Get the number of elements.
Definition: RelationArray.h:252
Belle2::TRGCDCSegment
A class to represent a wire in CDC.
Definition: Segment.h:40
Belle2::TRGCDC::_fFitter3Ds2DFit
bool _fFitter3Ds2DFit
Switch to us 2D fit or Hough finder results.
Definition: TRGCDC.h:576
Belle2::TRGCDC::_simulationMode
unsigned _simulationMode
Simulation mode.
Definition: TRGCDC.h:503
Belle2::TRGCDC::nStereoSuperLayers
unsigned nStereoSuperLayers(void) const
returns # of stereo super layers.
Definition: TRGCDC.h:899
Belle2::TRGCDC::update
void update()
updates TRGCDC wire information. clear() is called in this function.
Definition: TRGCDC.cc:982
Belle2::TRGUtilities::itostring
static std::string itostring(int i)
converts int to string. (Use boost::lexical_cast)
Belle2::TRGCDC::_badHits
std::vector< TRGCDCWireHit * > _badHits
Bad CDC hits.(not used now)
Definition: TRGCDC.h:642
Belle2::MCParticle::get4Vector
TLorentzVector get4Vector() const
Return 4Vector of particle.
Definition: MCParticle.h:218
Belle2::TRGCDC::saveCDCHitInformation
void saveCDCHitInformation(std::vector< std::vector< unsigned > > &)
Save functions for ROOT.
Definition: TRGCDC.cc:2757
Belle2::TRGCDC::m_tree
TTree * m_tree
root tree for reconstructed 3D tracks
Definition: TRGCDC.h:739
Belle2::TRGCDC::_stereoHits
std::vector< TRGCDCWireHit * > _stereoHits
CDC hits on stereo wires.
Definition: TRGCDC.h:639
Belle2::TRGDebug::tab
static std::string tab(void)
returns tab spaces.
Definition: Debug.cc:52
Belle2::CDC::CDCGeometryPar::nWiresInLayer
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
Definition: CDCGeometryPar.h:1211
Belle2::RelationVector::weight
float weight(int index) const
Get weight with index.
Definition: RelationVector.h:120
Belle2::TRGCDC::_perfect2DFinder
const bool _perfect2DFinder
Switch to activate perfect 2D finder.
Definition: TRGCDC.h:549
Belle2::MCParticle::getMomentum
TVector3 getMomentum() const
Return momentum.
Definition: MCParticle.h:209
Belle2::TRGCDC::_makeRootFile
bool _makeRootFile
Switch for TRGCDC.root file.
Definition: TRGCDC.h:546
Belle2::TRGClock::absoluteTime
double absoluteTime(int clockPosition) const
returns absolute time of clock position
Definition: Clock.cc:133
Belle2::TRGCDC::_rootTRGCDCFilename
std::string _rootTRGCDCFilename
The filename of root file for TRGCDC.
Definition: TRGCDC.h:561
Belle2::TRGCDC::hits
std::vector< const TRGCDCWireHit * > hits(void) const
returns a list of TRGCDCWireHit.
Definition: TRGCDC.cc:1703
Belle2::TRGCDC::clear
void clear(void)
clears all TRGCDC hit information.
Definition: TRGCDC.cc:940
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::TRGCDC::fastSimulation
void fastSimulation(void)
Fast simulation.
Definition: TRGCDC.cc:2062
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::TRGCDC::_stereoLayers
std::vector< TRGCDCLayer * > _stereoLayers
Stereo layers.
Definition: TRGCDC.h:624
Belle2::TRGCDC::terminate
void terminate(void)
terminates when run is finished
Definition: TRGCDC.cc:737
Belle2::TRGCDC::_trackList2DFitted
std::vector< TRGCDCTrack * > _trackList2DFitted
Track list for 2D fitted tracks.
Definition: TRGCDC.h:540
Belle2::TRGCDC::nAxialSuperLayers
unsigned nAxialSuperLayers(void) const
return # of axial super layers.
Definition: TRGCDC.h:892
Belle2::TRGCDC::_inefficiency
double _inefficiency
Hit inefficiency parameter.
Definition: TRGCDC.h:582
Belle2::TRGCDCWire::signal
const TRGSignal & signal(void) const override
returns an input to the trigger. This is sync'ed to 1GHz clock.
Definition: Wire.h:225
Belle2::TRGCDC::_superLayers
std::vector< std::vector< TRGCDCLayer * > * > _superLayers
Super layers.
Definition: TRGCDC.h:609
Belle2::TRGCDC::saveTRGHitInformation
void saveTRGHitInformation(std::vector< std::vector< int > > &)
Save functions for ROOT.
Definition: TRGCDC.cc:2772
Belle2::TRGDebug::leaveStage
static void leaveStage(const std::string &stageName)
Declare that you leave a stage.
Definition: Debug.cc:39
Belle2::TRGCDC::nSegments
unsigned nSegments(void) const
returns # of track segments.
Definition: TRGCDC.h:955
Belle2::TRGCDC::m_rootTRGRawInformation
TClonesArray * m_rootTRGRawInformation
[0]: iLayer, [1]: iWire, [2]: Timing(CDC), [3]: MatchNumber MatchNumber: 1: Only CDC,...
Definition: TRGCDC.h:789
Belle2::TRGDebug::enterStage
static void enterStage(const std::string &stageName)
Declare that you enter new stage.
Definition: Debug.cc:29
Belle2::TRGTime
A class to represent a signal timing in the trigger system.
Definition: Time.h:30
Belle2::TRGCDC::configure
void configure(void)
configures trigger modules for firmware simulation.
Definition: TRGCDC.cc:2448
Belle2::TRGCDC::saveTRGRawInformation
void saveTRGRawInformation(std::vector< std::string > &)
Save functions for ROOT.
Definition: TRGCDC.cc:2786
Belle2::CDCTriggerSegmentHit
Combination of several CDCHits to a track segment hit for the trigger.
Definition: CDCTriggerSegmentHit.h:16
Belle2::TRGCDCSegment::lutPattern
unsigned lutPattern(void) const
hit pattern containing bit for priority position
Definition: Segment.cc:560
Belle2::TRGCDC::axialStereoSuperLayerId
unsigned axialStereoSuperLayerId(unsigned axialStereo, unsigned axialStereoLayerId) const
returns axialStereo super layer ID. This function is expensive.
Definition: TRGCDC.cc:1863
Belle2::TRGCDC::_axialLayers
std::vector< TRGCDCLayer * > _axialLayers
Axial layers.
Definition: TRGCDC.h:621
Belle2::TRGCDCTrackSegmentFinder::doit
void doit(std::vector< TRGCDCSegment * > &tss, const bool trackSegmentClockSimulation, std::vector< TRGCDCSegmentHit * > &segmentHits, std::vector< TRGCDCSegmentHit * > *segmentHitsSL)
Member functions of doing TSF.
Definition: TrackSegmentFinder.cc:136
Belle2::TRGCDCSegment::wires
const std::vector< const TRGCDCWire * > & wires(void) const
returns a vector containing pointers to a wire.
Definition: Segment.h:191
Belle2::TRGCDCHough3DFinder::doit
void doit(std::vector< TRGCDCTrack * > const &trackList2D, std::vector< TRGCDCTrack * > &trackList3D)
Member functions.
Belle2::TRGClock
A class to represent a digitized signal. Unit is nano second.
Definition: Clock.h:43
Belle2::TRGSignalVector
A class to represent a bundle of digitized signals.
Definition: SignalVector.h:31
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226
Belle2::TRGCDC::versionCDC
std::string versionCDC(void) const
returns CDC version.
Definition: TRGCDC.h:857
Belle2::TRGSignalVector::set
const TRGSignalVector & set(const TRGState &, int clockPosition)
sets state at given clock.
Definition: SignalVector.cc:186
Belle2::TRGCDC::~TRGCDC
virtual ~TRGCDC()
Destructor.
Definition: TRGCDC.cc:2001
Belle2::TRGCDC::_tss
std::vector< TRGCDCSegment * > _tss
Track Segments.
Definition: TRGCDC.h:648
Belle2::TRGCDC::_fileETF
bool _fileETF
Switch for ETF.root file.
Definition: TRGCDC.h:588
Belle2::TRGCDC::m_mcTrackVertexVector
TClonesArray * m_mcTrackVertexVector
MC vertex.
Definition: TRGCDC.h:757
Belle2::TRGTime::reverse
TRGTime & reverse(void)
reverse edge.
Definition: Time.h:146
Belle2::TRGCDC::_firmwareSimulationStopDataClock
int _firmwareSimulationStopDataClock
Firmware simulation stop clock in CDCTRG data clock.
Definition: TRGCDC.h:531
Belle2::TRGCDC::_fFitter3Dsmclr
bool _fFitter3Dsmclr
Switch for MC L/R information in Fitter3D.
Definition: TRGCDC.h:573
Belle2::TRGCDCFitter3D::initialize
void initialize()
Initialization.
Definition: Fitter3D.cc:76
Belle2::TRGCDC::_firmwareSimulationStart
int _firmwareSimulationStart
Fimrware simulation start clock in FE.
Definition: TRGCDC.h:519
Belle2::TRGCDC::_pFinder
TRGCDCPerfectFinder * _pFinder
Perfect 2D finder.
Definition: TRGCDC.h:715
Belle2::TRGCDC::_trackList3D
std::vector< TRGCDCTrack * > _trackList3D
Track list for 3D fitted tracks.
Definition: TRGCDC.h:543
Belle2::TRGCDCSegment::LUT
const TRGCDCLUT * LUT(void) const
returns LUT
Definition: Segment.h:243
Belle2::TRGCDC::wire
const TRGCDCWire * wire(unsigned wireId) const
returns a pointer to a wire.
Definition: TRGCDC.cc:890
Belle2::TRGCDC::_trackList2D
std::vector< TRGCDCTrack * > _trackList2D
Track list by 2D finding.
Definition: TRGCDC.h:537
Belle2::RawDataBlock::GetBuffer
virtual int * GetBuffer(int n)
get nth buffer pointer
Definition: RawDataBlock.h:53