DataQualityFilter Class Reference

#include <DataQualityFilter.h>

Inheritance diagram for DataQualityFilter:
JobCModule

List of all members.

Public Member Functions

 DataQualityFilter ()
 ~DataQualityFilter ()
void BeginJob ()
JobCResult Ana (const MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)
void HandleCommand (JobCommand *command)
void EndJob ()

Private Member Functions

void WriteOutResults ()

Private Attributes

DataQualityInterfacefDQhandle
Int_t fTime
Int_t fCurrentTime
Int_t fLiveTime
Int_t fFilter
Int_t fSpillStatus
Int_t fBeamStatus
Int_t fHvStatus
Int_t fCoilStatus
Int_t fGpsStatus
Int_t fDetectorStatus
Int_t fBeamType
Double_t fProtonsOnTarget
Int_t fFilterOnOff
Int_t fFilterBadBeam
Int_t fFilterBadDetector
Int_t fWriteOutResults
Int_t fUseLookup
TString fFilterFileName
TFile * fFilterFile
TTree * fFilterTree

Detailed Description

Definition at line 13 of file DataQualityFilter.h.


Constructor & Destructor Documentation

DataQualityFilter::DataQualityFilter (  ) 

Definition at line 22 of file DataQualityFilter.cxx.

References Msg::kDebug, and MSG.

00022                                      :
00023   fTime(0),
00024   fCurrentTime(0),
00025   fFilter(0),
00026   fSpillStatus(-1),
00027   fBeamStatus(-1),
00028   fHvStatus(-1),
00029   fCoilStatus(-1),
00030   fGpsStatus(-1),
00031   fDetectorStatus(-1),
00032   fFilterOnOff(0),
00033   fFilterBadBeam(0),
00034   fFilterBadDetector(0),
00035   fWriteOutResults(0),
00036   fUseLookup(0),
00037   fFilterFileName("dataqualityfilter.root"),
00038   fFilterFile(0),
00039   fFilterTree(0)
00040 {
00041   MSG("DataQualityFilter",Msg::kDebug) << " *** DataQualityFilter::DataQualityFilter() *** " << endl;
00042 
00043   fDQhandle = new DataQualityInterface();
00044 }

DataQualityFilter::~DataQualityFilter (  ) 

Definition at line 46 of file DataQualityFilter.cxx.

References fDQhandle, Msg::kDebug, and MSG.

00047 {
00048   MSG("DataQualityFilter",Msg::kDebug) << " *** DataQualityFilter::~DataQualityFilter() *** " << endl;
00049 
00050   if( fDQhandle ) delete fDQhandle;
00051 }


Member Function Documentation

JobCResult DataQualityFilter::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 59 of file DataQualityFilter.cxx.

References fBeamStatus, fBeamType, fCoilStatus, fCurrentTime, fDetectorStatus, fDQhandle, fFilter, fFilterBadBeam, fFilterBadDetector, fFilterOnOff, fGpsStatus, fHvStatus, fLiveTime, fProtonsOnTarget, fSpillStatus, fTime, fUseLookup, fWriteOutResults, DataQualityInterface::GetBeamStatus(), DataQualityInterface::GetBeamType(), DataQualityInterface::GetCoilStatus(), DataQualityInterface::GetDetectorStatus(), MomNavigator::GetFragment(), DataQualityInterface::GetGpsStatus(), DataQualityInterface::GetHvStatus(), DataQualityInterface::GetProtonsOnTarget(), VldTimeStamp::GetSec(), DataQualityInterface::GetSpillStatus(), VldContext::GetTimeStamp(), RecMinos::GetVldContext(), JobCResult::kAOK, Msg::kDebug, JobCResult::kFailed, Msg::kInfo, JobCResult::kPassed, DataQualityInterface::LookupCoilStatus(), DataQualityInterface::LookupDetectorStatus(), DataQualityInterface::LookupHvStatus(), MSG, and WriteOutResults().

00060 {
00061   MSG("DataQualityFilter",Msg::kInfo) << " *** DataQualityFilter::Ana(...) *** " << endl;
00062 
00063   fSpillStatus=-1;
00064   fBeamStatus=-1;
00065   fHvStatus=-1;
00066   fCoilStatus=-1;
00067   fGpsStatus=-1;
00068   fDetectorStatus=-1;
00069   fBeamType=-1;
00070   fProtonsOnTarget=0.0;
00071   fFilter=0;
00072 
00073   JobCResult result(JobCResult::kAOK);
00074   
00075   // Get RawRecord
00076   // =============
00077   RawRecord* rawrec = dynamic_cast<RawRecord*>(mom->GetFragment("RawRecord"));
00078   if( rawrec ){ 
00079     MSG("DataQualityFilter",Msg::kDebug) << " Found RawRecord " << endl;
00080     VldContext* vldc = (VldContext*)(rawrec->GetVldContext());
00081     fCurrentTime=vldc->GetTimeStamp().GetSec();
00082     fSpillStatus=fDQhandle->GetSpillStatus(*vldc);
00083     fBeamStatus=fDQhandle->GetBeamStatus(*vldc);
00084     fBeamType=fDQhandle->GetBeamType(*vldc);
00085     fProtonsOnTarget=fDQhandle->GetProtonsOnTarget(*vldc);
00086     if( fUseLookup ){
00087       fDetectorStatus=fDQhandle->LookupDetectorStatus(*vldc);
00088       fHvStatus=fDQhandle->LookupHvStatus(*vldc);
00089       fCoilStatus=fDQhandle->LookupCoilStatus(*vldc);
00090       fGpsStatus=1;
00091     }
00092     else{
00093       fDetectorStatus=fDQhandle->GetDetectorStatus(*vldc);
00094       fHvStatus=fDQhandle->GetHvStatus(*vldc);
00095       fCoilStatus=fDQhandle->GetCoilStatus(*vldc);
00096       fGpsStatus=fDQhandle->GetGpsStatus(*vldc);
00097     }
00098   }
00099 
00100   // Get CandRecord
00101   // ==============
00102   CandRecord* candrec = dynamic_cast<CandRecord*>(mom->GetFragment("CandRecord"));
00103   if( candrec ){
00104     MSG("DataQualityFilter",Msg::kDebug) << " Found CandRecord " << endl;
00105     
00106   }
00107 
00108   // Set Filter
00109   // ==========
00110   // check whether filters are on/off then pass/fail event
00111   if( ( fFilterBadBeam==0     || fBeamStatus==1     ) 
00112    && ( fFilterBadDetector==0 || fDetectorStatus==1 ) ){
00113     fFilter=1;
00114   }
00115   
00116   // Write out Results
00117   // =================
00118   if( fCurrentTime!=fTime ){
00119     fLiveTime=1;
00120     if( fTime>0 
00121      && fCurrentTime-fTime>1 ) fLiveTime=fCurrentTime-fTime;
00122     fTime=fCurrentTime;
00123     if( fWriteOutResults ) this->WriteOutResults();
00124   }
00125 
00126   MSG("DataQualityFilter",Msg::kDebug) << " Time=" << fTime << endl;
00127   MSG("DataQualityFilter",Msg::kDebug) << " BeamType=" << fBeamType << endl;
00128   MSG("DataQualityFilter",Msg::kDebug) << " SpillStatus=" << fSpillStatus << endl;
00129   MSG("DataQualityFilter",Msg::kDebug) << " ProtonsOnTarget=" << fProtonsOnTarget << endl;
00130   MSG("DataQualityFilter",Msg::kDebug) << " DetectorStatus=" << fDetectorStatus << " [HV=" << fHvStatus << ", coil=" << fCoilStatus << ", gps=" << fGpsStatus << "]" << endl;   
00131   MSG("DataQualityFilter",Msg::kDebug) << " Beam=[" << fFilterBadBeam << "|" << fBeamStatus << "] Detector=[" << fFilterBadDetector << "|" << fDetectorStatus << "]" << endl;
00132   MSG("DataQualityFilter",Msg::kDebug) << " Filter=[" << fFilterOnOff << "|" << fFilter << "]" << endl;
00133   
00134   // Apply Filter
00135   // ============
00136   if( fFilterOnOff ){
00137     if( fFilter ){
00138       MSG("DataQualityFilter",Msg::kInfo) << " *** PASSED FILTER *** " << endl;
00139       return JobCResult::kPassed;
00140     }
00141     else{
00142       MSG("DataQualityFilter",Msg::kInfo) << " *** FAILED FILTER *** " << endl;
00143       return JobCResult::kFailed;
00144     }
00145   }
00146 
00147   return result;
00148 
00149 }

void DataQualityFilter::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 53 of file DataQualityFilter.cxx.

References Msg::kInfo, and MSG.

00054 {
00055   MSG("DataQualityFilter",Msg::kInfo) << " *** DataQualityFilter::BeginJob(...) *** " << endl;
00056 
00057 }

void DataQualityFilter::Config ( const Registry r  )  [virtual]

Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables.

Reimplemented from JobCModule.

Definition at line 169 of file DataQualityFilter.cxx.

References fFilterBadBeam, fFilterBadDetector, fFilterFileName, fFilterOnOff, fUseLookup, fWriteOutResults, Registry::Get(), Msg::kDebug, and MSG.

00170 {
00171   MSG("DataQualityFilter",Msg::kDebug) << " *** DataQualityFilter::Config() *** " << endl;
00172 
00173   Int_t tmpint;
00174   const char* tmpchar = 0;
00175           
00176   if(r.Get("FilterOnOff",tmpint)) fFilterOnOff = tmpint;        
00177   if(r.Get("FilterBadBeam",tmpint)) fFilterBadBeam = tmpint;
00178   if(r.Get("FilterBadDetector",tmpint)) fFilterBadDetector = tmpint;
00179   if(r.Get("WriteOutResults",tmpint)) fWriteOutResults = tmpint;
00180   if(r.Get("UseLookupTable",tmpint)) fUseLookup = tmpint;
00181   if(r.Get("OutputFile",tmpchar)) fFilterFileName=tmpchar;
00182 
00183   MSG("DataQualityFilter",Msg::kDebug)
00184     << "  configuration: " << endl
00185     << "     FilterOnOff=" << fFilterOnOff << endl
00186     << "     FilterBadBeam=" << fFilterBadBeam << endl
00187     << "     FilterBadDetector=" << fFilterBadDetector << endl
00188     << "     WriteOutResults=" << fWriteOutResults << endl
00189     << "     UseLookupTable=" << fUseLookup << endl
00190     << "     OutputFile=" << fFilterFileName << endl;
00191 
00192   return;
00193 }

const Registry & DataQualityFilter::DefaultConfig ( void   )  const [virtual]

Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like:

const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; }

Reimplemented from JobCModule.

Definition at line 151 of file DataQualityFilter.cxx.

References fFilterBadBeam, fFilterBadDetector, fFilterFileName, fFilterOnOff, fUseLookup, fWriteOutResults, Msg::kDebug, Registry::LockValues(), MSG, Registry::Set(), and Registry::UnLockValues().

00152 {
00153   MSG("DataQualityFilter",Msg::kDebug) << " *** DataQualityFilter::DefaultConfig() *** " << endl;
00154  
00155   static Registry r;
00156   r.SetName("DataQualityFilter.config.default");
00157   r.UnLockValues();
00158   r.Set("FilterOnOff",fFilterOnOff);
00159   r.Set("FilterBadBeam",fFilterBadBeam);
00160   r.Set("FilterBadDetector",fFilterBadDetector);
00161   r.Set("WriteOutResults",fWriteOutResults);
00162   r.Set("UseLookupTable",fUseLookup);
00163   r.Set("OutputFile",fFilterFileName);
00164   r.LockValues();
00165                     
00166   return r;
00167 }

void DataQualityFilter::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 204 of file DataQualityFilter.cxx.

References fFilterFile, fFilterTree, Msg::kInfo, and MSG.

00205 {
00206   MSG("DataQualityFilter",Msg::kInfo) << " *** DataQualityFilter::EndJob() *** " << endl;                                                                               
00207   if(fFilterFile){
00208     MSG("DataQualityFilter",Msg::kInfo) << " *** saving info to file ... " << endl;
00209     TDirectory* tmpd = gDirectory;
00210     fFilterFile->cd();
00211     fFilterTree->Write();
00212     fFilterFile->Close();
00213     gDirectory = tmpd;
00214     MSG("DataQualityFilter",Msg::kInfo) << "      ... info saved to file *** " << endl;
00215   }
00216 }

void DataQualityFilter::HandleCommand ( JobCommand command  )  [virtual]

Implement to handle a JobCommand

Reimplemented from JobCModule.

Definition at line 195 of file DataQualityFilter.cxx.

References JobCommand::PopCmd(), and JobCommand::PopOpt().

00196 {
00197   TString cmd = command->PopCmd();
00198   if(cmd=="Set"){
00199     TString opt = command->PopOpt();
00200                                                                                     
00201   }
00202 }

void DataQualityFilter::WriteOutResults (  )  [private]

Definition at line 218 of file DataQualityFilter.cxx.

References fBeamStatus, fBeamType, fCoilStatus, fDetectorStatus, fFilter, fFilterBadBeam, fFilterBadDetector, fFilterFile, fFilterFileName, fFilterOnOff, fFilterTree, fGpsStatus, fHvStatus, fLiveTime, fProtonsOnTarget, fSpillStatus, fTime, Msg::kDebug, and MSG.

Referenced by Ana().

00219 {
00220   MSG("DataQualityFilter",Msg::kDebug) << " *** DataQualityFilter::WriteOutResults() *** " << endl; 
00221 
00222   if(!fFilterFile){
00223     TDirectory* tmpd = gDirectory;
00224     fFilterFile = new TFile(fFilterFileName.Data(),"RECREATE");
00225     fFilterTree = new TTree("DataQualityFilter","DataQualityFilter");
00226     fFilterTree->SetAutoSave(300);
00227     fFilterTree->Branch("Time",&fTime,"Time/I");
00228     fFilterTree->Branch("BeamType",&fBeamType,"BeamType/I");
00229     fFilterTree->Branch("BeamStatus",&fBeamStatus,"BeamStatus/I");
00230     fFilterTree->Branch("SpillStatus",&fSpillStatus,"SpillStatus/I");
00231     fFilterTree->Branch("HvStatus",&fHvStatus,"HvStatus/I");
00232     fFilterTree->Branch("CoilStatus",&fCoilStatus,"CoilStatus/I");
00233     fFilterTree->Branch("GpsStatus",&fGpsStatus,"GpsStatus/I");
00234     fFilterTree->Branch("DetectorStatus",&fDetectorStatus,"DetectorStatus/I");
00235     fFilterTree->Branch("LiveTime",&fLiveTime,"LiveTime/I");
00236     fFilterTree->Branch("ProtonsOnTarget",&fProtonsOnTarget,"ProtonsOnTarget/D");
00237     fFilterTree->Branch("FilterOnOff",&fFilterOnOff,"FilterOnOff/I");
00238     fFilterTree->Branch("FilterBadBeam",&fFilterBadBeam,"FilterBadBeam/I");
00239     fFilterTree->Branch("FilterBadDetector",&fFilterBadDetector,"FilterDetector/I");
00240     fFilterTree->Branch("Filter",&fFilter,"Filter/I");
00241     gDirectory = tmpd;
00242   }
00243 
00244   if(fFilterFile){
00245     TDirectory* tmpd = gDirectory;
00246     fFilterFile->cd();
00247     fFilterTree->Fill();
00248     gDirectory = tmpd;
00249   }
00250 }


Member Data Documentation

Definition at line 34 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Definition at line 39 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Definition at line 36 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Definition at line 30 of file DataQualityFilter.h.

Referenced by Ana().

Definition at line 38 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Definition at line 27 of file DataQualityFilter.h.

Referenced by Ana(), and ~DataQualityFilter().

Int_t DataQualityFilter::fFilter [private]

Definition at line 32 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Definition at line 43 of file DataQualityFilter.h.

Referenced by Ana(), Config(), DefaultConfig(), and WriteOutResults().

Definition at line 44 of file DataQualityFilter.h.

Referenced by Ana(), Config(), DefaultConfig(), and WriteOutResults().

Definition at line 49 of file DataQualityFilter.h.

Referenced by EndJob(), and WriteOutResults().

Definition at line 48 of file DataQualityFilter.h.

Referenced by Config(), DefaultConfig(), and WriteOutResults().

Definition at line 42 of file DataQualityFilter.h.

Referenced by Ana(), Config(), DefaultConfig(), and WriteOutResults().

Definition at line 50 of file DataQualityFilter.h.

Referenced by EndJob(), and WriteOutResults().

Definition at line 37 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Definition at line 35 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Definition at line 31 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Definition at line 40 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Definition at line 33 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Int_t DataQualityFilter::fTime [private]

Definition at line 29 of file DataQualityFilter.h.

Referenced by Ana(), and WriteOutResults().

Definition at line 46 of file DataQualityFilter.h.

Referenced by Ana(), Config(), and DefaultConfig().

Definition at line 45 of file DataQualityFilter.h.

Referenced by Ana(), Config(), and DefaultConfig().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1