Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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

enum BDSwicDevice::MonitorType
 

General type of monitor, see GetMonitorType().

Enumeration values:
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.

Referenced by GetMonitorType().

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 155 of file BDSwicDevice.cxx.

References GetVoltage().

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

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

MonitorType BDSwicDevice::GetMonitorType  )  [inline]
 

Get general type of monitor as an enum.

Definition at line 173 of file BDSwicDevice.h.

References MonitorType.

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 136 of file BDSwicDevice.cxx.

References fData, fMvPerADC, fNoise, fScale, and MSG.

Referenced by BDProfMon::GetGaussFit().

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

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 159 of file BDSwicDevice.cxx.

References fCap, GetTotalVoltage(), and MSG.

Referenced by dump_hadmus().

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

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 146 of file BDSwicDevice.cxx.

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

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

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

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 125 of file BDSwicDevice.cxx.

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

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

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

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 119 of file BDSwicDevice.cxx.

References fCap.

Referenced by BDSwicCalibrator::CalibrateOne().

00120 {
00121     fCap = cap;    
00122 }

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, RawBeamSwicData::SetData(), RawBeamSwicData::UnscaledWireData(), and UpdateType().

Referenced by BDProfMon::SetData(), and BDHadMuMon::SetData().

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

void BDSwicDevice::SetGainCorrection double  gain  ) 
 

Set multiplicative gain correction.

Definition at line 115 of file BDSwicDevice.cxx.

References fGain.

Referenced by BDSwicCalibrator::CalibrateOne().

00116 {
00117     fGain = gain;
00118 }

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 92 of file BDSwicDevice.cxx.

References fMask.

Referenced by BDSwicCalibrator::CalibrateOne(), and BDProfMon::SetMask().

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

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 111 of file BDSwicDevice.cxx.

References fMvPerADC.

00112 {
00113     fMvPerADC = mvperadc;
00114 }

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 99 of file BDSwicDevice.cxx.

References fNoise.

Referenced by BDSwicCalibrator::CalibrateOne().

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

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 86 of file BDSwicDevice.cxx.

References fPeds.

Referenced by BDSwicCalibrator::CalibrateOne().

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

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 107 of file BDSwicDevice.cxx.

References fScale.

00108 {
00109     fScale = scale;
00110 }

void BDSwicDevice::UpdateType  )  [private]
 

Definition at line 62 of file BDSwicDevice.cxx.

References fType, RawBeamSwicData::GetData(), RawBeamData::GetName(), RawBeamSwicData::IsValid(), and MSG.

Referenced by BDSwicDevice(), and SetData().

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


Member Data Documentation

double BDSwicDevice::fCap [private]
 

Definition at line 186 of file BDSwicDevice.h.

Referenced by 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().

MonitorType BDSwicDevice::fType [private]
 

Definition at line 189 of file BDSwicDevice.h.

Referenced by UpdateType().


The documentation for this class was generated from the following files:
Generated on Sat Nov 21 22:49:36 2009 for loon by  doxygen 1.3.9.1