193 {
194
198 << " Aborting ... ");
199 return;
200 }
202
206 << " Aborting ... " );
207 return;
208 }
210
214 << " Aborting ... ");
215 return;
216 }
218
222 << " Aborting ... ");
223 return;
224 }
226
229
230 writeLHE.headerBlock() << readH.headerBlock;
231 writeLHE.initComments() << readH.initComments;
232 writeLHE.heprup = readH.heprup;
233 writeLHE.init();
234
235 long neve = 0;
237
238
239
240
241
242
243 while( readH.readEvent() ){
244
245 int ID_l[4] = {-999, -999, -999, -999};
246 int decayModeType = 4.0 *
m_rand.Rndm();
247
248 if (decayModeType == 0){
249
250 read4f = &read4e;
252 }
253 else if (decayModeType == 1 || decayModeType == 2){
254
255 read4f = &read2e2mu;
257 for(
int i = 2;
i < 4;
i++) ID_l[i] =
m_muonID;
258 }
259 else {
260
261 read4f = &read4mu;
262 for(
int i = 0;
i < 4;
i++) ID_l[i] =
m_muonID;
263 }
264
265 if( !read4f->readEvent() ){
266 ANA_MSG_INFO(
"Still Powheg events but no more Prophecy4f ");
267 ANA_MSG_INFO(
"events! Writing out LHE file ... Events processed so far " << neve );
268 break;
269 }
270
271 ++neve;
272 if(neve%1000==0){
273 print(
"Events processed so far ", neve);
274 }
275 if( readH.outsideBlock.length() )
277
278 int nup_org=readH.hepeup.NUP;
279
280 for(int nup=0; nup<nup_org; nup++){
282 readH.hepeup.ISTUP[nup]=2;
283 }
284 writeLHE.hepeup = readH.hepeup;
285
286 double P4_Z[5][2]{};
287 double P4_l[5][5]{};
288
289 double Pph[5] = {-999., -999., -999., -999., -999.};
290 double daughter2[5][5]{};
291
292 for(
int i=0;
i<nup_org;
i++){
294 TLorentzVector higgs( readH.hepeup.PUP[i][0],
295 readH.hepeup.PUP[i][1],
296 readH.hepeup.PUP[i][2],
297 readH.hepeup.PUP[i][3] );
298
299 TVector3 boostvec = higgs.BoostVector();
300 TLorentzRotation boost(-boostvec);
301 TLorentzRotation backboost(boostvec);
302
303
304 TLorentzVector r_higgs(higgs);
305 r_higgs*=boost;
306
307
308
309 writeLHE.hepeup.resize(nup_org+read4f->hepeup.NUP);
310
311 TLorentzVector sum_daughter;
312 TLorentzVector sum_daughter_rest;
313 TLorentzVector sum_daughter_rest_init;
314
315 for(
int k=0;
k<read4f->hepeup.NUP;
k++){
316 TLorentzVector daughter(read4f->hepeup.PUP[k][0],
317 read4f->hepeup.PUP[k][1],
318 read4f->hepeup.PUP[k][2],
319 read4f->hepeup.PUP[k][3]);
320 sum_daughter_rest_init+=daughter;
321 }
322
323 for(int j=0; j<read4f->hepeup.NUP; j++){
324 TLorentzVector daughter(read4f->hepeup.PUP[j][0],
325 read4f->hepeup.PUP[j][1],
326 read4f->hepeup.PUP[j][2],
327 read4f->hepeup.PUP[j][3]);
328 sum_daughter_rest+=daughter;
329
330 daughter *= backboost;
331 daughter *= higgs.M()/sum_daughter_rest_init.M();
332
333
336 break;
337 }
338
339 sum_daughter+=daughter;
340
342 std::abs(read4f->hepeup.IDUP[j])==
m_muonID ){
343
344
345 P4_l[0][j] = daughter.Px();
346 P4_l[1][j] = daughter.Py();
347 P4_l[2][j] = daughter.Pz();
348 P4_l[3][j] = daughter.E();
349
350 }
351 else if( std::abs(read4f->hepeup.IDUP[j])==
m_photonID ){
352 Pph[0] = daughter.Px();
353 Pph[1] = daughter.Py();
354 Pph[2] = daughter.Pz();
355 Pph[3] = daughter.E();
356 Pph[4] =0.0;
357 }
358 }
359
360 for(
int n=0;
n<4;
n++){
363
364
365 P4_Z[
n][0] = P4_l[
n][0] + P4_l[
n][1];
366 P4_Z[
n][1] = P4_l[
n][2] + P4_l[
n][3];
367 }
368 }
369
370 double mass1, mass2;
371 P4_Z[4][0] = sqrt(P4_Z[3][0] * P4_Z[3][0] - P4_Z[0][0] * P4_Z[0][0] - P4_Z[1][0] * P4_Z[1][0] - P4_Z[2][0] * P4_Z[2][0]);
372 P4_Z[4][1] = sqrt(P4_Z[3][1] * P4_Z[3][1] - P4_Z[0][1] * P4_Z[0][1] - P4_Z[1][1] * P4_Z[1][1] - P4_Z[2][1] * P4_Z[2][1]);
375
376 double p1[5],
p2[5], pZ1[5],
p3[5], p4[5], pZ2[5];
377 for(
int u=0;
u<5;
u++){
378
385
386 }
387
391 p4[4] = 0.0;
392
393
394
395 rescms(pZ1, p1, p2, mass1, mass1);
396 rescms(pZ2, p3, p4, mass2, mass2);
397
398 for(
int d =0;
d<5;
d++){
399 daughter2[0][
d] =
p1[
d];
400 daughter2[1][
d] =
p2[
d];
401 daughter2[2][
d] =
p3[
d];
402 daughter2[3][
d] = p4[
d];
403 daughter2[4][
d] = Pph[
d];
404 }
405
406
407 bool doDebug = false;
408 doDebug = true;
409 if (doDebug) {
410
413 ANA_MSG_DEBUG(
"Higgs " << higgs.M() <<
", " << higgs.Pt() <<
"," << higgs.Eta() <<
"," << higgs.Phi());
414
415
416 TLorentzVector higgsFromChildren;
417 for(
int d =0;
d < read4f->hepeup.NUP;
d++){
418 TLorentzVector child;
419 child.SetXYZM( daughter2[d][0],
420 daughter2[d][1],
421 daughter2[d][2],
422 daughter2[d][4] );
423
424 ANA_MSG_DEBUG(
"child " << d <<
" " << child.M() <<
", " << child.Pt() <<
", " << child.Eta() <<
", " << child.Phi());
425 higgsFromChildren += child;
426 }
427 ANA_MSG_DEBUG(
"Higgs mass " << higgs.M() <<
", from children " << higgsFromChildren.M() <<
", diff " << higgs.M() - higgsFromChildren.M());
428 }
429 break;
430 }
431 }
432
433
435 writeLHE.hepeup = readH.hepeup;
436 }
437 else{
438
439 for(int jp=0; jp<read4f->hepeup.NUP; jp++){
440 if (jp < 4){
441 writeLHE.hepeup.IDUP[nup_org+jp] = (jp % 2 == 0)? ID_l[jp] : -ID_l[jp];
442
443 }
444 else{
445 writeLHE.hepeup.IDUP[nup_org+jp] = read4f->hepeup.IDUP[jp];
446 }
447
448 writeLHE.hepeup.ISTUP[nup_org+jp]=read4f->hepeup.ISTUP[jp];
449 if( read4f->hepeup.ICOLUP[jp].first==0 &&
450 read4f->hepeup.ICOLUP[jp].second==0 ) {
451 writeLHE.hepeup.ICOLUP[nup_org+jp].first=0;
452 writeLHE.hepeup.ICOLUP[nup_org+jp].second=0;
453 }
454 else {
455 writeLHE.hepeup.ICOLUP[nup_org+jp].first=read4f->hepeup.ICOLUP[jp].first+100;
456 writeLHE.hepeup.ICOLUP[nup_org+jp].second=read4f->hepeup.ICOLUP[jp].second+100;
457 }
458 writeLHE.hepeup.MOTHUP[nup_org+jp].first=3;
459 writeLHE.hepeup.MOTHUP[nup_org+jp].second=3;
460 writeLHE.hepeup.PUP[nup_org+jp][0]=daughter2[jp][0];
461 writeLHE.hepeup.PUP[nup_org+jp][1]=daughter2[jp][1];
462 writeLHE.hepeup.PUP[nup_org+jp][2]=daughter2[jp][2];
463 writeLHE.hepeup.PUP[nup_org+jp][3]=daughter2[jp][3];
464 writeLHE.hepeup.PUP[nup_org+jp][4]=daughter2[jp][4];
465 writeLHE.hepeup.VTIMUP[nup_org+jp]=read4f->hepeup.VTIMUP[jp];
466 writeLHE.hepeup.SPINUP[nup_org+jp]=read4f->hepeup.SPINUP[jp];
467 }
468 }
469
470
471
472
473 writeLHE.hepeup.XWGTUP *= read4f->hepeup.XWGTUP;
474 double prophecyWeight = read4f->hepeup.XWGTUP;
475 if ( writeLHE.hepeup.weights_compressed.size() > 0 ) {
476 for ( int i = 1, N = writeLHE.hepeup.weights_compressed.size(); i < N; ++i ) {
477 writeLHE.hepeup.weights_compressed[
i] *= prophecyWeight;
478
479 }
480 }
481
482 writeLHE.eventComments() << readH.eventComments;
483 writeLHE.writeEvent();
484 }
485}
bool fileExists(const std::string &filename)
static const long m_higgsID
std::string m_inProphecy4mu
std::string m_inProphecy2e2mu
std::string m_inProphecy4e
static const long m_muonID
bool isPHevent(const TLorentzVector &higgs, const TLorentzVector &sum_daugh_rest_init)
int rescms(double *p, double *p1, double *p2, double m1, double m2)
void print(const std::string &field)
static const long m_photonID
static const long m_electronID
double setParticleMass(int id) const
@ u
Enums for curvilinear frames.