// PMTCalStatus.cc // Contact person: Javier Caravaca // See PMTCalStatus.hh for more details //———————————————————————// #include #include #include #include #include using namespace RAT; using namespace RAT::DU; #include ClassImp( RAT::DU::PMTCalStatus ) void PMTCalStatus::BeginOfRun() { //Defaults DBLinkPtr pmtCalDB = DB::Get()->GetLink("PMTCAL"); fECAHitMask = pmtCalDB->GetI("ECA_hitmask"); fPCAHitMask = pmtCalDB->GetI("PCA_hitmask"); fPdstMask = pmtCalDB->GetI("PDST_cellmask"); fTslpMask = pmtCalDB->GetI("TSLP_cellmask"); fTWMask = pmtCalDB->GetI("TW_chmask"); //Get ECA pattern and rates int ECAPDSTpattern = pmtCalDB->GetI("eca_pdst_pattern"); int ECAPDSTrate = pmtCalDB->GetI("eca_pdst_rate"); int ECATSLPpattern = pmtCalDB->GetI("eca_tslp_pattern"); int ECATSLPrate = pmtCalDB->GetI("eca_tslp_rate"); std::stringstream pdst_pattern_rate, tslp_pattern_rate; pdst_pattern_rate << ECAPDSTpattern <<"_"<GetLink("ECA_PDST",pdst_pattern_rate.str()); fPdstStatus = pdstDB->GetIArray("pdst_status"); fPdstBoardID = pdstDB->GetIArray("pdst_dqid"); DBLinkPtr tslpDB = DB::Get()->GetLink("ECA_TSLP",tslp_pattern_rate.str()); fTslpStatus = tslpDB->GetIArray("tslp_status"); fTslpBoardID = tslpDB->GetIArray("tslp_dqid"); DBLinkPtr twDB = DB::Get()->GetLink("PCA_TW"); fTWStatus = twDB->GetIArray("PCATW_status"); flagHits.resize(9728); // Get a list of channels out-of-sync or dropping data fChannelFlags = FlagHits(); } const RAT::DU::ChanHWStatus& PMTCalStatus::GetChanHWStatus() { return RAT::DU::Utility::Get()->GetChanHWStatus(); } const RAT::DU::ChanSWStatus& PMTCalStatus::GetChanSWStatus() { return RAT::DU::Utility::Get()->GetChanSWStatus(); } unsigned int PMTCalStatus::GetCellStatus(int cccc) const{ /* Whether a cell has good calibration. * Returns a bit mask with the failed tests: * - CHS * - ECA (including board ID test) * - PCA * - Out-of-sync, missed count Flags */ const RAT::DU::ChanHWStatus& chs = RAT::DU::PMTCalStatus::GetChanHWStatus(); int lcn = cccc/16; int ch = lcn%(32); int ca = (lcn/32)%16; int cr = lcn/(32*16); int db = ch/8; int status = 0; /* Test CHS */ if( !chs.IsTubeOnline( lcn ) ) status |= (1< PMTCalStatus::FlagHits(){ /* Returns vector of channels that were flagged * as out-of-sync or having missed counts. * Handles the fact that the tables might not * exist for every run, especially the sync24 * tables. */ try{ DBLinkPtr flagTable = DB::Get()->GetLink("MISSED_COUNTS"); fFlag = flagTable->GetIArray("missed_counts"); FillFlag(fFlag); } catch(DBNotFoundError &e){ detail << "No MISSED_COUNTS Table." << endl; } try{ DBLinkPtr flagTable = DB::Get()->GetLink("CMOS_SYNC16"); fFlag= flagTable->GetIArray("cmos_sync16"); FillFlag(fFlag); } catch(DBNotFoundError &e){ detail << "No CMOS_SYNC16 table." << endl; } try{ DBLinkPtr flagTable = DB::Get()->GetLink("CMOS_SYNC16_PREVIOUS_RUNS"); fFlag = flagTable->GetIArray("cmos_sync16"); FillFlag(fFlag); } catch(DBNotFoundError &e){ detail << "No CMOS_SYNC16 table for previous runs." << endl; } try{ DBLinkPtr flagTable = DB::Get()->GetLink("CGT_SYNC24"); fFlag = flagTable->GetIArray("cgt_sync24"); FillFlag(fFlag); } catch(DBNotFoundError &e){ detail << "No CGT_SYNC24 table." << endl; } try{ DBLinkPtr flagTable = DB::Get()->GetLink("CGT_SYNC24_PREVIOUS_RUNS"); fFlag = flagTable->GetIArray("cgt_sync24"); FillFlag(fFlag); } catch(DBNotFoundError &e){ detail << "No CGT_SYNC24 table for previous runs." << endl; } return flagHits; } void PMTCalStatus::FillFlag(std::vector flags){ for(int i = 0; i < flags.size(); i++){ if(!flags[i]) continue; flagHits[i] = 1; } }