38 int32_t EvioVersion = 0;
39 int status = evIoctl(
handle, (
char*)
"v", &EvioVersion);
40 fIsGood = (status == S_SUCCESS);
41 if( status != S_SUCCESS ) {
48 return (EvioVersion < 4) ? 2 : 3;
58 if (status == S_SUCCESS)
return;
61 cout << endl <<
"Normal end of file " <<
filename <<
" encountered"
65 cerr <<
Form(
"THaCodaFile: ERROR while trying to %s %s: ",
67 switch(
static_cast<UInt_t>(status) ) {
69 cerr <<
"Truncated event on file read. Evbuffer size is too small. "
72 case S_EVFILE_BADBLOCK :
73 cerr <<
"Bad block number encountered " << endl;
75 case S_EVFILE_BADHANDLE :
76 cerr <<
"Bad handle (file/stream not open) " << endl;
78 case S_EVFILE_ALLOCFAIL :
79 cerr <<
"Failed to allocate event I/O" << endl;
81 case S_EVFILE_BADFILE :
82 cerr <<
"File format error" << endl;
84 case S_EVFILE_UNKOPTION :
85 case S_EVFILE_BADARG :
86 case S_EVFILE_BADMODE :
87 cerr <<
"Unknown function argument or option" << endl;
89 case S_EVFILE_UNXPTDEOF :
90 cerr <<
"Unexpected end of file while reading event" << endl;
92 case S_EVFILE_BADSIZEREQ :
93 cerr <<
"Invalid buffer size request to evIoct" << endl;
95#if defined(S_EVFILE_BADHEADER)
96 case S_EVFILE_BADHEADER :
97 cerr <<
"Invalid bank/segment header data" << endl;
101 cerr <<
"Unknown error " << hex << status << dec << endl;
111 switch(
static_cast<UInt_t>(evio_retcode) ) {
116 case static_cast<UInt_t>(EOF):
119 case S_EVFILE_UNXPTDEOF:
121#if defined(S_EVFILE_BADHEADER)
122 case S_EVFILE_BADHEADER:
126 case S_EVFILE_BADBLOCK:
127 case S_EVFILE_BADHANDLE:
128 case S_EVFILE_ALLOCFAIL:
129 case S_EVFILE_BADFILE:
130 case S_EVFILE_BADSIZEREQ:
134 case S_EVFILE_UNKOPTION:
135 case S_EVFILE_BADARG:
136 case S_EVFILE_BADMODE:
154 fUpdateInterval(1000),
168 fSaved.push_back(evtsize);
171 auto it = min_element(ALL(
fSaved));
172 assert(it !=
fSaved.end());
173 if( evtsize > *it ) {
176 fSaved.push_back(evtsize);
188template<
typename T,
typename Alloc>
194 auto n =
vec.size() / 2;
195 nth_element(
vec.begin(),
vec.begin()+
n,
vec.end() );
197 if( !(
vec.size() & 1) ) {
199 auto med2 = *max_element(
vec.begin(),
vec.begin()+
n );
201 med = (med2 + med) / 2;
221 return std::abs((Long64_t)elem - (Long64_t)median);
228 UInt_t max_regular_event_size = median;
230 constexpr UInt_t lambda = 3;
233 for(
auto rt =
fSaved.rbegin(); rt !=
fSaved.rbegin()+
n; ++rt ) {
235 if( elem <= median + lambda * MAD ) {
236 max_regular_event_size = elem;
246 if(
fBuffer.capacity() > 2 * newsize )
269 if( maybe_newsize >
size() ) {
270 newsize = maybe_newsize;
274 newsize = 4 *
size();
278 newsize = 2 *
size();
280 }
else if( newsize <=
size() ) {
char * Form(const char *fmt,...)
EvtBuffer(UInt_t initial_size=0)
Bool_t grow(UInt_t newsize=0)
void staterr(const char *tried_to, Int_t status) const
virtual Int_t codaClose()=0
static Int_t ReturnCode(Int_t evio_retcode)
virtual Int_t getCodaVersion()
const char * Data() const
static constexpr UInt_t kMaxBufSize
static T Median(vector< T, Alloc > &vec)
static constexpr UInt_t kInitBufSize
std::vector< UInt_t, default_init_allocator< UInt_t > > VectorUIntNI
double min(double x, double y)
double max(double x, double y)