From 7e8cf810fbaef13d17285ddfa3bade58ad370023 Mon Sep 17 00:00:00 2001 From: cartier_s Date: Thu, 28 May 2015 14:28:17 +0200 Subject: [PATCH] main in moenchReadDataMT [multi threading] --- slsDetectorCalibration/moenchReadData.C | 5 ++-- slsDetectorCalibration/moenchReadDataMT.C | 36 +++++++++++++++++++++-- slsDetectorCalibration/slsDetectorData.h | 2 +- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/slsDetectorCalibration/moenchReadData.C b/slsDetectorCalibration/moenchReadData.C index bf7173f0b..965b2e88c 100644 --- a/slsDetectorCalibration/moenchReadData.C +++ b/slsDetectorCalibration/moenchReadData.C @@ -16,6 +16,7 @@ #include #include "moench02ModuleData.h" #include "moenchCommonMode.h" +#define MYROOT1 #include "singlePhotonDetector.h" //#include "MovingStat.h" @@ -26,7 +27,7 @@ using namespace std; #define NR 160 -#define MY_DEBUG 1 +//#define MY_DEBUG 1 #ifdef MY_DEBUG #include #endif @@ -215,7 +216,7 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb #endif nf++; - cout << "=" ; + cout << "=" << decoder->getFrameNumber(buff); delete [] buff; } cout << nph << endl; diff --git a/slsDetectorCalibration/moenchReadDataMT.C b/slsDetectorCalibration/moenchReadDataMT.C index 0720909c4..ecb578772 100644 --- a/slsDetectorCalibration/moenchReadDataMT.C +++ b/slsDetectorCalibration/moenchReadDataMT.C @@ -1,5 +1,6 @@ #include #include +#include #include "moenchReadData.C" typedef struct task_s{ @@ -9,6 +10,7 @@ typedef struct task_s{ int runmin; int runmax; int treeIndex; + double xTalk; } Task; void *moenchMakeTreeTask(void *p){ @@ -19,13 +21,16 @@ void *moenchMakeTreeTask(void *p){ TFile *f = new TFile(fname,"RECREATE"); cout << "Call moenchReadData(" << t->fformat << "," << t->tname << "," << t->runmin<< "," << t->runmax <<")" << endl; TThread::UnLock(); - moenchReadData(t->fformat,t->tname,t->runmin,t->runmax); - f->Close(); + 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(); + } 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]; TThread *threads[nThreads]; 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->runmax = runmin + (i+1)*runoffset - 1; t->treeIndex = treeIndexStart + i; + t->xTalk = xTalk; cout << "start thread " << i << " start: " << t->runmin << " end " << t->runmax << endl; threads[i] = new TThread(threadName, moenchMakeTreeTask, t); 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); + +} + diff --git a/slsDetectorCalibration/slsDetectorData.h b/slsDetectorCalibration/slsDetectorData.h index 8240a7484..01f00a316 100644 --- a/slsDetectorCalibration/slsDetectorData.h +++ b/slsDetectorCalibration/slsDetectorData.h @@ -96,7 +96,7 @@ class slsDetectorData { for (int iy=0; iy