178 {
179
181 DQParSet_t::const_iterator regexEnd =
m_regexlist.end();
182 for (DQParSet_t::const_iterator regex =
m_regexlist.begin(); regex != regexEnd; ++regex)
183 {
184 TSeqCollection* resultList = (*m_outputMap)[*
regex];
185 if (resultList == 0)
186 {
187 std::cerr << "Can't find original list for regex???" << std::endl;
188 }
189 else
190 {
191 tmpRegex.insert(DQOutputMap_t::value_type(*regex, resultList));
192 (*m_outputMap).erase(*regex);
193 DQParMap_t::const_iterator
i =
m_dqPars.find(*regex);
195 {
196 dqm_core::Region*
parent =
i->second;
197
199
200 static_cast<TSeqCollection*
>((*m_outputMap)[
parentName])->Remove(resultList);
201 }
202 }
203 }
204
205
206 DQResultMap_t::const_iterator rEnd =
m_dqResults.end();
207 for (DQResultMap_t::const_iterator
r =
m_dqResults.begin();
r != rEnd; ++
r)
208 {
209 const std::string
name(
r->first);
210 const dqm_core::Result&
result(*(
r->second));
211
213 DQParMap_t::const_iterator
i =
m_dqPars.find(name);
214
216 {
217 dqm_core::Region*
parent =
i->second;
219 }
220
221
222 TSeqCollection* resultList = (*m_outputMap)[
name];
224 std::string storename(name);
225
226 if (resultList == NULL)
227 {
228
229 bool isRegex = false;
231 for (DQParSet_t::const_iterator regex =
m_regexlist.begin(); regex != regexEnd; ++regex)
232 {
233 std::string::size_type regexlen =
regex->length();
234 if (*regex +
"_" ==
name.substr(0, regexlen + 1))
235 {
236 isRegex = true;
238 std::string::size_type atsign =
regex->rfind(
'@');
239 if (atsign != std::string::npos)
240 {
241 extra =
regex->substr(atsign, std::string::npos);
242 }
243 storename =
name.substr(regexlen + 1, std::string::npos);
244 break;
245 }
246 }
247 if (isRegex)
248 {
250 {
251 std::cerr << "WARNING: setInput() has not been set; cannot publish regex results" << std::endl;
252 continue;
253 }
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;
259 continue;
260 }
262 bool use_full_name = false;
264 {
265 std::unique_ptr<const HanConfigAssessor>
a(
m_config->GetAssessor(parentName, parname));
267 {
268 std::string store_using_path;
269 const HanConfigParMap* hcpm =
a->GetAnnotation(
"store_using_path");
270 if (hcpm)
271 {
272 store_using_path.assign(hcpm->GetValue());
273 }
274 boost::algorithm::to_lower(store_using_path);
275 if (store_using_path == "1" || store_using_path == "yes" || store_using_path == "true")
276 {
277 use_full_name = true;
278 }
279 }
280 }
281 if (use_full_name)
282 {
283 resultList->SetName((boost::algorithm::replace_all_copy(storename, "/", "_") + extra + "_").c_str());
284 }
285 else
286 {
287 resultList->SetName((storename + extra + "_").c_str());
288 }
289 if (
auto seqcoll =
dynamic_cast<TSeqCollection*
>((*
m_outputMap)[parentName])) {
290 seqcoll->Add(resultList);
291 }
292 else {
293 std::cerr << "dynamic_cast to TSeqCollection* fails\n";
294 }
296 if (key != 0)
297 {
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))
301 {
302 TNamed* transobj =
dynamic_cast<TNamed*
>(
key->ReadObj());
303 if (transobj != NULL)
304 {
305 HanHistogramLink* hhl =
new HanHistogramLink(
m_input, storename);
306 if (use_full_name)
307 {
308 hhl->SetName((boost::algorithm::replace_all_copy(storename, "/", "_") + extra).c_str());
309 }
310 else
311 {
312 hhl->SetName((std::string(transobj->GetName()) + extra).c_str());
313 }
314
315
316 resultList->Add(hhl);
317 }
318 else
319 {
320 std::cerr << "TNamed* cast failed for " << storename << std::endl;
321 }
322 }
323 }
324 else
325 {
326 std::cout << "key is NULL" << std::endl;
327 }
328 }
329 else
330 {
331 std::cerr <<
"WARNING: Unable to find mapping for " <<
name << std::endl;
332 continue;
333 }
334 }
335
336
337 if (resultList)
338 {
339 resultList = dynamic_cast<TSeqCollection*>(resultList->FindObject("Results"));
340 }
341
342 if (resultList == nullptr)
343 {
344 std::cerr <<
"Warning: no result list found associated with '" <<
name <<
"'\n";
345 continue;
346 }
347
348
349 resultList->Add(
newTObjArray(
"Status",
new TObjString(StatusToStr(
result.status_).c_str()), 1));
350
351
352 std::map<std::string, double>::const_iterator
iter =
result.tags_.begin();
354 {
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));
358 }
359
360
361 TObject* resultobj =
result.getObject();
362 if (resultobj != 0)
363 {
364 TObject* resultobjclone = resultobj->Clone();
366 {
367 resultList->Add(resultobjclone);
368 }
369 else
370 {
371 std::cerr <<
"Discarding result object " <<
result.getObject()->GetName() << std::endl;
372 delete resultobjclone;
373 }
374 }
375
377 {
378 TObject*
ref =
m_config->GetReference(parentName, parname);
380 {
382 {
383 resultList->Add(
ref);
384 }
385 else
386 {
387 std::cerr <<
"Discarding reference object " <<
ref->GetName() << std::endl;
388 }
389 }
390 }
391 }
392 }
const boost::regex ref(r_ef)
std::map< std::string, TSeqCollection * > DQOutputMap_t
TSeqCollection * newTObjArray(const char *name, TObject *obj=0, Int_t size=TCollection::kInitCapacity)
bool setNameGeneral(TObject *obj, const std::string &name)
TKey * getObjKey(TDirectory *dir, const std::string &path)