SCC/TFndSCCshowHistos.cxx

00001 // @(#)fROOT/SCC:$Name:  $:$Id: TFndSCCshowHistos.cxx,v 1.12 2007/09/24 07:32:41 Diego_Faso Exp $
00002 // Author: Diego Faso <mailto:faso@to.infn.it>, 2007/06/23
00003 
00005 //                                                                             //
00006 //
00007 // OptStat in hostograms
00008 //  The parameter mode can be = iourmen  (default = 0001111)
00009 //    n = 1;  name of histogram is printed
00010 //    e = 1;  number of entries printed
00011 //    m = 1;  mean value printed
00012 //    r = 1;  rms printed
00013 //    u = 1;  number of underflows printed
00014 //    o = 1;  number of overflows printed
00015 //    i = 1;  integral of bins printed
00016 //  Example: gStyle->SetOptStat(11);
00017 //           print only name of histogram and number of entries./
00019 
00020 #include "TFndSCCshowHistos.h"
00021 
00022 ClassImp(TFndSCCshowHistos)
00023 //____________________________
00024 TFndSCCshowHistos::TFndSCCshowHistos():
00025   fHP_Tofi(),fHP_Tofo(),
00026   fHP_Osim(),fHP_Isim(),
00027   fHP_LmdInn(),fHP_LmdOut(),
00028   fHP_Stb()
00029 {
00030   
00031   
00032 }
00033 
00034 //____________________________
00035 TFndSCCshowHistos::~TFndSCCshowHistos(){
00036 
00037   DeleteHistos();  
00038 }
00039 
00040 //____________________________
00041 void TFndSCCshowHistos::DeleteHistos(){
00042   // --- tof
00043   for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00044     for(Int_t sid=0;sid<2;sid++){
00045       for(Int_t ch=0;ch<K_N_TOFONE_SLABS;ch++){
00046         if(ch<K_N_TOFINO_SLABS){
00047           delete fHP_Tofi[mod][sid][ch]; 
00048           fHP_Tofi[mod][sid][ch] = 0; 
00049         }
00050         delete fHP_Tofo[mod][sid][ch]; 
00051         fHP_Tofo[mod][sid][ch] = 0; 
00052       }
00053     }
00054   }
00055   
00056   // --- sil
00057   for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00058     for(Int_t ch=0;ch<K_N_Sil_Modules;ch++){
00059       for(Int_t side=0;side<K_N_Sil_Sides;side++){
00060         for(Int_t sign=0;sign<2;sign++){
00061           delete fHP_Osim[mod][ch][side][sign];
00062           fHP_Osim[mod][ch][side][sign] = 0;      
00063           if( ch < (K_N_Sil_Modules-2) ){
00064             delete fHP_Isim[mod][ch][side][sign]; 
00065             fHP_Isim[mod][ch][side][sign] = 0; 
00066           }
00067         }
00068       }
00069     }
00070   }
00071   
00072   // --- lmd
00073   for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00074     for(Int_t ch=0;ch<K_N_LMD_CHAMS_PER_LAYER;ch++){
00075       for(Int_t sign=0;sign<2;sign++){
00076         delete fHP_LmdInn[mod][ch][sign]; 
00077         fHP_LmdInn[mod][ch][sign] = 0; 
00078         delete fHP_LmdOut[mod][ch][sign]; 
00079         fHP_LmdOut[mod][ch][sign] = 0; 
00080       }
00081     }
00082   }
00083   
00084   // --- stb
00085   for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00086     for(Int_t ch=0;ch<K_SLOW_N_CHANS[STB];ch++){
00087       delete fHP_Stb[mod][ch];
00088       fHP_Stb[mod][ch] = 0;
00089     }
00090   }
00091 }
00092 
00093 //____________________________
00094 void TFndSCCshowHistos::SetFndTimeGraphProperties(TFndGraph *fndgr,const Int_t &mod){
00095   
00096   if(!fndgr) TerminateFroot(0,"TFndSCCshowHistos::SetFndTimeGraphProperties"); 
00097   
00098   Int_t lcols[E_SccHisMod_End]; // lines
00099   Int_t fcols[E_SccHisMod_End]; // fill
00100   Int_t mcols[E_SccHisMod_End]; // markers
00101 
00102 
00103   lcols[E_SccHisMod_Avail] = 4;
00104   lcols[E_SccHisMod_PW]    = 4;
00105   lcols[E_SccHisMod_V]     = 4;
00106   lcols[E_SccHisMod_I]     = 50;
00107   lcols[E_SccHisMod_Trip]  = 2;
00108   lcols[E_SccHisMod_Stat]  = 9;
00109 
00110   fcols[E_SccHisMod_Avail] = 4;
00111   fcols[E_SccHisMod_PW]    = 4;
00112   fcols[E_SccHisMod_V]     = 4;
00113   fcols[E_SccHisMod_I]     = 50;
00114   fcols[E_SccHisMod_Trip]  = 2;
00115   fcols[E_SccHisMod_Stat]  = 9;
00116 
00117   mcols[E_SccHisMod_Avail] = 4;
00118   mcols[E_SccHisMod_PW]    = 4;
00119   mcols[E_SccHisMod_V]     = 4;
00120   mcols[E_SccHisMod_I]     = 50;
00121   mcols[E_SccHisMod_Trip]  = 2;
00122   mcols[E_SccHisMod_Stat]  = 9;
00123   
00124   //
00125   fndgr->SetLineWidth(2);
00126   fndgr->SetMarkerStyle(21);
00127   fndgr->SetMarkerSize(0.6);
00128   //
00129   fndgr->SetLineColor(lcols[mod]);
00130   fndgr->SetFillColor(fcols[mod]);
00131   fndgr->SetMarkerColor(mcols[mod]);
00132 
00133 }
00134 
00135 //____________________________
00136 void TFndSCCshowHistos::InitHistos(){
00137 
00138   gStyle->SetOptStat(0000101);
00139   gStyle->SetStatH(0.03);
00140   
00141   TString hnam = "";
00142   TString htit = "";
00143   TString side_str = "";
00144 
00145   // --- TOFINO
00146   for(Int_t ch=0;ch<K_N_TOFINO_SLABS;ch++){
00147     for(Int_t sid=0;sid<2;sid++){
00148       side_str = ( sid==(Int_t)(E_FIN_SIDE_E) ) ? "E" : "P";
00149       for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00150         hnam.Form("Tofi_%i_%s_%s",ch+1,side_str.Data(),GetHisMod(mod).Data());
00151         htit.Form("Tofi_%i_%s_%s",ch+1,side_str.Data(),GetHisMod(mod).Data());
00152         fHP_Tofi[mod][sid][ch] = new TFndGraph(hnam,htit); 
00153         SetFndTimeGraphProperties(fHP_Tofi[mod][sid][ch], mod);
00154       }
00155     }
00156   }
00157   // --- TOFINO completed
00158   
00159   // --- TOFONE
00160   for(Int_t ch=0;ch<K_N_TOFONE_SLABS;ch++){
00161     for(Int_t sid=0;sid<2;sid++){
00162       side_str = ( sid==(Int_t)(E_FIN_SIDE_E) ) ? "E" : "P";
00163       for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00164         hnam.Form("Tofo_%i_%s_%s",ch+1,side_str.Data(),GetHisMod(mod).Data());  
00165         htit.Form("Tofo_%i_%s_%s",ch+1,side_str.Data(),GetHisMod(mod).Data());
00166         fHP_Tofo[mod][sid][ch] = new TFndGraph(hnam,htit); 
00167         SetFndTimeGraphProperties(fHP_Tofo[mod][sid][ch], mod);
00168       }
00169     }
00170   }
00171   // --- TOFONE completed
00172   
00173   TString sign_str = "";
00174   
00175   // --- SIL
00176   for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00177     for(Int_t ch=0;ch<K_N_Sil_Modules;ch++){
00178       for(Int_t side=0;side<K_N_Sil_Sides;side++){
00179         side_str = SilSide_Name(side);
00180         for(Int_t sign=0;sign<2;sign++){
00181           sign_str = (sign == 0) ? "min" : "plu";
00182           hnam.Form("Osim_%i_%s_%s_%s",ch+1,side_str.Data(),sign_str.Data(),GetHisMod(mod).Data());
00183           htit.Form("Osim_%i_%s_%s_%s",ch+1,side_str.Data(),sign_str.Data(),GetHisMod(mod).Data());
00184           fHP_Osim[mod][ch][side][sign] = new TFndGraph(hnam,htit);
00185           SetFndTimeGraphProperties(fHP_Osim[mod][ch][side][sign], mod);
00186           if( ch < (K_N_Sil_Modules-2) ){
00187             hnam.Replace(0,1,"I");
00188             htit.Replace(0,1,"I");
00189             fHP_Isim[mod][ch][side][sign] = new TFndGraph(hnam,htit);
00190             SetFndTimeGraphProperties(fHP_Isim[mod][ch][side][sign], mod);
00191           }
00192         }
00193       }
00194     }
00195   }
00196   // --- SIL completed
00197   
00198   // --- LMD
00199   sign_str = "";
00200 
00201   for(Int_t ch=0;ch<K_N_LMD_CHAMS_PER_LAYER;ch++){
00202     for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00203       for(Int_t sign=0;sign<2;sign++){
00204         sign_str = (sign == 0) ? "min" : "plu";
00205         hnam.Form("LmdInn_%i_%s_%s",ch+1,sign_str.Data(),GetHisMod(mod).Data());
00206         htit.Form("LmdInn_%i_%s_%s",ch+1,sign_str.Data(),GetHisMod(mod).Data());
00207         fHP_LmdInn[mod][ch][sign] = new TFndGraph(hnam,htit); 
00208         SetFndTimeGraphProperties(fHP_LmdInn[mod][ch][sign], mod);
00209         // ---
00210         hnam.Form("LmdOut_%i_%s_%s",ch+1,sign_str.Data(),GetHisMod(mod).Data());
00211         htit.Form("LmdOut_%i_%s_%s",ch+1,sign_str.Data(),GetHisMod(mod).Data());
00212         fHP_LmdOut[mod][ch][sign] = new TFndGraph(hnam,htit);
00213         SetFndTimeGraphProperties(fHP_LmdOut[mod][ch][sign], mod);
00214       }
00215     }
00216   }
00217   // --- LMD completed
00218 
00219 
00220   // --- STB
00221   for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00222     for(Int_t ch=0;ch<K_SLOW_N_CHANS[STB];ch++){
00223       hnam.Form("Stb_%i_%s",ch+1,GetHisMod(mod).Data());
00224       htit.Form("Stb_%i_%s",ch+1,GetHisMod(mod).Data());
00225       fHP_Stb[mod][ch] = new TFndGraph(hnam,htit);
00226       SetFndTimeGraphProperties(fHP_Stb[mod][ch], mod);
00227     }
00228   }
00229   // --- STB completed
00230 
00231 
00232 }
00233 
00234 //____________________________
00235 void TFndSCCshowHistos::ResetHistos(Bool_t recreate){
00236   
00237   if(recreate){
00238     DeleteHistos();
00239     InitHistos();
00240     return;
00241   }
00242   
00243   //  cout << "Resetting histos" << endl;
00244   
00245   // --- TOFINO
00246   for(Int_t ch=0;ch<K_N_TOFINO_SLABS;ch++){
00247     for(Int_t sid=0;sid<2;sid++){
00248       for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00249         if(!fHP_Tofi[mod][sid][ch]){
00250           Error("ResetHistos","TOFINO plot not found (mod: %d, sid: %d, ch: %d)",mod,sid,ch);
00251           continue;
00252         }
00253         fHP_Tofi[mod][sid][ch]->Reset();
00254       }
00255     }
00256   }
00257   // --- TOFINO completed
00258 
00259   // --- TOFONE
00260   for(Int_t ch=0;ch<K_N_TOFONE_SLABS;ch++){
00261     for(Int_t sid=0;sid<2;sid++){
00262       for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00263         if(!fHP_Tofo[mod][sid][ch]){
00264           Error("ResetHistos","TOFONE plot not found (mod: %d, sid: %d, ch: %d)",mod,sid,ch);
00265           continue;
00266         }
00267         fHP_Tofo[mod][sid][ch]->Reset();
00268       }
00269     }
00270   }
00271   // --- TOFONE completed
00272 
00273   // --- SIL
00274   for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00275     for(Int_t ch=0;ch<K_N_Sil_Modules;ch++){
00276       for(Int_t side=0;side<K_N_Sil_Sides;side++){
00277         for(Int_t sign=0;sign<2;sign++){
00278           if(!fHP_Osim[mod][ch][side][sign] || (ch < (K_N_Sil_Modules-2) && !fHP_Isim[mod][ch][side][sign]) ){
00279             Error("ResetHistos","SIL plot not found (mod: %d, sid: %d, ch: %d, sign: %d)",mod,side,ch,sign);
00280             continue;
00281           }
00282           fHP_Osim[mod][ch][side][sign]->Reset(); 
00283           if( ch < (K_N_Sil_Modules-2) ){
00284             fHP_Isim[mod][ch][side][sign]->Reset(); 
00285           }
00286         }
00287       }
00288     }
00289   }
00290   // --- SIL completed
00291   
00292   // --- LMD
00293   for(Int_t ch=0;ch<K_N_LMD_CHAMS_PER_LAYER;ch++){
00294       for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00295         for(Int_t sign=0;sign<2;sign++){
00296           if(!fHP_LmdInn[mod][ch][sign] || !fHP_LmdOut[mod][ch][sign]){
00297             Error("ResetHistos","LMD plot not found (mod: %d, ch: %d)",mod,ch);
00298             continue;
00299           }
00300           fHP_LmdInn[mod][ch][sign]->Reset();
00301           fHP_LmdOut[mod][ch][sign]->Reset();
00302         }
00303       }
00304   }
00305   // --- LMD completed
00306 
00307   // --- STB
00308   for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00309     for(Int_t ch=0;ch<K_SLOW_N_CHANS[STB];ch++){
00310       if(!fHP_Stb[mod][ch]){
00311         Error("ResetHistos","STB plot not found (mod: %d, ch: %d)",mod,ch);
00312         continue;
00313       }
00314       fHP_Stb[mod][ch]->Reset();
00315     }
00316   }
00317   // --- STB completed
00318 
00319 }
00320 
00321 //____________________________
00322 void TFndSCCshowHistos::WriteHistosToFile(const TString &fnam,Bool_t tofi,Bool_t tofo,Bool_t sil,Bool_t lmd,Bool_t stb,Bool_t gas,Bool_t mag){
00323   
00324   TFile fout(fnam,"RECREATE");
00325   fout.cd();
00326 
00327   // --- TOFINO
00328   if(tofi){
00329     for(Int_t ch=0;ch<K_N_TOFINO_SLABS;ch++){
00330       for(Int_t sid=0;sid<2;sid++){
00331         for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00332           if(!fHP_Tofi[mod][sid][ch]){
00333             Error("WriteHistosToFile","TOFINO plot not found (mod: %d, sid: %d, ch: %d)",mod,sid,ch);
00334             continue;
00335           }
00336           fHP_Tofi[mod][sid][ch]->Write();
00337         }
00338       }
00339     }
00340   }
00341   // --- TOFINO completed
00342   
00343   // --- TOFONE
00344   if(tofo){
00345     for(Int_t ch=0;ch<K_N_TOFONE_SLABS;ch++){
00346       for(Int_t sid=0;sid<2;sid++){
00347         for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00348           if(!fHP_Tofo[mod][sid][ch]){
00349             Error("WriteHistosToFile","TOFONE plot not found (mod: %d, sid: %d, ch: %d)",mod,sid,ch);
00350             continue;
00351           }
00352           fHP_Tofo[mod][sid][ch]->Write();
00353         }
00354       }
00355     }
00356   }
00357   // --- TOFONE completed
00358 
00359   // --- SIL
00360   if(sil){
00361     for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00362       for(Int_t ch=0;ch<K_N_Sil_Modules;ch++){
00363         for(Int_t side=0;side<K_N_Sil_Sides;side++){
00364           for(Int_t sign=0;sign<2;sign++){
00365             if(!fHP_Osim[mod][ch][side][sign] || (ch < (K_N_Sil_Modules-2) && !fHP_Isim[mod][ch][side][sign]) ){
00366               Error("WriteHistosToFile","SIL plot not found (mod: %d, sid: %d, ch: %d, sign: %d)",mod,side,ch,sign);
00367               continue;
00368             }
00369             fHP_Osim[mod][ch][side][sign]->Write(); 
00370             if( ch < (K_N_Sil_Modules-2) ){
00371               fHP_Isim[mod][ch][side][sign]->Write(); 
00372             }
00373           }
00374         }
00375       }
00376     }
00377   }
00378   // --- SIL completed
00379   
00380   // --- LMD
00381   if(lmd){
00382     for(Int_t ch=0;ch<K_N_LMD_CHAMS_PER_LAYER;ch++){
00383       for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00384         for(Int_t sign=0;sign<2;sign++){
00385           if(!fHP_LmdInn[mod][ch][sign] || !fHP_LmdOut[mod][ch][sign]){
00386             Error("WriteHistosToFile","LMD plot not found (mod: %d, ch: %d)",mod,ch);
00387             continue;
00388           }
00389           fHP_LmdInn[mod][ch][sign]->Write();
00390           fHP_LmdOut[mod][ch][sign]->Write();
00391         }
00392       }
00393     }
00394   }
00395   // --- LMD completed
00396   
00397   // --- STB
00398   if(stb){
00399     for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00400       for(Int_t ch=0;ch<K_SLOW_N_CHANS[STB];ch++){
00401         if(!fHP_Stb[mod][ch]){
00402           Error("WriteHistosToFile","STB plot not found (mod: %d, ch: %d)",mod,ch);
00403           continue;
00404         }
00405         fHP_Stb[mod][ch]->Write();
00406       }
00407     }
00408   }
00409 
00410   //   if(gas){
00411   //     // ---
00412   //   }
00413   
00414 
00415   fout.Close();
00416 
00417 }
00418 
00419 
00420 //____________________________
00421 void TFndSCCshowHistos::LoadHistosFromFile(const TString &fnam,Bool_t tofi,Bool_t tofo,Bool_t sil,Bool_t lmd,Bool_t stb,Bool_t gas,Bool_t mag){
00422   
00423   TFile *fin = new TFile(fnam,"OPEN");
00424   
00425   if(!fin){
00426     Error("LoadHistosFromFile","File not found");
00427     return;
00428   }
00429   ResetHistos(kTRUE);
00430   // ---
00431   // --- TOFINO
00432   if(tofi){
00433     for(Int_t ch=0;ch<K_N_TOFINO_SLABS;ch++){
00434       for(Int_t sid=0;sid<2;sid++){
00435         for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00436           if(!fHP_Tofi[mod][sid][ch]){
00437             Error("LoadHistosFromFile","TOFINO plot not found (mod: %d, sid: %d, ch: %d)",mod,sid,ch);
00438             continue;
00439           }
00440           fHP_Tofi[mod][sid][ch]->LoadFromFile( fin );
00441         }
00442       }
00443     }
00444   }
00445   // --- TOFINO completed
00446   
00447   // --- TOFONE
00448   if(tofo){
00449     for(Int_t ch=0;ch<K_N_TOFONE_SLABS;ch++){
00450       for(Int_t sid=0;sid<2;sid++){
00451         for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00452           if(!fHP_Tofo[mod][sid][ch]){
00453             Error("LoadHistosFromFile","TOFONE plot not found (mod: %d, sid: %d, ch: %d)",mod,sid,ch);
00454             continue;
00455           }
00456           fHP_Tofo[mod][sid][ch]->LoadFromFile( fin );
00457         }
00458       }
00459     }
00460   }
00461   // --- TOFONE completed
00462   
00463   // --- SIL
00464   if(sil){
00465     for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00466       for(Int_t ch=0;ch<K_N_Sil_Modules;ch++){
00467         for(Int_t side=0;side<K_N_Sil_Sides;side++){
00468           for(Int_t sign=0;sign<2;sign++){
00469             if(!fHP_Osim[mod][ch][side][sign] || (ch < (K_N_Sil_Modules-2) && !fHP_Isim[mod][ch][side][sign]) ){
00470               Error("LoadHistosFromFile","SIL plot not found (mod: %d, sid: %d, ch: %d, sign: %d)",mod,side,ch,sign);
00471               continue;
00472             }
00473             fHP_Osim[mod][ch][side][sign]->LoadFromFile( fin ); 
00474             if( ch < (K_N_Sil_Modules-2) ){
00475               fHP_Isim[mod][ch][side][sign]->LoadFromFile( fin ); 
00476             }
00477           }
00478         }
00479       }
00480     }
00481   }
00482   // --- SIL completed
00483   
00484   // --- LMD
00485   if(lmd){
00486     for(Int_t ch=0;ch<K_N_LMD_CHAMS_PER_LAYER;ch++){
00487       for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00488         for(Int_t sign=0;sign<2;sign++){
00489           if(!fHP_LmdInn[mod][ch][sign] || !fHP_LmdOut[mod][ch][sign]){
00490             Error("LoadHistosFromFile","LMD plot not found (mod: %d, ch: %d)",mod,ch);
00491             continue;
00492           }
00493           fHP_LmdInn[mod][ch][sign]->LoadFromFile( fin );
00494           fHP_LmdOut[mod][ch][sign]->LoadFromFile( fin );
00495         }
00496       }
00497     }
00498   }
00499   // --- LMD completed
00500   
00501   // --- STB
00502   if(stb){
00503     for(Int_t mod=(Int_t)(E_SccHisMod_Avail) ; mod<(Int_t)(E_SccHisMod_End) ; mod++){
00504       for(Int_t ch=0;ch<K_SLOW_N_CHANS[STB];ch++){
00505         if(!fHP_Stb[mod][ch]){
00506           Error("LoadHistosFromFile","STB plot not found (mod: %d, ch: %d)",mod,ch);
00507           continue;
00508         }
00509         fHP_Stb[mod][ch]->LoadFromFile( fin );
00510       }
00511     }
00512   }
00513   //   if(gas){
00514   //     // ---
00515   //   }
00516 
00517   // ---
00518   fin->Close();
00519   delete fin;
00520 }
00521 
00522 //____________________________
00523 void TFndSCCshowHistos::FillHistos(const UInt_t &stop_datime,Bool_t tofi,Bool_t tofo,Bool_t sil,Bool_t lmd,Bool_t stb,Bool_t gas,Bool_t mag){
00524   
00525   if(K_DEBUG_LEV > 0) Info("FillHistos","Filling histos up to datime: %u",stop_datime);
00526 
00527   Bool_t fill_enable[K_N_SLOWS] = { kFALSE };
00528   fill_enable[(Int_t)(TOFI)] = tofi;
00529   fill_enable[(Int_t)(TOFO)] = tofo;
00530   fill_enable[(Int_t)(SIL)]  = sil;
00531   fill_enable[(Int_t)(LMD)]  = lmd;
00532   fill_enable[(Int_t)(STB)]  = stb;
00533   fill_enable[(Int_t)(GAS)]  = gas;
00534   fill_enable[(Int_t)(MAG)]  = mag;
00535 
00536   Int_t ev = 0;
00537   UInt_t *event = 0;
00538   while(1){
00539     ev++;
00540     Int_t exit_val = 0;
00541     event = GetNextRawEvent(exit_val);
00542     if(!event || exit_val != 0) return;
00543         
00544     // --- stop_datime check (from header):
00545     const Int_t id_time = (const Int_t)(HdrTot_SysTime);
00546     TDatime datime;
00547     datime.Set(fGlobalHdr[id_time]);
00548     UInt_t ctime = datime.Convert();
00549     //    Printf("Glob.Hdr time : %u (%s)", fGlobalHdr[id_time], datime.AsSQLString());
00550     if(ctime > stop_datime){
00551       if(K_DEBUG_LEV > 0) Info("FillHistos","requested stop-time reached.");
00552       return;
00553     }
00554     
00555     // ---
00556     // Now filling histos:
00557     // PrintAllInfo();
00558     UInt_t data_offset = 0;
00559     UInt_t entry = 0;
00560     Bool_t pow = 0;
00561     Int_t power = (Int_t)(E_SCC_PW_DN);
00562     UInt_t volts = 0;
00563     Float_t voltage = 0;
00564     UInt_t current = 0;
00565     Bool_t trip = 0;
00566     
00567     // --- loop on all detectors
00568     for(Int_t slow_det = (Int_t)TOFI ; slow_det <= (Int_t)MAG ; slow_det++){ // det loop
00569       if( !fill_enable[slow_det] ) continue;
00570       //
00571       UInt_t nchans = fSingleRawData[slow_det][HdrDet_nchans];
00572       
00573       // REMEMBER TO COMPLETE THIS PART !!!!!!!!!!!!
00574 
00575       // get status from the status-string
00576       //      cout << "slow_det: " << slow_det << "; " << nchans << endl;
00577       /*
00578       TString message = GetMessagePart(slow_det);
00579       //
00580       if(! message.IsNull()){
00581         TString CmpStr[3] = {0};
00582         CmpStr[0] = "ok";
00583         CmpStr[1] = "warning";
00584         CmpStr[2] = "error";  
00585         Int_t i = 0;
00586         for(i=0;i<3;i++){
00587           if(!strncasecmp(CmpStr[i],message.Data(),CmpStr[i].Sizeof()-1)) break;
00588         }
00589         
00590         //      cout << "\"" << CmpStr[i] << "\"" << endl;
00591       }
00592       */
00593 
00594       // --- loop on all channels      
00595       for(UInt_t ch=0;ch<nchans;ch++){ // ch loop
00596         data_offset =  (UInt_t)( (fSingleRawData[slow_det][HdrDet_dataoff]) / 4);
00597         entry = fSingleRawData[slow_det][data_offset + ch];
00598         DecodeDataElement(entry, pow, volts, current, trip);
00600         // Bad encoding from STB Slow-Control machine
00601         //      ( FINUDA data-taking 2006/2007 )
00602         if( slow_det == (Int_t)(STB) ){
00603           TDatime StbSysTime(fSingleRawData[(Int_t)(STB)][(Int_t)(HdrDet_systime)]);
00604           if(StbSysTime.Convert() <= DTak_2006_SftwStopTime) power = !power;
00605         }
00607         if( slow_det == (Int_t)(SIL) ) voltage = (Float_t)( (Float_t)(volts) / 100.);
00608         else voltage = (Float_t)(volts);
00609         //
00610         power = (pow) ? (Int_t)(E_SCC_PW_ON) : (Int_t)(E_SCC_PW_OFF);
00611         // ---
00612         
00613         // ----------------
00614         Bool_t second_half = kFALSE;
00615         if( ch > (UInt_t)( (K_SLOW_N_CHANS[slow_det] / 2) -1) ) second_half = kTRUE;
00616 
00617         Int_t which_quarter = 0; // 1,2,3,4
00618         UInt_t div[3] = {0};
00619         
00620         div[0] = (UInt_t)( (K_SLOW_N_CHANS[slow_det] / 4) );
00621         div[1] = (UInt_t)( (K_SLOW_N_CHANS[slow_det] / 2) );
00622         div[2] = (UInt_t)( K_SLOW_N_CHANS[slow_det] - (K_SLOW_N_CHANS[slow_det] / 4) );
00623         
00624         if( ch < div[0] ) which_quarter = 1;
00625         else if   ( ch >= div[0] && ch < div[1] ) which_quarter = 2;
00626         else if   ( ch >= div[1] && ch < div[2] ) which_quarter = 3;
00627         else which_quarter = 4;
00628         
00629         Int_t side = -1; 
00630         UInt_t det_ch = 0; // numbering: 1,2,3,...
00631         
00632         Int_t lay = -1; // needed by LMD and SIL
00633         
00634         Int_t sign = -1;
00635         Int_t modch = 0; // needed by SIL
00636         Int_t modnum = 0; // needed by SIL
00637 
00638         //   enum E_SCC_HisMod_VI {
00639         //     E_SccHisMod_Avail = 0,
00640         //     E_SccHisMod_PW   = 1,
00641         //     E_SccHisMod_V    = 2,
00642         //     E_SccHisMod_I    = 3,
00643         //     E_SccHisMod_Trip = 4,
00644         //     E_SccHisMod_Stat = 5,
00645         //     E_SccHisMod_End  = 6
00646         //   };
00647         
00648         //
00649         // NOTE: ch here is an index: starting from "0"
00650         switch(slow_det){
00651         case (Int_t)(TOFI):
00652           side = (second_half) ? 1 : 0;
00653           det_ch = (UInt_t) ( ch );
00654           if(second_half) det_ch -=  ( (K_SLOW_N_CHANS[slow_det] / 2 ) );
00655           //      cout << "==== mode: " << (Int_t)(E_SccHisMod_Avail) << " ; side: " << side << " ; ch: " << det_ch << endl;
00656           fHP_Tofi[(Int_t)(E_SccHisMod_Avail)][side][det_ch]->AddPoint(ctime,1);
00657           fHP_Tofi[(Int_t)(E_SccHisMod_PW)   ][side][det_ch]->AddPoint(ctime,power);
00658           fHP_Tofi[(Int_t)(E_SccHisMod_V)    ][side][det_ch]->AddPoint(ctime,voltage);
00659           fHP_Tofi[(Int_t)(E_SccHisMod_I)    ][side][det_ch]->AddPoint(ctime,current);
00660           fHP_Tofi[(Int_t)(E_SccHisMod_Trip) ][side][det_ch]->AddPoint(ctime,trip);
00661           //      cout << "=============================" << endl;
00662           break;
00663         case (Int_t)(TOFO):
00664           side = (second_half) ? 1 : 0;
00665           det_ch = (UInt_t) ( ch );
00666           if(second_half) det_ch -=  ( (K_SLOW_N_CHANS[slow_det] / 2 ) );
00667           fHP_Tofo[(Int_t)(E_SccHisMod_Avail)][side][det_ch]->AddPoint(ctime,1);
00668           fHP_Tofo[(Int_t)(E_SccHisMod_PW)   ][side][det_ch]->AddPoint(ctime,power);
00669           fHP_Tofo[(Int_t)(E_SccHisMod_V)    ][side][det_ch]->AddPoint(ctime,voltage);
00670           fHP_Tofo[(Int_t)(E_SccHisMod_I)    ][side][det_ch]->AddPoint(ctime,current);
00671           fHP_Tofo[(Int_t)(E_SccHisMod_Trip) ][side][det_ch]->AddPoint(ctime,trip);
00672           break;
00673         case (Int_t)(LMD):
00674           switch(which_quarter){
00675           case 1:
00676             lay = (Int_t)(E_FIN_INNER_LAYER);
00677             sign = 1;
00678             break;
00679           case 2:
00680             lay = (Int_t)(E_FIN_INNER_LAYER);
00681             sign = 0;
00682             break;
00683           case 3:
00684             lay = (Int_t)(E_FIN_OUTER_LAYER);
00685             sign = 1;
00686             break;
00687           case 4:
00688             lay = (Int_t)(E_FIN_OUTER_LAYER);
00689             sign = 0;
00690             break;
00691           default: 
00692             gROOT->Error("TFndSCCshoHistos::FillHistos","BUG detected!");
00693             gApplication->Terminate();
00694             return;
00695           }
00696           det_ch = (UInt_t) ( ch -  ( (which_quarter -1) *8 ) );
00697           //cout << "ch:" << ch << ";wq:" <<  which_quarter << ";l:" << lay << ";sd:" << side << ";sg:" << sign << endl;
00698           if( lay == (Int_t)(E_FIN_INNER_LAYER)){
00699             fHP_LmdInn[(Int_t)(E_SccHisMod_Avail)][det_ch][sign]->AddPoint(ctime,1);
00700             fHP_LmdInn[(Int_t)(E_SccHisMod_PW)   ][det_ch][sign]->AddPoint(ctime,power);
00701             fHP_LmdInn[(Int_t)(E_SccHisMod_V)    ][det_ch][sign]->AddPoint(ctime,voltage);
00702             fHP_LmdInn[(Int_t)(E_SccHisMod_I)    ][det_ch][sign]->AddPoint(ctime,current);
00703             fHP_LmdInn[(Int_t)(E_SccHisMod_Trip) ][det_ch][sign]->AddPoint(ctime,trip);
00704           }
00705           else{
00706             fHP_LmdOut[(Int_t)(E_SccHisMod_Avail)][det_ch][sign]->AddPoint(ctime,1);
00707             fHP_LmdOut[(Int_t)(E_SccHisMod_PW)   ][det_ch][sign]->AddPoint(ctime,power);
00708             fHP_LmdOut[(Int_t)(E_SccHisMod_V)    ][det_ch][sign]->AddPoint(ctime,voltage);
00709             fHP_LmdOut[(Int_t)(E_SccHisMod_I)    ][det_ch][sign]->AddPoint(ctime,current);
00710             fHP_LmdOut[(Int_t)(E_SccHisMod_Trip) ][det_ch][sign]->AddPoint(ctime,trip);
00711           }
00712           break;
00713         case (Int_t)(STB):
00714           det_ch = ch;
00715           fHP_Stb[(Int_t)(E_SccHisMod_Avail)][det_ch]->AddPoint(ctime,1);
00716           fHP_Stb[(Int_t)(E_SccHisMod_PW)   ][det_ch]->AddPoint(ctime,power);
00717           fHP_Stb[(Int_t)(E_SccHisMod_V)    ][det_ch]->AddPoint(ctime,voltage);
00718           fHP_Stb[(Int_t)(E_SccHisMod_I)    ][det_ch]->AddPoint(ctime,current);
00719           fHP_Stb[(Int_t)(E_SccHisMod_Trip) ][det_ch]->AddPoint(ctime,trip);
00720           break;
00721         case (Int_t)(GAS):
00722           break;
00723         case (Int_t)(SIL):
00724           if(ch< 8 *6){
00725             lay = (Int_t)(E_FIN_INNER_LAYER);
00726             modnum = (ch / 6) +1;
00727           }
00728           else{
00729             lay = (Int_t)(E_FIN_OUTER_LAYER);
00730             modnum = ( (ch - (7 *6) ) / 6) ;
00731           }
00732           
00733           modch = ch%6;
00734           if     (modch == 0 || modch ==1) side = (Int_t)(E_FIN_SIL_SIDE_PH);
00735           else if(modch == 2 || modch ==3) side = (Int_t)(E_FIN_SIL_SIDE_ZA);
00736           else if(modch == 4 || modch ==5) side = (Int_t)(E_FIN_SIL_SIDE_ZB);
00737           
00738           if(ch%2 ==0) sign = 1;
00739           else sign = 0;
00740           
00741           //      cout << "fill: " << modnum << "\t" << side << "\t" << sign << endl;
00742 
00743           if(lay == (Int_t)(E_FIN_INNER_LAYER)){
00744             fHP_Isim[(Int_t)(E_SccHisMod_Avail)][modnum-1][side][sign]->AddPoint(ctime,1); 
00745             fHP_Isim[(Int_t)(E_SccHisMod_PW)   ][modnum-1][side][sign]->AddPoint(ctime,power); 
00746             fHP_Isim[(Int_t)(E_SccHisMod_V)    ][modnum-1][side][sign]->AddPoint(ctime,voltage); 
00747             fHP_Isim[(Int_t)(E_SccHisMod_I)    ][modnum-1][side][sign]->AddPoint(ctime,current); 
00748             fHP_Isim[(Int_t)(E_SccHisMod_Trip) ][modnum-1][side][sign]->AddPoint(ctime,trip); 
00749           }
00750           else if(lay == (Int_t)(E_FIN_OUTER_LAYER)){
00751             fHP_Osim[(Int_t)(E_SccHisMod_Avail)][modnum-1][side][sign]->AddPoint(ctime,1); 
00752             fHP_Osim[(Int_t)(E_SccHisMod_PW)   ][modnum-1][side][sign]->AddPoint(ctime,power); 
00753             fHP_Osim[(Int_t)(E_SccHisMod_V)    ][modnum-1][side][sign]->AddPoint(ctime,voltage); 
00754             fHP_Osim[(Int_t)(E_SccHisMod_I)    ][modnum-1][side][sign]->AddPoint(ctime,current); 
00755             fHP_Osim[(Int_t)(E_SccHisMod_Trip) ][modnum-1][side][sign]->AddPoint(ctime,trip); 
00756           }
00757           
00758           break;
00759         case (Int_t)(MAG):
00760           break;
00761         default:
00762           return;
00763         }
00765       }// ch loop
00766     }// det loop
00767     // ---
00768   }// ev loop
00769   
00770 }

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