Belle II Software development
TRGCDCT3DConverterModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8//---------------------------------------------------------------
9// $Id$
10//---------------------------------------------------------------
11// Filename : TRGCDCT3DConverterModule.cc
12// Section :
13// Owner :
14// Email :
15//---------------------------------------------------------------
16// Description : TRGCDCT3DConverter Module
17//---------------------------------------------------------------
18// $Log$
19//---------------------------------------------------------------
20
21
22#include <trg/cdc/modules/trgcdct3dConverter/TRGCDCT3DConverterModule.h>
23#include <bitset>
24#include "trg/cdc/Fitter3D.h"
25#include "trg/cdc/Fitter3DUtility.h"
26#include "trg/cdc/JSignal.h"
27#include "trg/cdc/JSignalData.h"
28#include "boost/multi_array.hpp"
29
30using namespace std;
31using namespace Belle2;
32using namespace TRGCDCT3DCONVERTERSPACE;
33
34REG_MODULE(TRGCDCT3DConverter);
35
37 : Module::Module()
38{
40 setDescription("TRGCDCT3DConverter module");
41 addParam("hitCollectionName", m_hitCollectionName,
42 "Name of the input StoreArray of CDCTriggerSegmentHits.",
43 string("CDCTriggerSegmentHits0"));
44 addParam("addTSToDatastore", m_addTSToDatastore,
45 "If true, adds TS to datastore",
46 true);
47 addParam("EventTimeName", m_EventTimeName,
48 "Name of the event time object.",
49 string("BinnedEventT00"));
50 addParam("addEventTimeToDatastore", m_addEventTimeToDatastore,
51 "If true, adds event time to datastore",
52 true);
53 addParam("inputCollectionName", m_inputCollectionName,
54 "Name of the StoreArray holding the input tracks from the 2D finder.",
55 string("TRGCDC2DFinderTracks0"));
56 addParam("add2DFinderToDatastore", m_add2DFinderToDatastore,
57 "If true, adds 2D Finder results to datastore",
58 true);
59 addParam("outputCollectionName", m_outputCollectionName,
60 "Name of the StoreArray holding the 3D output tracks.",
61 string("TRGCDC3DFitterTracks0"));
62 addParam("add3DToDatastore", m_add3DToDatastore,
63 "If true, adds 3D results to datastore",
64 true);
65 addParam("fit3DWithTSIM", m_fit3DWithTSIM,
66 "0: use firmware results. 1: Fits with fast TSIM. 2: Fits with firm TSIM",
67 unsigned(0));
68 addParam("firmwareResultCollectionName", m_firmwareResultCollectionName,
69 "Name of the StoreArray holding the firmware results.",
70 string("TRGCDCT3DUnpackerStores0"));
71 addParam("isVerbose", m_isVerbose,
72 "If not zero, prints detail information.",
73 unsigned(0));
74}
75
79
83
97
101
105
107{
108 //cout<<"Event"<<endl;
109
110 if (m_addTSToDatastore) {
111 // Process firmware stereo TS
112 // stTsfFirmwareInfo[stSL][tsIndex][iClk][id, rt, lr, pr, foundTime]
113 boost::multi_array<double, 4> stTsfFirmwareInfo{boost::extents[4][15][48][5]};
114 storeTSFirmwareData(stTsfFirmwareInfo);
115
116 // stTsfInfo[stSL][iTS][id, rt, lr, pr, foundTime]
117 boost::multi_array<double, 3> stTsfInfo{boost::extents[4][0][5]};
118
119 filterTSData(stTsfFirmwareInfo, stTsfInfo);
120 // Add to TS datastore
121 addTSDatastore(stTsfInfo, 1);
122 }
123
125 // Process firmware 2D
126
127 // t2DFirmwareInfo[tIndex][iClk][valid, isOld, charge, rho, phi0]
128 boost::multi_array<double, 3> t2DFirmwareInfo{boost::extents[4][48][5]};
129 // t2DTsfFirmwareInfo[tIndex][iClk][axSL][id, rt, lr, pr]
130 boost::multi_array<double, 4> t2DTsfFirmwareInfo{boost::extents[4][48][5][4]};
131 store2DFirmwareData(t2DFirmwareInfo, t2DTsfFirmwareInfo);
132
133 // t2DInfo[tIndex][charge, rho, phi0]
134 boost::multi_array<double, 2> t2DInfo{boost::extents[0][3]};
135 // t2DTsfInfo[tIndex][axSL][id, rt, lr, pr, -9999]
136 boost::multi_array<double, 3> t2DTsfInfo{boost::extents[0][5][5]};
137
138 filter2DData(t2DFirmwareInfo, t2DTsfFirmwareInfo, t2DInfo, t2DTsfInfo);
139 add2DDatastore(t2DInfo, t2DTsfInfo);
140 }
141
143 if (!m_eventTime.isValid()) m_eventTime.create();
144 // add eventTime
145 bool validEventTime = 0;
146 int eventTime = 0;
147 for (int iClk = 0; iClk < m_firmwareResults.getEntries() - 17 - 1; iClk++) {
149 if (result->m_t3dtrk0_evtTimeValid_delay) {
150 validEventTime = 1;
151 eventTime = result->m_t3dtrk0_evtTime_delay;
152 }
153 }
154 if (validEventTime) {
155 m_eventTime->addBinnedEventT0(eventTime, Const::CDC);
156 }
157 if (m_isVerbose) {
158 if (validEventTime) cout << "[ET] valid: 1 eventTime:" << eventTime << endl;
159 else cout << "[ET] valid: 0" << endl;
160 }
161 }
162
163 if (m_add3DToDatastore) {
164 // t3DFirmwareInfo[tIndex][iClk][2DValid, 2DisOld, TSFValid, EventTimeValid, eventTime, charge, rho, phi0, z0, cot, zchi]
165 boost::multi_array<double, 3> t3DFirmwareInfo{boost::extents[4][48][11]};
166
167 // m_fit3DWithTSIM 0:firmware 1:fastSim 2:firmSim
168 // Use Firmware results
169 if (m_fit3DWithTSIM == 0) store3DFirmwareData(t3DFirmwareInfo);
170 // Use fast sim with debug
171 if (m_fit3DWithTSIM == 1) store3DFastSimData(t3DFirmwareInfo);
172 // Use firm sim with debug
173 if (m_fit3DWithTSIM == 2) store3DFirmSimData(t3DFirmwareInfo);
174
175 // t3DInfo[eventTime, charge, rho, phi0, z0, cot, zchi]
176 boost::multi_array<double, 2> t3DInfo{boost::extents[0][7]};
177
178
179 filter3DData(t3DFirmwareInfo, t3DInfo);
180
181 if (m_fit3DWithTSIM == 0) add3DDatastore(t3DInfo);
182 else add3DDatastore(t3DInfo, 0);
183 }
184
185 if (m_isVerbose > 1) {
187 }
188
189
190
191 //vector<int> t2DClks;
192 //vector<int> t2DTrackId;
193 //filter2DData(t2DFirmwareInfo, t2DTsfFirmwareInfo, t2DInfo, t2DTsfInfo, t2DClks, t2DTrackId);
194
197 //for(unsigned iTrack = 0; iTrack < t2DInfo.size(); iTrack++)
198 //{
199 // cout<<"[2D] iClk: "<<t2DClks[iTrack]<<" trackid: "<<t2DTrackId[iTrack]<<" charge:"<<t2DInfo[iTrack][0]<<endl;
200 // int rho_s = t2DInfo[iTrack][1];
201 // int rho_2Dint = toSigned(rho_s, 7);
202 // double rho = 0.3*34/30/1.5e-4/abs(rho_2Dint);
203 // int rho_3Dint = rho*(pow(2,11)-0.5)/2500;
204 // cout<<" rho_s "<<rho_s<<" rho_int: "<<rho_2Dint<<" rho: "<<rho<<" rho_3Dint: "<<rho_3Dint<<endl;;
205 // //cout<<" phi0: "<<t2DInfo[iTrack][2]<<" s: "<<toSigned(t2DInfo[iTrack][2],13)<<" convert: "<<endl;
206 // //for(unsigned iAx = 0; iAx < t2DTsfInfo[iTrack].size(); iAx++)
207 // //{
208 // // cout<<" iAx: "<<iAx<<" id: "<<t2DTsfInfo[iTrack][iAx][0]<<" lr: "<<t2DTsfInfo[iTrack][iAx][2]<<endl;
209 // //}
210 //}
212 //for (unsigned iTrack = 0; iTrack < t3DInfo.size(); iTrack++)
213 //{
214 // cout<<"iClk: "<<t3DClks[iTrack]<<" trackid: "<<t3DTrackId[iTrack]<<" validTS: "<<bitset<4>(t3DInfo[iTrack][0])<<" z0: "<<t3DInfo[iTrack][1]<<" cot: "<<t3DInfo[iTrack][2]<<" zchi: "<<t3DInfo[iTrack][3]<<endl;
215 //}
216
217
218}
219
220int TRGCDCT3DConverterModule::toTSID(int iSL, int iWire)
221{
222 vector<int> nWires = {160, 160, 192, 224, 256, 288, 320, 352, 384};
223 int id = 0;
224 for (int i = 0; i < (int)iSL; i++) {
225 id += nWires[i];
226 }
227
228//Correct the segmentID. The zero points of raw segmentID for four boards are different.
229 if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore0") {
230 id = id + iWire + nWires[(int)iSL] / 4.0 * 0;
231 if (iWire + nWires[(int)iSL] / 4.0 * 0 > nWires[(int)iSL]) {
232 id = id - nWires[(int)iSL];
233 }
234 } else if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore1") {
235 id = id + iWire + nWires[(int)iSL] / 4.0 * 1;
236 if (iWire + nWires[(int)iSL] / 4.0 * 1 > nWires[(int)iSL]) {
237 id = id - nWires[(int)iSL];
238 }
239 } else if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore2") {
240 id = id + iWire + nWires[(int)iSL] / 4.0 * 2;
241 if (iWire + nWires[(int)iSL] / 4.0 * 2 > nWires[(int)iSL]) {
242 id = id - nWires[(int)iSL];
243 }
244 } else if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore3") {
245 id = id + iWire + nWires[(int)iSL] / 4.0 * 3;
246 if (iWire + nWires[(int)iSL] / 4.0 * 3 > nWires[(int)iSL]) {
247 id = id - nWires[(int)iSL];
248 }
249 }
250 //cout<<"toID: iSL"<<iSL<<" iWire:"<<iWire<<" id:"<<id<<endl;
251 return id;
252}
253
254int TRGCDCT3DConverterModule::toSigned(int value, int nBits)
255{
256 int signMask = 1 << (nBits - 1);
257 if (value & signMask) {
258 int mask = (1 << nBits) - 1;
259 value |= ~mask;
260 }
261 return value;
262}
263
265//int TRGCDCT3DConverterModule::t2DRhoTot3DRho(int value, bool isSigned)
266//{
267// if (value == 0) return 2047;
268// if (value == 125) {
269// B2WARNING("Bug in 2D parser.");
270// return 451;
271// }
272// if (isSigned) return int(0.3 * 34 / 30 / 1.5e-4 / abs(toSigned(value, 7)) * (pow(2, 11) - 0.5) / 2500);
273// else return int(0.3 * 34 / 30 / 1.5e-4 / abs(value) * (pow(2, 11) - 0.5) / 2500);
274//}
275//
276
278{
279 double phiReal = 45 + 90. / 80 * (1 + phi);
280 if (toSigned(rho, 7) >= 0) phiReal -= 90;
281 else phiReal += 90;
282
283 while (phiReal > 180) {
284 phiReal -= 360;
285 }
286 while (phiReal < -180) {
287 phiReal += 360;
288 }
289
290 int phiInt = phiReal * (pow(2, 12) - 0.5) / 180;
291 return phiInt;
292}
293
294void TRGCDCT3DConverterModule::filterTSData(boost::multi_array<double, 4>& tsfFirmwareInfo,
295 boost::multi_array<double, 3>& tsfInfo)
296{
297 // iSl is stereo SL index
298 for (unsigned iSL = 0; iSL < tsfFirmwareInfo.shape()[0]; iSL++) {
299 unsigned iTS_filter = 0;
300 for (unsigned iTS = 0; iTS < tsfFirmwareInfo.shape()[1]; iTS++) {
301 for (unsigned iClk = 0; iClk < tsfFirmwareInfo.shape()[2]; iClk++) {
302 double id = tsfFirmwareInfo[iSL][iTS][iClk][0];
303 double rt = tsfFirmwareInfo[iSL][iTS][iClk][1];
304 double lr = tsfFirmwareInfo[iSL][iTS][iClk][2];
305 double pr = tsfFirmwareInfo[iSL][iTS][iClk][3];
306 double ft = tsfFirmwareInfo[iSL][iTS][iClk][4];
307
308 if (pr != 0) {
309 double ts_ref[5] = {id, rt, lr, pr, ft};
310 boost::multi_array_ref<double, 1> ts((double*)ts_ref, boost::extents[5]);
311 tsfInfo.resize(boost::extents[4][tsfInfo.shape()[1] + 1][5]);
312 tsfInfo[iSL][iTS_filter++] = ts;
313 }
314
315 }
316 }
317 }
318}
319
322//void TRGCDCT3DConverterModule::filter3DData(std::vector<std::vector<std::vector<double> > > & t3DFirmwareInfo, std::vector<std::vector<double> > & t3DInfo, std::vector<int> & t3DClks, std::vector<int> & t3DTrackId)
323//{
324// for (unsigned iTrack = 0; iTrack < t3DFirmwareInfo.size(); iTrack++)
325// {
326// for (unsigned iClk = 0; iClk < t3DFirmwareInfo[iTrack].size(); iClk++)
327// {
328// double valid2D = t3DFirmwareInfo[iTrack][iClk][0];
329// double validTS = t3DFirmwareInfo[iTrack][iClk][1];
330// bitset<4> tsf_fnf(validTS);
331// int nStHits = int(tsf_fnf[0]) + int(tsf_fnf[1]) + int(tsf_fnf[2]) + int(tsf_fnf[3]);
332// if (valid2D != 1 || nStHits < 2) continue;
333// double z0 = t3DFirmwareInfo[iTrack][iClk][2];
334// double cot = t3DFirmwareInfo[iTrack][iClk][3];
335// double zchi = t3DFirmwareInfo[iTrack][iClk][4];
336// //cout<<"valid2D:"<<valid2D<<" tsf_fnf: "<<tsf_fnf<<" nSt: "<<nStHits<<endl;
337// vector<double> track = {validTS, z0, cot, zchi};
338// t3DInfo.push_back(track);
339// t3DClks.push_back(iClk);
340// t3DTrackId.push_back(iTrack);
341// }
342// }
343//}
344
345
346// t2DFirmwareInfo[tIndex][iClk][valid, isOld, charge, rho, phi0]
347// t2DTsfFirmwareInfo[tIndex][iClk][axSL][id, rt, lr, pr]
348// t2DInfo[tIndex][charge, rho, phi0]
349// t2DTsfInfo[tIndex][axSL][id, rt, lr, pr, -9999]
350void TRGCDCT3DConverterModule::filter2DData(boost::multi_array<double, 3>& t2DFirmwareInfo,
351 boost::multi_array<double, 4>& t2DTsfFirmwareInfo, boost::multi_array<double, 2>& t2DInfo,
352 boost::multi_array<double, 3>& t2DTsfInfo)
353{
354
355 for (unsigned iTrack = 0; iTrack < t2DFirmwareInfo.shape()[0]; iTrack++) {
356 for (unsigned iClk = 0; iClk < t2DFirmwareInfo.shape()[1]; iClk++) {
357 if (t2DFirmwareInfo[iTrack][iClk][0] == 0) continue;
358 // TODO make an algorithm to follow the track.
359
360 //choose new tracks
361 //if (t2DInfo.shape()[0] != 0 && t2DFirmwareInfo[iTrack][iClk][1] == 1) continue;
362
363 double track_ref[3] = {t2DFirmwareInfo[iTrack][iClk][2], t2DFirmwareInfo[iTrack][iClk][3], t2DFirmwareInfo[iTrack][iClk][4]};
364 boost::multi_array_ref<double, 1> track((double*)track_ref, boost::extents[3]);
365 t2DInfo.resize(boost::extents[t2DInfo.shape()[0] + 1][3]);
366 t2DInfo[t2DInfo.shape()[0] - 1] = track;
367
368
369 boost::multi_array<double, 2> axTSInfo{boost::extents[5][5]};
370 for (unsigned iAx = 0; iAx < t2DTsfFirmwareInfo.shape()[2]; iAx++) {
371 double id = t2DTsfFirmwareInfo[iTrack][iClk][iAx][0];
372 double rt = t2DTsfFirmwareInfo[iTrack][iClk][iAx][1];
373 double lr = t2DTsfFirmwareInfo[iTrack][iClk][iAx][2];
374 double pr = t2DTsfFirmwareInfo[iTrack][iClk][iAx][3];
375
376 axTSInfo[iAx][0] = id;
377 axTSInfo[iAx][1] = rt;
378 axTSInfo[iAx][2] = lr;
379 axTSInfo[iAx][3] = pr;
380 axTSInfo[iAx][4] = -9999;
381 }
382 t2DTsfInfo.resize(boost::extents[t2DTsfInfo.shape()[0] + 1][5][5]);
383 t2DTsfInfo[t2DTsfInfo.shape()[0] - 1] = axTSInfo;
384 }
385 }
386 //for(unsigned iTrack = 0; iTrack < t2DInfo.size(); iTrack++)
387 //{
388 // cout<<"iTrack: "<<iTrack<<" charge:"<<t2DInfo[iTrack][0]<<" rho: "<<t2DInfo[iTrack][1]<<" phi0: "<<t2DInfo[iTrack][2]<<endl;
389 // for(unsigned iAx = 0; iAx < t2DTsfInfo[iTrack].size(); iAx++)
390 // {
391 // cout<<" iAx: "<<iAx<<" id: "<<t2DTsfInfo[iTrack][iAx][0]<<" lr: "<<t2DTsfInfo[iTrack][iAx][2]<<endl;
392 // }
393 //}
394}
395
400//void TRGCDCT3DConverterModule::filter2DData(std::vector<std::vector<std::vector<double> > > & t2DFirmwareInfo, std::vector<std::vector<std::vector<std::vector<double> > > > & t2DTsfFirmwareInfo, std::vector<std::vector<double> > & t2DInfo, std::vector<std::vector<std::vector<double> > > & t2DTsfInfo, std::vector<int> & t2DClks, std::vector<int> & t2DTrackId)
401//{
402// for (unsigned iTrack = 0; iTrack < t2DFirmwareInfo.size(); iTrack++)
403// {
404// for (unsigned iClk = 0; iClk < t2DFirmwareInfo[iTrack].size(); iClk++)
405// {
406// if (t2DFirmwareInfo[iTrack][iClk][0] == 0) continue;
407//
408// vector<double> track = {t2DFirmwareInfo[iTrack][iClk][1], t2DFirmwareInfo[iTrack][iClk][2], t2DFirmwareInfo[iTrack][iClk][3]};
409// t2DInfo.push_back(track);
410//
411// vector<vector< double> > axTSInfo (5, vector<double> (5));
412// for (unsigned iAx = 0; iAx < t2DTsfFirmwareInfo[iTrack][iClk].size(); iAx++)
413// {
414// double id = t2DTsfFirmwareInfo[iTrack][iClk][iAx][0];
415// double rt = t2DTsfFirmwareInfo[iTrack][iClk][iAx][1];
416// double lr = t2DTsfFirmwareInfo[iTrack][iClk][iAx][2];
417// double pr = t2DTsfFirmwareInfo[iTrack][iClk][iAx][3];
418//
419// axTSInfo[iAx][0] = id;
420// axTSInfo[iAx][1] = rt;
421// axTSInfo[iAx][2] = lr;
422// axTSInfo[iAx][3] = pr;
423// axTSInfo[iAx][4] = -9999;
424// }
425// t2DTsfInfo.push_back(axTSInfo);
426//
427// t2DClks.push_back(iClk);
428// t2DTrackId.push_back(iTrack);
429// }
430// }
431// //for(unsigned iTrack = 0; iTrack < t2DInfo.size(); iTrack++)
432// //{
433// // cout<<"iTrack: "<<iTrack<<" charge:"<<t2DInfo[iTrack][0]<<" rho: "<<t2DInfo[iTrack][1]<<" phi0: "<<t2DInfo[iTrack][2]<<endl;
434// // for(unsigned iAx = 0; iAx < t2DTsfInfo[iTrack].size(); iAx++)
435// // {
436// // cout<<" iAx: "<<iAx<<" id: "<<t2DTsfInfo[iTrack][iAx][0]<<" lr: "<<t2DTsfInfo[iTrack][iAx][2]<<endl;
437// // }
438// // cout<<" iClk: "<<t2DClks[iTrack]<<" trackid: "<<t2DTrackId[iTrack]<<endl;
439// //}
440//}
441
444// t3DInfo[eventTime, charge, rho, phi0, z0, cot, zchi]
445void TRGCDCT3DConverterModule::add2DDatastore(boost::multi_array<double, 2>& t2DInfo,
446 boost::multi_array<double, 3>& t2DTsfInfo)
447{
448 // Add 2D track
449 for (unsigned iTrack = 0; iTrack < t2DInfo.shape()[0]; ++iTrack) {
450 double charge = 0, phi0_i = 0, omega = 0, chi2D = 0;
451 //double phi0_c = 0;
452 //Convert
453 charge = t2DInfo[iTrack][0] == 2 ? -1 : 1;
454 //phi0_c = t2DPhiTot3DPhi(t2DInfo[iTrack][2], t2DInfo[iTrack][1]) / (pow(2, 12) - 0.5) * M_PI;
455 //phi0_i = phi0_c + charge * M_PI_2;
456 //cout<<phi0_i<<" "<<(45 + 90./80 * (1+ t2DInfo[iTrack][2]))/180*M_PI<<endl;
457 phi0_i = (45 + 90. / 80 * (1 + t2DInfo[iTrack][2])) / 180 * M_PI;
458
459 //Correct phi0_i. The zero points of raw phi0_i for four boards are different.
460 if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore0") {
461 phi0_i = phi0_i + (M_PI / 2.0) * 0;
462 } else if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore1") {
463 phi0_i = phi0_i + (M_PI / 2.0) * 1;
464 } else if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore2") {
465 phi0_i = phi0_i + (M_PI / 2.0) * 2;
466 } else if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore3") {
467 phi0_i = phi0_i + (M_PI / 2.0) * 3;
468 }
469
470 // Confine the range of the angle to -pi ~ pi
471 while (phi0_i > M_PI) {
472 phi0_i -= 2 * M_PI;
473 }
474 while (phi0_i < -M_PI) {
475 phi0_i += 2 * M_PI;
476 }
477
478 //omega = charge / t2DRhoTot3DRho(t2DInfo[iTrack][1])/(pow(2,11)-0.5)*2500;
479 //cout<<omega<<" "<<toSigned(t2DInfo[iTrack][1],7)*1.5e-4*30/0.3/34<<endl;
480 //omega = toSigned(t2DInfo[iTrack][1], 7) * 1.5e-4 * 30 / 0.3 / 34;
481 omega = toSigned(t2DInfo[iTrack][1], 7) / 33.0 * 3.2;
482 //cout<<"iTrack: "<<iTrack<<" charge:"<<t2DInfo[iTrack][0]<<" "<<charge<<" rho: "<<t2DInfo[iTrack][1]<<" "<<omega<<" phi0_i: "<<t2DInfo[iTrack][2]<<" "<<phi0_i<<endl;
483
484 CDCTriggerTrack* track = m_tracks2D.appendNew(phi0_i, omega, chi2D, 0, 0, 0);
485
486 if (m_isVerbose) cout << "[2D] iTrack:" << iTrack << " charge:" << charge << " phi0_i:" << phi0_i << " " << phi0_i * 180 / M_PI <<
487 " omega:" << omega << " pt:" << charge / omega * 0.3 * 1.5 * 0.01 << endl;
488
489 for (unsigned iAx = 0; iAx < t2DTsfInfo.shape()[1]; ++iAx) {
490 double rawId = t2DTsfInfo[iTrack][iAx][0];
491 double id = -1;
492 if (iAx != 4) id = rawId;
493 else {
494 id = rawId - 16;
495 if (id < 0) id += 384;
496 }
497 double rt = t2DTsfInfo[iTrack][iAx][1];
498 double lr = t2DTsfInfo[iTrack][iAx][2];
499 double pr = t2DTsfInfo[iTrack][iAx][3];
500 double ft = t2DTsfInfo[iTrack][iAx][4];
501 if (pr == 0) continue;
502 CDCHit prHit(rt, 0, iAx * 2, pr == 3 ? 2 : 3, id);
503 m_hits.appendNew(prHit, toTSID(int(iAx * 2), id), pr, lr, rt, 0, ft);
504 track->addRelationTo(m_hits[m_hits.getEntries() - 1]);
505 if (m_isVerbose) cout << "[2D] iTrack: " << iTrack << " iAx:" << iAx << " id:" << id << " rt:" << rt << " lr:" << lr << " pr:" << pr
506 << " ft:" << ft << endl;
507 }
508
509
510 }
511}
512
513void TRGCDCT3DConverterModule::addTSDatastore(boost::multi_array<double, 3>& tsfInfo, int isSt)
514{
515 for (unsigned iSL = 0; iSL < tsfInfo.shape()[0]; iSL++) {
516 for (unsigned iTS = 0; iTS < tsfInfo.shape()[1]; iTS++) {
517 double id = tsfInfo[iSL][iTS][0];
518 double rt = tsfInfo[iSL][iTS][1];
519 double lr = tsfInfo[iSL][iTS][2];
520 double pr = tsfInfo[iSL][iTS][3];
521 double ft = tsfInfo[iSL][iTS][4];
522 if (m_isVerbose) cout << "[TSF] iSL:" << iSL << " iTS:" << iTS << " id:" << id << " rt:" << rt << " lr:" << lr << " pr:" << pr <<
523 " ft:" << ft << endl;
524 if (pr != 0) {
525 CDCHit prHit(rt, 0, iSL * 2 + isSt, pr == 3 ? 2 : 3, id);
526 m_hits.appendNew(prHit, toTSID(int(iSL * 2 + isSt), id), pr, lr, rt, 0, ft);
527 }
528 }
529 }
530}
531
532void TRGCDCT3DConverterModule::storeTSFirmwareData(boost::multi_array<double, 4>& tsfInfo)
533{
534 for (int iClk = 0; iClk < m_firmwareResults.getEntries(); iClk++) {
536 //cout<<"iClk:"<<iClk<<" tsf1_cc:"<<result->m_tsf1_cc<<" tsf1ts0_id:"<<result->m_tsf1ts0_id<<" tsf1ts0_rt:"<<result->m_tsf1ts0_rt<<" tsf1ts0_lr:"<<result->m_tsf1ts0_lr<<" tsf1ts0_pr:"<<result->m_tsf1ts0_pr<<endl;
537 tsfInfo[0][0][iClk][0] = result->m_tsf1ts0_id;
538 tsfInfo[0][0][iClk][1] = result->m_tsf1ts0_rt;
539 tsfInfo[0][0][iClk][2] = result->m_tsf1ts0_lr;
540 tsfInfo[0][0][iClk][3] = result->m_tsf1ts0_pr;
541 tsfInfo[0][0][iClk][4] = result->m_tsf1_cc;
542 tsfInfo[0][1][iClk][0] = result->m_tsf1ts1_id;
543 tsfInfo[0][1][iClk][1] = result->m_tsf1ts1_rt;
544 tsfInfo[0][1][iClk][2] = result->m_tsf1ts1_lr;
545 tsfInfo[0][1][iClk][3] = result->m_tsf1ts1_pr;
546 tsfInfo[0][1][iClk][4] = result->m_tsf1_cc;
547 tsfInfo[0][2][iClk][0] = result->m_tsf1ts2_id;
548 tsfInfo[0][2][iClk][1] = result->m_tsf1ts2_rt;
549 tsfInfo[0][2][iClk][2] = result->m_tsf1ts2_lr;
550 tsfInfo[0][2][iClk][3] = result->m_tsf1ts2_pr;
551 tsfInfo[0][2][iClk][4] = result->m_tsf1_cc;
552 tsfInfo[0][3][iClk][0] = result->m_tsf1ts3_id;
553 tsfInfo[0][3][iClk][1] = result->m_tsf1ts3_rt;
554 tsfInfo[0][3][iClk][2] = result->m_tsf1ts3_lr;
555 tsfInfo[0][3][iClk][3] = result->m_tsf1ts3_pr;
556 tsfInfo[0][3][iClk][4] = result->m_tsf1_cc;
557 tsfInfo[0][4][iClk][0] = result->m_tsf1ts4_id;
558 tsfInfo[0][4][iClk][1] = result->m_tsf1ts4_rt;
559 tsfInfo[0][4][iClk][2] = result->m_tsf1ts4_lr;
560 tsfInfo[0][4][iClk][3] = result->m_tsf1ts4_pr;
561 tsfInfo[0][4][iClk][4] = result->m_tsf1_cc;
562 tsfInfo[0][5][iClk][0] = result->m_tsf1ts5_id;
563 tsfInfo[0][5][iClk][1] = result->m_tsf1ts5_rt;
564 tsfInfo[0][5][iClk][2] = result->m_tsf1ts5_lr;
565 tsfInfo[0][5][iClk][3] = result->m_tsf1ts5_pr;
566 tsfInfo[0][5][iClk][4] = result->m_tsf1_cc;
567 tsfInfo[0][6][iClk][0] = result->m_tsf1ts6_id;
568 tsfInfo[0][6][iClk][1] = result->m_tsf1ts6_rt;
569 tsfInfo[0][6][iClk][2] = result->m_tsf1ts6_lr;
570 tsfInfo[0][6][iClk][3] = result->m_tsf1ts6_pr;
571 tsfInfo[0][6][iClk][4] = result->m_tsf1_cc;
572 tsfInfo[0][7][iClk][0] = result->m_tsf1ts7_id;
573 tsfInfo[0][7][iClk][1] = result->m_tsf1ts7_rt;
574 tsfInfo[0][7][iClk][2] = result->m_tsf1ts7_lr;
575 tsfInfo[0][7][iClk][3] = result->m_tsf1ts7_pr;
576 tsfInfo[0][7][iClk][4] = result->m_tsf1_cc;
577 tsfInfo[0][8][iClk][0] = result->m_tsf1ts8_id;
578 tsfInfo[0][8][iClk][1] = result->m_tsf1ts8_rt;
579 tsfInfo[0][8][iClk][2] = result->m_tsf1ts8_lr;
580 tsfInfo[0][8][iClk][3] = result->m_tsf1ts8_pr;
581 tsfInfo[0][8][iClk][4] = result->m_tsf1_cc;
582 tsfInfo[0][9][iClk][0] = result->m_tsf1ts9_id;
583 tsfInfo[0][9][iClk][1] = result->m_tsf1ts9_rt;
584 tsfInfo[0][9][iClk][2] = result->m_tsf1ts9_lr;
585 tsfInfo[0][9][iClk][3] = result->m_tsf1ts9_pr;
586 tsfInfo[0][9][iClk][4] = result->m_tsf1_cc;
587 tsfInfo[0][10][iClk][0] = result->m_tsf1ts10_id;
588 tsfInfo[0][10][iClk][1] = result->m_tsf1ts10_rt;
589 tsfInfo[0][10][iClk][2] = result->m_tsf1ts10_lr;
590 tsfInfo[0][10][iClk][3] = result->m_tsf1ts10_pr;
591 tsfInfo[0][10][iClk][4] = result->m_tsf1_cc;
592 tsfInfo[0][11][iClk][0] = result->m_tsf1ts11_id;
593 tsfInfo[0][11][iClk][1] = result->m_tsf1ts11_rt;
594 tsfInfo[0][11][iClk][2] = result->m_tsf1ts11_lr;
595 tsfInfo[0][11][iClk][3] = result->m_tsf1ts11_pr;
596 tsfInfo[0][11][iClk][4] = result->m_tsf1_cc;
597 tsfInfo[0][12][iClk][0] = result->m_tsf1ts12_id;
598 tsfInfo[0][12][iClk][1] = result->m_tsf1ts12_rt;
599 tsfInfo[0][12][iClk][2] = result->m_tsf1ts12_lr;
600 tsfInfo[0][12][iClk][3] = result->m_tsf1ts12_pr;
601 tsfInfo[0][12][iClk][4] = result->m_tsf1_cc;
602 tsfInfo[0][13][iClk][0] = result->m_tsf1ts13_id;
603 tsfInfo[0][13][iClk][1] = result->m_tsf1ts13_rt;
604 tsfInfo[0][13][iClk][2] = result->m_tsf1ts13_lr;
605 tsfInfo[0][13][iClk][3] = result->m_tsf1ts13_pr;
606 tsfInfo[0][13][iClk][4] = result->m_tsf1_cc;
607 tsfInfo[0][14][iClk][0] = result->m_tsf1ts14_id;
608 tsfInfo[0][14][iClk][1] = result->m_tsf1ts14_rt;
609 tsfInfo[0][14][iClk][2] = result->m_tsf1ts14_lr;
610 tsfInfo[0][14][iClk][3] = result->m_tsf1ts14_pr;
611 tsfInfo[0][14][iClk][4] = result->m_tsf1_cc;
612
613 tsfInfo[1][0][iClk][0] = result->m_tsf3ts0_id;
614 tsfInfo[1][0][iClk][1] = result->m_tsf3ts0_rt;
615 tsfInfo[1][0][iClk][2] = result->m_tsf3ts0_lr;
616 tsfInfo[1][0][iClk][3] = result->m_tsf3ts0_pr;
617 tsfInfo[1][0][iClk][4] = result->m_tsf3_cc;
618 tsfInfo[1][1][iClk][0] = result->m_tsf3ts1_id;
619 tsfInfo[1][1][iClk][1] = result->m_tsf3ts1_rt;
620 tsfInfo[1][1][iClk][2] = result->m_tsf3ts1_lr;
621 tsfInfo[1][1][iClk][3] = result->m_tsf3ts1_pr;
622 tsfInfo[1][1][iClk][4] = result->m_tsf3_cc;
623 tsfInfo[1][2][iClk][0] = result->m_tsf3ts2_id;
624 tsfInfo[1][2][iClk][1] = result->m_tsf3ts2_rt;
625 tsfInfo[1][2][iClk][2] = result->m_tsf3ts2_lr;
626 tsfInfo[1][2][iClk][3] = result->m_tsf3ts2_pr;
627 tsfInfo[1][2][iClk][4] = result->m_tsf3_cc;
628 tsfInfo[1][3][iClk][0] = result->m_tsf3ts3_id;
629 tsfInfo[1][3][iClk][1] = result->m_tsf3ts3_rt;
630 tsfInfo[1][3][iClk][2] = result->m_tsf3ts3_lr;
631 tsfInfo[1][3][iClk][3] = result->m_tsf3ts3_pr;
632 tsfInfo[1][3][iClk][4] = result->m_tsf3_cc;
633 tsfInfo[1][4][iClk][0] = result->m_tsf3ts4_id;
634 tsfInfo[1][4][iClk][1] = result->m_tsf3ts4_rt;
635 tsfInfo[1][4][iClk][2] = result->m_tsf3ts4_lr;
636 tsfInfo[1][4][iClk][3] = result->m_tsf3ts4_pr;
637 tsfInfo[1][4][iClk][4] = result->m_tsf3_cc;
638 tsfInfo[1][5][iClk][0] = result->m_tsf3ts5_id;
639 tsfInfo[1][5][iClk][1] = result->m_tsf3ts5_rt;
640 tsfInfo[1][5][iClk][2] = result->m_tsf3ts5_lr;
641 tsfInfo[1][5][iClk][3] = result->m_tsf3ts5_pr;
642 tsfInfo[1][5][iClk][4] = result->m_tsf3_cc;
643 tsfInfo[1][6][iClk][0] = result->m_tsf3ts6_id;
644 tsfInfo[1][6][iClk][1] = result->m_tsf3ts6_rt;
645 tsfInfo[1][6][iClk][2] = result->m_tsf3ts6_lr;
646 tsfInfo[1][6][iClk][3] = result->m_tsf3ts6_pr;
647 tsfInfo[1][6][iClk][4] = result->m_tsf3_cc;
648 tsfInfo[1][7][iClk][0] = result->m_tsf3ts7_id;
649 tsfInfo[1][7][iClk][1] = result->m_tsf3ts7_rt;
650 tsfInfo[1][7][iClk][2] = result->m_tsf3ts7_lr;
651 tsfInfo[1][7][iClk][3] = result->m_tsf3ts7_pr;
652 tsfInfo[1][7][iClk][4] = result->m_tsf3_cc;
653 tsfInfo[1][8][iClk][0] = result->m_tsf3ts8_id;
654 tsfInfo[1][8][iClk][1] = result->m_tsf3ts8_rt;
655 tsfInfo[1][8][iClk][2] = result->m_tsf3ts8_lr;
656 tsfInfo[1][8][iClk][3] = result->m_tsf3ts8_pr;
657 tsfInfo[1][8][iClk][4] = result->m_tsf3_cc;
658 tsfInfo[1][9][iClk][0] = result->m_tsf3ts9_id;
659 tsfInfo[1][9][iClk][1] = result->m_tsf3ts9_rt;
660 tsfInfo[1][9][iClk][2] = result->m_tsf3ts9_lr;
661 tsfInfo[1][9][iClk][3] = result->m_tsf3ts9_pr;
662 tsfInfo[1][9][iClk][4] = result->m_tsf3_cc;
663 tsfInfo[1][10][iClk][0] = result->m_tsf3ts10_id;
664 tsfInfo[1][10][iClk][1] = result->m_tsf3ts10_rt;
665 tsfInfo[1][10][iClk][2] = result->m_tsf3ts10_lr;
666 tsfInfo[1][10][iClk][3] = result->m_tsf3ts10_pr;
667 tsfInfo[1][10][iClk][4] = result->m_tsf3_cc;
668 tsfInfo[1][11][iClk][0] = result->m_tsf3ts11_id;
669 tsfInfo[1][11][iClk][1] = result->m_tsf3ts11_rt;
670 tsfInfo[1][11][iClk][2] = result->m_tsf3ts11_lr;
671 tsfInfo[1][11][iClk][3] = result->m_tsf3ts11_pr;
672 tsfInfo[1][11][iClk][4] = result->m_tsf3_cc;
673 tsfInfo[1][12][iClk][0] = result->m_tsf3ts12_id;
674 tsfInfo[1][12][iClk][1] = result->m_tsf3ts12_rt;
675 tsfInfo[1][12][iClk][2] = result->m_tsf3ts12_lr;
676 tsfInfo[1][12][iClk][3] = result->m_tsf3ts12_pr;
677 tsfInfo[1][12][iClk][4] = result->m_tsf3_cc;
678 tsfInfo[1][13][iClk][0] = result->m_tsf3ts13_id;
679 tsfInfo[1][13][iClk][1] = result->m_tsf3ts13_rt;
680 tsfInfo[1][13][iClk][2] = result->m_tsf3ts13_lr;
681 tsfInfo[1][13][iClk][3] = result->m_tsf3ts13_pr;
682 tsfInfo[1][13][iClk][4] = result->m_tsf3_cc;
683 tsfInfo[1][14][iClk][0] = result->m_tsf3ts14_id;
684 tsfInfo[1][14][iClk][1] = result->m_tsf3ts14_rt;
685 tsfInfo[1][14][iClk][2] = result->m_tsf3ts14_lr;
686 tsfInfo[1][14][iClk][3] = result->m_tsf3ts14_pr;
687 tsfInfo[1][14][iClk][4] = result->m_tsf3_cc;
688
689 tsfInfo[2][0][iClk][0] = result->m_tsf5ts0_id;
690 tsfInfo[2][0][iClk][1] = result->m_tsf5ts0_rt;
691 tsfInfo[2][0][iClk][2] = result->m_tsf5ts0_lr;
692 tsfInfo[2][0][iClk][3] = result->m_tsf5ts0_pr;
693 tsfInfo[2][0][iClk][4] = result->m_tsf5_cc;
694 tsfInfo[2][1][iClk][0] = result->m_tsf5ts1_id;
695 tsfInfo[2][1][iClk][1] = result->m_tsf5ts1_rt;
696 tsfInfo[2][1][iClk][2] = result->m_tsf5ts1_lr;
697 tsfInfo[2][1][iClk][3] = result->m_tsf5ts1_pr;
698 tsfInfo[2][1][iClk][4] = result->m_tsf5_cc;
699 tsfInfo[2][2][iClk][0] = result->m_tsf5ts2_id;
700 tsfInfo[2][2][iClk][1] = result->m_tsf5ts2_rt;
701 tsfInfo[2][2][iClk][2] = result->m_tsf5ts2_lr;
702 tsfInfo[2][2][iClk][3] = result->m_tsf5ts2_pr;
703 tsfInfo[2][2][iClk][4] = result->m_tsf5_cc;
704 tsfInfo[2][3][iClk][0] = result->m_tsf5ts3_id;
705 tsfInfo[2][3][iClk][1] = result->m_tsf5ts3_rt;
706 tsfInfo[2][3][iClk][2] = result->m_tsf5ts3_lr;
707 tsfInfo[2][3][iClk][3] = result->m_tsf5ts3_pr;
708 tsfInfo[2][3][iClk][4] = result->m_tsf5_cc;
709 tsfInfo[2][4][iClk][0] = result->m_tsf5ts4_id;
710 tsfInfo[2][4][iClk][1] = result->m_tsf5ts4_rt;
711 tsfInfo[2][4][iClk][2] = result->m_tsf5ts4_lr;
712 tsfInfo[2][4][iClk][3] = result->m_tsf5ts4_pr;
713 tsfInfo[2][4][iClk][4] = result->m_tsf5_cc;
714 tsfInfo[2][5][iClk][0] = result->m_tsf5ts5_id;
715 tsfInfo[2][5][iClk][1] = result->m_tsf5ts5_rt;
716 tsfInfo[2][5][iClk][2] = result->m_tsf5ts5_lr;
717 tsfInfo[2][5][iClk][3] = result->m_tsf5ts5_pr;
718 tsfInfo[2][5][iClk][4] = result->m_tsf5_cc;
719 tsfInfo[2][6][iClk][0] = result->m_tsf5ts6_id;
720 tsfInfo[2][6][iClk][1] = result->m_tsf5ts6_rt;
721 tsfInfo[2][6][iClk][2] = result->m_tsf5ts6_lr;
722 tsfInfo[2][6][iClk][3] = result->m_tsf5ts6_pr;
723 tsfInfo[2][6][iClk][4] = result->m_tsf5_cc;
724 tsfInfo[2][7][iClk][0] = result->m_tsf5ts7_id;
725 tsfInfo[2][7][iClk][1] = result->m_tsf5ts7_rt;
726 tsfInfo[2][7][iClk][2] = result->m_tsf5ts7_lr;
727 tsfInfo[2][7][iClk][3] = result->m_tsf5ts7_pr;
728 tsfInfo[2][7][iClk][4] = result->m_tsf5_cc;
729 tsfInfo[2][8][iClk][0] = result->m_tsf5ts8_id;
730 tsfInfo[2][8][iClk][1] = result->m_tsf5ts8_rt;
731 tsfInfo[2][8][iClk][2] = result->m_tsf5ts8_lr;
732 tsfInfo[2][8][iClk][3] = result->m_tsf5ts8_pr;
733 tsfInfo[2][8][iClk][4] = result->m_tsf5_cc;
734 tsfInfo[2][9][iClk][0] = result->m_tsf5ts9_id;
735 tsfInfo[2][9][iClk][1] = result->m_tsf5ts9_rt;
736 tsfInfo[2][9][iClk][2] = result->m_tsf5ts9_lr;
737 tsfInfo[2][9][iClk][3] = result->m_tsf5ts9_pr;
738 tsfInfo[2][9][iClk][4] = result->m_tsf5_cc;
739 tsfInfo[2][10][iClk][0] = result->m_tsf5ts10_id;
740 tsfInfo[2][10][iClk][1] = result->m_tsf5ts10_rt;
741 tsfInfo[2][10][iClk][2] = result->m_tsf5ts10_lr;
742 tsfInfo[2][10][iClk][3] = result->m_tsf5ts10_pr;
743 tsfInfo[2][10][iClk][4] = result->m_tsf5_cc;
744 tsfInfo[2][11][iClk][0] = result->m_tsf5ts11_id;
745 tsfInfo[2][11][iClk][1] = result->m_tsf5ts11_rt;
746 tsfInfo[2][11][iClk][2] = result->m_tsf5ts11_lr;
747 tsfInfo[2][11][iClk][3] = result->m_tsf5ts11_pr;
748 tsfInfo[2][11][iClk][4] = result->m_tsf5_cc;
749 tsfInfo[2][12][iClk][0] = result->m_tsf5ts12_id;
750 tsfInfo[2][12][iClk][1] = result->m_tsf5ts12_rt;
751 tsfInfo[2][12][iClk][2] = result->m_tsf5ts12_lr;
752 tsfInfo[2][12][iClk][3] = result->m_tsf5ts12_pr;
753 tsfInfo[2][12][iClk][4] = result->m_tsf5_cc;
754 tsfInfo[2][13][iClk][0] = result->m_tsf5ts13_id;
755 tsfInfo[2][13][iClk][1] = result->m_tsf5ts13_rt;
756 tsfInfo[2][13][iClk][2] = result->m_tsf5ts13_lr;
757 tsfInfo[2][13][iClk][3] = result->m_tsf5ts13_pr;
758 tsfInfo[2][13][iClk][4] = result->m_tsf5_cc;
759 tsfInfo[2][14][iClk][0] = result->m_tsf5ts14_id;
760 tsfInfo[2][14][iClk][1] = result->m_tsf5ts14_rt;
761 tsfInfo[2][14][iClk][2] = result->m_tsf5ts14_lr;
762 tsfInfo[2][14][iClk][3] = result->m_tsf5ts14_pr;
763 tsfInfo[2][14][iClk][4] = result->m_tsf5_cc;
764
765 tsfInfo[3][0][iClk][0] = result->m_tsf7ts0_id;
766 tsfInfo[3][0][iClk][1] = result->m_tsf7ts0_rt;
767 tsfInfo[3][0][iClk][2] = result->m_tsf7ts0_lr;
768 tsfInfo[3][0][iClk][3] = result->m_tsf7ts0_pr;
769 tsfInfo[3][0][iClk][4] = result->m_tsf7_cc;
770 tsfInfo[3][1][iClk][0] = result->m_tsf7ts1_id;
771 tsfInfo[3][1][iClk][1] = result->m_tsf7ts1_rt;
772 tsfInfo[3][1][iClk][2] = result->m_tsf7ts1_lr;
773 tsfInfo[3][1][iClk][3] = result->m_tsf7ts1_pr;
774 tsfInfo[3][1][iClk][4] = result->m_tsf7_cc;
775 tsfInfo[3][2][iClk][0] = result->m_tsf7ts2_id;
776 tsfInfo[3][2][iClk][1] = result->m_tsf7ts2_rt;
777 tsfInfo[3][2][iClk][2] = result->m_tsf7ts2_lr;
778 tsfInfo[3][2][iClk][3] = result->m_tsf7ts2_pr;
779 tsfInfo[3][2][iClk][4] = result->m_tsf7_cc;
780 tsfInfo[3][3][iClk][0] = result->m_tsf7ts3_id;
781 tsfInfo[3][3][iClk][1] = result->m_tsf7ts3_rt;
782 tsfInfo[3][3][iClk][2] = result->m_tsf7ts3_lr;
783 tsfInfo[3][3][iClk][3] = result->m_tsf7ts3_pr;
784 tsfInfo[3][3][iClk][4] = result->m_tsf7_cc;
785 tsfInfo[3][4][iClk][0] = result->m_tsf7ts4_id;
786 tsfInfo[3][4][iClk][1] = result->m_tsf7ts4_rt;
787 tsfInfo[3][4][iClk][2] = result->m_tsf7ts4_lr;
788 tsfInfo[3][4][iClk][3] = result->m_tsf7ts4_pr;
789 tsfInfo[3][4][iClk][4] = result->m_tsf7_cc;
790 tsfInfo[3][5][iClk][0] = result->m_tsf7ts5_id;
791 tsfInfo[3][5][iClk][1] = result->m_tsf7ts5_rt;
792 tsfInfo[3][5][iClk][2] = result->m_tsf7ts5_lr;
793 tsfInfo[3][5][iClk][3] = result->m_tsf7ts5_pr;
794 tsfInfo[3][5][iClk][4] = result->m_tsf7_cc;
795 tsfInfo[3][6][iClk][0] = result->m_tsf7ts6_id;
796 tsfInfo[3][6][iClk][1] = result->m_tsf7ts6_rt;
797 tsfInfo[3][6][iClk][2] = result->m_tsf7ts6_lr;
798 tsfInfo[3][6][iClk][3] = result->m_tsf7ts6_pr;
799 tsfInfo[3][6][iClk][4] = result->m_tsf7_cc;
800 tsfInfo[3][7][iClk][0] = result->m_tsf7ts7_id;
801 tsfInfo[3][7][iClk][1] = result->m_tsf7ts7_rt;
802 tsfInfo[3][7][iClk][2] = result->m_tsf7ts7_lr;
803 tsfInfo[3][7][iClk][3] = result->m_tsf7ts7_pr;
804 tsfInfo[3][7][iClk][4] = result->m_tsf7_cc;
805 tsfInfo[3][8][iClk][0] = result->m_tsf7ts8_id;
806 tsfInfo[3][8][iClk][1] = result->m_tsf7ts8_rt;
807 tsfInfo[3][8][iClk][2] = result->m_tsf7ts8_lr;
808 tsfInfo[3][8][iClk][3] = result->m_tsf7ts8_pr;
809 tsfInfo[3][8][iClk][4] = result->m_tsf7_cc;
810 tsfInfo[3][9][iClk][0] = result->m_tsf7ts9_id;
811 tsfInfo[3][9][iClk][1] = result->m_tsf7ts9_rt;
812 tsfInfo[3][9][iClk][2] = result->m_tsf7ts9_lr;
813 tsfInfo[3][9][iClk][3] = result->m_tsf7ts9_pr;
814 tsfInfo[3][9][iClk][4] = result->m_tsf7_cc;
815 tsfInfo[3][10][iClk][0] = result->m_tsf7ts10_id;
816 tsfInfo[3][10][iClk][1] = result->m_tsf7ts10_rt;
817 tsfInfo[3][10][iClk][2] = result->m_tsf7ts10_lr;
818 tsfInfo[3][10][iClk][3] = result->m_tsf7ts10_pr;
819 tsfInfo[3][10][iClk][4] = result->m_tsf7_cc;
820 tsfInfo[3][11][iClk][0] = result->m_tsf7ts11_id;
821 tsfInfo[3][11][iClk][1] = result->m_tsf7ts11_rt;
822 tsfInfo[3][11][iClk][2] = result->m_tsf7ts11_lr;
823 tsfInfo[3][11][iClk][3] = result->m_tsf7ts11_pr;
824 tsfInfo[3][11][iClk][4] = result->m_tsf7_cc;
825 tsfInfo[3][12][iClk][0] = result->m_tsf7ts12_id;
826 tsfInfo[3][12][iClk][1] = result->m_tsf7ts12_rt;
827 tsfInfo[3][12][iClk][2] = result->m_tsf7ts12_lr;
828 tsfInfo[3][12][iClk][3] = result->m_tsf7ts12_pr;
829 tsfInfo[3][12][iClk][4] = result->m_tsf7_cc;
830 tsfInfo[3][13][iClk][0] = result->m_tsf7ts13_id;
831 tsfInfo[3][13][iClk][1] = result->m_tsf7ts13_rt;
832 tsfInfo[3][13][iClk][2] = result->m_tsf7ts13_lr;
833 tsfInfo[3][13][iClk][3] = result->m_tsf7ts13_pr;
834 tsfInfo[3][13][iClk][4] = result->m_tsf7_cc;
835 tsfInfo[3][14][iClk][0] = result->m_tsf7ts14_id;
836 tsfInfo[3][14][iClk][1] = result->m_tsf7ts14_rt;
837 tsfInfo[3][14][iClk][2] = result->m_tsf7ts14_lr;
838 tsfInfo[3][14][iClk][3] = result->m_tsf7ts14_pr;
839 tsfInfo[3][14][iClk][4] = result->m_tsf7_cc;
840
841 }
842}
843
844// t2DFirmwareInfo[tIndex][iClk][valid, isOld charge, rho, phi0]
845// t2DTsfFirmwareInfo[tIndex][iClk][axSL][id, rt, lr, pr]
846void TRGCDCT3DConverterModule::store2DFirmwareData(boost::multi_array<double, 3>& t2DFirmwareInfo,
847 boost::multi_array<double, 4>& t2DTsfFirmwareInfo)
848{
849
850 for (int iClk = 0; iClk < m_firmwareResults.getEntries(); iClk++) {
852 bitset<6> t2d_fnf(int(result->m_t2d_fnf));
853 bitset<6> t2d_oldfnf(int(result->m_t3d_2doldtrk));
854 //cout<<"iclk:"<<iClk<<" fnf:"<<result->m_t2d_fnf<<" "<<t2d_fnf<<" "<<t2d_fnf[5]<<endl;
855 //cout<<"iClk:"<<iClk<<" t2d_fnf:"<<m_firmwareResults[iClk]->m_t2d_fnf<<endl;
856
857 t2DFirmwareInfo[0][iClk][0] = t2d_fnf[5];
858 t2DFirmwareInfo[0][iClk][1] = t2d_oldfnf[5];;
859 t2DFirmwareInfo[0][iClk][2] = result->m_t2d0_charge;
860 t2DFirmwareInfo[0][iClk][3] = result->m_t2d0_rho_s;
861 t2DFirmwareInfo[0][iClk][4] = result->m_t2d0_phi;
862
863 t2DFirmwareInfo[1][iClk][0] = t2d_fnf[4];
864 t2DFirmwareInfo[1][iClk][1] = t2d_oldfnf[4];;
865 t2DFirmwareInfo[1][iClk][2] = result->m_t2d1_charge;
866 t2DFirmwareInfo[1][iClk][3] = result->m_t2d1_rho_s;
867 t2DFirmwareInfo[1][iClk][4] = result->m_t2d1_phi;
868
869 t2DFirmwareInfo[2][iClk][0] = t2d_fnf[3];
870 t2DFirmwareInfo[2][iClk][1] = t2d_oldfnf[3];;
871 t2DFirmwareInfo[2][iClk][2] = result->m_t2d2_charge;
872 t2DFirmwareInfo[2][iClk][3] = result->m_t2d2_rho_s;
873 t2DFirmwareInfo[2][iClk][4] = result->m_t2d2_phi;
874
875 t2DFirmwareInfo[3][iClk][0] = t2d_fnf[2];
876 t2DFirmwareInfo[3][iClk][1] = t2d_oldfnf[2];;
877 t2DFirmwareInfo[3][iClk][2] = result->m_t2d3_charge;
878 t2DFirmwareInfo[3][iClk][3] = result->m_t2d3_rho_s;
879 t2DFirmwareInfo[3][iClk][4] = result->m_t2d3_phi;
880
881 t2DTsfFirmwareInfo[0][iClk][0][0] = result->m_t2d0ts0_id;
882 t2DTsfFirmwareInfo[0][iClk][0][1] = result->m_t2d0ts0_rt;
883 t2DTsfFirmwareInfo[0][iClk][0][2] = result->m_t2d0ts0_lr;
884 t2DTsfFirmwareInfo[0][iClk][0][3] = result->m_t2d0ts0_pr;
885 t2DTsfFirmwareInfo[0][iClk][1][0] = result->m_t2d0ts2_id;
886 t2DTsfFirmwareInfo[0][iClk][1][1] = result->m_t2d0ts2_rt;
887 t2DTsfFirmwareInfo[0][iClk][1][2] = result->m_t2d0ts2_lr;
888 t2DTsfFirmwareInfo[0][iClk][1][3] = result->m_t2d0ts2_pr;
889 t2DTsfFirmwareInfo[0][iClk][2][0] = result->m_t2d0ts4_id;
890 t2DTsfFirmwareInfo[0][iClk][2][1] = result->m_t2d0ts4_rt;
891 t2DTsfFirmwareInfo[0][iClk][2][2] = result->m_t2d0ts4_lr;
892 t2DTsfFirmwareInfo[0][iClk][2][3] = result->m_t2d0ts4_pr;
893 t2DTsfFirmwareInfo[0][iClk][3][0] = result->m_t2d0ts6_id;
894 t2DTsfFirmwareInfo[0][iClk][3][1] = result->m_t2d0ts6_rt;
895 t2DTsfFirmwareInfo[0][iClk][3][2] = result->m_t2d0ts6_lr;
896 t2DTsfFirmwareInfo[0][iClk][3][3] = result->m_t2d0ts6_pr;
897 t2DTsfFirmwareInfo[0][iClk][4][0] = result->m_t2d0ts8_id;
898 t2DTsfFirmwareInfo[0][iClk][4][1] = result->m_t2d0ts8_rt;
899 t2DTsfFirmwareInfo[0][iClk][4][2] = result->m_t2d0ts8_lr;
900 t2DTsfFirmwareInfo[0][iClk][4][3] = result->m_t2d0ts8_pr;
901
902 t2DTsfFirmwareInfo[1][iClk][0][0] = result->m_t2d1ts0_id;
903 t2DTsfFirmwareInfo[1][iClk][0][1] = result->m_t2d1ts0_rt;
904 t2DTsfFirmwareInfo[1][iClk][0][2] = result->m_t2d1ts0_lr;
905 t2DTsfFirmwareInfo[1][iClk][0][3] = result->m_t2d1ts0_pr;
906 t2DTsfFirmwareInfo[1][iClk][1][0] = result->m_t2d1ts2_id;
907 t2DTsfFirmwareInfo[1][iClk][1][1] = result->m_t2d1ts2_rt;
908 t2DTsfFirmwareInfo[1][iClk][1][2] = result->m_t2d1ts2_lr;
909 t2DTsfFirmwareInfo[1][iClk][1][3] = result->m_t2d1ts2_pr;
910 t2DTsfFirmwareInfo[1][iClk][2][0] = result->m_t2d1ts4_id;
911 t2DTsfFirmwareInfo[1][iClk][2][1] = result->m_t2d1ts4_rt;
912 t2DTsfFirmwareInfo[1][iClk][2][2] = result->m_t2d1ts4_lr;
913 t2DTsfFirmwareInfo[1][iClk][2][3] = result->m_t2d1ts4_pr;
914 t2DTsfFirmwareInfo[1][iClk][3][0] = result->m_t2d1ts6_id;
915 t2DTsfFirmwareInfo[1][iClk][3][1] = result->m_t2d1ts6_rt;
916 t2DTsfFirmwareInfo[1][iClk][3][2] = result->m_t2d1ts6_lr;
917 t2DTsfFirmwareInfo[1][iClk][3][3] = result->m_t2d1ts6_pr;
918 t2DTsfFirmwareInfo[1][iClk][4][0] = result->m_t2d1ts8_id;
919 t2DTsfFirmwareInfo[1][iClk][4][1] = result->m_t2d1ts8_rt;
920 t2DTsfFirmwareInfo[1][iClk][4][2] = result->m_t2d1ts8_lr;
921 t2DTsfFirmwareInfo[1][iClk][4][3] = result->m_t2d1ts8_pr;
922
923 t2DTsfFirmwareInfo[2][iClk][0][0] = result->m_t2d2ts0_id;
924 t2DTsfFirmwareInfo[2][iClk][0][1] = result->m_t2d2ts0_rt;
925 t2DTsfFirmwareInfo[2][iClk][0][2] = result->m_t2d2ts0_lr;
926 t2DTsfFirmwareInfo[2][iClk][0][3] = result->m_t2d2ts0_pr;
927 t2DTsfFirmwareInfo[2][iClk][1][0] = result->m_t2d2ts2_id;
928 t2DTsfFirmwareInfo[2][iClk][1][1] = result->m_t2d2ts2_rt;
929 t2DTsfFirmwareInfo[2][iClk][1][2] = result->m_t2d2ts2_lr;
930 t2DTsfFirmwareInfo[2][iClk][1][3] = result->m_t2d2ts2_pr;
931 t2DTsfFirmwareInfo[2][iClk][2][0] = result->m_t2d2ts4_id;
932 t2DTsfFirmwareInfo[2][iClk][2][1] = result->m_t2d2ts4_rt;
933 t2DTsfFirmwareInfo[2][iClk][2][2] = result->m_t2d2ts4_lr;
934 t2DTsfFirmwareInfo[2][iClk][2][3] = result->m_t2d2ts4_pr;
935 t2DTsfFirmwareInfo[2][iClk][3][0] = result->m_t2d2ts6_id;
936 t2DTsfFirmwareInfo[2][iClk][3][1] = result->m_t2d2ts6_rt;
937 t2DTsfFirmwareInfo[2][iClk][3][2] = result->m_t2d2ts6_lr;
938 t2DTsfFirmwareInfo[2][iClk][3][3] = result->m_t2d2ts6_pr;
939 t2DTsfFirmwareInfo[2][iClk][4][0] = result->m_t2d2ts8_id;
940 t2DTsfFirmwareInfo[2][iClk][4][1] = result->m_t2d2ts8_rt;
941 t2DTsfFirmwareInfo[2][iClk][4][2] = result->m_t2d2ts8_lr;
942 t2DTsfFirmwareInfo[2][iClk][4][3] = result->m_t2d2ts8_pr;
943
944 t2DTsfFirmwareInfo[3][iClk][0][0] = result->m_t2d3ts0_id;
945 t2DTsfFirmwareInfo[3][iClk][0][1] = result->m_t2d3ts0_rt;
946 t2DTsfFirmwareInfo[3][iClk][0][2] = result->m_t2d3ts0_lr;
947 t2DTsfFirmwareInfo[3][iClk][0][3] = result->m_t2d3ts0_pr;
948 t2DTsfFirmwareInfo[3][iClk][1][0] = result->m_t2d3ts2_id;
949 t2DTsfFirmwareInfo[3][iClk][1][1] = result->m_t2d3ts2_rt;
950 t2DTsfFirmwareInfo[3][iClk][1][2] = result->m_t2d3ts2_lr;
951 t2DTsfFirmwareInfo[3][iClk][1][3] = result->m_t2d3ts2_pr;
952 t2DTsfFirmwareInfo[3][iClk][2][0] = result->m_t2d3ts4_id;
953 t2DTsfFirmwareInfo[3][iClk][2][1] = result->m_t2d3ts4_rt;
954 t2DTsfFirmwareInfo[3][iClk][2][2] = result->m_t2d3ts4_lr;
955 t2DTsfFirmwareInfo[3][iClk][2][3] = result->m_t2d3ts4_pr;
956 t2DTsfFirmwareInfo[3][iClk][3][0] = result->m_t2d3ts6_id;
957 t2DTsfFirmwareInfo[3][iClk][3][1] = result->m_t2d3ts6_rt;
958 t2DTsfFirmwareInfo[3][iClk][3][2] = result->m_t2d3ts6_lr;
959 t2DTsfFirmwareInfo[3][iClk][3][3] = result->m_t2d3ts6_pr;
960 t2DTsfFirmwareInfo[3][iClk][4][0] = result->m_t2d3ts8_id;
961 t2DTsfFirmwareInfo[3][iClk][4][1] = result->m_t2d3ts8_rt;
962 t2DTsfFirmwareInfo[3][iClk][4][2] = result->m_t2d3ts8_lr;
963 t2DTsfFirmwareInfo[3][iClk][4][3] = result->m_t2d3ts8_pr;
964 }
965}
966
967
968// t3DFirmwareInfo[tIndex][iClk][2DValid, 2DisOld, TSFValid, EventTimeValid, eventTime, charge, rho, phi0, z0, cot, zchi]
969void TRGCDCT3DConverterModule::store3DFirmwareData(boost::multi_array<double, 3>& t3DFirmwareInfo)
970{
971
972 for (int iClk = 0; iClk < m_firmwareResults.getEntries() - 17 - 1; iClk++) {
974 TRGCDCT3DUnpackerStore* result3D = m_firmwareResults[iClk + 17];
975
976 bitset<6> t3d_fnf(int(result3D->m_t3d_2dfnf));
977 bitset<4> tsf_fnf(int(result3D->m_t3d_validTS));
978 bitset<6> t3d_oldfnf(int(result->m_t3d_2doldtrk));
979
980 //cout<<iClk<<" "<<t3d_fnf<<" "<<t3d_oldfnf<<endl;
981
982//The evtTime information was for debugging, but the current firmware does not output the evtTime information corresponding to every track.
983
984 t3DFirmwareInfo[0][iClk][0] = t3d_fnf[5];
985 t3DFirmwareInfo[0][iClk][1] = t3d_oldfnf[5];
986 t3DFirmwareInfo[0][iClk][2] = tsf_fnf[0];
987// t3DFirmwareInfo[0][iClk][3] = result3D->m_t3dtrk0_evtTimeValid_delay;
988// t3DFirmwareInfo[0][iClk][4] = result3D->m_t3dtrk0_evtTime_delay;
989 t3DFirmwareInfo[0][iClk][5] = result->m_t2d0_charge;
990 t3DFirmwareInfo[0][iClk][6] = result->m_t2d0_rho_s;
991 t3DFirmwareInfo[0][iClk][7] = result->m_t2d0_phi;
992 t3DFirmwareInfo[0][iClk][8] = result3D->m_t3dtrk0_z0_s;
993 t3DFirmwareInfo[0][iClk][9] = result3D->m_t3dtrk0_cot_s;
994 t3DFirmwareInfo[0][iClk][10] = result3D->m_t3dtrk0_zchisq;
995
996 t3DFirmwareInfo[1][iClk][0] = t3d_fnf[4];
997 t3DFirmwareInfo[1][iClk][1] = t3d_oldfnf[4];
998 t3DFirmwareInfo[1][iClk][2] = tsf_fnf[1];
999// t3DFirmwareInfo[1][iClk][3] = result3D->m_t3dtrk1_evtTimeValid_delay;
1000// t3DFirmwareInfo[1][iClk][4] = result3D->m_t3dtrk1_evtTime_delay;
1001 t3DFirmwareInfo[1][iClk][5] = result->m_t2d1_charge;
1002 t3DFirmwareInfo[1][iClk][6] = result->m_t2d1_rho_s;
1003 t3DFirmwareInfo[1][iClk][7] = result->m_t2d1_phi;
1004 t3DFirmwareInfo[1][iClk][8] = result3D->m_t3dtrk1_z0_s;
1005 t3DFirmwareInfo[1][iClk][9] = result3D->m_t3dtrk1_cot_s;
1006 t3DFirmwareInfo[1][iClk][10] = result3D->m_t3dtrk1_zchisq;
1007
1008 t3DFirmwareInfo[2][iClk][0] = t3d_fnf[3];
1009 t3DFirmwareInfo[2][iClk][1] = t3d_oldfnf[3];
1010 t3DFirmwareInfo[2][iClk][2] = tsf_fnf[2];
1011// t3DFirmwareInfo[2][iClk][3] = result3D->m_t3dtrk2_evtTimeValid_delay;
1012// t3DFirmwareInfo[2][iClk][4] = result3D->m_t3dtrk2_evtTime_delay;
1013 t3DFirmwareInfo[2][iClk][5] = result->m_t2d2_charge;
1014 t3DFirmwareInfo[2][iClk][6] = result->m_t2d2_rho_s;
1015 t3DFirmwareInfo[2][iClk][7] = result->m_t2d2_phi;
1016 t3DFirmwareInfo[2][iClk][8] = result3D->m_t3dtrk2_z0_s;
1017 t3DFirmwareInfo[2][iClk][9] = result3D->m_t3dtrk2_cot_s;
1018 t3DFirmwareInfo[2][iClk][10] = result3D->m_t3dtrk2_zchisq;
1019
1020 t3DFirmwareInfo[3][iClk][0] = t3d_fnf[2];
1021 t3DFirmwareInfo[3][iClk][1] = t3d_oldfnf[2];
1022 t3DFirmwareInfo[3][iClk][2] = tsf_fnf[3];
1023// t3DFirmwareInfo[3][iClk][3] = result3D->m_t3dtrk3_evtTimeValid_delay;
1024// t3DFirmwareInfo[3][iClk][4] = result3D->m_t3dtrk3_evtTime_delay;
1025 t3DFirmwareInfo[3][iClk][5] = result->m_t2d3_charge;
1026 t3DFirmwareInfo[3][iClk][6] = result->m_t2d3_rho_s;
1027 t3DFirmwareInfo[3][iClk][7] = result->m_t2d3_phi;
1028 t3DFirmwareInfo[3][iClk][8] = result3D->m_t3dtrk3_z0_s;
1029 t3DFirmwareInfo[3][iClk][9] = result3D->m_t3dtrk3_cot_s;
1030 t3DFirmwareInfo[3][iClk][10] = result3D->m_t3dtrk3_zchisq;
1031
1032 }
1033
1034}
1035
1036// t3DFirmwareInfo[tIndex][iClk][2DValid, 2DisOld, TSFValid, EventTimeValid, eventTime, charge, rho, phi0, z0, cot, zchi]
1037void TRGCDCT3DConverterModule::store3DFastSimData(boost::multi_array<double, 3>& t3DFirmwareInfo)
1038{
1039
1040 for (int iClk = 0; iClk < m_firmwareResults.getEntries() - 17 - 1; iClk++) {
1041
1043 TRGCDCT3DUnpackerStore* result3D = m_firmwareResults[iClk + 17];
1044 TRGCDCT3DUnpackerStore* resultDebug = m_firmwareResults[iClk + 4];
1045
1046 if (bitset<6> (result->m_t2d_fnf)[5] == 0) continue;
1047
1048 // Store information(charge, radius(cm), phi_c(rad), eventTime, eventTimeValid, [TS ID, TS LR, TS driftTime])
1049 // [TODO] Is evtTime clock correct?
1050 int charge = resultDebug->m_t3dtrk0_charge == 2 ? -1 : 1;
1051 double radius = resultDebug->m_t3dtrk0_rho * 2500 / (pow(2, 11) - 0.5);
1052 double phi_c = toSigned(resultDebug->m_t3dtrk0_phi0, 13) * M_PI / (pow(2, 12) - 0.5);
1053 int eventTime = result3D->m_t3dtrk0_evtTime_delay;
1054 int eventTimeValid = result3D->m_t3dtrk0_evtTimeValid_delay;
1055 // rawStTSs[iSt] = [TS ID, TS LR, TS driftTime]
1056 vector<vector<int> > rawStTSs(4, vector<int> (3));
1057 rawStTSs[0][0] = resultDebug->m_t3dtrk0ts0_id;
1058 rawStTSs[0][1] = resultDebug->m_t3dtrk0ts0_lr;
1059 rawStTSs[0][2] = resultDebug->m_t3dtrk0ts0_rt;
1060 rawStTSs[1][0] = resultDebug->m_t3dtrk0ts1_id;
1061 rawStTSs[1][1] = resultDebug->m_t3dtrk0ts1_lr;
1062 rawStTSs[1][2] = resultDebug->m_t3dtrk0ts1_rt;
1063 rawStTSs[2][0] = resultDebug->m_t3dtrk0ts2_id;
1064 rawStTSs[2][1] = resultDebug->m_t3dtrk0ts2_lr;
1065 rawStTSs[2][2] = resultDebug->m_t3dtrk0ts2_rt;
1066 rawStTSs[3][0] = resultDebug->m_t3dtrk0ts3_id;
1067 rawStTSs[3][1] = resultDebug->m_t3dtrk0ts3_lr;
1068 rawStTSs[3][2] = resultDebug->m_t3dtrk0ts3_rt;
1069
1070 // Get geometry
1071 map<string, vector<double> > stGeometry;
1072 vector<vector<double> > stXts;
1074 TRGCDCFitter3D::getStereoXt(stGeometry["priorityLayer"], stXts);
1075
1076 double z0 = 0, cot = 0, chi2 = 0;
1077 Fitter3DUtility::fitter3D(stGeometry, stXts, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, z0, cot, chi2);
1078
1079 bitset<6> t2d_fnf(int(result3D->m_t3d_2dfnf));
1080 bitset<4> tsf_fnf(int(result3D->m_t3d_validTS));
1081 bitset<6> t2d_oldfnf(int(result->m_t3d_2doldtrk));
1082
1083 //cout<<iClk<<" "<<t2d_fnf<<" "<<t2d_oldfnf<<endl;
1084
1085 t3DFirmwareInfo[0][iClk][0] = t2d_fnf[5];
1086 t3DFirmwareInfo[0][iClk][1] = t2d_oldfnf[5];
1087 t3DFirmwareInfo[0][iClk][2] = tsf_fnf[3];
1088
1089 t3DFirmwareInfo[0][iClk][3] = result3D->m_t3dtrk0_evtTimeValid_delay;
1090 t3DFirmwareInfo[0][iClk][4] = result3D->m_t3dtrk0_evtTime_delay;
1091 t3DFirmwareInfo[0][iClk][5] = charge;
1092 t3DFirmwareInfo[0][iClk][6] = radius;
1093 t3DFirmwareInfo[0][iClk][7] = phi_c;
1094 t3DFirmwareInfo[0][iClk][8] = z0;
1095 t3DFirmwareInfo[0][iClk][9] = cot;
1096 t3DFirmwareInfo[0][iClk][10] = chi2;
1097 }
1098}
1099
1100// t3DFirmwareInfo[tIndex][iClk][2DValid, 2DisOld, TSFValid, EventTimeValid, eventTime, charge, rho, phi0, z0, cot, zchi]
1101void TRGCDCT3DConverterModule::store3DFirmSimData(boost::multi_array<double, 3>& t3DFirmwareInfo)
1102{
1103 for (int iClk = 0; iClk < m_firmwareResults.getEntries() - 17 - 1; iClk++) {
1104
1106 TRGCDCT3DUnpackerStore* result3D = m_firmwareResults[iClk + 17];
1107 TRGCDCT3DUnpackerStore* resultDebug = m_firmwareResults[iClk + 4];
1108
1109 if (bitset<6> (result->m_t2d_fnf)[5] == 0) continue;
1110
1111 // Store information(charge, radius(cm), phi_c(rad), eventTime, eventTimeValid, [TS ID, TS LR, TS driftTime])
1112 // [TODO] Is evtTime clock correct?
1113 int charge = resultDebug->m_t3dtrk0_charge == 2 ? -1 : 1;
1114 double radius = resultDebug->m_t3dtrk0_rho * 2500 / (pow(2, 11) - 0.5);
1115 double phi_c = toSigned(resultDebug->m_t3dtrk0_phi0, 13) * M_PI / (pow(2, 12) - 0.5);
1116 int eventTime = result3D->m_t3dtrk0_evtTime_delay;
1117 int eventTimeValid = result3D->m_t3dtrk0_evtTimeValid_delay;
1118 // rawStTSs[iSt] = [TS ID, TS LR, TS driftTime]
1119 vector<vector<int> > rawStTSs(4, vector<int> (3));
1120 rawStTSs[0][0] = resultDebug->m_t3dtrk0ts0_id;
1121 rawStTSs[0][1] = resultDebug->m_t3dtrk0ts0_lr;
1122 rawStTSs[0][2] = resultDebug->m_t3dtrk0ts0_rt;
1123 rawStTSs[1][0] = resultDebug->m_t3dtrk0ts1_id;
1124 rawStTSs[1][1] = resultDebug->m_t3dtrk0ts1_lr;
1125 rawStTSs[1][2] = resultDebug->m_t3dtrk0ts1_rt;
1126 rawStTSs[2][0] = resultDebug->m_t3dtrk0ts2_id;
1127 rawStTSs[2][1] = resultDebug->m_t3dtrk0ts2_lr;
1128 rawStTSs[2][2] = resultDebug->m_t3dtrk0ts2_rt;
1129 rawStTSs[3][0] = resultDebug->m_t3dtrk0ts3_id;
1130 rawStTSs[3][1] = resultDebug->m_t3dtrk0ts3_lr;
1131 rawStTSs[3][2] = resultDebug->m_t3dtrk0ts3_rt;
1132
1133 // Get geometry
1134 map<string, vector<double> > stGeometry;
1135 vector<vector<double> > stXts;
1137 TRGCDCFitter3D::getStereoXt(stGeometry["priorityLayer"], stXts);
1138
1139 // Prepare complex fit3D
1140 map<string, vector<double> > mConstV;
1141 map<string, double> mConstD;
1142 TRGCDCFitter3D::getConstants(mConstD, mConstV);
1143 Fitter3DUtility::fitter3DFirm(mConstD, mConstV, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, m_commonData,
1145 double z0 = m_mSignalStorage["z0_r"].getRealInt();
1146 double cot = m_mSignalStorage["cot_r"].getRealInt();
1147 double chi2 = m_mSignalStorage["zChi2_r"].getRealInt();
1148
1149 bitset<6> t2d_fnf(int(result3D->m_t3d_2dfnf));
1150 bitset<4> tsf_fnf(int(result3D->m_t3d_validTS));
1151 bitset<6> t2d_oldfnf(int(result->m_t3d_2doldtrk));
1152
1153 //cout<<iClk<<" "<<t2d_fnf<<" "<<t2d_oldfnf<<endl;
1154
1155 t3DFirmwareInfo[0][iClk][0] = t2d_fnf[5];
1156 t3DFirmwareInfo[0][iClk][1] = t2d_oldfnf[5];
1157 t3DFirmwareInfo[0][iClk][2] = tsf_fnf[3];
1158
1159 t3DFirmwareInfo[0][iClk][3] = result3D->m_t3dtrk0_evtTimeValid_delay;
1160 t3DFirmwareInfo[0][iClk][4] = result3D->m_t3dtrk0_evtTime_delay;
1161 t3DFirmwareInfo[0][iClk][5] = charge;
1162 t3DFirmwareInfo[0][iClk][6] = radius;
1163 t3DFirmwareInfo[0][iClk][7] = phi_c;
1164 t3DFirmwareInfo[0][iClk][8] = z0;
1165 t3DFirmwareInfo[0][iClk][9] = cot;
1166 t3DFirmwareInfo[0][iClk][10] = chi2;
1167 }
1168}
1169
1171{
1172 bool doPrint = (m_isVerbose > 1);
1173
1174 for (int iClk = 0; iClk < m_firmwareResults.getEntries(); iClk++) {
1176 //bitset<6> t2d_fnf (int(result->m_t3d_2dfnf));
1177 //bitset<4> tsf_fnf (int(result->m_t3d_validTS));
1178
1179 //cout<<"iClk:"<<iClk<<endl;
1180 //cout<<" [2D] fnf:"<<result->m_t2d_fnf<<" "<<bitset<6> (result->m_t2d_fnf)<<endl;
1181 //cout<<" [0] rho: "<<result->m_t2d0_rho_s<<" "<<toSigned(result->m_t2d0_rho_s, 7)<<" "<<int(0.3*34/30/1.5e-4/abs(toSigned(result->m_t2d0_rho_s, 7))*(pow(2,11)-0.5)/2500)<<" phi0: "<<result->m_t2d0_phi<<endl;
1182 //cout<<" [1] rho: "<<result->m_t2d1_rho_s<<" "<<toSigned(result->m_t2d1_rho_s, 7)<<" "<<int(0.3*34/30/1.5e-4/abs(toSigned(result->m_t2d1_rho_s, 7))*(pow(2,11)-0.5)/2500)<<" phi0: "<<result->m_t2d1_phi<<endl;
1183 //cout<<" [2] rho: "<<result->m_t2d2_rho_s<<" "<<toSigned(result->m_t2d2_rho_s, 7)<<" "<<int(0.3*34/30/1.5e-4/abs(toSigned(result->m_t2d2_rho_s, 7))*(pow(2,11)-0.5)/2500)<<" phi0: "<<result->m_t2d2_phi<<endl;
1184 //cout<<" [3] rho: "<<result->m_t2d3_rho_s<<" "<<toSigned(result->m_t2d3_rho_s, 7)<<" "<<int(0.3*34/30/1.5e-4/abs(toSigned(result->m_t2d3_rho_s, 7))*(pow(2,11)-0.5)/2500)<<" phi0: "<<result->m_t2d3_phi<<endl;
1185 //cout<<" [3D] fnf:"<<result->m_t3d_2dfnf<<" "<<t2d_fnf<<" "<<t2d_fnf[5]<<" tsValid: "<<result->m_t3d_validTS<<" "<<tsf_fnf<<endl;;
1186 //cout<<" [0] z0: "<<result->m_t3dtrk0_z0_s<<" cot: "<<result->m_t3dtrk0_cot_s<<" chi2: "<<result->m_t3dtrk0_zchisq<<endl;
1187 //cout<<" [1] z0: "<<result->m_t3dtrk1_z0_s<<" cot: "<<result->m_t3dtrk1_cot_s<<" chi2: "<<result->m_t3dtrk1_zchisq<<endl;
1188 //cout<<" [2] z0: "<<result->m_t3dtrk2_z0_s<<" cot: "<<result->m_t3dtrk2_cot_s<<" chi2: "<<result->m_t3dtrk2_zchisq<<endl;
1189 //cout<<" [3] z0: "<<result->m_t3dtrk3_z0_s<<" cot: "<<result->m_t3dtrk3_cot_s<<" chi2: "<<result->m_t3dtrk3_zchisq<<endl;
1190 //cout<<" [debug] MSB"<<endl;
1191 //cout<<" evtTime: "<<result->m_t3dtrk0_evtTime_delay<<" evtTimeValid: "<<result->m_t3dtrk0_evtTimeValid_delay<<endl;
1192 //cout<<" charge: "<<result->m_t3dtrk0_charge<<" rho: "<<result->m_t3dtrk0_rho<<" phi0: "<<result->m_t3dtrk0_phi0<<endl;;
1193 //cout<<" ts0 id: "<<result->m_t3dtrk0ts0_id<<" lr: "<<result->m_t3dtrk0ts0_lr<<" rt: "<<result->m_t3dtrk0ts0_rt<<endl;
1194 //cout<<" ts1 id: "<<result->m_t3dtrk0ts1_id<<" lr: "<<result->m_t3dtrk0ts1_lr<<" rt: "<<result->m_t3dtrk0ts1_rt<<endl;
1195 //cout<<" ts2 id: "<<result->m_t3dtrk0ts2_id<<" lr: "<<result->m_t3dtrk0ts2_lr<<" rt: "<<result->m_t3dtrk0ts2_rt<<endl;
1196 //cout<<" ts3 id: "<<result->m_t3dtrk0ts3_id<<" lr: "<<result->m_t3dtrk0ts3_lr<<" rt: "<<result->m_t3dtrk0ts3_rt<<endl;
1197 //cout<<" [debug] LSB"<<endl;
1198 //cout<<" evtTime: "<<result->m_t3dtrk1_evtTime_delay<<" evtTimeValid: "<<result->m_t3dtrk1_evtTimeValid_delay<<endl;
1199 //cout<<" charge: "<<result->m_t3dtrk1_charge<<" rho: "<<result->m_t3dtrk1_rho<<" phi0: "<<result->m_t3dtrk1_phi0<<endl;;
1200 //cout<<" ts0 id: "<<result->m_t3dtrk1ts0_id<<" lr: "<<result->m_t3dtrk1ts0_lr<<" rt: "<<result->m_t3dtrk1ts0_rt<<endl;
1201 //cout<<" ts1 id: "<<result->m_t3dtrk1ts1_id<<" lr: "<<result->m_t3dtrk1ts1_lr<<" rt: "<<result->m_t3dtrk1ts1_rt<<endl;
1202 //cout<<" ts2 id: "<<result->m_t3dtrk1ts2_id<<" lr: "<<result->m_t3dtrk1ts2_lr<<" rt: "<<result->m_t3dtrk1ts2_rt<<endl;
1203 //cout<<" ts3 id: "<<result->m_t3dtrk1ts3_id<<" lr: "<<result->m_t3dtrk1ts3_lr<<" rt: "<<result->m_t3dtrk1ts3_rt<<endl;
1204
1206 //if (result->m_t2d_fnf && iClk < 48-4-1 && bitset<6> (result->m_t2d_fnf)[5])
1207 //{
1208 // TRGCDCT3DUnpackerStore * resultDebug = m_firmwareResults[iClk+4];
1209 // if(t2DRhoTot3DRho(result->m_t2d0_rho_s) == resultDebug->m_t3dtrk0_rho)
1210 // {
1211 // cout<<"Matched 2D0 and debug0"<<endl;
1212 // } else {
1213 // cout<<"iClk:"<<iClk<<endl;
1214 // cout<<" [2D] fnf:"<<result->m_t2d_fnf<<" "<<bitset<6> (result->m_t2d_fnf)<<endl;
1215 // cout<<" [0] rho: "<<result->m_t2d0_rho_s<<" "<<toSigned(result->m_t2d0_rho_s, 7)<<" "<<t2DRhoTot3DRho(result->m_t2d0_rho_s)<<" phi0: "<<result->m_t2d0_phi<<endl;
1216 // cout<<" [1] rho: "<<result->m_t2d1_rho_s<<" "<<toSigned(result->m_t2d1_rho_s, 7)<<" "<<t2DRhoTot3DRho(result->m_t2d1_rho_s)<<" phi0: "<<result->m_t2d1_phi<<endl;
1217 // cout<<" [2] rho: "<<result->m_t2d2_rho_s<<" "<<toSigned(result->m_t2d2_rho_s, 7)<<" "<<t2DRhoTot3DRho(result->m_t2d2_rho_s)<<" phi0: "<<result->m_t2d2_phi<<endl;
1218 // cout<<" [3] rho: "<<result->m_t2d3_rho_s<<" "<<toSigned(result->m_t2d3_rho_s, 7)<<" "<<t2DRhoTot3DRho(result->m_t2d3_rho_s)<<" phi0: "<<result->m_t2d3_phi<<endl;
1219 // cout<<" [3DDebug] MSB"<<endl;
1220 // cout<<" charge: "<<resultDebug->m_t3dtrk0_charge<<" rho: "<<resultDebug->m_t3dtrk0_rho<<" phi0: "<<resultDebug->m_t3dtrk0_phi0<<endl;;
1221 // cout<<" ts0 id: "<<resultDebug->m_t3dtrk0ts0_id<<" lr: "<<resultDebug->m_t3dtrk0ts0_lr<<" rt: "<<resultDebug->m_t3dtrk0ts0_rt<<endl;
1222 // cout<<" ts1 id: "<<resultDebug->m_t3dtrk0ts1_id<<" lr: "<<resultDebug->m_t3dtrk0ts1_lr<<" rt: "<<resultDebug->m_t3dtrk0ts1_rt<<endl;
1223 // cout<<" ts2 id: "<<resultDebug->m_t3dtrk0ts2_id<<" lr: "<<resultDebug->m_t3dtrk0ts2_lr<<" rt: "<<resultDebug->m_t3dtrk0ts2_rt<<endl;
1224 // cout<<" ts3 id: "<<resultDebug->m_t3dtrk0ts3_id<<" lr: "<<resultDebug->m_t3dtrk0ts3_lr<<" rt: "<<resultDebug->m_t3dtrk0ts3_rt<<endl;
1225 // }
1226 //}
1227
1229 //if (iClk < 48-4-1 && bitset<6> (result->m_t2d_fnf)[2])
1230 //{
1231 // TRGCDCT3DUnpackerStore * resultDebug = m_firmwareResults[iClk+4];
1232 // if(t2DRhoTot3DRho(result->m_t2d3_rho_s) == resultDebug->m_t3dtrk1_rho)
1233 // {
1234 // cout<<"Matched 2D3 and debug1"<<endl;
1235 // } else {
1236 // cout<<"iClk:"<<iClk<<endl;
1237 // cout<<" [2D] fnf:"<<result->m_t2d_fnf<<" "<<bitset<6> (result->m_t2d_fnf)<<endl;
1238 // cout<<" [0] rho: "<<result->m_t2d0_rho_s<<" "<<toSigned(result->m_t2d0_rho_s, 7)<<" "<<t2DRhoTot3DRho(result->m_t2d0_rho_s)<<" phi0: "<<result->m_t2d0_phi<<endl;
1239 // cout<<" [1] rho: "<<result->m_t2d1_rho_s<<" "<<toSigned(result->m_t2d1_rho_s, 7)<<" "<<t2DRhoTot3DRho(result->m_t2d1_rho_s)<<" phi0: "<<result->m_t2d1_phi<<endl;
1240 // cout<<" [2] rho: "<<result->m_t2d2_rho_s<<" "<<toSigned(result->m_t2d2_rho_s, 7)<<" "<<t2DRhoTot3DRho(result->m_t2d2_rho_s)<<" phi0: "<<result->m_t2d2_phi<<endl;
1241 // cout<<" [3] rho: "<<result->m_t2d3_rho_s<<" "<<toSigned(result->m_t2d3_rho_s, 7)<<" "<<t2DRhoTot3DRho(result->m_t2d3_rho_s)<<" phi0: "<<result->m_t2d3_phi<<endl;
1242 // cout<<" [3DDebug] LSB"<<endl;
1243 // cout<<" evtTime: "<<resultDebug->m_t3dtrk1_evtTime_delay<<" evtTimeValid: "<<resultDebug->m_t3dtrk1_evtTimeValid_delay<<endl;
1244 // cout<<" charge: "<<resultDebug->m_t3dtrk1_charge<<" rho: "<<resultDebug->m_t3dtrk1_rho<<" phi0: "<<resultDebug->m_t3dtrk1_phi0<<endl;;
1245 // cout<<" ts0 id: "<<resultDebug->m_t3dtrk1ts0_id<<" lr: "<<resultDebug->m_t3dtrk1ts0_lr<<" rt: "<<resultDebug->m_t3dtrk1ts0_rt<<endl;
1246 // cout<<" ts1 id: "<<resultDebug->m_t3dtrk1ts1_id<<" lr: "<<resultDebug->m_t3dtrk1ts1_lr<<" rt: "<<resultDebug->m_t3dtrk1ts1_rt<<endl;
1247 // cout<<" ts2 id: "<<resultDebug->m_t3dtrk1ts2_id<<" lr: "<<resultDebug->m_t3dtrk1ts2_lr<<" rt: "<<resultDebug->m_t3dtrk1ts2_rt<<endl;
1248 // cout<<" ts3 id: "<<resultDebug->m_t3dtrk1ts3_id<<" lr: "<<resultDebug->m_t3dtrk1ts3_lr<<" rt: "<<resultDebug->m_t3dtrk1ts3_rt<<endl;
1249 // }
1250 //}
1251
1253 //int countTrk0 = int(result->m_t3dtrk0ts0_lr!=0)+int(result->m_t3dtrk0ts1_lr!=0)+int(result->m_t3dtrk0ts2_lr!=0)+int(result->m_t3dtrk0ts3_lr!=0);
1254 //if ( iClk < 48 - 7 - 1)
1255 //{
1256 // TRGCDCT3DUnpackerStore * resultDebug = m_firmwareResults[iClk];
1257 // TRGCDCT3DUnpackerStore * result = m_firmwareResults[iClk+7];
1258
1259 // if (int(countTrk0 > 1) == bitset<4> (int(result->m_t3d_validTS))[3])
1260 // {
1261 // cout<<"debug TSF matches with TSFValid0"<<endl;
1262 // } else {
1263 // cout<<"iClk:"<<iClk+7<<endl;
1264 // cout<<" [3D] fnf:"<<result->m_t3d_2dfnf<<" "<<bitset<6> (int(result->m_t3d_2dfnf))<<" tsValid: "<<result->m_t3d_validTS<<" "<<bitset<4> (int(result->m_t3d_validTS))<<endl;;
1265 // cout<<" [3DDebug] MSB"<<endl;
1266 // cout<<" charge: "<<resultDebug->m_t3dtrk0_charge<<" rho: "<<resultDebug->m_t3dtrk0_rho<<" phi0: "<<resultDebug->m_t3dtrk0_phi0<<endl;;
1267 // cout<<" ts0 id: "<<resultDebug->m_t3dtrk0ts0_id<<" lr: "<<resultDebug->m_t3dtrk0ts0_lr<<" rt: "<<resultDebug->m_t3dtrk0ts0_rt<<endl;
1268 // cout<<" ts1 id: "<<resultDebug->m_t3dtrk0ts1_id<<" lr: "<<resultDebug->m_t3dtrk0ts1_lr<<" rt: "<<resultDebug->m_t3dtrk0ts1_rt<<endl;
1269 // cout<<" ts2 id: "<<resultDebug->m_t3dtrk0ts2_id<<" lr: "<<resultDebug->m_t3dtrk0ts2_lr<<" rt: "<<resultDebug->m_t3dtrk0ts2_rt<<endl;
1270 // cout<<" ts3 id: "<<resultDebug->m_t3dtrk0ts3_id<<" lr: "<<resultDebug->m_t3dtrk0ts3_lr<<" rt: "<<resultDebug->m_t3dtrk0ts3_rt<<endl;
1271 // cout<<" count: "<<countTrk0<<endl;
1272 // }
1273 //}
1274
1276 //int countTrk3 = int(result->m_t3dtrk1ts0_lr!=0)+int(result->m_t3dtrk1ts1_lr!=0)+int(result->m_t3dtrk1ts2_lr!=0)+int(result->m_t3dtrk1ts3_lr!=0);
1277 //if ( iClk < 48 - 7 - 1)
1278 //{
1279 // TRGCDCT3DUnpackerStore * resultDebug = m_firmwareResults[iClk];
1280 // TRGCDCT3DUnpackerStore * result = m_firmwareResults[iClk+7];
1281
1282 // if (int(countTrk3 > 1) == bitset<4> (int(result->m_t3d_validTS))[2])
1283 // {
1284 // cout<<"debug TSF matches with TSFValid3"<<endl;
1285 // } else {
1286 // cout<<"iClk:"<<iClk+7<<endl;
1287 // cout<<" [3D] fnf:"<<result->m_t3d_2dfnf<<" "<<bitset<6> (int(result->m_t3d_2dfnf))<<" tsValid: "<<result->m_t3d_validTS<<" "<<bitset<4> (int(result->m_t3d_validTS))<<endl;;
1288 // cout<<" [3DDebug] LSB"<<endl;
1289 // cout<<" charge: "<<resultDebug->m_t3dtrk1_charge<<" rho: "<<resultDebug->m_t3dtrk1_rho<<" phi0: "<<resultDebug->m_t3dtrk1_phi0<<endl;;
1290 // cout<<" ts0 id: "<<resultDebug->m_t3dtrk1ts0_id<<" lr: "<<resultDebug->m_t3dtrk1ts0_lr<<" rt: "<<resultDebug->m_t3dtrk1ts0_rt<<endl;
1291 // cout<<" ts1 id: "<<resultDebug->m_t3dtrk1ts1_id<<" lr: "<<resultDebug->m_t3dtrk1ts1_lr<<" rt: "<<resultDebug->m_t3dtrk1ts1_rt<<endl;
1292 // cout<<" ts2 id: "<<resultDebug->m_t3dtrk1ts2_id<<" lr: "<<resultDebug->m_t3dtrk1ts2_lr<<" rt: "<<resultDebug->m_t3dtrk1ts2_rt<<endl;
1293 // cout<<" ts3 id: "<<resultDebug->m_t3dtrk1ts3_id<<" lr: "<<resultDebug->m_t3dtrk1ts3_lr<<" rt: "<<resultDebug->m_t3dtrk1ts3_rt<<endl;
1294 // cout<<" count: "<<countTrk3<<endl;
1295 // }
1296 //}
1297
1298 // Compare 2D with debug and 3D after 4 clks and 11 clks
1299 if (result->m_t2d_fnf && iClk < 48 - 17 - 1 && bitset<6> (result->m_t2d_fnf)[5]) {
1300 TRGCDCT3DUnpackerStore* resultDebug = m_firmwareResults[iClk + 4];
1301 TRGCDCT3DUnpackerStore* result3D = m_firmwareResults[iClk + 17];
1302
1303 // Store information(charge, radius(cm), phi_c(rad), eventTime, eventTimeValid, [TS ID, TS LR, TS driftTime])
1304 // [TODO] Is evtTime clock correct?
1305 int charge = resultDebug->m_t3dtrk0_charge;
1306 double radius = resultDebug->m_t3dtrk0_rho * 2500 / (pow(2, 11) - 0.5);
1307 double phi_c = toSigned(resultDebug->m_t3dtrk0_phi0, 13) * M_PI / (pow(2, 12) - 0.5);
1308 int eventTime = result3D->m_t3dtrk0_evtTime_delay;
1309 int eventTimeValid = result3D->m_t3dtrk0_evtTimeValid_delay;
1310 // rawStTSs[iSt] = [TS ID, TS LR, TS driftTime]
1311 vector<vector<int> > rawStTSs(4, vector<int> (3));
1312 rawStTSs[0][0] = resultDebug->m_t3dtrk0ts0_id;
1313 rawStTSs[0][1] = resultDebug->m_t3dtrk0ts0_lr;
1314 rawStTSs[0][2] = resultDebug->m_t3dtrk0ts0_rt;
1315 rawStTSs[1][0] = resultDebug->m_t3dtrk0ts1_id;
1316 rawStTSs[1][1] = resultDebug->m_t3dtrk0ts1_lr;
1317 rawStTSs[1][2] = resultDebug->m_t3dtrk0ts1_rt;
1318 rawStTSs[2][0] = resultDebug->m_t3dtrk0ts2_id;
1319 rawStTSs[2][1] = resultDebug->m_t3dtrk0ts2_lr;
1320 rawStTSs[2][2] = resultDebug->m_t3dtrk0ts2_rt;
1321 rawStTSs[3][0] = resultDebug->m_t3dtrk0ts3_id;
1322 rawStTSs[3][1] = resultDebug->m_t3dtrk0ts3_lr;
1323 rawStTSs[3][2] = resultDebug->m_t3dtrk0ts3_rt;
1324
1325 // Get geometry
1326 map<string, vector<double> > stGeometry;
1327 vector<vector<double> > stXts;
1329 TRGCDCFitter3D::getStereoXt(stGeometry["priorityLayer"], stXts);
1330 //Fitter3DUtility::loadStereoXt("TODOdata/stereoXt",4,stXts);
1331
1333 //vector<double> stTSs(4);
1334 //Fitter3DUtility::calPhiFast(stGeometry, stXts, eventTimeValid, eventTime, rawStTSs, stTSs);
1335 //cout<<" [calPhi] "<<stTSs[0]<<" "<<stTSs[1]<<" "<<stTSs[2]<<" "<<stTSs[3]<<endl;
1337 //vector<double> invZError2;
1338 //Fitter3DUtility::setErrorFast(rawStTSs, eventTimeValid, invZError2);
1339 //cout<<" [invZError2] "<<invZError2[0]<<" "<<invZError2[1]<<" "<<invZError2[2]<<" "<<invZError2[3]<<endl;
1342 //vector<double> zz(4, 0);
1343 //vector<double> arcS(4, 0);
1344 //for (unsigned iSt = 0; iSt < 4; iSt++) {
1345 // if (rawStTSs[iSt][1] != 0) {
1346 // zz[iSt] = Fitter3DUtility::calZ(charge, stGeometry["angleSt"][iSt], stGeometry["zToStraw"][iSt],
1347 // stGeometry["cdcRadius"][iSt], stTSs[iSt], radius, phi_c);
1348 // arcS[iSt] = Fitter3DUtility::calS(radius, stGeometry["cdcRadius"][iSt]);
1349 // }
1350 //}
1351 //cout<<" [zz] "<<zz[0]<<" "<<zz[1]<<" "<<zz[2]<<" "<<zz[3]<<endl;
1352 //cout<<" [arcS] "<<arcS[0]<<" "<<arcS[1]<<" "<<arcS[2]<<" "<<arcS[3]<<endl;
1354 //double z0 = 0;
1355 //double cot = 0;
1356 //double chi2 = 0;
1357 //Fitter3DUtility::rSFit(&invZError2[0], &arcS[0], &zz[0], z0, cot, chi2);
1358 double z0 = 0;
1359 double cot = 0;
1360 double chi2 = 0;
1361 Fitter3DUtility::fitter3D(stGeometry, stXts, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, z0, cot, chi2);
1362
1363 // Prepare complex fit3D
1364 map<string, vector<double> > mConstV;
1365 map<string, double> mConstD;
1366 TRGCDCFitter3D::getConstants(mConstD, mConstV);
1367 //Belle2::TRGCDCJSignalData commonData;
1368 //map<string, TRGCDCJSignal> mSignalStorage;
1369 //map<string, TRGCDCJLUT*> mLutStorage;
1370 Fitter3DUtility::fitter3DFirm(mConstD, mConstV, eventTimeValid, eventTime, rawStTSs, charge, radius, phi_c, m_commonData,
1372
1375 //vector<tuple<string, double, int, double, double, int> > t_values = {
1376 // make_tuple("phi0", phi_c, mConstD["phiBitSize"], mConstD["phiMin"], mConstD["phiMax"], 0),
1377 // make_tuple("rho", radius, mConstD["rhoBitSize"], mConstD["rhoMin"], mConstD["rhoMax"], 0),
1378 // //make_tuple("charge",(int) (m_mDouble["charge"]==1 ? 1 : 0), 1, 0, 1.5, 0),
1379 // make_tuple("charge", (int)(charge == 1 ? 1 : 0), 1, 0, 1.5, 0),
1380 // make_tuple("lr_0", rawStTSs[0][1], 2, 0, 3.5, 0),
1381 // make_tuple("lr_1", rawStTSs[1][1], 2, 0, 3.5, 0),
1382 // make_tuple("lr_2", rawStTSs[2][1], 2, 0, 3.5, 0),
1383 // make_tuple("lr_3", rawStTSs[3][1], 2, 0, 3.5, 0),
1384 // make_tuple("tsId_0", rawStTSs[0][0], ceil(log(mConstV["nTSs"][1]) / log(2)), 0, pow(2, ceil(log(mConstV["nTSs"][1]) / log(2))) - 0.5, 0),
1385 // make_tuple("tsId_1", rawStTSs[1][0], ceil(log(mConstV["nTSs"][3]) / log(2)), 0, pow(2, ceil(log(mConstV["nTSs"][3]) / log(2))) - 0.5, 0),
1386 // make_tuple("tsId_2", rawStTSs[2][0], ceil(log(mConstV["nTSs"][5]) / log(2)), 0, pow(2, ceil(log(mConstV["nTSs"][5]) / log(2))) - 0.5, 0),
1387 // make_tuple("tsId_3", rawStTSs[3][0], ceil(log(mConstV["nTSs"][7]) / log(2)), 0, pow(2, ceil(log(mConstV["nTSs"][7]) / log(2))) - 0.5, 0),
1388 // make_tuple("tdc_0", rawStTSs[0][2], mConstD["tdcBitSize"], 0, pow(2, mConstD["tdcBitSize"]) - 0.5, 0),
1389 // make_tuple("tdc_1", rawStTSs[1][2], mConstD["tdcBitSize"], 0, pow(2, mConstD["tdcBitSize"]) - 0.5, 0),
1390 // make_tuple("tdc_2", rawStTSs[2][2], mConstD["tdcBitSize"], 0, pow(2, mConstD["tdcBitSize"]) - 0.5, 0),
1391 // make_tuple("tdc_3", rawStTSs[3][2], mConstD["tdcBitSize"], 0, pow(2, mConstD["tdcBitSize"]) - 0.5, 0),
1392 // make_tuple("eventTime", eventTime, mConstD["tdcBitSize"], 0, pow(2, mConstD["tdcBitSize"]) - 0.5, 0),
1393 // make_tuple("eventTimeValid", eventTimeValid, 1, 0, 1.5, 0),
1394 //};
1395 //TRGCDCJSignal::valuesToMapSignals(t_values, m_commonData, m_mSignalStorage);
1397 //Fitter3DUtility::setError(mConstD, mConstV, m_mSignalStorage);
1398 //Fitter3DUtility::calPhi(mConstD, mConstV, m_mSignalStorage, m_mLutStorage);
1399 //Fitter3DUtility::constrainRPerStSl(mConstV, m_mSignalStorage);
1400 //Fitter3DUtility::calZ(mConstD, mConstV, m_mSignalStorage, m_mLutStorage);
1401 //Fitter3DUtility::calS(mConstD, mConstV, m_mSignalStorage, m_mLutStorage);
1402 //Fitter3DUtility::rSFit(mConstD, mConstV, m_mSignalStorage, m_mLutStorage);
1405 //if ((*m_mSignalStorage.begin()).second.getName() == "") {
1406 // for (auto it = m_mSignalStorage.begin(); it != m_mSignalStorage.end(); ++it) {
1407 // (*it).second.setName((*it).first);
1408 // }
1409 //}
1410
1411 if (toSigned(result3D->m_t3dtrk0_z0_s, 11) != m_mSignalStorage["z0_r"].getInt()
1412 || toSigned(result3D->m_t3dtrk0_cot_s, 11) != m_mSignalStorage["cot_r"].getInt()) {
1413 bitset<6> t2d_oldfnf(int(result->m_t3d_2doldtrk));
1414 cout << "iClk:" << iClk << endl;
1415 cout << " [2D] fnf:" << result->m_t2d_fnf << " " << bitset<6> (result->m_t2d_fnf) << " oldfnf: " << t2d_oldfnf << endl;
1416// cout << " [0] rho: " << result->m_t2d0_rho_s << " " << t2DRhoTot3DRho(result->m_t2d0_rho_s) << " phi0: " << result->m_t2d0_phi <<
1417// " " << t2DPhiTot3DPhi(result->m_t2d0_phi, result->m_t2d0_rho_s) << endl;
1418 cout << " [debug] MSB" << endl;
1419 cout << " charge: " << resultDebug->m_t3dtrk0_charge << " rho: " << resultDebug->m_t3dtrk0_rho << " phi0: " << toSigned(
1420 resultDebug->m_t3dtrk0_phi0, 13) << endl;;
1421 cout << " ts0 id: " << resultDebug->m_t3dtrk0ts0_id << " lr: " << resultDebug->m_t3dtrk0ts0_lr << " rt: " <<
1422 resultDebug->m_t3dtrk0ts0_rt << endl;
1423 cout << " ts1 id: " << resultDebug->m_t3dtrk0ts1_id << " lr: " << resultDebug->m_t3dtrk0ts1_lr << " rt: " <<
1424 resultDebug->m_t3dtrk0ts1_rt << endl;
1425 cout << " ts2 id: " << resultDebug->m_t3dtrk0ts2_id << " lr: " << resultDebug->m_t3dtrk0ts2_lr << " rt: " <<
1426 resultDebug->m_t3dtrk0ts2_rt << endl;
1427 cout << " ts3 id: " << resultDebug->m_t3dtrk0ts3_id << " lr: " << resultDebug->m_t3dtrk0ts3_lr << " rt: " <<
1428 resultDebug->m_t3dtrk0ts3_rt << endl;
1429 cout << " [3D] fnf:" << result3D->m_t3d_2dfnf << " " << bitset<6> (result3D->m_t3d_2dfnf) << " tsValid: " <<
1430 result3D->m_t3d_validTS << " " << bitset<4> (result3D->m_t3d_validTS) << endl;;
1431 cout << " [0] z0: " << result3D->m_t3dtrk0_z0_s << " " << toSigned(result3D->m_t3dtrk0_z0_s,
1432 11) << " " << toSigned(result3D->m_t3dtrk0_z0_s,
1433 11) * 0.0382 << " cot: " << result3D->m_t3dtrk0_cot_s << " " << toSigned(result3D->m_t3dtrk0_cot_s,
1434 11) << " " << toSigned(result3D->m_t3dtrk0_cot_s, 11) * 0.00195 << " chi2: " << result3D->m_t3dtrk0_zchisq << endl;
1435 cout << " [1] z0: " << result3D->m_t3dtrk1_z0_s << " " << toSigned(result3D->m_t3dtrk1_z0_s,
1436 11) << " " << toSigned(result3D->m_t3dtrk1_z0_s,
1437 11) * 0.0382 << " cot: " << result3D->m_t3dtrk1_cot_s << " " << toSigned(result3D->m_t3dtrk1_cot_s,
1438 11) << " " << toSigned(result3D->m_t3dtrk1_cot_s, 11) * 0.00195 << " chi2: " << result3D->m_t3dtrk1_zchisq << endl;
1439 cout << " [2] z0: " << result3D->m_t3dtrk2_z0_s << " " << toSigned(result3D->m_t3dtrk2_z0_s,
1440 11) << " " << toSigned(result3D->m_t3dtrk2_z0_s,
1441 11) * 0.0382 << " cot: " << result3D->m_t3dtrk2_cot_s << " " << toSigned(result3D->m_t3dtrk2_cot_s,
1442 11) << " " << toSigned(result3D->m_t3dtrk2_cot_s, 11) * 0.00195 << " chi2: " << result3D->m_t3dtrk2_zchisq << endl;
1443 cout << " [3] z0: " << result3D->m_t3dtrk3_z0_s << " " << toSigned(result3D->m_t3dtrk3_z0_s,
1444 11) << " " << toSigned(result3D->m_t3dtrk3_z0_s,
1445 11) * 0.0382 << " cot: " << result3D->m_t3dtrk3_cot_s << " " << toSigned(result3D->m_t3dtrk3_cot_s,
1446 11) << " " << toSigned(result3D->m_t3dtrk3_cot_s, 11) * 0.00195 << " chi2: " << result3D->m_t3dtrk3_zchisq << endl;
1447 cout << " evtTime: " << result3D->m_t3dtrk0_evtTime_delay << " evtTimeValid: " << result3D->m_t3dtrk0_evtTimeValid_delay << endl;
1448
1449 cout << " [Store information]" << endl;
1450 cout << " charge: " << charge << " radius(cm): " << radius << " phi_c(rad): " << phi_c << endl;
1451 cout << " eventTime: " << eventTime << " valid: " << eventTimeValid << endl;
1452 cout << " rawStTSs[0] id:" << rawStTSs[0][0] << " lr: " << rawStTSs[0][1] << " rt: " << rawStTSs[0][2] << endl;
1453 cout << " rawStTSs[1] id:" << rawStTSs[1][0] << " lr: " << rawStTSs[1][1] << " rt: " << rawStTSs[1][2] << endl;
1454 cout << " rawStTSs[2] id:" << rawStTSs[2][0] << " lr: " << rawStTSs[2][1] << " rt: " << rawStTSs[2][2] << endl;
1455 cout << " rawStTSs[3] id:" << rawStTSs[3][0] << " lr: " << rawStTSs[3][1] << " rt: " << rawStTSs[3][2] << endl;
1456
1457 cout << " [Calculate fast]" << endl;
1458 cout << " [z0] " << z0 << " [cot] " << cot << " [chi2] " << chi2 << endl;
1459
1460 cout << " [Calculate firm]" << endl;
1461 cout << " z0: " << m_mSignalStorage["z0_r"].getInt() << " " << m_mSignalStorage["z0_r"].getRealInt() << " " <<
1462 m_mSignalStorage["z0_r"].getToReal() << " cot: " << m_mSignalStorage["cot_r"].getInt() << " " <<
1463 m_mSignalStorage["cot_r"].getRealInt() << " " << m_mSignalStorage["cot_r"].getToReal() << " zchi: " <<
1464 m_mSignalStorage["zChi2_r"].getInt() << " " << m_mSignalStorage["zChi2_r"].getRealInt() << " " <<
1465 m_mSignalStorage["zChi2_r"].getToReal() << endl;
1466 //doPrint = 1;
1467 }
1468 //else
1469 //{
1470 // cout<<"same"<<endl;
1471 //}
1472
1473 }
1474
1475 }
1476
1477 if (doPrint) {
1478 for (int iClk = 0; iClk < m_firmwareResults.getEntries(); iClk++) {
1480 bitset<6> t2d_fnf(int(result->m_t3d_2dfnf));
1481 bitset<4> tsf_fnf(int(result->m_t3d_validTS));
1482 bitset<6> t2d_oldfnf(int(result->m_t3d_2doldtrk));
1483 cout << "iClk:" << iClk << endl;
1484 cout << " [2D] fnf:" << result->m_t2d_fnf << " " << bitset<6> (result->m_t2d_fnf) << " oldfnf: " << t2d_oldfnf << endl;
1485 cout << " [0] rho: " << result->m_t2d0_rho_s << " " << toSigned(result->m_t2d0_rho_s,
1486 7) << " " << int(0.3 * 34 / 30 / 1.5e-4 / abs(toSigned(result->m_t2d0_rho_s, 7)) * (pow(2,
1487 11) - 0.5) / 2500) << " phi0: " << result->m_t2d0_phi << endl;
1488 cout << " [1] rho: " << result->m_t2d1_rho_s << " " << toSigned(result->m_t2d1_rho_s,
1489 7) << " " << int(0.3 * 34 / 30 / 1.5e-4 / abs(toSigned(result->m_t2d1_rho_s, 7)) * (pow(2,
1490 11) - 0.5) / 2500) << " phi0: " << result->m_t2d1_phi << endl;
1491 cout << " [2] rho: " << result->m_t2d2_rho_s << " " << toSigned(result->m_t2d2_rho_s,
1492 7) << " " << int(0.3 * 34 / 30 / 1.5e-4 / abs(toSigned(result->m_t2d2_rho_s, 7)) * (pow(2,
1493 11) - 0.5) / 2500) << " phi0: " << result->m_t2d2_phi << endl;
1494 cout << " [3] rho: " << result->m_t2d3_rho_s << " " << toSigned(result->m_t2d3_rho_s,
1495 7) << " " << int(0.3 * 34 / 30 / 1.5e-4 / abs(toSigned(result->m_t2d3_rho_s, 7)) * (pow(2,
1496 11) - 0.5) / 2500) << " phi0: " << result->m_t2d3_phi << endl;
1497 cout << " [3D] fnf:" << result->m_t3d_2dfnf << " " << t2d_fnf << " " << t2d_fnf[5] << " tsValid: " << result->m_t3d_validTS << " "
1498 << tsf_fnf << endl;;
1499 cout << " [0] z0: " << result->m_t3dtrk0_z0_s << " cot: " << result->m_t3dtrk0_cot_s << " chi2: " << result->m_t3dtrk0_zchisq
1500 << endl;
1501 cout << " [1] z0: " << result->m_t3dtrk1_z0_s << " cot: " << result->m_t3dtrk1_cot_s << " chi2: " << result->m_t3dtrk1_zchisq
1502 << endl;
1503 cout << " [2] z0: " << result->m_t3dtrk2_z0_s << " cot: " << result->m_t3dtrk2_cot_s << " chi2: " << result->m_t3dtrk2_zchisq
1504 << endl;
1505 cout << " [3] z0: " << result->m_t3dtrk3_z0_s << " cot: " << result->m_t3dtrk3_cot_s << " chi2: " << result->m_t3dtrk3_zchisq
1506 << endl;
1507 cout << " [debug] MSB" << endl;
1508 cout << " evtTime: " << result->m_t3dtrk0_evtTime_delay << " evtTimeValid: " << result->m_t3dtrk0_evtTimeValid_delay <<
1509 endl;
1510 cout << " charge: " << result->m_t3dtrk0_charge << " rho: " << result->m_t3dtrk0_rho << " phi0: " << result->m_t3dtrk0_phi0
1511 << endl;;
1512 cout << " ts0 id: " << result->m_t3dtrk0ts0_id << " lr: " << result->m_t3dtrk0ts0_lr << " rt: " << result->m_t3dtrk0ts0_rt
1513 << endl;
1514 cout << " ts1 id: " << result->m_t3dtrk0ts1_id << " lr: " << result->m_t3dtrk0ts1_lr << " rt: " << result->m_t3dtrk0ts1_rt
1515 << endl;
1516 cout << " ts2 id: " << result->m_t3dtrk0ts2_id << " lr: " << result->m_t3dtrk0ts2_lr << " rt: " << result->m_t3dtrk0ts2_rt
1517 << endl;
1518 cout << " ts3 id: " << result->m_t3dtrk0ts3_id << " lr: " << result->m_t3dtrk0ts3_lr << " rt: " << result->m_t3dtrk0ts3_rt
1519 << endl;
1520 cout << " [debug] LSB" << endl;
1521 cout << " evtTime: " << result->m_t3dtrk1_evtTime_delay << " evtTimeValid: " << result->m_t3dtrk1_evtTimeValid_delay <<
1522 endl;
1523 cout << " charge: " << result->m_t3dtrk1_charge << " rho: " << result->m_t3dtrk1_rho << " phi0: " << result->m_t3dtrk1_phi0
1524 << endl;;
1525 cout << " ts0 id: " << result->m_t3dtrk1ts0_id << " lr: " << result->m_t3dtrk1ts0_lr << " rt: " << result->m_t3dtrk1ts0_rt
1526 << endl;
1527 cout << " ts1 id: " << result->m_t3dtrk1ts1_id << " lr: " << result->m_t3dtrk1ts1_lr << " rt: " << result->m_t3dtrk1ts1_rt
1528 << endl;
1529 cout << " ts2 id: " << result->m_t3dtrk1ts2_id << " lr: " << result->m_t3dtrk1ts2_lr << " rt: " << result->m_t3dtrk1ts2_rt
1530 << endl;
1531 cout << " ts3 id: " << result->m_t3dtrk1ts3_id << " lr: " << result->m_t3dtrk1ts3_lr << " rt: " << result->m_t3dtrk1ts3_rt
1532 << endl;
1533 }
1534 }
1535}
1536
1537
1538// t3DFirmwareInfo[tIndex][iClk][2DValid, 2DisOld, TSFValid, EventTimeValid, eventTime, charge, rho, phi0, z0, cot, zchi]
1539// t3DInfo[eventTime, charge, rho, phi0, z0, cot, zchi]
1540void TRGCDCT3DConverterModule::filter3DData(boost::multi_array<double, 3>& t3DFirmwareInfo,
1541 boost::multi_array<double, 2>& t3DInfo)
1542{
1543 for (unsigned iTrack = 0; iTrack < t3DFirmwareInfo.shape()[0]; iTrack++) {
1544 for (unsigned iClk = 0; iClk < t3DFirmwareInfo.shape()[1]; iClk++) {
1545 //cout<<iClk<<" 2d: "<<t3DFirmwareInfo[iTrack][iClk][0]<<" tsf: "<<t3DFirmwareInfo[iTrack][iClk][2]<<" evt: "<<t3DFirmwareInfo[iTrack][iClk][3]<<" isOld: "<<t3DFirmwareInfo[iTrack][iClk][1]<<endl;
1546 // 2DValid
1547 if (t3DFirmwareInfo[iTrack][iClk][0] == 0) continue;
1548 //cout<<iClk<<" 2d: "<<t3DFirmwareInfo[iTrack][iClk][0]<<" tsf: "<<t3DFirmwareInfo[iTrack][iClk][2]<<" evt: "<<t3DFirmwareInfo[iTrack][iClk][3]<<" isOld: "<<t3DFirmwareInfo[iTrack][iClk][1]<<endl;
1549 // TSFValid
1550//t3DFirmwareInfo[iTrack][iClk][0] (t3d_fnf) := t2d_fnf & TSFValid, so using t3d_fnf is already sufficient
1551// if (t3DFirmwareInfo[iTrack][iClk][2] == 0) continue;
1552 // EventTimeValid
1553// if (t3DFirmwareInfo[iTrack][iClk][3] == 0) continue;
1554 // TODO make an algorithm to follow the track.
1555 // Start follow status of track.
1556 //choose new tracks
1557// if (t3DInfo.size() != 0 && t3DFirmwareInfo[iTrack][iClk][1] == 1) continue;
1558 //if (t3DFirmwareInfo[iTrack][iClk][1] == 1) continue;
1559 double track3D_ref[7] = {t3DFirmwareInfo[iTrack][iClk][4], t3DFirmwareInfo[iTrack][iClk][5], t3DFirmwareInfo[iTrack][iClk][6], t3DFirmwareInfo[iTrack][iClk][7], t3DFirmwareInfo[iTrack][iClk][8], t3DFirmwareInfo[iTrack][iClk][9], t3DFirmwareInfo[iTrack][iClk][10]};
1560
1561 boost::multi_array_ref<double, 1> track3D((double*)track3D_ref, boost::extents[7]);
1562
1563 t3DInfo.resize(boost::extents[t3DInfo.shape()[0] + 1][7]);
1564 t3DInfo[t3DInfo.shape()[0] - 1] = track3D;
1565
1566 }
1567 }
1568}
1569
1570// t3DInfo[eventTime, charge, rho, phi0, z0, cot, zchi]
1571void TRGCDCT3DConverterModule::add3DDatastore(boost::multi_array<double, 2>& t3DInfo, bool doConvert)
1572{
1573 for (unsigned iTrack = 0; iTrack < t3DInfo.shape()[0]; ++iTrack) {
1574 double charge = 0, phi0_i = 0, omega = 0, chi2D = 0, z0 = 0, cot = 0, zchi2 = 0;
1575 double phi0_c = 0;
1576 if (doConvert) {
1577 charge = t3DInfo[iTrack][1] == 2 ? -1 : 1;
1578 phi0_c = t2DPhiTot3DPhi(t3DInfo[iTrack][3], t3DInfo[iTrack][2]) / (pow(2, 12) - 0.5) * M_PI;
1579 //phi0_i = phi0_c + charge * M_PI_2;
1580 phi0_i = (45 + 90. / 80 * (1 + t3DInfo[iTrack][3])) / 180 * M_PI;
1581 //omega = charge / t2DRhoTot3DRho(t3DInfo[iTrack][2]) / (pow(2, 11) - 0.5) * 2500;
1582 omega = toSigned(t3DInfo[iTrack][2], 7) / 33.0 * 3.2;
1583 z0 = toSigned(t3DInfo[iTrack][4], 11) * 0.0382;
1584 cot = toSigned(t3DInfo[iTrack][5], 11) * 0.00195;
1585 zchi2 = t3DInfo[iTrack][6];
1586 } else {
1587 charge = t3DInfo[iTrack][1] == 1 ? 1 : -1;
1588 phi0_c = t2DPhiTot3DPhi((t3DInfo[iTrack][3] - 34 / 90.*80 - 1), t3DInfo[iTrack][2]) / (pow(2, 12) - 0.5) * M_PI;
1589 phi0_i = t3DInfo[iTrack][3];
1590 omega = t3DInfo[iTrack][2];
1591 z0 = t3DInfo[iTrack][4];
1592 cot = t3DInfo[iTrack][5];
1593 zchi2 = t3DInfo[iTrack][6];
1594 }
1595
1596 //Correct phi0_i. The zero points of raw phi0_i for four boards are different.
1597 if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore0") {
1598 phi0_c = phi0_c + (M_PI / 2.0) * 0;
1599 phi0_i = phi0_i + (M_PI / 2.0) * 0;
1600 } else if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore1") {
1601 phi0_c = phi0_c + (M_PI / 2.0) * 1;
1602 phi0_i = phi0_i + (M_PI / 2.0) * 1;
1603 } else if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore2") {
1604 phi0_c = phi0_c + (M_PI / 2.0) * 2;
1605 phi0_i = phi0_i + (M_PI / 2.0) * 2;
1606 } else if (m_firmwareResultCollectionName == "TRGCDCT3DUnpackerStore3") {
1607 phi0_c = phi0_c + (M_PI / 2.0) * 3;
1608 phi0_i = phi0_i + (M_PI / 2.0) * 3;
1609 }
1610 // Confine the range of the angle to -pi ~ pi
1611 while (phi0_c > M_PI) {
1612 phi0_c -= 2 * M_PI;
1613 }
1614 while (phi0_i < -M_PI) {
1615 phi0_c += 2 * M_PI;
1616 }
1617 while (phi0_i > M_PI) {
1618 phi0_i -= 2 * M_PI;
1619 }
1620 while (phi0_i < -M_PI) {
1621 phi0_i += 2 * M_PI;
1622 }
1623
1624 //cout<<"iTrack: "<<iTrack<<" eventTime:"<<t3DInfo[iTrack][0]<<" charge:"<<charge<<" omega: "<<omega<<" rho: "<<charge/omega<<" pt: "<<charge/omega*0.3*1.5*0.01<<" phi0_i: "<<phi0_i<<" "<<phi0_i*180/M_PI<<" phi0_c: "<<phi0_c<<" "<<phi0_c*180/M_PI<<" z0:"<<z0<<" cot:"<<cot<<" theta: "<<M_PI/2-atan(cot)<<" zchi:"<<zchi2<<endl;
1625 if (m_isVerbose) cout << "[3D] iTrack:" << iTrack << " charge: " << charge << " phi0_i:" << phi0_i << " " << phi0_i * 180 / M_PI <<
1626 " omega:" << omega << " pt:" << charge / omega * 0.3 * 1.5 * 0.01 << " z0:" << z0 << " cot:" << cot << " zchi2:" << zchi2 << endl;
1627 m_tracks3D.appendNew(phi0_i, omega, chi2D, z0, cot, zchi2);
1628 }
1629}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition CDCHit.h:40
Track created by the CDC trigger.
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
Module()
Constructor.
Definition Module.cc:30
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
A class to hold common data for JSignals.
Definition JSignalData.h:33
std::string m_EventTimeName
name of the event time StoreObjPtr
StoreArray< CDCTriggerTrack > m_tracks2D
list of 2D input tracks
void addTSDatastore(boost::multi_array< double, 3 > &tsfInfo, int isSt=1)
adds tsfInfo to TS data store
bool m_add2DFinderToDatastore
Flag for adding 2D finder to datastore.
void store3DFirmSimData(boost::multi_array< double, 3 > &t3DFirmwareInfo)
uses firm sim with debug
Belle2::TRGCDCJSignalData * m_commonData
TRGCDCJSignalData for VHDL generation (jbkim's class)
int toSigned(int value, int nBits)
converts to signed value
void store3DFastSimData(boost::multi_array< double, 3 > &t3DFirmwareInfo)
uses fast sim with debug
virtual void initialize() override
Initializes TRGCDCT3DConverterModule.
std::string m_outputCollectionName
Name of the StoreArray containing the resulting 3D tracks.
StoreArray< CDCTriggerSegmentHit > m_hits
list of track segment hits
void filterTSData(boost::multi_array< double, 4 > &tsfFirmwareInfo, boost::multi_array< double, 3 > &tsfInfo)
filters tsfFirmwareInfo to tsfInfo
std::map< std::string, TRGCDCJLUT * > m_mLutStorage
TRGCDCJLUT for VHDL generation (jbkim's class)
virtual void terminate() override
Called when processing ended.
void add3DDatastore(boost::multi_array< double, 2 > &t3DInfo, bool doConvert=1)
adds t3DInfo to track data store
std::map< std::string, TRGCDCJSignal > m_mSignalStorage
TRGCDCJSignal for VHDL generation (jbkim's class)
void store2DFirmwareData(boost::multi_array< double, 3 > &t2DFirmwareInfo, boost::multi_array< double, 4 > &axTsfFirmwareInfo)
converts firmwareResults of 2D to a vector
std::string m_inputCollectionName
Name of the StoreArray containing the input tracks from the 2D fitter.
void store3DFirmwareData(boost::multi_array< double, 3 > &t3DFirmwareInfo)
converts firmwareResults of 3D to a vector
virtual void beginRun() override
Called when new run started.
void storeTSFirmwareData(boost::multi_array< double, 4 > &tsfInfo)
converts firmwareResults of TS to a vector
bool m_addEventTimeToDatastore
Flag for adding event time to datastore.
StoreArray< CDCTriggerTrack > m_tracks3D
list of 3D output tracks
StoreObjPtr< BinnedEventT0 > m_eventTime
StoreObjPtr containing the event time.
void filter3DData(boost::multi_array< double, 3 > &t3DFirmwareInfo, boost::multi_array< double, 2 > &t3DInfo)
filters t3DFirmwareInfo to t3DInfo
void filter2DData(boost::multi_array< double, 3 > &t2DFirmwareInfo, boost::multi_array< double, 4 > &t2DTsfFirmwareInfo, boost::multi_array< double, 2 > &t2DInfo, boost::multi_array< double, 3 > &t2DTsfInfo)
filters t2DFirmwareInfo to t2DInfo*‍/ void filter2DData(boost::multi_array<double,...
int toTSID(int iSL, int iWire)
converts sl, iWire to continuous TS ID [0,2335]
std::string m_hitCollectionName
Name of the StoreArray containing the input track segment hits.
std::string m_firmwareResultCollectionName
Name of the StoreArray containing the input firmware results.
void add2DDatastore(boost::multi_array< double, 2 > &t2DInfo, boost::multi_array< double, 3 > &t2DTsfInfo)
adds t2DInfo to track data store
int t2DPhiTot3DPhi(int phi, int rho)
converts to 2D rho to 3D rho value, obsolete
StoreArray< TRGCDCT3DUnpackerStore > m_firmwareResults
list of firmware results
int m_t3dtrk3_cot_s
m_t3dtrk3_cot_s leaf
int m_t3dtrk3_zchisq
m_t3dtrk3_zchisq leaf
int m_t3dtrk0_evtTimeValid_delay
m_t3dtrk0_evtTimeValid_delay leaf
int m_t3dtrk0ts2_id
m_t3dtrk0ts2_id leaf
int m_t3dtrk0ts0_rt
m_t3dtrk0ts0_rt leaf
int m_t3dtrk0ts3_lr
m_t3dtrk0ts3_lr leaf
int m_t3dtrk0ts1_id
m_t3dtrk0ts1_id leaf
int m_t3dtrk2_zchisq
m_t3dtrk2_zchisq leaf
int m_t3dtrk2_cot_s
m_t3dtrk2_cot_s leaf
int m_t3dtrk0ts3_id
m_t3dtrk0ts3_id leaf
int m_t3dtrk0ts0_lr
m_t3dtrk0ts0_lr leaf
int m_t3dtrk0_zchisq
m_t3dtrk0_zchisq leaf
int m_t3dtrk1_cot_s
m_t3dtrk1_cot_s leaf
int m_t3dtrk0ts0_id
m_t3dtrk0ts0_id leaf
int m_t3dtrk0_cot_s
m_t3dtrk0_cot_s leaf
int m_t3dtrk0_evtTime_delay
m_t3dtrk0_evtTime_delay leaf
int m_t3dtrk0ts2_lr
m_t3dtrk0ts2_lr leaf
int m_t3dtrk0ts1_rt
m_t3dtrk0ts1_rt leaf
int m_t3dtrk0ts3_rt
m_t3dtrk0ts3_rt leaf
int m_t3dtrk0_charge
m_t3dtrk0_charge leaf
int m_t3dtrk0ts1_lr
m_t3dtrk0ts1_lr leaf
int m_t3dtrk0ts2_rt
m_t3dtrk0ts2_rt leaf
int m_t3dtrk1_zchisq
m_t3dtrk1_zchisq leaf
static void fitter3DFirm(std::map< std::string, double > &mConstD, const std::map< std::string, std::vector< double > > &mConstV, int eventTimeValid, int eventTime, std::vector< std::vector< int > > const &rawStTSs, int charge, double radius, double phi_c, Belle2::TRGCDCJSignalData *commonData, std::map< std::string, Belle2::TRGCDCJSignal > &mSignalStorage, std::map< std::string, Belle2::TRGCDCJLUT * > &mLutStorage)
Combines several functions for fitter3D firmware.
static void fitter3D(std::map< std::string, std::vector< double > > &stGeometry, std::vector< std::vector< double > > const &stXts, int eventTimeValid, int eventTime, std::vector< std::vector< int > > const &rawStTSs, int charge, double radius, double phi_c, double &z0, double &cot, double &chi2)
Combines several functions for fitter3D.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
static void getStereoGeometry(std::map< std::string, std::vector< double > > &stGeometry)
Get stereo geometry.
Definition Fitter3D.cc:1558
static void getStereoXt(std::vector< double > const &stPriorityLayer, std::vector< std::vector< double > > &stXts, bool isSimple=0)
Get stereo Xt.
Definition Fitter3D.cc:1578
static void getConstants(std::map< std::string, double > &mConstD, std::map< std::string, std::vector< double > > &mConstV, bool isXtSimple=0)
Get constants for firmwareFit.
Definition Fitter3D.cc:1596
Abstract base class for different kinds of events.
STL namespace.