FileGap Class Reference

#include <FileGap.h>

List of all members.

Public Types

typedef std::pair
< VldTimeStamp, VldTimeStamp
Bound
typedef std::list< BoundBoundList

Public Member Functions

 FileGap ()
 ~FileGap ()
BoundList GetFileBounds (VldTimeStamp beg=VldTimeStamp::GetBOT(), VldTimeStamp end=VldTimeStamp::GetEOT(), double deltas=0)
void DumpGaps (VldTimeStamp beg=VldTimeStamp::GetBOT(), VldTimeStamp end=VldTimeStamp::GetEOT())
void DumpMissing (std::list< std::string > file_list)
void DumpMissing (const char *directory)

Private Attributes

DbiResultPtr
< BeamMonFileSummary > * 
fRes

Detailed Description

Definition at line 13 of file FileGap.h.


Member Typedef Documentation

Definition at line 19 of file FileGap.h.

typedef std::list<Bound> FileGap::BoundList

Definition at line 20 of file FileGap.h.


Constructor & Destructor Documentation

FileGap::FileGap (  ) 

Definition at line 15 of file FileGap.cxx.

00016     : fRes(new DbiResultPtr<BeamMonFileSummary>)
00017 {
00018 
00019 }

FileGap::~FileGap (  ) 

Definition at line 21 of file FileGap.cxx.

References fRes.

00022 {
00023     if (fRes) delete fRes; fRes = 0;
00024 }


Member Function Documentation

void FileGap::DumpGaps ( VldTimeStamp  beg = VldTimeStamp::GetBOT(),
VldTimeStamp  end = VldTimeStamp::GetEOT() 
)

Definition at line 56 of file FileGap.cxx.

References GetFileBounds(), and it.

00057 {
00058     BoundList bounds = this->GetFileBounds(beg,end);
00059 
00060     VldTimeStamp last = beg;
00061     double total_gap = 0, total_data = 0;
00062     for (BoundList::iterator it=bounds.begin(); it != bounds.end(); ++it) {
00063         VldTimeStamp start = it->first;
00064         VldTimeStamp stop = it->second;
00065 
00066         double dt_gap = start - last;
00067         double dt_data = stop - start;
00068         if (dt_gap>120.0) {
00069             cerr << last << " - " << start << " = " << dt_gap
00070                  << " (" << dt_data << ")\n";
00071 
00072             if (last != beg) total_gap += dt_gap;
00073         }
00074         total_data += dt_data;
00075 
00076         last = stop;
00077     }
00078 
00079     cerr << "From " << beg << " to " << end <<endl
00080          << "total data = " << total_data
00081          << " total gap = " << total_gap << endl;
00082 }

void FileGap::DumpMissing ( const char *  directory  ) 

Same as above but use all files in matching B*.mbeam.root in given directory

Definition at line 154 of file FileGap.cxx.

References DumpMissing(), and gSystem().

00155 {
00156     void* dir = gSystem->OpenDirectory(directory);
00157     if (!dir) {
00158         cerr << "Failed to open " << directory << endl;
00159         return;
00160     }
00161     
00162     cerr << "Checking: " << directory << endl;
00163 
00164     list<string> file_names;
00165     const char* cptr = 0;
00166     while ( (cptr = gSystem->GetDirEntry(dir))) {
00167 
00168         if (cptr[0] == '.') {
00169             cerr << "Skipping (dot file): " << cptr << endl;
00170             continue;
00171         }
00172         if (cptr[0] != 'B') {
00173             continue;
00174             cerr << "Skipping (bad name): " << cptr << endl;
00175         }
00176         string file(cptr);
00177         if (string::npos == file.rfind(".mbeam.root")) {
00178             cerr << "Skipping (bad ext): " << cptr << endl;
00179             continue;
00180         }
00181 
00182         file_names.push_back(file);
00183     }
00184     file_names.sort();
00185     cerr << "Using " << file_names.size() << " files\n";
00186     this->DumpMissing(file_names);
00187 }

void FileGap::DumpMissing ( std::list< std::string >  file_list  ) 

Print out any files named in file_list array that are not in the database.

Definition at line 95 of file FileGap.cxx.

References bfld::AsString(), det, done(), dump_file_summary(), BeamMonFileSummary::fFileName, Form(), fRes, VldTimeStamp::GetBOT(), VldTimeStamp::GetEOT(), DbiResultPtr< T >::GetRow(), it, SimFlag::kData, Detector::kNear, missing(), and DbiResultPtr< T >::NewQuery().

Referenced by DumpMissing().

00096 {
00097     Detector::Detector_t det = Detector::kNear;
00098     SimFlag::SimFlag_t simflag = SimFlag::kData;
00099     VldContext vc(det,simflag,VldTimeStamp::GetBOT());
00100 
00101     const char* sql = Form("(TIMEEND>='%s') and (TIMESTART<='%s')",
00102                            VldTimeStamp::GetBOT().AsString("s"),
00103                            VldTimeStamp::GetEOT().AsString("s"));
00104     int nrows = fRes->NewQuery(DbiSqlContext(sql));
00105     cerr << "There are " << nrows << " files in the DB\n";
00106 
00107     typedef map<string,const BeamMonFileSummary*> DbMap;
00108     DbMap dbmap;
00109 
00110     for (int ind=0; ind<nrows; ++ind) {
00111         const BeamMonFileSummary *fs = fRes->GetRow(ind);
00112         if (!fs) {
00113             cerr << "Got zero row at " << ind << " / " << nrows << endl;
00114             continue;
00115         }
00116         dbmap[fs->fFileName] = fs;
00117     }
00118 
00119     int checked=0, found=0, missing=0;
00120     list<string>::iterator it, done=file_list.end();
00121     const BeamMonFileSummary* last=0;
00122     bool ingap = true;
00123     for (it=file_list.begin(); it!=done; ++it) {
00124         ++checked;
00125         const BeamMonFileSummary* fs = dbmap[*it];
00126         if (fs) {
00127 
00128             ++found;
00129             last = fs;
00130             if (ingap) {
00131                 dump_file_summary(fs);
00132                 ingap = false;
00133             }
00134             continue;
00135         }
00136         if (last) {
00137             dump_file_summary(last);
00138             last = 0;
00139             ingap = true;
00140         }
00141         ++missing;
00142         cerr  << *it << " missing from db" << endl;
00143     }
00144     cerr << checked << " checked, "
00145          << found << " found, "
00146          << missing << " missing "
00147          << endl;
00148 
00149 }

FileGap::BoundList FileGap::GetFileBounds ( VldTimeStamp  beg = VldTimeStamp::GetBOT(),
VldTimeStamp  end = VldTimeStamp::GetEOT(),
double  deltas = 0 
)

Return a list of bounds of files covering the range [beg,end]. deltas is the time in seconds to enlarge the file bounds to deal with the rather large uncerainty on the timing from the beam monitoring devices.

Definition at line 31 of file FileGap.cxx.

References VldTimeStamp::Add(), VldTimeStamp::AsString(), bound_less_than(), det, BeamMonFileSummary::fFirstSpillTime, BeamMonFileSummary::fLastSpillTime, Form(), fRes, BeamMonFileSummary::fSpillCount, BeamMonFileSummary::fTclkTriggerEvent, DbiResultPtr< T >::GetRow(), SimFlag::kData, Detector::kNear, and DbiResultPtr< T >::NewQuery().

Referenced by DumpGaps(), StndBmsSpin::Scan(), BMS_STND::Scan(), and STND_BMS::Scan().

00032 {
00033     Detector::Detector_t det = Detector::kNear;
00034     SimFlag::SimFlag_t simflag = SimFlag::kData;
00035     VldContext vc(det,simflag,beg);
00036 
00037     const char* sql = Form("(TIMEEND>='%s') and (TIMESTART<='%s')",
00038                            beg.AsString("s"),end.AsString("s"));
00039     int nrows = fRes->NewQuery(DbiSqlContext(sql));
00040     BoundList bounds;
00041     for (int ind=0; ind<nrows; ++ind) {
00042         const BeamMonFileSummary *fs = fRes->GetRow(ind);
00043         if (!fs->fSpillCount) continue;
00044         if (fs->fTclkTriggerEvent != 0xa9) continue;
00045         VldTimeStamp first_spilltime = fs->fFirstSpillTime;
00046         first_spilltime.Add(-1*deltas);
00047         VldTimeStamp last_spilltime = fs->fLastSpillTime;
00048         last_spilltime.Add(deltas);
00049         bounds.push_back(Bound(first_spilltime,last_spilltime));
00050     }
00051 
00052     bounds.sort(bound_less_than);
00053     return bounds;
00054 }


Member Data Documentation

Definition at line 14 of file FileGap.h.

Referenced by DumpMissing(), GetFileBounds(), and ~FileGap().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1