38 std::vector<TString> suffixes;
40 void *dirp = gSystem->OpenDirectory(sol_dir);
42 std::cerr <<
"DiscoverSolRunSuffixesFromBase: cannot open " << sol_dir
47 TString prefix = Form(
"music_exp1915_%03d_00_66222_", run);
49 while ((name = gSystem->GetDirEntry(dirp))) {
51 if (!fname.BeginsWith(prefix))
53 if (!fname.EndsWith(
".sol"))
56 TString rest = fname(prefix.Length(), fname.Length() - prefix.Length() - 4);
60 Int_t seq = rest.Atoi();
62 suffixes.push_back(
"");
64 suffixes.push_back(Form(
"_%d", seq));
67 gSystem->FreeDirectory(dirp);
69 std::sort(suffixes.begin(), suffixes.end(),
70 [](
const TString &a,
const TString &b) {
75 return a.Atoi() < b.Atoi();
95 const char *outputDir) {
102 std::mutex log_mutex;
107 std::lock_guard<std::mutex> lk(work_mutex);
119 if (gSystem->AccessPathName(solPath)) {
121 std::lock_guard<std::mutex> lk(log_mutex);
122 std::cerr <<
" [missing] " << solPath.Data() << std::endl;
128 TString baseName = solPath;
129 Int_t lastSlash = baseName.Last(
'/');
130 if (lastSlash >= 0) {
131 baseName = baseName(lastSlash + 1, baseName.Length() - lastSlash - 1);
135 TString chunk0Path = TString(outputDir) +
"/" + baseName +
"_chunk000.sol";
136 if (!gSystem->AccessPathName(chunk0Path)) {
146 std::lock_guard<std::mutex> lk(log_mutex);
147 std::cerr <<
" [skip] Not Minimum format: " << baseName << std::endl;
153 Int_t totalBlocks = 0;
154 Int_t totalChunks = 0;
155 std::vector<TString> outputFiles = SOLReader::SplitSolFileByTime(
159 if (outputFiles.empty()) {
161 std::lock_guard<std::mutex> lk(log_mutex);
162 std::cerr <<
" [error] Failed to split: " << solPath.Data()
170 std::lock_guard<std::mutex> lk(log_mutex);
171 std::cout <<
" [split] " << baseName <<
": " << totalBlocks
172 <<
" blocks -> " << totalChunks <<
" chunks" << std::endl;
180int main(
int argc,
char *argv[]) {
182 Double_t forcedSeconds = 0.0;
183 Bool_t forced = kFALSE;
187 forcedSeconds = std::stod(argv[1]);
191 nWorkers = std::stoi(argv[2]);
196 std::vector<std::pair<Int_t, Double_t>> runs;
200 for (Int_t r = 0; r < Int_t(
Constants::cfg.RUN_NUMBERS.size()); r++)
201 runs.push_back(std::make_pair(
Constants::cfg.RUN_NUMBERS[r], sec));
208 std::cout <<
"epoch " << ep.
name <<
": " << ep.
runs.size() <<
" run(s), ";
210 std::cout << sec <<
"s chunks" << std::endl;
212 std::cout <<
"no splitting (whole files)" << std::endl;
213 for (Int_t r = 0; r < Int_t(ep.
runs.size()); r++)
214 runs.push_back(std::make_pair(ep.
runs[r], sec));
217 std::queue<WorkItem> work;
218 for (Int_t r = 0; r < Int_t(runs.size()); r++) {
219 if (!(runs[r].second > 0))
222 Bool_t seen = kFALSE;
223 for (Int_t q = 0; q < r && !seen; q++)
224 seen = runs[q].first == runs[r].first;
227 std::vector<TString> suffixes =
229 for (Int_t k = 0; k < Int_t(suffixes.size()); k++) {
231 item.
run = runs[r].first;
232 item.
suffix = suffixes[k];
238 std::cout <<
"SOLARIS preprocessing: nothing to split; the pipeline reads "
239 "the whole files from "
243 std::cout <<
"SOLARIS preprocessing: splitting Minimum files (" << nWorkers
244 <<
" workers)" << std::endl;
247 std::cout <<
"Output dir: " <<
Constants::cfg.SOL_SPLIT_DIR.Data()
249 std::cout << std::endl;
253 std::cout <<
"Total files to process: " << work.size() << std::endl;
256 std::mutex work_mutex;
257 std::vector<std::thread> workers;
258 std::vector<SplitResult> results(nWorkers);
260 for (Int_t w = 0; w < nWorkers; w++) {
261 workers.emplace_back([&work, &work_mutex, &results, w]() {
267 for (Int_t w = 0; w < nWorkers; w++) {
271 Int_t totalSplit = 0;
272 Int_t totalSkipped = 0;
273 Int_t totalMissing = 0;
274 Int_t totalAlreadySplit = 0;
275 for (Int_t w = 0; w < nWorkers; w++) {
276 totalSplit += results[w].nSplit;
277 totalSkipped += results[w].nSkipped;
278 totalMissing += results[w].nMissing;
279 totalAlreadySplit += results[w].nAlreadySplit;
282 std::cout << std::endl;
283 std::cout <<
"Preprocessing complete:" << std::endl;
284 std::cout <<
" Split: " << totalSplit << std::endl;
285 std::cout <<
" Already split:" << totalAlreadySplit << std::endl;
286 std::cout <<
" Skipped: " << totalSkipped << std::endl;
287 std::cout <<
" Missing: " << totalMissing << std::endl;
289 return (totalMissing > 0) ? 1 : 0;
int main()
compute-regions: fit each reaction strip's (a,n) and (a,a') regions from the scatter cache and save t...
SplitResult SplitWorker(std::queue< WorkItem > &work, std::mutex &work_mutex, const char *outputDir)
std::vector< TString > DiscoverSolRunSuffixesFromBase(Int_t run)
Bool_t IsMinimumFormat(const char *filePath)