--- chewbacca/YodaProfiler/src/GLTables.cpp 2009/12/14 16:53:43 1.11 +++ chewbacca/YodaProfiler/src/GLTables.cpp 2009/12/15 09:58:25 1.12 @@ -41,6 +41,23 @@ TObject *Q2TH::Draw(TString query, Bool_t verbose, TString hname){ // + if ( !strcmp(query.Data(),"help") ){ + printf(" USAGE: \n"); + printf(" 1) start root and create Q2TH object with \n"); + printf(" Q2TH *qt = new Q2TH() \n"); + printf(" or \n"); + printf(" Q2TH *qt = new Q2TH(\"mysql://srvg-g2-01.ts.infn.it/pamelaProcessing9_TS\",\"pamelaprod_ro\",\"mypassword\") \n"); + printf(" 2) query the DB with \n"); + printf(" qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\"); \n"); + printf(" qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\",true); this will print numbers on screen \n"); + printf(" qt->Draw(\"select REAL_TIME_INIT from ROOT_TABLE_MERGING;\",true,\"myhisto\"); this will print numbers on screen and create histo \"myhisto\"\n"); + printf(" 3) to use your own THxD create it and then query the DB giving as argument the name of histo: \n"); + printf(" TH2D *myhisto=new TH2D(\"myhisto\",\"myhisto\",5000,1140000000.,1240000000.,10000,0.,1.) \n"); + printf(" qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\",false,\"myhisto\")\n\n\n"); + + return NULL; + }; + // pResult = dbc->Query(query.Data()); // Row = pResult->Next(); @@ -74,13 +91,21 @@ }; pResult->Delete(); // + + // Int_t f1bin = 70; Int_t f2bin = 70; if ( dim == 1 ){ f1bin = int((maxf1-minf1)/1000.); if ( f1bin < 70 ) f1bin = 70; if ( f1bin > 1000 ) f1bin = 1000; - 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"; + // h1 = dynamic_cast(gDirectory->FindObject(hname.Data())); + h1 = (TH1D*)(gDirectory->FindObject(hname.Data())); + if ( !strcmp(hname.Data(),"q2th1") ){ + if ( h1 ) h1->Delete(); + }; + if ( !h1 ) h1 = new TH1D(hname.Data(),hname.Data(),f1bin,minf1*0.98,maxf1*1.02); // h1->SetBit(TH1::kCanRebin); if ( verbose ) printf("\n\n Row %s \n",pResult->GetFieldName(0)); }; @@ -88,7 +113,13 @@ f2bin = int((maxf2-minf2)/1000.); if ( f2bin < 70 ) f2bin = 70; if ( f2bin > 1000 ) f2bin = 1000; - 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"; + // h2 = dynamic_cast(gDirectory->FindObject(hname.Data())); + h2 = (TH2D*)(gDirectory->FindObject(hname.Data())); + if ( !strcmp(hname.Data(),"q2th2") ){ + if ( h2 ) h2->Delete(); + }; + if ( !h2 ) h2 = new TH2D(hname.Data(),hname.Data(),f1bin,minf1*0.98,maxf1*1.02,f2bin,minf2*0.98,maxf2*1.02); // h2->SetBit(TH2::kCanRebin); if ( verbose ) printf("\n\n Row %s %s \n",pResult->GetFieldName(0),pResult->GetFieldName(1)); }; @@ -102,18 +133,23 @@ while ( Row ){ f1 = (Double_t)atof(Row->GetField(0)); if ( dim == 1 ){ - if ( verbose ) printf(" %f \n",r,f1); + if ( verbose ) printf(" %i %f \n",r,f1); h1->Fill(f1); } else { f2 = (Double_t)atof(Row->GetField(1)); - if ( verbose ) printf(" %f %f \n",r,f1,f2); + if ( verbose ) printf(" %i %f %f \n",r,f1,f2); h2->Fill(f1,f2); }; r++; Row = pResult->Next(); }; // - TCanvas *c = new TCanvas(Form("%sc",hname.Data())); + TCanvas *c = NULL; + TString cname = Form("%sc",hname.Data()); + // c = dynamic_cast(gDirectory->FindObject(hname.Data())); + c = (TCanvas*)(gDirectory->FindObject(cname.Data())); + if ( !c ) c = new TCanvas(Form("%sc",cname.Data())); + c->Clear(); c->cd(); if ( dim == 1 ) h1->Draw(); if ( dim == 2 ) h2->Draw();