mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
main in moenchReadDataMT [multi threading]
This commit is contained in:
parent
c9269d0f21
commit
7e8cf810fb
@ -16,6 +16,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "moench02ModuleData.h"
|
#include "moench02ModuleData.h"
|
||||||
#include "moenchCommonMode.h"
|
#include "moenchCommonMode.h"
|
||||||
|
#define MYROOT1
|
||||||
#include "singlePhotonDetector.h"
|
#include "singlePhotonDetector.h"
|
||||||
|
|
||||||
//#include "MovingStat.h"
|
//#include "MovingStat.h"
|
||||||
@ -26,7 +27,7 @@ using namespace std;
|
|||||||
#define NR 160
|
#define NR 160
|
||||||
|
|
||||||
|
|
||||||
#define MY_DEBUG 1
|
//#define MY_DEBUG 1
|
||||||
#ifdef MY_DEBUG
|
#ifdef MY_DEBUG
|
||||||
#include <TCanvas.h>
|
#include <TCanvas.h>
|
||||||
#endif
|
#endif
|
||||||
@ -215,7 +216,7 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
|||||||
#endif
|
#endif
|
||||||
nf++;
|
nf++;
|
||||||
|
|
||||||
cout << "=" ;
|
cout << "=" << decoder->getFrameNumber(buff);
|
||||||
delete [] buff;
|
delete [] buff;
|
||||||
}
|
}
|
||||||
cout << nph << endl;
|
cout << nph << endl;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <TFile.h>
|
#include <TFile.h>
|
||||||
#include <TThread.h>
|
#include <TThread.h>
|
||||||
|
#include <THStack.h>
|
||||||
#include "moenchReadData.C"
|
#include "moenchReadData.C"
|
||||||
|
|
||||||
typedef struct task_s{
|
typedef struct task_s{
|
||||||
@ -9,6 +10,7 @@ typedef struct task_s{
|
|||||||
int runmin;
|
int runmin;
|
||||||
int runmax;
|
int runmax;
|
||||||
int treeIndex;
|
int treeIndex;
|
||||||
|
double xTalk;
|
||||||
} Task;
|
} Task;
|
||||||
|
|
||||||
void *moenchMakeTreeTask(void *p){
|
void *moenchMakeTreeTask(void *p){
|
||||||
@ -19,13 +21,16 @@ void *moenchMakeTreeTask(void *p){
|
|||||||
TFile *f = new TFile(fname,"RECREATE");
|
TFile *f = new TFile(fname,"RECREATE");
|
||||||
cout << "Call moenchReadData(" << t->fformat << "," << t->tname << "," << t->runmin<< "," << t->runmax <<")" << endl;
|
cout << "Call moenchReadData(" << t->fformat << "," << t->tname << "," << t->runmin<< "," << t->runmax <<")" << endl;
|
||||||
TThread::UnLock();
|
TThread::UnLock();
|
||||||
moenchReadData(t->fformat,t->tname,t->runmin,t->runmax);
|
THStack *s = moenchReadData(t->fformat,t->tname,t->runmin,t->runmax, 1500, -500, 1000, 1, t->xTalk);
|
||||||
|
s->Write();
|
||||||
|
if(f && f->IsOpen()){
|
||||||
f->Close();
|
f->Close();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void moenchReadDataMT(char *fformat, char *tit, char *tdir, int runmin, int runoffset, int nThreads, int treeIndexStart=0){
|
void moenchReadDataMT(char *fformat, char *tit, char *tdir, int runmin, int runoffset, int nThreads, int treeIndexStart=0, double xTalk=0.044){
|
||||||
char threadName[1000];
|
char threadName[1000];
|
||||||
TThread *threads[nThreads];
|
TThread *threads[nThreads];
|
||||||
for(int i = 0; i < nThreads; i++){
|
for(int i = 0; i < nThreads; i++){
|
||||||
@ -37,6 +42,7 @@ void moenchReadDataMT(char *fformat, char *tit, char *tdir, int runmin, int runo
|
|||||||
t->runmin = runmin + i*runoffset;
|
t->runmin = runmin + i*runoffset;
|
||||||
t->runmax = runmin + (i+1)*runoffset - 1;
|
t->runmax = runmin + (i+1)*runoffset - 1;
|
||||||
t->treeIndex = treeIndexStart + i;
|
t->treeIndex = treeIndexStart + i;
|
||||||
|
t->xTalk = xTalk;
|
||||||
cout << "start thread " << i << " start: " << t->runmin << " end " << t->runmax << endl;
|
cout << "start thread " << i << " start: " << t->runmin << " end " << t->runmax << endl;
|
||||||
threads[i] = new TThread(threadName, moenchMakeTreeTask, t);
|
threads[i] = new TThread(threadName, moenchMakeTreeTask, t);
|
||||||
threads[i]->Run();
|
threads[i]->Run();
|
||||||
@ -50,3 +56,27 @@ void moenchReadDataMT(char *fformat, char *tit, char *tdir, int runmin, int runo
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//to compile: g++ -DMYROOT -DMYROOT1 -g `root-config --cflags --glibs` -o moenchReadDataMT moenchReadDataMT.C
|
||||||
|
int main(int argc, char **argv){
|
||||||
|
if(argc < 8){
|
||||||
|
cout << "Usage: " << argv[0] << " fformat tit tdir runmin runoffset nThreads treeIndexStart [xTalkFactor]" << endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *fformat = argv[1];
|
||||||
|
char *tit = argv[2];
|
||||||
|
char *tdir = argv[3];
|
||||||
|
int runmin = atoi(argv[4]);
|
||||||
|
int runoffset = atoi(argv[5]);
|
||||||
|
int nThreads = atoi(argv[6]);
|
||||||
|
int treeIndexStart = atoi(argv[7]);
|
||||||
|
double xTalkFactor = 0.044;
|
||||||
|
|
||||||
|
if(argc == 9)
|
||||||
|
xTalkFactor = atof(argv[8]);
|
||||||
|
|
||||||
|
moenchReadDataMT(fformat, tit, tdir,runmin,runoffset,nThreads,treeIndexStart, xTalkFactor);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class slsDetectorData {
|
|||||||
for (int iy=0; iy<ny; iy++)
|
for (int iy=0; iy<ny; iy++)
|
||||||
for (int ix=0; ix<nx; ix++) {
|
for (int ix=0; ix<nx; ix++) {
|
||||||
dataMap[iy][ix]=dMap[iy][ix];
|
dataMap[iy][ix]=dMap[iy][ix];
|
||||||
cout << ix << " " << iy << endl;
|
//cout << ix << " " << iy << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user