14 #define TRG_SHORT_NAMES
15 #define TRGCDC_SHORT_NAMES
18 #define PROGRAM_NAME "TRGCDCTrackSegmentSimulator"
19 #define PROGRAM_VERSION "version 0.00"
20 #define ENV_PATH "BELLE2_LOCAL_DIR"
22 #define CONFIG "TRGCDCConfig_0_20101111_1051_2013beamtest.dat"
27 #include "trg/trg/Debug.h"
28 #include "trg/trg/Utilities.h"
29 #include "trg/trg/State.h"
30 #include "trg/trg/Channel.h"
31 #include "trg/cdc/TRGCDC.h"
32 #include "trg/cdc/Wire.h"
33 #include "trg/cdc/Segment.h"
34 #include "trg/cdc/TrackSegmentFinder.h"
35 #include "framework/gearbox/Gearbox.h"
38 #include "trg/cdc/DisplayRphi.h"
39 #include "trg/cdc/DisplayHough.h"
40 namespace Belle2_TRGCDC {
41 Belle2::TRGCDCDisplayRphi* D = 0;
48 using namespace Belle2_TRGCDC;
51 void readFile(
const string& filename,
57 main(
int argc,
char* argv[])
60 cout << PROGRAM_NAME <<
" ... " << PROGRAM_VERSION << endl;
65 cout << PROGRAM_NAME <<
" needs 3 arguments" << endl;
68 const unsigned dl = stoi(
string(argv[1]));
69 const unsigned sl = stoi(
string(argv[2]));
70 const string fn = string(argv[3]);
75 const string path = getenv(ENV_PATH);
76 const string patht = path +
"/data/trg/cdc/";
77 vector<std::string> backends;
78 backends.push_back(
"file:");
79 string filename =
"geometry/Belle2.xml";
80 Gearbox& gearbox = Gearbox::getInstance();
81 gearbox.setBackends(backends);
82 gearbox.open(filename);
85 const string configFile = patht + CONFIG;
86 const unsigned simulationMode = 3;
87 const unsigned fastSimulationMode = 0;
88 const unsigned firmwareSimulationMode = 0;
89 const int firmwareSimulationStart = 0;
90 const int firmwareSimulationStop = 32 * 32 - 1;
91 const unsigned makeRootFile = 0;
92 const bool perfect2DFinder =
false;
93 const bool perfect3DFinder =
false;
94 const string innerTSLUTFile = patht +
"innerLUT_v2.2.coe";
95 const string outerTSLUTFile = patht +
"outerLUT_v2.2.coe";
96 const string rootTRGCDCFile =
"TRGCDC.root";
97 const string rootFitter3DFile =
"Fitter3D.root";
98 const unsigned houghFinderPeakMin = 5;
99 const string houghMappingFilePlus = patht +
"HoughMappingPlus20140807.dat";
100 const string houghMappingFileMinus = patht +
101 "HoughMappingMinus20140808.dat";
102 const unsigned houghDoit = 2;
103 const unsigned fLogicLUTTSF = 0;
104 const unsigned fLRLUT = 1;
105 const unsigned fevtTime = 1;
106 const unsigned fmclr = 0;
107 const double inefficiency = 0;
108 const unsigned fileTSF = 0;
109 const unsigned fileETF = 0;
110 const unsigned fverETF = 0;
111 const unsigned fprintFirmETF = 0;
112 const unsigned fileHough3D = 0;
113 const unsigned finder3DMode = 2;
114 const unsigned fileFitter3D = 0;
115 const unsigned trgCDCDataInputMode = 0;
118 TRGCDC* cdc = TRGCDC::getTRGCDC(configFile,
121 firmwareSimulationMode,
122 firmwareSimulationStart,
123 firmwareSimulationStop,
132 houghMappingFilePlus,
133 houghMappingFileMinus,
147 trgCDCDataInputMode);
153 const TRGClock& dc = TRGCDC::getTRGCDC()->dataClock();
157 readFile(fn, isb, osbe, osbt);
163 isbd.push_back(& dummy);
164 for (
unsigned i = 1; i < tsfb.
nInput(); i++)
175 #ifdef TRGCDC_DISPLAY
182 cout << PROGRAM_NAME <<
" ... terminated" << endl;
186 readFile(
const string& fn,
193 ifstream ifile(fn.c_str(), ios::in);
195 cout << PROGRAM_NAME <<
" !!! can not open file" << endl
196 <<
" " << fn << endl;
201 const TRGClock& dc = TRGCDC::getTRGCDC()->dataClock();
202 const unsigned eSize = 625;
203 const unsigned tSize = 1054 - 625;
204 const unsigned mSize = 1309 - 1053 - 9;
211 while (! ifile.eof()) {
212 ifile.getline(b, 10000);
215 if (l.size() == 0)
continue;
216 if (b[0] ==
'#')
continue;
217 if (b[0] ==
'S')
continue;
220 l = TRGUtil::cdrstring(l);
222 l = TRGUtil::cdrstring(l);
223 const string dat = TRGUtil::carstring(l);
224 l = TRGUtil::cdrstring(l);
229 TRGState t = a.subset(eSize, tSize);
231 TRGState c = a.subset(1054 + mSize, 9);
232 unsigned cMgr = unsigned(c);
244 osbe.push_back(eOut);
245 osbt.push_back(tOut);