FillFarRunQuality Class Reference

#include <FillFarRunQuality.h>

Inheritance diagram for FillFarRunQuality:
JobCModule

List of all members.

Public Member Functions

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

Private Member Functions

void WriteToDatabase ()
void ReadFromDatabase ()
void WriteOutResults ()
void WriteOutFile ()
void ProcessHeader (TObject *obj)
void ProcessBlock (TObject *obj)
void EndSubRun ()
void WriteSubRun ()
void Reset ()

Private Attributes

TFile * fRunQualityFile
TTree * fRunQualityTree
TString fRunQualityFileName
Int_t fWriteToDatabase
Int_t fReadFromDatabase
Int_t fWriteOutResults
Int_t fTime
Int_t fRecord
Int_t fCounter
Int_t fGoodCounter
Int_t fHvStatus
Int_t fHvStatusSM1
Int_t fHvStatusSM2
Int_t fReadoutStatus
Int_t fTimeFrame
Int_t fSource
Int_t fRun
Int_t fSubRun
Int_t fRunType
Int_t fRopMask
Int_t fCrateMask
Int_t fTriggerMask
Int_t fStartTime
Int_t fEndTime
Int_t fTimeFrames
Int_t fSnarls
Int_t fGoodSnarls
Int_t fSnarlRateMin
Int_t fSnarlRateMax
Float_t fSnarlRateMean
Float_t fSnarlRateMedian
Int_t fTriggersPlane
Int_t fTriggersEnergy
Int_t fTriggersSpill
Int_t fTriggersRealSpill
Int_t fTriggersFakeSpill
Int_t fPhysicsRun
Int_t fModifiedRun
Int_t fTestRun
Int_t fGoodRun
Int_t * fSnarlRates
Int_t * fCrateRates
RawReadoutfRawReadout

Detailed Description

Definition at line 14 of file FillFarRunQuality.h.


Constructor & Destructor Documentation

FillFarRunQuality::FillFarRunQuality (  ) 

Definition at line 46 of file FillFarRunQuality.cxx.

References Msg::kDebug, and MSG.

00046                                      :
00047   fTime(-1),
00048   fRecord(0),
00049   fCounter(-1),
00050   fGoodCounter(0),
00051   fHvStatus(-1),
00052   fHvStatusSM1(-1),
00053   fHvStatusSM2(-1),
00054   fReadoutStatus(-1),
00055   fTimeFrame(-1),
00056   fSource(-1),
00057   fRun(-1),
00058   fSubRun(-1),
00059   fRunType(-1),
00060   fRopMask(-1),
00061   fCrateMask(-1),
00062   fTriggerMask(-1),
00063   fStartTime(-1),
00064   fEndTime(-1),
00065   fTimeFrames(0),
00066   fSnarls(0),
00067   fGoodSnarls(0),
00068   fSnarlRateMin(-1),
00069   fSnarlRateMax(-1),
00070   fSnarlRateMean(-999.9),
00071   fSnarlRateMedian(-999.9),
00072   fTriggersPlane(0),
00073   fTriggersEnergy(0),
00074   fTriggersSpill(0),
00075   fTriggersRealSpill(0),
00076   fTriggersFakeSpill(0),
00077   fPhysicsRun(-1),
00078   fModifiedRun(-1),
00079   fTestRun(-1),
00080   fGoodRun(-1),
00081   fRawReadout(0)
00082 {
00083   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::FillFarRunQuality() *** " << endl;
00084 
00085   fRunQualityFile = 0;
00086   fRunQualityTree = 0;
00087   fRunQualityFileName = "dburunquality.root";
00088 
00089   fWriteOutResults = 0;
00090   fWriteToDatabase = 0;
00091   fReadFromDatabase = 0;
00092 
00093   fSnarlRates = new Int_t[1001];
00094   fCrateRates = new Int_t[17];
00095 
00096   fRawReadout = new RawReadout();
00097 
00098   this->Reset();
00099 }

FillFarRunQuality::~FillFarRunQuality (  ) 

Definition at line 101 of file FillFarRunQuality.cxx.

References fCrateRates, fRawReadout, fSnarlRates, Msg::kDebug, and MSG.

00102 {
00103   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::~FillFarRunQuality() *** " << endl;
00104 
00105   delete [] fSnarlRates;
00106   delete [] fCrateRates;
00107   if( fRawReadout ) delete fRawReadout;
00108 }


Member Function Documentation

void FillFarRunQuality::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 110 of file FillFarRunQuality.cxx.

References Msg::kDebug, and MSG.

00111 {
00112   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::BeginJob(...) *** " << endl;
00113 
00114 }

void FillFarRunQuality::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 183 of file FillFarRunQuality.cxx.

References fReadFromDatabase, fRunQualityFileName, fWriteOutResults, fWriteToDatabase, Registry::Get(), Msg::kDebug, and MSG.

00184 {
00185   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::Config() *** " << endl;
00186 
00187   Int_t tmpint; const char* tmpchar = 0;
00188 
00189   if(r.Get("RunQualityFileName",tmpchar)) fRunQualityFileName = tmpchar;
00190   if(r.Get("WriteToDatabase",tmpint)) fWriteToDatabase = tmpint;
00191   if(r.Get("ReadFromDatabase",tmpint)) fReadFromDatabase = tmpint;
00192   if(r.Get("WriteOutResults",tmpint)) fWriteOutResults = tmpint;
00193 
00194   return;
00195 }

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

References fReadFromDatabase, fRunQualityFileName, fWriteOutResults, fWriteToDatabase, Msg::kDebug, Registry::LockValues(), MSG, Registry::Set(), and Registry::UnLockValues().

00168 {
00169   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::DefaultConfig() *** " << endl;
00170  
00171   static Registry r;
00172   r.SetName("FillFarRunQuality.config.default");
00173   r.UnLockValues();
00174   r.Set("RunQualityFileName",fRunQualityFileName.Data());
00175   r.Set("WriteToDatabase",fWriteToDatabase);
00176   r.Set("ReadFromDatabase",fReadFromDatabase);
00177   r.Set("WriteOutResults",fWriteOutResults);
00178   r.LockValues();
00179                     
00180   return r;
00181 }

void FillFarRunQuality::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 206 of file FillFarRunQuality.cxx.

References EndSubRun(), fWriteOutResults, Msg::kInfo, MSG, and WriteOutFile().

00207 {
00208   MSG("FarRunQuality",Msg::kInfo) << " *** FillFarRunQuality::EndJob() *** " << endl;
00209 
00210   // process last subrun
00211   // ===================
00212   this->EndSubRun();
00213 
00214   // writing out file
00215   // ================
00216   if( fWriteOutResults ){
00217     this->WriteOutFile();
00218   }
00219 }

void FillFarRunQuality::EndSubRun (  )  [private]

Definition at line 845 of file FillFarRunQuality.cxx.

References fCrateMask, fCrateRates, fEndTime, fGoodRun, fGoodSnarls, fModifiedRun, fPhysicsRun, fRopMask, fRun, fRunType, fSnarlRateMax, fSnarlRateMean, fSnarlRateMedian, fSnarlRateMin, fSnarlRates, fSnarls, fStartTime, fSubRun, fTestRun, fTimeFrames, fTriggerMask, fTriggersEnergy, fTriggersFakeSpill, fTriggersPlane, fTriggersRealSpill, fTriggersSpill, Msg::kDebug, Msg::kInfo, Msg::kVerbose, MSG, and WriteSubRun().

Referenced by EndJob(), and ProcessHeader().

00846 {
00847   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::EndSubRun() *** " << endl;
00848 
00849   // Calculate run quality parameters
00850   // ================================
00851 
00852   // calculate mean and median snarl rates
00853   if( fTimeFrames>0 ){
00854     Int_t oldtotal = 0;
00855     Int_t newtotal = 0;
00856     Int_t middletotal = (Int_t)(0.5*fTimeFrames);
00857   
00858     for(Int_t i=0; i<1001; i++){
00859       oldtotal = newtotal;
00860       newtotal += fSnarlRates[i];
00861       if( oldtotal<=middletotal && middletotal<newtotal ){
00862         fSnarlRateMedian = (float)i - 0.5;
00863         if( newtotal-oldtotal>0 ){
00864           fSnarlRateMedian += (float)(middletotal-oldtotal)/(float)(newtotal-oldtotal);
00865         }
00866       }
00867     }
00868 
00869     if( fSnarlRateMedian<fSnarlRateMin) fSnarlRateMedian=fSnarlRateMin;
00870     if( fSnarlRateMedian>fSnarlRateMax) fSnarlRateMedian=fSnarlRateMax;
00871 
00872     fSnarlRateMean = ((float)(fSnarls))/((float)(fTimeFrames));
00873   }
00874 
00875   // determine cratemask (number of crates reading out)
00876   // for cratemask=16 (full readout), require:
00877   //   >60 secs "good readout" OR <60 secs "bad readout".
00878   if( fTimeFrames>0 ){
00879     Int_t goodreadout = 0;
00880     Int_t badreadout = 0;
00881     for(Int_t i=0; i<=16; i++){
00882       if( i==16 ) goodreadout += fCrateRates[i]; 
00883       else badreadout += fCrateRates[i];
00884     }
00885 
00886     Int_t cratemask = -1;
00887     Int_t maxcratemask = 16;
00888     if( ( goodreadout>0 )
00889      && ( goodreadout>60 || badreadout<60 ) ) maxcratemask=16;
00890     else maxcratemask = 15;
00891     
00892     for(Int_t i=0; i<=maxcratemask; i++){
00893       if( fCrateRates[i]>0 ) cratemask = i;
00894     }
00895 
00896     fCrateMask = cratemask;
00897   }
00898 
00899   // determine whether this is a good run
00900   // physics runtype + no test bit set + full readout
00901   // run >= 300 seconds, subrun >= 120 seconds
00902   // good snarls >= 100
00903   // good snarl rate < 30 Hz
00904   // median snarl rate < 100 Hz
00905   // maximum snarl rate < 300 Hz
00906   fGoodRun = 0;
00907   if( ( fRun>=0 )
00908    && ( fPhysicsRun==1 && fTestRun==0 )
00909    && ( fCrateMask==16 )
00910    && ( fTimeFrames>=300 || (fSubRun>0 && fTimeFrames>120 ) )
00911    && ( fGoodSnarls>=100 && (double)fGoodSnarls/(double)fTimeFrames<30 )
00912    && ( fSnarlRateMedian<100 && fSnarlRateMax<300 ) ){
00913     fGoodRun = 1;
00914   }
00915 
00916   // print results
00917   // =============
00918   MSG("FarRunQuality",Msg::kVerbose) << " *** FillFarRunQuality::PrintResults() *** " << endl;
00919 
00920   MSG("FarRunQuality",Msg::kInfo) << endl
00921                                   << " RESULTS: " << endl
00922                                   << " ======= " << endl
00923                                   << " Run=" << fRun << endl
00924                                   << " SubRun=" << fSubRun << endl
00925                                   << " RunType=" << fRunType << endl
00926                                   << " RopMask=" << fRopMask << endl
00927                                   << " CrateMask=" << fCrateMask << endl
00928                                   << " TriggerMask=" << fTriggerMask << endl
00929                                   << " StartTime=" << fStartTime << endl
00930                                   << " EndTime=" << fEndTime << endl
00931                                   << " TimeFrames=" << fTimeFrames << endl
00932                                   << " Snarls=" << fSnarls << endl
00933                                   << " GoodSnarls=" << fGoodSnarls << endl
00934                                   << " MinSnarlRate=" << fSnarlRateMin << endl
00935                                   << " MaxSnarlRate=" << fSnarlRateMax << endl
00936                                   << " MeanSnarlRate=" << fSnarlRateMean << endl
00937                                   << " MedianSnarlRate=" << fSnarlRateMedian << endl
00938                                   << " PlaneTriggers=" << fTriggersPlane << endl
00939                                   << " EnergyTriggers=" << fTriggersEnergy << endl
00940                                   << " SpillTriggers=" << fTriggersSpill << endl
00941                                   << " SpillTriggersReal=" << fTriggersRealSpill << endl
00942                                   << " SpillTriggersFake=" << fTriggersFakeSpill << endl
00943                                   << " PhysicsRun=" << fPhysicsRun << endl
00944                                   << " ModifiedRun=" << fModifiedRun << endl
00945                                   << " TestRun=" << fTestRun << endl
00946                                   << " GoodRun=" << fGoodRun << endl;  
00947 
00948   // write out results
00949   // =================
00950   this->WriteSubRun();
00951 
00952 }

JobCResult FillFarRunQuality::Get ( MomNavigator mom  )  [virtual]

Implement if your module needs to read data from some external source and fill mom

Reimplemented from JobCModule.

Definition at line 116 of file FillFarRunQuality.cxx.

References MomNavigator::FragmentIter(), fRecord, RawRecord::GetRawBlockIter(), RawRecord::GetRawHeader(), RecMinosHdr::GetVldContext(), Msg::kDebug, JobCResult::kPassed, Msg::kWarning, MSG, ProcessBlock(), ProcessHeader(), and JobCResult::SetFailed().

00117 {
00118   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::Get(...) *** " << endl;
00119 
00120   JobCResult result(JobCResult::kPassed);
00121 
00122   VldContext vldc;
00123   TObject* momobject = 0;
00124   Bool_t foundit = 0;
00125 
00126   // PROCESS RAW RECORD
00127   // ==================
00128   TIter momitr(mom->FragmentIter());
00129   while((momobject = momitr())){
00130     if(momobject->InheritsFrom("RawRecord")){
00131       foundit = 1;
00132       fRecord++;
00133       MSG("FarRunQuality",Msg::kDebug) << "  *** RAW RECORD [" << fRecord << "] ***  " << endl;
00134       RawRecord* rawrec = dynamic_cast<RawRecord*>(momobject);
00135   
00136       // Get the raw header and extract validity context
00137       // Process the raw header (ProcessHeader)
00138       vldc = rawrec->GetRawHeader()->GetVldContext();
00139       this->ProcessHeader((TObject*)(rawrec->GetRawHeader()));
00140        
00141       // Iterate over the raw blocks in raw record
00142       // Process the raw block (ProcessBlock)
00143       TIter rawrecitr = rawrec->GetRawBlockIter();
00144       TObject* tob = 0;
00145       while((tob = rawrecitr())){
00146         MSG("FarRunQuality",Msg::kDebug) << " " << tob->GetName() << endl;
00147         this->ProcessBlock(tob);
00148       }                                  
00149     }
00150   }
00151              
00152   if( !foundit ){
00153     MSG("FarRunQuality",Msg::kWarning) << "  *** FAILED TO FIND RAW RECORD ***  " << endl;
00154     return result.SetFailed();
00155   }
00156 
00157   return result;
00158 }

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

Implement to handle a JobCommand

Reimplemented from JobCModule.

Definition at line 197 of file FillFarRunQuality.cxx.

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

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

void FillFarRunQuality::ProcessBlock ( TObject *  obj  )  [private]

Definition at line 585 of file FillFarRunQuality.cxx.

References MuELoss::e, fCrateRates, fHvStatus, fHvStatusSM1, fHvStatusSM2, fRawReadout, fReadoutStatus, fRopMask, fStartTime, fTriggerMask, RawConfigFilesBlock::GetConfigFile(), RawChannelId::GetCrate(), RawTpSinglesSummaryBlock::GetEndTimeStamp(), RawTpSinglesSummaryBlock::GetHitsPerSecByCrate(), VldTimeStamp::GetNanoSec(), RawTpSinglesSummaryBlock::GetNumberOfCrates(), RawTpSinglesSummaryBlock::GetRates(), RawReadout::GetReadoutType(), RawRunConfigBlock::GetRunConfig(), VldTimeStamp::GetSec(), RawTpSinglesSummaryBlock::GetSource(), RawRunStartBlock::GetStartTime(), RawTpSinglesSummaryBlock::GetStartTimeStamp(), Msg::kDebug, RawReadout::kDetector, Detector::kFar, Detector::kNear, Detector::kUnknown, Msg::kVerbose, RawReadout::kVetoShield, MSG, and n.

Referenced by Get().

00586 {
00587  
00588   // Header Block
00589   // ============
00590   if(obj->InheritsFrom("RawDaqHeaderBlock")){
00591     MSG("FarRunQuality",Msg::kDebug) << " ... found RawDaqHeaderBlock " << endl;
00592 
00594     // RawDaqHeaderBlock* rdb = (RawDaqHeaderBlock*)(obj); 
00595   }
00596 
00597   // Snarl Header Block
00598   // ==================
00599   if(obj->InheritsFrom("RawSnarlHeaderBlock")){
00600     MSG("FarRunQuality",Msg::kDebug) << " ... found RawSnarlHeaderBlock " << endl;
00601 
00603     // RawSnarlHeaderBlock* rdb = (RawSnarlHeaderBlock*)(obj);
00604   }
00605 
00606   // Run Configuration
00607   // =================
00608   if(obj->InheritsFrom("RawRunConfigBlock")){
00609     MSG("FarRunQuality",Msg::kDebug) << " ... found RawRunConfigBlock " << endl;
00610     RawRunConfigBlock* rdb = (RawRunConfigBlock*)(obj);
00611 
00612     char* config;
00613     config = (char*)(rdb->GetRunConfig());  
00614 
00615     MSG("FarRunQuality",Msg::kVerbose) << " RUN_CONFIG_BLOCK: " << config << endl;
00616 
00617     char* word;
00618     int ctr = 0;
00619     bool cont = 1;
00620     word = strtok(config,";");
00621 
00622     while( cont ){
00623       MSG("FarRunQuality",Msg::kVerbose) << " (" << ctr << ") " << word << endl;
00624 
00625       // extract RopMask from run configuration
00626       if( strstr(word,"ropIdMask#") ){
00627         if( (word = strchr(word,'=')) ){
00628           if( strlen(word)>1 ){
00629             word=&(word[1]); 
00630             if( fRopMask<0 ) fRopMask = strtol(word,&word,0);
00631           }
00632         }
00633       }
00634 
00635       // extract TriggerMask from  run configuration
00636       if( strstr(word,"triggerMask#") ){
00637         if( (word = strchr(word,'=')) ){
00638           if( strlen(word)>1 ){
00639             word=&(word[1]); 
00640             if( fTriggerMask<0 ) fTriggerMask = strtol(word,&word,0);
00641           }
00642         }
00643       }
00644 
00645       cont = ( word = strtok(0,";") );
00646       ctr++;
00647     }
00648 
00649     // convert RopMask into CrateMask
00650     if( fRopMask>=0 ){
00651       Int_t cratemask = 0;
00652       for( Int_t n=0; n<16; n++){
00653         Int_t nbit = ( 1 << n );
00654         if( (fRopMask&nbit)==(nbit) ) cratemask++;
00655       }
00656       // (could record number of crates here)
00657       // fCrateMask = cratemask;
00658     }
00659 
00660     MSG("FarRunQuality",Msg::kDebug) << " RopMask=" << fRopMask << " TriggerMask=" << fTriggerMask << endl;
00661   }
00662 
00663   // Run Configuration Files
00664   // =======================
00665   if(obj->InheritsFrom("RawConfigFilesBlock")){
00666     MSG("FarRunQuality",Msg::kDebug) << " ... found RawConfigFilesBlock " << endl;
00667     RawConfigFilesBlock* rdb = (RawConfigFilesBlock*)(obj);
00668 
00669     char* config;
00670     config = (char*)(rdb->GetConfigFile()); 
00671 
00673     // MSG("FarRunQuality",Msg::kVerbose) << " RUN_CONFIG_FILE: " << config << endl;
00674   }
00675 
00676   // Run Start Block
00677   // ===============
00678   if(obj->InheritsFrom("RawRunStartBlock")){
00679     MSG("FarRunQuality",Msg::kDebug) << " ... found RawRunStartBlock " << endl;
00680     RawRunStartBlock* rdb = (RawRunStartBlock*)(obj);
00681 
00682     fStartTime = rdb->GetStartTime().GetSec();
00683 
00684     MSG("FarRunQuality",Msg::kDebug) << " StartTime=" << fStartTime << endl;
00685   }
00686 
00687   // Singles Summary Block
00688   // =====================
00689   if(obj->InheritsFrom("RawTpSinglesSummaryBlock")){
00690     MSG("FarRunQuality",Msg::kDebug) << " ... found RawTpSinglesSummaryBlock " << endl;
00691     RawTpSinglesSummaryBlock* rdb = (RawTpSinglesSummaryBlock*)(obj);
00692 
00693     Int_t time = rdb->GetStartTimeStamp().GetSec();
00694     Double_t frametime = (rdb->GetEndTimeStamp().GetSec()-rdb->GetStartTimeStamp().GetSec())+1.0e-9*(rdb->GetEndTimeStamp().GetNanoSec()-rdb->GetStartTimeStamp().GetNanoSec());
00695 
00696     Int_t source = rdb->GetSource();
00697     Int_t sourcecheck = 0;
00698     Int_t minrate = -99999;
00699     Int_t maxchips = +99999;
00700 
00701     Int_t allchips1 = 0;
00702     Int_t allchips2 = 0;
00703     Int_t coldchips1 = 0;
00704     Int_t coldchips2 = 0;
00705 
00706     Detector::Detector_t Detector = Detector::kUnknown;
00707 
00708     switch( source ){
00709       case 0: // Crate only
00710         Detector = Detector::kUnknown;
00711         break;
00712       case 1: // Crate and VARC (VA)
00713         Detector = Detector::kFar;
00714         break;
00715       case 2: // Crate and VFB/ADCSEL (VA)
00716         Detector = Detector::kFar;
00717         break;
00718       case 3: // Crate and VACHIP (VA)
00719         Detector = Detector::kFar;
00720         break;
00721       case 4: // Crate and Plane
00722         Detector = Detector::kUnknown;
00723         break;
00724       case 5: // Crate and MASTER (QIE)
00725         Detector = Detector::kNear;
00726         break;
00727       case 6: // Crate and MINDER (QIE)
00728         Detector = Detector::kNear;
00729         break;
00730       case 7: // Crate and MENU (QIE)
00731         Detector = Detector::kNear;
00732         break;
00733       default:
00734         break;
00735     }
00736 
00737     // check source type
00738     if( source==3 && Detector==Detector::kFar ){
00739       minrate = 50;
00740       maxchips = 20;
00741       sourcecheck = 1;
00742     }      
00743 
00744     if( source==7 && Detector==Detector::kNear ){
00745       minrate = -99999;
00746       maxchips = +99999;
00747       sourcecheck = 1;
00748     }
00749 
00750     // Iterate over raw channels and record any hot/cold chips
00751     typedef std::map<RawChannelId,UInt_t> RCIdToRateMap;
00752     const RCIdToRateMap& rates = rdb->GetRates();
00753     RCIdToRateMap::const_iterator rateItr = rates.begin();
00754     RCIdToRateMap::const_iterator rateEnd = rates.end();
00755     while ( rateItr != rateEnd ) {
00756       RawChannelId rawch = rateItr->first;
00757       Int_t rawrate = rateItr->second;
00758       Int_t correctedrate = (Int_t)(rawrate/frametime);
00759       Int_t rate = correctedrate;
00760       Int_t crate = rawch.GetCrate();
00761 
00762       RawReadout::ReadoutType_t readout = fRawReadout->GetReadoutType(rawch);
00763             
00764       if( ( sourcecheck )
00765        && ( readout==RawReadout::kDetector 
00766          || readout==RawReadout::kVetoShield ) ){     
00767 
00768         // supermodule 1   
00769         if( crate>=0 && crate<8 ){
00770           allchips1++; 
00771           if( rate<minrate ){
00772             coldchips1++;
00773             MSG("FarRunQuality",Msg::kVerbose) << "   cold chip (SM1): crate=" << crate << " corrected rate=" << correctedrate << endl; 
00774           }
00775         }
00776 
00777         // supermodule 2
00778         if( crate>=8 && crate<16 ){
00779           allchips2++; 
00780           if( rate<minrate ){
00781             coldchips2++;
00782             MSG("FarRunQuality",Msg::kVerbose) << "   cold chip (SM2): crate=" << crate << " corrected rate=" << correctedrate << endl; 
00783           }
00784         }
00785 
00786       }
00787 
00788       rateItr++;
00789     }
00790 
00791     // record number of crates in readout
00792     Int_t ncrates = rdb->GetNumberOfCrates();
00793     Int_t ncrates_readout = 0;
00794  
00795     for( Int_t k=0; k<ncrates; k++ ){
00796       if( rdb->GetHitsPerSecByCrate(k)>0 ) ncrates_readout++;
00797     }  
00798 
00799     if( ncrates_readout>=0 && ncrates_readout<=16 ){
00800       fCrateRates[ncrates_readout]++;
00801     }
00802   
00803     MSG("FarRunQuality",Msg::kVerbose) << "   time=" << time << " frametime=" << frametime << endl;
00804     MSG("FarRunQuality",Msg::kVerbose) << "   crates=" << ncrates_readout << "/" << ncrates << endl;
00805     MSG("FarRunQuality",Msg::kVerbose) << "   source=" << source << " check=" << sourcecheck << endl;
00806     MSG("FarRunQuality",Msg::kVerbose) << "   minrate=" << minrate << " maxchips=" << maxchips << endl;
00807     MSG("FarRunQuality",Msg::kVerbose) << "   SM1: allchips=" << allchips1 << " coldchips=" << coldchips1 << endl;
00808     MSG("FarRunQuality",Msg::kVerbose) << "   SM2: allchips=" << allchips2 << " coldchips=" << coldchips2 << endl;
00809 
00810     fHvStatus = -1;
00811     fHvStatusSM1 = -1;
00812     fHvStatusSM2 = -1;
00813     fReadoutStatus = -1;
00814 
00815     // analyse singles data
00816     if( sourcecheck ){
00817 
00818       // supermodule 1
00819       if( allchips1>0 ){
00820         if( coldchips1<maxchips ) fHvStatusSM1 = 1;
00821         else fHvStatusSM1 = 0;
00822       }
00823 
00824       // supermodule 2
00825       if( allchips2>0 ){
00826         if( coldchips2<maxchips ) fHvStatusSM2 = 1;
00827         else fHvStatusSM2 = 0;
00828       }
00829 
00830       // determine HV status
00831       if( fHvStatusSM1==1 && fHvStatusSM2!=0 ) fHvStatus = 1;
00832       if( fHvStatusSM1!=0 && fHvStatusSM2==1 ) fHvStatus = 1;
00833       if( fHvStatusSM1==0 || fHvStatusSM2==0 ) fHvStatus = 0;
00834 
00835       // determine readout status
00836       if( ncrates_readout==16 ) fReadoutStatus = 1; 
00837       else fReadoutStatus = 0;
00838     }
00839 
00840     MSG("FarRunQuality",Msg::kDebug) << "   HV STATUS: SM1=" << fHvStatusSM1 << " SM2=" << fHvStatusSM2 << " overall=" << fHvStatus << endl;
00841     MSG("FarRunQuality",Msg::kDebug) << "   READOUT STATUS: " << fReadoutStatus << endl;
00842   }
00843 }

void FillFarRunQuality::ProcessHeader ( TObject *  obj  )  [private]

Definition at line 466 of file FillFarRunQuality.cxx.

References digits(), EndSubRun(), fCounter, fEndTime, fGoodCounter, fGoodSnarls, fHvStatus, fModifiedRun, fPhysicsRun, fRun, fRunType, fSnarlRateMax, fSnarlRateMin, fSnarlRates, fSnarls, fStartTime, fSubRun, fTestRun, fTime, fTimeFrame, fTimeFrames, fTriggersEnergy, fTriggersFakeSpill, fTriggersPlane, fTriggersRealSpill, fTriggersSpill, RawDaqSnarlHeader::GetNumRawDigits(), RawDaqSnarlHeader::GetRemoteSpillType(), RawDaqHeader::GetRun(), RawDaqHeader::GetRunType(), VldTimeStamp::GetSec(), RawDaqHeader::GetSubRun(), RawDaqHeader::GetTimeFrameNum(), VldContext::GetTimeStamp(), RawDaqSnarlHeader::GetTrigSrc(), RecMinosHdr::GetVldContext(), Msg::kDebug, Msg::kVerbose, MSG, Reset(), run(), RUN_TYPE_MASK_MODIFIED, RUN_TYPE_MASK_TEST, RUN_TYPE_PHYSICS, TRIGGER_BIT_E4, TRIGGER_BIT_PLANE, and TRIGGER_BIT_SPILL_IP.

Referenced by Get().

00467 {
00468  
00469   // DAQ Header
00470   // ==========
00471   if(obj->InheritsFrom("RawDaqHeader")){
00472     MSG("FarRunQuality",Msg::kDebug) << " ... found RawDaqHeader " << endl;
00473     RawDaqHeader* hdr = (RawDaqHeader*)(obj); 
00474 
00475     Int_t time = hdr->GetVldContext().GetTimeStamp().GetSec();
00476     Int_t timeframe = hdr->GetTimeFrameNum();
00477     Int_t run = hdr->GetRun();
00478     Int_t subrun = hdr->GetSubRun();
00479     Int_t runtype = hdr->GetRunType();
00480 
00481     MSG("FarRunQuality",Msg::kDebug) << "   timeframe=" << timeframe << " time=" << time << endl;
00482 
00483     // New Run/SubRun
00484     if( (fRun>=0 && fSubRun>=0)
00485      && !(run==fRun && subrun==fSubRun) 
00486      && !(run==fRun && fEndTime-fStartTime<30) ){
00487       MSG("FarRunQuality",Msg::kDebug) << "   closing:" << fRun << "/"<< fSubRun << endl;
00488       this->EndSubRun();
00489       this->Reset();
00490     }
00491 
00492     // Record Run/SubRun
00493     if( fRun<0 || fSubRun<0 ){
00494       MSG("FarRunQuality",Msg::kDebug) << "   opening:" << run << "/"<< subrun << endl;
00495       fRun = run;
00496       fSubRun = subrun;
00497       fRunType = runtype;
00498     }
00499 
00500     // Record RunType
00501     if( fPhysicsRun<0 ){
00502       if( fRun>=0 ){      
00503         fPhysicsRun = 0;
00504         fModifiedRun = 0;
00505         fTestRun = 0;
00506         if( fRunType>=0 ){
00507           if( (fRunType==2) ) fPhysicsRun = 1;
00508           if( (fRunType&RUN_TYPE_PHYSICS)==(RUN_TYPE_PHYSICS) ) fPhysicsRun = 1;
00509           if( (fRunType&RUN_TYPE_MASK_MODIFIED)==(RUN_TYPE_MASK_MODIFIED) ) fModifiedRun = 1;
00510           if( (fRunType&RUN_TYPE_MASK_TEST)==(RUN_TYPE_MASK_TEST) ) fTestRun = 1;
00511         }
00512       }
00513     }
00514     
00515     // Record Time
00516     if( timeframe>=0 && time!=fTime ){
00517 
00518       if( time>fTime ){
00519         if( fStartTime<0 ) fStartTime = time;
00520         if( time>fEndTime ) fEndTime = time;
00521         if( fCounter>=0 ){
00522           if( fSnarlRateMin<0 || fCounter<fSnarlRateMin ) fSnarlRateMin = fCounter;
00523           if( fCounter>fSnarlRateMax ) fSnarlRateMax = fCounter;
00524           if( fCounter>1000 ) fCounter = 1000;
00525           fSnarls += fCounter;
00526           fGoodSnarls += fGoodCounter;
00527           fSnarlRates[fCounter]++;
00528           fTimeFrames++;
00529         }
00530       }
00531 
00532       fCounter = 0;
00533       fGoodCounter = 0;
00534       fTime = time;
00535       fTimeFrame = timeframe;
00536     }   
00537 
00538     MSG("FarRunQuality",Msg::kVerbose) << "   run=" << fRun << " subrun=" << fSubRun << " runtype=" << fRunType << " physics=" << fPhysicsRun << endl; 
00539   }
00540  
00541   // Snarl Header
00542   // ============
00543   if(obj->InheritsFrom("RawDaqSnarlHeader")){
00544     MSG("FarRunQuality",Msg::kDebug) << " ... found RawDaqSnarlHeader " << endl;
00545     RawDaqSnarlHeader* hdr = (RawDaqSnarlHeader*)(obj);
00546     
00547     Int_t time = hdr->GetVldContext().GetTimeStamp().GetSec();
00548     Int_t timeframe = hdr->GetTimeFrameNum();
00549     Int_t trigger = hdr->GetTrigSrc();
00550     Int_t digits = hdr->GetNumRawDigits();
00551     Int_t spilltype = hdr->GetRemoteSpillType();
00552 
00553     // Record Trigger Type
00554     Bool_t plane_trigger = ((trigger&TRIGGER_BIT_PLANE)==(TRIGGER_BIT_PLANE));
00555     Bool_t energy_trigger = ((trigger&TRIGGER_BIT_E4)==(TRIGGER_BIT_E4));
00556     Bool_t spill_trigger = ((trigger&TRIGGER_BIT_SPILL_IP)==(TRIGGER_BIT_SPILL_IP));
00557     Bool_t real_spill_trigger = 0; if( spill_trigger && spilltype==1 ) real_spill_trigger = 1;
00558     Bool_t fake_spill_trigger = 0; if( spill_trigger && spilltype==3 ) fake_spill_trigger = 1;
00559 
00560     MSG("FarRunQuality",Msg::kVerbose) << "   time=" << time << " timeframe=" << timeframe << endl;
00561     MSG("FarRunQuality",Msg::kVerbose) << "   trigger=" << trigger << " (PL,EN,SP)=(" << plane_trigger << "," << energy_trigger << "," << spill_trigger << ")" << endl;
00562    
00563     Bool_t good_trigger = 0;
00564     if( plane_trigger ) { good_trigger |= 1; fTriggersPlane++; }
00565     if( energy_trigger ){ good_trigger |= 1; fTriggersEnergy++; }
00566     if( spill_trigger ) { good_trigger |= 1; fTriggersSpill++; }
00567     if( real_spill_trigger ) { good_trigger |= 1; fTriggersRealSpill++; }
00568     if( fake_spill_trigger ) { good_trigger |= 1; fTriggersFakeSpill++; }
00569 
00570     Bool_t good_detector = 0;
00571     if( fHvStatus>0 ) good_detector = fHvStatus;
00572 
00573     Bool_t good_event = 0;
00574     if( digits>=0 && digits<1000 ) good_event = 1;
00575  
00576     // Count Good Snarls
00577     if( fCounter>=0 ){
00578       fCounter++;
00579       if( good_detector && good_trigger && good_event ) fGoodCounter++;
00580     }
00581   }
00582 
00583 }

void FillFarRunQuality::ReadFromDatabase (  )  [private]

Definition at line 320 of file FillFarRunQuality.cxx.

References fCrateMask, fEndTime, fGoodRun, fGoodSnarls, fModifiedRun, fPhysicsRun, fRopMask, fRun, fRunType, fSnarlRateMax, fSnarlRateMean, fSnarlRateMedian, fSnarlRateMin, fSnarls, fStartTime, fSubRun, fTestRun, fTimeFrames, fTriggerMask, fTriggersEnergy, fTriggersFakeSpill, fTriggersPlane, fTriggersRealSpill, fTriggersSpill, DbiTableProxyRegistry::GetCascader(), DbuFarRunQuality::GetCrateMask(), DbuFarRunQuality::GetEndTime(), DbuFarRunQuality::GetEnergyTriggers(), DbuFarRunQuality::GetGoodRun(), DbuFarRunQuality::GetGoodSnarls(), DbuFarRunQuality::GetMaxSnarlRate(), DbuFarRunQuality::GetMeanSnarlRate(), DbuFarRunQuality::GetMedianSnarlRate(), DbuFarRunQuality::GetMinSnarlRate(), DbuFarRunQuality::GetModifiedRun(), DbiResultPtr< T >::GetNumRows(), DbuFarRunQuality::GetPhysicsRun(), DbuFarRunQuality::GetPlaneTriggers(), DbuFarRunQuality::GetRopMask(), DbiResultPtr< T >::GetRow(), DbuFarRunQuality::GetRun(), DbuFarRunQuality::GetRunType(), VldTimeStamp::GetSec(), DbuFarRunQuality::GetSnarls(), DbuFarRunQuality::GetSpillTriggers(), DbuFarRunQuality::GetSpillTriggersFake(), DbuFarRunQuality::GetSpillTriggersReal(), DbuFarRunQuality::GetStartTime(), DbuFarRunQuality::GetSubRun(), DbuFarRunQuality::GetTestRun(), DbuFarRunQuality::GetTimeFrames(), DbuFarRunQuality::GetTriggerMask(), DbiTableProxyRegistry::Instance(), SimFlag::kData, Msg::kDebug, Detector::kFar, Msg::kVerbose, Msg::kWarning, MSG, and DbiCascader::TableExists().

Referenced by WriteSubRun().

00321 {
00322   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::ReadFromDatabase() *** " << endl;
00323 
00324   // Protect against null entries
00325   if( fStartTime<=0 || fEndTime<=0 ){
00326     MSG("FarRunQuality",Msg::kWarning) << " *** Time is unphysical, skipping database query *** " << endl;
00327     return;
00328   }
00329 
00330   DbiCascader& cascader = DbiTableProxyRegistry::Instance().GetCascader();
00331 
00332   if( cascader.TableExists("DBUFARRUNQUALITY") ){
00333     MSG("FarRunQuality",Msg::kVerbose) << "    Reading from DBUFARRUNQUALITY table... " << endl;
00334     cout << "    Reading from DBUFARRUNQUALITY table... " << endl;
00335     
00336     Int_t time = (Int_t)(0.5*((double)fStartTime+(double)fEndTime));
00337     VldTimeStamp timestamp(time,0);
00338     VldContext vldc(Detector::kFar,SimFlag::kData,timestamp);
00339     Dbi::Task task = 0;
00340 
00341     DbiResultPtr<DbuFarRunQuality> resptr("DBUFARRUNQUALITY",vldc,task);
00342 
00343     MSG("FarRunQuality",Msg::kVerbose) << "    Number Of Rows = " << resptr.GetNumRows() << endl;
00344 
00345     if( resptr.GetNumRows()>0 ){
00346       for( unsigned int i=0; i<resptr.GetNumRows(); i++){
00347         const DbuFarRunQuality* rowptr = resptr.GetRow(i);
00348         fRun = rowptr->GetRun();
00349         fSubRun = rowptr->GetSubRun();
00350         fRunType = rowptr->GetRunType();
00351         fRopMask = rowptr->GetRopMask();
00352         fCrateMask = rowptr->GetCrateMask();
00353         fTriggerMask = rowptr->GetTriggerMask();
00354 
00355         fStartTime = rowptr->GetStartTime().GetSec();
00356         fEndTime = rowptr->GetEndTime().GetSec();
00357         fTimeFrames = rowptr->GetTimeFrames();
00358         fSnarls = rowptr->GetSnarls();
00359         fGoodSnarls = rowptr->GetGoodSnarls();
00360         fSnarlRateMin = rowptr->GetMinSnarlRate();
00361         fSnarlRateMax = rowptr->GetMaxSnarlRate();
00362         fSnarlRateMean = rowptr->GetMeanSnarlRate();
00363         fSnarlRateMedian = rowptr->GetMedianSnarlRate();
00364         fTriggersPlane = rowptr->GetPlaneTriggers();
00365         fTriggersEnergy = rowptr->GetEnergyTriggers();
00366         fTriggersSpill = rowptr->GetSpillTriggers();
00367         fTriggersRealSpill = rowptr->GetSpillTriggersReal();
00368         fTriggersFakeSpill = rowptr->GetSpillTriggersFake(); 
00369         fPhysicsRun = rowptr->GetPhysicsRun();
00370         fModifiedRun = rowptr->GetModifiedRun();
00371         fTestRun = rowptr->GetTestRun();
00372         fGoodRun = rowptr->GetGoodRun();
00373 
00374         MSG("FarRunQuality",Msg::kDebug) << endl
00375                                   << " READING RESULTS: " << endl
00376                                   << " =============== " << endl
00377                                   << " Run=" << fRun << endl
00378                                   << " SubRun=" << fSubRun << endl
00379                                   << " RunType=" << fRunType << endl
00380                                   << " RopMask=" << fRopMask << endl
00381                                   << " CrateMask=" << fCrateMask << endl
00382                                   << " TriggerMask=" << fTriggerMask << endl
00383                                   << " StartTime=" << fStartTime << endl
00384                                   << " EndTime=" << fEndTime << endl
00385                                   << " TimeFrames=" << fTimeFrames << endl
00386                                   << " Snarls=" << fSnarls << endl
00387                                   << " GoodSnarls=" << fGoodSnarls << endl
00388                                   << " MinSnarlRate=" << fSnarlRateMin << endl
00389                                   << " MaxSnarlRate=" << fSnarlRateMax << endl
00390                                   << " MeanSnarlRate=" << fSnarlRateMean << endl
00391                                   << " MedianSnarlRate=" << fSnarlRateMedian << endl
00392                                   << " PlaneTriggers=" << fTriggersPlane << endl
00393                                   << " EnergyTriggers=" << fTriggersEnergy << endl
00394                                   << " SpillTriggers=" << fTriggersSpill << endl
00395                                   << " SpillTriggersReal=" << fTriggersRealSpill << endl
00396                                   << " SpillTriggersFake=" << fTriggersFakeSpill << endl
00397                                   << " PhysicsRun=" << fPhysicsRun << endl
00398                                   << " ModifiedRun=" << fModifiedRun << endl
00399                                   << " TestRun=" << fTestRun << endl
00400                                   << " GoodRun=" << fGoodRun << endl;
00401       }
00402     }
00403   }
00404 }

void FillFarRunQuality::Reset (  )  [private, virtual]

Implement to reset oneself

Reimplemented from JobCModule.

Definition at line 987 of file FillFarRunQuality.cxx.

References fCounter, fCrateMask, fCrateRates, fEndTime, fGoodCounter, fGoodRun, fGoodSnarls, fHvStatus, fHvStatusSM1, fHvStatusSM2, fModifiedRun, fPhysicsRun, fReadoutStatus, fRopMask, fRun, fRunType, fSnarlRateMax, fSnarlRateMean, fSnarlRateMedian, fSnarlRateMin, fSnarlRates, fSnarls, fSource, fStartTime, fSubRun, fTestRun, fTime, fTimeFrame, fTimeFrames, fTriggerMask, fTriggersEnergy, fTriggersFakeSpill, fTriggersPlane, fTriggersRealSpill, fTriggersSpill, Msg::kDebug, and MSG.

Referenced by ProcessHeader().

00988 {
00989   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::Reset() *** " << endl;
00990 
00991   fTime = -1;
00992   fCounter = -1;
00993   fGoodCounter = 0;
00994   fHvStatus = -1;
00995   fHvStatusSM1 = -1;
00996   fHvStatusSM2 = -1;
00997   fReadoutStatus = -1;
00998   fTimeFrame = -1;
00999   fSource = -1;
01000   fRun = -1;
01001   fSubRun = -1;
01002   fRunType = -1;
01003   fRopMask = -1;
01004   fCrateMask = -1;
01005   fTriggerMask = -1;
01006   fStartTime = -1;
01007   fEndTime = -1;
01008   fTimeFrames = 0;
01009   fSnarls = 0;
01010   fGoodSnarls = 0;
01011   fSnarlRateMin = -1;
01012   fSnarlRateMax = -1;
01013   fSnarlRateMean = -999.9;
01014   fSnarlRateMedian = -999.9;
01015   fTriggersPlane = 0;
01016   fTriggersEnergy = 0;
01017   fTriggersSpill = 0;
01018   fTriggersRealSpill = 0;
01019   fTriggersFakeSpill = 0;
01020   fPhysicsRun = -1;
01021   fModifiedRun = -1;
01022   fTestRun = -1;
01023   fGoodRun = -1;
01024 
01025   for(Int_t i=0; i<17; i++){ fCrateRates[i]=0; }
01026   for(Int_t i=0; i<1001; i++){ fSnarlRates[i]=0; }
01027 }

void FillFarRunQuality::WriteOutFile (  )  [private]

Definition at line 452 of file FillFarRunQuality.cxx.

References fRunQualityFile, fRunQualityFileName, fRunQualityTree, Msg::kDebug, and MSG.

Referenced by EndJob().

00453 {
00454   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::WriteOutFile() *** " << endl;
00455 
00456   if( fRunQualityFile ){
00457     MSG("FarRunQuality",Msg::kDebug) << "   closing file: " << fRunQualityFileName.Data() << endl;
00458     TDirectory* tmpd = gDirectory;
00459     fRunQualityFile->cd();
00460     fRunQualityTree->Write();
00461     fRunQualityFile->Close();
00462     gDirectory = tmpd;
00463   }
00464 }

void FillFarRunQuality::WriteOutResults (  )  [private]

Definition at line 406 of file FillFarRunQuality.cxx.

References fCrateMask, fEndTime, fGoodRun, fGoodSnarls, fModifiedRun, fPhysicsRun, fRopMask, fRun, fRunQualityFile, fRunQualityFileName, fRunQualityTree, fRunType, fSnarlRateMax, fSnarlRateMean, fSnarlRateMedian, fSnarlRateMin, fSnarls, fSource, fStartTime, fSubRun, fTestRun, fTimeFrames, fTriggerMask, fTriggersEnergy, fTriggersFakeSpill, fTriggersPlane, fTriggersRealSpill, fTriggersSpill, Msg::kDebug, and MSG.

Referenced by WriteSubRun().

00407 {
00408   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::WriteOutResults() *** " << endl;
00409 
00410   if( !fRunQualityFile ){
00411     MSG("FarRunQuality",Msg::kDebug) << "   opening file: " << fRunQualityFileName.Data() << endl;
00412     TDirectory* tmpd = gDirectory;
00413     fRunQualityFile = new TFile(fRunQualityFileName.Data(),"RECREATE");
00414     fRunQualityTree = new TTree("FarRunQuality","FarRunQuality");
00415     fRunQualityTree->SetAutoSave(100);
00416     fRunQualityTree->Branch("Source",&fSource,"Source/I");
00417     fRunQualityTree->Branch("Run",&fRun,"Run/I");
00418     fRunQualityTree->Branch("SubRun",&fSubRun,"SubRun/I");
00419     fRunQualityTree->Branch("RunType",&fRunType,"RunType/I");  
00420     fRunQualityTree->Branch("RopMask",&fRopMask,"RopMask/I");
00421     fRunQualityTree->Branch("CrateMask",&fCrateMask,"CrateMask/I");
00422     fRunQualityTree->Branch("TriggerMask",&fTriggerMask,"TriggerMask/I");
00423     fRunQualityTree->Branch("StartTime",&fStartTime,"StartTime/I");
00424     fRunQualityTree->Branch("EndTime",&fEndTime,"EndTime/I");
00425     fRunQualityTree->Branch("TimeFrames",&fTimeFrames,"TimeFrames/I");
00426     fRunQualityTree->Branch("Snarls",&fSnarls,"Snarls/I");
00427     fRunQualityTree->Branch("GoodSnarls",&fGoodSnarls,"GoodSnarls/I");
00428     fRunQualityTree->Branch("SnarlRateMin",&fSnarlRateMin,"MinSnarlRate/I");
00429     fRunQualityTree->Branch("SnarlRateMax",&fSnarlRateMax,"MaxSnarlRate/I");
00430     fRunQualityTree->Branch("SnarlRateMean",&fSnarlRateMean,"MeanSnarlRate/F");
00431     fRunQualityTree->Branch("SnarlRateMedian",&fSnarlRateMedian,"MedianSnarlRate/F");
00432     fRunQualityTree->Branch("PlaneTriggers",&fTriggersPlane,"PlaneTriggers/I");
00433     fRunQualityTree->Branch("EnergyTriggers",&fTriggersEnergy,"EnergyTriggers/I");
00434     fRunQualityTree->Branch("SpillTriggers",&fTriggersSpill,"SpillTriggers/I");
00435     fRunQualityTree->Branch("SpillTriggersReal",&fTriggersRealSpill,"SpillTriggersReal/I");
00436     fRunQualityTree->Branch("SpillTriggersFake",&fTriggersFakeSpill,"SpillTriggersFake/I");
00437     fRunQualityTree->Branch("PhysicsRun",&fPhysicsRun,"PhysicsRun/I");
00438     fRunQualityTree->Branch("ModifiedRun",&fModifiedRun,"ModifiedRun/I");
00439     fRunQualityTree->Branch("TestRun",&fTestRun,"TestRun/I");
00440     fRunQualityTree->Branch("GoodRun",&fGoodRun,"GoodRun/I");
00441     gDirectory = tmpd;
00442   }
00443 
00444   if( fRunQualityFile ){
00445     TDirectory* tmpd = gDirectory;
00446     fRunQualityFile->cd();
00447     fRunQualityTree->Fill();
00448     gDirectory = tmpd;
00449   }
00450 }

void FillFarRunQuality::WriteSubRun (  )  [private]

Definition at line 954 of file FillFarRunQuality.cxx.

References fReadFromDatabase, fSource, fWriteOutResults, fWriteToDatabase, Msg::kDebug, MSG, ReadFromDatabase(), WriteOutResults(), and WriteToDatabase().

Referenced by EndSubRun().

00955 {
00956   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::WriteSubRun() *** " << endl;
00957 
00958   // write results to file
00959   // =====================
00960   if( fWriteOutResults ){
00961     fSource = 0;
00962     this->WriteOutResults();
00963   }
00964 
00965   // write results to database
00966   // =========================
00967   if( fWriteToDatabase ){
00968     this->WriteToDatabase();
00969     if( fWriteOutResults ){
00970       fSource = 1;
00971       this->WriteOutResults();
00972     }
00973   }
00974     
00975   // read results from database
00976   // ==========================
00977   if( fReadFromDatabase ){
00978     this->ReadFromDatabase();
00979     if( fWriteOutResults ){
00980       fSource = 2;
00981       this->WriteOutResults();
00982     }
00983   }
00984 
00985 }

void FillFarRunQuality::WriteToDatabase (  )  [private]

Definition at line 221 of file FillFarRunQuality.cxx.

References DbiCascader::CreateTemporaryTable(), fCrateMask, fEndTime, fGoodRun, fGoodSnarls, fModifiedRun, fPhysicsRun, fRopMask, fRun, fRunType, fSnarlRateMax, fSnarlRateMean, fSnarlRateMedian, fSnarlRateMin, fSnarls, fStartTime, fSubRun, fTestRun, fTimeFrames, fTriggerMask, fTriggersEnergy, fTriggersFakeSpill, fTriggersPlane, fTriggersRealSpill, fTriggersSpill, DbiTableProxyRegistry::GetCascader(), DbiTableProxyRegistry::Instance(), SimFlag::kData, Msg::kDebug, Detector::kFar, Msg::kVerbose, Msg::kWarning, MSG, and DbiCascader::TableExists().

Referenced by WriteSubRun().

00222 {
00223   MSG("FarRunQuality",Msg::kDebug) << " *** FillFarRunQuality::WriteToDatabase() *** " << endl;
00224 
00225   // Protect against null entries
00226   if( fStartTime<=0 || fEndTime<=0 
00227    || fRun<=0 || fTimeFrames<=0 ){
00228     MSG("FarRunQuality",Msg::kWarning) << " *** Run has no timeframes, no database entry will be created *** " << endl;
00229     return;
00230   }
00231 
00232   // Protect against non-physics runs
00233   if( fPhysicsRun<=0 ){
00234     MSG("FarRunQuality",Msg::kWarning) << " *** This is not a physics run, no database entry will be created *** " << endl;
00235     return;
00236   }
00237 
00238   DbiCascader& cascader = DbiTableProxyRegistry::Instance().GetCascader();
00239 
00240   if( !cascader.TableExists("DBUFARRUNQUALITY") ){
00241     MSG("FarRunQuality",Msg::kDebug) << "    Creating temporary DBUFARRUNQUALITY table " << endl;
00242 
00243     string tableDescr = "(SEQNO int, RUN int, SUBRUN int, RUNTYPE int, ROPMASK int, CRATEMASK int, TRIGGERMASK int, STARTTIME timestamp, ENDTIME timestamp, TIMEFRAMES int, SNARLS int, GOODSNARLS int, MINSNARLRATE int, MAXSNARLRATE int, MEANSNARLRATE float, MEDIANSNARLRATE float, PLANETRIGGERS int, ENERGYTRIGGERS int, SPILLTRIGGERS int, SPILLTRIGGERSREAL int, SPILLTRIGGERSFAKE int, PHYSICSRUN int, MODIFIEDRUN int, TESTRUN int)";
00244       
00245     Int_t dbNoTempDb = cascader.CreateTemporaryTable("DBUFARRUNQUALITY",tableDescr);
00246 
00247     MSG("FarRunQuality",Msg::kDebug) << "    DbNoTempDb=" << dbNoTempDb << endl;
00248   }
00249 
00250   if( cascader.TableExists("DBUFARRUNQUALITY") ){
00251     MSG("FarRunQuality",Msg::kVerbose) << "    Writing to DBUFARRUNQUALITY table... " << endl;
00252 
00253     VldTimeStamp start(fStartTime,0);
00254     VldTimeStamp end(fEndTime,0);
00255     TString logentry("Run Quality (Run=");
00256     logentry+=fRun;
00257     logentry.Append("/");
00258     logentry+=fSubRun;
00259     logentry.Append(")");
00260 
00261     MSG("FarRunQuality",Msg::kVerbose) << "     run: " << fRun << "/" << fSubRun << endl; 
00262     MSG("FarRunQuality",Msg::kVerbose) << "     start time: " << start << endl;
00263     MSG("FarRunQuality",Msg::kVerbose) << "     end time: " << end << endl;
00264     MSG("FarRunQuality",Msg::kVerbose) << "     log entry: " << logentry.Data() << endl;
00265 
00266     VldRange range(Detector::kFar,SimFlag::kData,start,end,logentry.Data());
00267 
00268     DbuFarRunQuality row( fRun,fSubRun,fRunType,
00269                       fRopMask,fCrateMask,fTriggerMask, 
00270                       start,end,fTimeFrames,
00271                       fSnarls,fGoodSnarls,
00272                       fSnarlRateMin,fSnarlRateMax, 
00273                       fSnarlRateMean,fSnarlRateMedian,
00274                       fTriggersPlane,fTriggersEnergy, 
00275                       fTriggersSpill,fTriggersRealSpill,fTriggersFakeSpill,
00276                       fPhysicsRun,fModifiedRun,fTestRun );
00277     fGoodRun = row.GetGoodRun();
00278 
00279     Int_t aggNo = row.GetAggregateNo();
00280     Dbi::Task task = 0;
00281     VldTimeStamp creationDate;
00282 
00283     MSG("FarRunQuality",Msg::kVerbose) << "     aggNo: " << aggNo << " taskNo: " << task << endl;
00284 
00285     DbiWriter<DbuFarRunQuality> writer(range,aggNo,task,creationDate,0,logentry.Data());
00286     writer << row;
00287     writer.Close();
00288 
00289     MSG("FarRunQuality",Msg::kDebug) << endl
00290                                   << " WRITING RESULTS: " << endl
00291                                   << " =============== " << endl
00292                                   << " Run=" << fRun << endl
00293                                   << " SubRun=" << fSubRun << endl
00294                                   << " RunType=" << fRunType << endl
00295                                   << " RopMask=" << fRopMask << endl
00296                                   << " CrateMask=" << fCrateMask << endl
00297                                   << " TriggerMask=" << fTriggerMask << endl
00298                                   << " StartTime=" << fStartTime << endl
00299                                   << " EndTime=" << fEndTime << endl
00300                                   << " TimeFrames=" << fTimeFrames << endl
00301                                   << " Snarls=" << fSnarls << endl
00302                                   << " GoodSnarls=" << fGoodSnarls << endl
00303                                   << " MinSnarlRate=" << fSnarlRateMin << endl
00304                                   << " MaxSnarlRate=" << fSnarlRateMax << endl
00305                                   << " MeanSnarlRate=" << fSnarlRateMean << endl
00306                                   << " MedianSnarlRate=" << fSnarlRateMedian << endl
00307                                   << " PlaneTriggers=" << fTriggersPlane << endl
00308                                   << " EnergyTriggers=" << fTriggersEnergy << endl
00309                                   << " SpillTriggers=" << fTriggersSpill << endl
00310                                   << " SpillTriggersReal=" << fTriggersRealSpill << endl
00311                                   << " SpillTriggersFake=" << fTriggersFakeSpill << endl
00312                                   << " PhysicsRun=" << fPhysicsRun << endl
00313                                   << " ModifiedRun=" << fModifiedRun << endl
00314                                   << " TestRun=" << fTestRun << endl
00315                                   << " GoodRun=" << fGoodRun << endl;
00316 
00317   }
00318 }


Member Data Documentation

Int_t FillFarRunQuality::fCounter [private]

Definition at line 39 of file FillFarRunQuality.h.

Referenced by ProcessHeader(), and Reset().

Definition at line 74 of file FillFarRunQuality.h.

Referenced by EndSubRun(), ProcessBlock(), Reset(), and ~FillFarRunQuality().

Int_t FillFarRunQuality::fEndTime [private]

Definition at line 40 of file FillFarRunQuality.h.

Referenced by ProcessHeader(), and Reset().

Int_t FillFarRunQuality::fGoodRun [private]

Definition at line 41 of file FillFarRunQuality.h.

Referenced by ProcessBlock(), ProcessHeader(), and Reset().

Definition at line 42 of file FillFarRunQuality.h.

Referenced by ProcessBlock(), and Reset().

Definition at line 43 of file FillFarRunQuality.h.

Referenced by ProcessBlock(), and Reset().

Definition at line 89 of file FillFarRunQuality.h.

Referenced by ProcessBlock(), and ~FillFarRunQuality().

Definition at line 34 of file FillFarRunQuality.h.

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

Definition at line 44 of file FillFarRunQuality.h.

Referenced by ProcessBlock(), and Reset().

Int_t FillFarRunQuality::fRecord [private]

Definition at line 38 of file FillFarRunQuality.h.

Referenced by Get().

Int_t FillFarRunQuality::fRopMask [private]
Int_t FillFarRunQuality::fRun [private]

Definition at line 29 of file FillFarRunQuality.h.

Referenced by WriteOutFile(), and WriteOutResults().

Definition at line 32 of file FillFarRunQuality.h.

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

Definition at line 30 of file FillFarRunQuality.h.

Referenced by WriteOutFile(), and WriteOutResults().

Int_t FillFarRunQuality::fRunType [private]

Definition at line 73 of file FillFarRunQuality.h.

Referenced by EndSubRun(), ProcessHeader(), Reset(), and ~FillFarRunQuality().

Int_t FillFarRunQuality::fSnarls [private]
Int_t FillFarRunQuality::fSource [private]

Definition at line 47 of file FillFarRunQuality.h.

Referenced by Reset(), WriteOutResults(), and WriteSubRun().

Int_t FillFarRunQuality::fSubRun [private]
Int_t FillFarRunQuality::fTestRun [private]
Int_t FillFarRunQuality::fTime [private]

Definition at line 37 of file FillFarRunQuality.h.

Referenced by ProcessHeader(), and Reset().

Definition at line 45 of file FillFarRunQuality.h.

Referenced by ProcessHeader(), and Reset().

Definition at line 35 of file FillFarRunQuality.h.

Referenced by Config(), DefaultConfig(), EndJob(), and WriteSubRun().

Definition at line 33 of file FillFarRunQuality.h.

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


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1