00001
00002
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,
00024 kSecondsPerDay = 86400,
00025 kEvhLen = 16,
00026 kGtsLen = 36,
00027 kScbLen = 82,
00028 };
00029
00030 struct Data {
00031 UInt_t evh[kEvhLen];
00032 UInt_t gts[kGtsLen];
00033 UInt_t scb[kScbLen];
00034 Data(const UInt_t rawEvent[]);
00035 };
00036
00037 public:
00038 static TFndPreanScalers *Instance();
00039 Int_t Write(const Data &data);
00040
00041 protected:
00042 TFndPreanScalers();
00043 ~TFndPreanScalers();
00044
00045 private:
00046 TFndPreanScalers(const TFndPreanScalers &);
00047 TFndPreanScalers &operator = (const TFndPreanScalers &);
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
00064 TDatime fDatime;
00065 UInt_t fCurTime;
00066 UInt_t fSavedTime;
00067 UInt_t fSavedDay;
00068 UInt_t fSavedFif;
00069
00070
00071 UInt_t fV0[kScbLen];
00072 UInt_t fBhaInt;
00073 UInt_t fBhaInt0;
00074 UInt_t fHypInt;
00075 UInt_t fHypInt0;
00076 UInt_t fSavedEvNum;
00077
00078
00079
00080
00081 TString fPath[2];
00082 int fFastFd[2];
00083 std::ofstream fRawFile[2];
00084
00085 private:
00086 ClassDef(TFndPreanScalers, 0)
00087 };
00088
00089 #endif // FROOT_TFndPreanScalers