AlgDataQuality Class Reference

#include <AlgDataQuality.h>

Inheritance diagram for AlgDataQuality:

AlgBase List of all members.

Public Member Functions

 AlgDataQuality ()
 ~AlgDataQuality ()
void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
void Trace (const char *c) const

Detailed Description

Definition at line 6 of file AlgDataQuality.h.


Constructor & Destructor Documentation

AlgDataQuality::AlgDataQuality (  ) 

Definition at line 33 of file AlgDataQuality.cxx.

00034 {
00035 
00036 }

AlgDataQuality::~AlgDataQuality (  ) 

Definition at line 38 of file AlgDataQuality.cxx.

00039 {
00040 
00041 }


Member Function Documentation

void AlgDataQuality::RunAlg ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

Implements AlgBase.

Definition at line 43 of file AlgDataQuality.cxx.

References CandHandle::AddDaughterLink(), DQRawDigits::At(), DQHotColdElectronics::At(), DQLightInjection::At(), AlgFactory::GetAlgHandle(), DQHeader::GetBaseNanosec(), CandDataQualityHandle::GetBusyChips(), DQLightInjection::GetCalibPoint(), DQLightInjection::GetCalibType(), CandContext::GetCandRecord(), CandDataQualityHandle::GetColdChips(), CandDataQualityHandle::GetCrateMask(), CandContext::GetDataIn(), CandDataQualityHandle::GetDataQuality(), CandDataQualityHandle::GetErrorCode(), DQHeader::GetErrorCode(), CandDataQualityHandle::GetHotChips(), AlgFactory::GetInstance(), DQLightInjection::GetLast(), DQHotColdElectronics::GetLast(), DQRawDigits::GetLast(), CandDataQualityHandle::GetLiCalibPoint(), CandDataQualityHandle::GetLiCalibType(), CandDataQualityHandle::GetLiPulseHeight(), CandDataQualityHandle::GetLiPulserBox(), CandDataQualityHandle::GetLiPulserLed(), CandDataQualityHandle::GetLiPulseWidth(), CandDataQualityHandle::GetLiRelativeTime(), CandDataQualityHandle::GetLiSubtractedTime(), CandDataQualityHandle::GetLiTime(), CandDataQualityHandle::GetLiTrigger(), CandContext::GetMom(), DQHotColdElectronics::GetNumberOfCrates(), DQHotColdElectronics::GetNumberOfCratesInReadout(), CandDataQualityHandle::GetPostTriggerDigits(), DQRawDigits::GetPostTriggerDigits(), CandDataQualityHandle::GetPreTriggerDigits(), DQRawDigits::GetPreTriggerDigits(), DQLightInjection::GetPulseHeight(), DQLightInjection::GetPulserBox(), DQLightInjection::GetPulserLed(), DQLightInjection::GetPulseWidth(), CandDataQualityHandle::GetReadoutErrors(), CandDataQualityHandle::GetRun(), DQHeader::GetRun(), CandDataQualityHandle::GetRunType(), DQHeader::GetRunType(), CandDataQualityHandle::GetSnarl(), DQHeader::GetSnarl(), CandDataQualityHandle::GetSnarlMultiplicity(), DQRawDigits::GetSnarlMultiplicity(), DQRawDigits::GetSnarlPassFail(), CandDataQualityHandle::GetSpillStatus(), DQSpillServer::GetSpillStatus(), CandDataQualityHandle::GetSpillTimeError(), DQSpillServer::GetSpillTimeError(), CandDataQualityHandle::GetSpillType(), DQSpillServer::GetSpillType(), CandDataQualityHandle::GetSubRun(), DQHeader::GetSubRun(), CandDataQualityHandle::GetTime(), DQSpillServer::GetTime(), DQLightInjection::GetTime(), DQHotColdElectronics::GetTime(), DQRawDigits::GetTime(), DQHeader::GetTime(), CandDataQualityHandle::GetTimeFrame(), DQHeader::GetTimeFrame(), DQHeader::GetTriggerNanosec(), CandDataQualityHandle::GetTriggerSource(), DQHeader::GetTriggerSource(), CandDataQualityHandle::GetTriggerTime(), CandDataQuality::kBad, Msg::kDebug, CandDataQuality::kFailed, Detector::kFar, CandDataQuality::kHighMultiplicity, CandDataQuality::kLightInjection, CandDataQuality::kLowMultiplicity, CandDataQuality::kManyBusyChips, CandDataQuality::kManyColdChips, CandDataQuality::kManyHotChips, CandDataQuality::kManyReadoutErrors, Detector::kNear, CandDataQuality::kOkay, CandDataQuality::kTimeFrameBoundary, CandDeadChip::MakeCandidate(), MSG, CandDataQualityHandle::SetCrateMask(), CandDataQualityHandle::SetDataQuality(), CandDataQualityHandle::SetErrorCode(), CandDataQualityHandle::SetLiCalibPoint(), CandDataQualityHandle::SetLiCalibType(), CandDataQualityHandle::SetLiPulseHeight(), CandDataQualityHandle::SetLiPulserBox(), CandDataQualityHandle::SetLiPulserLed(), CandDataQualityHandle::SetLiPulseWidth(), CandDataQualityHandle::SetLiRelativeTime(), CandDataQualityHandle::SetLiSubtractedTime(), CandDataQualityHandle::SetLiTime(), CandDataQualityHandle::SetLiTrigger(), CandHandle::SetName(), CandDataQualityHandle::SetPostTriggerDigits(), CandDataQualityHandle::SetPreTriggerDigits(), CandDataQualityHandle::SetRun(), CandDataQualityHandle::SetRunType(), CandDataQualityHandle::SetSnarl(), CandDataQualityHandle::SetSnarlMultiplicity(), CandDataQualityHandle::SetSpillStatus(), CandDataQualityHandle::SetSpillTimeError(), CandDataQualityHandle::SetSpillType(), CandDataQualityHandle::SetSubRun(), CandDataQualityHandle::SetTime(), CandDataQualityHandle::SetTimeFrame(), CandHandle::SetTitle(), CandDataQualityHandle::SetTriggerSource(), and CandDataQualityHandle::SetTriggerTime().

00044 {
00045   MSG("DataQuality", Msg::kDebug) << " AlgDataQuality::RunAlg(...) " << endl;
00046 
00047   Int_t i,j;
00048   Int_t addme;
00049   Int_t time,subtime;
00050   Int_t fSnarlPassFail;
00051 
00052   CandDataQualityHandle& cdh = dynamic_cast<CandDataQualityHandle&>(ch);
00053   const TObjArray* arr = dynamic_cast<const TObjArray*>(cx.GetDataIn());
00054 
00055   CandRecord* candrec = (CandRecord*)(cx.GetCandRecord());
00056   Detector::Detector_t detector = candrec->GetVldContext()->GetDetector();
00057   
00058 
00059   // STORE DATA QUALITY INFORMATION
00060   // ==============================
00061   // Sort through monitoring objects and store header information
00062 
00063   MSG("DataQuality", Msg::kDebug) << " Store the Header Information " << endl;
00064 
00065   // Store information from the data quality header
00066   //  [ run, snarl, timeframe, trigger source etc ... ]
00067   DQHeader* myDQHeader = (DQHeader*)(arr->At(0));
00068   MSG("DataQuality", Msg::kDebug) << " Header (+" << myDQHeader->GetTime()-myDQHeader->GetTime() << ")" << endl; 
00069   MSG("DataQuality", Msg::kDebug) << "     [run=" << myDQHeader->GetRun() << ", snarl=" << myDQHeader->GetSnarl() << "]" << endl;
00070   MSG("DataQuality", Msg::kDebug) << "     [trigger=" << myDQHeader->GetTriggerNanosec() << ", base=" << myDQHeader->GetBaseNanosec() << ", subtracted=" << myDQHeader->GetTriggerNanosec()-myDQHeader->GetBaseNanosec() << "]" << endl;
00071   cdh.SetTime(myDQHeader->GetTime());
00072   cdh.SetRunType(myDQHeader->GetRunType());
00073   cdh.SetRun(myDQHeader->GetRun());
00074   cdh.SetSubRun(myDQHeader->GetSubRun());
00075   cdh.SetTimeFrame(myDQHeader->GetTimeFrame());
00076   cdh.SetSnarl(myDQHeader->GetSnarl());
00077   cdh.SetTriggerSource(myDQHeader->GetTriggerSource());
00078   cdh.SetTriggerTime(myDQHeader->GetTriggerNanosec());
00079   cdh.SetErrorCode(myDQHeader->GetErrorCode());
00080   fSnarlPassFail = 1;
00081 
00082   // Store information on the raw digit data block
00083   //  [ readout errors, busy electronics etc ... ]
00084   DQRawDigits* myDQRawDigits = (DQRawDigits*)(arr->At(1));
00085   MSG("DataQuality", Msg::kDebug) << " Raw Digits (+" << myDQRawDigits->GetTime()-myDQHeader->GetTime() << ")" << endl;
00086   MSG("DataQuality", Msg::kDebug) << "     [pre hits=" << myDQRawDigits->GetPreTriggerDigits() << ", post hits=" << myDQRawDigits->GetPostTriggerDigits() << ", snarl hits=" << myDQRawDigits->GetSnarlMultiplicity() << ", busy/error chips=" << 1+myDQRawDigits->GetLast()<< ", pass/fail=" << myDQRawDigits->GetSnarlPassFail() << "]" << endl;
00087   cdh.SetPreTriggerDigits(myDQRawDigits->GetPreTriggerDigits());
00088   cdh.SetPostTriggerDigits(myDQRawDigits->GetPostTriggerDigits());
00089   cdh.SetSnarlMultiplicity(myDQRawDigits->GetSnarlMultiplicity());
00090   fSnarlPassFail = myDQRawDigits->GetSnarlPassFail();
00091   
00092   // Store information on the hot and cold electronics (check time)
00093   // [ crate mask etc... ]
00094   DQHotColdElectronics* myDQHotColdElectronics = (DQHotColdElectronics*)(arr->At(2));
00095   if( myDQHotColdElectronics->GetTime()>0 ){
00096     MSG("DataQuality", Msg::kDebug) << " Hot/Cold Electronics (+" << myDQHotColdElectronics->GetTime()-myDQHeader->GetTime() << ")" << endl;
00097     MSG("DataQuality", Msg::kDebug) << "     [crates=" << myDQHotColdElectronics->GetNumberOfCrates() << ", hot/cold chips=" << 1+myDQHotColdElectronics->GetLast() << "]" << endl;
00098   }
00099   if( myDQHotColdElectronics->GetTime()>0
00100    && myDQHotColdElectronics->GetTime()-myDQHeader->GetTime()==0 ){
00101     cdh.SetCrateMask(myDQHotColdElectronics->GetNumberOfCratesInReadout());
00102   }
00103   
00104   // Store information on light injection (check time)
00105   //  [ LI type, LI pulser box/led, LI pulse parameters, LI time etc... ]
00106   DQLightInjection* myDQLightInjection = (DQLightInjection*)(arr->At(3));
00107   if( myDQLightInjection->GetTime()>0 ){
00108     MSG("DataQuality", Msg::kDebug) << " Light Injection (+" << myDQLightInjection->GetTime()-myDQHeader->GetTime() << ")" << endl;
00109     MSG("DataQuality", Msg::kDebug) << "     [box=" << myDQLightInjection->GetPulserBox() << ", led=" << myDQLightInjection->GetPulserLed() << ", tpmt hits=" << 1+myDQLightInjection->GetLast()<< "]" << endl;
00110   }
00111   if( myDQLightInjection->GetTime()>0 
00112    && myDQLightInjection->GetTime()-myDQHeader->GetTime()==0 ){
00113     cdh.SetLiCalibPoint(myDQLightInjection->GetCalibPoint());
00114     cdh.SetLiCalibType(myDQLightInjection->GetCalibType());
00115     cdh.SetLiPulserBox(myDQLightInjection->GetPulserBox());
00116     cdh.SetLiPulserLed(myDQLightInjection->GetPulserLed());
00117     cdh.SetLiPulseHeight(myDQLightInjection->GetPulseHeight());
00118     cdh.SetLiPulseWidth(myDQLightInjection->GetPulseWidth());
00119   }
00120 
00121   // Store information on spills (check time)
00122   //  [ spill status, type, time error etc... ]
00123   DQSpillServer* myDQSpillServer = (DQSpillServer*)(arr->At(4));
00124   if( myDQSpillServer->GetTime()>0 ){
00125     MSG("DataQuality", Msg::kDebug) << " Spill Server (+" << myDQSpillServer->GetTime()-myDQHeader->GetTime() << ")" << endl;
00126     MSG("DataQuality", Msg::kDebug) << "     [status=" << myDQSpillServer->GetSpillStatus() << ", type=" << myDQSpillServer->GetSpillType() << ", error=" << myDQSpillServer->GetSpillTimeError() << "]" << endl;
00127   }
00128   if( myDQSpillServer->GetTime()>0 
00129    && myDQSpillServer->GetTime()-myDQHeader->GetTime()==0 ){
00130     cdh.SetSpillStatus(myDQSpillServer->GetSpillStatus());
00131     cdh.SetSpillType(myDQSpillServer->GetSpillType());
00132     cdh.SetSpillTimeError(myDQSpillServer->GetSpillTimeError());
00133   }
00134   
00135   
00136   // CALCULATE THE CLOSEST TPMT HIT
00137   // ==============================
00138   // look in window [-100,+100] microseconds around trigger time
00139     
00140   if( myDQLightInjection->GetTime()>0 
00141    && myDQLightInjection->GetTime()-myDQHeader->GetTime()==0 ){
00142 
00143     Int_t fMinSubTime=-100000;
00144     Int_t fMaxSubTime=+100000;
00145     
00146     Int_t litrigger=0;
00147     Int_t litime=-99999;
00148     Int_t lisubtime=-99999;
00149     Int_t lireltime=-99999;
00150 
00151     for(i=0;i<1+myDQLightInjection->GetLast();i++){
00152       RawChip* tpmt = (RawChip*)(myDQLightInjection->At(i));
00153 
00154       time=tpmt->GetNanosec();
00155       subtime=tpmt->GetNanosec()-(myDQHeader->GetTriggerNanosec()-myDQHeader->GetBaseNanosec());
00156 
00157       if( (subtime>fMinSubTime && subtime<fMaxSubTime) 
00158        && (lireltime<0 || abs(subtime)<lireltime) ){
00159         litrigger=1;
00160         litime=time;
00161         lisubtime=subtime;
00162         lireltime=abs(subtime);
00163       }
00164     }
00165     
00166     MSG("DataQuality", Msg::kDebug) << " Tpmt Hits (+" << myDQLightInjection->GetTime()-myDQHeader->GetTime() << ")" << endl;
00167     MSG("DataQuality", Msg::kDebug) << "     [trigger=" << litrigger << ", litime=" << litime << ", lisubtime=" << lisubtime << ", lireltime=" << lireltime << "]" << endl;
00168 
00169     cdh.SetLiTrigger(litrigger);
00170     cdh.SetLiTime(litime);
00171     cdh.SetLiSubtractedTime(lisubtime);
00172     cdh.SetLiRelativeTime(lireltime);
00173 }
00174 
00175 
00176   // STORE THE BAD CHANNELS
00177   // ======================
00178   //
00179  
00180   MSG("DataQuality", Msg::kDebug) << " Sort the Bad Chips " << endl;
00181 
00182   TObjArray* badelectronics = new TObjArray();
00183 
00184   // Adding Hot/Cold Chips
00185   for(i=0;i<1+myDQHotColdElectronics->GetLast();i++){
00186     RawChip* badchip = (RawChip*)(myDQHotColdElectronics->At(i));
00187     addme=1;
00188     for(j=0;j<1+badelectronics->GetLast();j++){
00189       TObjArray* tmparray = (TObjArray*)(badelectronics->At(j));
00190       RawChip* tmpchip = (RawChip*)(tmparray->First());
00191       if( badchip->IsSameChip(tmpchip) ){
00192         tmparray->Add(badchip);
00193         addme=0;
00194       }
00195     }
00196     if( addme ){
00197       TObjArray* newarray = new TObjArray();
00198       newarray->Add(badchip);
00199       badelectronics->Add(newarray);
00200     }
00201   }
00202 
00203   // Adding Raw Digits
00204   for(i=0;i<1+myDQRawDigits->GetLast();i++){
00205     RawChip* badchip = (RawChip*)(myDQRawDigits->At(i));
00206     addme=1;
00207     for(j=0;j<1+badelectronics->GetLast();j++){
00208       TObjArray* tmparray = (TObjArray*)(badelectronics->At(j));
00209       RawChip* tmpchip = (RawChip*)(tmparray->First());
00210       if( badchip->IsSameChip(tmpchip) ){
00211         tmparray->Add(badchip);
00212         addme=0;
00213       }
00214     }
00215     if( addme ){
00216       TObjArray* newarray = new TObjArray();
00217       newarray->Add(badchip);
00218       badelectronics->Add(newarray);
00219     }
00220   }
00221 
00222   MSG("DataQuality", Msg::kDebug) << "   ... Found " << 1+badelectronics->GetLast() << " Bad Chips " << endl;
00223 
00224   // Create CandDeadChips
00225   AlgFactory &af = AlgFactory::GetInstance();
00226   AlgHandle ah = af.GetAlgHandle("AlgDeadChip", "default");
00227   CandContext mycx(this, cx.GetMom());
00228   mycx.SetCandRecord(candrec);
00229 
00230   for(i=0;i<1+badelectronics->GetLast();i++){
00231     TObjArray* tmparray = (TObjArray*)(badelectronics->At(i)); 
00232     mycx.SetDataIn(tmparray);
00233     CandDeadChipHandle deadchip = CandDeadChip::MakeCandidate(ah,mycx);
00234     deadchip.SetName(TString("CandDeadChipHandle"));
00235     deadchip.SetTitle(TString("Created by CandDataQualityModule"));
00236     cdh.AddDaughterLink(deadchip);
00237   }
00238 
00239   badelectronics->Delete();
00240   delete badelectronics;
00241 
00242 
00243   // SET THE DATA QUALITY SUMMARY
00244   // ============================
00245 
00246   CandDataQuality::DataQuality_t quality(CandDataQuality::kOkay);
00247   
00248   // Far Detector
00249   if( detector==Detector::kFar ){
00250 
00251     Int_t fMinMultiplicity=10;
00252     Int_t fMaxMultiplicity=1000;
00253     Int_t fMaxColdChips=20;
00254     Int_t fMaxBusyChips=20;
00255     Int_t fMaxHotChips=9999;
00256     Int_t fMaxReadoutErrors=9999;
00257 
00258     // low multiplicity (less than 10 hits)
00259     if( cdh.GetSnarlMultiplicity()<fMinMultiplicity ){
00260       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kLowMultiplicity);
00261     }
00262 
00263     // high multiplicity (more than 1000 hits)
00264     if( cdh.GetSnarlMultiplicity()>fMaxMultiplicity ){
00265       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kHighMultiplicity);
00266     }
00267 
00268     // proximity to Light Injection
00269     if( cdh.GetLiTrigger()==1 ){
00270       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kLightInjection);
00271     };
00272 
00273     // proximity to Timeframe Boundary
00274     if( cdh.GetTriggerTime()-1000000000>-100000 ){
00275       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kTimeFrameBoundary);
00276     }
00277 
00278     // too many cold chips
00279     if( cdh.GetColdChips()>fMaxColdChips ){
00280       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kBad);
00281       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kManyColdChips);
00282     }
00283 
00284     // too many hot chips
00285     if( cdh.GetBusyChips()>fMaxHotChips ){
00286       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kBad);
00287       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kManyHotChips);
00288     }
00289 
00290     // too many busy chips
00291     if( cdh.GetBusyChips()>fMaxBusyChips ){
00292       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kBad);
00293       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kManyBusyChips);
00294     }
00295 
00296     // too many readout errors
00297     if( cdh.GetReadoutErrors()>fMaxReadoutErrors ){
00298       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kBad);
00299       quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kManyReadoutErrors);
00300     }
00301 
00302   }
00303 
00304   // Near Detector
00305   if( detector==Detector::kNear ){
00306 
00307     //
00308     // SET NEAR DETECTOR STUFF
00309     //
00310 
00311   }
00312 
00313   // bailed out of snarl
00314   if( fSnarlPassFail==0 ){
00315     quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kBad);
00316     quality=(CandDataQuality::DataQuality_t)(quality|CandDataQuality::kFailed);
00317   }
00318 
00319   // set data quality summary
00320   cdh.SetDataQuality(quality);
00321 
00322 
00323   MSG("DataQuality", Msg::kDebug) << endl  
00324     << "   NEW CANDDATAQUALITYHANDLE " << endl
00325     << "   ========================= " << endl
00326     << "    Time=" << cdh.GetTime() << endl
00327     << "    RunType=" << cdh.GetRunType() << endl
00328     << "    Run=" << cdh.GetRun() << endl
00329     << "    SubRun=" << cdh.GetSubRun() << endl
00330     << "    TimeFrame=" << cdh.GetTimeFrame() << endl
00331     << "    Snarl=" << cdh.GetSnarl() << endl
00332     << "    TriggerSource=" << cdh.GetTriggerSource() << endl
00333     << "    TriggerTime=" << cdh.GetTriggerTime() << endl
00334     << "    ErrorCode=" << cdh.GetErrorCode() << endl
00335     << "    CrateMask=" << cdh.GetCrateMask() << endl
00336     << "    PreTriggerDigits=" << cdh.GetPreTriggerDigits() << endl
00337     << "    PostTriggerDigits=" << cdh.GetPostTriggerDigits() << endl
00338     << "    SnarlMultiplicity=" << cdh.GetSnarlMultiplicity() << endl
00339     << "    SpillStatus=" << cdh.GetSpillStatus() << endl
00340     << "    SpillType=" << cdh.GetSpillType() << endl
00341     << "    SpillTimeError=" << cdh.GetSpillTimeError() << endl
00342     << "    LiTrigger=" << cdh.GetLiTrigger() << endl
00343     << "    LiTime=" << cdh.GetLiTime() << endl
00344     << "    LiSubtractedTime=" << cdh.GetLiSubtractedTime() << endl
00345     << "    LiRelativeTime=" << cdh.GetLiRelativeTime() << endl
00346     << "    LiCalibPoint=" << cdh.GetLiCalibPoint() << endl
00347     << "    LiCalibType=" << cdh.GetLiCalibType() << endl
00348     << "    LiPulserBox=" << cdh.GetLiPulserBox() << endl
00349     << "    LiPulserLed=" << cdh.GetLiPulserLed() << endl
00350     << "    LiPulseHeight=" << cdh.GetLiPulseHeight() << endl
00351     << "    LiPulseWidth=" << cdh.GetLiPulseWidth() << endl
00352     << "    ColdChips=" << cdh.GetColdChips() << endl
00353     << "    HotChips=" << cdh.GetHotChips() << endl
00354     << "    BusyChips=" << cdh.GetBusyChips() << endl
00355     << "    ReadoutErrors=" << cdh.GetReadoutErrors() << endl
00356     << "    DataQuality=" << cdh.GetDataQuality() << endl;
00357 
00358   return;
00359 }

void AlgDataQuality::Trace ( const char *  c  )  const [virtual]

Reimplemented from AlgBase.

Definition at line 361 of file AlgDataQuality.cxx.

00362 {
00363 
00364 }


The documentation for this class was generated from the following files:
Generated on Wed Sep 10 22:50:42 2014 for loon by  doxygen 1.4.7