Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

EDHistos.cxx

Go to the documentation of this file.
00001 
00002 #include "TCanvas.h"
00003 #include "TStyle.h"
00004 
00005 #include "bfemDisplay/EDHistos.h"
00006 
00007 ClassImp(EDHistos)
00008 
00009 Char_t *nameACD[ NUM_ACD_HISTS ] = { "Tile000","Tile001","Tile010","Tile011","Tile100","Tile110","Tile200",
00010                                      "Tile210","Tile300","Tile310","Tile400","Tile410","Tile1000" };
00011 
00012 Char_t *nameXGT[ NUM_XGT_HISTS ] = { "XGT2000","XGT2001","XGT2010","XGT2011" };
00013 
00014 Char_t *nameTKR[ NUM_TKR_HISTS ] = { "Plane0-Y(L0) ","Plane0-X(L1) ","Plane1-X(L2) ","Plane1-Y(L3) ",
00015                                      "Plane2-Y(L4) ","Plane2-X(L5) ","Plane3-X(L6) ",
00016                                      "Plane3-Y(L7) ","Plane4-Y(L8) ","Plane4-X(L9) ","Plane5-X(L10) ",
00017                                      "Plane5-Y(L11) ","Plane6-Y(L12) ","Plane6-X(L13) ",
00018                                      "Plane7-X(L14) ","Plane7-Y(L15) ","Plane8-Y(L16) ","Plane8-X(L17) ",
00019                                      "Plane9-X(L18) ","Plane9-Y(L19) ","Plane10-Y(L20) ",
00020                                      "Plane10-X(L21) ","Plane11-X(L22) ","Plane11-Y(L23) ","Plane12-Y(L24) ",
00021                                      "Plane12-X(L25) " };
00022 
00023 Char_t *nameTKRtotR[ NUM_TKR_HISTS ] = { "TOTr-Plane0-Y(L0) ","TOTr-Plane0-X(L1) ","TOTr-Plane1-X(L2) ",
00024                                          "TOTr-Plane1-Y(L3) ","TOTr-Plane2-Y(L4) ",
00025                                          "TOTr-Plane2-X(L5) ","TOTr-Plane3-X(L6) ","TOTr-Plane3-Y(L7) ",
00026                                          "TOTr-Plane4-Y(L8) ","TOTr-Plane4-X(L9) ",
00027                                          "TOTr-Plane5-X(L10) ","TOTr-Plane5-Y(L11) ","TOTr-Plane6-Y(L12) ",
00028                                          "TOTr-Plane6-X(L13) ","TOTr-Plane7-X(L14) ",
00029                                          "TOTr-Plane7-Y(L15) ","TOTr-Plane8-Y(L16) ","TOTr-Plane8-X(L17) ",
00030                                          "TOTr-Plane9-X(L18) ","TOTr-Plane9-Y(L19) ",
00031                                          "TOTr-Plane10-Y(L20) ","TOTr-Plane10-X(L21) ","TOTr-Plane11-X(L22) ",
00032                                          "TOTr-Plane11-Y(L23) ","TOTr-Plane12-Y(L24) ",
00033                                          "TOTr-Plane12-X(L25) " };
00034 
00035 
00036 Char_t *nameTKRtotL[ NUM_TKR_HISTS ] = { "TOTl-Plane0-Y(L0) ","TOTl-Plane0-X(L1) ","TOTl-Plane1-X(L2) ",
00037                                          "TOTl-Plane1-Y(L3) ","TOTl-Plane2-Y(L4) ",
00038                                          "TOTl-Plane2-X(L5) ","TOTl-Plane3-X(L6) ","TOTl-Plane3-Y(L7) ",
00039                                          "TOTl-Plane4-Y(L8) ","TOTl-Plane4-X(L9) ",
00040                                          "TOTl-Plane5-X(L10) ","TOTl-Plane5-Y(L11) ","TOTl-Plane6-Y(L12) ",
00041                                          "TOTl-Plane6-X(L13) ","TOTl-Plane7-X(L14) ",
00042                                          "TOTl-Plane7-Y(L15) ","TOTl-Plane8-Y(L16) ","TOTl-Plane8-X(L17) ",
00043                                          "TOTl-Plane9-X(L18) ","TOTl-Plane9-Y(L19) ",
00044                                          "TOTl-Plane10-Y(L20) ","TOTl-Plane10-X(L21) ","TOTl-Plane11-X(L22) ",
00045                                          "TOTl-Plane11-Y(L23) ","TOTl-Plane12-Y(L24) ",
00046                                          "TOTl-Plane12-X(L25) " };
00047 
00048 
00049 void EDHistos::InitHistos() {
00050 
00051   m_histFile = 0;
00052   m_histList = 0;
00053   HistDefine();
00054   MakeHistList();
00055 
00056 
00057 }
00058 
00059 EDHistos::~EDHistos() {
00060 
00061   // destructor: cleanup
00062 
00063   m_histFile->Write();  
00064   HClr();
00065   AllHistDelete();
00066   if (m_histFile) delete m_histFile;
00067   //if (m_histList) delete m_histList;
00068 
00069 }
00070 
00071 void EDHistos::MakeHistList() {
00072 
00073   // make a TObjArray of histograms
00074 
00075   if (m_histList) delete m_histList;
00076 
00077   TFile *histFile = (TFile*)gROOT->GetFile("Histograms.root");
00078 
00079   m_histList = new TObjArray();
00080 
00081   TList* list = histFile->GetList();
00082   TIter*  iter = new TIter(list);
00083 
00084   histFile->GetList()->ls();
00085   TObject* obj = 0;
00086 
00087   while ( ( obj=iter->Next() ) ) {
00088 
00089     if (obj->InheritsFrom("TH1")) {
00090       m_histList->Add(obj);
00091     }
00092 
00093   }
00094 
00095   delete iter;
00096 
00097 }
00098 
00099 
00100 
00101 void EDHistos::HClr() {
00102 
00103   // clear histograms
00104 
00105   if (!m_histList) return;
00106 
00107   for (Int_t i=0; i < m_histList->GetEntries(); i++) {
00108      ((TH1*)m_histList->At(i))->Reset();
00109   }
00110 
00111 }
00112 
00113 
00114 
00115 void EDHistos::AllHistDelete() {
00116 
00117   // delete histograms
00118 
00119   if (m_histList) {
00120 
00121     for (Int_t i=0; i < m_histList->GetEntries(); i++) {
00122       TObject* obj = m_histList->At(i);
00123       ((TH1*)obj)->SetDirectory(0);
00124       delete obj;
00125     }
00126 
00127     delete m_histList;
00128 
00129   }
00130 
00131 }
00132 
00133 
00134 
00135 void EDHistos::Help() {
00136 
00137 cout << "\n"<< endl;
00138 cout << "
00139 cout << "//  User instructions:                                      //" << endl;
00140 cout << "//                                                          //" << endl;
00141 cout << "//    analysis:     .x histo.c                              //" << endl; 
00142 cout << "//    m->Go(500); // loop over 500 events.                  //" << endl;
00143 cout << "//    m->Go();    // look at remainder of file              //" << endl;
00144 cout << "//    m->Rewind();// go to the beginnig of the input file   //" << endl;
00145 cout << "//    h->HClr();  // clear histograms                       //" << endl;
00146 cout << "//    h->DrawACDHistos(); // Draw ACD histos                //" << endl;
00147 cout << "//    h->DrawXGTHistos(); // Draw XGT histos                //" << endl;
00148 cout << "//    h->DrawTKRHistos();// Draw TKR histos                 //" << endl;
00149 cout << "//    h->DrawTKRtotLHistos()  : display TOT left            //" << endl;
00150 cout << "//    h->DrawTKRtotRHistos()  : display TOT right           //" << endl;
00151 cout << "//    h->DrawCALHistos(); // Draw CAL histos                //" << endl;
00152 cout << "//    h->Help(); // This help                               //" << endl;  
00153 cout << "//                                                          //" << endl;
00154 cout << "// Version 0.2 23-May-2001 Gloria S.                        //" << endl;
00155 cout << "
00156 
00157 }
00158 
00159 
00160 
00161 void EDHistos::HistDefine() {
00162   
00163   TH1F *hist;
00164 
00165   
00166   // Set up root file for histos here_______________________________________
00167 
00168   m_histFile = new TFile("Histograms.root","RECREATE");
00169   
00170   
00171   // Booking ACD and XGT histos_______________________________________
00172    
00173   
00174   for (Int_t itile = 0; itile < NUM_ACD_HISTS; itile++) {
00175     
00176     hACD[itile] = new TH1F(nameACD[itile],nameACD[itile],100,0,2500);
00177     
00178     hist = (TH1F*)hACD[itile];
00179     
00180     hist->SetMaximum(80); 
00181     
00182     hist->GetXaxis()->SetTitle("PHA, ADC counts");
00183      
00184   }
00185   
00186   for (Int_t itile = 0; itile < NUM_XGT_HISTS; itile++) {
00187     
00188     hXGT[itile] = new  TH1F(nameXGT[itile],nameXGT[itile],100,150,800);
00189     
00190     hist = (TH1F*)hXGT[itile];
00191     
00192     hist->SetMaximum(40); 
00193     
00194     hist->GetXaxis()->SetTitle("PHA, ADC counts");
00195      
00196   }
00197   
00198 
00199   
00200   // Booking CAL histos_______________________________________
00201   
00202   
00203   
00204   LOGID = new TH1F("LOGID","Cal LogID",100,0,100);
00205 
00206   NLOGS = new TH1F("NLOGS","Num Cal Logs",100,0,100);
00207   
00208   BESTRANGE = new TH1F("BESTRANGE","Cal selected range",6,-1,5);
00209   
00210   ELOG = new TH1F("ELOG","Cal Elog (GeV)",100,0,.05);
00211   
00212   ETOTADCCAL = new TH1F("ETOTADCCAL","Cal Etot (ADC counts)",1000,1e4,30e3);
00213   
00214   ETOTCAL = new TH1F("ETOTCAL","Cal Etot (GeV)",100,0,5);
00215   
00216   ADC0 = new TH1F("ADC0","Cal ADC Range 0",100,0,1000);
00217   
00218   ADC1 = new TH1F("ADC1","Cal ADC Range 1",100,0,1000);
00219   
00220   ADC2 = new TH1F("ADC2","Cal ADC Range 2",100,0,1000);
00221 
00222   ADC3 = new TH1F("ADC3","Cal ADC Range 3",100,0,1000);
00223 
00224   ETOTVSNLOGS = new TH2F("ETOTVSNLOGS","Cal Etot vs. NLogs",100,0,.5,100,0,100);
00225   
00226 
00227   
00228   // Booking TKR histos_______________________________________
00229   
00230   
00231   
00232   for (Int_t ilayer = 0; ilayer < NUM_TKR_HISTS; ilayer++) {
00233     
00234     hTKR[ilayer] = new  TH1F(nameTKR[ilayer],nameTKR[ilayer],1600,0,1600);
00235     
00236     hist = (TH1F*)hTKR[ilayer];
00237     
00238     hist->SetMaximum(30); 
00239     
00240     hist->GetXaxis()->SetTitle("Hits");
00241 
00242     hist->GetXaxis()->SetLabelSize(0.1);
00243 
00244     hist->GetYaxis()->SetLabelSize(0.1);
00245 
00246   }
00247   
00248   
00249   
00250   for (Int_t ilayer = 0; ilayer < NUM_TKR_HISTS; ilayer++) {
00251     
00252     hTKRtotL[ilayer] = new  TH1F(nameTKRtotL[ilayer],nameTKRtotL[ilayer],256, 0, 512);
00253     
00254     hist = (TH1F*)hTKRtotL[ilayer];
00255     
00256     hist->SetMaximum(100); 
00257     
00258     hist->GetXaxis()->SetLabelSize(0.06);
00259     
00260     hist->GetXaxis()->SetTitle("TOT-Left");
00261 
00262     hist->GetXaxis()->SetLabelSize(0.1);
00263 
00264     hist->GetYaxis()->SetLabelSize(0.1);
00265   }
00266 
00267   for (Int_t ilayer = 0; ilayer < NUM_TKR_HISTS; ilayer++) {
00268 
00269     hTKRtotR[ilayer] = new  TH1F(nameTKRtotR[ilayer],nameTKRtotR[ilayer],256, 0, 512);
00270      
00271     hist = (TH1F*)hTKRtotR[ilayer];
00272       
00273     hist->SetMaximum(100); 
00274       
00275     hist->GetXaxis()->SetLabelSize(0.06);
00276       
00277     hist->GetXaxis()->SetTitle("TOT-Right");
00278 
00279     hist->GetXaxis()->SetLabelSize(0.1);
00280 
00281     hist->GetYaxis()->SetLabelSize(0.1);
00282   }
00283   
00284   
00285   // end histogram definition ________________________________________
00286   
00287 }
00288 
00289 
00290 void EDHistos::DrawTKRHistos()
00291 
00292 {
00293 
00294   m_canvas->Clear();
00295 
00296   m_canvas->Divide(4,7,0,0);
00297 
00298   for (Int_t ihis = 1; ihis < 27; ihis++) {
00299 
00300 
00301     m_canvas->cd(ihis);
00302 
00303     gStyle->SetOptStat(0);
00304 
00305     ((TH1*)m_histList->At(ihis+27))->Draw();
00306 
00307     m_canvas->Update();
00308 
00309 
00310     TPaveText *mytitle = ( TPaveText* )gROOT->FindObject("title");
00311 
00312     ChangePaveTextDim(mytitle,3.);
00313 
00314     m_canvas->Update();
00315 
00316   }
00317 
00318 }
00319 
00320 
00321 
00322 void EDHistos::DrawTKRtotLHistos()
00323 
00324 {
00325 
00326   m_canvas->Clear();
00327 
00328   m_canvas->Divide(4,7,0,0);
00329 
00330 
00331   for (Int_t ihis = 1; ihis < 27; ihis++) {
00332 
00333 
00334     m_canvas->cd(ihis);
00335 
00336     gStyle->SetOptStat(0);
00337 
00338     ((TH1*)m_histList->At(ihis+53))->Draw();
00339 
00340     m_canvas->Update();
00341 
00342 
00343     TPaveText *mytitle = ( TPaveText* )gROOT->FindObject("title");
00344 
00345     ChangePaveTextDim(mytitle,3.);
00346 
00347     m_canvas->Update();
00348 
00349   }
00350 
00351 }
00352 
00353 
00354 void EDHistos::DrawTKRtotRHistos()
00355 
00356 {
00357 
00358   m_canvas->Clear();
00359 
00360   m_canvas->Divide(4,7,0,0);
00361 
00362 
00363   for (Int_t ihis = 1; ihis < 27; ihis++) {
00364 
00365 
00366     m_canvas->cd(ihis);
00367 
00368     gStyle->SetOptStat(0);
00369 
00370     ((TH1*)m_histList->At(ihis+79))->Draw();
00371 
00372     m_canvas->Update();
00373 
00374 
00375     TPaveText *mytitle = ( TPaveText* )gROOT->FindObject("title");
00376 
00377     ChangePaveTextDim(mytitle,3.);
00378 
00379     m_canvas->Update();
00380 
00381   }
00382 
00383 }
00384 
00385 
00386 void EDHistos::DrawCALHistos()
00387 
00388 {
00389 
00390   m_canvas->Clear();
00391 
00392   m_canvas->Divide(3,3,0,0);
00393 
00394   gStyle->SetOptStat(110);
00395 
00396      
00397   for (Int_t ihis = 1; ihis < 10; ihis++) {
00398 
00399 
00400     m_canvas->cd(ihis);
00401 
00402     ((TH1*)m_histList->At(ihis+17))->Draw();
00403 
00404     m_canvas->Update();
00405 
00406 
00407     TPaveText *mytitle = ( TPaveText* )gROOT->FindObject("title");
00408 
00409     ChangePaveTextDim(mytitle,1.5);
00410 
00411     mytitle = ( TPaveText* )gROOT->FindObject("stats");
00412 
00413     ChangePaveTextDim(mytitle,1.5);
00414 
00415     m_canvas->Update();
00416 
00417   }
00418 
00419 }
00420 
00421 
00422 
00423  void EDHistos::DrawACDHistos() 
00424 
00425 {
00426 
00427      m_canvas->Clear();
00428 
00429      m_canvas->Divide(4,4,0,0);
00430 
00431      m_canvas->cd(1);
00432 
00433      gStyle->SetOptStat(110);
00434 
00435      ((TH1*)m_histList->At(12))->Draw(); //BIG Tile Id=1000
00436 
00437      m_canvas->Update();
00438 
00439 
00440 
00441     TPaveText *mytitle = ( TPaveText* )gROOT->FindObject("title");
00442 
00443     ChangePaveTextDim(mytitle,2);
00444 
00445     mytitle = ( TPaveText* )gROOT->FindObject("stats");
00446 
00447     ChangePaveTextDim(mytitle,2);
00448 
00449     m_canvas->Update();
00450 
00451      for (Int_t ihis = 0; ihis < 12; ihis++) {  
00452 
00453          m_canvas->cd(ihis+5);
00454 
00455          ((TH1*)m_histList->At(ihis))->Draw();
00456 
00457          m_canvas->Update();
00458 
00459 
00460          TPaveText *mytitle = ( TPaveText* )gROOT->FindObject("title");
00461 
00462          ChangePaveTextDim(mytitle,1.5);
00463 
00464          mytitle = ( TPaveText* )gROOT->FindObject("stats");
00465 
00466          ChangePaveTextDim(mytitle,1.5);
00467 
00468          m_canvas->Update();
00469 
00470 
00471      }
00472 
00473 }
00474 
00475 
00476 
00477 void EDHistos::DrawXGTHistos()
00478 
00479 {
00480 
00481   m_canvas->Clear();
00482 
00483   m_canvas->Divide(2,2,0,0);
00484 
00485   gStyle->SetOptStat(110);
00486 
00487   for (Int_t ihis = 0; ihis < 4; ihis++) {      
00488 
00489 
00490       m_canvas->cd(ihis+1);
00491 
00492       ((TH1*)m_histList->At(ihis+13))->Draw();
00493 
00494       m_canvas->Update();
00495 
00496       
00497       TPaveText *mytitle = ( TPaveText* )gROOT->FindObject("title");
00498 
00499       ChangePaveTextDim(mytitle,1.);
00500 
00501       mytitle = ( TPaveText* )gROOT->FindObject("stats");
00502 
00503       ChangePaveTextDim(mytitle,1.);
00504 
00505       m_canvas->Update();
00506 
00507   }
00508 
00509 }
00510 
00511 
00512 
00513 void EDHistos::ChangePaveTextDim(TPaveText *mytext, Float_t zoom){
00514 
00515     Double_t newwidth = zoom*(mytext->GetX2NDC() - mytext->GetX1NDC());
00516 
00517     Double_t newheight = zoom*(mytext->GetY2NDC() - mytext->GetY1NDC());
00518 
00519     Double_t newx2 = mytext->GetX1NDC() + newwidth;
00520 
00521     if (newx2 > 1) {
00522 
00523       mytext->SetX1NDC(mytext->GetX1NDC() - newx2 + 0.95);
00524 
00525       newwidth = 1.1*newwidth;
00526 
00527     }
00528 
00529     mytext->SetX2NDC( mytext->GetX1NDC() + newwidth );
00530 
00531     mytext->SetY1NDC( mytext->GetY1NDC() - 0.1 );
00532 
00533     mytext->SetY2NDC( mytext->GetY1NDC() + newheight );
00534 
00535     mytext->SetTextFont(62);
00536 
00537     mytext->Paint();
00538 
00539 
00540 
00541 }
00542 
00543 

Generated at Wed Nov 14 20:41:42 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000