EventBuilder only output root file, and FSU2CAEN output CoMPASS BIN. the CoMPASS BIN can be converted to root using other repository

This commit is contained in:
Ryan Tang 2024-08-14 13:46:52 -04:00
parent 9af7ff721c
commit f65a6f9ef5
7 changed files with 193 additions and 142 deletions

5
.gitignore vendored
View File

@ -21,14 +21,19 @@ DumpFSU2ROOT
SettingsExplorer SettingsExplorer
AggSeparator AggSeparator
FSU2CAEN FSU2CAEN
Bin2Root
data data
Data Data
raw_binary
*.d *.d
*.pcm *.pcm
*.txt *.txt
*.tar
*.tar.gz
*.BIN
*~ *~
*.autosave *.autosave

View File

@ -83,6 +83,7 @@
], ],
"files.associations": { "files.associations": {
"*.C": "cpp", "*.C": "cpp",
"*.pro": "makefile" "*.pro": "makefile",
"regex": "cpp"
} }
} }

View File

@ -20,7 +20,7 @@ struct FileInfo{
}; };
#define NMINARG 5 #define NMINARG 4
#define debug 0 #define debug 0
//^############################################################# //^#############################################################
@ -32,14 +32,13 @@ int main(int argc, char **argv) {
printf("=========================================\n"); printf("=========================================\n");
if (argc < NMINARG) { if (argc < NMINARG) {
printf("Incorrect number of arguments:\n"); printf("Incorrect number of arguments:\n");
printf("%s [timeWindow] [withTrace] [format] [inFile1] [inFile2] .... \n", argv[0]); printf("%s [timeWindow] [withTrace] [inFile1] [inFile2] .... \n", argv[0]);
printf(" timeWindow : in ns, -1 = no event building \n"); printf(" timeWindow : in ns, -1 = no event building \n");
printf(" withTrace : 0 for no trace, 1 for trace \n"); printf(" withTrace : 0 for no trace, 1 for trace \n");
printf(" format : 0 for root, 1 for CoMPASS binary \n");
printf(" Output file name is contructed from inFile1 \n"); printf(" Output file name is contructed from inFile1 \n");
printf("\n"); printf("\n");
printf(" Example: %s -1 0 0 '\\ls -1 *001*.fsu' (no event build, no trace, no verbose)\n", argv[0]); printf(" Example: %s -1 0 '\\ls -1 *001*.fsu' (no event build, no trace, no verbose)\n", argv[0]);
printf(" %s 100 0 0 '\\ls -1 *001*.fsu' (event build with 100 ns, no trace, no verbose)\n", argv[0]); printf(" %s 100 0 '\\ls -1 *001*.fsu' (event build with 100 ns, no trace, no verbose)\n", argv[0]);
printf("\n\n"); printf("\n\n");
return 1; return 1;
@ -51,7 +50,7 @@ int main(int argc, char **argv) {
long timeWindow = atoi(argv[1]); long timeWindow = atoi(argv[1]);
bool traceOn = atoi(argv[2]); bool traceOn = atoi(argv[2]);
// unsigned int debug = atoi(argv[3]); // unsigned int debug = atoi(argv[3]);
unsigned short format = atoi(argv[3]); // unsigned short format = atoi(argv[3]);
unsigned int batchSize = 2* DEFAULT_HALFBUFFERSIZE; unsigned int batchSize = 2* DEFAULT_HALFBUFFERSIZE;
int nFile = argc - NMINARG + 1; int nFile = argc - NMINARG + 1;
TString inFileName[nFile]; TString inFileName[nFile];
@ -67,13 +66,9 @@ int main(int argc, char **argv) {
outFileName += "_" + ( timeWindow >= 0 ? std::to_string(timeWindow) : "single"); outFileName += "_" + ( timeWindow >= 0 ? std::to_string(timeWindow) : "single");
TString outFileFullName; TString outFileFullName;
if( format == 0 ){ outFileFullName = outFileName + ".root";
outFileFullName = outFileName + ".root";
}else{
outFileFullName = outFileName + ".bin";
}
uint16_t header = 0; // for caen bin // uint16_t header = 0; // for caen bin
printf("-------> Out file name : %s \n", outFileFullName.Data()); printf("-------> Out file name : %s \n", outFileFullName.Data());
printf("========================================= Number of Files : %d \n", nFile); printf("========================================= Number of Files : %d \n", nFile);
@ -148,37 +143,26 @@ int main(int argc, char **argv) {
unsigned short traceLength[MAX_MULTI]; unsigned short traceLength[MAX_MULTI];
short trace[MAX_MULTI][MAX_TRACE_LENGTH]; short trace[MAX_MULTI][MAX_TRACE_LENGTH];
FILE * caen = nullptr; // //*====================================== create tree
outRootFile = new TFile(outFileFullName, "recreate");
tree = new TTree("tree", outFileFullName);
if( format == 0 ){ tree->Branch("evID", &evID, "event_ID/l");
// //*====================================== create tree tree->Branch("multi", &multi, "multi/i");
outRootFile = new TFile(outFileFullName, "recreate"); tree->Branch("sn", sn, "sn[multi]/s");
tree = new TTree("tree", outFileFullName); tree->Branch("ch", ch, "ch[multi]/s");
tree->Branch("e", e, "e[multi]/s");
tree->Branch("evID", &evID, "event_ID/l"); tree->Branch("e2", e2, "e2[multi]/s");
tree->Branch("multi", &multi, "multi/i"); tree->Branch("e_t", e_t, "e_t[multi]/l");
tree->Branch("sn", sn, "sn[multi]/s"); tree->Branch("e_f", e_f, "e_f[multi]/s");
tree->Branch("ch", ch, "ch[multi]/s"); tree->Branch("traceLength", traceLength, "traceLength[multi]/s");
tree->Branch("e", e, "e[multi]/s");
tree->Branch("e2", e2, "e2[multi]/s");
tree->Branch("e_t", e_t, "e_t[multi]/l");
tree->Branch("e_f", e_f, "e_f[multi]/s");
tree->Branch("traceLength", traceLength, "traceLength[multi]/s");
if( traceOn ) {
tree->Branch("trace", trace,"trace[multi][MAX_TRACE_LENGTH]/S");
tree->GetBranch("trace")->SetCompressionSettings(205);
}
}else{
caen = fopen(outFileFullName.Data(), "wb");
if( caen == nullptr ){
perror("Failed to open file");
return -1;
}
if( traceOn ) {
tree->Branch("trace", trace,"trace[multi][MAX_TRACE_LENGTH]/S");
tree->GetBranch("trace")->SetCompressionSettings(205);
} }
//*======================================= Open files //*======================================= Open files
printf("========================================= Open files & Build Events.\n"); printf("========================================= Open files & Build Events.\n");
@ -322,26 +306,9 @@ int main(int argc, char **argv) {
} }
} }
if( format == 0 ){ outRootFile->cd();
outRootFile->cd(); tree->Fill();
tree->Fill(); // tree->Write();
// tree->Write();
}else{
if( caen ) {
if( header == 0 ){
header = 0xCAE1; // default to have the energy only
if( events[0].energy2 > 0 ) header += 0x4;
if( events[0].traceLength > 0 && traceOn ) header += 0x8;
size_t dummy = fwrite(&header, 2, 1, caen);
if( dummy != 1 ) printf("file write error.\n");
}
for( size_t gg = 0; gg < events.size(); gg++ ){
events[gg].WriteHitsToCAENBinary(caen, header);
}
}
}
multi = 0; multi = 0;
evID ++; evID ++;
@ -377,7 +344,7 @@ int main(int argc, char **argv) {
}while( nFileFinished < nGroup); }while( nFileFinished < nGroup);
if( format == 0 ) tree->Write(); tree->Write();
uInt runEndTime = getTime_us(); uInt runEndTime = getTime_us();
double runTime = (runEndTime - runStartTime) * 1e-6; double runTime = (runEndTime - runStartTime) * 1e-6;
@ -391,15 +358,12 @@ int main(int argc, char **argv) {
printf(" total data duration = %.2f sec = %.2f min\n", tDuration_sec, tDuration_sec/60.); printf(" total data duration = %.2f sec = %.2f min\n", tDuration_sec, tDuration_sec/60.);
printf("========================================> saved to %s \n", outFileFullName.Data()); printf("========================================> saved to %s \n", outFileFullName.Data());
if( format == 0 ){ TMacro info;
TMacro info; info.AddLine(Form("tStart= %20llu ns",tStart));
info.AddLine(Form("tStart= %20llu ns",tStart)); info.AddLine(Form(" tEnd= %20llu ns",tEnd));
info.AddLine(Form(" tEnd= %20llu ns",tEnd)); info.Write("info");
info.Write("info"); outRootFile->Close();
outRootFile->Close();
}else{
fclose(caen);
}
for( int i = 0; i < nGroup; i++) delete reader[i]; for( int i = 0; i < nGroup; i++) delete reader[i];
delete [] reader; delete [] reader;

View File

@ -4,6 +4,9 @@ struct FileInfo{
std::string fileName; std::string fileName;
int fileevID; int fileevID;
unsigned long hitCount; unsigned long hitCount;
int sn;
int numCh;
int runNum;
}; };
#define minNARG 3 #define minNARG 3
@ -14,14 +17,13 @@ int main(int argc, char **argv) {
printf("=========================================\n"); printf("=========================================\n");
printf("=== *.fsu to CoMPASS bin ===\n"); printf("=== *.fsu to CoMPASS bin ===\n");
printf("=== no trace, no flags ===\n");
printf("=========================================\n"); printf("=========================================\n");
if (argc < minNARG) { if (argc < minNARG) {
printf("Incorrect number of arguments:\n"); printf("Incorrect number of arguments:\n");
printf("%s [tar] [inFile1] [inFile2] .... \n", argv[0]); printf("%s [tar] [inFile1] [inFile2] .... \n", argv[0]);
printf(" tar : output tar, 0 = no, 1 = yes \n"); printf(" tar : output tar, 0 = no, 1 = yes \n");
printf("\n"); printf("\n");
printf(" Example: %s '\\ls 0 *001*.fsu'\n", argv[0]); printf(" Example: %s 0 '\\ls -1 *001*.fsu'\n", argv[0]);
printf("\n\n"); printf("\n\n");
return 1; return 1;
@ -29,8 +31,6 @@ int main(int argc, char **argv) {
unsigned int debug = false; unsigned int debug = false;
uInt runStartTime = getTime_us(); uInt runStartTime = getTime_us();
unsigned short header = 0xCAE1;
unsigned int flags = 0;
///============= read input ///============= read input
// long timeWindow = atoi(argv[1]); // long timeWindow = atoi(argv[1]);
@ -41,19 +41,11 @@ int main(int argc, char **argv) {
std::string inFileName[nFile]; std::string inFileName[nFile];
for( int i = 0 ; i < nFile ; i++){ inFileName[i] = argv[i+ minNARG - 1];} for( int i = 0 ; i < nFile ; i++){ inFileName[i] = argv[i+ minNARG - 1];}
std::string temp = inFileName[0];
size_t pos = temp.find('_');
pos = temp.find('_', pos + 1);
std::string outFile_prefix = temp.substr(0, pos);
std::string outFileName = outFile_prefix + ".BIN";
printf("========================================= Number of Files : %d \n", nFile); printf("========================================= Number of Files : %d \n", nFile);
for( int i = 0; i < nFile; i++) printf("%2d | %s \n", i, inFileName[i].c_str()); for( int i = 0; i < nFile; i++) printf("%2d | %s \n", i, inFileName[i].c_str());
printf("=========================================\n"); printf("=========================================\n");
printf(" Batch size = %d events/file\n", batchSize); printf(" Batch size = %d events/file\n", batchSize);
printf(" Out file name = %s \n", outFileName.c_str()); // printf(" Out file name = %s \n", outFileName.c_str());
printf(" Is tar output = %s \n", tarFlag ? "Yes" : "No"); printf(" Is tar output = %s \n", tarFlag ? "Yes" : "No");
printf("========================================= Grouping files\n"); printf("========================================= Grouping files\n");
@ -65,7 +57,7 @@ int main(int argc, char **argv) {
FSUReader * readerA = new FSUReader(inFileName[0], 1, 1); FSUReader * readerA = new FSUReader(inFileName[0], 1, 1);
readerA->ScanNumBlock(0,0); readerA->ScanNumBlock(0,0);
if( readerA->GetOptimumBatchSize() > batchSize ) batchSize = readerA->GetOptimumBatchSize(); if( readerA->GetOptimumBatchSize() > batchSize ) batchSize = readerA->GetOptimumBatchSize();
FileInfo fileInfo = {inFileName[0], readerA->GetSN() * 1000 + readerA->GetFileOrder(), readerA->GetTotalHitCount()}; FileInfo fileInfo = {inFileName[0], readerA->GetSN() * 1000 + readerA->GetFileOrder(), readerA->GetTotalHitCount(), readerA->GetSN(), readerA->GetNumCh(), readerA->GetRunNum()};
fileList.push_back(fileInfo); fileList.push_back(fileInfo);
totalHitCount += readerA->GetTotalHitCount(); totalHitCount += readerA->GetTotalHitCount();
@ -75,7 +67,7 @@ int main(int argc, char **argv) {
if( readerB->GetOptimumBatchSize() > batchSize ) batchSize = readerB->GetOptimumBatchSize(); if( readerB->GetOptimumBatchSize() > batchSize ) batchSize = readerB->GetOptimumBatchSize();
totalHitCount += readerB->GetTotalHitCount(); totalHitCount += readerB->GetTotalHitCount();
fileInfo = {inFileName[i], readerB->GetSN() * 1000 + readerB->GetFileOrder(), readerB->GetTotalHitCount()}; fileInfo = {inFileName[i], readerB->GetSN() * 1000 + readerB->GetFileOrder(), readerB->GetTotalHitCount(), readerB->GetSN(), readerB->GetNumCh(), readerB->GetRunNum()};
if( readerA->GetSN() == readerB->GetSN() ){ if( readerA->GetSN() == readerB->GetSN() ){
fileList.push_back(fileInfo); fileList.push_back(fileInfo);
@ -107,6 +99,34 @@ int main(int argc, char **argv) {
} }
//*====================================== format output files
const short numFileGroup = fileGroupList.size();
FILE ** outFile[numFileGroup];
std::vector<std::string> outFileName[numFileGroup];
std::vector<uint16_t> header[numFileGroup];
std::vector<unsigned int> flags[numFileGroup];
for( int i = 0; i < numFileGroup; i++ ){
outFile[i] = new FILE * [fileGroupList[i][0].numCh];
for( int ch = 0; ch < fileGroupList[i][0].numCh; ch++ ){
std::string dudu = "Data_CH" + std::to_string(ch) + "@DIGI_" + std::to_string(fileGroupList[i][0].sn) + "_run_" + std::to_string(fileGroupList[i][0].runNum) + ".BIN";
// printf("|%s| \n", dudu.c_str());
outFile[i][ch] = fopen(dudu.c_str(), "wb");
outFileName[i].push_back(dudu);
header[i].push_back(0);
flags[i].push_back(0);
}
}
// std::string temp = inFileName[0];
// size_t pos = temp.find('_');
// pos = temp.find('_', pos + 1);
// std::string outFile_prefix = temp.substr(0, pos);
// std::string outFileName = outFile_prefix + ".BIN";
//*======================================= Open files //*======================================= Open files
printf("========================================= Open files & Build Events.\n"); printf("========================================= Open files & Build Events.\n");
@ -142,8 +162,6 @@ int main(int argc, char **argv) {
int nFileFinished = 0; int nFileFinished = 0;
unsigned long long hitProcessed = 0; unsigned long long hitProcessed = 0;
FILE * outFile = fopen(outFileName.c_str(), "wb");
do{ do{
// find the earlist time // find the earlist time
@ -167,29 +185,38 @@ int main(int argc, char **argv) {
} }
if( hitList[g0][evID[g0]].energy2 > 0 ) header += 4; // Set file header
if( hitList[g0][evID[g0]].traceLength > 0 ) header += 8; int p_ch = hitList[g0][evID[g0]].ch; // present ch
if( hitList[g0][evID[g0]].pileUp ) flags += 0x8000;
if( hitList[g0][evID[g0]].fineTime > 0 ) flags += 0x4000;
fwrite(&(header), 2, 1, outFile); if( header[g0][p_ch] == 0 ) {
fwrite(&(hitList[g0][evID[g0]].sn), 2, 1, outFile); header[g0][p_ch] = 0xCAE1;
fwrite(&(hitList[g0][evID[g0]].ch), 2, 1, outFile); if( hitList[g0][evID[g0]].energy2 > 0 ) header[g0][p_ch] += 4;
unsigned psTimestamp = hitList[g0][evID[g0]].timestamp * 1000 + hitList[g0][evID[g0]].fineTime; if( hitList[g0][evID[g0]].traceLength > 0 ) header[g0][p_ch] += 8;
fwrite(&(psTimestamp), 8, 1, outFile); if( hitList[g0][evID[g0]].pileUp ) flags[g0][p_ch] += 0x8000;
fwrite(&(hitList[g0][evID[g0]].energy), 2, 1, outFile); if( hitList[g0][evID[g0]].fineTime > 0 ) flags[g0][p_ch] += 0x4000;
if( hitList[g0][evID[g0]].energy2 > 0 ) fwrite(&(hitList[g0][evID[g0]].energy2), 2, 1, outFile);
fwrite(&(flags), 4, 1, outFile);
if( hitList[g0][evID[g0]].traceLength > 0 ){
char waveCode = 1;
fwrite(&(waveCode), 1, 1, outFile);
fwrite(&(hitList[g0][evID[g0]].traceLength), 4, 1, outFile);
for( int i = 0; i < hitList[g0][evID[g0]].traceLength; i++ ){ fwrite(&(header[g0][p_ch]), 2, 1, outFile[g0][p_ch]);
fwrite(&(hitList[g0][evID[g0]].trace[i]), 2, 1, outFile);
}
} }
hitList[g0][evID[g0]].WriteHitsToCAENBinary(outFile[g0][p_ch], header[g0][p_ch]);
// fwrite(&(hitList[g0][evID[g0]].sn), 2, 1, outFile);
// fwrite(&(hitList[g0][evID[g0]].ch), 2, 1, outFile);
// unsigned psTimestamp = hitList[g0][evID[g0]].timestamp * 1000 + hitList[g0][evID[g0]].fineTime;
// fwrite(&(psTimestamp), 8, 1, outFile);
// fwrite(&(hitList[g0][evID[g0]].energy), 2, 1, outFile);
// if( hitList[g0][evID[g0]].energy2 > 0 ) fwrite(&(hitList[g0][evID[g0]].energy2), 2, 1, outFile);
// fwrite(&(flags), 4, 1, outFile);
// if( hitList[g0][evID[g0]].traceLength > 0 ){
// char waveCode = 1;
// fwrite(&(waveCode), 1, 1, outFile);
// fwrite(&(hitList[g0][evID[g0]].traceLength), 4, 1, outFile);
// for( int i = 0; i < hitList[g0][evID[g0]].traceLength; i++ ){
// fwrite(&(hitList[g0][evID[g0]].trace[i]), 2, 1, outFile);
// }
// }
evID[g0]++; evID[g0]++;
if( hitProcessed == 0) tStart = hitList[g0][evID[g0]].timestamp; if( hitProcessed == 0) tStart = hitList[g0][evID[g0]].timestamp;
hitProcessed ++; hitProcessed ++;
@ -224,21 +251,47 @@ int main(int argc, char **argv) {
printf(" first timestamp = %20llu ns\n", tStart); printf(" first timestamp = %20llu ns\n", tStart);
printf(" last timestamp = %20llu ns\n", tEnd); printf(" last timestamp = %20llu ns\n", tEnd);
printf(" total data duration = %.2f sec = %.2f min\n", tDuration_sec, tDuration_sec/60.); printf(" total data duration = %.2f sec = %.2f min\n", tDuration_sec, tDuration_sec/60.);
printf("==============> saved to %s \n", outFileName.c_str());
for( int i = 0; i < nGroup; i++) delete reader[i]; for( int i = 0; i < nGroup; i++) delete reader[i];
delete [] reader; delete [] reader;
if( tarFlag ){ //============================== delete empty files and close FILE
std::string tarFileName = outFile_prefix + ".tar"; std::vector<std::string> nonEmptyFileList;
std::string command = "tar -cvf " + tarFileName + " " + outFileName; printf("================= Removing Empty Files ....\n");
printf("============================> saved to ....");
if( tarFlag == false ) printf("\n");
for( int i = 0; i < numFileGroup; i++ ){
for( int ch = 0; ch < fileGroupList[i][0].numCh; ch++){
if( ftell(outFile[i][ch]) == 0 ){
int dummy = std::system(("rm -f " + outFileName[i][ch]).c_str());
// printf("Remove %s.\n", outFileName[i][ch].c_str());
}else{
nonEmptyFileList.push_back(outFileName[i][ch]);
if( tarFlag == false ) printf("%s\n", outFileName[i][ch].c_str());
}
}
}
if( tarFlag ){
std::string tarFileName = "run_" + std::to_string(fileGroupList[0][0].runNum) + ".tar.gz";
printf("%s\n", tarFileName.c_str());
printf("============================> tar.gz the BIN\n");
std::string command = "tar -czf " + tarFileName + " ";
for( size_t i = 0; i < nonEmptyFileList.size(); i++ ){
command += nonEmptyFileList[i] + " ";
}
int result = std::system(command.c_str()); int result = std::system(command.c_str());
if (result == 0) { if (result == 0) {
printf("Archive created successfully: %s\n", tarFileName.c_str()); printf("Archive created successfully: %s\n", tarFileName.c_str());
std::system(("rm -f " + outFileName).c_str()); for( size_t i = 0; i < nonEmptyFileList.size(); i++ ){
printf("Remove %s.\n", outFileName.c_str()); int dummy = std::system(("rm -f " + nonEmptyFileList[i]).c_str());
// printf("Remove %s.\n", nonEmptyFileList[i].c_str());
}
} else { } else {
printf("Error creating archive\n"); printf("Error creating archive\n");
} }

View File

@ -6,6 +6,7 @@
#include "TTreeReaderArray.h" #include "TTreeReaderArray.h"
#include "TClonesArray.h" #include "TClonesArray.h"
#include "TGraph.h" #include "TGraph.h"
#include "TCutG.h"
#include "TH2.h" #include "TH2.h"
#include "TCanvas.h" #include "TCanvas.h"
#include "TStyle.h" #include "TStyle.h"
@ -50,10 +51,11 @@ TH2F * hFocal;
TH2F * hXavg_Q; TH2F * hXavg_Q;
TH2F * hXavg_Theta; TH2F * hXavg_Theta;
TH2F * haha; TH2F * hRay;
TH1F * hEx; TH1F * hEx;
TH2F * hEx_Multi;
ULong64_t t1, t2; ULong64_t t1, t2;
#define XMIN -200 #define XMIN -200
@ -61,7 +63,7 @@ ULong64_t t1, t2;
//^########################################### //^###########################################
void SplitPolePlotter(TChain *tree){ void SplitPolePlotter(TChain *tree, TCutG * pidCut = nullptr, double rhoOffset = 0, double rhoScaling = 1, bool isFSUDAQ = true){
printf("#####################################################################\n"); printf("#####################################################################\n");
printf("################# SplitPolePlotter.C ####################\n"); printf("################# SplitPolePlotter.C ####################\n");
@ -83,26 +85,34 @@ void SplitPolePlotter(TChain *tree){
//*====================================================== histograms //*====================================================== histograms
PID = new TH2F("hPID", "PID; Scin_X ; AnodeB", 200, 0, 20000, 100, 0, 40000);
coin = new TH2F("hCoin", "Coincident ", 16, 0, 16, 16, 0, 16); coin = new TH2F("hCoin", "Coincident ", 16, 0, 16, 16, 0, 16);
hMulti = new TH1F("hMulti", "Multiplicity", 16, 0, 16); hMulti = new TH1F("hMulti", "Multiplicity", 16, 0, 16);
if( isFSUDAQ ){
PID = new TH2F("hPID", "PID; Scin_X ; AnodeB", 200, 0, 20000, 100, 0, 40000);
hXavg_Q = new TH2F("hXavg_Q", "Xavg vs Q ", 200, XMIN, XMAX, 200, 0, 40000);
}else{
PID = new TH2F("hPID", "PID; Scin_X ; AnodeB", 200, 0, 4000, 100, 0, 5000);
hXavg_Q = new TH2F("hXavg_Q", "Xavg vs Q ", 200, XMIN, XMAX, 200, 0, 5000);
}
hF = new TH1F("hF", "Front delay line position", 600, XMIN, XMAX); hF = new TH1F("hF", "Front delay line position", 600, XMIN, XMAX);
hB = new TH1F("hB", "Back delay line position", 600, XMIN, XMAX); hB = new TH1F("hB", "Back delay line position", 600, XMIN, XMAX);
hXavg = new TH1F("hAvg", "Xavg", 600, XMIN, XMAX); hXavg = new TH1F("hAvg", "Xavg", 600, XMIN, XMAX);
hFocal = new TH2F("hFocal", "Front vs Back ", 200, XMIN, XMAX, 200, XMIN, XMAX); hFocal = new TH2F("hFocal", "Front vs Back ", 200, XMIN, XMAX, 200, XMIN, XMAX);
hXavg_Q = new TH2F("hXavg_Q", "Xavg vs Q ", 200, XMIN, XMAX, 200, 0, 40000); hXavg_Theta = new TH2F("hXavg_Theta", "Xavg vs Theta ", 200, XMIN, XMAX, 200, 0.5, 1.4);
hXavg_Theta = new TH2F("hXavg_Theta", "Xavg vs Theta ", 200, XMIN, XMAX, 200, 0.5, 2);
haha = new TH2F("haha", "", 400, XMIN, XMAX, 400, -50, 50); hRay = new TH2F("hRay", "Ray plot", 400, XMIN, XMAX, 400, -50, 50);
hEx = new TH1F("hEx", "Ex; Ex [MeV]; count/100 keV", 250, -5, 5); hEx = new TH1F("hEx", "Ex; Ex [MeV]; count/10 keV", 600, -1, 5);
hEx_Multi = new TH2F("hEx_Multi", "Ex vs Multi; Ex; Multi", 600, -1, 5, 16, 0, 16);
hit.SetMassTablePath("../analyzers/mass20.txt"); hit.SetMassTablePath("../analyzers/mass20.txt");
hit.CalConstants("12C", "d", "p", 16, 20); // 80MeV, 5 deg hit.CalConstants("12C", "d", "p", 16, 18); // 80MeV, 5 deg
hit.CalZoffset(0.751); // 1.41 T hit.CalZoffset(0.750); // 1.41 T
t1 = 0; t1 = 0;
t2 = 0; t2 = 0;
@ -142,11 +152,11 @@ void SplitPolePlotter(TChain *tree){
// } // }
hit.ClearData(); hit.ClearData();
hMulti->Fill(sn.GetSize()); hMulti->Fill(*multi);
// if( multi.Get()[0] != 9 ) continue; // if( *multi != 9 ) continue;
for( int i = 0; i < sn.GetSize(); i++){ for( int i = 0; i < *multi; i++){
t2 = e_t[i]; t2 = e_t[i];
if( t2 < t1 ) printf("entry %lld-%d, timestamp is not in order. %llu, %llu\n", processedEntries, i, t2, t1); if( t2 < t1 ) printf("entry %lld-%d, timestamp is not in order. %llu, %llu\n", processedEntries, i, t2, t1);
@ -176,13 +186,16 @@ void SplitPolePlotter(TChain *tree){
PID->Fill(Qt, dQ); PID->Fill(Qt, dQ);
} }
// if( hit.eAF < 50000 ) return kTRUE; //=============== PID gate cut
// if( hit.eCath == 0 ) return kTRUE; if( pidCut ){
// if( hit.eCath > 13000 ) return kTRUE; if( !pidCut->IsInside(Qt, dQ) ) continue;
}
hit.CalData(2); hit.CalData(2);
if( (!TMath::IsNaN(hit.x1) || !TMath::IsNaN(hit.x2)) && 1000 < dQ && dQ < 9000) { if( hit.theta > 1.2 || 0.5 > hit.theta ) continue;
if( (!TMath::IsNaN(hit.x1) || !TMath::IsNaN(hit.x2)) ) {
hFocal->Fill(hit.x1, hit.x2); hFocal->Fill(hit.x1, hit.x2);
hF->Fill(hit.x1); hF->Fill(hit.x1);
hB->Fill(hit.x2); hB->Fill(hit.x2);
@ -196,12 +209,14 @@ void SplitPolePlotter(TChain *tree){
double x = (z/42.8625 + 0.5)* ( hit.x2-hit.x1) + hit.x1; double x = (z/42.8625 + 0.5)* ( hit.x2-hit.x1) + hit.x1;
haha->Fill(x,z); hRay->Fill(x,z);
} }
double ex = hit.Rho2Ex( (hit.xAvg/100 + 0.363) ); double ex = hit.Rho2Ex( ((hit.xAvg - rhoOffset)/1000/rhoScaling + hit.GetRho0() ) );
//if( XMIN < hit.xAvg && hit.xAvg < XMAX) printf("x1 : %6.2f, x2 : %6.2f, xAvg %6.2f cm , ex : %f \n", hit.x1, hit.x2, hit.xAvg, ex); //if( XMIN < hit.xAvg && hit.xAvg < XMAX) printf("x1 : %6.2f, x2 : %6.2f, xAvg %6.2f cm , ex : %f \n", hit.x1, hit.x2, hit.xAvg, ex);
hEx->Fill(ex); hEx->Fill(ex);
hEx_Multi->Fill(ex, *multi);
} }
//*============================================ Progress Bar //*============================================ Progress Bar
@ -222,15 +237,18 @@ void SplitPolePlotter(TChain *tree){
//^########################################################### //^###########################################################
//^ * Plot //^ * Plot
//^########################################################### //^###########################################################
TCanvas * canvas = new TCanvas("cc", "Split-Pole", 1600, 1200); TCanvas * canvas = new TCanvas("cc", "Split-Pole", 2500, 1000);
gStyle->SetOptStat("neiou"); gStyle->SetOptStat("neiou");
canvas->Divide(4, 3); canvas->Divide(5, 2);
canvas->cd(1); PID->Draw("colz"); canvas->cd(1); {
//canvas->cd(2); coin->Draw("colz"); PID->Draw("colz");
canvas->cd(2); haha->Draw("colz"); if( pidCut ) pidCut->Draw("same");
}
canvas->cd(2); hRay->Draw("colz");
canvas->cd(3); hF->Draw(); canvas->cd(3); hF->Draw();
canvas->cd(4); hB->Draw(); canvas->cd(4); hB->Draw();
@ -241,7 +259,8 @@ void SplitPolePlotter(TChain *tree){
canvas->cd(7); hEx->Draw(); canvas->cd(7); hEx->Draw();
canvas->cd(8); coin->Draw("colz"); //canvas->cd(8); coin->Draw("colz");
canvas->cd(8); hEx_Multi->Draw("colz");
canvas->cd(9); canvas->cd(9)->SetLogy(); hMulti->Draw(); canvas->cd(9); canvas->cd(9)->SetLogy(); hMulti->Draw();

View File

@ -49,6 +49,7 @@ class FSUReader{
int GetNumCh() const{return numCh;} int GetNumCh() const{return numCh;}
int GetFileOrder() const{return order;} int GetFileOrder() const{return order;}
int GetChMask() const{return chMask;} int GetChMask() const{return chMask;}
int GetRunNum() const{return runNum;}
unsigned long GetFileByteSize() const {return inFileSize;} unsigned long GetFileByteSize() const {return inFileSize;}
void ClearHitList() { hit.clear();} void ClearHitList() { hit.clear();}
@ -116,6 +117,7 @@ class FSUReader{
uShort order; uShort order;
uShort chMask; uShort chMask;
uShort numCh; uShort numCh;
uShort runNum;
std::vector<unsigned int> blockPos; std::vector<unsigned int> blockPos;
std::vector<unsigned int > blockTimeStamp; std::vector<unsigned int > blockTimeStamp;
@ -264,6 +266,7 @@ inline void FSUReader::OpenFile(std::string fileName, uInt dataSize, int verbose
while (std::getline(iss, token, '_')) { tokens.push_back(token); } while (std::getline(iss, token, '_')) { tokens.push_back(token); }
short token_size = tokens.size(); short token_size = tokens.size();
// for( short i = 0; i < token_size; i ++ ) printf("%d | %s\n", i, tokens[i].c_str()); // for( short i = 0; i < token_size; i ++ ) printf("%d | %s\n", i, tokens[i].c_str());
runNum = atoi(tokens[token_size-5].c_str());
sn = atoi(tokens[token_size-4].c_str()); sn = atoi(tokens[token_size-4].c_str());
tick2ns = atoi(tokens[token_size-2].c_str()); tick2ns = atoi(tokens[token_size-2].c_str());
order = atoi(tokens[token_size-1].c_str()); order = atoi(tokens[token_size-1].c_str());

View File

@ -7,11 +7,17 @@ void script(){
TChain * chain = new TChain("tree"); TChain * chain = new TChain("tree");
chain->Add("data/12C_dp_009_3000.root"); chain->Add("raw_binary/run_13/run013_3000.root");
// chain->Add("run13._3000.root"); // chain->Add("data/12C_dp_009_3000.root");
SplitPolePlotter(chain); TFile * pidCutFile = new TFile("cut_proton.root");
// TFile * pidCutFile = new TFile("cut_proton_FSU.root");
TCutG * pidCut = (TCutG *) pidCutFile->Get("protons");
SplitPolePlotter(chain, pidCut, 123.307, 2.75, false);
// SplitPolePlotter(chain, pidCut, 123.307, 2.75, true);
//^===================================================== //^=====================================================