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 3313 of file history_schema.cxx.

3314{
3315 fNumEntries = 0;
3316
3320
3321 fSum0 = new double[num_bins];
3322 fSum1 = new double[num_bins];
3323 fSum2 = new double[num_bins];
3324
3325 for (int i=0; i<num_bins; i++) {
3326 fSum0[i] = 0;
3327 fSum1[i] = 0;
3328 fSum2[i] = 0;
3329 }
3330}
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 3332 of file history_schema.cxx.

3333{
3334 delete fSum0; fSum0 = NULL;
3335 delete fSum1; fSum1 = NULL;
3336 delete fSum2; fSum2 = NULL;
3337 // poison the pointers
3338 fCount = NULL;
3339 fMean = NULL;
3340 fRms = NULL;
3341 fMin = NULL;
3342 fMax = NULL;
3349}
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 3373 of file history_schema.cxx.

3374{
3375 if (t < fFirstTime)
3376 return;
3377 if (t > fLastTime)
3378 return;
3379
3380 fNumEntries++;
3381
3382 double a = (double)(t - fFirstTime);
3383 double b = (double)(fLastTime - fFirstTime);
3384 double fbin = fNumBins*a/b;
3385
3386 int ibin = (int)fbin;
3387
3388 if (ibin < 0)
3389 ibin = 0;
3390 else if (ibin >= fNumBins)
3391 ibin = fNumBins-1;
3392
3393 if (fSum0[ibin] == 0) {
3394 if (fMin)
3395 fMin[ibin] = v;
3396 if (fMax)
3397 fMax[ibin] = v;
3398 if (fBinsFirstTime)
3399 fBinsFirstTime[ibin] = t;
3400 if (fBinsFirstValue)
3401 fBinsFirstValue[ibin] = v;
3402 if (fBinsLastTime)
3403 fBinsLastTime[ibin] = t;
3404 if (fBinsLastValue)
3405 fBinsLastValue[ibin] = v;
3406 if (fLastTimePtr)
3407 *fLastTimePtr = t;
3408 if (fLastValuePtr)
3409 *fLastValuePtr = v;
3410 }
3411
3412 fSum0[ibin] += 1.0;
3413 fSum1[ibin] += v;
3414 fSum2[ibin] += v*v;
3415
3416 if (fMin)
3417 if (v < fMin[ibin])
3418 fMin[ibin] = v;
3419
3420 if (fMax)
3421 if (v > fMax[ibin])
3422 fMax[ibin] = v;
3423
3424 // NOTE: this assumes t and v are sorted by time.
3425 if (fBinsLastTime)
3426 fBinsLastTime[ibin] = t;
3427 if (fBinsLastValue)
3428 fBinsLastValue[ibin] = v;
3429
3430 if (fLastTimePtr)
3431 if (t > *fLastTimePtr) {
3432 *fLastTimePtr = t;
3433 if (fLastValuePtr)
3434 *fLastValuePtr = v;
3435 }
3436}
Here is the call graph for this function:

◆ Finish()

void MidasHistoryBinnedBuffer::Finish ( )

Definition at line 3438 of file history_schema.cxx.

3439{
3440 for (int i=0; i<fNumBins; i++) {
3441 double num = fSum0[i];
3442 double mean = 0;
3443 double variance = 0;
3444 if (num > 0) {
3445 mean = fSum1[i]/num;
3447 }
3448 double rms = 0;
3449 if (variance > 0)
3450 rms = sqrt(variance);
3451
3452 if (fCount)
3453 fCount[i] = (int)num;
3454
3455 if (fMean)
3456 fMean[i] = mean;
3457
3458 if (fRms)
3459 fRms[i] = rms;
3460
3461 if (num == 0) {
3462 if (fMin)
3463 fMin[i] = 0;
3464 if (fMax)
3465 fMax[i] = 0;
3466 }
3467 }
3468}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Start()

void MidasHistoryBinnedBuffer::Start ( )

Definition at line 3351 of file history_schema.cxx.

3352{
3353 for (int ibin = 0; ibin < fNumBins; ibin++) {
3354 if (fMin)
3355 fMin[ibin] = 0;
3356 if (fMax)
3357 fMax[ibin] = 0;
3358 if (fBinsFirstTime)
3359 fBinsFirstTime[ibin] = 0;
3360 if (fBinsFirstValue)
3361 fBinsFirstValue[ibin] = 0;
3362 if (fBinsLastTime)
3363 fBinsLastTime[ibin] = 0;
3364 if (fBinsLastValue)
3365 fBinsLastValue[ibin] = 0;
3366 }
3367 if (fLastTimePtr)
3368 *fLastTimePtr = 0;
3369 if (fLastValuePtr)
3370 *fLastValuePtr = 0;
3371}
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: