[ROOT] Histogram title problem

From: lijowski@cosray2.wustl.edu
Date: Wed Apr 19 2000 - 16:32:11 MEST


  Hello,

   I am trying to set a histogram title with the simple macro but 
   the position of one part of this title in not consistent with 
   the rest. You have to run it, to see the problem. I am using 
   root 2.24/02. I appreciate any hints.
 
    Regards,

    Michal Lijowski


#include <string.h>

  void Test_Hist()

{
//   gROOT -> Reset();
 
   Char_t  MacroName[40] = "Test_Hist";
   gBenchmark -> Start(MacroName);

   const Int_t  XSize = 200, YSize = 200;

// create a new Root file
    Char_t  outfile[200];

    sprintf(outfile, "%s%s.root", MacroName);
    printf("  Output file  %s\n", outfile);

    TFile *top = new TFile(outfile, "recreate");

    Char_t  htitle[200], ctitle[40], cname[40], outps[120];
    const Int_t NTests = 4; 
    TObjString  *TESTLabels[NTests] = {
                   "  BufId > 50",                //  0
                  "  |ZRAT_E1_Norm| < 5",        //  1
                  "  |ZRAT_Last_Norm| < 5",
                  "  #Theta #leq 25"};            //  3
  
   Int_t TestFlags[NTests] = {
                1,        // BufId > 50               // 0 
                1,        // |ZRAT_E1_Norm| < 5.0     // 1
                1,        // |ZRAT_Last_Norm| < 5.0   // 2
                1};        // Theta <= 25               // 3
  
   Char_t  TTitle[120], ttitle[35];
   TTitle[0] = '\0';
   for (Int_t it = 0; it < NTests; it++) {
       if (TestFlags[it]) {
          ttitle[0] = '\0';
          sprintf(ttitle, "%s", TESTLabels[it]);
          strcat(TTitle, ttitle);
          cout << " it " << it << " TTitle " << TTitle << endl;
       } 
   }
   cout << " TTitle " << TTitle << "  Length " << strlen(TTitle) << endl;
   Float_t  AA = 100.0;
   Float_t  BB1 = 100.0;
   Float_t  BB2 = 100.0;
   Float_t  CC1 = 30.0;
   Float_t  CC2 = 30.0;

   htitle[0] = '\0';
   sprintf(htitle, "^6!Li Kinetic Energy IZ == 3 Range 5  120 - 130 EP_Norm > 160 BufId > 50 |ZRAT_E1_Norm| < 5 |ZRAT_Last_Norm| < 5 `Q# < 25");

   htitle[0] = '\0';
   sprintf(htitle, "{}^{6}Li SOFT Efficiency IZ == 3  Range 5 120 - 130 EP_Norm > 160");
   strcat(htitle, TTitle);
   cout << "  htitle  " << htitle << " Length " << strlen(htitle) << endl;

   Float_t  xxmin = 0, xxmax = XSize, yymin = 0, yymax = YSize;
   TH1F *HH = new TH1F("HH", htitle, XSize, xxmin, xxmax);
// fill the histogram
   Float_t  wwmin = 5.0, wwmax = 10.0;
   for  (Int_t yk = 0; yk < YSize; yk++) {
       Float_t  YY = (Float_t) yk;
       for  (Int_t xk = 0; xk < XSize; xk++) {
           Float_t  XX = (Float_t) xk;
           Float_t  argx = (XX - BB1) / CC1;
           Float_t  argy = (YY - BB2) / CC2; 
           Float_t  ZZ1 = TMath::Exp(-0.5 * argx * argx);
           Float_t  ZZ2 = TMath::Exp(-0.5 * argy * argy);
           Float_t  ww = AA * ZZ1 * ZZ2;

           HH -> Fill(ww);
       }
   }
 
   Int_t  ii = 0;
   sprintf(ctitle, "Canvas %d", ii);
   TCanvas *cc1 = new TCanvas("cc1", ctitle, 800, 600);
   cc1 -> SetTicks();
   HH -> DrawCopy();

   cc1 -> Update();
   cc1 -> SaveAs("cc1.ps");
   top -> Write();
   top -> Close();
   gBenchmark -> Show(MacroName);
}

    



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:24 MET