Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

toppair.C

Go to the documentation of this file.
00001 // toppair
00002 // Test program to test fitter classes:
00003 // Generate Top pairs and let them decay
00004 // B. List 13.4.04
00005 
00006 
00007 #include <iostream>              // - cout
00008 using std::cout;
00009 using std::endl;
00010 
00011 #include "jbltools/kinfit/WWFitterFast.h"
00012 #include "jbltools/kinfit/WWFitter.h"
00013 #include "jbltools/kinfit/TopEvent.h"
00014 #include "jbltools/kinfit/ftypes.h"
00015 #include "jbltools/kinfit/hbook.h"
00016 
00017 
00018 
00019 int main(int argc, char** argv) {
00020   int failed = 0;
00021   int total = 1000;
00022   WWFitter fitter;
00023   
00024   // ntuple variables
00025   FInteger IERR;
00026   FReal FITPROB, CHI2;
00027   FReal WSTARTMASS[2], TSTARTMASS[2];
00028   FReal WSTOPMASS[2], TSTOPMASS[2];
00029   FReal PXSTART, PYSTART;
00030   FReal PXSTOP, PYSTOP;
00031 //  FReal J1[4], J2[4], J3[4], J4[4], J5[4], J6[4];
00032   FReal J1E[4], J2E[4], J3E[4], J4E[4], J5E[4], J6E[4];
00033   FReal J1TRUE[4], J2TRUE[4], J3TRUE[4], J4TRUE[4], J5TRUE[4], J6TRUE[4];
00034   FReal J1FIT[4], J2FIT[4], J3FIT[4], J4FIT[4], J5FIT[4], J6FIT[4];
00035   
00036   FInteger LREC=1024, ISTAT=0;
00037   hropen (21, "KINFIT", "toppair.hbook", "N", LREC, ISTAT);
00038   hbnt (999,"kinfit","");
00039   hbname (999, "FIT", IERR, "IERR:I");
00040   hbname (999, "FIT", FITPROB, "FITPROB:R");
00041   hbname (999, "FIT", CHI2, "CHI2:R");
00042   hbname (999, "FIT", WSTARTMASS[0], "WSTARTMASS(2):R");
00043   hbname (999, "FIT", WSTOPMASS[0], "WSTOPMASS(2):R");
00044   hbname (999, "FIT", TSTARTMASS[0], "TSTARTMASS(2):R");
00045   hbname (999, "FIT", TSTOPMASS[0], "TSTOPMASS(2):R");
00046   hbname (999, "FIT", PXSTART, "PXSTART:R");
00047   hbname (999, "FIT", PYSTART, "PYSTART:R");
00048   hbname (999, "FIT", PXSTOP, "PXSTOP:R");
00049   hbname (999, "FIT", PYSTOP, "PYSTOP:R");
00050   hbname (999, "FIT", J1TRUE[0], "J1TRUE(4):R");
00051   hbname (999, "FIT", J2TRUE[0], "J2TRUE(4):R");
00052   hbname (999, "FIT", J3TRUE[0], "J3TRUE(4):R");
00053   hbname (999, "FIT", J4TRUE[0], "J4TRUE(4):R");
00054   hbname (999, "FIT", J5TRUE[0], "J5TRUE(4):R");
00055   hbname (999, "FIT", J6TRUE[0], "J6TRUE(4):R");
00056   hbname (999, "FIT", J1FIT[0], "J1FIT(4):R");
00057   hbname (999, "FIT", J2FIT[0], "J2FIT(4):R");
00058   hbname (999, "FIT", J3FIT[0], "J3FIT(4):R");
00059   hbname (999, "FIT", J4FIT[0], "J4FIT(4):R");
00060   hbname (999, "FIT", J5FIT[0], "J5FIT(4):R");
00061   hbname (999, "FIT", J6FIT[0], "J6FIT(4):R");
00062   hbname (999, "FIT", J1E[0], "J1E(4):R");
00063   hbname (999, "FIT", J2E[0], "J2E(4):R");
00064   hbname (999, "FIT", J3E[0], "J3E(4):R");
00065   hbname (999, "FIT", J4E[0], "J4E(4):R");
00066   hbname (999, "FIT", J5E[0], "J5E(4):R");
00067   hbname (999, "FIT", J6E[0], "J6E(4):R");
00068   
00069   
00070   
00071   for (int i = 0; i < total; i++) {
00072     TopEvent evt;
00073     evt.genEvent();
00074     
00075     // start values
00076     WSTARTMASS[0] = evt.getW1Constraint().getMass();
00077     WSTARTMASS[1] = evt.getW2Constraint().getMass();
00078     TSTARTMASS[0] = evt.getTopConstraint().getMass(1);
00079     TSTARTMASS[1] = evt.getTopConstraint().getMass(2);
00080     PXSTART = evt.getPxConstraint().getValue();
00081     PYSTART = evt.getPyConstraint().getValue();
00082     
00083     if ((IERR = evt.fitEvent(fitter)) != 0) {
00084       failed++;
00085       cout << "IERR = " << IERR << endl;
00086     }
00087     FITPROB = fitter.getProbability();
00088     CHI2    = fitter.getChi2();
00089     
00090     // stop values
00091     WSTOPMASS[0] = evt.getW1Constraint().getMass();
00092     WSTOPMASS[1] = evt.getW2Constraint().getMass();
00093     TSTOPMASS[0] = evt.getTopConstraint().getMass(1);
00094     TSTOPMASS[1] = evt.getTopConstraint().getMass(2);
00095     PXSTOP = evt.getPxConstraint().getValue();
00096     PYSTOP = evt.getPyConstraint().getValue();
00097     
00098     // parameters & errors
00099     for (int i = 0; i < 3; ++i) {
00100       J1TRUE[i] = evt.getTrueFitObject(0)->getParam(i);
00101       J2TRUE[i] = evt.getTrueFitObject(1)->getParam(i);
00102       J3TRUE[i] = evt.getTrueFitObject(2)->getParam(i);
00103       J4TRUE[i] = evt.getTrueFitObject(3)->getParam(i);
00104       J5TRUE[i] = evt.getTrueFitObject(4)->getParam(i);
00105       J6TRUE[i] = evt.getTrueFitObject(5)->getParam(i);
00106       J1FIT[i] = evt.getSmearedFitObject(0)->getParam(i);
00107       J2FIT[i] = evt.getSmearedFitObject(1)->getParam(i);
00108       J3FIT[i] = evt.getSmearedFitObject(2)->getParam(i);
00109       J4FIT[i] = evt.getSmearedFitObject(3)->getParam(i);
00110       J5FIT[i] = evt.getSmearedFitObject(4)->getParam(i);
00111       J6FIT[i] = evt.getSmearedFitObject(5)->getParam(i);
00112       J1E[i] = evt.getSmearedFitObject(0)->getError(i);
00113       J2E[i] = evt.getSmearedFitObject(1)->getError(i);
00114       J3E[i] = evt.getSmearedFitObject(2)->getError(i);
00115       J4E[i] = evt.getSmearedFitObject(3)->getError(i);
00116       J5E[i] = evt.getSmearedFitObject(4)->getError(i);
00117       J6E[i] = evt.getSmearedFitObject(5)->getError(i);
00118     }
00119     
00120     hfnt(999);
00121   }
00122   
00123   std::cerr << "Failed fits: " << failed 
00124             << "(" << (100.0*failed)/total << "%)" << endl;
00125             
00126   hrout(999);
00127   hrend("KINFIT");          
00128 
00129   return 0;
00130 }

Generated on Fri Sep 14 17:38:21 2007 for Kinfit by doxygen 1.3.2