evtReader: in the scanning evt file, store 10, 20, ...90 precent file position for jumping

This commit is contained in:
nrb@Debain10 2022-03-17 22:19:27 -04:00
parent dba4364144
commit 3066de5c09
4 changed files with 55 additions and 28 deletions

View File

@ -451,6 +451,7 @@ void Analyzer::Terminate(){
hPID[9]->Draw("colz"); hPID[9]->Draw("colz");
if( cut1 != NULL ) cut1->Draw("same"); if( cut1 != NULL ) cut1->Draw("same");
if( cut2 != NULL ) cut2->Draw("same"); if( cut2 != NULL ) cut2->Draw("same");
if( cut3 != NULL ) cut2->Draw("same");
//========================= canvas 6 //========================= canvas 6

View File

@ -34,6 +34,12 @@
// 4) eventBuilding // 4) eventBuilding
// 3) last 10% data // 3) last 10% data
//################################## user setting
int eRange[2] = {50, 1000}; ///min, max
bool PIDFlag = false;
int GAGGID = 209;
//############################################# //#############################################
// main // main
//############################################### //###############################################
@ -97,14 +103,16 @@ int main(int argn, char **argv) {
if( evt->IsOpen() == false ) return -404; if( evt->IsOpen() == false ) return -404;
DataBlock * data = evt->data; DataBlock * data = evt->data;
printf(" in file: \033[1;31m%s\033[m\n", inFileName.Data()); printf(" in file: \033[1;31m%s\033[m\n", inFileName.Data());
printf(" Gamma energy correction file : %s\n", corrFile == "" ? "Not provided." : corrFile.Data()); printf(" Gamma energy correction file : %s\n", corrFile == "" ? "Not provided." : corrFile.Data());
printf(" raw E threshold : %d ch\n", rawEnergyThreshold); printf(" raw E threshold : %d ch\n", rawEnergyThreshold);
if( histFileName != "" ) printf(" Save histograms to %s\n", histFileName.Data()); if( histFileName != "" ) printf(" Save histograms to %s\n", histFileName.Data());
if( rootFileName != "" ) printf(" Save root to %s\n", rootFileName.Data()); if( rootFileName != "" ) printf(" Save root to %s\n", rootFileName.Data());
printf("--------------------------------\n"); printf("--------------------------------\n");
printf("Scanning the evt file... \n");
evt->ScanNumberOfBlock();
printf("go to 90%% of data \n");
evt->JumptoPrecent(9);
//================ ROOT tree //================ ROOT tree
TFile * fFile = NULL; TFile * fFile = NULL;
@ -129,7 +137,7 @@ int main(int argn, char **argv) {
//================ Historgrams //================ Historgrams
TH1F * he[NCRYSTAL]; TH1F * he[NCRYSTAL];
for( int i = 0 ; i < NCRYSTAL; i++){ for( int i = 0 ; i < NCRYSTAL; i++){
he[i] = new TH1F(Form("he%02d", i), Form("e-%2d", i), 2000, 0, 2000); he[i] = new TH1F(Form("he%02d", i), Form("e-%2d", i), eRange[1]-eRange[0], eRange[0], eRange[1]);
switch (i % 4){ switch (i % 4){
case 0 : he[i]->SetLineColor(2); break; case 0 : he[i]->SetLineColor(2); break;
case 1 : he[i]->SetLineColor(4); break; case 1 : he[i]->SetLineColor(4); break;
@ -138,8 +146,9 @@ int main(int argn, char **argv) {
} }
} }
int GAGGID = 209;
TH2F * hPID = new TH2F(Form("hPID%d", GAGGID), Form("GAGG - %d; tail; peak", GAGGID), 400, -10, 600, 400, -50, 1000); TH2F * hPID ;
if( PIDFlag ) hPID = new TH2F(Form("hPID%d", GAGGID), Form("GAGG - %d; tail; peak", GAGGID), 400, -10, 600, 400, -50, 1000);
TGraph * gTrace = new TGraph(); TGraph * gTrace = new TGraph();
TLatex text; TLatex text;
@ -153,7 +162,7 @@ int main(int argn, char **argv) {
TCanvas * canvas = new TCanvas("fCanvas", "Online Spectrum", 1800, 2000); TCanvas * canvas = new TCanvas("fCanvas", "Online Spectrum", 1800, 2000);
canvas->Divide(1, 9, 0); canvas->Divide(3, TMath::Ceil(NCLOVER/3.), 0);
canvas->SetCrosshair(1); canvas->SetCrosshair(1);
for( int i = 0; i < 9 ; i++){ for( int i = 0; i < 9 ; i++){
canvas->cd(i+1)->SetBottomMargin(0.1); canvas->cd(i+1)->SetBottomMargin(0.1);
@ -161,17 +170,15 @@ int main(int argn, char **argv) {
} }
///TCanvas * cTrace = new TCanvas("cTrace", "Trace", 100, 100, 1000, 500); ///TCanvas * cTrace = new TCanvas("cTrace", "Trace", 100, 100, 1000, 500);
TCanvas * cPID;
TCanvas * cPID = new TCanvas("cPID", "PID", 100, 100, 500, 500); if( PIDFlag ) cPID = new TCanvas("cPID", "PID", 100, 100, 500, 500);
//=============== Read File //=============== Read File
int sleepCount = 0; int sleepCount = 0;
while ( true ){ while ( true ){
int status = evt->ReadBlock(); if( evt->ReadBlock()== -1 ) {
if( status == -1 ) {
break; break;
//printf("\n\n\nReached the end of file, wait %d sec to see any update.\n", sleepTime); //printf("\n\n\nReached the end of file, wait %d sec to see any update.\n", sleepTime);
//sleep( sleepTime ); //sleep( sleepTime );
@ -211,13 +218,10 @@ int main(int argn, char **argv) {
} }
///============ QDC ///============ QDC
if( detID == GAGGID && (data->headerLength < data->eventLength) ){ if( PIDFlag && detID == GAGGID && (data->headerLength < data->eventLength) ){
double bg = (data->QDCsum[0] + data->QDCsum[1])/60.; double bg = (data->QDCsum[0] + data->QDCsum[1])/60.;
double peak = data->QDCsum[3]/20. - bg; double peak = data->QDCsum[3]/20. - bg;
double tail = data->QDCsum[5]/55. - bg; double tail = data->QDCsum[5]/55. - bg;
hPID->Fill( tail , peak); hPID->Fill( tail , peak);
} }
@ -279,11 +283,13 @@ int main(int argn, char **argv) {
///} ///}
///=== for GAGG PID ///=== for GAGG PID
if( PIDFlag ) {
cPID->cd(); cPID->cd();
cPID->SetLogz(); cPID->SetLogz();
hPID->Draw("colz"); hPID->Draw("colz");
cPID->Modified(); cPID->Modified();
cPID->Update(); cPID->Update();
}
gSystem->ProcessEvents(); gSystem->ProcessEvents();
} }
@ -335,5 +341,4 @@ int main(int argn, char **argv) {
app->Run(); app->Run();
} }

View File

@ -1,16 +1,12 @@
#ifndef EVTREADER_H #ifndef EVTREADER_H
#define EVTREADER_H #define EVTREADER_H
#include <stdio.h> #include <stdio.h> /// for FILE
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "TSystem.h"
#include "TObject.h"
#include "TFile.h"
#include "TTree.h"
#include "TString.h" #include "TString.h"
#include "TBenchmark.h" #include "TBenchmark.h"
@ -41,6 +37,9 @@ class evtReader{
TBenchmark gClock; TBenchmark gClock;
long int inFilePosPrecent[10];
Long64_t blockIDPrecent[10];
///============================================ Methods ///============================================ Methods
public: public:
@ -60,10 +59,12 @@ class evtReader{
Long64_t GetBlockID() {return blockID;} Long64_t GetBlockID() {return blockID;}
Long64_t GetNumberOfBlock() {return nBlock;} Long64_t GetNumberOfBlock() {return nBlock;}
int ReadBlock(int opt = 0); /// 0 = default, fill data int ReadBlock(int opt = 0); /// 0 = default, fill data
/// 1 = no fill data /// 1 = no fill data
void ScanNumberOfBlock(); void ScanNumberOfBlock();
void JumptoPrecent(int precent); ///this is offset by 1 block
void PrintStatus(int mod); void PrintStatus(int mod);
}; };
@ -82,6 +83,7 @@ evtReader::evtReader(){
blockID = -1; blockID = -1;
endOfFile = false; endOfFile = false;
isOpened = false; isOpened = false;
} }
@ -254,8 +256,16 @@ int evtReader::ReadBlock(int opt){
void evtReader::ScanNumberOfBlock(){ void evtReader::ScanNumberOfBlock(){
nBlock = 0; nBlock = 0;
int count = 0;
while( ReadBlock(1) != -1 ){ while( ReadBlock(1) != -1 ){
nBlock ++; nBlock ++;
int haha = (inFilePos*10/inFileSize)%10;
if( haha == count ) {
inFilePosPrecent[count] = inFilePos;
blockIDPrecent[count] = blockID;
count++;
}
PrintStatus(10000); PrintStatus(10000);
} }
@ -270,6 +280,17 @@ void evtReader::ScanNumberOfBlock(){
} }
void evtReader::JumptoPrecent(int precent){
if( precent < 0 || precent > 10 ) {
printf("input precent should be 0 to 10\n");
return;
}
fseek(inFile, inFilePosPrecent[precent], SEEK_SET);
blockID = blockIDPrecent[precent];
}
void evtReader::PrintStatus(int mod){ void evtReader::PrintStatus(int mod){

View File

@ -10,11 +10,11 @@ ZERO DEGREE : 300 - 399
//==================== mapping //==================== mapping
#define NCLOVER 10 #define NCLOVER 11
#define NCRYSTAL NCLOVER*4 #define NCRYSTAL NCLOVER*4
#define NBGO NCLOVER #define NBGO NCLOVER
#define NGAGG 26 #define NGAGG 26
#define NZERO 2 #define NZEROGAGG 2 ///NZERO is used
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int mapping[128] ={ 0, 1, 2, 3, 100, 4, 5, 6, 7, 101, 8, 9, 10, 11, 102, -1, //mod-0 int mapping[128] ={ 0, 1, 2, 3, 100, 4, 5, 6, 7, 101, 8, 9, 10, 11, 102, -1, //mod-0