REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestDataSetPlot.cxx
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see https://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see https://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
260
261#include "TRestDataSetPlot.h"
262
263#include "TCanvas.h"
264#include "TDirectory.h"
265#include "TStyle.h"
266
267ClassImp(TRestDataSetPlot);
268
273
277TRestDataSetPlot::TRestDataSetPlot(const char* configFilename, std::string name)
278 : TRestMetadata(configFilename) {
279 Initialize();
282}
283
288
293void TRestDataSetPlot::Initialize() { SetSectionName(this->ClassName()); }
294
300
301 if (fDataSetName == "") fDataSetName = GetParameter("inputFileName", "");
302 if (fOutputFileName == "") fOutputFileName = GetParameter("outputFileName", "");
303
304 fCut = ReadCut(fCut);
305
306 ReadPlotInfo();
308}
309
316TRestCut* TRestDataSetPlot::ReadCut(TRestCut* cut, TiXmlElement* ele) {
317 TiXmlElement* cutele = GetElement("addCut", ele);
318 while (cutele != nullptr) {
319 std::string cutName = GetParameter("name", cutele, "");
320 if (!cutName.empty()) {
321 if (cut == nullptr) {
322 cut = (TRestCut*)InstantiateChildMetadata("TRestCut", cutName);
323 } else {
324 cut->AddCut((TRestCut*)InstantiateChildMetadata("TRestCut", cutName));
325 }
326 }
327 cutele = GetNextElement(cutele);
328 }
329
330 return cut;
331}
332
338 if (!fPanels.empty()) {
339 RESTWarning << "Plot metadata already initialized" << RESTendl;
340 }
341
342 TiXmlElement* panelele = GetElement("panel");
343 while (panelele != nullptr) {
344 std::string active = GetParameter("value", panelele, "ON");
345 if (ToUpper(active) != "ON") continue;
346
347 PanelInfo panel;
348 panel.font_size = StringToDouble(GetParameter("font_size", panelele, "0.1"));
349 panel.precision = StringToInteger(GetParameter("precision", panelele, "2"));
350
351 panel.panelCut = ReadCut(panel.panelCut, panelele);
352
353 TiXmlElement* labelele = GetElement("variable", panelele);
354 while (labelele != nullptr) {
355 std::array<std::string, 3> label;
356 label[0] = GetParameter("value", labelele, "");
357 label[1] = GetParameter("label", labelele, "");
358 label[2] = GetParameter("units", labelele, "");
359 double posX = StringToDouble(GetParameter("x", labelele, "0.1"));
360 double posY = StringToDouble(GetParameter("y", labelele, "0.1"));
361
362 panel.variablePos.push_back(std::make_pair(label, TVector2(posX, posY)));
363
364 labelele = GetNextElement(labelele);
365 }
366 TiXmlElement* metadata = GetElement("metadata", panelele);
367 while (metadata != nullptr) {
368 std::array<std::string, 3> label;
369 label[0] = GetParameter("value", metadata, "");
370 label[1] = GetParameter("label", metadata, "");
371 label[2] = GetParameter("units", metadata, "");
372 double posX = StringToDouble(GetParameter("x", metadata, "0.1"));
373 double posY = StringToDouble(GetParameter("y", metadata, "0.1"));
374
375 panel.metadataPos.push_back(std::make_pair(label, TVector2(posX, posY)));
376
377 metadata = GetNextElement(metadata);
378 }
379 TiXmlElement* observable = GetElement("observable", panelele);
380 while (observable != nullptr) {
381 std::array<std::string, 3> label;
382 label[0] = GetParameter("value", observable, "");
383 label[1] = GetParameter("label", observable, "");
384 label[2] = GetParameter("units", observable, "");
385 double posX = StringToDouble(GetParameter("x", observable, "0.1"));
386 double posY = StringToDouble(GetParameter("y", observable, "0.1"));
387
388 panel.obsPos.push_back(std::make_pair(label, TVector2(posX, posY)));
389
390 observable = GetNextElement(observable);
391 }
392
393 fPanels.push_back(panel);
394 panelele = GetNextElement(panelele);
395 }
396}
397
403 if (!fPlots.empty()) {
404 RESTWarning << "Plot metadata already initialized" << RESTendl;
405 return;
406 }
407
408 TiXmlElement* plotele = GetElement("plot");
409 while (plotele != nullptr) {
410 std::string active = GetParameter("value", plotele, "ON");
411 if (ToUpper(active) != "ON") continue;
412 int N = fPlots.size();
413 PlotInfo plot;
414 plot.name = RemoveWhiteSpaces(GetParameter("name", plotele, "plot_" + ToString(N)));
415 plot.title = GetParameter("title", plotele, plot.name);
416 plot.logX = StringToBool(GetParameter("logX", plotele, "false"));
417 plot.logY = StringToBool(GetParameter("logY", plotele, "false"));
418 plot.logZ = StringToBool(GetParameter("logZ", plotele, "false"));
419 plot.gridY = StringToBool(GetParameter("gridY", plotele, "false"));
420 plot.gridX = StringToBool(GetParameter("gridX", plotele, "false"));
421 plot.normalize = StringToDouble(GetParameter("norm", plotele, ""));
422 plot.scale = GetParameter("scale", plotele, "");
423 plot.labelX = GetParameter("xlabel", plotele, "");
424 plot.labelY = GetParameter("ylabel", plotele, "");
425 plot.marginBottom = StringToDouble(GetParameter("marginBottom", plotele, "0.15"));
426 plot.marginTop = StringToDouble(GetParameter("marginTop", plotele, "0.07"));
427 plot.marginLeft = StringToDouble(GetParameter("marginLeft", plotele, "0.25"));
428 plot.marginRight = StringToDouble(GetParameter("marginRight", plotele, "0.1"));
429 plot.legendOn = StringToBool(GetParameter("legend", plotele, "OFF"));
430 plot.stackDrawOption = GetParameter("stackOption", plotele, "nostack");
431 // plot.annotationOn = StringToBool(GetParameter("annotation", plotele, "OFF"));
432 plot.xOffset = StringToDouble(GetParameter("xOffset", plotele, "0"));
433 plot.yOffset = StringToDouble(GetParameter("yOffset", plotele, "0"));
434 plot.timeDisplay = StringToBool(GetParameter("timeDisplay", plotele, "OFF"));
435 plot.save = RemoveWhiteSpaces(GetParameter("save", plotele, ""));
436
437 TiXmlElement* histele = GetElement("histo", plotele);
438 if (histele == nullptr) {
439 histele = plotele;
440 }
441 while (histele != nullptr) {
442 HistoInfo hist;
443 hist.name = RemoveWhiteSpaces(GetParameter("name", histele, plot.name));
444 hist.drawOption = GetParameter("option", histele, "colz");
445 TiXmlElement* varele = GetElement("variable", histele);
446 while (varele != nullptr) {
447 hist.variable.push_back(GetParameter("name", varele));
448 std::string rangeStr = GetParameter("range", varele);
449 hist.range.push_back(StringTo2DVector(rangeStr));
450 hist.nBins.push_back(StringToInteger(GetParameter("nbins", varele)));
451 varele = GetNextElement(varele);
452 }
453
454 hist.lineColor = GetIDFromMapString(ColorIdMap, GetParameter("lineColor", histele, "602"));
455 hist.lineWidth = StringToInteger(GetParameter("lineWidth", histele, "1"));
456 hist.lineStyle = GetIDFromMapString(LineStyleMap, GetParameter("lineStyle", histele, "1"));
457 hist.fillStyle = GetIDFromMapString(FillStyleMap, GetParameter("fillStyle", histele, "1001"));
458 hist.fillColor = GetIDFromMapString(ColorIdMap, GetParameter("fillColor", histele, "0"));
459 hist.statistics = StringToBool(GetParameter("stats", histele, "OFF"));
460 // hist.weight = GetParameter("weight", histele, "");
461 hist.histoCut = ReadCut(hist.histoCut, histele);
462 plot.histos.push_back(hist);
463
464 if (histele == plotele) {
465 break;
466 }
467 histele = GetNextElement(histele);
468 }
469
470 fPlots.push_back(plot);
471 plotele = GetNextElement(plotele);
472 }
473}
474
481 std::vector<std::string> obsList;
482
483 // Add obserbables from global cut
484 if (fCut != nullptr) {
485 const auto paramCut = fCut->GetParamCut();
486 for (const auto& [param, condition] : paramCut) {
487 obsList.push_back(param);
488 }
489 }
490
491 // Add obserbables from plot info, both variables and cuts
492 for (const auto& plots : fPlots) {
493 for (const auto& hist : plots.histos) {
494 for (const auto& var : hist.variable) {
495 obsList.push_back(var);
496 }
497 if (hist.histoCut == nullptr) continue;
498 const auto paramCut = hist.histoCut->GetParamCut();
499 for (const auto& [param, condition] : paramCut) {
500 obsList.push_back(param);
501 }
502 }
503 }
504
505 std::map<std::string, TRestDataSet::RelevantQuantity> quantity;
506
507 for (auto& panel : fPanels) {
508 // Add obserbables from panel info, both variables and cuts
509 for (auto& [key, posLabel] : panel.obsPos) {
510 auto&& [obs, label, units] = key;
511 obsList.push_back(obs);
512 }
513 // Add relevant quantity to metadata from the panel info
514 for (auto& [key, posLabel] : panel.metadataPos) {
515 auto&& [metadata, label, units] = key;
517 quant.metadata = metadata;
518 quant.strategy = "unique";
519 quantity[label] = quant;
520 }
521 }
522
523 // Remove duplicated observables if any
524 std::sort(obsList.begin(), obsList.end());
525 obsList.erase(std::unique(obsList.begin(), obsList.end()), obsList.end());
526 dataSet.SetFilePattern(fDataSetName);
527 dataSet.SetObservablesList(obsList);
528 dataSet.SetQuantity(quantity);
529 dataSet.GenerateDataSet();
530}
531
537 TRestDataSet dataSet;
538
539 // Import dataSet
540 dataSet.Import(fDataSetName);
541
542 // If dataSet is not valid, try to generate it, but note that this is deprecated
543 if (dataSet.GetTree() == nullptr) {
544 RESTWarning << "Cannot import dataSet, trying to generate it with pattern " << fDataSetName
545 << RESTendl;
546 RESTWarning << "Note that the generation of a dataSet inside TRestDataSetPlot is deplecated. Check "
547 "TRestDataSet documentation to generate a dataSet"
548 << RESTendl;
550 if (dataSet.GetTree() == nullptr) {
551 RESTError << "Cannot generate dataSet " << RESTendl;
552 exit(1);
553 }
554 }
555
556 // Perform the global cut over the dataSet
557 dataSet.SetDataFrame(dataSet.MakeCut(fCut));
558
559 TCanvas combinedCanvas(this->GetName(), this->GetName(), 0, 0, fCanvasSize.X(), fCanvasSize.Y());
560 combinedCanvas.Divide((Int_t)fCanvasDivisions.X(), (Int_t)fCanvasDivisions.Y(),
561 fCanvasDivisionMargins.X(), fCanvasDivisionMargins.Y());
562
563 gStyle->SetPalette(fPaletteStyle);
564
565 const double duration = dataSet.GetTotalTimeInSeconds();
566 const double startTime = dataSet.GetStartTime();
567 const double endTime = dataSet.GetEndTime();
568
569 // Fill general variables for the panel
570 std::map<std::string, std::string> paramMap;
571 paramMap["[[startTime]]"] = ToDateTimeString(startTime);
572 paramMap["[[endTime]]"] = ToDateTimeString(endTime);
573
574 // DataSet quantity is used to replace metadata parameters
575 const auto quantity = dataSet.GetQuantity();
576
577 int canvasIndex = 1;
578
579 for (auto& panel : fPanels) {
580 combinedCanvas.cd(canvasIndex);
581 // Gets a dataFrame with the panel cut
582 auto dataFrame = dataSet.MakeCut(panel.panelCut);
583 const int entries = *dataFrame.Count();
584 const double meanRate = entries / duration;
585 const double runLength = duration / 3600.;
586 paramMap["[[runLength]]"] = StringWithPrecision(runLength, panel.precision);
587 paramMap["[[entries]]"] = StringWithPrecision(entries, panel.precision);
588 paramMap["[[meanRate]]"] = StringWithPrecision(meanRate, panel.precision);
589 // Replace panel variables and generate a TLatex label
590 for (const auto& [key, posLabel] : panel.variablePos) {
591 auto&& [variable, label, units] = key;
592 bool found = false;
593 std::string var = variable;
594 if (!var.empty()) {
595 for (const auto& [param, val] : paramMap) {
596 if (var == param) {
597 size_t pos = 0;
598 var = Replace(var, param, val, pos);
599 found = true;
600 break;
601 }
602 }
603 if (!found) RESTWarning << "Variable " << variable << " not found" << RESTendl;
604 }
605 std::string lab = label + ": " + StringWithPrecision(var, panel.precision) + " " + units;
606 panel.text.emplace_back(new TLatex(posLabel.X(), posLabel.Y(), lab.c_str()));
607 }
608
609 // Replace metadata variables and generate a TLatex label
610 for (const auto& [key, posLabel] : panel.metadataPos) {
611 auto&& [metadata, label, units] = key;
612 std::string value = "";
613
614 for (const auto& [name, quant] : quantity) {
615 if (quant.metadata == metadata) value = quant.value;
616 }
617
618 if (value.empty()) {
619 RESTWarning << "Metadata quantity " << metadata << " not found in dataSet" << RESTendl;
620 continue;
621 }
622
623 std::string lab = label + ": " + StringWithPrecision(value, panel.precision) + " " + units;
624 panel.text.emplace_back(new TLatex(posLabel.X(), posLabel.Y(), lab.c_str()));
625 }
626
627 // Replace observable variables and generate a TLatex label
628 for (const auto& [key, posLabel] : panel.obsPos) {
629 auto&& [obs, label, units] = key;
630 auto value = *dataFrame.Mean(obs);
631
632 std::string lab = label + ": " + StringWithPrecision(value, panel.precision) + " " + units;
633 panel.text.emplace_back(new TLatex(posLabel.X(), posLabel.Y(), lab.c_str()));
634 }
635
636 // Draw the labels inside the pad
637 for (const auto& text : panel.text) {
638 text->SetTextColor(1);
639 text->SetTextSize(panel.font_size);
640 text->Draw("same");
641 }
642 canvasIndex++;
643 }
644
645 for (auto& plots : fPlots) {
646 // Histograms are added to a THStack and will be ploted later on
647 combinedCanvas.cd(canvasIndex);
648 plots.hs = new THStack(plots.name.c_str(), plots.title.c_str());
649 if (plots.legendOn) plots.legend = new TLegend(fLegendX1, fLegendY1, fLegendX2, fLegendY2);
651 for (auto& hist : plots.histos) {
652 auto dataFrame = dataSet.MakeCut(hist.histoCut);
653 if (hist.variable.front() == "timeStamp") {
654 hist.range.front().SetX(startTime);
655 hist.range.front().SetY(endTime);
656 }
657 // 1-D Histograms
658 if (hist.variable.size() == 1) {
659 auto histo = dataFrame.Histo1D({hist.name.c_str(), hist.name.c_str(), hist.nBins.front(),
660 hist.range.front().X(), hist.range.front().Y()},
661 hist.variable.front());
662 hist.histo = static_cast<TH1*>(histo->DrawClone());
663 // 2-D Histograms
664 } else if (hist.variable.size() == 2) {
665 auto histo = dataFrame.Histo2D(
666 {hist.name.c_str(), hist.name.c_str(), hist.nBins.front(), hist.range.front().X(),
667 hist.range.front().Y(), hist.nBins.back(), hist.range.back().X(), hist.range.back().Y()},
668 hist.variable.front(), hist.variable.back());
669 hist.histo = static_cast<TH1*>(histo->DrawClone());
670 } else {
671 RESTError << "Only 1D or 2D histograms are supported " << RESTendl;
672 continue;
673 }
674 hist.histo->SetLineColor(hist.lineColor);
675 hist.histo->SetLineWidth(hist.lineWidth);
676 hist.histo->SetLineStyle(hist.lineStyle);
677 hist.histo->SetFillColor(hist.fillColor);
678 hist.histo->SetFillStyle(hist.fillStyle);
679 // If stats are on histos must we drawn
680 if (hist.statistics) {
681 hist.histo->SetStats(true);
682 hist.histo->Draw();
683 combinedCanvas.Update();
684 } else {
685 hist.histo->SetStats(false);
686 }
687 // Normalize histos
688 if (plots.normalize > 0) {
689 const double integral = hist.histo->Integral();
690 if (integral > 0) hist.histo->Scale(plots.normalize / integral);
691 }
692 // Scale histos
693 if (plots.scale != "") {
694 Double_t scale = 1.;
695 if (plots.scale == "binSize") {
696 scale = 1. / hist.histo->GetXaxis()->GetBinWidth(1);
697 } else {
698 scale = StringToDouble(plots.scale);
699 }
700 hist.histo->Scale(scale);
701 }
702
703 // Add histos to the THStack
704 plots.hs->Add(hist.histo, hist.drawOption.c_str());
705 // Add histos to the legend
706 if (plots.legend != nullptr) plots.legend->AddEntry(hist.histo, hist.histo->GetName(), "lf");
707 }
708 }
709
710 // This function do the actual drawing of the THStack with the different options
711 for (auto& plots : fPlots) {
712 if (plots.hs == nullptr) continue;
713 // TPad parameters
714 TPad* targetPad = (TPad*)combinedCanvas.cd(canvasIndex);
715 targetPad->SetLogx(plots.logX);
716 targetPad->SetLogy(plots.logY);
717 targetPad->SetLogz(plots.logZ);
718 targetPad->SetGridx(plots.gridX);
719 targetPad->SetGridy(plots.gridY);
720 targetPad->SetLeftMargin(plots.marginLeft);
721 targetPad->SetRightMargin(plots.marginRight);
722 targetPad->SetBottomMargin(plots.marginBottom);
723 targetPad->SetTopMargin(plots.marginTop);
724
725 // HStack draw parameters
726 plots.hs->Draw(plots.stackDrawOption.c_str());
727 plots.hs->GetXaxis()->SetTitle(plots.labelX.c_str());
728 plots.hs->GetYaxis()->SetTitle(plots.labelY.c_str());
729 plots.hs->GetXaxis()->SetLabelSize(1.1 * plots.hs->GetXaxis()->GetLabelSize());
730 plots.hs->GetYaxis()->SetLabelSize(1.1 * plots.hs->GetYaxis()->GetLabelSize());
731 plots.hs->GetXaxis()->SetTitleSize(1.1 * plots.hs->GetXaxis()->GetTitleSize());
732 plots.hs->GetYaxis()->SetTitleSize(1.1 * plots.hs->GetYaxis()->GetTitleSize());
733
734 if (plots.timeDisplay) plots.hs->GetXaxis()->SetTimeDisplay(1);
735 if (plots.legend != nullptr) plots.legend->Draw();
736
737 targetPad->Update();
738 combinedCanvas.Update();
739 canvasIndex++;
740 }
741
742 // Preview plot. User can make some changed before saving
743 if (!REST_Display_CompatibilityMode && fPreviewPlot) {
744 combinedCanvas.Resize();
745 GetChar();
746 }
747
748 // Save single pads if save is marked
749 for (auto& plots : fPlots) {
750 if (plots.save.empty()) continue;
751 std::unique_ptr<TCanvas> canvas(new TCanvas());
752 canvas->SetLogx(plots.logX);
753 canvas->SetLogy(plots.logY);
754 canvas->SetLogz(plots.logZ);
755 canvas->SetGridx(plots.gridX);
756 canvas->SetGridy(plots.gridY);
757 canvas->SetLeftMargin(plots.marginLeft);
758 canvas->SetRightMargin(plots.marginRight);
759 canvas->SetBottomMargin(plots.marginBottom);
760 canvas->SetTopMargin(plots.marginTop);
761 plots.hs->Draw(plots.stackDrawOption.c_str());
762 canvas->Print(plots.save.c_str());
763 }
764
765 // Save combined canvas
766 if (!fOutputFileName.empty()) {
767 for (const auto& [name, quant] : quantity) {
768 size_t pos = 0;
769 fOutputFileName = Replace(fOutputFileName, quant.metadata, quant.value, pos);
770 }
771 combinedCanvas.Print(fOutputFileName.c_str());
772 // In case of root file save also the histograms
774 std::unique_ptr<TFile> f(TFile::Open(fOutputFileName.c_str(), "UPDATE"));
775 for (auto& plots : fPlots) {
776 for (auto& hist : plots.histos) {
777 hist.histo->Write();
778 }
779 }
780 this->Write();
781 }
782 }
783
784 CleanUp();
785}
786
792 for (auto& plots : fPlots) {
793 for (auto& hist : plots.histos) {
794 delete hist.histo;
795 }
796 delete plots.hs;
797 delete plots.legend;
798 }
799
800 for (auto& panel : fPanels) {
801 for (auto& text : panel.text) {
802 delete text;
803 }
804 panel.text.clear();
805 }
806}
807
813Int_t TRestDataSetPlot::GetIDFromMapString(const std::map<std::string, int>& mapStr, const std::string& in) {
814 if (in.find_first_not_of("0123456789") == std::string::npos) {
815 return StringToInteger(in);
816 }
817 auto it = mapStr.find(in);
818 if (it != mapStr.end()) {
819 return it->second;
820 } else {
821 RESTWarning << "cannot find ID with name \"" << in << "\"" << RESTendl;
822 }
823 return -1;
824}
825
831
832 RESTMetadata << "DataSet name: " << fDataSetName << RESTendl;
833 RESTMetadata << "PaletteStyle: " << fPaletteStyle << RESTendl;
834 if (fPreviewPlot) RESTMetadata << "Preview plot is ACTIVE" << RESTendl;
835 RESTMetadata << "Canvas size: (" << fCanvasSize.X() << " ," << fCanvasSize.Y() << ")" << RESTendl;
836 RESTMetadata << "Canvas divisions: (" << fCanvasDivisions.X() << " ," << fCanvasDivisions.Y() << ")"
837 << RESTendl;
838 RESTMetadata << "-------------------" << RESTendl;
839 for (const auto& plot : fPlots) {
840 RESTMetadata << "-------------------" << RESTendl;
841 RESTMetadata << "Plot name/title: " << plot.name << " " << plot.title << RESTendl;
842 RESTMetadata << "Save string: " << plot.save << RESTendl;
843 RESTMetadata << "Set log X,Y,Z: " << plot.logX << ", " << plot.logY << ", " << plot.logZ << RESTendl;
844 RESTMetadata << "Stack draw Option: " << plot.stackDrawOption << RESTendl;
845 if (plot.legend) RESTMetadata << "Legend is ON" << RESTendl;
846 if (plot.timeDisplay) RESTMetadata << "Time display is ON" << RESTendl;
847 RESTMetadata << "Labels X,Y: " << plot.labelX << ", " << plot.labelY << RESTendl;
848 for (const auto& hist : plot.histos) {
849 RESTMetadata << "****************" << RESTendl;
850 RESTMetadata << "Histo name: " << hist.name << RESTendl;
851 RESTMetadata << "Draw Option: " << hist.drawOption << RESTendl;
852 RESTMetadata << "Histogram size: " << hist.variable.size() << " with parameters:" << RESTendl;
853 for (size_t i = 0; i < hist.variable.size(); i++) {
854 RESTMetadata << "\t" << i << " " << hist.variable[i] << ", " << hist.nBins[i] << ", "
855 << hist.range[i].X() << ", " << hist.range[i].Y() << RESTendl;
856 }
857 RESTMetadata << "****************" << RESTendl;
858 }
859 }
860 RESTMetadata << "-------------------" << RESTendl;
861 for (auto& panel : fPanels) {
862 RESTMetadata << "-------------------" << RESTendl;
863 RESTMetadata << "Panel font size/precision " << panel.font_size << ", " << panel.precision
864 << RESTendl;
865 RESTMetadata << "****************" << RESTendl;
866 for (auto& [key, posLabel] : panel.variablePos) {
867 auto&& [obs, label, units] = key;
868 RESTMetadata << "Label variable " << obs << ", label " << label << ", units " << units << " Pos ("
869 << posLabel.X() << ", " << posLabel.Y() << ")" << RESTendl;
870 }
871 RESTMetadata << "****************" << RESTendl;
872 for (auto& [key, posLabel] : panel.metadataPos) {
873 auto&& [obs, label, units] = key;
874 RESTMetadata << "Label metadata " << obs << ", label " << label << ", units " << units << " Pos ("
875 << posLabel.X() << ", " << posLabel.Y() << ")" << RESTendl;
876 }
877 RESTMetadata << "****************" << RESTendl;
878 for (auto& [key, posLabel] : panel.obsPos) {
879 auto&& [obs, label, units] = key;
880 RESTMetadata << "Label Observable " << obs << ", label " << label << ", units " << units
881 << " Pos (" << posLabel.X() << ", " << posLabel.Y() << ")" << RESTendl;
882 }
883 RESTMetadata << "****************" << RESTendl;
884 }
885 RESTMetadata << "-------------------" << RESTendl;
886
887 RESTMetadata << RESTendl;
888}
A class to help on cuts definitions. To be used with TRestAnalysisTree.
Definition: TRestCut.h:31
Perform the plot over datasets.
Int_t GetIDFromMapString(const std::map< std::string, int > &mapStr, const std::string &in)
This functions gets the ID from a map string that is passed by reference. It is used to translate col...
std::vector< PanelInfo > fPanels
Vector with panels/label options.
TRestCut * ReadCut(TRestCut *cut, TiXmlElement *ele=nullptr)
this function is used to add the different cuts provided in different metadata sections,...
void Initialize() override
Function to initialize input/output event members and define the section name.
void PlotCombinedCanvas()
This functions performs the plot of the combined canvas with the different panels and plots.
const std::map< std::string, int > LineStyleMap
LineStyleMap as enum "ELineStyle" defined in TAttLine.h.
std::string fDataSetName
Name of the dataset to be imported.
void ReadPlotInfo()
This function reads the config file plot info and stores it in a vector of PlotInfo.
void ReadPanelInfo()
This function reads the config file panel info and stores it in a vector of PanelInfo.
void GenerateDataSetFromFilePattern(TRestDataSet &dataSet)
This functions generates a dataSet based on the information of the rml file. A TRestDataSet is pased ...
Int_t fPaletteStyle
Palette style.
const std::map< std::string, int > FillStyleMap
FillStyleMap as enum "EFillStyle" defined in TAttFill.h.
TRestDataSetPlot()
Default constructor.
TRestCut * fCut
Global cut for the entire dataSet.
Bool_t fPreviewPlot
Preview plot.
const std::map< std::string, int > ColorIdMap
Maps for internal use only.
void PrintMetadata() override
Prints on screen the information about the metadata members of TRestDataSetPlot.
TVector2 fCanvasSize
Canvas options, size, divisions and margins.
std::string fOutputFileName
OutputFileName.
~TRestDataSetPlot()
Default destructor.
Double_t fLegendX1
Legend position and size.
std::vector< PlotInfo > fPlots
Vector with plots/pads options.
void InitFromConfigFile() override
Initialization of specific TRestDataSetPlot members through an RML file.
void CleanUp()
Clean up histos and text but note that the metadata is unchanged.
It allows to group a number of runs that satisfy given metadata conditions.
Definition: TRestDataSet.h:34
void Import(const std::string &fileName)
This function imports metadata from a root file it import metadata info from the previous dataSet whi...
Double_t GetTotalTimeInSeconds() const
It returns the accumulated run time in seconds.
Definition: TRestDataSet.h:164
ROOT::RDF::RNode MakeCut(const TRestCut *cut)
This function applies a TRestCut to the dataframe and returns a dataframe with the applied cuts....
void GenerateDataSet()
This function generates the data frame with the filelist and column names (or observables) that have ...
TTree * GetTree() const
Gives access to the tree.
Definition: TRestDataSet.h:136
A base class for any REST metadata class.
Definition: TRestMetadata.h:70
virtual void PrintMetadata()
Implemented it in the derived metadata class to print out specific metadata information.
endl_t RESTendl
Termination flag object for TRestStringOutput.
TiXmlElement * GetElement(std::string eleDeclare, TiXmlElement *e=nullptr)
Get an xml element from a given parent element, according to its declaration.
Int_t LoadConfigFromFile(const std::string &configFilename, const std::string &sectionName="")
Give the file name, find out the corresponding section. Then call the main starter.
TRestMetadata * InstantiateChildMetadata(int index, std::string pattern="")
This method will retrieve a new TRestMetadata instance of a child element of the present TRestMetadat...
virtual void InitFromConfigFile()
To make settings from rml file. This method must be implemented in the derived class.
TRestStringOutput::REST_Verbose_Level GetVerboseLevel()
returns the verboselevel in type of REST_Verbose_Level enumerator
void SetSectionName(std::string sName)
set the section name, clear the section content
std::string fConfigFileName
Full name of the rml file.
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
overwriting the write() method with fStore considered
TiXmlElement * GetNextElement(TiXmlElement *e)
Get the next sibling xml element of this element, with same eleDeclare.
std::string GetParameter(std::string parName, TiXmlElement *e, TString defaultValue=PARAMETER_NOT_FOUND_STR)
Returns the value for the parameter named parName in the given section.
@ REST_Info
+show most of the information for each steps
static std::string GetFileNameExtension(const std::string &fullname)
Gets the file extension as the substring found after the latest ".".
Definition: TRestTools.cxx:823
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.
Double_t StringToDouble(std::string in)
Gets a double from a string.
std::string ToUpper(std::string in)
Convert string to its upper case. Alternative of TString::ToUpper.
Int_t StringToInteger(std::string in)
Gets an integer from a string.
TVector2 StringTo2DVector(std::string in)
Gets a 2D-vector from a string.
std::string RemoveWhiteSpaces(std::string in)
Returns the input string removing all white spaces.
std::string ToDateTimeString(time_t time)
Format time_t into string.
std::string Replace(std::string in, std::string thisString, std::string byThisString, size_t fromPosition=0, Int_t N=0)
Replace any occurences of thisSring by byThisString inside string in.
Nested classes for internal use only.
Auxiliary class for panels/labels.
Auxiliary struct for plots/pads.
std::string metadata
The associated metadata member used to register the relevant quantity.
Definition: TRestDataSet.h:38
std::string strategy
It determines how to produce the relevant quantity (accumulate/unique/last/max/min)
Definition: TRestDataSet.h:41