// ChanSWStatus.cc // Contact person: Billy Liggins ( billy.liggins@qmul.ac.uk) // See ChanSWStatus.hh for more details //———————————————————————// #include #include #include #include #include #include using namespace RAT; using namespace RAT::DU; #include #include using namespace std; ClassImp( RAT::DU::ChanSWStatus ) void ChanSWStatus::BeginOfRun() { //Setting up the bitMask. fBitMap["run_length"] = RunLength; fBitMap["high_occ"] = HighOcc; fBitMap["low_occ"] = LowOcc; fBitMap["qhs"] = QHS; fBitMap["qhl"] = QHL; fBitMap["qlx"] = QLX; fBitMap["tac"] = TAC; fBitMap["eca"] = ECA; fBitMap["pca"] = PCA; fBitMap["chs"] = CHS; fBitMap["chs_standard"] = CHS_STANDARD; for( map::iterator iter = fBitMap.begin(); iter != fBitMap.end(); ++iter ) fInverseBitMap[iter->second] = iter->first; DBLinkPtr lCSSMask = DB::Get()->GetLink("CSS_SELECTION"); for( std::map::const_iterator iter = fBitMap.begin(); iter != fBitMap.end(); ++iter ){ fdefaultCSS |= lCSSMask->GetI( iter->first) << iter->second; } DBLinkPtr lCSSReuslt = DB::Get()->GetLink( "CSS_RESULT" ); try { channelMask = lCSSReuslt->GetIArray("channelWord"); fResultExist= true; }catch( DBNotFoundError& e ) { info<< "ChanSWStatus: CSS_RESULT table not found. IsTubeStable() will return true by default.\n"; } } bool ChanSWStatus::IsTubeStable( const unsigned int lcn ) const { if(fResultExist){ return ( channelMask.at( lcn ) & fdefaultCSS ) == 0; }else{ //CSS assumes the channel is stable until it has evidence it isn't. return true; } } string ChanSWStatus::GetBitName( const size_t index ) const { Log::Assert( fInverseBitMap.count( index ) > 0, "ChanSWStatus::GetBitName: Index '" + ::to_string( index ) + "' is invalid." ); return fInverseBitMap.at( index ); } size_t ChanSWStatus::GetBitIndex( const std::string& name ) const { Log::Assert( fBitMap.count( name ) > 0, "ChanSWStatus::GetBitIndex: Name '" + name + "' is invalid." ); return fBitMap.at( name ); } std::vector ChanSWStatus::GetBitNames() const { std::vector names; for( std::map::const_iterator iTer = fInverseBitMap.begin(); iTer != fInverseBitMap.end(); ++iTer ) names.push_back(iTer->second); return names; } void ChanSWStatus::DumpNames() { info << "ChanSWStatus::Dump: Bit index and name." << newline; for( map::iterator iTer = fInverseBitMap.begin(); iTer != fInverseBitMap.end(); ++iTer ) info << dformat("%3d : %s", iTer->first, iTer->second.c_str() ) << newline; } const std::map& ChanSWStatus::GetBitMap() const{ return fBitMap; } const std::map& ChanSWStatus::GetInverseBitMap() const{ return fInverseBitMap; }