00001
00002 #define H1K0S_cxx
00003
00004 #include <iostream>
00005 #include <cmath>
00006 #include <cstring>
00007 #include "H1K0S.h"
00008 #include <TApplication.h>
00009
00010 #include "jbltools/kinfit/H1K0Event.h"
00011 #include "jbltools/kinfit/WWFitter.h"
00012 #include "jbltools/kinfit/ftypes.h"
00013 #include "jbltools/kinfit/hbook.h"
00014 #include "jbltools/kinfit/TrackFitObject.h"
00015 #include "jbltools/kinfit/VertexFitObject.h"
00016
00017 int main(int argc, char** argv) {
00018
00019
00020 FInteger IERR;
00021 FReal FITPROB, CHI2;
00022 FReal V0TRUE[3], V1TRUE[3];
00023 FReal V0FIT[3], V1FIT[3];
00024 FReal P0FIT[4], P1FIT[4], P2FIT[4];
00025 FReal MTRUE, MFIT;
00026
00027
00028 FInteger LREC=1024, ISTAT=0;
00029 hropen (21, "K0FIT", "h1-k0.hbook", "N", LREC, ISTAT);
00030 hbnt (999,"k0fit","");
00031 hbname (999, "FIT", IERR, "IERR:I");
00032 hbname (999, "FIT", FITPROB, "FITPROB:R");
00033 hbname (999, "FIT", CHI2, "CHI2:R");
00034 hbname (999, "FIT", V0TRUE[0], "V0TRUE(3):R");
00035 hbname (999, "FIT", V1TRUE[0], "V1TRUE(3):R");
00036 hbname (999, "FIT", V0FIT[0], "V0FIT(3):R");
00037 hbname (999, "FIT", V1FIT[0], "V1FIT(3):R");
00038 hbname (999, "FIT", P0FIT[0], "P0FIT(4):R");
00039 hbname (999, "FIT", P1FIT[0], "P1FIT(4):R");
00040 hbname (999, "FIT", P2FIT[0], "P2FIT(4):R");
00041 hbname (999, "FIT", MTRUE, "MTRUE:R");
00042 hbname (999, "FIT", MFIT, "MFIT:R");
00043
00044
00045 H1K0S nt;
00046 if (nt.fChain == 0) {
00047 std::cout << "ERROR opening ntuple" << std::endl;
00048 return 1;
00049 }
00050
00051
00052 TApplication theApp("main", &argc, argv);
00053
00054
00055 int nentries = int(nt.fChain->GetEntriesFast());
00056 for (int ievent = 0; ievent < nentries; ++ievent) {
00057 Int_t ix = nt.LoadTree (ievent);
00058 if (ix < 0) break;
00059 nt.fChain->GetEntry(ievent);
00060
00061 std::cout << "Run " << nt.RunNumber
00062 << ", event " << nt.EventNumber << std::endl;
00063
00064 WWFitter fitter;
00065 H1K0Event evt (nt);
00066 int ierr = evt.fitEvent (fitter);
00067 if (ierr) std::cout << "IERR: " << ierr << std::endl;
00068
00069 if (ievent%10 == 9) std::cout << "processed event " << ievent+1 << std::endl;
00070 if (ievent >= 1000) break;
00071
00072 IERR = ierr;
00073 FITPROB = fitter.getProbability();
00074 CHI2 = fitter.getChi2();
00075
00076
00077 for (int i = 0; i < 3; ++i) {
00078 V0TRUE[i] = nt.myVtx[i];
00079 V1TRUE[i] = nt.K0Vert[i];
00080 V0FIT[i] = evt.rectrack[0]->getTrajectoryPoint(0).getComponent(i);
00081 V1FIT[i] = evt.k0decvertex->getVertex().getComponent(i);
00082 }
00083
00084
00085 for (int i = 0; i < 4; ++i) {
00086 P0FIT[i] = evt.rectrack[0]->getMomentum(0).getComponent(i);
00087 P1FIT[i] = evt.rectrack[1]->getMomentum(0).getComponent(i);
00088 P2FIT[i] = evt.rectrack[2]->getMomentum(0).getComponent(i);
00089 }
00090 MTRUE = std::sqrt (nt.K0Mom[3]*nt.K0Mom[3] - nt.K0Mom[0]*nt.K0Mom[0]
00091 - nt.K0Mom[1]*nt.K0Mom[1] - nt.K0Mom[2]*nt.K0Mom[2]);
00092 MFIT = (evt.rectrack[1]->getMomentum(0) + evt.rectrack[2]->getMomentum(0)).getM();
00093
00094 hfnt(999);
00095 }
00096
00097 hrout(999);
00098 hrend("K0FIT");
00099
00100 return 0;
00101
00102 }