2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/SmartDataPtr.h"
12 : Algorithm(name, pSvcLocator),
16 declareProperty(
"dump", m_dump =
false);
17 declareProperty(
"InjectionInterval", m_interval = 60);
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);
23 m_printInterval =
true;
34 MsgStream log(
msgSvc(), name());
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");
40 m_root = TFile::Open( m_etsfile.c_str(),
"RECREATE");
41 m_tree->SetDirectory(m_root);
50 StatusCode sc = service(
"InjSigIntervalSvc", m_InjSigIntervalSvc);
51 if( sc != StatusCode::SUCCESS ){
52 log << MSG::FATAL <<
"can not use InjSigIntervalSvc" << endreq;
54 return StatusCode::SUCCESS;
59 MsgStream log(
msgSvc(), name());
61 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
62 unsigned long t1 = eventHeader->etsT1();
63 unsigned long t2 = eventHeader->etsT2();
71 cout <<
"GetRawETS::execute() m_interval = " << m_interval << endl;
72 m_printInterval =
false;
75 double dt1 = (double(t1)/double(2000000.));
76 double dt2 = (double(t2)/double(2000000.));
78 std::cout <<
"Event: " << eventHeader->eventNumber()
79 <<
" run: " << eventHeader->runNumber()
80 <<
" time: " << eventHeader->time()
86 if ( t2 != 0 && t2 != m_ets2 ) {
88 m_vec.push_back(m_ets2);
99 return StatusCode::SUCCESS;
104 if ( m_vec.empty() ) {
107 return StatusCode::SUCCESS;
110 std::sort(m_vec.begin(), m_vec.end());
111 m_vec.erase(std::unique(m_vec.begin(), m_vec.end()), m_vec.end());
113 unsigned long _interval = m_interval * 2000;
117 unsigned long tmp = m_vec.front();
118 for (
int j = m_nfill; j > 0; --j ) {
119 if ( tmp <= _interval*j )
continue;
121 m_ets2 = tmp - _interval*j;
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;
132 if ( diff > _interval*(m_nfill+1)*2+10000 ) {
133 _1stEvtInTopUp =
true;
134 for (
int j = 1; j < m_nfill+1; ++j ) {
136 m_ets2 = m_vec[i-1] + _interval*j;
139 for (
int j = m_nfill; j > 0; --j ) {
141 m_ets2 = m_vec[i] - _interval*j;
145 else if ( diff > _interval+10000 ) {
146 for (
int j = 1; j < 10; ++j ) {
148 m_ets2 = m_vec[i-1] + _interval*j;
149 if ( m_ets2 >= m_vec[i] || m_vec[i]-m_ets2 < 10000 ) {
156 m_flag = _1stEvtInTopUp ? m_1stFlag : 0;
161 unsigned long tmp = m_vec.back();
162 for (
int j = 1; j < m_nfill+1; ++j ) {
164 m_ets2 = tmp + _interval*j;
172 return StatusCode::SUCCESS;
GetRawETS(const std::string &name, ISvcLocator *pSvcLocator)
virtual int getTInterval() const =0