BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
GetRawETS Class Reference

#include <GetRawETS.h>

+ Inheritance diagram for GetRawETS:

Public Member Functions

 GetRawETS (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 

Detailed Description

Definition at line 10 of file GetRawETS.h.

Constructor & Destructor Documentation

◆ GetRawETS()

GetRawETS::GetRawETS ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 11 of file GetRawETS.cxx.

12 : Algorithm(name, pSvcLocator),
13 m_flag(0),
14 m_ets2(0)
15{
16 declareProperty("dump", m_dump = false);
17 declareProperty("InjectionInterval", m_interval = 60); /*in ms*/
18 declareProperty("NumFill", m_nfill = 1);
19 declareProperty("FirstEvtInTopUpFlag", m_1stFlag = 0);
20 declareProperty("ETS_FILE", m_etsfile = "ets2.root");
21 declareProperty("ReadFromDB", m_readFromDB = true);
22
23 m_printInterval = true;
24}

Member Function Documentation

◆ execute()

StatusCode GetRawETS::execute ( )

Definition at line 57 of file GetRawETS.cxx.

58{
59 MsgStream log(msgSvc(), name());
60
61 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
62 unsigned long t1 = eventHeader->etsT1(); //500ns
63 unsigned long t2 = eventHeader->etsT2(); //500ns
64
65 if(m_readFromDB){
66 m_interval = m_InjSigIntervalSvc->getTInterval();
67 m_readFromDB = false;
68 }
69
70 if(m_printInterval){
71 cout << "GetRawETS::execute() m_interval = " << m_interval << endl;
72 m_printInterval = false;
73 }
74 if ( m_dump ) {
75 double dt1 = (double(t1)/double(2000000.)); //in seconds
76 double dt2 = (double(t2)/double(2000000.)); //in seconds
77
78 std::cout << "Event: " << eventHeader->eventNumber()
79 << " run: " << eventHeader->runNumber()
80 << " time: " << eventHeader->time()
81 << " EtsT1: " << t1
82 << " EtsT2: " << t2
83 << std::endl;
84 }
85
86 if ( t2 != 0 && t2 != m_ets2 ) {
87 m_ets2 = t2;
88 m_vec.push_back(m_ets2);
89 }
90
91 //{
92 // _Event = eventHeader->eventNumber();
93 // _EvtTime = eventHeader->time();
94 // _ETS1 = t1;
95 // _ETS2 = t2;
96 // _TestTree->Fill();
97 //}
98
99 return StatusCode::SUCCESS;
100}
IMessageSvc * msgSvc()
virtual int getTInterval() const =0

◆ finalize()

StatusCode GetRawETS::finalize ( )

Definition at line 102 of file GetRawETS.cxx.

103{
104 if ( m_vec.empty() ) {
105 // DO NOT CRASH when m_vec is empty
106 m_root->Write();
107 return StatusCode::SUCCESS;
108 }
109
110 std::sort(m_vec.begin(), m_vec.end());
111 m_vec.erase(std::unique(m_vec.begin(), m_vec.end()), m_vec.end());
112
113 unsigned long _interval = m_interval * 2000; // -> 500ns
114
115 // Fill the Tree
116 {
117 unsigned long tmp = m_vec.front();
118 for ( int j = m_nfill; j > 0; --j ) {
119 if ( tmp <= _interval*j ) continue;
120 m_flag = 10 + j;
121 m_ets2 = tmp - _interval*j;
122 m_tree->Fill(); //case 13,12,11: prepend N addtional ets to current injection period
123 }
124 m_flag = m_1stFlag;
125 m_ets2 = tmp;
126 m_tree->Fill(); //the first real ets
127 }
128 for ( unsigned int i = 1; i < m_vec.size(); ++i ) {
129 unsigned long diff = m_vec[i] - m_vec[i-1];
130 bool _1stEvtInTopUp = false;
131
132 if ( diff > _interval*(m_nfill+1)*2+10000 ) { //long gap: +5ms for safe
133 _1stEvtInTopUp = true;
134 for ( int j = 1; j < m_nfill+1; ++j ) {
135 m_flag = 20 + j;
136 m_ets2 = m_vec[i-1] + _interval*j;
137 m_tree->Fill(); //case 21,22,23: append N addtional ets to previous injection period
138 }
139 for ( int j = m_nfill; j > 0; --j ) {
140 m_flag = 10 + j;
141 m_ets2 = m_vec[i] - _interval*j;
142 m_tree->Fill(); //case 13,12,11: prepend N addtional ets to current injection period
143 }
144 }
145 else if ( diff > _interval+10000 ) { //missing ets2: +5ms for safe
146 for ( int j = 1; j < 10; ++j ) {
147 m_flag = 1;
148 m_ets2 = m_vec[i-1] + _interval*j; //m_interval * ms * j
149 if ( m_ets2 >= m_vec[i] || m_vec[i]-m_ets2 < 10000 ) { //5ms
150 break;
151 }
152 m_tree->Fill(); //case 1: fill the missing ets2 explicitly
153 }
154 }
155
156 m_flag = _1stEvtInTopUp ? m_1stFlag : 0;
157 m_ets2 = m_vec[i];
158 m_tree->Fill(); //case 0: good ets2
159 }
160 {
161 unsigned long tmp = m_vec.back();
162 for ( int j = 1; j < m_nfill+1; ++j ) {
163 m_flag = 20 + j;
164 m_ets2 = tmp + _interval*j;
165 m_tree->Fill(); //case 21,22,23: append N addtional ets to the last injection period
166 }
167 }
168
169 // Write ROOT file
170 m_root->Write();
171
172 return StatusCode::SUCCESS;
173}

◆ initialize()

StatusCode GetRawETS::initialize ( )

Definition at line 32 of file GetRawETS.cxx.

33{
34 MsgStream log(msgSvc(), name());
35
36 m_tree = new TTree("ist", "The IST time for BES3 raw data");
37 m_tree->Branch("flag", &m_flag, "flag/I");
38 m_tree->Branch("IST", &m_ets2, "IST/l");
39
40 m_root = TFile::Open( m_etsfile.c_str(), "RECREATE");
41 m_tree->SetDirectory(m_root);
42
43 //_TestTree = new TTree("test", "The test TTree");
44 //_TestTree->Branch("event", &_Event, "event/I");
45 //_TestTree->Branch("time", &_EvtTime, "time/I");
46 //_TestTree->Branch("ets1", &_ETS1, "ets1/l");
47 //_TestTree->Branch("ets2", &_ETS2, "ets2/l");
48 //_TestTree->SetDirectory(m_root);
49
50 StatusCode sc = service("InjSigIntervalSvc", m_InjSigIntervalSvc);
51 if( sc != StatusCode::SUCCESS ){
52 log << MSG::FATAL << "can not use InjSigIntervalSvc" << endreq;
53 }
54 return StatusCode::SUCCESS;
55}

The documentation for this class was generated from the following files: