--- quicklook/calo/FQLOOK/src/FCaloCHKCALIB.cc 2006/03/09 16:14:33 1.1.1.1 +++ quicklook/calo/FQLOOK/src/FCaloCHKCALIB.cc 2014/01/17 15:10:30 1.7 @@ -8,47 +8,121 @@ // // 0.00 - 1.00 : working. // -#include +#include #include +#include +#include +#include +#include +#include +#include // -extern void FCaloCHKCALIB(TString, Long64_t, TString, int, TString); +extern void FCaloCHKCALIB(TString, Long64_t, TString, int, TString, Bool_t, Bool_t); extern void info(); using namespace std; // +void usage(){ + printf("\nUsage:\n\n FCaloCHKCALIB [-name] file [OPTIONS] \n"); + printf("\n file must be in the form: /path/to/filesfromyoda/ZZZ_XXX_YYYYY_cln2.root \n"); + printf( " if in the first position \"-name\" can be omitted. \n"); + printf("\n OPTIONS: \n"); + printf("\n -v be verbose \n"); + printf( " -entry entry calibration entry to analyze [default = 0, all] \n"); + printf( " -interactive shows figures on the screen [default = non-interactive] \n"); + printf( " -wait wait for canvas to be closed before going on [default = don't wait] \n"); + printf( " -matra draw the strip rms in a box plot [default: do not draw] \n"); + printf( " -oudDir output_dir path of the output directory [default = ./] (with or without final '/') \n"); + printf( " -format format format for output file (without . )[default = png] \n"); + printf("\nExamples: "); + printf("\n\nFCaloCHKCALIB /home/pamela/filesfromyoda/dw_050301_00100.root \n"); + printf("\nFCaloCHKCALIB -v -name /home/pamela/filesfromyoda/dw_050301_00100.root \n"); + printf("\nFCaloCHKCALIB /home/pamela/filesfromyoda/DW_050523_01600.root -v -entry 2 -matra -outDir /tmp/ -format gif \n\n"); +} +// int main(int numinp, char *inps[]){ TString name; - TString outdir; - TString format; - int matra; - Long64_t calibno; - if ( numinp != 6 ){ - if ( numinp > 1 ){ - if ( !strcmp(inps[1],"--version") ){ + TString outdir = "./"; + TString format = "png"; + int matra = 0; + Long64_t calibno = 0; + char *pEnd; + int nul = 0; + bool beverbose = false; + Bool_t iactive = false; + Bool_t w4i = false; + + if ( numinp > 1 ){ + name = (TString)inps[1]; + for ( int i = 0; i < numinp; i++ ){ + + if ( !strcmp(inps[i],"--version") ){ info(); return(0); }; + if ( !strcmp(inps[i],"-h") || !strcmp(inps[i],"--help") ){ + usage(); + return(0); + }; + if ( !strcmp(inps[i],"-name") ) { + if ( numinp-1 < i+1 ){ + usage(); + exit(-3); + }; + name = (TString)inps[i+1]; + }; + if ( !strcmp(inps[i],"-outDir") ) { + if ( numinp-1 < i+1 ){ + usage(); + exit(-3); + }; + outdir = (TString)inps[i+1]; + }; + if ( !strcmp(inps[i],"-format") ) { + if ( numinp-1 < i+1 ){ + usage(); + exit(-3); + }; + format = (TString)inps[i+1]; + }; + + if ( !strcmp(inps[i],"-entry") ) { + if ( numinp-1 < i+1 ){ + usage(); + exit(-3); + }; + calibno = strtoull(inps[i+1],&pEnd,0); + }; + if ( !strcmp(inps[i],"-matra") ) { + matra = 1; + }; + if ( !strcmp(inps[i],"-interactive") ) { + iactive = true; + }; + if ( !strcmp(inps[i],"-wait") ) { + w4i = true; + }; + if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; }; - printf("\nUsage:\n\n FCaloCHKCALIB file calib_number output_directory matra figure_format \n"); - printf("\n - file must be in the form: /path/to/filesfromyoda/dw_000000_00000/ \n"); - printf( " - calib_number is an integer (progressive calibration number), 0 = all \n"); - printf( " - output_dir directory where to store figures \n"); - printf( " - matra integer, 1 to print the strip rms in a box plot 0 to skip it\n"); - printf( " - figure format any format recognized by ROOT (eps,gif,...)\n"); - printf("\nExample: \n\nFCaloCHKCALIB /home/pamela/filesfromyoda/dw_050301_00100/ 0 /tmp/ 0 eps \n\n"); - return(0); - // } else { - printf("\n Welcome to FCaloCHKCALIB! \n"); - name = (TString)inps[1]; - char *pEnd; - calibno = strtoull(inps[2],&pEnd,0); - // calibno = atoi(inps[2]); - outdir = (TString)inps[3]; - matra = atoi(inps[4]); - format = (TString)inps[5]; + // + // no input parameters exit with error, we need at least the run id. + // + usage(); + return(0); + }; + // + if ( !beverbose ){ + // + // redirect to /dev/null the stdout and stderr + // + nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE); + dup2(nul,1); + dup2(nul,2); }; + printf("\n Welcome to FCaloCHKCALIB! \n"); // - FCaloCHKCALIB(name,calibno,outdir,matra,format); + FCaloCHKCALIB(name,calibno,outdir,matra,format,iactive,w4i); // + if ( !beverbose ) close(nul); return(0); }