/[PAMELA software]/calo/flight/FQLOOK/src/FCaloCHKCALIB.cc
ViewVC logotype

Annotation of /calo/flight/FQLOOK/src/FCaloCHKCALIB.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download)
Fri Jan 17 15:10:30 2014 UTC (10 years, 10 months ago) by mocchiut
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +2 -0 lines
Compilation warnings using GCC4.7 fixed

1 mocchiut 1.1 //
2     // CaloCHKCALIB.cc -- standalone program to call the CaloCHKCALIB macro.
3     // by Emiliano Mocchiutti
4     //
5     // Version 1.00 (2005/08/16)
6     //
7     // Changelog:
8     //
9     // 0.00 - 1.00 : working.
10     //
11 mocchiut 1.2 #include <TSystem.h>
12 mocchiut 1.1 #include <iostream>
13 mocchiut 1.2 #include <sys/types.h>
14 mocchiut 1.6 #include <cstdlib>
15 mocchiut 1.2 #include <unistd.h>
16     #include <stdio.h>
17 mocchiut 1.7 #include <sys/stat.h>
18     #include <cstdlib>
19 mocchiut 1.1 //
20 mocchiut 1.4 extern void FCaloCHKCALIB(TString, Long64_t, TString, int, TString, Bool_t, Bool_t);
21 mocchiut 1.1 extern void info();
22     using namespace std;
23     //
24 mocchiut 1.2 void usage(){
25 mocchiut 1.3 printf("\nUsage:\n\n FCaloCHKCALIB [-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( " -entry entry calibration entry to analyze [default = 0, all] \n");
31 mocchiut 1.4 printf( " -interactive shows figures on the screen [default = non-interactive] \n");
32     printf( " -wait wait for canvas to be closed before going on [default = don't wait] \n");
33 mocchiut 1.3 printf( " -matra draw the strip rms in a box plot [default: do not draw] \n");
34     printf( " -oudDir output_dir path of the output directory [default = ./] (with or without final '/') \n");
35 mocchiut 1.4 printf( " -format format format for output file (without . )[default = png] \n");
36 mocchiut 1.3 printf("\nExamples: ");
37     printf("\n\nFCaloCHKCALIB /home/pamela/filesfromyoda/dw_050301_00100.root \n");
38     printf("\nFCaloCHKCALIB -v -name /home/pamela/filesfromyoda/dw_050301_00100.root \n");
39     printf("\nFCaloCHKCALIB /home/pamela/filesfromyoda/DW_050523_01600.root -v -entry 2 -matra -outDir /tmp/ -format gif \n\n");
40 mocchiut 1.2 }
41     //
42 mocchiut 1.1 int main(int numinp, char *inps[]){
43     TString name;
44 mocchiut 1.5 TString outdir = "./";
45 mocchiut 1.4 TString format = "png";
46 mocchiut 1.2 int matra = 0;
47     Long64_t calibno = 0;
48     char *pEnd;
49     int nul = 0;
50     bool beverbose = false;
51 mocchiut 1.4 Bool_t iactive = false;
52     Bool_t w4i = false;
53 mocchiut 1.3
54 mocchiut 1.2 if ( numinp > 1 ){
55 mocchiut 1.3 name = (TString)inps[1];
56     for ( int i = 0; i < numinp; i++ ){
57    
58     if ( !strcmp(inps[i],"--version") ){
59     info();
60     return(0);
61     };
62     if ( !strcmp(inps[i],"-h") || !strcmp(inps[i],"--help") ){
63     usage();
64     return(0);
65     };
66     if ( !strcmp(inps[i],"-name") ) {
67     if ( numinp-1 < i+1 ){
68     usage();
69     exit(-3);
70     };
71     name = (TString)inps[i+1];
72     };
73     if ( !strcmp(inps[i],"-outDir") ) {
74     if ( numinp-1 < i+1 ){
75     usage();
76     exit(-3);
77     };
78     outdir = (TString)inps[i+1];
79     };
80     if ( !strcmp(inps[i],"-format") ) {
81     if ( numinp-1 < i+1 ){
82     usage();
83     exit(-3);
84     };
85     format = (TString)inps[i+1];
86     };
87    
88     if ( !strcmp(inps[i],"-entry") ) {
89     if ( numinp-1 < i+1 ){
90     usage();
91     exit(-3);
92 mocchiut 1.2 };
93 mocchiut 1.3 calibno = strtoull(inps[i+1],&pEnd,0);
94 mocchiut 1.1 };
95 mocchiut 1.3 if ( !strcmp(inps[i],"-matra") ) {
96     matra = 1;
97     };
98 mocchiut 1.4 if ( !strcmp(inps[i],"-interactive") ) {
99     iactive = true;
100     };
101     if ( !strcmp(inps[i],"-wait") ) {
102     w4i = true;
103     };
104 mocchiut 1.3 if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true;
105 mocchiut 1.1 };
106 mocchiut 1.3 } else {
107     //
108     // no input parameters exit with error, we need at least the run id.
109     //
110     usage();
111     return(0);
112 mocchiut 1.2 };
113     //
114     if ( !beverbose ){
115     //
116     // redirect to /dev/null the stdout and stderr
117 mocchiut 1.1 //
118 mocchiut 1.2 nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE);
119     dup2(nul,1);
120     dup2(nul,2);
121 mocchiut 1.1 };
122 mocchiut 1.2 printf("\n Welcome to FCaloCHKCALIB! \n");
123 mocchiut 1.1 //
124 mocchiut 1.4 FCaloCHKCALIB(name,calibno,outdir,matra,format,iactive,w4i);
125 mocchiut 1.1 //
126 mocchiut 1.2 if ( !beverbose ) close(nul);
127 mocchiut 1.1 return(0);
128     }

  ViewVC Help
Powered by ViewVC 1.1.23