334 {
335 MsgStream log(
msgSvc(), name() );
336
337 SmartDataPtr<Event::EventHeader> eventHeader( m_eventSvc, "/Event/EventHeader" );
340 int run = eventHeader->runNumber();
341 unsigned long time_etsT1 = eventHeader->etsT1();
342 long time_etsT1_timelike32 = ( ( time_etsT1 / 2000000 ) & 0x00000000ffffffffLU );
343
344
345
346
347
348
349
350 if ( m_useEtsT1 )
351 {
352
353 if ( m_etsT1Offset == 0 ) {
time = time_etsT1_timelike32 + getRunBeginTime( run ); }
354 else {
time = time_etsT1_timelike32 + m_etsT1Offset; }
355 }
356
357 if ( run < 0 ) return 0;
358
359 log << MSG::INFO <<
"query time " <<
time << endmsg;
360 log << MSG::INFO << "current boundary " << m_vData.getLowerBoundaryEventTime() << " : "
361 << m_vData.getUpperBoundaryEventTime() << endmsg;
362
363 if ( m_vData.getUpperBoundaryEventTime() <
time ||
364 time < m_vData.getLowerBoundaryEventTime() )
365 {
366
367 if ( m_vData.size() == 0 )
368 {
369 char time1str[100];
370 Time_t2str(
time, time1str, 100 );
371 log << MSG::INFO <<
"INFO: MdcHvDropSvc time " <<
time <<
" aka " << time1str
372 << " is not in cache yet.\n"
373 <<
"\tfetching HV info for 1h ago" <<
time - 3600 <<
" til fetch Length"
374 <<
time + m_fetchLength - 3600 << endmsg;
375 fetchBeginTime =
time - 3600;
376 }
377
378 else
379 {
380 Time_t upTimeCachedDBTime =
381 m_vData.getUpperBoundaryEventTime() + m_vData.getOffsetEvt2Db();
382 char time1str[100];
383 Time_t2str(
time, time1str, 100 );
384
385 if ( m_vData.getLowerBoundaryEventTime() <
time &&
386 time < m_vData.getUpperBoundaryEventTime() + m_fetchLength )
387 {
388
389 log << MSG::INFO <<
"INFO:MdcHvDropSvc time " <<
time <<
" aka " << time1str
390 << " is not in cache yet.\n"
391 << "\tcurrent upperBoundary is " << m_vData.getUpperBoundaryEventTime() << "\n"
392 << "\tfetching HV info for dbTime " << upTimeCachedDBTime
393 << " to fetch Length later" << upTimeCachedDBTime + m_fetchLength << endmsg;
394 fetchBeginTime = upTimeCachedDBTime;
395 }
396
397 else
398 {
399 log << MSG::INFO <<
"INFO:MdcHvDropSvc time " <<
time <<
" aka " << time1str
400 << " is not in cache or canbe fetched in a interval.\n"
401 << "\tcurrent cache boundary is " << m_vData.getLowerBoundaryEventTime() << ":"
402 << m_vData.getUpperBoundaryEventTime() << ".\n"
403 << "\tcurrent fetch interval is " << m_vData.getUpperBoundaryEventTime() << ":"
404 << m_vData.getUpperBoundaryEventTime() + m_fetchLength << endmsg;
405 log << MSG::INFO << "aborted cache and fetching new data.\n"
406 <<
"\tfetching HV info for 1h ago" <<
time - 3600 <<
" til fetch Length"
407 <<
time + m_fetchLength - 3600 << endmsg;
408 m_vData.clear();
409 fetchBeginTime =
time - 3600;
410 }
411 }
412
413 fetchBeginTime += m_vData.getOffsetEvt2Db();
414 Time_t time2 = fetchBeginTime + m_fetchLength;
415 if ( !FetchHvInfo( fetchBeginTime - 600, time2 ).isSuccess() )
416 {
417 cout << "ERROR: MdcHvDropSvc failed to fetch HV info\n";
418 return -10000;
419 }
420 }
421 if ( !m_vData.isValid(
time ) )
return -9999;
422 if ( m_ignoreLayer_21_24 )
return m_vData.getAvgDropButVeryDrop(
time );
423 else return m_vData.getAvgDrop(
time );
424}