ATLAS Offline Software
PowhegV_EW.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // This program is based in the example "main31.cc" from the Pythia8 examples, used to interface Pythia shower with Powheg events
6 
7 // Copyright (C) 2012 Torbjorn Sjostrand.
8 // PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
9 // Please respect the MCnet Guidelines, see GUIDELINES for details.
10 
11 // Adapted to be Athena and Pythia8_i compliant by giancarlo.panizzo@cern.ch
12 
13 #include "Pythia8/Pythia.h"
14 #include "UserHooksUtils.h"
15 #include "UserSetting.h"
17 
18 
19 using namespace Pythia8;
20 
21 namespace Pythia8{
22  struct si_data_type {
25  };
26 
28  double xphcut;
29  double vetoscale_isr;
30  double vetoscale_fsr;
31  int evtnumber;
32  };
33 
34  class CustomV_EW;
35  class PowhegV_EW;
36 }
37 
40 
41 
42 namespace Pythia8{
43 
44  // Use userhooks to veto PYTHIA emissions above the POWHEG scale.
45  // CustomV_EW is intended to start from scalup the QED radiation from the
46  // resonance. It has to be used with SpaceShower:pTmaxMatch = 1 and "TimeShower:pTmaxMatch = 1"
47 
48  class CustomV_EW : public UserHooks {
49 
50  public:
51 
53 
54  std::cout<<"**********************************************************"<<std::endl;
55  std::cout<<"* *"<<std::endl;
56  std::cout<<"* SI: Defining custom UserHook needed *"<<std::endl;
57  std::cout<<"* to veto QED radiation (ptmaxmatch = 1) *"<<std::endl;
58  std::cout<<"* *"<<std::endl;
59  std::cout<<"* WARNING: This code is unvalidated!!! *"<<std::endl;
60  std::cout<<"* *"<<std::endl;
61  std::cout<<"**********************************************************"<<std::endl;
62 
63 
64  Pythia8_UserHooks::UserHooksFactory::userSettings<bool>()["m_si_data_.vetoqed"]=true;
65  Pythia8_UserHooks::UserHooksFactory::userSettings<bool>()["m_si_data_.py8veto"]=true;
66  Pythia8_UserHooks::UserHooksFactory::userSettings<double>()["m_si_event_info_.vetoscale_fsr"]=10.0;
67 
68  }
69 
71 
72  // Initialize settings.
73 
74  virtual bool initAfterBeams() override {
75  m_si_data_.vetoqed = settingsPtr->mode("m_si_data_.vetoqed");
76  m_si_data_.py8veto = settingsPtr->mode("m_si_data_.py8veto");
77  m_si_event_info_.vetoscale_fsr = settingsPtr->mode("m_si_event_info_.vetoscale_fsr");
78  return true;
79  }
80 
81 
82  // Allow process cross section to be modified..
83 
84  virtual bool canSetResonanceScale() override {
85  // If we are vetoing QED emissions, and ptmaxmatch = 1, and we are using PYTHIA8 based veto, set scale for QED radiation from leptons
86  // (the default would be the resonance mass)
87  std::cout << "**** SI: Allow to set scale to veto QED emissions in PYTHIA" << std::endl;
88  if ((m_si_data_.vetoqed) && (m_si_data_.py8veto)) return true;
89  else return false;
90  }
91 
92  using UserHooks::scaleResonance;
93  virtual double scaleResonance() {
94  // virtual double scaleResonance( const int iRes, const Event& event) {
95  // Set scale for the emissions from the resonace (FSR), equal to the scale stored in the LHE file
96  //std::cout << "SI in scaleResonance. Setting scale: " << si_event_info_.vetoscale_fsr << std::endl;
97  //std::cout << event[iRes].id();
98  //std::cout << "\n";
99 
101  }
102 
103  virtual double EventList( const Event& event)
104  {
105  event.list();
106  return false;
107  }
108 
109  private:
112  };
113 
114  // PowhegV_EW is intended to veto QCD radiation (ISR and FSR)
115  // and QED radiation from the resonance. So it has to be used with
116  // SpaceShower:pTmaxMatch = 2 and "TimeShower:pTmaxMatch = 2"
117 
118  class PowhegV_EW : public UserHooks {
119 
120  public:
121 
122  // Constructor and destructor.
124 
125  std::cout<<"**********************************************************"<<std::endl;
126  std::cout<<"* *"<<std::endl;
127  std::cout<<"* SI: Defining modified PowhegHook to perform *"<<std::endl;
128  std::cout<<"* the matching (ptmaxmatch = 2) *"<<std::endl;
129  std::cout<<"* *"<<std::endl;
130  std::cout<<"**********************************************************"<<std::endl;
131 
132  Pythia8_UserHooks::UserHooksFactory::userSettings<bool>()["m_si_data_.vetoqed"]=true;
133  Pythia8_UserHooks::UserHooksFactory::userSettings<bool>()["m_si_data_.py8veto"]=true;
134  Pythia8_UserHooks::UserHooksFactory::userSettings<double>()["m_si_event_info_.vetoscale_fsr"]=10.0;
135  Pythia8_UserHooks::UserHooksFactory::userSettings<double>()["m_si_event_info_.vetoscale_isr"]=10.0;
136 
137  };
138 
140 
141  // Initialize settings, detailing merging strategy to use.
142  bool initAfterBeams() {
143  m_nFinal = settingsPtr->mode("POWHEG:nFinal");
144  m_vetoMode = settingsPtr->mode("POWHEG:veto");
145  m_vetoCount = settingsPtr->mode("POWHEG:vetoCount");
146  m_pThardMode = settingsPtr->mode("POWHEG:pThard");
147  m_pTemtMode = settingsPtr->mode("POWHEG:pTemt");
148  m_emittedMode = settingsPtr->mode("POWHEG:emitted");
149  m_pTdefMode = settingsPtr->mode("POWHEG:pTdef");
150  m_MPIvetoMode = settingsPtr->mode("POWHEG:MPIveto");
151 
152  m_si_data_.vetoqed = settingsPtr->mode("si_data_.vetoqed");
153  m_si_data_.py8veto = settingsPtr->mode("si_data_.py8veto");
154  m_si_event_info_.vetoscale_fsr = settingsPtr->mode("m_si_event_info_.vetoscale_fsr");
155  m_si_event_info_.vetoscale_isr = settingsPtr->mode("m_si_event_info_.vetoscale_isr");
156  return true;
157  }
158 
159 
160  //--------------------------------------------------------------------------
161 
162  // Routines to calculate the pT (according to pTdefMode) in a splitting:
163  // ISR: i (radiator after) -> j (emitted after) k (radiator before)
164  // FSR: i (radiator before) -> j (emitted after) k (radiator after)
165  // For the Pythia pT definition, a recoiler (after) must be specified.
166 
167  // Compute the Pythia pT separation. Based on pTLund function in History.cc
168  double pTpythia(const Event &e, int RadAfterBranch, int EmtAfterBranch,
169  int RecAfterBranch, bool FSR) {
170 
171  // Convenient shorthands for later
172  Vec4 radVec = e[RadAfterBranch].p();
173  Vec4 emtVec = e[EmtAfterBranch].p();
174  Vec4 recVec = e[RecAfterBranch].p();
175  int radID = e[RadAfterBranch].id();
176 
177  // Calculate virtuality of splitting
178  double sign = (FSR) ? 1. : -1.;
179  Vec4 Q(radVec + sign * emtVec);
180  double Qsq = sign * Q.m2Calc();
181 
182  // Mass term of radiator
183  double m2Rad = (std::abs(radID) >= 4 && std::abs(radID) < 7) ?
184  pow2(particleDataPtr->m0(radID)) : 0.;
185 
186  // z values for FSR and ISR
187  double z, pTnow;
188  if (FSR) {
189  // Construct 2 -> 3 variables
190  Vec4 sum = radVec + recVec + emtVec;
191  double m2Dip = sum.m2Calc();
192  double x1 = 2. * (sum * radVec) / m2Dip;
193  double x3 = 2. * (sum * emtVec) / m2Dip;
194  z = x1 / (x1 + x3);
195  pTnow = z * (1. - z);
196 
197  } else {
198  // Construct dipoles before/after splitting
199  Vec4 qBR(radVec - emtVec + recVec);
200  Vec4 qAR(radVec + recVec);
201  z = qBR.m2Calc() / qAR.m2Calc();
202  pTnow = (1. - z);
203  }
204 
205  // Virtuality with correct sign
206  pTnow *= (Qsq - sign * m2Rad);
207 
208  // Can get negative pT for massive splittings
209  if (pTnow < 0.) {
210  std::cout << "Warning: pTpythia was negative" << std::endl;
211  return -1.;
212  }
213 
214 #ifdef DBGOUTPUT
215  std::cout << "pTpythia: rad = " << RadAfterBranch << ", emt = "
216  << EmtAfterBranch << ", rec = " << RecAfterBranch
217  << ", pTnow = " << std::sqrt(pTnow) << std::endl;
218 #endif
219 
220  // Return pT
221  return std::sqrt(pTnow);
222  }
223 
224  // Compute the POWHEG pT separation between i and j
225  // ISR: absolute pT of j
226  // FSR: pT of j w.r.t. to i
227  double pTpowheg(const Event &e, int i, int j, bool FSR) {
228 
229  // pT value for FSR and ISR
230  double pTnow = 0.;
231  if (FSR) {
232  // POWHEG d_ij (in CM frame). Note that the incoming beams have not
233  // been updated in the parton systems pointer yet (i.e. prior to any
234  // potential recoil).
235  int iInA = partonSystemsPtr->getInA(0);
236  int iInB = partonSystemsPtr->getInB(0);
237  double betaZ = - ( e[iInA].pz() + e[iInB].pz() ) /
238  ( e[iInA].e() + e[iInB].e() );
239  Vec4 iVecBst(e[i].p()), jVecBst(e[j].p());
240  iVecBst.bst(0., 0., betaZ);
241  jVecBst.bst(0., 0., betaZ);
242 
243  if ( e[i].id() == 21 && e[j].id() == 21) {
244  pTnow = std::sqrt( (iVecBst + jVecBst).m2Calc() *
245  iVecBst.e() * jVecBst.e() /
246  pow2(iVecBst.e() + jVecBst.e()) );
247  } else {
248  pTnow = std::sqrt( (iVecBst + jVecBst).m2Calc() *
249  jVecBst.e() / iVecBst.e() );
250  }
251 
252  } else {
253  // POWHEG pT_ISR is just kinematic pT
254  pTnow = e[j].pT();
255  }
256 
257  // Check result
258  if (pTnow < 0.) {
259  std::cout << "Warning: pTpowheg was negative" << std::endl;
260  return -1.;
261  }
262 
263 #ifdef DBGOUTPUT
264  std::cout << "pTpowheg: i = " << i << ", j = " << j
265  << ", pTnow = " << pTnow << std::endl;
266 #endif
267 
268  return pTnow;
269  }
270 
271  // Calculate pT for a splitting based on m_pTdefMode.
272  // If j is -1, all final-state partons are tried.
273  // If i, k, r and xSR are -1, then all incoming and outgoing
274  // partons are tried.
275  // xSR set to 0 means ISR, while xSR set to 1 means FSR
276  double pTcalc(const Event &e, int i, int j, int k, int r, int xSRin) {
277 
278 
279  // Loop over ISR and FSR if necessary
280  double pTemt = -1., pTnow;
281  int xSR1 = (xSRin == -1) ? 0 : xSRin;
282  int xSR2 = (xSRin == -1) ? 2 : xSRin + 1;
283  for (int xSR = xSR1; xSR < xSR2; xSR++) {
284  // FSR flag
285  bool FSR = (xSR == 0) ? false : true;
286 
287  // If all necessary arguments have been given, then directly calculate.
288  // POWHEG ISR and FSR, need i and j.
289  if ((m_pTdefMode == 0 || m_pTdefMode == 1) && i > 0 && j > 0) {
290  pTemt = pTpowheg(e, i, j, (m_pTdefMode == 0) ? false : FSR);
291 
292  // Pythia ISR, need i, j and r.
293  } else if (!FSR && m_pTdefMode == 2 && i > 0 && j > 0 && r > 0) {
294  pTemt = pTpythia(e, i, j, r, FSR);
295 
296  // Pythia FSR, need k, j and r.
297  } else if (FSR && m_pTdefMode == 2 && j > 0 && k > 0 && r > 0) {
298  pTemt = pTpythia(e, k, j, r, FSR);
299 
300  // Otherwise need to try all possible combintations.
301  } else {
302  // Start by finding incoming legs to the hard system after
303  // branching (radiator after branching, i for ISR).
304  // Use partonSystemsPtr to find incoming just prior to the
305  // branching and track mothers.
306  int iInA = partonSystemsPtr->getInA(0);
307  int iInB = partonSystemsPtr->getInB(0);
308  while (e[iInA].mother1() != 1) { iInA = e[iInA].mother1(); }
309  while (e[iInB].mother1() != 2) { iInB = e[iInB].mother1(); }
310 
311  // If we do not have j, then try all final-state partons
312  int jNow = (j > 0) ? j : 0;
313  int jMax = (j > 0) ? j + 1 : e.size();
314  for (; jNow < jMax; jNow++) {
315 
316  // Final-state jNow only
317  if ( !e[jNow].isFinal() ) continue;
318 
319  // POWHEG
320  if (m_pTdefMode == 0 || m_pTdefMode == 1) {
321 
322  // ISR - only done once as just kinematical pT
323  if (!FSR) {
324  pTnow = pTpowheg(e, iInA, jNow, (m_pTdefMode == 0) ? false : FSR);
325  if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow : min(pTemt, pTnow);
326 
327  // FSR - try all outgoing partons from system before branching
328  // as i. Note that for the hard system, there is no
329  // "before branching" information.
330  } else {
331 
332  int outSize = partonSystemsPtr->sizeOut(0);
333  for (int iMem = 0; iMem < outSize; iMem++) {
334  int iNow = partonSystemsPtr->getOut(0, iMem);
335 
336  // Coloured only, i != jNow and no carbon copies
337  if (iNow == jNow) continue;
338  if (jNow == e[iNow].daughter1()
339  && jNow == e[iNow].daughter2()) continue;
340 
341  pTnow = pTpowheg(e, iNow, jNow, (m_pTdefMode == 0)
342  ? false : FSR);
343  if (pTnow > 0.) pTemt = (pTemt < 0)
344  ? pTnow : min(pTemt, pTnow);
345  } // for (iMem)
346 
347  } // if (!FSR)
348 
349  // Pythia
350  } else if (m_pTdefMode == 2) {
351 
352  // ISR - other incoming as recoiler
353  if (!FSR) {
354  pTnow = pTpythia(e, iInA, jNow, iInB, FSR);
355  if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow : min(pTemt, pTnow);
356  pTnow = pTpythia(e, iInB, jNow, iInA, FSR);
357  if (pTnow > 0.) pTemt = (pTemt < 0) ? pTnow : min(pTemt, pTnow);
358 
359  // FSR - try all final-state coloured partons as radiator
360  // after emission (k).
361  } else {
362  for (int kNow = 0; kNow < e.size(); kNow++) {
363  if (kNow == jNow || !e[kNow].isFinal()) continue;
364 
365  // For this kNow, need to have a recoiler.
366  // Try two incoming.
367  pTnow = pTpythia(e, kNow, jNow, iInA, FSR);
368  if (pTnow > 0.) pTemt = (pTemt < 0)
369  ? pTnow : min(pTemt, pTnow);
370  pTnow = pTpythia(e, kNow, jNow, iInB, FSR);
371  if (pTnow > 0.) pTemt = (pTemt < 0)
372  ? pTnow : min(pTemt, pTnow);
373 
374  // Try all other outgoing.
375  for (int rNow = 0; rNow < e.size(); rNow++) {
376  if (rNow == kNow || rNow == jNow ||
377  !e[rNow].isFinal()) continue;
378  pTnow = pTpythia(e, kNow, jNow, rNow, FSR);
379  if (pTnow > 0.) pTemt = (pTemt < 0)
380  ? pTnow : min(pTemt, pTnow);
381  } // for (rNow)
382 
383  } // for (kNow)
384  } // if (!FSR)
385  } // if (m_pTdefMode)
386  } // for (j)
387  }
388  } // for (xSR)
389 
390 #ifdef DBGOUTPUT
391  std::cout << "pTcalc: i = " << i << ", j = " << j << ", k = " << k
392  << ", r = " << r << ", xSR = " << xSRin
393  << ", pTemt = " << pTemt << std::endl;
394 #endif
395 
396  return pTemt;
397  }
398 
399  //--------------------------------------------------------------------------
400 
401  // Extraction of m_pThard based on the incoming event.
402  // Assume that all the final-state particles are in a continuous block
403  // at the end of the event and the final entry is the POWHEG emission.
404  // If there is no POWHEG emission, then m_pThard is set to SCALUP.
405 
406  bool canVetoMPIStep() { return true; }
407  int numberVetoMPIStep() { return 1; }
408  bool doVetoMPIStep(int nMPI, const Event &e) {
409 
410  if (nMPI > 1) return false;
411 
412  // Find if there is a POWHEG emission. Go backwards through the
413  // event record until there is a non-final particle. Also sum pT and
414  // find pT_1 for possible MPI vetoing
415  int count = 0;
416  double pT1 = 0., pTsum = 0.;
417  for (int i = e.size() - 1; i > 0; i--) {
418  if (e[i].isFinal()) {
419  count++;
420  pT1 = e[i].pT();
421  pTsum += e[i].pT();
422  } else break;
423  }
424  // Extra check that we have the correct final state
425  if (count != m_nFinal && count != m_nFinal + 1) {
426  std::cout << "Error: wrong number of final state particles in event" << std::endl;
427  exit(1);
428  }
429  // Flag if POWHEG radiation present and index
430  bool isEmt = (count == m_nFinal) ? false : true;
431  int iEmt = (isEmt) ? e.size() - 1 : -1;
432 
433  // If there is no radiation or if m_pThardMode is 0 then set m_pThard = SCALUP.
434  m_pThard = -1;
435  // m_pThardMode is 0
436  if (!isEmt || m_pThardMode == 0) {
437  // This sets the scale to veto emissions in the QCD shower by Pythia
438  // This scale is used for all emissions, except if they come from the resonance
440  // Not using directly scalup, because the special file LHE (two scales)
441 
442  // If m_pThardMode is 1 then the pT of the POWHEG emission is checked against
443  // all other incoming and outgoing partons, with the minimal value taken
444  } else if (m_pThardMode == 1) {
445  m_pThard = pTcalc(e, -1, iEmt, -1, -1, -1);
446 
447  // If m_pThardMode is 2, then the pT of all final-state partons is checked
448  // against all other incoming and outgoing partons, with the minimal value
449  // taken
450  } else if (m_pThardMode == 2) {
451  m_pThard = pTcalc(e, -1, -1, -1, -1, -1);
452  }
453 
454  // Find MPI veto pT if necessary
455  if (m_MPIvetoMode == 1) {
456  m_pTMPI = (isEmt) ? pTsum / 2. : pT1;
457  }
458 
459 #ifdef DBGOUTPUT
460  std::cout << "doVetoMPIStep: Qfac = " << infoPtr->scalup()
461  << ", pThard = " << m_pThard << std::endl;
462 #endif
463 
464  // Initialise other variables
465  m_accepted = false;
467 
468  if(m_pThard < 0)
469  {
470  std::cout << "something wrong with pThard = " << m_pThard << std::endl;
471  exit(1);
472  }
473 
474  // Do not veto the event
475  return false;
476  }
477 
478  //--------------------------------------------------------------------------
479 
480  // ISR veto
481 
482  bool canVetoISREmission() { return (m_vetoMode == 0) ? false : true; }
483  bool doVetoISREmission(int, const Event &e, int iSys) {
484 
485  // Must be radiation from the hard system, otherwise return
486  if (iSys != 0) return false;
487 
488  // If m_vetocount != 0 and we already have accepted 'vetoCount' emissions in a row,
489  // do nothing; if m_vetocount = 0 check all emissions
490  if (m_vetoCount != 0 && m_nAcceptSeq >= m_vetoCount) return false;
491 
492  // Pythia radiator after, emitted and recoiler after.
493  int iRadAft = -1, iEmt = -1, iRecAft = -1;
494  for (int i = e.size() - 1; i > 0; i--) {
495  if (iRadAft == -1 && e[i].status() == -41) iRadAft = i;
496  else if (iEmt == -1 && e[i].status() == 43) iEmt = i;
497  else if (iRecAft == -1 && e[i].status() == -42) iRecAft = i;
498  if (iRadAft != -1 && iEmt != -1 && iRecAft != -1) break;
499  }
500  if (iRadAft == -1 || iEmt == -1 || iRecAft == -1) {
501  e.list();
502  std::cout << "Error: couldn't find Pythia ISR emission" << std::endl;
503  exit(1);
504  }
505 
506  // m_pTemtMode == 0: pT of emitted w.r.t. radiator
507  // m_pTemtMode == 1: min(pT of emitted w.r.t. all incoming/outgoing)
508  // m_pTemtMode == 2: min(pT of all outgoing w.r.t. all incoming/outgoing)
509  int xSR = (m_pTemtMode == 0) ? 0 : -1;
510  int i = (m_pTemtMode == 0) ? iRadAft : -1;
511  int j = (m_pTemtMode != 2) ? iEmt : -1;
512  int k = -1;
513  int r = (m_pTemtMode == 0) ? iRecAft : -1;
514  double pTemt = pTcalc(e, i, j, k, r, xSR);
515 
516 #ifdef DBGOUTPUT
517  std::cout << "doVetoISREmission: pTemt = " << pTemt << std::endl;
518 #endif
519 
520  // Veto if pTemt > m_pThard
521  if (pTemt > m_pThard) {
522  m_nAcceptSeq = 0;
523  m_nISRveto++;
524  return true;
525  }
526 
527  // Else mark that an emission has been accepted and continue
528  m_nAcceptSeq++;
529  m_accepted = true;
530 
531  return false;
532  }
533 
534  //--------------------------------------------------------------------------
535 
536  // FSR veto
537 
538  bool canVetoFSREmission() { return (m_vetoMode == 0) ? false : true; }
539  bool doVetoFSREmission(int, const Event &e, int iSys, bool inr) {
540  // radiation from the hard system: isys=0
541  // radiation from resonances: isys!=0 and inr=1
542  // MPI radiation: isys!=0 and inr=0
543 
544  // we do not veto MPI radiation
545  // if we veto here gamma from resonance (inr==1),
546  // we do not have to use canSetResonanceScale
547  if (iSys != 0 && inr != 1) return false;
548 
549  // In case of radiation from resonance we veto
550  // This is used for ptmaxmatch = 2.
551  // If py8veto = 1, this method is also used to veto photons, otherwise, use external function
552  // force the radiation scale, m_pThard, to be equal to the one set in the LHE file
553  if (inr == 1) {
554  if ((m_si_data_.vetoqed == false) || (m_si_data_.py8veto == false)) {
555  return false;
556  }
557  else {
558  // Set scale for FSR from the resonance
560  }
561  }
562 
563 
564  // If m_vetocount != 0 and we already have accepted 'vetoCount' emissions in a row,
565  // do nothing; if m_vetocount = 0 check all emissions
566  if (m_vetoCount != 0 && m_nAcceptSeq >= m_vetoCount) return false;
567 
568  // Pythia radiator (before and after), emitted and recoiler (after)
569  int iRecAft = e.size() - 1;
570  int iEmt = e.size() - 2;
571  int iRadAft = e.size() - 3;
572  int iRadBef = e[iEmt].mother1();
573  if ( (e[iRecAft].status() != 52 && e[iRecAft].status() != -53) ||
574  e[iEmt].status() != 51 || e[iRadAft].status() != 51) {
575  e.list();
576  std::cout << "Error: couldn't find Pythia FSR emission" << std::endl;
577  exit(1);
578  }
579 
580  // Behaviour based on m_pTemtMode:
581  // 0 - pT of emitted w.r.t. radiator before
582  // 1 - min(pT of emitted w.r.t. all incoming/outgoing)
583  // 2 - min(pT of all outgoing w.r.t. all incoming/outgoing)
584  int xSR = (m_pTemtMode == 0) ? 1 : -1;
585 
586  int i = (m_pTemtMode == 0) ? iRadBef : -1;
587  i = (m_pTdefMode == 1) ? iRadAft : iRadBef;
588  // using POWHEG pT definition i should be iRadAft (daugther)
589  int k = (m_pTemtMode == 0) ? iRadAft : -1;
590  int r = (m_pTemtMode == 0) ? iRecAft : -1;
591 
592  // When pTemtMode is 0 or 1, iEmt has been selected
593  double pTemt = 0.;
594  if (m_pTemtMode == 0 || m_pTemtMode == 1) {
595  // Which parton is emitted, based on m_emittedMode:
596  // 0 - Pythia definition of emitted
597  // 1 - Pythia definition of radiated after emission
598  // 2 - Random selection of emitted or radiated after emission
599  // 3 - Try both emitted and radiated after emission
600 
601  // j = radiator after
602 
603  int j = iRadAft;
604  //m_emittedMode = 0 -> j = iRadAft + 1 = iEmt
605  if (m_emittedMode == 0 || (m_emittedMode == 2 && rndmPtr->flat() < 0.5)) j++;
606 
607  for (int jLoop = 0; jLoop < 2; jLoop++) {
608  if (jLoop == 0) pTemt = pTcalc(e, i, j, k, r, xSR);
609  else if (jLoop == 1) pTemt = min(pTemt, pTcalc(e, i, j, k, r, xSR));
610 
611  // For m_emittedMode == 3, have tried iRadAft, now try iEmt
612  if (m_emittedMode != 3) break;
613  if (k != -1) swap(j, k); else j = iEmt;
614  }
615 
616  // If m_pTemtMode is 2, then try all final-state partons as emitted
617  } else if (m_pTemtMode == 2) {
618  pTemt = pTcalc(e, i, -1, k, r, xSR);
619  }
620 
621 #ifdef DBGOUTPUT
622  std::cout << "doVetoFSREmission: pTemt = " << pTemt << std::endl;
623 #endif
624 
625  // Veto if pTemt > m_pThard
626  if (pTemt > m_pThard) {
627  m_nAcceptSeq = 0;
628  m_nFSRveto++;
629  return true;
630  }
631 
632  // Else mark that an emission has been accepted and continue
633  m_nAcceptSeq++;
634  m_accepted = true;
635  return false;
636  }
637 
638  //--------------------------------------------------------------------------
639 
640  // MPI veto
641 
642  bool canVetoMPIEmission() { return (m_MPIvetoMode == 0) ? false : true; }
643  bool doVetoMPIEmission(int, const Event &e) {
644 
645  if (m_MPIvetoMode == 1) {
646  if (e[e.size() - 1].pT() > m_pTMPI) {
647 #ifdef DBGOUTPUT
648  std::cout << "doVetoMPIEmission: pTnow = " << e[e.size() - 1].pT()
649  << ", pTMPI = " << m_pTMPI << std::endl;
650 #endif
651  return true;
652  }
653  }
654  return false;
655  }
656 
657  //--------------------------------------------------------------------------
658 
659  // Functions to return information
660 
661  int getNISRveto() { return m_nISRveto; }
662  int getNFSRveto() { return m_nFSRveto; }
663 
664  private:
667  double m_pThard{}, m_pTMPI{};
668  bool m_accepted{};
669  // The number of accepted emissions (in a row)
671  // Statistics on vetos
672  unsigned long int m_nISRveto{}, m_nFSRveto{};
675  };
676 
677 } // end namespace Pythia8
678 
Pythia8::PowhegV_EW::PowhegV_EW
PowhegV_EW()
Definition: PowhegV_EW.cxx:123
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
beamspotman.r
def r
Definition: beamspotman.py:676
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
Pythia8::si_data_type
Definition: PowhegV_EW.cxx:22
PowhegV_EWCreator
Pythia8_UserHooks::UserHooksFactory::Creator< Pythia8::PowhegV_EW > PowhegV_EWCreator("PowhegV_EW")
Pythia8::si_data_type::use_photos
bool use_photos
Definition: PowhegV_EW.cxx:24
FSR
Definition: FsrPhotonTool.h:24
Pythia8::PowhegV_EW::~PowhegV_EW
~PowhegV_EW()
Definition: PowhegV_EW.cxx:139
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
Event
Definition: trigbs_orderedMerge.cxx:42
Pythia8::si_data_type::nohad
bool nohad
Definition: PowhegV_EW.cxx:24
Pythia8::CustomV_EW::m_si_event_info_
si_event_info_type m_si_event_info_
Definition: PowhegV_EW.cxx:111
Pythia8::PowhegV_EW::canVetoMPIStep
bool canVetoMPIStep()
Definition: PowhegV_EW.cxx:406
Pythia8::PowhegV_EW::m_vetoCount
int m_vetoCount
Definition: PowhegV_EW.cxx:665
Pythia8::PowhegV_EW::numberVetoMPIStep
int numberVetoMPIStep()
Definition: PowhegV_EW.cxx:407
Pythia8::PowhegV_EW::m_nAcceptSeq
int m_nAcceptSeq
Definition: PowhegV_EW.cxx:670
Pythia8::si_event_info_type::vetoscale_isr
double vetoscale_isr
Definition: PowhegV_EW.cxx:29
Pythia8_UserHooks::UserHooksFactory::Creator
Definition: UserHooksFactory.h:54
Pythia8::si_event_info_type::evtnumber
int evtnumber
Definition: PowhegV_EW.cxx:31
Pythia8::si_event_info_type::xphcut
double xphcut
Definition: PowhegV_EW.cxx:28
Pythia8::PowhegV_EW::m_pThardMode
int m_pThardMode
Definition: PowhegV_EW.cxx:665
Pythia8::PowhegV_EW::initAfterBeams
bool initAfterBeams()
Definition: PowhegV_EW.cxx:142
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
UserHooksFactory.h
Pythia8::PowhegV_EW::m_emittedMode
int m_emittedMode
Definition: PowhegV_EW.cxx:666
Pythia8
Author: James Monk (jmonk@cern.ch)
Definition: IPythia8Custom.h:13
Pythia8::PowhegV_EW::canVetoISREmission
bool canVetoISREmission()
Definition: PowhegV_EW.cxx:482
Pythia8::CustomV_EW::m_si_data_
si_data_type m_si_data_
Definition: PowhegV_EW.cxx:110
Pythia8::PowhegV_EW::doVetoMPIStep
bool doVetoMPIStep(int nMPI, const Event &e)
Definition: PowhegV_EW.cxx:408
Pythia8::PowhegV_EW::getNFSRveto
int getNFSRveto()
Definition: PowhegV_EW.cxx:662
Pythia8::PowhegV_EW::m_vetoMode
int m_vetoMode
Definition: PowhegV_EW.cxx:665
Pythia8::CustomV_EW::CustomV_EW
CustomV_EW()
Definition: PowhegV_EW.cxx:52
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
Pythia8::CustomV_EW::canSetResonanceScale
virtual bool canSetResonanceScale() override
Definition: PowhegV_EW.cxx:84
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
Pythia8::PowhegV_EW::m_pThard
double m_pThard
Definition: PowhegV_EW.cxx:667
Pythia8::PowhegV_EW::pTpythia
double pTpythia(const Event &e, int RadAfterBranch, int EmtAfterBranch, int RecAfterBranch, bool FSR)
Definition: PowhegV_EW.cxx:168
Pythia8::CustomV_EW::EventList
virtual double EventList(const Event &event)
Definition: PowhegV_EW.cxx:103
Pythia8::PowhegV_EW::getNISRveto
int getNISRveto()
Definition: PowhegV_EW.cxx:661
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
CustomV_EWCreator
Pythia8_UserHooks::UserHooksFactory::Creator< Pythia8::CustomV_EW > CustomV_EWCreator("CustomV_EW")
Pythia8::si_data_type::vetoqed
bool vetoqed
Definition: PowhegV_EW.cxx:24
Pythia8::si_event_info_type
Definition: PowhegV_EW.cxx:27
UserSetting.h
Pythia8::PowhegV_EW::m_si_event_info_
si_event_info_type m_si_event_info_
Definition: PowhegV_EW.cxx:674
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
calibdata.exit
exit
Definition: calibdata.py:236
Pythia8::PowhegV_EW::m_si_data_
si_data_type m_si_data_
Definition: PowhegV_EW.cxx:673
Pythia8::CustomV_EW::initAfterBeams
virtual bool initAfterBeams() override
Definition: PowhegV_EW.cxx:74
Pythia8::PowhegV_EW::m_pTMPI
double m_pTMPI
Definition: PowhegV_EW.cxx:667
Pythia8::PowhegV_EW::canVetoMPIEmission
bool canVetoMPIEmission()
Definition: PowhegV_EW.cxx:642
Pythia8::PowhegV_EW::pTcalc
double pTcalc(const Event &e, int i, int j, int k, int r, int xSRin)
Definition: PowhegV_EW.cxx:276
Pythia8::PowhegV_EW::m_MPIvetoMode
int m_MPIvetoMode
Definition: PowhegV_EW.cxx:666
Pythia8::PowhegV_EW::m_nFinal
int m_nFinal
Definition: PowhegV_EW.cxx:665
Pythia8::PowhegV_EW::pTpowheg
double pTpowheg(const Event &e, int i, int j, bool FSR)
Definition: PowhegV_EW.cxx:227
Pythia8::si_data_type::savelhe
bool savelhe
Definition: PowhegV_EW.cxx:24
Pythia8::PowhegV_EW::m_accepted
bool m_accepted
Definition: PowhegV_EW.cxx:668
Pythia8::si_event_info_type::vetoscale_fsr
double vetoscale_fsr
Definition: PowhegV_EW.cxx:30
Pythia8::PowhegV_EW::m_pTemtMode
int m_pTemtMode
Definition: PowhegV_EW.cxx:665
UserHooksUtils.h
Pythia8::CustomV_EW
Definition: PowhegV_EW.cxx:48
Pythia8::PowhegV_EW::m_nFSRveto
unsigned long int m_nFSRveto
Definition: PowhegV_EW.cxx:672
Pythia8::CustomV_EW::scaleResonance
virtual double scaleResonance()
Definition: PowhegV_EW.cxx:93
Pythia8::PowhegV_EW
Definition: PowhegV_EW.cxx:118
Pythia8::si_data_type::noQEDqopt
bool noQEDqopt
Definition: PowhegV_EW.cxx:24
Pythia8::PowhegV_EW::m_nISRveto
unsigned long int m_nISRveto
Definition: PowhegV_EW.cxx:672
Pythia8::PowhegV_EW::doVetoISREmission
bool doVetoISREmission(int, const Event &e, int iSys)
Definition: PowhegV_EW.cxx:483
Pythia8::PowhegV_EW::canVetoFSREmission
bool canVetoFSREmission()
Definition: PowhegV_EW.cxx:538
merge.status
status
Definition: merge.py:17
Pythia8::si_data_type::py8veto
bool py8veto
Definition: PowhegV_EW.cxx:24
Pythia8::PowhegV_EW::doVetoMPIEmission
bool doVetoMPIEmission(int, const Event &e)
Definition: PowhegV_EW.cxx:643
Pythia8::si_data_type::pytune
int pytune
Definition: PowhegV_EW.cxx:23
Pythia8::PowhegV_EW::doVetoFSREmission
bool doVetoFSREmission(int, const Event &e, int iSys, bool inr)
Definition: PowhegV_EW.cxx:539
fitman.k
k
Definition: fitman.py:528
Pythia8::CustomV_EW::~CustomV_EW
~CustomV_EW()
Definition: PowhegV_EW.cxx:70
Pythia8::PowhegV_EW::m_pTdefMode
int m_pTdefMode
Definition: PowhegV_EW.cxx:666
Pythia8::si_data_type::pythiamatching
int pythiamatching
Definition: PowhegV_EW.cxx:23