MIDAS
Loading...
Searching...
No Matches
MidasHistoryBinnedBuffer Class Reference

#include <history.h>

Inheritance diagram for MidasHistoryBinnedBuffer:
Collaboration diagram for MidasHistoryBinnedBuffer:

Public Member Functions

 MidasHistoryBinnedBuffer (time_t first_time, time_t last_time, int num_bins)
 
 ~MidasHistoryBinnedBuffer ()
 
void Start ()
 
void Add (time_t t, double v)
 
void Finish ()
 
- Public Member Functions inherited from MidasHistoryBufferInterface
 MidasHistoryBufferInterface ()
 
virtual ~MidasHistoryBufferInterface ()
 

Public Attributes

int fNumBins = 0
 
time_t fFirstTime = 0
 
time_t fLastTime = 0
 
int fNumEntries = 0
 
doublefSum0 = NULL
 
doublefSum1 = NULL
 
doublefSum2 = NULL
 
intfCount = NULL
 
doublefMean = NULL
 
doublefRms = NULL
 
doublefMin = NULL
 
doublefMax = NULL
 
time_tfBinsFirstTime = NULL
 
doublefBinsFirstValue = NULL
 
time_tfBinsLastTime = NULL
 
doublefBinsLastValue = NULL
 
time_tfLastTimePtr = NULL
 
doublefLastValuePtr = NULL
 

Detailed Description

Definition at line 69 of file history.h.

Constructor & Destructor Documentation

◆ MidasHistoryBinnedBuffer()

MidasHistoryBinnedBuffer::MidasHistoryBinnedBuffer ( time_t  first_time,
time_t  last_time,
int  num_bins 
)

Definition at line 3238 of file history_schema.cxx.

3239{
3240 fNumEntries = 0;
3241
3245
3246 fSum0 = new double[num_bins];
3247 fSum1 = new double[num_bins];
3248 fSum2 = new double[num_bins];
3249
3250 for (int i=0; i<num_bins; i++) {
3251 fSum0[i] = 0;
3252 fSum1[i] = 0;
3253 fSum2[i] = 0;
3254 }
3255}
DWORD last_time
Definition mana.cxx:3070
INT i
Definition mdump.cxx:32
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:

◆ ~MidasHistoryBinnedBuffer()

MidasHistoryBinnedBuffer::~MidasHistoryBinnedBuffer ( )

Definition at line 3257 of file history_schema.cxx.

3258{
3259 delete fSum0; fSum0 = NULL;
3260 delete fSum1; fSum1 = NULL;
3261 delete fSum2; fSum2 = NULL;
3262 // poison the pointers
3263 fCount = NULL;
3264 fMean = NULL;
3265 fRms = NULL;
3266 fMin = NULL;
3267 fMax = NULL;
3274}
Here is the call graph for this function:

Member Function Documentation

◆ Add()

void MidasHistoryBinnedBuffer::Add ( time_t  t,
double  v 
)
virtual

Implements MidasHistoryBufferInterface.

Definition at line 3298 of file history_schema.cxx.

3299{
3300 if (t < fFirstTime)
3301 return;
3302 if (t > fLastTime)
3303 return;
3304
3305 fNumEntries++;
3306
3307 double a = (double)(t - fFirstTime);
3308 double b = (double)(fLastTime - fFirstTime);
3309 double fbin = fNumBins*a/b;
3310
3311 int ibin = (int)fbin;
3312
3313 if (ibin < 0)
3314 ibin = 0;
3315 else if (ibin >= fNumBins)
3316 ibin = fNumBins-1;
3317
3318 if (fSum0[ibin] == 0) {
3319 if (fMin)
3320 fMin[ibin] = v;
3321 if (fMax)
3322 fMax[ibin] = v;
3323 if (fBinsFirstTime)
3324 fBinsFirstTime[ibin] = t;
3325 if (fBinsFirstValue)
3326 fBinsFirstValue[ibin] = v;
3327 if (fBinsLastTime)
3328 fBinsLastTime[ibin] = t;
3329 if (fBinsLastValue)
3330 fBinsLastValue[ibin] = v;
3331 if (fLastTimePtr)
3332 *fLastTimePtr = t;
3333 if (fLastValuePtr)
3334 *fLastValuePtr = v;
3335 }
3336
3337 fSum0[ibin] += 1.0;
3338 fSum1[ibin] += v;
3339 fSum2[ibin] += v*v;
3340
3341 if (fMin)
3342 if (v < fMin[ibin])
3343 fMin[ibin] = v;
3344
3345 if (fMax)
3346 if (v > fMax[ibin])
3347 fMax[ibin] = v;
3348
3349 // NOTE: this assumes t and v are sorted by time.
3350 if (fBinsLastTime)
3351 fBinsLastTime[ibin] = t;
3352 if (fBinsLastValue)
3353 fBinsLastValue[ibin] = v;
3354
3355 if (fLastTimePtr)
3356 if (t > *fLastTimePtr) {
3357 *fLastTimePtr = t;
3358 if (fLastValuePtr)
3359 *fLastValuePtr = v;
3360 }
3361}
Here is the call graph for this function:

◆ Finish()

void MidasHistoryBinnedBuffer::Finish ( )

Definition at line 3363 of file history_schema.cxx.

3364{
3365 for (int i=0; i<fNumBins; i++) {
3366 double num = fSum0[i];
3367 double mean = 0;
3368 double variance = 0;
3369 if (num > 0) {
3370 mean = fSum1[i]/num;
3372 }
3373 double rms = 0;
3374 if (variance > 0)
3375 rms = sqrt(variance);
3376
3377 if (fCount)
3378 fCount[i] = (int)num;
3379
3380 if (fMean)
3381 fMean[i] = mean;
3382
3383 if (fRms)
3384 fRms[i] = rms;
3385
3386 if (num == 0) {
3387 if (fMin)
3388 fMin[i] = 0;
3389 if (fMax)
3390 fMax[i] = 0;
3391 }
3392 }
3393}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Start()

void MidasHistoryBinnedBuffer::Start ( )

Definition at line 3276 of file history_schema.cxx.

3277{
3278 for (int ibin = 0; ibin < fNumBins; ibin++) {
3279 if (fMin)
3280 fMin[ibin] = 0;
3281 if (fMax)
3282 fMax[ibin] = 0;
3283 if (fBinsFirstTime)
3284 fBinsFirstTime[ibin] = 0;
3285 if (fBinsFirstValue)
3286 fBinsFirstValue[ibin] = 0;
3287 if (fBinsLastTime)
3288 fBinsLastTime[ibin] = 0;
3289 if (fBinsLastValue)
3290 fBinsLastValue[ibin] = 0;
3291 }
3292 if (fLastTimePtr)
3293 *fLastTimePtr = 0;
3294 if (fLastValuePtr)
3295 *fLastValuePtr = 0;
3296}
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fBinsFirstTime

time_t* MidasHistoryBinnedBuffer::fBinsFirstTime = NULL

Definition at line 88 of file history.h.

◆ fBinsFirstValue

double* MidasHistoryBinnedBuffer::fBinsFirstValue = NULL

Definition at line 89 of file history.h.

◆ fBinsLastTime

time_t* MidasHistoryBinnedBuffer::fBinsLastTime = NULL

Definition at line 90 of file history.h.

◆ fBinsLastValue

double* MidasHistoryBinnedBuffer::fBinsLastValue = NULL

Definition at line 91 of file history.h.

◆ fCount

int* MidasHistoryBinnedBuffer::fCount = NULL

Definition at line 82 of file history.h.

◆ fFirstTime

time_t MidasHistoryBinnedBuffer::fFirstTime = 0

Definition at line 73 of file history.h.

◆ fLastTime

time_t MidasHistoryBinnedBuffer::fLastTime = 0

Definition at line 74 of file history.h.

◆ fLastTimePtr

time_t* MidasHistoryBinnedBuffer::fLastTimePtr = NULL

Definition at line 93 of file history.h.

◆ fLastValuePtr

double* MidasHistoryBinnedBuffer::fLastValuePtr = NULL

Definition at line 94 of file history.h.

◆ fMax

double* MidasHistoryBinnedBuffer::fMax = NULL

Definition at line 86 of file history.h.

◆ fMean

double* MidasHistoryBinnedBuffer::fMean = NULL

Definition at line 83 of file history.h.

◆ fMin

double* MidasHistoryBinnedBuffer::fMin = NULL

Definition at line 85 of file history.h.

◆ fNumBins

int MidasHistoryBinnedBuffer::fNumBins = 0

Definition at line 72 of file history.h.

◆ fNumEntries

int MidasHistoryBinnedBuffer::fNumEntries = 0

Definition at line 76 of file history.h.

◆ fRms

double* MidasHistoryBinnedBuffer::fRms = NULL

Definition at line 84 of file history.h.

◆ fSum0

double* MidasHistoryBinnedBuffer::fSum0 = NULL

Definition at line 77 of file history.h.

◆ fSum1

double* MidasHistoryBinnedBuffer::fSum1 = NULL

Definition at line 78 of file history.h.

◆ fSum2

double* MidasHistoryBinnedBuffer::fSum2 = NULL

Definition at line 79 of file history.h.


The documentation for this class was generated from the following files: