00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00038 #include "TopQuarkAnalysis/TopHitFit/interface/gentop.h"
00039 #include "CLHEP/Random/RandFlat.h"
00040 #include "CLHEP/Random/RandExponential.h"
00041 #include "CLHEP/Random/RandBreitWigner.h"
00042 #include "CLHEP/Random/RandGauss.h"
00043 #include "CLHEP/Units/PhysicalConstants.h"
00044 #include "TopQuarkAnalysis/TopHitFit/interface/fourvec.h"
00045 #include "TopQuarkAnalysis/TopHitFit/interface/Lepjets_Event.h"
00046 #include "TopQuarkAnalysis/TopHitFit/interface/Defaults.h"
00047 #include <cmath>
00048 #include <ostream>
00049
00050
00051 using std::ostream;
00052
00053
00054
00058 namespace {
00059 int next_evnum = 0;
00060 }
00061
00062
00063 namespace hitfit {
00064
00065
00066
00067
00068
00069
00070
00071 Gentop_Args::Gentop_Args (const Defaults& defs)
00072
00073
00074
00075
00076
00077
00078 : _t_pt_mean (defs.get_float ("t_pt_mean")),
00079 _mt (defs.get_float ("mt")),
00080 _sigma_mt (defs.get_float ("sigma_mt")),
00081 _mh (defs.get_float ("mh")),
00082 _sigma_mh (defs.get_float ("sigma_mh")),
00083 _recoil_pt_mean (defs.get_float ("recoil_pt_mean")),
00084 _boost_sigma (defs.get_float ("boost_sigma")),
00085 _m_boost (defs.get_float ("m_boost")),
00086 _mb (defs.get_float ("mb")),
00087 _sigma_mb (defs.get_float ("sigma_mb")),
00088 _mw (defs.get_float ("mw")),
00089 _sigma_mw (defs.get_float ("sigma_mw")),
00090 _svx_tageff (defs.get_float ("svx_tageff")),
00091 _smear (defs.get_bool ("smear")),
00092 _smear_dir (defs.get_bool ("smear_dir")),
00093 _muon (defs.get_bool ("muon")),
00094 _ele_res_str (defs.get_string ("ele_res_str")),
00095 _muo_res_str (defs.get_string ("muo_res_str")),
00096 _jet_res_str (defs.get_string ("jet_res_str")),
00097 _kt_res_str (defs.get_string ("kt_res_str"))
00098 {
00099 }
00100
00101
00102 double Gentop_Args::t_pt_mean () const
00103
00104
00105
00106
00107 {
00108 return _t_pt_mean;
00109 }
00110
00111
00112 double Gentop_Args::mt () const
00113
00114
00115
00116
00117 {
00118 return _mt;
00119 }
00120
00121
00122 double Gentop_Args::sigma_mt () const
00123
00124
00125
00126
00127 {
00128 return _sigma_mt;
00129 }
00130
00131
00132 double Gentop_Args::svx_tageff () const
00133
00134
00135
00136
00137 {
00138 return _svx_tageff;
00139 }
00140
00141
00142 double Gentop_Args::mh () const
00143
00144
00145
00146
00147 {
00148 return _mh;
00149 }
00150
00151
00152 double Gentop_Args::sigma_mh () const
00153
00154
00155
00156
00157 {
00158 return _sigma_mh;
00159 }
00160
00161
00162 bool Gentop_Args::smear () const
00163
00164
00165
00166
00167 {
00168 return _smear;
00169 }
00170
00171
00172 bool Gentop_Args::smear_dir () const
00173
00174
00175
00176
00177 {
00178 return _smear_dir;
00179 }
00180
00181
00182 bool Gentop_Args::muon () const
00183
00184
00185
00186
00187 {
00188 return _muon;
00189 }
00190
00191
00192 double Gentop_Args::recoil_pt_mean () const
00193
00194
00195
00196
00197 {
00198 return _recoil_pt_mean;
00199 }
00200
00201
00202 double Gentop_Args::boost_sigma () const
00203
00204
00205
00206
00207 {
00208 return _boost_sigma;
00209 }
00210
00211
00212 double Gentop_Args::m_boost () const
00213
00214
00215
00216
00217 {
00218 return _m_boost;
00219 }
00220
00221
00222 double Gentop_Args::mb () const
00223
00224
00225
00226
00227 {
00228 return _mb;
00229 }
00230
00231
00232 double Gentop_Args::sigma_mb () const
00233
00234
00235
00236
00237 {
00238 return _sigma_mb;
00239 }
00240
00241
00242 double Gentop_Args::mw () const
00243
00244
00245
00246
00247 {
00248 return _mw;
00249 }
00250
00251
00252 double Gentop_Args::sigma_mw () const
00253
00254
00255
00256
00257 {
00258 return _sigma_mw;
00259 }
00260
00261
00262 std::string Gentop_Args::ele_res_str () const
00263
00264
00265
00266
00267 {
00268 return _ele_res_str;
00269 }
00270
00271
00272 std::string Gentop_Args::muo_res_str () const
00273
00274
00275
00276
00277 {
00278 return _muo_res_str;
00279 }
00280
00281
00282 std::string Gentop_Args::jet_res_str () const
00283
00284
00285
00286
00287 {
00288 return _jet_res_str;
00289 }
00290
00291
00292 std::string Gentop_Args::kt_res_str () const
00293
00294
00295
00296
00297 {
00298 return _kt_res_str;
00299 }
00300
00301
00302
00303
00304
00305
00306
00307 namespace {
00308
00309
00316 Threevec rand_spher (CLHEP::HepRandomEngine& engine)
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327 {
00328 CLHEP::RandFlat r (engine);
00329
00330 Threevec v;
00331
00332 double U = r.fire(0.0,1.0);
00333 double V = r.fire(0.0,1.0);
00334
00335 double theta = 2.0*CLHEP::pi*U ;
00336 double phi = acos(2*V - 1.0);
00337
00338 double x = sin(theta)*cos(phi);
00339 double y = sin(theta)*sin(phi);
00340 double z = cos(theta);
00341
00342 v = Threevec(x,y,z);
00343
00344 return v.unit ();
00345 }
00346
00347
00362 Fourvec make_massive (const Threevec& p,
00363 double m_true,
00364 double sigma,
00365 CLHEP::HepRandomEngine& engine)
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380 {
00381 CLHEP::RandBreitWigner rbw (engine);
00382 double m = rbw.fire (m_true, sigma);
00383 return Fourvec (p, sqrt (m*m + p.mag2()));
00384 }
00385
00403 void decay (const Fourvec& v, double m1, double m2,
00404 CLHEP::HepRandomEngine& engine,
00405 Fourvec& vout1, Fourvec& vout2)
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419 {
00420
00421
00422 Threevec p = rand_spher (engine);
00423 double m0 = v.m();
00424
00425 if (m1 + m2 > m0) {
00426
00427 double f = m0 / (m1 + m2);
00428 m1 *= f;
00429 m2 *= f;
00430 }
00431
00432 double m0_2 = m0*m0;
00433 double m1_2 = m1*m1;
00434 double m2_2 = m2*m2;
00435
00436
00437 p *= 0.5/m0 * sqrt ( m0_2*m0_2 + m1_2*m1_2 + m2_2*m2_2
00438 - 2*m0_2*m1_2 - 2*m0_2*m2_2 - 2*m1_2*m2_2);
00439 double p2 = p.mag2();
00440
00441 vout1 = Fourvec ( p, sqrt (p2 + m1_2));
00442 vout2 = Fourvec (-p, sqrt (p2 + m2_2));
00443
00444
00445 vout1.boost (v.boostVector ());
00446 vout2.boost (v.boostVector ());
00447 }
00448
00449
00459 Threevec rand_pt (double pt_mean,
00460 CLHEP::HepRandomEngine& engine)
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472 {
00473 CLHEP::RandExponential rexp (engine);
00474
00475
00476 Threevec p = rand_spher (engine);
00477
00478
00479 p *= (rexp.fire (pt_mean) / p.perp());
00480
00481 return p;
00482 }
00483
00484
00492 Fourvec rand_boost (const Gentop_Args& args, CLHEP::HepRandomEngine& engine)
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503 {
00504 CLHEP::RandExponential rexp (engine);
00505 CLHEP::RandFlat rflat (engine);
00506 CLHEP::RandGauss rgauss (engine);
00507
00508
00509 Threevec p (1, 0, 0);
00510 p.rotateZ (rflat.fire (0, 2 * M_PI));
00511 p *= rexp.fire (args.recoil_pt_mean());
00512 p.setZ (rgauss.fire (0, args.boost_sigma()));
00513 return Fourvec (p, sqrt (p.mag2() + args.m_boost()*args.m_boost()));
00514 }
00515
00516
00526 void tagsim (const Gentop_Args& args,
00527 Lepjets_Event& ev,
00528 CLHEP::HepRandomEngine& engine)
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540 {
00541 CLHEP::RandFlat rflat (engine);
00542 for (std::vector<Lepjets_Event_Jet>::size_type i=0; i < ev.njets(); i++) {
00543 int typ = ev.jet(i).type();
00544 if (typ == hadb_label || typ == lepb_label || typ == higgs_label) {
00545 if (rflat.fire() < args.svx_tageff())
00546 ev.jet(i).svx_tag() = true;
00547 }
00548 }
00549 }
00550
00551
00552 }
00553
00554
00555
00556
00557
00558
00559
00560 Lepjets_Event gentop (const Gentop_Args& args,
00561 CLHEP::HepRandomEngine& engine)
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572 {
00573 CLHEP::RandBreitWigner rbw (engine);
00574 CLHEP::RandGauss rgauss (engine);
00575
00576
00577 Threevec p = rand_pt (args.t_pt_mean(), engine);
00578
00579
00580 Fourvec lept = make_massive ( p, args.mt(), args.sigma_mt(), engine);
00581 Fourvec hadt = make_massive (-p, args.mt(), args.sigma_mt(), engine);
00582
00583
00584 Fourvec boost = rand_boost (args, engine);
00585 lept.boost (boost.boostVector());
00586 hadt.boost (boost.boostVector());
00587
00588
00589 Fourvec lepb, lepw;
00590 double mlb = rgauss.fire (args.mb(), args.sigma_mb());
00591 double mlw = rbw.fire (args.mw(), args.sigma_mw());
00592 decay (lept,
00593 mlb,
00594 mlw,
00595 engine,
00596 lepb,
00597 lepw);
00598
00599
00600 Fourvec hadb, hadw;
00601 double mhb = rgauss.fire (args.mb(), args.sigma_mb());
00602 double mhw = rbw.fire (args.mw(), args.sigma_mw());
00603 decay (hadt,
00604 mhb,
00605 mhw,
00606 engine,
00607 hadb,
00608 hadw);
00609
00610
00611 Fourvec lep, nu;
00612 decay (lepw, 0, 0, engine, lep, nu);
00613
00614
00615 Fourvec q1, q2;
00616 decay (hadw, 0, 0, engine, q1, q2);
00617
00618
00619 Lepjets_Event ev (0, ++next_evnum);
00620 Vector_Resolution lep_res (args.muon() ?
00621 args.muo_res_str() :
00622 args.ele_res_str());
00623 Vector_Resolution jet_res (args.jet_res_str());
00624 Resolution kt_res = (args.kt_res_str());
00625
00626 ev.add_lep (Lepjets_Event_Lep (lep,
00627 args.muon() ? muon_label : electron_label,
00628 lep_res));
00629
00630 ev.add_jet (Lepjets_Event_Jet (lepb, lepb_label, jet_res));
00631 ev.add_jet (Lepjets_Event_Jet (hadb, hadb_label, jet_res));
00632 ev.add_jet (Lepjets_Event_Jet ( q1, hadw1_label, jet_res));
00633 ev.add_jet (Lepjets_Event_Jet ( q2, hadw2_label, jet_res));
00634
00635 ev.met() = nu;
00636 ev.kt_res() = kt_res;
00637
00638
00639 tagsim (args, ev, engine);
00640
00641
00642 if (args.smear())
00643 ev.smear (engine, args.smear_dir());
00644
00645
00646 return ev;
00647 }
00648
00649
00650 Lepjets_Event gentth (const Gentop_Args& args,
00651 CLHEP::HepRandomEngine& engine)
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662 {
00663 CLHEP::RandBreitWigner rbw (engine);
00664 CLHEP::RandGauss rgauss (engine);
00665
00666
00667 Threevec p_t1 = rand_pt (args.t_pt_mean(), engine);
00668 Threevec p_t2 = rand_pt (args.t_pt_mean(), engine);
00669
00670
00671 Threevec p_h = -(p_t1 + p_t2);
00672
00673
00674 Fourvec lept = make_massive (p_t1, args.mt(), args.sigma_mt(), engine);
00675 Fourvec hadt = make_massive (p_t2, args.mt(), args.sigma_mt(), engine);
00676 Fourvec higgs = make_massive ( p_h, args.mh(), args.sigma_mh(), engine);
00677
00678
00679 Fourvec boost = rand_boost (args, engine);
00680 lept.boost (boost.boostVector());
00681 hadt.boost (boost.boostVector());
00682 higgs.boost (boost.boostVector());
00683
00684
00685 Fourvec lepb, lepw;
00686 decay (lept,
00687 rgauss.fire (args.mb(), args.sigma_mb()),
00688 rbw.fire (args.mw(), args.sigma_mw()),
00689 engine,
00690 lepb,
00691 lepw);
00692
00693
00694 Fourvec hadb, hadw;
00695 decay (hadt,
00696 rgauss.fire (args.mb(), args.sigma_mb()),
00697 rbw.fire (args.mw(), args.sigma_mw()),
00698 engine,
00699 hadb,
00700 hadw);
00701
00702
00703 Fourvec lep, nu;
00704 decay (lepw, 0, 0, engine, lep, nu);
00705
00706
00707 Fourvec q1, q2;
00708 decay (hadw, 0, 0, engine, q1, q2);
00709
00710
00711 Fourvec hb1, hb2;
00712 decay (higgs,
00713 rgauss.fire (args.mb(), args.sigma_mb()),
00714 rgauss.fire (args.mb(), args.sigma_mb()),
00715 engine,
00716 hb1,
00717 hb2);
00718
00719
00720 Lepjets_Event ev (0, ++next_evnum);
00721 Vector_Resolution lep_res (args.muon() ?
00722 args.muo_res_str() :
00723 args.ele_res_str());
00724 Vector_Resolution jet_res (args.jet_res_str());
00725 Resolution kt_res = (args.kt_res_str());
00726
00727 ev.add_lep (Lepjets_Event_Lep (lep,
00728 args.muon() ? muon_label : electron_label,
00729 lep_res));
00730
00731 ev.add_jet (Lepjets_Event_Jet (lepb, lepb_label, jet_res));
00732 ev.add_jet (Lepjets_Event_Jet (hadb, hadb_label, jet_res));
00733 ev.add_jet (Lepjets_Event_Jet ( q1, hadw1_label, jet_res));
00734 ev.add_jet (Lepjets_Event_Jet ( q2, hadw2_label, jet_res));
00735 ev.add_jet (Lepjets_Event_Jet ( hb1, higgs_label, jet_res));
00736 ev.add_jet (Lepjets_Event_Jet ( hb2, higgs_label, jet_res));
00737
00738 ev.met() = nu;
00739 ev.kt_res() = kt_res;
00740
00741
00742 tagsim (args, ev, engine);
00743
00744
00745 if (args.smear())
00746 ev.smear (engine, args.smear_dir());
00747
00748
00749 return ev;
00750 }
00751
00752
00753 }