13#define TRG_SHORT_NAMES
14#define TRGCDC_SHORT_NAMES
16#include "trg/trg/Debug.h"
17#include "trg/cdc/Segment.h"
18#include "trg/cdc/TRGCDCTrack.h"
19#include "trg/cdc/EventTime.h"
26#include "trg/cdc/TRGCDC.h"
27#include "trg/cdc/Layer.h"
28#include "trg/cdc/Wire.h"
29#include "trg/cdc/WireHit.h"
30#include "trg/cdc/SegmentHit.h"
31#include "trg/trg/Utilities.h"
52 m_makeRootFile(makeRootFile),
56 if (m_makeRootFile) m_fileEvtTime =
new TFile(
"ETF.root",
"RECREATE");
58 m_evtOutputTs =
new TTree(
"m_evtOutsTs",
"EvtTime Outputs for TS");
59 m_evtOut =
new TTree(
"m_evtOut",
"EvtTime Outputs for 20 TS");
61 m_evtOutputTs->Branch(
"tsFastestTime", &m_fastestT,
"m_fastestT/I");
62 m_evtOutputTs->Branch(
"tsFoundTime", &m_foundT,
"m_foundT/I");
63 m_evtOutputTs->Branch(
"foundT_fastT_diff", &m_whdiff,
"m_whdiff/I");
65 m_evtOut->Branch(
"histTime", &m_histT,
"m_histT/I");
67 h =
new TH1D(
"h",
"h", 1000, -500, 499);
69 memset(cnt, 0,
sizeof cnt);
70 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);
126 const vector<const TCSHit*> tsh =
_cdc.segmentHits();
128 for (
int iClk = 0; iClk < 64; iClk++) {
129 for (
int iTS = 0; iTS < (int)tsh.size(); iTS++) {
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) {
162 for (
int i = 450; i < 600; i++) {
185 for (
unsigned i = 0; i <
_cdc.nSegmentLayers(); 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;
int m_foundT
Found time of TS.
TTree * m_evtOut
TTree pointer of the TFile.
int m_noET
no ET bin is looped
bool m_makeRootFile
make Root file or not
const TRGCDC & _cdc
TRGCDC class.
TTree * m_evtOutputTs
TTree pointer of the TFile.
int threshold
Threshold value.
int ft[9][64][10]
Fastest time array each SL and clock.
int m_whdiff
Drift time of TS.
int m_fastestT
The fastest time of TS.
TFile * m_fileEvtTime
TFile pointer.
bool m_foundT0
T0 is found or not.
int cnt[9][64]
TS counter for each SL and clock.
int m_minusET
minus ET bin
TH1 * h
TH1 pointer of the TFile.
A class to represent a cell layer.
A class to represent a wire in CDC.
The instance of TRGCDC is a singleton.
A class to represent a digitized signal. Unit is nano second.
void hist(void)
making hostogram
void doit(int ver, bool print)
Calculate T0 based on ver.
float fastestTime(void) const
return fastest time in TSHit.
unsigned id(void) const
returns id.
TRGCDCEventTime(const TRGCDC &, bool makeRootFile)
constructor of TRGCDCEventTime class
void terminate(void)
terminate function
static void enterStage(const std::string &stageName)
Declare that you enter new stage.
void initialize(void)
initialize the class
virtual ~TRGCDCEventTime()
destructor of TRGCDCEventTime class
int getT0(void) const
Calculate T0.
const TRGCDCLayer & layer(void) const
returns a pointer to a layer.
static void leaveStage(const std::string &stageName)
Declare that you leave a stage.
void oldVer(void)
old version of calculation function
unsigned nCells(void) const
returns # of cells.
float foundTime(void) const
return found time in TSHit.
void printFirm(void)
Print info in firmware level.
void hitcount(void)
hit count of TS
Abstract base class for different kinds of events.