/[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.12 by mocchiut, Tue Dec 15 09:58:25 2009 UTC
# Line 41  Q2TH::Q2TH(TString host, TString user, T Line 41  Q2TH::Q2TH(TString host, TString user, T
41    
42  TObject *Q2TH::Draw(TString query, Bool_t verbose, TString hname){  TObject *Q2TH::Draw(TString query, Bool_t verbose, TString hname){
43    //    //
44      if ( !strcmp(query.Data(),"help") ){
45        printf(" USAGE: \n");
46        printf(" 1) start root and create Q2TH object with  \n");
47        printf("    Q2TH *qt = new Q2TH()  \n");
48        printf("    or \n");
49        printf("    Q2TH *qt = new Q2TH(\"mysql://srvg-g2-01.ts.infn.it/pamelaProcessing9_TS\",\"pamelaprod_ro\",\"mypassword\")  \n");
50        printf(" 2) query the DB with  \n");
51        printf("    qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\");  \n");
52        printf("    qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\",true); this will print numbers on screen \n");
53        printf("    qt->Draw(\"select REAL_TIME_INIT from ROOT_TABLE_MERGING;\",true,\"myhisto\"); this will print numbers on screen and create histo \"myhisto\"\n");
54        printf(" 3) to use your own THxD create it and then query the DB giving as argument the name of histo:   \n");
55        printf("    TH2D *myhisto=new TH2D(\"myhisto\",\"myhisto\",5000,1140000000.,1240000000.,10000,0.,1.) \n");
56        printf("    qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\",false,\"myhisto\")\n\n\n");
57    
58        return NULL;
59      };
60      //
61    pResult = dbc->Query(query.Data());    pResult = dbc->Query(query.Data());
62    //    //
63    Row = pResult->Next();          Row = pResult->Next();      
# Line 74  TObject *Q2TH::Draw(TString query, Bool_ Line 91  TObject *Q2TH::Draw(TString query, Bool_
91    };    };
92    pResult->Delete();    pResult->Delete();
93    //    //
94            
95      //
96    Int_t f1bin = 70;    Int_t f1bin = 70;
97    Int_t f2bin = 70;    Int_t f2bin = 70;
98    if ( dim == 1 ){    if ( dim == 1 ){
99      f1bin = int((maxf1-minf1)/1000.);      f1bin = int((maxf1-minf1)/1000.);
100      if ( f1bin < 70 ) f1bin = 70;      if ( f1bin < 70 ) f1bin = 70;
101      if ( f1bin > 1000 ) f1bin = 1000;      if ( f1bin > 1000 ) f1bin = 1000;
102      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";
103            //      h1 =  dynamic_cast<TH1D*>(gDirectory->FindObject(hname.Data()));
104            h1 = (TH1D*)(gDirectory->FindObject(hname.Data()));
105            if ( !strcmp(hname.Data(),"q2th1") ){
106             if ( h1 ) h1->Delete();
107            };
108            if ( !h1 ) h1 = new TH1D(hname.Data(),hname.Data(),f1bin,minf1*0.98,maxf1*1.02);
109      //    h1->SetBit(TH1::kCanRebin);      //    h1->SetBit(TH1::kCanRebin);
110      if ( verbose ) printf("\n\n Row     %s \n",pResult->GetFieldName(0));      if ( verbose ) printf("\n\n Row     %s \n",pResult->GetFieldName(0));
111    };    };
# Line 88  TObject *Q2TH::Draw(TString query, Bool_ Line 113  TObject *Q2TH::Draw(TString query, Bool_
113      f2bin = int((maxf2-minf2)/1000.);      f2bin = int((maxf2-minf2)/1000.);
114      if ( f2bin < 70 ) f2bin = 70;      if ( f2bin < 70 ) f2bin = 70;
115      if ( f2bin > 1000 ) f2bin = 1000;      if ( f2bin > 1000 ) f2bin = 1000;
116      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";
117            //      h2 =  dynamic_cast<TH2D*>(gDirectory->FindObject(hname.Data()));
118            h2 =  (TH2D*)(gDirectory->FindObject(hname.Data()));
119            if ( !strcmp(hname.Data(),"q2th2") ){
120             if ( h2 ) h2->Delete();
121            };
122            if ( !h2 ) h2 = new TH2D(hname.Data(),hname.Data(),f1bin,minf1*0.98,maxf1*1.02,f2bin,minf2*0.98,maxf2*1.02);
123      //    h2->SetBit(TH2::kCanRebin);      //    h2->SetBit(TH2::kCanRebin);
124      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));
125    };    };
# Line 102  TObject *Q2TH::Draw(TString query, Bool_ Line 133  TObject *Q2TH::Draw(TString query, Bool_
133    while ( Row ){        while ( Row ){    
134      f1 = (Double_t)atof(Row->GetField(0));      f1 = (Double_t)atof(Row->GetField(0));
135      if ( dim == 1 ){      if ( dim == 1 ){
136        if ( verbose ) printf(" %f \n",r,f1);        if ( verbose ) printf(" %i     %f \n",r,f1);
137        h1->Fill(f1);        h1->Fill(f1);
138      } else {      } else {
139        f2 = (Double_t)atof(Row->GetField(1));        f2 = (Double_t)atof(Row->GetField(1));
140        if ( verbose ) printf(" %f     %f \n",r,f1,f2);        if ( verbose ) printf(" %i     %f     %f \n",r,f1,f2);
141        h2->Fill(f1,f2);        h2->Fill(f1,f2);
142      };      };
143      r++;      r++;
144      Row = pResult->Next();      Row = pResult->Next();
145    };    };
146    //    //
147    TCanvas *c = new TCanvas(Form("%sc",hname.Data()));    TCanvas *c = NULL;
148      TString cname = Form("%sc",hname.Data());
149      //  c =  dynamic_cast<TCanvas*>(gDirectory->FindObject(hname.Data()));
150      c =  (TCanvas*)(gDirectory->FindObject(cname.Data()));
151      if ( !c ) c = new TCanvas(Form("%sc",cname.Data()));
152      c->Clear();
153    c->cd();    c->cd();
154    if ( dim == 1 ) h1->Draw();    if ( dim == 1 ) h1->Draw();
155    if ( dim == 2 ) h2->Draw();    if ( dim == 2 ) h2->Draw();

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

  ViewVC Help
Powered by ViewVC 1.1.23