198 <<
" Aborting ... ");
206 <<
" Aborting ... " );
214 <<
" Aborting ... ");
222 <<
" Aborting ... ");
230 writeLHE.headerBlock() << readH.headerBlock;
231 writeLHE.initComments() << readH.initComments;
232 writeLHE.heprup = readH.heprup;
243 while( readH.readEvent() ){
245 int ID_l[4] = {-999, -999, -999, -999};
246 int decayModeType = 4.0 *
m_rand.Rndm();
248 if (decayModeType == 0){
253 else if (decayModeType == 1 || decayModeType == 2){
257 for(
int i = 2; i < 4; i++) ID_l[i] =
m_muonID;
262 for(
int i = 0; i < 4; i++) ID_l[i] =
m_muonID;
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 );
273 print(
"Events processed so far ", neve);
275 if( readH.outsideBlock.length() )
278 int nup_org=readH.hepeup.NUP;
280 for(
int nup=0; nup<nup_org; nup++){
282 readH.hepeup.ISTUP[nup]=2;
284 writeLHE.hepeup = readH.hepeup;
289 double Pph[5] = {-999., -999., -999., -999., -999.};
290 double daughter2[5][5]{};
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] );
299 TVector3 boostvec = higgs.BoostVector();
300 TLorentzRotation
boost(-boostvec);
301 TLorentzRotation backboost(boostvec);
304 TLorentzVector r_higgs(higgs);
309 writeLHE.hepeup.resize(nup_org+read4f->hepeup.NUP);
311 TLorentzVector sum_daughter;
312 TLorentzVector sum_daughter_rest;
313 TLorentzVector sum_daughter_rest_init;
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;
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;
330 daughter *= backboost;
331 daughter *= higgs.M()/sum_daughter_rest_init.M();
339 sum_daughter+=daughter;
342 std::abs(read4f->hepeup.IDUP[j])==
m_muonID ){
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();
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();
360 for(
int n=0; n<4; n++){
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];
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]);
376 double p1[5], p2[5], pZ1[5], p3[5], p4[5], pZ2[5];
377 for(
int u=0; u<5; u++){
395 rescms(pZ1, p1, p2, mass1, mass1);
396 rescms(pZ2, p3, p4, mass2, mass2);
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];
407 bool doDebug =
false;
413 ANA_MSG_DEBUG(
"Higgs " << higgs.M() <<
", " << higgs.Pt() <<
"," << higgs.Eta() <<
"," << higgs.Phi());
416 TLorentzVector higgsFromChildren;
417 for(
int d =0; d < read4f->hepeup.NUP; d++){
418 TLorentzVector child;
419 child.SetXYZM( daughter2[d][0],
424 ANA_MSG_DEBUG(
"child " << d <<
" " << child.M() <<
", " << child.Pt() <<
", " << child.Eta() <<
", " << child.Phi());
425 higgsFromChildren += child;
427 ANA_MSG_DEBUG(
"Higgs mass " << higgs.M() <<
", from children " << higgsFromChildren.M() <<
", diff " << higgs.M() - higgsFromChildren.M());
435 writeLHE.hepeup = readH.hepeup;
439 for(
int jp=0; jp<read4f->hepeup.NUP; jp++){
441 writeLHE.hepeup.IDUP[nup_org+jp] = (jp % 2 == 0)? ID_l[jp] : -ID_l[jp];
445 writeLHE.hepeup.IDUP[nup_org+jp] = read4f->hepeup.IDUP[jp];
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;
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;
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];
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;
482 writeLHE.eventComments() << readH.eventComments;
483 writeLHE.writeEvent();