/[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.11 by mocchiut, Mon Dec 14 16:53:43 2009 UTC revision 1.13 by mocchiut, Tue Dec 15 10:23:28 2009 UTC
# Line 33  ClassImp(GL_TLE); Line 33  ClassImp(GL_TLE);
33  using namespace std;  using namespace std;
34    
35  Q2TH::Q2TH(TString host, TString user, TString psw){  Q2TH::Q2TH(TString host, TString user, TString psw){
36      this->Open(host,user,psw);
37    };
38    
39    void Q2TH::Open(TString host, TString user, TString psw){
40    fh = gSystem->ExpandPathName(host.Data());    fh = gSystem->ExpandPathName(host.Data());
41    fu = gSystem->ExpandPathName(user.Data());    fu = gSystem->ExpandPathName(user.Data());
42    fp = gSystem->ExpandPathName(psw.Data());    fp = gSystem->ExpandPathName(psw.Data());
43      printf(" Connecting to DB %s \n",fh.Data());
44    dbc = TSQLServer::Connect(fh.Data(),fu.Data(),fp.Data());    dbc = TSQLServer::Connect(fh.Data(),fu.Data(),fp.Data());
45      if ( dbc && dbc->IsConnected() ){
46        printf(" connected! \n");
47      } else {
48        printf(" ERROR! not connected... :( \n");
49      };
50  };  };
51    
52  TObject *Q2TH::Draw(TString query, Bool_t verbose, TString hname){  TObject *Q2TH::Draw(TString query, Bool_t verbose, TString hname){
53    //    //
54      if ( !strcmp(query.Data(),"help") ){
55        printf(" USAGE: \n");
56        printf(" 1) start root and create Q2TH object with  \n");
57        printf("    Q2TH *qt = new Q2TH()  \n");
58        printf("    or \n");
59        printf("    Q2TH *qt = new Q2TH(\"mysql://srvg-g2-01.ts.infn.it/pamelaProcessing9_TS\",\"pamelaprod_ro\",\"mypassword\")  \n");
60        printf(" 2) query the DB with  \n");
61        printf("    qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\");  \n");
62        printf("    qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\",true); this will print numbers on screen \n");
63        printf("    qt->Draw(\"select REAL_TIME_INIT from ROOT_TABLE_MERGING;\",true,\"myhisto\"); this will print numbers on screen and create histo \"myhisto\"\n");
64        printf(" 3) to use your own THxD create it and then query the DB giving as argument the name of histo:   \n");
65        printf("    TH2D *myhisto=new TH2D(\"myhisto\",\"myhisto\",5000,1140000000.,1240000000.,10000,0.,1.) \n");
66        printf("    qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\",false,\"myhisto\")\n\n\n");
67    
68        return NULL;
69      };
70      //
71    pResult = dbc->Query(query.Data());    pResult = dbc->Query(query.Data());
72    //    //
73    Row = pResult->Next();          Row = pResult->Next();      
# Line 74  TObject *Q2TH::Draw(TString query, Bool_ Line 101  TObject *Q2TH::Draw(TString query, Bool_
101    };    };
102    pResult->Delete();    pResult->Delete();
103    //    //
104            
105      //
106    Int_t f1bin = 70;    Int_t f1bin = 70;
107    Int_t f2bin = 70;    Int_t f2bin = 70;
108    if ( dim == 1 ){    if ( dim == 1 ){
109      f1bin = int((maxf1-minf1)/1000.);      f1bin = int((maxf1-minf1)/1000.);
110      if ( f1bin < 70 ) f1bin = 70;      if ( f1bin < 70 ) f1bin = 70;
111      if ( f1bin > 1000 ) f1bin = 1000;      if ( f1bin > 1000 ) f1bin = 1000;
112      h1 = new TH1D(Form("%s1",hname.Data()),Form("%s1",hname.Data()),f1bin,minf1*0.98,maxf1*1.02);          if ( !strcmp(hname.Data(),"q2th") ) hname += "1";
113            //      h1 =  dynamic_cast<TH1D*>(gDirectory->FindObject(hname.Data()));
114            h1 = (TH1D*)(gDirectory->FindObject(hname.Data()));
115            if ( !strcmp(hname.Data(),"q2th1") ){
116             if ( h1 ) h1->Delete();
117            };
118            if ( !h1 ) h1 = new TH1D(hname.Data(),hname.Data(),f1bin,minf1*0.98,maxf1*1.02);
119      //    h1->SetBit(TH1::kCanRebin);      //    h1->SetBit(TH1::kCanRebin);
120      if ( verbose ) printf("\n\n Row     %s \n",pResult->GetFieldName(0));      if ( verbose ) printf("\n\n Row     %s \n",pResult->GetFieldName(0));
121    };    };
# Line 88  TObject *Q2TH::Draw(TString query, Bool_ Line 123  TObject *Q2TH::Draw(TString query, Bool_
123      f2bin = int((maxf2-minf2)/1000.);      f2bin = int((maxf2-minf2)/1000.);
124      if ( f2bin < 70 ) f2bin = 70;      if ( f2bin < 70 ) f2bin = 70;
125      if ( f2bin > 1000 ) f2bin = 1000;      if ( f2bin > 1000 ) f2bin = 1000;
126      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);          if ( !strcmp(hname.Data(),"q2th") ) hname += "2";
127            //      h2 =  dynamic_cast<TH2D*>(gDirectory->FindObject(hname.Data()));
128            h2 =  (TH2D*)(gDirectory->FindObject(hname.Data()));
129            if ( !strcmp(hname.Data(),"q2th2") ){
130             if ( h2 ) h2->Delete();
131            };
132            if ( !h2 ) h2 = new TH2D(hname.Data(),hname.Data(),f1bin,minf1*0.98,maxf1*1.02,f2bin,minf2*0.98,maxf2*1.02);
133      //    h2->SetBit(TH2::kCanRebin);      //    h2->SetBit(TH2::kCanRebin);
134      if ( verbose ) printf("\n\n Row     %s     %s \n",pResult->GetFieldName(0),pResult->GetFieldName(1));      if ( verbose ) printf("\n\n Row     %s     %s \n",pResult->GetFieldName(0),pResult->GetFieldName(1));
135    };    };
# Line 102  TObject *Q2TH::Draw(TString query, Bool_ Line 143  TObject *Q2TH::Draw(TString query, Bool_
143    while ( Row ){        while ( Row ){    
144      f1 = (Double_t)atof(Row->GetField(0));      f1 = (Double_t)atof(Row->GetField(0));
145      if ( dim == 1 ){      if ( dim == 1 ){
146        if ( verbose ) printf(" %f \n",r,f1);        if ( verbose ) printf(" %i     %f \n",r,f1);
147        h1->Fill(f1);        h1->Fill(f1);
148      } else {      } else {
149        f2 = (Double_t)atof(Row->GetField(1));        f2 = (Double_t)atof(Row->GetField(1));
150        if ( verbose ) printf(" %f     %f \n",r,f1,f2);        if ( verbose ) printf(" %i     %f     %f \n",r,f1,f2);
151        h2->Fill(f1,f2);        h2->Fill(f1,f2);
152      };      };
153      r++;      r++;
154      Row = pResult->Next();      Row = pResult->Next();
155    };    };
156    //    //
157    TCanvas *c = new TCanvas(Form("%sc",hname.Data()));    TCanvas *c = NULL;
158      TString cname = Form("%sc",hname.Data());
159      //  c =  dynamic_cast<TCanvas*>(gDirectory->FindObject(hname.Data()));
160      c =  (TCanvas*)(gDirectory->FindObject(cname.Data()));
161      if ( !c ) c = new TCanvas(Form("%sc",cname.Data()));
162      c->Clear();
163    c->cd();    c->cd();
164    if ( dim == 1 ) h1->Draw();    if ( dim == 1 ) h1->Draw();
165    if ( dim == 2 ) h2->Draw();    if ( dim == 2 ) h2->Draw();

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

  ViewVC Help
Powered by ViewVC 1.1.23