OltDataIntegrity Class Reference

#include <OltDataIntegrity.h>

Inheritance diagram for OltDataIntegrity:
JobCModule

List of all members.

Public Member Functions

 OltDataIntegrity ()
 ~OltDataIntegrity ()
JobCResult Reco (MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)

Private Attributes

int fRecord
bool fDump
int fNumDump
bool fDoTree
int fStartTF
TTree * fTree
TFile * fFile
int fTimeframe
int fRun
int fSubRun
int fCheckPeriod
float fTBThresh
int fTimeBlockHits [3][41]
std::string fFileName

Detailed Description

Definition at line 26 of file OltDataIntegrity.h.


Constructor & Destructor Documentation

OltDataIntegrity::OltDataIntegrity (  ) 

Definition at line 58 of file OltDataIntegrity.cxx.

00059 {
00060   fRecord = 0;
00061 }

OltDataIntegrity::~OltDataIntegrity (  ) 

Definition at line 63 of file OltDataIntegrity.cxx.

References fFile, and fTree.

00064 {
00065   TDirectory *save = gDirectory;
00066   fFile->cd();
00067   fTree->Write();
00068   fFile->Close();
00069   save->cd();
00070 }


Member Function Documentation

void OltDataIntegrity::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 175 of file OltDataIntegrity.cxx.

References fCheckPeriod, fDoTree, fDump, fFile, fFileName, fNumDump, fStartTF, fTBThresh, fTree, and Registry::Get().

00176 {
00177   int   tmpb;
00178   cout<<"Teapots\n";
00179   cout<<r<<endl;
00180   if (r.Get("DumpData",tmpb)) { cout<<"Hello "<<tmpb<<endl;fDump = bool(tmpb); }  
00181   if (r.Get("DoTree",tmpb)) fDoTree = bool(tmpb);
00182   if (r.Get("StartTF",tmpb)) fStartTF = tmpb;
00183   if (r.Get("NumDump",tmpb)) fNumDump = tmpb;
00184 
00185   const char *s;
00186   if (r.Get("OutFile",s)) fFileName = std::string(s);
00187    TDirectory *save = gDirectory;
00188   fFile = new TFile(fFileName.c_str(),"RECREATE");
00189   fTree = new TTree("ditree","Data Integrity Tree");
00190   save->cd();
00191 
00192   double f;
00193   if (r.Get("CheckPeriod",tmpb)) fCheckPeriod = tmpb;
00194  if (r.Get("TBThresh",f)) fTBThresh = f;
00195 }

const Registry & OltDataIntegrity::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 149 of file OltDataIntegrity.cxx.

References JobCModule::GetName(), Registry::LockValues(), Registry::Set(), and Registry::UnLockValues().

00150 {
00151 
00152   static Registry r; // Default configuration for module
00153 
00154 
00155   std::string name = this->JobCModule::GetName();
00156   name += ".config.default";
00157   r.SetName(name.c_str());
00158 
00159   // Set values in configuration
00160   r.UnLockValues();
00161   r.Set("DumpData", true);
00162   r.Set("NumDump",10);
00163   r.Set("DoTree", false);
00164   r.Set("StartTF",0);
00165   r.Set("OutFile","di.root");
00166   r.Set("CheckPeriod",10);
00167   r.Set("TBThresh",0.01);
00168   r.LockValues();
00169 
00170   return r;
00171 }

JobCResult OltDataIntegrity::Reco ( MomNavigator mom  )  [virtual]

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 72 of file OltDataIntegrity.cxx.

References fCheckPeriod, MomNavigator::FragmentIter(), fRecord, fRun, fSubRun, fTBThresh, fTimeBlockHits, fTimeframe, RawDataBlock::GetBlockId(), RawDigit::GetChannel(), RawChannelId::GetCrate(), RawDigitDataBlock::GetDatumIter(), RawDigit::GetErrorCode(), RawRecord::GetRawBlockIter(), RawSnarlHeaderBlock::GetRun(), RawSnarlHeaderBlock::GetSubRun(), RawDigit::GetTDC(), RawSnarlHeaderBlock::GetTimeFrameNo(), it, JobCResult::kAOK, Msg::kInfo, Msg::kVerbose, MSG, and run().

00073 {
00074   //MSG("Olt",Msg::kVerbose) << "OltModule::Reco()\n";
00075   // Find RawRecord fragment in MOM.
00076   TIter iter = mom->FragmentIter();
00077   while (TObject *obj = iter.Next()) {
00078     RawRecord *rawrec = dynamic_cast<RawRecord *>(obj);
00079     if (rawrec) {
00080       ++fRecord;
00081       MSG("Olt",Msg::kVerbose) <<"---------------New Record---------------"<<endl;
00082       TIter recit = rawrec->GetRawBlockIter();
00083       while (TObject *obj = recit.Next()) {
00084         RawDataBlock *rawdata = dynamic_cast<RawDataBlock *>(obj);
00085         if (rawdata) {
00086           if (rawdata->InheritsFrom("RawSnarlHeaderBlock")) {
00087             RawSnarlHeaderBlock *rshb =dynamic_cast<RawSnarlHeaderBlock *>(rawdata);
00088             fTimeframe = rshb->GetTimeFrameNo();
00089             int run = rshb->GetRun();
00090             int subrun = rshb->GetSubRun();
00091             if ((run!=fRun)||(subrun!=fSubRun)) {
00092               MSG("Olt",Msg::kInfo)<<"Now starting run "<<run<<":"<<subrun<<endl;
00093               fRun = run;
00094               fSubRun = subrun;
00095             }
00096           } 
00097          
00098           MSG("Olt",Msg::kVerbose) <<fRecord<<": "<<rawdata->GetBlockId()<<endl;
00099           RawDigitDataBlock *rddb = dynamic_cast<RawDigitDataBlock *>(rawdata);
00100           if (rddb) {
00101             TIter it = rddb->GetDatumIter();
00102             while (TObject *obj = it.Next()) {
00103               RawVaDigit *rvd = dynamic_cast<RawVaDigit *>(obj);
00104               if (rvd) {
00105                 int tb = (rvd->GetTDC()/16000000);
00106                 fTimeBlockHits[0][tb] = fTimeBlockHits[0][tb] + 1;
00107                 fTimeBlockHits[0][40] = fTimeBlockHits[0][40] + 1;
00108               }
00109               RawQieDigit *rqd = dynamic_cast<RawQieDigit *>(obj);
00110               if (rqd) {
00111                 int error = rqd->GetErrorCode();
00112                 RawChannelId rcid = rqd->GetChannel();
00113                 int crate = rcid.GetCrate();
00114                 int tb = rqd->GetTDC()/int(1000000*77.0/58.0);
00115                 fTimeBlockHits[crate][tb] = fTimeBlockHits[crate][tb] + 1;
00116                 fTimeBlockHits[crate][40] = fTimeBlockHits[crate][40] + 1;
00117                 if (error) {
00118                   MSG("Olt",Msg::kInfo)<<"Run "<<fRun<<":"<<fSubRun<<" Timeframe "<<fTimeframe<<" QIE error "<<error<<" in channel "<<rcid<<endl;               
00119                 }
00120               }
00121             }
00122           }
00123         } 
00124       }  
00125     }
00126   }
00127 
00128   if (fTimeframe&&(fTimeframe%fCheckPeriod==0)) {
00129     // Check timeblocks...
00130     for (int crate=0;crate<3;crate++) {
00131       for (int tb = 0; tb<40; tb++) {
00132         if (float(fTimeBlockHits[crate][tb])/float(fTimeBlockHits[crate][40])
00133             <fTBThresh) 
00134           MSG("Olt",Msg::kInfo) << "Warning: at tf " <<fTimeframe<< " Crate "
00135                                 <<crate<<" Timeblock "
00136                                 <<tb<<" has only "
00137                                 <<float(fTimeBlockHits[crate][tb])/float(fTimeBlockHits[crate][40])
00138                                 <<" of the hits"<<endl;
00139         fTimeBlockHits[crate][tb]=0;
00140       }
00141       fTimeBlockHits[crate][40] = 0;
00142     }
00143   }
00144   return JobCResult::kAOK;
00145 }


Member Data Documentation

Definition at line 48 of file OltDataIntegrity.h.

Referenced by Config(), and Reco().

bool OltDataIntegrity::fDoTree [private]

Definition at line 41 of file OltDataIntegrity.h.

Referenced by Config().

bool OltDataIntegrity::fDump [private]

Definition at line 39 of file OltDataIntegrity.h.

Referenced by Config().

TFile* OltDataIntegrity::fFile [private]

Definition at line 44 of file OltDataIntegrity.h.

Referenced by Config(), and ~OltDataIntegrity().

std::string OltDataIntegrity::fFileName [private]

Definition at line 51 of file OltDataIntegrity.h.

Referenced by Config().

Definition at line 40 of file OltDataIntegrity.h.

Referenced by Config().

Definition at line 38 of file OltDataIntegrity.h.

Referenced by Reco().

int OltDataIntegrity::fRun [private]

Definition at line 46 of file OltDataIntegrity.h.

Referenced by Reco().

Definition at line 42 of file OltDataIntegrity.h.

Referenced by Config().

Definition at line 47 of file OltDataIntegrity.h.

Referenced by Reco().

float OltDataIntegrity::fTBThresh [private]

Definition at line 49 of file OltDataIntegrity.h.

Referenced by Config(), and Reco().

int OltDataIntegrity::fTimeBlockHits[3][41] [private]

Definition at line 50 of file OltDataIntegrity.h.

Referenced by Reco().

Definition at line 45 of file OltDataIntegrity.h.

Referenced by Reco().

TTree* OltDataIntegrity::fTree [private]

Definition at line 43 of file OltDataIntegrity.h.

Referenced by Config(), and ~OltDataIntegrity().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1