Commit 2f941b1a authored by Stephan Wiederkehr's avatar Stephan Wiederkehr
Browse files

included ana (analysis) category

parent c5810316
......@@ -11,7 +11,12 @@ Currently, the r4s project is being set up. Please, be patient and check in anot
## Linux:
***
### Prerequisites
* not listed yet
* [FTD2XX driver](http://www.ftdichip.com/Drivers/D2XX.htm "FTD2XX driver for windows")
* libusb `sudo apt-get install libusb-1.0-0-dev`
* readline `sudo apt-get install libreadline6 libreadline6-dev`
***
>`cd r4stest/source/r4stest`
......@@ -22,6 +27,7 @@ Currently, the r4s project is being set up. Please, be patient and check in anot
***
### Prerequisites
* [FTD2XX driver](http://www.ftdichip.com/Drivers/D2XX.htm "FTD2XX driver for windows")
***
exists, but must be documented...
......
......@@ -2,7 +2,7 @@
UNAME := $(shell uname)
#cmd_analyzer.o
OBJS = cmd.o command.o cmd_dtb.o error.o file.o pixel_dtb.o profiler.o protocol.o r4stest.o rpc_calls.o rpc.o rpc_error.o rpc_io.o scanner.o settings.o usb.o linux/rs232.o
OBJS = test.o cmd.o command.o cmd_dtb.o cmd_analyzer.o error.o file.o pixel_dtb.o profiler.o protocol.o r4stest.o rpc_calls.o rpc.o rpc_error.o rpc_io.o scanner.o settings.o usb.o linux/rs232.o
ROOTCFLAGS = $(shell $(ROOTSYS)/bin/root-config --cflags)
# root C flags = -pthread -m64 -I/home/pitzl/ROOT/armin/root-cern/include
......@@ -19,7 +19,7 @@ endif
ifeq ($(UNAME), Linux)
#CXXFLAGS = -g -Os -Wall -I/usr/local/include -I/usr/X11/include -pthread
CXXFLAGS = -g -pg -O2 -Wall -Wextra $(ROOTCFLAGS) -I/usr/local/include -I/usr/X11/include -pthread
CXXFLAGS = -g -pg -O2 -Wall -Wextra $(ROOTCFLAGS) -I/usr/local/include -I/usr/X11/include -pthread
#LDFLAGS = -lftd2xx -lreadline -L/usr/local/lib -L/usr/X11/lib -lX11 -pthread -lrt
LDFLAGS = -lftd2xx -lreadline -L/usr/local/lib -pthread -lrt $(ROOTGLIBS) -L/usr/X11/lib -lX11
......
......@@ -16,24 +16,32 @@
#include "cmd.h"
#include "datalink.h"
#define IMG_WIDTH 157
#define IMG_HEIGHT 163
#define R4S_VALUE_OR 4096
class R4sImg
{
int *data;
public:
R4sImg() : data(0) {}
bool CreateRaw(const vector<uint16_t> &rawdata);
void Clear() { if (data) delete[] data; data = 0; }
void Save(const string &filename);
void Print(unsigned int count);
int Get(int x, int y) { return data[y*IMG_WIDTH + x]; }
int *data;
std::vector<int> dataNEW;
public:
R4sImg() : data(0) {}
bool CreateRaw(const vector<uint16_t> &rawdata);
void Clear() { if (data) delete[] data; data = 0; dataNEW.clear();}
void Save(const string &filename);
void Print(unsigned int count);
int Get(int x, int y);
std::vector<int> getData() {return dataNEW;}
};
int R4sImg::Get(int x, int y) {
if ( y>IMG_HEIGHT || x>IMG_WIDTH )
{printf("ERROR: Out of range");return -9999;}
return data[y*IMG_WIDTH + x];
}
bool R4sImg::CreateRaw(const vector<uint16_t> &rawdata)
{
......@@ -51,6 +59,7 @@ bool R4sImg::CreateRaw(const vector<uint16_t> &rawdata)
value -= 0x1000;
data[pos] = value;
dataNEW.push_back(value);
}
return true;
};
......@@ -79,6 +88,13 @@ void R4sImg::Print(unsigned int count)
void R4sImg::Save(const string &filename)
{
if (!data)
{
printf("<<empty>>\n");
return;
}
FILE *f = fopen(filename.c_str(), "wt");
if (!f) return;
......@@ -97,8 +113,7 @@ void R4sImg::Save(const string &filename)
fclose(f);
}
void ReadImage(R4sImg &map)
bool ReadImage(R4sImg &map, bool verbose=true)
{
tb.Daq_Open(50000);
......@@ -122,11 +137,11 @@ void ReadImage(R4sImg &map)
unsigned int ret = tb.Daq_Read(data);
unsigned int n = data.size();
printf("--- status = %u; n = %u\n", ret, (unsigned int)(data.size()));
if (verbose) {printf("--- status = %u; n = %u\n", ret, (unsigned int)(data.size()));}
tb.Daq_Close();
map.CreateRaw(data);
return map.CreateRaw(data);
}
......@@ -153,15 +168,119 @@ CMD_PROC(seqcalscan)
}
CMD_PROC(gui)
// CMD_PROC(gui)
// {
// printf("Connect to GUI ...");
// CDataLink link(1024, 65536);
// // ShellExecute(NULL, "open", "file.exe", NULL, NULL, SW_SHOWDEFAULT);
// system ("start roc4sens_view\\bin\\Release\\roc4sens_view.exe");
// // system ("start roc4sens_view.exe");
// link.Run();
// printf("Connection to GUI closed.\n");
// }
////////// ANALYSIS
#include "test.h"
CMD_PROC(test)
{
printf("Connect to GUI ...");
CDataLink link(1024, 65536);
// ShellExecute(NULL, "open", "file.exe", NULL, NULL, SW_SHOWDEFAULT);
test();
}
//#include "pixelAlive.h"
#include "TROOT.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TString.h"
#include "TTree.h"
#include "TBranch.h"
#include "TLeaf.h"
CMD_PROC(pixelAlive)
{
R4sImg map;
ReadImage(map);
map.Print(200);
TFile *rootFile = new TFile("pixelAlive.root","recreate");
// TH1D *h = new TH1D("h","title",10,0,10);
// h->Fill(1);
TH2D *pixelMap = new TH2D("pixelMap","pixel map",IMG_WIDTH,0,IMG_WIDTH,IMG_HEIGHT,0,IMG_HEIGHT);
//debugging
FILE *f = fopen("debug.txt", "wt");
std::vector<int> data = map.getData();
printf("data size: %d // should be %d \n",data.size(),IMG_HEIGHT*IMG_WIDTH);
for (unsigned int i=0;i<data.size();i++)
{
fprintf(f,"DEBUG: Filling %d : %d/%d \n",i,i%IMG_WIDTH,i/IMG_WIDTH);
pixelMap->Fill(i%IMG_WIDTH,i/IMG_WIDTH,data[i]);
}
fclose(f);
// int *i;
// char **ch;
// TApplication app("app",i,ch);
// TCanvas *c = new TCanvas("c","canvas",200,100);
// h->Draw();
// app.Run();
pixelMap->Write();
rootFile->Close();
}
system ("start roc4sens_view\\bin\\Release\\roc4sens_view.exe");
// system ("start roc4sens_view.exe");
//pixel Distribution
//Distribution of adc values for a given Vcal per pixel
CMD_PROC(pixelDist) {
int iterations;
PAR_INT(iterations, 0, 2147483647) //INT_MAX
TFile *rootFile = new TFile("pixelDist.root","recreate");
TTree *tPixDist = new TTree("pixelDist","pixelDist");
int col(0),row(0),iteration(0),value(0);
tPixDist->Branch("col",&col,"col/I");
tPixDist->Branch("row",&row,"row/I");
tPixDist->Branch("it",&iteration,"it/I");
tPixDist->Branch("value",&value,"value/I");
std::vector< std::vector<int> > data;
R4sImg map;
//get the data
printf("Taking data...");fflush(stdout);
for (int i=0;i<iterations;i++)
{
ReadImage(map,false);
std::vector<int> data_single = map.getData();
printf("Iteration %d: data size: %d // should be %d \n",i+1,data_single.size(),IMG_HEIGHT*IMG_WIDTH);
data.push_back(data_single);
}
printf("Done.\n");
//filling the data
printf("Writing the data into a TTree...");fflush(stdout);
for (int j=0;j<IMG_HEIGHT*IMG_WIDTH;j++)
{
for (unsigned int k=0;k<data.size();k++)
{
col = j%IMG_WIDTH;
row = j/IMG_WIDTH;
iteration = k;
value = data[k][j];
tPixDist->Fill();
}
}
printf("Done.\n");
link.Run();
printf("Connection to GUI closed.\n");
tPixDist->Write();
rootFile->Close();
}
......@@ -13,9 +13,14 @@
* -------------------------------------------------------------
*/
HELP_CAT("ana")
CMD_REG(getimg, "", "Read an image from r4s")
CMD_REG(seqreadout, "", "Load measure -> readout sequence")
CMD_REG(seqcalscan, "", "Load calibrate scan sequence")
/* CMD_REG(getimg, "", "Read an image from r4s") */
/* CMD_REG(seqreadout, "", "Load measure -> readout sequence") */
/* CMD_REG(seqcalscan, "", "Load calibrate scan sequence") */
//analysis
CMD_REG(test, "" , "print 'Hello World!'")
CMD_REG(pixelAlive, "" ,"performs a pixel alive test")
CMD_REG(pixelDist,"<iterations>","distribution of calibration pulses per pixel");
/* CMD_REG(gui, "", "Start graphical user interface"); */
//CMD_REG(gui, "", "Start graphical user interface");
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment