QIGUICoSessionHandler.hh

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     // Time coincidence type (kind of filler)
00047     std::string fType;
00048     double fTimeWindow;
00049 
00050     TThread * fCoThread;
00051     TMutex  fCoMutex; // protect CoStatus
00052     int fNEvents; 
00053     int fNCoincidences;
00054     QProgressBar * fProgressBar;
00055     QTimer * fTimer;
00056 
00057     // Projector
00058     QCoProjector * fCoProjector;
00059 
00060   public:
00061     // Ctr, Dtr, initialization
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     // Apply cut and generate a new list with the coincidences that pass the filter
00073     std::list<QCoincidence> Filter (const std::list<QCoincidence>& coincList);
00074     
00075 
00076 
00077     // Setters, getters
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     // These functions modify Status = CoToDoEventList 
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     // These functions dont modify Status. Status is modified by signals
00102     void SetCoCut (QIGUICoCut * coCut) {fCoCut = coCut;}
00103 
00104     void SetNEvents(int nev) {fNEvents=nev;}
00105     void SetNCoincidences(int nc) {fNCoincidences=nc;}
00106 
00107     // get pointer to projector. If CoSessionHandler Status is different form CoDone, 
00108     // regenerate coincidence list
00109     QCoProjector * GetCoProjector();
00110 
00111     // Get and Set Status(protected by Mutex)
00112     void SetStatus (Status st); 
00113     Status GetStatus (); 
00114 
00115     // Lock and UnLock Mutex that protects fStatus.
00116     void LockCoMutex();
00117     void UnLockCoMutex();
00118 
00119     // Fill two vectors with the event index in coincidence with event ev
00120     // (first vector: events in temporal coincidence
00121     // second vector: events in spatial coincidence)
00122     void GetCoincidentEvents(unsigned int ev, std::vector<QCoincidentEvent> &tempCoin, std::vector<QCoincidentEvent> &spatialCoin);
00123     
00124   private:
00125     // Thread function
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

Generated on Fri Mar 6 13:40:40 2009 for CUORE Software by  doxygen 1.5.1