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 if (
auto seqcoll =
dynamic_cast<TSeqCollection*
>((*
m_outputMap)[parentName])) {
290 seqcoll->Add(resultList);
293 std::cerr <<
"dynamic_cast to TSeqCollection* fails\n";
298 const char* className = key->GetClassName();
299 if ((strncmp(className,
"TH", 2) == 0) || (strncmp(className,
"TGraph", 6) == 0) ||
300 (strncmp(className,
"TProfile", 8) == 0) || (strncmp(className,
"TEfficiency", 11) == 0))
302 TNamed* transobj =
dynamic_cast<TNamed*
>(key->ReadObj());
303 if (transobj != NULL)
308 hhl->SetName((boost::algorithm::replace_all_copy(storename,
"/",
"_") + extra).c_str());
312 hhl->SetName((std::string(transobj->GetName()) + extra).c_str());
316 resultList->Add(hhl);
320 std::cerr <<
"TNamed* cast failed for " << storename << std::endl;
326 std::cout <<
"key is NULL" << std::endl;
331 std::cerr <<
"WARNING: Unable to find mapping for " << name << std::endl;
339 resultList =
dynamic_cast<TSeqCollection*
>(resultList->FindObject(
"Results"));
342 if (resultList ==
nullptr)
344 std::cerr <<
"Warning: no result list found associated with '" << name <<
"'\n";
349 resultList->Add(
newTObjArray(
"Status",
new TObjString(StatusToStr(
result.status_).c_str()), 1));
352 std::map<std::string, double>::const_iterator iter =
result.tags_.begin();
353 for (; iter !=
result.tags_.end(); ++iter)
355 std::ostringstream tagval;
356 tagval << std::setprecision(4) << iter->second;
357 resultList->Add(
newTObjArray(iter->first.c_str(),
new TObjString(tagval.str().c_str()), 1));
361 TObject* resultobj =
result.getObject();
364 TObject* resultobjclone = resultobj->Clone();
367 resultList->Add(resultobjclone);
371 std::cerr <<
"Discarding result object " <<
result.getObject()->GetName() << std::endl;
372 delete resultobjclone;
378 TObject*
ref =
m_config->GetReference(parentName, parname);
383 resultList->Add(
ref);
387 std::cerr <<
"Discarding reference object " <<
ref->GetName() << std::endl;
426 TDirectory* dir, TSeqCollection* list, TFile*
file,
int level,
int HanOutput_FileVersion)
428 TIter nextElem(list);
430 TSeqCollection* tmpList{};
432 while ((obj = nextElem()) != 0)
434 bool delete_when_done =
false;
440 delete_when_done =
true;
443 std::cerr <<
"HanOutput.cxx, WriteListToDirectory : setNameGeneral failed\n";
448 if (strncmp(obj->GetName(),
"Reference", 9) == 0 || strncmp(obj->GetName(),
"ResultObject", 12) == 0)
450 dir->WriteTObject(obj);
451 if (delete_when_done)
delete obj;
454 tmpList =
dynamic_cast<TSeqCollection*
>(obj);
458 std::vector<std::string>
dirs;
460 boost::split(
dirs, tmpList->GetName(), boost::is_any_of(
"/"));
463 if (
dirs.back().empty())
dirs.pop_back();
467 if (HanOutput_FileVersion == 2)
469 TString listname = tmpList->GetName();
470 if (listname ==
"Config" || listname ==
"Results")
474 TIter nextElemConfRes(tmpList);
475 TObject* objInResultConfig;
476 while ((objInResultConfig = nextElemConfRes()) != 0)
481 TSeqCollection* tmpList_ResConf{};
482 tmpList_ResConf =
dynamic_cast<TSeqCollection*
>(objInResultConfig);
483 if ((tmpList_ResConf != 0) && (strncmp(tmpList_ResConf->GetName(),
"TObjArray", 9) == 0))
486 TIter nextEleminTObjArray(tmpList_ResConf);
487 TObject* objInTObjArray;
488 while ((objInTObjArray = nextEleminTObjArray()) != 0){
489 dir->WriteTObject(objInTObjArray);
491 tmpList->Remove(objInResultConfig);
495 dir->WriteTObject(objInResultConfig);
500 nlohmann::ordered_json j =
to_JSON(tmpList);
503 std::string
string = j.dump(4);
505 char* cstr =
new char[
string.length() + 1];
506 std::strcpy(cstr,
string.c_str());
508 TObjString string_to_tfile;
509 string_to_tfile.SetString(cstr);
511 string_to_tfile.Write(listname);
517 TDirectory* daughter;
518 if (!dir->FindKey(
str.c_str()))
520 daughter = dir->mkdir(
str.c_str());
524 std::cout <<
"Failed to make " <<
str <<
" from " << tmpList->GetName() << std::endl;
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))
537 dir->GetMotherDir()->WriteTObject(obj);
542 dir->WriteTObject(obj);
544 if (delete_when_done)
delete obj;
548 nlohmann::ordered_json
to_JSON(TSeqCollection* tseq)
550 using json = nlohmann::ordered_json;
553 TIter nextElem(tseq);
555 while ((obj = nextElem()) != 0)
559 if ((strncmp(obj->ClassName(),
"TH", 2) == 0) || (strncmp(obj->ClassName(),
"TGraph", 6) == 0) ||
560 (strncmp(obj->ClassName(),
"TProfile", 8) == 0) || (strncmp(obj->ClassName(),
"TEfficiency", 11) == 0) ||
561 (strncmp(obj->GetName(),
"Reference", 9) == 0))
566 TSeqCollection* tmpList =
dynamic_cast<TSeqCollection*
>(obj);
571 std::string key_name_string(obj->GetName());
572 j.emplace(key_name_string,
to_JSON(tmpList));
614 DQRegMap_t::const_iterator dqRegIter =
m_dqRegs.begin();
615 DQRegMap_t::const_iterator dqRegEnd =
m_dqRegs.end();
616 for (; dqRegIter != dqRegEnd; ++dqRegIter)
618 std::string regname = dqRegIter->first->getName();
622 DQParSet_t::const_iterator regexItr =
m_regexlist.begin();
623 DQParSet_t::const_iterator regexEnd =
m_regexlist.end();
624 for (; regexItr != regexEnd; ++regexItr)
629 dqm_core::Result::Status status(dqm_core::Result::Undefined);
630 dqm_core::Result
result(status);
634 for (; unpubIter != unpubEnd; ++unpubIter)
636 const std::string& name = *unpubIter;