/[PAMELA software]/quicklook/calo/FQLOOK/src/FCaloQLOOK.cc
ViewVC logotype

Diff of /quicklook/calo/FQLOOK/src/FCaloQLOOK.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mocchiut, Thu Mar 9 16:14:33 2006 UTC revision 1.12 by mocchiut, Tue Aug 11 14:20:05 2009 UTC
# Line 8  Line 8 
8  //  //
9  // 0.00 - 1.00 : working.  // 0.00 - 1.00 : working.
10  //  //
11  #include <TString.h>  #include <TSystem.h>
12  #include <iostream>  #include <iostream>
13    #include <sstream>
14    #include <cstdlib>
15    #include <sys/types.h>
16    #include <unistd.h>
17    #include <stdio.h>
18  //  //
19  extern void FCaloQLOOK(TString ,  int , int , TString , TString );  extern void FCaloQLOOK(TString, int, int, TString, TString, Bool_t, Bool_t);
20  extern void info();  extern void info();
21    extern void stringcopy(TString& , const TString& , Int_t , Int_t );
22  using namespace std;  using namespace std;
23  //  //
24    void usage(){
25      printf("\nUsage:\n\n FCaloQLOOK [-name] file [OPTIONS] \n");
26      printf("\n file             must be in the form: /path/to/filesfromyoda/ZZZ_XXX_YYYYY_cln2.root  \n");
27      printf(  "                  if in the first position \"-name\" can be omitted. \n");  
28      printf("\n OPTIONS: \n");  
29      printf("\n -v                  be verbose \n");  
30      printf(  " -fromev from_event  first event to analyze [default = 0] \n");
31      printf(  " -toev to_event      last event to analyze  [default = 0] \n");
32      printf(  " -oudDir output_dir  path of the output directory [default = ./] (with or without final '/') \n");
33      printf(  " -format format      format for output file (without . )[default = png] \n");
34      printf(  " -interactive        shows figures on the screen [default = non-interactive] \n");
35      printf(  " -wait               wait for canvas to be closed before going on [default = don't wait] \n");
36      printf("\nExamples: ");
37      printf("\n\nFCaloQLOOK /home/pamela/filesfromyoda/dw_050301_00100.root \n");
38      printf("\nFCaloQLOOK -v -name /home/pamela/filesfromyoda/dw_050301_00100.root \n");
39      printf("\nFCaloQLOOK /home/pamela/filesfromyoda/DW_050523_01600.root -v -fromev 0 -toev 0 -outDir /tmp/ -format gif \n\n");
40    }
41    
42  int main(int numinp, char *inps[]){  int main(int numinp, char *inps[]){
43    TString name;    TString name;
44    TString outdir;    TString outdir = "./";
45    TString format;    TString format = "png";
46    int fromev;    int fromev = 0;
47    int toev;    int toev = 0;
48    if ( numinp != 6 ){    int nul = 0;
49      if ( numinp > 1 ){    bool beverbose = false;
50        if ( !strcmp(inps[1],"--version") ){    Bool_t iactive = false;
51      Bool_t w4i = false;
52      //
53      if ( numinp > 1 ){
54        name = (TString)inps[1];
55        for ( int i = 0; i < numinp; i++ ){
56          
57          if ( !strcmp(inps[i],"--version") ){
58          info();          info();
59          return(0);          return(0);
60        };        };
61          if ( !strcmp(inps[i],"-h") || !strcmp(inps[i],"--help") ){
62            usage();
63            return(0);
64          };
65          if ( !strcmp(inps[i],"-name") ) {
66            if ( numinp-1 < i+1 ){
67              usage();
68              exit(-3);
69            };
70            name = (TString)inps[i+1];
71          };
72          if ( !strcmp(inps[i],"-outDir") ) {
73            if ( numinp-1 < i+1 ){
74              usage();
75              exit(-3);
76            };
77            outdir = (TString)inps[i+1];
78          };
79          if ( !strcmp(inps[i],"-format") ) {
80            if ( numinp-1 < i+1 ){
81              usage();
82              exit(-3);
83            };
84            format = (TString)inps[i+1];
85          };
86    
87          if ( !strcmp(inps[i],"-fromev") ) {
88            if ( numinp-1 < i+1 ){
89              usage();
90              exit(-3);
91            };
92            fromev = atoi(inps[i+1]);
93          };
94          if ( !strcmp(inps[i],"-toev") ) {
95            if ( numinp-1 < i+1 ){
96              usage();
97              exit(-3);
98            };
99            toev = atoi(inps[i+1]);
100          };    
101          if ( !strcmp(inps[i],"-interactive") ) {
102            iactive = true;
103          };    
104          if ( !strcmp(inps[i],"-wait") ) {
105            w4i = true;
106          };    
107          if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;
108      };      };
     printf("\nUsage:\n\n FCaloQLOOK file from_event to_event output_dir figure_format \n");  
     printf("\n - file             must be in the form: /path/to/filesfromyoda/dw_000000_00000/  \n");  
     printf(  " - from_event       is an integer (progressive number) \n");  
     printf(  " - to_event         is an integer (progressive number) \n");  
     printf(  " - output_dir       directory where to store figures \n");  
     printf(  " - figure format    any format recognized by ROOT (eps,gif,...)\n");  
     printf("\nExample: \n\nFCaloQLOOK /home/pamela/filesfromyoda/dw_050301_00100/ 0 0 /tmp/ eps \n\n");  
     return(0);  
     //  
109    } else {    } else {
110      printf("\n Welcome to FCaloQLOOK! \n");      //
111      name = (TString)inps[1];      // no input parameters exit with error, we need at least the run id.
112      fromev = atoi(inps[2]);      //
113      toev = atoi(inps[3]);      usage();
114      outdir = (TString)inps[4];      return(0);    
     format = (TString)inps[5];  
115    };    };
116    //    //
117    FCaloQLOOK(name,fromev,toev,outdir,format);    stringstream figsave;    
118      if ( !beverbose ){
119        //
120        const string fil = gSystem->BaseName(name.Data());
121        Int_t posiz = fil.find(".root");
122        //
123        TString file2;
124        if ( posiz == -1 ){
125          file2 = gSystem->BaseName(name.Data());
126        } else {
127          Int_t posiz2 = 0;
128          stringcopy(file2,gSystem->BaseName(name.Data()),posiz2,posiz);
129        };
130        const char *figrec = file2;
131        //
132        const char *outDir = outdir;
133        figsave.str("");
134        figsave << outDir << "/" ;
135        figsave << figrec << "_CaloQLOOK.txt";
136        //
137        // redirect to /dev/null the stdout and stderr
138        //
139        nul = open(figsave.str().c_str(), O_CREAT | O_RDWR,S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH);
140        dup2(nul,1);
141        dup2(nul,2);
142      };
143      printf("\n Welcome to FCaloQLOOK! v1r23 \n");
144      //
145      FCaloQLOOK(name,fromev,toev,outdir,format,iactive,w4i);
146      //
147      if ( !beverbose ) close(nul);
148    //    //
149    return(0);    return(0);
150  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.23