#include <BDataQualityModule.h>
Inheritance diagram for BDataQualityModule:

Public Member Functions | |
| BDataQualityModule () | |
| virtual | ~BDataQualityModule () |
| void | BeginFile () |
| JobCResult | Ana (const MomNavigator *mom) |
| void | EndFile () |
Private Member Functions | |
| void | FillFile (const RawBeamMonHeaderBlock &head, const RawBeamMonBlock &block) |
Private Attributes | |
| double | fFirstSpillTime |
| double | fLastSpillTime |
Histogram quantities on a per-file basis that help show any problems with the beam data process.
This is slightly different from other BeamMonBaseModules in that it assumes that the SpillTimeND DB table is filled for the data being read in the MOM. In the Fill() method it will do BDP->STND comparisons and in the EndFile() method it will do STND->BDP comparisons.
One can add "HistMan::Put " after this module in the Job Path in order to write out the histograms. One should set "FileExtension" option of that module to get per-file histograms. O.w. one gets per-job histograms.
Created on: Mon Nov 28 14:53:03 2005
Definition at line 50 of file BDataQualityModule.h.
|
|
Definition at line 31 of file BDataQualityModule.cxx. 00032 : fFirstSpillTime(0) 00033 , fLastSpillTime(0) 00034 { 00035 }
|
|
|
Definition at line 36 of file BDataQualityModule.cxx. 00037 {
00038 }
|
|
|
Implement this for read only access to the MomNavigator Reimplemented from JobCModule. Definition at line 59 of file BDataQualityModule.cxx. References count, DataUtil::dump_mom(), fFirstSpillTime, file_hist_dir, HistMan::Fill1d(), FillFile(), fLastSpillTime, and BDUniquify::GetUniqueBlocks(). 00060 {
00061 static BDUniquify uniquify;
00062 static int count=-1, mult=1;
00063 ++count;
00064
00065 if (count>mult*10) {
00066 mult *= 10;
00067 }
00068
00069 if (count%mult == 0)
00070 cerr << count << endl;
00071
00072
00073 if (!mom) return JobCResult::kFailed;
00074
00075 HistMan hm(file_hist_dir);
00076
00077 int ntotalblocks = DataUtil::GetRawBlocks<RawBeamMonBlock>(mom).size();
00078 hm.Fill1d("total_blocks",ntotalblocks);
00079
00080 vector<BDUniquify::BlockPair> unique = uniquify.GetUniqueBlocks(*mom);
00081 size_t nblocks = unique.size();
00082
00083 if (nblocks && fFirstSpillTime == 0.0)
00084 fFirstSpillTime = unique[0].first->GetTimeStamp();
00085 if (nblocks)
00086 fLastSpillTime = unique[0].first->GetTimeStamp();
00087
00088 if (nblocks != 1) {
00089 cerr << "Other than a single block in record " << count << ", " << nblocks << endl;
00090 DataUtil::dump_mom(mom,cerr);
00091 }
00092
00093 hm.Fill1d("unique_blocks",nblocks);
00094
00095 for (size_t ind=0; ind<nblocks; ++ind) {
00096 this->FillFile(*unique[ind].first,*unique[ind].second);
00097 }
00098
00099 return JobCResult::kAOK;
00100 }
|
|
|
Implement for notification of begin of file. See GetCurrentFile(). Reimplemented from JobCModule. Definition at line 104 of file BDataQualityModule.cxx. References HistMan::Book(), file_hist_dir, HistMan::Get(), important_devs, and tor_names. 00105 {
00106 HistMan hm(file_hist_dir);
00107
00108 // Per MOM
00109 const char* hname = "unique_blocks";
00110 TH1I* hi = hm.Get<TH1I>(hname);
00111 if (hi) hi->Clear();
00112 else hm.Book<TH1I>(hname,"Unique BeamMonBlocks in RawRecord (should always be 1)",5,0,5);
00113 hname = "total_blocks";
00114 hi = hm.Get<TH1I>(hname);
00115 if (hi) hi->Clear();
00116 else hm.Book<TH1I>(hname,"Total BeamMonBlocks in RawRecord (should always be 1)",5,0,5);
00117
00118
00119 // Per block
00120 hname = "earliest_dae_stnd";
00121 TH1F* hf = hm.Get<TH1F>(hname);
00122 if (hf) hf->Clear();
00123 else hm.Book<TH1F>(hname,"Earliest DAE - STND (should be < 0.5)",1000,-1,1);
00124
00125 hname = "earliest_vme_stnd";
00126 hf = hm.Get<TH1F>(hname);
00127 if (hf) hf->Clear();
00128 else hm.Book<TH1F>(hname,"Earliest VME - STND (should be < 0.5)",1000,-1,1);
00129
00130 hname = "earliest_last_dae";
00131 hf = hm.Get<TH1F>(hname);
00132 if (hf) hf->Clear();
00133 else hm.Book<TH1F>(hname,"Rep period = Earliest - Last DAE (typically ~2sec)",
00134 1000,0,10);
00135
00136 hname = "dae_vme_dt";
00137 hf = hm.Get<TH1F>(hname);
00138 if (hf) hf->Clear();
00139 else hm.Book<TH1F>(hname,"DAE - VME time over TGT-Prof,Had,Mu monitors (should be ~0.5 sec)",
00140 1000,-1,1);
00141
00142 hname = "dae_vme_dt_min";
00143 TH2F *dae_vme_dt_min = hm.Get<TH2F>(hname);
00144 if (dae_vme_dt_min) dae_vme_dt_min->Clear();
00145 else dae_vme_dt_min =
00146 hm.Book<TH2F>(hname,"DAE - VME dt per min for TGT-PM,Had,Mu (>1.0 implies lost data)",
00147 12*60,0,12*60, 100,-5,5);
00148
00149 //
00150
00151 hname = "spills_per_hour";
00152 hf = hm.Get<TH1F>(hname);
00153 if (hf) hf->Clear();
00154 else hm.Book<TH1F>(hname,"Spills per hour",12,0,12);
00155
00156 hname = "npot_per_hour";
00157 hf = hm.Get<TH1F>(hname);
00158 if (hf) hf->Clear();
00159 else hm.Book<TH1F>(hname,"Npot per hour",12,0,12);
00160
00161 hname = "spills_per_min";
00162 hf = hm.Get<TH1F>(hname);
00163 if (hf) hf->Clear();
00164 else hm.Book<TH1F>(hname,"Spills per min",12*60,0,12*60);
00165
00166 hname = "npot_per_min";
00167 hf = hm.Get<TH1F>(hname);
00168 if (hf) hf->Clear();
00169 else hm.Book<TH1F>(hname,"Npot per min",12*60,0,12*60);
00170
00171 hname = "toroids";
00172 hf = hm.Get<TH1F>(hname);
00173 if (hf) hf->Clear();
00174 else hf = hm.Book<TH1F>(hname,"Toroids",4,0,4);
00175 for (int ind=0; tor_names[ind]; ++ind) {
00176 hf->GetXaxis()->SetBinLabel(ind+1,tor_names[ind]);
00177 }
00178
00179 hname = "tortgt_trtgtd";
00180 hf = hm.Get<TH1F>(hname);
00181 if (hf) hf->Clear();
00182 else hm.Book<TH1F>(hname,"(TORTGT - TRTGTD)/(TORTGT + TRTGTD)",100,-1,1);
00183
00184 hname = "tor101_tr101d";
00185 hf = hm.Get<TH1F>(hname);
00186 if (hf) hf->Clear();
00187 else hm.Book<TH1F>(hname,"(TOR101 - TR101D)/(TOR101 + TR101D)",100,-1,1);
00188
00189 hname = "tortgt_tor101";
00190 hf = hm.Get<TH1F>(hname);
00191 if (hf) hf->Clear();
00192 else hm.Book<TH1F>(hname,"(TORTGT - TOR101)/(TORTGT + TOR101)",100,-1,1);
00193
00194 hname = "trtgtd_tr101d";
00195 hf = hm.Get<TH1F>(hname);
00196 if (hf) hf->Clear();
00197 else hm.Book<TH1F>(hname,"(TRTGTD - TR101D)/(TRTGTD + TR101D)",100,-1,1);
00198
00199
00200 int ndevs = 0;
00201 while (important_devs[ndevs]) ++ndevs;
00202
00203 hname = "dev_count";
00204 hf = hm.Get<TH1F>(hname);
00205 if (hf) hf->Clear();
00206 else hf = hm.Book<TH1F>(hname,"Device counts",ndevs,0,ndevs);
00207 for (int ind=0; ind<ndevs; ++ind)
00208 hf->GetXaxis()->SetBinLabel(ind+1,important_devs[ind]);
00209 }
|
|
|
Implement for notification of end of file. See GetLastFile(). Reimplemented from JobCModule. Definition at line 211 of file BDataQualityModule.cxx. References HistMan::Book(), db_hist_dir, fFirstSpillTime, fLastSpillTime, BDSpillAccessor::Get(), HistMan::Get(), VldTimeStamp::GetEOT(), SpillTimeFinder::GetTimeOfNextSpill(), SpillTimeFinder::Instance(), BDSpillAccessor::LoadSpill(), and BeamMonSpill::SpillTime(). 00212 {
00213 HistMan hm(db_hist_dir);
00214
00215 const char* hname = "";
00216
00217 hname = "stnd_bdp_dt";
00218 TH1F *stnd_bdp_dt = hm.Get<TH1F>(hname);
00219 if (stnd_bdp_dt) stnd_bdp_dt->Clear();
00220 else stnd_bdp_dt =
00221 hm.Book<TH1F>(hname,"SpillTimeND - BDP Time (>1.0 implies lost data)",
00222 1000,-1,1);
00223
00224 hname = "stnd_bdp_dt_hour";
00225 TH2F *stnd_bdp_dt_hour = hm.Get<TH2F>(hname);
00226 if (stnd_bdp_dt_hour) stnd_bdp_dt_hour->Clear();
00227 else stnd_bdp_dt_hour =
00228 hm.Book<TH2F>(hname,"SpillTimeND - BDP Time per hour (>1.0 implies lost data)",
00229 12,0,12, 100,-5,5);
00230
00231 hname = "stnd_bdp_dt_min";
00232 TH2F *stnd_bdp_dt_min = hm.Get<TH2F>(hname);
00233 if (stnd_bdp_dt_min) stnd_bdp_dt_min->Clear();
00234 else stnd_bdp_dt_min =
00235 hm.Book<TH2F>(hname,"SpillTimeND - BDP Time per min (>1.0 implies lost data)",
00236 12*60,0,12*60, 100,-5,5);
00237
00238 // also need to check how many spills are in STND between the end
00239 // of the last file and the begin of this one.
00240
00241 Detector::Detector_t det = Detector::kNear;
00242 SimFlag::SimFlag_t simflag = SimFlag::kData;
00243 VldTimeStamp vts(fFirstSpillTime);
00244 VldTimeStamp numi_start(2005,1,1,0,0,0);
00245
00246 SpillTimeFinder& stf = SpillTimeFinder::Instance();
00247 BDSpillAccessor& sa = BDSpillAccessor::Get();
00248
00249 while ((double)vts <= fLastSpillTime + 1.0) {
00250 VldContext vc(det,simflag,vts);
00251 VldTimeStamp stnd_vts = stf.GetTimeOfNextSpill(vc);
00252
00253 if (stnd_vts < numi_start) {
00254 cerr << "Bailing on file due to getting early SpillTimeND: "
00255 << stnd_vts
00256 << " last vts = " << vts
00257 << endl;
00258 break;
00259 }
00260
00261 const BeamMonSpill* bms = sa.LoadSpill(stnd_vts);
00262 VldTimeStamp bms_vts;
00263 if (!bms) {
00264 cerr << "No BeamMonSpill for " << stnd_vts << endl;
00265 bms_vts = VldTimeStamp::GetEOT();
00266 }
00267 else {
00268 bms_vts = bms->SpillTime();
00269 }
00270
00271 double dt = stnd_vts-bms_vts;
00272
00273 stnd_bdp_dt->Fill(dt);
00274 stnd_bdp_dt_hour->Fill(((double)stnd_vts-fFirstSpillTime)/(60*60),dt);
00275 stnd_bdp_dt_min->Fill(((double)stnd_vts-fFirstSpillTime)/(60),dt);
00276
00277 if (vts >= stnd_vts) {
00278 cerr << "Error, infinite loop, bailing with\n\tbms= " << vts
00279 << " stnd= " << stnd_vts << endl;
00280 break;
00281 }
00282 vts = stnd_vts;
00283
00284 }
00285
00286
00287 }
|
|
||||||||||||
|
Definition at line 289 of file BDataQualityModule.cxx. References fFirstSpillTime, file_hist_dir, HistMan::Fill1d(), HistMan::Get(), RawBeamData::GetData(), RawBeamData::GetDataLength(), BDEarliest::GetLastTimestamps(), RawBeamData::GetMsecs(), RawBeamData::GetSeconds(), SpillTimeFinder::GetTimeOfNearestSpill(), BDEarliest::GetTimestamps(), important_devs, SpillTimeFinder::Instance(), RawBeamSwicData::SetData(), BDEarliest::SetSpill(), some_swics, tor_names, RawBeamSwicData::VmeNanoseconds(), and RawBeamSwicData::VmeSeconds(). Referenced by Ana(). 00291 {
00292 static BDEarliest bde;
00293 bde.SetSpill(head,block);
00294 double dae=0,vme=0,last_dae=0,last_vme=0;
00295 bde.GetTimestamps(dae,vme);
00296 bde.GetLastTimestamps(last_dae,last_vme);
00297
00298
00299 Detector::Detector_t det = Detector::kNear;
00300 SimFlag::SimFlag_t simflag = SimFlag::kData;
00301 VldTimeStamp dae_vts(dae);
00302 VldContext vc(det,simflag,dae_vts);
00303
00304 SpillTimeFinder& stf = SpillTimeFinder::Instance();
00305 VldTimeStamp stnd_vts = stf.GetTimeOfNearestSpill(vc);
00306 double stnd = stnd_vts;
00307
00308 HistMan hm(file_hist_dir);
00309
00310 const char* hname = "earliest_dae_stnd";
00311 hm.Fill1d(hname,dae-stnd);
00312
00313 hname = "earliest_vme_stnd";
00314 hm.Fill1d(hname,vme-stnd);
00315
00316 hname = "earliest_last_dae";
00317 hm.Fill1d(hname,dae-last_dae);
00318
00319
00320 hname = "dae_vme_dt";
00321 TH1F* dae_vme_dt =hm.Get<TH1F>(hname);
00322 hname = "dae_vme_dt_min";
00323 TH2F* dae_vme_dt_min = hm.Get<TH2F>(hname);
00324
00325 RawBeamSwicData swic;
00326 for (int ind=0; some_swics[ind]; ++ind) {
00327 const RawBeamData* rbd = block[some_swics[ind]];
00328 if (!rbd) continue;
00329 VldTimeStamp dae_vts(rbd->GetSeconds(), 1000000*rbd->GetMsecs());
00330
00331 swic.SetData(*rbd);
00332 VldTimeStamp vme_vts(swic.VmeSeconds(), swic.VmeNanoseconds());
00333
00334 double dt = (double)(dae_vts - vme_vts);
00335
00336 if (dae_vme_dt)
00337 dae_vme_dt->Fill(dt);
00338
00339 if (dae_vme_dt_min)
00340 dae_vme_dt_min->Fill((dae-fFirstSpillTime)/60.,dt);
00341 }
00342
00343 hname = "spills_per_hour";
00344 hm.Fill1d(hname,(dae-fFirstSpillTime)/(60*60));
00345
00346 hname = "spills_per_min";
00347 hm.Fill1d(hname,(dae-fFirstSpillTime)/(60));
00348
00349 double pot=0, pots[4] = {0};
00350
00351 for (int ind=0; tor_names[ind]; ++ind) {
00352 const RawBeamData* tor_dev = block[tor_names[ind]];
00353 if (tor_dev && tor_dev->GetDataLength())
00354 pots[ind] = tor_dev->GetData()[0];
00355 if (pot == 0) pot = pots[ind];
00356 hm.Fill1d("toroids",ind,pots[ind]);
00357 }
00358
00359
00360 hname = "npot_per_hour";
00361 hm.Fill1d(hname,(dae-fFirstSpillTime)/(60*60),pot);
00362
00363 hname = "npot_per_min";
00364 hm.Fill1d(hname,(dae-fFirstSpillTime)/(60),pot);
00365
00366 const char* hnames[] = {
00367 "tortgt_trtgtd",//0,1
00368 "tor101_tr101d",//2,3
00369 "tortgt_tor101",//0,2
00370 "trtgtd_tr101d",//1,3
00371 0
00372 };
00373 for (int ind=0; ind<2; ++ind) {
00374 double sum = pots[ind*2]+pots[ind*2+1];
00375 TH1F* h = hm.Get<TH1F>(hnames[ind]);
00376 if (sum == 0.0)
00377 h->Fill(-1);
00378 else
00379 h->Fill((pots[ind*2]-pots[ind*2+1])/sum);
00380
00381 sum = pots[ind]+pots[ind+2];
00382 h = hm.Get<TH1F>(hnames[ind+2]);
00383 if (sum == 0.0)
00384 h->Fill(-1);
00385 else
00386 h->Fill((pots[ind]-pots[ind+2])/sum);
00387
00388 }
00389
00390 hname = "dev_count";
00391 TH1F* id = hm.Get<TH1F>(hname);
00392 if (id) {
00393 for (int ind=0; important_devs[ind]; ++ind) {
00394 const RawBeamData* dev = block[important_devs[ind]];
00395 if (dev && dev->GetDataLength())
00396 id->Fill(ind);
00397 else
00398 cerr << "Failed to get " << important_devs[ind] << endl;
00399 }
00400 }
00401 else cerr << "Failed to get dev_count\n";
00402
00403 }
|
|
|
Definition at line 66 of file BDataQualityModule.h. Referenced by Ana(), EndFile(), and FillFile(). |
|
|
Definition at line 66 of file BDataQualityModule.h. |
1.3.9.1