mcr/hdt_read/RunSummaryHistos.C

00001 #include "TH2.h"
00002 #include "TCanvas.h"
00003 #include "TPDF.h"
00004 #include "TFile.h"
00005 #include "TApplication.h"
00006 #include "TTree.h"
00007 #include "TDatime.h"
00008 #include "TLegend.h"
00009 #include "TStyle.h"
00010 
00011 #include "TFndGenInfo.h"
00012 #include "TFndHdt.h"
00013 #include "Gui.h"
00014 
00015 #include "TFile.h"
00016 #include "TTree.h"
00017 
00018 #include "AccessHDT_MultiRun.C"
00019 
00020 class HdtAcc_Appl1: public THdtAccess{
00021 
00022 private:
00023 
00024   TLegend *leg[30];
00025 
00026   TString fCanvTit;
00027   TString fCurRunName;
00028   
00029 
00030   // --- outputs
00031   TFile *fOutFile;
00032   TCanvas *fCanvas;
00033 
00034   // --- noise
00035   Float_t fNoise;
00036   Float_t fNoise_Err;
00037   
00038   // --- histograms
00039   // Gts Histos
00040   TH1F *fHPU_cont[K_N_GTS_P_UNITS]; //-> Pattern Units histograms
00041   TH1F *fHPU_mult[K_N_GTS_P_UNITS]; //-> Pattern Units histograms
00042   TH1F *fHTrigSel[K_N_GTS_SELECTORS]; //-> Pattern Units histograms
00043 
00044   // Tof Histos
00045   TH2F *fH_Tof_i_o_mult;
00046   TH1F *fH_Tof_map[2]; 
00047   TH1F *fH_Tof_map_mt[2]; 
00048   
00049   TH1F *fH_Tofi_High_mult; // multiplicity on high thresholds
00050   TH1F *fH_Tofi_High_map; // pattern on high thresholds
00051 
00052   TH1D *fHD_TofiMult; // used as projection from fH_Tof_i_o_mult
00053   TH1D *fHD_TofoMult; // used as projection from fH_Tof_i_o_mult
00054 
00055   // Sil Histos
00056   //    pattern filled with number of clusters/module/event
00057   TH1F *fH_Sil_Patt_Clust_Low[2]; // [ISIM,OSIM] under threshold (MIP)
00058   TH1F *fH_Sil_Patt_Clust_High[2]; // [ISIM,OSIM] over threshold (PROTON/KAON)
00059   
00060   // Lmd Histos
00061   TH2F *fH_Lmd_i_o_mult;
00062   TH1F *fH_Lmd_tot_mult;
00063   TH2F *fH_Lmd_map[2]; 
00064 
00065   // Stb Histos
00066   TH1F *fH_Stb_mult;
00067   TH1F *fH_Stb_map[K_N_STB_CROWNS]; 
00068   TH1F *fH_Stb_Tdc[K_N_STB_CROWNS];
00069 
00070   // Noise Histos
00071   TH1F *fH_Noise;
00072   TH1F *fH_Noise_Err;
00073 
00074 private:
00075   void InitGtsHistos();
00076   void InitTofHistos();
00077   void InitSilHistos();
00078   void InitLmdHistos();
00079   void InitStbHistos();
00080   void InitNoiseHistos();
00081 
00082   void FillGtsHistos();
00083   void FillTofHistos();
00084   void FillSilHistos();
00085   void FillLmdHistos();
00086   void FillStbHistos();
00087   void FillNoiseHistos();
00088 
00089   void SaveGtsHistos();
00090   void SaveTofHistos();
00091   void SaveSilHistos();
00092   void SaveLmdHistos();
00093   void SaveStbHistos();
00094   void SaveNoiseHistos();
00095   
00096   void ResetGtsHistos();
00097   void ResetTofHistos();
00098   void ResetSilHistos();
00099   void ResetLmdHistos();
00100   void ResetStbHistos();
00101   void ResetNoiseHistos();
00102 
00103   void RemoveGtsHistos();
00104   void RemoveTofHistos();
00105   void RemoveSilHistos();
00106   void RemoveLmdHistos();
00107   void RemoveStbHistos();
00108   void RemoveNoiseHistos();
00109 
00110   //
00111   void CreateOutputRootFile();
00112   void CloseOutputFile();
00113 
00114 public:
00115   HdtAcc_Appl1();
00116   ~HdtAcc_Appl1();
00117 
00118   void Pre_Run_Operation();
00119   void Post_Run_Operation();
00120 
00121   void UseHdtEvent();
00122 
00123   // --- added for current application
00124   // --- style and displaying
00125   void SetHistoProperties(TH1 *his,Int_t mode);
00126   void EvalPatternUnit();
00127   void EvalNoise();
00128   void DrawSummaryHistos();
00129   void SaveSummaryPdf();
00130 
00131   // --- histogramming
00132   void InitHistos(){
00133     InitGtsHistos();
00134     InitTofHistos();
00135     InitSilHistos();
00136     InitLmdHistos();
00137     InitStbHistos();
00138     InitNoiseHistos();
00139   }
00140   
00141   void FillHistos(){
00142     FillGtsHistos();
00143     FillTofHistos();
00144     FillSilHistos();
00145     FillLmdHistos();
00146     FillStbHistos();
00147     FillNoiseHistos();
00148   }
00149   
00150   void SaveHistos(){
00151     CreateOutputRootFile();
00152     SaveGtsHistos();
00153     SaveTofHistos();
00154     SaveSilHistos();
00155     SaveLmdHistos();
00156     SaveStbHistos();
00157     SaveNoiseHistos();
00158     // output file not closed in order not to loose histos
00159   }
00160 
00161   void ResetHistos(){
00162     ResetGtsHistos();
00163     ResetTofHistos();
00164     ResetSilHistos();
00165     ResetLmdHistos();
00166     ResetStbHistos();
00167     ResetNoiseHistos();
00168   }
00169 
00170   void RemoveHistos(){
00171     RemoveGtsHistos();
00172     RemoveTofHistos();
00173     RemoveSilHistos();
00174     RemoveLmdHistos();
00175     RemoveStbHistos();
00176     RemoveNoiseHistos();
00177   }
00178 
00179   // ---
00180 
00181   ClassDef(HdtAcc_Appl1,1)
00182     };
00183 
00184 ClassImp(HdtAcc_Appl1)
00185 
00186 //_______________________________
00187 HdtAcc_Appl1::HdtAcc_Appl1():
00188   fCanvTit(),fCurRunName(),
00189   fOutFile(),fCanvas(),
00190   fNoise(),fNoise_Err(),
00191   fHPU_cont(),fHPU_mult(),fHTrigSel(),
00192   fH_Tof_i_o_mult(),fH_Tof_map(),fH_Tof_map_mt(),fH_Tofi_High_mult(),fH_Tofi_High_map(),
00193   fHD_TofiMult(),fHD_TofoMult(),
00194   fH_Sil_Patt_Clust_Low(),fH_Sil_Patt_Clust_High(),
00195   fH_Lmd_i_o_mult(),fH_Lmd_tot_mult(),fH_Lmd_map(),
00196   fH_Stb_mult(),fH_Stb_map(),fH_Stb_Tdc(),
00197   fH_Noise(),fH_Noise_Err()
00198 {
00199 
00200   //  cout << "HdtAcc_Appl1 constructor called" << endl;
00201 
00202 }
00203 
00204 //_______________________________
00205 HdtAcc_Appl1::~HdtAcc_Appl1(){
00206 
00207   FinishRun();
00208 
00209   if( fCanvas ){
00210     fCanvas->Clear();
00211     delete fCanvas;
00212     fCanvas = 0;
00213   }
00214 
00215   RemoveHistos();
00216 
00217 
00218 }
00219 
00220 //_______________________________
00221 void HdtAcc_Appl1::Pre_Run_Operation(){
00222 
00223   //  cout << "Performing pre-run operation for run " << fCurrentRun << endl;
00224   fCurRunName = BuildRunName(fRunType,fCurrentRun);
00225 }
00226 
00227 //_______________________________
00228 void HdtAcc_Appl1::Post_Run_Operation(){
00229 
00230   //  cout << "Performing post-run operation for run " << fCurrentRun << endl;
00231   EvalPatternUnit();
00232   EvalNoise();
00233 }
00234 
00235 //_______________________________
00236 void HdtAcc_Appl1::UseHdtEvent(){
00237   
00238   FillHistos();
00239   //  cout << "...............UseHdtEvent.................... " << endl;
00240   //  fCurHdtEv->PrintHits();
00241 }
00242 
00243 // --- Added methods (used for this application only)
00244 
00245 //_______________________________
00246 void HdtAcc_Appl1::SetHistoProperties(TH1 *his,Int_t mode){
00247   // mode values:
00248   //            0: normal with thik line
00249   //            1: first of (BW) superposition
00250   //            2: second of (BW) superposition
00251   gStyle->SetOptStat(1000101);
00252   gStyle->SetStatStyle(3002);
00253   gStyle->SetStatColor(0);
00254   gStyle->SetStatTextColor(12);
00255   
00256   gStyle->SetStatX(0.98);
00257   gStyle->SetStatW(0.235);
00258   gStyle->SetStatY(0.99);
00259   gStyle->SetStatH(0.35);
00260   
00261   gStyle->SetTitleX(0);
00262   gStyle->SetTitleW(0.5);
00263   gStyle->SetTitleY(1);
00264   gStyle->SetTitleH(0.08);
00265   
00266   switch(mode){
00267   case 0:
00268     his->SetLineWidth(2);
00269     break;
00270   case 1:
00271     his->SetLineStyle(1);
00272     his->SetLineWidth(3);
00273     his->SetFillStyle(3005);
00274     his->SetFillColor(15);
00275     break;
00276   case 2:    
00277     gStyle->SetStatX(0.74);
00278     //     gStyle->SetStatW(0.20);
00279     //     gStyle->SetStatY(0.99);
00280     //     gStyle->SetStatH(0.35);
00281     
00282     his->SetLineStyle(1);
00283     his->SetLineWidth(1);
00284     his->SetFillStyle(3001);
00285     his->SetFillColor(1);
00286   }
00287 
00288 }
00289 
00290 //_______________________________
00291 void HdtAcc_Appl1::EvalNoise(){
00292 
00293   Float_t allevs = (Float_t) (fCurHdtEv->GetEventNumber() );
00294   fNoise = fH_Noise->GetMean();
00295   fNoise_Err = fH_Noise_Err->GetEntries() / allevs;
00296 
00297   TString rtim_str = "";
00298   rtim_str.Form(" Noise:%.1f (err:%.2f%)",fNoise,fNoise_Err);
00299   fCanvTit+=rtim_str;
00300   
00301 }
00302 
00303 //_______________________________
00304 void HdtAcc_Appl1::EvalPatternUnit(){
00305 
00306   if(fVerboseLevel > 0) Printf("\n Evaluating trigger");
00307 
00308   Float_t max = fHPU_cont[0]->GetMaximum();
00309   if(fVerboseLevel > 1) Printf("maximum: %1f",max);
00310 
00311   Float_t thr = max/10;
00312   if(fVerboseLevel > 1) Printf("thr: %3f",thr);
00313 
00314   const Int_t nbinsx = (const Int_t) ( fHPU_cont[0]->GetNbinsX() );
00315   
00316   UInt_t b_on_code = 0;
00317   UInt_t b_over_th_code = 0;
00318   Bool_t b_on[16+1] = { kFALSE };
00319   Bool_t b_over_th[16+1] = { kFALSE };
00320   
00321   // take care: b_on indexing as bit numbering (from 1 to 16)
00322   //           b_on[0] will be always empty!
00323   for(Int_t b=2; b<=nbinsx; b++){
00324     Float_t cont = fHPU_cont[0]->GetBinContent(b);
00325     if(fVerboseLevel > 2) Printf("b: %i; content: %1f",b-1,cont);
00326     if(cont > 0 ) b_on[b-1] = kTRUE;
00327     if(cont > thr) b_over_th[b-1] = kTRUE;
00328   }
00329   // ---
00330   TString chk_str_on = "bits on: " ;
00331   TString chk_str_over_thr = "bits over threshold: " ;
00332   for(Int_t b=1; b<=16; b++){
00333     if(b_on[b]) {
00334       chk_str_on += b; chk_str_on +=  " "; 
00335       b_on_code = b_on_code | (0x1 << b);
00336     }
00337     if(b_over_th[b]) {
00338       chk_str_over_thr += b; chk_str_over_thr +=  " ";
00339       b_over_th_code = b_over_th_code | (0x1 << b);
00340     }
00341   }
00342   if(fVerboseLevel > 2){
00343     Printf("%s (0x%X)",chk_str_on.Data(),b_on_code);
00344     Printf("%s (0x%X)",chk_str_over_thr.Data(),b_over_th_code);
00345   }
00346   // ---
00347   //   UInt_t bhabha_code = 0x614;
00348   //   UInt_t hype_code = 0x232; // was 432
00349   //   UInt_t cosm_code = 0x410; // was 450
00350   UInt_t bhabha_code = 0x4;
00351   UInt_t hype_code = 0x2;
00352   UInt_t cosm_code = 0x40;
00353   UInt_t cosm_code1 = 0x400;
00354   
00355   UInt_t chk_bhabha = b_over_th_code & bhabha_code;
00356   UInt_t chk_hype   = b_over_th_code & hype_code;
00357   UInt_t chk_cosm   = b_over_th_code & cosm_code; // before the GorTofone hdw improvement
00358   UInt_t chk_cosm1   = b_over_th_code & cosm_code1; // after the GorTofone hdw improvement
00359   
00360   if(fVerboseLevel > 1){
00361     Printf("\n\n-----------------------");
00362     
00363     Printf("Check bhabha : 0x%X",chk_bhabha);
00364     Printf("Check hype   : 0x%X",chk_hype);
00365     Printf("Check cosm   : 0x%X",chk_cosm);
00366     Printf("Check cosm1  : 0x%X",chk_cosm1);
00367   }
00368   
00369   Bool_t rec_bha  = (chk_bhabha == bhabha_code) ? kTRUE : kFALSE;
00370   Bool_t rec_hyp  = (chk_hype  == hype_code) ? kTRUE : kFALSE;
00371   Bool_t rec_cosm = (chk_cosm  == cosm_code) ? kTRUE : kFALSE;
00372   Bool_t rec_cosm1 = (chk_cosm1  == cosm_code1) ? kTRUE : kFALSE;
00373   
00374   TString res_msg = "TRIG: ";
00375   if(rec_bha && ( (b_over_th_code & 0x40) == 0) )  res_msg += " BHA ";
00376   if(rec_hyp && ( (b_over_th_code & 0x40) == 0) ){
00377     res_msg += " HYP ";
00378     if( (b_over_th_code & 0x4) == 0) res_msg = " HYP ";
00379   }
00380   if( rec_cosm || (rec_cosm1 && !(rec_bha || rec_hyp)) ) res_msg += " COSM ";
00381   
00382   if(res_msg.CompareTo("TRIG: ")==0) res_msg = " ? ";
00383 
00384   if(fVerboseLevel > 0) Printf("detected trigger: \"%s\"",res_msg.Data());
00385   // ---
00386 
00387   fCanvTit.Form("%s (%s)",fCurRunName.Data(),res_msg.Data());
00388 
00389   //   Grab runtime (last run)
00390   TString rtim_str = "";
00391   if(fCurRunInfo){
00392     //fCurRunInfo->Print();
00393     TDatime rdatime = fCurRunInfo->GetDateTime();
00394     rtim_str.Form(" (%s)",rdatime.AsSQLString());
00395     fCanvTit+=rtim_str;
00396   }
00397 
00398 }
00399 
00400 //_______________________________
00401 void HdtAcc_Appl1::InitGtsHistos(){
00402   
00403   TString hname;
00404   TString htitle;
00405   for(Int_t i=0;i < K_N_GTS_P_UNITS ; i++){
00406     hname.Form("GtsHist_PU_cont_%d",i+1);
00407     htitle.Form("Pattern Unit %d (bits content)",i+1);
00408     fHPU_cont[i] = new TH1F(hname,htitle,17,-0.5,16.5);
00409     hname.Form("GtsHist_PU_mult_%d",i+1);
00410     htitle.Form("Pattern Unit %d (multiplicity)",i+1);
00411     fHPU_mult[i] = new TH1F(hname,htitle,16,-0.5,15.5);
00412   }
00413   
00414   for(Int_t i=0;i < K_N_GTS_SELECTORS ; i++){
00415     hname.Form("GtsHist_TrigSel_%d",i+1);
00416     htitle.Form("Trigger Selector %d",i+1);
00417     fHTrigSel[i] = new TH1F(hname,htitle,16,-0.5,15.5);
00418   }
00419 }
00420 
00421 //_______________________________
00422 void HdtAcc_Appl1::InitTofHistos(){
00423 
00424   fH_Tof_i_o_mult = new TH2F("tof_i_o_mult","Tof inner vs outer mult.",74,-0.5,73.5,14,-0.5,13.5);
00425   
00426   fH_Tof_map[0] = new TH1F("tof_i_map","Inner Tof Hit Map - full hits",14,-0.5,13.5);   
00427   fH_Tof_map[1] = new TH1F("tof_o_map","Outer Tof Hit Map - full hits",74,-0.5,73.5);   
00428 
00429   fH_Tof_map_mt[0] = new TH1F("tof_i_mt_map","Inner Tof Mean Timer pattern",14,-0.5,13.5);   
00430   fH_Tof_map_mt[1] = new TH1F("tof_o_mt_map","Outer Tof Mean Timer pattern",74,-0.5,73.5);   
00431   
00432   // --- 
00433   fH_Tofi_High_mult = new TH1F("TOFINO_MT_H_mul","TOFINO hi-MT-mult.",14,-0.5,13.5);
00434   fH_Tofi_High_map = new TH1F("TOFINO_MT_H_map","TOFINO hi-MT-patt.",14,-0.5,13.5);
00435 
00436 }
00437 
00438 //_______________________________
00439 void HdtAcc_Appl1::InitSilHistos(){
00440 
00441   fH_Sil_Patt_Clust_Low[0]  = new TH1F("ISIM_PATT_Low" ,"ISIM PATT",10,-0.5,9.5);
00442   fH_Sil_Patt_Clust_High[0] = new TH1F("ISIM_PATT_High","ISIM PATT High",10,-0.5,9.5);
00443 
00444   fH_Sil_Patt_Clust_Low[1]  = new TH1F("OSIM_PATT_Low" ,"OSIM PATT",12,-0.5,11.5);
00445   fH_Sil_Patt_Clust_High[1] = new TH1F("OSIM_PATT_High","OSIM PATT High",12,-0.5,11.5);
00446 
00447 }
00448 //_______________________________
00449 void HdtAcc_Appl1::InitLmdHistos(){
00450 
00451   fH_Lmd_i_o_mult = new TH2F("lmd_i_o_mult","Lmd inner vs outer mult.",10,-0.5,9.5,10,-0.5,9.5);
00452   fH_Lmd_tot_mult = new TH1F("lmd_tot_mult","Lmd total multiplicity",30,-0.5,29.5);
00453 
00454   fH_Lmd_map[0] = new TH2F("lmd_i_map","Inner Lmd Hit Map (Wire vs Drift Number) - full hits",9,-0.5,9.5,14,-0.5,13.5);   
00455   fH_Lmd_map[1] = new TH2F("lmd_o_map","Outer Lmd Hit Map (Wire vs Drift Number) - full hits",9,-0.5,9.5,24,-0.5,23.5);   
00456 
00457 }
00458 //_______________________________
00459 void HdtAcc_Appl1::InitStbHistos(){
00460 
00461   fH_Stb_mult = new TH1F("stb_mult","Stb multiplicity",101,-0.5,100.5);
00462   TString hname;
00463   TString htitle;
00464   
00465   for(Int_t ch=0;ch<K_N_STB_CROWNS;ch++ ){
00466     hname.Form("stb_map_%d",ch+1);
00467     htitle.Form("Stb Crown %d pattern",ch+1);
00468     fH_Stb_map[ch] = new TH1F(hname,htitle,K_N_STB_TUBES+2,-0.5,(Float_t) K_N_STB_TUBES+1.5); 
00469     hname.Form("Stb_Tdc_Crown_%d",ch+1);
00470     htitle.Form("Stb Crown %d Tdc distribution",ch+1);
00471     fH_Stb_Tdc[ch] = new TH1F(hname,htitle,660,0.,1980.);
00472   }
00473   
00474 }
00475 
00476 //_______________________________
00477 void HdtAcc_Appl1::InitNoiseHistos(){
00478 
00479   fH_Noise = new TH1F("gen_noise","general noise",8,-0.5,7.5);
00480   fH_Noise_Err = new TH1F("gen_noise_err","general noise error",8,-7.5,0.5);
00481 
00482 }
00483 
00485 
00486 //_______________________________
00487 void HdtAcc_Appl1::FillGtsHistos(){
00488 
00489   TFndTrig *fTrig = fCurHdtEv->GetGts();
00490   //  
00491   Int_t pu_mult[K_N_GTS_P_UNITS] = {0};
00492   for(Int_t i=0;i < K_N_GTS_P_UNITS ; i++){
00493     for(Int_t bit=0;bit<16;bit++){
00494       Short_t content = fTrig->GetPU_cont_bit(i,bit);
00495       fHPU_cont[i]->Fill(bit+1,content);
00496       if(content > 0) pu_mult[i]++;
00497     }
00498     fHPU_mult[i]->Fill(pu_mult[i]);
00499   }
00500   // ---
00501   for(Int_t i=0;i < K_N_GTS_SELECTORS ; i++){
00502     for(Int_t bit=0;bit<16;bit++) fHTrigSel[i]->Fill(bit,fTrig->GetTriggerSelector_bit(i,bit));
00503   }  
00504   //
00505   fTrig = 0;
00506 }
00507 //_______________________________
00508 void HdtAcc_Appl1::FillTofHistos(){
00509 
00510   TClonesArray *TofHits = fCurHdtEv->GetTofHits();
00511   //
00512   Int_t lay, slab;
00513   TFndHTof *cur_hit = 0;
00514   Int_t i_mult = 0;
00515   Int_t i_high_mult = 0;
00516   Int_t o_mult = 0;
00517   //cout << TofHits->GetEntries() << " tof hits" << endl;
00518   for(Int_t ic=0;ic< TofHits->GetEntries(); ic++) {
00519     cur_hit =  (TFndHTof *) ( TofHits->At(ic) );
00520     cur_hit->GetLayer_Slab(lay,slab);
00521     
00522     Int_t ae = cur_hit->GetAdcE();
00523     Int_t ap = cur_hit->GetAdcP();
00524     Int_t te = cur_hit->GetTdcE();
00525     Int_t tp = cur_hit->GetTdcP();
00526     Int_t tm = cur_hit->GetMeanTimer();
00527     Int_t tm_high = cur_hit->GetHighMeanTimer();
00528     Bool_t fullHit = kTRUE;
00529     if(ae==-1 || ap==-1 || te==-1 || tp==-1) fullHit = 0;
00530     
00531     if(tm >= 0 && lay == 1) i_mult++;
00532     if(tm_high >= 0 && lay == 1) i_high_mult++;
00533     else if(tm >= 0 && lay == 2) o_mult++;
00534     
00535     if(fullHit) fH_Tof_map[lay-1]->Fill(slab);
00536     if(tm>=0) fH_Tof_map_mt[lay-1]->Fill(slab);
00537     if(tm_high >= 0 && lay == 1) fH_Tofi_High_map->Fill(slab);
00538     
00539   }   
00540   fH_Tof_i_o_mult->Fill(o_mult,i_mult);
00541   fH_Tofi_High_mult->Fill(i_high_mult);
00542   //
00543   TofHits = 0;
00544 }
00545 //_______________________________
00546 void HdtAcc_Appl1::FillSilHistos(){
00547 
00548   TClonesArray *SilClus = fCurHdtEv->GetSilClusters();
00549   //
00550   if(!SilClus) return;
00551   TFndHSilCluster *cur_clus = 0;
00552   Int_t n_clusts = (Int_t)SilClus->GetEntries();
00553   //  cout << "n_clusts: " << n_clusts << endl;
00554   
00555   for(Int_t ic=0;ic< n_clusts; ic++) {
00556     cur_clus = (TFndHSilCluster *) ( SilClus->At(ic) );
00557     if(!cur_clus) return;
00558     //    cur_clus->PrintHit();
00559     Int_t slay = cur_clus->GetLayer();
00560     Int_t smod = cur_clus->GetModNum();
00561     // --- check
00562     if(slay < 1 || slay > 2){
00563       cout << " ************* ERROR: FillSilHistos(): slay = " << slay << endl;
00564       return;
00565     }
00566     if(slay == 1 && (smod < 1 || smod > 8) ){
00567       cout << " ************* ERROR: FillSilHistos(): slay = " << slay << "; mod = " << smod << endl;
00568       return;      
00569     }
00570     if(slay == 2 && (smod < 1 || smod > 10) ){
00571       cout << " ************* ERROR: FillSilHistos(): slay = " << slay << "; mod = " << smod << endl;
00572       return;      
00573     }
00574     // ---
00575     // add energy selection
00576     //    Bool_t is_over_threshold = kTRUE; // GET IT FROM THE CLUSTER
00577     //    if(is_over_threshold)
00578     if (cur_clus->GetIDCl() == 1 && cur_clus->GetGoodCl() == 1){
00579       fH_Sil_Patt_Clust_High[slay-1]->Fill(smod);
00580     } else if (cur_clus->GetGoodCl() == 1) {
00581       fH_Sil_Patt_Clust_Low[slay-1]->Fill(smod);
00582     }    
00583   }// hits loop end
00584   //  
00585   SilClus = 0;
00586 }
00587 //_______________________________
00588 void HdtAcc_Appl1::FillLmdHistos(){
00589 
00590   TClonesArray *LmdHits = fCurHdtEv->GetLmdHits();
00591   //
00592   Int_t lay, cham, wire;
00593   TFndHLmd *cur_hit = 0;
00594   Int_t i_mult = 0;
00595   Int_t o_mult = 0;
00596   for(Int_t ic=0;ic< LmdHits->GetEntries(); ic++) {
00597     cur_hit =  (TFndHLmd *) ( LmdHits->At(ic) );
00598     //cur_hit->PrintHit();
00599     cur_hit->GetLayer_Chamber_Wire(lay, cham, wire);
00600     Float_t ae = cur_hit->GetAdcE();
00601     Float_t ap = cur_hit->GetAdcP();
00602     Float_t te = cur_hit->GetTdcE();
00603     Float_t tp = cur_hit->GetTdcP();
00604     Float_t fullHit = ae*ap*te*tp;
00605     if(lay == 1) i_mult++;
00606     if(lay == 2) o_mult++;
00607     
00608     if(fullHit) fH_Lmd_map[lay-1]->Fill(cham,wire);
00609   }   
00610   fH_Lmd_i_o_mult->Fill(o_mult,i_mult);
00611   fH_Lmd_tot_mult->Fill(o_mult+i_mult);
00612   //
00613   LmdHits = 0;
00614 }
00615 //_______________________________
00616 void HdtAcc_Appl1::FillStbHistos(){
00617 
00618   TClonesArray *StbHits = fCurHdtEv->GetStbHits();
00619   //
00620   Int_t crown, tube;
00621   TFndHStb *cur_hit = 0;
00622   fH_Stb_mult->Fill(StbHits->GetEntries());
00623   for(Int_t ic=0;ic< StbHits->GetEntries(); ic++) {
00624     cur_hit =  (TFndHStb *) ( StbHits->At(ic) );
00625     cur_hit->GetCrown_Tube(crown, tube);
00626     fH_Stb_map[crown-1]->Fill(tube);
00627     fH_Stb_Tdc[crown-1]->Fill(cur_hit->GetTdc());
00628   } 
00629   //
00630   StbHits = 0;
00631 }
00632 //_______________________________
00633 void HdtAcc_Appl1::FillNoiseHistos(){
00634 
00635   Int_t cur_noise = fCurHdtEv->GetNoiseLevel();
00636   Float_t cn = 999;
00637   Float_t cner = -999;
00638 
00639   if(cur_noise == -999) return;
00640 
00641   if( cur_noise >= 0 ){
00642     cn = (cur_noise != 999) ? (Float_t)(cur_noise) : 4;
00643   }
00644   else{
00645     cner = (Float_t)(cur_noise);
00646   }
00647 
00648   if(cn != 999) fH_Noise->Fill(cn);
00649   if(cner != -999) fH_Noise_Err->Fill(cner);
00650 
00651 }
00652 
00654 //_______________________________
00655 void HdtAcc_Appl1::DrawSummaryHistos(){
00656 
00657   gStyle->SetPalette(1,0);
00658   if(fCanvas) delete fCanvas;
00659   fCanvas = new TCanvas("FND_Monitor","FND_Monitor",580,840);
00660   
00661   fCanvas->Clear();
00662 
00664   TString title = fCanvTit;
00665   //  Printf("==========> \"%s\"",fCanvTit.Data());
00666   Int_t TitColor = -1;
00667   Double_t pad_tit_h = 0.07;
00668   Double_t TitSize = 0.3;
00669   // ---
00670    
00671   Double_t sep = 0.005;  
00672   Double_t ori_w = (Double_t) ( fCanvas->GetWindowWidth() );
00673   Double_t ori_h = (Double_t) ( fCanvas->GetWindowHeight() );
00674 
00675   //   if(ori_w == 0 || ori_w == 32000) ori_w = 800;
00676   //   if(ori_h == 0 || ori_h == 32000) ori_h = 600;
00677   
00678   Double_t w_h_ratio = ori_w / ori_h;
00679   
00680   UInt_t displ_h = (UInt_t) ( ori_h - ( ori_h * pad_tit_h + sep) );
00681   UInt_t displ_w = (UInt_t) ( displ_h * w_h_ratio );
00682 
00683   
00684   TPad *pt = new TPad("pt","ptit",
00685                       .01 , (1.- (pad_tit_h - sep) ) ,
00686                       .99 ,  .999);
00687   
00688   if(TitColor != -1)pt->SetFillColor(TitColor);
00689   
00690   fCanvas->cd();
00691   pt->Draw();
00692   // WRITE TITLE
00693   pt->cd();
00694   TLatex tit;//= new TLatex(.05,.95,title);
00695   tit.SetTextAlign(23);
00696   tit.SetTextSize(TitSize);
00697   tit.DrawLatex(0.5,0.65,title);
00698 
00699   Double_t dis_perc_w = (Double_t) (displ_w) / ori_w;
00700   Double_t dis_perc_h = (Double_t) (displ_h) / ori_h;
00701   
00702   Double_t half_p = (1. - dis_perc_w)/2;
00703 
00704   TPad *pd = new TPad("pd","pdis",
00705                       half_p     , .0001,
00706                       1 - half_p , dis_perc_h);
00707 
00708   fCanvas->cd();
00709   pd->Draw();
00710 
00711   pd->cd();  
00713 
00714   pd->Divide(2,4);
00715   pd->cd(1);
00716 
00717   // --- TOF multiplicities
00718   fHD_TofiMult = fH_Tof_i_o_mult->ProjectionY();
00719   fHD_TofiMult->SetAxisRange(-0.5,7.5,"X");
00720   fHD_TofiMult->SetName("TOFINO MT multiplicity");
00721   fHD_TofiMult->SetTitle("TOFINO MT multiplicity");
00722   SetHistoProperties(fHD_TofiMult,1);
00723   fHD_TofiMult->Draw();
00724 
00725   fH_Tofi_High_mult->SetAxisRange(-0.5,7.5,"X");
00726   fH_Tofi_High_mult->SetName("TOFINO MT-h mult.");
00727   SetHistoProperties(fH_Tofi_High_mult,2);
00728   fH_Tofi_High_mult->Draw("sames");
00729   if(fH_Tofi_High_mult->GetMaximum() > fHD_TofiMult->GetMaximum() ) fHD_TofiMult->SetAxisRange(0,fH_Tofi_High_mult->GetMaximum(),"Y");
00730 
00731   leg[0] = new TLegend(0.6,0.5,0.99,0.75);
00732   leg[0]->AddEntry(fHD_TofiMult->GetName(),"low th.","cf");
00733   leg[0]->AddEntry(fH_Tofi_High_mult->GetName(),"high th.","cf");
00734   leg[0]->Draw();
00735 
00736   pd->cd(2);
00737   fHD_TofoMult = fH_Tof_i_o_mult->ProjectionX();
00738   fHD_TofoMult->SetAxisRange(-0.5,15.5,"X");
00739   fHD_TofoMult->SetTitle("TOFONE MT multiplicity");
00740   SetHistoProperties(fHD_TofoMult,0);
00741   fHD_TofoMult->Draw();
00742   
00743   // --- TOF patterns
00744   pd->cd(3);
00745   fH_Tof_map_mt[0]->SetAxisRange(-0.5,13.5,"X");
00746   fH_Tof_map_mt[0]->SetName("TOFINO MT-l patt.");
00747   fH_Tof_map_mt[0]->SetTitle("TOFINO MT patt.");
00748   SetHistoProperties(fH_Tof_map_mt[0],1);
00749   fH_Tof_map_mt[0]->Draw();
00750 
00751   fH_Tofi_High_map->SetAxisRange(-0.5,13.5,"X");
00752   fH_Tofi_High_map->SetName("TOFINO MT-h pattern");
00753   fH_Tofi_High_map->SetTitle("TOFINO MT-high pattern");
00754   SetHistoProperties(fH_Tofi_High_map,2);
00755   fH_Tofi_High_map->Draw("sames");
00756 
00757   pd->cd(4);
00758   fH_Tof_map_mt[1]->SetAxisRange(-0.5,72.5,"X");
00759   SetHistoProperties(fH_Tof_map_mt[1],0);
00760   fH_Tof_map_mt[1]->Draw();
00761 
00762   // --- SIL
00763   pd->cd(5);// ISIM
00764   SetHistoProperties(fH_Sil_Patt_Clust_Low[0],1);
00765   fH_Sil_Patt_Clust_Low[0]->Draw();
00766   SetHistoProperties(fH_Sil_Patt_Clust_High[0],2);
00767   fH_Sil_Patt_Clust_High[0]->Draw("sames");
00768   pd->cd(6);// OSIM
00769   SetHistoProperties(fH_Sil_Patt_Clust_Low[1],1);
00770   fH_Sil_Patt_Clust_Low[1]->Draw();
00771   SetHistoProperties(fH_Sil_Patt_Clust_High[1],2);
00772   fH_Sil_Patt_Clust_High[1]->Draw("sames");
00773 
00774 
00775   // --- LMD and STB multiplicities
00776   pd->cd(7);
00777   fH_Lmd_tot_mult->SetAxisRange(-0.5,14.5,"X");
00778   SetHistoProperties(fH_Lmd_tot_mult,0);
00779   fH_Lmd_tot_mult->Draw();  
00780 
00781   pd->cd(8);
00782   fH_Stb_mult->SetAxisRange(-0.5,34.5,"X");
00783   SetHistoProperties(fH_Stb_mult,0);
00784   fH_Stb_mult->Draw();
00785 
00786 }
00787 
00788 //_______________________________
00789 void HdtAcc_Appl1::SaveSummaryPdf(){
00790 
00791   TString start_pth=ExpandPathName("$FND_HISTOS");
00792   
00793 #if defined _FND_OUTPUTS_USE_SUBDIR
00794   CreateGrpSubDir(fRunType,fFirstRun,start_pth);
00795   TString fnam = BuildRunName(fRunType,fFirstRun,kTRUE);
00796 #else
00797   TString fnam = BuildRunName(fRunType,fFirstRun);
00798 #endif
00799   if(fLastRun != fFirstRun){
00800     fnam += "-";
00801     fnam += fLastRun;
00802   }
00803   fnam += "-summary.pdf";
00804   
00805   TString pdfname = "";
00806   pdfname.Form("%s/%s",start_pth.Data(),fnam.Data());
00807 
00808   DrawSummaryHistos();
00809 
00810   // --- SAVE PDF
00811   fCanvas->cd();
00812   fCanvas->SaveAs(pdfname);
00813   
00814 }
00815 
00816 //_______________________________
00817 void HdtAcc_Appl1::CreateOutputRootFile(){
00818   
00819   CloseOutputFile();
00820   
00821   TString start_pth = ExpandPathName("$FND_HISTOS/root-files");
00822   
00823 #if defined _FND_OUTPUTS_USE_SUBDIR
00824   CreateGrpSubDir(fRunType,fFirstRun,start_pth);
00825   TString fnam = BuildRunName(fRunType,fFirstRun,kTRUE);
00826 #else
00827   TString fnam = BuildRunName(fRunType,fFirstRun);
00828 #endif
00829   
00830   if(fLastRun != fFirstRun){
00831     fnam += "-";
00832     fnam += fLastRun;
00833   }
00834   fnam += "-monitor.root";
00835   
00836   TString outpath = "";
00837   outpath.Form("%s/%s",start_pth.Data(),fnam.Data());
00838   fOutFile = new TFile(outpath,"RECREATE");
00839 }
00840 
00841 //_______________________________
00842 void HdtAcc_Appl1::CloseOutputFile(){
00843 
00844   if(!fOutFile) return;
00845 
00846   if(fOutFile->IsOpen()) fOutFile->Close();
00847   delete fOutFile;
00848   fOutFile = 0;
00849 }
00850 
00851 //_______________________________
00852 void HdtAcc_Appl1::SaveGtsHistos(){
00853 
00854   for(Int_t i=0;i < K_N_GTS_P_UNITS ; i++){
00855     fHPU_cont[i]->Write();
00856     fHPU_mult[i]->Write();
00857   }
00858   
00859   for(Int_t i=0;i < K_N_GTS_SELECTORS ; i++){
00860     fHTrigSel[i]->Write();
00861   }
00862 }
00863 //_______________________________
00864 void HdtAcc_Appl1::SaveTofHistos(){
00865 
00866   fH_Tof_i_o_mult->Write();
00867   
00868   fH_Tof_map[0]->Write();   
00869   fH_Tof_map[1]->Write();   
00870   fH_Tof_map_mt[0]->Write();
00871   fH_Tof_map_mt[1]->Write();
00872 
00873   // --- 
00874   fH_Tofi_High_mult->Write();
00875   fH_Tofi_High_map ->Write();
00876 
00877   if(fHD_TofiMult) { fHD_TofiMult->Write(); } 
00878   if(fHD_TofoMult) { fHD_TofoMult->Write(); } 
00879 
00880 }
00881 //_______________________________
00882 void HdtAcc_Appl1::SaveSilHistos(){
00883   
00884   fH_Sil_Patt_Clust_Low[0]  ->Write();
00885   fH_Sil_Patt_Clust_High[0] ->Write();
00886   
00887   fH_Sil_Patt_Clust_Low[1]  ->Write();
00888   fH_Sil_Patt_Clust_High[1] ->Write();
00889 
00890 }
00891 //_______________________________
00892 void HdtAcc_Appl1::SaveLmdHistos(){
00893  
00894   fH_Lmd_i_o_mult->Write();
00895   fH_Lmd_tot_mult->Write();
00896 
00897   fH_Lmd_map[0]->Write();   
00898   fH_Lmd_map[1]->Write();  
00899 
00900 }
00901 //_______________________________
00902 void HdtAcc_Appl1::SaveStbHistos(){
00903 
00904   fH_Stb_mult->Write();
00905   
00906   for(Int_t ch=0;ch<K_N_STB_CROWNS;ch++ ){
00907     fH_Stb_map[ch]->Write(); 
00908     fH_Stb_Tdc[ch]->Write();
00909   }
00910 }
00911 //_______________________________
00912 void HdtAcc_Appl1::SaveNoiseHistos(){
00913 
00914   fH_Noise->Write();
00915   fH_Noise_Err->Write();
00916 }
00917 
00919 
00920 //_______________________________
00921 void HdtAcc_Appl1::ResetGtsHistos(){
00922 
00923   for(Int_t i=0;i < K_N_GTS_P_UNITS ; i++){
00924     fHPU_cont[i]->Reset();
00925     fHPU_mult[i]->Reset();
00926   }
00927   
00928   for(Int_t i=0;i < K_N_GTS_SELECTORS ; i++){
00929     fHTrigSel[i]->Reset();
00930   }
00931 }
00932 //_______________________________
00933 void HdtAcc_Appl1::ResetTofHistos(){
00934 
00935   fH_Tof_i_o_mult->Reset();
00936   
00937   fH_Tof_map[0]->Reset();   
00938   fH_Tof_map[1]->Reset();   
00939   fH_Tof_map_mt[0]->Reset();   
00940   fH_Tof_map_mt[1]->Reset();   
00941   
00942   // --- 
00943   fH_Tofi_High_mult->Reset();
00944   fH_Tofi_High_map ->Reset();
00945 
00946   if(fHD_TofiMult) { fHD_TofiMult->Reset(); } 
00947   if(fHD_TofoMult) { fHD_TofoMult->Reset(); } 
00948 
00949 }
00950 //_______________________________
00951 void HdtAcc_Appl1::ResetSilHistos(){
00952 
00953   fH_Sil_Patt_Clust_Low[0]  ->Reset();
00954   fH_Sil_Patt_Clust_High[0] ->Reset();
00955 
00956   fH_Sil_Patt_Clust_Low[1]  ->Reset();
00957   fH_Sil_Patt_Clust_High[1] ->Reset();
00958 
00959 }
00960 //_______________________________
00961 void HdtAcc_Appl1::ResetLmdHistos(){
00962 
00963   fH_Lmd_i_o_mult->Reset();
00964   fH_Lmd_tot_mult->Reset();
00965 
00966   fH_Lmd_map[0]->Reset();   
00967   fH_Lmd_map[1]->Reset();  
00968 
00969 }
00970 //_______________________________
00971 void HdtAcc_Appl1::ResetStbHistos(){
00972 
00973   fH_Stb_mult->Reset();
00974   
00975   for(Int_t ch=0;ch<K_N_STB_CROWNS;ch++ ){
00976     fH_Stb_map[ch]->Reset(); 
00977     fH_Stb_Tdc[ch]->Reset();
00978   }
00979   
00980 }
00981 //_______________________________
00982 void HdtAcc_Appl1::ResetNoiseHistos(){
00983 
00984   fH_Noise->Reset();
00985   fH_Noise_Err->Reset();
00986 }
00987 
00989 
00990 //_______________________________
00991 void HdtAcc_Appl1::RemoveGtsHistos(){
00992 
00993   for(Int_t i=0;i < K_N_GTS_P_UNITS ; i++){
00994     delete fHPU_cont[i]; fHPU_cont[i] = 0;
00995     delete fHPU_mult[i]; fHPU_mult[i] = 0;
00996   }
00997   
00998   for(Int_t i=0;i < K_N_GTS_SELECTORS ; i++){
00999     delete fHTrigSel[i]; fHTrigSel[i] = 0;
01000   }
01001 }
01002 //_______________________________
01003 void HdtAcc_Appl1::RemoveTofHistos(){
01004 
01005   delete fH_Tof_i_o_mult; fH_Tof_i_o_mult = 0;
01006   
01007   delete fH_Tof_map[0]; fH_Tof_map[0] = 0;   
01008   delete fH_Tof_map[1]; fH_Tof_map[1] = 0;
01009   delete fH_Tof_map_mt[0]; fH_Tof_map_mt[0] = 0;   
01010   delete fH_Tof_map_mt[1]; fH_Tof_map_mt[1] = 0;
01011   
01012   // --- 
01013   delete fH_Tofi_High_mult; fH_Tofi_High_mult = 0;
01014   delete fH_Tofi_High_map;  fH_Tofi_High_map = 0;
01015 
01016   // do not uncomment   if(fHD_TofiMult) { delete fHD_TofiMult; fHD_TofiMult = 0; } 
01017   // do not uncomment   if(fHD_TofoMult) { delete fHD_TofoMult; fHD_TofoMult = 0; } 
01018 
01019 }
01020 //_______________________________
01021 void HdtAcc_Appl1::RemoveSilHistos(){
01022 
01023   delete fH_Sil_Patt_Clust_Low[0]; fH_Sil_Patt_Clust_Low[0] = 0;
01024   delete fH_Sil_Patt_Clust_High[0]; fH_Sil_Patt_Clust_High[0] = 0;
01025 
01026   delete fH_Sil_Patt_Clust_Low[1]; fH_Sil_Patt_Clust_Low[1] = 0;
01027   delete fH_Sil_Patt_Clust_High[1]; fH_Sil_Patt_Clust_High[1] = 0;
01028 }
01029 //_______________________________
01030 void HdtAcc_Appl1::RemoveLmdHistos(){
01031 
01032   delete fH_Lmd_i_o_mult; fH_Lmd_i_o_mult = 0;
01033   delete fH_Lmd_tot_mult; fH_Lmd_tot_mult = 0;
01034 
01035   delete fH_Lmd_map[0];   fH_Lmd_map[0] = 0;
01036   delete fH_Lmd_map[1];   fH_Lmd_map[1] = 0;
01037 }
01038 //_______________________________
01039 void HdtAcc_Appl1::RemoveStbHistos(){
01040 
01041   delete fH_Stb_mult; fH_Stb_mult = 0;
01042   
01043   for(Int_t ch=0;ch<K_N_STB_CROWNS;ch++ ){
01044     delete fH_Stb_map[ch]; fH_Stb_map[ch] = 0;
01045     delete fH_Stb_Tdc[ch]; fH_Stb_Tdc[ch] = 0;
01046   }
01047   
01048 }
01049 //_______________________________
01050 void HdtAcc_Appl1::RemoveNoiseHistos(){
01051 
01052   delete fH_Noise; fH_Noise = 0;
01053   delete fH_Noise_Err; fH_Noise_Err = 0;
01054   
01055 }
01056 
01057   //_______________________________________________
01058   //_______________________________________________
01059   //_______________________________________________
01060 void RunSummaryHistos(TString run_type="FINU",Int_t first_run = -1,Int_t last_run = -1,Int_t n_evs_run=-1,Int_t n_evs_tot=-1){
01061   // this is an application of the official method for reading HDT-files
01062   //  (see $FROOTSYS/mcr_included/AccessHDT_MultiRun.C
01063 
01064   enum E_DisplaySaveMode_e {
01065     E_DisSavMod_DoNothing = 0,
01066     E_DisSavMod_DrawOnly = 1,
01067     E_DisSavMod_SavePdfOnly = 2,
01068     E_DisSavMod_SaveRootOnly = 3,
01069     E_DisSavMod_Complete = 4
01070   };
01071 
01072   E_DisplaySaveMode_e display_mode = E_DisSavMod_Complete;
01073 
01074   HdtAcc_Appl1 *hdt_appl = new HdtAcc_Appl1();
01075   Int_t debug_lev = 0;
01076   //
01077   hdt_appl->SetVerboseLevel(0);
01078   hdt_appl->SetUpdateEvGap(3000);
01079   //
01080   hdt_appl->InitHistos();
01081   hdt_appl->Init("$MSQL_DB_HOST","$RDT",run_type,first_run,last_run,n_evs_run,n_evs_tot,debug_lev);
01082 
01083   Int_t res_loop =  hdt_appl->RunLoop();
01084   if( res_loop != 0 ) return;
01085   
01086   if(display_mode != E_DisSavMod_DoNothing){
01087     hdt_appl->DrawSummaryHistos();  
01088     if(display_mode == E_DisSavMod_SaveRootOnly || display_mode == E_DisSavMod_Complete)
01089       hdt_appl->SaveHistos(); 
01090     
01091     if(display_mode == E_DisSavMod_SavePdfOnly || display_mode == E_DisSavMod_Complete)
01092       hdt_appl->SaveSummaryPdf();// histograms will be lost after this line
01093     
01094     hdt_appl->CloseOutputFile();// histograms will be lost after this line
01095   }
01096   // --- 
01097   if(display_mode != E_DisSavMod_DrawOnly) delete hdt_appl; // need to keep histos
01098   
01099 }

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