File indexing completed on 2024-04-06 12:31:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #include "TopQuarkAnalysis/TopHitFit/interface/gentop.h"
0037 #include "CLHEP/Random/RandFlat.h"
0038 #include "CLHEP/Random/RandExponential.h"
0039 #include "CLHEP/Random/RandBreitWigner.h"
0040 #include "CLHEP/Random/RandGauss.h"
0041 #include "CLHEP/Units/PhysicalConstants.h"
0042 #include "TopQuarkAnalysis/TopHitFit/interface/fourvec.h"
0043 #include "TopQuarkAnalysis/TopHitFit/interface/Lepjets_Event.h"
0044 #include "TopQuarkAnalysis/TopHitFit/interface/Defaults.h"
0045 #include <cmath>
0046 #include <ostream>
0047
0048 using std::ostream;
0049
0050
0051
0052
0053
0054 namespace {
0055 int next_evnum = 0;
0056 }
0057
0058 namespace hitfit {
0059
0060
0061
0062
0063
0064 Gentop_Args::Gentop_Args(const Defaults& defs)
0065
0066
0067
0068
0069
0070
0071 : _t_pt_mean(defs.get_float("t_pt_mean")),
0072 _mt(defs.get_float("mt")),
0073 _sigma_mt(defs.get_float("sigma_mt")),
0074 _mh(defs.get_float("mh")),
0075 _sigma_mh(defs.get_float("sigma_mh")),
0076 _recoil_pt_mean(defs.get_float("recoil_pt_mean")),
0077 _boost_sigma(defs.get_float("boost_sigma")),
0078 _m_boost(defs.get_float("m_boost")),
0079 _mb(defs.get_float("mb")),
0080 _sigma_mb(defs.get_float("sigma_mb")),
0081 _mw(defs.get_float("mw")),
0082 _sigma_mw(defs.get_float("sigma_mw")),
0083 _svx_tageff(defs.get_float("svx_tageff")),
0084 _smear(defs.get_bool("smear")),
0085 _smear_dir(defs.get_bool("smear_dir")),
0086 _muon(defs.get_bool("muon")),
0087 _ele_res_str(defs.get_string("ele_res_str")),
0088 _muo_res_str(defs.get_string("muo_res_str")),
0089 _jet_res_str(defs.get_string("jet_res_str")),
0090 _kt_res_str(defs.get_string("kt_res_str")) {}
0091
0092 double Gentop_Args::t_pt_mean() const
0093
0094
0095
0096
0097 {
0098 return _t_pt_mean;
0099 }
0100
0101 double Gentop_Args::mt() const
0102
0103
0104
0105
0106 {
0107 return _mt;
0108 }
0109
0110 double Gentop_Args::sigma_mt() const
0111
0112
0113
0114
0115 {
0116 return _sigma_mt;
0117 }
0118
0119 double Gentop_Args::svx_tageff() const
0120
0121
0122
0123
0124 {
0125 return _svx_tageff;
0126 }
0127
0128 double Gentop_Args::mh() const
0129
0130
0131
0132
0133 {
0134 return _mh;
0135 }
0136
0137 double Gentop_Args::sigma_mh() const
0138
0139
0140
0141
0142 {
0143 return _sigma_mh;
0144 }
0145
0146 bool Gentop_Args::smear() const
0147
0148
0149
0150
0151 {
0152 return _smear;
0153 }
0154
0155 bool Gentop_Args::smear_dir() const
0156
0157
0158
0159
0160 {
0161 return _smear_dir;
0162 }
0163
0164 bool Gentop_Args::muon() const
0165
0166
0167
0168
0169 {
0170 return _muon;
0171 }
0172
0173 double Gentop_Args::recoil_pt_mean() const
0174
0175
0176
0177
0178 {
0179 return _recoil_pt_mean;
0180 }
0181
0182 double Gentop_Args::boost_sigma() const
0183
0184
0185
0186
0187 {
0188 return _boost_sigma;
0189 }
0190
0191 double Gentop_Args::m_boost() const
0192
0193
0194
0195
0196 {
0197 return _m_boost;
0198 }
0199
0200 double Gentop_Args::mb() const
0201
0202
0203
0204
0205 {
0206 return _mb;
0207 }
0208
0209 double Gentop_Args::sigma_mb() const
0210
0211
0212
0213
0214 {
0215 return _sigma_mb;
0216 }
0217
0218 double Gentop_Args::mw() const
0219
0220
0221
0222
0223 {
0224 return _mw;
0225 }
0226
0227 double Gentop_Args::sigma_mw() const
0228
0229
0230
0231
0232 {
0233 return _sigma_mw;
0234 }
0235
0236 std::string Gentop_Args::ele_res_str() const
0237
0238
0239
0240
0241 {
0242 return _ele_res_str;
0243 }
0244
0245 std::string Gentop_Args::muo_res_str() const
0246
0247
0248
0249
0250 {
0251 return _muo_res_str;
0252 }
0253
0254 std::string Gentop_Args::jet_res_str() const
0255
0256
0257
0258
0259 {
0260 return _jet_res_str;
0261 }
0262
0263 std::string Gentop_Args::kt_res_str() const
0264
0265
0266
0267
0268 {
0269 return _kt_res_str;
0270 }
0271
0272
0273
0274
0275
0276 namespace {
0277
0278
0279
0280
0281
0282
0283
0284 Threevec rand_spher(CLHEP::HepRandomEngine& engine)
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295 {
0296 CLHEP::RandFlat r(engine);
0297
0298 Threevec v;
0299
0300 double U = r.fire(0.0, 1.0);
0301 double V = r.fire(0.0, 1.0);
0302
0303 double theta = 2.0 * CLHEP::pi * U;
0304 double phi = acos(2 * V - 1.0);
0305
0306 double x = sin(theta) * cos(phi);
0307 double y = sin(theta) * sin(phi);
0308 double z = cos(theta);
0309
0310 v = Threevec(x, y, z);
0311
0312 return v.unit();
0313 }
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329 Fourvec make_massive(const Threevec& p, double m_true, double sigma, CLHEP::HepRandomEngine& engine)
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344 {
0345 CLHEP::RandBreitWigner rbw(engine);
0346 double m = rbw.fire(m_true, sigma);
0347 return Fourvec(p, sqrt(m * m + p.mag2()));
0348 }
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367 void decay(const Fourvec& v, double m1, double m2, CLHEP::HepRandomEngine& engine, Fourvec& vout1, Fourvec& vout2)
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381 {
0382
0383
0384 Threevec p = rand_spher(engine);
0385 double m0 = v.m();
0386
0387 if (m1 + m2 > m0) {
0388
0389 double f = m0 / (m1 + m2);
0390 m1 *= f;
0391 m2 *= f;
0392 }
0393
0394 double m0_2 = m0 * m0;
0395 double m1_2 = m1 * m1;
0396 double m2_2 = m2 * m2;
0397
0398
0399 p *= 0.5 / m0 *
0400 sqrt(m0_2 * m0_2 + m1_2 * m1_2 + m2_2 * m2_2 - 2 * m0_2 * m1_2 - 2 * m0_2 * m2_2 - 2 * m1_2 * m2_2);
0401 double p2 = p.mag2();
0402
0403 vout1 = Fourvec(p, sqrt(p2 + m1_2));
0404 vout2 = Fourvec(-p, sqrt(p2 + m2_2));
0405
0406
0407 vout1.boost(v.boostVector());
0408 vout2.boost(v.boostVector());
0409 }
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420 Threevec rand_pt(double pt_mean, CLHEP::HepRandomEngine& engine)
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432 {
0433 CLHEP::RandExponential rexp(engine);
0434
0435
0436 Threevec p = rand_spher(engine);
0437
0438
0439 p *= (rexp.fire(pt_mean) / p.perp());
0440
0441 return p;
0442 }
0443
0444
0445
0446
0447
0448
0449
0450
0451 Fourvec rand_boost(const Gentop_Args& args, CLHEP::HepRandomEngine& engine)
0452
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462 {
0463 CLHEP::RandExponential rexp(engine);
0464 CLHEP::RandFlat rflat(engine);
0465 CLHEP::RandGauss rgauss(engine);
0466
0467
0468 Threevec p(1, 0, 0);
0469 p.rotateZ(rflat.fire(0, 2 * M_PI));
0470 p *= rexp.fire(args.recoil_pt_mean());
0471 p.setZ(rgauss.fire(0, args.boost_sigma()));
0472 return Fourvec(p, sqrt(p.mag2() + args.m_boost() * args.m_boost()));
0473 }
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484 void tagsim(const Gentop_Args& args, Lepjets_Event& ev, CLHEP::HepRandomEngine& engine)
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496 {
0497 CLHEP::RandFlat rflat(engine);
0498 for (std::vector<Lepjets_Event_Jet>::size_type i = 0; i < ev.njets(); i++) {
0499 int typ = ev.jet(i).type();
0500 if (typ == hadb_label || typ == lepb_label || typ == higgs_label) {
0501 if (rflat.fire() < args.svx_tageff())
0502 ev.jet(i).svx_tag() = true;
0503 }
0504 }
0505 }
0506
0507 }
0508
0509
0510
0511
0512
0513 Lepjets_Event gentop(const Gentop_Args& args, CLHEP::HepRandomEngine& engine)
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524 {
0525 CLHEP::RandBreitWigner rbw(engine);
0526 CLHEP::RandGauss rgauss(engine);
0527
0528
0529 Threevec p = rand_pt(args.t_pt_mean(), engine);
0530
0531
0532 Fourvec lept = make_massive(p, args.mt(), args.sigma_mt(), engine);
0533 Fourvec hadt = make_massive(-p, args.mt(), args.sigma_mt(), engine);
0534
0535
0536 Fourvec boost = rand_boost(args, engine);
0537 lept.boost(boost.boostVector());
0538 hadt.boost(boost.boostVector());
0539
0540
0541 Fourvec lepb, lepw;
0542 double mlb = rgauss.fire(args.mb(), args.sigma_mb());
0543 double mlw = rbw.fire(args.mw(), args.sigma_mw());
0544 decay(lept, mlb, mlw, engine, lepb, lepw);
0545
0546
0547 Fourvec hadb, hadw;
0548 double mhb = rgauss.fire(args.mb(), args.sigma_mb());
0549 double mhw = rbw.fire(args.mw(), args.sigma_mw());
0550 decay(hadt, mhb, mhw, engine, hadb, hadw);
0551
0552
0553 Fourvec lep, nu;
0554 decay(lepw, 0, 0, engine, lep, nu);
0555
0556
0557 Fourvec q1, q2;
0558 decay(hadw, 0, 0, engine, q1, q2);
0559
0560
0561 Lepjets_Event ev(0, ++next_evnum);
0562 Vector_Resolution lep_res(args.muon() ? args.muo_res_str() : args.ele_res_str());
0563 Vector_Resolution jet_res(args.jet_res_str());
0564 Resolution kt_res = (args.kt_res_str());
0565
0566 ev.add_lep(Lepjets_Event_Lep(lep, args.muon() ? muon_label : electron_label, lep_res));
0567
0568 ev.add_jet(Lepjets_Event_Jet(lepb, lepb_label, jet_res));
0569 ev.add_jet(Lepjets_Event_Jet(hadb, hadb_label, jet_res));
0570 ev.add_jet(Lepjets_Event_Jet(q1, hadw1_label, jet_res));
0571 ev.add_jet(Lepjets_Event_Jet(q2, hadw2_label, jet_res));
0572
0573 ev.met() = nu;
0574 ev.kt_res() = kt_res;
0575
0576
0577 tagsim(args, ev, engine);
0578
0579
0580 if (args.smear())
0581 ev.smear(engine, args.smear_dir());
0582
0583
0584 return ev;
0585 }
0586
0587 Lepjets_Event gentth(const Gentop_Args& args, CLHEP::HepRandomEngine& engine)
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598 {
0599 CLHEP::RandBreitWigner rbw(engine);
0600 CLHEP::RandGauss rgauss(engine);
0601
0602
0603 Threevec p_t1 = rand_pt(args.t_pt_mean(), engine);
0604 Threevec p_t2 = rand_pt(args.t_pt_mean(), engine);
0605
0606
0607 Threevec p_h = -(p_t1 + p_t2);
0608
0609
0610 Fourvec lept = make_massive(p_t1, args.mt(), args.sigma_mt(), engine);
0611 Fourvec hadt = make_massive(p_t2, args.mt(), args.sigma_mt(), engine);
0612 Fourvec higgs = make_massive(p_h, args.mh(), args.sigma_mh(), engine);
0613
0614
0615 Fourvec boost = rand_boost(args, engine);
0616 lept.boost(boost.boostVector());
0617 hadt.boost(boost.boostVector());
0618 higgs.boost(boost.boostVector());
0619
0620
0621 Fourvec lepb, lepw;
0622 decay(lept, rgauss.fire(args.mb(), args.sigma_mb()), rbw.fire(args.mw(), args.sigma_mw()), engine, lepb, lepw);
0623
0624
0625 Fourvec hadb, hadw;
0626 decay(hadt, rgauss.fire(args.mb(), args.sigma_mb()), rbw.fire(args.mw(), args.sigma_mw()), engine, hadb, hadw);
0627
0628
0629 Fourvec lep, nu;
0630 decay(lepw, 0, 0, engine, lep, nu);
0631
0632
0633 Fourvec q1, q2;
0634 decay(hadw, 0, 0, engine, q1, q2);
0635
0636
0637 Fourvec hb1, hb2;
0638 decay(higgs, rgauss.fire(args.mb(), args.sigma_mb()), rgauss.fire(args.mb(), args.sigma_mb()), engine, hb1, hb2);
0639
0640
0641 Lepjets_Event ev(0, ++next_evnum);
0642 Vector_Resolution lep_res(args.muon() ? args.muo_res_str() : args.ele_res_str());
0643 Vector_Resolution jet_res(args.jet_res_str());
0644 Resolution kt_res = (args.kt_res_str());
0645
0646 ev.add_lep(Lepjets_Event_Lep(lep, args.muon() ? muon_label : electron_label, lep_res));
0647
0648 ev.add_jet(Lepjets_Event_Jet(lepb, lepb_label, jet_res));
0649 ev.add_jet(Lepjets_Event_Jet(hadb, hadb_label, jet_res));
0650 ev.add_jet(Lepjets_Event_Jet(q1, hadw1_label, jet_res));
0651 ev.add_jet(Lepjets_Event_Jet(q2, hadw2_label, jet_res));
0652 ev.add_jet(Lepjets_Event_Jet(hb1, higgs_label, jet_res));
0653 ev.add_jet(Lepjets_Event_Jet(hb2, higgs_label, jet_res));
0654
0655 ev.met() = nu;
0656 ev.kt_res() = kt_res;
0657
0658
0659 tagsim(args, ev, engine);
0660
0661
0662 if (args.smear())
0663 ev.smear(engine, args.smear_dir());
0664
0665
0666 return ev;
0667 }
0668
0669 }