mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-15 00:42:12 +02:00
some modifications
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorCalibration@29 113b152e-814d-439b-b186-022a431db7b5
This commit is contained in:
parent
d9a5e7e2a5
commit
fea8670994
@ -23,9 +23,9 @@ using namespace std;
|
||||
|
||||
|
||||
//tree variables
|
||||
int xC,yC,iFrameC;
|
||||
double meC,sigC;
|
||||
Double_t dataC[3][3];
|
||||
int xC,yC,iFrameC;
|
||||
double meC,sigC;
|
||||
Double_t dataC[3][3];
|
||||
TTree* tall;
|
||||
|
||||
typedef struct task_s{
|
||||
@ -50,13 +50,19 @@ inline void storeEvent(int iF,int x,int y, Double_t data[][3], double me, double
|
||||
TThread::Lock();
|
||||
xC = x; yC = y; iFrameC = iF;
|
||||
memcpy(dataC,data,sizeof(Double_t)*3*3);
|
||||
//cout << "X: " << x << " Y: " << y << endl;
|
||||
/* for(int i = 0; i < 3; i++){
|
||||
for(int j = 0; j < 3; j++){
|
||||
cout << "i: " << i << " j: " << j << " dataC " << dataC[i][j] << " data " << data[i][j] << endl;
|
||||
}
|
||||
}*/
|
||||
meC = me; sigC = sig;
|
||||
tall->Fill();
|
||||
TThread::UnLock();
|
||||
}
|
||||
|
||||
void moenchMakeTree(char *fformat, char *tname, int runmin, int runmax, int sign=1) {
|
||||
|
||||
double nThSigma = 3.;
|
||||
moench02ModuleData *decoder=new moench02ModuleData();
|
||||
char *buff;
|
||||
char fname[10000];
|
||||
@ -71,9 +77,9 @@ void moenchMakeTree(char *fformat, char *tname, int runmin, int runmax, int sign
|
||||
|
||||
ifstream filebin;
|
||||
|
||||
int nbg=1000;
|
||||
int nbg=20;
|
||||
|
||||
int ix, iy, ir, ic;
|
||||
int ix, iy, ir, ic, mx,my;
|
||||
Double_t data[3][3];
|
||||
|
||||
nPhotonsStat.Clear();
|
||||
@ -93,21 +99,31 @@ void moenchMakeTree(char *fformat, char *tname, int runmin, int runmax, int sign
|
||||
|
||||
while ((buff=decoder->readNextFrame(filebin))) {
|
||||
nPhotons=0;
|
||||
for (ix=0; ix<160; ix++){
|
||||
for (iy=0; iy<160; iy++) {
|
||||
//for (ix=0; ix<160; ix++){
|
||||
for (ix=0; ix<40; ix++){
|
||||
for (iy=0; iy<160; iy++) {
|
||||
|
||||
|
||||
|
||||
dum=0; //no hit
|
||||
// tot=0;
|
||||
|
||||
me=stat[iy][ix].Mean();
|
||||
sig=stat[iy][ix].StandardDeviation();
|
||||
val=sign*(decoder->getChannelShort(buff,ix,iy)-me);
|
||||
|
||||
dum=0; //no hit
|
||||
tot=0;
|
||||
|
||||
if (nf>nbg) {
|
||||
me=stat[iy][ix].Mean();
|
||||
sig=stat[iy][ix].StandardDeviation();
|
||||
val=sign*decoder->getChannel(buff,ix,iy)-me;
|
||||
|
||||
dum=0; //no hit
|
||||
// dum=0; //no hit
|
||||
tot=0;
|
||||
maxNei = 0;
|
||||
|
||||
if (val>nThSigma*sig)//{ //hit check if neighbors are higher
|
||||
dum=1;
|
||||
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) {
|
||||
@ -115,24 +131,35 @@ void moenchMakeTree(char *fformat, char *tname, int runmin, int runmax, int sign
|
||||
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);
|
||||
if(valNei/stat[iy+ir][ix+ic].StandardDeviation() > maxNei){
|
||||
maxNei = valNei/stat[iy+ir][ix+ic].StandardDeviation();
|
||||
mx = ir;
|
||||
my = ic;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
if (val<(me-3.*sig)) dum=2; //discard negative events!
|
||||
if (val<(-nThSigma*sig)) dum=2; //discard negative events!
|
||||
|
||||
if(maxNei == val && dum == 1){ // this is an event and we are in the center
|
||||
if(dum == 1 && mx == 0 && my == 0){ // this is an event and we are in the center
|
||||
storeEvent(nf,ix,iy,data,me,sig);
|
||||
nPhotons++;
|
||||
//cout << "X: " << ix << " Y: " << iy << " val: " << val << " tot: " << tot << endl;
|
||||
}else{
|
||||
dum = 3; //discard events (for pedestal) where sum of the neighbours is too large.
|
||||
//cout << "BF X: " << ix << " Y: " << iy << " val: " << val << " tot: " << tot << " me: " << me << " sig: " << sig << endl;
|
||||
}
|
||||
|
||||
//if (tot>3.*sig && dum == 1){ dum=3;}
|
||||
|
||||
//if (tot>9.*sig && dum == 1){ dum=3;}
|
||||
//cout << dum;
|
||||
}
|
||||
//if (ix==20 && iy==40)
|
||||
//cout << decoder->getChannelShort(buff,ix,iy)<< " " << val << " " << me << " " << sig << " " << dum << endl;
|
||||
|
||||
if ( dum==0) {
|
||||
|
||||
stat[iy][ix].Calc(decoder->getChannelShort(buff,ix,iy));
|
||||
}
|
||||
if (nf<nbg || dum==0)
|
||||
stat[iy][ix].Calc(sign*decoder->getChannel(buff,ix,iy));
|
||||
|
||||
@ -144,7 +171,7 @@ void moenchMakeTree(char *fformat, char *tname, int runmin, int runmax, int sign
|
||||
nf++;
|
||||
}
|
||||
//cout << endl;
|
||||
cout << "processed File " << fname << " done. Avg. Photons/Frame: " << nPhotonsStat.Mean() << " sig: " << nPhotonsStat.StandardDeviation() << endl;
|
||||
cout << "processed File " << fname << " done. Avg. Photons/Frame: " << nPhotonsStat.Mean() << " sig: " << nPhotonsStat.StandardDeviation() << " " << runmax-irun << " files need processing" << endl;
|
||||
if (filebin.is_open())
|
||||
filebin.close();
|
||||
else
|
||||
@ -168,7 +195,7 @@ void *moenchMakeTreeTask(void *p){
|
||||
int main(int argc, char **argv){
|
||||
if(argc != 6){ cout << "Usage: inFile outdir tname fileNrStart fileNrEnd" << endl; exit(-1); }
|
||||
|
||||
int nThreads = 15;
|
||||
int nThreads = 10;
|
||||
TThread *threads[nThreads];
|
||||
|
||||
char *inFile = argv[1];
|
||||
@ -192,24 +219,26 @@ int main(int argc, char **argv){
|
||||
Task *t = (Task *)malloc(sizeof(Task));
|
||||
t->fformat = inFile;
|
||||
t->tname = tName;
|
||||
t->sign = -1;
|
||||
t->runmin = start + (end-start)/(nThreads-1)*i;
|
||||
t->runmax = start + (end-start)/(nThreads-1)*(i+1);
|
||||
t->sign = 1.;
|
||||
t->runmin = start + (end-start)/(nThreads)*i;
|
||||
t->runmax = start + (end-start)/(nThreads)*(i+1);
|
||||
if(i == nThreads - 1) t->runmax = end;
|
||||
cout << "start thread " << i << " start: " << t->runmin << " end " << t->runmax << endl;
|
||||
threads[i] = new TThread(threadName, moenchMakeTreeTask, t);
|
||||
threads[i]->Run();
|
||||
//moenchMakeTreeTask(t);
|
||||
}
|
||||
|
||||
|
||||
//TThread::Ps();
|
||||
|
||||
for(int i = 0; i < nThreads; i++){
|
||||
for(int i = 0; i < nThreads; i++){
|
||||
threads[i]->Join();
|
||||
}
|
||||
|
||||
|
||||
tall->Write();
|
||||
tall->GetCurrentFile()->Close();
|
||||
tall->Print();
|
||||
f->Close();
|
||||
}
|
||||
|
||||
|
@ -151,6 +151,7 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
while ((buff=decoder->readNextFrame(filebin))) {
|
||||
|
||||
|
||||
if (hitfinder) {
|
||||
filter->newFrame();
|
||||
|
||||
//calculate pedestals and common modes
|
||||
@ -161,7 +162,7 @@ THStack *moenchReadData(char *fformat, char *tit, int runmin, int runmax, int nb
|
||||
thisEvent=filter->getEventType(buff, ix, iy,0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// cout << "new frame " << endl;
|
||||
|
||||
|
@ -13,7 +13,7 @@ void raedNoiseData(char *tit, int sign=1){
|
||||
sprintf(fname,"/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_120V_%s.root",tit);
|
||||
fout=new TFile(fname,"RECREATE");
|
||||
|
||||
sprintf(fname,"/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_12us_120V_%s_f00000%%04d000_0.raw",tit);
|
||||
sprintf(fname,"/data/moench_xbox_20140113/MoTarget_45kV_0_8mA_120V_%s_f00000%%04d000_0.raw",tit);
|
||||
|
||||
hs2N=moenchReadData(fname,tit,0,3000,1500,-500,2500,sign,0.,1,159,1,159, 0);
|
||||
hs2N->SetName(tit);
|
||||
@ -34,6 +34,39 @@ void raedNoiseData(char *tit, int sign=1){
|
||||
|
||||
|
||||
|
||||
void raedNoiseDataN(char *tit, int sign=1){
|
||||
|
||||
|
||||
|
||||
char fname[1000];
|
||||
char f[1000];
|
||||
TFile *fout;
|
||||
THStack *hs2N;
|
||||
|
||||
sprintf(fname,"/data/moench_xbox_20140116/noise_%s.root",tit);
|
||||
fout=new TFile(fname,"RECREATE");
|
||||
|
||||
sprintf(fname,"/data/moench_xbox_20140116/noise_%s_f00000%%04d000_0.raw",tit);
|
||||
|
||||
hs2N=moenchReadData(fname,tit,0,3000,1500,-500,2500,sign,0.,1,159,1,159, 0,0);
|
||||
hs2N->SetName(tit);
|
||||
hs2N->SetTitle(tit);
|
||||
(TH2F*)(hs2N->GetHists()->At(0))->Write();
|
||||
|
||||
// (TH2F*)(hs2N->GetHists()->At(1))->Write();
|
||||
// (TH2F*)(hs2N->GetHists()->At(2))->Write();
|
||||
// (TH2F*)(hs2N->GetHists()->At(3))->Write();
|
||||
// (TH2F*)(hs2N->GetHists()->At(4))->Write();
|
||||
|
||||
|
||||
fout->Close();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void g4() {
|
||||
|
||||
raedNoiseData("cds_g4_low_gain");
|
||||
@ -72,3 +105,29 @@ void all_low_gains() {
|
||||
raedNoiseData("cds_g1_2_low_gain");
|
||||
raedNoiseData("cds_g2_3_low_gain");
|
||||
}
|
||||
|
||||
/*
|
||||
clkdivider data
|
||||
/data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_cds_g1_clkdiv17_f000000010000_0.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 12:40 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_cds_g1_clkdiv25_f000000010000_0.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 13:26 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_cds_g1_clkdiv35_f000000010000_0.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 14:09 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_cds_g1_clkdiv50_f000000010000_0.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 14:54 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_cds_g1_clkdiv70_f000000010000_0.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 16:42 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_cds_g1_clkdiv110_f000000010000_0.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 17:27 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_cds_g1_clkdiv170_f000000010000_0.raw
|
||||
*/
|
||||
|
||||
|
||||
/* oversampled data
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 18:12 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_os10_16rows_f000000010000_0.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 18:47 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_os10_16rows_f000000010000_1.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 19:22 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_os10_16rows_f000000010000_2.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 20:02 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_os10_16rows_f000000010000_3.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 20:41 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_os10_16rows_f000000010000_4.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 21:16 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_os10_16rows_f000000010000_5.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 21:56 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_os10_16rows_f000000010000_6.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 22:35 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_os10_16rows_f000000010000_7.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 23:11 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_os10_16rows_f000000010000_8.raw
|
||||
-rw-rw-r-- 1 l_msdetect l_msdetect 51440000 Jan 14 23:50 /data/moench_xbox_20140114/MoTarget_45kV_0_8mA_12us_120V_os10_16rows_f000000010000_9.raw
|
||||
*/
|
||||
|
||||
|
@ -191,6 +191,7 @@ class singlePhotonDetector {
|
||||
if (cm==0) {
|
||||
// cout << "=" << endl;
|
||||
addToPedestal(det->getValue(data, ix, iy),ix,iy);
|
||||
cluster->set_data(dataSign*(det->getValue(data, ix, iy)-getPedestal(ix,iy,cm)), 0,0 );
|
||||
// cout << "=" << endl;
|
||||
}
|
||||
return UNDEFINED;
|
||||
|
Loading…
x
Reference in New Issue
Block a user