CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
LHAupAlpgen Class Reference

#include <GeneratorInput.h>

Inheritance diagram for LHAupAlpgen:

Public Member Functions

bool fileFound ()
 
 LHAupAlpgen (const char *baseFNin, Pythia8::Info *infoPtrIn=NULL)
 
void printParticles ()
 
bool setEvent (int, double)
 
bool setInit ()
 
 ~LHAupAlpgen ()
 

Private Member Functions

bool addResonances ()
 
bool rescaleMomenta ()
 

Private Attributes

AlpgenPar alpgenPar
 
string baseFN
 
double ebmupA
 
double ebmupB
 
ifstream ifsUnw
 
int ihvy1
 
int ihvy2
 
istream * isUnw
 
int lprup
 
double mb
 
vector< Pythia8::LHAParticle > myParticles
 
string parFN
 
string unwFN
 

Static Private Attributes

static const double EWARNTHRESHOLD = 3e-3
 
static const double INCOMINGMIN = 1e-3
 
static const bool LHADEBUG = false
 
static const bool LHADEBUGRESCALE = false
 
static const double PTWARNTHRESHOLD = 1e-3
 
static const double ZEROTHRESHOLD = 1e-10
 

Detailed Description

Definition at line 84 of file GeneratorInput.h.

Constructor & Destructor Documentation

LHAupAlpgen::LHAupAlpgen ( const char *  baseFNin,
Pythia8::Info *  infoPtrIn = NULL 
)

Definition at line 194 of file GeneratorInput.cc.

References alpgenPar, baseFN, ifsUnw, isUnw, NULL, parFN, AlpgenPar::parse(), edm::setPtr(), and unwFN.

195  : baseFN(baseFNin), alpgenPar(infoPtrIn), isUnw(NULL) {
196 
197  // Set the info pointer if given
198  if (infoPtrIn) setPtr(infoPtrIn);
199 
200  // Read in '_unw.par' file to get parameters
201  ifstream ifsPar;
202  istream* isPar = NULL;
203 
204  // Try gzip file first then normal file afterwards
205 #ifdef GZIPSUPPORT
206  parFN = baseFN + "_unw.par.gz";
207  isPar = openFile(parFN.c_str(), ifsPar);
208  if (!ifsPar.is_open()) closeFile(isPar, ifsPar);
209 #endif
210  if (isPar == NULL) {
211  parFN = baseFN + "_unw.par";
212  isPar = openFile(parFN.c_str(), ifsPar);
213  if (!ifsPar.is_open()) {
214  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::LHAupAlpgen: "
215  "cannot open parameter file", parFN);
216  closeFile(isPar, ifsPar);
217  return;
218  }
219  }
220 
221  // Read entire contents into string and close file
222  string paramStr((istreambuf_iterator<char>(isPar->rdbuf())),
223  istreambuf_iterator<char>());
224 
225  // Make sure we reached EOF and not other error
226  if (ifsPar.bad()) {
227  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::LHAupAlpgen: "
228  "cannot read parameter file", parFN);
229  return;
230  }
231  closeFile(isPar, ifsPar);
232 
233  // Parse file and set LHEF header
234  alpgenPar.parse(paramStr);
235  if (infoPtr) setInfoHeader("AlpgenPar", paramStr);
236 
237  // Open '.unw' events file (with possible gzip support)
238 #ifdef GZIPSUPPORT
239  unwFN = baseFN + ".unw.gz";
240  isUnw = openFile(unwFN.c_str(), ifsUnw);
241  if (!ifsUnw.is_open()) closeFile(isUnw, ifsUnw);
242 #endif
243  if (isUnw == NULL) {
244  unwFN = baseFN + ".unw";
245  isUnw = openFile(unwFN.c_str(), ifsUnw);
246  if (!ifsUnw.is_open()) {
247  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::LHAupAlpgen: "
248  "cannot open event file", unwFN);
249  closeFile(isUnw, ifsUnw);
250  }
251  }
252 }
AlpgenPar alpgenPar
#define NULL
Definition: scimark2.h:8
istream * isUnw
void setPtr(std::vector< T, A > const &obj, std::type_info const &iToType, unsigned long iIndex, void const *&oPtr)
Definition: setPtr.h:75
bool parse(const string paramStr)
ifstream ifsUnw
LHAupAlpgen::~LHAupAlpgen ( )
inline

Definition at line 90 of file GeneratorInput.h.

References ifsUnw, and isUnw.

90 { closeFile(isUnw, ifsUnw); }
istream * isUnw
ifstream ifsUnw

Member Function Documentation

bool LHAupAlpgen::addResonances ( )
private

Definition at line 484 of file GeneratorInput.cc.

References funct::abs(), i, customizeTrackingMonitorSeedNumber::idx, ihvy1, LHADEBUG, lprup, mb, myParticles, template_L1THistoryDQMService_cfg::outOfOrder, printParticles(), and mathSSE::sqrt().

Referenced by setEvent().

484  {
485 
486  // Temporary storage for resonance information
487  int idT, statusT, mother1T, mother2T, col1T, col2T;
488  double pxT, pyT, pzT, eT, mT;
489  // Leave tau and spin as default values
490  double tauT = 0., spinT = 9.;
491 
492  // Alpgen process dependent parts. Processes:
493  // 1 = W + QQbar + jets
494  // 2 = Z/gamma* + QQbar + jets
495  // 3 = W + jets
496  // 4 = Z/gamma* + jets
497  // 10 = W + c + jets
498  // 14 = W + gamma + jets
499  // 15 = W + QQbar + gamma + jets
500  // When QQbar = ttbar, tops are not decayed in these processes.
501  // Explicitly reconstruct W/Z resonances; assumption is that the
502  // decay products are the last two particles.
503  if (lprup <= 4 || lprup == 10 || lprup == 14 || lprup == 15) {
504  // Decay products are the last two entries
505  int i1 = myParticles.size() - 1, i2 = i1 - 1;
506 
507  // Follow 'alplib/alpsho.f' procedure to get ID
508  if (myParticles[i1].idPart + myParticles[i2].idPart == 0)
509  idT = 0;
510  else
511  idT = - (myParticles[i1].idPart % 2) - (myParticles[i2].idPart % 2);
512  idT = (idT > 0) ? 24 : (idT < 0) ? -24 : 23;
513 
514  // Check that we get the expected resonance type; Z/gamma*
515  if (lprup == 2 || lprup == 4) {
516  if (idT != 23) {
517  if (infoPtr) infoPtr->errorMsg("Error in "
518  "LHAupAlpgen::addResonances: wrong resonance type in event");
519  return false;
520  }
521 
522  // W's
523  } else {
524  if (abs(idT) != 24) {
525  if (infoPtr) infoPtr->errorMsg("Error in "
526  "LHAupAlpgen::addResonances: wrong resonance type in event");
527  return false;
528  }
529  }
530 
531  // Remaining input
532  statusT = 2;
533  mother1T = 1;
534  mother2T = 2;
535  col1T = col2T = 0;
536  pxT = myParticles[i1].pxPart + myParticles[i2].pxPart;
537  pyT = myParticles[i1].pyPart + myParticles[i2].pyPart;
538  pzT = myParticles[i1].pzPart + myParticles[i2].pzPart;
539  eT = myParticles[i1].ePart + myParticles[i2].ePart;
540  mT = sqrt(eT*eT - pxT*pxT - pyT*pyT - pzT*pzT);
541  myParticles.push_back(LHAParticle(
542  idT, statusT, mother1T, mother2T, col1T, col2T,
543  pxT, pyT, pzT, eT, mT, tauT, spinT, -1.));
544 
545  // Update decay product mothers (note array size as if from 1)
546  myParticles[i1].mother1Part = myParticles[i2].mother1Part =
547  myParticles.size();
548  myParticles[i1].mother2Part = myParticles[i2].mother2Part = 0;
549 
550  // Processes:
551  // 5 = nW + mZ + j gamma + lH + jets
552  // 6 = QQbar + jets (QQbar = ttbar)
553  // 8 = QQbar + Higgs + jets (QQbar = ttbar)
554  // 13 = top + q (topprc = 1)
555  // 13 = top + b (topprc = 2)
556  // 13 = top + W + jets (topprc = 3)
557  // 13 = top + W + b (topprc = 4)
558  // 16 = QQbar + gamma + jets (QQbar = ttbar)
559  //
560  // When tops are present, they are decayed to Wb (both the W and b
561  // are not given), with this W also decaying (decay products given).
562  // The top is marked intermediate, the (intermediate) W is
563  // reconstructed from its decay products, and the decay product mothers
564  // updated. The final-state b is reconstructed from (top - W).
565  //
566  // W/Z resonances are given, as well as their decay products. The
567  // W/Z is marked intermediate, and the decay product mothers updated.
568  //
569  // It is always assumed that decay products are at the end.
570  // For processes 5 and 13, it is also assumed that the decay products
571  // are in the same order as the resonances.
572  // For processes 6, 8 and 16, the possibility of the decay products
573  // being out-of-order is also taken into account.
574  } else if ( ((lprup == 6 || lprup == 8 || lprup == 16) && ihvy1 == 6) ||
575  lprup == 5 || lprup == 13) {
576 
577  // Go backwards through the particles looking for W/Z/top
578  int idx = myParticles.size() - 1;
579  for (int i = myParticles.size() - 1; i > -1; i--) {
580 
581  // W or Z
582  if (myParticles[i].idPart == 23 ||
583  abs(myParticles[i].idPart) == 24) {
584 
585  // Check that decay products and resonance match up
586  int flav;
587  if (myParticles[idx].idPart + myParticles[idx - 1].idPart == 0)
588  flav = 0;
589  else
590  flav = - (myParticles[idx].idPart % 2)
591  - (myParticles[idx - 1].idPart % 2);
592  flav = (flav > 0) ? 24 : (flav < 0) ? -24 : 23;
593  if (flav != myParticles[i].idPart) {
594  if (infoPtr)
595  infoPtr->errorMsg("Error in LHAupAlpgen::addResonance: "
596  "resonance does not match decay products");
597  return false;
598  }
599 
600  // Update status/mothers
601  myParticles[i].statusPart = 2;
602  myParticles[idx ].mother1Part = i + 1;
603  myParticles[idx--].mother2Part = 0;
604  myParticles[idx ].mother1Part = i + 1;
605  myParticles[idx--].mother2Part = 0;
606 
607  // Top
608  } else if (abs(myParticles[i].idPart) == 6) {
609 
610  // Check that decay products and resonance match up
611  int flav;
612  if (myParticles[idx].idPart + myParticles[idx - 1].idPart == 0)
613  flav = 0;
614  else
615  flav = - (myParticles[idx].idPart % 2)
616  - (myParticles[idx - 1].idPart % 2);
617  flav = (flav > 0) ? 24 : (flav < 0) ? -24 : 23;
618 
619  bool outOfOrder = false, wrongFlavour = false;;
620  if ( abs(flav) != 24 ||
621  (flav == 24 && myParticles[i].idPart != 6) ||
622  (flav == -24 && myParticles[i].idPart != -6) ) {
623 
624  // Processes 5 and 13, order should always be correct
625  if (lprup == 5 || lprup == 13) {
626  wrongFlavour = true;
627 
628  // Processes 6, 8 and 16, can have out of order decay products
629  } else {
630 
631  // Go back two decay products and retry
632  idx -= 2;
633  if (myParticles[idx].idPart + myParticles[idx - 1].idPart == 0)
634  flav = 0;
635  else
636  flav = - (myParticles[idx].idPart % 2)
637  - (myParticles[idx - 1].idPart % 2);
638  flav = (flav > 0) ? 24 : (flav < 0) ? -24 : 23;
639 
640  // If still the wrong flavour then error
641  if ( abs(flav) != 24 ||
642  (flav == 24 && myParticles[i].idPart != 6) ||
643  (flav == -24 && myParticles[i].idPart != -6) )
644  wrongFlavour = true;
645  else outOfOrder = true;
646  }
647 
648  // Error if wrong flavour
649  if (wrongFlavour) {
650  if (infoPtr)
651  infoPtr->errorMsg("Error in LHAupAlpgen::addResonance: "
652  "resonance does not match decay products");
653  return false;
654  }
655  }
656 
657  // Mark t/tbar as now intermediate
658  myParticles[i].statusPart = 2;
659 
660  // New intermediate W+/W-
661  idT = flav;
662  statusT = 2;
663  mother1T = i + 1;
664  mother2T = 0;
665  col1T = col2T = 0;
666  pxT = myParticles[idx].pxPart + myParticles[idx - 1].pxPart;
667  pyT = myParticles[idx].pyPart + myParticles[idx - 1].pyPart;
668  pzT = myParticles[idx].pzPart + myParticles[idx - 1].pzPart;
669  eT = myParticles[idx].ePart + myParticles[idx - 1].ePart;
670  mT = sqrt(eT*eT - pxT*pxT - pyT*pyT - pzT*pzT);
671  myParticles.push_back(LHAParticle(
672  idT, statusT, mother1T, mother2T, col1T, col2T,
673  pxT, pyT, pzT, eT, mT, tauT, spinT, -1.));
674 
675  // Update the decay product mothers
676  myParticles[idx ].mother1Part = myParticles.size();
677  myParticles[idx--].mother2Part = 0;
678  myParticles[idx ].mother1Part = myParticles.size();
679  myParticles[idx--].mother2Part = 0;
680 
681  // New final-state b/bbar
682  idT = (flav == 24) ? 5 : -5;
683  statusT = 1;
684  // Colour from top
685  col1T = myParticles[i].col1Part;
686  col2T = myParticles[i].col2Part;
687  // Momentum from (t/tbar - W+/W-)
688  pxT = myParticles[i].pxPart - myParticles.back().pxPart;
689  pyT = myParticles[i].pyPart - myParticles.back().pyPart;
690  pzT = myParticles[i].pzPart - myParticles.back().pzPart;
691  eT = myParticles[i].ePart - myParticles.back().ePart;
692  mT = sqrt(eT*eT - pxT*pxT - pyT*pyT - pzT*pzT);
693  myParticles.push_back(LHAParticle(
694  idT, statusT, mother1T, mother2T, col1T, col2T,
695  pxT, pyT, pzT, eT, mT, tauT, spinT, -1.));
696 
697  // If decay products were out of order, reset idx to point
698  // at correct decay products
699  if (outOfOrder) idx += 4;
700 
701  } // if (abs(myParticles[i].idPart) == 6)
702  } // for (i)
703 
704 
705  // Processes:
706  // 7 = QQbar + Q'Qbar' + jets (tops are not decayed)
707  // 9 = jets
708  // 11 = gamma + jets
709  // 12 = Higgs + jets
710  } else if (lprup == 7 || lprup == 9 || lprup == 11 || lprup == 12) {
711  // Nothing to do for these processes
712  }
713 
714  // For single top, set incoming b mass if necessary
715  if (lprup == 13) for (int i = 0; i < 2; i++)
716  if (abs(myParticles[i].idPart) == 5) {
717  myParticles[i].mPart = mb;
718  myParticles[i].ePart = sqrt(pow2(myParticles[i].pzPart) + pow2(mb));
719  }
720 
721  // Debug output and done.
722  if (LHADEBUG) printParticles();
723  return true;
724 
725 }
int i
Definition: DBlmapReader.cc:9
void printParticles()
vector< Pythia8::LHAParticle > myParticles
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static const bool LHADEBUG
bool LHAupAlpgen::fileFound ( )
inline

Definition at line 93 of file GeneratorInput.h.

References isUnw, and NULL.

93 { return (isUnw != NULL); }
#define NULL
Definition: scimark2.h:8
istream * isUnw
void LHAupAlpgen::printParticles ( )

Definition at line 457 of file GeneratorInput.cc.

References gather_cfg::cout, i, and myParticles.

Referenced by addResonances(), and rescaleMomenta().

457  {
458 
459  cout << endl << "---- LHAupAlpgen particle listing begin ----" << endl;
460  cout << scientific << setprecision(6);
461  for (int i = 0; i < int(myParticles.size()); i++) {
462  cout << setw(5) << i
463  << setw(5) << myParticles[i].idPart
464  << setw(5) << myParticles[i].statusPart
465  << setw(15) << myParticles[i].pxPart
466  << setw(15) << myParticles[i].pyPart
467  << setw(15) << myParticles[i].pzPart
468  << setw(15) << myParticles[i].ePart
469  << setw(15) << myParticles[i].mPart
470  << setw(5) << myParticles[i].mother1Part - 1
471  << setw(5) << myParticles[i].mother2Part - 1
472  << setw(5) << myParticles[i].col1Part
473  << setw(5) << myParticles[i].col2Part
474  << endl;
475  }
476  cout << "---- LHAupAlpgen particle listing end ----" << endl;
477 }
int i
Definition: DBlmapReader.cc:9
vector< Pythia8::LHAParticle > myParticles
tuple cout
Definition: gather_cfg.py:121
bool LHAupAlpgen::rescaleMomenta ( )
private

Definition at line 741 of file GeneratorInput.cc.

References a, funct::abs(), b, gather_cfg::cout, reco::dp, EWARNTHRESHOLD, i, j, LHADEBUGRESCALE, max(), myParticles, printParticles(), PTWARNTHRESHOLD, mathSSE::sqrt(), and ZEROTHRESHOLD.

Referenced by setEvent().

741  {
742 
743  // Total momenta in/out
744  int nOut = 0;
745  Vec4 pIn, pOut;
746  for (int i = 0; i < int(myParticles.size()); i++) {
747  Vec4 pNow = Vec4(myParticles[i].pxPart, myParticles[i].pyPart,
748  myParticles[i].pzPart, myParticles[i].ePart);
749  if (i < 2) pIn += pNow;
750  else if (myParticles[i].statusPart == 1) {
751  nOut++;
752  pOut += pNow;
753  }
754  }
755 
756  // pT out to match pT in. Split any imbalances over all outgoing
757  // particles, and scale energies also to keep m^2 fixed.
758  if (abs(pOut.pT() - pIn.pT()) > ZEROTHRESHOLD) {
759  // Differences in px/py
760  double pxDiff = (pOut.px() - pIn.px()) / nOut,
761  pyDiff = (pOut.py() - pIn.py()) / nOut;
762 
763  // Warn if resulting changes above warning threshold
764  if (pxDiff > PTWARNTHRESHOLD || pyDiff > PTWARNTHRESHOLD) {
765  if (infoPtr) infoPtr->errorMsg("Warning in LHAupAlpgen::setEvent: "
766  "large pT imbalance in incoming event");
767 
768  // Debug printout
769  if (LHADEBUGRESCALE) {
770  printParticles();
771  cout << "pxDiff = " << pxDiff << ", pyDiff = " << pyDiff << endl;
772  }
773  }
774 
775  // Adjust all final-state outgoing
776  pOut.reset();
777  for (int i = 2; i < int(myParticles.size()); i++) {
778  if (myParticles[i].statusPart != 1) continue;
779  myParticles[i].pxPart -= pxDiff;
780  myParticles[i].pyPart -= pyDiff;
781  myParticles[i].ePart = sqrt(max(0., pow2(myParticles[i].pxPart) +
782  pow2(myParticles[i].pyPart) + pow2(myParticles[i].pzPart) +
783  pow2(myParticles[i].mPart)));
784  pOut += Vec4(myParticles[i].pxPart, myParticles[i].pyPart,
785  myParticles[i].pzPart, myParticles[i].ePart);
786  }
787  }
788 
789  // Differences in E/pZ and scaling factors
790  double de = (pOut.e() - pIn.e());
791  double dp = (pOut.pz() - pIn.pz());
792  double a = 1 + (de + dp) / 2. / myParticles[0].ePart;
793  double b = 1 + (de - dp) / 2. / myParticles[1].ePart;
794 
795  // Warn if resulting energy changes above warning threshold.
796  // Change in pz less than or equal to change in energy (incoming b
797  // quark can have mass at this stage for process 13). Note that for
798  // very small incoming momenta, the relative adjustment may be large,
799  // but still small in absolute terms.
800  if (abs(a - 1.) * myParticles[0].ePart > EWARNTHRESHOLD ||
801  abs(b - 1.) * myParticles[1].ePart > EWARNTHRESHOLD) {
802  if (infoPtr) infoPtr->errorMsg("Warning in LHAupAlpgen::setEvent: "
803  "large rescaling factor");
804 
805  // Debug printout
806  if (LHADEBUGRESCALE) {
807  printParticles();
808  cout << "de = " << de << ", dp = " << dp
809  << ", a = " << a << ", b = " << b << endl
810  << "Absolute energy change for incoming 0 = "
811  << abs(a - 1.) * myParticles[0].ePart << endl
812  << "Absolute energy change for incoming 1 = "
813  << abs(b - 1.) * myParticles[1].ePart << endl;
814  }
815  }
816  myParticles[0].ePart *= a;
817  myParticles[0].pzPart *= a;
818  myParticles[1].ePart *= b;
819  myParticles[1].pzPart *= b;
820 
821  // Recalculate resonance four vectors
822  for (int i = 0; i < int(myParticles.size()); i++) {
823  if (myParticles[i].statusPart != 2) continue;
824 
825  // Only mothers stored in LHA, so go through all
826  Vec4 resVec;
827  for (int j = 0; j < int(myParticles.size()); j++) {
828  if (myParticles[j].mother1Part - 1 != i) continue;
829  resVec += Vec4(myParticles[j].pxPart, myParticles[j].pyPart,
830  myParticles[j].pzPart, myParticles[j].ePart);
831  }
832 
833  myParticles[i].pxPart = resVec.px();
834  myParticles[i].pyPart = resVec.py();
835  myParticles[i].pzPart = resVec.pz();
836  myParticles[i].ePart = resVec.e();
837  }
838 
839  return true;
840 }
static const double PTWARNTHRESHOLD
int i
Definition: DBlmapReader.cc:9
void printParticles()
ExtVec< T, 4 > Vec4
Definition: ExtVec.h:23
vector< Pythia8::LHAParticle > myParticles
static const bool LHADEBUGRESCALE
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
auto dp
Definition: deltaR.h:24
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:121
static const double EWARNTHRESHOLD
static const double ZEROTHRESHOLD
bool LHAupAlpgen::setEvent ( int  ,
double   
)

Definition at line 352 of file GeneratorInput.cc.

References funct::abs(), addResonances(), ebmupA, i, ifsUnw, INCOMINGMIN, isUnw, geometryCSVtoXML::line, lprup, max(), myParticles, nEvent, rescaleMomenta(), and mathSSE::sqrt().

352  {
353 
354  // Read in the first line of the event
355  int nEvent, iProc, nParton;
356  double Swgt, Sq;
357  string line;
358  if (!getline(*isUnw, line)) {
359  // Read was bad
360  if (ifsUnw.bad()) {
361  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::setEvent: "
362  "could not read events from file");
363  return false;
364  }
365  // End of file reached
366  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::setEvent: "
367  "end of file reached");
368  return false;
369  }
370  istringstream iss1(line);
371  iss1 >> nEvent >> iProc >> nParton >> Swgt >> Sq;
372 
373  // Set the process details (ignore alphaQED and alphaQCD parameters)
374  double wgtT = Swgt, scaleT = Sq;
375  setProcess(lprup, wgtT, scaleT);
376 
377  // Incoming flavour and x information for later
378  int id1T, id2T;
379  double x1T, x2T;
380  // Temporary storage for read in parton information
381  int idT, statusT, mother1T, mother2T, col1T, col2T;
382  double pxT, pyT, pzT, eT, mT;
383  // Leave tau and spin as default values
384  double tauT = 0., spinT = 9.;
385 
386  // Store particles locally at first so that resonances can be added
387  myParticles.clear();
388 
389  // Now read in partons
390  for (int i = 0; i < nParton; i++) {
391  // Get the next line
392  if (!getline(*isUnw, line)) {
393  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::setEvent: "
394  "could not read events from file");
395  return false;
396  }
397  istringstream iss2(line);
398 
399  // Incoming (flavour, colour, anticolour, pz)
400  if (i < 2) {
401  // Note that mothers will be set automatically by Pythia, and LHA
402  // status -1 is for an incoming parton
403  iss2 >> idT >> col1T >> col2T >> pzT;
404  statusT = -1;
405  mother1T = mother2T = 0;
406  pxT = pyT = mT = 0.;
407  eT = abs(pzT);
408 
409  // Adjust when zero pz/e
410  if (pzT == 0.) {
411  pzT = (i == 0) ? INCOMINGMIN : -INCOMINGMIN;
412  eT = INCOMINGMIN;
413  }
414 
415  // Outgoing (flavour, colour, anticolour, px, py, pz, mass)
416  } else {
417  // Note that mothers 1 and 2 corresport to the incoming partons,
418  // as set above, and LHA status +1 is for outgoing final state
419  iss2 >> idT >> col1T >> col2T >> pxT >> pyT >> pzT >> mT;
420  statusT = 1;
421  mother1T = 1;
422  mother2T = 2;
423  eT = sqrt(max(0., pxT*pxT + pyT*pyT + pzT*pzT + mT*mT));
424  }
425 
426  // Add particle
427  myParticles.push_back(LHAParticle(
428  idT, statusT, mother1T, mother2T, col1T, col2T,
429  pxT, pyT, pzT, eT, mT, tauT, spinT,-1.));
430  }
431 
432  // Add resonances if required
433  if (!addResonances()) return false;
434 
435  // Rescale momenta if required (must be done after full event
436  // reconstruction in addResonances)
437  if (!rescaleMomenta()) return false;
438 
439  // Pass particles on to Pythia
440  for (size_t i = 0; i < myParticles.size(); i++)
441  addParticle(myParticles[i]);
442 
443  // Set incoming flavour/x information and done
444  id1T = myParticles[0].idPart;
445  x1T = myParticles[0].ePart / ebmupA;
446  id2T = myParticles[1].idPart;
447  x2T = myParticles[1].ePart / ebmupA;
448  setIdX(id1T, id2T, x1T, x2T);
449  setPdf(id1T, id2T, x1T, x2T, 0., 0., 0., false);
450  return true;
451 }
int i
Definition: DBlmapReader.cc:9
istream * isUnw
int nEvent
Definition: myFastSimVal.cc:49
vector< Pythia8::LHAParticle > myParticles
bool rescaleMomenta()
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool addResonances()
ifstream ifsUnw
static const double INCOMINGMIN
bool LHAupAlpgen::setInit ( )

Definition at line 259 of file GeneratorInput.cc.

References alpgenPar, ebmupA, ebmupB, AlpgenPar::getParam(), AlpgenPar::getParamAsInt(), AlpgenPar::haveParam(), ihvy1, ihvy2, lprup, and mb.

259  {
260 
261  // Check that all required parameters are present
262  if (!alpgenPar.haveParam("ih2") || !alpgenPar.haveParam("ebeam") ||
263  !alpgenPar.haveParam("hpc") || !alpgenPar.haveParam("xsecup") ||
264  !alpgenPar.haveParam("xerrup")) {
265  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::setInit: "
266  "missing input parameters");
267  return false;
268  }
269 
270  // Beam IDs
271  int ih2 = alpgenPar.getParamAsInt("ih2");
272  int idbmupA = 2212;
273  int idbmupB = (ih2 == 1) ? 2212 : -2212;
274 
275  // Beam energies
276  double ebeam = alpgenPar.getParam("ebeam");
277  ebmupA = ebeam;
278  ebmupB = ebmupA;
279 
280  // PDF group and set (at the moment not set)
281  int pdfgupA = 0, pdfsupA = 0;
282  int pdfgupB = 0, pdfsupB = 0;
283 
284  // Strategy is for unweighted events and xmaxup not important
285  int idwtup = 3;
286  double xmaxup = 0.;
287 
288  // Get hard process code
289  lprup = alpgenPar.getParamAsInt("hpc");
290 
291  // Check for unsupported processes
292  if (lprup == 7 || lprup == 8 || lprup == 13) {
293  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::setInit: "
294  "process not implemented");
295  return false;
296  }
297 
298  // Depending on the process code, get heavy flavour information:
299  // 6 = QQbar + jets
300  // 7 = QQbar + Q'Qbar' + jets
301  // 8 = QQbar + Higgs + jets
302  // 16 = QQbar + gamma + jets
303  if (lprup == 6 || lprup == 7 || lprup == 8 || lprup == 16) {
304  if (!alpgenPar.haveParam("ihvy")) {
305  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::setInit: "
306  "heavy flavour information not present");
307  return false;
308  }
309  ihvy1 = alpgenPar.getParamAsInt("ihvy");
310 
311  } else ihvy1 = -1;
312  if (lprup == 7) {
313  if (!alpgenPar.haveParam("ihvy2")) {
314  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::setInit: "
315  "heavy flavour information not present");
316  return false;
317  }
318  ihvy2 = alpgenPar.getParamAsInt("ihvy2");
319  } else ihvy2 = -1;
320  // For single top (process 13), get b mass to set incoming
321  mb = -1.;
322  if (lprup == 13) {
323  if (!alpgenPar.haveParam("mb")) {
324  if (infoPtr) infoPtr->errorMsg("Error in LHAupAlpgen::setInit: "
325  "heavy flavour information not present");
326  return false;
327  }
328  mb = alpgenPar.getParam("mb");
329  }
330 
331  // Set the beams
332  setBeamA(idbmupA, ebmupA, pdfgupA, pdfsupA);
333  setBeamB(idbmupB, ebmupB, pdfgupB, pdfsupB);
334  setStrategy(idwtup);
335 
336  // Add the process
337  double xsecup = alpgenPar.getParam("xsecup");
338  double xerrup = alpgenPar.getParam("xerrup");
339  addProcess(lprup, xsecup, xerrup, xmaxup);
340  xSecSumSave = xsecup;
341  xErrSumSave = xerrup;
342 
343  // All okay
344  return true;
345 }
AlpgenPar alpgenPar
double getParam(const string &paramIn)
bool haveParam(const string &paramIn)
int getParamAsInt(const string &paramIn)

Member Data Documentation

AlpgenPar LHAupAlpgen::alpgenPar
private

Definition at line 112 of file GeneratorInput.h.

Referenced by LHAupAlpgen(), and setInit().

string LHAupAlpgen::baseFN
private

Definition at line 111 of file GeneratorInput.h.

Referenced by LHAupAlpgen().

double LHAupAlpgen::ebmupA
private

Definition at line 114 of file GeneratorInput.h.

Referenced by setEvent(), and setInit().

double LHAupAlpgen::ebmupB
private

Definition at line 114 of file GeneratorInput.h.

Referenced by setInit().

const double LHAupAlpgen::EWARNTHRESHOLD = 3e-3
staticprivate

Definition at line 123 of file GeneratorInput.h.

Referenced by rescaleMomenta().

ifstream LHAupAlpgen::ifsUnw
private

Definition at line 117 of file GeneratorInput.h.

Referenced by LHAupAlpgen(), setEvent(), and ~LHAupAlpgen().

int LHAupAlpgen::ihvy1
private

Definition at line 115 of file GeneratorInput.h.

Referenced by addResonances(), and setInit().

int LHAupAlpgen::ihvy2
private

Definition at line 115 of file GeneratorInput.h.

Referenced by setInit().

const double LHAupAlpgen::INCOMINGMIN = 1e-3
staticprivate

Definition at line 123 of file GeneratorInput.h.

Referenced by setEvent().

istream* LHAupAlpgen::isUnw
private

Definition at line 118 of file GeneratorInput.h.

Referenced by fileFound(), LHAupAlpgen(), setEvent(), and ~LHAupAlpgen().

const bool LHAupAlpgen::LHADEBUG = false
staticprivate

Definition at line 122 of file GeneratorInput.h.

Referenced by addResonances().

const bool LHAupAlpgen::LHADEBUGRESCALE = false
staticprivate

Definition at line 122 of file GeneratorInput.h.

Referenced by rescaleMomenta().

int LHAupAlpgen::lprup
private

Definition at line 113 of file GeneratorInput.h.

Referenced by addResonances(), setEvent(), and setInit().

double LHAupAlpgen::mb
private

Definition at line 116 of file GeneratorInput.h.

Referenced by addResonances(), and setInit().

vector<Pythia8::LHAParticle> LHAupAlpgen::myParticles
private

Definition at line 119 of file GeneratorInput.h.

Referenced by addResonances(), printParticles(), rescaleMomenta(), and setEvent().

string LHAupAlpgen::parFN
private

Definition at line 111 of file GeneratorInput.h.

Referenced by LHAupAlpgen().

const double LHAupAlpgen::PTWARNTHRESHOLD = 1e-3
staticprivate

Definition at line 123 of file GeneratorInput.h.

Referenced by rescaleMomenta().

string LHAupAlpgen::unwFN
private

Definition at line 111 of file GeneratorInput.h.

Referenced by LHAupAlpgen().

const double LHAupAlpgen::ZEROTHRESHOLD = 1e-10
staticprivate

Definition at line 123 of file GeneratorInput.h.

Referenced by rescaleMomenta().