620      new GPopup(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), 500, 200);
 
  629            for(
auto* 
hist : hists) {
 
  634            for(
auto* 
hist : hists) {
 
  645      GetContextMenu()->Action(hists.back()->GetXaxis(),
 
  646                               TAxis::Class()->GetMethodAny(
"SetRangeUser"));
 
  648         double x1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetFirst());
 
  649         double x2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetLast());
 
  650         TIter  iter(GetListOfPrimitives());
 
  651         while(TObject* obj = iter.Next()) {
 
  652            if(obj->InheritsFrom(TPad::Class())) {
 
  653               TPad* pad = 
static_cast<TPad*
>(obj);
 
  654               TIter iter2(pad->GetListOfPrimitives());
 
  655               while(TObject* obj2 = iter2.Next()) {
 
  656                  if(obj2->InheritsFrom(TH1::Class())) {
 
  657                     TH1* 
hist = 
static_cast<TH1*
>(obj2);
 
  658                     hist->GetXaxis()->SetRangeUser(x1, x2);
 
  673         std::cout << 
"x low = " << 
fMarkers.at(
fMarkers.size() - 2)->GetLocalX() << 
"\t\txhigh = " << 
fMarkers.back()->GetLocalX() << std::endl;
 
  682         std::cout << 
"x low = " << 
fMarkers.at(
fMarkers.size() - 2)->GetLocalX() << 
"\t\txhigh = " << 
fMarkers.back()->GetLocalX() << std::endl;
 
  700         if(binlow > binhigh) {
 
  701            std::swap(binlow, binhigh);
 
  703         double xlow  = hists.back()->GetXaxis()->GetBinLowEdge(binlow);
 
  704         double xhigh = hists.back()->GetXaxis()->GetBinLowEdge(binhigh);
 
  707            double epsilon = 16 * (std::nextafter(xlow, INFINITY) - xlow);
 
  712            double epsilon = 16 * (xhigh - std::nextafter(xhigh, -INFINITY));
 
  717            hists.back()->Integral(hists.back()->GetXaxis()->FindBin(xlow), hists.back()->GetXaxis()->FindBin(xhigh));
 
  718         std::cout << 
BLUE << std::endl
 
  719                   << 
"\tSum [" << xlow << 
" : " << xhigh << 
"] = " << sum << 
RESET_COLOR << std::endl;
 
  730         for(
auto* 
hist : hists) {
 
  731            hist->GetYaxis()->UnZoom();
 
  736         for(
auto* 
hist : hists) {
 
  737            if(
hist->GetYaxis()->GetXmin() < 0) {
 
  738               hist->GetYaxis()->SetRangeUser(0, 
hist->GetYaxis()->GetXmax());
 
  754      for(
auto* 
hist : hists) {
 
  755         hist->GetListOfFunctions()->Clear();
 
  757      for(
auto* 
hist : hists) {
 
  765      for(
auto* 
hist : hists) {
 
  766         hist->GetListOfFunctions()->Clear();
 
  770      hists.at(0)->Draw(
"hist");
 
  771      for(
unsigned int i = 1; i < hists.size(); i++) {
 
  772         hists.at(i)->Draw(
"histsame");
 
  778      for(
auto* 
hist : hists) {
 
  779         hist->GetXaxis()->UnZoom();
 
  780         hist->GetYaxis()->UnZoom();
 
  790      GH1D* ghist = 
nullptr;
 
  791      for(
auto* 
hist : hists) {
 
  792         if(
hist->InheritsFrom(GH1D::Class())) {
 
  802      if(ghist != 
nullptr) {
 
  803         GH1D* proj    = 
nullptr;
 
  806         if(binlow > binhigh) {
 
  807            std::swap(binlow, binhigh);
 
  809         double value_low  = ghist->GetXaxis()->GetBinLowEdge(binlow);
 
  810         double value_high = ghist->GetXaxis()->GetBinLowEdge(binhigh);
 
  813            double epsilon = 16 * (std::nextafter(value_low, INFINITY) - value_low);
 
  814            value_low += epsilon;
 
  818            double epsilon = 16 * (value_high - std::nextafter(value_high, -INFINITY));
 
  819            value_high -= epsilon;
 
  825            if(bg_binlow > bg_binhigh) {
 
  826               std::swap(bg_binlow, bg_binhigh);
 
  828            double bg_value_low  = ghist->GetXaxis()->GetBinCenter(bg_binlow);
 
  829            double bg_value_high = ghist->GetXaxis()->GetBinCenter(bg_binhigh);
 
  836            proj = ghist->
Project(value_low, value_high);
 
  838         if(proj != 
nullptr) {
 
  846      GH1D* ghist = 
nullptr;
 
  847      for(
auto* 
hist : hists) {
 
  848         if(
hist->InheritsFrom(GH1D::Class())) {
 
  854      if(ghist != 
nullptr) {
 
  860      TH1* ghist = hists.at(0);
 
  867         TIter iter(ghist->GetListOfFunctions());
 
  868         while(TObject* o = iter.Next()) {
 
  869            if(o->InheritsFrom(TF1::Class())) {
 
  870               (
static_cast<TF1*
>(o))->
Draw(
"same");
 
  884            for(
auto* 
hist : hists) {
 
  889            for(
auto* 
hist : hists) {
 
  900      GetContextMenu()->Action(hists.back()->GetYaxis(),
 
  901                               TAxis::Class()->GetMethodAny(
"SetRangeUser"));
 
  903         double y1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetFirst());
 
  904         double y2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetLast());
 
  905         TIter  iter(GetListOfPrimitives());
 
  906         while(TObject* obj = iter.Next()) {
 
  907            if(obj->InheritsFrom(TPad::Class())) {
 
  908               TPad* pad = 
static_cast<TPad*
>(obj);
 
  909               TIter iter2(pad->GetListOfPrimitives());
 
  910               while(TObject* obj2 = iter2.Next()) {
 
  911                  if(obj2->InheritsFrom(TH1::Class())) {
 
  912                     TH1* 
hist = 
static_cast<TH1*
>(obj2);
 
  913                     hist->GetYaxis()->SetRangeUser(y1, y2);
 
  930         edited = 
ShowPeaks(hists.data(), hists.size());
 
  944         double ymax   = hists.at(0)->GetMaximum();
 
  945         double thresh = y1 / ymax;
 
  946         double sigma  = x2 - x1;
 
  950         edited = 
ShowPeaks(hists.data(), hists.size(), sigma, thresh);
 
  957         edited = 
ShowPeaks(hists.data(), hists.size());
 
  971         double ymax   = hists.at(0)->GetMaximum();
 
  972         double thresh = y1 / ymax;
 
  977         edited = 
ShowPeaks(hists.data(), hists.size(), sigma, thresh);
 
  982      int color = hists.at(0)->GetLineColor() + 1;
 
  986      hists.at(0)->SetLineColor(
static_cast<Color_t
>(color));
 
 
 1010   bool              edited = 
false;
 
 1017      TString defaultName = 
"cut";
 
 1018      if(gROOT->FindObject(
"CUTG") == 
nullptr) {
 
 1019         std::cout << 
"Something went wrong, can't find 'CUTG', did you initialize the cut beforehand? Or maybe you already pressed c?" << std::endl
 
 1020                   << 
"Current list of cuts is ";
 
 1021         if(
fCuts.empty()) { std::cout << 
"empty"; }
 
 1022         for(
auto* cut : 
fCuts) {
 
 1023            std::cout << cut->GetName() << 
" ";
 
 1025         std::cout << std::endl;
 
 1028      fCuts.push_back(
static_cast<TCutG*
>(gROOT->FindObject(
"CUTG")));
 
 1030      std::cout << 
"Added cut to list of cuts: ";
 
 1031      for(
auto* cut : 
fCuts) {
 
 1032         std::cout << cut->GetName() << 
" ";
 
 1034      std::cout << std::endl;
 
 1052         for(
auto* 
hist : hists) {
 
 1053            hist->GetXaxis()->SetRangeUser(x1, x2);
 
 1054            hist->GetYaxis()->SetRangeUser(y1, y2);
 
 1063      GetContextMenu()->Action(hists.back()->GetXaxis(),
 
 1064                               TAxis::Class()->GetMethodAny(
"SetRangeUser"));
 
 1066         double x1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetFirst());
 
 1067         double x2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetXaxis()->GetLast());
 
 1068         TIter  iter(GetListOfPrimitives());
 
 1069         while(TObject* obj = iter.Next()) {
 
 1070            if(obj->InheritsFrom(TPad::Class())) {
 
 1071               TPad* pad = 
static_cast<TPad*
>(obj);
 
 1072               TIter iter2(pad->GetListOfPrimitives());
 
 1073               while(TObject* obj2 = iter2.Next()) {
 
 1074                  if(obj2->InheritsFrom(TH1::Class())) {
 
 1075                     TH1* 
hist = 
static_cast<TH1*
>(obj2);
 
 1076                     hist->GetXaxis()->SetRangeUser(x1, x2);
 
 1095         static int cutcounter = 0;
 
 1096         auto*      cut        = 
new TCutG(Form(
"_cut%i", cutcounter++), 9);
 
 1110         double xdist = (x2 - x1) / 2.0;
 
 1111         double ydist = (y2 - y1) / 2.0;
 
 1114         cut->SetPoint(0, x1, y1);
 
 1115         cut->SetPoint(1, x1, y1 + ydist);
 
 1116         cut->SetPoint(2, x1, y2);
 
 1117         cut->SetPoint(3, x1 + xdist, y2);
 
 1118         cut->SetPoint(4, x2, y2);
 
 1119         cut->SetPoint(5, x2, y2 - ydist);
 
 1120         cut->SetPoint(6, x2, y1);
 
 1121         cut->SetPoint(7, x2 - xdist, y1);
 
 1122         cut->SetPoint(8, x1, y1);
 
 1123         cut->SetLineColor(kBlack);
 
 1124         hists.at(0)->GetListOfFunctions()->Add(cut);
 
 1134      TString defaultName = 
"cut";
 
 1135      new TGInputDialog(
nullptr, 
static_cast<TRootCanvas*
>(GetCanvasImp()), 
"Enter name of cut", defaultName, 
fCutName);
 
 1139      gROOT->SetEditorMode(
"CutG");
 
 1147      for(
auto* 
hist : hists) {
 
 1154      for(
auto* 
hist : hists) {
 
 1155         TH2* h = 
static_cast<TH2*
>(
hist);
 
 1156         h->GetXaxis()->UnZoom();
 
 1157         h->GetYaxis()->UnZoom();
 
 1163      GH2D* ghist = 
nullptr;
 
 1164      for(
auto* 
hist : hists) {
 
 1165         if(
hist->InheritsFrom(GH2Base::Class())) {
 
 1171      if((ghist != 
nullptr) && (ghist->
GetProjections()->GetSize() != 0)) {
 
 1182            for(
auto* 
hist : hists) {
 
 1187            for(
auto* 
hist : hists) {
 
 1198      GetContextMenu()->Action(hists.back()->GetYaxis(),
 
 1199                               TAxis::Class()->GetMethodAny(
"SetRangeUser"));
 
 1201         double y1 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetFirst());
 
 1202         double y2 = hists.back()->GetXaxis()->GetBinCenter(hists.back()->GetYaxis()->GetLast());
 
 1203         TIter  iter(GetListOfPrimitives());
 
 1204         while(TObject* obj = iter.Next()) {
 
 1205            if(obj->InheritsFrom(TPad::Class())) {
 
 1206               TPad* pad = 
static_cast<TPad*
>(obj);
 
 1207               TIter iter2(pad->GetListOfPrimitives());
 
 1208               while(TObject* obj2 = iter2.Next()) {
 
 1209                  if(obj2->InheritsFrom(TH1::Class())) {
 
 1210                     TH1* 
hist = 
static_cast<TH1*
>(obj2);
 
 1211                     hist->GetYaxis()->SetRangeUser(y1, y2);
 
 1226      TDirectory* oldDir      = gDirectory;
 
 1227      TString     defaultName = 
"CutFile.cuts";
 
 1228      char*       fileName    = 
new char[256];
 
 1229      new TGInputDialog(
nullptr, 
static_cast<TRootCanvas*
>(GetCanvasImp()), 
"Enter file name to save cuts to", defaultName, fileName);
 
 1230      if(strlen(fileName) == 0) {
 
 1233      TFile f(fileName, 
"update");
 
 1235         std::cout << 
RESET_COLOR << 
"Failed to open file '" << fileName << 
"', not saving cuts!" << std::endl;
 
 1238      std::cout << 
RESET_COLOR << 
"Writing the following cuts to '" << fileName << 
"':" << std::endl;
 
 1239      for(
auto* cut : 
fCuts) {
 
 1240         std::cout << cut->GetName() << std::endl;
 
 1249      GH2D* ghist = 
nullptr;
 
 1250      for(
auto* 
hist : hists) {
 
 1251         if(
hist->InheritsFrom(GH2Base::Class())) {
 
 1257      if(ghist != 
nullptr) {
 
 1260         if(phist != 
nullptr) {
 
 1269      GH2D* ghist = 
nullptr;
 
 1270      for(
auto* 
hist : hists) {
 
 1271         if(
hist->InheritsFrom(GH2Base::Class())) {
 
 1277      if(ghist != 
nullptr) {
 
 1281         if(phist != 
nullptr) {
 
 1290      GH2D* ghist = 
nullptr;
 
 1291      for(
auto* 
hist : hists) {
 
 1292         if(
hist->InheritsFrom(GH2Base::Class())) {
 
 1298      if(ghist != 
nullptr) {
 
 1301         if(phist != 
nullptr) {
 
 1310      GH2D* ghist = 
nullptr;
 
 1311      for(
auto* 
hist : hists) {
 
 1312         if(
hist->InheritsFrom(GH2Base::Class())) {
 
 1318      if(ghist != 
nullptr) {
 
 1323         if(phist != 
nullptr) {
 
 1333      if(GetLogz() != 0) {
 
 1335         for(
auto* 
hist : hists) {
 
 1336            hist->GetZaxis()->UnZoom();
 
 1338         TVirtualPad* cpad = gPad;
 
 1344         for(
auto* 
hist : hists) {
 
 1345            if(
hist->GetZaxis()->GetXmin() < 0) {
 
 1346               hist->GetZaxis()->SetRangeUser(0, 
hist->GetYaxis()->GetXmax());
 
 1349         TVirtualPad* cpad = gPad;