First: we need to know - are there any histograms storing in this dir (e.g. References).
422 {
423 TIter nextElem(list);
424 TObject* obj{};
425 TSeqCollection* tmpList{};
426
427 while ((obj = nextElem()) != 0)
428 {
429 bool delete_when_done = false;
431 if (hhl != 0)
432 {
433 obj = hhl->getObject();
434 if (!obj) continue;
435 delete_when_done = true;
437 {
438 std::cerr << "HanOutput.cxx, WriteListToDirectory : setNameGeneral failed\n";
440 continue;
441 };
442 }
443 if (strncmp(
obj->GetName(),
"Reference", 9) == 0 || strncmp(
obj->GetName(),
"ResultObject", 12) == 0)
444 {
445 dir->WriteTObject(obj);
446 if (delete_when_done)
delete obj;
447 continue;
448 }
449 tmpList =
dynamic_cast<TSeqCollection*
>(
obj);
450 if (tmpList != 0)
451 {
452
453 std::vector<std::string>
dirs;
455 boost::split(
dirs, tmpList->GetName(), boost::is_any_of(
"/"));
457 {
458 if (
dirs.back().empty())
dirs.pop_back();
460 }
461
462 if (HanOutput_FileVersion == 2)
463 {
464 TString listname = tmpList->GetName();
465 if (listname == "Config" || listname == "Results")
466 {
468
469 TIter nextElemConfRes(tmpList);
470 TObject* objInResultConfig;
471 while ((objInResultConfig = nextElemConfRes()) != 0)
472 {
474 {
475
476 TSeqCollection* tmpList_ResConf{};
477 tmpList_ResConf = dynamic_cast<TSeqCollection*>(objInResultConfig);
478 if ((tmpList_ResConf != 0) && (strncmp(tmpList_ResConf->GetName(), "TObjArray", 9) == 0))
479 {
480
481 TIter nextEleminTObjArray(tmpList_ResConf);
482 TObject* objInTObjArray;
483 while ((objInTObjArray = nextEleminTObjArray()) != 0){
484 dir->WriteTObject(objInTObjArray);
485 }
486 tmpList->Remove(objInResultConfig);
487 }
488 else
489 {
490 dir->WriteTObject(objInResultConfig);
491 }
492 }
493 }
494
495 nlohmann::ordered_json j =
to_JSON(tmpList);
496
497
498 std::string string = j.dump(4);
499
500 char* cstr = new char[string.length() + 1];
501 std::strcpy(cstr, string.c_str());
502
503 TObjString string_to_tfile;
504 string_to_tfile.SetString(cstr);
506 string_to_tfile.Write(listname);
507 delete[] cstr;
508 continue;
509 }
510 }
511
512 TDirectory* daughter;
513 if (!
dir->FindKey(
str.c_str()))
514 {
515 daughter =
dir->mkdir(
str.c_str());
516 }
517 else
518 {
519 std::cout <<
"Failed to make " <<
str <<
" from " << tmpList->GetName() << std::endl;
520 continue;
521 }
523 if (level > 0)
524 {
526 delete daughter;
527 }
528 }
529 else if ((strncmp(
obj->ClassName(),
"TH", 2) == 0) || (strncmp(
obj->ClassName(),
"TGraph", 6) == 0) ||
530 (strncmp(
obj->ClassName(),
"TProfile", 8) == 0) || (strncmp(
obj->ClassName(),
"TEfficiency", 11) == 0))
531 {
532 dir->GetMotherDir()->WriteTObject(obj);
533 }
534 else
535 {
536
537 dir->WriteTObject(obj);
538 }
539 if (delete_when_done)
delete obj;
540 }
541 }
std::map< std::string, int > dirs
list of directories to be explicitly included, together with corresponding depths of subdirectories
bool setNameGeneral(TObject *obj, const std::string &name)
static void WriteListToDirectory(TDirectory *dir, TSeqCollection *list, TFile *file, int level, int HanOutput_FileVersion)