44 {
47
48 string inputFile;
51 int duration_ms;
52 int outNumberOfLines;
53
54 try {
55
56 JParser<> zap(
"Auxiliary program to test generation of L0 background.");
57
58 zap[
'f'] =
make_field(inputFile,
"input file (output from JRipple).");
60 zap[
'T'] =
make_field(duration_ms,
"duration in ms of the background sample.") = 500;
61 zap[
'N'] =
make_field(outNumberOfLines,
"number of lines of the simulated (output) detector") = 115;
63 zap(argc, argv);
64 }
65 catch(const exception &error) {
66 FATAL(error.what() << endl);
67 }
68
69 TFile* in = TFile::Open(inputFile.c_str(), "exist");
70
71 if (in == NULL || !in->IsOpen()) {
72 FATAL(
"File: " << inputFile <<
" not opened." << endl);
73 }
74
75 NOTICE(
"Initialising generator." << endl);
76
78
79 in->Close();
80
81 NOTICE(
"File loaded." << endl);
82
83 int T_ms = duration_ms;
84
85 simbad.configureTimeWindow(T_ms);
86 simbad.setSeed();
87
88 int inNumberOfLines = 1;
89
90 simbad.configureRatio(inNumberOfLines, outNumberOfLines);
91
94
97
99
100 NOTICE(
"Generation SEQ" << endl);
101
102 for (int i = 0; i < 10; i++) {
103 bg_type seq = simbad.generate();
104
105 for (
int j = 0;
j < T_ms;
j++) {
106 RT_SEQ[i]->Fill(
j, seq[0][
j]);
107 NC_SEQ[i]->Fill(
j, seq[1][
j]);
108
109 }
110
111 }
112
113 NOTICE(
"Generation SHF" << endl);
114
115 for (int i = 0; i < 10; i++) {
116 bg_type shf = simbad.generate_shuffled();
117
118 for (
int j = 0;
j < T_ms;
j++) {
119
120 RT_SHF[i]->Fill(
j, shf[0][
j]);
121 NC_SHF[i]->Fill(
j, shf[1][
j]);
122
123 }
124 }
125
126 NOTICE(
"Generation H2D + FIT" << endl);
127
128 h2d_t* test1 = simbad.generate_H2D();
129
130 bg_type fit1 = simbad.generate_fitted();
131
132 for (
int j = 0;
j < T_ms;
j++) {
133 RT_FIT[
"SG_1"]->Fill(
j, fit1[0][
j]);
134 }
135
136 NOTICE(
"Generation H2D + FIT - rebin = 5" << endl);
137
138 h2d_t* test5 = simbad.generate_H2D(5);
139
140
141 bg_type fit5 = simbad.generate_fitted(5);
142
143 for (
size_t j = 0;
j < fit5[0].size();
j++) {
144 cout << fit5[0][
j] << endl;
145 RT_FIT[
"SG_5"]->Fill(
j, fit5[0][
j]);
146 }
147
148
149
150
151
152
153
154
155
156
157
158
159
160
162
163 TDirectory* dseq = out.mkdir("SEQ");
164 TDirectory* dshf = out.mkdir("SHF");
165 TDirectory* dfit = out.mkdir("FIT");
166
167 RT_SEQ.Write(*dseq);
168 NC_SEQ.Write(*dseq);
169
170 RT_SHF.Write(*dshf);
171 NC_SHF.Write(*dshf);
172
173 RT_FIT.Write(*dfit);
174
175 dfit->cd();
176 test1->Write();
177 test5->Write();
178
179 out.Close();
180
181}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
Class to emulate L0 background for an arbitrarily sized detector.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).