13#define TRG_SHORT_NAMES
14#define TRGCDC_SHORT_NAMES
18#include "trg/trg/Debug.h"
19#include "trg/trg/State.h"
20#include "trg/trg/Channel.h"
21#include "trg/trg/Utilities.h"
22#include "trg/cdc/TRGCDC.h"
23#include "trg/cdc/Cell.h"
24#include "trg/cdc/Wire.h"
25#include "trg/cdc/WireHit.h"
26#include "trg/cdc/Segment.h"
27#include "trg/cdc/SegmentHit.h"
28#include "trg/cdc/TrackSegmentFinder.h"
29#include "framework/datastore/StoreArray.h"
30#include "framework/datastore/RelationArray.h"
31#include <framework/geometry/B2Vector3.h>
32#include "cdc/dataobjects/CDCSimHit.h"
33#include "mdst/dataobjects/MCParticle.h"
34#include "trg/cdc/FrontEnd.h"
35#include "trg/cdc/Merger.h"
53 TRGBoard(
"",
TRGClock(
"", 0, 0),
TRGClock(
"", 0, 0),
TRGClock(
"", 0, 0),
56 m_logicLUTFlag(logicLUTFlag),
57 m_makeRootFile(makeRootFile),
58 _type(), _tosbE(), _tosbT()
67 TDirectory* currentDir = gDirectory;
69 m_fileTSF =
new TFile(
"TSF.root",
"RECREATE");
88 const std::string& name,
94 const std::vector<TRGCDCSegment*>& tsSL)
95 :
TRGBoard(name, systemClock, dataClock, userClockInput, userClockOutput),
134 const bool trackSegmentClockSimulation,
135 std::vector<TRGCDCSegmentHit*>& segmentHits,
136 std::vector<TRGCDCSegmentHit*>* segmentHitsSL)
144 const unsigned n = tss.size();
145 for (
unsigned i = 0; i < n; i++) {
146 TCSegment& s = * tss[i];
149 if (s.signal().active()) {
150 TCSHit* th =
new TCSHit(s);
152 segmentHits.push_back(th);
153 segmentHitsSL[s.layerId()].push_back(th);
165 string dumpOption =
"trigger";
167 dumpOption =
"detail";
170 if (s.signal().active())
176 dumpOption =
"detail";
177 for (
unsigned i = 0; i < segmentHits.size(); i++) {
178 const TCSHit& s = * segmentHits[i];
184 dumpOption =
"detail";
186 for (
unsigned i = 0; i < segmentHitsSL[j].size(); i++) {
187 const vector<TCSHit*>& s = segmentHitsSL[j];
188 for (
unsigned k = 0; k < s.size(); k++)
198 vector <TRGSignalVector*>
204 tsid) +
" in " +
name();
205 TCSegment* tsi =
_tsSL[tsid];
206 vector <TRGSignalVector*> result;
209 vector<bool> fTimeVect;
213 vector <bool> tmpOutBool;
218 eachInput->
clock(), 0);
221 for (
unsigned i = 0; i < 12; i++) {
222 Hitmap->push_back((*eachInput)[i]);
223 (*Hitmap)[i].widen(16);
225 for (
unsigned i = 0; i < 4; i++) {
226 pTime.push_back((*eachInput)[i + 12]);
227 fTime.push_back((*eachInput)[i + 16]);
229 for (
unsigned i = 0; i < 5; i++) {
230 pTime.push_back((*eachInput)[i + 20]);
231 fTime.push_back((*eachInput)[i + 20]);
236 int* LUTValue =
new int[changeTime.size()];
237 if (changeTime.size()) {
245 fTimeVect.insert(fTimeVect.begin(), fTimeBool, fTimeBool + 10);
248 for (
unsigned i = 0; i < changeTime.size(); i++) {
249 LUTValue[i] = tsi->LUT()->getValue(
mkint(Hitmap->
state(changeTime[i])));
252 if ((LUTValue[i]) && (eOUT)) {
253 resultE->
set(fTimeVect, changeTime[i]);
257 bool priority1rise = (*Hitmap)[6].riseEdge(changeTime[i]);
258 bool priority2rise = ((*Hitmap)[7].riseEdge(changeTime[i]) or
259 (*Hitmap)[8].riseEdge(changeTime[i]));
266 tmpCTime = changeTime[i];
267 }
else if (priority2rise) {
270 tmpCTime = changeTime[i];
271 if ((*Hitmap)[0].state(changeTime[i])) hitPosition = 2;
272 else hitPosition = 1;
277 if ((hitPosition) && (LUTValue[i]) && ((changeTime[i] - tmpCTime) < 16)) {
278 tmpOutInt = tsid * pow(2, 13) + tmpPTime * pow(2, 4) + LUTValue[i] * pow(2,
280 tmpOutBool =
mkbool(tmpOutInt, 22);
281 if (hitPosition == 3) {
282 if (priority1rise) resultT->
set(tmpOutBool, changeTime[i]);
284 if ((LUTValue[i] == 1) | (LUTValue[i] == 2)) {
285 if (!((LUTValue[i - 1] == 1) |
286 (LUTValue[i - 1] == 2)))
287 resultT->
set(tmpOutBool, changeTime[i]);
289 if (!(LUTValue[i - 1])) resultT->
set(tmpOutBool, changeTime[i]);
293 if (priority2rise) resultT->
set(tmpOutBool, changeTime[i]);
295 if ((LUTValue[i] == 1) | (LUTValue[i] == 2)) {
296 if (!((LUTValue[i - 1] == 1) |
297 (LUTValue[i - 1] == 2)))
298 resultT->
set(tmpOutBool, changeTime[i]);
300 if (!(LUTValue[i])) resultT->
set(tmpOutBool, changeTime[i]);
309 result.push_back(resultT);
310 result.push_back(resultE);
322 const unsigned maxHit)
327 for (
unsigned ci = 0; ci < cList.size(); ci++) {
329 for (
unsigned hi = 0; hi < hitList.size(); hi++) {
330 TRGState s = (* hitList[hi]).state(cList[ci]);
332 if (cntHit >= maxHit)
continue;
333 for (
unsigned j = 0; j < 21; j++) {
334 if ((* hitList[hi])[j].state(cList[ci])) {
335 (* result)[21 * (maxHit - 1) - (cntHit * 21) + j]
336 .set(cList[ci], cList[ci] + 1);
340 TRGState t = hitList[hi]->state(cList[ci]).subset(13, 9);
342 << unsigned(t) <<
"(" << t <<
")" << endl;
361 hitList.size() + 9 * maxHit);
363 for (
unsigned ci = 0; ci < cList.size(); ci++) {
365 for (
unsigned hi = 0; hi < hitList.size(); hi++) {
366 if ((*hitList[hi]).state(cList[ci]).active()) {
367 (*result)[9 * maxHit + hi].set(cList[ci], cList[ci] + 1);
368 if (cntHit >= maxHit)
continue;
369 for (
unsigned j = 0; j < (((*hitList[hi])).size() - 1); j++) {
370 if ((*hitList[hi])[j].state(cList[ci]))
371 (*result)[9 * (maxHit - 1) - (cntHit * 9) + j].set(cList[ci], cList[ci] + 1);
384 bool* binput =
new bool[bitInput.
size()];
386 for (
unsigned i = 0; i < bitInput.
size(); i++) {
397 vector<bool> boutput;
398 boutput.resize(bitSize);
400 for (
unsigned i = 0; tmpint; i++) {
401 if (tmpint % 2) boutput[i] =
true;
402 else boutput[i] =
false;
416 hitPatternInformation.Clear();
431 const unsigned nTSs = tss.size();
432 unsigned nHitTSs = 0;
433 for (
unsigned iTS = 0; iTS < nTSs; iTS++) {
434 const TCSegment& ts = * tss[iTS];
439 if (ts.wires().size() == 15) {
440 priority = ts.wires()[0];
441 secondPriorityR = ts.wires()[1];
442 secondPriorityL = ts.wires()[2];
444 priority = ts.wires()[5];
445 secondPriorityR = ts.wires()[6];
446 secondPriorityL = ts.wires()[7];
449 vector<int> priorityLRs(3);
450 vector<float> priorityPhis(3);
453 if (priority->
hit() != 0) {
455 priorityLRs[0] = SimHits[iSimHit]->getPosFlag();
456 posOnTrack = SimHits[iSimHit]->getPosTrack();
457 posOnWire = SimHits[iSimHit]->getPosWire();
458 priorityPhis[0] = (posOnTrack - posOnWire).Phi() + M_PI_2 -
467 priorityPhis[0] = 9999;
469 if (secondPriorityR->
hit() != 0) {
471 priorityLRs[1] = SimHits[iSimHit]->getPosFlag();
472 posOnTrack = SimHits[iSimHit]->getPosTrack();
473 posOnWire = SimHits[iSimHit]->getPosWire();
474 priorityPhis[1] = (posOnTrack - posOnWire).Phi() + M_PI_2 -
478 priorityPhis[1] = 9999;
480 if (secondPriorityL->
hit() != 0) {
482 priorityLRs[2] = SimHits[iSimHit]->getPosFlag();
483 posOnTrack = SimHits[iSimHit]->getPosTrack();
484 posOnWire = SimHits[iSimHit]->getPosWire();
485 priorityPhis[2] = (posOnTrack - posOnWire).Phi() + M_PI_2 -
489 priorityPhis[2] = 9999;
492 const unsigned nWires = ts.wires().size();
493 unsigned nHitWires = 0;
495 map<int, unsigned> particleTSPattern;
497 for (
unsigned iWire = 0; iWire < nWires; iWire++) {
499 const TRGSignal& wireSignal = ts.wires()[iWire]->signal();
500 if (wireSignal.
active()) ++nHitWires;
505 int iMCParticle = (particle) ? particle->getArrayIndex() : mcParticles.
getEntries();
507 if (particleTSPattern[iMCParticle] == 0) {
508 particleTSPattern[iMCParticle] = 1 << iWire;
510 particleTSPattern[iMCParticle] |= 1 << iWire;
521 if (nHitWires != 0) {
523 if (particleTSPattern.size() == 1) {
524 map<int, unsigned>::const_iterator it = particleTSPattern.begin();
525 bitset<15> printPattern((*it).second);
529 TVectorD tsPatternInformation(9);
530 tsPatternInformation[0] = (*it).first;
531 tsPatternInformation[1] = ts.superLayerId();
532 tsPatternInformation[2] = double((*it).second);
533 tsPatternInformation[3] = priorityLRs[0];
534 tsPatternInformation[4] = priorityPhis[0];
535 tsPatternInformation[5] = priorityLRs[1];
536 tsPatternInformation[6] = priorityPhis[1];
537 tsPatternInformation[7] = priorityLRs[2];
538 tsPatternInformation[8] = priorityPhis[2];
539 new (hitPatternInformation[nHitTSs++]) TVectorD(tsPatternInformation);
556 particleEfficiency.Clear();
557 tsInformation.Clear();
559 int mcInformation = 1;
574 map<int, int> simHitsMCParticlesMap;
576 for (
int iPart = 0; iPart < cdcSimHitRel.
getEntries(); iPart++) {
578 for (
unsigned iHit = 0; iHit < cdcSimHitRel[iPart].getToIndices().size();
581 simHitsMCParticlesMap[cdcSimHitRel[iPart].getToIndex(iHit)] =
582 cdcSimHitRel[iPart].getFromIndex();
592 map<int, unsigned> particleNHitTS;
594 for (
int iSuperLayer = 0; iSuperLayer < 9; iSuperLayer++) {
596 for (
unsigned iTS = 0; iTS < segmentHitsSL[iSuperLayer].size(); iTS++) {
597 const TCSegment& ts = segmentHitsSL[iSuperLayer][iTS]->segment();
598 unsigned nWires = ts.wires().size();
599 for (
unsigned iWire = 0; iWire < nWires; iWire++) {
602 int iMCParticle = simHitsMCParticlesMap[wireHit->
iCDCSimHit()];
603 if (particleNHitTS[iMCParticle] == 0) {
605 hitTSSL = 1 << iSuperLayer;
606 particleNHitTS[iMCParticle] = hitTSSL;
608 particleNHitTS[iMCParticle] |= 1 << iSuperLayer;
623 vector<vector<float>> tsEfficiency;
625 for (
int iPart = 0; iPart < cdcSimHitRel.
getEntries(); iPart++) {
626 int lastWireHit = -1;
628 for (
unsigned iHit = 0; iHit < cdcSimHitRel[iPart].getToIndices().size();
630 int iSimHit = cdcSimHitRel[iPart].getToIndex(iHit);
631 if (SimHits[iSimHit]->getWireID().getICLayer() > lastWireHit) lastWireHit =
632 SimHits[iSimHit]->getWireID().getICLayer();
639 if (lastWireHit >= 53) lastSLHit = 9;
640 else if (lastWireHit >= 47) lastSLHit = 8;
641 else if (lastWireHit >= 41) lastSLHit = 7;
642 else if (lastWireHit >= 35) lastSLHit = 6;
643 else if (lastWireHit >= 29) lastSLHit = 5;
644 else if (lastWireHit >= 23) lastSLHit = 4;
645 else if (lastWireHit >= 17) lastSLHit = 3;
646 else if (lastWireHit >= 11) lastSLHit = 2;
647 else if (lastWireHit >= 5) lastSLHit = 1;
649 int iMCParticle = cdcSimHitRel[iPart].getFromIndex();
650 bitset<9> hitSuperLayers(particleNHitTS[iMCParticle]);
651 int numberHitSuperLayers = hitSuperLayers.count();
653 float mcPt = mcParticles[iMCParticle]->getMomentum().Rho();
655 if (lastSLHit == 0) efficiency = -1;
656 else efficiency = float(numberHitSuperLayers) / lastSLHit;
658 vector<float> tempEfficiency;
659 tempEfficiency.resize(3);
660 tempEfficiency[0] = efficiency;
661 tempEfficiency[1] = mcPt;
662 tempEfficiency[2] = lastSLHit;
663 tsEfficiency.push_back(tempEfficiency);
671 for (
unsigned iEfficiency = 0; iEfficiency < tsEfficiency.size();
673 TVectorD t_particleEfficiency(3);
674 t_particleEfficiency[0] = tsEfficiency[iEfficiency][0];
675 t_particleEfficiency[1] = tsEfficiency[iEfficiency][1];
676 t_particleEfficiency[2] = tsEfficiency[iEfficiency][2];
677 new (particleEfficiency[iEfficiency]) TVectorD(t_particleEfficiency);
686 for (
int iSuperLayer = 0; iSuperLayer < 9; iSuperLayer++) {
687 for (
unsigned iTS = 0; iTS < segmentHitsSL[iSuperLayer].size(); iTS++) {
688 const TCSegment& ts = segmentHitsSL[iSuperLayer][iTS]->segment();
691 if (iSuperLayer == 0) iWire = 0;
695 unsigned nHits = ts.wires()[iWire]->signal().nSignals();
696 for (
unsigned iHit = 0; iHit < nHits; iHit++) {
697 if (iHit % 2 == 1)
continue;
698 TVectorD tempTSInformation(3);
699 tempTSInformation[0] = iSuperLayer;
700 tempTSInformation[1] = ts.localId();
701 tempTSInformation[2] = ts.wires()[iWire]->signal().stateChanges()[iHit];
702 new (tsInformation[iHitTS++]) TVectorD(tempTSInformation);
718 std::vector<TRGCDCSegment*>& tss)
728 nnPatternInformation.Clear();
732 const unsigned nTSs = tss.size();
733 unsigned indexSaving = 0;
734 for (
unsigned iTS = 0; iTS < nTSs; iTS++) {
736 const TCSegment& ts = * tss[iTS];
737 const TCSHit* tsHit = ts.hit();
740 if (ts.wires().size() == 15) priority = ts.wires()[0];
741 else priority = ts.wires()[5];
743 if (priority->
hit()) {
747 vector<float> wireTime;
748 if (ts.superLayerId() == 0)
754 const unsigned nWires = ts.wires().size();
755 for (
unsigned iWire = 0; iWire < nWires; iWire++) {
764 wireTime[iWire] = 9999;
774 int lastLayer = ts.wires().back()->layerId();
775 int lastWire = ts.wires().back()->localId();
778 for (
unsigned iWire = 0; iWire < 6; iWire++) {
779 int wireIndex = lastWire - 4 + iWire;
780 if (wireIndex < 0) wireIndex += nWiresLayer;
781 if (wireIndex >= nWiresLayer) wireIndex -= nWiresLayer;
791 wireTime.push_back(9999);
794 for (
unsigned iWire = 0; iWire < 5; iWire++) {
795 int wireIndex = lastWire - 3 + iWire;
796 if (wireIndex < 0) wireIndex += nWiresLayer;
797 if (wireIndex >= nWiresLayer) wireIndex -= nWiresLayer;
807 wireTime.push_back(9999);
831 if (priority->
hit()->
mcLR()) mcLRDriftTime *= -1;
835 TVectorD t_nnPatternInformation;
836 if (ts.superLayerId() == 0) {
838 t_nnPatternInformation.ResizeTo(23);
839 t_nnPatternInformation[0] = ts.superLayerId();
840 t_nnPatternInformation[1] = mcLRDriftTime;
842 for (
unsigned iWire = 0; iWire < 21; iWire++)
843 t_nnPatternInformation[iWire + 2] = wireTime[iWire];
844 new (nnPatternInformation[indexSaving++]) TVectorD(t_nnPatternInformation);
847 t_nnPatternInformation.ResizeTo(17);
848 t_nnPatternInformation[0] = ts.superLayerId();
849 t_nnPatternInformation[1] = mcLRDriftTime;
851 for (
unsigned iWire = 0; iWire < 15; iWire++)
852 t_nnPatternInformation[iWire + 2] = wireTime[iWire];
853 new (nnPatternInformation[indexSaving++]) TVectorD(t_nnPatternInformation);
867 std::vector<const TRGCDCMerger*>::push_back(a);
875 const string sn =
"TSF::simulateOuter : " +
name();
879 for (
unsigned m = 0; m <
nInput(); m++) {
882 for (
unsigned i = 0; i < 16; i++) {
883 _secMap.push_back(& ((* b)[0][0][208 + i]));
884 for (
unsigned j = 0; j < 5; j++)
886 for (
unsigned j = 0; j < 4; j++)
887 _priMap.push_back(& ((* b)[0][0][80 + i * 4 + j]));
888 for (
unsigned j = 0; j < 4; j++)
889 _fasMap.push_back(& ((* b)[0][0][144 + i * 4 + j]));
892 for (
unsigned i = 0; i < 4; i++)
893 _edg0Map.push_back(& ((* b)[0][0][224 + i]));
894 for (
unsigned i = 0; i < 4; i++)
895 _edg1Map.push_back(& ((* b)[0][0][224 + 4 + i]));
896 for (
unsigned i = 0; i < 4; i++)
897 _edg2Map.push_back(& ((* b)[0][0][224 + 8 + i]));
901 const unsigned nTSF =
nInput() * 16;
902 vector<TRGSignalVector*> trker[4];
903 vector<int> tsfStateChanges;
906 for (
unsigned t = 0; t < nTSF; t++) {
915 s->push_back(* (
_hitMap[0][nTSF - 1]));
916 s->push_back(* (
_hitMap[0][0]));
917 s->push_back(* (
_hitMap[0][1]));
918 s->push_back(* (
_hitMap[1][nTSF - 1]));
919 s->push_back(* (
_hitMap[1][0]));
920 s->push_back(* (
_hitMap[2][0]));
921 s->push_back(* (
_hitMap[3][nTSF - 1]));
922 s->push_back(* (
_hitMap[3][0]));
923 s->push_back(* (
_hitMap[4][nTSF - 1]));
924 s->push_back(* (
_hitMap[4][0]));
925 s->push_back(* (
_hitMap[4][1]));
926 }
else if (t == (nTSF - 1)) {
927 s->push_back(* (
_hitMap[0][nTSF - 2]));
928 s->push_back(* (
_hitMap[0][nTSF - 1]));
929 s->push_back(* (
_hitMap[0][0]));
930 s->push_back(* (
_hitMap[1][nTSF - 2]));
931 s->push_back(* (
_hitMap[1][nTSF - 1]));
932 s->push_back(* (
_hitMap[2][nTSF - 1]));
933 s->push_back(* (
_hitMap[3][nTSF - 2]));
934 s->push_back(* (
_hitMap[3][nTSF - 1]));
936 s->push_back(* (
_hitMap[4][nTSF - 2]));
937 s->push_back(* (
_hitMap[4][nTSF - 1]));
938 s->push_back(* (
_hitMap[4][0]));
940 s->push_back(* (
_hitMap[0][t - 1]));
941 s->push_back(* (
_hitMap[0][t]));
942 s->push_back(* (
_hitMap[0][t + 1]));
943 s->push_back(* (
_hitMap[1][t - 1]));
944 s->push_back(* (
_hitMap[1][t]));
945 s->push_back(* (
_hitMap[2][t]));
946 s->push_back(* (
_hitMap[3][t - 1]));
947 s->push_back(* (
_hitMap[3][t]));
948 s->push_back(* (
_hitMap[4][t - 1]));
949 s->push_back(* (
_hitMap[4][t]));
950 s->push_back(* (
_hitMap[4][t + 1]));
954 s->push_back(*
_priMap[t * 4 + 0]);
955 s->push_back(*
_priMap[t * 4 + 1]);
956 s->push_back(*
_priMap[t * 4 + 2]);
957 s->push_back(*
_priMap[t * 4 + 3]);
974 _tsfOut.push_back(forTracker0);
975 _tsfOut.push_back(forTracker1);
980 for (
unsigned i = 0; i < sc.size(); i++) {
982 for (
unsigned j = 0; j < tsfStateChanges.size(); j++) {
983 if (tsfStateChanges[j] == sc[i]) {
988 if (! skip) tsfStateChanges.push_back(sc[i]);
992 const unsigned pos = t / (nTSF / 4);
994 addID(* forTracker0, t + (nTSF / 4));
995 addID(* forTracker1, t);
996 trker[3].push_back(forTracker0);
997 trker[0].push_back(forTracker1);
998 }
else if (pos == 1) {
999 addID(* forTracker0, t);
1000 addID(* forTracker1, t - 1 * (nTSF / 4));
1001 trker[0].push_back(forTracker0);
1002 trker[1].push_back(forTracker1);
1003 }
else if (pos == 2) {
1004 addID(* forTracker0, t - 1 * (nTSF / 4));
1005 addID(* forTracker1, t - 2 * (nTSF / 4));
1006 trker[1].push_back(forTracker0);
1007 trker[2].push_back(forTracker1);
1009 addID(* forTracker0, t - 2 * (nTSF / 4));
1010 addID(* forTracker1, t - 3 * (nTSF / 4));
1011 trker[2].push_back(forTracker0);
1012 trker[3].push_back(forTracker1);
1016 if (forTracker0->
active())
1022 std::sort(tsfStateChanges.begin(), tsfStateChanges.end());
1025 for (
unsigned i = 0; i < 4; i++) {
1033 output(i)->signal(b);
1047 vector <TRGSignalVector*>
1054 TCSegment* tsi =
_tsSL[tsid];
1055 vector <TRGSignalVector*> result;
1058 vector<bool> fTimeVect;
1062 vector <bool> tmpOutBool;
1070 for (
unsigned i = 0; i < 12; i++) {
1071 Hitmap->push_back((*in)[i]);
1072 (*Hitmap)[i].widen(16);
1074 for (
unsigned i = 0; i < 4; i++) {
1075 pTime.push_back((*in)[i + 12]);
1076 fTime.push_back((*in)[i + 16]);
1081 for (
unsigned i = 0; i < 5; i++) {
1082 pTime.push_back(cc[i]);
1083 fTime.push_back(cc[i]);
1088 int* LUTValue =
new int[changeTime.size()];
1089 if (changeTime.size()) {
1090 int hitPosition = 0;
1096 fTimeBool[9] =
true;
1097 fTimeVect.insert(fTimeVect.begin(), fTimeBool, fTimeBool + 10);
1100 for (
unsigned i = 0; i < changeTime.size(); i++) {
1101 LUTValue[i] = tsi->LUT()->getValue(
mkint(Hitmap->
state(changeTime[i])));
1104 if ((LUTValue[i]) && (eOUT)) {
1105 resultE->
set(fTimeVect, changeTime[i]);
1109 bool priority1rise = (*Hitmap)[6].riseEdge(changeTime[i]);
1110 bool priority2rise = ((*Hitmap)[7].riseEdge(changeTime[i]) or
1111 (*Hitmap)[8].riseEdge(changeTime[i]));
1115 if (priority1rise) {
1117 tmpPTime =
mkint(pTime.
state(changeTime[i]));
1118 tmpCTime = changeTime[i];
1119 }
else if (priority2rise) {
1121 tmpPTime =
mkint(pTime.
state(changeTime[i]));
1122 tmpCTime = changeTime[i];
1123 if ((*Hitmap)[0].state(changeTime[i])) hitPosition = 2;
1124 else hitPosition = 1;
1129 if ((hitPosition) && (LUTValue[i]) && ((changeTime[i] - tmpCTime) < 16)) {
1132 tmpOutInt = tmpPTime * pow(2, 4) +
1133 LUTValue[i] * pow(2, 2) + hitPosition;
1134 tmpOutBool =
mkbool(tmpOutInt, 13);
1135 if (hitPosition == 3) {
1136 if (priority1rise) resultT->
set(tmpOutBool, changeTime[i]);
1138 if ((LUTValue[i] == 1) | (LUTValue[i] == 2)) {
1139 if (!((LUTValue[i - 1] == 1) |
1140 (LUTValue[i - 1] == 2)))
1141 resultT->
set(tmpOutBool, changeTime[i]);
1143 if (!(LUTValue[i - 1])) resultT->
set(tmpOutBool, changeTime[i]);
1147 if (priority2rise) resultT->
set(tmpOutBool, changeTime[i]);
1149 if ((LUTValue[i] == 1) | (LUTValue[i] == 2)) {
1150 if (!((LUTValue[i - 1] == 1) |
1151 (LUTValue[i - 1] == 2)))
1152 resultT->
set(tmpOutBool, changeTime[i]);
1154 if (!(LUTValue[i])) resultT->
set(tmpOutBool, changeTime[i]);
1163 result.push_back(resultT);
1164 result.push_back(resultE);
1175 const unsigned nTSF,
1182 unsigned rem = t % 16;
1185 s.push_back(*
_priMap[t * 4 + 0]);
1186 s.push_back(*
_priMap[t * 4 + 1]);
1187 s.push_back(*
_priMap[t * 4 + 2]);
1188 s.push_back(*
_priMap[t * 4 + 3]);
1194 tc.push_back(center);
1195 tc.push_back(right);
1200 s.push_back(*
_priMap[t * 4 + 0]);
1201 s.push_back(*
_priMap[t * 4 + 1]);
1202 s.push_back(*
_priMap[t * 4 + 2]);
1203 s.push_back(*
_priMap[t * 4 + 3]);
1207 const string sn =
"TSF priority timing outer";
1212 t0.push_back(*
_priMap[t * 4 + 0]);
1213 t0.push_back(*
_priMap[t * 4 + 1]);
1214 t0.push_back(*
_priMap[t * 4 + 2]);
1215 t0.push_back(*
_priMap[t * 4 + 3]);
1218 unsigned p = t / 16;
1222 t1.push_back(*
_edg0Map[p * 4 + 0]);
1223 t1.push_back(*
_edg0Map[p * 4 + 1]);
1224 t1.push_back(*
_edg0Map[p * 4 + 2]);
1225 t1.push_back(*
_edg0Map[p * 4 + 3]);
1228 vector<TRGState*> outputTimingStates;
1229 vector<int> clkStates;
1232 for (
unsigned i = 0; i < sc.size(); i++) {
1240 else if (stt[1] && (! stt[2]))
1242 else if ((! stt[1]) && stt[2])
1245 if (
unsigned(t0.
state(clk)) <
unsigned(t1.state(clk)))
1253 sb.push_back(
false);
1255 outputTimingStates.push_back(
new TRGState(t1.state(clk)));
1258 clkStates.push_back(clk);
1262 const unsigned n = outputTimingStates.size();
1264 for (
unsigned i = 0; i < n; i++) {
1266 s[0].unset(clkStates[i], clkStates[i] + 1);
1267 st.set(* outputTimingStates[i], clkStates[i]);
1268 delete outputTimingStates[i];
1290 const unsigned nTSF,
1294 const unsigned rem = t % 16;
1296 if ((rem != 0) && (rem != 15)) {
1297 s.push_back(*
_fasMap[t * 4 + 0]);
1298 s.push_back(*
_fasMap[t * 4 + 1]);
1299 s.push_back(*
_fasMap[t * 4 + 2]);
1300 s.push_back(*
_fasMap[t * 4 + 3]);
1306 for (
unsigned i = 0; i < 11; i++) {
1307 if (s[i + 1].active()) {
1315 s.push_back(*
_fasMap[t * 4 + 0]);
1316 s.push_back(*
_fasMap[t * 4 + 1]);
1317 s.push_back(*
_fasMap[t * 4 + 2]);
1318 s.push_back(*
_fasMap[t * 4 + 3]);
1322 const string sn =
"TSF fastest timing outer";
1327 t0.push_back(*
_fasMap[t * 4 + 0]);
1328 t0.push_back(*
_fasMap[t * 4 + 1]);
1329 t0.push_back(*
_fasMap[t * 4 + 2]);
1330 t0.push_back(*
_fasMap[t * 4 + 3]);
1336 unsigned n = t / 16;
1342 t1.push_back(*
_edg2Map[n * 4 + 0]);
1343 t1.push_back(*
_edg2Map[n * 4 + 1]);
1344 t1.push_back(*
_edg2Map[n * 4 + 2]);
1345 t1.push_back(*
_edg2Map[n * 4 + 3]);
1360 unsigned n = t / 16 + 1;
1364 t1.push_back(*
_edg1Map[n * 4 + 0]);
1365 t1.push_back(*
_edg1Map[n * 4 + 1]);
1366 t1.push_back(*
_edg1Map[n * 4 + 2]);
1367 t1.push_back(*
_edg1Map[n * 4 + 3]);
1385 vector<int> tmp = t1.stateChanges();
1386 sc.insert(sc.end(), tmp.begin(), tmp.end());
1387 std::sort(sc.begin(), sc.end());
1392 for (
unsigned i = 0; i < sc.size(); i++) {
1400 unsigned tm0 = unsigned(ts0);
1401 unsigned tm1 = unsigned(ts1);
1402 bool th0 = ht0.
state(clk);
1403 bool th1 = ht1.
state(clk);
1405 if ((! th0) && (! th1))
1407 else if (th0 && th1) {
1444 const string sn =
"TSF::simulateInner : " +
name();
1448 for (
unsigned i = 0; i < 4; i++) {
1452 b->push_back(dummy);
1453 output(i)->signal(b);
1467 for (
unsigned m = 0; m <
nInput(); m++) {
1470 for (
unsigned i = 0; i < 16; i++) {
1471 _secMap.push_back(& ((* b)[0][0][208 + i]));
1472 for (
unsigned j = 0; j < 5; j++)
1474 for (
unsigned j = 0; j < 4; j++)
1475 _priMap.push_back(& ((* b)[0][0][80 + i * 4 + j]));
1476 for (
unsigned j = 0; j < 4; j++)
1477 _fasMap.push_back(& ((* b)[0][0][144 + i * 4 + j]));
1480 for (
unsigned i = 0; i < 4; i++)
1481 _edg0Map.push_back(& ((* b)[0][0][224 + i]));
1482 for (
unsigned i = 0; i < 4; i++)
1483 _edg1Map.push_back(& ((* b)[0][0][224 + 4 + i]));
1484 for (
unsigned i = 0; i < 4; i++)
1485 _edg2Map.push_back(& ((* b)[0][0][224 + 8 + i]));
1486 for (
unsigned i = 0; i < 4; i++)
1487 _edg3Map.push_back(& ((* b)[0][0][224 + 12 + i]));
1488 for (
unsigned i = 0; i < 4; i++)
1489 _edg4Map.push_back(& ((* b)[0][0][224 + 16 + i]));
1493 const unsigned nTSF =
nInput() * 16;
1494 vector<TRGSignalVector*> trker[4];
1495 vector<int> tsfStateChanges;
1498 for (
unsigned t = 0; t < nTSF; t++) {
1507 s->push_back(* (
_hitMap[0][0]));
1508 s->push_back(* (
_hitMap[1][nTSF - 1]));
1509 s->push_back(* (
_hitMap[1][0]));
1510 s->push_back(* (
_hitMap[2][nTSF - 1]));
1511 s->push_back(* (
_hitMap[2][0]));
1512 s->push_back(* (
_hitMap[2][1]));
1513 s->push_back(* (
_hitMap[3][nTSF - 2]));
1514 s->push_back(* (
_hitMap[3][nTSF - 1]));
1515 s->push_back(* (
_hitMap[3][0]));
1516 s->push_back(* (
_hitMap[3][1]));
1517 s->push_back(* (
_hitMap[4][nTSF - 2]));
1518 s->push_back(* (
_hitMap[4][nTSF - 1]));
1519 s->push_back(* (
_hitMap[4][0]));
1520 s->push_back(* (
_hitMap[4][1]));
1521 s->push_back(* (
_hitMap[4][2]));
1522 }
else if (t == 1) {
1523 s->push_back(* (
_hitMap[0][1]));
1524 s->push_back(* (
_hitMap[1][0]));
1525 s->push_back(* (
_hitMap[1][1]));
1526 s->push_back(* (
_hitMap[2][0]));
1527 s->push_back(* (
_hitMap[2][1]));
1528 s->push_back(* (
_hitMap[2][2]));
1529 s->push_back(* (
_hitMap[3][nTSF - 1]));
1530 s->push_back(* (
_hitMap[3][0]));
1531 s->push_back(* (
_hitMap[3][1]));
1532 s->push_back(* (
_hitMap[3][2]));
1533 s->push_back(* (
_hitMap[4][nTSF - 1]));
1534 s->push_back(* (
_hitMap[4][0]));
1535 s->push_back(* (
_hitMap[4][1]));
1536 s->push_back(* (
_hitMap[4][2]));
1537 s->push_back(* (
_hitMap[4][3]));
1538 }
else if (t == (nTSF - 2)) {
1539 s->push_back(* (
_hitMap[0][t]));
1540 s->push_back(* (
_hitMap[1][t - 11]));
1541 s->push_back(* (
_hitMap[1][t]));
1542 s->push_back(* (
_hitMap[2][t - 1]));
1543 s->push_back(* (
_hitMap[2][t]));
1544 s->push_back(* (
_hitMap[2][0]));
1545 s->push_back(* (
_hitMap[3][t - 2]));
1546 s->push_back(* (
_hitMap[3][t - 1]));
1547 s->push_back(* (
_hitMap[3][t]));
1548 s->push_back(* (
_hitMap[3][0]));
1549 s->push_back(* (
_hitMap[4][t - 2]));
1550 s->push_back(* (
_hitMap[4][t - 1]));
1551 s->push_back(* (
_hitMap[4][t]));
1552 s->push_back(* (
_hitMap[4][t + 1]));
1553 s->push_back(* (
_hitMap[4][0]));
1554 }
else if (t == (nTSF - 1)) {
1555 s->push_back(* (
_hitMap[0][t]));
1556 s->push_back(* (
_hitMap[1][t - 11]));
1557 s->push_back(* (
_hitMap[1][t]));
1558 s->push_back(* (
_hitMap[2][t - 1]));
1559 s->push_back(* (
_hitMap[2][t]));
1560 s->push_back(* (
_hitMap[2][0]));
1561 s->push_back(* (
_hitMap[3][t - 2]));
1562 s->push_back(* (
_hitMap[3][t - 1]));
1563 s->push_back(* (
_hitMap[3][t]));
1564 s->push_back(* (
_hitMap[3][0]));
1565 s->push_back(* (
_hitMap[4][t - 2]));
1566 s->push_back(* (
_hitMap[4][t - 1]));
1567 s->push_back(* (
_hitMap[4][t]));
1568 s->push_back(* (
_hitMap[4][0]));
1569 s->push_back(* (
_hitMap[4][1]));
1571 s->push_back(* (
_hitMap[0][t]));
1572 s->push_back(* (
_hitMap[1][t - 11]));
1573 s->push_back(* (
_hitMap[1][t]));
1574 s->push_back(* (
_hitMap[2][t - 1]));
1575 s->push_back(* (
_hitMap[2][t]));
1576 s->push_back(* (
_hitMap[2][0]));
1577 s->push_back(* (
_hitMap[3][t - 2]));
1578 s->push_back(* (
_hitMap[3][t - 1]));
1579 s->push_back(* (
_hitMap[3][t]));
1580 s->push_back(* (
_hitMap[3][0]));
1581 s->push_back(* (
_hitMap[4][t - 2]));
1582 s->push_back(* (
_hitMap[4][t - 1]));
1583 s->push_back(* (
_hitMap[4][t]));
1584 s->push_back(* (
_hitMap[4][t + 1]));
1585 s->push_back(* (
_hitMap[4][t + 2]));
1589 s->push_back(*
_priMap[t * 4 + 0]);
1590 s->push_back(*
_priMap[t * 4 + 1]);
1591 s->push_back(*
_priMap[t * 4 + 2]);
1592 s->push_back(*
_priMap[t * 4 + 3]);
1606 _tsfOut.push_back(forTracker);
1611 for (
unsigned i = 0; i < sc.size(); i++) {
1613 for (
unsigned j = 0; j < tsfStateChanges.size(); j++) {
1614 if (tsfStateChanges[j] == sc[i]) {
1619 if (! skip) tsfStateChanges.push_back(sc[i]);
1623 const unsigned pos = t / (nTSF / 4);
1625 trker[0].push_back(forTracker);
1626 trker[1].push_back(forTracker);
1627 }
else if (pos == 1) {
1628 trker[1].push_back(forTracker);
1629 trker[2].push_back(forTracker);
1630 }
else if (pos == 2) {
1631 trker[2].push_back(forTracker);
1632 trker[3].push_back(forTracker);
1634 trker[3].push_back(forTracker);
1635 trker[0].push_back(forTracker);
1658 std::sort(tsfStateChanges.begin(), tsfStateChanges.end());
1661 for (
unsigned i = 0; i < 4; i++) {
1668 output(i)->signal(b);
1676 const unsigned nTSF,
1680 const unsigned rem = t % 16;
1682 if ((rem > 1) && (rem < 14)) {
1683 s.push_back(*
_fasMap[t * 4 + 0]);
1684 s.push_back(*
_fasMap[t * 4 + 1]);
1685 s.push_back(*
_fasMap[t * 4 + 2]);
1686 s.push_back(*
_fasMap[t * 4 + 3]);
1692 for (
unsigned i = 0; i < 11; i++) {
1693 if (s[i + 1].active()) {
1701 s.push_back(*
_fasMap[t * 4 + 0]);
1702 s.push_back(*
_fasMap[t * 4 + 1]);
1703 s.push_back(*
_fasMap[t * 4 + 2]);
1704 s.push_back(*
_fasMap[t * 4 + 3]);
1708 const string sn =
"TSF fastest timing inner";
1713 t0.push_back(*
_fasMap[t * 4 + 0]);
1714 t0.push_back(*
_fasMap[t * 4 + 1]);
1715 t0.push_back(*
_fasMap[t * 4 + 2]);
1716 t0.push_back(*
_fasMap[t * 4 + 3]);
1722 unsigned n = t / 16;
1728 t1.push_back(*
_edg3Map[n * 4 + 0]);
1729 t1.push_back(*
_edg3Map[n * 4 + 1]);
1730 t1.push_back(*
_edg3Map[n * 4 + 2]);
1731 t1.push_back(*
_edg3Map[n * 4 + 3]);
1748 }
else if (rem == 1) {
1749 unsigned n = t / 16;
1755 t1.push_back(*
_edg4Map[n * 4 + 0]);
1756 t1.push_back(*
_edg4Map[n * 4 + 1]);
1757 t1.push_back(*
_edg4Map[n * 4 + 2]);
1758 t1.push_back(*
_edg4Map[n * 4 + 3]);
1775 }
else if (rem == 14) {
1776 unsigned n = t / 16 + 1;
1780 t1.push_back(*
_edg1Map[n * 4 + 0]);
1781 t1.push_back(*
_edg1Map[n * 4 + 1]);
1782 t1.push_back(*
_edg1Map[n * 4 + 2]);
1783 t1.push_back(*
_edg1Map[n * 4 + 3]);
1801 unsigned n = t / 16 + 1;
1805 t1.push_back(*
_edg2Map[n * 4 + 0]);
1806 t1.push_back(*
_edg2Map[n * 4 + 1]);
1807 t1.push_back(*
_edg2Map[n * 4 + 2]);
1808 t1.push_back(*
_edg2Map[n * 4 + 3]);
1829 vector<int> tmp = t1.stateChanges();
1830 sc.insert(sc.end(), tmp.begin(), tmp.end());
1831 std::sort(sc.begin(), sc.end());
1836 for (
unsigned i = 0; i < sc.size(); i++) {
1844 unsigned tm0 = unsigned(ts0);
1845 unsigned tm1 = unsigned(ts1);
1846 bool th0 = ht0.
state(clk);
1847 bool th1 = ht1.
state(clk);
1849 if ((! th0) && (! th1))
1851 else if (th0 && th1) {
1884 vector<TRGSignalVector*>
1914 vector<int> sc = s.stateChanges();
1915 for (
unsigned i = 0; i < sc.size(); i++) {
1917 TRGState st = s.state(clk).subset(1, 3);
1921 if (st[1] && st[2]) {
1930 vector<TRGSignalVector*> v;
1943 vector<int> sc = s.stateChanges();
1944 for (
unsigned i = 0; i < sc.size(); i++) {
1945 if (s.active(sc[i]))
1946 idv.
set(sid, sc[i]);
1958 for (
unsigned i = 0; i <
nOutput(); i++) {
1960 if (output(i)->signal())
1961 delete output(i)->signal();
1963 for (
unsigned i = 0; i <
_tsfIn.size(); i++)
1966 for (
unsigned i = 0; i <
_tsfOut.size(); i++)
1974 for (
unsigned i = 0; i < 5; i++)
1985 if (
_type == innerType)
1995 const string sn =
"TSF::simulate2 : " +
name();
2005 for (
unsigned i = 0; i <
nOutput(); i++) {
2007 if (output(i)->signal())
2008 delete output(i)->signal();
2010 for (
unsigned i = 0; i <
_tsfIn.size(); i++)
2013 for (
unsigned i = 0; i <
_tsfOut.size(); i++)
2021 for (
unsigned i = 0; i < 5; i++)
2033 const unsigned nTSF =
nInput() * 16;
2034 vector<TRGSignalVector*> trker[4];
2035 vector<int> tsfStateChanges;
2038 if (
_type == innerType)
2044 for (
unsigned t = 0; t < nTSF; t++) {
2051 if (
_type == innerType)
2057 vector<TRGSignalVector*> result =
simulateTSF(s, t);
2062 if (result.size() != result2.size()) {
2063 cout <<
"TSF::simulateTSF2 has different response(size)"
2066 for (
unsigned i = 0; i < result.size(); i++) {
2067 if ((* result[i]) != (* result2[i]))
2068 cout <<
"TSF::simulateTSF2 has different response"
2069 <<
"(contents)" << endl;
2077 _tsfOut.push_back(forTracker0);
2078 _tsfOut.push_back(forTracker1);
2082 for (
unsigned i = 0; i < sc.size(); i++) {
2084 for (
unsigned j = 0; j < tsfStateChanges.size(); j++) {
2085 if (tsfStateChanges[j] == sc[i]) {
2090 if (! skip) tsfStateChanges.push_back(sc[i]);
2094 const unsigned pos = t / (nTSF / 4);
2096 addID(* forTracker0, t - 3 * (nTSF / 4));
2097 addID(* forTracker1, t);
2098 trker[3].push_back(forTracker0);
2099 trker[0].push_back(forTracker1);
2100 }
else if (pos == 1) {
2101 addID(* forTracker0, t);
2102 addID(* forTracker1, t - 1 * (nTSF / 4));
2103 trker[0].push_back(forTracker0);
2104 trker[1].push_back(forTracker1);
2105 }
else if (pos == 2) {
2106 addID(* forTracker0, t - 1 * (nTSF / 4));
2107 addID(* forTracker1, t - 2 * (nTSF / 4));
2108 trker[1].push_back(forTracker0);
2109 trker[2].push_back(forTracker1);
2111 addID(* forTracker0, t - 2 * (nTSF / 4));
2112 addID(* forTracker1, t - 3 * (nTSF / 4));
2113 trker[2].push_back(forTracker0);
2114 trker[3].push_back(forTracker1);
2118 if (forTracker0->
active())
2124 std::sort(tsfStateChanges.begin(), tsfStateChanges.end());
2127 for (
unsigned i = 0; i < 4; i++) {
2135 output(i)->signal(b);
2155 for (
unsigned m = 0; m <
nInput(); m++) {
2160 for (
unsigned i = 0; i < 16; i++) {
2161 _secMap.push_back(& ((* b)[0][0][208 + i]));
2162 for (
unsigned j = 0; j < 5; j++) {
2163 _hitMap[j].push_back(& ((* b)[0][0][j * 16 + i]));
2168 for (
unsigned j = 0; j < 4; j++)
2169 _priMap.push_back(& ((* b)[0][0][80 + i * 4 + j]));
2170 for (
unsigned j = 0; j < 4; j++)
2171 _fasMap.push_back(& ((* b)[0][0][144 + i * 4 + j]));
2174 for (
unsigned i = 0; i < 4; i++)
2175 _edg0Map.push_back(& ((* b)[0][0][224 + i]));
2176 for (
unsigned i = 0; i < 4; i++)
2177 _edg1Map.push_back(& ((* b)[0][0][224 + 4 + i]));
2178 for (
unsigned i = 0; i < 4; i++)
2179 _edg2Map.push_back(& ((* b)[0][0][224 + 8 + i]));
2180 for (
unsigned i = 0; i < 4; i++)
2181 _edg3Map.push_back(& ((* b)[0][0][224 + 12 + i]));
2182 for (
unsigned i = 0; i < 4; i++)
2183 _edg4Map.push_back(& ((* b)[0][0][224 + 16 + i]));
2192 for (
unsigned m = 0; m <
nInput(); m++) {
2195 for (
unsigned i = 0; i < 16; i++) {
2196 _secMap.push_back(& ((* b)[0][0][208 + i]));
2197 for (
unsigned j = 0; j < 5; j++)
2199 for (
unsigned j = 0; j < 4; j++)
2200 _priMap.push_back(& ((* b)[0][0][80 + i * 4 + j]));
2201 for (
unsigned j = 0; j < 4; j++)
2202 _fasMap.push_back(& ((* b)[0][0][144 + i * 4 + j]));
2205 for (
unsigned i = 0; i < 4; i++)
2206 _edg0Map.push_back(& ((* b)[0][0][224 + i]));
2207 for (
unsigned i = 0; i < 4; i++)
2208 _edg1Map.push_back(& ((* b)[0][0][224 + 4 + i]));
2209 for (
unsigned i = 0; i < 4; i++)
2210 _edg2Map.push_back(& ((* b)[0][0][224 + 8 + i]));
2216 const unsigned nTSF,
2222 s->push_back(* (
_hitMap[0][0]));
2223 s->push_back(* (
_hitMap[1][nTSF - 1]));
2224 s->push_back(* (
_hitMap[1][0]));
2225 s->push_back(* (
_hitMap[2][nTSF - 1]));
2226 s->push_back(* (
_hitMap[2][0]));
2227 s->push_back(* (
_hitMap[2][1]));
2228 s->push_back(* (
_hitMap[3][nTSF - 2]));
2229 s->push_back(* (
_hitMap[3][nTSF - 1]));
2230 s->push_back(* (
_hitMap[3][0]));
2231 s->push_back(* (
_hitMap[3][1]));
2232 s->push_back(* (
_hitMap[4][nTSF - 2]));
2233 s->push_back(* (
_hitMap[4][nTSF - 1]));
2234 s->push_back(* (
_hitMap[4][0]));
2235 s->push_back(* (
_hitMap[4][1]));
2236 s->push_back(* (
_hitMap[4][2]));
2237 }
else if (t == 1) {
2238 s->push_back(* (
_hitMap[0][1]));
2239 s->push_back(* (
_hitMap[1][0]));
2240 s->push_back(* (
_hitMap[1][1]));
2241 s->push_back(* (
_hitMap[2][0]));
2242 s->push_back(* (
_hitMap[2][1]));
2243 s->push_back(* (
_hitMap[2][2]));
2244 s->push_back(* (
_hitMap[3][nTSF - 1]));
2245 s->push_back(* (
_hitMap[3][0]));
2246 s->push_back(* (
_hitMap[3][1]));
2247 s->push_back(* (
_hitMap[3][2]));
2248 s->push_back(* (
_hitMap[4][nTSF - 1]));
2249 s->push_back(* (
_hitMap[4][0]));
2250 s->push_back(* (
_hitMap[4][1]));
2251 s->push_back(* (
_hitMap[4][2]));
2252 s->push_back(* (
_hitMap[4][3]));
2253 }
else if (t == (nTSF - 2)) {
2254 s->push_back(* (
_hitMap[0][t]));
2255 s->push_back(* (
_hitMap[1][t - 11]));
2256 s->push_back(* (
_hitMap[1][t]));
2257 s->push_back(* (
_hitMap[2][t - 1]));
2258 s->push_back(* (
_hitMap[2][t]));
2259 s->push_back(* (
_hitMap[2][0]));
2260 s->push_back(* (
_hitMap[3][t - 2]));
2261 s->push_back(* (
_hitMap[3][t - 1]));
2262 s->push_back(* (
_hitMap[3][t]));
2263 s->push_back(* (
_hitMap[3][0]));
2264 s->push_back(* (
_hitMap[4][t - 2]));
2265 s->push_back(* (
_hitMap[4][t - 1]));
2266 s->push_back(* (
_hitMap[4][t]));
2267 s->push_back(* (
_hitMap[4][t + 1]));
2268 s->push_back(* (
_hitMap[4][0]));
2269 }
else if (t == (nTSF - 1)) {
2270 s->push_back(* (
_hitMap[0][t]));
2271 s->push_back(* (
_hitMap[1][t - 11]));
2272 s->push_back(* (
_hitMap[1][t]));
2273 s->push_back(* (
_hitMap[2][t - 1]));
2274 s->push_back(* (
_hitMap[2][t]));
2275 s->push_back(* (
_hitMap[2][0]));
2276 s->push_back(* (
_hitMap[3][t - 2]));
2277 s->push_back(* (
_hitMap[3][t - 1]));
2278 s->push_back(* (
_hitMap[3][t]));
2279 s->push_back(* (
_hitMap[3][0]));
2280 s->push_back(* (
_hitMap[4][t - 2]));
2281 s->push_back(* (
_hitMap[4][t - 1]));
2282 s->push_back(* (
_hitMap[4][t]));
2283 s->push_back(* (
_hitMap[4][0]));
2284 s->push_back(* (
_hitMap[4][1]));
2290 s->push_back(* (
_hitMap[0][t]));
2293 s->push_back(* (
_hitMap[1][t]));
2294 s->push_back(* (
_hitMap[2][t - 1]));
2295 s->push_back(* (
_hitMap[2][t]));
2296 s->push_back(* (
_hitMap[2][0]));
2297 s->push_back(* (
_hitMap[3][t - 2]));
2298 s->push_back(* (
_hitMap[3][t - 1]));
2299 s->push_back(* (
_hitMap[3][t]));
2300 s->push_back(* (
_hitMap[3][0]));
2301 s->push_back(* (
_hitMap[4][t - 2]));
2302 s->push_back(* (
_hitMap[4][t - 1]));
2303 s->push_back(* (
_hitMap[4][t]));
2304 s->push_back(* (
_hitMap[4][t + 1]));
2305 s->push_back(* (
_hitMap[4][t + 2]));
2325 const unsigned nTSF,
2331 s->push_back(* (
_hitMap[0][nTSF - 1]));
2332 s->push_back(* (
_hitMap[0][0]));
2333 s->push_back(* (
_hitMap[0][1]));
2334 s->push_back(* (
_hitMap[1][nTSF - 1]));
2335 s->push_back(* (
_hitMap[1][0]));
2336 s->push_back(* (
_hitMap[2][0]));
2337 s->push_back(* (
_hitMap[3][nTSF - 1]));
2338 s->push_back(* (
_hitMap[3][0]));
2339 s->push_back(* (
_hitMap[4][nTSF - 1]));
2340 s->push_back(* (
_hitMap[4][0]));
2341 s->push_back(* (
_hitMap[4][1]));
2342 }
else if (t == (nTSF - 1)) {
2343 s->push_back(* (
_hitMap[0][nTSF - 2]));
2344 s->push_back(* (
_hitMap[0][nTSF - 1]));
2345 s->push_back(* (
_hitMap[0][0]));
2346 s->push_back(* (
_hitMap[1][nTSF - 2]));
2347 s->push_back(* (
_hitMap[1][nTSF - 1]));
2348 s->push_back(* (
_hitMap[2][nTSF - 1]));
2349 s->push_back(* (
_hitMap[3][nTSF - 2]));
2350 s->push_back(* (
_hitMap[3][nTSF - 1]));
2352 s->push_back(* (
_hitMap[4][nTSF - 2]));
2353 s->push_back(* (
_hitMap[4][nTSF - 1]));
2354 s->push_back(* (
_hitMap[4][0]));
2356 s->push_back(* (
_hitMap[0][t - 1]));
2357 s->push_back(* (
_hitMap[0][t]));
2358 s->push_back(* (
_hitMap[0][t + 1]));
2359 s->push_back(* (
_hitMap[1][t - 1]));
2360 s->push_back(* (
_hitMap[1][t]));
2361 s->push_back(* (
_hitMap[2][t]));
2362 s->push_back(* (
_hitMap[3][t - 1]));
2363 s->push_back(* (
_hitMap[3][t]));
2364 s->push_back(* (
_hitMap[4][t - 1]));
2365 s->push_back(* (
_hitMap[4][t]));
2366 s->push_back(* (
_hitMap[4][t + 1]));
2387 const unsigned maxHit)
2393 for (
unsigned ci = 0; ci < cList.size(); ci++) {
2394 unsigned cntHit = 0;
2395 for (
unsigned hi = 0; hi < hitList.size(); hi++) {
2396 TRGState s = (* hitList[hi]).state(cList[ci]);
2398 if (cntHit >= maxHit)
continue;
2399 for (
unsigned j = 0; j < 21; j++) {
2400 if ((* hitList[hi])[j].state(cList[ci])) {
2401 (* result)[21 * (maxHit - 1) - (cntHit * 21) + j]
2402 .set(cList[ci], cList[ci] + 1);
2406 TRGState t = hitList[hi]->state(cList[ci]).subset(13, 8);
2408 << unsigned(t) <<
"(" << t <<
")" << endl;
2420 vector <TRGSignalVector*>
2427 TCSegment* tsi =
_tsSL[tsid];
2428 vector <TRGSignalVector*> result;
2431 vector<bool> fTimeVect;
2435 vector <bool> tmpOutBool;
2446 if (
_type == innerType) {
2447 for (
unsigned i = 0; i < 16; i++) {
2448 Hitmap->push_back((* in)[i]);
2449 (* Hitmap)[i].widen(16);
2451 for (
unsigned i = 0; i < 4; i++) {
2452 pTime.push_back((* in)[i + 16]);
2453 fTime.push_back((* in)[i + 20]);
2455 pri0 = & (*Hitmap)[1];
2456 pri1 = & (*Hitmap)[2];
2457 pri2 = & (*Hitmap)[3];
2459 for (
unsigned i = 0; i < 12; i++) {
2460 Hitmap->push_back((* in)[i]);
2461 (* Hitmap)[i].widen(16);
2463 for (
unsigned i = 0; i < 4; i++) {
2464 pTime.push_back((* in)[i + 12]);
2465 fTime.push_back((* in)[i + 16]);
2467 pri0 = & (*Hitmap)[6];
2468 pri1 = & (*Hitmap)[7];
2469 pri2 = & (*Hitmap)[8];
2474 for (
unsigned i = 0; i < 5; i++) {
2475 pTime.push_back(cc[i]);
2476 fTime.push_back(cc[i]);
2481 int* LUTValue =
new int[changeTime.size()];
2482 if (changeTime.size()) {
2484 const string fn =
"TSF::simulateTSF:tsid=" + to_string(tsid);
2487 int hitPosition = 0;
2493 fTimeBool[9] =
true;
2494 fTimeVect.insert(fTimeVect.begin(), fTimeBool, fTimeBool + 10);
2497 for (
unsigned i = 0; i < changeTime.size(); i++) {
2498 int ct = changeTime[i];
2501 LUTValue[i] = tsi->LUT()->getValue(
unsigned(Hitmap->
state(ct)));
2504 if ((LUTValue[i]) && (eOUT)) {
2505 resultE->
set(fTimeVect, ct);
2509 bool priority1rise = pri0->
riseEdge(ct);
2514 if (priority1rise) {
2517 tmpPTime = unsigned(pTime.
state(ct));
2519 }
else if (priority2rise) {
2522 tmpPTime = unsigned(pTime.
state(ct));
2524 if ((*Hitmap)[0].state(ct)) hitPosition = 2;
2525 else hitPosition = 1;
2530 if ((hitPosition) && (LUTValue[i]) && ((ct - tmpCTime) < 16)) {
2531 tmpOutInt = tmpPTime * pow(2, 4) +
2532 LUTValue[i] * pow(2, 2) + hitPosition;
2533 tmpOutBool =
mkbool(tmpOutInt, 13);
2535 if (hitPosition == 3) {
2536 if (priority1rise) {
2537 resultT->
set(tmpOutBool, ct);
2539 if ((LUTValue[i] == 1) | (LUTValue[i] == 2)) {
2540 if (!((LUTValue[i - 1] == 1) |
2541 (LUTValue[i - 1] == 2)))
2542 resultT->
set(tmpOutBool, ct);
2544 if (!(LUTValue[i - 1])) resultT->
set(tmpOutBool, ct);
2548 if (priority2rise) resultT->
set(tmpOutBool, ct);
2550 if ((LUTValue[i] == 1) | (LUTValue[i] == 2)) {
2551 if (!((LUTValue[i - 1] == 1) |
2552 (LUTValue[i - 1] == 2)))
2553 resultT->
set(tmpOutBool, ct);
2555 if (!(LUTValue[i])) resultT->
set(tmpOutBool, ct);
2563 <<
", pattern=" << Hitmap->
state(ct)
2564 <<
", LUT=" << LUTValue[i]
2565 <<
", pri=" << priority1rise
2566 <<
", sec=" << priority2rise
2567 <<
", hitPos=" << hitPosition
2568 <<
", (clk-tmpCTime)=" << (ct - tmpCTime)
2576 result.push_back(resultT);
2577 result.push_back(resultE);
2586 vector <TRGSignalVector*>
2593 TCSegment* tsi =
_tsSL[tsid];
2594 vector <TRGSignalVector*> result;
2597 vector<bool> fTimeVect;
2601 vector <bool> tmpOutBool;
2613 if (
_type == innerType) {
2614 for (
unsigned i = 0; i < 16; i++) {
2615 Hitmap->push_back((* in)[i]);
2616 (* Hitmap)[i].widen(16);
2618 for (
unsigned i = 0; i < 4; i++) {
2619 pTime.push_back((* in)[i + 16]);
2620 fTime.push_back((* in)[i + 20]);
2622 pri0 = & (*Hitmap)[1];
2623 pri1 = & (*Hitmap)[2];
2624 pri2 = & (*Hitmap)[3];
2626 for (
unsigned i = 0; i < 12; i++) {
2627 Hitmap->push_back((* in)[i]);
2628 (* Hitmap)[i].widen(16);
2630 for (
unsigned i = 0; i < 4; i++) {
2631 pTime.push_back((* in)[i + 12]);
2632 fTime.push_back((* in)[i + 16]);
2634 pri0 = & (*Hitmap)[6];
2635 pri1 = & (*Hitmap)[7];
2636 pri2 = & (*Hitmap)[8];
2641 for (
unsigned i = 0; i < 5; i++) {
2642 pTime.push_back(cc[i]);
2643 fTime.push_back(cc[i]);
2648 int* LUTValue =
new int[changeTime.size()];
2650 int lastFastHit = in->
clock().
min();
2651 if (changeTime.size()) {
2654 const string fn =
"TSF::simulateTSF:tsid=" + to_string(tsid);
2657 int hitPosition = 0;
2663 for (
unsigned i = 0; i < changeTime.size(); i++) {
2665 int ct = changeTime[i];
2670 LUTValue[i] = tsi->LUT()->getValue(
unsigned(st));
2673 bool active = st.active();
2675 const int timeCounter = ct - lastFastHit;
2678 if (timeCounter > 15) {
2688 if ((LUTValue[i])) {
2690 resultE->
set(fTimeVect, ct);
2695 bool priority1rise = pri0->
riseEdge(ct);
2700 if (priority1rise) {
2702 tmpPTime = unsigned(pTime.
state(ct));
2704 }
else if (priority2rise) {
2706 tmpPTime = unsigned(pTime.
state(ct));
2708 if ((*Hitmap)[0].state(ct)) hitPosition = 2;
2709 else hitPosition = 1;
2714 if ((ct - tmpCTime) < 16) {
2715 if ((hitPosition) && (LUTValue[i])) {
2718 tmpOutInt = tmpPTime * pow(2, 4) +
2719 LUTValue[i] * pow(2, 2) + hitPosition;
2720 tmpOutBool =
mkbool(tmpOutInt, 13);
2722 if (hitPosition == 3) {
2723 if (priority1rise) {
2724 resultT->
set(tmpOutBool, ct);
2725 oldLUT = LUTValue[i];
2727 if ((LUTValue[i] == 1) | (LUTValue[i] == 2)) {
2728 if (!((oldLUT == 1) |
2730 resultT->
set(tmpOutBool, ct);
2731 oldLUT = LUTValue[i];
2734 if (!(LUTValue[i - 1])) {
2735 resultT->
set(tmpOutBool, ct);
2736 oldLUT = LUTValue[i];
2741 if ((priority2rise) && (!oldLUT)) resultT->
set(tmpOutBool, ct);
2743 if ((LUTValue[i] == 1) | (LUTValue[i] == 2)) {
2744 if (!((oldLUT == 1) |
2746 resultT->
set(tmpOutBool, ct);
2747 oldLUT = LUTValue[i];
2751 resultT->
set(tmpOutBool, ct);
2752 oldLUT = LUTValue[i];
2765 <<
", pattern=" << st
2766 <<
", LUT=" << LUTValue[i]
2767 <<
", pri=" << priority1rise
2768 <<
", sec=" << priority2rise
2769 <<
", hitPos=" << hitPosition
2770 <<
", (clk-tmpCTime)=" << (ct - tmpCTime)
2779 vector<unsigned> lv;
2780 for (
unsigned i = 0; i < sc.size(); i++) {
2782 unsigned l = unsigned(resultT->
state(sc[i]).
subset(2, 2));
2784 cout <<
"clk=" << sc[i] <<
" LUT output[" << i <<
"]=" << l << endl;
2786 bool found1or2 =
false;
2787 bool found3 =
false;
2788 for (
unsigned i = 0; i < lv.size(); i++) {
2789 if (found1or2 && (lv[i] > 0))
2790 cout <<
"!!! simulateTSF something wrong(found1or2)" << endl;
2791 if (found3 && (lv[i] == 3))
2792 cout <<
"!!! simulateTSF something wrong(found3)" << endl;
2794 if ((lv[i] == 1) or (lv[i] == 2))
2796 else if (lv[i] == 3)
2801 result.push_back(resultT);
2802 result.push_back(resultE);
2810 vector <TRGSignalVector*>
2817 TCSegment* tsi =
_tsSL[tsid];
2818 vector <TRGSignalVector*> result;
2821 vector<bool> fTimeVect;
2836 if (
_type == innerType) {
2837 for (
unsigned i = 0; i < 16; i++) {
2838 Hitmap->push_back((* in)[i]);
2839 (* Hitmap)[i].widen(16);
2841 for (
unsigned i = 0; i < 4; i++) {
2842 pTime.push_back((* in)[i + 16]);
2843 fTime.push_back((* in)[i + 20]);
2845 pri0 = & (*Hitmap)[1];
2846 pri1 = & (*Hitmap)[2];
2847 pri2 = & (*Hitmap)[3];
2849 for (
unsigned i = 0; i < 12; i++) {
2850 Hitmap->push_back((* in)[i]);
2851 (* Hitmap)[i].widen(16);
2853 for (
unsigned i = 0; i < 4; i++) {
2854 pTime.push_back((* in)[i + 12]);
2855 fTime.push_back((* in)[i + 16]);
2857 pri0 = & (*Hitmap)[6];
2858 pri1 = & (*Hitmap)[7];
2859 pri2 = & (*Hitmap)[8];
2864 for (
unsigned i = 0; i < 5; i++) {
2865 pTime.push_back(cc[i]);
2866 fTime.push_back(cc[i]);
2871 vector<unsigned> luts;
2872 int lastFastHit = in->
clock().
min();
2874 if (changeTime.size()) {
2876 const string fn =
"TSF::simulateTSF2:tsid=" + to_string(tsid);
2882 unsigned stateHitPos = 0;
2883 unsigned hitPos = 0;
2884 unsigned timing = 0;
2885 int timePosFound = 0;
2888 unsigned stateLR = 0;
2892 for (
unsigned i = 0; i < changeTime.size(); i++) {
2894 const int ct = changeTime[i];
2899 const unsigned lut = tsi->LUT()->getValue(
unsigned(st));
2900 luts.push_back(lut);
2903 const bool active = st.active();
2905 const int timeCounter = ct - lastFastHit;
2908 if (timeCounter > 15) {
2920 resultE->
set(fTimeVect, ct);
2926 const bool hit1st = pri0->
riseEdge(ct);
2927 const bool hit2nd0 = pri1->
riseEdge(ct);
2928 const bool hit2nd1 = pri2->
riseEdge(ct);
2929 const bool hit2nd = hit2nd0 || hit2nd1;
2934 if (stateHitPos == 0) {
2940 timing = unsigned(pTime.
state(ct));
2943 }
else if (hit2nd) {
2944 if ((* Hitmap)[0].state(ct))
2948 timing = unsigned(pTime.
state(ct));
2955 else if (stateHitPos == 1) {
2956 counterPos = ct - timePosFound;
2957 if (counterPos > 15)
2962 else if (stateHitPos == 2) {
2965 timing = unsigned(pTime.
state(ct));
2969 counterPos = ct - timePosFound;
2970 if (counterPos > 15)
2977 cout <<
"TSF::simulateTSF2 !!! strange state in hit position"
2986 const unsigned val = (timing << 4) | (lut << 2) | hitPos;
2988 resultT->
set(output, ct);
2990 if ((lut == 1) || (lut == 2))
2996 if (((lut == 1) || (lut == 2)) && (stateHitPos == 0))
2998 <<
"!!! state machines incosistent" << endl;
3004 else if (stateLR == 1) {
3006 if (counterPos > 15)
3011 else if (stateLR == 2) {
3013 if ((lut == 1) || (lut == 2)) {
3014 const unsigned val = (timing << 4) | (lut << 2) |
3017 resultT->
set(output, ct);
3022 if (counterPos > 15)
3030 cout <<
"TSF::simulateTSF2 !!! strange state in L/R decision"
3038 <<
", pri=" << hit1st
3039 <<
", sec=" << hit2nd
3040 <<
", hPos=" << hitPos
3041 <<
", ctr=" << counterPos
3042 <<
", states=" << stateHitPos <<
"," << stateLR
3051 vector<unsigned> lv;
3052 for (
unsigned i = 0; i < sc.size(); i++) {
3054 unsigned l = unsigned(resultT->
state(sc[i]).
subset(2, 2));
3056 cout <<
"clk=" << sc[i] <<
" LUT output[" << i <<
"]=" << l << endl;
3060 result.push_back(resultT);
3061 result.push_back(resultE);
DataType Phi() const
The azimuth angle.
A Class to store the Monte Carlo particle information.
Low-level class to create/modify relations between StoreArrays.
int getEntries() const
Get the number of elements.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
A class to represent a trigger board.
A class to represent a wire hit in CDC.
A class to represent a wire in CDC.
virtual const TRGSignal & signal(void) const =0
returns trigger output. Null will returned if no signal.
A class to represent a CDC merger board.
std::vector< TRGSignal * > _priMap
Internal data of the priority hit timing.
TClonesArray * m_hitPatternInformation
Stores hitpattern information.
std::vector< TRGSignal * > _edg4Map
Internal data of the edge timing information.
boardType _type
Unit type.
std::vector< TRGSignal * > _edg0Map
Internal data of the edge timing information.
TTree * m_treeInputTSF
ROOT TTree for input.
bool m_makeRootFile
make ROOT file or not
const TRGCDC & _cdc
Members.
TClonesArray * m_particleEfficiency
[Efficiency, Pt, # MC TS] Efficiency = -1 means that # MC TS is 0.
std::vector< TRGSignalVector * > _toBeDeleted
One time info. to be deleted in next event;.
std::vector< TRGSignal * > _edg1Map
Internal data of the edge timing information.
TClonesArray * m_nnPatternInformation
[superlayer id, lrDriftTime, timeWire0, timeWire1, ..., ...]
TTree * m_treeOutputTSF
ROOT TTree for output.
std::vector< TRGSignal * > _edg2Map
Internal data of the edge timing information.
TClonesArray * m_tsInformation
[SuperLayer Id, Wire Id, Priority Timing]
std::vector< TRGSignalVector * > _tsfOut
TSF response storeage.
std::vector< TRGSignal * > _hitMap[5]
Internal data of wire hit map.
TTree * m_treeNNTSF
ROOT Tree for NNTSF.
std::vector< TRGSignal * > _secMap
Internal data of the priority cell hit position flag.
std::vector< TCSegment * > _tsSL
list of TSF
std::vector< TRGSignalVector * > _tsfIn
TSF input storage.
TFile * m_fileTSF
ROOT file.
std::vector< TRGSignal * > _edg3Map
Internal data of the edge timing information.
bool m_logicLUTFlag
0 is Logic. 1 is LUT.
std::vector< TRGSignal * > _fasMap
Internal data of the fastest hit timing.
boardType
enum of boardType of TrackSegmentFinder
A class to represent a wire hit in CDC.
A class to represent a wire in CDC.
The instance of TRGCDC is a singleton.
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.
vector< TRGSignalVector * > simulateTSFOld(TRGSignalVector *in, unsigned id)
Simulate TSF response (unified version)
unsigned size(void) const
returns bit size.
static std::string tab(void)
returns tab spaces.
~TRGCDCTrackSegmentFinder()
Destructor.
const TRGSignalVector & set(const TRGState &, int clockPosition)
sets state at given clock.
static TRGCDC * getTRGCDC(void)
returns TRGCDC object.
void fastestTimingOuter(unsigned tsfID, const unsigned nTSF, TRGSignalVector &s) const
Make TRGSignals for the fastest timing bits.
int mcLR(void) const
returns mc left/right information
void simulateOuter(void)
Firmware simulation for the outers. yi.
TRGState subset(unsigned i, unsigned n) const
returns subset from i with n bits.
void copy2bool(bool *array) const
returns a filled array.
TRGState state(int clockPosition) const
returns state at given clock position.
TRGSignalVector * packerOuterTracker(vector< TRGSignalVector * > &, vector< int > &, const unsigned)
Packing output for tracker.
const TRGClock & clock(void) const
returns clock.
void priorityTiming(unsigned tsfID, const unsigned nTSF, TRGSignalVector &s, const TRGSignal ¢er, const TRGSignal &right, const TRGSignal &left) const
Make TRGSignals for the priority timing bits.
void terminate(void)
terminate
const TRGClock & clockData(void) const
returns data clock.
TRGSignalVector * packerForTracker(vector< TRGSignalVector * > &, vector< int > &, const unsigned)
Output packer for tracker.
bool riseEdge(int clockPosition) const
returns true if signal is active and rising edge in give clock position.
const CDCHit * hit(void) const
Access to CDCHit.
void push_back(const TRGCDCMerger *)
push back the Mergers of this TSF
vector< TRGSignalVector * > findTSHit(TRGSignalVector *eachInput, int)
Use LUT for find TSHit.
vector< TRGSignalVector * > simulateTSF(TRGSignalVector *in, unsigned id)
Simulate TSF response (unified version, 2016/07/12)
void inputOuter(const unsigned id, const unsigned nTSF, TRGSignalVector *s)
Creates input signals to TSF for the outer.
const std::string & name(void) const
returns name.
std::vector< int > stateChanges(void) const
returns a list of clock position of state change.
static void enterStage(const std::string &stageName)
Declare that you enter new stage.
unsigned nInput(void) const
returns input channels.
int min(void) const
returns min. clock point.
TRGCDCTrackSegmentFinder(const TRGCDC &, bool makeRootFile, bool logicLUTFlag)
Constructor.
const TRGCDCCellHit * hit(void) const
returns a pointer to a TRGCDCCellHit.
const TRGSignal & signal(void) const override
returns an input to the trigger. This is sync'ed to 1GHz clock.
static std::string itostring(int i)
converts int to string. (Use boost::lexical_cast)
void simulateInner(void)
Firmware simulation for the outers. yi.
int max(void) const
returns max. clock point.
unsigned nSegments(void) const
returns # of track segments.
void saveTSFResults(std::vector< TRGCDCSegmentHit * > *segmentHitsSL)
save result of TSF
static void addID(TRGSignalVector &s, unsigned id)
Add TSF ID to timing signal vector for the output.
const TRGCDCWireHit * hit(void) const
returns a pointer to a TRGCDCWireHit.
unsigned nSuperLayers(void) const
returns # of super layers.
void saveTSInformation(std::vector< TRGCDCSegment * > &tss)
save the TS info
const TRGCDCSegment & segment(unsigned id) const
returns a track segment.
void hitMapOuter(void)
Creates the hit maps for the outer.
void simulate2(void)
Firmware simulation. Unified version of inner and outer : yi.
bool state(int clockPosition) const
returns true if signal is active in given clock position.
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.
bool active(void) const
returns true if there is a signal.
const TRGSignalVector & clockCounter(void) const
returns the clock counter.
void inputInner(const unsigned id, const unsigned nTSF, TRGSignalVector *s)
Creates input signals to TSF for the inner.
const TRGCDCLayer * layer(unsigned id) const
returns a pointer to a layer. 0 will be returned if 'id' is invalid.
static void leaveStage(const std::string &stageName)
Declare that you leave a stage.
vector< TRGSignalVector * > simulateTSF2(TRGSignalVector *in, unsigned id)
Simulate TSF response (unified version, state machine)
unsigned nCells(void) const
returns # of cells.
unsigned iCDCSimHit(void) const
return index of CDCSimHit
void saveNNTSInformation(std::vector< TRGCDCSegment * > &tss)
Saves NNTS information. Only when ts is hit.
void simulate(void)
Firmware simulation. yi.
void hitMapInner(void)
Creates the hit maps for the inner.
TRGSignalVector * packerOuterEvt(vector< TRGSignalVector * >, vector< int >, int)
Packing output for evtTime & Low pT.
double mkint(TRGState)
tranformatoin into integer
unsigned nOutput(void) const
returns output channels.
boardType type(void) const
board type of TSF
void fastestTimingInner(unsigned tsfID, const unsigned nTSF, TRGSignalVector &s) const
Make TRGSignals for the fastest timing bits.
vector< bool > mkbool(int, int)
tranformatoin into bool
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Abstract base class for different kinds of events.