616 new GPopup(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), 500, 200);
625 for(
auto*
hist : hists) {
630 for(
auto*
hist : hists) {
641 GetContextMenu()->Action(hists.back()->GetXaxis(),
642 TAxis::Class()->GetMethodAny(
"SetRangeUser"));
644 double x1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetFirst());
645 double x2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetLast());
646 TIter iter(GetListOfPrimitives());
647 while(TObject* obj = iter.Next()) {
648 if(obj->InheritsFrom(TPad::Class())) {
649 TPad* pad =
static_cast<TPad*
>(obj);
650 TIter iter2(pad->GetListOfPrimitives());
651 while(TObject* obj2 = iter2.Next()) {
652 if(obj2->InheritsFrom(TH1::Class())) {
653 TH1*
hist =
static_cast<TH1*
>(obj2);
654 hist->GetXaxis()->SetRangeUser(x1, x2);
669 std::cout <<
"x low = " <<
fMarkers.at(
fMarkers.size() - 2)->GetLocalX() <<
"\t\txhigh = " <<
fMarkers.back()->GetLocalX() << std::endl;
678 std::cout <<
"x low = " <<
fMarkers.at(
fMarkers.size() - 2)->GetLocalX() <<
"\t\txhigh = " <<
fMarkers.back()->GetLocalX() << std::endl;
696 if(binlow > binhigh) {
697 std::swap(binlow, binhigh);
699 double xlow = hists.back()->GetXaxis()->GetBinLowEdge(binlow);
700 double xhigh = hists.back()->GetXaxis()->GetBinLowEdge(binhigh);
703 double epsilon = 16 * (std::nextafter(xlow, INFINITY) - xlow);
708 double epsilon = 16 * (xhigh - std::nextafter(xhigh, -INFINITY));
713 hists.back()->Integral(hists.back()->GetXaxis()->FindBin(xlow), hists.back()->GetXaxis()->FindBin(xhigh));
714 std::cout <<
BLUE << std::endl
715 <<
"\tSum [" << xlow <<
" : " << xhigh <<
"] = " << sum <<
RESET_COLOR << std::endl;
726 for(
auto*
hist : hists) {
727 hist->GetYaxis()->UnZoom();
732 for(
auto*
hist : hists) {
733 if(
hist->GetYaxis()->GetXmin() < 0) {
734 hist->GetYaxis()->SetRangeUser(0,
hist->GetYaxis()->GetXmax());
750 for(
auto*
hist : hists) {
751 hist->GetListOfFunctions()->Clear();
753 for(
auto*
hist : hists) {
761 for(
auto*
hist : hists) {
762 hist->GetListOfFunctions()->Clear();
766 hists.at(0)->Draw(
"hist");
767 for(
unsigned int i = 1; i < hists.size(); i++) {
768 hists.at(i)->Draw(
"histsame");
774 for(
auto*
hist : hists) {
775 hist->GetXaxis()->UnZoom();
776 hist->GetYaxis()->UnZoom();
786 GH1D* ghist =
nullptr;
787 for(
auto*
hist : hists) {
788 if(
hist->InheritsFrom(GH1D::Class())) {
798 if(ghist !=
nullptr) {
799 GH1D* proj =
nullptr;
802 if(binlow > binhigh) {
803 std::swap(binlow, binhigh);
805 double value_low = ghist->GetXaxis()->GetBinLowEdge(binlow);
806 double value_high = ghist->GetXaxis()->GetBinLowEdge(binhigh);
809 double epsilon = 16 * (std::nextafter(value_low, INFINITY) - value_low);
810 value_low += epsilon;
814 double epsilon = 16 * (value_high - std::nextafter(value_high, -INFINITY));
815 value_high -= epsilon;
821 if(bg_binlow > bg_binhigh) {
822 std::swap(bg_binlow, bg_binhigh);
824 double bg_value_low = ghist->GetXaxis()->GetBinCenter(bg_binlow);
825 double bg_value_high = ghist->GetXaxis()->GetBinCenter(bg_binhigh);
832 proj = ghist->
Project(value_low, value_high);
834 if(proj !=
nullptr) {
842 GH1D* ghist =
nullptr;
843 for(
auto*
hist : hists) {
844 if(
hist->InheritsFrom(GH1D::Class())) {
850 if(ghist !=
nullptr) {
856 TH1* ghist = hists.at(0);
863 TIter iter(ghist->GetListOfFunctions());
864 while(TObject* o = iter.Next()) {
865 if(o->InheritsFrom(TF1::Class())) {
866 (
static_cast<TF1*
>(o))->
Draw(
"same");
880 for(
auto*
hist : hists) {
885 for(
auto*
hist : hists) {
896 GetContextMenu()->Action(hists.back()->GetYaxis(),
897 TAxis::Class()->GetMethodAny(
"SetRangeUser"));
899 double y1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetFirst());
900 double y2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetLast());
901 TIter iter(GetListOfPrimitives());
902 while(TObject* obj = iter.Next()) {
903 if(obj->InheritsFrom(TPad::Class())) {
904 TPad* pad =
static_cast<TPad*
>(obj);
905 TIter iter2(pad->GetListOfPrimitives());
906 while(TObject* obj2 = iter2.Next()) {
907 if(obj2->InheritsFrom(TH1::Class())) {
908 TH1*
hist =
static_cast<TH1*
>(obj2);
909 hist->GetYaxis()->SetRangeUser(y1, y2);
926 edited =
ShowPeaks(hists.data(), hists.size());
940 double ymax = hists.at(0)->GetMaximum();
941 double thresh = y1 / ymax;
942 double sigma = x2 - x1;
946 edited =
ShowPeaks(hists.data(), hists.size(), sigma, thresh);
953 edited =
ShowPeaks(hists.data(), hists.size());
967 double ymax = hists.at(0)->GetMaximum();
968 double thresh = y1 / ymax;
973 edited =
ShowPeaks(hists.data(), hists.size(), sigma, thresh);
978 int color = hists.at(0)->GetLineColor() + 1;
982 hists.at(0)->SetLineColor(
static_cast<Color_t
>(color));
1006 bool edited =
false;
1013 TString defaultName =
"cut";
1014 if(gROOT->FindObject(
"CUTG") ==
nullptr) {
1015 std::cout <<
"Something went wrong, can't find 'CUTG', did you initialize the cut beforehand? Or maybe you already pressed c?" << std::endl
1016 <<
"Current list of cuts is ";
1017 if(
fCuts.empty()) { std::cout <<
"empty"; }
1018 for(
auto* cut :
fCuts) {
1019 std::cout << cut->GetName() <<
" ";
1021 std::cout << std::endl;
1024 fCuts.push_back(
static_cast<TCutG*
>(gROOT->FindObject(
"CUTG")));
1026 std::cout <<
"Added cut to list of cuts: ";
1027 for(
auto* cut :
fCuts) {
1028 std::cout << cut->GetName() <<
" ";
1030 std::cout << std::endl;
1048 for(
auto*
hist : hists) {
1049 hist->GetXaxis()->SetRangeUser(x1, x2);
1050 hist->GetYaxis()->SetRangeUser(y1, y2);
1059 GetContextMenu()->Action(hists.back()->GetXaxis(),
1060 TAxis::Class()->GetMethodAny(
"SetRangeUser"));
1062 double x1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetFirst());
1063 double x2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetLast());
1064 TIter iter(GetListOfPrimitives());
1065 while(TObject* obj = iter.Next()) {
1066 if(obj->InheritsFrom(TPad::Class())) {
1067 TPad* pad =
static_cast<TPad*
>(obj);
1068 TIter iter2(pad->GetListOfPrimitives());
1069 while(TObject* obj2 = iter2.Next()) {
1070 if(obj2->InheritsFrom(TH1::Class())) {
1071 TH1*
hist =
static_cast<TH1*
>(obj2);
1072 hist->GetXaxis()->SetRangeUser(x1, x2);
1091 static int cutcounter = 0;
1092 auto* cut =
new TCutG(Form(
"_cut%i", cutcounter++), 9);
1106 double xdist = (x2 - x1) / 2.0;
1107 double ydist = (y2 - y1) / 2.0;
1110 cut->SetPoint(0, x1, y1);
1111 cut->SetPoint(1, x1, y1 + ydist);
1112 cut->SetPoint(2, x1, y2);
1113 cut->SetPoint(3, x1 + xdist, y2);
1114 cut->SetPoint(4, x2, y2);
1115 cut->SetPoint(5, x2, y2 - ydist);
1116 cut->SetPoint(6, x2, y1);
1117 cut->SetPoint(7, x2 - xdist, y1);
1118 cut->SetPoint(8, x1, y1);
1119 cut->SetLineColor(kBlack);
1120 hists.at(0)->GetListOfFunctions()->Add(cut);
1130 TString defaultName =
"cut";
1131 new TGInputDialog(
nullptr,
static_cast<TRootCanvas*
>(GetCanvasImp()),
"Enter name of cut", defaultName,
fCutName);
1135 gROOT->SetEditorMode(
"CutG");
1143 for(
auto*
hist : hists) {
1150 for(
auto*
hist : hists) {
1151 TH2* h =
static_cast<TH2*
>(
hist);
1152 h->GetXaxis()->UnZoom();
1153 h->GetYaxis()->UnZoom();
1159 GH2D* ghist =
nullptr;
1160 for(
auto*
hist : hists) {
1161 if(
hist->InheritsFrom(GH2Base::Class())) {
1167 if((ghist !=
nullptr) && (ghist->
GetProjections()->GetSize() != 0)) {
1178 for(
auto*
hist : hists) {
1183 for(
auto*
hist : hists) {
1194 GetContextMenu()->Action(hists.back()->GetYaxis(),
1195 TAxis::Class()->GetMethodAny(
"SetRangeUser"));
1197 double y1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetFirst());
1198 double y2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetLast());
1199 TIter iter(GetListOfPrimitives());
1200 while(TObject* obj = iter.Next()) {
1201 if(obj->InheritsFrom(TPad::Class())) {
1202 TPad* pad =
static_cast<TPad*
>(obj);
1203 TIter iter2(pad->GetListOfPrimitives());
1204 while(TObject* obj2 = iter2.Next()) {
1205 if(obj2->InheritsFrom(TH1::Class())) {
1206 TH1*
hist =
static_cast<TH1*
>(obj2);
1207 hist->GetYaxis()->SetRangeUser(y1, y2);
1222 TDirectory* oldDir = gDirectory;
1223 TString defaultName =
"CutFile.cuts";
1224 char* fileName =
new char[256];
1225 new TGInputDialog(
nullptr,
static_cast<TRootCanvas*
>(GetCanvasImp()),
"Enter file name to save cuts to", defaultName, fileName);
1226 if(strlen(fileName) == 0) {
1229 TFile f(fileName,
"update");
1231 std::cout <<
RESET_COLOR <<
"Failed to open file '" << fileName <<
"', not saving cuts!" << std::endl;
1234 std::cout <<
RESET_COLOR <<
"Writing the following cuts to '" << fileName <<
"':" << std::endl;
1235 for(
auto* cut :
fCuts) {
1236 std::cout << cut->GetName() << std::endl;
1245 GH2D* ghist =
nullptr;
1246 for(
auto*
hist : hists) {
1247 if(
hist->InheritsFrom(GH2Base::Class())) {
1253 if(ghist !=
nullptr) {
1256 if(phist !=
nullptr) {
1265 GH2D* ghist =
nullptr;
1266 for(
auto*
hist : hists) {
1267 if(
hist->InheritsFrom(GH2Base::Class())) {
1273 if(ghist !=
nullptr) {
1277 if(phist !=
nullptr) {
1286 GH2D* ghist =
nullptr;
1287 for(
auto*
hist : hists) {
1288 if(
hist->InheritsFrom(GH2Base::Class())) {
1294 if(ghist !=
nullptr) {
1297 if(phist !=
nullptr) {
1306 GH2D* ghist =
nullptr;
1307 for(
auto*
hist : hists) {
1308 if(
hist->InheritsFrom(GH2Base::Class())) {
1314 if(ghist !=
nullptr) {
1319 if(phist !=
nullptr) {
1329 if(GetLogz() != 0) {
1331 for(
auto*
hist : hists) {
1332 hist->GetZaxis()->UnZoom();
1334 TVirtualPad* cpad = gPad;
1340 for(
auto*
hist : hists) {
1341 if(
hist->GetZaxis()->GetXmin() < 0) {
1342 hist->GetZaxis()->SetRangeUser(0,
hist->GetYaxis()->GetXmax());
1345 TVirtualPad* cpad = gPad;