fix ClassData.h and EventBuilder.cpp for MacOS

This commit is contained in:
Ryan@iMac 2023-10-05 14:30:04 -04:00
parent 1c25b44ce2
commit a72fb2fdc8
2 changed files with 35 additions and 8 deletions

View File

@ -7,6 +7,8 @@
#include <cmath> #include <cmath>
#include <cstring> ///memset #include <cstring> ///memset
#include <iostream> ///cout #include <iostream> ///cout
#include <sstream>
#include <iomanip> // for setw
#include <bitset> #include <bitset>
#include <vector> #include <vector>
#include <sys/stat.h> #include <sys/stat.h>
@ -212,11 +214,19 @@ inline void Data::CopyBuffer(const char * buffer, const unsigned int size){
inline bool Data::OpenSaveFile(std::string fileNamePrefix){ inline bool Data::OpenSaveFile(std::string fileNamePrefix){
outFilePrefix = fileNamePrefix; outFilePrefix = fileNamePrefix;
char saveFileName[100];
sprintf(saveFileName, "%s_%03d_%3s_%03u.fsu", outFilePrefix.c_str() , boardSN, DPPTypeStr.c_str(), outFileIndex); std::ostringstream oss;
oss << outFilePrefix << "_"
<< std::setfill('0') << std::setw(3) << boardSN << "_"
<< DPPTypeStr << "_"
<< std::setfill('0') << std::setw(3) << outFileIndex << ".fsu";
std::string saveFileName = oss.str();
//char saveFileName[100];
//sprintf(saveFileName, "%s_%03d_%3s_%03u.fsu", outFilePrefix.c_str() , boardSN, DPPTypeStr.c_str(), outFileIndex);
outFileName = saveFileName; outFileName = saveFileName;
outFile = fopen(saveFileName, "wb"); // overwrite binary outFile = fopen(saveFileName.c_str(), "wb"); // overwrite binary
if (outFile == NULL) { if (outFile == NULL) {
printf("Failed to open the file. Probably Read-ONLY.\n"); printf("Failed to open the file. Probably Read-ONLY.\n");
@ -242,8 +252,17 @@ inline void Data::SaveData(){
FinishedOutFilesSize += ftell(outFile); FinishedOutFilesSize += ftell(outFile);
CloseSaveFile(); CloseSaveFile();
outFileIndex ++; outFileIndex ++;
char saveFileName[100];
sprintf(saveFileName, "%s_%03d_%3s_%03u.fsu", outFilePrefix.c_str() , boardSN, DPPTypeStr.c_str(), outFileIndex); // char saveFileName[100];
// sprintf(saveFileName, "%s_%03d_%3s_%03u.fsu", outFilePrefix.c_str() , boardSN, DPPTypeStr.c_str(), outFileIndex);
std::ostringstream oss;
oss << outFilePrefix << "_"
<< std::setfill('0') << std::setw(3) << boardSN << "_"
<< DPPTypeStr << "_"
<< std::setfill('0') << std::setw(3) << outFileIndex << ".fsu";
std::string saveFileName = oss.str();
outFileName = saveFileName; outFileName = saveFileName;
outFile = fopen(outFileName.c_str(), "wb"); //overwrite binary outFile = fopen(outFileName.c_str(), "wb"); //overwrite binary
} }

View File

@ -192,10 +192,18 @@ int main(int argc, char **argv) {
char * buffer = nullptr; char * buffer = nullptr;
unsigned int word[1]; // 4 byte = 32 bit unsigned int word[1]; // 4 byte = 32 bit
int lastDataIndex[nGroup][MaxNChannels]={0}; // keep track of the DataIndex int lastDataIndex[nGroup][MAX_MULTI]; // keep track of the DataIndex
int lastLoopIndex[nGroup][MaxNChannels]={0}; // keep track of the DataIndex int lastLoopIndex[nGroup][MAX_MULTI]; // keep track of the DataIndex
int aggCount[nGroup];
for( int i = 0; i < nGroup; i++){
aggCount[i] = 0;
for( int j = 0; j < MAX_MULTI; j++){
lastDataIndex[i][j] = 0;
lastLoopIndex[i][j] = 0;
}
}
int aggCount[nGroup] = {0};
do{ do{
/// fill the data class with some agg; /// fill the data class with some agg;