#include <BDSwicPedAccessor.h>
Public Member Functions | |
| BDSwicPedAccessor () | |
| ~BDSwicPedAccessor () | |
| void | AddDevice (const char *device_name, int minimum_sample_size=10) |
| bool | SetSpillTime (VldContext vc) |
| int | GetPeds (const char *device_name, std::vector< double > &mean, std::vector< double > &sigma) const |
| int | GetPeds (const char *device_name, std::vector< double > &mean) const |
Private Types | |
| typedef std::map< std::string, Device > | SwicMap |
Private Attributes | |
| SwicMap | fSwicMap |
| DbiResultPtr< BeamMonSwicPeds > * | fDRP |
Currently this constructs pedestal values using measurements from the vld range containing the time given in SetSpillTime(). If that doesn't provide enough to satisify the minium_sample_size given in the constructor it will go back in time adding additional vld ranges until the minimum is satisfied.
Created on: Wed Apr 13 18:14:17 2005
Definition at line 42 of file BDSwicPedAccessor.h.
|
|
Definition at line 75 of file BDSwicPedAccessor.h. |
|
|
Definition at line 37 of file BDSwicPedAccessor.cxx. 00038 : fDRP(new DbiResultPtr<BeamMonSwicPeds>) 00039 { 00040 }
|
|
|
Definition at line 42 of file BDSwicPedAccessor.cxx. References done(), fDRP, and fSwicMap. 00043 {
00044 SwicMap::iterator it, done = fSwicMap.end();
00045 for (it=fSwicMap.begin(); it != done; ++it) {
00046 delete it->second.channels;
00047 }
00048 fSwicMap.clear();
00049 if (fDRP) delete fDRP;
00050 fDRP = 0;
00051 }
|
|
||||||||||||
|
Add a device of the given name to the list of ones that should be maintained. The optional minimum sample specifies the minimum number of pedestals desired. Definition at line 53 of file BDSwicPedAccessor.cxx. References BDSwicPedAccessor::Device::channels, det, fSwicMap, BDSwicPedAccessor::Device::is_profile, is_profile_monitor(), and BDSwicPedAccessor::Device::range. Referenced by BDSwicCalibrator::AddDevice(). 00055 {
00056 if (fSwicMap.find(device_name) != fSwicMap.end()) return;
00057
00058 int det = Detector::kNear | Detector::kFar;
00059 int sf = SimFlag::kData;
00060
00061 Device dev;
00062 dev.channels = new UtilBlockedRunningAverageVector(96,minimum_sample_size);
00063 dev.range = VldRange(det,sf,VldTimeStamp::GetEOT(),VldTimeStamp::GetBOT(),
00064 "swicpeds");
00065 dev.is_profile = is_profile_monitor(device_name);
00066 fSwicMap[device_name] = dev;
00067 }
|
|
||||||||||||
|
Definition at line 187 of file BDSwicPedAccessor.cxx. References fSwicMap, UtilRunningAverageVector::GetPopulationSize(), and UtilRunningAverageVector::PopulationMean(). 00189 {
00190 SwicMap::const_iterator it = fSwicMap.find(device_name);
00191 if (it == fSwicMap.end()) {
00192 mean = vector<double>(96,0);
00193 return 0;
00194 }
00195 mean = it->second.channels->PopulationMean();
00196 return it->second.channels->GetPopulationSize();
00197 }
|
|
||||||||||||||||
|
Get the current pedestal statistics for given device. Return 0 and zero out vectors if the device name isn't known. Definition at line 173 of file BDSwicPedAccessor.cxx. References fSwicMap, UtilRunningAverageVector::GetPopulationSize(), UtilRunningAverageVector::PopulationMean(), and UtilRunningAverageVector::PopulationSigma(). Referenced by BDSwicCalibrator::CalibrateOne(). 00176 {
00177 SwicMap::const_iterator it = fSwicMap.find(device_name);
00178 if (it == fSwicMap.end()) {
00179 mean = vector<double>(96,0);
00180 sigma = vector<double>(96,0);
00181 return 0;
00182 }
00183 mean = it->second.channels->PopulationMean();
00184 sigma = it->second.channels->PopulationSigma();
00185 return it->second.channels->GetPopulationSize();
00186 }
|
|
|
Update pedestals. Should be called once per spill. Return true if needed to update peds. Definition at line 69 of file BDSwicPedAccessor.cxx. References UtilBlockedRunningAverageVector::Add(), BDSwicPedAccessor::Device::channels, UtilBlockedRunningAverageVector::Clear(), done(), fDRP, fSwicMap, BeamMonSwicPeds::GetDeviceName(), BeamMonSwicPeds::GetMeansAsDoubles(), BeamMonSwicPeds::GetNsamples(), DbiResultPtr< T >::GetRow(), BeamMonSwicPeds::GetSigmasAsDoubles(), VldRange::GetTimeEnd(), VldRange::GetTimeStart(), DbiResultPtr< T >::GetValidityRec(), DbiValidityRec::GetVldRange(), BDSwicPedAccessor::Device::is_profile, UtilRunningAverageVector::IsSampleFull(), mask_high_peds(), MSG, DbiResultPtr< T >::NewQuery(), DbiResultPtr< T >::NextQuery(), BDSwicPedAccessor::Device::range, VldRange::SetTimeEnd(), and VldRange::SetTimeStart(). Referenced by BDSwicCalibrator::Calibrate(). 00070 {
00071 //cerr << "SetSpillTime with vc=" << vc << endl;
00072
00073
00074 // First find out if we need to bother
00075 bool finished = true;
00076 SwicMap::iterator it, done = fSwicMap.end();
00077 for (it=fSwicMap.begin(); it != done; ++it) {
00078 //cerr << it->first << ": vr=" << it->second.range << endl;
00079
00080 if (! it->second.range.IsCompatible(vc)) {
00081 //cerr << "Incompatible, vc=" << vc << endl
00082 //<< "vr=" << it->second.range << endl;
00083 finished = false;
00084 break;
00085 }
00086 }
00087 if (finished) return false;
00088
00089 // Got to hit the DB. Maybe there is a smarter way to do this but
00090 // for now just clear everything and start fresh.
00091 for (it=fSwicMap.begin(); it != done; ++it) {
00092 if (!it->second.channels) {
00093 MSG("BD",Msg::kWarning) << "No device channels for " << it->first << endl;
00094 continue;
00095 }
00096 it->second.channels->Clear();
00097 it->second.range.SetTimeStart(VldTimeStamp::GetEOT());
00098 it->second.range.SetTimeEnd(VldTimeStamp::GetBOT());
00099 }
00100
00101 int nrows = fDRP->NewQuery(vc,0,true);
00102 int n_empty_queries = 0;
00103 for (finished = false; !finished; nrows = fDRP->NextQuery(false)) {
00104
00105 if (nrows)
00106 n_empty_queries = 0;
00107 else
00108 ++n_empty_queries;
00109
00110 if (n_empty_queries > 2) {
00111 MSG("BD",Msg::kWarning) << "Too many empty queries, giving up\n";
00112 return false;
00113 }
00114
00115 const DbiValidityRec* vr = fDRP->GetValidityRec();
00116 //cerr << "Next query " << n_empty_queries << " with "
00117 //<< nrows << " rows, seqno="
00118 //<< vr->GetSeqNo() << endl
00119 //<< vr->GetVldRange() << endl;
00120
00121 if (!nrows) { // hit a gap.
00122 SwicMap::iterator it, done = fSwicMap.end();
00123 for (it=fSwicMap.begin(); it != done; ++it) {
00124 Device& dev = it->second;
00125 if (dev.range.GetTimeEnd() < vr->GetVldRange().GetTimeEnd())
00126 dev.range.SetTimeEnd(vr->GetVldRange().GetTimeEnd());
00127 if (dev.range.GetTimeStart() > vr->GetVldRange().GetTimeStart())
00128 dev.range.SetTimeStart(vr->GetVldRange().GetTimeStart());
00129 }
00130 continue;
00131 }
00132
00133 finished = true;
00134
00135 for (int row = 0; row<nrows; ++row) {
00136 const BeamMonSwicPeds* peds = fDRP->GetRow(row);
00137 string name = peds->GetDeviceName();
00138 SwicMap::iterator it = fSwicMap.find(name);
00139 if (it == fSwicMap.end()) {
00140 MSG("BD",Msg::kDebug) << "No Device for " << name << ", continuing\n";
00141 continue;
00142 }
00143 Device& dev = it->second;
00144
00145 if (!dev.channels) {
00146 MSG("BD",Msg::kWarning) << "No Device for " << name << endl;
00147 continue;
00148 }
00149
00150 // don't need any more samples
00151 if (dev.channels->IsSampleFull()) {
00152 MSG("BD",Msg::kDebug) << "Sample not yet full for " << name << ", continuing\n";
00153 continue;
00154 }
00155
00156 // enlarge vld range to include this
00157 if (dev.range.GetTimeEnd() < vr->GetVldRange().GetTimeEnd())
00158 dev.range.SetTimeEnd(vr->GetVldRange().GetTimeEnd());
00159 if (dev.range.GetTimeStart() > vr->GetVldRange().GetTimeStart())
00160 dev.range.SetTimeStart(vr->GetVldRange().GetTimeStart());
00161
00162 vector<double> means = peds->GetMeansAsDoubles();
00163 if (dev.is_profile) mask_high_peds(means);
00164 vector<double> sigmas = peds->GetSigmasAsDoubles();
00165 dev.channels->Add(means,sigmas,peds->GetNsamples());
00166
00167 if (!dev.channels->IsSampleFull()) finished = false;
00168 }
00169 }
00170
00171 return true;
00172 }
|
|
|
Definition at line 78 of file BDSwicPedAccessor.h. Referenced by SetSpillTime(), and ~BDSwicPedAccessor(). |
|
|
Definition at line 76 of file BDSwicPedAccessor.h. Referenced by AddDevice(), GetPeds(), SetSpillTime(), and ~BDSwicPedAccessor(). |
1.3.9.1