SIL/TFndSilMon.h

00001 // @(#)fROOT/SIL:$Name:  $:$Id: TFndSilMon.h,v 1.13 2007/09/05 10:40:27 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>, 2002
00004 
00005 #ifndef FROOT_TFndSilMon
00006 #define FROOT_TFndSilMon
00007 
00009 //                                             //
00010 //                 TFndSilMon                  //
00011 //                                             //
00012 // Base class fir of the Sil  online monitor   //
00013 //   - Histograms collection and filling       //
00014 //   - Shared memories management              //
00015 //                                             //
00016 //  see GTS relative class for documentation   //
00017 //                                             //
00019 
00020 #include "FROOT.h"
00021 
00022 #include "TFile.h"
00023 #ifdef _FND_ONL_USE_MAP_FILES_
00024 #include "TMapFile.h"
00025 #endif
00026 #include "TFndFeeMap.h"
00027 #include "TH1.h"
00028 #include "TH2.h"
00029 
00030 #include "TClonesArray.h"
00031 #include "TObject.h"
00032 
00033 class TFndHdt;
00034 
00035 using namespace FROOT;
00036 
00037 class TFndSilMon : public TObject {
00038   
00039  protected:
00040 
00041   Int_t  shmflg;  // Shared Memory flag
00042   TFile *fout;
00043   Int_t  fDet;    // see FROOT::E_Fnd_Layer
00044   TFile *fsil;    // Sil histogram file
00045 
00046 #if defined _FND_ONL_USE_MAP_FILES_
00047   TMapFile *msil;  // SIL shared memory
00048 #elif defined _FND_ONL_USE_SHARED_FILES_
00049   TFile *msil;  // SIL shared memory
00050 #endif
00051 
00052   // --- shared memories/files names
00053   Bool_t fMustRecoverHistos; // true if a recovery must be performed after a break
00054   
00055   TString fSharedMemName[2];  // isim/osim shared memory name
00056   TString fSharedFileName[2]; // isim/osim shared file name
00057 
00058   // --- histograms 
00059 
00060   TH1F * fH_Sil_Noise[E_FIN_OUTER_LAYER][K_N_Sil_Modules][K_N_Sil_Sides]; // -0.5 , 1023.5, 1024
00061   TH1F * fH_Sil_Mult[E_FIN_OUTER_LAYER][K_N_Sil_Modules][K_N_Sil_Sides]; // -0.5 , 1023.5, 1024
00062   TH1F * fH_Sil_ClCh[E_FIN_OUTER_LAYER][K_N_Sil_Modules][K_N_Sil_Sides]; // -0.5 , 800.5, 801
00063   TH1F * fH_Sil_CMsigma[E_FIN_OUTER_LAYER][K_N_Sil_Modules][K_N_Sil_Sides]; // -0.5 , 7.5, 8
00064   TH1F * fH_Sil_CMmean[E_FIN_OUTER_LAYER][K_N_Sil_Modules][K_N_Sil_Sides]; // -0.5 , 7.5, 8
00065 
00066   // --- after clusters evaluation (sides are phi/n (zeta): no separation between "Za" and "Zb")
00067   TH1F * fH_Sil_CleanMult[E_FIN_OUTER_LAYER][K_N_Sil_Modules][K_N_Sil_Sides-1];
00068   TH1F * fH_Sil_ClChClean[E_FIN_OUTER_LAYER][K_N_Sil_Modules][K_N_Sil_Sides-1];
00069   TH1F * fH_Sil_dEdx[E_FIN_OUTER_LAYER][K_N_Sil_Modules][K_N_Sil_Sides-1];
00070   TH2F * fH_Sil_dEdx_PvsZ[E_FIN_OUTER_LAYER][K_N_Sil_Modules];
00071   TH2F * fH_Sil_Pos_PvsZ[E_FIN_OUTER_LAYER][K_N_Sil_Modules];
00072 
00073   Double_t fComMod_sum[(Int_t)K_N_Sil_AdcChips][(Int_t)K_N_Sil_Sides][(Int_t)K_N_Sil_Modules+1][(Int_t)E_FIN_OUTER_LAYER+1]; 
00074   Double_t fComMod_square[(Int_t)K_N_Sil_AdcChips][(Int_t)K_N_Sil_Sides][(Int_t)K_N_Sil_Modules+1][(Int_t)E_FIN_OUTER_LAYER+1]; 
00075   Double_t fComMod_events[(Int_t)K_N_Sil_AdcChips][(Int_t)K_N_Sil_Sides][(Int_t)K_N_Sil_Modules+1][(Int_t)E_FIN_OUTER_LAYER+1]; 
00076 
00077   void FillCommonMode(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer, Double_t val){
00078     fComMod_sum[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] += val;
00079     fComMod_square[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] += (val*val);
00080     fComMod_events[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] += 1.;
00081   }
00082 
00083   void SetZeroCommonMode(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer){
00084     fComMod_sum[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] = 0.;
00085     fComMod_square[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] = 0.;
00086     fComMod_events[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] = 0.;
00087   }
00088 
00089   Double_t GetMeanCommonMode(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer){
00090     return ((fComMod_events[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] > 0.) ? (fComMod_sum[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] / fComMod_events[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer]) : 0.) ;
00091   }
00092 
00093   Double_t GetSigmaCommonMode(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer){
00094     Double_t meanval = GetMeanCommonMode(Sil_AdcChip, Sil_Side, Sil_Module, Sil_Layer);
00095     return ((fComMod_events[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] > 0.) ? (TMath::Sqrt( fComMod_square[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] / fComMod_events[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] - meanval * meanval)) : 0.)  ;
00096   }
00097 
00098   // ---
00099   void Init(); // called by ctors
00100 
00101   void InitHistos(); // try to recover histograms from shared file (if still available...)
00102   void OpenSharedFiles(const TString &fmode); // will handle shared memories/files creation
00103   void Fill(const TClonesArray &SilClus);     // Fill Histograms in shared memories
00104 
00105  public:
00106 
00107   TFndSilMon();
00108   TFndSilMon(const TString &fmode, Int_t det);  // Constructor used by producers
00109   ~TFndSilMon();
00110   void Fill();                     // Fill Histograms in shared memories/files
00111   void Update(Bool_t purge=kTRUE); // Update shared memories (online only)
00112   void ResetHistos();
00113   void WriteToFile(TString filename=0,Bool_t IsShared = kFALSE);     // Write Histograms to File 
00114 
00115   friend class TFndSilMonFrame;
00116      
00117   ClassDef(TFndSilMon,1) // The SIL monitor producer
00118   };
00119 
00120 #endif // FROOT_TFndSilMon
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 

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