-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_rate.cxx
executable file
·85 lines (67 loc) · 2.44 KB
/
plot_rate.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "macros.h"
#include <getopt.h>
// ----------------------------------------------------
// plot rate vs time
// ----------------------------------------------------
int main(int argc, char *argv[]) {
// argc should be >=2 for correct execution
if ( argc < 2 ) {
// We print argv[0] assuming it is the program name
std::cout<<"usage: "<< argv[0] <<" <arguments> " << std::endl;
std::cout<<"arguments:" << std::endl;
std::cout<<"--file <list_file.root> \t list file" << std::endl;
std::cout<<"--binwidth <binwidth> \t bin width (s)" << std::endl;
std::cout<<"--energy \t use energy calibration" << std::endl;
std::cout<<"--range_min <r0> --range_max <r1> \t select pulseheight/energy range [r0,r1]" << std::endl;
return 1;
}
int c = 0;
TString option="";
double binwidth=2000.;
double range_min=100.;
double range_max=30000.;
TString FileName;
struct option longopts[] = {
{ "energy", no_argument, 0, 'e' },
{ "file", required_argument, 0, 'f' },
{ "range_min", required_argument, 0, 'a' },
{ "range_max", required_argument, 0, 'b' },
{ "binwidth", required_argument, 0, 'c' },
{ 0, 0, 0, 0 }
};
while((c = getopt_long(argc,argv,"ea:b:c:",longopts, NULL)) != -1)
{
switch(c)
{
case 'e':
option="energy";
break;
case 'f':
FileName = optarg;
break;
case 'a':
range_min = atof(optarg);
break;
case 'b':
range_max = atof(optarg);
break;
case 'c':
binwidth = atof(optarg);
break;
case ':': /* missing option argument */
fprintf(stderr, "%s: option `-%c' requires an argument\n",
argv[0], optopt);
break;
}
}
if (FileName=="") {
std::cout << "##### ERROR: no file name specified" << std::endl;
std::cout << "use option --file <list_file.root>" << std::endl;
return 1;
}
// read parameters from file
if (rate_from_list(FileName,binwidth,range_min,range_max,option)) {
return 1;
}
return 0;
}