Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
Andrä Marie 2018-01-31 11:46:17 +01:00
commit 6af3a6d33a
17 changed files with 739 additions and 359 deletions

View File

@ -71,9 +71,6 @@ Here is an explanation of the LED color scheme of the bchip100:
\end{itemize}
You can also Check temperatures and water flow in a browser (from the same subnet where the 9M is: http://bchip100/status.cgi
\subsection{Mandatory setup - Receiver}
The receiver is a process run on a PC closely connected to the detector. Open one receiver for every half module board (remember, a module has two receivers!!!) . Go to {\tt{slsDetectorsPackage/bin/}}, \textbf{slsReceiver} should be started on the machine expected to receive the data from the detector.
@ -85,9 +82,17 @@ The receiver is a process run on a PC closely connected to the detector. Open on
where xxxx, yyyy are the tcp port numbers. Use 1955 and 1956 for example. Note that in older version of the software {\tt{--mode 1}} was used only for the ``bottom'' half module. Now, the receiver for the bottom is open without arguments anymore, but still in the configuration file one needs to write {\tt{n:flippeddatax 1}}, where {\tt{n}} indicated the half module number, 1 if it is a module.
\\ Open as many receiver as half module boards. A single module has two half module boards.
From the software version 3.0.1, one can decide weather start a zmq callback from the receiver to the client (for example to visualize data in the slsDetectorGui or another gui). If the zmq steam is not required (cased of the command line for example, one can switch off the streaming with {\tt{./sls\_detector\_put rx\_datastream 0}}, enable it with {\tt{./sls\_detector\_put rx\_datastream 1}}. In the case of inizialising the stream to use the slsDetectorGui, nothing needs to be taken care of by the user. If instead you want to stream the streaming on different channels, the zmq port of the client can be set stealing from the slsDetectorGui stream having {\tt{./sls\_detector\_put n:zmqport 300y}}, where n is each half module independently, matching the receiver stream {\tt{./sls\_detector\_put n:rx\_zmqport 300y}}.
There is an example code that can be compiled in {\tt{manual/manual-api/mainReceiver.cpp}} and gives the executable {\tt{./detReceiver}}, use it with two or more receivers to open all receivers in one single terminal: {\tt{./detReceiver startTCPPort numReceivers withCallback}}, where startTCPPort assumes the other ports are consecutively increased.
\subsection{Mandatory setup - Client}
\underline{In the case of cSAXS, the detector software is installed on the x12sa-ed-1 machine:}\\
\underline{In the case of cSAXS, the detector software is installed on:}\\
\underline{/sls/X12SA/data/x12saop/EigerPackage/slsDetectorsPackage}
The command line interface consists in these main functions:
@ -97,7 +102,7 @@ The command line interface consists in these main functions:
\item[sls\_detector\_get] to retrieve detector parameters
\end{description}
First, your detector should always be configured for each PC that you might want to use for controlling the detector. All the examples given here show the command {\tt{0-}}, which could be omitted for the EIGER system $0$. In the case more EIGER systems are controlled at once, the call of {\tt{1-}},.. becomes compulsory.
First, your detector should always be configured for each PC that you might want to use for controlling the detector. All the examples given here show the command {\tt{0-}}, which could be omitted for the EIGER system $0$. In the case more EIGER systems are controlled at once, the call of {\tt{1-}},.. becomes compulsory.
To make sure the shared memory is cleaned, before starting, one should do:
\begin{verbatim}
@ -120,6 +125,7 @@ hostname beb059+beb058+ #1Gb detector hostname for controls
1:rx_udpport2 50014 #udp port second quadrant, second halfmodule
rx_hostname x12sa-vcons #1Gb receiver pc hostname
outdir /sls/X12SA/data/x12saop/Data10/Eiger0.5M
threaded 1
\end{verbatim}
In the config file, if client, receiver and detector commands are on 1Gb, but detector data to receiver are sent using \textbf{10GbE} the following lines are mandatory (see slsDetectorsPackage/examples/eiger\_10Gb.config):
@ -139,8 +145,17 @@ hostname beb059+beb058+ #1Gb detector hostname for controls
1:detectorip 10.0.40.101 #second half module 10 Gb IP
rx_hostname x12sa-vcons #1Gb receiver pc hostname
outdir /sls/X12SA/data/x12saop/Data10/Eiger0.5M
threaded 1
\end{verbatim}
In the case you are developing your own receiver, then you need to remove the 1Gb receiver hostname {\tt{rx\_hostname}} and substitute it with the mac address of the device:
\begin{verbatim}
configuremac 0
rx_udpmac xx:xx:...
\end{verbatim}
One can configure all the detector settings in a parameter file {\tt{setup.det}}, which is loaded by doing:
\begin{verbatim}
sls_detector_put 0-parameters setup.det
@ -186,7 +201,7 @@ The first line requires to specify how many ({\tt{N}}) and at which energies in
NORMALLY, in this new calibration scheme, only {\tt{settings standard}} will be provided to you, unless specific cases to be discussed.
The threshold at 6000 eV , for example would be set as:{\tt{sls\_detector\_put 0-threshold 6000}}.
We have added a special command, {\tt{thresholdnotb}}, which allows to scan the threshold energy without reloading the trimbits at every stage. One cain either keep the trimbits at a specific value (es.32 if the range of energies to scan is large) or use the trimbits from a specific energy (like a central energy).
We have added a special command, {\tt{thresholdnotb}}, which allows to scan the threshold energy without reloading the trimbits at every stage. One can either keep the trimbits at a specific value (es.32 if the range of energies to scan is large) or use the trimbits from a specific energy (like a central energy).
\begin{verbatim}
sls_detector_put 0-thresholdnotb energy_in_eV
\end{verbatim}
@ -440,150 +455,10 @@ If \textbf{dr} is 32 and \textbf{clkdivider} is not 2, whatever the detector get
\item If the variable \textbf{frames} is greater than what the memory can store (table~\ref{timgs}) and the frame rate exceed the continuos streaming (table~\ref{tcont}), limits on the maximum number of images need to be implemented if the period is lower than the one listed in table~\ref{tcont}. Check table~\ref{tframes} to see the different cases.
\item Running at a speed that does not support the frame rate you are asking: see table~\ref{tframes} to check if the frame rate (\textbf{period}) you are asking is compatible with the \textbf{clkdivider} you are asking.
\item Running at a redout time that does not support the frame rate you are asking. Check table~\ref{tframes} to check if the frame rate (\textbf{period}) you are asking is compatible with the \textbf{flags} you are asking.
\item The minimum allowed value for \textbf{epttime} should be 10~$\mu$s.
\item The minimum allowed value for \textbf{exptime} should be 10~$\mu$s.
\item By default the {\textbf{subexptime}} is set to 2.621440~ms. Values smaller than 500~$\mu$s do not make sense. The maximum value is 5.2~s. This limits should be checked.
\end{enumerate}
\section{Client checks - command line}
Guide on returned strings:
\begin{enumerate}
\item \begin{verbatim}
sls_detector_get free
\end{verbatim}
Returns a list of shared memories cleaned (variable number depending on detector):
\begin{verbatim}
Shared memory 273612805 deleted
Shared memory 276922374 deleted
Shared memory 270270468 deleted
free freed
\end{verbatim}
Note that occasionally if there is a shared memory of a different size (from an older software version), it will return also a line like this:
\begin{verbatim}
*** shmget error (server) ***-1
\end{verbatim}
This needs to be cleaned with {\tt{ipcs -m}} and then {\tt{ipcrm -M xxx}}, where xxx are the keys with nattch 0.
\item \begin{verbatim}sls_detector_get settings
settings standard
\end{verbatim}
{\tt{standard}} is only if correct. {\tt{undefined}} or anything else is wrong.
\item \begin{verbatim}
sls_detector_get threshold
threshold xxxx
\end{verbatim}
Returns a string (xxxx) that can be interpreted as the threshold in eV. If it fails to set it, returns the last threshold it was set (which the detector still has). If settings are not defined or different trimbits are chosen, it will return "undefined".
\item \begin{verbatim}
sls_detector_get fname
fname string
\end{verbatim}
\item \begin{verbatim}
sls_detector_get exptime
exptime number
\end{verbatim}
where {\tt{number}} is a string to be interpreted as a float in (s).
\item \begin{verbatim}
sls_detector_get period
period number
\end{verbatim}
where {\tt{nuymber}} is a string to be interpreted as a float in (s).
\item \begin{verbatim}
sls_detector_get frames
frames number
\end{verbatim}
where {\tt{number}} is a string to be interpreted as an integer.
\item \begin{verbatim}
sls_detector_get cycles
cycles number
\end{verbatim}
where {\tt{number}} is a string to be interpreted as an integer.
\item \begin{verbatim}
sls_detector_get status
status string
\end{verbatim}
where {\tt{string}} can be {\tt{idle}} or {\tt{running}}.
\item \begin{verbatim}
sls_detector_get index
status number
\end{verbatim}
where {\tt{number}} is a string to be interpreted as an integer.
\item \begin{verbatim}
sls_detector_get dr
dr number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as an integer (4/8/16/32).
\item \begin{verbatim}
sls_detector_get clkdivider
clkdivider number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as an integer (0/1/2/3).
\item \begin{verbatim}
sls_detector_get flags
flags string1 string2
\end{verbatim}
where {\tt{string1}} is a string should be always {\tt{continous}} and {\tt{string2}} can be either {\tt{nonparallel}} or {\tt{parallel}}.
\item \begin{verbatim}
sls_detector_get timing
timing string
\end{verbatim}
where {\tt{string}} is a string which can be {\tt{auto/trigger/burst\_trigger/gating}}.
\item \begin{verbatim}
sls_detector_get enablefwrite
enablefwrite number
\end{verbatim}
where {\tt{number}} is a string which should be interpreted as an integer "0" or "1".
\item \begin{verbatim}
sls_detector_get framescaught
framescaught number
\end{verbatim}
where {\tt{number}} is a string which should be interpreted as an integer of the complete frames got by the receiver.
\item \begin{verbatim}
sls_detector_get frameindex
frameindex number
\end{verbatim}
where {\tt{number}} is a string which should be interpreted as an integer of the last frame number read from firmware. It comes from the receiver, though and reset after every acquisition series.
\item \begin{verbatim}
sls_detector_get subexptime
subexptime number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as a float in s. The default value is 0.002621440.
\item \begin{verbatim}
sls_detector_get ratecorr
ratecorr number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as a float in s. 0.000000 means correction off. Values above zero are the value of $\tau$ in ns.
\item \begin{verbatim}
sls_detector_get vhighvoltage
vhighvoltage number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as an int and for proper Eiger setting is approximately 150~V if it is correctly set. If two master modules are presents (multi systems), the average is returned (still to be tested). If one asks for the individual $n$ half module bias voltage through {\tt{sls\_detector\_get n:vhighvoltage}}, if the $n$ module is a master, the actual voltage will be returned. If it is a slave, -999 will be returned.
\item \begin{verbatim}
sls_detector_get busy
busy number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as an int for 0/1 meaning no/yes. This command tells if the sharedmemory has in memory that an acquisition has been started or not. It should allows to use the non blocking acquire, regardless of any delay to the detector getting into 'running' mode.
\end{enumerate}
\section{1Gb/s, 10Gb/s links}
\subsection{Checking the 1Gb/s, 10Gb/s physical links}\label{led}
@ -1009,5 +884,148 @@ Scroll up in the terminal till you find:\\
\section{Client checks - command line}
Guide on returned strings:
\begin{enumerate}
\item \begin{verbatim}
sls_detector_get free
\end{verbatim}
Returns a list of shared memories cleaned (variable number depending on detector):
\begin{verbatim}
Shared memory 273612805 deleted
Shared memory 276922374 deleted
Shared memory 270270468 deleted
free freed
\end{verbatim}
Note that occasionally if there is a shared memory of a different size (from an older software version), it will return also a line like this:
\begin{verbatim}
*** shmget error (server) ***-1
\end{verbatim}
This needs to be cleaned with {\tt{ipcs -m}} and then {\tt{ipcrm -M xxx}}, where xxx are the keys with nattch 0.
\item \begin{verbatim}sls_detector_get settings
settings standard
\end{verbatim}
{\tt{standard}} is only if correct. {\tt{undefined}} or anything else is wrong.
\item \begin{verbatim}
sls_detector_get threshold
threshold xxxx
\end{verbatim}
Returns a string (xxxx) that can be interpreted as the threshold in eV. If it fails to set it, returns the last threshold it was set (which the detector still has). If settings are not defined or different trimbits are chosen, it will return "undefined".
\item \begin{verbatim}
sls_detector_get fname
fname string
\end{verbatim}
\item \begin{verbatim}
sls_detector_get exptime
exptime number
\end{verbatim}
where {\tt{number}} is a string to be interpreted as a float in (s).
\item \begin{verbatim}
sls_detector_get period
period number
\end{verbatim}
where {\tt{nuymber}} is a string to be interpreted as a float in (s).
\item \begin{verbatim}
sls_detector_get frames
frames number
\end{verbatim}
where {\tt{number}} is a string to be interpreted as an integer.
\item \begin{verbatim}
sls_detector_get cycles
cycles number
\end{verbatim}
where {\tt{number}} is a string to be interpreted as an integer.
\item \begin{verbatim}
sls_detector_get status
status string
\end{verbatim}
where {\tt{string}} can be {\tt{idle}} or {\tt{running}}.
\item \begin{verbatim}
sls_detector_get index
status number
\end{verbatim}
where {\tt{number}} is a string to be interpreted as an integer.
\item \begin{verbatim}
sls_detector_get dr
dr number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as an integer (4/8/16/32).
\item \begin{verbatim}
sls_detector_get clkdivider
clkdivider number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as an integer (0/1/2/3).
\item \begin{verbatim}
sls_detector_get flags
flags string1 string2
\end{verbatim}
where {\tt{string1}} is a string should be always {\tt{continous}} and {\tt{string2}} can be either {\tt{nonparallel}} or {\tt{parallel}}.
\item \begin{verbatim}
sls_detector_get timing
timing string
\end{verbatim}
where {\tt{string}} is a string which can be {\tt{auto/trigger/burst\_trigger/gating}}.
\item \begin{verbatim}
sls_detector_get enablefwrite
enablefwrite number
\end{verbatim}
where {\tt{number}} is a string which should be interpreted as an integer "0" or "1".
\item \begin{verbatim}
sls_detector_get framescaught
framescaught number
\end{verbatim}
where {\tt{number}} is a string which should be interpreted as an integer of the complete frames got by the receiver.
\item \begin{verbatim}
sls_detector_get frameindex
frameindex number
\end{verbatim}
where {\tt{number}} is a string which should be interpreted as an integer of the last frame number read from firmware. It comes from the receiver, though and reset after every acquisition series.
\item \begin{verbatim}
sls_detector_get subexptime
subexptime number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as a float in s. The default value is 0.002621440.
\item \begin{verbatim}
sls_detector_get ratecorr
ratecorr number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as a float in s. 0.000000 means correction off. Values above zero are the value of $\tau$ in ns.
\item \begin{verbatim}
sls_detector_get vhighvoltage
vhighvoltage number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as an int and for proper Eiger setting is approximately 150~V if it is correctly set. If two master modules are presents (multi systems), the average is returned (still to be tested). If one asks for the individual $n$ half module bias voltage through {\tt{sls\_detector\_get n:vhighvoltage}}, if the $n$ module is a master, the actual voltage will be returned. If it is a slave, -999 will be returned.
\item \begin{verbatim}
sls_detector_get busy
busy number
\end{verbatim}
where {\tt{number}} is a string that should be interpreted as an int for 0/1 meaning no/yes. This command tells if the sharedmemory has in memory that an acquisition has been started or not. It should allows to use the non blocking acquire, regardless of any delay to the detector getting into 'running' mode.
\end{enumerate}
\end{document}

View File

@ -50,9 +50,13 @@ public:
for(int ix=0; ix<xpixels; ix++) {
imod=ix%2;
if (imod==0)
dMap[0][ix] =ix+offset;
ipix=ix/2;
else
dMap[0][ix] = 1280*2+2*offset+2*(1280-1-ix/2);//dataSize-2-ix;//+2*offset;
ipix=1280-1-ix/2;
if (imod==0)
dMap[0][ix] =ipix*2+offset;
else
dMap[0][ix] = 1280*2+2*offset+ipix*2;//dataSize-2-ix;//+2*offset;
// dMap[0][ix] = 2*ipix+offset*(imod+1)+1280*2*imod;
dMask[0][ix] = 0x0;
}

View File

@ -54,7 +54,7 @@ int main(int argc, char *argv[]){
int fifosize=1000;
int nthreads=3;
int nthreads=1;
int nph, nph1;
int etabins=550;
double etamin=-1, etamax=2;
@ -72,8 +72,8 @@ int main(int argc, char *argv[]){
gotthardModuleDataNew *decoder=new gotthardModuleDataNew();
gotthardDoubleModuleDataNew *det=new gotthardDoubleModuleDataNew(offset);
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 200);
filter->setROI(0,512,0,1);
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 100);
filter->setROI(0,2560,0,1);
char *buff;//[2*(48+1280*2)];
char *buff0;
char *buff1;
@ -82,7 +82,7 @@ int main(int argc, char *argv[]){
mt->StartThreads();
mt->popFree(buff);
buff0=buff;
buff1=buff+48+1280*2;
buff1=buff+offset*2+1280*2;
int photons[1280*2];
int nf=0;
int ok=0;
@ -249,7 +249,6 @@ int main(int argc, char *argv[]){
int runmax=atoi(argv[4]);
char *outdir=argv[5];
sprintf(ff,"%s/%s",indir,fformat);
// strcpy(fformat,"/external_pool/gotthard_data/datadir_gotthardI/bchip074075/20170731/Xray/xray_15kV_200uA_5us_d%d_f000000000000_0.raw");
// sprintf(fname0,fformat,0,0);
// sprintf(fname1,fformat,1,1);
@ -277,21 +276,37 @@ int main(int argc, char *argv[]){
#ifdef ZMQ
int end_of_acquisition;
while(1) {
if ((!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) && (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1))){
end_of_acquisition=0;
// cout << "Receive header " << nf << endl;
if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) {
cout << "************************************************************************** packet0!*****************************"<< endl;
end_of_acquisition++;
}
if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) {
cout << "************************************************************************** packet1!*****************************"<< endl;
end_of_acquisition++;
}
// if ((!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) && (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1))){
if (end_of_acquisition) {
cout << "************************************************************************** END OF FRAME" << end_of_acquisition << " !*****************************"<< endl;
// return 0;
while (mt->isBusy()) {;}
image=filter->getImage();
if (image) {
fout=fopen(ofname,"w");
//cout << nf << "*****************" << endl;
for (int i=0; i<512; i++) {
fprintf(fout,"%d %d\n",i,image[i]);
dout[i]=image[i];
//fout=fopen(ofname,"w");
cout << nf << "*****************" << endl;
for (int i=0; i<2560; i++) {
// // fprintf(fout,"%d %d\n",i,image[i]);
dout[i]=image[i];
}
fclose(fout);;
// // fclose(fout);;
}
@ -330,9 +345,10 @@ int main(int argc, char *argv[]){
cout << "different frame indexes " << frameIndex0 << " and " << frameIndex1 << endl;
// cout << "Receive data " << nf << endl;
length = zmqsocket0->ReceiveData(0, buff0, size/2);
length += zmqsocket0->ReceiveData(0, buff1, size/2);
length += zmqsocket1->ReceiveData(0, buff1, size/2);
irun=fileindex0;
sprintf(ofname,"%s_%d.ph",filename0.c_str(),fileindex0);
@ -344,7 +360,7 @@ int main(int argc, char *argv[]){
mt->nextThread();
mt->popFree(buff);
buff0=buff;
buff1=buff+48+1280*2;
buff1=buff+offset*2+1280*2;
nf++;

View File

@ -0,0 +1,261 @@
#ifndef ETA_INTERPOLATION_ADAPTIVEBINS_H
#define ETA_INTERPOLATION_ADAPTIVEBINS_H
#include "tiffIO.h"
//#include "etaInterpolationBase.h"
#include "etaInterpolationPosXY.h"
class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
private:
double calcDiff(double avg, float *hx, float *hy) {
double p_tot=0;
double diff=0;
double bsize=1./nSubPixels;
for (int ipx=0; ipx<nSubPixels; ipx++) {
for (int ipy=0; ipy<nSubPixels; ipy++) {
p_tot=0;
for (int ibx=0; ibx<nbeta; ibx++) {
for (int iby=0; iby<nbeta; iby++) {
if ( hx[ibx+iby*nbeta]>=((ipx)*bsize) && hx[ibx+iby*nbeta]<((ipx+1)*bsize) && hy[ibx+iby*nbeta]>=((ipy)*bsize) && hy[ibx+iby*nbeta]<((ipy+1)*bsize)) {
p_tot+=heta[ibx+iby*nbeta];
}
}
}
cout << p_tot << " \t ";
diff+=(p_tot-avg)*(p_tot-avg);
}
cout << "\n";
}
return diff;
}
void iterate(float *newhhx, float *newhhy) {
double bsize=1./nSubPixels;
double hy[nbeta]; //profile y
double hx[nbeta]; //profile x
double hix[nbeta]; //integral of projection x
double hiy[nbeta]; //integral of projection y
double tot_eta_x=0;
double tot_eta_y=0;
for (int ipy=0; ipy<nSubPixels; ipy++) {
for (int ibx=0; ibx<nbeta; ibx++) {
hx[ibx]=0;
hy[ibx]=0;
}
tot_eta_x=0;
tot_eta_y=0;
// cout << ipy << " " << ((ipy)*bsize) << " " << ((ipy+1)*bsize) << endl;
for (int ibx=0; ibx<nbeta; ibx++) {
for (int iby=0; iby<nbeta; iby++) {
if (hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
hx[ibx]+=heta[ibx+iby*nbeta];
tot_eta_x+=heta[ibx+iby*nbeta];
}
if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
hy[iby]+=heta[ibx+iby*nbeta];
tot_eta_y+=heta[ibx+iby*nbeta];
}
}
}
hix[0]=hx[0];
hiy[0]=hy[0];
for (int ib=1; ib<nbeta; ib++) {
hix[ib]=hix[ib-1]+hx[ib];
hiy[ib]=hiy[ib-1]+hy[ib];
}
// tot_eta_x=hix[nbeta-1];
// tot_eta_y=hiy[nbeta-1];
/* cout << "ipx " << ipy << " x: " << tot_eta_x << " " << hix[10]<< " " << hix[nbeta-1] << endl; */
/* cout << "ipy " << ipy << " y: " << tot_eta_y << " " << hiy[10]<< " " << hiy[nbeta-1] << endl; */
// for (int ipy=0; ipy<nSubPixels; ipy++) {
for (int ibx=0; ibx<nbeta; ibx++) {
for (int iby=0; iby<nbeta; iby++) {
if ( hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
newhhx[ibx+iby*nbeta]=hix[ibx]/((double)tot_eta_x);
if (newhhx[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhx[ibx+iby*nbeta] << endl;
// if (ipy==3 && ibx==10) cout << newhhx[ibx+iby*nbeta] << " " << hix[ibx] << " " << ibx+iby*nbeta << endl;
}
if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
newhhy[ibx+iby*nbeta]=hiy[iby]/((double)tot_eta_y);
if (newhhy[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhy[ibx+iby*nbeta] << endl;
// if (ipy==3 && iby==10) cout << newhhy[ibx+iby*nbeta] << " " << hiy[iby] << " " << ibx+iby*nbeta << endl;
}
}
}
}
}
public:
etaInterpolationAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){};
etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationPosXY(orig){};
virtual etaInterpolationAdaptiveBins* Clone() {
return new etaInterpolationAdaptiveBins(this);
};
virtual void prepareInterpolation(int &ok)
{
ok=1;
cout << "Adaptive bins" << endl;
///*Eta Distribution Rebinning*///
double bsize=1./nSubPixels; //precision
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl;
double tot_eta=0;
double tot_eta_x=0;
double tot_eta_y=0;
for (int ip=0; ip<nbeta*nbeta; ip++)
tot_eta+=heta[ip];
if (tot_eta<=0) {ok=0; return;};
double hx[nbeta]; //profile x
double hy[nbeta]; //profile y
double hix[nbeta]; //integral of projection x
double hiy[nbeta]; //integral of projection y
int ii=0;
/** initialize distribution to linear interpolation */
// for (int ibx=0; ibx<nbeta; ibx++) {
// for (int ib=0; ib<nbeta; ib++) {
// hhx[ibx+ib*nbeta]=((float)ibx)/((float)nbeta);
// hhy[ibx+ib*nbeta]=((float)ib)/((float)nbeta);
// }
// }
etaInterpolationPosXY::prepareInterpolation(ok);
#ifdef SAVE_ALL
char tit[10000];
float *etah=new float[nbeta*nbeta];
int etabins=nbeta;
for (int ii=0; ii<etabins*etabins; ii++) {
etah[ii]=hhx[ii];
}
sprintf(tit,"/scratch/start_hhx.tiff");
WriteToTiff(etah, tit, etabins, etabins);
for (int ii=0; ii<etabins*etabins; ii++) {
etah[ii]=hhy[ii];
}
sprintf(tit,"/scratch/start_hhy.tiff");
WriteToTiff(etah, tit, etabins, etabins);
#endif
int nint=1000;
double thr=1./((double)nSubPixels);
double avg=tot_eta/((double)(nSubPixels*nSubPixels));
cout << "total eta entries is :"<< tot_eta << " avg: "<< avg << endl;
cout << "Start " << endl;
double old_diff=calcDiff(avg, hhx, hhy), new_diff=old_diff+1;
cout << " diff= " << new_diff << endl;
int iint=0;
float *newhhx=new float[nbeta*nbeta]; //profile x
float *newhhy=new float[nbeta*nbeta]; //profile y
while (iint<nint) {
cout << "Iteration " << iint << endl;
iterate(newhhx,newhhy);
new_diff=calcDiff(avg, newhhx, newhhy);
cout << " diff= " << new_diff << endl;
#ifdef SAVE_ALL
for (int ii=0; ii<etabins*etabins; ii++) {
etah[ii]=newhhx[ii];
if (etah[ii]>1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl;
}
sprintf(tit,"/scratch/neweta_hhx_%d.tiff",iint);
WriteToTiff(etah, tit, etabins, etabins);
for (int ii=0; ii<etabins*etabins; ii++) {
etah[ii]=newhhy[ii];
if (etah[ii]>1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl;
}
sprintf(tit,"/scratch/neweta_hhy_%d.tiff",iint);
WriteToTiff(etah, tit, etabins, etabins);
#endif
// if (new_diff<old_diff) {
delete [] hhx;
delete [] hhy;
hhx=newhhx;
hhy=newhhy;
newhhx=new float[nbeta*nbeta]; //profile x
newhhy=new float[nbeta*nbeta]; //profile y
old_diff=new_diff;
// } /* else { */
/* cout << "Difference not decreasing after "<< iint << " iterations (" << old_diff << " < " << new_diff << ")"<< endl; */
/* break; */
/* } */
iint++;
}
delete [] newhhx;
delete [] newhhy;
#ifdef SAVE_ALL
for (int ii=0; ii<etabins*etabins; ii++) {
etah[ii]=hhx[ii];
}
sprintf(tit,"/scratch/eta_hhx_%d.tiff",id);
WriteToTiff(etah, tit, etabins, etabins);
for (int ii=0; ii<etabins*etabins; ii++) {
etah[ii]=hhy[ii];
}
sprintf(tit,"/scratch/eta_hhy_%d.tiff",id);
WriteToTiff(etah, tit, etabins, etabins);
for (int ii=0; ii<etabins*etabins; ii++) {
etah[ii]=heta[ii];
}
sprintf(tit,"/scratch/eta_%d.tiff",id);
WriteToTiff(etah, tit, etabins, etabins);
delete [] etah;
#endif
return ;
}
};
#endif

View File

@ -285,25 +285,21 @@ float *gethhx()
switch (corner)
{
case TOP_LEFT:
dX=-1.;//.99;
dY=0;//+1.;//.99;
//etay=1-etay;
dX=-1.;
dY=0;
break;
case TOP_RIGHT:
;
dX=0;//+1.;//.99;
dY=0;//+1.;//.99;
dX=0;
dY=0;
break;
case BOTTOM_LEFT:
//etax=1-etax;
//etay=1-etay;
dX=-1.;//99;
dY=-1.;//.99;
dX=-1.;
dY=-1.;
break;
case BOTTOM_RIGHT:
//etay=1-etay;
dX=0;//1.;//+.99;
dY=-1.;//-.99;
dX=0;
dY=-1.;
break;
default:
cout << "bad quadrant" << endl;
@ -353,16 +349,9 @@ float *gethhx()
ypos_eta=0.5*dY+0.25;
}
// int_x=((double)x) + 0.5*dX + xpos_eta;
// int_y=((double)y) + 0.5*dY + ypos_eta;
int_x=((double)x) + xpos_eta;
int_y=((double)y) + ypos_eta;
/* if (int_x<x-0.5 || int_y<y-0.5 ) { */
/* // cout << "***"<< x <<" " << y << " " << int_x << " " << int_y << endl; */
/* cout << corner << " X "<< x << " " << etax << " " << xpos_eta << " " << int_x <<" Y "<< y << " " << etay << " " << ypos_eta << " " <<int_y << endl; */
/* } */
//return 1;
int_x=((double)x) + xpos_eta+0.5;
int_y=((double)y) + ypos_eta+0.5;
}

View File

@ -143,6 +143,7 @@ class etaInterpolationPosXY : public etaInterpolationBase{
}
sprintf(tit,"/scratch/eta_%d.tiff",id);
WriteToTiff(etah, tit, etabins, etabins);
delete [] etah;
#endif
return ;
}

View File

@ -2,19 +2,19 @@
#include <iomanip>
ClassImp(EtaVEL);
// ClassImp(EtaVEL);
double Median(const TH1D * histo1) {
// double Median(const TH1D * histo1) {
int numBins = histo1->GetXaxis()->GetNbins();
Double_t *x = new Double_t[numBins];
Double_t* y = new Double_t[numBins];
for (int i = 0; i < numBins; i++) {
x[i] = histo1->GetBinCenter(i);
y[i] = histo1->GetBinContent(i);
}
return TMath::Median(numBins, x, y);
}
// int numBins = histo1->GetXaxis()->GetNbins();
// Double_t *x = new Double_t[numBins];
// Double_t* y = new Double_t[numBins];
// for (int i = 0; i < numBins; i++) {
// x[i] = histo1->GetBinCenter(i);
// y[i] = histo1->GetBinContent(i);
// }
// return TMath::Median(numBins, x, y);
// }
double *EtaVEL::getPixelCorners(int x, int y){

View File

@ -3,11 +3,11 @@
#include <slsInterpolation.h>
#include "EtaVEL.h"
#include "TH2F.h"
//#include "TH2F.h"
//#include "EtaVEL.cpp"
//class EtaVEL;
class interpolation_EtaVEL: public slsInterpolation {
class etaVELInterpolation: public etaInterpolationBase {
public:
interpolation_EtaVEL(int nx=40, int ny=160, int ns=25, double etamin=-0.02, double etamax=1.02, int p=0);
@ -31,18 +31,21 @@ class interpolation_EtaVEL: public slsInterpolation {
int addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay);
int addToFlatField(Double_t etax, Double_t etay);
int setPlot(int p=-1) {if (p>=0) plot=p; return plot;};
int WriteH(){newEta->Write("newEta"); heta->Write("heta");};
// int WriteH(){newEta->Write("newEta"); heta->Write("heta");};
EtaVEL *setEta(EtaVEL *ev){if (ev) {delete newEta; newEta=ev;} return newEta;};
TH2F *setEta(TH2F *ev){if (ev) {delete heta; heta=ev;} return heta;};
// TH2F *setEta(TH2F *ev){if (ev) {delete heta; heta=ev;} return heta;};
void iterate();
void DrawH();
// void DrawH();
double getChiSq(){return newEta->getChiSq();};
protected:
EtaVEL *newEta;
TH2F *heta;
// TH2F *heta;
int plot;
// ClassDefNV(interpolation_EtaVEL,1);

View File

@ -1,11 +1,10 @@
#CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
#ZMQLIB=../slsReceiverSoftware/include
#LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
INCDIR=-IslsDetectorCalibration -I. -IetaVEL -I../slsReceiverSoftware/include
#-I$(CBFLIBDIR)/include/
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/
#LIBHDF5=
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
#-L$(ZMQLIB) -lzmq
#-L../../bin
MAIN=moench03ClusterFinder.cpp
@ -17,17 +16,18 @@ all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation
moenchClusterFinder: $(MAIN) $(INCS) clean
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DOLDDATA
moenchMakeEta: moench03MakeEta.cpp $(INCS) clean
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
clean:
rm -f moenchClusterFinder moenchMakeEta
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation

View File

@ -2,7 +2,7 @@
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
#ZMQLIB=../slsReceiverSoftware/include
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
INCDIR=-IslsDetectorCalibration -I. -IetaVEL -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/
INCDIR=-I.. -I. -I../interpolations -I../interpolations/etaVEL -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ ../tiffIO.cpp -I../dataStructures
#LIBHDF5=
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff -lhdf5
#-L$(ZMQLIB) -lzmq
@ -17,14 +17,8 @@ all: moenchClusterFinderPhoenix
moenchClusterFinderPhoenix: $(MAIN) $(INCS) clean
g++ -o moenchClusterFinderPhoenix $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
moenchMakeEtaPhoenix: moench03MakeEtaPhoenix.cpp $(INCS) clean
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
moenchInterpolationPhoenix: moench03InterpolationPhoenix.cpp $(INCS) clean
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
g++ -o moenchClusterFinderPhoenix $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
clean:
rm -f moenchClusterFinderPhoenix moenchMakeEtaPhoenix moenchInterpolationPhoenix
rm -f moenchClusterFinderPhoenix

View File

@ -5,9 +5,9 @@
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
ZMQLIB=../slsReceiverSoftware/include
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
INCDIR=-IslsDetectorCalibration -I. -IetaVEL -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I$(ROOTSYS)/include
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I$(ROOTSYS)/include
#LIBHDF5=
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB) -lzmq
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff
MAIN=tiff_to_th2f.cpp
@ -18,7 +18,7 @@ all: tiff_to_th2f
tiff_to_th2f: $(MAIN) $(INCS)
g++ -o tiff_to_th2f $(MAIN) `root-config --cflags --glibs` -lMinuit -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp
g++ -o tiff_to_th2f $(MAIN) `root-config --cflags --glibs` -lMinuit -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) ../tiffIO.cpp
clean:
rm -f tiff_to_th2f

View File

@ -1,8 +1,18 @@
//#include "ansi.h"
#include <iostream>
//#include "moench03T1ZmqData.h"
#ifdef NEWRECEIVER
#include "moench03T1ReceiverDataNew.h"
#endif
#ifdef CSAXS_FP
#include "moench03T1ReceiverData.h"
#endif
#ifdef OLDDATA
#include "moench03Ctb10GbT1Data.h"
#endif
// #include "interpolatingDetector.h"
//#include "etaInterpolationPosXY.h"
@ -24,12 +34,13 @@ using namespace std;
int main(int argc, char *argv[]) {
if (argc<7) {
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax pedfname" << endl;
if (argc<6) {
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
return 1;
}
int p=10000;
int fifosize=1000;
int nthreads=20;
int nthreads=8;
int nsubpix=25;
int etabins=nsubpix*10;
double etamin=-1, etamax=2;
@ -42,11 +53,30 @@ int main(int argc, char *argv[]) {
int ok;
int iprog=0;
#ifdef NEWRECEIVER
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
#endif
#ifdef CSAXS_FP
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
#endif
#ifdef OLDDATA
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
cout << "OLD RECEIVER DATA!"<<endl;
#endif
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
// char tit[10000];
cout << "filter " << endl;
@ -80,7 +110,7 @@ int main(int argc, char *argv[]) {
char outfname[10000];
char imgfname[10000];
char pedfname[10000];
strcpy(pedfname,argv[6]);
// strcpy(pedfname,argv[6]);
char fn[10000];
std::time_t end_time;
@ -89,52 +119,52 @@ int main(int argc, char *argv[]) {
cout << "input directory is " << indir << endl;
cout << "output directory is " << outdir << endl;
cout << "fileformat is " << fformat << endl;
cout << "pedestal file is " << fformat << endl;
// cout << "pedestal file is " << fformat << endl;
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
filter->setFrameMode(eFrame);
// mt->setFrameMode(ePedestal);
cout << pedfname<< endl;
// filter->setFrameMode(eFrame);
// mt->setFrameMode(ePedestal);
// cout << pedfname<< endl;
filebin.open((const char *)(pedfname), ios::in | ios::binary);
//filebin.open((const char *)(fname), ios::in | ios::binary);
// filebin.open((const char *)(pedfname), ios::in | ios::binary);
// //filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
if (filebin.is_open()){
// //while read frame
cout << "pedestal file " << endl;
while (decoder->readNextFrame(filebin, ff, np,data)) {
// cout << ff << " " << np << endl;
// //push
// mt->pushData(buff);
// // //pop
//mt->nextThread();
// // // cout << " " << (void*)buff;
//mt->popFree(buff);
filter->processData(data);
}
filebin.close();
// //close file
// //join threads
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
// cout << outfname << endl;
// filter->writePedestals(outfname);
// sprintf(outfname,"%s/%s_pedimg.tiff",outdir,fn);
// // //open file
// if (filebin.is_open()){
// // //while read frame
// cout << "pedestal file " << endl;
// while (decoder->readNextFrame(filebin, ff, np,data)) {
// // cout << ff << " " << np << endl;
// // //push
// // mt->pushData(buff);
// // // //pop
// //mt->nextThread();
// // // // cout << " " << (void*)buff;
// //mt->popFree(buff);
// filter->processData(data);
// }
// filebin.close();
// // //close file
// // //join threads
// // while (mt->isBusy()) {;}//wait until all data are processed from the queues
// // cout << outfname << endl;
// // filter->writePedestals(outfname);
// // sprintf(outfname,"%s/%s_pedimg.tiff",outdir,fn);
// cout << outfname << endl;
// // cout << outfname << endl;
// filter->writeImage(outfname);
// //mt->clearImage();
} else
cout << "Could not open "<< pedfname << " for reading " << endl;
// // filter->writeImage(outfname);
// // //mt->clearImage();
// } else
// cout << "Could not open "<< pedfname << " for reading " << endl;
// for (int ix=0; ix<400; ix++)
// for (int iy=0; iy<400; iy++)
// cout << ix << " " << iy << " " << filter->getPedestal(ix,iy) << " " << filter->getPedestalRMS(ix,iy) << endl;
// // for (int ix=0; ix<400; ix++)
// // for (int iy=0; iy<400; iy++)
// // cout << ix << " " << iy << " " << filter->getPedestal(ix,iy) << " " << filter->getPedestalRMS(ix,iy) << endl;
@ -149,11 +179,12 @@ filter->setFrameMode(eFrame);
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
// mt->prepareInterpolation(ok);
mt->setFrameMode(eFrame);
mt->setFrameMode(eFrame);
mt->StartThreads();
mt->popFree(buff);
cout << "mt " << endl;
int ifr=0;
// //loop on files
@ -165,37 +196,37 @@ filter->setFrameMode(eFrame);
for (int irun=runmin; irun<runmin+5; irun++) {
sprintf(fn,fformat,irun);
sprintf(fname,"%s/%s.raw",indir,fn);
// for (int irun=runmin; irun<runmin+5; irun++) {
// sprintf(fn,fformat,irun);
// sprintf(fname,"%s/%s.raw",indir,fn);
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
if (filebin.is_open()){
// //while read frame
while (decoder->readNextFrame(filebin, ff, np,buff)) {
// cout << "*"<<ifr++<<"*"<<ff<< endl;
// cout << ff << " " << np << endl;
// //push
mt->pushData(buff);
// // //pop
mt->nextThread();
// // // cout << " " << (void*)buff;
mt->popFree(buff);
// filebin.open((const char *)(fname), ios::in | ios::binary);
// // //open file
// if (filebin.is_open()){
// // //while read frame
// while (decoder->readNextFrame(filebin, ff, np,buff)) {
// // cout << "*"<<ifr++<<"*"<<ff<< endl;
// // cout << ff << " " << np << endl;
// // //push
// mt->pushData(buff);
// // // //pop
// mt->nextThread();
// // // // cout << " " << (void*)buff;
// mt->popFree(buff);
}
// cout << "--" << endl;
filebin.close();
// }
// // cout << "--" << endl;
// filebin.close();
}
// }
}
// }
while (mt->isBusy()) {;}//wait until all data are processed from the queues
mt->clearImage();
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
// mt->clearImage();
for (int irun=runmin; irun<runmax; irun++) {
sprintf(fn,fformat,irun);
@ -218,18 +249,19 @@ filter->setFrameMode(eFrame);
return 1;
}
// //while read frame
ff=-1;
while (decoder->readNextFrame(filebin, ff, np,buff)) {
// cout << "*"<<ifr++<<"*"<<ff<< endl;
// cout << ff << " " << np << endl;
// //push
mt->pushData(buff);
mt->pushData(buff);
// // //pop
mt->nextThread();
mt->nextThread();
// // // cout << " " << (void*)buff;
mt->popFree(buff);
mt->popFree(buff);
ff=-1;
}
// cout << "--" << endl;
cout << "--" << endl;
filebin.close();
// //close file
// //join threads

View File

@ -32,7 +32,7 @@ int main(int argc, char *argv[]) {
}
int p=10000;
int fifosize=1000;
int nthreads=20;
int nthreads=1;
int nsubpix=25;
int etabins=nsubpix*10;
double etamin=-1, etamax=2;
@ -48,7 +48,7 @@ int main(int argc, char *argv[]) {
cout << "decoder" << endl;
//moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
// char tit[10000];
cout << "filter" << endl;
@ -117,21 +117,21 @@ int main(int argc, char *argv[]) {
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
// mt->prepareInterpolation(ok);
mt->setFrameMode(eFrame);
mt->setFrameMode(eFrame);
mt->StartThreads();
mt->popFree(buff);
int ifr=0;
// //loop on files
// mt->setFrameMode(eFrame);
//mt->setFrameMode(eFlat);
//mt->setFrameMode(eFlat);
for (int irun=runmin; irun<runmax; irun++) {
sprintf(fn,fformat,irun);
sprintf(fname,"%s/%s.raw",indir,fn);
@ -155,8 +155,8 @@ int main(int argc, char *argv[]) {
// //while read frame
ff=-1;
while (decoder->readNextFrame(filebin, ff, np,buff)) {
// cout << "*"<<ifr++<<"*"<<ff<< endl;
// cout << ff << " " << np << endl;
//cout << "*"<<ifr++<<"*"<<ff<< endl;
//cout << ff << " " << np << endl;
// //push
mt->pushData(buff);
// // //pop
@ -164,7 +164,7 @@ int main(int argc, char *argv[]) {
// // // cout << " " << (void*)buff;
mt->popFree(buff);
ff=-1;
ff=-1;
}
// cout << "--" << endl;
filebin.close();

View File

@ -5,8 +5,8 @@
#include "moench03T1ZmqData.h"
#include "single_photon_hit.h"
#include "etaInterpolationPosXY.h"
// #include "etaInterpolationPosXY.h"
#include "etaInterpolationAdaptiveBins.h"
using namespace std;
#define NC 400
#define NR 400
@ -43,9 +43,13 @@ int main(int argc, char *argv[]) {
FILE *f=NULL;
single_photon_hit cl(3,3);
etaInterpolationPosXY *interp=new etaInterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
// etaInterpolationPosXY *interp=new etaInterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
etaInterpolationAdaptiveBins *interp=new etaInterpolationAdaptiveBins (NC, NR, nsubpix, etabins, etamin, etamax);
//#ifndef FF
cout << "read ff " << argv[2] << endl;
interp->readFlatField(argv[2]);
interp->prepareInterpolation(ok);
//#endif
int *img;
float *totimg=new float[NC*NR*nsubpix*nsubpix];
@ -133,7 +137,7 @@ int main(int argc, char *argv[]) {
}
}
cout << "writing eta!" << endl;
WriteToTiff(ffimg, outfname,NC*nsubpix,NR*nsubpix);

View File

@ -1,5 +1,10 @@
#include "single_photon_hit.h"
#include "../single_photon_hit.h"
//#include "etaVEL/etaInterpolationPosXY.h"
#include <TH1F.h>
#include <TH2F.h>
#include <TCanvas.h>
#include <iostream>
using namespace std;
TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
FILE *f=fopen(fname,"r");
@ -11,83 +16,136 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
int x1,y1;
if (h2==NULL)
h2=new TH2F("h2",fname,nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
h2mult=new TH2F("h2mult",fname,nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
TH2F *hint=new TH2F("hint",fname,nx*ns, -0.5, nx-0.5, ny*ns, -0.5, ny-0.5);
TH2F *hff=new TH2F("hff","hff",ns, -0.5, 0.5, ns, -0.5, +0.5);
TH1F *hsp=new TH1F("hsp",fname,500,0,2000);
//h2mult=new TH2F("h2mult",fname,nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
// TH2F *hint=new TH2F("hint",fname,nx*ns, -0.5, nx-0.5, ny*ns, -0.5, ny-0.5);
TH1F *hf=new TH1F("hf","hf",1000,0,10E6);
//TH2F *hff=new TH2F("hff","hff",ns, -0.5, 0.5, ns, -0.5, +0.5);
TH1F *hsp=new TH1F("hsp",fname,500,0,10000);
// TH1F *hsp1=new TH1F("hsp1",fname,500,0,10000);
// TH1F *hsp2=new TH1F("hsp2",fname,500,0,1000);
// TH1F *hsp3=new TH1F("hsp3",fname,500,0,1000);
// hsp1->SetLineColor(2);
// hsp2->SetLineColor(3);
// hsp3->SetLineColor(4);
TCanvas *c=new TCanvas();
c->SetLogz(kTRUE);
h2->Draw("colz");
TCanvas *c1=new TCanvas();
hsp->Draw();
c1->SetLogy(kTRUE);
// hsp1->Draw("same");
// hsp2->Draw("same");
// hsp3->Draw("same");
TCanvas *c2=new TCanvas();
hint->Draw("colz");
c2->SetLogz(kTRUE);
hf->Draw();
// hint->Draw("colz");
//c2->SetLogz(kTRUE);
single_photon_hit cl(3,3);
double tot;
int w;
double phw=340, phs=62;
int f0=-1;
double tl, bl, tr, br, qt;
int iimage=0;
while (cl.read(f)) {
//cl.get_pixel(x1, y1);
//cout << cl.iframe << " " << cl.x << " " << cl.y << endl;
//if (cl.x>80 && cl.x<280 && cl.y>80 && cl.y<300) {
tot=0;
tot=0; /*
left=0;
right=0;
top=0;
bottom=0;
bottom=0;*/
tl=0; tr=0; bl=0; br=0;
for (int ix=-1; ix<2; ix++)
for (int iy=-1; iy<2; iy++){
tot+=cl.get_data(ix,iy);
if (ix<0) left+=cl.get_data(ix,iy);
if (ix>0) right+=cl.get_data(ix,iy);
if (iy<0) bottom+=cl.get_data(ix,iy);
if (iy>0) top+=cl.get_data(ix,iy);
if (ix<=0 && iy<=0) bl+=cl.get_data(ix,iy);
if (ix<=0 && iy>=0) tl+=cl.get_data(ix,iy);
if (ix>=0 && iy<=0) br+=cl.get_data(ix,iy);
if (ix>=0 && iy>=0) tr+=cl.get_data(ix,iy);
//if (ix<0) left+=cl.get_data(ix,iy);
// if (ix>0) right+=cl.get_data(ix,iy);
// if (iy<0) bottom+=cl.get_data(ix,iy);
// if (iy>0) top+=cl.get_data(ix,iy);
}
qt=bl;
if (br>qt) qt=br;
if (tl>qt) qt=tl;
if (tr>qt) qt=tr;
/*
px=(-left+right)/tot;
py=(-bottom+top)/tot;
py=(-bottom+top)/tot;*/
//max at 340
if (tot>200) {
w=(tot+3.5*phs)/phw;
} else
w=0;
if (w) {
hsp->Fill(tot);
if (w==1) {
h2->Fill(cl.x,cl.y,w);
hint->Fill(px+cl.x,py+cl.y,w);
if (cl.y<350)
hff->Fill(px,py,w);
}
h2mult->Fill(cl.x,cl.y,w);
//if (tot>200) {
w=1;
if (qt>1000) {
if (qt/tot>0.8 && qt/tot<1.2){
if (f0<0)
f0=cl.iframe;
hf->Fill(cl.iframe-f0);
// if (qt>540) w++;
// if (qt>820) w++;
//(tot+3.5*phs)/phw;
//} else
//w=0;
// if (w) {
// if (cl.y<350) {
// if (cl.y<100 || cl.y>300) {
// if (cl.x>150 && cl.x<250 && cl.y>200 && cl.y<250)
// hsp1->Fill(qt);
// else
hsp->Fill(qt);
// hsp2->Fill(cl.get_data(0,0));
// } else {
// hsp1->Fill(qt);
// hsp3->Fill(cl.get_data(0,0));
// }
//if (cl.x>160 && cl.x<260 && cl.y>30 && cl.y<80 && tot>0)
//if (w==1) {
// if (w==2)
h2->Fill(cl.x,cl.y,w);
// }
//}
// hint->Fill(px+cl.x,py+cl.y,w);
// if (cl.y<350)
// hff->Fill(px,py,w);
//}
// }
//h2mult->Fill(cl.x,cl.y,w);
}
iph+=w;
if (iph%100000==0) {
// c->Modified();
// c->Update();
c->Modified();
c->Update();
c1->Modified();;
c1->Update();
// c2->Modified();;
// c2->Update();
c2->Modified();;
c2->Update();
}
// if (iph>1E7)
// break;
//}
// if (iph>0.5E7) break;
}
// if (iph>0.5E7) break;
}
fclose(f);
hff->Scale(hff->GetNbinsX()*hff->GetNbinsY()/hff->Integral());
TH2F *hint2=(TH2F*)hint->Clone("hint2");
double ff;
for (int ibx=0; ibx<hint->GetNbinsX(); ibx++) {
for (int iby=0; iby<hint->GetNbinsY(); iby++) {
ff=hff->GetBinContent(ibx%ns+1, iby%ns+1);
// cout << ibx << " " << iby << " " << ibx%ns << " " << iby%ns << " " << ff << endl;
if (ff>0)
hint2->SetBinContent(ibx+1, iby+1,hint->GetBinContent(ibx+1,iby+1)/ff);
}
}
// hff->Scale(hff->GetNbinsX()*hff->GetNbinsY()/hff->Integral());
// TH2F *hint2=(TH2F*)hint->Clone("hint2");
// double ff;
// for (int ibx=0; ibx<hint->GetNbinsX(); ibx++) {
// for (int iby=0; iby<hint->GetNbinsY(); iby++) {
// ff=hff->GetBinContent(ibx%ns+1, iby%ns+1);
// // cout << ibx << " " << iby << " " << ibx%ns << " " << iby%ns << " " << ff << endl;
// if (ff>0)
// hint2->SetBinContent(ibx+1, iby+1,hint->GetBinContent(ibx+1,iby+1)/ff);
// }
// }
@ -96,7 +154,7 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
return h2;
} else
} else
cout << "could not open file " << fname << endl;
return NULL;

View File

@ -447,7 +447,7 @@ int *getClusters(char *data, int *ph=NULL) {
(clusters+nph)->rms=getPedestalRMS(ix,iy);
cluster=clusters+nph;
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {