mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-21 17:18:00 +02:00
multi threadet version of moenchReadData
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorCalibration@26 113b152e-814d-439b-b186-022a431db7b5
This commit is contained in:
44
slsDetectorCalibration/moenchReadDataMT.C
Normal file
44
slsDetectorCalibration/moenchReadDataMT.C
Normal file
@ -0,0 +1,44 @@
|
||||
#include <TFile.h>
|
||||
#include <TThread.h>
|
||||
#include "moenchReadData.C"
|
||||
|
||||
typedef struct task_s{
|
||||
char *fformat;
|
||||
char *tname;
|
||||
char *tdir;
|
||||
int runmin;
|
||||
int runmax;
|
||||
int treeIndex;
|
||||
} Task;
|
||||
|
||||
void *moenchMakeTreeTask(void *p){
|
||||
char fname[1000];
|
||||
Task *t = (Task *)p;
|
||||
sprintf(fname,"%s%s_%i.root",t->tdir,t->tname,t->treeIndex);
|
||||
TFile *f = new TFile(fname,"RECREATE");
|
||||
moenchReadData(t->fformat,t->tname,t->runmin,t->runmax);
|
||||
f->Close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void moenchReadDataMT(char *fformat, char *tit, char *tdir, int runmin, int runoffset, int nThreads, int treeIndexStart=0){
|
||||
char threadName[1000];
|
||||
TThread *threads[nThreads];
|
||||
for(int i = 0; i < nThreads; i++){
|
||||
sprintf(threadName,"t%i",i);
|
||||
Task *t = (Task *)malloc(sizeof(Task));
|
||||
t->fformat = fformat;
|
||||
t->tname = tit;
|
||||
t->tdir = tdir;
|
||||
t->runmin = runmin + i*runoffset;
|
||||
t->runmax = runmin + (i+1)*runoffset - 1;
|
||||
t->treeIndex = treeIndexStart + i;
|
||||
cout << "start thread " << i << " start: " << t->runmin << " end " << t->runmax << endl;
|
||||
threads[i] = new TThread(threadName, moenchMakeTreeTask, t);
|
||||
threads[i]->Run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user