PREAN/TFndPreanHistos.h

00001 // @(#)fROOT/PREAN:$Name:  $:$Id: TFndPreanHistos.h,v 1.24 2007/10/04 14:10:26 Diego_Faso Exp $
00002 // Author: Diego Faso <mailto:faso@to.infn.it>, 2005/06/24
00003 
00004 #ifndef FROOT_TFndPreanHistos
00005 #define FROOT_TFndPreanHistos
00006 
00007 #include <Riostream.h>
00008 #include "TROOT.h"
00009 #include "TSystem.h"
00010 #include "TApplication.h"
00011 
00012 #include "TString.h"
00013 #include "TThread.h"
00014 
00015 #include "TFile.h"
00016 #include "TTree.h"
00017 #include "TCanvas.h"
00018 #include "TStyle.h"
00019 #include "TH2.h"
00020 #include "TH3F.h"
00021 
00022 #include "TFndGraphs.h"
00023 #include "TFndPrean.h"
00024 
00025 class TFndPreanHistos: public TFndPrean{
00026 
00027  public:
00028   enum E_FndPreanShowNCanv
00029     {
00030       PreanShow_N_BhaCanv = 2,
00031       PreanShow_N_HypCanv = 3,
00032     };
00033   
00034   Int_t TrkTypes() { return 7; }
00035   Int_t TrkType(Int_t id,TString &str){
00036     switch(id){
00037     case 0: str = "ANY";        return    -1; // ANY
00038     case 1: str = "FWD-LONG";   return 11110; // FWD-LONG
00039     case 2: str = "FWD-SHORT";  return  1110; // FWD-SHORT
00040     case 3: str = "BCK-XLONG";  return 11112; // BCK-EXTRA-LONG
00041     case 4: str = "BCK-LONG";   return  1112; // BCK-LONG
00042     case 5: str = "BCK-SHORT";  return   112; // BCK-LONG
00043     case 6: str = "BCK-XSHORT"; return    12; // BCK-EXTRA-SHORT
00044     default: return 0;
00045     }
00046     return 0;
00047   }
00048 
00049   // following paths are referred to targets (fwd positive particles)
00050   UInt_t GetSelMuPath(Int_t pathnum){
00051     switch(pathnum){
00052       /*     case 1: return 0x33100; */
00053       /*     case 2: return 0x22300; */
00054       /*     case 3: return 0x11400; */
00055       /*     case 4: return 0x88500; */
00056       /*     case 5: return 0x77600; */
00057       /*     case 6: return 0x66800; */
00058       /*     case 7: return 0x55900; */
00059       /*     case 8: return 0x44A00; */
00060     case 1: return 0x44100;
00061     case 2: return 0x33200;
00062     case 3: return 0x22300;
00063     case 4: return 0x11500;
00064     case 5: return 0x88600;
00065     case 6: return 0x77700;
00066     case 7: return 0x66900;
00067     case 8: return 0x55A00;
00068     default:
00069       Error("MuPathName","pathnum \"%d\" not available (possible BUG!)",pathnum);
00070       TerminateFroot();
00071     }
00072 
00073   }
00074 
00075   
00076   TString MuPathNameTitle(Int_t pathnum,Bool_t is_name){
00077     switch(pathnum){
00078     case 1: return (is_name) ? "t1_1-4-4" : "t1: 1,4,4";
00079     case 2: return (is_name) ? "t2_2-3-3" : "t2: 2,3,3";
00080     case 3: return (is_name) ? "t3_3-2-2" : "t3: 3,2,2";
00081     case 4: return (is_name) ? "t4_5-1-1" : "t4: 5,1,1";
00082     case 5: return (is_name) ? "t5_6-8-8" : "t5: 6,8,8";
00083     case 6: return (is_name) ? "t6_7-7-7" : "t6: 7,7,7";
00084     case 7: return (is_name) ? "t7_9-6-6" : "t7: 9,6,6";
00085     case 8: return (is_name) ? "t8_A-5-5" : "t8: 10,5,5";
00086     default:
00087       Error("MuPathName","pathnum \"%d\" not available (possible BUG!)",pathnum);
00088       TerminateFroot();
00089     }
00090   }
00091 
00092  protected:
00093   // bhabha show
00094   Bool_t fGesHistosInitialized;
00095   Bool_t fBhabhaHistosInitialized;
00096   Bool_t fHypeHistosInitialized;
00097   Bool_t fStatGraphsInitialized;
00098 
00099   Int_t fKstopMarkCol[E_Kaon_Stop_Other+1];
00100   
00101   // bhabha show
00102   TCanvas *fBhabhaCanvas[PreanShow_N_BhaCanv];
00103   TCanvas *fHypeCanvas[PreanShow_N_HypCanv];
00104     
00105   // public:
00106  protected:
00107   
00108   // ges histos
00109   TH1F *fH_GesTrigBit; // trigger-bit value
00110 
00111   // bhabha histos
00112   TH2F *fH_BhaMom_2D; // negative vs positive momentum
00113 
00114   TH1F *fH_InvMass_EpluEmin; // invariant mass (hypothesys: bhabha e+e- pair)
00115   TH1F *fH_InvMass_PIpluPImin; // invariant mass (hypothesys: K_short decay)
00116 
00117   TH3F *fH_BhaVert_XYZ; // 3D reconstructed position (interaction point)
00118   TH2F *fH_BhaVert_XY; // Y vs X reconstructed position (interaction point)
00119   TH2F *fH_BhaVert_XZ; // Z vs X reconstructed position (interaction point)
00120 
00121   TH1F *fH_BhaTracksAngle; // angle between the two tracks
00122   TH1F *fH_BhaTotalMomentum; // total momentum (scalar product) [filled but not drawn]
00123   
00124   // --- BHABHA TOF time added after version 9.00/01
00125   TH2F *fH_BhaParticleTOF_2D; // negative vs positive TOF (calib. TOFONE - calib. TOFINO)
00126   TH1F *fH_BhaTofi_TimeDiff; // Time difference between e+ and e- at TOFINO
00127   TH2F *fH_BhaTofi_Time_2D;  // Time of e- vs time of e+
00128   TH1F *fH_BhaTofo_TimeDiff; // Time difference between e+ and e- at TOFONE
00129 
00130   // ---
00131 
00132   // hype histos
00133   TH1F *fH_Hyp_PattRecErr;
00134 
00135   TH2F *fH_HypKmin_stop_XY[E_Kaon_Stop_Other+1];
00136   TH2F *fH_HypKplu_stop_XY[E_Kaon_Stop_Other+1];
00137 
00138   TH1F *fH_Hyp_Kmin_StopCode; // volume in which kaon stopped
00139   TH1F *fH_Hyp_Kplu_StopCode; // volume in which kaon stopped
00140 
00141   TH1F *fH_Hyp_Kmin_StopTgt; // K- stop target number if stopped inside target
00142   TH1F *fH_Hyp_Kplu_StopTgt; // K+ stop target number if stopped inside target
00143   TH2F *fH_Hyp_K_StopTgt_2D; // (K- vs K+) if stopped inside target
00144   
00145   TH1F *fH_Hyp_Kmin_StopVol; // K- stop volume number if stopped inside target
00146   TH1F *fH_Hyp_Kplu_StopVol; // K+ stop volume number if stopped inside target
00147   TH2F *fH_Hyp_K_StopVol_2D; // (K- vs K+) if stopped outside target
00148 
00149   TH3F *fH_Hyp_PhiDecPos_XYZ; // 3D reconstructed position (phi decay)
00150   TH2F *fH_Hyp_PhiDecPos_XY; // Y vs X reconstructed position (phi decay)
00151   TH2F *fH_Hyp_PhiDecPos_XZ; // Z vs X reconstructed position (phi decay)
00152   TH1F *fH_PhiDecPos_X;      // X reconstructed position (phi decay)
00153   TH1F *fH_PhiDecPos_Y;      // Y reconstructed position (phi decay)
00154   TH1F *fH_PhiDecPos_Z;      // Z reconstructed position (phi decay)
00155   
00156   TH1F *fH_HypTrk_KpluPosAll; // pos tracks from K+ overall targets (no path selection)
00157   TH1F *fH_HypTrk_KpluPosPthAll; // pos tracks from K+ overall targets (path selection)
00158 
00159   TH1F *fH_HypTrk_KpluPosTgt[8]; // one histo for each target (no path selection)
00160   TH1F *fH_HypTrk_KpluPosPth[8]; // one histo for each target (path selection)
00161 
00162   // --- K+/K-/mu+ TOF time added at version 9.01/02
00163   TH1F *fH_Hyp_KTofi_TimeDiff; // Time difference between K- and K+ at TOFINO
00164   TH2F *fH_Hyp_KTofi_Time_2D;  // Time of K- vs time of K+ at TOFINO
00165   TH1F *fH_Hyp_MuTof; // Muon+ time of flight (raw)
00166   TH1F *fH_Hyp_MuTofCorr; // Muon+ time of flight (corrected by track length/momentum)
00167   // ---
00168   Int_t fCount_EventTotal;
00169   // --- run-dependences (variables as a function of the run number)
00170   // scalers variables (resetted at every run)
00171   Int_t fCount_EventPerRun;
00172   Int_t fCount_KminPerRun;
00173   Int_t fCount_KpluPerRun;
00174   Int_t fCount_Stat_Time[E_Scal_Inhib_End];
00175   Int_t fCount_Stat_BhaNum[E_Scal_Inhib_End];
00176   Int_t fCount_Stat_HypNum[E_Scal_Inhib_End];
00177   //
00178 
00179   // --- evaluated variables (on the ovaerall statistics)
00180   // --- HYPE from K+
00181   Int_t fEval_NumOfStoppedKplu[8]; // K+ stopped per target
00182   Int_t fEval_NumOfStoppedKplu_All; // K+ stopped overall targets
00183   
00184   Int_t fEval_NumOf_Mu_plu[8]; // mu+ stopped per target
00185   Int_t fEval_NumOf_Mu_plu_All; // mu+ stopped overall targets
00186 
00187   Int_t fEval_NumOf_Mu_plu_Pth[8]; // mu+ stopped per target (forward)
00188   Int_t fEval_NumOf_Mu_plu_Pth_All; // mu+ stopped overall targets (forward)
00189 
00190   Float_t fEval_RecEff[8]; // reconstruction efficiency per target (eval on all mu+)
00191   Float_t fEval_RecEff_All; // reconstruction efficiency overall targets (eval on all mu+)
00192   Float_t fEval_RecEff_Pth[8]; // reconstruction efficiency per target (eval on fwd mu+)
00193   Float_t fEval_RecEff_Pth_All; // reconstruction efficiency overall targets (eval on fwd mu+)
00194 
00195   // --- HYPE from K-
00196   Int_t fEval_NumOfStoppedKmin[8]; // K+ stopped per target
00197   Int_t fEval_NumOfStoppedKmin_All; // K+ stopped overall targets
00198 
00199 
00200   // stat histos (scalers)
00201   TFndGraph *fGR_Stat_Evs;
00202 
00203   TFndGraph *fGR_Stat_BhaNum[E_Scal_Inhib_End];  
00204   TFndGraph *fGR_Stat_HypNum[E_Scal_Inhib_End];  
00205   TFndGraph *fGR_Stat_AvgLum[E_Scal_Inhib_End];  
00206   TFndGraph *fGR_Stat_IntLum[E_Scal_Inhib_End];  
00207   TFndGraph *fGR_Stat_IntLum_Tot[E_Scal_Inhib_End];  
00208 
00209   TFndGraph *fGR_Stat_KminStop_Num; // total number of stopped K- / inv.nb (all targets)
00210   TFndGraph *fGR_Stat_KpluStop_Num; // total number of stopped K+ / inv.nb (all targets)
00211 
00212   TFndGraph *fGR_Stat_MuPluAll_Num; // total number of mu-plu/ inv.nb /run (all targets)
00213   TFndGraph *fGR_Stat_MuPluAll_Mom; // mu-plu momentum/run (all targets)
00214 
00215   TFndGraph *fGR_Stat_BhaRec_Num; // total number of Bhabha rec / inv.nb (from "e+e-" invariant-mass)
00216   TFndGraph *fGR_Stat_BhaRec_ECMee; // center of mass energy (from "e+e-" invariant-mass)
00217   TFndGraph *fGR_Stat_BhaRec_Kshort_Num; // total number of K_short rec / inv.nb (from "K_short")
00218   TFndGraph *fGR_Stat_BhaRec_Kshort_InvMass; // invariant mass pi+pi- (from "K_short" )
00219   TFndGraph *fGR_Stat_BhaRec_Ratio; // K_short/Bhabha ratio
00220 
00221   // temporary storage histograms
00222   TH1F *fHTmp_MuPluAll;
00223   TH1F *fHTmp_BhaInvMass;
00224   TH1F *fHTmp_PionsInvMass;
00225 
00226   // stat histos (hype)
00227   // --- mu+ vs run_num
00228 
00229   // --- evaluation data-members
00230   //  some of them are available from histograms
00231   //  (not really calculated)
00232   //  but they are reported as single data-member
00233   //  in order to be easier to handle
00234 
00235   // --- SELECTIONS (quality cuts)
00236   Bool_t fCut_Fitted;
00237   Int_t  fCut_TrkType; // -1 means any
00238   
00239  private:
00240   void InitStatGraphs();
00241   void DeleteStatGraphs();
00242 
00243   void InitGesHistos();
00244   void InitBhabhaHistos();
00245   void InitHypeHistos();
00246   
00247   void ResetGesHistos();
00248   void ResetBhabhaHistos();
00249   void ResetHypeHistos();
00250 
00251   void WriteGesHistos();
00252   void WriteBhabhaHistos();
00253   void WriteHypeHistos();
00254   void WriteStatGraphs();
00255 
00256   void LoadGesHistos(TFile *fin);
00257   void LoadBhabhaHistos(TFile *fin);
00258   void LoadHypeHistos(TFile *fin);
00259   void LoadStatHistos(TFile *fin);
00260 
00261   void FillGesHistos();
00262   void FillBhabhaHistos();
00263   void FillHypeHistos();
00264   void FillScalVariables();
00265   
00266   void EvalGesHistos();
00267   void EvalBhabhaHistos();
00268   void EvalHypeHistos();
00269   void EvalStatGraphs(const Int_t &cur_run);
00270   
00271   void AddSingleHistoFromFile(TH1 *hori,TFile *fin){
00272     if(!hori || !fin){
00273       Error("AddSingleHistoFromFile","At least one NULL argument!");
00274       return;
00275     }
00276     hori->Add( (TH1*) (fin->Get( hori->GetName() ) ) );
00277   }
00278   
00279   void LoadSingleGraphFromFile(TFndGraph *pori,TFile *fin){
00280     if(!pori || !fin){
00281       Error("LoadSingleGraphFromFile","At least one NULL argument!");
00282       return;
00283     }
00284     
00285     TFndGraph *grfil =  (TFndGraph *) ( fin->Get( pori->GetName() ) );
00286     Double_t px = 0;
00287     Double_t py = 0;
00288     Double_t ex = 0;
00289     Double_t ey = 0;
00290     for(Int_t p=0;p<grfil->GetN();p++){
00291       grfil->GetPoint(p,px,py);
00292       ex = grfil->GetErrorX(p);
00293       ey = grfil->GetErrorY(p);
00294       pori->AddPoint(px,py,ex,ey);
00295     }
00296     grfil = 0; // deleted lately while closing source file
00297   }
00298 
00299  public:
00300   TFndPreanHistos();
00301   ~TFndPreanHistos();
00302   
00303   void InitHistos()
00304     {
00305     // need to use the "hist" draw option
00306     //  in order to remove error-bars
00307     InitGesHistos();
00308     InitBhabhaHistos();
00309     InitHypeHistos();
00310     InitStatGraphs();
00311   }
00312 
00313   void ResetHistos()
00314   {
00315     ResetGesHistos();
00316     ResetBhabhaHistos();
00317     ResetHypeHistos();
00318   }
00319 
00320   void ResetStatGraphs(const Bool_t &recreate);
00321   //  void ResetStatHistos(const Int_t &first_run,const Int_t &last_run);
00322 
00323   void FillHistos()
00324   {
00325     FillGesHistos();
00326     FillBhabhaHistos();
00327     FillHypeHistos();
00328     FillScalVariables();
00329   }
00330   
00331   // --- Calculations on histograms content
00332   void EvalHistos()
00333     {
00334       EvalGesHistos();
00335       EvalBhabhaHistos();
00336       EvalHypeHistos();
00337     }
00338   
00339   void WriteHistosToFile(const TString &fnam);
00340   void LoadHistosFromFile(const TString &fnam);
00341 
00342   // ---
00343   friend class TFndPreanGUI;
00344     
00345   ClassDef(TFndPreanHistos,1)
00346 };
00347 
00348 
00349 #endif // FROOT_TFndPreanHistos

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