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