]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/AliMonitorProcess.h
client server connection improved, interrupt handler for monitor process added
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorProcess.h
1 #ifndef ALIMONITORPROCESS_H
2 #define ALIMONITORPROCESS_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 #include <TObject.h>
9 #include <TSystem.h>
10 #include <TString.h>
11 #include <TObjArray.h>
12
13 class AliRawReader;
14 class AliTPCParam;
15 class AliITSgeom;
16 class AliRunLoader;
17 class TFile;
18 class TGrid;
19 class TTimer;
20 class TServerSocket;
21 class TFolder;
22 class TTree;
23 #ifdef ALI_HLT
24 class AliLevel3;
25 class AliL3Hough;
26 #endif
27
28
29 class AliMonitorProcess : public TObject {
30 public:
31   AliMonitorProcess(const char* alienHost,
32                     const char* alienDir,
33                     const char* fileNameGalice = "galice.root");
34   AliMonitorProcess(const AliMonitorProcess& process);
35   AliMonitorProcess& operator = (const AliMonitorProcess& process);
36   virtual ~AliMonitorProcess();
37
38   static const char* GetRevision();
39
40   void             Run();
41   void             Stop();
42   void             Reset();
43
44   void             ProcessFile(const char* fileName);
45
46   UInt_t           GetRunNumber() const {return fRunNumber;};
47   UInt_t           GetEventPeriodNumber() const;
48   UInt_t           GetEventOrbitNumber() const;
49   UInt_t           GetEventBunchNumber() const;
50
51   enum EStatus     {kStopped, kWaiting, kReading, kRecTPC, kRecITS, kRecV0s,
52                     kRecHLT, kFilling, kUpdating, kWriting, kResetting, 
53                     kConnecting, kBroadcasting};
54   EStatus          GetStatus() const 
55     {gSystem->ProcessEvents(); return fStatus;};
56   Bool_t           WillStop() const {return fStopping;};
57   Bool_t           IsStopped() const {return (fStatus == kStopped);};
58
59   Int_t            GetNumberOfEvents() const {return fNEvents;};
60   Int_t            GetNumberOfClients() const 
61     {return fSockets.GetEntriesFast();};
62   TObjArray*       GetListOfClients() {return &fSockets;};
63   Int_t            GetNEventsMin() const {return fNEventsMin;};
64   void             SetNEventsMin(Int_t nEventsMin) {fNEventsMin = nEventsMin;};
65   void             SetWriteHistoList(Bool_t writeHistoList = kTRUE) 
66                                          {fWriteHistoList = writeHistoList;};
67
68   static Int_t     GetPort() {return fgkPort;};
69   
70 private:
71   Bool_t           CheckForNewFile();
72   Bool_t           ProcessFile();
73   Int_t            GetNumberOfEvents(const char* fileName) const;
74   Bool_t           ReconstructTPC(AliRawReader* rawReader);
75   Bool_t           ReconstructITS(AliRawReader* rawReader);
76   Bool_t           ReconstructV0s();
77 #ifdef ALI_HLT
78   void             CreateHLT(const char* fileName);
79   void             CreateHLTHough(const char* fileName);
80 #endif
81   Bool_t           ReconstructHLT(Int_t iEvent);
82   Bool_t           ReconstructHLTHough(Int_t iEvent);
83
84   Bool_t           WriteHistos();
85   void             StartNewRun();
86
87   void             CheckForConnections();
88   void             BroadcastHistos(TSocket* toSocket = NULL);
89   void             SetStatus(EStatus status);
90
91   static const Int_t fgkPort;          // port number for client connections
92
93   TGrid*           fGrid;               // pointer to AliEn
94   TString          fAlienDir;           // name of alien directory
95   AliRunLoader*    fRunLoader;          // the current run loader
96   AliTPCParam*     fTPCParam;           // TPC parameters
97   AliITSgeom*      fITSgeom;            // ITS parameters
98   TString          fLogicalFileName;    // logical AliEn file name
99   TString          fFileName;           // physical file name
100 #ifdef ALI_HLT
101   AliLevel3*       fHLT;                // the HLT tracker
102   AliL3Hough*      fHLTHough;           // the HLT hough transformer
103 #endif
104
105   UInt_t           fRunNumber;          // current run number
106   UInt_t           fSubRunNumber;       // current part (=resets per run)
107   UInt_t           fEventNumber[2];     // current event number
108   Int_t            fNEvents;            // total number of monitored events
109   Int_t            fNEventsMin;         // threshold for writing
110   Bool_t           fWriteHistoList;     // write event histos or not
111
112   TFolder*         fTopFolder;          // folder with histos
113   TObjArray        fMonitors;           // array of monitor objects
114   TFile*           fFile;               // file with tree
115   TTree*           fTree;               // monitor tree
116
117   TServerSocket*   fServerSocket;       // socket for client connections
118   TObjArray        fSockets;            // array of client sockets
119   TSocket*         fDisplaySocket;      // socket for an event display
120
121   EStatus          fStatus;             // current status
122   Bool_t           fStopping;           // stop of process requested or not
123
124   class AliMonitorInterruptHandler : public TSignalHandler {
125   public:
126     AliMonitorInterruptHandler(AliMonitorProcess* process);
127     AliMonitorInterruptHandler(const AliMonitorInterruptHandler& handler);
128     AliMonitorInterruptHandler& operator = 
129       (const AliMonitorInterruptHandler& handler);
130     virtual Bool_t Notify();
131   private:
132     AliMonitorProcess* fProcess;       // process to notify
133   };
134
135   AliMonitorInterruptHandler* fInterruptHandler;  // interrupt handler
136
137   ClassDef(AliMonitorProcess, 0)   // class for performing the monitoring
138 };
139  
140
141 #endif
142
143
144
145
146
147
148
149
150