1#include "RawDataCnv/OfflineRevise.h"
2#include "RawDataCnv/SniperJSON.h"
7 const SniperJSON& c1 = json[
"Ets1MissingSecond"];
9 it != c1[
"RunRanges"].
vec_end(); ++it )
11 m_runRanges.push_back(
12 std::make_pair( ( *it )[
"From"].get<int>(), ( *it )[
"To"].get<int>() ) );
15 m_runs = c1[
"Runs"].
get<std::vector<int>>();
26 m_tRoundSwitch = json[
"TimeRoundSwitch"].
get<
int>();
35 if ( run == m_lastRun ) { goodFlag = m_lastFlag; }
38 for ( std::vector<std::pair<int, int>>::iterator it = m_runRanges.begin();
39 it != m_runRanges.end(); ++it )
41 if ( run >= it->first && run <= it->second )
48 if ( goodFlag && std::find( m_runs.begin(), m_runs.end(), run ) != m_runs.end() )
51 m_lastFlag = goodFlag;
54 m_t0Sec = header->
time();
70 long tNow = header->
time() - m_t0Sec;
71 unsigned long _ets1 = header->
etsT1();
72 long ets1NanoSec = _ets1 % 2000000;
76 long _shift0 = ets1NanoSec % 2000000;
77 if ( _shift0 > m_t0NanoShift0 ) { m_t0NanoShift0 = _shift0; }
81 if ( m_t0NanoShift1 == -1 )
83 if ( ets1NanoSec > m_t0NanoShift0 )
85 m_t0NanoShift1 = ets1NanoSec;
91 if ( m_t0NanoShift1 > 0 && ets1NanoSec >= m_t0NanoShift1 ) { --tNow; }
93 unsigned long ets1 = tNow * 2000000 + ets1NanoSec;
97 if ( labs( ets1 - m_lastEts1 ) < 1000000 &&
abs( evtDiff ) < 100 )
103 if ( ets1NanoSec > m_t0NanoShift0 - 200000 )
105 long tDiff = ets1NanoSec - m_lastEts1 % 2000000;
106 if ( tDiff > 1000000 )
108 if ( evtDiff < 100 ) { tNow = m_lastEts1 / 2000000 - 1; }
110 else if ( tDiff < -1000000 )
112 if ( evtDiff > 100 ) { tNow = m_lastEts1 / 2000000 + 1; }
114 else { tNow = m_lastEts1 / 2000000; }
115 ets1 = tNow * 2000000 + ets1NanoSec;
121 if (
abs( evtDiff ) < 100 ) { m_lastEts1 = ets1; }
125 unsigned long _ets2 = header->
etsT2();
129 if ( _ets2 == m_lastEts2Old ) { header->
setEtsT2( m_lastEts2New ); }
132 unsigned long ets1 = header->
etsT1();
133 long ets1NanoSec = ets1 % 2000000;
134 long tNow = ets1 / 2000000;
136 long ets2NanoSec = _ets2 % 2000000;
138 long tDiff = ets2NanoSec - ets1NanoSec;
139 if ( tDiff > 1000000 ) { --tNow; }
140 else if ( tDiff < -1000000 ) { ++tNow; }
142 unsigned long ets2 = tNow * 2000000 + ets2NanoSec;
145 m_lastEts2Old = _ets2;
146 m_lastEts2New = ets2;
OfflineRevise(const SniperJSON &json)
void fixHeader(Event::EventHeader *header)
std::vector< SniperJSON >::const_iterator vec_iterator
vec_iterator vec_end() const