--- calo/flight/FQLOOK/src/FCaloQLOOK.cc	2006/08/03 15:25:47	1.4
+++ calo/flight/FQLOOK/src/FCaloQLOOK.cc	2009/08/11 14:20:05	1.12
@@ -10,12 +10,15 @@
 //
 #include <TSystem.h>
 #include <iostream>
+#include <sstream>
+#include <cstdlib>
 #include <sys/types.h>
 #include <unistd.h>
 #include <stdio.h>
 //
-extern void FCaloQLOOK(TString, int, int, TString, TString);
+extern void FCaloQLOOK(TString, int, int, TString, TString, Bool_t, Bool_t);
 extern void info();
+extern void stringcopy(TString& , const TString& , Int_t , Int_t );
 using namespace std;
 //
 void usage(){
@@ -28,6 +31,8 @@
   printf(  " -toev to_event      last event to analyze  [default = 0] \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(  " -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("\nExamples: ");
   printf("\n\nFCaloQLOOK /home/pamela/filesfromyoda/dw_050301_00100.root \n");
   printf("\nFCaloQLOOK -v -name /home/pamela/filesfromyoda/dw_050301_00100.root \n");
@@ -36,12 +41,14 @@
 
 int main(int numinp, char *inps[]){
   TString name;
-  TString outdir = "";
+  TString outdir = "./";
   TString format = "png";
   int fromev = 0;
   int toev = 0;
   int nul = 0;
   bool beverbose = false;
+  Bool_t iactive = false;
+  Bool_t w4i = false;
   //
   if ( numinp > 1 ){
     name = (TString)inps[1];
@@ -91,6 +98,12 @@
 	};
 	toev = atoi(inps[i+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;
     };
   } else {
@@ -101,17 +114,35 @@
     return(0);    
   };
   //
+  stringstream figsave;    
   if ( !beverbose ){
     //
+    const string fil = gSystem->BaseName(name.Data());
+    Int_t posiz = fil.find(".root");
+    //
+    TString file2;
+    if ( posiz == -1 ){
+      file2 = gSystem->BaseName(name.Data());
+    } else {
+      Int_t posiz2 = 0;
+      stringcopy(file2,gSystem->BaseName(name.Data()),posiz2,posiz);
+    };
+    const char *figrec = file2;
+    //
+    const char *outDir = outdir;
+    figsave.str("");
+    figsave << outDir << "/" ;
+    figsave << figrec << "_CaloQLOOK.txt";
+    //
     // redirect to /dev/null the stdout and stderr
     //
-    nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
+    nul = open(figsave.str().c_str(), O_CREAT | O_RDWR,S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH);
     dup2(nul,1);
     dup2(nul,2);
   };
-  printf("\n Welcome to FCaloQLOOK! \n");
+  printf("\n Welcome to FCaloQLOOK! v1r23 \n");
   //
-  FCaloQLOOK(name,fromev,toev,outdir,format);
+  FCaloQLOOK(name,fromev,toev,outdir,format,iactive,w4i);
   //
   if ( !beverbose ) close(nul);
   //