13#define TRG_SHORT_NAMES
14#define TRGCDC_SHORT_NAMES
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/TRGCDCTrack.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#include <framework/geometry/B2Vector3.h>
62#include <TObjString.h>
64#define NOT_USE_SOCKETLIB
73#include "trg/cdc/DisplayRphi.h"
74#include "trg/cdc/DisplayHough.h"
75namespace Belle2_TRGCDC {
76 Belle2::TRGCDCDisplayRphi* D = 0;
78using namespace Belle2_TRGCDC;
81#define P3D HepGeom::Point3D<double>
100 return string(
"TRGCDC 5.39");
108 unsigned simulationMode,
109 unsigned fastSimulationMode,
110 unsigned firmwareSimulationMode,
111 int firmwareSimulationStart,
112 int firmwareSimulationStop,
114 bool perfect2DFinder,
115 bool perfect3DFinder,
116 const string& innerTSLUTFile,
117 const string& outerTSLUTFile,
118 const string& rootTRGCDCFile,
119 const string& rootFitter3DFile,
120 unsigned houghFinderPeakMin,
121 const string& houghMappingFilePlus,
122 const string& houghMappingFileMinus,
127 bool fFitter3Ds2DFit,
128 bool fFitter3Ds2DFitDrift,
137 bool fXtSimpleFitter3D,
139 int trgCDCDataInputMode,
140 const string& cdchitCollectionName)
147 if (configFile !=
"good-bye") {
162 houghMappingFilePlus,
163 houghMappingFileMinus,
169 fFitter3Ds2DFitDrift,
181 cdchitCollectionName);
183 cout <<
"TRGCDC::getTRGCDC ... good-bye" << endl;
195 cout <<
"TRGCDC::getTRGCDC !!! TRGCDC is not created yet" << endl;
218 unsigned simulationMode,
219 unsigned fastSimulationMode,
220 unsigned firmwareSimulationMode,
221 int firmwareSimulationStart,
222 int firmwareSimulationStop,
224 bool perfect2DFinder,
225 bool perfect3DFinder,
226 const string& innerTSLUTFile,
227 const string& outerTSLUTFile,
228 const string& rootTRGCDCFile,
229 const string& rootFitter3DFile,
230 unsigned houghFinderPeakMin,
231 const string& houghMappingFilePlus,
232 const string& houghMappingFileMinus,
237 bool fFitter3Ds2DFit,
238 bool fFitter3Ds2DFitDrift,
247 bool fXtSimpleFitter3D,
249 int trgCDCDataInputMode,
250 const string& cdchitCollectionName):
252 _configFilename(configFile),
253 _simulationMode(simulationMode),
254 _fastSimulationMode(fastSimulationMode),
255 _firmwareSimulationMode(firmwareSimulationMode),
256 _firmwareSimulationStart(firmwareSimulationStart),
257 _firmwareSimulationStop(firmwareSimulationStop),
259 _makeRootFile(makeRootFile),
260 _perfect2DFinder(perfect2DFinder),
261 _perfect3DFinder(perfect3DFinder),
262 _innerTSLUTFilename(innerTSLUTFile),
263 _outerTSLUTFilename(outerTSLUTFile),
264 _rootTRGCDCFilename(rootTRGCDCFile),
265 _rootFitter3DFilename(rootFitter3DFile),
266 _fLogicLUTTSF(fLogicLUTTSF),
268 _fFitter3Dsmclr(fFitter3Dsmclr),
269 _fFitter3Ds2DFit(fFitter3Ds2DFit),
270 _fFitter3Ds2DFitDrift(fFitter3Ds2DFitDrift),
271 _inefficiency(inefficiency),
275 _fprintFirmETF(fprintFirmETF),
276 _fileHough3D(fileHough3D),
277 _finder3DMode(finder3DMode),
278 _fileFitter3D(fileFitter3D),
279 _fXtSimpleFitter3D(fXtSimpleFitter3D),
284 _clock(
"CDCTrigger system clock", 0, 125. / TdcBinWidth),
285 _clockFE(
"CDCFE TDC clock", _clock, 8),
286 _clockTDC(
"CDCTrigger TDC clock (after mergers)", _clock, 4),
287 _clockD(
"CDCTrigger data clock", _clock, 1, 4),
288 _clockUser3125(
"CDCTrigger Aurora user clock (3.125Gbps)",
290 _clockUser6250(
"CDCTrigger Aurora user clock (6.250Gbps)",
298 _trgCDCDataInputMode(trgCDCDataInputMode),
299 _cdchitCollectionName(cdchitCollectionName)
307 Gtk::Main main_instance(argc, argv);
309 D =
new TCDisplayRphi();
312 cout <<
"TRGCDC ... GTK initialized" << endl;
360 houghMappingFilePlus,
361 houghMappingFileMinus,
373 const string& houghMappingFilePlus,
374 const string& houghMappingFileMinus,
387 unsigned lastNWires = 0;
388 int lastShifts = -1000;
396 for (
unsigned i = 0; i <
nLayers; i++) {
405 unsigned axialStereoLayerId = 0;
408 axialStereoLayerId = ia;
411 axialStereoLayerId = is;
416 << nWiresInLayer <<
" axial: " << axial <<
" nShifts: "
421 if ((lastNWires != nWiresInLayer) || (lastShifts != nShifts)) {
434 lastNWires = nWiresInLayer;
435 lastShifts = nShifts;
440 << lastNWires <<
" " << nWiresInLayer << endl;
441 cout <<
TRGDebug::tab() <<
"(lastShifts,nShifts) " << lastShifts
442 <<
" " << nShifts << endl;
444 cout <<
"ia: " << ia <<
" is: " << is <<
" ias: " << ias
445 <<
" iss: " << iss << endl;
454 const float innerRadius = swr - (fwr - swr);
455 const float outerRadius = swr + (fwr - swr);
458 cout <<
TRGDebug::tab() <<
"lyr " << i <<
", in=" << innerRadius
459 <<
", out=" << outerRadius <<
", swr=" << swr <<
", fwr"
472 /
double(nWiresInLayer),
484 for (
unsigned j = 0; j < nWiresInLayer; j++) {
495 layer->push_back(tw);
504 const unsigned nWiresInTS[2] = {15, 11};
505 const int shape[2][30] = {
556 const int layerOffset[2] = {5, 2};
567 cout <<
"TRGCDC !!! can not create TS because "
568 <<
"#layers is less than 5 in super layer " << i
574 const TCCell& ww = *(*
_superLayers[i])[layerOffset[tsType]]->front();
579 const unsigned nWiresInLayer = ww.layer().nCells();
580 for (
unsigned j = 0; j < nWiresInLayer; j++) {
582 *(TCWire*)(*(*
_superLayers[i])[layerOffset[tsType]])[j];
584 const unsigned localId = w.localId();
585 const unsigned layerId = w.layerId();
586 vector<const TCWire*> cells;
588 for (
unsigned k = 0; k < nWiresInTS[tsType]; k++) {
589 const unsigned laid =
layerId + shape[tsType][k * 2];
590 const unsigned loid =
localId + shape[tsType][k * 2 + 1];
592 const TCWire* c =
wire(laid, loid);
594 cout <<
"TRGCDC !!! no such a wire for TS : "
595 <<
"layer id=" << laid <<
", local id=" << loid
602 if (w.superLayerId()) {
621 _tsSL[i].push_back(ts);
622 layer->push_back(ts);
628 if (
_r)
delete []
_r;
635 _width[i] = M_PI * 2 / float(slayer.back()->nCells());
636 _r[i] = slayer[0]->innerRadius();
639 _r[i + 1] = slayer.back()->outerRadius();
640 _r2[i + 1] =
_r[i + 1] *
_r[i + 1];
644 const TCCell& wi = *slayer[0]->front();
645 const unsigned layerId = wi.layerId();
648 cout <<
" super layer " << i <<
" radius=" <<
_r[i]
649 <<
"(r^2=" <<
_r2[i] <<
")" << endl;
657 _pFinder =
new TCPFinder(
"Perfect2DFinder", *
this);
663 _hFinder =
new TCHFinder(
"HoughFinder",
666 houghMappingFilePlus,
667 houghMappingFileMinus,
674 map<string, bool> flags = {
695 m_tree =
new TTree(
"m_tree",
"tree");
711 m_evtTime =
new TClonesArray(
"TVectorD");
714 _tree2D =
new TTree(
"tree2D",
"2D Tracks");
715 _tracks2D =
new TClonesArray(
"TVectorD");
771 if (msg.find(
"name") != string::npos ||
772 msg.find(
"version") != string::npos ||
773 msg.find(
"detail") != string::npos ||
778 if (msg.find(
"detail") != string::npos ||
779 msg.find(
"state") != string::npos) {
786 if (msg ==
"" || msg.find(
"geometry") != string::npos) {
788 unsigned nLayer =
_layers.size();
789 cout <<
" version : " <<
version() << endl;
790 cout <<
" cdc version: " <<
versionCDC() << endl;
791 cout <<
" # of wires : " <<
_wires.size() << endl;
792 cout <<
" # of layers: " << nLayer << endl;
793 cout <<
" super layer information" << endl;
794 cout <<
" # of super layers() = "
796 cout <<
" # of Axial super layers = "
798 cout <<
" # of Stereo super layers = "
801 if (msg.find(
"superLayers") != string::npos) {
802 cout <<
" super layer detail" << endl;
803 cout <<
" id #layers (stereo type)" << endl;
806 cout <<
" " << i <<
" " << n <<
" (";
807 for (
unsigned j = 0; j < n; j++) {
814 cout <<
" layer information" << endl;
815 cout <<
" # of Axial layers = "
817 cout <<
" # of Stereo layers = "
820 if (msg.find(
"layers") != string::npos) {
821 cout <<
" layer detail" << endl;
822 cout <<
" id type sId #wires lId asId assId"
824 for (
unsigned int i = 0; i <
nLayers(); ++i) {
837 if (msg.find(
"wires") != string::npos) {
838 cout <<
" wire information" << endl;
839 for (
unsigned i = 0; i <
nWires(); i++)
840 (
_wires[i])->dump(
"neighbor", tab);
845 if (msg.find(
"hits") != string::npos) {
846 cout <<
" hits : " <<
_hits.size() << endl;
847 for (
unsigned i = 0; i < (unsigned)
_hits.size(); i++)
850 if (msg.find(
"axialHits") != string::npos) {
851 cout <<
" hits : " <<
_axialHits.size() << endl;
852 for (
unsigned i = 0; i < (unsigned)
_axialHits.size(); i++)
855 if (msg.find(
"stereoHits") != string::npos) {
857 for (
unsigned i = 0; i < (unsigned)
_stereoHits.size(); i++)
860 if (msg.find(
"trgWireHits") != string::npos) {
861 const string dumpOption =
"trigger detail";
862 cout <<
" wire hits" << endl;
863 for (
unsigned i = 0; i <
nWires(); i++) {
864 const TCWire& w = *
wire(i);
865 if (w.signal().active())
869 if (msg.find(
"trgWireCentralHits") != string::npos) {
870 const string dumpOption =
"trigger detail";
871 cout <<
" wire hits" << endl;
872 for (
unsigned i = 0; i <
nSegments(); i++) {
873 const TCSegment& s =
segment(i);
874 if (s.wires()[5]->signal().active())
878 if (msg.find(
"trgTSHits") != string::npos) {
879 const string dumpOption =
"trigger detail";
880 cout <<
" TS hits" << endl;
881 for (
unsigned i = 0; i <
nSegments(); i++) {
882 const TCSegment& s =
segment(i);
883 if (s.signal().active())
952 for (
unsigned i = 0; i <
_hitsMC.size(); i++)
959 for (
unsigned i = 0; i <
_wires.size(); i++) {
963 for (
unsigned i = 0; i <
_tss.size(); i++) {
964 TCSegment* s =
_tss[i];
974 for (
unsigned i = 0; i < 9; i++)
1004 cout <<
"TRGCDC !!! can not access to CDCSimHits" << endl;
1014 cout <<
"TRGCDC !!! can not access to CDCHits" << endl;
1018 const unsigned nHits = CDCHits.getEntries();
1022 if (! mcParticles) {
1024 cout <<
"TRGCDC !!! can not access to MCParticles" << endl;
1033 const unsigned nRelsMC = relsMC.
getEntries();
1036 for (
unsigned i = 0; i < nHits; i++) {
1037 const CDCHit& h = *CDCHits[i];
1038 double tmp = gRandom->Uniform(0.0, 1.0) / (double(RAND_MAX));
1046 unsigned iSimHit = 0;
1047 for (
unsigned j = 0; j < nRels; j++) {
1048 const unsigned k = rels[j].getToIndices().size();
1049 for (
unsigned l = 0; l < k; l++) {
1050 if (rels[j].getToIndex(l) == i)
1051 iSimHit = rels[j].getFromIndex();
1056 cout <<
"TRGCDC::update !!! CDCSimHit[" << iSimHit
1057 <<
"] has multiple CDCHit(" << k <<
" hits)" << endl;
1062 unsigned iMCPart = 0;
1063 for (
unsigned j = 0; j < nRelsMC; j++) {
1064 const unsigned k = relsMC[j].getToIndices().size();
1065 for (
unsigned l = 0; l < k; l++) {
1066 if (relsMC[j].getToIndex(l) == i) {
1067 iMCPart = relsMC[j].getFromIndex();
1074 cout <<
"TRGCDC::update !!! MCParticle[" << iMCPart
1075 <<
"] has multiple CDCHit(" << k <<
" hits)" << endl;
1080 if (h.getISuperLayer() == 0) t_layerId = h.getILayer();
1081 else t_layerId = h.getILayer() + 6 * h.getISuperLayer() + 2;
1082 const unsigned layerId = t_layerId;
1083 const unsigned wireId = h.getIWire();
1084 const TCWire& w = *
static_cast<const TCWire*
>(
wire(
layerId, wireId));
1089 "tdc count:" << h.getTDCCount());
1091 - h.getTDCCount() + 0.5);
1095 const float driftLengthError = 0.013;
1107 w._signal.name(w.name());
1110 const int LRflag = SimHits[iSimHit]->getPosFlag();
1113 TCWHit* hit =
new TCWHit(w,
1123 hit->state(CellHitFindingValid | CellHitFittingValid);
1128 _hits.push_back(hit);
1136 << h.getTDCCount() << std::endl;
1147 cout <<
TRGDebug::tab() <<
"#CDCSimHit=" << n <<
",#CDCHit="
1156 for (
unsigned i = 0; i <
_hits.size(); i++) {
1157 const TCWHit& h = *
_hits[i];
1164 <<
" hits of a wire" << endl;
1165 for (
unsigned i = 0; i < n; i++) {
1166 const TCWHit& h = *
_hits[i];
1189 int nCDCWindows = 28 + 1;
1198 unsigned nTRGWindows = 48;
1199 int nTrgBitsInWindow = 352;
1201 vector<string> trgInformations;
1205 vector<vector<unsigned> > inBinaryData;
1207 if (inputMode == 1) {
1209 int nCdcBitsInWindow = 1536;
1222 int* temp_buf = raw_datablkarray[ iBlock ]->GetBuffer(iCopper);
1223 int nwords = raw_datablkarray[ iBlock ]->GetBlockNwords(iCopper);
1224 int malloc_flag = 0;
1229 raw_copper_buf.
SetBuffer(temp_buf, nwords, malloc_flag, num_nodes, num_events);
1230 raw_copper = &raw_copper_buf;
1256 int widthCDCFEData = 3 - 1 + nCdcBitsInWindow / 32 * nCDCWindows;
1257 int widthTRGData = nTrgBitsInWindow / 32 * nTRGWindows;
1262 vector<vector<unsigned> > rawBinaryData;
1263 for (
int iFe = 0; iFe < 2; iFe++) {
1264 int startCDCData = daqHeader + cdcHeader + (iFe * (widthCDCFEData + cdcTrailer + cdcHeader)) + 1;
1266 vector<unsigned> t_feData(widthCDCFEData + 1);
1268 for (
int iWord = 0; iWord < widthCDCFEData; iWord++) {
1269 t_feData[iWord] = (raw_copper->
GetBuffer(iCopper))[iWord + startCDCData];
1272 t_feData[widthCDCFEData] = 0;
1273 rawBinaryData.push_back(t_feData);
1275 vector<unsigned> t_trgData(widthTRGData);
1277 int startTRGData = daqHeader + 2 * (cdcHeader + widthCDCFEData + cdcTrailer) + trgHeader + 1;
1278 for (
int iWord = 0; iWord < widthTRGData; iWord++) {
1279 t_trgData[iWord] = (raw_copper->
GetBuffer(iCopper))[iWord + startTRGData];
1281 rawBinaryData.push_back(t_trgData);
1292 for (
unsigned iBoard = 0; iBoard < 2; iBoard++) {
1295 vector<unsigned> t_feData(widthCDCFEData + 1);
1296 for (
unsigned iWord = 0; iWord < rawBinaryData[iBoard].size(); iWord++) {
1297 unsigned t_value = t_buf + (rawBinaryData[iBoard][iWord] >> 8);
1298 t_buf = rawBinaryData[iBoard][iWord] << 24;
1299 t_feData[iWord] = t_value;
1301 inBinaryData.push_back(t_feData);
1303 inBinaryData.push_back(rawBinaryData[2]);
1312 }
else if (inputMode == 2) {
1315 for (
int i = 0; i < raw_trgarray.
getEntries(); i++) {
1316 cout <<
"\n===== DataBlock(RawTRG) : Block # " << i << endl;
1317 for (
int j = 0; j < raw_trgarray[ i ]->GetNumEntries(); j++) {
1318 RawCOPPER* raw_copper = raw_trgarray[ i ];
1319 vector<vector<unsigned> > rawBinaryData;
1321 for (
int iFinesse = 0; iFinesse < 4; iFinesse++) {
1323 if (bufferNwords > 0) {
1324 printf(
"===== Detector Buffer(FINESSE # %i) 0x%x words \n", iFinesse, bufferNwords);
1327 for (
int iWord = 0; iWord < bufferNwords; iWord++) {
1330 rawBinaryData.push_back(t_copperData);
1331 inBinaryData.push_back(t_copperData);
1347 cout <<
"[ERROR} TRGCDCDataInputMode is incorrect! No simulation will be done." << endl;
1354 vector<unsigned> cdcTrgTiming(2);
1355 for (
unsigned iFe = 0; iFe < 2; iFe++) {
1356 cdcTrgTiming[iFe] = (inBinaryData[iFe][1]) >> 16;
1357 if (cdcTrgTiming[iFe] >= 32768) cout <<
"CDC trigger timing error. TDC is larger than 0x8000" << endl;
1364 vector<vector<unsigned>> hitCdcData;
1366 for (
int iWindow = 0; iWindow < nCDCWindows; iWindow++) {
1367 for (
int iFE = 0; iFE < 2; iFE++) {
1368 for (
int iWire = 0; iWire < 48; iWire++) {
1371 unsigned t_layerId = 3 * iFE + ((iWire / 8) % 3);
1372 unsigned t_wireId = 8 * (iWire / 24) + iWire % 8;
1374 t_adc = ((inBinaryData[iFE][iWire / 2 + iWindow * 48 + 3] << (16 * (iWire % 2))) >> 16);
1375 t_tdc = ((inBinaryData[iFE][iWire / 2 + iWindow * 48 + 24 + 3] << (16 * (iWire % 2))) >> 16);
1377 if (t_tdc >= 32768) {
1381 unsigned startTiming;
1382 if (
unsigned(cdcTrgTiming[iFE] / 32) * 32 > (unsigned)(cdcDelay + nCDCWindows) * 32) {
1383 startTiming = unsigned(cdcTrgTiming[iFE] / 32) * 32 - (cdcDelay + nCDCWindows) * 32;
1385 startTiming = unsigned(cdcTrgTiming[iFE] / 32) * 32 + 32768 - (cdcDelay + nCDCWindows) * 32;
1387 if (t_tdc > startTiming) t_tdc -= startTiming;
1388 else t_tdc += 32768 - startTiming;
1390 vector<unsigned> t_hitCdcData(5);
1391 t_hitCdcData[0] = t_layerId;
1392 t_hitCdcData[1] = t_wireId;
1393 t_hitCdcData[2] = t_adc;
1394 t_hitCdcData[3] = t_tdc;
1395 t_hitCdcData[4] = cdcTrgTiming[iFE];
1396 hitCdcData.push_back(t_hitCdcData);
1398 cout <<
"CDC TDC data error. TDC is smaller than 0x8000. " << hex << t_tdc << dec << endl;
1411 stringstream t_trgWindow;
1412 for (
unsigned iWord = 0; iWord < inBinaryData[2].size(); iWord++) {
1413 t_trgWindow << setw(8) << setfill(
'0') << hex << inBinaryData[2][iWord];
1414 if (iWord % 11 == 10) {
1415 trgInformations.push_back(t_trgWindow.str());
1416 t_trgWindow.str(
"");
1422 vector<vector<int> > hitTrgData;
1423 for (
unsigned iWindow = 0; iWindow < nTRGWindows; iWindow++) {
1425 vector<unsigned> t_trgData(inBinaryData[2].begin() + 11 * iWindow, inBinaryData[2].begin() + 11 * iWindow + 11);
1440 for (
unsigned iWire = 0; iWire < t_hitMap.
size(); iWire++) {
1441 unsigned t_layerId = iWire / 16;
1442 unsigned t_wireId = iWire % 16;
1443 if (t_hitMap[iWire] == 1) {
1444 vector<int> t_hitTrgData(4);
1445 t_hitTrgData[0] = t_layerId;
1446 t_hitTrgData[1] = t_wireId;
1447 t_hitTrgData[2] = iWindow;
1449 if (t_layerId == 2) {
1450 t_hitTrgData[3] = (unsigned)t_priorityTiming.
subset(4 * t_wireId, 4);
1452 }
else if (t_layerId == 3) {
1458 if (t_wireId != 15) {
1459 t_priorityHits = t_priorityMap.
subset(t_wireId, 2);
1460 t_secondaryLR = t_secondHitFlag.
subset(t_wireId, 2);
1461 t_leftInformation.
set(1, t_priorityMap.
subset(t_wireId + 1, 1));
1462 t_leftInformation.
set(0, t_secondHitFlag.
subset(t_wireId + 1, 1));
1463 t_rightInformation.
set(1, t_priorityMap.
subset(t_wireId, 1));
1464 t_rightInformation.
set(0, t_secondHitFlag.
subset(t_wireId, 1));
1466 t_priorityHits.
set(0, t_priorityMap.
subset(t_wireId, 1));
1467 t_priorityHits.
set(1, 0);
1468 t_secondaryLR.
set(0, t_secondHitFlag.
subset(t_wireId, 1));
1469 t_secondaryLR.
set(1, 0);
1470 t_leftInformation.
set(1, 1);
1471 t_leftInformation.
set(0, 0);
1472 t_rightInformation.
set(1, t_priorityMap.
subset(t_wireId, 1));
1473 t_rightInformation.
set(0, t_secondHitFlag.
subset(t_wireId, 1));
1479 int secondaryFlag = -1;
1480 if ((
unsigned)t_leftInformation == (
unsigned)
TRGState(
"00", 0)) secondaryFlag = 0;
1481 if ((
unsigned)t_leftInformation == (
unsigned)
TRGState(
"01", 0)) secondaryFlag = 1;
1483 if (secondaryFlag != -1) {
1484 if (t_wireId + (1 - secondaryFlag) < 16) {
1486 unsigned t_secondaryTiming = (unsigned)t_priorityTiming.
subset(4 * (t_wireId + (1 - secondaryFlag)), 4);
1487 t_hitTrgData[3] = t_secondaryTiming;
1490 cout <<
"Error in TRGDATA for secondary priority hits" << endl;
1494 t_hitTrgData[3] = -1;
1498 t_hitTrgData[3] = -1;
1500 hitTrgData.push_back(t_hitTrgData);
1529 const int trgOutput = 2;
1539 trgData =
new TRGSignalVector(
string(
"TRGData"), dClock, nTrgBitsInWindow);
1541 for (
unsigned iWindow = 0; iWindow < nTRGWindows; iWindow++) {
1542 vector<unsigned> t_trgData(inBinaryData[2].begin() + 11 * iWindow, inBinaryData[2].begin() + 11 * iWindow + 11);
1544 trgData->
set(t_trgState, iWindow);
1547 allTrgData->push_back(trgData);
1549 for (
unsigned i = 0; i < allTrgData->size(); i++)
delete (*allTrgData)[i];
1559 if (trgOutput == 2) {
1566 for (
unsigned iHit = 0; iHit < hitCdcData.size(); iHit++) {
1567 unsigned t_layerId = hitCdcData[iHit][0] + 50;
1568 unsigned t_wireId = hitCdcData[iHit][1];
1569 int t_rawTdc = hitCdcData[iHit][2];
1570 const TCWire& currentWire = *
static_cast<const TCWire*
>(
wire(t_layerId, t_wireId));
1576 if (currentWire._signal.active()) {
1577 currentWire._signal = currentWire.signal() |
TRGSignal(rise & fall);
1578 currentWire._signal.name(currentWire.name());
1580 currentWire._signal =
TRGSignal(rise & fall);
1581 currentWire._signal.name(currentWire.name());
1585 TCWHit* hit =
new TCWHit(currentWire, 0, 0, 0, t_rawTdc, 0, t_rawTdc, 0, 0, 1);
1586 hit->state(CellHitFindingValid | CellHitFittingValid);
1587 ((TCWire*)(*
_layers[t_layerId])[t_wireId])->hit(hit);
1588 _hits.push_back(hit);
1589 if (currentWire.axial())
_axialHits.push_back(hit);
1608 unsigned n =
_hits.size();
1610 for (
unsigned i = 0; i < n; i++) {
1611 TCWHit* h =
_hits[i];
1612 const TCWire& w = h->wire();
1613 unsigned state = h->state();
1617 for (
unsigned j = 0; j < 7; j++)
neighbor[j] = w.neighbor(j);
1620 unsigned pattern = 0;
1621 for (
unsigned j = 0; j < 7; j++) {
1624 pattern += (1 << j);
1626 state |= (pattern << CellHitNeighborHit);
1629 const TCWHit* hr1 =
neighbor[2]->hit();
1630 const TCWHit* hl1 =
neighbor[3]->hit();
1631 if ((hr1 == 0) && (hl1 == 0)) {
1632 state |= CellHitIsolated;
1634 const TCWHit* hr2 =
neighbor[2]->neighbor(2)->hit();
1635 const TCWHit* hl2 =
neighbor[3]->neighbor(3)->hit();
1636 if (((hr2 == 0) && (hr1 != 0) && (hl1 == 0)) ||
1637 ((hl2 == 0) && (hl1 != 0) && (hr1 == 0)))
1638 state |= CellHitIsolated;
1643 bool previous =
false;
1645 if (
neighbor[0] == 0) previous =
true;
1659 if (previous || next) state |= CellHitContinuous;
1662 if ((pattern == 34) || (pattern == 42) ||
1663 (pattern == 40) || (pattern == 10) ||
1664 (pattern == 35) || (pattern == 50))
1665 state |= CellHitPatternRight;
1666 else if ((pattern == 17) || (pattern == 21) ||
1667 (pattern == 20) || (pattern == 5) ||
1668 (pattern == 19) || (pattern == 49))
1669 state |= CellHitPatternLeft;
1678 vector<const TCWHit*>
1681 vector<const TCWHit*> t;
1691 vector<const TCWHit*>
1694 vector<const TCWHit*> t;
1704 vector<const TCWHit*>
1707 vector<const TCWHit*> t;
1750 vector<const TCWHitMC*>
1753 vector<const TCWHitMC*> t;
1762 const TCWire*
const w =
wire(wireId);
1767 return "invalid_wire(" + TRGUtil::itostring(wireId) +
")";
1769 return TRGUtil::itostring(
layerId(wireId)) + as + TRGUtil::itostring(
localId(wireId));
1775 cout <<
"TRGCDC::localId !!! this function is not tested yet"
1777 unsigned iLayer = 0;
1779 bool nextLayer =
true;
1781 unsigned nWLast = nW;
1788 cout <<
"TRGCDC::localId !!! no such a wire (id=" <<
id << endl;
1789 return TRGCDC_UNDEFINED;
1795 cout <<
"TRGCDC::layerId !!! this function is not tested yet"
1797 unsigned iLayer = 0;
1799 bool nextLayer =
true;
1807 cout <<
"TRGCDC::layerId !!! no such a wire (id=" <<
id << endl;
1808 return TRGCDC_UNDEFINED;
1814 cout <<
"TRGCDC::layerId !!! this function is not implemented yet"
1816 return TRGCDC_UNDEFINED;
1822 unsigned iLayer = 0;
1824 bool nextLayer =
true;
1826 const vector<TRGCDCLayer*>& sl = *
superLayer(iLayer);
1827 const unsigned nLayers = sl.size();
1828 for (
unsigned i = 0; i <
nLayers; i++)
1829 nW += sl[i]->nCells();
1836 cout <<
"TRGCDC::superLayerId !!! no such a wire (id=" <<
id
1838 return TRGCDC_UNDEFINED;
1844 unsigned iLayer = 0;
1846 bool nextLayer =
true;
1848 const vector<TRGCDCLayer*>& sl = *
superLayer(iLayer);
1849 const unsigned nLayers = sl.size();
1850 for (
unsigned i = 0; i <
nLayers; i++) {
1851 nW += sl[i]->nCells();
1859 cout <<
"TRGCDC::localLayerId !!! no such a wire (id=" <<
id
1861 return TRGCDC_UNDEFINED;
1872 }
else if (i <= 13) {
1874 }
else if (i <= 19) {
1876 }
else if (i <= 25) {
1878 }
else if (i <= 31) {
1881 }
else if (aors == 1) {
1884 }
else if (i <= 11) {
1886 }
else if (i <= 17) {
1888 }
else if (i <= 23) {
2020#ifdef TRGCDC_DISPLAY
2023 cout <<
"TRGCDC ... rphi displays deleted" << endl;
2032 const int lyr0 = w0.layerId();
2033 const int lyr1 = w1.layerId();
2034 const int lyr = lyr0 - lyr1;
2036 if (abs(lyr) > 1)
return false;
2037 if (w0.superLayerId() != w1.superLayerId())
return false;
2039 for (
unsigned i = 0; i < 7; i++) {
2040 if (w0.neighbor(i)) {
2041 if (w0.neighbor(i)->id() == w1.id())
2068#ifdef TRGCDC_DISPLAY
2069 D->beginningOfEvent();
2078 trackSegmentClockSimulation,
2085 if (trackSegmentSimulationOnly) {
2090#ifdef TRGCDC_DISPLAY
2092 string stg =
"fast simulation results";
2096 D->information(inf);
2097 D->area().append(
hits());
2119 cout <<
"> links=" << t.links().size() << endl;
2144 int t_debugValue = 0;
2145 for (
unsigned iTrack = 0; iTrack <
_trackList3D.size(); iTrack++) {
2146 t_debugValue |=
_trackList3D[iTrack]->getDebugValue(TRGCDCTrack::EDebugValueType::any);
2157 for (
unsigned iTrack = 0; iTrack <
_trackList3D.size(); iTrack++) {
2159 if (aTrack.fitted()) {
2160 double fitPt = aTrack.pt();
2161 double fitPhi0 = aTrack.helix().phi0();
2162 int fitCharge = aTrack.charge();
2163 if (fitCharge < 0) {
2165 if (fitPhi0 < 0) fitPhi0 += 2 * M_PI;
2167 double fitZ0 = aTrack.helix().dz();
2168 double fitCot = aTrack.helix().tanl();
2169 cout <<
TRGDebug::tab() <<
"Track[" << iTrack <<
"]: charge=" << fitCharge
2170 <<
" pt=" << fitPt <<
" phi_c=" << fitPhi0
2171 <<
" z0=" << fitZ0 <<
" cot=" << fitCot << endl;
2172 const TCRelation& trackRelation = aTrack.relation();
2173 const MCParticle& trackMCParticle = trackRelation.mcParticle(0);
2174 int mcCharge = trackMCParticle.
getCharge();
2175 double mcPt = trackMCParticle.
getMomentum().Rho();
2176 double mcPhi0 = 0.0;
2177 if (mcCharge > 0) mcPhi0 = trackMCParticle.
getMomentum().Phi() - M_PI / 2;
2178 if (mcCharge < 0) mcPhi0 = trackMCParticle.
getMomentum().Phi() + M_PI / 2;
2180 if (mcPhi0 < 0) mcPhi0 += 2 * M_PI;
2182 ROOT::Math::XYZVector vertex = trackMCParticle.
getVertex();
2183 ROOT::Math::PxPyPzEVector vector4 = trackMCParticle.
get4Vector();
2184 ROOT::Math::XYVector helixCenter;
2185 ROOT::Math::XYZVector impactPosition;
2187 double mcZ0 = impactPosition.Z();
2189 cout <<
TRGDebug::tab() <<
"Track[" << iTrack <<
"]: mcCharge=" << mcCharge
2190 <<
" mcPt=" << mcPt <<
" mcPhi_c=" << mcPhi0
2191 <<
" mcZ0=" << mcZ0 <<
" mcCot=" << mcCot << endl;
2205#ifdef TRGCDC_DISPLAY
2207 vector<const TCTrack*> t2;
2209 vector<const TCTrack*> t2f;
2211 vector<const TCTrack*> t3;
2214 stg =
"fast simulation results";
2215 inf =
"red:2D, blue:2DF, green:3D";
2218 D->information(inf);
2219 D->area().append(
hits());
2221 D->area().append(t2, Gdk::Color(
"red"));
2222 D->area().append(t2f, Gdk::Color(
"blue"));
2223 D->area().append(t3, Gdk::Color(
"green"));
2249 string collection2Dfitter,
2250 string collection3Dfitter)
2258 for (
unsigned its = 0; its <
_segmentHits.size(); ++its) {
2260 const CDCHit* priorityHit = cdcHits[segmentHit->iCDCHit()];
2261 const TCSegment*
segment =
static_cast<const TCSegment*
>(&segmentHit->cell());
2263 storeSegmentHits.
appendNew(*priorityHit,
2272 for (
unsigned iw = 0; iw <
segment->
wires().size(); ++iw) {
2282 for (
unsigned imc = 0; imc < mcrel.
size(); ++imc) {
2283 mcrel[imc]->addRelationTo(storeHit, mcrel.
weight(imc));
2292 for (
unsigned itr = 0; itr <
_trackList2D.size(); ++itr) {
2294 double phi0 = remainder(track2D->helix().phi0() + M_PI_2, 2. * M_PI);
2295 double omega = track2D->charge() / track2D->helix().radius();
2297 storeTracks2Dfinder.
appendNew(phi0, omega, 0.);
2299 vector<TRGCDCLink*> links = track2D->links();
2300 for (
unsigned its = 0; its < links.size(); ++its) {
2302 const vector<const CDCTriggerSegmentHit*> storeHits =
segment->
storeHits();
2303 for (
unsigned ihit = 0; ihit < storeHits.size(); ++ihit) {
2304 track->addRelationTo(storeHits[ihit]);
2312 if (!track2D->fitted())
continue;
2313 double phi0 = remainder(track2D->helix().phi0() + M_PI_2, 2. * M_PI);
2314 double omega = track2D->charge() / track2D->helix().radius();
2315 double chi2 = track2D->get2DFitChi2();
2317 storeTracks2Dfitter.
appendNew(phi0, omega, chi2);
2319 vector<TRGCDCLink*> links = track2D->links();
2320 for (
unsigned its = 0; its < links.size(); ++its) {
2322 const vector<const CDCTriggerSegmentHit*> storeHits =
segment->
storeHits();
2323 for (
unsigned ihit = 0; ihit < storeHits.size(); ++ihit) {
2324 track->addRelationTo(storeHits[ihit]);
2329 storeTracks2Dfinder[itr]->addRelationTo(track);
2333 for (
unsigned itr = 0; itr <
_trackList3D.size(); ++itr) {
2335 if (!track3D->fitted())
continue;
2336 double phi0 = remainder(track3D->helix().phi0() + M_PI_2, 2. * M_PI);
2337 double omega = 1. / track3D->helix().radius();
2338 double chi2 = track3D->get2DFitChi2();
2339 double z = track3D->helix().dz();
2340 double cot = track3D->helix().tanl();
2341 double chi3 = track3D->get3DFitChi2();
2343 storeTracks3Dfitter.
appendNew(phi0, omega, chi2, z, cot, chi3);
2345 vector<TRGCDCLink*> links = track3D->links();
2346 for (
unsigned its = 0; its < links.size(); ++its) {
2348 const vector<const CDCTriggerSegmentHit*> storeHits =
segment->
storeHits();
2349 for (
unsigned ihit = 0; ihit < storeHits.size(); ++ihit) {
2350 track->addRelationTo(storeHits[ihit]);
2355 storeTracks2Dfinder[itr]->addRelationTo(track);
2365#ifdef TRGCDC_DISPLAY
2366 D->beginningOfEvent();
2374 const unsigned nFronts =
_fronts.size();
2375 for (
unsigned i = 0; i < nFronts; i++) {
2385 const unsigned nMergers =
_mergers.size();
2386 for (
unsigned i = 0; i < nMergers; i++) {
2391 const unsigned nTSFBoards =
_tsfboards.size();
2392 for (
unsigned i = 0; i < nTSFBoards; i++) {
2400 int t_eventTime =
_eventTime.back()->getT0();
2404 for (
unsigned iHits = 0; iHits <
_hits.size(); iHits++) {
2406 _hits[iHits]->setDriftTime((
_hits[iHits]->drift(0) - t_eventTime) / 250, 0);
2407 _hits[iHits]->setDriftTime((
_hits[iHits]->drift(1) - t_eventTime) / 250, 1);
2414 for (
unsigned i = 0; i < nTracker2Ds; i++) {
2418#ifdef TRGCDC_DISPLAY
2421 string stg =
"Firmware simulation";
2425 D->information(inf);
2426 D->area().append(
hits());
2456 if (infile.fail()) {
2457 cout <<
"TRGCDC !!! can not open file" << endl
2465 unsigned lastSl = 0;
2466 unsigned lastMergerLocalId = 0;
2467 while (! infile.eof()) {
2468 infile.getline(b, 800);
2479 if (lid != 0) mid = lid + tid;
2480 for (
unsigned i = 0; i < 5; i++) {
2481 const string car = TRGUtil::carstring(cdr);
2482 cdr = TRGUtil::cdrstring(cdr);
2487 }
else if (car ==
"CDC") {
2493 wid = atoi(car.c_str());
2494 }
else if (i == 1) {
2495 lid = atoi(car.c_str());
2496 }
else if (i == 2) {
2497 fid = atoi(car.c_str());
2498 }
else if (i == 3) {
2499 mid = atoi(car.c_str());
2500 }
else if (i == 4) {
2501 tid = atoi(car.c_str());
2511 const unsigned sl =
_wires[wid]->superLayerId();
2513 lastMergerLocalId = 0;
2516 bool newFrontEnd =
false;
2522 const string name =
"CDCFrontEnd" + TRGUtil::itostring(fid);
2523 TCFrontEnd::boardType t;
2526 t = TCFrontEnd::innerInside;
2528 t = TCFrontEnd::innerOutside;
2531 t = TCFrontEnd::outerInside;
2533 t = TCFrontEnd::outerOutside;
2539 f->push_back(
_wires[wid]);
2547 bool newMerger =
false;
2548 TCMerger* m =
nullptr;
2555 const string name =
"CDCMerger" + TRGUtil::itostring(sl) +
2556 "-" + TRGUtil::itostring(lastMergerLocalId);
2557 TCMerger::unitType mt;
2559 mt = TCMerger::innerType;
2561 mt = TCMerger::outerType;
2562 m =
new TCMerger(
name,
2569 ++lastMergerLocalId;
2578 const string n = f->name() + string(
"-") + m->name();
2580 f->appendOutput(ch);
2592 const string name =
"CDCTSFBoard" + TRGUtil::itostring(tid);
2593 TSFinder::boardType tt;
2595 tt = TSFinder::innerType;
2597 tt = TSFinder::outerType;
2598 t =
new TSFinder(*
this,
2612 const string n = m->name() + string(
"-") + t->name();
2614 m->appendOutput(chmt);
2615 t->appendInput(chmt);
2624 for (
unsigned i = 0; i < 4; i++) {
2625 const string name =
"CDC2DBoard" + TRGUtil::itostring(i);
2626 TCTracker2D* t =
new TCTracker2D(
name,
2632 for (
unsigned j = 0; j < 9; j++) {
2634 const string n = tsf->name() + string(
"-") + t->name();
2636 tsf->appendOutput(ch);
2639 const string n = t->name() + string(
"-") +
"CDC3DBoard" + TRGUtil::itostring(i);
2642 t->appendOutput(ch);
2648 for (
unsigned i = 0; i <
_tsfboards.size(); i++) {
2652 cout <<
TRGDebug::tab() <<
"Tracker2D configuration" << endl;
2653 for (
unsigned i = 0; i <
_tracker2Ds.size(); i++) {
2763 rootCDCHitInformation.Clear();
2764 for (
unsigned iHit = 0; iHit < hitWiresFromCDC.size(); iHit++) {
2765 TVectorD t_rootCDCHitInformation(5);
2766 t_rootCDCHitInformation[0] = hitWiresFromCDC[iHit][0];
2767 t_rootCDCHitInformation[1] = hitWiresFromCDC[iHit][1];
2768 t_rootCDCHitInformation[2] = hitWiresFromCDC[iHit][2];
2769 t_rootCDCHitInformation[3] = hitWiresFromCDC[iHit][3];
2770 t_rootCDCHitInformation[4] = hitWiresFromCDC[iHit][4];
2771 new (rootCDCHitInformation[iHit]) TVectorD(t_rootCDCHitInformation);
2778 rootTRGHitInformation.Clear();
2779 for (
unsigned iHit = 0; iHit < hitWiresFromTRG.size(); iHit++) {
2780 TVectorD t_rootTRGHitInformation(4);
2781 t_rootTRGHitInformation[0] = hitWiresFromTRG[iHit][0];
2782 t_rootTRGHitInformation[1] = hitWiresFromTRG[iHit][1];
2783 t_rootTRGHitInformation[2] = hitWiresFromTRG[iHit][2];
2784 t_rootTRGHitInformation[3] = hitWiresFromTRG[iHit][3];
2785 new (rootTRGHitInformation[iHit]) TVectorD(t_rootTRGHitInformation);
2792 rootTRGRawInformation.Clear();
2793 for (
unsigned iWindow = 0; iWindow < trgInformations.size(); iWindow++) {
2794 TObjString t_rootTRGRawInformation;
2795 t_rootTRGRawInformation.SetString(trgInformations[iWindow].c_str());
2796 new (rootTRGRawInformation[iWindow]) TObjString(t_rootTRGRawInformation);
DataType y() const
access variable Y (= .at(1) without boundary check)
DataType z() const
access variable Z (= .at(2) without boundary check)
DataType x() const
access variable X (= .at(0) without boundary check)
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Combination of several CDCHits to a track segment hit for the trigger.
This class is the interface between TSim/basf2 TSF module and the firmware simulation core of XSim/IS...
Track created by the CDC trigger.
int nShifts(int layerId) const
Returns number shift.
double fieldWireR(int layerId) const
Returns radius of field wire in each layer.
const B2Vector3D wireForwardPosition(uint layerId, int cellId, EWirePosition set=c_Base) const
Returns the forward position of the input sense wire.
const B2Vector3D wireBackwardPosition(uint layerId, int cellId, EWirePosition set=c_Base) const
Returns the backward position of the input sense wire.
double getTdcBinWidth() const
Return TDC bin width (nsec).
float getT0(const WireID &wireID) const
Returns t0 parameter of the specified sense wire.
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
double getNominalDriftV() const
Return the nominal drift velocity of He-ethane gas (default: 4.0x10^-3 cm/nsec).
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
unsigned nWireLayers() const
Returns a number of wire layers.
double senseWireR(int layerId) const
Returns radius of sense wire in each layer.
double zOffsetWireLayer(unsigned i) const
Returns the offset of z of the wire layer i.
A Class to store the Monte Carlo particle information.
ROOT::Math::XYZVector getVertex() const
Return production vertex position, shorthand for getProductionVertex().
float getCharge() const
Return the particle charge defined in TDatabasePDG.
ROOT::Math::PxPyPzEVector get4Vector() const
Return 4Vector of particle.
ROOT::Math::XYZVector getMomentum() const
Return momentum.
The Raw COPPER class This class stores data received by COPPER via belle2linkt Data from all detector...
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 )
virtual int * GetBuffer(int n)
get nth buffer pointer
Low-level class to create/modify relations between StoreArrays.
int getEntries() const
Get the number of elements.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
float weight(int index) const
Get weight with index.
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).
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
bool construct(Args &&... params)
Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
A class to represent a cell layer.
A class to represent a wire in CDC.
A class to represent a wire in CDC.
The instance of TRGCDC is a singleton.
TClonesArray * m_fitParameters
3D fit
bool _fileFitter3D
Switch for Fitter3D.root file.
std::vector< TRGCDCTrack * > _trackList3D
Track list for 3D fitted tracks.
std::vector< TRGCDCTracker2D * > _tracker2Ds
CDC 2D finder boards.
bool _fFitter3Ds2DFitDrift
Switch to us wire 2D fit or drift 2D fit.
int _firmwareSimulationStopDataClock
Firmware simulation stop clock in CDCTRG data clock.
std::vector< TRGCDCWireHit * > _axialHits
CDC hits on axial wires.
bool _fFitter3Ds2DFit
Switch to us 2D fit or Hough finder results.
unsigned _simulationMode
Simulation mode.
TClonesArray * m_rootTRGRawInformation
[0]: iLayer, [1]: iWire, [2]: Timing(CDC), [3]: MatchNumber MatchNumber: 1: Only CDC,...
std::string _configFilename
CDC trigger configuration filename.
TTree * m_tree
root tree for reconstructed 3D tracks
std::vector< std::vector< TRGCDCLayer * > * > _superLayers
Super layers.
unsigned _fastSimulationMode
Fast simulation mode.
TTree * m_treeAllTracks
root tree for MC tracks
std::vector< TRGCDCWire * > _hitWires
Wires with a hit.
std::vector< TRGCDCSegment * > _tsSL[9]
Track Segments.
int _trgCDCDataInputMode
Switch for TRG CDC input mode.
std::string _cdchitCollectionName
name of the CDCHit DataStore array used as input
int _debugLevel
Debug level.
void perfect3DFinder(std::vector< TRGCDCTrack * > trackList) const
fills stereo TSs to tracks using MC info.
std::vector< TRGCDCTrack * > _trackList2DFitted
Track list for 2D fitted tracks.
int _finder3DMode
Sets mode of 3DFinder.
std::vector< TRGCDCTrackSegmentFinder * > _tsfboards
CDC trigger tsf boards.
bool _fXtSimpleFitter3D
Switch for using simple x-t curve or non-linear x-t curve. 0: non-linear 1: simple.
TClonesArray * m_mcParameters
MC.
float * _width
Cell width in radian.
std::string _outerTSLUTFilename
The filename of LUT for outer track segments.
std::string _innerTSLUTFilename
The filename of LUT for the inner-most track segments.
bool _fLogicLUTTSF
Switch for logic or LUT TSF.
int _fverETF
Switch for selecting ETF version.
std::vector< TRGCDCWireHitMC * > _hitsMC
MC info. of CDC hits.
TClonesArray * m_mcTrackVertexVector
MC vertex.
std::vector< TRGCDCSegment * > _tss
Track Segments.
const bool _perfect2DFinder
Switch to activate perfect 2D finder.
bool _fileHough3D
Switch for Hough3D.root file.
std::vector< TRGCDCLayer * > _stereoLayers
Stereo layers.
const TRGClock _clockD
CDC trigger data clock.
bool _fileTSF
Switch for TSF.root file.
bool _fileETF
Switch for ETF.root file.
std::vector< std::vector< TRGCDCLayer * > * > _stereoSuperLayers
Stereo super layers.
std::string _rootTRGCDCFilename
The filename of root file for TRGCDC.
std::vector< TRGCDCSegmentHit * > _segmentHits
Track Segments with hits.
std::vector< TRGCDCLayer * > _tsLayers
Track Segment layers.
TTree * m_treeROOTInput
Debugging members for firmware ROOT input.
std::vector< TRGCDCWireHit * > _badHits
Bad CDC hits.(not used now)
bool _makeRootFile
Switch for TRGCDC.root file.
EReturnValueType
Enum for returnValue types.
int _returnValue
Return value for trg cdc module;.
std::vector< TRGCDCTrack * > _trackList2D
Track list by 2D finding.
bool _fprintFirmETF
Switch for printing Firmware inputs for ETF.
TRGCDCHoughFinder * _hFinder
Hough finder.
TRGCDCTrackSegmentFinder * _tsFinder
Track Segement Finder.
std::vector< TRGCDCEventTime * > _eventTime
EventTime.
TClonesArray * m_mcTrack4Vector
MC track.
TRGSignal _firmwareSimulationWindow
Firmware simulation time window in FE.
std::vector< TRGCDCWire * > _wires
All wires.
TClonesArray * m_rootTRGHitInformation
[0]: iLayer, [1]: iWire, [2]: window number, [3]: priority timing
std::vector< TRGCDCLayer * > _layers
All layers.
const TRGClock _clock
CDC trigger system clock.
TClonesArray * m_mcTrackStatus
MC track status.
double _inefficiency
Hit inefficiency parameter.
TClonesArray * m_evtTime
Event time.
TRGCDCFitter3D * _fitter3D
3D fitter.
std::vector< TRGCDCFrontEnd * > _fronts
CDC front-end boards.
std::vector< TRGCDCSegmentHit * > _segmentHitsSL[9]
Track Segments with hits in each super layer.
std::vector< TRGCDCWireHit * > _stereoHits
CDC hits on stereo wires.
int _firmwareSimulationStop
Fimrware simulation stop clock in FE.
int _firmwareSimulationStart
Fimrware simulation start clock in FE.
TRGCDCPerfectFinder * _pFinder
Perfect 2D finder.
std::vector< std::vector< TRGCDCLayer * > * > _axialSuperLayers
Axial super layers.
TClonesArray * _tracks2D
2D track information
std::vector< TRGCDCLayer * > _axialLayers
Axial layers.
TRGCDCPerfectFinder * _p3DFinder
Perfect 3D finder.
CDC::CDCGeometryPar * m_cdcp
returns a pointer to CDCGeometryPar
TRGCDCHough3DFinder * _h3DFinder
Hough 3D finder.
const TRGClock _clockUser3125
CDC trigger user clock for Aurora 3.125 Gbps.
std::vector< TRGCDCWireHit * > _hits
CDC hits.
const TRGClock _clockFE
CDC front end clock. Resolution is CDC TdcBinWidth.
std::string _rootFitter3DFilename
The filename of root file for Fitter3D.
bool _fFitter3Dsmclr
Switch for MC L/R information in Fitter3D.
std::vector< TRGCDCMerger * > _mergers
CDC trigger merger boards.
bool _fLRLUT
Switch for the LR LUT in Fitter3D.
const TRGClock _clockUser6250
CDC trigger user clock for Aurora 6.250 Gbps.
TTree * _tree2D
root tree for 2D tracks
const TRGClock _clockTDC
CDC trigger TDC clock.
int _firmwareSimulationStartDataClock
Firmware simulation start clock in CDCTRG data clock.
TClonesArray * m_rootCDCHitInformation
[0]: iLayer, [1]: iWire, [2]: CDCADC, [3]: CDCTDC, [4]: CDC FE TRG timing
A class to represent a serial link between trigger hardware modules.
A class to represent a digitized signal. Unit is nano second.
A class to represent a bundle of SignalVectors.
A class to represent a bundle of digitized signals.
A class to represent a digitized signal. Unit is nano second.
A class to represent a state of multi bits.
A class to represent a signal timing in the trigger system.
Class to identify a wire inside the CDC.
static void findImpactPosition(ROOT::Math::XYZVector *mcPosition, ROOT::Math::PxPyPzEVector *mcMomentum, int charge, ROOT::Math::XYVector &helixCenter, ROOT::Math::XYZVector &impactPosition)
MC calculation functions Calculates the impact position of track.
int GetDetectorNwords(int n, int finesse_num)
get Detector buffer length
int * GetDetectorBuffer(int n, int finesse_num)
get Detector buffer
std::vector< const TRGCDCSegmentHit * > segmentHits(void) const
returns a list of TRGCDCSegmentHit.
std::vector< TRGCDCTrack * > getTrackList2DFitted(void)
returns 2D fitted track list.
unsigned nAxialLayers(void) const
return # of axial layers.
unsigned size(void) const
returns bit size.
unsigned localId(unsigned wireId) const
returns local ID in a layer. This function is expensive.
void configure(void)
configures trigger modules for firmware simulation.
static std::string tab(void)
returns tab spaces.
const TRGSignalVector & set(const TRGState &, int clockPosition)
sets state at given clock.
static TRGCDC * getTRGCDC(void)
returns TRGCDC object.
void setReturnValue(EReturnValueType const &moduleName, bool flag)
sets return value for trg cdc module.
unsigned layerId(unsigned wireId) const
returns layer ID. This function is expensive.
std::string name(void) const
simulates track segment decisions.
void initialize()
Initialization.
unsigned localLayerId(unsigned wireId) const
returns local layer ID in a super layer. This function is expensive.
void fastClear(void)
clears TRGCDC information.
double absoluteTime(int clockPosition) const
returns absolute time of clock position
int priorityPosition(void) const
return priority cell position in TSHit. 0: no hit, 3: 1st priority, 1: 2nd right, 2: 2nd left
std::string wireName(unsigned wireId) const
returns wire name.
int FindAndFit(std::vector< TRGCDCTrack * > &trackList2D, std::vector< TRGCDCTrack * > &trackList2DFitted)
do track finding and fitting (wrapper that can choose between different versions).
TRGState subset(unsigned i, unsigned n) const
returns subset from i with n bits.
float fastestTime(void) const
return fastest time in TSHit.
TRGCDC(const std::string &configFile, unsigned simulationMode, unsigned fastSimulationMode, unsigned firmwareSimulationMode, int firmwareSimulationStart, int firmwareSimulationStop, bool makeRootFile, bool perfect2DFinder, bool perfect3DFinder, const std::string &innerTSLUTFile, const std::string &outerTSLUTFile, const std::string &rootTRGCDCFile, const std::string &rootFitter3DFile, unsigned houghFinderPeakMin, const std::string &houghMappingFilePlus, const std::string &houghMappingFileMinus, unsigned houghDoit, bool fLogicLUTTSF, bool fLRLUT, bool fFitter3Dsmclr, bool fFitter3Ds2DFit, bool fFitter3Ds2DFitDrift, double inefficiecny, bool fileTSF, bool fileETF, int fverETF, bool fprintFirmETF, bool fileHough3D, int finder3DMode, bool fileFitter3D, bool fXtSimpleFitter3D, double TdcBinWidth, int trgCDCDataInputMode, const std::string &cdchitCollectionName)
Constructor.
unsigned id(void) const
returns id.
int doit(std::vector< TRGCDCTrack * > &trackList)
Does track fitting.
const TRGClock & clock(void) const
returns clock.
int doit(std::vector< TRGCDCTrack * > &trackListClone, std::vector< TRGCDCTrack * > &trackList)
do track finding.
unsigned localLayerId(void) const
returns local layer id in a super layer.
void terminate(void)
terminates when run is finished
TRGTime & reverse(void)
reverse edge.
int getValue(unsigned) const
get LUT Values
const std::string & name(void) const
returns name.
static void enterStage(const std::string &stageName)
Declare that you enter new stage.
bool neighbor(const TRGCDCWire &w0, const TRGCDCWire &w1) const
returns true if w0 and w1 are neighbor.
unsigned superLayerId(void) const
returns super layer id.
virtual ~TRGCDC()
Destructor.
void saveTRGHitInformation(std::vector< std::vector< int > > &)
Save functions for ROOT.
void terminate()
Termination.
const std::string stereoType(void) const
returns "A" or "U" or "V" depending on stereo type.
const TRGSignal & signal(void) const override
returns an input to the trigger. This is sync'ed to 1GHz clock.
std::vector< TRGCDCTrack * > getTrackList3D(void)
returns 3D track list (fitted).
static std::string itostring(int i)
converts int to string. (Use boost::lexical_cast)
const TRGCDCWire & priority(void) const
returns priority wire.
unsigned nAxialSuperLayers(void) const
return # of axial super layers.
unsigned axialStereoSuperLayerId(void) const
returns id of axial or stereo super layer id.
const TRGState & set(unsigned position, bool state=true)
sets state at bit i.
std::vector< const TRGCDCWireHitMC * > hitsMC(void) const
returns a list of TRGCDCWireHitMC.
const TRGClock & dataClock(void) const
returns the data clock.
unsigned nSegments(void) const
returns # of track segments.
TRGTime & shift(int unit)
delays by clock unit.
const TRGCDCWireHit * hit(void) const
returns a pointer to a TRGCDCWireHit.
unsigned axialStereoSuperLayerId(unsigned axialStereo, unsigned axialStereoLayerId) const
returns axialStereo super layer ID. This function is expensive.
unsigned firmwareSimulationMode(void) const
returns firmware simulation mode.
unsigned nSuperLayers(void) const
returns # of super layers.
int firmwareSimulationStart(void) const
returns start clock of the firmware simulation in FE clock.
unsigned nStereoLayers(void) const
returns # of stereo layers.
void initialize(void)
initilize variables.
unsigned lutPattern(void) const
hit pattern containing bit for priority position
std::string versionCDC(void) const
returns CDC version.
void initialize(unsigned houghFinderPeakMin, const std::string &houghMappingFilePlus, const std::string &houghMappingFileMinus, unsigned houghDoit)
initializes CDC geometry.
const TRGCDCSegment & segment(unsigned id) const
returns a track segment.
void saveTRGRawInformation(std::vector< std::string > &)
Save functions for ROOT.
const TRGCDCLUT * LUT(void) const
returns LUT
unsigned nLayers(void) const
return # of layers.
int getEventTime(void) const
returns bad hits(finding invalid hits).
const std::vector< TRGCDCLayer * > * superLayer(unsigned id) const
returns a pointer to a super-layer.
void dump(const std::string &message) const
dumps debug information.
std::vector< const TRGCDCWireHit * > stereoHits(void) const
returns a list of stereo hits.
const std::vector< const CDCTriggerSegmentHit * > storeHits(void) const
returns a pointer to a CDCTriggerSegmentHit.
unsigned iCDCHit(void) const
returns an index to CDCHit.
std::vector< TRGCDCTrack * > getTrackList2D(void)
returns 2D track list (no fit).
std::vector< const TRGCDCWireHit * > axialHits(void) const
returns a list of axial hits.
unsigned superLayerId(unsigned wireId) const
returns super layer ID. This function is expensive.
void doit(std::vector< TRGCDCSegment * > &tss, const bool trackSegmentClockSimulation, std::vector< TRGCDCSegmentHit * > &segmentHits, std::vector< TRGCDCSegmentHit * > *segmentHitsSL)
Member functions of doing TSF.
static int level(void)
returns the debug level.
unsigned axialStereoLayerId(void) const
returns id of axial or stereo id.
std::vector< const TRGCDCWireHit * > hits(void) const
returns a list of TRGCDCWireHit.
int getReturnValue(void) const
gets return value for trg cdc module.
bool active(void) const
returns true if there is a signal.
const std::vector< const TRGCDCWire * > & wires(void) const
returns a vector containing pointers to a wire.
float priorityTime(void) const
return priority time in TSHit.
static TRGCDC * _cdc
CDC trigger singleton.
const TRGCDCLayer * layer(unsigned id) const
returns a pointer to a layer. 0 will be returned if 'id' is invalid.
void update()
updates TRGCDC wire information. clear() is called in this function.
int position(double timing) const
returns clock position.
static void leaveStage(const std::string &stageName)
Declare that you leave a stage.
unsigned nCells(void) const
returns # of cells.
unsigned nStereoSuperLayers(void) const
returns # of stereo super layers.
void fastSimulation(void)
Fast simulation.
float foundTime(void) const
return found time in TSHit.
std::string version(void) const
returns version.
unsigned nWires(void) const
return # of wires.
void simulate(void)
fast trigger simulation.
void clear(void)
clears all TRGCDC hit information.
void saveCDCHitInformation(std::vector< std::vector< unsigned > > &)
Save functions for ROOT.
void doit(std::vector< TRGCDCTrack * > const &trackList2D, std::vector< TRGCDCTrack * > &trackList3D)
Member functions.
void firmwareSimulation(void)
Firmware simulation.
void classification(void)
classify hits.
void updateByData(int inputMode)
updates TRGCDC wire information by Hardware data 0: From CDC FE ASCII file (Implementing) 1: From CDC...
void storeSimulationResults(std::string collection2Dfinder, std::string collection2Dfitter, std::string collection3Dfitter)
Save results of fast simulation to data store (segment hits & tracks).
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
int firmwareSimulationStop(void) const
returns stop clock of the firmware simulation in FE clock.
const TRGCDCWire * wire(unsigned wireId) const
returns a pointer to a wire.
Abstract base class for different kinds of events.