Swic Class Reference

#include <Swic.h>

Inheritance diagram for Swic:
HadMon ProfMon

List of all members.

Public Member Functions

 Swic ()
 Create a swic with file of pedistals to subtract.
virtual ~Swic ()
bool SetPeds (const std::vector< double > &peds)
bool SetMask (const std::vector< double > &peds)
void SetScale (double scale=1.0)
bool SetAcnetDevice (const AcnetDevice &ad)
void SetMvPerADC (double mvperadc=-0.30518)
 Set mV/ADC conversion.
double GetVoltage (int index) const
int GetRawADC (int index) const
double GetIntegralVoltage () const
 Get total voltage.
int GetIntegralADC () const
 Get total raw ADC counts.
double GetVmeTimestamp () const
 Access timing info - return 0 if it hasn't been set.
int GetVmeSeconds () const
int GetVmeNanosecs () const

Static Public Attributes

static const int WIRE_DATA_START = 104
static const int WIRE_DATA_LENGTH = 96
static const int VME_TIMESTAMP_START = 205
static const double UNSCALE_FACTOR = 3276.7001

Protected Member Functions

virtual void NewData ()
virtual bool VisitAcnetDevice (const AcnetDevice &)

Private Attributes

std::vector< double > fPeds
std::vector< double > fMask
std::vector< int > fData
double fMvPerADC
double fScale
int fVmeSec
int fVmeNsec

Detailed Description

Definition at line 14 of file Swic.h.


Constructor & Destructor Documentation

Swic::Swic (  ) 

Create a swic with file of pedistals to subtract.

Definition at line 12 of file Swic.cxx.

References SetMvPerADC(), and SetScale().

00013     : fPeds(WIRE_DATA_LENGTH,0)
00014     , fMask(WIRE_DATA_LENGTH,1)
00015     , fData(WIRE_DATA_LENGTH,0)
00016     , fVmeSec(0), fVmeNsec(0)
00017 {
00018     this->SetMvPerADC();
00019     this->SetScale();
00020 }

Swic::~Swic (  )  [virtual]

Definition at line 21 of file Swic.cxx.

00021 {}


Member Function Documentation

int Swic::GetIntegralADC (  )  const

Get total raw ADC counts.

Definition at line 99 of file Swic.cxx.

References GetRawADC(), and WIRE_DATA_LENGTH.

00100 {
00101     int ret=0;
00102     for (int ind=0; ind<WIRE_DATA_LENGTH; ++ind)
00103         ret += this->GetRawADC(ind);
00104     return ret;
00105 }

double Swic::GetIntegralVoltage (  )  const

Get total voltage.

Definition at line 92 of file Swic.cxx.

References GetVoltage(), and WIRE_DATA_LENGTH.

00093 {
00094     double ret=0;
00095     for (int ind=0; ind<WIRE_DATA_LENGTH; ++ind)
00096         ret += this->GetVoltage(ind);
00097     return ret;
00098 }

int Swic::GetRawADC ( int  index  )  const

Get the raw unscaled channel dtata by the index into the 96 element data block chunk, count from zero - 95.

Definition at line 88 of file Swic.cxx.

References fData.

Referenced by GetIntegralADC().

00089 {
00090     return fData[offset];
00091 }

int Swic::GetVmeNanosecs (  )  const [inline]

Definition at line 77 of file Swic.h.

References fVmeNsec.

00077 { return fVmeNsec; }

int Swic::GetVmeSeconds (  )  const [inline]

Definition at line 76 of file Swic.h.

References fVmeSec.

Referenced by ProtonDist::Fill().

00076 { return fVmeSec; }

double Swic::GetVmeTimestamp (  )  const [inline]

Access timing info - return 0 if it hasn't been set.

Definition at line 75 of file Swic.h.

References fVmeNsec, and fVmeSec.

Referenced by DeltaT::Fill(), Pedestals::GeneratePeds(), and pedmaker().

00075 { return fVmeSec + fVmeNsec/1.0e9; }

double Swic::GetVoltage ( int  index  )  const

Get the mV by index into the 96 element data block chunk, count from zero - 95.

Definition at line 84 of file Swic.cxx.

References fData, fMask, fMvPerADC, fPeds, and fScale.

Referenced by ProtonDist::Fill(), fill_profile(), Pedestals::GeneratePeds(), GetIntegralVoltage(), ProfMon::GetStats(), HadMon::GetStats(), and pedmaker().

00085 {
00086     return fScale*(fData[offset]*fMvPerADC - fPeds[offset])*fMask[offset];
00087 }

virtual void Swic::NewData (  )  [inline, protected, virtual]

Definition at line 24 of file Swic.h.

00024 {}

bool Swic::SetAcnetDevice ( const AcnetDevice ad  ) 

Set the data by giving an AcnetDevice which is a Swic. Returns false if the AcnetDevice doesn't seem to be a Swic or, if called through a sub class, any of the protected unpackers fail.

Definition at line 29 of file Swic.cxx.

References AcnetDevice::data, fData, fVmeNsec, fVmeSec, AcnetDevice::name, AcnetDevice::ndata, unscale(), VisitAcnetDevice(), VME_TIMESTAMP_START, WIRE_DATA_LENGTH, and WIRE_DATA_START.

Referenced by book_and_fill(), DeltaT::Fill(), ProtonDist::Fill(), Pedestals::GeneratePeds(), and pedmaker().

00030 {
00031     if (ad.ndata != 216) {
00032         cerr << "Swic::SetAcnetDevice: warning wrong number of data for "
00033              << ad.name << " 216 != " << ad.ndata << endl;
00034         return false;
00035     }
00036 
00037     double tot = 0;
00038     for (int ind=0; ind < WIRE_DATA_LENGTH; ++ind) {
00039         int off = ind + WIRE_DATA_START;
00040         fData[ind] = unscale(ad.data[off]);
00041         tot += fData[ind];
00042     }
00043     if (tot == 0.0) {
00044         //cerr << "Swic::SetAcnetDevice: warning zero total data for "
00045         //   << ad.name << endl;
00046         return false;
00047     }
00048 
00049     int i1 = unscale(ad.data[VME_TIMESTAMP_START+0]);
00050     int i2 = unscale(ad.data[VME_TIMESTAMP_START+1]);
00051     fVmeSec = (i1<<16)+(i2&0xffff);
00052 
00053     int i3 = unscale(ad.data[VME_TIMESTAMP_START+2]);
00054     int i4 = unscale(ad.data[VME_TIMESTAMP_START+3]);
00055     fVmeNsec = (i3<<16)+(i4&0xffff);
00056 
00057     return this->VisitAcnetDevice(ad);
00058 }

bool Swic::SetMask ( const std::vector< double > &  peds  ) 

Set channel mask to be multiplied from wire data. Return false if not given right size vector

Definition at line 67 of file Swic.cxx.

References fMask, and WIRE_DATA_LENGTH.

Referenced by ProtonDist::Fill().

00068 {
00069     int siz = mask.size();
00070     if (siz != WIRE_DATA_LENGTH) return false;
00071     fMask = mask;
00072     return true;
00073 }

void Swic::SetMvPerADC ( double  mvperadc = -0.30518  ) 

Set mV/ADC conversion.

Definition at line 79 of file Swic.cxx.

References fMvPerADC.

Referenced by pedmaker(), and Swic().

00080 {
00081     fMvPerADC = mvperadc;
00082 }

bool Swic::SetPeds ( const std::vector< double > &  peds  ) 

Set Pedestals to be subtracted from wire data. Return false if not given right size vector

Definition at line 60 of file Swic.cxx.

References fPeds, and WIRE_DATA_LENGTH.

Referenced by book_and_fill(), and ProtonDist::Fill().

00061 {
00062     int siz = peds.size();
00063     if (siz != WIRE_DATA_LENGTH) return false;
00064     fPeds = peds;
00065     return true;
00066 }

void Swic::SetScale ( double  scale = 1.0  ) 

Set overall scale (eg to track a torroid). This is multiplied to the pedestal subtracted data

Definition at line 75 of file Swic.cxx.

References fScale.

Referenced by make_plots(), and Swic().

00076 {
00077     fScale = scale;
00078 }

virtual bool Swic::VisitAcnetDevice ( const AcnetDevice  )  [inline, protected, virtual]

Definition at line 26 of file Swic.h.

Referenced by SetAcnetDevice().

00026 { return true; }


Member Data Documentation

std::vector<int> Swic::fData [private]

Definition at line 16 of file Swic.h.

Referenced by GetRawADC(), GetVoltage(), and SetAcnetDevice().

std::vector<double> Swic::fMask [private]

Definition at line 15 of file Swic.h.

Referenced by GetVoltage(), and SetMask().

double Swic::fMvPerADC [private]

Definition at line 17 of file Swic.h.

Referenced by GetVoltage(), and SetMvPerADC().

std::vector<double> Swic::fPeds [private]

Definition at line 15 of file Swic.h.

Referenced by GetVoltage(), and SetPeds().

double Swic::fScale [private]

Definition at line 17 of file Swic.h.

Referenced by GetVoltage(), and SetScale().

int Swic::fVmeNsec [private]

Definition at line 18 of file Swic.h.

Referenced by GetVmeNanosecs(), GetVmeTimestamp(), and SetAcnetDevice().

int Swic::fVmeSec [private]

Definition at line 18 of file Swic.h.

Referenced by GetVmeSeconds(), GetVmeTimestamp(), and SetAcnetDevice().

const double Swic::UNSCALE_FACTOR = 3276.7001 [static]

Definition at line 33 of file Swic.h.

Referenced by unscale().

const int Swic::VME_TIMESTAMP_START = 205 [static]

Definition at line 32 of file Swic.h.

Referenced by SetAcnetDevice().

const int Swic::WIRE_DATA_LENGTH = 96 [static]

Definition at line 31 of file Swic.h.

Referenced by GetIntegralADC(), GetIntegralVoltage(), SetAcnetDevice(), SetMask(), and SetPeds().

const int Swic::WIRE_DATA_START = 104 [static]

Definition at line 30 of file Swic.h.

Referenced by SetAcnetDevice().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1