FillBadChannelDB Class Reference

#include <FillBadChannelDB.h>

Inheritance diagram for FillBadChannelDB:
JobCModule

List of all members.

Public Member Functions

 FillBadChannelDB ()
 ~FillBadChannelDB ()
void BeginJob ()
JobCResult Ana (const MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)
void EndJob ()

Private Member Functions

void ProcessHeader (TObject *obj)
void ProcessBlock (TObject *obj)
void Initialise ()
void Reset ()
void AnalyseRawDigits ()
void AnalyseTpSingles ()
void FindBadChannels ()
void WriteToDatabase (Int_t crate, Int_t master, Int_t minder, Int_t menu, Int_t starttime, Int_t endtime, Int_t reason)
void WriteAllBadToDatabase (Int_t startTime, Int_t endTime, std::map< RawChannelId, Int_t > &badList)
void WriteOutResults ()
void CloseFile ()

Private Attributes

Int_t fRecCounter
Int_t fWriteOutResults
Int_t fWriteToDatabase
TFile * fBadChannelFile
TTree * fBadChannelTree
Int_t fADCCut
Double_t fAverageADCCut
Double_t fAverageADCCutFactor
Double_t fAverageADCCutPercentile
Int_t fNdigitsCut
Double_t fNdigitsCutFactor
Double_t fNdigitsCutPercentile
Int_t fNdigitsColdCut
Double_t fNdigitsColdCutFactor
Double_t fNdigitsColdCutPercentile
Int_t fRun
Int_t fSubRun
Int_t fRunType
Int_t fSnarl
Int_t fTrigSrc
Int_t fDigits
Int_t fTrigTime
Int_t fTrigBaseTime
Int_t fTimeFrame
Int_t fTime
Int_t fADC
Int_t fTDC
Int_t fDeltaTDC
Int_t fCrate
Int_t fMaster
Int_t fMinder
Int_t fMenu
Int_t fCrateT0sec
Int_t fCrateT0nsec
Int_t fDataType
Int_t fErrorCode
Int_t fFoundErrorBit
Int_t fRate
Int_t fReadoutInt
NearReadoutfReadout
Int_t fPhysicsRun
Int_t fStartTime
Int_t fEndTime
Int_t fMinRunLength
Int_t fMinTDC
Int_t fMaxTDC
Int_t fNdigits
Int_t fNdigitsHighADC
Int_t fNdigitsErrorBits
Double_t fAverageADC
Int_t fBadChannel
UInt_t fBadnessReason
Int_t fCountDigits [8][16][8][16]
Int_t fCountDigitsErrors [8][16][8][16]
Int_t fCountDigitsHighADC [8][16][8][16]
Int_t fTotalTDCWindow [8][16][8][16]
Double_t fIntegrateDigits [8][16][8][16]
Double_t fIntegrateDigitsADC [8][16][8][16]
Int_t fTotalCrateDigits [8]
Double_t fTotalCrateADC [8]
Int_t fTotalDigitsInCrate
Double_t fTotalADCInCrate

Detailed Description

Definition at line 19 of file FillBadChannelDB.h.


Constructor & Destructor Documentation

FillBadChannelDB::FillBadChannelDB (  ) 

Definition at line 52 of file FillBadChannelDB.cxx.

References fReadout, Initialise(), Msg::kVerbose, MSG, and Reset().

00052                                    :
00053   fRecCounter(0),
00054   fWriteOutResults(0),
00055   fWriteToDatabase(0),
00056   fBadChannelFile(0),
00057   fBadChannelTree(0),
00058   fADCCut(32766),
00059   fAverageADCCutFactor(3),
00060   fAverageADCCutPercentile(0.975),
00061   fNdigitsCutFactor(5),
00062   fNdigitsCutPercentile(0.975),
00063         fNdigitsColdCutFactor(0.2),
00064         fNdigitsColdCutPercentile(0.025),
00065   fRun(-1),
00066   fSubRun(-1),
00067   fRunType(-1),
00068   fSnarl(0),
00069   fTrigSrc(-1),
00070   fDigits(-1),
00071   fTimeFrame(-1),
00072   fTime(-1),
00073   fPhysicsRun(-1),
00074   fStartTime(-1),
00075   fEndTime(-1),
00076         fMinRunLength(875),
00077   fMaxTDC(0)
00078 {
00079   MSG("BadChannels",Msg::kVerbose) << " *** FillBadChannelDB::FillBadChannelDB() *** " << endl;
00080 
00081   fReadout = new NearReadout();
00082 
00083   this->Initialise();
00084   this->Reset();
00085 }

FillBadChannelDB::~FillBadChannelDB (  ) 

Definition at line 87 of file FillBadChannelDB.cxx.

References fReadout, Msg::kVerbose, and MSG.

00088 {
00089   MSG("BadChannels",Msg::kVerbose) << " *** FillBadChannelDB::~FillBadChannelDB() *** " << endl;
00090   if ( fReadout ) delete fReadout;
00091 }


Member Function Documentation

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

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 139 of file FillBadChannelDB.cxx.

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

00140 {
00141   MSG("BadChannels",Msg::kDebug) << " *** FillBadChannelDB::Ana(...) [" << fRecCounter << "] *** " << endl;
00142 
00143   JobCResult result(JobCResult::kPassed);
00144 
00145   VldContext vldc;
00146   TObject* momobject = 0;
00147   Bool_t   foundit   = 0;
00148 
00149   // ===================
00150   // PROCESS RAW RECORDS
00151   // ===================
00152   // Iterate over raw records in mom and extract
00153   // monitoring information from raw data blocks
00154 
00155   TIter momitr(mom->FragmentIter());
00156   while((momobject = momitr())){
00157     if(momobject->InheritsFrom("RawRecord")){
00158       foundit = 1;
00159 
00160       if( fRecCounter%1000==0 ) MSG("BadChannels",Msg::kInfo) << " *** RAW RECORD [" << fRecCounter << "] ***  " << endl;
00161       else if( fRecCounter%100==0 ) MSG("BadChannels",Msg::kSynopsis) << " *** RAW RECORD [" << fRecCounter << "] ***  " << endl;
00162       else MSG("BadChannels",Msg::kDebug) << "  *** RAW RECORD [" << fRecCounter << "] ***  " << endl;
00163       fRecCounter++;
00164       
00165       // Get the Raw Record; 
00166       RawRecord* rawrec = dynamic_cast<RawRecord*>(momobject);
00167 
00168       // Get the raw header and extract validity context
00169       vldc = rawrec->GetRawHeader()->GetVldContext();
00170       this->ProcessHeader((TObject*)(rawrec->GetRawHeader()));
00171 
00172       // Iterate over the raw blocks in raw record
00173       TIter rawrecitr = rawrec->GetRawBlockIter();
00174       TObject* tob = 0;
00175       while((tob = rawrecitr())){
00176         MSG("BadChannels",Msg::kDebug) << " " << tob->GetName() << endl;
00177         this->ProcessBlock(tob);
00178       }
00179     }
00180   }
00181 
00182   if ( !foundit ){
00183     MSG("BadChannels", Msg::kWarning) << "  *** FAILED TO FIND RAW RECORD ***  " << endl;
00184     return result.SetFailed();
00185   }
00186 
00187   MSG("BadChannels",Msg::kDebug) << " *** FillBadChannelDB::Ana( ) FINISHED *** " << endl;
00188   return result;
00189 
00190 }

void FillBadChannelDB::AnalyseRawDigits (  )  [private]

Definition at line 454 of file FillBadChannelDB.cxx.

References fADC, fADCCut, fCountDigits, fCountDigitsErrors, fCountDigitsHighADC, fCrate, fErrorCode, fFoundErrorBit, fIntegrateDigits, fIntegrateDigitsADC, fMaster, fMenu, fMinder, RawQieDigit::kCapIdError, RawQieDigit::kCapIdSameMenuError, RawQieDigit::kCapIdSharedMinderError, RawQieDigit::kMisCountError, RawQieDigit::kParityError, RawQieDigit::kPriorityTruncate, and RawQieDigit::kTransferSharedMinderError.

Referenced by ProcessBlock().

00455 {
00456   if( fCrate>=0  && fCrate<8
00457    && fMaster>=9 && fMaster<25
00458    && fMinder>=0 && fMinder<8
00459    && fMenu>=0   && fMenu<16 ){
00460 
00461     // Count Digits
00462     fCountDigits[fCrate][fMaster-9][fMinder][fMenu]++;
00463 
00464     // Count High ADC Digits [place cut at 32767 ADCs, i.e. pow(2,15)-1]
00465     if( fADC>fADCCut ){ 
00466       fCountDigitsHighADC[fCrate][fMaster-9][fMinder][fMenu]++; 
00467     }
00468 
00469     // Calculate Average ADC [truncate at 100 ADCs]
00470     if( fADC>100 ){
00471       fIntegrateDigitsADC[fCrate][fMaster-9][fMinder][fMenu] += fADC;
00472       fIntegrateDigits[fCrate][fMaster-9][fMinder][fMenu] += 1.0;
00473     }
00474        
00475     // Count Error Bits
00476     fFoundErrorBit = 0;
00477     if( (fErrorCode&RawQieDigit::kCapIdError)==RawQieDigit::kCapIdError) fFoundErrorBit = 1;
00478     if( (fErrorCode&RawQieDigit::kParityError)==RawQieDigit::kParityError) fFoundErrorBit = 1;
00479     if( (fErrorCode&RawQieDigit::kMisCountError)==RawQieDigit::kMisCountError) fFoundErrorBit = 1; 
00480     if( (fErrorCode&RawQieDigit::kPriorityTruncate)==RawQieDigit::kPriorityTruncate) fFoundErrorBit = 1;
00481     if( (fErrorCode&RawQieDigit::kCapIdSameMenuError)==RawQieDigit::kCapIdSameMenuError) fFoundErrorBit = 1;
00482     if( (fErrorCode&RawQieDigit::kCapIdSharedMinderError)==RawQieDigit::kCapIdSharedMinderError) fFoundErrorBit = 1;
00483     if( (fErrorCode&RawQieDigit::kTransferSharedMinderError)==RawQieDigit::kTransferSharedMinderError) fFoundErrorBit = 1;
00484 
00485     if( fFoundErrorBit ){
00486       fCountDigitsErrors[fCrate][fMaster-9][fMinder][fMenu]++; 
00487     }
00488   }
00489 
00490   return;
00491 }

void FillBadChannelDB::AnalyseTpSingles (  )  [private]

Definition at line 493 of file FillBadChannelDB.cxx.

Referenced by ProcessBlock().

00494 {
00495   return;
00496 }

void FillBadChannelDB::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 134 of file FillBadChannelDB.cxx.

References Msg::kInfo, and MSG.

00135 {
00136   MSG("BadChannels",Msg::kInfo) << " *** FillBadChannelDB::BeginJob() *** " << endl;
00137 }

void FillBadChannelDB::CloseFile (  )  [private]

Definition at line 899 of file FillBadChannelDB.cxx.

References fBadChannelFile, fBadChannelTree, Msg::kInfo, and MSG.

Referenced by EndJob().

00900 {
00901   if( fBadChannelFile ){
00902     MSG("BadChannels",Msg::kInfo) << " Closing file: " << fBadChannelFile->GetName() << endl;
00903     TDirectory* tmpd = gDirectory;
00904     fBadChannelFile->cd();
00905     fBadChannelTree->Write();
00906     fBadChannelFile->Close();
00907     gDirectory = tmpd;
00908   }
00909 
00910   return;
00911 }

void FillBadChannelDB::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 218 of file FillBadChannelDB.cxx.

References fWriteOutResults, fWriteToDatabase, Registry::Get(), Msg::kInfo, and MSG.

00219 {
00220   MSG("BadChannels",Msg::kInfo) << " *** FillBadChannelDB::Config() *** " << endl;
00221 
00222   Int_t tmpint; 
00223   if(r.Get("WriteOutResults",tmpint)){
00224     fWriteOutResults = tmpint;
00225     MSG("BadChannels",Msg::kInfo) << " Config: fWriteOutResults=" << fWriteOutResults << endl;
00226   }
00227   if(r.Get("WriteToDatabase",tmpint)){
00228     fWriteToDatabase = tmpint;
00229     MSG("BadChannels",Msg::kInfo) << " Config: fWriteToDatabase=" << fWriteToDatabase << endl;
00230   }
00231 
00232   return;
00233 }

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

References fWriteOutResults, fWriteToDatabase, Msg::kInfo, Registry::LockValues(), MSG, Registry::Set(), and Registry::UnLockValues().

00205 {
00206   MSG("BadChannels",Msg::kInfo) << " *** FillBadChannelDB::DefaultConfig() *** " << endl;
00207 
00208   static Registry r;
00209   r.SetName("FillBadChannelDB.config.default");
00210   r.UnLockValues();
00211   r.Set("WriteOutResults",fWriteOutResults);
00212   r.Set("WriteToDatabase",fWriteToDatabase);
00213   r.LockValues();
00214 
00215   return r;
00216 }

void FillBadChannelDB::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 192 of file FillBadChannelDB.cxx.

References CloseFile(), FindBadChannels(), Msg::kInfo, MSG, and Reset().

00193 {
00194   MSG("BadChannels",Msg::kInfo) << " *** FillBadChannelDB::EndJob() *** " << endl;
00195 
00196   // find bad channels
00197   this->FindBadChannels();
00198   this->Reset();
00199 
00200   // Write the tree(s) and file(s)
00201   this->CloseFile();
00202 }

void FillBadChannelDB::FindBadChannels (  )  [private]

Definition at line 498 of file FillBadChannelDB.cxx.

References CandDigitBadChannels::cold, NearReadout::ConnectedMenu(), NearReadout::ConnectedMenus(), NearReadout::ConnectedMinder(), CandDigitBadChannels::dead, fADCCut, fAverageADC, fAverageADCCut, fAverageADCCutFactor, fAverageADCCutPercentile, fBadChannel, fBadnessReason, fCountDigits, fCountDigitsErrors, fCountDigitsHighADC, fCrate, fEndTime, fIntegrateDigits, fIntegrateDigitsADC, fMaster, fMenu, fMinder, fMinRunLength, fNdigits, fNdigitsColdCut, fNdigitsColdCutFactor, fNdigitsColdCutPercentile, fNdigitsCut, fNdigitsCutFactor, fNdigitsCutPercentile, fNdigitsErrorBits, fNdigitsHighADC, fPhysicsRun, fReadout, fRun, fStartTime, fSubRun, fTotalADCInCrate, fTotalCrateADC, fTotalCrateDigits, fTotalDigitsInCrate, fWriteOutResults, fWriteToDatabase, CandDigitBadChannels::hot, NearReadout::kConnected, Msg::kDebug, Msg::kInfo, Detector::kNear, ElecType::kQIE, MSG, CandDigitBadChannels::vhot, CandDigitBadChannels::warm, WriteAllBadToDatabase(), and WriteOutResults().

Referenced by EndJob(), and ProcessHeader().

00499 {
00500   MSG("BadChannels",Msg::kInfo) << " *** FillBadChannelDB::FindBadChannels() *** " << std::endl;
00501   MSG("BadChannels",Msg::kInfo) << "  Finding Bad Channels for Run: " << fRun << "/" << fSubRun << endl; 
00502   MSG("BadChannels",Msg::kInfo) << "  Physics = " << fPhysicsRun << ", Start Time = " << fStartTime << ", End Time = " << fEndTime+1 << endl;
00503 
00504   if( fPhysicsRun<=0 ){
00505     MSG("BadChannels",Msg::kInfo) << "  Run is Not Physics [RETURN] " << std::endl;
00506     return;
00507   }
00508 
00509   if( fStartTime<=0 || fEndTime<=0
00510    || fEndTime-fStartTime<= 10 ){
00511     MSG("BadChannels",Msg::kInfo) << "  Run is Not Long Enough [RETURN] " << std::endl;
00512     return;
00513   }
00514 
00515   // Split the average ADC and integrated number of digits up by crate so they can be sorted
00516   // We have 8 crates and each contains 16*8*16 = 2048 channels
00517   std::vector<std::vector<Double_t> > vAverageADC(8, std::vector<Double_t>(2048,0.0));
00518   std::vector<std::vector<Int_t> > vCountDigits(8, std::vector<Int_t>(2048,0));
00519 
00520   for(int icrate=0; icrate<8; ++icrate){
00521     fCrate = icrate;
00522     fTotalCrateDigits[icrate] = 0;
00523     fTotalCrateADC[icrate] = 0;
00524     for(int imaster=0; imaster<16; ++imaster){
00525       fMaster = imaster+9;
00526       for(int iminder=0; iminder<8; ++iminder){ 
00527         fMinder = iminder;
00528         if( fReadout->ConnectedMinder(fCrate,fMaster,fMinder)==NearReadout::kConnected ){
00529           MSG("BadChannels",Msg::kDebug) << "  [" << fCrate << "|" << fMaster << "|" << fMinder << "] " << endl;
00530           for(int imenu=0; imenu<16; ++imenu){ 
00531             if( fReadout->ConnectedMenu(fCrate,fMaster,fMinder, imenu)==NearReadout::kConnected ){
00532               fNdigits = fCountDigits[icrate][imaster][iminder][imenu];
00533                                         vCountDigits[icrate][8*16*imaster+16*iminder+imenu] = fNdigits;
00534                                         fTotalCrateDigits[icrate] += fNdigits;
00535               fTotalCrateADC[icrate] += fIntegrateDigitsADC[icrate][imaster][iminder][imenu];
00536                                         if( fIntegrateDigits[icrate][imaster][iminder][imenu]>0.0 ){
00537                 fAverageADC = fIntegrateDigitsADC[icrate][imaster][iminder][imenu]/fIntegrateDigits[icrate][imaster][iminder][imenu]; 
00538                 vAverageADC[icrate][8*16*imaster+16*iminder+imenu] = fAverageADC;
00539               }
00540             }
00541           }
00542         }
00543       }
00544     }
00545   }
00546 
00547         // Check each channel against the cuts
00548         std::map<RawChannelId, Int_t> badList;
00549  
00550         // Now find the chosen percentiles of average ADC and digits to determine the cuts
00551   for(int icrate = 0; icrate < 8; icrate++)
00552   {
00553     fAverageADCCut = fADCCut;
00554                 fNdigitsCut = 1000000000;
00555 
00556                 std::sort(vAverageADC[icrate].begin(), vAverageADC[icrate].end());
00557     std::sort(vCountDigits[icrate].begin(), vCountDigits[icrate].end());
00558  
00559                 // Offset the start point from which we consider percentiles because many of the channels aren't connected
00560                 Float_t connectedMenus = (Float_t)fReadout->ConnectedMenus(icrate);
00561                 Int_t startPoint = 0;
00562                 if(connectedMenus <= 0 || connectedMenus > 2048)
00563                 {       
00564                         MSG("BadChannels",Msg::kDebug) << "Number of connected menus was <= 0 or > 2048, defaulting to 2048" << std::endl;
00565                         connectedMenus = 2048.0;
00566                 } 
00567                 startPoint = 2048 - (Int_t)connectedMenus;
00568 
00569                 // Work out where in the sorted vector to place the cut
00570                 Int_t cutHereHighADC = (Int_t)floor(fAverageADCCutPercentile * connectedMenus + startPoint);
00571                 Int_t cutHereHighRate = (Int_t)floor(fNdigitsCutPercentile * connectedMenus + startPoint);
00572                 Int_t cutHereLowRate = (Int_t)floor(fNdigitsColdCutPercentile * connectedMenus + startPoint);
00573 
00574                 // Make sure we stay inside the vector
00575                 if(cutHereHighADC > 2048 || cutHereHighADC <= 0) cutHereHighADC = (Int_t)floor(fAverageADCCutPercentile * 2048);
00576                 if(cutHereHighRate > 2048 || cutHereHighRate <= 0) cutHereHighRate = (Int_t)floor(fNdigitsCutPercentile * 2048);
00577                 if(cutHereLowRate > 2048 || cutHereLowRate <= 0) cutHereLowRate = (Int_t)floor(fNdigitsColdCutPercentile * 2048);
00578 
00579                 // Now set the cuts
00580         fAverageADCCut = fAverageADCCutFactor * vAverageADC[icrate][cutHereHighADC];
00581         fNdigitsCut = (Int_t) (fNdigitsCutFactor * vCountDigits[icrate][cutHereHighRate]);
00582                 fNdigitsColdCut = (Int_t) (fNdigitsColdCutFactor * vCountDigits[icrate][cutHereLowRate]);
00583 
00584 
00585                 fCrate = icrate;
00586                 for(int imaster=0; imaster<16; ++imaster){
00587                   fMaster = imaster+9;
00588                   for(int iminder=0; iminder<8; ++iminder){ 
00589                     fMinder = iminder;
00590                     if( fReadout->ConnectedMinder(fCrate,fMaster,fMinder)==NearReadout::kConnected ){
00591                       // MSG("BadChannels",Msg::kDebug) << "  [" << fCrate << "|" << fMaster << "|" << fMinder << "] " << endl;
00592                       for(int imenu=0; imenu<16; ++imenu){ 
00593                                                 fMenu = imenu;
00594                         if( fReadout->ConnectedMenu(fCrate,fMaster,fMinder, fMenu)==NearReadout::kConnected ){
00595               fNdigits = fCountDigits[icrate][imaster][iminder][imenu]; 
00596               fNdigitsHighADC = fCountDigitsHighADC[icrate][imaster][iminder][imenu]; 
00597               fNdigitsErrorBits = fCountDigitsErrors[icrate][imaster][iminder][imenu]; 
00598               fAverageADC = 0.0;
00599               if( fIntegrateDigits[icrate][imaster][iminder][imenu]>0.0 ){
00600                 fAverageADC = fIntegrateDigitsADC[icrate][imaster][iminder][imenu]/fIntegrateDigits[icrate][imaster][iminder][imenu]; 
00601               }
00602                         } 
00603  
00604                         fBadChannel = 0;
00605                         fBadnessReason = 0x00;
00606 
00607 
00608                         // This is where we check for bad channels.  I've put this comment here so it's easy to search for "hot channels" (or warm)
00609 
00610             // If run is too short, only consider very hot channels
00611             if(fEndTime - fStartTime > fMinRunLength)
00612             {
00613                           // Dead
00614               if( fNdigits == 0)
00615                           {
00616                             fBadChannel = 1;
00617                             MSG("BadChannels",Msg::kInfo) << " Found Bad Channel: " << fCrate << "-" << fMaster << "-" << fMinder << "-" << fMenu << ", fNdigits = " << fNdigits << endl;
00618                             fBadnessReason |= CandDigitBadChannels::dead;
00619                                 MSG("BadChannels",Msg::kInfo) << "  Reason=" << (fBadnessReason & CandDigitBadChannels::dead) << std::endl;
00620                           }
00621                                             else
00622                                             {            
00623                              // Cold
00624                                                 if( fNdigits < fNdigitsColdCut)
00625                 {
00626                                   if(!fBadChannel)
00627                                                         {
00628                                                                 MSG("BadChannels",Msg::kInfo) << " Found Bad Channel: " << fCrate << "-" << fMaster << "-" << fMinder << "-" << fMenu << endl;
00629                                         fBadChannel = 1;
00630                                   }
00631                                                         fBadnessReason |= CandDigitBadChannels::cold;
00632                                         MSG("BadChannels",Msg::kInfo) << "  Reason=" << (fBadnessReason & CandDigitBadChannels::cold) << ", Ndigits=" << fNdigits << ", NdigitsColdCut=" << fNdigitsColdCut << " at " << fNdigitsColdCutFactor << " x " << fNdigitsColdCutPercentile*100 << "th percentile" << std::endl;
00633                                                 }
00634 
00635                                                 // Warm
00636                                 if( fNdigits > fNdigitsCut)
00637                 {
00638                                   if( !fBadChannel )
00639                                                         {
00640                                                                  MSG("BadChannels",Msg::kInfo) << " Found Bad Channel: " << fCrate << "-" << fMaster << "-" << fMinder << "-" << fMenu << endl;
00641                                          fBadChannel = 1;
00642                                                         }
00643 
00644                                   fBadnessReason |= CandDigitBadChannels::warm;
00645                                   MSG("BadChannels",Msg::kInfo) << "  Reason=" << (fBadnessReason & CandDigitBadChannels::warm) << ", Ndigits=" << fNdigits << ", NdigitsCut=" << fNdigitsCut << " at " << fNdigitsCutFactor << " x " << fNdigitsCutPercentile*100 << "th percentile" << std::endl;
00646                                 }
00647 
00648                                                 // Hot
00649                                 if( fAverageADC > fAverageADCCut)
00650                                                 {
00651                                   if( !fBadChannel )
00652                                                         { 
00653                                                                 MSG("BadChannels",Msg::kInfo) << " Found Bad Channel: " << fCrate << "-" << fMaster << "-" << fMinder << "-" << fMenu << endl;
00654                                         fBadChannel = 1;
00655                                   }
00656                                                         fBadnessReason |= CandDigitBadChannels::hot;
00657                                   MSG("BadChannels",Msg::kInfo) << "  Reason=" << (fBadnessReason & CandDigitBadChannels::hot) << ", AverageADC=" << fAverageADC << ", AverageADCCut=" << fAverageADCCut << " at " << fAverageADCCutFactor << " x " << fAverageADCCutPercentile*100 << "th percentile" << std::endl;
00658                                 }
00659               }
00660            }
00661                        // Very hot
00662                                          if(fNdigits)
00663            {  
00664              if( ((double)fNdigitsHighADC/(double)fNdigits > 0.5) || ( fNdigits>100 && fAverageADC>fADCCut ) )
00665                                            {
00666                            if( !fBadChannel )
00667                                                 {
00668                                                         MSG("BadChannels",Msg::kInfo) << " Found Bad Channel: " << fCrate << "-" << fMaster << "-" << fMinder << "-" << fMenu << endl;
00669                                 fBadChannel = 1;
00670                                                 }
00671                            fBadnessReason |= CandDigitBadChannels::vhot;
00672                            MSG("BadChannels",Msg::kInfo) << "  Reason=" << (fBadnessReason & CandDigitBadChannels::vhot) << ", HighADCfrac=" << (double)fNdigitsHighADC/(double)fNdigits << ", AverageADC=" << fAverageADC << std::endl;
00673                                            }
00674                                          }
00675                 
00676 
00677                         if( fBadChannel )
00678                                                 {
00679                                 MSG("BadChannels",Msg::kInfo) << " Found Bad Channel: " << fCrate << "-" << fMaster << "-" << fMinder << "-" << fMenu << endl;
00680                                 MSG("BadChannels",Msg::kInfo) << "  Reason=";
00681                                 for( UInt_t compare = CandDigitBadChannels::dead; compare >= CandDigitBadChannels::vhot; compare >>= 1)
00682                                                         { 
00683                                                                 if( (fBadnessReason & compare) != 0) MSG("BadChannels",Msg::kInfo) << "1";
00684                                                                 else MSG("BadChannels",Msg::kInfo) << "0";
00685                                                         }
00686                                 MSG("BadChannels",Msg::kInfo) << std::endl; 
00687                                 RawChannelId rcid( Detector::kNear, ElecType::kQIE, fCrate, fMaster, fMinder, fMenu );
00688                                 badList[rcid] = fBadnessReason; 
00689                                                         
00690                                                         // Write to root file:
00691                                                         fTotalDigitsInCrate = fTotalCrateDigits[fCrate];
00692                                                         fTotalADCInCrate = fTotalCrateADC[fCrate];
00693                                                 if(fWriteOutResults) this->WriteOutResults();
00694                         }
00695                                         }
00696                     }
00697                   }
00698                 }
00699         }               
00700   
00701   if(badList.size() > 0)
00702   {
00703     if(fWriteToDatabase) this->WriteAllBadToDatabase( fStartTime, fEndTime, badList );
00704         }
00705   
00706 }

void FillBadChannelDB::Initialise (  )  [private]

Definition at line 93 of file FillBadChannelDB.cxx.

Referenced by FillBadChannelDB().

00094 {
00095   return;
00096 }

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

Definition at line 300 of file FillBadChannelDB.cxx.

References AnalyseRawDigits(), AnalyseTpSingles(), NearReadout::ConnectedMenu(), fADC, fCrate, fCrateT0nsec, fCrateT0sec, fDataType, fDeltaTDC, fErrorCode, fMaster, fMaxTDC, fMenu, fMinder, fMinTDC, fPhysicsRun, fRate, fReadout, fReadoutInt, fTDC, fTrigBaseTime, fTrigTime, RawChannelId::GetCrate(), RawDigitDataBlock::GetDatumIter(), RawChannelId::GetMaster(), RawChannelId::GetMenu(), RawChannelId::GetMinder(), VldTimeStamp::GetNanoSec(), RawTpSinglesSummaryBlock::GetRates(), RawTpSinglesSummaryBlock::GetSource(), VldContext::GetTimeStamp(), RawSnarlHeaderBlock::GetTriggerTime(), RawDaqHeaderBlock::GetVldContext(), Msg::kDebug, Detector::kFar, Detector::kNear, Detector::kUnknown, Msg::kVerbose, and MSG.

Referenced by Ana().

00301 {
00302 
00303   MSG("BadChannels",Msg::kVerbose) << " *** ProcessBlock *** " << endl;
00304 
00305   // SKIP NON-PHYSICS RUNS
00306   // =====================
00307   if( fPhysicsRun<=0 ){
00308     MSG("BadChannels",Msg::kDebug) << "   ProcessBlock : Not a physics run, RETURN" << endl;
00309     return;
00310   }
00311 
00312   // HEADER BLOCKS
00313   // =============
00314   if(obj->InheritsFrom("RawDaqHeaderBlock")){
00315     MSG("BadChannels",Msg::kVerbose) << " ... found RawDaqHeaderBlock " << endl;
00316     RawDaqHeaderBlock* rdb = (RawDaqHeaderBlock*)(obj);
00317     fTrigBaseTime = rdb->GetVldContext().GetTimeStamp().GetNanoSec();
00318   }
00319 
00320   // SNARL HEADER BLOCK
00321   // ==================
00322   if(obj->InheritsFrom("RawSnarlHeaderBlock")){
00323     MSG("BadChannels",Msg::kVerbose) << " ... found RawSnarlHeaderBlock " << endl;
00324     RawSnarlHeaderBlock* rdb = (RawSnarlHeaderBlock*)(obj);
00325     fTrigTime = rdb->GetTriggerTime().GetNanoSec();
00326   }
00327 
00328   // TP SINGLES SUMMARY BLOCK
00329   // ========================
00330   if(obj->InheritsFrom("RawTpSinglesSummaryBlock")){
00331 
00332     MSG("BadChannels",Msg::kVerbose) << " ... found RawTpSinglesSummaryBlock " << endl;
00333     RawTpSinglesSummaryBlock* rdb = (RawTpSinglesSummaryBlock*)(obj);
00334     
00335 //     Int_t time = rdb->GetStartTimeStamp().GetSec();
00336 //     Double_t frametime = ( rdb->GetEndTimeStamp().GetSec() - rdb->GetStartTimeStamp().GetSec() ) + 1.0e-9*( rdb->GetEndTimeStamp().GetNanoSec() - rdb->GetStartTimeStamp().GetNanoSec() );
00337     Int_t source = rdb->GetSource();
00338     Int_t sourcecheck = 0;
00339   
00340     Detector::Detector_t Detector = Detector::kUnknown;
00341     
00342     switch( source ){
00343     case 0: // Crate only
00344       Detector = Detector::kUnknown;
00345       break;
00346     case 1: // Crate and VARC (VA)
00347       Detector = Detector::kFar;
00348       break;
00349     case 2: // Crate and VFB/ADCSEL (VA)
00350       Detector = Detector::kFar;
00351       break;
00352     case 3: // Crate and VACHIP (VA)
00353       Detector = Detector::kFar;
00354       break;
00355     case 4: // Crate and Plane
00356       Detector = Detector::kUnknown;
00357       break;
00358     case 5: // Crate and MASTER (QIE)
00359       Detector = Detector::kNear;
00360       break;
00361     case 6: // Crate and MINDER (QIE)
00362       Detector = Detector::kNear;
00363       break;
00364     case 7: // Crate and MENU (QIE)
00365       Detector = Detector::kNear;
00366       sourcecheck = 1;
00367       break;
00368     default:
00369       break;
00370     }
00371     
00372     // Iterate over raw channels for minders on/off per timeframe
00373     typedef std::map<RawChannelId,UInt_t> RCIdToRateMap;
00374     const RCIdToRateMap& rates = rdb->GetRates();
00375     RCIdToRateMap::const_iterator rateItr = rates.begin();
00376     RCIdToRateMap::const_iterator rateEnd = rates.end();
00377     
00378     //Perform the iteration
00379     while ( rateItr != rateEnd ) {
00380 
00381       RawChannelId rawch = rateItr->first;
00382       Int_t rawrate = rateItr->second;
00383       //Int_t correctedrate = (Int_t(rawrate/frametime);
00384       //Int_t rate = correctedrate;
00385       fRate   = rawrate;
00386       fCrate  = rawch.GetCrate();
00387       fMaster = rawch.GetMaster();
00388       fMinder = rawch.GetMinder();
00389       fMenu   = rawch.GetMenu();      
00390 
00391       fReadoutInt = fReadout->ConnectedMenu(fCrate,fMaster,fMinder,fMenu);
00392 
00393       if( sourcecheck ) this->AnalyseTpSingles();
00394 
00395       rateItr++;
00396     }
00397 
00398   }
00399   
00400   // RAW DATA BLOCKS
00401   // ===============
00402   if(obj->InheritsFrom("RawDigitDataBlock")){
00403     MSG("BadChannels",Msg::kVerbose) << " ... found RawDigitDataBlock " << endl;
00404     RawDigitDataBlock* rdb = (RawDigitDataBlock*)(obj);
00405 
00406     // Min and Max TDC
00407     // ===============
00408     TIter digitr0 = rdb->GetDatumIter();
00409     Int_t tdc;
00410     Int_t mintdc = 100000000;
00411     while(RawDigit *rd = (RawDigit*)(digitr0())){
00412       if (rd){
00413   tdc = (Int_t)(rd->GetTDC());
00414   if( tdc<mintdc )  mintdc = tdc;
00415   if( tdc>fMaxTDC ) fMaxTDC = tdc;
00416       }
00417     }
00418     fMinTDC = mintdc;
00419 
00420     // Iterate over raw digits
00421     // =======================    
00422     TIter digitr = rdb->GetDatumIter();
00423     while(RawDigit *rd = (RawDigit*)(digitr())){
00424       if(rd){
00425   // Get the data
00426         RawChannelId rawch = (RawChannelId)(rd->GetChannel());
00427         fCrate  = rawch.GetCrate();
00428         fMaster = rawch.GetMaster();
00429         fMinder = rawch.GetMinder();
00430         fMenu   = rawch.GetMenu();      
00431 
00432         fADC = (Int_t)(rd->GetADC());
00433         fTDC = (Int_t)(rd->GetTDC());
00434         fErrorCode = (Int_t)(rd->GetErrorCode());
00435   fDeltaTDC  = fTDC - fMinTDC; 
00436 
00437         fCrateT0sec  = rd->GetCrateT0().GetSec();
00438         fCrateT0nsec = rd->GetCrateT0().GetNanoSec();
00439         fDataType    = rd->GetDataType();
00440 
00441   // Check the readout map
00442   fReadoutInt = fReadout->ConnectedMenu(fCrate,fMaster,fMinder,fMenu);
00443 
00444   // analyse raw digits
00445         this->AnalyseRawDigits();
00446 
00447       }
00448     }
00449   }
00450   
00451   return;
00452 }

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

Definition at line 235 of file FillBadChannelDB.cxx.

References fEndTime, FindBadChannels(), fPhysicsRun, fRun, fRunType, fSnarl, fStartTime, fSubRun, fTime, fTimeFrame, fTrigSrc, RawDaqHeader::GetRun(), RawDaqHeader::GetRunType(), VldTimeStamp::GetSec(), RawDaqSnarlHeader::GetSnarl(), RawDaqHeader::GetSubRun(), RawDaqHeader::GetTimeFrameNum(), VldContext::GetTimeStamp(), RawDaqSnarlHeader::GetTrigSrc(), RecMinosHdr::GetVldContext(), Msg::kInfo, Msg::kVerbose, MSG, Reset(), run(), and RUN_TYPE_PHYSICS.

Referenced by Ana().

00236 {
00237   MSG("BadChannels",Msg::kVerbose) << "*** ProcessHeader *** " << endl;
00238 
00239   // DAQ HEADER
00240   // ==========
00241   if(obj->InheritsFrom("RawDaqHeader")){
00242     MSG("BadChannels",Msg::kVerbose) << " ... found RawDaqHeader " << endl;
00243     RawDaqHeader* hdr = (RawDaqHeader*)(obj);
00244         
00245     Int_t time = hdr->GetVldContext().GetTimeStamp().GetSec();
00246     Int_t timeframe = hdr->GetTimeFrameNum();
00247     Int_t run       = hdr->GetRun();
00248     Int_t subrun    = hdr->GetSubRun();
00249     Int_t runtype   = hdr->GetRunType();
00250 
00251     // New Run/Subrun
00252     if ( (fRun>=0 && fSubRun>=0)
00253      && !(run==fRun && subrun==fSubRun) ){
00254       MSG("BadChannels",Msg::kInfo) << " Closing: " << fRun << "/" << fSubRun << endl;
00255       this->FindBadChannels();
00256       this->Reset();
00257     }
00258 
00259     // Record Run/Subrun
00260     if( fRun<0 || fSubRun<0 ){
00261       MSG("BadChannels",Msg::kInfo) << " Opening: " << run << "/" << subrun << endl;
00262       fRun = run;
00263       fSubRun = subrun;
00264       fRunType = runtype;
00265     }
00266 
00267     // Record Run Type
00268     if( fPhysicsRun<0 ){
00269       if( fRun>=0 ){
00270   fPhysicsRun = 0;
00271   if( fRunType>=0 ){
00272           // if ( fRunType == 2 ) fPhysicsRun = 1;
00273     if ( (fRunType&RUN_TYPE_PHYSICS) == (RUN_TYPE_PHYSICS) ) fPhysicsRun = 1;
00274   }
00275       }
00276     }
00277 
00278     // Duration of subrun
00279     if( timeframe>=0 && time!=fTime ){
00280       if( time > fTime ){
00281   if (fStartTime<0)  fStartTime = time;
00282   if (fEndTime<time) fEndTime = time;
00283       }
00284       fTime = time;
00285       fTimeFrame = timeframe;
00286     }
00287   }
00288 
00289   // SNARL HEADER
00290   // ============
00291   if(obj->InheritsFrom("RawDaqSnarlHeader")){
00292     MSG("BadChannels",Msg::kVerbose) << " ... found RawDaqSnarlHeader " << endl;
00293     RawDaqSnarlHeader* hdr = (RawDaqSnarlHeader*)(obj);
00294         
00295     fTrigSrc = hdr->GetTrigSrc();
00296     fSnarl   = hdr->GetSnarl(); 
00297   }
00298 }

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

Implement to reset oneself

Reimplemented from JobCModule.

Definition at line 98 of file FillBadChannelDB.cxx.

References fADCCut, fAverageADCCut, fCountDigits, fCountDigitsErrors, fCountDigitsHighADC, fDigits, fEndTime, fIntegrateDigitsADC, fMaxTDC, fMinTDC, fNdigitsColdCut, fNdigitsCut, fPhysicsRun, fRun, fRunType, fSnarl, fStartTime, fSubRun, fTime, fTimeFrame, fTotalCrateADC, fTotalCrateDigits, and fTrigSrc.

Referenced by EndJob(), FillBadChannelDB(), and ProcessHeader().

00099 {  
00100   fRun = -1;
00101   fSubRun = -1;
00102   fRunType = -1;
00103   fSnarl = -1;
00104   fTrigSrc = -1;
00105   fDigits = -1;
00106   fTimeFrame = -1;
00107   fTime = -1;
00108   fPhysicsRun = -1;
00109   fStartTime = -1;
00110   fEndTime = -1;
00111   fMinTDC = 100000000;
00112   fMaxTDC = 0; 
00113   fAverageADCCut = fADCCut;
00114   fNdigitsCut = 100000000;
00115         fNdigitsColdCut = 0;
00116   for(int icrate=0; icrate<8; ++icrate){
00117     fTotalCrateDigits[icrate] = 0;
00118     fTotalCrateADC[icrate] = 0;
00119     for(int imaster=0; imaster<16; ++imaster){
00120       for(int iminder=0; iminder<8; ++iminder){
00121         for(int imenu=0; imenu<16; ++imenu){  
00122           fCountDigits[icrate][imaster][iminder][imenu] = 0; 
00123           fCountDigitsErrors[icrate][imaster][iminder][imenu] = 0; 
00124           fCountDigitsHighADC[icrate][imaster][iminder][imenu] = 0; 
00125           fIntegrateDigitsADC[icrate][imaster][iminder][imenu] = 0; 
00126   }
00127       }
00128     }
00129   }
00130 
00131   return;
00132 }

void FillBadChannelDB::WriteAllBadToDatabase ( Int_t  startTime,
Int_t  endTime,
std::map< RawChannelId, Int_t > &  badList 
) [private]

Definition at line 776 of file FillBadChannelDB.cxx.

References det, RawChannelId::GetChAdd(), RawChannelId::GetCrate(), RawChannelId::GetMaster(), RawChannelId::GetMenu(), RawChannelId::GetMinder(), SimFlag::kData, Msg::kInfo, Detector::kNear, and MSG.

Referenced by FindBadChannels().

00777 {
00778   MSG("BadChannels",Msg::kInfo) << " *** Writing To Database *** " << endl;
00779 
00780   // switch, for debugging
00781   Bool_t fYesReallyWriteToDatabase = 1; // activate!
00782 
00783   //set the various types
00784   SimFlag::SimFlag_t simFlag = SimFlag::kData;
00785   Detector::Detector_t det     = Detector::kNear;
00786 
00787   // generate log comment
00788   TString logComment("automatically mask out bad channel(s) in ND: ");
00789   std::map<RawChannelId,Int_t>::const_iterator commentItr = badList.begin();
00790   for ( ; commentItr != badList.end(); ++commentItr ) {
00791     RawChannelId rcid = commentItr->first;
00792     Int_t reason = commentItr->second;  
00793     Int_t crate = rcid.GetCrate();
00794     Int_t master = rcid.GetMaster();
00795     Int_t minder = rcid.GetMinder();
00796     Int_t menu  = rcid.GetMenu();
00797 
00798     logComment += crate; logComment.Append("-");
00799     logComment += master; logComment.Append("-");
00800     logComment += minder; logComment.Append("-");
00801     logComment += menu;
00802     logComment.Append("   ");
00803 
00804     MSG("BadChannels",Msg::kInfo) << "  Channel: " << crate << "-" << master << "-" << minder << "-" << menu << endl;
00805     MSG("BadChannels",Msg::kInfo) << "  StartTime: " << starttime << endl;
00806     MSG("BadChannels",Msg::kInfo) << "  EndTime: " << endtime << endl;
00807     MSG("BadChannels",Msg::kInfo) << "  Reason: " << reason << endl;
00808     MSG("BadChannels",Msg::kInfo) << "  Writing Entry..." << endl;
00809   }
00810 
00811   // start and end times
00812   VldTimeStamp start = VldTimeStamp(starttime,0);
00813   VldTimeStamp end   = VldTimeStamp(endtime,0);
00814   VldRange range(det,simFlag,start,end,logComment.Data());
00815 
00816   Int_t aggNo = -1;
00817   Int_t taskNo = 0;
00818   VldTimeStamp creationDate;
00819 
00820   // write to database
00821   if( fYesReallyWriteToDatabase ){
00822     DbiWriter<CandDigitBadChannels> writer(range,aggNo,taskNo,
00823                                            creationDate,0,logComment.Data());
00824   
00825     std::map<RawChannelId,Int_t>::const_iterator blitr = badList.begin();
00826     MSG("BadChannels",Msg::kInfo)  << "   DB: Start=" << start << endl;
00827     MSG("BadChannels",Msg::kInfo)  << "   DB: End=" << end << endl;
00828     MSG("BadChannels",Msg::kInfo)  << "   DB: LogComment=" << logComment.Data() << endl;
00829     // loop over all entries in the map
00830     for ( ; blitr != badList.end(); ++blitr ) {
00831       // extract channel info and reason
00832       RawChannelId rcid = blitr->first;
00833       Int_t reason = blitr->second;
00834       Int_t crate = rcid.GetCrate();
00835       Int_t chadd = rcid.GetChAdd();
00836       Int_t parA = -1;
00837       Float_t parB = -1;
00838       Float_t parC = -1;
00839       MSG("BadChannels",Msg::kInfo)  << "   DB: Channel=" << crate << "-" << rcid.GetMaster() << "-" << rcid.GetMinder() << "-" << rcid.GetMenu() << endl;
00840       MSG("BadChannels",Msg::kInfo)  << "   DB: ChannelAddress=" << chadd << endl;
00841       MSG("BadChannels",Msg::kInfo)  << "   DB: CheckCrate=" << rcid.GetCrate() << endl;
00842       MSG("BadChannels",Msg::kInfo)  << "   DB: Reason=" << reason << " (" << parA << "," << parB << "," << parC << ") " << endl;
00843       CandDigitBadChannels badChannel(crate, chadd, reason, parA, parB, parC);
00844       writer << badChannel;
00845     }
00846     writer.Close();
00847   }
00848   return;
00849 }

void FillBadChannelDB::WriteOutResults (  )  [private]

Definition at line 852 of file FillBadChannelDB.cxx.

References fAverageADC, fAverageADCCut, fBadChannel, fBadChannelFile, fBadChannelTree, fBadnessReason, fCrate, fEndTime, fMaster, fMenu, fMinder, fNdigits, fNdigitsCut, fNdigitsErrorBits, fNdigitsHighADC, fRun, fRunType, fStartTime, fSubRun, fTotalADCInCrate, fTotalDigitsInCrate, Msg::kInfo, and MSG.

Referenced by FindBadChannels().

00853 {
00854   if( !fBadChannelFile ){
00855     TDirectory* tmpd = gDirectory;
00856     TString filename = "dataquality.badchannels.";
00857     filename+=fRun;
00858     filename.Append(".");
00859     filename+=fSubRun;
00860     filename.Append(".root");
00861     MSG("BadChannels",Msg::kInfo) << " Opening file: " << filename.Data() << endl;
00862     fBadChannelFile = new TFile(filename.Data(),"RECREATE");
00863     fBadChannelTree = new TTree("BadChannels","BadChannels");
00864     fBadChannelTree->SetAutoSave(100);
00865     fBadChannelTree->Branch("run",&fRun,"run/I");
00866     fBadChannelTree->Branch("subrun",&fSubRun,"subrun/I");
00867     fBadChannelTree->Branch("runtype",&fRunType,"runtype/I");
00868     fBadChannelTree->Branch("crate",&fCrate,"crate/I");
00869     fBadChannelTree->Branch("master",&fMaster,"master/I");
00870     fBadChannelTree->Branch("minder",&fMinder,"minder/I");
00871     fBadChannelTree->Branch("menu",&fMenu,"menu/I");
00872     fBadChannelTree->Branch("digits",&fNdigits,"digits/I");
00873     fBadChannelTree->Branch("digitsHighADC",&fNdigitsHighADC,"digitsHighADC/I");
00874     fBadChannelTree->Branch("digitsErrorBits",&fNdigitsErrorBits,"digitsErrorBits/I");
00875     fBadChannelTree->Branch("averageADC",&fAverageADC,"averageADC/D");
00876     fBadChannelTree->Branch("badchannel",&fBadChannel,"badchannel/I");
00877                 fBadChannelTree->Branch("badnessreason",&fBadnessReason,"badnessreason/I");
00878                 fBadChannelTree->Branch("averageADC",&fAverageADC,"averageADC/D");
00879                 fBadChannelTree->Branch("averageADCCut",&fAverageADCCut,"averageADCCut/D");
00880                 fBadChannelTree->Branch("nDigitsCut",&fNdigitsCut,"nDigitsCut/I");
00881     fBadChannelTree->Branch("startTime",&fStartTime,"startTime/I");
00882     fBadChannelTree->Branch("endTime",&fEndTime,"endTime/I");
00883     fBadChannelTree->Branch("totalDigitsInCrate",&fTotalDigitsInCrate,"totalDigitsInCrate/I");
00884     fBadChannelTree->Branch("totalADCInCrate",&fTotalADCInCrate,"totalADCInCrate/D");
00885 
00886     gDirectory = tmpd;
00887   }
00888 
00889   if( fBadChannelFile ){
00890     TDirectory* tmpd = gDirectory;
00891     fBadChannelFile->cd();
00892     fBadChannelTree->Fill();
00893     gDirectory = tmpd;
00894   }
00895 
00896   return;
00897 }

void FillBadChannelDB::WriteToDatabase ( Int_t  crate,
Int_t  master,
Int_t  minder,
Int_t  menu,
Int_t  starttime,
Int_t  endtime,
Int_t  reason 
) [private]

Definition at line 708 of file FillBadChannelDB.cxx.

References DbiWriter< T >::Close(), det, RawChannelId::GetChAdd(), RawChannelId::GetCrate(), SimFlag::kData, Msg::kInfo, Detector::kNear, ElecType::kQIE, and MSG.

00709 {
00710   MSG("BadChannels",Msg::kInfo) << " *** Writing To Database *** " << endl;
00711   MSG("BadChannels",Msg::kInfo) << "  Channel: " << crate << "-" << master << "-" << minder << "-" << menu << endl;
00712   MSG("BadChannels",Msg::kInfo) << "  StartTime: " << starttime << endl;
00713   MSG("BadChannels",Msg::kInfo) << "  EndTime: " << endtime << endl;
00714   MSG("BadChannels",Msg::kInfo) << "  Reason: " << reason << endl;
00715   MSG("BadChannels",Msg::kInfo) << "  Writing Entry..." << endl;
00716 
00717   // switch, for debugging
00718   Bool_t fYesReallyWriteToDatabase = 1; // activate!
00719 
00720   //set the various types
00721   Detector::Detector_t det     = Detector::kNear;
00722   ElecType::Elec_t     elec    = ElecType::kQIE;
00723   SimFlag::SimFlag_t   simFlag = SimFlag::kData;
00724 
00725   // comment
00726   TString logComment("automatically mask out bad channel in ND: ");
00727   logComment += crate; logComment.Append("-");
00728   logComment += master; logComment.Append("-");
00729   logComment += minder; logComment.Append("-");
00730   logComment += menu;
00731 
00732   // start and end times
00733   VldTimeStamp start = VldTimeStamp(starttime,0);
00734   VldTimeStamp end   = VldTimeStamp(endtime,0);
00735   VldRange range(det,simFlag,start,end,logComment.Data());
00736 
00737   Int_t aggNo = -1;
00738   Int_t taskNo = 0;
00739   VldTimeStamp creationDate;
00740 
00741   // channel number
00742   RawChannelId rcid(det,elec,
00743                     crate,master,minder,menu);
00744 
00745   Int_t channelAddress = rcid.GetChAdd();
00746   Int_t badnessReason = reason;
00747   Int_t parA = -1;
00748   Float_t parB = -1;
00749   Float_t parC = -1;
00750 
00751   MSG("BadChannels",Msg::kInfo)  << "   DB: Start=" << start << endl;
00752   MSG("BadChannels",Msg::kInfo)  << "   DB: End=" << end << endl;
00753   MSG("BadChannels",Msg::kInfo)  << "   DB: LogComment=" << logComment.Data() << endl;
00754 
00755   MSG("BadChannels",Msg::kInfo)  << "   DB: Channel=" << crate << "-" << master << "-" << minder << "-" << menu << endl;
00756   MSG("BadChannels",Msg::kInfo)  << "   DB: ChannelAddress=" << channelAddress << endl;
00757   MSG("BadChannels",Msg::kInfo)  << "   DB: CheckCrate=" << rcid.GetCrate() << endl;
00758   MSG("BadChannels",Msg::kInfo)  << "   DB: Reason=" << badnessReason << " (" << parA << "," << parB << "," << parC << ") " << endl;
00759 
00760   // write to database
00761   if( fYesReallyWriteToDatabase ){
00762     DbiWriter<CandDigitBadChannels> writer(range,aggNo,taskNo,
00763                                            creationDate,0,logComment.Data());
00764 
00765     CandDigitBadChannels badChannel(crate,
00766                                     channelAddress,
00767                                     badnessReason,
00768                                     parA,parB,parC);
00769     writer << badChannel;
00770     writer.Close();
00771   }
00772 
00773   return;
00774 }


Member Data Documentation

Int_t FillBadChannelDB::fADC [private]

Definition at line 86 of file FillBadChannelDB.h.

Referenced by AnalyseRawDigits(), and ProcessBlock().

Int_t FillBadChannelDB::fADCCut [private]

Definition at line 60 of file FillBadChannelDB.h.

Referenced by AnalyseRawDigits(), FindBadChannels(), and Reset().

Double_t FillBadChannelDB::fAverageADC [private]

Definition at line 113 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and WriteOutResults().

Definition at line 63 of file FillBadChannelDB.h.

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

Definition at line 64 of file FillBadChannelDB.h.

Referenced by FindBadChannels().

Definition at line 65 of file FillBadChannelDB.h.

Referenced by FindBadChannels().

Definition at line 115 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and WriteOutResults().

Definition at line 56 of file FillBadChannelDB.h.

Referenced by CloseFile(), and WriteOutResults().

Definition at line 57 of file FillBadChannelDB.h.

Referenced by CloseFile(), and WriteOutResults().

Definition at line 116 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and WriteOutResults().

Int_t FillBadChannelDB::fCountDigits[8][16][8][16] [private]

Definition at line 124 of file FillBadChannelDB.h.

Referenced by AnalyseRawDigits(), FindBadChannels(), and Reset().

Int_t FillBadChannelDB::fCountDigitsErrors[8][16][8][16] [private]

Definition at line 125 of file FillBadChannelDB.h.

Referenced by AnalyseRawDigits(), FindBadChannels(), and Reset().

Int_t FillBadChannelDB::fCountDigitsHighADC[8][16][8][16] [private]

Definition at line 126 of file FillBadChannelDB.h.

Referenced by AnalyseRawDigits(), FindBadChannels(), and Reset().

Int_t FillBadChannelDB::fCrate [private]

Definition at line 94 of file FillBadChannelDB.h.

Referenced by ProcessBlock().

Definition at line 93 of file FillBadChannelDB.h.

Referenced by ProcessBlock().

Int_t FillBadChannelDB::fDataType [private]

Definition at line 95 of file FillBadChannelDB.h.

Referenced by ProcessBlock().

Int_t FillBadChannelDB::fDeltaTDC [private]

Definition at line 88 of file FillBadChannelDB.h.

Referenced by ProcessBlock().

Int_t FillBadChannelDB::fDigits [private]

Definition at line 81 of file FillBadChannelDB.h.

Referenced by Reset().

Int_t FillBadChannelDB::fEndTime [private]

Definition at line 105 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), ProcessHeader(), Reset(), and WriteOutResults().

Definition at line 96 of file FillBadChannelDB.h.

Referenced by AnalyseRawDigits(), and ProcessBlock().

Definition at line 97 of file FillBadChannelDB.h.

Referenced by AnalyseRawDigits().

Double_t FillBadChannelDB::fIntegrateDigits[8][16][8][16] [private]

Definition at line 129 of file FillBadChannelDB.h.

Referenced by AnalyseRawDigits(), and FindBadChannels().

Double_t FillBadChannelDB::fIntegrateDigitsADC[8][16][8][16] [private]

Definition at line 130 of file FillBadChannelDB.h.

Referenced by AnalyseRawDigits(), FindBadChannels(), and Reset().

Int_t FillBadChannelDB::fMaster [private]
Int_t FillBadChannelDB::fMaxTDC [private]

Definition at line 109 of file FillBadChannelDB.h.

Referenced by ProcessBlock(), and Reset().

Int_t FillBadChannelDB::fMenu [private]
Int_t FillBadChannelDB::fMinder [private]

Definition at line 106 of file FillBadChannelDB.h.

Referenced by FindBadChannels().

Int_t FillBadChannelDB::fMinTDC [private]

Definition at line 108 of file FillBadChannelDB.h.

Referenced by ProcessBlock(), and Reset().

Int_t FillBadChannelDB::fNdigits [private]

Definition at line 110 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and WriteOutResults().

Definition at line 71 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and Reset().

Definition at line 72 of file FillBadChannelDB.h.

Referenced by FindBadChannels().

Definition at line 73 of file FillBadChannelDB.h.

Referenced by FindBadChannels().

Definition at line 67 of file FillBadChannelDB.h.

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

Definition at line 68 of file FillBadChannelDB.h.

Referenced by FindBadChannels().

Definition at line 69 of file FillBadChannelDB.h.

Referenced by FindBadChannels().

Definition at line 112 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and WriteOutResults().

Definition at line 111 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and WriteOutResults().

Definition at line 103 of file FillBadChannelDB.h.

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

Int_t FillBadChannelDB::fRate [private]

Definition at line 98 of file FillBadChannelDB.h.

Referenced by ProcessBlock().

Definition at line 99 of file FillBadChannelDB.h.

Referenced by ProcessBlock().

Definition at line 34 of file FillBadChannelDB.h.

Referenced by Ana().

Int_t FillBadChannelDB::fRun [private]

Definition at line 76 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), ProcessHeader(), Reset(), and WriteOutResults().

Int_t FillBadChannelDB::fRunType [private]

Definition at line 78 of file FillBadChannelDB.h.

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

Int_t FillBadChannelDB::fSnarl [private]

Definition at line 79 of file FillBadChannelDB.h.

Referenced by ProcessHeader(), and Reset().

Definition at line 104 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), ProcessHeader(), Reset(), and WriteOutResults().

Int_t FillBadChannelDB::fSubRun [private]

Definition at line 77 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), ProcessHeader(), Reset(), and WriteOutResults().

Int_t FillBadChannelDB::fTDC [private]

Definition at line 87 of file FillBadChannelDB.h.

Referenced by ProcessBlock().

Int_t FillBadChannelDB::fTime [private]

Definition at line 85 of file FillBadChannelDB.h.

Referenced by ProcessHeader(), and Reset().

Definition at line 84 of file FillBadChannelDB.h.

Referenced by ProcessHeader(), and Reset().

Definition at line 134 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and WriteOutResults().

Double_t FillBadChannelDB::fTotalCrateADC[8] [private]

Definition at line 132 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and Reset().

Definition at line 131 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and Reset().

Definition at line 133 of file FillBadChannelDB.h.

Referenced by FindBadChannels(), and WriteOutResults().

Int_t FillBadChannelDB::fTotalTDCWindow[8][16][8][16] [private]

Definition at line 127 of file FillBadChannelDB.h.

Definition at line 83 of file FillBadChannelDB.h.

Referenced by ProcessBlock().

Int_t FillBadChannelDB::fTrigSrc [private]

Definition at line 80 of file FillBadChannelDB.h.

Referenced by ProcessHeader(), and Reset().

Int_t FillBadChannelDB::fTrigTime [private]

Definition at line 82 of file FillBadChannelDB.h.

Referenced by ProcessBlock().

Definition at line 53 of file FillBadChannelDB.h.

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

Definition at line 54 of file FillBadChannelDB.h.

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


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1