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