PREAN/TFndPreanScalers.h

00001 // @(#)fROOT/PREAN:$Name:  $:$Id: TFndPreanScalers.h,v 1.4 2007/09/05 10:15:21 Diego_Faso Exp $
00002 // Author: H. So , 2006/05/29
00003 
00004 #ifndef FROOT_TFndPreanScalers
00005 #define FROOT_TFndPreanScalers
00006 
00007 #include <string>
00008 #include <fstream>
00009 #include <TObject.h>
00010 #include <TDatime.h>
00011 
00012 #include "FROOT.h"
00013 
00014 class TFndPreanScalers : public TObject {
00015 public:
00016   enum EDaqStatus {
00017     kStopped = 0,
00018     kCrashed = 1,
00019     kActive  = 5
00020   };
00021 
00022   enum {
00023     kScalerInterval  = 15,      // raw files are written in every 15 seconds
00024     kSecondsPerDay   = 86400,
00025     kEvhLen          = 16,      // length of the Global Event Header
00026     kGtsLen          = 36,      // length of the GTS buffer
00027     kScbLen          = 82,      // length of the VME scaler buffers in total
00028   };
00029 
00030   struct Data {
00031     UInt_t evh[kEvhLen];        // copy of the Global Event Header
00032     UInt_t gts[kGtsLen];        // copy of the GTS buffer
00033     UInt_t scb[kScbLen];        // copy of the VME scaler buffer
00034     Data(const UInt_t rawEvent[]);
00035   };
00036 
00037 public:
00038   static TFndPreanScalers *Instance(); // Get the singleton instance
00039   Int_t Write(const Data &data);
00040 
00041 protected:
00042   TFndPreanScalers();
00043   ~TFndPreanScalers();
00044 
00045 private:
00046   TFndPreanScalers(const TFndPreanScalers &); // Noncopiable; not implemented,
00047   TFndPreanScalers &operator = (const TFndPreanScalers &); // Noncopiable; not implemented,
00048 
00049 private:
00050   Int_t RecreateFastFiles();
00051   Int_t CloseFastFiles();
00052   Int_t WriteFastFiles(const std::string &readScalerText, const std::string &runInfoText);
00053 
00054   Int_t OpenRawFiles();
00055   Int_t CloseRawFiles();
00056   Int_t WriteRawFiles(const std::string &scalerText, const std::string &scalerInfoText);
00057 
00058   void        CalculateRate(const UInt_t v[], const UInt_t v0[], Float_t vr[]);
00059   std::string GenerateReadScalerText(const UInt_t evh[], const Float_t vr[], UInt_t daqStatus);
00060   std::string GenerateRunInfoText(const UInt_t evh[], const UInt_t gts[], const Float_t vr[], UInt_t daqStatus);
00061 
00062 private:
00063   // time
00064   TDatime fDatime;
00065   UInt_t  fCurTime;
00066   UInt_t  fSavedTime;           // in seconds
00067   UInt_t  fSavedDay;
00068   UInt_t  fSavedFif;            // 15 seconds interval
00069 
00070   // data
00071   UInt_t fV0[kScbLen];          // holds counts at time n-1
00072   UInt_t fBhaInt;               // holds the integral counts of Bhabha collected in 15 sec at time n
00073   UInt_t fBhaInt0;              // holds the integral counts of Bhabha at time n-15sec
00074   UInt_t fHypInt;               // holds the integral counts of Hyp collected in 15 sec at time n
00075   UInt_t fHypInt0;              // holds the integral counts of Hyp at time n-15sec
00076   UInt_t fSavedEvNum;           // holds the hardware event number at time n-1
00077 
00078   // files:
00079   //   0: selected for DAFNE
00080   //   1: all scalers
00081   TString       fPath[2];       // path to the data files
00082   int           fFastFd[2];     // fast raw-file descriptors (written via low-level system calls)
00083   std::ofstream fRawFile[2];    // (slow) raw-file streams
00084 
00085 private:
00086   ClassDef(TFndPreanScalers, 0) // preanalyzer for scaler data
00087 };
00088 
00089 #endif // FROOT_TFndPreanScalers

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