added analyzer.cpp
This commit is contained in:
parent
7531c9c4c4
commit
e1244f1026
12
.vscode/c_cpp_properties.json
vendored
12
.vscode/c_cpp_properties.json
vendored
|
@ -11,6 +11,18 @@
|
||||||
"cStandard": "c17",
|
"cStandard": "c17",
|
||||||
"cppStandard": "gnu++17",
|
"cppStandard": "gnu++17",
|
||||||
"intelliSenseMode": "linux-gcc-x64"
|
"intelliSenseMode": "linux-gcc-x64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hades",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**",
|
||||||
|
"/usr/local/cern/root_v6.26.06/**"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "gnu++17",
|
||||||
|
"intelliSenseMode": "linux-gcc-x64"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": 4
|
"version": 4
|
||||||
|
|
25
BinReader.h
25
BinReader.h
|
@ -49,7 +49,7 @@ struct Data{
|
||||||
}else{
|
}else{
|
||||||
printf("Energy : %5u, TimeStamp : %16lu ps\n", Energy, TimeStamp);
|
printf("Energy : %5u, TimeStamp : %16lu ps\n", Energy, TimeStamp);
|
||||||
}
|
}
|
||||||
printf(" Flag : 0x%X\n", Flags);
|
printf(" Flag : 0x%08X\n", Flags);
|
||||||
if( (Header & 0x8 ) >= 1 ){ /// is waevform exist
|
if( (Header & 0x8 ) >= 1 ){ /// is waevform exist
|
||||||
printf(" Wave form code : %d , nSample : %d\n", WaveformCode, NSample);
|
printf(" Wave form code : %d , nSample : %d\n", WaveformCode, NSample);
|
||||||
for( int i = 0 ; i < NSample ; i++){
|
for( int i = 0 ; i < NSample ; i++){
|
||||||
|
@ -81,6 +81,7 @@ class BinReader{
|
||||||
Long64_t blockIDPrecent[10];
|
Long64_t blockIDPrecent[10];
|
||||||
|
|
||||||
bool isHeaderOK;
|
bool isHeaderOK;
|
||||||
|
bool isOldFormat;
|
||||||
|
|
||||||
template <typename T> int FillData(T * dataItem); // if successful, return 1, else 0; cannot fill Trace
|
template <typename T> int FillData(T * dataItem); // if successful, return 1, else 0; cannot fill Trace
|
||||||
|
|
||||||
|
@ -123,6 +124,7 @@ BinReader::BinReader(){
|
||||||
isOpened = false;
|
isOpened = false;
|
||||||
|
|
||||||
isHeaderOK = false;
|
isHeaderOK = false;
|
||||||
|
isOldFormat = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,8 +170,17 @@ void BinReader::OpenFile(TString inFileName){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
///printf("HEADER: 0x%X , 0x%X\n", data.Header, (data.Header >> 4));
|
///printf("HEADER: 0x%X , 0x%X\n", data.Header, (data.Header >> 4));
|
||||||
|
|
||||||
|
if( (data.Header >> 4 ) == 0 ){
|
||||||
|
printf(" Old format of CoMPASS, 0x%04x\n", data.Header);
|
||||||
|
isHeaderOK = true;
|
||||||
|
isOldFormat = true;
|
||||||
|
data.Header = 0xCAE5; // only with energy and energy short
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( (data.Header >> 4 ) != 0xCAE ) {
|
if( (data.Header >> 4 ) != 0xCAE ) {
|
||||||
printf(" Header format not right. \n");
|
printf(" Header format not right. 0x%04x\n", data.Header);
|
||||||
isHeaderOK = false;
|
isHeaderOK = false;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
@ -234,6 +245,11 @@ int BinReader::ReadBlock(int skipTrace){
|
||||||
|
|
||||||
FillData(&data.Flags);
|
FillData(&data.Flags);
|
||||||
|
|
||||||
|
if( isOldFormat ) {
|
||||||
|
uint32_t dummy = 0;
|
||||||
|
FillData(&dummy);
|
||||||
|
}
|
||||||
|
|
||||||
/// check is wave form exist
|
/// check is wave form exist
|
||||||
if( (data.Header & 0x8) == 1){
|
if( (data.Header & 0x8) == 1){
|
||||||
FillData(&data.WaveformCode);
|
FillData(&data.WaveformCode);
|
||||||
|
@ -279,10 +295,11 @@ void BinReader::ScanNumHit(){
|
||||||
printf("scan complete: number of data Block : %ld\n", numHit);
|
printf("scan complete: number of data Block : %ld\n", numHit);
|
||||||
|
|
||||||
rewind(inFile); ///back to the File begining
|
rewind(inFile); ///back to the File begining
|
||||||
FillData(&data.Header);
|
if( !isOldFormat ){
|
||||||
|
FillData(&data.Header);
|
||||||
|
}
|
||||||
inFilePos = 0;
|
inFilePos = 0;
|
||||||
hitID = -1;
|
hitID = -1;
|
||||||
|
|
||||||
endOfFile = false;
|
endOfFile = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
125
analyzer.cpp
Normal file
125
analyzer.cpp
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
#include "TFile.h"
|
||||||
|
#include "TTree.h"
|
||||||
|
#include "TTreeReader.h"
|
||||||
|
#include "TTreeReaderArray.h"
|
||||||
|
#include "TH2F.h"
|
||||||
|
#include "TStyle.h"
|
||||||
|
#include "TCanvas.h"
|
||||||
|
#include "TCutG.h"
|
||||||
|
#include "TChain.h"
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#define NDET 16
|
||||||
|
|
||||||
|
TH1F * tDiff[NDET];
|
||||||
|
TH1F * tDiffg[NDET];
|
||||||
|
TH2F * PSD[NDET];
|
||||||
|
TH2F * PSDg[NDET];
|
||||||
|
|
||||||
|
TH2F * eL_tDiff[NDET];
|
||||||
|
|
||||||
|
ushort eL[NDET];
|
||||||
|
ushort eS[NDET];
|
||||||
|
|
||||||
|
const float timeResol = 2.0; //ns
|
||||||
|
const int timeRange[2] = {200, 800};
|
||||||
|
const int timeBin = (timeRange[1] - timeRange[0])/timeResol;
|
||||||
|
|
||||||
|
void analyzer(){
|
||||||
|
|
||||||
|
for( int i = 0; i < NDET; i++ ){
|
||||||
|
|
||||||
|
tDiff[i] = new TH1F(Form("Tdiff-%d", i), Form(" Detector %d", i), timeBin, timeRange[0], timeRange[1]);
|
||||||
|
|
||||||
|
PSD[i] = new TH2F(Form("PSD-%d", i), Form(" Detector %d", i), 4096, 0, 30000,512,-1,1);
|
||||||
|
|
||||||
|
eL_tDiff[i] = new TH2F(Form("E_tDiff-%d", i), Form(" Detector %d; TOF [ns]; eL", i), timeBin, timeRange[0], timeRange[1] ,1000, 0,15000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TFile * file = new TFile("run268_3000.root");
|
||||||
|
TTree * tree = (TTree *) file->Get("tree");
|
||||||
|
|
||||||
|
TTreeReader reader(tree);
|
||||||
|
|
||||||
|
TTreeReaderValue<ULong64_t> evID = {reader, "evID"};
|
||||||
|
TTreeReaderValue<UInt_t> multi = {reader, "multi"};
|
||||||
|
TTreeReaderArray<UShort_t> sn = {reader, "sn"}; // serial no.
|
||||||
|
TTreeReaderArray<UShort_t> ch = {reader, "ch"}; // channel
|
||||||
|
TTreeReaderArray<UShort_t> e = {reader, "e"}; //long
|
||||||
|
TTreeReaderArray<UShort_t> e2 = {reader, "e2"}; //short
|
||||||
|
TTreeReaderArray<ULong64_t> e_t = {reader, "e_t"}; // in ns
|
||||||
|
TTreeReaderArray<UShort_t> e_f = {reader, "e_f"}; // in ps
|
||||||
|
|
||||||
|
//^###########################################################
|
||||||
|
//^ * Process
|
||||||
|
//^###########################################################
|
||||||
|
|
||||||
|
while(reader.Next()){
|
||||||
|
|
||||||
|
unsigned long long tRF = 0;
|
||||||
|
unsigned long long tN[NDET];
|
||||||
|
for( int i =0; i < NDET; i++){
|
||||||
|
tN[i] = 0;
|
||||||
|
eL[i] = 0;
|
||||||
|
eS[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( *multi > 2) continue;
|
||||||
|
|
||||||
|
for( int i = 0; i < *multi; i++){
|
||||||
|
|
||||||
|
int bd = sn[i] - 6; // 6 = RF, 7 = Neutron detector
|
||||||
|
int ID = ch[i];
|
||||||
|
|
||||||
|
if( sn[i] == 6){
|
||||||
|
tRF = e_t[i] * 1000 + e_f[i]; //in ps
|
||||||
|
}else{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
eL[ID] = e[i];
|
||||||
|
eS[ID] = e2[i];
|
||||||
|
|
||||||
|
tN[ID] = e_t[i] * 1000 + e_f[i]; //in ps
|
||||||
|
|
||||||
|
} // end multiplicity for loop
|
||||||
|
|
||||||
|
for( int i = 0; i < NDET; i++) {
|
||||||
|
if( tRF == 0 || tN[i] == 0 ) continue;
|
||||||
|
|
||||||
|
double tdf;
|
||||||
|
|
||||||
|
if( tRF > tN[i]){
|
||||||
|
tdf = (tRF - tN[i])*1./1000.;
|
||||||
|
}else{
|
||||||
|
tdf = (tN[i] - tRF)*(-1.)/1000.;
|
||||||
|
}
|
||||||
|
|
||||||
|
//std::cout << "Finito" << std::endl;
|
||||||
|
|
||||||
|
PSD[i]->Fill(eL[i],(eL[i]-eS[i])*1.0/eL[i]);
|
||||||
|
tDiff[i]->Fill( tdf );
|
||||||
|
|
||||||
|
} // end for loop over NDET
|
||||||
|
|
||||||
|
} // end while(reader.Next())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
gStyle->SetOptStat(11111111);
|
||||||
|
|
||||||
|
TCanvas *canvas = new TCanvas("canvas", "anlayszer", 1000, 1000);
|
||||||
|
canvas->Divide(4,4);
|
||||||
|
|
||||||
|
for( int i = 0 ; i < NDET; i++ ){
|
||||||
|
|
||||||
|
canvas->cd(i+1);
|
||||||
|
tDiff[i]->Draw();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end script()
|
||||||
|
|
11
script.sh
Executable file
11
script.sh
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
./Bin2Root 3000 0 \
|
||||||
|
run_268/CH0@V1725_324_Data_run_268.bin \
|
||||||
|
run_268/CH1@V1725_324_Data_run_268.bin \
|
||||||
|
run_268/CH2@V1725_324_Data_run_268.bin \
|
||||||
|
run_268/CH3@V1725_324_Data_run_268.bin \
|
||||||
|
run_268/CH4@V1725_324_Data_run_268.bin \
|
||||||
|
run_268/CH5@V1725_324_Data_run_268.bin \
|
||||||
|
run_268/CH0@V1730_89_Data_run_268.bin
|
7
test.C
7
test.C
|
@ -17,7 +17,8 @@ TH1I * hChannel;
|
||||||
TH1I * he[NChannel];
|
TH1I * he[NChannel];
|
||||||
|
|
||||||
// BinReader * reader = new BinReader("/home/ryan/ExpData/fsu_testing/testing_014_single.bin");
|
// BinReader * reader = new BinReader("/home/ryan/ExpData/fsu_testing/testing_014_single.bin");
|
||||||
BinReader * reader = new BinReader("data/run_123/UNFILTERED/Data_CH9@V1725S_19555_run_123.BIN");
|
// BinReader * reader = new BinReader("data/run_123/UNFILTERED/Data_CH9@V1725S_19555_run_123.BIN");
|
||||||
|
BinReader * reader = new BinReader("run_268/CH0@V1725_324_Data_run_268.bin");
|
||||||
|
|
||||||
void test(){
|
void test(){
|
||||||
|
|
||||||
|
@ -34,9 +35,11 @@ void test(){
|
||||||
reader->data.Print();
|
reader->data.Print();
|
||||||
count ++;
|
count ++;
|
||||||
|
|
||||||
|
// if( count > 10 ) break;
|
||||||
|
|
||||||
}while( !reader->IsEndOfFile() );
|
}while( !reader->IsEndOfFile() );
|
||||||
|
|
||||||
printf(">>>>>>>>>>>>>>. count : %ld\n", count);
|
printf(">>>>>>>>>>>>>>. count : %u\n", count);
|
||||||
|
|
||||||
reader->PrintStatus(1);
|
reader->PrintStatus(1);
|
||||||
printf("\n\n\n");
|
printf("\n\n\n");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user