mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +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:
parent
5c245d6c62
commit
849c5eb190
@ -102,7 +102,7 @@ void moenchMakeTree(char *fformat, char *tname, int runmin, int runmax, int sign
|
||||
if (nf>nbg) {
|
||||
me=stat[iy][ix].Mean();
|
||||
sig=stat[iy][ix].StandardDeviation();
|
||||
val=sign*decoder->getChannelShort(buff,ix,iy)-me;
|
||||
val=sign*decoder->getChannel(buff,ix,iy)-me;
|
||||
|
||||
dum=0; //no hit
|
||||
tot=0;
|
||||
@ -111,8 +111,8 @@ void moenchMakeTree(char *fformat, char *tname, int runmin, int runmax, int sign
|
||||
for (ir=-1; ir<2; ir++){
|
||||
for (ic=-1; ic<2; ic++){
|
||||
if ((ix+ic)>=0 && (ix+ic)<160 && (iy+ir)>=0 && (iy+ir)<160) {
|
||||
valNei = sign*decoder->getChannelShort(buff,ix+ic,iy+ir)-stat[iy+ir][ix+ic].Mean();
|
||||
if (sign*decoder->getChannelShort(buff,ix+ic,iy+ir)>(stat[iy+ir][ix+ic].Mean()+3.*stat[iy+ir][ix+ic].StandardDeviation())) dum=1; //is a hit or neighbour is a hit!
|
||||
valNei = sign*decoder->getChannel(buff,ix+ic,iy+ir)-stat[iy+ir][ix+ic].Mean();
|
||||
if (sign*decoder->getChannel(buff,ix+ic,iy+ir)>(stat[iy+ir][ix+ic].Mean()+3.*stat[iy+ir][ix+ic].StandardDeviation())) dum=1; //is a hit or neighbour is a hit!
|
||||
tot+=valNei;
|
||||
data[ir+1][ic+1] = valNei;
|
||||
maxNei = max(maxNei,valNei);
|
||||
@ -134,7 +134,7 @@ void moenchMakeTree(char *fformat, char *tname, int runmin, int runmax, int sign
|
||||
//cout << dum;
|
||||
}
|
||||
if (nf<nbg || dum==0)
|
||||
stat[iy][ix].Calc(sign*decoder->getChannelShort(buff,ix,iy));
|
||||
stat[iy][ix].Calc(sign*decoder->getChannel(buff,ix,iy));
|
||||
|
||||
}
|
||||
}
|
||||
|
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user