14 #define TRG_SHORT_NAMES
15 #define TRGCDC_SHORT_NAMES
17 #include "trg/trg/Debug.h"
18 #include "trg/cdc/Segment.h"
19 #include "trg/cdc/Track.h"
20 #include "trg/cdc/EventTime.h"
27 #include "trg/cdc/TRGCDC.h"
28 #include "trg/cdc/Layer.h"
29 #include "trg/cdc/Wire.h"
30 #include "trg/cdc/WireHit.h"
31 #include "trg/cdc/SegmentHit.h"
32 #include "trg/trg/Utilities.h"
44 TRGCDCEventTime::TRGCDCEventTime(
const TRGCDC&
TRGCDC,
bool makeRootFile)
53 m_makeRootFile(makeRootFile),
57 if (m_makeRootFile) m_fileEvtTime =
new TFile(
"ETF.root",
"RECREATE");
59 m_evtOutputTs =
new TTree(
"m_evtOutsTs",
"EvtTime Outputs for TS");
60 m_evtOut =
new TTree(
"m_evtOut",
"EvtTime Outputs for 20 TS");
62 m_evtOutputTs->Branch(
"tsFastestTime", &m_fastestT,
"m_fastestT/I");
63 m_evtOutputTs->Branch(
"tsFoundTime", &m_foundT,
"m_foundT/I");
64 m_evtOutputTs->Branch(
"foundT_fastT_diff", &m_whdiff,
"m_whdiff/I");
66 m_evtOut->Branch(
"histTime", &m_histT,
"m_histT/I");
68 h =
new TH1D(
"h",
"h", 1000, -500, 499);
70 memset(cnt, 0,
sizeof cnt);
71 memset(ft, 0,
sizeof ft);
103 }
else if (ver == 0) {
107 }
else if (ver == 2) {
112 cout <<
"verETF error" << endl;
113 cout <<
"choose 0:hist, 1:old, 2:trueT0" << endl;
123 memset(
cnt, 0,
sizeof cnt);
124 memset(
ft, 0,
sizeof ft);
128 for (
int iClk = 0; iClk < 64; iClk++) {
129 for (
int iTS = 0; iTS < (int)tsh.size(); iTS++) {
131 int fndC = ts.foundTime() / 16;
134 m_whdiff = ts.foundTime() - ts.fastestTime();
136 if (iClk == fndC + 31) {
137 for (
int iSL = 0; iSL < 9; iSL++) {
138 if ((
int)ts.layer().id() == iSL) {
140 if (
cnt[iSL][iClk] <= 10) {
143 ft[iSL][iClk][
cnt[iSL][iClk] - 1] = ts.fastestTime();
162 for (
int i = 450; i < 600; i++) {
187 const unsigned nWires = l->nCells();
188 for (
unsigned j = 0; j < nWires; j++) {
189 const TCSegment& s = (TCSegment&) * (*l)[j];
190 const vector<const TCWire*>& wires = s.wires();
192 if (timing.active()) {
193 for (
unsigned k = 0; k < wires.size(); k++) {
194 if (wires[k]->hit()) {
195 int dt = wires[k]->signal()[0]->time();
213 for (
int iClk = 0; iClk < 64; iClk++) {
214 for (
int iSL = 0; iSL < 9; iSL++) {
215 int hmbw = 160 + 32 * (iSL - 1);
216 if (iSL == 0) hmbw = 160;
220 sprintf(file,
"SL%d.coe", iSL);
221 string cnts = string(
cnt[iSL][iClk],
'1');
223 string clk = bitset<9>(iClk + 64 * (
m_eventN - 1)).to_string();
224 string clk2 = bitset<5>(iClk).to_string();
225 for (
int i = 0; i < 10; i++) {
226 hs[i] = bitset<4>(
ft[iSL][iClk][i]).to_string();
227 if (
cnt[iSL][iClk] > i) t[i] = clk2 + hs[i];
228 else t[i] =
"00000" + hs[i];
231 fout.open(file, ios::app);
233 fout << setfill(
'0') << setw(hmbw) << cnts;
234 fout << t[9] << t[8] << t[7] << t[6] << t[5] << t[4] << t[3] << t[2] << t[1] << t[0] << endl;