38int main(
int argc,
char **argv)
43 typedef JTYPELIST<JEvt, JSuperEvt>::typelist typelist;
45 JMultipleFileScanner<typelist> inputFile;
46 JLimit_t& numberOfEvents = inputFile.getLimit();
53 JParser<> zap(
"Example program to plot acoustic fit results.");
55 zap[
'f'] = make_field(inputFile,
"input file (output of JKatoomba[.sh]/JFremantle[.sh])");
56 zap[
'n'] = make_field(numberOfEvents) = JLimit::max();
57 zap[
'o'] = make_field(outputFile) =
"parramatta.root";
58 zap[
'Z'] = make_field(Z,
"detector height (for 2nd order tilt correction)") = 0.0;
59 zap[
'd'] = make_field(debug) = 2;
63 catch(
const exception &error) {
64 FATAL(error.what() << endl);
69 const JFormat_t format(4, 0, std::ios_base::fmtflags(),
'0');
71 TH1D h1(
"chi2/NDF", NULL, 500, 0.0, 10.0);
72 TH1D h2(
"amplitude", NULL, 500, 0.0, 100.0);
78 map<int, JGraph_t> GO;
79 map<int, JGraph_t> GA;
80 map<int, JGraph_t> GS;
82 JManager<int, TProfile> H1(
new TProfile(
"stretching[%]", NULL, 50, 0.0, 1.0e2));
83 JManager<int, TH2D> H2(
new TH2D(
"[%].tiltdeviation", NULL, 300, -4.0, +4.0, 300, -4.0, +4.0),
'%', format);
85 JObjectMultiplexer<typelist, JEvt> in(inputFile);
87 for (counter_type counter = 0; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
89 STATUS(
"event: " << setw(10) << counter <<
'\r'); DEBUG(endl);
91 const JEvt* evt = in.next();
98 g1.put(t1, evt->
chi2 / evt->
ndf);
106 for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) {
108 const int id = i->id;
109 const double tx = (i->tx + i->tx2 * Z) * 1.0e3;
110 const double ty = (i->ty + i->ty2 * Z) * 1.0e3;
111 const double vs = i->vs * 1.0e2;
112 const double ts = sqrt(tx*tx + ty*ty);
122 H1[id]->Fill(ts, vs);
124 GO[id].put(t1, atan2(ty, tx));
134 for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) {
136 const double tx = (i->tx + i->tx2 * Z) * 1.0e3;
137 const double ty = (i->ty + i->ty2 * Z) * 1.0e3;
139 H2 ->Fill(tx - Tx, ty - Ty);
140 H2[i->id]->Fill(tx - Tx, ty - Ty);
142 GO[-1].put(t1, atan2(Ty, Tx));
149 TH1D hx(
"hx", NULL, H2.size(), -0.5, H2.size() + 0.5);
150 TH1D hy(
"hy", NULL, H2.size(), -0.5, H2.size() + 0.5);
154 for (JManager<int, TH2D>::const_iterator i = H2.begin(); i != H2.end(); ++i) {
156 const int ix = distance(H2.cbegin(), i) + 1;
158 hx.GetXaxis()->SetBinLabel(ix, MAKE_CSTRING(i->first));
159 hy.GetXaxis()->SetBinLabel(ix, MAKE_CSTRING(i->first));
161 hx.SetBinContent(ix, i->second->GetMean(1));
162 hy.SetBinContent(ix, i->second->GetMean(2));
163 hx.SetBinError (ix, i->second->GetStdDev(1));
164 hy.SetBinError (ix, i->second->GetStdDev(2));
166 Qx.put(i->second->GetMean(1));
167 Qy.put(i->second->GetMean(2));
170 if (Qx.getCount() > 1 && Qy.getCount() > 1) {
171 cout <<
"deviation: " << FIXED(7,3) << Qx.getSTDev() <<
' ' << FIXED(7,3) << Qy.getSTDev() << endl;
174 TFile out(outputFile.c_str(),
"recreate");
176 out << h1 << h2 << hx << hy
181 out << H1 << *H1 << H2 << *H2;
183 for (map<int, JGraph_t>::const_iterator i = GO.begin(); i != GO.end(); ++i) {
184 out << JGraph(i->second, MAKE_CSTRING(
"G[" << FILL(4,
'0') << i->first <<
"].orientation"));
187 for (map<int, JGraph_t>::const_iterator i = GA.begin(); i != GA.end(); ++i) {
188 out << JGraph(i->second, MAKE_CSTRING(
"G[" << FILL(4,
'0') << i->first <<
"].amplitude"));
191 for (map<int, JGraph_t>::const_iterator i = GS.begin(); i != GS.end(); ++i) {
192 out << JGraph(i->second, MAKE_CSTRING(
"G[" << FILL(4,
'0') << i->first <<
"].stretching"));