Go to the documentation of this file.00001 #ifndef BASE_PROGMGR_H
00002 #define BASE_PROGMGR_H
00003
00004 #include <vector>
00005 #include <map>
00006
00007 #include "base/Buffer.h"
00008 #include "base/StreamProc.h"
00009 #include "base/Event.h"
00010
00011 namespace base {
00012
00017 class ProcMgr {
00018 protected:
00019
00020 enum { MaxBrdId = 256 };
00021
00022 enum {
00023 NoSyncIndex = 0xfffffffe,
00024 DummyIndex = 0xffffffff
00025 };
00026
00027 typedef std::vector<StreamProc*> ProcessorsVect;
00028 typedef std::map<unsigned,StreamProc*> ProcessorsMap;
00029
00030 ProcessorsVect fProc;
00031 ProcessorsMap fMap;
00032
00033 GlobalTriggerMarksQueue fTriggers;
00034
00035 unsigned fTimeMasterIndex;
00036
00037 bool fRawAnalysisOnly;
00038
00039 static ProcMgr* fInstance;
00040
00041 virtual unsigned SyncIdRange() const { return 0x1000000; }
00042
00046 int SyncIdDiff(unsigned id1, unsigned id2) const;
00047
00048 public:
00049 ProcMgr();
00050 virtual ~ProcMgr();
00051
00052 static ProcMgr* instance();
00053
00054 static ProcMgr* AddProc(StreamProc* proc);
00055
00057 bool RegisterProc(StreamProc* proc, unsigned kind, unsigned brdid);
00058
00059 unsigned NumProc() const { return fProc.size(); }
00060 StreamProc* GetProc(unsigned n) const { return n<NumProc() ? fProc[n] : 0; }
00061
00062 virtual H1handle MakeH1(const char* name, const char* title, int nbins, double left, double right, const char* xtitle = 0) { return 0; }
00063 virtual void FillH1(H1handle h1, double x, double weight = 1.) {}
00064
00065 virtual H2handle MakeH2(const char* name, const char* title, int nbins1, double left1, double right1, int nbins2, double left2, double right2, const char* options = 0) { return 0; }
00066 virtual void FillH2(H1handle h2, double x, double y, double weight = 1.) {}
00067
00068 virtual C1handle MakeC1(const char* name, double left, double right, base::H1handle h1 = 0) { return 0; }
00069 virtual void ChangeC1(C1handle c1, double left, double right) {}
00072 virtual int TestC1(C1handle c1, double value, double* dist = 0) { return false; }
00073 virtual double GetC1Limit(C1handle c1, bool isleft = true) { return 0; }
00074
00075
00076
00077 bool IsRawAnalysis() const { return fRawAnalysisOnly; }
00078 void SetRawAnalysis(bool on) { fRawAnalysisOnly = on; }
00079
00081 void SetTimeSorting(bool on);
00082
00084 void SetTimeMasterIndex(unsigned indx) { fTimeMasterIndex = indx; }
00085
00087 void ProvideRawData(const Buffer& buf);
00088
00090 void ScanNewData();
00091
00093 bool SkipAllData();
00094
00095
00097 bool AnalyzeSyncMarkers();
00098
00100 bool CollectNewTriggers();
00101
00103 bool ScanDataForNewTriggers();
00104
00105
00109 bool ProduceNextEvent(base::Event* &evt);
00110 };
00111 }
00112
00113 #endif