//#include #include "TROOT.h" #include "TDatime.h" #include "TGraph.h" #include "TFile.h" #include "TTree.h" #include #include "TAxis.h" #include "TCanvas.h" #include #include "TLegend.h" using namespace std; //void Plot(int, string); /* int main (int argc, char* argv[]) { if (argc<=1 ) { cout<<"usage: IGraphs "<Convert(); if (period==1) time_begin-= 7*24*60*60; else if (period==2) time_begin-=24*60*60; //vars for tree data float fHV_plus[1]; float fHV_minus[1]; float fI_plus[1]; float fI_minus[1]; float fT1[1]; float fT2[1]; float fT3[1]; float fT4[1]; float fT5[1]; float fT6[1]; float fT7[1]; float fT8[1]; float fT9[1]; float fP[1]; float fRH1[1]; float fRH2[1]; float fHV_total[1]; float fI_mean[1]; float fT_mean[1]; float fRH_mean[1]; struct Times { UInt_t Date; UInt_t Time; } fTimes; //Init Graphs //DEBUG// cout << "test1"<Get(RPC_name.c_str()); ///////////////////////////////automate //access branches //DEBUG// cout << "opened file"<SetBranchAddress("HV_plus",fHV_plus); fTree->SetBranchAddress("HV_minus",fHV_minus); fTree->SetBranchAddress("I_plus",fI_plus); fTree->SetBranchAddress("I_minus",fI_minus); fTree->SetBranchAddress("T1",fT1); fTree->SetBranchAddress("T2",fT2); fTree->SetBranchAddress("T3",fT3); fTree->SetBranchAddress("T4",fT4); fTree->SetBranchAddress("T5",fT5); fTree->SetBranchAddress("T6",fT6); fTree->SetBranchAddress("T7",fT7); fTree->SetBranchAddress("T8",fT8); fTree->SetBranchAddress("T9",fT9); fTree->SetBranchAddress("RH1",fRH1); fTree->SetBranchAddress("RH2",fRH2); fTree->SetBranchAddress("P",fP); fTree->SetBranchAddress("HV_total",fHV_total); fTree->SetBranchAddress("I_mean",fI_mean); fTree->SetBranchAddress("T_mean",fT_mean); fTree->SetBranchAddress("RH_mean",fRH_mean); fTree->SetBranchAddress("Times",&fTimes); //DEBUG// cout << "Brances"<GetEntries(); Int_t ipoint=0; // Int_t ipointT1=0; // Int_t ipointT2=0; // Int_t ipointT3=0; // Int_t ipointP=0; // Int_t ipointT4=0; // Int_t ipointRH=0; for (Int_t i=0;iGetEntry(i); time->Set((Int_t)fTimes.Date,(Int_t)fTimes.Time); //cout << fTimes.Date << " =? " << time->GetDate() << " XXX " // <GetTime() << " --> " // <Convert() <<" Convert()Convert(),plot_val); if (ipoint==0) { HV_max=plot_val; HV_min=plot_val; } if (plot_val>HV_max) HV_max=plot_val; if (plot_valConvert(),plot_val); if (plot_val>HV_max) HV_max=plot_val; if (plot_valConvert(),plot_val); if (plot_val>HV_max) HV_max=plot_val; if (plot_valConvert(),plot_val); if (ipoint==0) { I_max=plot_val; I_min=plot_val; } if (plot_val>I_max) I_max=plot_val; if (plot_valConvert(),plot_val); if (plot_val>I_max) I_max=plot_val; if (plot_valConvert(),plot_val); if (plot_val>I_max) I_max=plot_val; if (plot_valConvert(),plot_val); if (ipoint==0) { Tmax=plot_val; Tmin=plot_val; } if (plot_val>Tmax) Tmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>Tmax) Tmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>Tmax) Tmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>Tmax) Tmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>Tmax) Tmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>Tmax) Tmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>Tmax) Tmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>Tmax) Tmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>Tmax) Tmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>Tmax) Tmax=plot_val; if (plot_valConvert(),plot_val); if (ipoint==0) { RHmax=plot_val; RHmin=plot_val; } if (plot_val>RHmax) RHmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>RHmax) RHmax=plot_val; if (plot_valConvert(),plot_val); if (plot_val>RHmax) RHmax=plot_val; if (plot_valConvert(),plot_val); if (ipoint==0) { Pmax=plot_val; Pmin=plot_val; } if (plot_val>Pmax) Pmax=plot_val; if (plot_val80)Tmax=80; for (int igraph=0;igraph<20;igraph++) //for HV and Temp and Press and RH { vGraph[igraph].GetXaxis()->SetTimeDisplay(1); vGraph[igraph].SetLineWidth(2); } //////////////////////////////////////////////////// //High Voltage //////////////////////////////////////////////////// //vGraph[0].GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M"); float HV_toler=(HV_max-HV_min)*.1; vGraph[0].GetXaxis()->SetTimeOffset(0,"gmt"); vGraph[0].GetYaxis()->SetRangeUser(HV_min-HV_toler,HV_max+HV_toler); TCanvas* cHV= new TCanvas("cHV","cHV",550,390); vGraph[0].GetYaxis()->SetRangeUser(HV_min-HV_toler,HV_max+HV_toler); vGraph[0].SetLineColor(kRed); vGraph[0].Draw("al"); vGraph[1].SetLineColor(kBlue); vGraph[1].Draw("l"); vGraph[2].SetLineColor(kBlack); vGraph[2].Draw("l"); vGraph[0].SetTitle(RPC_name+TString(" HV plot produced on ")+TDatime().AsString()); vGraph[0].GetYaxis()->SetTitle("Applied HV [V]"); vGraph[0].GetXaxis()->SetTitle("Date-Time"); TLegend* legHV=new TLegend(.85,.75,.95,.95); //leg->SetHeader("Station"); legHV->AddEntry(&(vGraph[0]),"HV+","l"); legHV->AddEntry(&(vGraph[1]),"HV-","l"); legHV->AddEntry(&(vGraph[2]),"","l"); legHV->Draw(); //save it // cout << "saving it"<Print((sBase+RPC_name+"Plot_HV_all.png").c_str()); else if (period==1) cHV->Print((sBase+RPC_name+"Plot_HV_week.png").c_str()); else if (period==2) cHV->Print((sBase+RPC_name+"Plot_HV_day.png").c_str()); //////////////////////////////////////////////////// //Current //////////////////////////////////////////////////// //vGraph[0].GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M"); float I_toler=(I_max-I_min)*.1; vGraph[3].GetXaxis()->SetTimeOffset(0,"gmt"); vGraph[3].GetYaxis()->SetRangeUser(I_min-I_toler,I_max+I_toler); TCanvas* cI= new TCanvas("cI","cI",550,390); vGraph[3].GetYaxis()->SetRangeUser(I_min-I_toler,I_max+I_toler); vGraph[3].SetLineColor(kRed); vGraph[3].Draw("al"); vGraph[4].SetLineColor(kBlue); vGraph[4].Draw("l"); vGraph[5].SetLineColor(kBlack); vGraph[5].Draw("l"); vGraph[3].SetTitle(RPC_name+TString(" I plot produced on ")+TDatime().AsString()); vGraph[3].GetYaxis()->SetTitle("I [nA]"); vGraph[3].GetXaxis()->SetTitle("Date-Time"); TLegend* legI=new TLegend(.85,.75,.95,.95); //leg->SetHeader("Station"); legI->AddEntry(&(vGraph[3]),"I+","l"); legI->AddEntry(&(vGraph[4]),"I-","l"); legI->AddEntry(&(vGraph[5]),"","l"); legI->Draw(); //save it // cout << "saving it"<Print((sBase+RPC_name+"Plot_I_all.png").c_str()); else if (period==1) cI->Print((sBase+RPC_name+"Plot_I_week.png").c_str()); else if (period==2) cI->Print((sBase+RPC_name+"Plot_I_day.png").c_str()); //////////////////////////////////////////////////// //Temperature //////////////////////////////////////////////////// //vGraph[0].GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M"); float T_toler=(Tmax-Tmin)*.1; vGraph[6].GetXaxis()->SetTimeOffset(0,"gmt"); vGraph[6].GetYaxis()->SetRangeUser(Tmin-T_toler,Tmax+T_toler); TCanvas* cT= new TCanvas("cT","cT",550,390); vGraph[6].GetYaxis()->SetRangeUser(Tmin-T_toler,Tmax+T_toler); vGraph[6].SetLineColor(kYellow+2); vGraph[6].Draw("al"); vGraph[7].SetLineColor(kOrange); vGraph[7].Draw("l"); vGraph[8].SetLineColor(kRed+2); vGraph[8].Draw("l"); vGraph[9].SetLineColor(kPink); vGraph[9].Draw("l"); vGraph[10].SetLineColor(kMagenta+1); vGraph[10].Draw("l"); vGraph[11].SetLineColor(kViolet+6); vGraph[11].Draw("l"); vGraph[12].SetLineColor(kBlue-7); vGraph[12].Draw("l"); vGraph[13].SetLineColor(kCyan-2); vGraph[13].Draw("l"); vGraph[14].SetLineColor(kGreen+2); vGraph[14].Draw("l"); vGraph[15].SetLineColor(kBlack); vGraph[15].Draw("l"); vGraph[6].SetTitle(RPC_name+TString(" T plot produced on ")+TDatime().AsString()); vGraph[6].GetYaxis()->SetTitle("T [#circ C]"); vGraph[6].GetXaxis()->SetTitle("Date-Time"); TLegend* legT=new TLegend(.85,.75,.95,.95); //leg->SetHeader("Station"); legT->AddEntry(&(vGraph[6]),"T1","l"); legT->AddEntry(&(vGraph[7]),"T2","l"); legT->AddEntry(&(vGraph[8]),"T3","l"); legT->AddEntry(&(vGraph[9]),"T4","l"); legT->AddEntry(&(vGraph[10]),"T5","l"); legT->AddEntry(&(vGraph[11]),"T6","l"); legT->AddEntry(&(vGraph[12]),"T7","l"); legT->AddEntry(&(vGraph[13]),"T8","l"); legT->AddEntry(&(vGraph[14]),"T9","l"); legT->AddEntry(&(vGraph[15]),"","l"); legT->Draw(); //save it // cout << "saving it"<Print((sBase+RPC_name+"Plot_T_all.png").c_str()); else if (period==1) cT->Print((sBase+RPC_name+"Plot_T_week.png").c_str()); else if (period==2) cT->Print((sBase+RPC_name+"Plot_T_day.png").c_str()); //////////////////////////////////////////////////// //Relative Humidity //////////////////////////////////////////////////// //vGraph[0].GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M"); float RH_toler=(RHmax-RHmin)*.1; vGraph[16].GetXaxis()->SetTimeOffset(0,"gmt"); vGraph[16].GetYaxis()->SetRangeUser(RHmin-RH_toler,RHmax+RH_toler); TCanvas* cRH= new TCanvas("cRH","cRH",550,390); vGraph[16].GetYaxis()->SetRangeUser(RHmin-RH_toler,RHmax+RH_toler); vGraph[16].SetLineColor(kRed); vGraph[16].Draw("al"); vGraph[17].SetLineColor(kBlue); vGraph[17].Draw("l"); vGraph[18].SetLineColor(kBlack); vGraph[18].Draw("l"); vGraph[16].SetTitle(RPC_name+TString(" RH plot produced on ")+TDatime().AsString()); vGraph[16].GetYaxis()->SetTitle(" RH [%]"); vGraph[16].GetXaxis()->SetTitle("Date-Time"); TLegend* legRH=new TLegend(.85,.75,.95,.95); //leg->SetHeader("Station"); legRH->AddEntry(&(vGraph[16]),"RH1","l"); legRH->AddEntry(&(vGraph[17]),"RH2","l"); legRH->AddEntry(&(vGraph[18]),"","l"); legRH->Draw(); //save it // cout << "saving it"<Print((sBase+RPC_name+"Plot_RH_all.png").c_str()); else if (period==1) cRH->Print((sBase+RPC_name+"Plot_RH_week.png").c_str()); else if (period==2) cRH->Print((sBase+RPC_name+"Plot_RH_day.png").c_str()); //////////////////////////////////////////////////// //Pressure //////////////////////////////////////////////////// //vGraph[0].GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M"); float P_toler=(Pmax-Pmin)*.1; vGraph[19].GetXaxis()->SetTimeOffset(0,"gmt"); vGraph[19].GetYaxis()->SetRangeUser(Pmin-P_toler,Pmax+P_toler); TCanvas* cP= new TCanvas("cP","cP",550,390); vGraph[19].GetYaxis()->SetRangeUser(Pmin-P_toler,Pmax+P_toler); vGraph[19].SetLineColor(kBlack); vGraph[19].Draw("al"); vGraph[19].SetTitle(RPC_name+TString(" P plot produced on ")+TDatime().AsString()); vGraph[19].GetYaxis()->SetTitle("P [mbar]"); vGraph[19].GetXaxis()->SetTitle("Date-Time"); TLegend* legP=new TLegend(.85,.75,.95,.95); //leg->SetHeader("Station"); legP->AddEntry(&(vGraph[19]),"P","l"); legP->Draw(); //save it // cout << "saving it"<Print((sBase+RPC_name+"Plot_P_all.png").c_str()); else if (period==1) cP->Print((sBase+RPC_name+"Plot_P_week.png").c_str()); else if (period==2) cP->Print((sBase+RPC_name+"Plot_P_day.png").c_str()); delete time; delete cHV; delete legHV; delete cI; delete legI; delete cT; delete legT; delete cRH; delete legRH; delete cP; delete legP; return; }