BDSwicDevice Class Reference
[BeamDataUtil]

Base class for data from SWIC scanner devices. More...

#include <BDSwicDevice.h>

Inheritance diagram for BDSwicDevice:
RawBeamSwicData BDHadMuMon BDProfMon

List of all members.

Public Types

enum  MonitorType {
  kUnknown = 0, kProfile, kHadron, kMuon,
  kWire
}
 

General type of monitor, see GetMonitorType().

More...

Public Member Functions

 BDSwicDevice ()
 Default constructor.
 BDSwicDevice (const RawBeamData &swic_data)
 Construct a BDSwicDevice with an initial RawBeamData object.
virtual ~BDSwicDevice ()
virtual void SetData (const RawBeamData &swic_data)
 Set the RawBeamData from a swic scanner device.
bool SetPeds (const std::vector< double > &peds)
 Set the per channel pedestals to use.
virtual bool SetMask (const std::vector< double > &mask)
 Mask off any bad channels.
bool SetNoise (const std::vector< double > &noise)
 Set the per channel noise to use.
void SetScale (double scale)
 Set an overall scale.
void SetMvPerADC (double mvperadc)
 Set millivolt per ADC count correction.
void SetGainCorrection (double gain)
 Set multiplicative gain correction.
void SetCapacitance (double cap)
 Set capacitance of integrating capacitor for GetCharge().
virtual double GetVoltage (int index) const
 Get a channel's voltage with all corrections applied.
double GetCharge (int index) const
 Get a channel's corrected charge in Munits (not pC!).
double GetTotalVoltage ()
 Get the total voltage.
double GetTotalCharge ()
 Get the total charge.
MonitorType GetMonitorType ()
double GetNoise (int index) const
 Get the channel noise.

Private Member Functions

void UpdateType ()

Private Attributes

std::vector< double > fPeds
std::vector< double > fMask
std::vector< double > fNoise
double fMvPerADC
double fScale
double fGain
double fCap
std::vector< int > fData
MonitorType fType

Detailed Description

Base class for data from SWIC scanner devices.

This class is a RawBeamSwicData object which applies pedestals, channel masks, and anything else needed to make the per-channel data more regular. It provides the base class for more specific devices such as BDHadMuMon and BDProfMon.

Note:
Due to different channel numbering conventions between hardware is important to distinguish between a "channel number" and a data array "index number". Channel numbering is specific to the device. See BDHadMuMon and BDProfMon classes. Array "index numbers" ALWAYS count from 0. Data is ALWAYS accessed via an index. Never use a channel number to access that channels data, use the index. The sub classes provide an Index() method that converts their native numbering scheme into an index.
Author:
(last to touch it)
Author
bishai
Version:
Revision
1.7
Date:
Date
2005/08/22 15:40:44

Contact: bv@bnl.gov

Created on: Fri Apr 15 11:52:50 2005

Id
BDSwicDevice.h,v 1.7 2005/08/22 15:40:44 bishai Exp

Definition at line 41 of file BDSwicDevice.h.


Member Enumeration Documentation

General type of monitor, see GetMonitorType().

Enumerator:
kUnknown 
kProfile 

on of many SEM profile monitor

kHadron 

the hadron monitor

kMuon 

one of muon monitor 1, 2 or 3.

kWire 

real SWIC.

Definition at line 46 of file BDSwicDevice.h.

00046                      {
00047         kUnknown = 0,
00048         kProfile,               
00049         kHadron,                
00050         kMuon,                  
00051         kWire                   
00052     };


Constructor & Destructor Documentation

BDSwicDevice::BDSwicDevice (  ) 

Default constructor.

Constructed this way, this object will not be valid until SetData() is called.

Definition at line 14 of file BDSwicDevice.cxx.

00015     : RawBeamSwicData()
00016     , fPeds(96,0)
00017     , fMask(96,1)
00018     , fNoise(96,0.1)
00019     , fMvPerADC(-0.30518)
00020     , fScale(1.0)
00021     , fGain(1.0)
00022     , fCap(0)
00023     , fType(kUnknown)
00024 
00025 {
00026 }

BDSwicDevice::BDSwicDevice ( const RawBeamData swic_data  ) 

Construct a BDSwicDevice with an initial RawBeamData object.

The RawBeamData object should be from SWIC scanner data.

Definition at line 28 of file BDSwicDevice.cxx.

References BDSwicCalibrator::AddDevice(), fData, BDSwicCalibrator::Get(), RawBeamSwicData::UnscaledWireData(), and UpdateType().

00029     : RawBeamSwicData(swic_data)
00030     , fPeds(96,0)
00031     , fMask(96,1)
00032     , fNoise(96,0.1)
00033     , fMvPerADC(-0.30518)
00034     , fScale(1.0)
00035     , fGain(1.0)
00036     , fCap(0)
00037     , fType(kUnknown)
00038 {
00039     this->RawBeamSwicData::UnscaledWireData(fData);
00040     this->UpdateType();
00041     BDSwicCalibrator::Get().AddDevice(*this);
00042 }

BDSwicDevice::~BDSwicDevice (  )  [virtual]

Definition at line 44 of file BDSwicDevice.cxx.

References BDSwicCalibrator::Get(), and BDSwicCalibrator::RemoveDevice().

00045 {
00046     BDSwicCalibrator::Get().RemoveDevice(*this);
00047 }


Member Function Documentation

double BDSwicDevice::GetCharge ( int  index  )  const

Get a channel's corrected charge in Munits (not pC!).

Definition at line 156 of file BDSwicDevice.cxx.

References fCap, and GetVoltage().

Referenced by dump_hadmus(), and BDHadMuMon::GetStats().

00157 {
00158     return this->GetVoltage(index)*fCap;
00159 }

MonitorType BDSwicDevice::GetMonitorType (  )  [inline]

Get general type of monitor as an enum.

Definition at line 173 of file BDSwicDevice.h.

References fType.

Referenced by BDSwicCalibrator::CalibrateOne().

00173 { return fType; }

double BDSwicDevice::GetNoise ( int  index  )  const

Get the channel noise.

Units are in mV. This just returns the noise on a given channel. Noise is defined as the RMS of the pedestal distribution.

Definition at line 137 of file BDSwicDevice.cxx.

References fData, fMvPerADC, fNoise, fScale, Msg::kWarning, Munits::millivolt, and MSG.

Referenced by BDProfMon::GetGaussFit().

00138 {
00139     if (!fData.size() || index < 0 || index >= 96) {
00140         MSG("BDU",Msg::kWarning)
00141             << "BDSwicDevice::GetNoise given bad index: " << index << endl;
00142         return 0;
00143     }
00144     return fScale*fMvPerADC*fNoise[index]*Munits::millivolt;
00145 }

double BDSwicDevice::GetTotalCharge (  ) 

Get the total charge.

Units are in Munits (not pC!). This just returns the sum of the above over all unmasked channels.

Definition at line 160 of file BDSwicDevice.cxx.

References fCap, GetTotalVoltage(), Msg::kWarning, and MSG.

Referenced by dump_hadmus().

00161 {
00162     if (fCap == 0.0) {
00163         MSG("BDU",Msg::kWarning)
00164             << "BDSwicDevice::GetTotalCharge called but capacitance is zero\n";
00165         return 0;
00166     }
00167     return this->GetTotalVoltage() * fCap;
00168 }

double BDSwicDevice::GetTotalVoltage (  ) 

Get the total voltage.

Units are in Munits. This just returns the sum of the above over all unmasked channels.

Definition at line 147 of file BDSwicDevice.cxx.

References fData, fMask, fMvPerADC, fPeds, fScale, and Munits::millivolt.

Referenced by HadMuMonModule::Fill(), and GetTotalCharge().

00148 {
00149     if (!fData.size()) return 0.0;
00150     double ret=0;
00151     for (int ind=0; ind<96; ++ind)
00152         ret += (fData[ind] - fPeds[ind])*fMask[ind];
00153     ret *= fScale*fMvPerADC*Munits::millivolt;
00154     return ret;
00155 }

double BDSwicDevice::GetVoltage ( int  index  )  const [virtual]

Get a channel's voltage with all corrections applied.

Units are in Munits (not mV!) and indexing is SWIC level indexing with "index" ranging from 0-95, inclusive. A zero is returned if a bad index is passed.

Definition at line 126 of file BDSwicDevice.cxx.

References fData, fMask, fMvPerADC, fPeds, fScale, Msg::kWarning, Munits::millivolt, and MSG.

Referenced by HadMuMonModule::Fill(), GetCharge(), BDProfMon::GetGaussFit(), and BDProfMon::GetStats().

00127 {
00128     if (!fData.size() || index < 0 || index >= 96) {
00129         MSG("BDU",Msg::kWarning)
00130             << "BDSwicDevice::GetVoltage given bad index: " << index << endl;
00131         return 0;
00132     }
00133     return fScale*fMvPerADC*(fData[index] - fPeds[index])*fMask[index]*Munits::millivolt;
00134 }

void BDSwicDevice::SetCapacitance ( double  cap  ) 

Set capacitance of integrating capacitor for GetCharge().

If this goes unset all charge returned will be zero.

units are Munits

Definition at line 120 of file BDSwicDevice.cxx.

References fCap.

Referenced by BDSwicCalibrator::CalibrateOne().

00121 {
00122     fCap = cap;    
00123 }

void BDSwicDevice::SetData ( const RawBeamData swic_data  )  [virtual]

Set the RawBeamData from a swic scanner device.

If subclasses override this, they should still pass the data to the parent class.

Reimplemented from RawBeamSwicData.

Reimplemented in BDHadMuMon, and BDProfMon.

Definition at line 48 of file BDSwicDevice.cxx.

References BDSwicCalibrator::AddDevice(), fData, BDSwicCalibrator::Get(), RawBeamData::GetName(), RawBeamSwicData::IsValid(), Msg::kInfo, MSG, RawBeamSwicData::UnscaledWireData(), and UpdateType().

00049 {
00050     this->RawBeamSwicData::SetData(swic_data);
00051 
00052     if (!this->IsValid()) {
00053       MSG("BDU",Msg::kInfo) << swic_data.GetName() 
00054                             << " given invalid data\n";
00055     }
00056 
00057     fData.clear();
00058     this->RawBeamSwicData::UnscaledWireData(fData);
00059 
00060     this->UpdateType();
00061     BDSwicCalibrator::Get().AddDevice(*this);
00062 }

void BDSwicDevice::SetGainCorrection ( double  gain  ) 

Set multiplicative gain correction.

Definition at line 116 of file BDSwicDevice.cxx.

References fGain.

Referenced by BDSwicCalibrator::CalibrateOne().

00117 {
00118     fGain = gain;
00119 }

bool BDSwicDevice::SetMask ( const std::vector< double > &  mask  )  [virtual]

Mask off any bad channels.

Returns:
a boolean which will be false if vector is wrong size.

This should be an array of 96 channels worth of masks. The mask is multiplied to the channel so a 0 means don't use the channel, 1 means use it at normal strenght. A copy is made of the vector.

Sub classes can override this in order to zero out channels that are always missing but the mask should still be passed to the base class for storage and use. The subclass should only zero a channel and not otherwise modify since the mask can hold per-channel scaling information.

Reimplemented in BDProfMon.

Definition at line 93 of file BDSwicDevice.cxx.

References fMask.

Referenced by BDSwicCalibrator::CalibrateOne().

00094 {
00095     if (mask.size() != 96) return false;
00096     fMask = mask;
00097     return true;
00098 }

void BDSwicDevice::SetMvPerADC ( double  mvperadc  ) 

Set millivolt per ADC count correction.

This allows a linear correction to convert from raw ADC counts to millivolts. Default is -0.30518 mV/ADC.

Definition at line 112 of file BDSwicDevice.cxx.

References fMvPerADC.

00113 {
00114     fMvPerADC = mvperadc;
00115 }

bool BDSwicDevice::SetNoise ( const std::vector< double > &  noise  ) 

Set the per channel noise to use.

Returns:
a boolean which will be false if vector is wrong size.

This should be an array of 96 channels worth of pedestal RMS. A copy is made of the vector.

Note:
It is assumed that noise is in millivolts not Munits!!!

Definition at line 100 of file BDSwicDevice.cxx.

References fNoise.

Referenced by BDSwicCalibrator::CalibrateOne().

00101 {
00102     if (noise.size() != 96) return false;
00103     fNoise = noise;
00104     return true;
00105 }

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

Set the per channel pedestals to use.

Returns:
a boolean which will be false if vector is wrong size.

This should be an array of 96 channels worth of pedestals. A copy is made of the vector.

Note:
It is assumed the pedestals are in millivolts not Munits!!!

Definition at line 87 of file BDSwicDevice.cxx.

References fPeds.

Referenced by BDSwicCalibrator::CalibrateOne().

00088 {
00089     if (peds.size() != 96) return false;
00090     fPeds = peds;
00091     return true;
00092 }

void BDSwicDevice::SetScale ( double  scale  ) 

Set an overall scale.

This allows an overall scale to be set by the user which will be multiplied to the pedestal subtracted data. It can be useful if one wants to normalize the data to proton intensity as measured by, say, a toroid. Default is 1.0. It is external (in addition) to any calibrations.

Definition at line 108 of file BDSwicDevice.cxx.

References fScale.

00109 {
00110     fScale = scale;
00111 }

void BDSwicDevice::UpdateType (  )  [private]

Definition at line 63 of file BDSwicDevice.cxx.

References fType, RawBeamSwicData::GetData(), RawBeamData::GetName(), RawBeamSwicData::IsValid(), kHadron, kMuon, kProfile, kUnknown, Msg::kWarning, kWire, and MSG.

Referenced by BDSwicDevice(), and SetData().

00064 {
00065     if (!this->IsValid()) {
00066         MSG("BDU",Msg::kWarning)
00067             << "BDSwicDevice: Attempt to update with invalid data\n";
00068         fType = kUnknown;
00069         return;
00070     }
00071     string name = this->GetData().GetName();
00072     if (name == "E:HADMDS") {
00073         fType = kHadron;
00074         return;
00075     }
00076     if (name == "E:MMA1DS" || name == "E:MMA2DS" || name == "E:MMA3DS") {
00077         fType = kMuon;
00078         return;
00079     }
00080     if (name == "E:M117DS") {
00081         fType = kWire;
00082         return;
00083     }
00084     fType = kProfile;           // should do explicit check.  meh.
00085 }


Member Data Documentation

double BDSwicDevice::fCap [private]

Definition at line 186 of file BDSwicDevice.h.

Referenced by GetCharge(), GetTotalCharge(), and SetCapacitance().

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

Reimplemented from RawBeamSwicData.

Definition at line 187 of file BDSwicDevice.h.

Referenced by BDSwicDevice(), GetNoise(), GetTotalVoltage(), GetVoltage(), and SetData().

double BDSwicDevice::fGain [private]

Definition at line 186 of file BDSwicDevice.h.

Referenced by SetGainCorrection().

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

Definition at line 185 of file BDSwicDevice.h.

Referenced by GetTotalVoltage(), GetVoltage(), and SetMask().

double BDSwicDevice::fMvPerADC [private]

Definition at line 186 of file BDSwicDevice.h.

Referenced by GetNoise(), GetTotalVoltage(), GetVoltage(), and SetMvPerADC().

std::vector<double> BDSwicDevice::fNoise [private]

Definition at line 185 of file BDSwicDevice.h.

Referenced by GetNoise(), and SetNoise().

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

Definition at line 185 of file BDSwicDevice.h.

Referenced by GetTotalVoltage(), GetVoltage(), and SetPeds().

double BDSwicDevice::fScale [private]

Definition at line 186 of file BDSwicDevice.h.

Referenced by GetNoise(), GetTotalVoltage(), GetVoltage(), and SetScale().

Definition at line 189 of file BDSwicDevice.h.

Referenced by GetMonitorType(), and UpdateType().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1