Skip to content
Snippets Groups Projects
Commit 9f8c5196 authored by Theodore Efremov's avatar Theodore Efremov :hibiscus:
Browse files

Changed my snakefile and added a macro to merge root file

parent bcfee946
No related branches found
No related tags found
1 merge request!27Draft: [Epic] Preparation of the environement for the new GaseousDetectorScorers...
Pipeline #359185 passed
......@@ -26,7 +26,7 @@ rule all:
input:
expand("{file}",file=analysedfile)
# Règle pour convertir les fichiers .fast dans le dossier .cat en .root
# Règle pour convertir les fichiers raw en analysé
rule npanalysis:
input:
f"{input_directory}/{{name}}.root"
......
void Merger(int N, const char* outputDir, const char* outputFileName, const char* inputBaseName) {
TString outputPath = Form("%s/%s", outputDir, outputFileName);
TFile *outputFile = new TFile(outputPath, "RECREATE");
TList *fileList = new TList();
TString outputPath = Form("%s/%s.root", outputDir, outputFileName);
TFileMerger merger;
merger.OutputFile(outputPath, "RECREATE"); // Correct usage: specify the output file path directly
for (int i = 0; i < N; i++) {
TString fileName = Form("%s%d.root", inputBaseName, i); // Base name + index + .root
......@@ -10,18 +10,16 @@ void Merger(int N, const char* outputDir, const char* outputFileName, const char
std::cerr << "Error opening file: " << fileName << std::endl;
continue;
}
fileList->Add(inputFile);
merger.AddFile(fileName); // Add file to the merger
// Display progress
int progress = ((i + 1) * 100) / N;
std::cout << "\rMerging files: " << progress << "% complete." << std::flush;
}
TFileMerger merger;
merger.OutputFile(outputFile, "RECREATE");
merger.Merge(fileList);
// Perform the merge operation
merger.Merge();
std::cout << std::endl << "Merging completed! Output saved at: " << outputPath << std::endl;
outputFile->Close();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment