BDSwicPeds Class Reference
[BeamDataUtil]

Calculate pedestals for swic scanner channels using raw beam data. More...

#include <BDSwicPeds.h>

Inheritance diagram for BDSwicPeds:
BDProcessor

List of all members.

Public Types

typedef std::map< std::string,
UtilRunningAverageVector * > 
SwicMap

Public Member Functions

 BDSwicPeds ()
 BDSwicPeds (const SwicMap &map)
 ~BDSwicPeds ()
void Clear ()
 Reset object to initial conditions, as if it was reconstructed.
void SetSpill (const RawBeamMonHeaderBlock &rbmhb, const RawBeamMonBlock &rbmb)
 Call once per spill if filling from data files.
const UtilRunningAverageVectorGetChannels (const char *name) const
const SwicMapGetAllChannels () const
 Access vector of Channels.
SwicMapGetAllChannels ()
VldTimeStamp GetStart ()
VldTimeStamp GetStop ()

Static Public Member Functions

static bool IsPedSpill (const RawBeamMonBlock &rbmb)

Private Attributes

SwicMap fSwicMap
VldTimeStamp fBeginTS
VldTimeStamp fEndTS

Detailed Description

Calculate pedestals for swic scanner channels using raw beam data.

This class maintains one UtilRunningAverageVector object for each SWIC scanner worth of channels.

Note:
There is no attempt to determine if a SWIC channel is bad! A pedestal will be happily calculated even if there are noisy channels.
Author:
(last to touch it)
Author
bv
Version:
Revision
1.8
Date:
Date
2005/05/12 18:48:31

Contact: bv@bnl.gov

Created on: Fri Apr 15 10:00:54 2005

Id
BDSwicPeds.h,v 1.8 2005/05/12 18:48:31 bv Exp

Definition at line 45 of file BDSwicPeds.h.


Member Typedef Documentation

typedef std::map<std::string,UtilRunningAverageVector*> BDSwicPeds::SwicMap

Definition at line 48 of file BDSwicPeds.h.


Constructor & Destructor Documentation

BDSwicPeds::BDSwicPeds (  ) 

Create default BDSwicPeds. This will use BDDevices::SwicDevices() to form a ChannelsList

Definition at line 24 of file BDSwicPeds.cxx.

References Clear().

00025 {
00026     this->Clear();
00027 }

BDSwicPeds::BDSwicPeds ( const SwicMap map  ) 

Create a BDSwicPeds with pre-existing swic map. The map will be shallow copied. This transfers ownership of the URAV's.

Definition at line 29 of file BDSwicPeds.cxx.

References Clear().

00030     : fSwicMap(map)
00031 {
00032     this->Clear();
00033 }

BDSwicPeds::~BDSwicPeds (  ) 

Definition at line 55 of file BDSwicPeds.cxx.

References done(), fSwicMap, and it.

00056 {
00057     SwicMap::iterator it, done = fSwicMap.end();
00058     for (it=fSwicMap.begin(); it != done; ++it) 
00059         delete it->second;
00060     fSwicMap.clear();
00061 }


Member Function Documentation

void BDSwicPeds::Clear (  ) 

Reset object to initial conditions, as if it was reconstructed.

Definition at line 35 of file BDSwicPeds.cxx.

References done(), fBeginTS, fEndTS, fSwicMap, VldTimeStamp::GetBOT(), VldTimeStamp::GetEOT(), it, Msg::kDebug, MSG, nswics, BDDevices::SwicDevices(), and swics.

Referenced by BDSwicPeds(), and BeamMonSwicPedsDbuModule::Dump().

00036 {
00037     fBeginTS = VldTimeStamp::GetEOT(); // yes, EOT.
00038     fEndTS   = VldTimeStamp::GetBOT(); // yes, BOT
00039 
00040     size_t nswics = fSwicMap.size();
00041     if (!nswics) {
00042         vector<string> swics = BDDevices::SwicDevices();
00043         for (size_t ind=0; ind<swics.size(); ++ind) {
00044             MSG("BD",Msg::kDebug)
00045                 << "BDSwicPeds::Clear: adding " << swics[ind] << endl;
00046             fSwicMap[swics[ind]] = new UtilRunningAverageVector(96);
00047         }
00048         return;
00049     }
00050     SwicMap::iterator it, done = fSwicMap.end();
00051     for (it=fSwicMap.begin(); it != done; ++it) 
00052         it->second->Clear();
00053 }

BDSwicPeds::SwicMap & BDSwicPeds::GetAllChannels (  ) 

Definition at line 175 of file BDSwicPeds.cxx.

References fSwicMap.

00176 {
00177     return fSwicMap;
00178 }

const BDSwicPeds::SwicMap & BDSwicPeds::GetAllChannels (  )  const

Access vector of Channels.

Definition at line 171 of file BDSwicPeds.cxx.

References fSwicMap.

Referenced by BeamMonSwicPedsDbuModule::Dump().

00172 {
00173     return fSwicMap;
00174 }

const UtilRunningAverageVector * BDSwicPeds::GetChannels ( const char *  name  )  const

Access the Channels object corresponding to the given name. Returns 0 if there is no such channel name.

Definition at line 164 of file BDSwicPeds.cxx.

References fSwicMap, and it.

00165 {
00166     SwicMap::const_iterator it = fSwicMap.find(name);
00167     if (it == fSwicMap.end()) return 0;
00168     return it->second;
00169 }

VldTimeStamp BDSwicPeds::GetStart (  )  [inline]

Return the earliest spill seen or VldtimeStamp::GetEOT() if not yet seen any spill.

Definition at line 80 of file BDSwicPeds.h.

References fBeginTS.

Referenced by BeamMonSwicPedsDbuModule::Dump().

00080 { return fBeginTS; }

VldTimeStamp BDSwicPeds::GetStop (  )  [inline]

Return the latest spill seen or VldTimeStamp::GetBOT() if not yet seen any spill.

Definition at line 83 of file BDSwicPeds.h.

References fEndTS.

Referenced by BeamMonSwicPedsDbuModule::Dump().

00083 { return fEndTS; }

bool BDSwicPeds::IsPedSpill ( const RawBeamMonBlock rbmb  )  [static]

Return true if this spill would be suitable for use as a pedestal. This is called internally by SetSpill

Definition at line 74 of file BDSwicPeds.cxx.

References BDDevices::BpmIntensities(), dae_jitter, dae_vme_padding, RawBeamData::GetMsecs(), RawBeamData::GetSeconds(), Msg::kDebug, Msg::kVerbose, Msg::kWarning, maximum_bpm_intensity, maximum_toroid_intensity, MSG, RawBeamSwicData::SetData(), BDDevices::SwicDevices(), swics, RawBeamMonBlock::TclkTriggerDelay(), toroids, total(), RawBeamSwicData::VmeNanoseconds(), and RawBeamSwicData::VmeSeconds().

Referenced by SetSpill(), and BMSpillFiller::Spill().

00075 {
00076     // First find empty spills by requiring the toroids
00077     // to be existing and quiet
00078     const char* toroids[] = { "E:TR101D", "E:TOR101", "E:TRTGTD", "E:TORTGT", 0 };
00079     for (int ind=0; toroids[ind]; ++ind) {
00080         const RawBeamData *rbd = rbmb[toroids[ind]];
00081         if (!rbd) {
00082             MSG("BD",Msg::kDebug)
00083                 << "SetSpill bailing because can't get toroid " << toroids[ind] << endl;
00084             return false;
00085         }
00086         double tot = total(*rbd);
00087         if (tot > maximum_toroid_intensity) {
00088             MSG("BD",Msg::kVerbose)
00089                 << "SetSpill bailing because toroid " << toroids[ind]
00090                 << " intensity too high: "
00091                 << tot << " > " << maximum_toroid_intensity << endl;
00092             return false;
00093         }
00094     }
00095 
00096     // It's been found that some spills will have protons even with
00097     // quiet toroids!  So, require quiet BPMs as well.
00098     vector<string> bpm_intensity = BDDevices::BpmIntensities();
00099     for (size_t ind=0; ind<bpm_intensity.size(); ++ind) {
00100         const RawBeamData *rbd = rbmb[bpm_intensity[ind].c_str()];
00101         if (!rbd) continue;     // Don't just bail in case a BPM is simply removed
00102         double tot = total(*rbd);
00103         if (tot > maximum_bpm_intensity) {
00104             MSG("BD",Msg::kDebug)
00105                 << "SetSpill bailing because bpm " << bpm_intensity[ind]
00106                 << " intensity too high: "
00107                 << tot << " > " << maximum_bpm_intensity << endl;
00108             return false;
00109         }
00110     }
00111 
00112     // Go through SWIC devices and check if the VME and DAE times are
00113     // compatible.
00114     vector<string> swics = BDDevices::SwicDevices();
00115     RawBeamSwicData swic;
00116     double delay = rbmb.TclkTriggerDelay()/1.0e3;
00117     for (size_t ind=0; ind<swics.size(); ++ind) {
00118         const RawBeamData *rbd = rbmb[swics[ind].c_str()];
00119         if (!rbd) continue;
00120         swic.SetData(*rbd);
00121         double delta = rbd->GetSeconds() - swic.VmeSeconds() - delay;
00122         delta += rbd->GetMsecs()/1.0e3 - swic.VmeNanoseconds()/1.0e9;
00123 
00124         if (delta < -dae_vme_padding || delta > dae_jitter+dae_vme_padding ) {
00125             MSG("BD",Msg::kWarning)
00126                 << "SetSpill bailing, SWIC " << swics[ind]
00127                 << " DAE-delay-VME time delta bad: "
00128                 << delta << endl;
00129             return false;
00130         }
00131 
00132     }   
00133 
00134     return true;
00135 }

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

Call once per spill if filling from data files.

Implements BDProcessor.

Definition at line 138 of file BDSwicPeds.cxx.

References done(), fBeginTS, fEndTS, fSwicMap, RawBeamMonHeaderBlock::GetTimeStamp(), IsPedSpill(), it, and RawBeamSwicData::UnscaledWireData().

00140 {
00141     VldTimeStamp vts = rbmhb.GetTimeStamp();
00142     if (vts < fBeginTS) fBeginTS = vts;
00143     if (vts > fEndTS) fEndTS = vts;
00144 
00145     if (!BDSwicPeds::IsPedSpill(rbmb)) return;
00146 
00147     // If we get here we are reasonably sure there are no protons in
00148     // the pipe.
00149     SwicMap::iterator it, done = fSwicMap.end();
00150     for (it=fSwicMap.begin(); it != done; ++it) {
00151         const RawBeamData* rbd = rbmb[it->first];
00152         if (!rbd) continue;
00153         
00154         RawBeamSwicData rbsd(*rbd);
00155         vector<int> idata;
00156         rbsd.UnscaledWireData(idata);
00157         vector<double> ddata;
00158         for (size_t ind=0; ind<idata.size(); ++ind)
00159             ddata.push_back((double)idata[ind]);
00160         it->second->Add(ddata);
00161     }
00162 }


Member Data Documentation

Definition at line 87 of file BDSwicPeds.h.

Referenced by Clear(), GetStart(), and SetSpill().

Definition at line 87 of file BDSwicPeds.h.

Referenced by Clear(), GetStop(), and SetSpill().

Definition at line 86 of file BDSwicPeds.h.

Referenced by Clear(), GetAllChannels(), GetChannels(), SetSpill(), and ~BDSwicPeds().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1