#include <BDLivePlot.h>
Public Member Functions | |
| BDLivePlot (VldTimeStamp beg=VldTimeStamp::GetBOT(), VldTimeStamp end=VldTimeStamp::GetEOT(), double binsize=1 *Munits::day, const char *histman_file="bdliveplot.root") | |
|
||||||||||||||||||||
|
Definition at line 23 of file BDLivePlot.cxx. References VldTimeStamp::AsString(), HistMan::Book(), count, DbuSubRunSummary::fDetector, files, DbuSubRunSummary::Fill(), Form(), DbuSubRunSummary::fRun, DbuSubRunSummary::fRunType, BeamMonSpill::fTor101, BeamMonSpill::fTortgt, BeamMonSpill::fTr101d, BeamMonSpill::fTrtgtd, BDSpillAccessor::Get(), VldTimeStamp::GetBOT(), VldTimeStamp::GetEOT(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRow(), BDSpillAccessor::LoadSpill(), DbiResultPtr< T >::NewQuery(), UtilRSM::RunTypeName(), BeamMonSpill::SpillTime(), and HistMan::WriteOut(). 00025 {
00026 BDSpillAccessor& sa = BDSpillAccessor::Get();
00027
00028
00029 if (end == VldTimeStamp::GetEOT()) {
00030 const BeamMonSpill* spill = sa.LoadSpill(end,-1);
00031 end = spill->SpillTime();
00032 }
00033 double dend = (double)end;
00034
00035 const BeamMonSpill* spill = 0;
00036 if (beg == VldTimeStamp::GetBOT()) {
00037 spill = sa.LoadSpill(beg,+1);
00038 beg = spill->SpillTime();
00039 }
00040 else spill = sa.LoadSpill(beg);
00041
00042 double dbeg = (double)beg;
00043
00044 int nbins = (int)((dend-dbeg)/(binsize/Munits::second)) + 1;
00045
00046 HistMan hm("bdlive");
00047 TH1F* tortgt = hm.Book<TH1F>("tortgt","All Tortgt protons",nbins,dbeg,dend);
00048 TH1F* trtgtd = hm.Book<TH1F>("trtgtd","All Trtgtd protons",nbins,dbeg,dend);
00049 TH1F* tor101 = hm.Book<TH1F>("tor101","All Tor101 protons",nbins,dbeg,dend);
00050 TH1F* tr101d = hm.Book<TH1F>("tr101d","All Tr101d protons",nbins,dbeg,dend);
00051 TH1F* spills = hm.Book<TH1F>("spills","Spills",nbins,dbeg,dend);
00052 TH1F* wnd = hm.Book<TH1F>("wnd","With near det",nbins,dbeg,dend);
00053 TH1F* wfd = hm.Book<TH1F>("wfd","With far det",nbins,dbeg,dend);
00054
00055
00056 VldTimeStamp now = beg;
00057
00058 DbiResultPtr<DbuSubRunSummary> *daq_query = 0;
00059 int count = 0;
00060 while (now <= end) {
00061 if (1 == count % 1000) cerr << now << endl;
00062 ++count;
00063
00064
00065 double dnow = (double)now;
00066
00067 tortgt->Fill(dnow,spill->fTortgt);
00068 trtgtd->Fill(dnow,spill->fTrtgtd);
00069 tor101->Fill(dnow,spill->fTor101);
00070 tr101d->Fill(dnow,spill->fTr101d);
00071 spills->Fill(dnow);
00072
00073 string files = Form("TIMESTART<='%s' and TIMEEND>='$s' "
00074 "order by TIMESTART desc",
00075 beg.AsString("s"),end.AsString("s"));
00076
00077 DbiSqlContext ctx(files);
00078 if (!daq_query)
00079 daq_query =
00080 new DbiResultPtr<DbuSubRunSummary>("DbuSubRunSummary",ctx);
00081 else
00082 daq_query->NewQuery(ctx,Dbi::kAnyTask);
00083
00084
00085 bool found_far = false, found_near = false;
00086 int nfiles = daq_query->GetNumRows();
00087 for (int ifile = 0; ifile < nfiles; ++ifile) {
00088 const DbuSubRunSummary* srs = daq_query->GetRow(ifile);
00089 string run_type = RunTypeName(srs->fRunType,srs->fDetector,srs->fRun);
00090 if (run_type != "physics" && run_type != "normal-data") continue;
00091 if (srs->fDetector == Detector::kNear) {
00092 found_near = true;
00093 }
00094 if (srs->fDetector == Detector::kFar) {
00095 found_far = true;
00096 }
00097 }
00098 if (found_near) wnd->Fill(dnow);
00099 if (found_far) wfd->Fill(dnow);
00100
00101 spill = sa.LoadSpill(now,+1);
00102 VldTimeStamp next = spill->SpillTime();
00103 if (next <= now) {
00104 cerr << "Busting inifinite loop - something's screwy\n";
00105 break;
00106 }
00107 now = next;
00108 }
00109
00110 HistMan io("");
00111 io.WriteOut(histman_file);
00112 }
|
1.3.9.1