--- calo/flight/FUTILITIES/macros/FCaloFUNCTIONS.cxx 2006/03/22 15:07:47 1.1 +++ calo/flight/FUTILITIES/macros/FCaloFUNCTIONS.cxx 2008/09/22 20:18:45 1.3 @@ -33,6 +33,7 @@ #include #include #include +#include // #include #include @@ -304,17 +305,33 @@ } TString getFilename(const TString filename){ - const string fil = (const char*)filename; - Int_t posiz = fil.find("dw_"); - if ( posiz == -1 ) posiz = fil.find("DW_"); - if ( posiz == -1 ) return 0; - Int_t posiz2 = posiz+13; - TString file2; - stringcopy(file2,filename,posiz,posiz2); - TString pdat(".dat"); - stringappend(file2,pdat); - return file2; + // + const string fil = gSystem->BaseName(filename.Data()); + Int_t posiz = fil.find(".root"); + // + TString file2; + if ( posiz == -1 ){ + file2 = gSystem->BaseName(filename.Data()); + } else { + Int_t posiz2 = 0; + stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz); + TString pdat(".pam"); + stringappend(file2,pdat); + }; + return file2; } +// TString getFilename(const TString filename){ +// const string fil = (const char*)filename; +// Int_t posiz = fil.find("dw_"); +// if ( posiz == -1 ) posiz = fil.find("DW_"); +// if ( posiz == -1 ) return 0; +// Int_t posiz2 = posiz+13; +// TString file2; +// stringcopy(file2,filename,posiz,posiz2); +// TString pdat(".dat"); +// stringappend(file2,pdat); +// return file2; +// } Int_t fetchpreviousfile(TString ffile, Int_t s){ const char *file = ffile; @@ -755,7 +772,7 @@ string fil = (const char *)filename; Int_t posiz = fil.find("dw_"); if ( posiz == -1 ) posiz = fil.find("DW_"); - if ( posiz == -1 ) return(0); + if ( posiz == -1 ) return("unkwnown.root"); Int_t spos = posiz; Int_t epos = posiz+15; TString tmptempf; @@ -778,7 +795,7 @@ string fil = (const char *)filename; Int_t posiz = fil.find("dw_"); if ( posiz == -1 ) posiz = fil.find("DW_"); - if ( posiz == -1 ) return(0); + if ( posiz == -1 ) return("unknown.root"); Int_t spos = posiz; Int_t epos = posiz+13; TString tmptempf; @@ -1323,22 +1340,33 @@ } void PrintFigure(TString filename, TString outDir, TString figty, TString saveas, TCanvas& figure) { - const string fil = (const char*)filename; - Int_t posiz = fil.find("dw_"); - if ( posiz == -1 ) posiz = fil.find("DW_"); - Int_t posiz2 = posiz+13; - TString file2; - stringcopy(file2,filename,posiz,posiz2); - // - const char *figrec = file2; - stringstream figsave; - figsave.str(""); - figsave << outDir.Data() << "/"; - figsave << figrec << "_"; - figsave << figty.Data() << "."; - figsave << saveas.Data(); - figure.SaveAs(figsave.str().c_str()); - return; + // + const string fil = gSystem->BaseName(filename.Data()); + Int_t posiz = fil.find(".root"); + // + TString file2; + if ( posiz == -1 ){ + file2 = gSystem->BaseName(filename.Data()); + } else { + Int_t posiz2 = 0; + stringcopy(file2,gSystem->BaseName(filename.Data()),posiz2,posiz); + }; +// const string fil = (const char*)filename; +// Int_t posiz = fil.find("dw_"); +// if ( posiz == -1 ) posiz = fil.find("DW_"); +// Int_t posiz2 = posiz+13; +// TString file2; +// stringcopy(file2,filename,posiz,posiz2); + // + const char *figrec = file2; + stringstream figsave; + figsave.str(""); + figsave << outDir.Data() << "/"; + figsave << figrec << "_"; + figsave << figty.Data() << "."; + figsave << saveas.Data(); + figure.SaveAs(figsave.str().c_str()); + return; } Double_t langaufun(Double_t *x, Double_t *par) {