/[PAMELA software]/chewbacca/YodaProfiler/src/GLTables.cpp
ViewVC logotype

Diff of /chewbacca/YodaProfiler/src/GLTables.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by mocchiut, Tue Jan 27 11:38:13 2009 UTC revision 1.11 by mocchiut, Mon Dec 14 16:53:43 2009 UTC
# Line 7  Line 7 
7  //  //
8  #include <sstream>  #include <sstream>
9  #include <iostream>  #include <iostream>
10    #include <limits.h>
11  //  //
12  #include <TFile.h>  #include <TFile.h>
13  #include <TTree.h>  #include <TTree.h>
# Line 17  Line 18 
18  #include <GLTables.h>  #include <GLTables.h>
19  #include <sgp4.h>  #include <sgp4.h>
20  //  //
21    ClassImp(Q2TH);
22  ClassImp(GL_TABLES);  ClassImp(GL_TABLES);
23  ClassImp(GL_TRK_CALIB);  ClassImp(GL_TRK_CALIB);
24  ClassImp(GL_RUN);  ClassImp(GL_RUN);
# Line 30  ClassImp(GL_TLE); Line 32  ClassImp(GL_TLE);
32  //  //
33  using namespace std;  using namespace std;
34    
35    Q2TH::Q2TH(TString host, TString user, TString psw){
36      fh = gSystem->ExpandPathName(host.Data());
37      fu = gSystem->ExpandPathName(user.Data());
38      fp = gSystem->ExpandPathName(psw.Data());
39      dbc = TSQLServer::Connect(fh.Data(),fu.Data(),fp.Data());
40    };
41    
42    TObject *Q2TH::Draw(TString query, Bool_t verbose, TString hname){
43      //
44      pResult = dbc->Query(query.Data());
45      //
46      Row = pResult->Next();      
47      //
48      Int_t dim = pResult->GetFieldCount();
49      if ( dim < 1 || dim > 2 ){
50        printf(" Dim == %i not supported yet \n",dim);
51        return NULL;
52      };  
53      //
54      TH1D *h1 = NULL;
55      TH2D *h2 = NULL;
56      Double_t f1 = 0.;
57      Double_t minf1 = numeric_limits<Double_t>::max();
58      Double_t maxf1 = numeric_limits<Double_t>::min();
59      Double_t f2 = 0.;  
60      Double_t minf2 = numeric_limits<Double_t>::max();
61      Double_t maxf2 = numeric_limits<Double_t>::min();
62      //
63      while ( Row ){    
64        f1 = (Double_t)atof(Row->GetField(0));
65        if ( f1 > maxf1 ) maxf1 = f1;
66        if ( f1 < minf1 ) minf1 = f1;
67        if ( dim == 2 ){
68          f2 = (Double_t)atof(Row->GetField(1));
69          if ( f2 > maxf2 ) maxf2 = f2;
70          if ( f2 < minf2 ) minf2 = f2;
71    
72        };
73        Row = pResult->Next();
74      };
75      pResult->Delete();
76      //
77      Int_t f1bin = 70;
78      Int_t f2bin = 70;
79      if ( dim == 1 ){
80        f1bin = int((maxf1-minf1)/1000.);
81        if ( f1bin < 70 ) f1bin = 70;
82        if ( f1bin > 1000 ) f1bin = 1000;
83        h1 = new TH1D(Form("%s1",hname.Data()),Form("%s1",hname.Data()),f1bin,minf1*0.98,maxf1*1.02);
84        //    h1->SetBit(TH1::kCanRebin);
85        if ( verbose ) printf("\n\n Row     %s \n",pResult->GetFieldName(0));
86      };
87      if ( dim == 2 ){
88        f2bin = int((maxf2-minf2)/1000.);
89        if ( f2bin < 70 ) f2bin = 70;
90        if ( f2bin > 1000 ) f2bin = 1000;
91        h2 = new TH2D(Form("%s2",hname.Data()),Form("%s2",hname.Data()),f1bin,minf1*0.98,maxf1*1.02,f2bin,minf2*0.98,maxf2*1.02);
92        //    h2->SetBit(TH2::kCanRebin);
93        if ( verbose ) printf("\n\n Row     %s     %s \n",pResult->GetFieldName(0),pResult->GetFieldName(1));
94      };
95      //
96      pResult = dbc->Query(query.Data());
97      //
98      Row = pResult->Next();      
99      //
100      Int_t r = 0;
101      //
102      while ( Row ){    
103        f1 = (Double_t)atof(Row->GetField(0));
104        if ( dim == 1 ){
105          if ( verbose ) printf(" %f \n",r,f1);
106          h1->Fill(f1);
107        } else {
108          f2 = (Double_t)atof(Row->GetField(1));
109          if ( verbose ) printf(" %f     %f \n",r,f1,f2);
110          h2->Fill(f1,f2);
111        };
112        r++;
113        Row = pResult->Next();
114      };
115      //
116      TCanvas *c = new TCanvas(Form("%sc",hname.Data()));
117      c->cd();
118      if ( dim == 1 ) h1->Draw();
119      if ( dim == 2 ) h2->Draw();
120      //
121      pResult->Delete();
122      if ( dim == 1 ) return h1;
123      if ( dim == 2 ) return h2;
124      //
125      return NULL;
126    };
127    
128  GL_TABLES::GL_TABLES(){  GL_TABLES::GL_TABLES(){
129  };  };
130    
# Line 56  void GL_TABLES::Set(TString host, TStrin Line 151  void GL_TABLES::Set(TString host, TStrin
151    mp = psw.Data();    mp = psw.Data();
152  };  };
153    
154  Bool_t GL_TABLES::IsConnected(TSQLServer *&dbc){  //Bool_t GL_TABLES::IsConnected(TSQLServer *&dbc){
155    Bool_t GL_TABLES::IsConnected(TSQLServer *dbc){
156    //    //
157    //    //
158    //    //
# Line 92  Bool_t GL_TABLES::IsConnected(TSQLServer Line 188  Bool_t GL_TABLES::IsConnected(TSQLServer
188      TString host = fHost->Data();      TString host = fHost->Data();
189      TString user = fUser->Data();      TString user = fUser->Data();
190      TString psw = fPsw->Data();      TString psw = fPsw->Data();
191      dbc->Close();      if ( dbc ){
192      delete dbc;        dbc->Close();
193          delete dbc;
194        };
195      dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());      dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data());
196      //      //
197      myquery.str("");      myquery.str("");

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.23