Beispiel #1
0
void img2pad()
{
   // Display image in canvas and pad.
   //Author: valeriy Onuchin
   
   TImage *img = TImage::Open("rose512.jpg");
   if (!img) {
      printf("Could not create an image... exit\n");
      return;
   }
   img->SetConstRatio(kFALSE);
   img->Draw("N");

   TCanvas *c = gROOT->GetListOfCanvases()->FindObject("rose512jpg");
   c->SetFixedAspectRatio();

   TCanvas *c = new TCanvas("roses", "roses", 800, 800);
   img->Draw("T100,100,yellow");
   //img->Draw("T100,100,#556655");
   //img->Draw("T100,100");

   TImage *i1 = TImage::Open("rose512.jpg");
   i1->SetConstRatio(kFALSE);
   i1->Flip(90);
   TImage *i2 = TImage::Open("rose512.jpg");
   i2->SetConstRatio(kFALSE);
   i2->Flip(180);
   TImage *i3 = TImage::Open("rose512.jpg");
   i3->SetConstRatio(kFALSE);
   i3->Flip(270);
   TImage *i4 = TImage::Open("rose512.jpg");
   i4->SetConstRatio(kFALSE);
   i4->Mirror(kTRUE);

   float d = 0.40;
   TPad *p1 = new TPad("i1", "i1", 0.05, 0.55, 0.05+d*i1->GetWidth()/i1->GetHeight(), 0.95);
   TPad *p2 = new TPad("i2", "i2", 0.55, 0.55, 0.95, 0.55+d*i2->GetHeight()/i2->GetWidth());
   TPad *p3 = new TPad("i3", "i3", 0.55, 0.05, 0.55+d*i3->GetWidth()/i3->GetHeight(), 0.45);
   TPad *p4 = new TPad("i4", "i4", 0.05, 0.05, 0.45, 0.05+d*i4->GetHeight()/i4->GetWidth());

   p1->Draw();
   p1->cd();
   i1->Draw();
   c->cd();

   p2->Draw();
   p2->cd();
   i2->Draw();
   c->cd();

   p3->Draw();
   p3->cd();
   i3->Draw();
   c->cd();

   p4->Draw();
   p4->cd();
   i4->Draw();
   c->cd();
}
Beispiel #2
0
void img2pad()
{
   TImage *img = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
   if (!img) {
      printf("Could not create an image... exit\n");
      return;
   }
   img->SetConstRatio(kFALSE);
   img->Draw("N");

   TCanvas *c = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("rose512jpg");
   c->SetFixedAspectRatio();

   TCanvas *c1 = new TCanvas("roses", "roses", 800, 800);
   img->Draw("T100,100,#ffff00");
   /*img->Draw("T100,100,#556655");*/
   /*img->Draw("T100,100");*/

   TImage *i1 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
   i1->SetConstRatio(kFALSE);
   i1->Flip(90);
   TImage *i2 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
   i2->SetConstRatio(kFALSE);
   i2->Flip(180);
   TImage *i3 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
   i3->SetConstRatio(kFALSE);
   i3->Flip(270);
   TImage *i4 = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");
   i4->SetConstRatio(kFALSE);
   i4->Mirror(kTRUE);

   float d = 0.40;
   TPad *p1 = new TPad("i1", "i1", 0.05, 0.55, 0.05+d*i1->GetWidth()/i1->GetHeight(), 0.95);
   TPad *p2 = new TPad("i2", "i2", 0.55, 0.55, 0.95, 0.55+d*i2->GetHeight()/i2->GetWidth());
   TPad *p3 = new TPad("i3", "i3", 0.55, 0.05, 0.55+d*i3->GetWidth()/i3->GetHeight(), 0.45);
   TPad *p4 = new TPad("i4", "i4", 0.05, 0.05, 0.45, 0.05+d*i4->GetHeight()/i4->GetWidth());

   p1->Draw();
   p1->cd();
   i1->Draw();
   c1->cd();

   p2->Draw();
   p2->cd();
   i2->Draw();
   c1->cd();

   p3->Draw();
   p3->cd();
   i3->Draw();
   c1->cd();

   p4->Draw();
   p4->cd();
   i4->Draw();
   c1->cd();
}
Beispiel #3
0
void psview()
{
   // set to batch mode -> do not display graphics
   gROOT->SetBatch(1);

   // create a PostScript file
   TString dir = gROOT->GetTutorialDir();
   dir.Append("/graphics/feynman.C");
   gROOT->Macro(dir);
   gPad->Print("feynman.eps");

   // back to graphics mode
   gROOT->SetBatch(0);

   // create an image from PS file
   TImage *ps = TImage::Open("feynman.eps");

   if (!ps) {
      printf("GhostScript (gs) program must be installed\n");
      return;
   }

   new TCanvas("psexam", "Example how to display PS file in canvas", 600, 400);
   TLatex *tex = new TLatex(0.06,0.9,"The picture below has been loaded from a PS file:");
   tex->Draw();

   TPad *eps = new TPad("eps", "eps", 0., 0., 1., 0.75);
   eps->Draw();
   eps->cd();
   ps->Draw("xxx");
}
Beispiel #4
0
// Open a FITS file and retrieve the first plane of the image array 
// as a TImage object
void FITS_tutorial3()
{
   printf("\n\n--------------------------------\n");
   printf("WELCOME TO FITS tutorial #3 !!!!\n");
   printf("--------------------------------\n");
   printf("We're gonna open a FITS file that contains several image\n");
   printf("extensions. The primary HDU contains no data.\n");
   printf("Data copyright: NASA\n\n");
   
   if (!gROOT->IsBatch()) {
      //printf("Press ENTER to start..."); getchar();
   }
   
   // Open extensions 1 to 5 from file
   //printf("Press ENTER to see a canvas with all images within the file:"); getchar();
   
   TCanvas *c = new TCanvas("c1", "FITS tutorial #1", 800, 700);
   c->Divide(2,3);
   for (int i=1; i <= 5; i++) {
      TFITSHDU *hdu = new TFITSHDU("sample3.fits", i);
      if (hdu == 0) {
         printf("ERROR: could not access the HDU\n"); return;
      }
      
      TImage *im = hdu->ReadAsImage(0);
      c->cd(i);
      im->Draw();
      delete hdu;
   }
}
Beispiel #5
0
   void plot_logo( Float_t v_scale = 1.0, Float_t skew = 1.0 )
   {

      TImage *img = findImage("tmva_logo.gif");
      if (!img) {
         cout << "+++ Could not open image tmva_logo.gif" << endl;
         return;
      }
      
      img->SetConstRatio(kFALSE);
      UInt_t h_ = img->GetHeight();
      UInt_t w_ = img->GetWidth();

      Float_t r = w_/h_;
      gPad->Update();
      Float_t rpad = Double_t(gPad->VtoAbsPixel(0) - gPad->VtoAbsPixel(1))/(gPad->UtoAbsPixel(1) - gPad->UtoAbsPixel(0));
      r *= rpad;

      Float_t d = 0.055;
      // absolute coordinates
      Float_t x1R = 1 - gStyle->GetPadRightMargin(); 
      Float_t y1B = 1 - gStyle->GetPadTopMargin()+.01; // we like the logo to sit a bit above the histo 

      Float_t x1L = x1R - d*r/skew;
      Float_t y1T = y1B + d*v_scale*skew;
      if (y1T>0.99) y1T = 0.99;

      TPad *p1 = new TPad("imgpad", "imgpad", x1L, y1B, x1R, y1T );
      p1->SetRightMargin(0);
      p1->SetBottomMargin(0);
      p1->SetLeftMargin(0);
      p1->SetTopMargin(0);
      p1->Draw();

      Int_t xSizeInPixel = p1->UtoAbsPixel(1) - p1->UtoAbsPixel(0);
      Int_t ySizeInPixel = p1->VtoAbsPixel(0) - p1->VtoAbsPixel(1);
      if (xSizeInPixel<=25 || ySizeInPixel<=25) {
         delete p1;
         return; // ROOT doesn't draw smaller than this
      }

      p1->cd();
      img->Draw();
   } 
Beispiel #6
0
void hist2image()
{

   TCanvas *canv = new TCanvas("image", "xygaus + xygaus(5) + xylandau(10)");
   canv->ToggleEventStatus();
   canv->SetRightMargin(0.2);
   canv->SetLeftMargin(0.01);
   canv->SetTopMargin(0.01);
   canv->SetBottomMargin(0.01);

   // histogram as image (hist taken from draw2dopt.C)
   TImage *img = TImage::Create();

   TF2 *f2 = new TF2("f2","(xygaus + xygaus(5) + xylandau(10))",-4,4,-4,4);
   Double_t params[] = {130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5, 3600,-2,0.7,-3,0.3};
   f2->SetParameters(params);
   TH2D *h2 = new TH2D("h2","xygaus + xygaus(5) + xylandau(10)",100,-4,4,100,-4,4);
   h2->FillRandom("f2",40000);
   img->SetImage((const Double_t *)h2->GetArray(), h2->GetNbinsX() + 2,
                  h2->GetNbinsY() + 2, gHistImagePalette);
   img->Draw();
   img->StartPaletteEditor();
}
void draw_activation(TCanvas* c, Double_t cx, Double_t cy, 
                     Double_t radx, Double_t rady, Int_t whichActivation)
{
   TImage *activation = NULL;

   switch (whichActivation) {
   case 0:
      activation = TImage::Open("sigmoid-small.png");
      break;
   case 1:
      activation = TImage::Open("line-small.png");
      break;
   default:
      cout << "Activation index " << whichActivation << " is not known." << endl;
      cout << "You messed up or you need to modify network.C to introduce a new "
           << "activation function (and image) corresponding to this index" << endl;
   }

   if (activation == NULL) {
      cout << "Could not create an image... exit" << endl;
      return;
   }
  
   activation->SetConstRatio(kFALSE);

   radx *= 0.7;
   rady *= 0.7;
   TString name = Form("activation%f%f", cx, cy);
   TPad* p = new TPad(name+"", name+"", cx-radx, cy-rady, cx+radx, cy+rady);

   p->Draw();
   p->cd();

   activation->Draw();
   c->cd();
}
void plotAnitaEventMap(Adu5Pat *patPtr,double phi,double theta){

  double sourceLon,sourceLat,headLon,headLat,phi10Lon,phi10Lat,phi6Lon,phi6Lat,phi14Lon,phi14Lat,actualLat,actualLon,actual2Lat,actual2Lon;
  float xEvent,yEvent,xAnita,yAnita,anitaLat,anitaLon,anitaAlt,xHead,yHead,x10,y10,x6,y6,x14,y14,yActual,xActual,yActual2,xActual2;

  anitaLat = patPtr->latitude;
  anitaLon = patPtr->longitude;
  anitaAlt = patPtr->altitude;

  UsefulAdu5Pat usefulPat(patPtr);
  std::cout << "source " << std::endl;
  //int sourceLoc = usefulPat.getSourceLonAndLatAltZero((180-phi)/180.*PI,(theta)/180.*PI,sourceLon,sourceLat);
  int sourceLoc = usefulPat.getSourceLonAndLatAltZero((phi)/180.*PI,(theta)/180.*PI,sourceLon,sourceLat);
  std::cout << std::endl << "heading " << std::endl;
  int headLoc = usefulPat.getSourceLonAndLatAltZero(0./180.*PI,10./180.*PI,headLon,headLat);
  std::cout << std::endl << "phi 10 " << std::endl;
  int headLoc10 = usefulPat.getSourceLonAndLatAltZero(180./180.*PI,10./180.*PI,phi10Lon,phi10Lat);
  std::cout << std::endl << "phi 14 " << std::endl;
  int headLoc14 = usefulPat.getSourceLonAndLatAltZero(270./180.*PI,10./180.*PI,phi14Lon,phi14Lat);
  std::cout << std::endl << "phi 6 " << std::endl;
  int headLoc6 = usefulPat.getSourceLonAndLatAltZero(90./180.*PI,10./180.*PI,phi6Lon,phi6Lat);
  std::cout << std::endl << "actual 14.5 " << std::endl;
  int actualLoc = usefulPat.getSourceLonAndLatAltZero(phi/180.*PI,12.5/180.*PI,actualLon,actualLat);
  std::cout << std::endl << "actual 4.5 " << std::endl;
  int actualLoc2 = usefulPat.getSourceLonAndLatAltZero(phi/180.*PI,7.5/180.*PI,actual2Lon,actual2Lat);
  //int sourceLoc = usefulPat.getSourceLonAndLatAltZero((phi)/180.*PI,(TMath::PiOver2()-theta)/180.*PI,sourceLon,sourceLat);
  TImage *map = TImage::Open("/home/mottram/work/eventCorrelator/macros/antarcticaIceMap.png");

  std::cout << "sourceLoc " << sourceLoc << " phi " << phi << " theta " << theta << " lon " << sourceLon << " lat " << sourceLat << std::endl;
  gStyle->SetMarkerColor(kBlack);
  //gStyle->SetMarkerSize(2);
  gStyle->SetTextSize(0.02);
  TMarker *anitaPos = new TMarker(xAnita,yAnita,23);

  getRelXYFromLatLong(anitaLat,anitaLon,xAnita,yAnita);
  getRelXYFromLatLong(static_cast<float>(sourceLat),static_cast<float>(sourceLon),xEvent,yEvent);
  getRelXYFromLatLong(static_cast<float>(headLat),static_cast<float>(headLon),xHead,yHead);
  getRelXYFromLatLong(static_cast<float>(phi10Lat),static_cast<float>(phi10Lon),x10,y10);
  getRelXYFromLatLong(static_cast<float>(phi14Lat),static_cast<float>(phi14Lon),x14,y14);
  getRelXYFromLatLong(static_cast<float>(phi6Lat),static_cast<float>(phi6Lon),x6,y6);
  getRelXYFromLatLong(static_cast<float>(actualLat),static_cast<float>(actualLon),xActual,yActual);
  getRelXYFromLatLong(static_cast<float>(actual2Lat),static_cast<float>(actual2Lon),xActual2,yActual2);

  TCanvas *canMap=(TCanvas*)gROOT->FindObject("canMap");
  if(!canMap)
     canMap = new TCanvas("canMap","canMap",(int)xSize,(int)ySize);
  canMap->Clear();
  canMap->SetLogz();
  canMap->SetTopMargin(0);
  canMap->SetBottomMargin(0);
  canMap->SetLeftMargin(0);
  canMap->SetRightMargin(0);

  map->Draw("");

  TMarker *headingPos = new TMarker(xHead,yHead,29);
  TMarker *heading14Pos = new TMarker(x14,y14,29);
  TMarker *heading10Pos = new TMarker(x10,y10,29);
  TMarker *heading6Pos = new TMarker(x6,y6,29);
  TMarker *actualPos = new TMarker(xActual,yActual,29);
  TMarker *actual2Pos = new TMarker(xActual2,yActual2,29);
  headingPos->SetMarkerColor(kRed);
  heading14Pos->SetMarkerColor(kGray);
  heading10Pos->SetMarkerColor(kGray+2);
  heading6Pos->SetMarkerColor(kViolet);
  actualPos->SetMarkerColor(kRed+2);//12.5 theta
  actual2Pos->SetMarkerColor(kBlue+2);//7.5 theta

  headingPos->Draw("");
  heading14Pos->Draw("");
  heading10Pos->Draw("");
  heading6Pos->Draw("");
  actualPos->Draw("");
  actual2Pos->Draw("");
  anitaPos->DrawMarker(xAnita,yAnita);
  

  TLatex *positionLabel=0;
  char label[FILENAME_MAX];

  if(sourceLoc==0){
    if(anitaAlt<0){
      sprintf(label,"Could not get event position, ANITA below 0 altitude!");
    }
    else if(theta>0){
      sprintf(label,"Pointing upwards!  Cannot locate source at ground position");
    }
    else{
      sprintf(label,"Unkown error, cannot position source at 0 altitude");
    }
    positionLabel = new TLatex();
    positionLabel->DrawLatex(0.05,0.95,label);
    return;
  }

  TMarker *eventPos = new TMarker(xEvent,yEvent,29);
  eventPos->SetMarkerColor(kBlack);
  eventPos->Draw("");

  sprintf(label,"ANITA location: lat %f; long %f; alt %f, x %f, y %f",anitaLat,anitaLon,anitaAlt,xAnita,yAnita);
  positionLabel = new TLatex();
  positionLabel->DrawLatex(0.05,0.97,label);
  sprintf(label,"Event location: lat %f; long %f, x %f, y %f",sourceLat,sourceLon,xEvent,yEvent);
  positionLabel->DrawLatex(0.05,0.94,label);

}
Beispiel #9
0
void rose_image()
{
   // Display image in a new canvas and pad.

   TImage *img = TImage::Open("rose512.jpg");

   if (!img) {
      printf("Could not create an image... exit\n");
      return;
   }

   img->SetConstRatio(0);
   img->SetImageQuality(TAttImage::kImgBest);

   TString fp = gEnv->GetValue("Root.TTFontPath", "");
   TString bc = fp + "/BlackChancery.ttf";
   TString ar = fp + "/arial.ttf";

   // draw text over image with funny font
   img->DrawText(120, 160, "Hello World!", 32, 
                 gROOT->GetColor(4)->AsHexString(), 
                 bc, TImage::kShadeBelow);

   // draw text over image with foreground specified by pixmap
   img->DrawText(250, 350, "goodbye cruel world ...", 24, 0, 
                 ar, TImage::kPlain, "fore.xpm");

   TImage *img2 = TImage::Open("mditestbg.xpm");

   // tile image
   img2->Tile(img->GetWidth(), img->GetHeight());

   c1 = new TCanvas("rose512", "examples of image manipulations", 760, 900);
   c1->Divide(2, 3);
   c1->cd(1);
   img->Draw("xxx");
   img->SetEditable(kTRUE);

   c1->cd(2);
   // averaging with mditestbg.xpm image
   TImage *img3 = (TImage*)img->Clone("img3");
   img3->Merge(img2, "allanon");
   img3->Draw();

   // contrasting (tint with itself)
   c1->cd(3);
   TImage *img4 = (TImage*)img->Clone("img4");
   img4->Merge(img4, "tint");

   // draw filled rectangle with magenta color
   img4->FillRectangle("#FF00FF", 20, 220, 40, 40);

   // Render multipoint alpha-blended gradient (R->G->B)
   img4->Gradient(0, "#FF0000 #00FF00 #220000FF", 0, 50, 50, 100, 100);

   // draw semi-transparent 3D button
   img4->Bevel(300, 20, 160, 40, "#ffffffff", "#fe000000", 3, 0);
   img4->DrawLine(10, 100, 100, 10, "#0000ff", 4);
   img4->Draw();

   // vectorize image. Reduce palette to 256 colors
   c1->cd(4);
   TImage *img5 = (TImage*)img->Clone("img5");
   img5->Vectorize(256);
   img5->Draw();

   // quantization of the image
   c1->cd(5);
   TImage *img6 = (TImage*)img->Clone("img6");
   TImagePalette *pal = (TImagePalette *)&img5->GetPalette();
   TArrayD *arr = img6->GetArray(50, 40, pal);
   img6->SetImage(arr->GetArray(), 50, 40, pal);
   img6->Draw();

   // HSV adjustment (convert red to yellow)
   c1->cd(6);
   TImage *img7 = (TImage*)img->Clone("img7");
   img7->HSV(0, 40, 40);
   img7->Draw();
}
void eventviewer::viewEvent_1() //Event viewer
{
    //open beta
    gStyle->SetOptStat(0);
    aida_beta.GetTreeBETA(sinfile);
    if (aida_beta.fChain==0) return;
    //output
    TFile* rootfile=new TFile(soutfile,"RECREATE");
    //histograms
    TCanvas* c1=new TCanvas("ss","ss",600,600);
    TCanvas *c2rot = new TCanvas("c2rot","c2rot",300,300);
    c1->Divide(2,2);
    TH1F* hisx=new TH1F("hisX","hisX",128,0,128);
    TH1F* hisy=new TH1F("hisY","hisY",128,0,128);

    TH2F* hisxy=new TH2F("hisXY","hisXY",128,0,128,128,0,128);

    TH1I* hisTX=new TH1I("hisTX","hisTX",200,-1500,1500);
    TH1I* hisTY=new TH1I("hisTY","hisTY",200,-1500,1500);

    //Start reading input file!
    Long64_t nentries = aida_beta.GetEntries();
    cout<<"Total entries="<<nentries<<endl;
    Long64_t nbytes = 0, nb = 0;
    Long64_t entriestobreak=nentries+10;
    for (Long64_t jentry=0; jentry<nentries;jentry++) {
        Long64_t ientry=aida_beta.LoadTree(jentry);
        if (ientry<0) break;
        nb=aida_beta.GetEntry(jentry);nbytes+=nb;
        Double_t percent_complete=(Double_t)jentry/(Double_t)nentries*100;
        if (jentry%3000==0) cout<<percent_complete<<" % data piece proceeded"<<endl;
        //if (rawaida.Cut(ientry) < 0) continue;
        if (jentry>entriestobreak) break;

        hisx->Reset();
        hisy->Reset();
        hisxy->Reset();
        hisTX->Reset();
        hisTY->Reset();

        hisx->SetTitle(Form("hisX%d",(Int_t)jentry));
        hisy->SetTitle(Form("hisY%d",(Int_t)jentry));
        hisxy->SetTitle(Form("hisXY%d",(Int_t)jentry));

        Double_t totalExy=0;
        //if (aida_beta.dssd_Z_mult[0]>0){
        //if (aida_beta.pos_index_beta[0]==0&&aida_beta.npos_beta[0]>0){
            for (Int_t i=0;i<128;i++){
                Double_t ex=(Double_t)aida_beta.dssdH_E_X[0][i][0];
                Double_t ey=(Double_t)aida_beta.dssdH_E_Y[0][i][0];
                if (ex<0) ex=0.;
                if (ey<0) ey=0.;
                hisx->Fill(i,ex);
                hisy->Fill(i,ey);
                if (ex>0) hisTX->Fill(aida_beta.dssdH_T_X[0][i][0]-aida_beta.timestamp,ex);
                if (ey>0) hisTY->Fill(aida_beta.dssdH_T_Y[0][i][0]-aida_beta.timestamp,ey);
                for (Int_t j=0;j<128;j++){
                  Double_t eyy=(Double_t)aida_beta.dssdH_E_Y[0][j][0];
                  if (eyy<0) eyy=0.;
                    Double_t exy=ex+eyy;
                    hisxy->Fill(i,j,exy);
                    totalExy+=exy;
                }
            }
            //perform operation here
            //Draw to Canvas
            //if (totalExy>0){
            //if (aida_beta.dssd_Z_mult[0]>0){
            c2rot->cd();
            hisy->SetFillColor(3);
            hisy->SetLineColor(3);
            hisy->GetYaxis()->SetRangeUser(0,3000);
            hisy->Draw();
            c2rot->Update();
            TImage *img = TImage::Create();
            img->FromPad(c2rot);
            cout<<"Entry="<<jentry<<endl;
            c1->cd(1);
            img->Flip(90);
            img->Draw("x");
            //hisy->Draw("his");
            c1->cd(2);
            hisxy->SetMaximum(3000);
            hisxy->Draw("colz");
            //Draw hit position
            /*
            //Get Hit position
            Int_t beta_mult;
            map<Int_t, vector<pair<pair<Double_t,Double_t>,pair<Double_t,Double_t> > > > map_beta;
            map<Int_t, vector<pair<pair<Double_t,Double_t>,pair<Double_t,Double_t> > > >::iterator imap_beta;
            map_beta.clear();
            aida_beta.BetaGetPosNEW(0.3,beta_mult,map_beta);

            TMarker* mk[beta_mult];
            imap_beta = map_beta.find(0);
            if(imap_beta != map_beta.end()){
                Int_t beta_x = -1,beta_y = -1;
                for(unsigned int jj=0; jj<imap_beta->second.size(); jj++){
                    beta_x=imap_beta->second[jj].first.first;
                    beta_y=imap_beta->second[jj].second.first;
                    cout<<imap_beta->second[jj].first.second<<"-"<<imap_beta->second[jj].second.second<<endl;
                    mk[jj]=new TMarker(beta_x,beta_y,20);
                    mk[jj]->SetMarkerSize(1.);
                    mk[jj]->SetMarkerColor(2);
                    mk[jj]->Draw();
                }
            }
            */
            TMarker* mk=new TMarker(aida_beta.dssd_x[0],aida_beta.dssd_y[0],20);
            cout<<aida_beta.dssdH_E_X[0][aida_beta.dssd_X[0]][0]<<"-"<<aida_beta.dssdH_E_Y[0][aida_beta.dssd_Y[0]][0]<<endl;
            mk->SetMarkerSize(1.);
            mk->SetMarkerColor(2);
            mk->Draw();

            c1->cd(3);
            hisTX->SetFillColor(2);
            hisTX->SetLineColor(2);
            hisTX->GetYaxis()->SetRangeUser(0,3000);
            hisTX->Draw("his");
            hisTY->SetFillColor(3);
            hisTY->SetLineColor(3);
            hisTY->GetYaxis()->SetRangeUser(0,3000);
            hisTY->Draw("his same");

            c1->cd(4);
            hisx->GetYaxis()->SetRangeUser(0,3000);
            hisx->SetFillColor(2);
            hisx->SetLineColor(2);
            hisx->Draw("his");
            c1->Update();
            std::string name;
            std::getline (std::cin,name);
            if (name=="q") break;
        //}
        //---
    }//end of event loop



    c1->Write();
    rootfile->Close();
}
// 窗口事件处理
Boolean TCommentDetailForm::EventHandler(TApplication * pApp, EventType * pEvent)
{
	Boolean bHandled = FALSE;

	switch (pEvent->eType)
	{
	case EVENT_WinInit:
		{
			_OnWinInitEvent(pApp, pEvent);
			bHandled = TRUE;
			break;
		}

	case EVENT_WinClose:
		{
			_OnWinClose(pApp, pEvent);
			break;
		}

	case EVENT_WinEraseClient:
		{
			TDC 	   dc(this);
			WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent );
			TRectangle rc(pEraseEvent->rc);
			TRectangle rcBack(5, 142, 310, 314);
			this->GetBounds(&rcBack);

			// 擦除
			dc.EraseRectangle(&rc, 0);

			dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_title_bg), 0, 0, SCR_W,
				GUI_API_STYLE_ALIGNMENT_LEFT);

			//dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_bottom_bg), 0, rcBack.Bottom()-68, 
			//320, GUI_API_STYLE_ALIGNMENT_LEFT|GUI_API_STYLE_ALIGNMENT_TOP); 


			pEraseEvent->result = 1;				
			bHandled = TRUE;
		}
		break;

	case EVENT_CtrlSelect:
		{
			bHandled = _OnCtrlSelectEvent(pApp, pEvent);
			break;
		}
	case MSG_POST_THREAD_NOTIFY:
		{
			PostNotifyMsgDataType notifyData;
			Sys_GetMessageBody((MESSAGE_t *)pEvent, &notifyData, sizeof(PostNotifyMsgDataType));

			switch(notifyData.nEditType)
			{
			case ReplyUserCommentEdit:
			case ReplyCommentEdit:
				{		
					Set_Url_Params(KX_ReplyComment, "replycont", (char*)notifyData.PostMsgData.commentdata.pszCommentContent);
					Set_Url_Params(KX_ReplyComment, "fuid", (char*)notifyData.PostMsgData.commentdata.nOuid);	
					Set_Url_Params(KX_ReplyComment, "thread_cid", (char*)notifyData.PostMsgData.commentdata.nId);					

					KaiXinAPICommon_Download(KX_ReplyComment, this->GetWindowHwndId());
					break;
				}			

			default:
				break;

			}

			bHandled = TRUE;
		}
		break;	
		//下载完成消息在给各自form中处理模板
	case MSG_DL_THREAD_NOTIFY:
		{
			NotifyMsgDataType notifyData;
			Sys_GetMessageBody((MESSAGE_t *)pEvent, &notifyData, sizeof(NotifyMsgDataType));						

			bHandled = TRUE;
			switch(notifyData.nAccessType)
			{
			case KX_PhotoDownload:
				{
					if( pBmp[notifyData.nParam] != NULL)
					{
						pBmp[notifyData.nParam]->Destroy();
						pBmp[notifyData.nParam] = NULL; 								
					}
					pBmp[notifyData.nParam] = LoadImgByPath(notifyData.pszFilePath);

					if(pBmp[notifyData.nParam])
					{
						TImage* pTImage;

						pTImage = static_cast< TImage* >(this->GetControlPtr(m_iaTImageID[notifyData.nParam]));
						if(pTImage)
						{
							pTImage->SetBitmap(pBmp[notifyData.nParam]);
							pTImage->Draw();
						}
					}
					break;
				}
			case KX_ReplyComment:
				{
					//Shoud do update data here

					break;
				}
			case KX_DeleteComment:
				{
					//Shoud do update data here
					this->CloseWindow();
					break;
				}				
			}

		}
	case EVENT_KeyCommand: 
		{ 
			// 抓取右软键事件 
			if (pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP  
				|| pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG) 
			{ 
				// 模拟退出按钮选中消息 
				HitControl(m_BackBtn); 
				bHandled = TRUE; 
			} 
		} 
		break;
	default:
		break;
	}

	if (!bHandled)
	{
		bHandled = TWindow::EventHandler(pApp, pEvent);
	}

	return bHandled;
}
// 窗口事件处理
Boolean TPhotosGetAlbumsForm::EventHandler(TApplication * pApp, EventType * pEvent)
{
	Boolean bHandled = FALSE;

	switch (pEvent->eType)
	{
		//窗口创建
	case EVENT_WinInit:
		{
			_OnWinInitEvent(pApp, pEvent);
			bHandled = TRUE;
		}
		break;

		//窗口关闭
	case EVENT_WinClose:
		{
			_OnWinClose(pApp, pEvent);
		}
		break;

		//点击控件
	case EVENT_CtrlSelect:
		{
			bHandled = _OnCtrlSelectEvent(pApp, pEvent);
		}
		break;

		//控件获取焦点
	case EVENT_CtrlSetFocus:
		{
			bHandled = _OnCtrlSetFocusEvent(pApp, pEvent);
		}
		break;

		//控件丢失焦点
	case EVENT_CtrlKillFocus :
		{
			bHandled = _OnCtrlKillFocusEvent(pApp, pEvent);
		}
		break;

		//输入框内容变化
	case EVENT_FieldChanged:
		{
			_OnFldChangedEvent(pApp, pEvent);
			bHandled = TRUE;
		}
		break;

		//窗口的背景
	case EVENT_WinEraseClient:
		{
			TDC dc(this);
			WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent );
			TRectangle rc(pEraseEvent->rc);
			dc.SetBackColor(RGB_COLOR_FORM_BACKGROUND);
			dc.EraseRectangle(&rc, 0);
			dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_title_bg), 0, 0, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT);

			if(m_FormMode == FORM_MODE_MYHOME)
				dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_Bottom_btn_bg), 0, BOTTOM_TAB_Y, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT);				
			pEraseEvent->result = 1;				
			bHandled = TRUE;
		}
		break;

		// 右软键事件 
	case EVENT_KeyCommand: 
		{ 
			if( pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG ) 
			{ 
				// 模拟标题栏右按钮选中消息 
				HitControl(m_TitleBtnRight); 
				bHandled = TRUE; 
			} 
		} 
		break;

        //下载完成事件
	case MSG_DL_THREAD_NOTIFY:
		{
			NotifyMsgDataType notifyData;
			Sys_GetMessageBody((MESSAGE_t *)pEvent, &notifyData, sizeof(NotifyMsgDataType));
			bHandled = TRUE;
			switch(notifyData.nAccessType)
			{
				case RR_PhotoDownload:
				{
					if(notifyData.nParam == FEED_PROFILE_IMAGE_INDEX)
					{	
						//下载完后更新对应的图片
						TBitmap* pDownLoadBitmap = NULL;
						pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath);

						if(pDownLoadBitmap)
						{
							TMaskButton* pLogo = NULL;
							pLogo = static_cast<TMaskButton*>(GetControlPtr(m_ProfileImageID));
							if(pLogo)
							{
								TRectangle rc;							
								pLogo->GetBounds(&rc);
								if( pProfileImage != NULL)
								{
									pProfileImage->Destroy();
									pProfileImage = NULL; 							
								}
									
								pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth());
								pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255));
								pLogo->SetCaption(TUSTR_Re_NULL,0,0);
								pLogo->SetImage(pProfileImage, (rc.Width()-pProfileImage->GetWidth())/2, (rc.Height()-pProfileImage->GetHeight())/2);										pLogo->Draw();
							}				

							//释放图片
							pDownLoadBitmap->Destroy();
							pDownLoadBitmap = NULL; 						
						}	
						break;
					}
						
					TBitmap* pDownLoadBitmap = NULL;
					pDownLoadBitmap= LoadImgByPath(notifyData.pszFilePath);
					if(pDownLoadBitmap != NULL)
					{
						TImage* pImage = static_cast<TImage*>(GetControlPtr(gItemData[notifyData.nParam].nImageID));
						if(pImage != NULL)
						{
							if( gItemData[notifyData.nParam].pBmp != NULL)
							{
								gItemData[notifyData.nParam].pBmp->Destroy();
								gItemData[notifyData.nParam].pBmp = NULL;									
							}
							gItemData[notifyData.nParam].pBmp = pDownLoadBitmap->Create(IMAGE_W, IMAGE_H, 32);
							gItemData[notifyData.nParam].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0);
					
							//pImage->SetImage(gItemData[notifyData.nParam].pBmp, (HEADMASKBUTTON_W - gItemData[notifyData.nParam].pBmp->GetWidth())/2, (HEADMASKBUTTON_H - gItemData[notifyData.nParam].pBmp->GetHeight())/2 );
							pImage->SetBitmap(gItemData[notifyData.nParam].pBmp);
							pImage->Draw();
						}

						//释放图片
						pDownLoadBitmap->Destroy();
						pDownLoadBitmap = NULL; 							
					}
				}					
				break;
				
				case RR_PhotosUpload:
				{
					if(pApp->MessageBox(TResource::LoadConstString(APP_RE_ID_STRING_PhotoUploadContinue),TResource::LoadConstString(APP_RE_ID_STRING_PhotoUploadSuccess),WMB_YESNO) ==0 )
					{
						HitControl(m_TitleBtnLeft); 
					}
					else
					{
						RenRenAPICommon_Download(RR_PhotosGetAlbums, this->GetWindowHwndId(), 0, m_FormMode); 
					}
					break;
				}

				case RR_UsersGetInfoPhoto:
					{
					tResponseUsersGetInfo* Response = NULL;
					RenRenAPI_JsonParse(RR_UsersGetInfoPhoto, (void **)&Response);
					if(Response)
						{
						_UpdateProfilePhoto(pApp, Response);
						delete Response;
						Response = NULL;
						}
					}
				break;					
			default:
				break;
			}
		}
		break;
		
		case MSG_POST_THREAD_NOTIFY:
		{
			PostNotifyMsgDataType notifyData;
			Sys_GetMessageBody((MESSAGE_t *)pEvent, &notifyData, sizeof(PostNotifyMsgDataType));

			if(notifyData.nParam == EDIT_PARAM_PASSWORD)
			{
				Set_Url_Params(RR_PhotosGet, "password", (char*)notifyData.pszEditContent);	
				RenRenAPICommon_Download(RR_PhotosGet, this->GetWindowHwndId(), 0, 0); 
			}
			else if(notifyData.nParam == RR_PhotosUpload)
			{
				Set_Url_Params(RR_PhotosUpload, "caption", (char*)notifyData.pszEditContent);
				RenRenAPICommon_Download(RR_PhotosUpload,  this->GetWindowHwndId(), 0, 0);
			}
			
			bHandled = TRUE;
			break;
		}
	default:
		break;
	}

	if (!bHandled)
	{
		bHandled = TWindow::EventHandler(pApp, pEvent);
	}

	return bHandled;
}