00001 #ifndef _QIGUI_CO_SESSION_HANDLER__H_
00002 #define _QIGUI_CO_SESSION_HANDLER__H_
00003
00004 #include <QObject>
00005 #include <QCoincidence.hh>
00006 #include <map>
00007 #include <string>
00008 #include <TMutex.h>
00009
00010 class QIGUISession;
00011 class QCoincidenceFiller;
00012 class QIGUICoCut;
00013 class QIGUIPlotData;
00014 class TThread;
00015 class QProgressBar;
00016 class QTimer;
00017 class QCoProjector;
00018
00019
00020 class QIGUICoSessionHandler: public QObject
00021 {
00022 Q_OBJECT
00023
00024 public:
00025 enum Status
00026 {
00027 CoToDoEventList = 0,
00028 CoToDoCoCut,
00029 CoDone
00030 };
00031 Status fStatus;
00032
00033 private:
00034
00035 QCoincidenceFiller* fFiller;
00036 QIGUICoCut * fCoCut;
00037
00039 QIGUISession * fSession;
00040 QIGUIPlotData * fPlotData;
00041
00042 QString fName;
00043 std::string fEnergyVar;
00044 std::string fTimeVar;
00045
00046
00047 std::string fType;
00048 double fTimeWindow;
00049
00050 TThread * fCoThread;
00051 TMutex fCoMutex;
00052 int fNEvents;
00053 int fNCoincidences;
00054 QProgressBar * fProgressBar;
00055 QTimer * fTimer;
00056
00057
00058 QCoProjector * fCoProjector;
00059
00060 public:
00061
00062 QIGUICoSessionHandler (QString name, QObject * parent=0);
00063 QIGUICoSessionHandler (QString name, QIGUISession * session, QObject * parent=0);
00064 virtual ~QIGUICoSessionHandler();
00065 void Init();
00066
00067 int BuildCoincidences(QProgressBar * bar);
00068 int CreateFiller();
00069 int BuildTimeCoincidences();
00070 int BuildCoCutCoincidences();
00071 void CoAnalysisEnd();
00072
00073 std::list<QCoincidence> Filter (const std::list<QCoincidence>& coincList);
00074
00075
00076
00077
00078 QString GetName() {return fName;}
00079 QIGUISession * GetSession() { return fSession;}
00080 QIGUIPlotData *GetPlotData() { return fPlotData;}
00081 QCoincidenceFiller * GetFiller () {return fFiller;}
00082 std::string GetType() {return fType;}
00083 double GetTimeWindow () {return fTimeWindow;}
00084 QTimer * GetTimer() {return fTimer;}
00085 std::string GetEnergyVar() {return fEnergyVar;}
00086 std::string GetTimeVar() {return fTimeVar;}
00087 QIGUICoCut * GetCoCut () {return fCoCut;}
00088 int GetNEvents() {return fNEvents;}
00089 int GetNCoincidences() {return fNCoincidences;}
00090 QProgressBar * GetProgressBar() {return fProgressBar;}
00091
00092 void SetSession (QIGUISession * session) {fSession = session;fStatus=CoToDoEventList;}
00093 void SetPlotData(QIGUIPlotData * plotdata) {fPlotData = plotdata;fStatus=CoToDoEventList;}
00094
00095
00096 void SetType (std::string type);
00097 void SetTimeWindow(double timeWindow);
00098 void SetEnergyVar(std::string energy);
00099 void SetTimeVar(std::string time);
00100
00101
00102 void SetCoCut (QIGUICoCut * coCut) {fCoCut = coCut;}
00103
00104 void SetNEvents(int nev) {fNEvents=nev;}
00105 void SetNCoincidences(int nc) {fNCoincidences=nc;}
00106
00107
00108
00109 QCoProjector * GetCoProjector();
00110
00111
00112 void SetStatus (Status st);
00113 Status GetStatus ();
00114
00115
00116 void LockCoMutex();
00117 void UnLockCoMutex();
00118
00119
00120
00121
00122 void GetCoincidentEvents(unsigned int ev, std::vector<QCoincidentEvent> &tempCoin, std::vector<QCoincidentEvent> &spatialCoin);
00123
00124 private:
00125
00126 static void *LaunchCoAnalysis(void * coSessionHandler);
00127
00128
00129 public slots:
00130 void UpdateProgressBar();
00131 void DeleteProgressBar();
00132 void DeleteTimer();
00133
00134 signals:
00135 void UpdateProgressBar(int );
00136 void CoAnalysisEnd(QString, int);
00137
00138 };
00139
00140 #endif