SpectraPac 2.0(r200)
Evaluates PAC Measurements

PacCoincidenceSearchThread.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008-2010 by Matthias Nagl                              *
00003  *   mnagl@uni-goettingen.de                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef PACCOINCIDENCESEARCHTHREAD_H
00022 #define PACCOINCIDENCESEARCHTHREAD_H
00023 
00024 #include <QThread>
00025 #include <QMutex>
00026 #include <QPair>
00027 #include "PacKnockoutSettings.h"
00028 #include "pacCoincidenceDefinitions.h"
00029 
00030 class PrivateEvent; 
00031 class PacCoincidenceInput;
00032 class PacProgressDialog;
00033 class PacDataReader;
00034 
00040 class PacCoincidenceSearchThread : public QThread
00041 {
00042     Q_OBJECT
00043   public:
00044     PacCoincidenceSearchThread(quint8 numdetectors, PacDataReader *reader, QObject *parent = 0);
00045     ~PacCoincidenceSearchThread();
00050     void setInput(const PacCoincidenceInput *input, bool addendum = false);
00051 
00052   signals:
00053     void results(
00054       const PacCoincidenceInput *input,
00055       const PacCoincidenceSearchResults &spectra,
00056       bool addendum,
00057       bool stillwritten,
00058       quint64 nextcppointerpos
00059       );
00060     void progress(int p);
00061 
00062   private slots:
00063     void cancelThread();
00064     void stopThreadAndSave();
00065 
00066   private:
00067     enum StopMode {
00068       DontStop = 0,
00069       Cancel,
00070       StopAndSave
00071     };
00072     QAtomicInt stopthread;
00073 
00074     void run();
00075     void saveCorrelation(const PrivateEvent *start, const PrivateEvent *stop);
00076 
00077     const PacCoincidenceInput *input;
00078     PacDataReader *reader;
00079 
00080     PacProgressDialog *pdialog;
00081 
00082     unsigned int channels;
00083     QMutex mutex;
00084     QPair<qreal,qreal> startwindow, stopwindow;
00085     qreal minclength; // in ns
00086     qreal maxclength; // in ns
00087     qulonglong minclps; // in ps
00088     qulonglong maxclps; // in ps
00089     PacCoincidenceSearchResults spectra;
00090     quint8 numdetectors;
00091     qint32 bytebuffersize; 
00092     static const quint64 emitprogressafter; 
00093     quint32 progresscounter; 
00094     PacKnockoutSettings kosettings;
00095     quint32 delayedevents;
00096 
00097     void readEvent(PrivateEvent *target);
00098     void findBuddies(int starteventpointer);
00099     void findCoincidences(int starteventpointer);
00100     static const qint32 initialbuffersize = 100;
00101     QList<PrivateEvent*> ebuffer; 
00102     int buffersize;  
00103     int bufferfront; 
00104     int bufferback;  
00105     quint64 previoustimestamp; 
00106     bool addendum;
00107 };
00108 
00109 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines