00001
00002 #include "event/Run.hh"
00003
00004 #include "xml/XMLTool.hh"
00005
00006 #include "tools/Log.hh"
00007 #include "tools/MicroException.hh"
00008
00009 #include "slowControl/SlowControlManager.hh"
00010 #include "slowControl/SlowControlEntry.hh"
00011 #include "slowControl/BoardSlowControl.hh"
00012 #include "slowControl/PMSlowControl.hh"
00013
00014 #include <iostream>
00015 #include <time.h>
00016
00017
00018
00019 #include "TROOT.h"
00020 #include "TGraph.h"
00021 #include "TCanvas.h"
00022 #include "TAxis.h"
00023 #include "TTimeStamp.h"
00024 #include "TFrame.h"
00025 #include "TApplication.h"
00026 #include <TRint.h>
00027
00028
00029
00030
00031 using namespace std;
00032
00033 int main(int argc, char **argv)
00034 {
00035 string steerName;
00036
00037
00038 TApplication *theApp = NULL;
00039
00040 FILELog::ReportingLevel() = FILELog::FromString(INFO);
00041
00042 ui32 slowcontrolNotFound = 0;
00043
00044
00045 if ( argc != 2 ) {
00046 }
00047
00048
00049 steerName.assign(argv[1]);
00050
00051
00052 FILE *file = fopen(steerName.c_str(), "r");
00053 if(file == NULL){
00054 FILE_LOG(logERROR) << "Steer file ["<< steerName.c_str() << "] does not exist" << endl;
00055 exit(0);
00056 fclose(file);
00057 }
00058 else
00059 {
00060
00061
00062
00063 theApp = new TRint("App",NULL,NULL );
00064 SteerDesc steerDesc;
00065 XMLTool xml;
00066 xml.parse(steerDesc, steerName);
00067 fclose(file);
00068
00069 string slowControlPath = steerDesc.getSlowControlPath();
00070 SlowControlManager sc;
00071 sc.build(steerDesc);
00072 sc.readDB(slowControlPath);
00073
00074 FILE_LOG(logINFO) << "slowControl entries:[" << sc.getNbEntries() << "]" << endl;
00075
00076 const Int_t n = sc.getNbEntries();
00077 Double_t timestamp[n] ;
00078 Double_t temperature[n] ;
00079 Double_t pressure[n] ;
00080 Double_t rapport[n] ;
00081 Double_t voltage[6][n] ;
00082 TTimeStamp timeformat[n];
00083
00084
00085
00086
00087 UInt_t index = 0;
00088 for ( std::set<SlowControlEntry>::const_iterator iter = sc.begin(); iter!=sc.end(); iter++)
00089 {
00090 const SlowControlEntry& entry = *iter;
00091 timestamp[index] = entry.getTimeStamp();
00092 temperature[index] = entry.getTemperature();
00093 pressure[index] = entry.getPressure();
00094 time_t val = time_t(( entry.getTimeStamp() / 1000));
00095 timeformat[index] = TTimeStamp( val,0);
00096 rapport[index] = entry.getPressure()/entry.getTemperature();
00097
00098 try
00099 {
00100 voltage[0][index] = entry.getBoard(1,84,13).getDrift().voltage;
00101 voltage[1][index] = entry.getBoard(1,84,13).getMesh().voltage;
00102 voltage[2][index] = entry.getPM(1).getParams().v1;
00103 voltage[3][index] = entry.getPM(1).getParams().v2;
00104 voltage[4][index] = entry.getBoard(22,0,1).getDrift().voltage;
00105 voltage[5][index] = entry.getBoard(22,0,1).getMesh().voltage;
00106
00107
00108
00109
00110
00111 const PMSlowControl &pm = entry.getPM(1);
00112 const PMParams_t ¶m = pm.getParams();
00113
00114 }
00115 catch ( MicroException &e)
00116 {
00117 cout << e.getMessage() << endl;
00118 exit(-1);
00119 }
00120 index++;
00121 }
00122
00123
00124
00125
00126 TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);
00127
00128 c1->SetFillColor(42);
00129 c1->SetGrid();
00130 c1->Divide(2,3);
00131
00132
00133 TGraph *gr_temp = new TGraph(n,timestamp,temperature);
00134 TGraph *gr_pressure_temp = new TGraph(n,timestamp,rapport);
00135 TGraph *gr_vol_1_84_13 = new TGraph(n,timestamp,voltage[0]);
00136 TGraph *gr_vol_1_84_14 = new TGraph(n,timestamp,voltage[1]);
00137 TGraph *gr_vol_1_85_15 = new TGraph(n,timestamp,voltage[2]);
00138 TGraph *gr_vol_1_85_16 = new TGraph(n,timestamp,voltage[3]);
00139 TGraph *gr_vol_1_88_17 = new TGraph(n,timestamp,voltage[4]);
00140 TGraph *gr_vol_1_88_18 = new TGraph(n,timestamp,voltage[5]);
00141
00142 for (UInt_t i=1;i<=index;i=i+1000) {
00143 const char * foo = timeformat[i].AsString("s");
00144 }
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 c1->cd(1);
00162 gr_vol_1_84_13->SetTitle("Drift voltage ASU 13");
00163 gr_vol_1_84_13->GetXaxis()->SetTitle("timestamp");
00164 gr_vol_1_84_13->GetYaxis()->SetTitle("voltage");
00165 gr_vol_1_84_13->Draw("AL");
00166
00167 c1->cd(2);
00168 gr_vol_1_84_14->SetTitle("Mesh voltage ASU 13");
00169 gr_vol_1_84_14->GetXaxis()->SetTitle("timestamp");
00170 gr_vol_1_84_14->GetYaxis()->SetTitle("voltage");
00171 gr_vol_1_84_14->Draw("AL");
00172
00173 c1->cd(3);
00174 gr_vol_1_85_15->SetTitle("PM1 v1");
00175 gr_vol_1_85_15->GetXaxis()->SetTitle("timestamp");
00176 gr_vol_1_85_15->GetYaxis()->SetTitle("voltage");
00177 gr_vol_1_85_15->Draw("AL");
00178
00179 c1->cd(4);
00180 gr_vol_1_85_16->SetTitle("PM1 v2");
00181 gr_vol_1_85_16->GetXaxis()->SetTitle("timestamp");
00182 gr_vol_1_85_16->GetYaxis()->SetTitle("voltage");
00183 gr_vol_1_85_16->Draw("AL");
00184
00185 c1->cd(5);
00186 gr_vol_1_88_17->SetTitle("Strip 1 Drift");
00187 gr_vol_1_88_17->GetXaxis()->SetTitle("timestamp");
00188 gr_vol_1_88_17->GetYaxis()->SetTitle("voltage");
00189 gr_vol_1_88_17->Draw("AL");
00190
00191 c1->cd(6);
00192 gr_vol_1_88_18->SetTitle("Strip 1 Mesh");
00193 gr_vol_1_88_18->GetXaxis()->SetTitle("timestamp");
00194 gr_vol_1_88_18->GetYaxis()->SetTitle("voltage");
00195 gr_vol_1_88_18->Draw("AL");
00196
00197 c1->Update();
00198
00199
00200 }
00201
00202 theApp->Run();
00203 delete theApp;
00204 return 0;
00205 }