diff --git a/ClassData.h b/ClassData.h index f9d759d..8b8fe63 100644 --- a/ClassData.h +++ b/ClassData.h @@ -7,6 +7,8 @@ #include #include ///memset #include ///cout +#include +#include // for setw #include #include #include @@ -212,11 +214,19 @@ inline void Data::CopyBuffer(const char * buffer, const unsigned int size){ inline bool Data::OpenSaveFile(std::string 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; - outFile = fopen(saveFileName, "wb"); // overwrite binary + outFile = fopen(saveFileName.c_str(), "wb"); // overwrite binary if (outFile == NULL) { printf("Failed to open the file. Probably Read-ONLY.\n"); @@ -242,8 +252,17 @@ inline void Data::SaveData(){ FinishedOutFilesSize += ftell(outFile); CloseSaveFile(); 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; outFile = fopen(outFileName.c_str(), "wb"); //overwrite binary } diff --git a/EventBuilder.cpp b/EventBuilder.cpp index c57efcf..3920c66 100644 --- a/EventBuilder.cpp +++ b/EventBuilder.cpp @@ -192,10 +192,18 @@ int main(int argc, char **argv) { char * buffer = nullptr; unsigned int word[1]; // 4 byte = 32 bit - int lastDataIndex[nGroup][MaxNChannels]={0}; // keep track of the DataIndex - int lastLoopIndex[nGroup][MaxNChannels]={0}; // keep track of the DataIndex + int lastDataIndex[nGroup][MAX_MULTI]; // 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{ /// fill the data class with some agg;