// Program to plot FGD temperatures. // By default plots the average busboards (BB) temperatures for each FEB and individual BB sensors // for a week. User can specify the start date, end date and a file to save plots #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[]){ // Default times int start_time = gscUtils::GetEncodedPreviousWeek(); int end_time = gscUtils::GetEncodedCurrentTime(); bool modeSave = false; std::cout << "No args: " << argc << std::endl; if(argc > 1){ switch(argc){ case 3: // mode chosen start time start_time = gscUtils::EncodeTime(argv[1],argv[2]); break; case 5: // mode chosen start and end time start_time = gscUtils::EncodeTime(argv[1],argv[2]); end_time = gscUtils::EncodeTime(argv[3],argv[4]); break; } } // Make plots of humidity std::vector fgd_humidity; int crates[8] = {3,8,14,21,27,32,38,45}; for(int i = 0; i < 8; i++){ fgd_humidity.push_back(new TGraph()); } std::cout << "Start time: " << start_time << " and end time: " << end_time << std::endl; // Loop over crates for(int i =0; i < 8; i++){ int min = crates[i]; // Prepare the table name and list of required fields (ie columns); // In this case we will ask for the humidity sensor reading. char table_name[100]; sprintf(table_name,"fgdsc_f%02il",min); std::vector input_fields; char field[100]; sprintf(field,"f%02il_rhumid",min); std::string s(field); input_fields.push_back(s); sprintf(field,"f%02il_pdvsc",min); std::string s1(field); input_fields.push_back(s1); sprintf(field,"f%02il_pdisc",min); std::string s2(field); input_fields.push_back(s2); sprintf(field,"f%02il_pdv6",min); std::string s3(field); input_fields.push_back(s3); sprintf(field,"f%02il_pdi6",min); std::string s4(field); input_fields.push_back(s4); // get fiels of table between start and end time ordered by distance std::vector > > allhumidity = ISlowControlDatabase::Get().QueryGetFieldStartEndTime(table_name,input_fields,start_time,end_time); // Loop over all time entries for(int t = 0; t < allhumidity.size(); t++){ double time = allhumidity[t].first - start_time; double time_hours = time/(60.*60.); double humidity = allhumidity[t].second[0]; int nn = fgd_humidity[i]->GetN(); fgd_humidity[i]->SetPoint(nn,time_hours,humidity); } } TCanvas *canvas_histo = new TCanvas("histo_canvas","Humidity vs Time"); TLegend *leg = new TLegend(0.6,0.7,0.89,0.89); leg->SetNColumns(2); for(int i = 0; i < 8; i++){ if(i == 0){ fgd_humidity[i]->Draw("AP*"); fgd_humidity[i]->GetYaxis()->SetRangeUser(13,20); fgd_humidity[i]->GetYaxis()->SetTitle("Relative Humidity"); fgd_humidity[i]->GetXaxis()->SetTitle("Time (hours)"); fgd_humidity[i]->SetTitle("Humidity vs Time"); }else{ fgd_humidity[i]->Draw("*"); } fgd_humidity[i]->SetMarkerColor(i+1); fgd_humidity[i]->SetMarkerStyle(20+i); char name[100]; sprintf(name,"Crate %i",crates[i]); leg->AddEntry(fgd_humidity[i],name,"p"); } leg->Draw("SAME"); //histo_temps->Draw(); if(!modeSave) myapp.Run(1); }