/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/root/slowcontrol.cpp File Reference

#include "event/Run.hh"
#include "xml/XMLTool.hh"
#include "tools/Log.hh"
#include "tools/MicroException.hh"
#include "slowControl/SlowControlManager.hh"
#include "slowControl/SlowControlEntry.hh"
#include "slowControl/BoardSlowControl.hh"
#include "slowControl/PMSlowControl.hh"
#include <iostream>
#include <time.h>
#include "TROOT.h"
#include "TGraph.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "TTimeStamp.h"
#include "TFrame.h"
#include "TApplication.h"
#include <TRint.h>

Include dependency graph for slowcontrol.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 33 of file slowcontrol.cpp.

00034 {
00035 string steerName;
00036 
00037 
00038   TApplication *theApp  = NULL;
00039   // set verbose level
00040   FILELog::ReportingLevel() = FILELog::FromString(INFO);
00041 
00042   ui32 slowcontrolNotFound = 0;
00043 
00044 //----- Control usage and option
00045   if ( argc != 2  ) {
00046   }
00047 
00048   // Get command parameter : here steering file
00049    steerName.assign(argv[1]);
00050     
00051   // test if steer file exist
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     //theApp  = new TRint("App", &argc, argv);
00063     theApp  = new TRint("App",NULL,NULL );
00064     SteerDesc steerDesc;
00065     XMLTool xml;
00066     xml.parse(steerDesc, steerName); // parse steer file and fill steerDesc
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 //    Double_t x[n] , y[n];
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 //cout << "timestamp     :"<< timestamp[index] << endl;
00108 //cout << "temperature   :"<< temperature[index] << endl;
00109 //cout << "Drift ASU 13  :"<< voltage[0][index] << endl;
00110 //cout << "Mesh  ASU 13  :"<< voltage[1][index] << endl;
00111  const PMSlowControl &pm = entry.getPM(1);
00112  const PMParams_t &param = pm.getParams();
00113 //cout << "PM1           :"<< param.v1 << endl << endl;
00114       }
00115       catch ( MicroException &e)
00116       {
00117         cout << e.getMessage() << endl;
00118         exit(-1);
00119       }
00120       index++;
00121     }
00122       
00123 
00124 
00125   // Fill Root Graph and display it
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    TGraph *gr_pressure = new TGraph(n,timestamp,pressure);
00149    gr_temp->SetTitle("SPS H4 August temperature form slow control");
00150    gr_temp->GetXaxis()->SetTitle("timestamp");
00151    gr_temp->GetYaxis()->SetTitle("temperature");
00152    gr_temp->Draw("ACP");
00153 
00154    gr_pressure->SetTitle("SPS H4 August pressure form slow control");
00155    gr_pressure->GetXaxis()->SetTitle("timestamp");
00156    gr_pressure->GetYaxis()->SetTitle("pressure");
00157    gr_pressure->Draw("ACP");
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 }


Generated on Mon Jan 7 13:17:21 2013 for MicromegasFramework by  doxygen 1.4.7