]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RAW/AliMDC.h
Separated TOF libraries (base,rec,sim)
[u/mrichter/AliRoot.git] / RAW / AliMDC.h
1 #ifndef ALIMDC_H
2 #define ALIMDC_H
3 // @(#)alimdc:$Name$:$Id$
4 // Author: Fons Rademakers  26/11/99
5
6 /* Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
7  * See cxx source for full Copyright notice                               */
8
9 //////////////////////////////////////////////////////////////////////////
10 //                                                                      //
11 // AliMDC                                                               //
12 //                                                                      //
13 //////////////////////////////////////////////////////////////////////////
14
15 #ifndef ROOT_TObject
16 #include <TObject.h>
17 #endif
18
19 #ifndef ROOT_TSysEvtHandler
20 #include <TSysEvtHandler.h>
21 #endif
22
23 // Forward class declarations
24 class AliRawEvent;
25 class AliRawEventHeader;
26 class AliRawEquipmentHeader;
27 class AliRawData;
28 #ifdef USE_HLT
29 class AliESD;
30 #endif
31
32 class AliMDC : public TObject {
33
34 public:
35    enum EWriteMode { kLOCAL, kRFIO, kROOTD, kCASTOR, kDEVNULL };
36
37    AliMDC(Int_t fd, Int_t compress, Double_t maxFileSize, Bool_t useFilter,
38           EWriteMode mode, Bool_t useLoop, Bool_t delFiles);
39    ~AliMDC() { fgInstance = NULL; }
40
41    static AliMDC* Instance() {return fgInstance;}
42
43    Int_t  Run();
44    void   SetStopLoop() { fStopLoop = kTRUE; }
45    Bool_t StopLoop() const { return fStopLoop; }
46
47    void   SetDebugLevel(Int_t level) { fDebugLevel = level; }
48    Int_t  GetDebugLevel() const { return fDebugLevel; }
49
50    static Bool_t DeleteFiles() { return fgDeleteFiles; }
51
52    enum {kMDC = 6};  // Which MDC is this...
53
54    static const char* const Fifo() {return fgkFifo;}
55    static const char* const RawDBFS(Int_t i) {return fgkRawDBFS[i];}
56    static const char* const TagDBFS() {return fgkTagDBFS;}
57    static const char* const RunDBFS() {return fgkRunDBFS;}
58    static const char* const RFIOFS() {return fgkRFIOFS;}
59    static const char* const CastorFS() {return fgkCastorFS;}
60    static const char* const RootdFS() {return fgkRootdFS;}
61    static const char* const AlienHost() {return fgkAlienHost;}
62    static const char* const AlienDir() {return fgkAlienDir;}
63
64 private:
65    class AliMDCInterruptHandler : public TSignalHandler {
66    public:
67      AliMDCInterruptHandler(AliMDC *mdc) : TSignalHandler(kSigUser1, kFALSE), fMDC(mdc) { }
68      Bool_t Notify() {
69        Info("Notify", "received a SIGUSR1 signal");
70        fMDC->SetStopLoop();
71        return kTRUE;
72      }
73    private:
74      AliMDC *fMDC;   // alimdc to signal
75
76      AliMDCInterruptHandler(const AliMDCInterruptHandler& handler);
77      AliMDCInterruptHandler& operator=(const AliMDCInterruptHandler& handler);
78    };
79
80    static AliMDC* fgInstance;  // singleton instance
81
82    Int_t      fFd;          // DATE input stream
83    Int_t      fCompress;    // compression factor used for raw output DB
84    Int_t      fNumEvents;   // number of events processed
85    Int_t      fDebugLevel;  // controls debug print-out
86    Double_t   fMaxFileSize; // maximum size of raw output DB
87    EWriteMode fWriteMode;   // write mode (local, rfio, rootd, castor, /dev/null)
88    Bool_t     fUseFifo;     // read from fifo, file otherwise
89    Bool_t     fUseEb;       // use event builder API instead of fifo
90    Bool_t     fUseFilter;   // use 3rd level trigger filter
91    Bool_t     fUseLoop;     // loop on input source (must be file)
92    Bool_t     fStopLoop;    // break from endless loop (triggered by SIGUSR1)
93
94    static Bool_t fgDeleteFiles;  // flag for deletion of files
95
96    static const Double_t fgkMaxTagFileSize;  // maximal size of tag DB
97
98    // Fixed file system locations for the different DB's
99    static const char* const fgkFifo;       // fifo
100    static const char* const fgkRawDBFS[2]; // raw DB
101    static const char* const fgkTagDBFS;    // tag DB
102    static const char* const fgkRunDBFS;    // run DB
103    static const char* const fgkRFIOFS;     // rfio
104    static const char* const fgkCastorFS;   // castor
105    static const char* const fgkRootdFS;    // rootd
106    static const char* const fgkAlienHost;  // alien host name
107    static const char* const fgkAlienDir;   // alien directory
108
109    AliMDC(const AliMDC& mdc);
110    AliMDC& operator = (const AliMDC& mdc);
111
112    Int_t     Read(const char *name) { return TObject::Read(name); }
113    Int_t     Read(void *buffer, Int_t length);
114    Int_t     ReadHeader(AliRawEventHeader &header, void *eb = 0);
115    Int_t     ReadEquipmentHeader(AliRawEquipmentHeader &header,
116                                  Bool_t isSwapped, void *eb = 0);
117    Int_t     ReadRawData(AliRawData &raw, Int_t size, void *eb = 0);
118    Int_t     DumpEvent(Int_t toRead);
119    Int_t     Filter(
120 #ifdef USE_HLT
121                     AliRawEvent *event,AliESD *esd
122 #endif
123                     );
124
125    ClassDef(AliMDC,0)  // MDC processor
126 };
127
128 #endif