SOLARIS_QT6_DAQ/script.C

103 lines
3.0 KiB
C++
Raw Normal View History

2023-01-31 18:59:12 -05:00
#include "SolReader.h"
#include "TH1.h"
#include "TMath.h"
#include "TH2.h"
#include "TStyle.h"
#include "TCanvas.h"
2023-02-06 19:18:21 -05:00
#include "TGraph.h"
2023-01-31 18:59:12 -05:00
2023-09-22 18:35:14 -04:00
void script(std::string fileName){
2023-01-31 18:59:12 -05:00
2023-09-22 18:35:14 -04:00
SolReader * reader = new SolReader(fileName);
2023-09-26 10:41:24 -04:00
Hit * hit = reader->hit;
2023-01-31 18:59:12 -05:00
printf("----------file size: %u Byte\n", reader->GetFileSize());
reader->ScanNumBlock();
if( reader->GetTotalNumBlock() == 0 ) return;
unsigned long startTime, endTime;
reader->ReadBlock(0);
2023-09-26 10:41:24 -04:00
startTime = hit->timestamp;
2023-01-31 18:59:12 -05:00
reader->ReadBlock(reader->GetTotalNumBlock() - 1);
2023-09-26 10:41:24 -04:00
endTime = hit->timestamp;
2023-01-31 18:59:12 -05:00
double duration = double(endTime - startTime)*8./1e9;
printf("============== %lu ns = %.4f sec.\n", (endTime - startTime)*8, duration);
2023-09-22 18:35:14 -04:00
printf(" avarge rate : %f Hz\n", reader->GetTotalNumBlock()/duration);
2023-01-31 18:59:12 -05:00
reader->RewindFile();
2023-09-22 18:35:14 -04:00
TH1F * hid = new TH1F("hid", "Ch-ID", 64, 0, 64);
TH1F * h1 = new TH1F("h1", "Rate [Hz]; time [s] ; Hz", ceil(duration)+2, startTime*8/1e9 - 1 , ceil(endTime*8/1e9) + 1);
TH2F * h2 = new TH2F("h2", "Time vs Entry ; time [s] ; Entry", 1000, startTime*8/1e9, endTime*8/1e9 + 1, 1000, 0, reader->GetTotalNumBlock());
2023-01-31 18:59:12 -05:00
2023-02-06 19:18:21 -05:00
TGraph * g1 = new TGraph();
2023-09-22 18:35:14 -04:00
TGraph * g2 = new TGraph(); g2->SetLineColor(2);
TGraph * ga = new TGraph(); ga->SetLineColor(4);
TGraph * gb = new TGraph(); gb->SetLineColor(5);
TGraph * gc = new TGraph(); gc->SetLineColor(6);
TGraph * gd = new TGraph(); gd->SetLineColor(7);
2023-02-06 19:18:21 -05:00
2023-01-31 18:59:12 -05:00
uint64_t tOld = startTime;
for( int i = 0; i < reader->GetTotalNumBlock() ; i++){
//for( int i = 0; i < 8 ; i++){
reader->ReadNextBlock();
if( i < 8 ){
printf("########################## nBlock : %u, %u/%u\n", reader->GetNumBlock(),
reader->GetFilePos(),
reader->GetFileSize());
2023-09-26 10:41:24 -04:00
hit->PrintAll();
//hit->PrintAllTrace();
2023-01-31 18:59:12 -05:00
}
2023-09-26 10:41:24 -04:00
hid->Fill(hit->channel);
if( hit->channel == 0 ) h1->Fill(hit->timestamp*8/1e9);
h2->Fill(hit->timestamp*8/1e9, i);
2023-01-31 18:59:12 -05:00
2023-02-06 19:18:21 -05:00
if( i == 0){
2023-09-26 10:41:24 -04:00
for( int i = 0; i < hit->traceLenght; i++){
g1->AddPoint(i*8, hit->analog_probes[0][i]);
g2->AddPoint(i*8, hit->analog_probes[1][i]);
ga->AddPoint(i*8, 10000+5000*hit->digital_probes[0][i]);
gb->AddPoint(i*8, 20000+5000*hit->digital_probes[1][i]);
gc->AddPoint(i*8, 30000+5000*hit->digital_probes[2][i]);
gd->AddPoint(i*8, 40000+5000*hit->digital_probes[3][i]);
2023-02-06 19:18:21 -05:00
}
}
2023-01-31 18:59:12 -05:00
}
gStyle->SetOptStat("neiou");
2023-02-06 19:18:21 -05:00
TCanvas * canvas = new TCanvas("c1", "c1", 1200, 1200);
canvas->Divide(2,2);
2023-01-31 18:59:12 -05:00
canvas->cd(1); hid->Draw();
canvas->cd(2); h1->SetMinimum(0); h1->Draw();
2023-09-22 18:35:14 -04:00
canvas->cd(3); h2->Draw();
canvas->cd(4); g1->Draw("APl");
g1->GetYaxis()->SetRangeUser(0, 80000);
g2->Draw("same");
ga->Draw("same");
gb->Draw("same");
gc->Draw("same");
gd->Draw("same");
2023-09-26 10:41:24 -04:00
//printf("reader traceLength : %lu \n", hit->traceLenght);
2023-01-31 18:59:12 -05:00
/*
2023-09-26 10:41:24 -04:00
for( int i = 0; i < hit->traceLenght; i++){
2023-01-31 18:59:12 -05:00
2023-09-26 10:41:24 -04:00
printf("%4d| %d\n", i, hit->analog_probes[0][i]);
2023-01-31 18:59:12 -05:00
}
*/
2023-09-26 10:41:24 -04:00
hit = NULL;
2023-01-31 18:59:12 -05:00
delete reader;
}