// Program to plot current FGD temperatures. #include "TH1F.h" #include "TROOT.h" #include "TTree.h" #include "TFile.h" #include "TLine.h" #include "TMath.h" #include "TStyle.h" #include "TApplication.h" #include "TCanvas.h" #include "TPad.h" #include "TProfile.h" #include "TH1.h" #include "TF1.h" #include "TF2.h" #include "TH2.h" #include "TGraphErrors.h" #include "TLegend.h" //#include "IMidasFile.h" #include #include #include //#include "SCDatabase.h" #include "ISlowControlDatabase.hxx" #include "gscUtils.hxx" TApplication myapp("myapp",0,0,0,0); int main(int argc, char* argv[]){ // FGD electronics numbers const int NMIN = 48; // number of minicrates const int NFEB = 4; // number of FEBs const int NSENSOR = 8; // number of temperature sensors TH2F *feb_bb_temps = new TH2F("feb_bb_temps","FEB busboard temperatures",48,-0.5,47.5,4,-0.5, 3.5); TH2F *feb_uC_temps = new TH2F("feb_uC_temps","FEB uC temperatures",48,-0.5,47.5,4,-0.5, 3.5); TH2F *feb_aft_temps = new TH2F("feb_aft_temps","FEB AFTER temperatures",48,-0.5,47.5,4,-0.5, 3.5); TH2F *feb_adc_temps = new TH2F("feb_adc_temps","FEB ADC temperatures",48,-0.5,47.5,4,-0.5, 3.5); TH2F *feb_reg_temps = new TH2F("feb_reg_temps","FEB Regulator temperatures",48,-0.5,47.5,4,-0.5, 3.5); TH1F *cmb_uC_temps = new TH1F("cmb_uC_temps","CMB uC temperatures",48,-0.5,47.5); TH1F *cmb_fpga_temps = new TH1F("cmb_fpga_temps","CMB FPGA temperatures",48,-0.5,47.5); TH1F *cmb_reg_temps = new TH1F("cmb_reg_temps","CMB Regulator temperatures",48,-0.5,47.5); // Loop over minicrates for(int min =0; min < NMIN; min++){ // Loop over febs for(int feb = 0; feb < 4; feb++){ if(min >= 24 && (feb == 1 || feb == 3)) continue; // don't have FEBs here... struct timeval last; gettimeofday(&last,NULL); // Prepare the table name and list of required fields (ie columns); // In this case we will ask for the // - eight busboard temperature sensors for each FEB. // - one uC temp // - one AFTER temp // - one ADC temp // - one REG temp char table_name[100]; sprintf(table_name,"fgdsc_f%02i%01i",min,feb); std::vector input_fields; for(int tt = 0; tt < NSENSOR; tt++){ char field[100]; sprintf(field,"f%02i%01i_temp%i",min,feb,tt); std::string s(field); input_fields.push_back(s); } char field[100]; sprintf(field,"f%02i%01i_uCTemp",min,feb); std::string s(field); input_fields.push_back(s); sprintf(field,"f%02i%01i_aftTemp",min,feb); std::string s2(field); input_fields.push_back(s2); sprintf(field,"f%02i%01i_adcTemp",min,feb); std::string s3(field); input_fields.push_back(s3); sprintf(field,"f%02i%01i_regTemp",min,feb); std::string s4(field); input_fields.push_back(s4); std::vector alltemps = ISlowControlDatabase::Get().GetLastEntryNoCache(table_name,input_fields); struct timeval currentt; gettimeofday(¤tt,NULL); double timet = currentt.tv_sec-last.tv_sec + (currentt.tv_usec-last.tv_usec)/1000000.0; //std::cout << "time to complete this feb " << min << "/" << feb << " is " << timet << " s "<< std::endl; if(alltemps.size() != 12) std::cout << "Damn. Wrong number: " << alltemps.size() << std::endl; double avg_current = 0.0, denom = 0.0; for(int i = 0; i < 8; i++){ if(feb == 3 && i >=6) continue; if(min >= 24 && feb == 2 && i >=6) continue; if(alltemps[i] < 15 || alltemps[i] > 40){ std::cerr <<" ERROR: BAD TEMPERATURE READING T = " << alltemps[i] << ". MIN = " << min << " FEB = " << feb << " sensor = " << i << std::endl; continue; } avg_current += alltemps[i]; denom += 1.0; } avg_current /= denom; //std::cout << "avg temp " << avg_current << std::endl; feb_bb_temps->SetBinContent(min+1,feb+1,avg_current); feb_uC_temps->SetBinContent(min+1,feb+1,alltemps[8]); feb_aft_temps->SetBinContent(min+1,feb+1,alltemps[9]); feb_adc_temps->SetBinContent(min+1,feb+1,alltemps[10]); feb_reg_temps->SetBinContent(min+1,feb+1,alltemps[11]); } // Get CMB temperatures char table_name[100]; sprintf(table_name,"fgdsc_f%02im",min); std::vector input_fields; char field[100]; sprintf(field,"f%02im_uCTemp",min); std::string s(field); input_fields.push_back(s); sprintf(field,"f%02im_FpgaTemp",min); std::string s2(field); input_fields.push_back(s2); sprintf(field,"f%02im_Vrg1Temp",min); std::string s3(field); input_fields.push_back(s3); std::vector alltemps = ISlowControlDatabase::Get().GetLastEntryNoCache(table_name,input_fields); if(alltemps.size() != 3) { std::cerr << "Error! bad size = " << alltemps.size() << std::endl; continue; } cmb_uC_temps->SetBinContent(min+1,alltemps[0]); cmb_fpga_temps->SetBinContent(min+1,alltemps[1]); cmb_reg_temps->SetBinContent(min+1,alltemps[2]); } gStyle->SetPalette(1); gStyle->SetOptStat(0); TCanvas *c1 = new TCanvas("C1","FEB Busboard Temperatures",25,25,1000,800); feb_bb_temps->Draw("COLZ"); feb_bb_temps->SetMinimum(18); feb_bb_temps->SetXTitle("Minicrate"); feb_bb_temps->SetYTitle("FEB"); c1->SaveAs("FgdCurrentBusboardTemp.gif"); TCanvas *c2 = new TCanvas("C2","FEB MicroController Temperatures",50,50,1000,800); feb_uC_temps->Draw("COLZ"); feb_uC_temps->SetMinimum(18); feb_uC_temps->SetXTitle("Minicrate"); feb_uC_temps->SetYTitle("FEB"); c2->SaveAs("FgdCurrentUCTemp.gif"); TCanvas *c3 = new TCanvas("C3","FEB AFTER Temperatures",75,75,1000,800); feb_aft_temps->Draw("COLZ"); feb_aft_temps->SetMinimum(18); feb_aft_temps->SetXTitle("Minicrate"); feb_aft_temps->SetYTitle("FEB"); c3->SaveAs("FgdCurrentAftTemp.gif"); TCanvas *c4 = new TCanvas("C4","FEB ADC Temperatures",100,100,1000,800); feb_adc_temps->Draw("COLZ"); feb_adc_temps->SetMinimum(18); feb_adc_temps->SetXTitle("Minicrate"); feb_adc_temps->SetYTitle("FEB"); c4->SaveAs("FgdCurrentAdcTemp.gif"); TCanvas *c5 = new TCanvas("C5","FEB Regulator Temperatures",125,125,1000,800); feb_reg_temps->Draw("COLZ"); feb_reg_temps->SetMinimum(18); feb_reg_temps->SetXTitle("Minicrate"); feb_reg_temps->SetYTitle("FEB"); c5->SaveAs("FgdCurrentRegTemp.gif"); TCanvas *c6 = new TCanvas("C6","CMB MicroController Temperatures",150,150,1000,800); cmb_uC_temps->Draw(); cmb_uC_temps->SetMinimum(18); cmb_uC_temps->SetXTitle("Minicrate"); cmb_uC_temps->SetYTitle("Temperature (C)"); c6->SaveAs("FgdCMBCurrentUCTemp.gif"); TCanvas *c7 = new TCanvas("C7","CMB FPGA Temperatures",175,175,1000,800); cmb_fpga_temps->Draw(); cmb_fpga_temps->SetMinimum(18); cmb_fpga_temps->SetXTitle("Minicrate"); cmb_fpga_temps->SetYTitle("Temperature (C)"); c7->SaveAs("FgdCMBCurrentUCTemp.gif"); TCanvas *c8 = new TCanvas("C8","CMB Regulator Temperatures",200,200,1000,800); cmb_reg_temps->Draw(); cmb_reg_temps->SetMinimum(18); cmb_reg_temps->SetXTitle("Minicrate"); cmb_reg_temps->SetYTitle("Temperature (C)"); c8->SaveAs("FgdCMBCurrentUCTemp.gif"); myapp.Run(1); }