17: Algorithm(name, pSvcLocator),
23 declareProperty(
"dump", m_dump =
false);
24 declareProperty(
"ReadInjSigIntervalFromDB", m_readInjSigIntervalFromDB =
true);
25 declareProperty(
"ReadInjSigTimeFromDB", m_readInjSigTimeFromDB =
true);
26 declareProperty(
"InjSigInterval", m_interval=60);
27 declareProperty(
"RunListFile", m_runListFile);
28 m_printInterval =
true;
70 MsgStream log(
msgSvc(), name());
72 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
75 if ( m_fixer ==
NULL ) {
78 m_run = eventHeader->runNumber();
79 if ( std::find(m_runList.begin(), m_runList.end(), m_run) != m_runList.end() ) {
80 SmartDataPtr<CalibData::CorrectedETSCal> calConst(m_calibDataSvc,
"/Calib/CorrectedETS");
85 log << MSG::FATAL <<
"no result in DB for run " << m_run << endreq;
86 return StatusCode::FAILURE;
92 if ( m_alreadyInDB ) {
93 if ( m_run != eventHeader->runNumber() ) {
94 log << MSG::FATAL <<
"crossed runs are not supported" << endreq;
95 return StatusCode::FAILURE;
98 SmartDataPtr<CalibData::CorrectedETSCal> calConst(m_calibDataSvc,
"/Calib/CorrectedETS");
100 if ( m_count >= calConst->getNpar() || eventHeader->eventNumber() != calConst->getEvt(m_count) ) {
101 log << MSG::FATAL <<
"only 1 input file is supported" << endreq;
102 return StatusCode::FAILURE;
105 eventHeader->setRawEtsT1( eventHeader->etsT1() );
106 eventHeader->setEtsT1( calConst->getEts1(m_count) );
107 eventHeader->setEtsT2( calConst->getEts2_pre(m_count) );
108 eventHeader->setEtsFlag( calConst->getFlag_pre(m_count) );
112 return StatusCode::SUCCESS;
119 m_fixer->
fixT1(eventHeader);
125 if(m_readInjSigTimeFromDB){
126 int Npar = m_InjSigTimeSvc-> getNpar();
127 for(
int i=0; i<Npar; i++){
128 int flag = m_InjSigTimeSvc-> getFlag(i);
129 ULong64_t
time = m_InjSigTimeSvc-> getIST(i);
130 m_vecFlag.push_back(
flag);
131 m_vecTime.push_back(
time);
133 std::cout<<
"flag: "<<
flag<<
" time: "<<
time<<std::endl;
136 m_readInjSigTimeFromDB =
false;
139 if(m_readInjSigIntervalFromDB){
140 m_interval = double(m_InjSigIntervalSvc->
getTInterval());
141 m_readInjSigIntervalFromDB =
false;
145 cout <<
"ResetEts::execute() m_interval = " << m_interval << endl;
146 m_printInterval =
false;
149 unsigned long t1 = eventHeader->etsT1();
150 unsigned long t2 = eventHeader->etsT2();
154 std::cout<<
"raw data"<<std::endl<<
"Event: " << eventHeader->eventNumber()
155 <<
" run: " << eventHeader->runNumber()
156 <<
" time: " << eventHeader->time()
157 <<
" ETS_old: " << t1
158 <<
" IST_old: " << t2
163 double size = m_interval*
unit;
164 unsigned long ets2_pre = 0;
168 int vec_size = m_vecTime.size();
169 for(
int i=m_curIndex;i<vec_size;i++)
171 if (t1 < m_vecTime[i])
174 flag_pre = m_vecFlag[i];
175 ets2_pre = m_vecTime[i];
181 double delta= ((double)m_vecTime[i-1]-(double)t1)/size;
193 ets2_pre = m_vecTime[i-1];
194 flag_pre = m_vecFlag[i-1];
200 else if (t1 >= m_vecTime[vec_size-1]){
201 flag_pre = m_vecFlag[vec_size-1];
202 ets2_pre = m_vecTime[vec_size-1];
209 eventHeader->setEtsT2(ets2_pre);
210 eventHeader->setEtsFlag(flag_pre);
214 std::cout<<
"ReSetETSAlg"<<std::endl<<
"Event: " << eventHeader->eventNumber()
215 <<
" run: " << eventHeader->runNumber()
216 <<
" time: " << eventHeader->time()
217 <<
" ETS_new: " << eventHeader->etsT1()
218 <<
" IST_new: " << eventHeader->etsT2()
219 <<
" flag_pre: " << eventHeader->etsFlag()
224 return StatusCode::SUCCESS;