/// Class to hold ECAL TFB status for /// a particular time. The class /// holds information to indicate whether: /// Low Voltages are on /// FEMs are Powered /// MM HV > 245V /// DCC Power on /// Cathode HV 24950 to 25050 V /// Blair Jamieson (C) 2010 #include #include #include #include #include "IECALTFBStatus.hxx" #include "ISlowControlDatabase.hxx" #define nrmm 12 ///------------------------------------------------------------------------ /// Initialize ECAL TFB status object using unix time /// If it is intended to use this class to read many /// sequential values, set ancache to some value large /// enough to reduce the number of sql queries IECALTFBStatus::IECALTFBStatus( long autime, long atstart, long atend ){ fTime = autime; // time of current values fDebug = false; fTimeStamp = 0x0; fStartTime = atstart; fEndTime = atend; // nrmm = 2; ntfb[0] = 28; ntfb[1] = 28; ntfb[2] = 15; ntfb[3] = 44; ntfb[4] = 44; ntfb[5] = 26; ntfb[6] = 26; ntfb[7] = 15; ntfb[8] = 26; ntfb[9] = 26; ntfb[10] = 44; ntfb[11] = 44; Init(); } ///------------------------------------------------------------------------ /// Initialize TPC MM status object using year, month(0-11), /// day(1-31),... IECALTFBStatus::IECALTFBStatus( int ayear, int amonth, int aday, int ahour, int amin, int asec, long atstart, long atend){ fTimeStamp=0x0; fDebug = false; SetTimeNoRead(ayear, amonth, aday, ahour, amin, asec); fStartTime = atstart; fEndTime = atend; // nrmm = 2; ntfb[0] = 28; ntfb[1] = 28; ntfb[2] = 15; ntfb[3] = 44; ntfb[4] = 44; ntfb[5] = 26; ntfb[6] = 26; ntfb[7] = 15; ntfb[8] = 26; ntfb[9] = 26; ntfb[10] = 44; ntfb[11] = 44; Init(); } ///------------------------------------------------------------------------ /// Initialize TFB status properties object /// Sets offsets, makes histogram, reads values void IECALTFBStatus::Init(){ // Setup field name strings to read SetupFieldNames(); // Now read system properties int count = 0; for (int irmm=0; irmm=0&&irmm<=9){ sprintf(avarname,"em%1d0_0%02d_tempexternal0",irmm,itfb); } else if(irmm==10){ sprintf(avarname,"ema0_0%02d_tempexternal0",itfb); } else if(irmm==11){ sprintf(avarname,"emb0_0%02d_tempexternal0",itfb); } else { std::cout << "Unrecognized RMM number!" << std::endl; } fTempexternal_names[count].push_back(avarname); if(irmm>=0&&irmm<=9){ sprintf(avarname,"em%1d0_0%02d_vsupply2v5",irmm,itfb); } else if(irmm==10){ sprintf(avarname,"ema0_0%02d_vsupply2v5",itfb); } else if(irmm==11){ sprintf(avarname,"emb0_0%02d_vsupply2v5",itfb); } else { std::cout << "Unrecognized RMM number!" << std::endl; } fTFB_vsupplyv2v5_names[count].push_back(avarname); fTempexternal_names[count].push_back(avarname); // now fTempexternal_names contains the name of vsupply2v5 row as well if(irmm>=0&&irmm<=9){ sprintf(avarname,"em%1d0_0%02d_vbias",irmm,itfb); } else if(irmm==10){ sprintf(avarname,"ema0_0%02d_vbias",itfb); } else if(irmm==11){ sprintf(avarname,"emb0_0%02d_vbias",itfb); } else { std::cout << "Unrecognized RMM number!" << std::endl; } fTFB_vbias_names[count].push_back(avarname); fTempexternal_names[count].push_back(avarname); // now fTempexternal_names contains the name of vbias row as well //fTempexternal_names[count] = std::string(avarname); // std::cout << "Var name: " << avarname << std::endl; count++; } } /* for (int irmm=0; irmm Record for "< fTempexternal_idx[0]+2 ){ start_time = (long) fTempexternal_vec[0][ fTempexternal_idx[0] ].first; end_time = (long) fTempexternal_vec[0][ fTempexternal_idx[0]+1 ].first; } return; } ///------------------------------------------------------------------------ /// Get unix time long IECALTFBStatus::GetUnixTime( int ayear, int amonth, int aday, int ahour, int amin, int asec){ tm mt; // use time structure from time.h // to build unix time from year,month, etc. mt.tm_year = ayear - 1900; mt.tm_mon = amonth-1; mt.tm_mday = aday; mt.tm_hour = ahour; mt.tm_min = amin; mt.tm_sec = asec; mt.tm_isdst = -1; return (long)mktime(&mt); } ///------------------------------------------------------------------------ /// Set the time for this object void IECALTFBStatus::SetTimeNoRead( int ayear, int amonth, int aday, int ahour, int amin, int asec){ fTime = GetUnixTime(ayear, amonth, aday, ahour, amin, asec ); //std::cout<<"SetTimeNoRead "<= long( (fTempexternal_vec[count][i].first) ) && fTime < long( (fTempexternal_vec[count][i+1].first) ) ) { fTempexternal_idx[count] = i; fTempexternal_isok[count] = true; } if ( fTime+adeltat >= long( (fTempexternal_vec[count][i].first) ) && fTime+adeltat < long( (fTempexternal_vec[count][i+1].first) ) ) { fTempexternal_next_idx[count] = i; fTempexternal_next_isok[count] = true; break; } } } count++; } } //end for irmm=0 //now 2.5V line /* count = 0; for(int irmm(0);irmm= long( (fTFB_vsupplyv2v5_vec[count][i].first) ) && fTime < long( (fTFB_vsupplyv2v5_vec[count][i+1].first) ) ) { fTFB_vsupplyv2v5_idx[count] = i; fTFB_vsupplyv2v5_isok[count] = true; } if ( fTime+adeltat >= long( (fTFB_vsupplyv2v5_vec[count][i].first) ) && fTime+adeltat < long( (fTFB_vsupplyv2v5_vec[count][i+1].first) ) ) { fTFB_vsupplyv2v5_next_idx[count] = i; fTFB_vsupplyv2v5_next_isok[count] = true; break; } } } count++; } } //end for irmm=0 */ //now bias voltage /* count = 0; for(int irmm(0);irmm= long( (fTFB_vbias_vec[count][i].first) ) && fTime < long( (fTFB_vbias_vec[count][i+1].first) ) ) { fTFB_vbias_idx[count] = i; fTFB_vbias_isok[count] = true; } if ( fTime+adeltat >= long( (fTFB_vbias_vec[count][i].first) ) && fTime+adeltat < long( (fTFB_vbias_vec[count][i+1].first) ) ) { fTFB_vbias_next_idx[count] = i; fTFB_vbias_next_isok[count] = true; break; } } } count++; } } //end for irmm=0 */ return; } ///------------------------------------------------------------------------ /// Check if we need to read another chunk of slow control /// information from the database void IECALTFBStatus::CheckReadDB(int adeltat){ // buffer of number of readings to end of vector // needed to allow check of next unsigned int NtoEndBuf = 2; int passed[366]= {0}; int proceed = 0; int count=0; for(int irmm = 0;irmm fTempexternal_vec[count][ fTempexternal_vec[count].size()-NtoEndBuf ].first ){ passed[count] = 1; // std::cout << "TempExt Passed (" << count << ") = " << passed[count] << " rmm = " << irmm << " tfb = " << itfb < About to ReadSlowTempexternal with granularity "<< adeltat <"< fEnd){ amult = 1; fTime = fTime + adeltat; } else { if ( fEnd+1 <= fTime ){ // handle case where no readings for a while amult*=2; fTime += amult; } else { amult = 1; fTime = fEnd+1; } } Read( adeltat ); return 1; } ///------------------------------------------------------------------------ /// Update status variables based on the latest readings void IECALTFBStatus::UpdateStatus(){ // hard coded values for now fStatus = 0; // check if bad db read? //first external temperature int count=0; int fail_db_read_temp[12][44]={{0},{0}}; for (int irmm=0; irmm33) { std::cout << "1 - Failed temperature check: rmm = " << irmm << " tfb = " << itfb << " Temp = " << fTempexternal[irmm][itfb] << std::endl; fTFBStatus[irmm][itfb] +=1; } } if((irmm==5&&itfb==0)||(irmm==5&&itfb==5)||(irmm==9&&itfb==23)||(irmm==8&&itfb==19)||(irmm==9&&itfb==23)||(irmm==10&&itfb==10)||(irmm==10&&itfb==13)||(irmm==10&&itfb==15)||(irmm==10&&itfb==20)||(irmm==10&&itfb==22)||(irmm==10&&itfb==24)||(irmm==10&&itfb==27)||(irmm==10&&itfb==30)||(irmm==11&&itfb==14)||(irmm==11&&itfb==20)||(irmm==11&&itfb==28)) { fTFBStatus[irmm][itfb] = 0; //broken voltage sensors } else { if (fTFB_vsupplyv2v5[irmm][itfb]<2.4||fTFB_vsupplyv2v5[irmm][itfb]>2.6) { std::cout << "2 - Failed voltage check: rmm = " << irmm << " tfb = " << itfb << " 2V5 Voltage = " << fTFB_vsupplyv2v5[irmm][itfb] << std::endl; fTFBStatus[irmm][itfb] +=1; } } if((irmm==5&&itfb==0)||(irmm==5&&itfb==5)||(irmm==9&&itfb==23)||(irmm==8&&itfb==19)||(irmm==9&&itfb==23)||(irmm==10&&itfb==10)||(irmm==10&&itfb==13)||(irmm==10&&itfb==15)||(irmm==10&&itfb==20)||(irmm==10&&itfb==22)||(irmm==10&&itfb==24)||(irmm==10&&itfb==27)||(irmm==10&&itfb==30)||(irmm==11&&itfb==14)||(irmm==11&&itfb==20)||(irmm==11&&itfb==28)) { fTFBStatus[irmm][itfb] = 0; //broken voltage sensors } else { if (fTFB_vbias[irmm][itfb]<65.0||fTFB_vbias[irmm][itfb]>71.0) { std::cout << "3 - Failed bias voltage check: rmm = " << irmm << " tfb = " << itfb << " Bias Voltage = " << fTFB_vbias[irmm][itfb] << std::endl; fTFBStatus[irmm][itfb] +=1; } } if (fTFBStatus[irmm][itfb] > fECALStatus[irmm] ){ fECALStatus[irmm] = fTFBStatus[irmm][itfb]; if ( fECALStatus[irmm] > fStatus ) fStatus = fECALStatus[irmm]; } } //end if itfb } //end if irmm return; }