in progress to bypass the *.to file and directly build event

This commit is contained in:
Ryan@MBA2024 2024-05-24 15:23:36 -04:00
parent df5ad3947a
commit b44e63377a
6 changed files with 255 additions and 0 deletions

2
.gitignore vendored
View File

@ -25,6 +25,8 @@ fsu_run_2021
data data
Data Data
obsolete obsolete
raw_data
root_data
test.cpp test.cpp
test test

20
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/Applications/root_v6.30.06/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64"
}
],
"version": 4
}

69
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,69 @@
{
"files.associations": {
"algorithm": "cpp",
"allocator": "cpp",
"array": "cpp",
"limits": "cpp",
"__bit_reference": "cpp",
"__config": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__verbose_abort": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"execution": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"list": "cpp",
"locale": "cpp",
"map": "cpp",
"mutex": "cpp",
"new": "cpp",
"optional": "cpp",
"ostream": "cpp",
"queue": "cpp",
"ratio": "cpp",
"set": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"sstream": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"string_view": "cpp",
"tuple": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"valarray": "cpp",
"variant": "cpp",
"vector": "cpp"
}
}

68
armory/EventBuilder2.cpp Normal file
View File

@ -0,0 +1,68 @@
/*==================
Thie event builder both sort and build event. skip the *.to file.
===================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <stdbool.h>
#include "TFile.h"
#include "TTree.h"
#include "TMath.h"
#include "TBenchmark.h"
#include "TStopwatch.h"
#include "TTreeIndex.h"
#include "../mapping.h"
#include "evtReader.h"
#define MAXMULTI 100
#define MAXBUFFER 100 // number of hit in memory buffer
int main(int argn, char **argv){
printf("=====================================\n");
printf("=== Event Builder from *.evt ===\n");
printf("=====================================\n");
if (argn < 5 ) {
printf("Usage :\n");
printf("%s [timeWindows] [Reject Flag] [SaveFileName] [*.evt File1 [*.evt File2] ...\n", argv[0]);
printf(" timeWindows [int]: 1 unit = 10 ns \n");
printf(" Reject Flag [int]: 0 = no rejection, 1 = reject no gamma, 2 = reject no GAGG. see mapping.h\n");
printf(" SaveFileName [str]: custom save file name \n");
return 1;
}
unsigned short timeWindow = atoi(argv[1]);
unsigned short rejectFlag = atoi(argv[2]);
TString outFileName = argv[3];
std::vector<std::string> inFileList;
for( int i = 4; i < argn; i++) inFileList.push_back(argv[i]);
//========== put data into RAM buffer.
std::vector<DataBlock> hitListA, hitListB;
evtReader * reader = nullptr;
for( size_t i = 0 ; i < inFileList.size(); i++){
reader = new evtReader(inFileList[i]);
reader->ScanNumberOfBlock();
reader->ReadBatchDataAndSort(MAXBUFFER);
hitListA = reader->GetDataList();
reader->ReadBatchDataAndSort(MAXBUFFER);
hitListB = reader->GetDataList();
delete reader;
}
return 0;
}

View File

@ -40,6 +40,8 @@ class evtReader{
long int inFilePosPrecent[10]; long int inFilePosPrecent[10];
Long64_t blockIDPrecent[10]; Long64_t blockIDPrecent[10];
std::vector<DataBlock> dataList;
///============================================ Methods ///============================================ Methods
public: public:
@ -66,6 +68,8 @@ class evtReader{
void ScanNumberOfBlock(); void ScanNumberOfBlock();
void JumptoPrecent(int precent); ///this is offset by 1 block void JumptoPrecent(int precent); ///this is offset by 1 block
void PrintStatus(int mod); void PrintStatus(int mod);
std::vector<DataBlock> ReadBatchDataAndSort(long numData);
}; };
@ -306,4 +310,23 @@ void evtReader::PrintStatus(int mod){
} }
std::vector<DataBlock> evtReader::ReadBatchDataAndSort(long numData){
std::vector<DataBlock> dataList_A;
if( endOfFile ){
return dataList_A;
}
dataList.clear();
for( long long k = 0; k < std::min(numData, nBlock); k++){
ReadBlock();
dataList.push_back(*data);
}
//sort the dataList
std::sort(dataList.begin(), dataList.end(), [](const DataBlock & a, const DataBlock & b) { return a.time < b.time; });
}
#endif #endif

73
armory/text.cpp Normal file
View File

@ -0,0 +1,73 @@
/*==================
Thie event builder both sort and build event. skip the *.to file.
===================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <stdbool.h>
#include "TFile.h"
#include "TTree.h"
#include "TMath.h"
#include "TBenchmark.h"
#include "TStopwatch.h"
#include "TTreeIndex.h"
#include "../mapping.h"
#include "evtReader.h"
#define MAXMULTI 100
#define MAXBUFFER 100 // number of hit in memory buffer
int main(int argn, char **argv){
printf("=====================================\n");
printf("=== Event Builder from *.evt ===\n");
printf("=====================================\n");
if (argn < 5 ) {
printf("Usage :\n");
printf("%s [timeWindows] [Reject Flag] [SaveFileName] [*.evt File1 [*.evt File2] ...\n", argv[0]);
printf(" timeWindows [int]: 1 unit = 10 ns \n");
printf(" Reject Flag [int]: 0 = no rejection, 1 = reject no gamma, 2 = reject no GAGG. see mapping.h\n");
printf(" SaveFileName [str]: custom save file name \n");
return 1;
}
unsigned short timeWindow = atoi(argv[1]);
unsigned short rejectFlag = atoi(argv[2]);
TString outFileName = argv[3];
std::vector<std::string> inFileList;
for( int i = 4; i < argn; i++) inFileList.push_back(argv[i]);
//========== put data into RAM buffer.
std::vector<DataBlock> hitListA, hitListB;
evtReader * reader = nullptr;
for( size_t i = 0 ; i < inFileList.size(); i++){
reader = new evtReader(inFileList[i]);
reader->ScanNumberOfBlock();
// reader->ReadBatchDataAndSort(MAXBUFFER);
// hitListA = reader->GetDataList();
// reader->ReadBatchDataAndSort(MAXBUFFER);
// hitListB = reader->GetDataList();
delete reader;
}
return 0;
}