376 {
378 unsigned nIgnored=0;
379 TDirectory* histDir=nullptr;
380 std::string lastDir;
381 std::map<std::string,histDir_t>::const_iterator
it=
m_data.begin();
382 std::map<std::string,histDir_t>::const_iterator it_e=
m_data.end();
383 for(;
it!=it_e;++
it) {
384 const std::string
fulldir=
it->first +
"/";
385
386 std::string::size_type j=0,
j1=0;
387 while (j1!=std::string::npos) {
388 do {
391
392 }
393 while(j1!=std::string::npos && !
fulldir.compare(0,j1,lastDir,0,j1));
394 const std::string currDirAtLevel(
fulldir.substr(j,j1-j));
395 const std::string currFullDir(
fulldir.substr(0,j1));
396 const std::string currBaseDir(
fulldir.substr(0,j));
397
398 lastDir=std::move(currFullDir);
399 out->cd(currBaseDir.c_str());
401 }
402
404 it->second.md->SetDirectory(histDir);
405 it->second.md->Write(
nullptr,TObject::kOverwrite);
406 std::vector<histPerDir_t>::const_iterator ith=
it->second.histos.begin();
407 std::vector<histPerDir_t>::const_iterator ith_e=
it->second.histos.end();
408 for (;ith!=ith_e;++ith) {
409 if (ith->obj) {
410 ith->obj->Write();
411 std::cout <<
"Writing " << ith->name <<
" to dir " <<
fulldir << std::endl;
413 }
414 else {
415 std::cout << "NOT writing " << ith->name << ". Invalid." << std::endl;
416 ++nIgnored;
417 }
418 }
419 }
420 std::cout <<
"Wrote " <<
nWritten <<
" histograms to output file.";
421 if (nIgnored)
422 std::cout << " Omitting " << nIgnored << " histograms." << std::endl;
423 else
424 std::cout << std::endl;
425 return;
426}