35 {
36
37 std::cout << std::endl << "*** Running the calibration ***" << std::endl << std::endl;
38
39 std::string configfile("");
40 TString inputfile("");
41 int part = -1;
42 std::string parfile("parameters.txt");
43 int ask = 1;
44 TString saveas("");
45
46
47
48
49
50 for (int i = 1; i < argc; i++){
51
52 std::string
arg(argv[i]);
53
55 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
56 else configfile = argv[++i]; }
58 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
59 else inputfile = argv[++i]; }
61 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
62 else parfile = argv[++i]; }
64 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
65 else part = atoi(argv[++i]); }
67 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
68 else ask = atoi(argv[++i]); }
70 if ((i+1 == argc) || (argv[i+1][0] ==
'-'))
arg =
"-h";
71 else saveas = argv[++i]; }
73 std::cout << std::endl << " Usage for: " << argv[0] << std::endl << std::endl;
74 std::cout << "\t -c <file>\t Configuration file" << std::endl;
75 std::cout << "\t -s <file>\t Save output as" << std::endl;
76 std::cout << "\t -f <file>\t Input file" << std::endl;
77 std::cout << "\t -p <file>\t Curve parameter file" << std::endl;
78 std::cout << "\t -t <int>\t Particle type (-1 = all)" << std::endl;
79 std::cout << "\t -i <int>\t Ask before each step? (0 = no, 1 = yes)" << std::endl;
80 exit(1);
81 }
82 }
83
84 if( configfile == "" && inputfile == "" ){
85 std::cout << "ERROR: No input file was given..." << std::endl;
86 return 1;
87 }
88
89
90 std::string ready("y");
91
92
94
95 std::vector< TString > types;
96 types.push_back("pion");
97 types.push_back("kaon");
98 types.push_back("proton");
99 types.push_back("muon");
100 types.push_back("electron");
101
102
103
104
105 if( configfile != "" ){
108 }
109 else{
110 std::cout << "No configuration file provided, ";
111 std::cout << "are you sure you want to use the default values (y/n)? ";
112 std::cin >> ready; std::cout << std::endl;
113 if( ready != "y" ) return 1;
114
115 int bgbins[5];
116 double bgmax[5];
117 double bgmin[5];
118
119
120 bgbins[0] = 30;
121 bgmax[0] = 2.12/Widget::mpion;
122 bgmin[0] = 0.12/Widget::mpion;
123 bgbins[1] = 10;
124 bgmax[1] = 1.8/Widget::mkaon;
125 bgmin[1] = 0.35/Widget::mkaon;
126 bgbins[2] = 10;
127 bgmax[2] = 1.7/Widget::mproton;
128 bgmin[2] = 0.5/Widget::mproton;
129 bgbins[3] = 15;
130 bgmax[3] = 1.92/Widget::mmuon;
131 bgmin[3] = 1.76/Widget::mmuon;
132 bgbins[4] = 30;
133 bgmax[4] = 2.3/Widget::melectron;
134 bgmin[4] = 0.3/Widget::melectron;
135
136 int cosbins[5];
137 double cosmax[5];
138 double cosmin[5];
139 for( int i = 0; i < 4; ++i ){
140 cosbins[i] = 18;
141 cosmax[i] = 0.93;
142 cosmin[i] = 0.0;
143 }
144 cosbins[4] = 18;
145 cosmax[4] = 0.93;
146 cosmin[4] = 0.5;
147
148
149 for( int i = 0; i < 5; ++i ){
150 if( inputfile != "" )
151 widget.
AddParticle(types[i],inputfile+types[i]+
".root",0.0,
152 bgbins[i],bgmax[i],bgmin[i],
153 cosbins[i],cosmax[i],cosmin[i]);
154 else
155 widget.
AddParticle(types[i],
"widget."+types[i]+
".root",0.0,
156 bgbins[i],bgmax[i],bgmin[i],
157 cosbins[i],cosmax[i],cosmin[i]);
158 }
159 }
160
161
163
164
165
166
167 std::streambuf *coutbuf = std::cout.rdbuf();
168 std::ofstream out("widget.log");
169
170
171
172
173 std::cout.rdbuf( out.rdbuf() );
175 std::cout.rdbuf( coutbuf );
176
177}
double arg(const EvtComplex &c)
void SetParamFile(std::string paramfile)
void PlotEfficiency(TString saveas)
void SetupFromConfigFile(std::string configfile)
void AddParticle(TString particle, TString filename, int nevents, int bgbins, double upperbg, double lowerbg, int cosbins, double uppercos, double lowercos)