181 DQParSet_t::const_iterator regexEnd =
m_regexlist.end();
182 for (DQParSet_t::const_iterator regex =
m_regexlist.begin(); regex != regexEnd; ++regex)
184 TSeqCollection* resultList = (*m_outputMap)[*regex];
187 std::cerr <<
"Can't find original list for regex???" << std::endl;
191 tmpRegex.insert(DQOutputMap_t::value_type(*regex, resultList));
192 (*m_outputMap).erase(*regex);
193 DQParMap_t::const_iterator i =
m_dqPars.find(*regex);
196 dqm_core::Region* parent = i->second;
198 std::string parentName = parent->getName();
200 static_cast<TSeqCollection*
>((*m_outputMap)[parentName])->Remove(resultList);
206 DQResultMap_t::const_iterator rEnd =
m_dqResults.end();
207 for (DQResultMap_t::const_iterator
r =
m_dqResults.begin();
r != rEnd; ++
r)
209 const std::string name(
r->first);
210 const dqm_core::Result&
result(*(
r->second));
212 std::string parentName(
"top_level");
213 DQParMap_t::const_iterator i =
m_dqPars.find(name);
217 dqm_core::Region* parent = i->second;
218 parentName = parent->getName();
222 TSeqCollection* resultList = (*m_outputMap)[name];
223 std::string parname(name);
224 std::string storename(name);
226 if (resultList == NULL)
229 bool isRegex =
false;
231 for (DQParSet_t::const_iterator regex =
m_regexlist.begin(); regex != regexEnd; ++regex)
233 std::string::size_type regexlen = regex->length();
234 if (*regex +
"_" == name.substr(0, regexlen + 1))
238 std::string::size_type atsign = regex->rfind(
'@');
239 if (atsign != std::string::npos)
241 extra = regex->substr(atsign, std::string::npos);
243 storename = name.substr(regexlen + 1, std::string::npos);
251 std::cerr <<
"WARNING: setInput() has not been set; cannot publish regex results" << std::endl;
254 resultList =
static_cast<TSeqCollection*
>(tmpRegex[parname]->Clone());
255 (*m_outputMap)[storename + extra] = resultList;
256 DQParMap_t::const_iterator i =
m_dqPars.find(parname);
258 std::cerr <<
"WARNING: Can't find parname in m_dqPars" << std::endl;
261 parentName = i->second->getName();
262 bool use_full_name =
false;
265 std::unique_ptr<const HanConfigAssessor>
a(
m_config->GetAssessor(parentName, parname));
268 std::string store_using_path;
272 store_using_path.assign(hcpm->
GetValue());
274 boost::algorithm::to_lower(store_using_path);
275 if (store_using_path ==
"1" || store_using_path ==
"yes" || store_using_path ==
"true")
277 use_full_name =
true;
283 resultList->SetName((boost::algorithm::replace_all_copy(storename,
"/",
"_") + extra +
"_").c_str());
287 resultList->SetName((storename + extra +
"_").c_str());
289 dynamic_cast<TSeqCollection*
>((*m_outputMap)[parentName])->Add(resultList);
293 const char* className = key->GetClassName();
294 if ((strncmp(className,
"TH", 2) == 0) || (strncmp(className,
"TGraph", 6) == 0) ||
295 (strncmp(className,
"TProfile", 8) == 0) || (strncmp(className,
"TEfficiency", 11) == 0))
297 TNamed* transobj =
dynamic_cast<TNamed*
>(key->ReadObj());
298 if (transobj != NULL)
303 hhl->SetName((boost::algorithm::replace_all_copy(storename,
"/",
"_") + extra).c_str());
307 hhl->SetName((std::string(transobj->GetName()) + extra).c_str());
311 resultList->Add(hhl);
315 std::cerr <<
"TNamed* cast failed for " << storename << std::endl;
321 std::cout <<
"key is NULL" << std::endl;
326 std::cerr <<
"WARNING: Unable to find mapping for " << name << std::endl;
334 resultList =
dynamic_cast<TSeqCollection*
>(resultList->FindObject(
"Results"));
337 if (resultList ==
nullptr)
339 std::cerr <<
"Warning: no result list found associated with '" << name <<
"'\n";
344 resultList->Add(
newTObjArray(
"Status",
new TObjString(StatusToStr(
result.status_).c_str()), 1));
347 std::map<std::string, double>::const_iterator iter =
result.tags_.begin();
348 for (; iter !=
result.tags_.end(); ++iter)
350 std::ostringstream tagval;
351 tagval << std::setprecision(4) << iter->second;
352 resultList->Add(
newTObjArray(iter->first.c_str(),
new TObjString(tagval.str().c_str()), 1));
356 TObject* resultobj =
result.getObject();
359 TObject* resultobjclone = resultobj->Clone();
362 resultList->Add(resultobjclone);
366 std::cerr <<
"Discarding result object " <<
result.getObject()->GetName() << std::endl;
367 delete resultobjclone;
373 TObject*
ref =
m_config->GetReference(parentName, parname);
378 resultList->Add(
ref);
382 std::cerr <<
"Discarding reference object " <<
ref->GetName() << std::endl;
421 TDirectory* dir, TSeqCollection* list, TFile*
file,
int level,
int HanOutput_FileVersion)
423 TIter nextElem(list);
425 TSeqCollection* tmpList{};
427 while ((obj = nextElem()) != 0)
429 bool delete_when_done =
false;
435 delete_when_done =
true;
438 std::cerr <<
"HanOutput.cxx, WriteListToDirectory : setNameGeneral failed\n";
443 if (strncmp(obj->GetName(),
"Reference", 9) == 0 || strncmp(obj->GetName(),
"ResultObject", 12) == 0)
445 dir->WriteTObject(obj);
446 if (delete_when_done)
delete obj;
449 tmpList =
dynamic_cast<TSeqCollection*
>(obj);
453 std::vector<std::string>
dirs;
455 boost::split(
dirs, tmpList->GetName(), boost::is_any_of(
"/"));
458 if (
dirs.back().empty())
dirs.pop_back();
462 if (HanOutput_FileVersion == 2)
464 TString listname = tmpList->GetName();
465 if (listname ==
"Config" || listname ==
"Results")
469 TIter nextElemConfRes(tmpList);
470 TObject* objInResultConfig;
471 while ((objInResultConfig = nextElemConfRes()) != 0)
476 TSeqCollection* tmpList_ResConf{};
477 tmpList_ResConf =
dynamic_cast<TSeqCollection*
>(objInResultConfig);
478 if ((tmpList_ResConf != 0) && (strncmp(tmpList_ResConf->GetName(),
"TObjArray", 9) == 0))
481 TIter nextEleminTObjArray(tmpList_ResConf);
482 TObject* objInTObjArray;
483 while ((objInTObjArray = nextEleminTObjArray()) != 0){
484 dir->WriteTObject(objInTObjArray);
486 tmpList->Remove(objInResultConfig);
490 dir->WriteTObject(objInResultConfig);
495 nlohmann::ordered_json j =
to_JSON(tmpList);
498 std::string
string = j.dump(4);
500 char* cstr =
new char[
string.length() + 1];
501 std::strcpy(cstr,
string.c_str());
503 TObjString string_to_tfile;
504 string_to_tfile.SetString(cstr);
506 string_to_tfile.Write(listname);
512 TDirectory* daughter;
513 if (!dir->FindKey(
str.c_str()))
515 daughter = dir->mkdir(
str.c_str());
519 std::cout <<
"Failed to make " <<
str <<
" from " << tmpList->GetName() << std::endl;
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))
532 dir->GetMotherDir()->WriteTObject(obj);
537 dir->WriteTObject(obj);
539 if (delete_when_done)
delete obj;
543 nlohmann::ordered_json
to_JSON(TSeqCollection* tseq)
545 using json = nlohmann::ordered_json;
548 TIter nextElem(tseq);
550 while ((obj = nextElem()) != 0)
554 if ((strncmp(obj->ClassName(),
"TH", 2) == 0) || (strncmp(obj->ClassName(),
"TGraph", 6) == 0) ||
555 (strncmp(obj->ClassName(),
"TProfile", 8) == 0) || (strncmp(obj->ClassName(),
"TEfficiency", 11) == 0) ||
556 (strncmp(obj->GetName(),
"Reference", 9) == 0))
561 TSeqCollection* tmpList =
dynamic_cast<TSeqCollection*
>(obj);
566 std::string key_name_string(obj->GetName());
567 j.emplace(key_name_string,
to_JSON(tmpList));
609 DQRegMap_t::const_iterator dqRegIter =
m_dqRegs.begin();
610 DQRegMap_t::const_iterator dqRegEnd =
m_dqRegs.end();
611 for (; dqRegIter != dqRegEnd; ++dqRegIter)
613 std::string regname = dqRegIter->first->getName();
617 DQParSet_t::const_iterator regexItr =
m_regexlist.begin();
618 DQParSet_t::const_iterator regexEnd =
m_regexlist.end();
619 for (; regexItr != regexEnd; ++regexItr)
624 dqm_core::Result::Status status(dqm_core::Result::Undefined);
625 dqm_core::Result
result(status);
629 for (; unpubIter != unpubEnd; ++unpubIter)
631 const std::string& name = *unpubIter;