Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

TDragonRun.h

Go to the documentation of this file.
00001 // TDragonRun.h.
00002 // author  JEP, J. Chuma.
00003 // brief   Dragon run class, used as a driver class.
00004 // version 1.2.
00005 // date    December 2003.
00006 //
00007 #ifndef TDRAGONRUN_H
00008 #define TDRAGONRUN_H
00009 
00010 #include <vector>
00011 #include <string>
00012 
00013 #include <TFile.h>
00014 #include <TTree.h>
00015 
00016 #include "THiDetector.h"
00017 #include "TGrDetector.h"
00018 #include "TMidasFile.h"
00019 
00020 class TMidasEvent;
00021 class TDragonEvent;
00022 class TScalerEvent;
00023 class TEpicsEvent;
00024 
00025 using std::vector;
00026 using std::string;
00027 
00028 class TDragonRun {
00029 public:
00030   TDragonRun();
00031   ~TDragonRun();
00032   void SetHiModules(const UShort_t *, const UInt_t &,
00033                     const UShort_t *, const UInt_t &);
00034   void SetGrModules(const UShort_t *, const UInt_t &,
00035                     const UShort_t *, const UInt_t &);
00036   void SetDebug(Bool_t);
00037   void SetDatabase(const Char_t *);
00038   Bool_t HasDetector(const Char_t *) const;
00039   void AddDetector(THiDetector *);
00040   void AddDetector(TGrDetector *);
00041   void OpenRootFile(const Char_t *);
00042   void OpenMidasFile(const Char_t *);
00043   Bool_t ReadMidasEvent();
00044   Bool_t UnpackDragonEvent();
00045   Bool_t UnpackScalerEvent();
00046   Bool_t UnpackEpicsEvent();
00047   void WriteTree() const;
00048   void CloseRootFile() const;
00049   void CloseMidasFile() const;
00050   void GetModules(vector<UShort_t> *, const Char_t *, const Char_t *);
00051   vector<THiDetector *> & GetHiDetectors();
00052   vector<TGrDetector *> & GetGrDetectors();
00053   TMidasEvent * GetMidasEvent() const;
00054   TDragonEvent * GetDragonEvent() const;
00055   TScalerEvent * GetScalerEvent() const;
00056   TEpicsEvent * GetEpicsEvent() const;
00057   TTree * ReadDragonTree(const Char_t *) const;
00058   void TestDragonTree(const Char_t * = 0) const;
00059 
00063   enum EEventId {kEV_BOR      = 0x8000, kEV_EOR      = 0x8001,
00064                  kEV_DRAGON_G = 0x0001, kEV_DRAGON_H = 0x0004,
00065                  kEV_EPICS    = 0x0014, kEV_SCALER   = 0x0002};
00069   enum ETrigMask {kTRIG_DRAGON_HMEM = 0x0002, kTRIG_DRAGON_GMEM = 0x0008,
00070                   kTRIG_DRAGON_CHME = 0x0001, kTRIG_DRAGON_CGME = 0x0004,
00071                   kTRIG_SCALER      = 0x0000, kTRIG_EPICS       = 0x0064};
00072 
00073 private:
00076   string fDatabase;
00079   TFile *fRootFile;
00082   TMidasFile *fMidasFile;
00085   TTree *fDragonTree;
00089   TMidasEvent *fMidasEvent;
00093   TDragonEvent *fDragonEvent;
00097   TScalerEvent *fScalerEvent;
00101   TEpicsEvent *fEpicsEvent;
00106   vector<THiDetector *> fDetectorsH;
00111   vector<TGrDetector *> fDetectorsG;
00117   UInt_t fAdcSlotsH;
00123   UInt_t fTdcSlotsH;
00126   UInt_t *fAdcSlotH;
00129   UInt_t *fTdcSlotH;
00135   UInt_t fAdcSlotsG;
00140   UInt_t fTdcSlotsG;
00143   UInt_t *fAdcSlotG;
00146   UInt_t *fTdcSlotG;
00149   const UShort_t fFeraHeaderBit;
00152   UShort_t fHeaderWordG;
00155   UShort_t fHeaderWordH;
00161   Bool_t fDebug;
00162 
00163   TDragonRun(const TDragonRun &);
00164   TDragonRun & operator=(const TDragonRun &);
00165   void SetTree();
00166   Int_t DumpSubEventH(Int_t, const UShort_t *, Int_t) const;
00167   Int_t DumpSubEventG(Int_t, const UShort_t *, Int_t) const;
00168   Int_t UnpackSubEventH(Int_t, const UShort_t *, Int_t, TSubEvent &) const;
00169   Int_t UnpackSubEventG(Int_t, const UShort_t *, Int_t, TSubEvent &) const;
00170   Int_t DumpScaler(const UInt_t *, Int_t) const;
00171   Int_t UnpackScaler(const UInt_t *, Int_t,
00172                      vector<TDataItem<UInt_t> > &) const;
00173   Int_t DumpEpics(const Float_t *, Int_t) const;
00174   Int_t UnpackEpics(const Float_t *, Int_t,
00175                     vector<TDataItem<Float_t> > &) const;
00176   UInt_t * SetModules(const UShort_t *, UInt_t, UInt_t &);
00177 };
00178 
00179 inline void TDragonRun::SetDebug(Bool_t debug)
00180 {
00189   fDebug = debug;
00190 }
00191 
00192 inline void TDragonRun::SetDatabase(const Char_t *database)
00193 {
00197   fDatabase = database;
00198   cout << "SetDatabase: Using database \"" << fDatabase << "\"" << endl;
00199 }
00200 
00201 inline Bool_t TDragonRun::ReadMidasEvent()
00202 {
00207   return fMidasFile->Read(fMidasEvent);
00208 }
00209 
00210 inline void TDragonRun::WriteTree() const
00211 {
00216   fDragonTree->Fill();
00217 }
00218 
00219 inline void TDragonRun::CloseRootFile() const
00220 {
00223   fRootFile->Write();
00224   fRootFile->Close("R");
00225 }
00226 
00227 inline void TDragonRun::CloseMidasFile() const
00228 {
00231   fMidasFile->Close();
00232 }
00233 
00234 inline TMidasEvent * TDragonRun::GetMidasEvent() const
00235 {
00248   return fMidasEvent;
00249 }
00250 
00251 inline TDragonEvent * TDragonRun::GetDragonEvent() const
00252 {
00267   return fDragonEvent;
00268 }
00269 
00270 inline TScalerEvent * TDragonRun::GetScalerEvent() const
00271 {
00286   return fScalerEvent;
00287 }
00288 
00289 inline TEpicsEvent * TDragonRun::GetEpicsEvent() const
00290 {
00305   return fEpicsEvent;
00306 }
00307 
00308 inline vector<THiDetector *> & TDragonRun::GetHiDetectors()
00309 {
00313   return fDetectorsH;
00314 }
00315 
00316 inline vector<TGrDetector *> & TDragonRun::GetGrDetectors()
00317 {
00321   return fDetectorsG;
00322 }
00323 
00324 #endif // TDragonRun.h

Generated on Mon Jan 8 11:54:31 2007 for DragonRoot by  doxygen 1.3.9.1