RunQualityFinder Class Reference

#include <RunQualityFinder.h>

List of all members.

Classes

struct  Cleaner

Public Member Functions

virtual ~RunQualityFinder ()
Bool_t IsOK (const VldContext &context)
Bool_t IsOK (const Detector::Detector_t detector, const UInt_t run, const UInt_t subrun)
RunStatus::RunStatus_t GetStatus (const VldContext &context)
RunStatus::RunStatus_t GetStatus (const Detector::Detector_t detector, const UInt_t run, const UInt_t subrun)
UInt_t GetRun (const VldContext &context)
UInt_t GetSubRun (const VldContext &context)
void SetOverrideDB (Bool_t override=1)
Bool_t GetOverrideDB ()
void SetTask (Detector::Detector_t detector, Int_t itask)
Int_t GetTask (Detector::Detector_t detector)
Bool_t BadReadoutErrorsLegacy (const Detector::Detector_t detector, const UInt_t run, const UInt_t subrun)
void Reset ()

Static Public Member Functions

static RunQualityFinderInstance ()
static void OverrideDB (Bool_t override=1)
static void DbiTask (Detector::Detector_t detector, Int_t itask)

Private Member Functions

 RunQualityFinder ()
void SetTaskNear (Int_t itask)
void SetTaskFar (Int_t itask)
void QueryDB (const VldContext &context)
void QueryDB (const Detector::Detector_t detector, const UInt_t run, const UInt_t subrun)
Bool_t RejectRun (const UInt_t detector, const UInt_t run, const UInt_t subrun)
Bool_t RecoverRun (const UInt_t detector, const UInt_t run, const UInt_t subrun)

Private Attributes

DbiResultPtr< DbuFarRunQualityfarquery
DbiResultPtr< DbuNearRunQualitynearquery
Int_t fDetector
Int_t fStartTime
Int_t fEndTime
UInt_t fRun
UInt_t fSubRun
Int_t fDbiTaskFar
Int_t fDbiTaskNear
Bool_t fOverrideDB
Int_t fRunStatus
Int_t fRunStatusResult

Static Private Attributes

static RunQualityFinderfMyInstance = 0

Friends

struct Cleaner

Detailed Description

Definition at line 14 of file RunQualityFinder.h.


Constructor & Destructor Documentation

RunQualityFinder::~RunQualityFinder (  )  [virtual]

Definition at line 77 of file RunQualityFinder.cxx.

References Msg::kVerbose, and MSG.

00078 {
00079   MSG("RunQuality",Msg::kVerbose) << " *** RunQualityFinder::~RunQualityFinder() *** " << endl;
00080 }

RunQualityFinder::RunQualityFinder (  )  [private]

Definition at line 59 of file RunQualityFinder.cxx.

References fDbiTaskFar, fDbiTaskNear, fDetector, fEndTime, fOverrideDB, fRun, fRunStatus, fRunStatusResult, fStartTime, fSubRun, RunStatus::kUnknown, Msg::kVerbose, and MSG.

00060 {
00061   MSG("RunQuality",Msg::kVerbose) << " *** RunQualityFinder::RunQualityFinder() *** " << endl;
00062 
00063   fStartTime = -1;
00064   fEndTime = -1;
00065   fRun = 0;
00066   fSubRun = 0;
00067   fDetector = 0;
00068 
00069   fDbiTaskNear = 1;
00070   fDbiTaskFar = 0;
00071   fOverrideDB = 0;
00072 
00073   fRunStatus = RunStatus::kUnknown;
00074   fRunStatusResult = RunStatus::kUnknown;
00075 }


Member Function Documentation

Bool_t RunQualityFinder::BadReadoutErrorsLegacy ( const Detector::Detector_t  detector,
const UInt_t  run,
const UInt_t  subrun 
)

Definition at line 589 of file RunQualityFinder.cxx.

References DbuNearRunQuality::BadReadoutErrors(), fDbiTaskNear, DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRow(), DbuNearRunQuality::GetRun(), DbuNearRunQuality::GetSubRun(), Detector::kNear, nearquery, and QueryDB().

00590 {
00591   if( detector != Detector::kNear )
00592     return false;
00593 
00594   this->QueryDB(detector, run, subrun);
00595 
00596   for( unsigned int i=0; i<nearquery.GetNumRows(); i++ ){
00597     const DbuNearRunQuality* rowptr = nearquery.GetRow(i);
00598     if (rowptr->GetRun() == (Int_t)run && rowptr->GetSubRun() == (Int_t)subrun
00599      && rowptr->BadReadoutErrors(fDbiTaskNear, true)) 
00600       return true;
00601   }
00602 
00603   return false;
00604 }

void RunQualityFinder::DbiTask ( Detector::Detector_t  detector,
Int_t  itask 
) [static]

Definition at line 52 of file RunQualityFinder.cxx.

References GetTask(), Instance(), Msg::kDebug, MSG, and SetTask().

00053 {
00054   RunQualityFinder::Instance().SetTask(detector,itask);
00055   MSG("RunQuality", Msg::kDebug) << "  Setting: Detector=" << detector << ", Task=" << itask << endl;
00056   MSG("RunQuality", Msg::kDebug) << "  Check: Detector=" << detector << ", Task=" << RunQualityFinder::Instance().GetTask(detector) << endl;
00057 }

Bool_t RunQualityFinder::GetOverrideDB (  ) 

Definition at line 143 of file RunQualityFinder.cxx.

References fOverrideDB.

Referenced by OverrideDB().

00144 { 
00145   return fOverrideDB; 
00146 }

UInt_t RunQualityFinder::GetRun ( const VldContext context  ) 

Definition at line 118 of file RunQualityFinder.cxx.

References fRun, VldContext::GetDetector(), VldTimeStamp::GetSec(), VldContext::GetTimeStamp(), Msg::kDebug, MSG, and QueryDB().

00119 {
00120   MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::GetRun(detector=" << context.GetDetector() << ",time=" << context.GetTimeStamp().GetSec() << ") *** " << endl;
00121 
00122   this->QueryDB(context);
00123 
00124   return fRun;
00125 }

RunStatus::RunStatus_t RunQualityFinder::GetStatus ( const Detector::Detector_t  detector,
const UInt_t  run,
const UInt_t  subrun 
)

Definition at line 109 of file RunQualityFinder.cxx.

References fRunStatusResult, Msg::kDebug, MSG, and QueryDB().

00110 {
00111   MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::GetStatus(detector=" << detector << ",run=" << run << ",subrun=" << subrun << ") *** " << endl;
00112 
00113   this->QueryDB(detector,run,subrun);
00114 
00115   return (RunStatus::RunStatus_t)fRunStatusResult;
00116 }

RunStatus::RunStatus_t RunQualityFinder::GetStatus ( const VldContext context  ) 

Definition at line 100 of file RunQualityFinder.cxx.

References fRunStatusResult, VldContext::GetDetector(), VldTimeStamp::GetSec(), VldContext::GetTimeStamp(), Msg::kDebug, MSG, and QueryDB().

00101 {
00102   MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::GetStatus(detector=" << context.GetDetector() << ",time=" << context.GetTimeStamp().GetSec() << ") *** " << endl;
00103 
00104   this->QueryDB(context);
00105 
00106   return (RunStatus::RunStatus_t)fRunStatusResult;
00107 }

UInt_t RunQualityFinder::GetSubRun ( const VldContext context  ) 

Definition at line 127 of file RunQualityFinder.cxx.

References fSubRun, VldContext::GetDetector(), VldTimeStamp::GetSec(), VldContext::GetTimeStamp(), Msg::kDebug, MSG, and QueryDB().

00128 {
00129   MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::GetSubRun(detector=" << context.GetDetector() << ",time=" << context.GetTimeStamp().GetSec() << ") *** " << endl;
00130 
00131   this->QueryDB(context);
00132 
00133   return fSubRun;
00134 }

Int_t RunQualityFinder::GetTask ( Detector::Detector_t  detector  ) 

Definition at line 164 of file RunQualityFinder.cxx.

References fDbiTaskFar, fDbiTaskNear, Detector::kFar, and Detector::kNear.

Referenced by DbiTask().

00165 {
00166   switch(detector){
00167     case Detector::kFar: return fDbiTaskFar;
00168     case Detector::kNear: return fDbiTaskNear;
00169     default: return -1;
00170   }
00171 }

RunQualityFinder & RunQualityFinder::Instance ( void   )  [static]

Definition at line 14 of file RunQualityFinder.cxx.

References Msg::kDebug, Msg::kFatal, MSG, and RunQualityFinder::Cleaner::UseMe().

Referenced by DbiTask(), DataUtil::IsGoodDataRUN(), OverrideDB(), and DataQualityInterface::ProcessDetectorStatus().

00015 {
00016   MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::Instance() *** " << endl;
00017 
00018   // Cleaner destructor calls RunQualityFinder dtor
00019   static Cleaner cleaner;
00020 
00021   // create singleton instance of spillfinder
00022   if(!fMyInstance){
00023     MSG("RunQuality", Msg::kDebug) << "  Creating new instance of RunQualityFinder " << endl;
00024     cleaner.UseMe();
00025     fMyInstance = new RunQualityFinder();
00026   }
00027 
00028   // die if finder hasn't actually been created
00029   if(!fMyInstance){
00030     MSG("RunQuality", Msg::kFatal) << "  No RunQualityFinder Instance - aagghhh, I'm going to die!!!." << endl;
00031     assert(fMyInstance);
00032   }
00033 
00034   // can do re-setting here
00035   if(fMyInstance){
00036 
00037   }
00038 
00039   return *fMyInstance;
00040 }

Bool_t RunQualityFinder::IsOK ( const Detector::Detector_t  detector,
const UInt_t  run,
const UInt_t  subrun 
)

Definition at line 91 of file RunQualityFinder.cxx.

References fRunStatusResult, Msg::kDebug, RunStatus::kOK, MSG, and QueryDB().

00092 {
00093   MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::IsOK(detector=" << detector << ",run=" << run << ",subrun=" << subrun << ") *** " << endl;
00094 
00095   this->QueryDB(detector,run,subrun);
00096 
00097   return fRunStatusResult&RunStatus::kOK;  
00098 }

Bool_t RunQualityFinder::IsOK ( const VldContext context  ) 

Definition at line 82 of file RunQualityFinder.cxx.

References fRunStatusResult, VldContext::GetDetector(), VldTimeStamp::GetSec(), VldContext::GetTimeStamp(), Msg::kDebug, RunStatus::kOK, MSG, and QueryDB().

Referenced by DataUtil::IsGoodDataRUN().

00083 {
00084   MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::IsOK(detector=" << context.GetDetector() << ",time=" << context.GetTimeStamp().GetSec() << ") *** " << endl;
00085 
00086   this->QueryDB(context);
00087 
00088   return fRunStatusResult&RunStatus::kOK;
00089 }

void RunQualityFinder::OverrideDB ( Bool_t  override = 1  )  [static]

Definition at line 42 of file RunQualityFinder.cxx.

References GetOverrideDB(), Instance(), Msg::kDebug, MSG, and SetOverrideDB().

Referenced by ANtpInfoObjectFiller::ANtpInfoObjectFiller().

00043 {
00044   RunQualityFinder::Instance().SetOverrideDB(override);
00045 
00046   MSG("RunQuality", Msg::kDebug) << "  Setting: OverrideDB=" << override << endl;
00047   MSG("RunQuality", Msg::kDebug) << "  Check: OverrideDB=" << RunQualityFinder::Instance().GetOverrideDB() << endl;
00048 
00049   return;
00050 }

void RunQualityFinder::QueryDB ( const Detector::Detector_t  detector,
const UInt_t  run,
const UInt_t  subrun 
) [private]

Definition at line 355 of file RunQualityFinder.cxx.

References DbuNearRunQuality::BadReadoutErrors(), DbuNearRunQuality::BadSpillWindow(), DbuNearRunQuality::ColdReadout(), farquery, fDbiTaskNear, fDetector, fEndTime, Form(), fRun, fRunStatus, fRunStatusResult, fStartTime, fSubRun, DbuNearRunQuality::GetEndTime(), DbuFarRunQuality::GetEndTime(), DbuFarRunQuality::GetIndex(), DbuNearRunQuality::GetIndex(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRowByIndex(), DbuFarRunQuality::GetRun(), DbuNearRunQuality::GetRun(), VldTimeStamp::GetSec(), DbuFarRunQuality::GetStartTime(), DbuNearRunQuality::GetStartTime(), DataUtil::GetStartTime(), DbuFarRunQuality::GetSubRun(), DbuNearRunQuality::GetSubRun(), DbuFarRunQuality::GoodReadout(), DbuNearRunQuality::GoodReadout(), DbuNearRunQuality::GoodRun(), DbuFarRunQuality::GoodRun(), DbuNearRunQuality::GoodRunType(), DbuFarRunQuality::GoodRunType(), DbuNearRunQuality::HighADC(), DbuNearRunQuality::HighRate(), DbuFarRunQuality::HighRate(), DbuNearRunQuality::HotReadout(), RunStatus::kBad, RunStatus::kBadReadout, RunStatus::kBadReadoutErrors, RunStatus::kBadRunType, RunStatus::kBadSpillWindow, RunStatus::kColdReadout, SimFlag::kData, Msg::kDebug, Detector::kFar, RunStatus::kHighADC, RunStatus::kHighRate, RunStatus::kHotReadout, RunStatus::kLIRate, RunStatus::kLowRate, Detector::kNear, RunStatus::kOK, RunStatus::kShort, RunStatus::kUnknown, Msg::kVerbose, DbuNearRunQuality::LIRate(), DbuFarRunQuality::LowRate(), DbuNearRunQuality::LowRate(), MSG, nearquery, DbiResultPtr< T >::NewQuery(), RecoverRun(), RejectRun(), DbuFarRunQuality::Short(), and DbuNearRunQuality::Short().

00356 {
00357   MSG("RunQuality",Msg::kVerbose) << " *** RunQualityFinder::QueryDB(detector=" << detector << ",run=" << run << ",subrun=" << subrun<< ") *** " << endl;
00358 
00359   // Result of DB Query
00360   // ==================
00361   fRunStatusResult = RunStatus::kUnknown;
00362 
00363   // Far Detector Data Quality
00364   // =========================
00365   if( detector == Detector::kFar ){
00366     MSG("RunQuality",Msg::kDebug) << "   far detector: searching DBUFARRUNQUALITY database... " << endl;
00367     MSG("RunQuality",Msg::kDebug) << "    using task: 0 " << endl;
00368 
00369     // return previous result
00370     if( fDetector==detector
00371      && fRun==run && fSubRun==subrun ){
00372       MSG("RunQuality",Msg::kDebug) << "   returning previous result: " << endl;
00373       MSG("RunQuality",Msg::kDebug) << "    run=" << fRun << "/" << fSubRun << endl;   
00374       MSG("RunQuality",Msg::kDebug) << "    status=" << fRunStatus << endl;
00375       MSG("RunQuality",Msg::kDebug) << "    isok=" << (fRunStatus&RunStatus::kOK) << endl;
00376       fRunStatusResult = fRunStatus;
00377     }
00378 
00379     // perform database query
00380     else{
00381 
00382       const char* sqltxt = Form("(AGGREGATENO=%d) and (TASK=%d) and (DETECTORMASK & %d) and (SIMMASK & %d)",run,0,Detector::kFar,SimFlag::kData);
00383       MSG("RunQuality",Msg::kVerbose) << "    new query: " << sqltxt << endl; 
00384       DbiSqlContext sqlcontext(sqltxt);
00385       farquery.NewQuery(sqlcontext);
00386       MSG("RunQuality",Msg::kVerbose) << "    found " << farquery.GetNumRows() << " entries for run " << run << endl;
00387 
00388       UInt_t index = DbuFarRunQuality::GetIndex(run,subrun);
00389       const DbuFarRunQuality* rowptr = farquery.GetRowByIndex(index);
00390       MSG("RunQuality",Msg::kVerbose) << "    getting row by index: " << index << endl;
00391       if( rowptr ) MSG("RunQuality",Msg::kVerbose) << "    found entry for run " << run << "/" << subrun << endl;
00392       else MSG("RunQuality",Msg::kVerbose) << "    failed to find entry for run " << run << "/" << subrun << endl;
00393 
00394       fDetector = Detector::kFar;
00395       fRun = 0;
00396       fSubRun = 0;
00397       fStartTime = -1;
00398       fEndTime = -1;
00399       fRunStatus = RunStatus::kUnknown;
00400 
00401       if( rowptr ){
00402         MSG("RunQuality",Msg::kVerbose) << "     run=" << rowptr->GetRun() << "/" << rowptr->GetSubRun() << endl;
00403         MSG("RunQuality",Msg::kVerbose) << "     start=" << rowptr->GetStartTime() << endl;
00404         MSG("RunQuality",Msg::kVerbose) << "     end=" << rowptr->GetEndTime() << endl;
00405         MSG("RunQuality",Msg::kVerbose) << "     goodrun=" << rowptr->GoodRun() << endl;
00406 
00407         fRun = rowptr->GetRun(); fSubRun = rowptr->GetSubRun();
00408         if( fStartTime<0 || rowptr->GetStartTime().GetSec()<fStartTime ){
00409           fStartTime = rowptr->GetStartTime().GetSec(); }
00410         if( rowptr->GetEndTime().GetSec()>fEndTime ){ 
00411           fEndTime = rowptr->GetEndTime().GetSec(); }
00412 
00413         if( ( rowptr->GoodRun() 
00414            && !this->RejectRun(fDetector,fRun,fSubRun) ) 
00415          || ( this->RecoverRun(fDetector,fRun,fSubRun) ) ){ 
00416           if( fRunStatus==RunStatus::kUnknown ){
00417             fRunStatus = RunStatus::kOK; 
00418           }
00419         }
00420         else{
00421           if( fRunStatus==RunStatus::kOK ){
00422             fRunStatus = RunStatus::kUnknown; 
00423           }
00424           fRunStatus |= RunStatus::kBad;
00425           if( !rowptr->GoodRunType() ) fRunStatus |= RunStatus::kBadRunType;
00426           if( !rowptr->GoodReadout() ) fRunStatus |= RunStatus::kBadReadout;
00427           if( rowptr->Short() ) fRunStatus |= RunStatus::kShort;
00428           if( rowptr->LowRate() ) fRunStatus |= RunStatus::kLowRate;
00429           if( rowptr->HighRate() ) fRunStatus |= RunStatus::kHighRate;
00430         }
00431       }
00432   
00433       MSG("RunQuality",Msg::kDebug) << "   returning result: " << endl; 
00434       MSG("RunQuality",Msg::kDebug) << "    run=" << fRun << "/" << fSubRun << endl;   
00435       MSG("RunQuality",Msg::kDebug) << "    status=" << fRunStatus << endl;
00436       MSG("RunQuality",Msg::kDebug) << "    isok=" << (fRunStatus&RunStatus::kOK) << endl;
00437       fRunStatusResult = fRunStatus;
00438     }
00439 
00440     return;
00441   }
00442 
00443   // Near Detector Data Quality
00444   // ==========================
00445   if( detector == Detector::kNear ){
00446     MSG("RunQuality",Msg::kDebug) << "   near detector: searching DBUNEARRUNQUALITY database... " << endl;
00447     MSG("RunQuality",Msg::kDebug) << "    using task: " << fDbiTaskNear << endl;    
00448 
00449     // return previous result
00450     if( fDetector==detector
00451      && fRun==run && fSubRun==subrun ){
00452       MSG("RunQuality",Msg::kDebug) << "   returning previous result: " << endl;
00453       MSG("RunQuality",Msg::kDebug) << "    run=" << fRun << "/" << fSubRun << endl;   
00454       MSG("RunQuality",Msg::kDebug) << "    status=" << fRunStatus << endl;
00455       MSG("RunQuality",Msg::kDebug) << "    isok=" << (fRunStatus&RunStatus::kOK) << endl;
00456       fRunStatusResult = fRunStatus;
00457     }
00458     
00459     // perform database query
00460     else{
00461       
00462       const char* sqltxt = Form("(AGGREGATENO=%d) and (TASK=%d) and (DETECTORMASK & %d) and (SIMMASK & %d)",run,fDbiTaskNear,Detector::kNear,SimFlag::kData);
00463       MSG("RunQuality",Msg::kVerbose) << "    new query: " << sqltxt << endl; 
00464       DbiSqlContext sqlcontext(sqltxt);
00465       nearquery.NewQuery(sqlcontext,fDbiTaskNear);
00466       MSG("RunQuality",Msg::kVerbose) << "    found " << nearquery.GetNumRows() << " entries for run " << run << endl;
00467       
00468       UInt_t index = DbuNearRunQuality::GetIndex(run,subrun);
00469       const DbuNearRunQuality* rowptr = nearquery.GetRowByIndex(index);
00470       MSG("RunQuality",Msg::kVerbose) << "    getting row by index: " << index << endl;
00471       if( rowptr ) MSG("RunQuality",Msg::kVerbose) << "    found entry for run " << run << "/" << subrun << endl;
00472       else MSG("RunQuality",Msg::kVerbose) << "    failed to find entry for run " << run << "/" << subrun << endl;
00473 
00474       fDetector = Detector::kNear;
00475       fRun = 0;
00476       fSubRun = 0;
00477       fStartTime = -1;
00478       fEndTime = -1;
00479       fRunStatus = RunStatus::kUnknown;
00480 
00481       if( rowptr ){
00482         MSG("RunQuality",Msg::kVerbose) << "     run=" << rowptr->GetRun() << "/" << rowptr->GetSubRun() << endl;
00483         MSG("RunQuality",Msg::kVerbose) << "     start=" << rowptr->GetStartTime() << endl;
00484         MSG("RunQuality",Msg::kVerbose) << "     end=" << rowptr->GetEndTime() << endl;
00485         MSG("RunQuality",Msg::kVerbose) << "     goodrun=" << rowptr->GoodRun(fDbiTaskNear) << endl;
00486 
00487         fRun = rowptr->GetRun(); fSubRun = rowptr->GetSubRun();
00488         if( fStartTime<0 || rowptr->GetStartTime().GetSec()<fStartTime ){
00489           fStartTime = rowptr->GetStartTime().GetSec(); }
00490         if( rowptr->GetEndTime().GetSec()>fEndTime ){ 
00491           fEndTime = rowptr->GetEndTime().GetSec(); }
00492 
00493         if( ( rowptr->GoodRun(fDbiTaskNear) 
00494            && !this->RejectRun(fDetector,fRun,fSubRun) )
00495          || ( this->RecoverRun(fDetector,fRun,fSubRun) ) ){ 
00496           if( fRunStatus==RunStatus::kUnknown ){
00497             fRunStatus = RunStatus::kOK; 
00498           }
00499         }
00500         else{
00501           if( fRunStatus==RunStatus::kOK ){
00502             fRunStatus = RunStatus::kUnknown; 
00503           }
00504           fRunStatus |= RunStatus::kBad;
00505           if( !rowptr->GoodRunType(fDbiTaskNear) ) fRunStatus |= RunStatus::kBadRunType;
00506           if( !rowptr->GoodReadout(fDbiTaskNear) ) fRunStatus |= RunStatus::kBadReadout;
00507           if( rowptr->Short(fDbiTaskNear) ) fRunStatus |= RunStatus::kShort;
00508           if( rowptr->LowRate(fDbiTaskNear) ) fRunStatus |= RunStatus::kLowRate;
00509           if( rowptr->HighRate(fDbiTaskNear) ) fRunStatus |= RunStatus::kHighRate;
00510           if( rowptr->LIRate(fDbiTaskNear) ) fRunStatus |= RunStatus::kLIRate;
00511           if( rowptr->ColdReadout(fDbiTaskNear) ) fRunStatus |= RunStatus::kColdReadout;
00512           if( rowptr->HotReadout(fDbiTaskNear) )fRunStatus |= RunStatus::kHotReadout;
00513           if( rowptr->BadSpillWindow(fDbiTaskNear) ) fRunStatus |= RunStatus::kBadSpillWindow;
00514           if( rowptr->BadReadoutErrors(fDbiTaskNear) ) fRunStatus |= RunStatus::kBadReadoutErrors;
00515           if( rowptr->HighADC(fDbiTaskNear) ) fRunStatus |= RunStatus::kHighADC;
00516         }
00517       }
00518 
00519       MSG("RunQuality",Msg::kDebug) << "   returning result:" << endl; 
00520       MSG("RunQuality",Msg::kDebug) << "    run=" << fRun << "/" << fSubRun << endl;   
00521       MSG("RunQuality",Msg::kDebug) << "    status=" << fRunStatus << endl;
00522       MSG("RunQuality",Msg::kDebug) << "    isok=" << (fRunStatus&RunStatus::kOK) << endl;
00523       fRunStatusResult = fRunStatus;
00524     }
00525 
00526     return;
00527   }
00528 
00529   return;
00530 }

void RunQualityFinder::QueryDB ( const VldContext context  )  [private]

Definition at line 186 of file RunQualityFinder.cxx.

References DbuNearRunQuality::BadReadoutErrors(), DbuNearRunQuality::BadSpillWindow(), DbuNearRunQuality::ColdReadout(), farquery, fDbiTaskNear, fDetector, fEndTime, fRun, fRunStatus, fRunStatusResult, fStartTime, fSubRun, VldContext::GetDetector(), DbuNearRunQuality::GetEndTime(), DbuFarRunQuality::GetEndTime(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRow(), DbuFarRunQuality::GetRun(), DbuNearRunQuality::GetRun(), VldTimeStamp::GetSec(), VldContext::GetSimFlag(), DbuFarRunQuality::GetStartTime(), DbuNearRunQuality::GetStartTime(), DataUtil::GetStartTime(), DbuNearRunQuality::GetSubRun(), DbuFarRunQuality::GetSubRun(), VldContext::GetTimeStamp(), DbuNearRunQuality::GoodReadout(), DbuFarRunQuality::GoodReadout(), DbuNearRunQuality::GoodRun(), DbuFarRunQuality::GoodRun(), DbuNearRunQuality::GoodRunType(), DbuFarRunQuality::GoodRunType(), DbuNearRunQuality::HighADC(), DbuNearRunQuality::HighRate(), DbuFarRunQuality::HighRate(), DbuNearRunQuality::HotReadout(), RunStatus::kBad, RunStatus::kBadReadout, RunStatus::kBadReadoutErrors, RunStatus::kBadRunType, RunStatus::kBadSpillWindow, RunStatus::kColdReadout, SimFlag::kData, Msg::kDebug, Detector::kFar, RunStatus::kHighADC, RunStatus::kHighRate, RunStatus::kHotReadout, RunStatus::kLIRate, RunStatus::kLowRate, Detector::kNear, RunStatus::kOK, RunStatus::kShort, RunStatus::kUnknown, Msg::kVerbose, DbuNearRunQuality::LIRate(), DbuFarRunQuality::LowRate(), DbuNearRunQuality::LowRate(), MSG, nearquery, DbiResultPtr< T >::NewQuery(), RecoverRun(), RejectRun(), DbuNearRunQuality::Short(), and DbuFarRunQuality::Short().

Referenced by BadReadoutErrorsLegacy(), GetRun(), GetStatus(), GetSubRun(), and IsOK().

00187 {
00188   MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::QueryDB(detector=" << context.GetDetector() << ",time=" << context.GetTimeStamp().GetSec() << ") *** " << endl;
00189 
00190   // Result of DB Query
00191   // ==================
00192   fRunStatusResult = RunStatus::kUnknown;
00193 
00194   // If it's not real data, return 'OK'
00195   // ==================================
00196   if( context.GetSimFlag() != SimFlag::kData ){
00197     fRunStatusResult = RunStatus::kOK;
00198     return;
00199   }
00200 
00201   // Far Detector Data Quality
00202   // =========================
00203   if( context.GetDetector() == Detector::kFar ){
00204     MSG("RunQuality",Msg::kDebug) << "   far detector: searching DBUFARRUNQUALITY database... " << endl;
00205     MSG("RunQuality",Msg::kDebug) << "    using task: 0 " << endl;
00206 
00207     // return previous result
00208     if( fDetector==Detector::kFar
00209      && context.GetTimeStamp().GetSec()>=fStartTime
00210      && context.GetTimeStamp().GetSec()<=fEndTime ){
00211       MSG("RunQuality",Msg::kDebug) << "   returning previous result: " << endl;
00212       MSG("RunQuality",Msg::kDebug) << "    run=" << fRun << "/" << fSubRun << endl;   
00213       MSG("RunQuality",Msg::kDebug) << "    status=" << fRunStatus << endl;
00214       MSG("RunQuality",Msg::kDebug) << "    isok=" << (fRunStatus&RunStatus::kOK) << endl;
00215       fRunStatusResult = fRunStatus;
00216     }
00217 
00218     // perform database query
00219     else{
00220       farquery.NewQuery(context,0);
00221 
00222       MSG("RunQuality",Msg::kVerbose) << "    found " << farquery.GetNumRows() << " entries " << endl;
00223 
00224       fDetector = Detector::kFar;
00225       fRun = 0;
00226       fSubRun = 0;
00227       fStartTime = -1;
00228       fEndTime = -1;
00229       fRunStatus = RunStatus::kUnknown;
00230 
00231       for( unsigned int i=0; i<farquery.GetNumRows(); i++ ){
00232         const DbuFarRunQuality* rowptr = farquery.GetRow(i);
00233         MSG("RunQuality",Msg::kVerbose) << "     run=" << rowptr->GetRun() << "/" << rowptr->GetSubRun() << endl;
00234         MSG("RunQuality",Msg::kVerbose) << "     start=" << rowptr->GetStartTime() << endl;
00235         MSG("RunQuality",Msg::kVerbose) << "     end=" << rowptr->GetEndTime() << endl;
00236         MSG("RunQuality",Msg::kVerbose) << "     goodrun=" << rowptr->GoodRun() << endl;
00237 
00238         fRun = rowptr->GetRun(); fSubRun = rowptr->GetSubRun();
00239         if( fStartTime<0 || rowptr->GetStartTime().GetSec()<fStartTime ){
00240           fStartTime = rowptr->GetStartTime().GetSec(); }
00241         if( rowptr->GetEndTime().GetSec()>fEndTime ){ 
00242           fEndTime = rowptr->GetEndTime().GetSec(); }
00243 
00244         if( ( rowptr->GoodRun()  
00245            && !this->RejectRun(fDetector,fRun,fSubRun) ) 
00246          || ( this->RecoverRun(fDetector,fRun,fSubRun) ) ){ 
00247           if( fRunStatus==RunStatus::kUnknown ){
00248             fRunStatus = RunStatus::kOK; 
00249           }
00250         }
00251         else{
00252           if( fRunStatus==RunStatus::kOK ){
00253             fRunStatus = RunStatus::kUnknown; 
00254           }
00255           fRunStatus |= RunStatus::kBad;
00256           if( !rowptr->GoodRunType() ) fRunStatus |= RunStatus::kBadRunType;
00257           if( !rowptr->GoodReadout() ) fRunStatus |= RunStatus::kBadReadout;
00258           if( rowptr->Short() ) fRunStatus |= RunStatus::kShort;
00259           if( rowptr->LowRate() ) fRunStatus |= RunStatus::kLowRate;
00260           if( rowptr->HighRate() ) fRunStatus |= RunStatus::kHighRate;
00261         }
00262       }
00263 
00264       MSG("RunQuality",Msg::kDebug) << "   returning result:" << endl; 
00265       MSG("RunQuality",Msg::kDebug) << "    run=" << fRun << "/" << fSubRun << endl;   
00266       MSG("RunQuality",Msg::kDebug) << "    status=" << fRunStatus << endl;
00267       MSG("RunQuality",Msg::kDebug) << "    isok=" << (fRunStatus&RunStatus::kOK) << endl;
00268       fRunStatusResult = fRunStatus;
00269     }
00270 
00271     return;
00272   }
00273 
00274   // Near Detector Data Quality
00275   // ==========================
00276   if( context.GetDetector() == Detector::kNear ){
00277     MSG("RunQuality",Msg::kDebug) << "   near detector: searching DBUNEARRUNQUALITY database... " << endl;
00278     MSG("RunQuality",Msg::kDebug) << "    using task: " << fDbiTaskNear << endl;
00279 
00280     // return previous result
00281     if( fDetector==Detector::kNear
00282       && context.GetTimeStamp().GetSec()>=fStartTime
00283       && context.GetTimeStamp().GetSec()<fEndTime ){
00284       MSG("RunQuality",Msg::kDebug) << "   returning previous result: " << endl;
00285       MSG("RunQuality",Msg::kDebug) << "    run=" << fRun << "/" << fSubRun << endl;   
00286       MSG("RunQuality",Msg::kDebug) << "    status=" << fRunStatus << endl;
00287       MSG("RunQuality",Msg::kDebug) << "    isok=" << (fRunStatus&RunStatus::kOK) << endl;
00288       fRunStatusResult = fRunStatus;
00289     }
00290     
00291     // perform database query
00292     else{
00293       nearquery.NewQuery(context,fDbiTaskNear);
00294       
00295       MSG("RunQuality",Msg::kVerbose) << "    found " << nearquery.GetNumRows() << " entries " << endl;
00296       
00297       fDetector = Detector::kNear;
00298       fRun = 0;
00299       fSubRun = 0;
00300       fStartTime = -1;
00301       fEndTime = -1;
00302       fRunStatus = RunStatus::kUnknown;
00303       
00304       for( unsigned int i=0; i<nearquery.GetNumRows(); i++ ){
00305         const DbuNearRunQuality* rowptr = nearquery.GetRow(i);
00306         MSG("RunQuality",Msg::kVerbose) << "     run=" << rowptr->GetRun() << "/" << rowptr->GetSubRun() << endl;
00307         MSG("RunQuality",Msg::kVerbose) << "     start=" << rowptr->GetStartTime() << endl;
00308         MSG("RunQuality",Msg::kVerbose) << "     end=" << rowptr->GetEndTime() << endl;
00309         MSG("RunQuality",Msg::kVerbose) << "     goodrun=" << rowptr->GoodRun(fDbiTaskNear) << endl;
00310         
00311         fRun = rowptr->GetRun(); fSubRun = rowptr->GetSubRun();
00312         if( fStartTime<0 || rowptr->GetStartTime().GetSec()<fStartTime ){
00313           fStartTime = rowptr->GetStartTime().GetSec(); }
00314         if( rowptr->GetEndTime().GetSec()>fEndTime ){ 
00315           fEndTime = rowptr->GetEndTime().GetSec(); }
00316         
00317         if( ( rowptr->GoodRun(fDbiTaskNear)  
00318            && !this->RejectRun(fDetector,fRun,fSubRun) ) 
00319          || ( this->RecoverRun(fDetector,fRun,fSubRun) ) ){ 
00320           if( fRunStatus==RunStatus::kUnknown ){
00321             fRunStatus = RunStatus::kOK; 
00322           }
00323         }
00324         else{
00325           if( fRunStatus==RunStatus::kOK ){
00326             fRunStatus = RunStatus::kUnknown; 
00327           }
00328           fRunStatus |= RunStatus::kBad;
00329           if( !rowptr->GoodRunType(fDbiTaskNear) ) fRunStatus |= RunStatus::kBadRunType;
00330           if( !rowptr->GoodReadout(fDbiTaskNear) ) fRunStatus |= RunStatus::kBadReadout;
00331           if( rowptr->Short(fDbiTaskNear) ) fRunStatus |= RunStatus::kShort;
00332           if( rowptr->LowRate(fDbiTaskNear) ) fRunStatus |= RunStatus::kLowRate;
00333           if( rowptr->HighRate(fDbiTaskNear) ) fRunStatus |= RunStatus::kHighRate;
00334           if( rowptr->LIRate(fDbiTaskNear) ) fRunStatus |= RunStatus::kLIRate;
00335           if( rowptr->ColdReadout(fDbiTaskNear) ) fRunStatus |= RunStatus::kColdReadout;
00336           if( rowptr->HotReadout(fDbiTaskNear) )fRunStatus |= RunStatus::kHotReadout;
00337           if( rowptr->BadSpillWindow(fDbiTaskNear) ) fRunStatus |= RunStatus::kBadSpillWindow;
00338           if( rowptr->BadReadoutErrors(fDbiTaskNear) ) fRunStatus |= RunStatus::kBadReadoutErrors;
00339           if( rowptr->HighADC(fDbiTaskNear) ) fRunStatus |= RunStatus::kHighADC;
00340         }
00341       }
00342 
00343       MSG("RunQuality",Msg::kDebug) << "   returning result: " << endl; 
00344       MSG("RunQuality",Msg::kDebug) << "    run=" << fRun << "/" << fSubRun << endl;   
00345       MSG("RunQuality",Msg::kDebug) << "    status=" << fRunStatus << endl;
00346       MSG("RunQuality",Msg::kDebug) << "    isok=" << (fRunStatus&RunStatus::kOK) << endl;
00347       fRunStatusResult = fRunStatus;    
00348     } 
00349     return;
00350   }
00351 
00352   return;
00353 }

Bool_t RunQualityFinder::RecoverRun ( const UInt_t  detector,
const UInt_t  run,
const UInt_t  subrun 
) [private]

Definition at line 565 of file RunQualityFinder.cxx.

References fOverrideDB, Msg::kDebug, Detector::kFar, Detector::kNear, and MSG.

Referenced by QueryDB().

00566 {  
00567   // Override database
00568   if( fOverrideDB ){
00569     MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::RecoverRun(detector=" << detector << ",run=" << run << ",subrun=" << subrun<< ") *** " << endl;
00570     Bool_t recoverrun = 0;
00571 
00572     // Far Detector Data Quality
00573     if( detector == Detector::kFar ){
00574       
00575     }
00576 
00577     // Near Detector Data Quality
00578     if( detector == Detector::kNear ){
00579 
00580     }
00581 
00582     MSG("RunQuality",Msg::kDebug) << "     recoverrun=" << recoverrun << endl;
00583     return recoverrun;
00584   }
00585 
00586   return 0;
00587 }

Bool_t RunQualityFinder::RejectRun ( const UInt_t  detector,
const UInt_t  run,
const UInt_t  subrun 
) [private]

Definition at line 532 of file RunQualityFinder.cxx.

References fOverrideDB, Msg::kDebug, Detector::kFar, Detector::kNear, and MSG.

Referenced by QueryDB().

00533 {  
00534   // Override database
00535   if( fOverrideDB ){
00536     MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::RejectRun(detector=" << detector << ",run=" << run << ",subrun=" << subrun<< ") *** " << endl;
00537     Bool_t rejectrun = 0;
00538 
00539     // Far Detector Data Quality
00540     if( detector == Detector::kFar ){
00541       
00542       // added 23/07/10
00543       // bad for atmosperic neutrino analysis
00544       if( run>=18884 && run<=18896 ) rejectrun = 1;
00545 
00546     }
00547 
00548     // Near Detector Data Quality
00549     if( detector == Detector::kNear ){
00550 
00551       // added 05/01/10
00552       // hot channel in November 2007
00553       // see minos-doc-6722 (Phil R.)
00554       if( run==12947 || run==12950 ) rejectrun = 1;
00555 
00556     }
00557 
00558     MSG("RunQuality",Msg::kDebug) << "     rejectrun=" << rejectrun << endl;
00559     return rejectrun;
00560   }
00561 
00562   return 0;
00563 }

void RunQualityFinder::Reset ( void   ) 

Definition at line 173 of file RunQualityFinder.cxx.

References fDetector, fEndTime, fRun, fStartTime, fSubRun, Msg::kDebug, Detector::kUnknown, and MSG.

Referenced by SetOverrideDB(), and SetTask().

00174 {
00175   MSG("RunQuality",Msg::kDebug) << " *** RunQualityFinder::Reset() *** " << endl;
00176 
00177   fDetector = Detector::kUnknown;
00178   fRun = 0;
00179   fSubRun = 0;
00180   fStartTime = -1;
00181   fEndTime = -1;
00182 
00183   return;
00184 }

void RunQualityFinder::SetOverrideDB ( Bool_t  override = 1  ) 

Definition at line 136 of file RunQualityFinder.cxx.

References fOverrideDB, and Reset().

Referenced by OverrideDB().

00137 { 
00138   fOverrideDB = override; 
00139 
00140   this->Reset();
00141 }

void RunQualityFinder::SetTask ( Detector::Detector_t  detector,
Int_t  itask 
)

Definition at line 148 of file RunQualityFinder.cxx.

References Detector::kFar, Detector::kNear, Reset(), SetTaskFar(), and SetTaskNear().

Referenced by DbiTask().

00149 {
00150   switch(detector){
00151     case Detector::kFar: 
00152       this->SetTaskFar(0);                 // task 0 in far detector
00153       break;
00154     case Detector::kNear: 
00155       if( itask<=0 ) this->SetTaskNear(0); // task 0 in near detector
00156       else this->SetTaskNear(1);           // task 1 in near detector
00157       break;
00158     default: break;
00159   }
00160 
00161   this->Reset();
00162 }

void RunQualityFinder::SetTaskFar ( Int_t  itask  )  [inline, private]

Definition at line 49 of file RunQualityFinder.h.

References fDbiTaskFar.

Referenced by SetTask().

00049 { fDbiTaskFar = itask; }

void RunQualityFinder::SetTaskNear ( Int_t  itask  )  [inline, private]

Definition at line 48 of file RunQualityFinder.h.

References fDbiTaskNear.

Referenced by SetTask().

00048 { fDbiTaskNear = itask; }


Friends And Related Function Documentation

friend struct Cleaner [friend]

Definition at line 84 of file RunQualityFinder.h.


Member Data Documentation

Definition at line 58 of file RunQualityFinder.h.

Referenced by QueryDB().

Definition at line 67 of file RunQualityFinder.h.

Referenced by GetTask(), RunQualityFinder(), and SetTaskFar().

Int_t RunQualityFinder::fDetector [private]

Definition at line 61 of file RunQualityFinder.h.

Referenced by QueryDB(), Reset(), and RunQualityFinder().

Int_t RunQualityFinder::fEndTime [private]

Definition at line 63 of file RunQualityFinder.h.

Referenced by QueryDB(), Reset(), and RunQualityFinder().

Definition at line 85 of file RunQualityFinder.h.

Referenced by RunQualityFinder::Cleaner::~Cleaner().

UInt_t RunQualityFinder::fRun [private]

Definition at line 64 of file RunQualityFinder.h.

Referenced by GetRun(), QueryDB(), Reset(), and RunQualityFinder().

Definition at line 71 of file RunQualityFinder.h.

Referenced by QueryDB(), and RunQualityFinder().

Definition at line 72 of file RunQualityFinder.h.

Referenced by GetStatus(), IsOK(), QueryDB(), and RunQualityFinder().

Definition at line 62 of file RunQualityFinder.h.

Referenced by QueryDB(), Reset(), and RunQualityFinder().

UInt_t RunQualityFinder::fSubRun [private]

Definition at line 65 of file RunQualityFinder.h.

Referenced by GetSubRun(), QueryDB(), Reset(), and RunQualityFinder().

Definition at line 59 of file RunQualityFinder.h.

Referenced by BadReadoutErrorsLegacy(), and QueryDB().


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

Generated on 24 Apr 2017 for loon by  doxygen 1.6.1