SOLARIS_QT6_DAQ/script.C

85 lines
2.2 KiB
C

#include "SolReader.h"
#include "TH1.h"
#include "TMath.h"
#include "TH2.h"
#include "TStyle.h"
#include "TCanvas.h"
void script(){
SolReader * reader = new SolReader("haha_000.sol");
Event * evt = reader->evt;
printf("----------file size: %u Byte\n", reader->GetFileSize());
reader->ScanNumBlock();
if( reader->GetTotalNumBlock() == 0 ) return;
unsigned long startTime, endTime;
reader->ReadBlock(0);
startTime = evt->timestamp;
reader->ReadBlock(reader->GetTotalNumBlock() - 1);
endTime = evt->timestamp;
double duration = double(endTime - startTime)*8./1e9;
printf("============== %lu ns = %.4f sec.\n", (endTime - startTime)*8, duration);
printf(" avarge rate (16ch): %f Hz\n", reader->GetTotalNumBlock()/duration/16);
reader->RewindFile();
TH1F * hid = new TH1F("hid", "hid", 64, 0, 64);
TH1F * h1 = new TH1F("h1", "h1", duration, startTime, endTime);
TH2F * h2 = new TH2F("h2", "h2", 1000, startTime, endTime, 1000, 0, reader->GetTotalNumBlock());
TH1F * hTdiff = new TH1F("hTdiff", "hTdiff", 400, 0, 200000);
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());
evt->PrintAll();
//evt->PrintAllTrace();
}
hid->Fill(evt->channel);
if( evt->channel == 0 ) h1->Fill(evt->timestamp);
h2->Fill(evt->timestamp, i);
if( i > 0 ){
hTdiff->Fill(evt->timestamp - tOld);
if( evt->timestamp < tOld) printf("-------- time not sorted.");
tOld = evt->timestamp;
}
}
gStyle->SetOptStat("neiou");
TCanvas * canvas = new TCanvas("c1", "c1", 1800, 600);
canvas->Divide(3,1);
canvas->cd(1); hid->Draw();
canvas->cd(2); h1->SetMinimum(0); h1->Draw();
canvas->cd(3); hTdiff->Draw();
//printf("reader traceLength : %lu \n", evt->traceLenght);
/*
for( int i = 0; i < evt->traceLenght; i++){
printf("%4d| %d\n", i, evt->analog_probes[0][i]);
}
*/
evt = NULL;
delete reader;
}