From b51275f245e57d8472d0dc2d98ef2ad6539c9a2c Mon Sep 17 00:00:00 2001 From: clantz <clantz@gitlab.cern.ch> Date: Thu, 5 Sep 2019 10:45:33 -0500 Subject: [PATCH] Dissected the filename to make the output land next to the executable --- Analysis/plotHisto.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Analysis/plotHisto.cc b/Analysis/plotHisto.cc index 89e5588..8c55a64 100644 --- a/Analysis/plotHisto.cc +++ b/Analysis/plotHisto.cc @@ -4,17 +4,22 @@ #include "TTree.h" #include "TStyle.h" #include <iostream> +#include <string> using namespace std; int main(int argc, char *argv[]){ if(argc == 0) return 0; - TFile *f = new TFile( Form("%s.root",argv[1]) ); + TFile *f = new TFile( argv[1] ); if(f->IsZombie()){ cout << Form("%s.root does not exist... exiting",argv[1]) << endl; return 0; } + string name = argv[1]; + if(name.find("/") != string::npos) name.erase( 0, name.find_last_of("/") + 1 ); + if(name.find(".") != string::npos) name.erase( name.find_last_of(".") ); + TTree *t = (TTree*)f->Get("lightGuide"); double x,y; t->SetBranchAddress("X",&x); @@ -32,7 +37,7 @@ int main(int argc, char *argv[]){ gStyle->SetOptStat(0); h->Scale(1.0/h->GetMaximum()); h->Draw("COLZ"); - c->Print( Form("%s.png",argv[1]) ); + c->Print( Form("%s.png",name.c_str()) ); delete f; return 1; } -- GitLab