From f65a6f9ef5a0043939b3a991bddf7510db04818d Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Wed, 14 Aug 2024 13:46:52 -0400 Subject: [PATCH] EventBuilder only output root file, and FSU2CAEN output CoMPASS BIN. the CoMPASS BIN can be converted to root using other repository --- .gitignore | 5 ++ .vscode/settings.json | 3 +- Aux/EventBuilder.cpp | 104 ++++++++++--------------------- Aux/FSU2CAEN.cpp | 137 ++++++++++++++++++++++++++++------------- Aux/SplitPolePlotter.C | 71 +++++++++++++-------- Aux/fsuReader.h | 3 + Aux/script.C | 12 +++- 7 files changed, 193 insertions(+), 142 deletions(-) diff --git a/.gitignore b/.gitignore index bd65ea5..91497de 100644 --- a/.gitignore +++ b/.gitignore @@ -21,14 +21,19 @@ DumpFSU2ROOT SettingsExplorer AggSeparator FSU2CAEN +Bin2Root data Data +raw_binary *.d *.pcm *.txt +*.tar +*.tar.gz +*.BIN *~ *.autosave diff --git a/.vscode/settings.json b/.vscode/settings.json index 2e0fb90..1f9a97d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -83,6 +83,7 @@ ], "files.associations": { "*.C": "cpp", - "*.pro": "makefile" + "*.pro": "makefile", + "regex": "cpp" } } \ No newline at end of file diff --git a/Aux/EventBuilder.cpp b/Aux/EventBuilder.cpp index 012e6ed..8265098 100644 --- a/Aux/EventBuilder.cpp +++ b/Aux/EventBuilder.cpp @@ -20,7 +20,7 @@ struct FileInfo{ }; -#define NMINARG 5 +#define NMINARG 4 #define debug 0 //^############################################################# @@ -32,14 +32,13 @@ int main(int argc, char **argv) { printf("=========================================\n"); if (argc < NMINARG) { 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(" 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("\n"); - printf(" Example: %s -1 0 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(" Example: %s -1 0 '\\ls -1 *001*.fsu' (no event build, 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"); return 1; @@ -51,7 +50,7 @@ int main(int argc, char **argv) { long timeWindow = atoi(argv[1]); bool traceOn = atoi(argv[2]); // unsigned int debug = atoi(argv[3]); - unsigned short format = atoi(argv[3]); + // unsigned short format = atoi(argv[3]); unsigned int batchSize = 2* DEFAULT_HALFBUFFERSIZE; int nFile = argc - NMINARG + 1; TString inFileName[nFile]; @@ -67,13 +66,9 @@ int main(int argc, char **argv) { outFileName += "_" + ( timeWindow >= 0 ? std::to_string(timeWindow) : "single"); TString outFileFullName; - if( format == 0 ){ - outFileFullName = outFileName + ".root"; - }else{ - outFileFullName = outFileName + ".bin"; - } + outFileFullName = outFileName + ".root"; - uint16_t header = 0; // for caen bin + // uint16_t header = 0; // for caen bin printf("-------> Out file name : %s \n", outFileFullName.Data()); printf("========================================= Number of Files : %d \n", nFile); @@ -148,37 +143,26 @@ int main(int argc, char **argv) { unsigned short traceLength[MAX_MULTI]; 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 ){ - // //*====================================== create tree - outRootFile = new TFile(outFileFullName, "recreate"); - tree = new TTree("tree", outFileFullName); - - tree->Branch("evID", &evID, "event_ID/l"); - tree->Branch("multi", &multi, "multi/i"); - tree->Branch("sn", sn, "sn[multi]/s"); - tree->Branch("ch", ch, "ch[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; - } + tree->Branch("evID", &evID, "event_ID/l"); + tree->Branch("multi", &multi, "multi/i"); + tree->Branch("sn", sn, "sn[multi]/s"); + tree->Branch("ch", ch, "ch[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); } + //*======================================= Open files printf("========================================= Open files & Build Events.\n"); @@ -322,27 +306,10 @@ int main(int argc, char **argv) { } } - if( format == 0 ){ - outRootFile->cd(); - tree->Fill(); - // 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); - } - } - } - + outRootFile->cd(); + tree->Fill(); + // tree->Write(); + multi = 0; evID ++; @@ -377,7 +344,7 @@ int main(int argc, char **argv) { }while( nFileFinished < nGroup); - if( format == 0 ) tree->Write(); + tree->Write(); uInt runEndTime = getTime_us(); 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("========================================> saved to %s \n", outFileFullName.Data()); - if( format == 0 ){ - TMacro info; - info.AddLine(Form("tStart= %20llu ns",tStart)); - info.AddLine(Form(" tEnd= %20llu ns",tEnd)); - info.Write("info"); - outRootFile->Close(); - }else{ - fclose(caen); - } + TMacro info; + info.AddLine(Form("tStart= %20llu ns",tStart)); + info.AddLine(Form(" tEnd= %20llu ns",tEnd)); + info.Write("info"); + outRootFile->Close(); + for( int i = 0; i < nGroup; i++) delete reader[i]; delete [] reader; diff --git a/Aux/FSU2CAEN.cpp b/Aux/FSU2CAEN.cpp index f4a9fba..672e1a1 100644 --- a/Aux/FSU2CAEN.cpp +++ b/Aux/FSU2CAEN.cpp @@ -4,6 +4,9 @@ struct FileInfo{ std::string fileName; int fileevID; unsigned long hitCount; + int sn; + int numCh; + int runNum; }; #define minNARG 3 @@ -14,14 +17,13 @@ int main(int argc, char **argv) { printf("=========================================\n"); printf("=== *.fsu to CoMPASS bin ===\n"); - printf("=== no trace, no flags ===\n"); printf("=========================================\n"); if (argc < minNARG) { printf("Incorrect number of arguments:\n"); printf("%s [tar] [inFile1] [inFile2] .... \n", argv[0]); printf(" tar : output tar, 0 = no, 1 = yes \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"); return 1; @@ -29,8 +31,6 @@ int main(int argc, char **argv) { unsigned int debug = false; uInt runStartTime = getTime_us(); - unsigned short header = 0xCAE1; - unsigned int flags = 0; ///============= read input // long timeWindow = atoi(argv[1]); @@ -41,19 +41,11 @@ int main(int argc, char **argv) { std::string inFileName[nFile]; 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); for( int i = 0; i < nFile; i++) printf("%2d | %s \n", i, inFileName[i].c_str()); printf("=========================================\n"); 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("========================================= Grouping files\n"); @@ -65,7 +57,7 @@ int main(int argc, char **argv) { FSUReader * readerA = new FSUReader(inFileName[0], 1, 1); readerA->ScanNumBlock(0,0); 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); totalHitCount += readerA->GetTotalHitCount(); @@ -75,7 +67,7 @@ int main(int argc, char **argv) { if( readerB->GetOptimumBatchSize() > batchSize ) batchSize = readerB->GetOptimumBatchSize(); 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() ){ 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 outFileName[numFileGroup]; + std::vector header[numFileGroup]; + std::vector 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 printf("========================================= Open files & Build Events.\n"); @@ -142,8 +162,6 @@ int main(int argc, char **argv) { int nFileFinished = 0; unsigned long long hitProcessed = 0; - FILE * outFile = fopen(outFileName.c_str(), "wb"); - do{ // find the earlist time @@ -167,29 +185,38 @@ int main(int argc, char **argv) { } - if( hitList[g0][evID[g0]].energy2 > 0 ) header += 4; - if( hitList[g0][evID[g0]].traceLength > 0 ) header += 8; - if( hitList[g0][evID[g0]].pileUp ) flags += 0x8000; - if( hitList[g0][evID[g0]].fineTime > 0 ) flags += 0x4000; + // Set file header + int p_ch = hitList[g0][evID[g0]].ch; // present ch - fwrite(&(header), 2, 1, outFile); - 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); + if( header[g0][p_ch] == 0 ) { + header[g0][p_ch] = 0xCAE1; + if( hitList[g0][evID[g0]].energy2 > 0 ) header[g0][p_ch] += 4; + if( hitList[g0][evID[g0]].traceLength > 0 ) header[g0][p_ch] += 8; + if( hitList[g0][evID[g0]].pileUp ) flags[g0][p_ch] += 0x8000; + if( hitList[g0][evID[g0]].fineTime > 0 ) flags[g0][p_ch] += 0x4000; - for( int i = 0; i < hitList[g0][evID[g0]].traceLength; i++ ){ - fwrite(&(hitList[g0][evID[g0]].trace[i]), 2, 1, outFile); - } + fwrite(&(header[g0][p_ch]), 2, 1, outFile[g0][p_ch]); } + 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]++; if( hitProcessed == 0) tStart = hitList[g0][evID[g0]].timestamp; hitProcessed ++; @@ -224,21 +251,47 @@ int main(int argc, char **argv) { printf(" first timestamp = %20llu ns\n", tStart); printf(" last timestamp = %20llu ns\n", tEnd); 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]; delete [] reader; - if( tarFlag ){ - std::string tarFileName = outFile_prefix + ".tar"; + //============================== delete empty files and close FILE + std::vector 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()); if (result == 0) { printf("Archive created successfully: %s\n", tarFileName.c_str()); - std::system(("rm -f " + outFileName).c_str()); - printf("Remove %s.\n", outFileName.c_str()); + for( size_t i = 0; i < nonEmptyFileList.size(); i++ ){ + int dummy = std::system(("rm -f " + nonEmptyFileList[i]).c_str()); + // printf("Remove %s.\n", nonEmptyFileList[i].c_str()); + } } else { printf("Error creating archive\n"); } diff --git a/Aux/SplitPolePlotter.C b/Aux/SplitPolePlotter.C index 92f0aed..f538d1d 100644 --- a/Aux/SplitPolePlotter.C +++ b/Aux/SplitPolePlotter.C @@ -6,6 +6,7 @@ #include "TTreeReaderArray.h" #include "TClonesArray.h" #include "TGraph.h" +#include "TCutG.h" #include "TH2.h" #include "TCanvas.h" #include "TStyle.h" @@ -50,10 +51,11 @@ TH2F * hFocal; TH2F * hXavg_Q; TH2F * hXavg_Theta; -TH2F * haha; - +TH2F * hRay; TH1F * hEx; +TH2F * hEx_Multi; + ULong64_t t1, t2; #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("################# SplitPolePlotter.C ####################\n"); @@ -83,26 +85,34 @@ void SplitPolePlotter(TChain *tree){ //*====================================================== 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); - 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); hB = new TH1F("hB", "Back delay line position", 600, XMIN, XMAX); hXavg = new TH1F("hAvg", "Xavg", 600, 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, 2); + hXavg_Theta = new TH2F("hXavg_Theta", "Xavg vs Theta ", 200, XMIN, XMAX, 200, 0.5, 1.4); - 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.CalConstants("12C", "d", "p", 16, 20); // 80MeV, 5 deg - hit.CalZoffset(0.751); // 1.41 T + hit.CalConstants("12C", "d", "p", 16, 18); // 80MeV, 5 deg + hit.CalZoffset(0.750); // 1.41 T t1 = 0; t2 = 0; @@ -142,11 +152,11 @@ void SplitPolePlotter(TChain *tree){ // } 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]; 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); } - // if( hit.eAF < 50000 ) return kTRUE; - // if( hit.eCath == 0 ) return kTRUE; - // if( hit.eCath > 13000 ) return kTRUE; + //=============== PID gate cut + if( pidCut ){ + if( !pidCut->IsInside(Qt, dQ) ) continue; + } 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); hF->Fill(hit.x1); 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; - 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); hEx->Fill(ex); + + hEx_Multi->Fill(ex, *multi); } //*============================================ Progress Bar @@ -222,15 +237,18 @@ void SplitPolePlotter(TChain *tree){ //^########################################################### //^ * Plot //^########################################################### - TCanvas * canvas = new TCanvas("cc", "Split-Pole", 1600, 1200); + TCanvas * canvas = new TCanvas("cc", "Split-Pole", 2500, 1000); gStyle->SetOptStat("neiou"); - canvas->Divide(4, 3); + canvas->Divide(5, 2); - canvas->cd(1); PID->Draw("colz"); - //canvas->cd(2); coin->Draw("colz"); - canvas->cd(2); haha->Draw("colz"); + canvas->cd(1); { + PID->Draw("colz"); + if( pidCut ) pidCut->Draw("same"); + } + + canvas->cd(2); hRay->Draw("colz"); canvas->cd(3); hF->Draw(); canvas->cd(4); hB->Draw(); @@ -241,7 +259,8 @@ void SplitPolePlotter(TChain *tree){ 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(); diff --git a/Aux/fsuReader.h b/Aux/fsuReader.h index a264290..e3b802b 100644 --- a/Aux/fsuReader.h +++ b/Aux/fsuReader.h @@ -49,6 +49,7 @@ class FSUReader{ int GetNumCh() const{return numCh;} int GetFileOrder() const{return order;} int GetChMask() const{return chMask;} + int GetRunNum() const{return runNum;} unsigned long GetFileByteSize() const {return inFileSize;} void ClearHitList() { hit.clear();} @@ -116,6 +117,7 @@ class FSUReader{ uShort order; uShort chMask; uShort numCh; + uShort runNum; std::vector blockPos; std::vector 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); } short token_size = tokens.size(); // 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()); tick2ns = atoi(tokens[token_size-2].c_str()); order = atoi(tokens[token_size-1].c_str()); diff --git a/Aux/script.C b/Aux/script.C index 6a0c556..af1259d 100644 --- a/Aux/script.C +++ b/Aux/script.C @@ -7,12 +7,18 @@ void script(){ TChain * chain = new TChain("tree"); - chain->Add("data/12C_dp_009_3000.root"); -// chain->Add("run13._3000.root"); + chain->Add("raw_binary/run_13/run013_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); + //^===================================================== // FSUReader * reader = new FSUReader("data/12C_dp_002_19555_PSD_4_000.fsu", 10000, 2);