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