TOF/TFndTofMonFrame.cxx

00001 // @(#)fROOT/TOF:$Name:  $:$Id: TFndTofMonFrame.cxx,v 1.22 2007/09/24 07:32:41 Diego_Faso Exp $
00002 // Revision Author: Diego Faso <mailto:faso@to.infn.it>, 2005/06/24
00003 // Original Author: Piergiorgio Cerello <mailto:cerello@to.infn.it>, 2000
00004 
00006 //                                                //
00007 //               TFndTofMonFrame                  //
00008 //                                                //
00009 //  Class for the TOF monitoring GUI              //
00010 //  (see Gts relative class for descriptions)     //
00011 //                                                //
00013 
00014 #include <TSystem.h>
00015 #include <TStyle.h>
00016 
00017 #include "FROOT.h"
00018 #include "TFndTofMonFrame.h" 
00019 #include "TFndRun.h" 
00020 #include "TFndHdt.h" 
00021 
00022 ClassImp(TFndTofMonFrame)
00023 
00024 //_____________________________________
00025 TFndTofMonFrame::TFndTofMonFrame(TString filename):
00026   TFndMonFrame(filename),fIO(),fCurSlab(),fNSlabs(),
00027   fGenMapFile(),fAdcMapFile(),fTdcMapFile(),
00028   fSlabPad(),fAllPad(),
00029   fSlabButton(),fAllButton(),
00030   hists(),h2(),
00031   fWhichGroup(-1),fAllId(-1)
00032 {
00033   
00034   Init();
00035 }
00036 
00037 //_____________________________________
00038 TFndTofMonFrame::~TFndTofMonFrame() {
00039   
00040   if(!fClosed) Close();
00041 }
00042   
00043 //_____________________________________
00044 void TFndTofMonFrame::Init() {
00045 
00046   //   fCheckedHistos = new TObjArray(1000);
00047   SetStyle();
00048 
00049   fNSlabs[0] = 12;
00050   fNSlabs[1] = 72;
00051 
00052   fHighlightCol[0] = 5;
00053   fHighlightCol[1] = 5;
00054 
00055   //   fSHMEntries = 0;
00056   //   time_t now;
00057   //   now = time(&now);
00058   //   fTime = now;
00059   //   cout << "Time is: " << fTime << " in TFndTofMonFrame::Init()" << endl;
00060   
00061   //  fndrun->SetTofMonFrame(this);
00062   //   if(! StartInterface(0)) return;
00063   //   if(! StartInterface(1)) return;
00064   //  fClosed = kFALSE;
00065 }
00066 
00067 //_____________________________________
00068 void TFndTofMonFrame::Open() {
00069   
00070   if(!fClosed) return;
00071   if(! StartInterface(1)) return;  
00072   if(! StartInterface(0)) return;  // TOFINO on top
00073   fClosed = kFALSE;
00074 }
00075 
00076 //_____________________________________
00077 void TFndTofMonFrame::Close() {
00078   // the consumer should not close shared memories
00079 
00080   if(!fClosed){
00081     Printf("TFndTofMonFrame::Close() ---> closing and re-initializing to zero all mapfiles");    
00082     if(fGenMapFile) { fGenMapFile->Close(); fGenMapFile = 0; }
00083     if(fAdcMapFile) { fAdcMapFile->Close(); fAdcMapFile = 0; }
00084     if(fTdcMapFile) { fTdcMapFile->Close(); fTdcMapFile = 0; }
00085     Printf("TFndTofMonFrame::Close() ---> Done");    
00086   }
00087   fClosed = kTRUE;
00088 
00089 }
00090 
00091 //_____________________________________
00092 Bool_t TFndTofMonFrame::ReloadMapFiles(){
00093 
00094   Bool_t result = kTRUE;
00095   if(!fIsOnline) return result;
00096 
00097   if( CheckProducerMessages() != 0 ) return kFALSE; // chech if shared memories are busy (producer message)
00098   TString shr_file_map_name[3] = 0;
00099 
00100 #if defined _FND_ONL_USE_MAP_FILES_
00101   if(fndrun->GetDebug()) Printf("TFndTofMonFrame::ReloadMapFiles() ---> closing and re-initializing to zero all mapfiles");      
00102   if(fGenMapFile) { fGenMapFile->Close(); fGenMapFile = 0; }
00103   if(fAdcMapFile) { fAdcMapFile->Close(); fAdcMapFile = 0; }
00104   if(fTdcMapFile) { fTdcMapFile->Close(); fTdcMapFile = 0; }
00105   if(fndrun->GetDebug()) Printf("TFndTofMonFrame::ReloadMapFiles() ---> Done");
00106   //
00107   shr_file_map_name[0] = "$FND_SHR/tof_map.map";
00108   shr_file_map_name[1] = "$FND_SHR/tof_adc.map";
00109   shr_file_map_name[2] = "$FND_SHR/tof_tdc.map";
00110 #elif defined _FND_ONL_USE_SHARED_FILES_
00111   if(fGenMapFile) { if(fGenMapFile->IsOpen()) fGenMapFile->Close(); delete fGenMapFile; fGenMapFile = 0; }
00112   if(fAdcMapFile) { if(fAdcMapFile->IsOpen()) fAdcMapFile->Close(); delete fAdcMapFile; fAdcMapFile = 0; }
00113   if(fTdcMapFile) { if(fTdcMapFile->IsOpen()) fTdcMapFile->Close(); delete fTdcMapFile; fTdcMapFile = 0; }
00114   if(fndrun->GetDebug()) Printf("TFndTofMonFrame::ReloadMapFiles() ---> Done");
00115   //
00116   shr_file_map_name[0] = "$FND_SHR/tof_map.file.map";
00117   shr_file_map_name[1] = "$FND_SHR/tof_adc.file.map";
00118   shr_file_map_name[2] = "$FND_SHR/tof_tdc.file.map";
00119 #endif
00120   
00121   if(fndrun->GetDebug()) Printf("Reloading shared memories...");
00122   
00123   if(!gSystem->AccessPathName(FROOT::ExpandPathName(shr_file_map_name[0].Data()))){
00124 #if defined _FND_ONL_USE_MAP_FILES_
00125     if(fndrun->GetDebug()) Printf(" fGenMapFile ");
00126     //fGenMapFile = TMapFile::Create(FROOT::ExpandPathName("$FND_SHR/tof_map.map"),"READ",(Int_t)(1048576*FROOT::K_TofMapSize));
00127     fGenMapFile = TMapFile::Create(FROOT::ExpandPathName(shr_file_map_name[0].Data()),"READ");
00128     if(fndrun->GetDebug())fGenMapFile->Print();
00129     //if(fndrun->GetDebug())fGenMapFile->ls();
00130 #elif defined _FND_ONL_USE_SHARED_FILES_
00131     fGenMapFile = new TFile(FROOT::ExpandPathName(shr_file_map_name[0].Data()),"READ");
00132     Info("TFndTofMonFrame::ReloadMapFiles","Reloading shared file \"%s\"",shr_file_map_name[0].Data());
00133     //fGenMapFile->ls();
00134 #endif
00135   }
00136   else result = kFALSE;
00137   
00138   if(!gSystem->AccessPathName(FROOT::ExpandPathName(shr_file_map_name[1].Data()))){
00139 #if defined _FND_ONL_USE_MAP_FILES_
00140     if(fndrun->GetDebug()) Printf(" fAdcMapFile ");
00141     //fAdcMapFile = TMapFile::Create(FROOT::ExpandPathName("$FND_SHR/tof_adc.map"),"READ",(Int_t)(1048576*FROOT::K_TofAdcMapSize));
00142     fAdcMapFile = TMapFile::Create(FROOT::ExpandPathName(shr_file_map_name[1].Data()),"READ");
00143     if(fndrun->GetDebug())fAdcMapFile->Print();
00144     //if(fndrun->GetDebug())fAdcMapFile->ls();
00145 #elif defined _FND_ONL_USE_SHARED_FILES_
00146     fAdcMapFile = new TFile(FROOT::ExpandPathName(shr_file_map_name[1].Data()),"READ");
00147     Info("TFndTofMonFrame::ReloadMapFiles","Reloading shared file \"%s\"",shr_file_map_name[1].Data());
00148     //fAdcMapFile->ls();
00149 #endif
00150   }
00151   else result = kFALSE;
00152   
00153   if(!gSystem->AccessPathName(FROOT::ExpandPathName(shr_file_map_name[2].Data()))){
00154 #if defined _FND_ONL_USE_MAP_FILES_
00155     if(fndrun->GetDebug()) Printf(" fTdcMapFile ");
00156     //fTdcMapFile = TMapFile::Create(FROOT::ExpandPathName("$FND_SHR/tof_tdc.map"),"READ",(Int_t)(1048576*FROOT::K_TofTdcMapSize));
00157     fTdcMapFile = TMapFile::Create(FROOT::ExpandPathName(shr_file_map_name[2].Data()),"READ");
00158     if(fndrun->GetDebug())fTdcMapFile->Print();
00159     //if(fndrun->GetDebug())fTdcMapFile->ls();
00160 #elif defined _FND_ONL_USE_SHARED_FILES_
00161     fTdcMapFile = new TFile(FROOT::ExpandPathName(shr_file_map_name[2].Data()),"READ");
00162     Info("TFndTofMonFrame::ReloadMapFiles","Reloading shared file \"%s\"",shr_file_map_name[2].Data());
00163     //fTdcMapFile->ls();
00164 #endif
00165   }
00166   else result = kFALSE;
00167   
00168   if(fndrun->GetDebug()){
00169     if(result)  Printf("TFndTofMonFrame::ReloadMapFiles() ---> exiting method");
00170     else Printf("TFndTofMonFrame::ReloadMapFiles() ---> exiting method (shared memories not found)");
00171   }
00172   return result;
00173 }
00174 
00175 //_____________________________________
00176 Bool_t TFndTofMonFrame::StartInterface(Int_t ring) {
00177   
00178   Int_t BackgroundCol = 12;
00179   Int_t DisplayPadCol = 15;
00180 
00181   Int_t x0 = 150;     // main canvas
00182   Int_t y0 = 100;       // main canvas
00183   //  Int_t xsize = 1050; // main canvas
00184   //  Int_t ysize = 700;  // main canvas
00185 
00186   Float_t sep = 0.001;
00187   Float_t smallsep = 0.0005;
00188 
00189   Float_t Start_X_displaypad[2];
00190   Float_t Stop_X_displaypad[2];
00191   Float_t Start_Y_displaypad[2];
00192   Float_t Stop_Y_displaypad[2];
00193   Start_X_displaypad[0] = 0.085;
00194   Stop_X_displaypad[0]  = 1.;
00195   Start_Y_displaypad[0] = 0.05;
00196   Stop_Y_displaypad[0]  = 1.;
00197   
00198   Start_X_displaypad[1] = 0.055;
00199   Stop_X_displaypad[1]  = 0.945;
00200   Start_Y_displaypad[1] = 0.05;
00201   Stop_Y_displaypad[1]  = 0.95;
00202 
00203   // Stop here if no source file was found
00204   if(!fCanStartGUI) return kFALSE;
00205   // ---
00206 
00207   fIO=ring;
00208   fCurSlab=0;
00209 
00210   //  cout << "layer (fIO): " << fIO << endl;
00211   ReloadMapFiles();
00212   //  cout << "mapfiles loaded" << endl;
00213   //  fCanStartGUI = ReloadMapFiles();
00214   //  if(!fCanStartGUI) return 0;
00215 
00216   if (fRF)  Printf("TFndTofMonFrame::StartInterface ---> source file found...starting GUI");
00217   
00218   TString str1 = TString();
00219   TString name1 = TString();
00220   //  Char_t *mod;
00221   //  if(fIO==0) mod = "tof";
00222   //  if(fIO==1) mod = "TOF";
00223   Char_t *mod[2];
00224   mod[0] = "tof";
00225   mod[1] = "TOF";
00226   str1+=mod[fIO];
00227   str1+=" Detector Display";
00228   name1+=mod[fIO];
00229   name1+="_MainCanvas";
00230   if(fIO==1) {
00231     x0 +=100;
00232     y0 -=100;
00233   }
00234   fMainCanvas[fIO] = new TCanvas(name1.Data(),str1.Data(),
00235                                  fMainCanvCoord[0],fMainCanvCoord[1],
00236                                  fMainCanvCoord[2],fMainCanvCoord[3]); 
00237   if(fIO==0) SetMonitorTitle(0,"tofino");
00238   else SetMonitorTitle(1,"TOFONE");
00239   fMainCanvas[fIO]->SetEditable(kFALSE);
00240   fMainCanvas[fIO]->SetFillColor(BackgroundCol);
00241   fMainCanvas[fIO]->Draw();
00242 
00243   //  cout << "control pad" << endl;
00244   str1+=mod[fIO];
00245   str1+=" control pad";
00246 
00247   //  cout << "fDisplayPad" << endl;
00248   str1 = mod[fIO];
00249   str1+=" hist display";
00250   name1 = mod[fIO];
00251   name1+=" viewpad";
00252   fDisplayPad[fIO] = new TPad(name1.Data(),str1.Data(),
00253                               Start_X_displaypad[fIO],Start_Y_displaypad[fIO],
00254                               Stop_X_displaypad[fIO],Stop_Y_displaypad[fIO]);
00255   fDisplayPad[fIO]->Draw();
00256   fDisplayPad[fIO]->SetFillColor(DisplayPadCol);
00257   fDisplayPad[fIO]->SetBorderSize(2);
00258 
00259   str1 = mod[fIO];
00260   str1+=" tof_AllPadControl";
00261 
00262   //  cout << "fAllPad" << endl; // tofino only
00263   fAllPad[0] = new TPad(str1.Data(),str1.Data(),
00264                         Start_X_displaypad[fIO], 0.,
00265                         Stop_X_displaypad[fIO],  Start_Y_displaypad[fIO]-sep);
00266 
00267   switch(fIO){
00268   case 0: // tofino
00269     fSlabPad[0] = new TPad("SlabTofSelPad","SlabTofSelPad",0.,Start_Y_displaypad[fIO],Start_X_displaypad[fIO]-sep,Stop_Y_displaypad[fIO]);
00270     fSlabPad[0]->SetFillColor(13);
00271     fSlabPad[0]->Draw();
00272 
00273     fAllPad[fIO]->Draw();    
00274     break;
00275   case 1: // tofone
00276     fSlabPad[1] = new TPad("SlabTofSelPad1","SlabTofSelPad1",
00277                            0.,                          Start_Y_displaypad[fIO]+smallsep,
00278                            Start_X_displaypad[fIO]-sep, Stop_Y_displaypad[fIO]-smallsep);
00279     fSlabPad[1]->SetFillColor(3);
00280     fSlabPad[1]->Draw();
00281 
00282     fSlabPad[2] = new TPad("SlabTofSelPad2","SlabTofSelPad2",
00283                            0., Stop_Y_displaypad[fIO]+smallsep,
00284                            1., 1.);
00285     fSlabPad[2]->SetFillColor(3);
00286     fSlabPad[2]->Draw();
00287  
00288     fSlabPad[3] = new TPad("SlabTofSelPad3","SlabTofSelPad3",
00289                            Stop_X_displaypad[fIO]+sep, Start_Y_displaypad[fIO]+smallsep,
00290                            1.,                         Stop_Y_displaypad[fIO]-smallsep);
00291     fSlabPad[3]->SetFillColor(3);
00292     fSlabPad[3]->Draw();
00293 
00294     fSlabPad[4] = new TPad("SlabTofSelPad4","SlabTofSelPad4",
00295                            0., 0.,
00296                            1., Start_Y_displaypad[fIO]-smallsep);
00297     fSlabPad[4]->SetFillColor(3);
00298     fSlabPad[4]->Draw();
00299     break;
00300   default: break;
00301   }
00302 
00303   DrawButtons();
00304   BuildConnections();
00305   return kTRUE;
00306 }
00307 
00308 //_____________________________________
00309 void TFndTofMonFrame::DrawButtons() {
00310 
00311   Int_t ButtonsPerPad = 18;
00312   Float_t butstep = 0.0001;
00313   //  fMainCanvas[fIO]->cd();
00314   Float_t step = 1./9.;
00315   Float_t xi = 0.;
00316   Float_t yi = 0.;
00317   Float_t xo = 0.;
00318   Float_t yo = 0.;
00319   Float_t xf = 0; // tofino All only
00320 
00321   TString command = TString();
00322   TString modlab = TString();
00323   
00324   switch(fIO){
00325   case 0: // tofino
00326     //    cout << "...building buttons for TOFINO..." << endl;
00327     // AllPad (tofino only)
00328     fAllPad[fIO]->cd();
00329     xf = 0;
00330     xf = step;
00331     fAllButton[0] = new TButton("Maps","fndrun->TofMonFrame()->DisplayMaps();",xi,0.,xf,1.);
00332     fAllButton[0]->Draw();
00333     xi = xf;
00334     xf += step;
00335     fAllButton[1] = new TButton("eff","fndrun->TofMonFrame()->DisplayAllHist(0,10);",xi,0.,xf,1.);
00336     fAllButton[1]->Draw();
00337     xi = xf;
00338     xf += step;
00339     fAllButton[2] = new TButton("adc_tdc","fndrun->TofMonFrame()->DisplayAllHist(0,11);",xi,0.,xf,1.);
00340     fAllButton[2]->Draw();
00341     xi = xf;
00342     xf += step;
00343     fAllButton[3] = new TButton("adcs","fndrun->TofMonFrame()->DisplayAllHist(0,0);",xi,0.,xf,1.);
00344     fAllButton[3]->Draw();
00345     xi = xf;
00346     xf += step;
00347     fAllButton[4] = new TButton("light","fndrun->TofMonFrame()->DisplayAllHist(0,3);",xi,0.,xf,1.);
00348     fAllButton[4]->Draw();
00349     xi = xf;
00350     xf += step;
00351     fAllButton[5] = new TButton("zet","fndrun->TofMonFrame()->DisplayAllHist(0,4);",xi,0.,xf,1.);
00352     fAllButton[5]->Draw();
00353     xi = xf;
00354     xf += step;
00355     fAllButton[6] = new TButton("tdcs","fndrun->TofMonFrame()->DisplayAllHist(0,5);",xi,0.,xf,1.);
00356     fAllButton[6]->Draw();
00357     xi = xf;
00358     xf += step;
00359     fAllButton[7] = new TButton("tmn","fndrun->TofMonFrame()->DisplayAllHist(0,8);",xi,0.,xf,1.);
00360     fAllButton[7]->Draw();
00361     xi = xf;
00362     xf += step;
00363     fAllButton[8] = new TButton("tdf","fndrun->TofMonFrame()->DisplayAllHist(0,9);",xi,0.,xf,1.);
00364     fAllButton[8]->Draw();
00365     fAllPad[fIO]->Modified();
00366 
00367     // SlabPad
00368     fSlabPad[0]->cd();
00369     for(Int_t i=0;i<fNSlabs[fIO];i++) {
00370       // n = i+1;
00371       modlab = "sl_";
00372       modlab+=i+1;
00373       command = "fndrun->TofMonFrame()->SelectSlab(";
00374       command+=i+1;
00375       command+="); ";
00376       command+="fndrun->TofMonFrame()->DisplayHist();";
00377       
00378       xi = 0.;
00379       yi = ((Float_t) i)/fNSlabs[fIO];
00380       xo = 1.;
00381       yo = (i+1.)/fNSlabs[fIO];
00382       fSlabButton[i] = new TButton(modlab.Data(),command.Data(),xi,yi,xo,yo);
00383       fSlabButton[i]->SetTextSize(0.5);
00384       fSlabButton[i]->Draw();
00385       
00386     }
00387     fSlabPad[0]->Modified();
00388     break;
00389     
00390   case 1: // tofone
00391     //    cout << "...building buttons for TOFONE..." << endl;
00392     
00393     step = 1./(Float_t)ButtonsPerPad;
00394     for(Int_t p=1;p<=4;p++) {
00395       fSlabPad[p]->cd();
00396       // --- initialize buttons placement
00397       switch(p){
00398       case 1:
00399         xi = 0;  yi = 0;
00400         xo = 1.; yo = step - butstep;
00401         break;
00402       case 2:
00403         xi = 0;    yi = 0;
00404         xo = step; yo = 1.;
00405         break;
00406       case 3:
00407         xi = 0;  yi = 1. - step;
00408         xo = 1.; yo = 1.;
00409         break;
00410       case 4:
00411         xi = 1. -step; yi = 0;
00412         xo = 1.;       yo = 1.;
00413         break;
00414       default: break;
00415       }
00416       // --- buttons placement initialized
00417 
00418       // --- Building buttons
00419       for(Int_t i=0;i<ButtonsPerPad;i++) {
00420         //      cout << "p: " << p << " --- i: " << i << endl; 
00421         Int_t nsl = i + fNSlabs[0] + (ButtonsPerPad * (p-1)) +1;
00422         Int_t but_id = nsl - 1;
00423         if(nsl>(fNSlabs[0]+fNSlabs[1])) Error("DrawButtons","\"nsl\" too big!!!");
00424         modlab = "sl_";
00425         modlab+= nsl-fNSlabs[0];
00426         command = "fndrun->TofMonFrame()->SelectSlab(";
00427         command+=nsl;
00428         command+="); ";
00429         command+="fndrun->TofMonFrame()->DisplayHist();";
00430         // ---
00431         fSlabButton[but_id] = new TButton(modlab.Data(),command.Data(),xi,yi,xo,yo);
00432         fSlabButton[but_id]->SetTextSize(0.5);
00433         fSlabButton[but_id]->Draw();
00434         // --- next button placement
00435         switch(p){
00436         case 1:
00437           xi = 0;  yi = yo + butstep;
00438           xo = 1.; yo += step - butstep;
00439           break;
00440         case 2:
00441           xi = xo + butstep;    yi = 0;
00442           xo += step - butstep; yo = 1.;
00443           break;
00444         case 3:
00445           xi = 0;  yo = yi - butstep;
00446           xo = 1.; yi -= step - butstep;
00447           break;
00448         case 4:
00449           xo = xi -butstep;     yi = 0;
00450           xi -= step - butstep; yo = 1.;
00451           break;
00452         default: break;
00453         }
00454         // ---
00455       }
00456       fSlabPad[p]->Modified();    
00457     }
00458     break; // ending tofone buttons
00459     
00460   default: break;
00461   }
00462   
00463   ResetFrameColors();
00464 }
00465 
00466 //_____________________________________
00467 void TFndTofMonFrame::ResetFrameColors(){
00468   
00469   Int_t SlabButCol[2];
00470   SlabButCol[0] = 33; // tofino slab buttons
00471   SlabButCol[1] = 38; // tofone slab buttons
00472   Int_t AllButCols[9] = {25,25,22,22,28,28,22,22,28}; // tofino "all" buttons
00473 
00474   switch(fIO){
00475   case 0: // tofino
00476     for(Int_t i=0;i<9;i++){
00477       fAllButton[i]->SetFillColor(AllButCols[i]);
00478       fAllButton[i]->Modified();
00479     }
00480     for(Int_t i=0;i<fNSlabs[fIO];i++){
00481       fSlabButton[i]->SetFillColor(SlabButCol[fIO]);
00482       fSlabButton[i]->Modified();
00483     }
00484     break;
00485   case 1:
00486     for(Int_t i=0;i<fNSlabs[1];i++){
00487       fSlabButton[fNSlabs[0]+i]->SetFillColor(SlabButCol[fIO]);
00488       fSlabButton[fNSlabs[0]+i]->Modified();
00489     }
00490     break;
00491   default: break;
00492   }
00493 }
00494 
00495 //_____________________________________
00496 void TFndTofMonFrame::SelectSlab(Int_t s){ 
00497   if(s<0 || s>(fNSlabs[0]+fNSlabs[1])) { Warning("SelectSlab","Wrong Slab Number: %d",s); return; } 
00498   fIO = 0; 
00499   fCurSlab = s;
00500   if(s>fNSlabs[0]) { fIO = 1; fCurSlab = s+88; } 
00501 }
00502 
00503 //_____________________________________
00504 void TFndTofMonFrame::DrawHist(Int_t opt, Int_t flg, Char_t *DrawOpt){
00505   
00506   // --- new code (D. Faso - November 2005)
00507   TString type = 0;
00508   //  cout << "option = " << opt << endl;
00509   switch(opt){
00510   case  0: type = "adc"; break;
00511   case  1: type = "adcp"; break;
00512   case  2: type = "adce"; break;
00513   case  3: type = "crg"; break;
00514   case  4: type = "zet"; break;
00515   case  5: type = "tdc"; break;
00516   case  6: type = "tdcp"; break;
00517   case  7: type = "tdce"; break;
00518   case  8: type = "tmn"; break;
00519   case  9: type = "tdf"; break;
00520   case 10: type = "mapadctdc"; break;
00521   case 11: type = "adc_tdc"; break;
00522   case 12: type = "tmn_hw"; break;
00523   default: if(fndrun->GetDebug()) Warning("DrawHist","wrong option"); return;
00524   }
00525 
00526   h2 = NULL;
00527   hists = NULL;
00528 
00529   TString label = TString("tof_"); label+=type.Data(); label+="_"; label+=fCurSlab;
00530   switch(opt){
00531   case 0:
00532     if(fIsOnline) h2 =(TH2F*) fAdcMapFile->Get(label.Data());
00533     else          h2 =(TH2F*) fRF->Get(label.Data());
00534     break;
00535   case 1:
00536     if(fIsOnline) hists =(TH1F*) fAdcMapFile->Get(label.Data());
00537     else          hists =(TH1F*) fRF->Get(label.Data());   
00538     break;
00539   case 2:
00540     if(fIsOnline) hists =(TH1F*) fAdcMapFile->Get(label.Data());
00541     else          hists =(TH1F*) fRF->Get(label.Data());   
00542     break;
00543   case 3:
00544     if(fIsOnline) hists =(TH1F*) fAdcMapFile->Get(label.Data());
00545     else          hists =(TH1F*) fRF->Get(label.Data());   
00546     break;
00547   case 4:
00548     if(fIsOnline) hists =(TH1F*) fAdcMapFile->Get(label.Data());
00549     else          hists =(TH1F*) fRF->Get(label.Data());   
00550     break;
00551   case 5:
00552     if(fIsOnline) h2 =(TH2F*) fTdcMapFile->Get(label.Data());
00553     else          h2 =(TH2F*) fRF->Get(label.Data());
00554     break;
00555   case 6:
00556     if(fIsOnline) hists =(TH1F*) fTdcMapFile->Get(label.Data());
00557     else          hists =(TH1F*) fRF->Get(label.Data());
00558     break;
00559   case 7:
00560     if(fIsOnline) hists =(TH1F*) fTdcMapFile->Get(label.Data());
00561     else          hists =(TH1F*) fRF->Get(label.Data());
00562     break;
00563   case 8:
00564     if(fIsOnline) hists =(TH1F*) fTdcMapFile->Get(label.Data());
00565     else          hists =(TH1F*) fRF->Get(label.Data());
00566     break;
00567   case 9:
00568     if(fIsOnline) hists =(TH1F*) fTdcMapFile->Get(label.Data());
00569     else          hists =(TH1F*) fRF->Get(label.Data());
00570     break;
00571   case 10:
00572     if(fIsOnline) h2 =(TH2F*) fGenMapFile->Get(label.Data());
00573     else          h2 =(TH2F*) fRF->Get(label.Data());
00574     break;
00575   case 11:
00576     if(fIsOnline) h2 =(TH2F*) fGenMapFile->Get(label.Data());
00577     else          h2 =(TH2F*) fRF->Get(label.Data());
00578     break;
00579   case 12:
00580     if(fIsOnline) hists =(TH1F*) fTdcMapFile ->Get(label.Data());
00581     else          hists =(TH1F*) fRF->Get(label.Data());
00582     break;
00583   default: if(fndrun->GetDebug()) Warning("DrawHist","wrong option"); return;
00584   }
00585 
00586   if(h2) h2->Draw(DrawOpt);
00587   if(hists) {
00588     if(flg) 
00589       hists->Draw("SAME");
00590     else
00591       hists->Draw(DrawOpt);
00592   }
00593 
00594 }
00595   
00596 //_____________________________________
00597 void TFndTofMonFrame::DisplayMaps(){
00598 
00599   if(!ReloadMapFiles()){
00600     for(Int_t i=0;i<2;i++){
00601       fDisplayPad[i]->Clear();
00602       fDisplayPad[i]->Modified();
00603     }
00604     Warning("TFndTofMonFrame::DisplayMaps","Problems while reloading shared memories");
00605     return;
00606   }
00607 
00608   Char_t *Draw2D_opt = "colz";
00609   Int_t EachPadCol = 18;
00610   Float_t Margin = 0.002;
00611 
00612   //  fMainCanvas[0]->cd();
00613   
00614   fDisplayPad[0]->Clear();
00615   fDisplayPad[0]->Divide(4,2,Margin,Margin,EachPadCol);
00616   
00617   for(Int_t j=0;j<8;j++) {
00618     TString str = TString("tof_");
00619     if(j==0) str+="i_o_mult";
00620     if(j!=0) str+="map";
00621     if(j>=1 && j<4) str+="adc";
00622     if(j==4) str+="mt";
00623     if(j>4) str+="tdc";
00624     if(j==2 || j==6) str+="p";
00625     if(j==3 || j==7) str+="e";
00626     fDisplayPad[0]->cd(j+1);
00627     h2 = 0;
00628     hists = 0;
00629     if(j==0) {
00630       Draw2D_opt = "box";
00631       if(fRF)
00632         h2 = (TH2F *) fRF->Get(str.Data());
00633       else
00634         h2 = (TH2F *) fGenMapFile->Get(str.Data());
00635     } 
00636     else {
00637       Draw2D_opt = "";
00638       if(fRF)
00639         hists = (TH1F *) fRF->Get(str.Data());
00640       else
00641         hists = (TH1F *) fGenMapFile->Get(str.Data());
00642     }
00643     if(h2) h2->Draw(Draw2D_opt);
00644     if(hists) hists->Draw(Draw2D_opt);
00645   }    
00646   fDisplayPad[0]->Modified();
00647 
00648   ResetFrameColors();
00649   HighlightButtons(1,0);
00650 }
00651 
00652 //_____________________________________
00653 void TFndTofMonFrame::DisplayHist(){
00654 
00655   if(!ReloadMapFiles()){
00656     for(Int_t i=0;i<2;i++){
00657       fDisplayPad[i]->Clear();
00658       fDisplayPad[i]->Modified();
00659     }
00660     Warning("TFndTofMonFrame::DisplayHist","Problems while reloading shared memories");
00661     return;
00662   }
00663   Char_t *Draw2D_opt = "";
00664   Int_t EachPadCol = 17;
00665   Float_t Margin = 0.002;
00666 
00667   
00668   fDisplayPad[fIO]->Clear();
00669   fDisplayPad[fIO]->Divide(4,3,Margin,Margin,EachPadCol);
00670 
00671   
00672   Int_t opt = -1;
00673   for(Int_t j=0;j<12;j++){
00674     fDisplayPad[fIO]->cd(j+1);
00675     opt++;
00676     if(j==8) Draw2D_opt = "colz";
00677     else Draw2D_opt = "";
00678     DrawHist(opt,0,Draw2D_opt);
00679     if(j==1 || j==5) DrawHist(++opt,1);
00680   }
00681   fDisplayPad[fIO]->Modified();
00682 
00683   ResetFrameColors();
00684   HighlightButtons(0);
00685 }    
00686 
00687 //_____________________________________
00688 void TFndTofMonFrame::DisplayAllHist(Int_t io, Int_t option){
00689 
00690   if(!ReloadMapFiles()){
00691     for(Int_t i=0;i<2;i++){
00692       fDisplayPad[i]->Clear();
00693       fDisplayPad[i]->Modified();
00694     }
00695     Warning("TFndTofMonFrame::DisplayAllHist","Problems while reloading shared memories");
00696     return;
00697   }
00698   Char_t *Draw2D_opt = 0;
00699   if(option==10) Draw2D_opt = "colz"; // eff
00700   else Draw2D_opt = "";
00701 
00702   Int_t EachPadCol = 19;
00703   Float_t Margin = 0.002;
00704 
00705   fDisplayPad[0]->Clear();
00706   fDisplayPad[0]->Divide(4,3,Margin,Margin,EachPadCol);
00707 
00708 
00709   fIO = io;
00710   //fCurSlab = 0;
00711   for(Int_t k=0;k<12;k++){
00712     fDisplayPad[0]->cd(k+1);
00713     fCurSlab = k+1;
00714     DrawHist(option,0,Draw2D_opt);
00715   }
00716   fDisplayPad[0]->Modified();
00717 
00718   ResetFrameColors();
00719   Int_t all_id = 0;
00720   switch(option){
00721   case 10: all_id = 1; break;
00722   case 11: all_id = 2; break;
00723   case 0:  all_id = 3; break;
00724   case 3:  all_id = 4; break;
00725   case 4:  all_id = 5; break;
00726   case 5:  all_id = 6; break;
00727   case 8:  all_id = 7; break;
00728   case 9:  all_id = 8; break;
00729   default: break;
00730   }
00731   HighlightButtons(1,all_id);
00732 }
00733 
00734 //____________________________________________________
00735 TButton *TFndTofMonFrame::HighlightButtons(Int_t which_group,Int_t All_id){
00736   // Highlight active buttons (considering the selected detector (tofino/tofone))
00737   //  - which_group==0 : fSlabButton buttons highlighted
00738   //  - which_group==1 : fAllButtons buttons highlighted
00739   //  - All_id : index for the all_button
00740 
00741   // --- remember the last clicked button
00742   fWhichGroup = which_group;
00743   fAllId = All_id;
00744 
00745   Int_t sl = fCurSlab;
00746   if(sl > fNSlabs[0]) sl -= 88; 
00747   //  cout << "fCurSlab: " << fCurSlab << endl;
00748   
00749   switch(which_group){
00750   case 0:
00751     fSlabButton[sl-1]->SetFillColor(fHighlightCol[fIO]);
00752     fSlabButton[sl-1]->Modified();
00753     return fSlabButton[sl-1];
00754     //     break;
00755   case 1:
00756     fAllButton[All_id]->SetFillColor(fHighlightCol[fIO]); 
00757     fAllButton[All_id]->Modified();
00758     return fAllButton[All_id];
00759     //break;
00760   default: return 0;
00761   } 
00762 }
00763 
00764 //___________________________________________
00765 void TFndTofMonFrame::RefreshSingleMonView(){
00766 
00767   if(fndrun->GetDebug()){
00768     Printf("");
00769     Printf("fWhichGroup: %d",fWhichGroup);
00770     Printf("fCurSlab: %d",fCurSlab);
00771     Printf("fAllId: %d",fAllId);
00772     Printf("fIO: %d",fIO);
00773   }
00774 
00775   if(fWhichGroup ==- 1 || fAllId == - 1) return;
00776 
00777   if(fCurSlab > fNSlabs[0]) FlashDisplayPad(1); // flash tofone
00778   else FlashDisplayPad(0); // flash tofino
00779 
00780   HighlightButtons(fWhichGroup,fAllId)->ExecuteEvent(11,0,0);
00781 }
00782 
00783 //_____________________________________
00784 // void TFndTofMonFrame::CheckHistos() 
00785 // { 
00786 //   Bool_t kReload = CheckEntries();
00787 //   if(kReload) ReloadMapFiles();
00788 //   CheckIOMult();
00789 //   CheckAdcTdcMaps();
00790 //   CheckMTPattern();
00791 //   CheckHWMT();
00792 //   CheckSWMT();
00793 // }
00794 
00795 //_____________________________________
00796 // Bool_t TFndTofMonFrame::CheckEntries() 
00797 // { 
00798 //   Bool_t kReload = kFALSE;
00799 //   TH2F *i_o_mult = (TH2F *) fGenMapFile->Get("tof_i_o_mult");
00800 //   Int_t fEntries = (Int_t) i_o_mult->GetEntries();
00801 //   time_t now;
00802 //   now = time(&now);
00803 //   Int_t timeInterval = now - fTime;
00804 //   fTime = now;
00805 //   Int_t tUpdate = 60;
00806 //   if(timeInterval > tUpdate && fEntries == fSHMEntries) {
00807 //     cout << "Number of Entries did not change for the last " << tUpdate << " seconds: reload TOF Shared memories" << endl;
00808 //     kReload = kTRUE;
00809 //   }
00810 //   return kReload;
00811 // }
00812 
00813 //_____________________________________
00814 // void TFndTofMonFrame::CheckIOMult() 
00815 // { 
00816 //   /*
00817 //     Bool_t isCosmic = fndrun->Hdt()->Trig()->Cosmic();
00818 //     if(isCosmic) cout << "Cosmic ray trigger on" << endl;
00819 //   */
00820 //   TString s2("tof_i_o_mult");
00821 //   cout << "check tof_i_o_mult" << endl;
00822 //   TH2F *i_o_mult = (TH2F *) fGenMapFile->Get(s2.Data());
00823 //   Bool_t doCheck = kFALSE;
00824 
00825 //   /*
00826 //     Int_t nx = i_o_mult->GetNbinsX();
00827 //     Int_t ny = i_o_mult->GetNbinsY();
00828 //     for(Int_t i=0; i<nx; i++) {
00829 //     for(Int_t j=0; j<ny; j++) {
00830 //     Double_t nEntries = i_o_mult->GetBinContent(i+1,j+1);
00831 //     // FIXME
00832 //     if(nEntries > 0 && i >= 10) doCheck = kTRUE;
00833 //     if(nEntries > 0 && j >= 10) doCheck = kTRUE;
00834 //     }
00835 //     }
00836 //   */
00837 //   doCheck = kTRUE; // check by default
00838 
00839 //   TFndMonCheckFrame *a =0;
00840 //   Bool_t isThere = kFALSE;
00841 //   Int_t nH = fCheckedHistos->GetEntriesFast();
00842 //   //  cout << nH << " entries in objarray" << endl;
00843 //   for(Int_t i=0; i<nH; i++) {
00844 //     TString curName = ((TFndMonCheckFrame *) fCheckedHistos->At(i))->GetHName();    
00845 //     if(!curName.CompareTo(s2)) {
00846 //       isThere = kTRUE;
00847 //       a = ((TFndMonCheckFrame *) fCheckedHistos->At(i));
00848 //       if(!doCheck) {
00849 //      cout << "Remove: " << curName.Data() << endl;
00850 //      TFndMonCheckFrame *b = (TFndMonCheckFrame *) fCheckedHistos->Remove(a);
00851 //      fCheckedHistos->Compress();
00852 //      /*
00853 //        cout << "delete a " << endl;
00854 //        delete a;
00855 //        cout << "delete b " << endl;
00856 //        delete b;
00857 //      */
00858 //       }
00859 //       break;
00860 //     }   
00861 //   }
00862 //   if(doCheck && isThere == kFALSE) {
00863 //     cout << "Add " << s2.Data() << " to objarray" << endl;
00864 //     a = new TFndMonCheckFrame(fGenMapFile,s2,2,gClient->GetRoot());
00865 //     fCheckedHistos->Add(a);
00866 //   }
00867 //   delete i_o_mult;
00868 // }
00869 
00870 //_____________________________________
00871 // void TFndTofMonFrame::CheckMTPattern() 
00872 // { 
00873 //   /*
00874 //     Bool_t isCosmic = fndrun->Hdt()->Trig()->Cosmic();
00875 //     if(isCosmic) cout << "Cosmic ray trigger on" << endl;
00876 //   */
00877 //   cout << "check mean timer pattern" << endl;
00878 //   TString s2("tof_mapmt");
00879 //   TH1F *mtPattern = (TH1F *) fGenMapFile->Get(s2.Data());
00880 //   Bool_t doCheck = kFALSE;
00881 //   Int_t nx = mtPattern->GetNbinsX();
00882 
00883 //   Double_t nEntries[nx];
00884 //   Double_t mttofAverage = 0.;
00885 //   Double_t mttofSigma = 0.;
00886 //   Double_t mtTofAverage = 0.;
00887 //   Double_t mtTofSigma = 0.;
00888 //   for(Int_t i=0; i<nx; i++) {
00889 //     nEntries[i] = mtPattern->GetBinContent(i+1);
00890 //     if(i<100) {
00891 //       mttofAverage += nEntries[i];
00892 //       mttofSigma += nEntries[i]*nEntries[i];
00893 //     } else {
00894 //       mtTofAverage += nEntries[i];
00895 //       mtTofSigma += nEntries[i]*nEntries[i];
00896 //     }
00897 //   }
00898 //   mttofAverage /= nx;
00899 //   mttofSigma /= nx;
00900 //   mttofSigma = TMath::Sqrt(mttofSigma);
00901 //   mtTofAverage /= nx;
00902 //   mtTofSigma /= nx;
00903 //   mtTofSigma = TMath::Sqrt(mtTofSigma);
00904 //   cout << "tof: average " << mttofAverage << ", sigma: " << mttofSigma << endl;
00905 //   cout << "TOF: average " << mtTofAverage << ", sigma: " << mtTofSigma << endl;
00906 //   for(Int_t i=0; i<nx; i++) {
00907 //     if(i<100 && mttofAverage > 100 && (nEntries[i] < mttofAverage-3*mttofSigma || nEntries[i] > mttofAverage+3*mttofSigma)) {
00908 //       doCheck = kTRUE;
00909 //       cout << "Warning: mean timer counts for tof slab: " << i+1 << " out of range" << endl;
00910 //     }
00911 //     if(i>=100 && mtTofAverage > 100 && (nEntries[i] < mtTofAverage-3*mtTofSigma || nEntries[i] > mtTofAverage+3*mtTofSigma)) {
00912 //       doCheck = kTRUE;
00913 //       cout << "Warning: mean timer counts for TOF slab: " << i+1 << " out of range" << endl;
00914 //     }
00915 //   }
00916 
00917 //   TFndMonCheckFrame *a =0;
00918 //   Bool_t isThere = kFALSE;
00919 //   Int_t nH = fCheckedHistos->GetEntriesFast();
00920 //   for(Int_t i=0; i<nH; i++) {
00921 //     TString curName = ((TFndMonCheckFrame *) fCheckedHistos->At(i))->GetHName();    
00922 //     if(!curName.CompareTo(s2)) {
00923 //       isThere = kTRUE;
00924 //       a = ((TFndMonCheckFrame *) fCheckedHistos->At(i));
00925 //       if(!doCheck) {
00926 //      cout << "Remove: " << curName.Data() << endl;
00927 //      fCheckedHistos->Remove(a);
00928 //      fCheckedHistos->Compress();
00929 //       }
00930 //       break;
00931 //     }   
00932 //   }
00933 //   if(doCheck && isThere == kFALSE) {
00934 //     cout << "Add " << s2.Data() << " to objarray" << endl;
00935 //     a = new TFndMonCheckFrame(fGenMapFile,s2,1,gClient->GetRoot());
00936 //     fCheckedHistos->Add(a);
00937 //   }
00938 //   delete mtPattern;
00939 // }
00940 
00941 //_____________________________________
00942 // void TFndTofMonFrame::CheckHWMT() 
00943 // { 
00944 //   /*
00945 //     Bool_t isCosmic = fndrun->Hdt()->Trig()->Cosmic();
00946 //     if(isCosmic) cout << "Cosmic ray trigger on" << endl;
00947 //   */
00948 //   cout << "check HW mean timer" << endl;
00949 
00950 //   // mean timer HW
00951 //   for(Int_t idet=0;idet<2;idet++) {
00952 //     Int_t ntslab = 12 + 60*idet;
00953 //     Bool_t tofMT[ntslab]; 
00954 //     Bool_t isTMNThere[ntslab];
00955 //     for(Int_t itsl=0; itsl<ntslab; itsl++) {
00956 //       TString hname("tof_tmn_hw_");
00957 //       char slab[3];
00958 //       sprintf(slab,"%d",100*idet+itsl+1);
00959 //       hname.Append(slab);
00960 //       TH1F *hwMT = (TH1F *) fTdcMapFile->Get(hname.Data());
00961 //       tofMT[itsl] = kFALSE;
00962 //       Int_t nx = hwMT->GetNbinsX();
00963 //       Double_t maxi = 0.;
00964 //       Double_t tmaxi = 0.;
00965 //       for(Int_t nb=0; nb<nx; nb++) {
00966 //      Double_t lowEdge = hwMT->GetBinLowEdge(nb+1);
00967 //      Double_t width = hwMT->GetBinWidth(nb+1);
00968 //      Int_t content = (Int_t) hwMT->GetBinContent(nb+1);
00969 //      if(content > maxi) {
00970 //        tmaxi = lowEdge;
00971 //        maxi = content;
00972 //      }
00973 //       }
00974 //       if(tmaxi != 0 && (tmaxi < 2200 || tmaxi > 3300 )) {
00975 //      tofMT[itsl] = kTRUE;
00976 //      cout << "bad HW mean timer for slab: " << 100*idet+itsl+1 << " at t = " << tmaxi << endl;
00977 //       }
00978 
00979 //       TFndMonCheckFrame *a =0;
00980 //       isTMNThere[itsl] = kFALSE;
00981 //       Int_t nH = fCheckedHistos->GetEntriesFast();
00982 //       for(Int_t i=0; i<nH; i++) {
00983 //      TString curName = ((TFndMonCheckFrame *) fCheckedHistos->At(i))->GetHName();
00984 //      if(!curName.CompareTo(hname)) {
00985 //        isTMNThere[itsl] = kTRUE;       
00986 //        a = ((TFndMonCheckFrame *) fCheckedHistos->At(i));
00987 //        if(!tofMT[itsl]) {
00988 //          cout << "Remove: " << curName.Data() << endl;
00989 //          fCheckedHistos->Remove(a);
00990 //          fCheckedHistos->Compress();
00991 //        }
00992 //        break;
00993 //      }   
00994 //       }
00995 //       if(tofMT[itsl] && isTMNThere[itsl] == kFALSE) {
00996 //      cout << "Add " << hname.Data() << " to objarray" << endl;
00997 //      a = new TFndMonCheckFrame(fTdcMapFile,hname,1,gClient->GetRoot());
00998 //      fCheckedHistos->Add(a);
00999 //       }
01000 //       delete hwMT;
01001 //     }
01002 //   }
01003 // }
01004 
01005 //_____________________________________
01006 // void TFndTofMonFrame::CheckSWMT() 
01007 // { 
01008 //   /*
01009 //     Bool_t isCosmic = fndrun->Hdt()->Trig()->Cosmic();
01010 //     if(isCosmic) cout << "Cosmic ray trigger on" << endl;
01011 //   */
01012 //   cout << "check SW mean timer" << endl;
01013 //   for(Int_t idet=0;idet<2;idet++) {
01014 //     Int_t ntslab = 12 + 60*idet;
01015 //     Bool_t tofMT[ntslab]; 
01016 //     Bool_t isTMNThere[ntslab];
01017 //     for(Int_t itsl=0; itsl<ntslab; itsl++) {
01018 //       TString hname("tof_tmn_");
01019 //       char slab[3];
01020 //       sprintf(slab,"%d",100*idet+itsl+1);
01021 //       hname.Append(slab);
01022 //       TH1F *swMT = (TH1F *) fTdcMapFile->Get(hname.Data());
01023 //       tofMT[itsl] = kFALSE;
01024 //       Int_t nx = swMT->GetNbinsX();
01025 //       Double_t maxi = 0.;
01026 //       Double_t tmaxi = 0.;
01027 //       for(Int_t nb=0; nb<nx; nb++) {
01028 //      Double_t lowEdge = swMT->GetBinLowEdge(nb+1);
01029 //      Double_t width = swMT->GetBinWidth(nb+1);
01030 //      Int_t content = (Int_t) swMT->GetBinContent(nb+1);
01031 //      if(content > maxi) {
01032 //        tmaxi = lowEdge;
01033 //        maxi = content;
01034 //      }
01035 //       }
01036 //       if(tmaxi != 0 && (tmaxi < 2400 || tmaxi > 3100 )) {
01037 //      tofMT[itsl] = kTRUE;
01038 //      cout << "bad SW mean timer for slab: " << 100*idet+itsl+1 << " at t = " << tmaxi << endl;
01039 //       }
01040 
01041 //       TFndMonCheckFrame *a =0;
01042 //       isTMNThere[itsl] = kFALSE;
01043 //       Int_t nH = fCheckedHistos->GetEntriesFast();
01044 //       for(Int_t i=0; i<nH; i++) {
01045 //      TString curName = ((TFndMonCheckFrame *) fCheckedHistos->At(i))->GetHName();
01046 //      if(!curName.CompareTo(hname)) {
01047 //        isTMNThere[itsl] = kTRUE;
01048 //        a = ((TFndMonCheckFrame *) fCheckedHistos->At(i));
01049 //        if(!tofMT[itsl]) {
01050 //          cout << "Remove: " << curName.Data() << endl;
01051 //          fCheckedHistos->Remove(a);
01052 //          fCheckedHistos->Compress();
01053 //        }
01054 //        break;
01055 //      }
01056 //       }   
01057 //       if(tofMT[itsl] && isTMNThere[itsl] == kFALSE) {
01058 //      cout << "Add " << hname.Data() << " to objarray" << endl;
01059 //      a = new TFndMonCheckFrame(fTdcMapFile,hname,1,gClient->GetRoot());
01060 //      fCheckedHistos->Add(a);
01061 //       }
01062 //       delete swMT;
01063 //     }
01064 //   }
01065 // }
01066 
01067 //_____________________________________
01068 // void TFndTofMonFrame::CheckAdcTdcMaps() 
01069 // { 
01070 //   /*
01071 //     Bool_t isCosmic = fndrun->Hdt()->Trig()->Cosmic();
01072 //     if(isCosmic) cout << "Cosmic ray trigger on" << endl;
01073 //   */
01074 
01075 //   cout << "check Adc vs Tdc maps" << endl;
01076 //   Float_t ScalingFactor = 0.2;
01077 //   for(Int_t idet=0;idet<2;idet++) {
01078 //     Int_t ntslab = 12 + 60*idet;
01079 //     Bool_t tofAdcTdcMap[ntslab]; 
01080 //     Bool_t isMapThere[ntslab];
01081 //     for(Int_t itsl=0; itsl<ntslab; itsl++) {
01082 //       TString hname("tof_mapadctdc_");
01083 //       char slab[3];
01084 //       sprintf(slab,"%d",100*idet+itsl+1);
01085 //       hname.Append(slab);
01086 //       TH2F *mapAT = (TH2F *) fGenMapFile->Get(hname.Data());
01087 //       tofAdcTdcMap[itsl] = kFALSE;
01088 //       Int_t nx = mapAT->GetNbinsX();
01089 //       Int_t ny = mapAT->GetNbinsY();
01090 
01091 //       Int_t content[nx*ny];
01092 //       Float_t maxi = 0;
01093 //       Int_t maxi_x = -1;
01094 //       Int_t maxi_y = -1;
01095 //       for(Int_t nbx=0; nbx<nx; nbx++) {
01096 //      for(Int_t nby=0; nby<ny; nby++) {
01097 //        Int_t idx = nbx*ny+nby;
01098 //        content[idx] = (Int_t) mapAT->GetBinContent(nbx+1,nby+1);
01099 //        if(idet == 0 && idx == 3) content[idx] = 0; // FIXME
01100 //        if(content[idx] > maxi) {
01101 //          maxi_x = nbx;
01102 //          maxi_y = nby;
01103 //          maxi = content[idx];
01104 //        } 
01105 //      }
01106 //       }
01107 //       if(maxi_x*maxi_y != 9) {
01108 //      cout << "slab " << 100*idet+itsl+1 << ", maximum in wrong place: " << maxi_x << "," << maxi_y << endl;
01109 //      tofAdcTdcMap[itsl] = kTRUE;
01110 //       }
01111 //       for(Int_t nbx=0; nbx<nx; nbx++) {
01112 //      for(Int_t nby=0; nby<ny; nby++) {
01113 //        Int_t idx = nbx*ny+nby;
01114 //        if(content[idx] > ScalingFactor*maxi && maxi_x != nbx && maxi_y != nby) {
01115 //          tofAdcTdcMap[itsl] = kTRUE;
01116 //          cout << "slab " << 100*idet+itsl+1 << ", maximum in wrong place, idx: " << idx << "," << maxi_x << "," << maxi_y << endl;
01117 //        } 
01118 //      }      
01119 //       }
01120 //       /*
01121 //      if(content[0] != 0) {
01122 //      tofAdcTdcMap[itsl] = kTRUE;
01123 //      cout << content[0] << " bad Adc & Tdc on both sides for slab: " << itsl+1 << " of detector " << idet+1 << endl;
01124 //      }
01125 //      if(content[1]+content[2] != 0) {
01126 //      tofAdcTdcMap[itsl] = kTRUE;
01127 //      cout << content[1]+content[2] << " bad Tdc(both) & Adc on one side for slab: " << itsl+1 << " of detector " << idet+1 << endl;
01128 //      } 
01129 //      if(content[4]+content[8] != 0) {
01130 //      tofAdcTdcMap[itsl] = kTRUE;
01131 //      cout << content[4]+content[8] << " bad Adc(both) & Tdc on one side for slab: " << itsl+1 << " of detector " << idet+1 << endl;
01132 //      } 
01133 //      if(content[5]+content[6]+content[9]+content[10] != 0) {
01134 //      tofAdcTdcMap[itsl] = kTRUE;
01135 //      cout << content[5]+content[6]+content[9]+content[10] << " bad Adc & Tdc on one side for slab: " << itsl+1 << " of detector " << idet+1 << endl;
01136 //      } 
01137 //      if(content[3] != 0) {
01138 //      tofAdcTdcMap[itsl] = kTRUE;
01139 //      cout << content[3] << " bad Tdc(both) for slab: " << itsl+1 << " of detector " << idet+1 << endl;
01140 //      } 
01141 //      if(content[12] != 0) {
01142 //      tofAdcTdcMap[itsl] = kTRUE;
01143 //      cout << content[12] << " bad Adc(both) for slab: " << itsl+1 << " of detector " << idet+1 << endl;
01144 //      }
01145 //      if(content[7]+content[11] != 0) {
01146 //      tofAdcTdcMap[itsl] = kTRUE;
01147 //      cout << content[7]+content[11] << " bad Tdc on one side for slab: " << itsl+1 << " of detector " << idet+1 << endl;
01148 //      } 
01149 //      if(content[13]+content[14] != 0) {
01150 //      tofAdcTdcMap[itsl] = kTRUE;
01151 //      cout << content[13]+content[14] << " bad Adc on one side for slab: " << itsl+1 << " of detector " << idet+1 << endl;
01152 //      } 
01153 //       */
01154 //       TFndMonCheckFrame *a =0;
01155 //       isMapThere[itsl] = kFALSE;
01156 //       Int_t nH = fCheckedHistos->GetEntriesFast();
01157 //       for(Int_t i=0; i<nH; i++) {
01158 //      TString curName = ((TFndMonCheckFrame *) fCheckedHistos->At(i))->GetHName();
01159 //      if(!curName.CompareTo(hname)) {
01160 //        isMapThere[itsl] = kTRUE;
01161 //        a = ((TFndMonCheckFrame *) fCheckedHistos->At(i));
01162 //        if(!tofAdcTdcMap[itsl]) {
01163 //          cout << "Remove: " << curName.Data() << endl;
01164 //          fCheckedHistos->Remove(a);
01165 //          fCheckedHistos->Compress();
01166 //        }
01167 //        break;
01168 //      }
01169 //       }   
01170 //       if(tofAdcTdcMap[itsl] && isMapThere[itsl] == kFALSE) {
01171 //      cout << "Add " << hname.Data() << " to objarray" << endl;
01172 //      a = new TFndMonCheckFrame(fGenMapFile,hname,2,gClient->GetRoot());
01173 //      fCheckedHistos->Add(a);
01174 //       }
01175 //       delete mapAT;
01176 //     }
01177 //   }
01178 // }
01179 
01180 //_____________________________________
01181 // void TFndTofMonFrame::DrawCheckedHistos() 
01182 // { 
01183 //   static TFndMonCheckFrame *a[1000];
01184 //   if(fNHpres != 0 && fNHpres <= 1000) 
01185 //     for(Int_t i=0; i<fNHpres; i++) 
01186 //       if(a[i]) a[i]->DoClose();  
01187 //   Int_t nH = fCheckedHistos->GetEntriesFast();
01188 //   if(nH > 0) {
01189 //     fNHpres = nH;
01190 //     for(Int_t i=0; i<fNHpres; i++) {
01191 //       a[i] = ((TFndMonCheckFrame *) fCheckedHistos->At(i));
01192 //       a[i]->Create();
01193 //       a[i]->DoDraw();
01194 //     }
01195 //   }
01196 // }

Generated on Tue Oct 16 15:40:48 2007 by  doxygen 1.5.2