BDEarliest Class Reference
[BeamDataUtil]

Extract earliest time of spill. More...

#include <BDEarliest.h>

Inheritance diagram for BDEarliest:

BDProcessor List of all members.

Public Member Functions

 BDEarliest ()
void SetSpill (const RawBeamMonHeaderBlock &rbmhb, const RawBeamMonBlock &rbmb)
 Set the current spill blocks.
void SetAllowedVmeDeviation (float before=-0.1 *Munits::second, float after=+0.4 *Munits::second)
void GetTimestamps (double &dae, double &vme)
void GetLastTimestamps (double &dae, double &vme)

Static Public Member Functions

static void CalculateEarliest (const RawBeamMonBlock &rbmb, double &dae, double &vme, float before=-0.1 *Munits::second, float after=+0.4 *Munits::second)

Private Attributes

double fDae
double fVme
double fLastDae
double fLastVme
float fBefore
float fAfter

Detailed Description

Extract earliest time of spill.

This is done by:

1) Find the earliest SWIC VME time that is w/in the set deviation of the DAE time less the ACNET readout delay (encoded in the data).

2) If no such VME time can be found, use the earliest SWIC DAE time.

3) If there are no SWICS use earliest torroid

4) If there are no torroids in the spill use the earliest DAE time from a BPM.

5) If no BPMs, use zero. You wouldn't want this spill anyways.

Author:
(last to touch it)
Author
bv
Version:
Revision
1.4
Date:
Date
2005/07/11 18:31:55
Contact: bv@bnl.gov

Created on: Fri Apr 15 09:56:12 2005

Id
BDEarliest.h,v 1.4 2005/07/11 18:31:55 bv Exp

Definition at line 43 of file BDEarliest.h.


Constructor & Destructor Documentation

BDEarliest::BDEarliest (  ) 

Definition at line 18 of file BDEarliest.cxx.

References SetAllowedVmeDeviation().

00019     : fDae(0), fVme(0), fLastDae(0), fLastVme(0), fBefore(0), fAfter(0)
00020 {
00021     this->SetAllowedVmeDeviation();
00022 }


Member Function Documentation

void BDEarliest::CalculateEarliest ( const RawBeamMonBlock rbmb,
double &  dae,
double &  vme,
float  before = -0.1 *Munits::second,
float  after = +0.4 *Munits::second 
) [static]

Definition at line 37 of file BDEarliest.cxx.

References BDDevices::BpmPositions(), find_earliest(), Form(), Msg::kDebug, Msg::kVerbose, MSG, RawBeamSwicData::SetData(), BDDevices::SwicDevices(), RawBeamMonBlock::TclkTriggerDelay(), BDDevices::Toroids(), RawBeamSwicData::VmeNanoseconds(), and RawBeamSwicData::VmeSeconds().

Referenced by get_timestamp(), and SetSpill().

00040 {
00041     
00042     double earliest_vme=-1, earliest_dae=-1;
00043 
00044     RawBeamSwicData swic;
00045 
00046     vector<string> swic_names = BDDevices::SwicDevices();
00047 
00048     const float delay = rbmb.TclkTriggerDelay()/1000.0;
00049     MSG("BD",Msg::kVerbose)
00050         << "TCLK trigger delay is " << delay << endl;
00051     
00052 
00053     for (size_t ind=0; ind<swic_names.size(); ++ind) {
00054         const RawBeamData* rbd = rbmb[swic_names[ind]];
00055         if (!rbd) continue;
00056 
00057         double dae = rbd->GetSeconds() + rbd->GetMsecs()/1.0e3 - delay;
00058 
00059         if (earliest_dae < 0 || dae < earliest_dae)
00060             earliest_dae = dae;
00061 
00062         if (!swic.SetData(*rbd)) continue; // skip bogus data
00063 
00064         double vme = swic.VmeSeconds() + swic.VmeNanoseconds()/1.0e9;
00065 
00066         if (vme < 1.0) continue; // skip bogus timestamps
00067 
00068         double diff = dae-vme;
00069 
00070         if (diff < before || diff > after) {
00071             MSG("BD",Msg::kDebug)
00072                 << swic_names[ind] << " has too large dae-vme=" << diff << endl;
00073             continue; // skip bogus timestamps
00074         }
00075 
00076         // Get here, then vme timestamp is non-bogus 
00077 
00078         if (earliest_vme < 0 || vme < earliest_vme) earliest_vme = vme;
00079     }
00080 
00081     if (earliest_vme < 0) earliest_vme = 0.0;
00082     if (earliest_dae < 0) {
00083         double tmp = find_earliest(rbmb,BDDevices::Toroids());
00084         if (tmp>1 && tmp<earliest_dae) earliest_dae = tmp;
00085     }
00086     if (earliest_dae < 0) {
00087         double tmp = find_earliest(rbmb,BDDevices::BpmPositions());
00088         if (tmp>1 && tmp<earliest_dae) earliest_dae = tmp;
00089     }
00090     if (earliest_dae < 0)
00091         earliest_dae = 0;
00092     
00093     dae_out = earliest_dae;
00094     vme_out = earliest_vme;
00095 
00096     MSG("BD",Msg::kVerbose)
00097         << Form("dae = %16.3f, vme = %16.3f, diff = %.3f",
00098                 earliest_dae, earliest_vme, earliest_dae - earliest_vme)
00099         << endl;
00100 }

void BDEarliest::GetLastTimestamps ( double &  dae,
double &  vme 
) [inline]

Definition at line 61 of file BDEarliest.h.

References fLastDae, and fLastVme.

Referenced by BDataQualityModule::FillFile().

00062     { dae = fLastDae; vme = fLastVme; }

void BDEarliest::GetTimestamps ( double &  dae,
double &  vme 
) [inline]

Get the timestamps. Note, that dae is corrected to have the ACNET readout delay removed

Definition at line 59 of file BDEarliest.h.

References fDae, and fVme.

Referenced by dump(), fill_bdtest(), BDataQualityModule::FillFile(), BDUniquify::GetUniqueBlocks(), and BMSpillFiller::Spill().

00060     { dae = fDae; vme = fVme; }

void BDEarliest::SetAllowedVmeDeviation ( float  before = -0.1*Munits::second,
float  after = +0.4*Munits::second 
) [inline]

Set the amount that the VME time is allowed to deviate from the DAE time after readout delay is removed. The readout delay is taken from the value in the RawBeamMonBlock.

Definition at line 53 of file BDEarliest.h.

References fAfter, and fBefore.

Referenced by BDEarliest().

00055     { fBefore = before; fAfter = after; }

void BDEarliest::SetSpill ( const RawBeamMonHeaderBlock rbmhb,
const RawBeamMonBlock rbmb 
) [virtual]

Set the current spill blocks.

Implements BDProcessor.

Definition at line 102 of file BDEarliest.cxx.

References CalculateEarliest(), fAfter, fBefore, fDae, fLastDae, fLastVme, and fVme.

Referenced by dump(), fill_bdtest(), BDataQualityModule::FillFile(), and BDUniquify::GetUniqueBlocks().

00104 {
00105     fLastDae = fDae;
00106     fLastVme = fVme;
00107     
00108     fDae = fVme = 0.0;
00109 
00110     BDEarliest::CalculateEarliest(rbmb,fDae,fVme,fBefore,fAfter);
00111 }


Member Data Documentation

float BDEarliest::fAfter [private]

Definition at line 70 of file BDEarliest.h.

Referenced by SetAllowedVmeDeviation(), and SetSpill().

float BDEarliest::fBefore [private]

Definition at line 70 of file BDEarliest.h.

Referenced by SetAllowedVmeDeviation(), and SetSpill().

double BDEarliest::fDae [private]

Definition at line 69 of file BDEarliest.h.

Referenced by GetTimestamps(), and SetSpill().

double BDEarliest::fLastDae [private]

Definition at line 69 of file BDEarliest.h.

Referenced by GetLastTimestamps(), and SetSpill().

double BDEarliest::fLastVme [private]

Definition at line 69 of file BDEarliest.h.

Referenced by GetLastTimestamps(), and SetSpill().

double BDEarliest::fVme [private]

Definition at line 69 of file BDEarliest.h.

Referenced by GetTimestamps(), and SetSpill().


The documentation for this class was generated from the following files:
Generated on Thu Apr 10 23:02:13 2014 for loon by  doxygen 1.4.7