SOLARIS_Analysis/working/script_single.C

89 lines
2.2 KiB
C++
Raw Normal View History

2023-03-28 15:28:36 -04:00
#include "../armory/SolReader.h"
#include "TH1.h"
#include "TH2.h"
#include "TCanvas.h"
2023-09-26 15:45:46 -04:00
void script_single(std::string fileName){
2023-03-28 15:28:36 -04:00
2023-09-26 15:45:46 -04:00
SolReader * reader = new SolReader(fileName);
Hit * hit = reader->hit;
2023-03-28 15:28:36 -04:00
reader->ScanNumBlock();
long numBlock = reader->GetTotalNumBlock();
for( int i = 1; i < 10; i ++ ){
reader->ReadBlock(numBlock-i);
2023-09-26 15:45:46 -04:00
hit->PrintEnergyTimeStamp();
}
/*
SolReader * reader = new SolReader("../data_raw/Master_003_00_21245_000.sol");
2023-09-26 15:45:46 -04:00
Event * hit = reader->hit;
2023-03-28 15:28:36 -04: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 15:45:46 -04:00
startTime = hit->timestamp;
2023-03-28 15:28:36 -04:00
reader->ReadBlock(reader->GetTotalNumBlock() - 1);
2023-09-26 15:45:46 -04:00
endTime = hit->timestamp;
2023-03-28 15:28:36 -04:00
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();
TCanvas * canvas = new TCanvas("c1", "c1", 600, 600);
TH1F * h1 = new TH1F("h1", "h1", 1000, startTime, endTime);
TH2F * h2 = new TH2F("h2", "h2", 1000, startTime, endTime, 1000, 0, reader->GetTotalNumBlock());
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->GetBlockID(),
2023-03-28 15:28:36 -04:00
reader->GetFilePos(),
reader->GetFileSize());
2023-09-26 15:45:46 -04:00
hit->PrintAll();
//hit->PrintAllTrace();
2023-03-28 15:28:36 -04:00
}
2023-09-26 15:45:46 -04:00
h1->Fill(hit->timestamp);
h2->Fill(hit->timestamp, i);
2023-03-28 15:28:36 -04:00
if( i > 0 ){
2023-09-26 15:45:46 -04:00
if( hit->timestamp < tOld) printf("-------- time not sorted.");
tOld = hit->timestamp;
2023-03-28 15:28:36 -04:00
}
}
h2->Draw();
*/
2023-03-28 15:28:36 -04:00
2023-09-26 15:45:46 -04:00
//printf("reader traceLength : %lu \n", hit->traceLenght);
2023-03-28 15:28:36 -04:00
/*
2023-09-26 15:45:46 -04:00
for( int i = 0; i < hit->traceLenght; i++){
2023-03-28 15:28:36 -04:00
2023-09-26 15:45:46 -04:00
printf("%4d| %d\n", i, hit->analog_probes[0][i]);
2023-03-28 15:28:36 -04:00
}
*/
2023-09-26 15:45:46 -04:00
hit = NULL;
2023-03-28 15:28:36 -04:00
delete reader;
}