CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
gen::Cascade2Hadronizer Class Reference

#include <Cascade2Hadronizer.h>

Inheritance diagram for gen::Cascade2Hadronizer:
gen::BaseHadronizer

Public Member Functions

 Cascade2Hadronizer (edm::ParameterSet const &ps)
 
void cascadePrintParameters ()
 
bool cascadeReadParameters (const std::string &ParameterString)
 
const char * classname () const
 
bool decay ()
 
bool declareSpecialSettings (const std::vector< std::string > &)
 
bool declareStableParticles (const std::vector< int > &)
 
void finalizeEvent ()
 
bool generatePartonsAndHadronize ()
 
bool hadronize ()
 
bool initializeForExternalPartons ()
 
bool initializeForInternalPartons ()
 
void pythia6PrintParameters ()
 
bool readSettings (int)
 
bool residualDecay ()
 
void statistics ()
 
 ~Cascade2Hadronizer () override
 
- Public Member Functions inherited from gen::BaseHadronizer
 BaseHadronizer (edm::ParameterSet const &ps)
 
void cleanLHE ()
 
void generateLHE (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine, unsigned int ncpu)
 
edm::EventgetEDMEvent () const
 
std::unique_ptr< HepMC::GenEventgetGenEvent ()
 
std::unique_ptr< GenEventInfoProductgetGenEventInfo ()
 
virtual std::unique_ptr< GenLumiInfoHeadergetGenLumiInfoHeader () const
 
GenRunInfoProductgetGenRunInfo ()
 
std::unique_ptr< lhef::LHEEventgetLHEEvent ()
 
const std::shared_ptr< lhef::LHERunInfo > & getLHERunInfo () const
 
const std::string & gridpackPath () const
 
int randomIndex () const
 
const std::string & randomInitConfigDescription () const
 
void randomizeIndex (edm::LuminosityBlock const &lumi, CLHEP::HepRandomEngine *rengine)
 
void resetEvent (std::unique_ptr< HepMC::GenEvent > event)
 
void resetEventInfo (std::unique_ptr< GenEventInfoProduct > eventInfo)
 
virtual bool select (HepMC::GenEvent *) const
 
void setEDMEvent (edm::Event &event)
 
void setLHEEvent (std::unique_ptr< lhef::LHEEvent > event)
 
void setLHERunInfo (std::unique_ptr< lhef::LHERunInfo > runInfo)
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
std::vector< std::string > const & sharedResources () const
 
virtual ~BaseHadronizer ()(false)
 

Private Member Functions

void doSetRandomEngine (CLHEP::HepRandomEngine *v) override
 
std::vector< std::string > const & doSharedResources () const override
 
void fillTmpStorage ()
 
void flushTmpStorage ()
 
void imposeProperTime ()
 

Private Attributes

double fComEnergy
 
bool fConvertToPDG
 
bool fDisplayPythiaBanner
 
bool fDisplayPythiaCards
 
double fextCrossSection
 
double fextCrossSectionError
 
double fFilterEfficiency
 
bool fHepMCVerbosity
 
unsigned int fMaxEventsToPrint
 
edm::ParameterSet fParameters
 
Pythia6ServicefPy6Service
 
unsigned int fPythiaListVerbosity
 

Static Private Attributes

static const std::vector< std::string > theSharedResources
 

Additional Inherited Members

- Protected Member Functions inherited from gen::BaseHadronizer
std::unique_ptr< HepMC::GenEvent > & event ()
 
std::unique_ptr< GenEventInfoProduct > & eventInfo ()
 
lhef::LHEEventlheEvent ()
 
lhef::LHERunInfolheRunInfo ()
 
GenRunInfoProductrunInfo ()
 
- Protected Attributes inherited from gen::BaseHadronizer
std::string lheFile_
 
int randomIndex_
 

Detailed Description

Definition at line 24 of file Cascade2Hadronizer.h.

Constructor & Destructor Documentation

gen::Cascade2Hadronizer::Cascade2Hadronizer ( edm::ParameterSet const &  ps)

Definition at line 80 of file Cascade2Hadronizer.cc.

References gen::call_pygive(), edm::errors::Configuration, Exception, edm::ParameterSet::exists(), fConvertToPDG, fDisplayPythiaBanner, fDisplayPythiaCards, flushTmpStorage(), fParameters, and edm::ParameterSet::getParameter().

82  fPy6Service(new Pythia6ServiceWithCallback(pset)), //-- this will store py6 parameters for further settings
83 
84  fComEnergy(pset.getParameter<double>("comEnergy")),
85  fextCrossSection(pset.getUntrackedParameter<double>("crossSection", -1.)),
86  fextCrossSectionError(pset.getUntrackedParameter<double>("crossSectionError", -1.)),
87  fFilterEfficiency(pset.getUntrackedParameter<double>("filterEfficiency", -1.)),
88 
89  fMaxEventsToPrint(pset.getUntrackedParameter<int>("maxEventsToPrint", 0)),
90  fHepMCVerbosity(pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity", false)),
91  fPythiaListVerbosity(pset.getUntrackedParameter<int>("pythiaPylistVerbosity", 0)),
92 
93  fDisplayPythiaBanner(pset.getUntrackedParameter<bool>("displayPythiaBanner", false)),
94  fDisplayPythiaCards(pset.getUntrackedParameter<bool>("displayPythiaCards", false)) {
95  fParameters = pset.getParameter<ParameterSet>("Cascade2Parameters");
96 
97  fConvertToPDG = false;
98  if (pset.exists("doPDGConvert"))
99  fConvertToPDG = pset.getParameter<bool>("doPDGConvert");
100 
101  //-- silence Pythia6 banner printout, unless display requested
102 
103  if (!fDisplayPythiaBanner) {
104  if (!call_pygive("MSTU(12)=12345")) {
105  throw edm::Exception(edm::errors::Configuration, "PythiaError") << " Pythia did not accept MSTU(12)=12345";
106  }
107  }
108 
109  //-- silence printouts from PYGIVE, unless display requested
110 
111  if (!fDisplayPythiaCards) {
112  if (!call_pygive("MSTU(13)=0")) {
113  throw edm::Exception(edm::errors::Configuration, "PythiaError") << " Pythia did not accept MSTU(13)=0";
114  }
115  }
116 
117  //-- tmp stuff to deal with EvtGen corrupting pyjets
118  flushTmpStorage();
119  }
Pythia6Service * fPy6Service
BaseHadronizer(edm::ParameterSet const &ps)
bool call_pygive(const std::string &line)
edm::ParameterSet fParameters
gen::Cascade2Hadronizer::~Cascade2Hadronizer ( )
override

Definition at line 121 of file Cascade2Hadronizer.cc.

References fPy6Service.

121  {
122  if (fPy6Service != nullptr)
123  delete fPy6Service;
124  }
Pythia6Service * fPy6Service

Member Function Documentation

void gen::Cascade2Hadronizer::cascadePrintParameters ( )

Definition at line 724 of file Cascade2Hadronizer.cc.

References cagluon, cahflav, cainpu, caluco, capar1, capar6, captcut, cascol, cashower, caspdf, casprre, casshwr, gather_cfg::cout, fComEnergy, fextCrossSection, fextCrossSectionError, fFilterEfficiency, integr, jpsi, and scalf.

Referenced by initializeForInternalPartons().

724  {
725  cout << "" << endl;
726  cout << "----------------------------------" << endl;
727  cout << "---- Cascade Parameters ----" << endl;
728  cout << "----------------------------------" << endl;
729  cout << "" << endl;
730 
731  cout << "computation switch: " << endl;
732  cout << "number of calls per iteration for bases: " << integr.ncb << endl;
733  cout << "relative precision for grid optimisation: " << integr.acc1 << " %" << endl;
734  cout << "relative precision for integration: " << integr.acc2 << " %" << endl;
735  cout << "" << endl;
736 
737  cout << "kinematics: " << endl;
738  cout << "flavour code of beam 1: " << caluco.ke << endl;
739  cout << "direct or resolved particle 1: " << capar6.ires[0] << endl;
740  cout << "pz of incoming beam 1: " << cainpu.plepin << " GeV" << endl;
741  cout << "flavour code of beam 2: " << caluco.kp << endl;
742  cout << "direct or resolved particle 2: " << capar6.ires[1] << endl;
743  cout << "pz of incoming beam 2: " << cainpu.ppin << " GeV" << endl;
744  cout << "number of active flavors: " << caluco.nflav << endl;
745  cout << "" << endl;
746 
747  cout << "hard subprocess selection: " << endl;
748  cout << "hard subprocess number (IPRO): " << capar1.ipro << endl;
749  cout << "IPRO = 10, switch to select QCD process g* g* -> q qbar: " << cascol.irpa << endl;
750  cout << "IPRO = 10, switch to select QCD process g* g -> g g: " << cascol.irpb << endl;
751  cout << "IPRO = 10, switch to select QCD process g* q -> g q: " << cascol.irpc << endl;
752  cout << "flavor of heavy quark produced (IPRO = 11, 504, 514): " << cahflav.ihfla << endl;
753  // cout<<"select vector meson state: "<<jpsi.i23s<<endl;
754  cout << "use matrix element including J/psi (Upsilon) polarisation: " << jpsi.ipsipol << endl;
755  cout << "pt2 cut in matrix element for massless partons: " << captcut.pt2cut[capar1.ipro - 1] << " GeV^2" << endl;
756  cout << "" << endl;
757 
758  cout << "parton shower and fragmentation: " << endl;
759  cout << "switch for fragmentation: " << cainpu.nfrag << endl;
760  cout << "switch for parton shower (0 off - 1 initial state - 2 final state - 3 initial & final state): "
761  << cainpu.ifps << endl;
762  cout << "switch for time like parton shower in initial state: " << casshwr.itimshr << endl;
763  cout << "select CCFM (1) or DGLAP (0) evolution: " << casshwr.iccfm << endl;
764  cout << "scale switch for final state parton shower: " << cainpu.ifinal << endl;
765  cout << "scale factor for final state parton shower: " << scalf.scalfaf << endl;
766  cout << "switch for proton remnant treatment: " << casprre.irspl << endl;
767  cout << "keep track of intermediate state in parton shower: " << cashower.ipst << endl;
768  cout << "mode of interaction for e p: " << cainpu.inter << endl;
769  cout << "" << endl;
770 
771  cout << "pdfs, couplings and scales: " << endl;
772  cout << "switch for running alphaem: " << capar1.irunaem << endl;
773  cout << "switch for running alphas: " << capar1.iruna << endl;
774  cout << "scale in alphas: " << capar1.iq2 << endl;
775  cout << "scale factor for scale in alphas: " << scalf.scalfa << endl;
776  cout << "unintegrated pdf: " << cagluon.iglu << endl;
777  cout << "path where updf are stored: " << caspdf.pdfpath << endl;
778  cout << "" << endl;
779 
780  cout << "center of mass energy, cross section, filter efficiency: " << endl;
781  cout << "center of mass energy: " << fComEnergy << " GeV" << endl;
782  cout << "external LO cross section: " << fextCrossSection << " +/- " << fextCrossSectionError << " pb" << endl;
783  cout << "filter efficiency: " << fFilterEfficiency << endl;
784  cout << "" << endl;
785  }
#define cainpu
#define captcut
#define cahflav
#define caluco
#define cagluon
#define integr
#define cascol
#define caspdf
#define scalf
#define capar6
#define capar1
#define cashower
#define casshwr
#define jpsi
#define casprre
bool gen::Cascade2Hadronizer::cascadeReadParameters ( const std::string &  ParameterString)

Definition at line 624 of file Cascade2Hadronizer.cc.

References cms::dd::accepted(), cagluon, cahflav, cainpu, caluco, capar1, capar6, captcut, cascol, cashower, casprre, casshwr, integr, jpsi, and scalf.

Referenced by initializeForInternalPartons().

624  {
625  bool accepted = true;
626 
627  if (!strncmp(ParameterString.c_str(), "KE", 2))
628  caluco.ke = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
629 
630  else if (!strncmp(ParameterString.c_str(), "IRES(1)", 7))
631  capar6.ires[0] = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
632 
633  else if (!strncmp(ParameterString.c_str(), "KP", 2))
634  caluco.kp = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
635 
636  else if (!strncmp(ParameterString.c_str(), "IRES(2)", 7))
637  capar6.ires[1] = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
638 
639  else if (!strncmp(ParameterString.c_str(), "NFRAG", 5))
640  cainpu.nfrag = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
641 
642  else if (!strncmp(ParameterString.c_str(), "IPST", 4))
643  cashower.ipst = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
644 
645  else if (!strncmp(ParameterString.c_str(), "IPSIPOL", 7))
646  jpsi.ipsipol = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
647 
648  //-- from version 2.2.03 on
649  // else if(!strncmp(ParameterString.c_str(),"I23S",4))
650  // jpsi.i23s = atoi(&ParameterString[strcspn(ParameterString.c_str(),"=")+1]);
651 
652  else if (!strncmp(ParameterString.c_str(), "IFPS", 4))
653  cainpu.ifps = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
654 
655  else if (!strncmp(ParameterString.c_str(), "ITIMSHR", 7))
656  casshwr.itimshr = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
657 
658  else if (!strncmp(ParameterString.c_str(), "IRUNAEM", 7))
659  capar1.irunaem = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
660 
661  else if (!strncmp(ParameterString.c_str(), "IRUNA", 5))
662  capar1.iruna = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
663 
664  else if (!strncmp(ParameterString.c_str(), "IQ2", 3))
665  capar1.iq2 = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
666 
667  else if (!strncmp(ParameterString.c_str(), "IPRO", 4))
668  capar1.ipro = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
669 
670  else if (!strncmp(ParameterString.c_str(), "NFLAV", 5))
671  caluco.nflav = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
672 
673  else if (!strncmp(ParameterString.c_str(), "INTER", 5))
674  cainpu.inter = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
675 
676  else if (!strncmp(ParameterString.c_str(), "IHFLA", 5))
677  cahflav.ihfla = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
678 
679  else if (!strncmp(ParameterString.c_str(), "IRPA", 4))
680  cascol.irpa = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
681 
682  else if (!strncmp(ParameterString.c_str(), "IRPB", 4))
683  cascol.irpb = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
684 
685  else if (!strncmp(ParameterString.c_str(), "IRPC", 4))
686  cascol.irpc = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
687 
688  else if (!strncmp(ParameterString.c_str(), "ICCFM", 5))
689  casshwr.iccfm = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
690 
691  else if (!strncmp(ParameterString.c_str(), "IFINAL", 6))
692  cainpu.ifinal = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
693 
694  else if (!strncmp(ParameterString.c_str(), "IGLU", 4))
695  cagluon.iglu = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
696 
697  else if (!strncmp(ParameterString.c_str(), "IRspl", 5))
698  casprre.irspl = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
699 
700  else if (!strncmp(ParameterString.c_str(), "PT2CUT", 6))
701  captcut.pt2cut[capar1.ipro - 1] = atof(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
702 
703  else if (!strncmp(ParameterString.c_str(), "NCB", 3))
704  integr.ncb = atoi(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
705 
706  else if (!strncmp(ParameterString.c_str(), "ACC1", 4))
707  integr.acc1 = atof(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
708 
709  else if (!strncmp(ParameterString.c_str(), "ACC2", 4))
710  integr.acc2 = atof(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
711 
712  else if (!strncmp(ParameterString.c_str(), "SCALFAF", 7))
713  scalf.scalfaf = atof(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
714 
715  else if (!strncmp(ParameterString.c_str(), "SCALFA", 6))
716  scalf.scalfa = atof(&ParameterString[strcspn(ParameterString.c_str(), "=") + 1]);
717 
718  else
719  accepted = false;
720 
721  return accepted;
722  }
#define cainpu
#define captcut
#define cahflav
#define caluco
#define cagluon
#define integr
#define cascol
#define scalf
#define capar6
#define capar1
bool accepted(std::vector< std::string_view > const &, std::string_view)
#define cashower
#define casshwr
#define jpsi
#define casprre
const char * gen::Cascade2Hadronizer::classname ( ) const

Definition at line 620 of file Cascade2Hadronizer.cc.

620 { return "gen::Cascade2Hadronizer"; }
bool gen::Cascade2Hadronizer::decay ( )

Definition at line 275 of file Cascade2Hadronizer.cc.

275 { return true; }
bool gen::Cascade2Hadronizer::declareSpecialSettings ( const std::vector< std::string > &  )
inline
bool gen::Cascade2Hadronizer::declareStableParticles ( const std::vector< int > &  _pdg)

Definition at line 515 of file Cascade2Hadronizer.cc.

References gen::call_pygive(), mps_fire::i, and gen::pycomp_().

515  {
516  vector<int> pdg = _pdg;
517  for (size_t i = 0; i < pdg.size(); i++) {
518  int PyID = HepPID::translatePDTtoPythia(pdg[i]);
519  int pyCode = pycomp_(PyID);
520 
521  if (pyCode > 0) {
522  ostringstream pyCard;
523  pyCard << "MDCY(" << pyCode << ",1)=0";
524  //-- cout << "pdg= " << pdg[i] << " " << pyCard.str() << endl;
525 
526  call_pygive(pyCard.str());
527  }
528  }
529 
530  return true;
531  }
bool call_pygive(const std::string &line)
int pycomp_(int &)
void gen::Cascade2Hadronizer::doSetRandomEngine ( CLHEP::HepRandomEngine *  v)
overrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 126 of file Cascade2Hadronizer.cc.

References cascade2RandomEngine, fPy6Service, gen::Pythia6Service::setRandomEngine(), and gen::v.

126  {
129  }
Pythia6Service * fPy6Service
double v[5][pyjets_maxn]
static CLHEP::HepRandomEngine * cascade2RandomEngine
void setRandomEngine(CLHEP::HepRandomEngine *v)
std::vector<std::string> const& gen::Cascade2Hadronizer::doSharedResources ( ) const
inlineoverrideprivatevirtual

Reimplemented from gen::BaseHadronizer.

Definition at line 51 of file Cascade2Hadronizer.h.

51 { return theSharedResources; }
static const std::vector< std::string > theSharedResources
void gen::Cascade2Hadronizer::fillTmpStorage ( )
private

Definition at line 145 of file Cascade2Hadronizer.cc.

References mps_fire::i, and gen::pyjets_local.

Referenced by generatePartonsAndHadronize().

145  {
146  pyjets_local.n = pyjets.n;
147  pyjets_local.npad = pyjets.npad;
148 
149  for (int ip = 0; ip < pyjets_maxn; ip++) {
150  for (int i = 0; i < 5; i++) {
151  pyjets_local.k[i][ip] = pyjets.k[i][ip];
152  pyjets_local.p[i][ip] = pyjets.p[i][ip];
153  pyjets_local.v[i][ip] = pyjets.v[i][ip];
154  }
155  }
156  return;
157  }
static struct gen::@658 pyjets_local
void gen::Cascade2Hadronizer::finalizeEvent ( )

Definition at line 159 of file Cascade2Hadronizer.cc.

References gen::call_pylist(), gather_cfg::cout, debug, gen::BaseHadronizer::event(), gen::BaseHadronizer::eventInfo(), fConvertToPDG, fHepMCVerbosity, fMaxEventsToPrint, fPythiaListVerbosity, imposeProperTime(), pydat1, pyint1, and pypars.

159  {
160  HepMC::PdfInfo pdf;
161 
162  //-- filling factorization "Q scale" now! pthat moved to binningValues()
163 
164  if (event()->signal_process_id() <= 0)
165  event()->set_signal_process_id(pypars.msti[0]);
166  if (event()->event_scale() <= 0)
167  event()->set_event_scale(pypars.pari[22]);
168  if (event()->alphaQED() <= 0)
169  event()->set_alphaQED(pyint1.vint[56]);
170  if (event()->alphaQCD() <= 0)
171  event()->set_alphaQCD(pyint1.vint[57]);
172 
173  //-- get pdf info directly from Pythia6 and set it up into HepMC::GenEvent
174  //-- S. Mrenna: Prefer vint block
175 
176  if (pdf.id1() <= 0)
177  pdf.set_id1(pyint1.mint[14] == 21 ? 0 : pyint1.mint[14]);
178  if (pdf.id2() <= 0)
179  pdf.set_id2(pyint1.mint[15] == 21 ? 0 : pyint1.mint[15]);
180  if (pdf.x1() <= 0)
181  pdf.set_x1(pyint1.vint[40]);
182  if (pdf.x2() <= 0)
183  pdf.set_x2(pyint1.vint[41]);
184  if (pdf.pdf1() <= 0)
185  pdf.set_pdf1(pyint1.vint[38] / pyint1.vint[40]);
186  if (pdf.pdf2() <= 0)
187  pdf.set_pdf2(pyint1.vint[39] / pyint1.vint[41]);
188  if (pdf.scalePDF() <= 0)
189  pdf.set_scalePDF(pyint1.vint[50]);
190 
191  event()->set_pdf_info(pdf);
192 
193  if (debug) {
194  cout << "standard Py6 event weight: pyint1.vint[96]: " << pyint1.vint[96] << endl;
195  cout << "event weight returned by PYEVWT: 1./(pyint1.vint[98]): " << 1. / (pyint1.vint[98]) << endl;
196  }
197 
198  //-- this is "standard" Py6 event weight (corresponds to PYINT1/VINT(97))
199  // event()->weights().push_back(pyint1.vint[96]);
200 
201  //-- this is event weight as 1./VINT(99) (PYINT1/VINT(99) is returned by the PYEVWT)
202  // event()->weights().push_back(1./(pyint1.vint[98]));
203 
204  //-- all cascade events have weight = 1
205  event()->weights().push_back(1.);
206 
207  //-- now create the GenEventInfo product from the GenEvent and fill the missing pieces
208 
209  eventInfo().reset(new GenEventInfoProduct(event().get()));
210 
211  //-- in Pythia6 pthat is used to subdivide samples into different bins
212  //-- in LHE mode the binning is done by the external ME generator
213  //-- which is likely not pthat, so only filling it for Py6 internal mode
214 
215  eventInfo()->setBinningValues(vector<double>(1, pypars.pari[16]));
216 
217  //-- here we treat long-lived particles
218 
219  if (pydat1.mstj[21] == 3 || pydat1.mstj[21] == 4)
221 
222  //-- convert particle IDs Py6 -> PDG (if requested)
223 
224  if (fConvertToPDG) {
225  for (HepMC::GenEvent::particle_iterator part = event()->particles_begin(); part != event()->particles_end();
226  ++part) {
227  (*part)->set_pdg_id(HepPID::translatePythiatoPDT((*part)->pdg_id()));
228  }
229  }
230 
231  //-- service printouts, if requested
232  if (fMaxEventsToPrint > 0) {
236  if (fHepMCVerbosity) {
237  cout << "Event process = " << pypars.msti[0] << endl << "----------------------" << endl;
238  event()->print();
239  }
240  }
241 
242  return;
243  }
#define pydat1
void call_pylist(int mode)
#define pyint1
std::unique_ptr< HepMC::GenEvent > & event()
#define pypars
part
Definition: HCALResponse.h:20
std::unique_ptr< GenEventInfoProduct > & eventInfo()
#define debug
void gen::Cascade2Hadronizer::flushTmpStorage ( )
private

Definition at line 131 of file Cascade2Hadronizer.cc.

References mps_fire::i, and gen::pyjets_local.

Referenced by Cascade2Hadronizer(), and generatePartonsAndHadronize().

131  {
132  pyjets_local.n = 0;
133  pyjets_local.npad = 0;
134 
135  for (int ip = 0; ip < pyjets_maxn; ip++) {
136  for (int i = 0; i < 5; i++) {
137  pyjets_local.k[i][ip] = 0;
138  pyjets_local.p[i][ip] = 0.;
139  pyjets_local.v[i][ip] = 0.;
140  }
141  }
142  return;
143  }
static struct gen::@658 pyjets_local
bool gen::Cascade2Hadronizer::generatePartonsAndHadronize ( )

Definition at line 247 of file Cascade2Hadronizer.cc.

References call_event(), gen::BaseHadronizer::event(), fillTmpStorage(), flushTmpStorage(), fPy6Service, gen::FortranCallback::getInstance(), hepevtio, pyint1, and gen::FortranCallback::resetIterationsPerEvent().

247  {
248  //-- grab Py6 instance
249  Pythia6Service::InstanceWrapper guard(fPy6Service);
250 
252 
253  //-- skip event if py6 considers it bad
254  if (pyint1.mint[50] != 0) {
255  event().reset();
256  return false;
257  }
258 
259  //-- generation of the event with CASCADE
260  call_event();
261 
262  //-- pythia pyhepc routine converts common PYJETS in common HEPEVT
263  call_pyhepc(1);
264 
265  //-- delete the created event from memory
266  event().reset(hepevtio.read_next_event());
267 
268  //-- this is to deal with post-gen tools & residualDecay() that may reuse PYJETS
269  flushTmpStorage();
270  fillTmpStorage();
271 
272  return true;
273  }
Pythia6Service * fPy6Service
#define pyint1
std::unique_ptr< HepMC::GenEvent > & event()
static FortranCallback * getInstance()
void call_event()
HepMC::IO_HEPEVT hepevtio
bool gen::Cascade2Hadronizer::hadronize ( )

Definition at line 245 of file Cascade2Hadronizer.cc.

245 { return false; }
void gen::Cascade2Hadronizer::imposeProperTime ( )
private

Definition at line 533 of file Cascade2Hadronizer.cc.

References funct::abs(), gen::FortranInstance::call(), class-composition::children, gen::BaseHadronizer::event(), DQMScaleToClient_cfi::factor, fPy6Service, dqm-mbProfile::log, gen::pycomp_(), pydat1, gen::pyr_(), mathSSE::sqrt(), OrderedSet::t, vbegin, and vend.

Referenced by finalizeEvent().

533  {
534  // this is practically a copy/paste of the original code by J.Alcaraz,
535  // taken directly from PythiaSource
536 
537  int dumm = 0;
538  HepMC::GenEvent::vertex_const_iterator vbegin = event()->vertices_begin();
539  HepMC::GenEvent::vertex_const_iterator vend = event()->vertices_end();
540  HepMC::GenEvent::vertex_const_iterator vitr = vbegin;
541 
542  for (; vitr != vend; ++vitr) {
543  HepMC::GenVertex::particle_iterator pbegin = (*vitr)->particles_begin(HepMC::children);
544  HepMC::GenVertex::particle_iterator pend = (*vitr)->particles_end(HepMC::children);
545  HepMC::GenVertex::particle_iterator pitr = pbegin;
546 
547  for (; pitr != pend; ++pitr) {
548  if ((*pitr)->end_vertex())
549  continue;
550  if ((*pitr)->status() != 1)
551  continue;
552 
553  int pdgcode = abs((*pitr)->pdg_id());
554  // Do nothing if the particle is not expected to decay
555  if (pydat3.mdcy[0][pycomp_(pdgcode) - 1] != 1)
556  continue;
557 
558  double ctau = pydat2.pmas[3][pycomp_(pdgcode) - 1];
559  HepMC::FourVector mom = (*pitr)->momentum();
560  HepMC::FourVector vin = (*vitr)->position();
561  double x = 0.;
562  double y = 0.;
563  double z = 0.;
564  double t = 0.;
565  bool decayInRange = false;
566  while (!decayInRange) {
567  double unif_rand = fPy6Service->call(pyr_, &dumm);
568  // Value of 0 is excluded, so following line is OK
569  double proper_length = -ctau * log(unif_rand);
570  double factor = proper_length / mom.m();
571  x = vin.x() + factor * mom.px();
572  y = vin.y() + factor * mom.py();
573  z = vin.z() + factor * mom.pz();
574  t = vin.t() + factor * mom.e();
575 
576  // Decay must be happen outside a cylindrical region
577  if (pydat1.mstj[21] == 4) {
578  if (sqrt(x * x + y * y) > pydat1.parj[72] || fabs(z) > pydat1.parj[73])
579  decayInRange = true;
580  // Decay must be happen outside a given sphere
581  } else if (pydat1.mstj[21] == 3) {
582  if (sqrt(x * x + y * y + z * z) > pydat1.parj[71])
583  decayInRange = true;
584  }
585  // Decay is always OK otherwise
586  else {
587  decayInRange = true;
588  }
589  }
590 
591  HepMC::GenVertex* vdec = new HepMC::GenVertex(HepMC::FourVector(x, y, z, t));
592  event()->add_vertex(vdec);
593  vdec->add_particle_in((*pitr));
594  }
595  }
596 
597  return;
598  }
#define pydat1
void call(void(&fn)())
Pythia6Service * fPy6Service
#define vend()
Definition: vmac.h:43
T sqrt(T t)
Definition: SSEVec.h:19
#define vbegin()
Definition: vmac.h:36
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::unique_ptr< HepMC::GenEvent > & event()
int pycomp_(int &)
double pyr_(int *idummy)
bool gen::Cascade2Hadronizer::initializeForExternalPartons ( )

Definition at line 443 of file Cascade2Hadronizer.cc.

443 { return false; }
bool gen::Cascade2Hadronizer::initializeForInternalPartons ( )

Definition at line 445 of file Cascade2Hadronizer.cc.

References cainpu, call_caend(), call_cascade(), call_cascha(), call_casini(), cascadePrintParameters(), cascadeReadParameters(), gen::Pythia6Service::closeSLHA(), edm::errors::Configuration, Exception, fComEnergy, fParameters, fPy6Service, edm::ParameterSet::getParameter(), mps_fire::i, pythia6PrintParameters(), gen::Pythia6Service::setCSAParams(), gen::Pythia6Service::setGeneralParams(), gen::Pythia6Service::setPYUPDAParams(), and gen::Pythia6Service::setSLHAParams().

445  {
446  //-- grab Py6 instance
447  Pythia6Service::InstanceWrapper guard(fPy6Service);
448 
449  //-- change standard parameters of JETSET/PYTHIA - replace call_pytcha()
450 
452 
456 
458 
459  //-- mstu(8) is set to NMXHEP in this dummy call (version >=6.404)
460  call_pyhepc(1);
461 
462  //-- initialise random number generator: has been changed to be CMSSW compliant
463  //-- dcasrn overloaded: call to rluxgo not needed anymore
464  //-- call_rluxgo(4,314159265,0,0);
465 
466  //-- initialise CASCADE parameters (default values)
467  call_casini();
468 
469  //-- Read the parameters and pass them to the common blocks
470  //-- call_steer();
471 
472  //-- initialise CASCADE parameters (user values)
473 
474  //-- retrieve all the different sets
475  vector<string> AllSets = fParameters.getParameter<vector<string> >("parameterSets");
476 
477  //-- loop over the different sets
478  for (unsigned i = 0; i < AllSets.size(); ++i) {
479  string Set = AllSets[i];
480  vector<string> Para_Set = fParameters.getParameter<vector<string> >(Set);
481 
482  //-- loop over all the parameters and stop in case of mistake
483  for (vector<string>::const_iterator itPara = Para_Set.begin(); itPara != Para_Set.end(); ++itPara) {
484  if (!cascadeReadParameters(*itPara)) {
485  throw edm::Exception(edm::errors::Configuration, "CascadeError")
486  << " Cascade did not accept the following parameter: \"" << *itPara << "\"" << endl;
487  }
488  } //-- end loop over all the parameters
489  } //-- end loop over the different sets
490 
491  cainpu.plepin = -fComEnergy / 2;
492  cainpu.ppin = fComEnergy / 2;
493 
495 
496  //-- change standard parameters of CASCADE
497  call_cascha();
498 
499  //-- change standard parameters of JETSET/PYTHIA
500  //-- call_pytcha();
501 
502  //-- set up for running CASCADE (integration of the cross-section)
503  call_cascade();
504 
505  //-- print cross-section result from integration
506  call_caend(1);
507 
509 
511 
512  return true;
513  }
#define cainpu
T getParameter(std::string const &) const
Pythia6Service * fPy6Service
void call_casini()
edm::ParameterSet fParameters
void call_cascade()
void call_caend(int mode)
void setPYUPDAParams(bool afterPyinit)
bool cascadeReadParameters(const std::string &ParameterString)
void call_cascha()
void gen::Cascade2Hadronizer::pythia6PrintParameters ( )

Definition at line 787 of file Cascade2Hadronizer.cc.

References gather_cfg::cout, and pydat1.

Referenced by initializeForInternalPartons().

787  {
788  cout << "" << endl;
789  cout << "----------------------------------" << endl;
790  cout << "---- Pythia6 Parameters ----" << endl;
791  cout << "----------------------------------" << endl;
792  cout << "" << endl;
793 
794  cout << "charm mass: " << pydat2.pmas[0][3] << " GeV (default value = 1.5 GeV)" << endl;
795  cout << "bottom mass: " << pydat2.pmas[0][4] << " GeV (default value = 4.8 GeV)" << endl;
796  cout << "Higgs mass: " << pydat2.pmas[0][24] << " GeV (default value = 115 GeV)" << endl;
797 
798  cout << "lambda QCD: " << pydat1.paru[111] << " GeV (default value = 0.25 GeV)" << endl;
799 
800  cout << "alphas behaviour: " << pydat1.mstu[110] << " (default value = 1)" << endl;
801  cout << "nr of flavours wrt lambda QCD: " << pydat1.mstu[111] << " (default value = 5)" << endl;
802  cout << "min nr of flavours for alphas: " << pydat1.mstu[112] << " (default value = 3)" << endl;
803  cout << "max nr of flavours for alphas: " << pydat1.mstu[113] << " (default value = 5)" << endl;
804 
805  cout << "maximum angle settings: " << pydat1.mstj[47] << " (default value = 0)" << endl;
806 
807  cout << "" << endl;
808  }
#define pydat1
bool gen::Cascade2Hadronizer::readSettings ( int  key)

Definition at line 430 of file Cascade2Hadronizer.cc.

References fPy6Service, gen::Pythia6Service::setCSAParams(), gen::Pythia6Service::setGeneralParams(), and gen::Pythia6Service::setSLHAParams().

430  {
431  //-- grab Py6 instance
432  Pythia6Service::InstanceWrapper guard(fPy6Service);
433 
435 
436  if (key == 0)
439 
440  return true;
441  }
Pythia6Service * fPy6Service
bool gen::Cascade2Hadronizer::residualDecay ( )

Definition at line 277 of file Cascade2Hadronizer.cc.

References gen::BaseHadronizer::event(), fPy6Service, GenParticle::GenParticle, mps_fire::i, class-composition::parent, EgammaValidation_cff::pdgid, gen::pycomp_(), gen::pydecy_(), gen::pyjets_local, and mps_update::status.

277  {
278  //-- grab Py6 instance
279  Pythia6Service::InstanceWrapper guard(fPy6Service);
280 
281  int NPartsBeforeDecays = pyjets_local.n;
282  int NPartsAfterDecays = event().get()->particles_size();
283  int barcode = NPartsAfterDecays;
284 
285  // JVY: well, in principle, it's not a 100% fair to go up to NPartsBeforeDecays,
286  // because Photos will attach gamma's to existing vertices, i.e. in the middle
287  // of the event rather than at the end; but this will only shift pointers down,
288  // so we'll be going again over a few "original" particle...
289  // in the alternative, we may go all the way up to the beginning of the event
290  // and re-check if anything remains to decay, that's fine even if it'll take
291  // some extra CPU...
292 
293  for (int ipart = NPartsAfterDecays; ipart > NPartsBeforeDecays; ipart--) {
294  HepMC::GenParticle* part = event().get()->barcode_to_particle(ipart);
295  int status = part->status();
296  if (status != 1)
297  continue; // check only "stable" particles,
298  // as some undecayed may still be marked as such
299  int pdgid = part->pdg_id();
300  int py6ptr = pycomp_(pdgid);
301 
302  if (pydat3.mdcy[0][py6ptr - 1] != 1)
303  continue; // particle is not expected to decay
304 
305  int py6id = HepPID::translatePDTtoPythia(pdgid);
306 
307  // first, will need to zero out, then fill up PYJETS
308  // I better do it directly (by hands) rather than via py1ent
309  // - to avoid (additional) mass smearing
310 
311  if (part->momentum().t() <= part->generated_mass()) {
312  continue; // e == m -> 0-momentum, nothing to decay...
313  }
314 
315  else {
316  pyjets.n = 0;
317 
318  for (int i = 0; i < 5; i++) {
319  pyjets.k[i][0] = 0;
320  pyjets.p[i][0] = 0.;
321  pyjets.v[i][0] = 0.;
322  }
323 
324  pyjets.k[0][0] = 1;
325  pyjets.k[1][0] = py6id;
326  pyjets.p[4][0] = part->generated_mass();
327  pyjets.p[3][0] = part->momentum().t();
328  pyjets.p[0][0] = part->momentum().x();
329  pyjets.p[1][0] = part->momentum().y();
330  pyjets.p[2][0] = part->momentum().z();
331  HepMC::GenVertex* prod_vtx = part->production_vertex();
332  if (!prod_vtx)
333  continue; // in principle, should never happen but...
334  pyjets.v[0][0] = prod_vtx->position().x();
335  pyjets.v[1][0] = prod_vtx->position().y();
336  pyjets.v[2][0] = prod_vtx->position().z();
337  pyjets.v[3][0] = prod_vtx->position().t();
338  pyjets.v[4][0] = 0.;
339  pyjets.n = 1;
340  pyjets.npad = pyjets_local.npad;
341  }
342 
343  //-- now call Py6 decay routine
344 
345  int parent = 1; // since we always pass to Py6 a single particle
346  pydecy_(parent);
347 
348  //-- now attach decay products to mother
349 
350  for (int iprt1 = 1; iprt1 < pyjets.n; iprt1++) {
351  part->set_status(2);
352 
353  HepMC::GenVertex* DecVtx = new HepMC::GenVertex(
354  HepMC::FourVector(pyjets.v[0][iprt1], pyjets.v[1][iprt1], pyjets.v[2][iprt1], pyjets.v[3][iprt1]));
355  DecVtx->add_particle_in(part); // this will cleanup end_vertex if exists, replace with the new one
356  // I presume (vtx) barcode will be given automatically
357 
358  HepMC::FourVector pmom(pyjets.p[0][iprt1], pyjets.p[1][iprt1], pyjets.p[2][iprt1], pyjets.p[3][iprt1]);
359 
360  int dstatus = 0;
361  if (pyjets.k[0][iprt1] >= 1 && pyjets.k[0][iprt1] <= 10)
362  dstatus = 1;
363  else if (pyjets.k[0][iprt1] >= 11 && pyjets.k[0][iprt1] <= 20)
364  dstatus = 2;
365  else if (pyjets.k[0][iprt1] >= 21 && pyjets.k[0][iprt1] <= 30)
366  dstatus = 3;
367  else if (pyjets.k[0][iprt1] >= 31 && pyjets.k[0][iprt1] <= 100)
368  dstatus = pyjets.k[0][iprt1];
369 
370  HepMC::GenParticle* daughter =
371  new HepMC::GenParticle(pmom, HepPID::translatePythiatoPDT(pyjets.k[1][iprt1]), dstatus);
372  barcode++;
373  daughter->suggest_barcode(barcode);
374  DecVtx->add_particle_out(daughter);
375 
376  int iprt2;
377  for (iprt2 = iprt1 + 1; iprt2 < pyjets.n; iprt2++) { // the pointer is shifted by -1, c++ style
378 
379  if (pyjets.k[2][iprt2] != parent) {
380  parent = pyjets.k[2][iprt2];
381  break; // another parent particle; reset & break the loop
382  }
383 
384  HepMC::FourVector pmomN(pyjets.p[0][iprt2], pyjets.p[1][iprt2], pyjets.p[2][iprt2], pyjets.p[3][iprt2]);
385 
386  dstatus = 0;
387  if (pyjets.k[0][iprt2] >= 1 && pyjets.k[0][iprt2] <= 10)
388  dstatus = 1;
389  else if (pyjets.k[0][iprt2] >= 11 && pyjets.k[0][iprt2] <= 20)
390  dstatus = 2;
391  else if (pyjets.k[0][iprt2] >= 21 && pyjets.k[0][iprt2] <= 30)
392  dstatus = 3;
393  else if (pyjets.k[0][iprt2] >= 31 && pyjets.k[0][iprt2] <= 100)
394  dstatus = pyjets.k[0][iprt2];
395 
396  HepMC::GenParticle* daughterN =
397  new HepMC::GenParticle(pmomN, HepPID::translatePythiatoPDT(pyjets.k[1][iprt2]), dstatus);
398  barcode++;
399  daughterN->suggest_barcode(barcode);
400  DecVtx->add_particle_out(daughterN);
401  } //-- end iprt2 loop
402 
403  iprt1 = iprt2 - 1; // reset counter such that it doesn't go over the same child more than once
404  // don't forget to offset back into c++ counting, as it's already +1 forward
405 
406  event().get()->add_vertex(DecVtx);
407  } //-- end iprt1 loop
408  } //-- end loop over decay products
409 
410  // now restore the very original Py6 event record
411 
412  if (pyjets_local.n != pyjets.n) {
413  // restore pyjets to its state as it was before external decays -
414  // might have been jammed by action above or by py1ent calls in EvtGen
415 
416  pyjets.n = pyjets_local.n;
417  pyjets.npad = pyjets_local.npad;
418  for (int ip = 0; ip < pyjets_local.n; ip++) {
419  for (int i = 0; i < 5; i++) {
420  pyjets.k[i][ip] = pyjets_local.k[i][ip];
421  pyjets.p[i][ip] = pyjets_local.p[i][ip];
422  pyjets.v[i][ip] = pyjets_local.v[i][ip];
423  }
424  }
425  }
426 
427  return true;
428  }
Pythia6Service * fPy6Service
static struct gen::@658 pyjets_local
void pydecy_(int &ip)
std::unique_ptr< HepMC::GenEvent > & event()
int pycomp_(int &)
part
Definition: HCALResponse.h:20
void gen::Cascade2Hadronizer::statistics ( )

Definition at line 600 of file Cascade2Hadronizer.cc.

References caeffic, call_caend(), fextCrossSection, fextCrossSectionError, gen::BaseHadronizer::runInfo(), GenRunInfoProduct::setExternalXSecLO(), GenRunInfoProduct::setExternalXSecNLO(), and GenRunInfoProduct::setInternalXSec().

600  {
602 
604 
605  if (!runInfo().internalXSec()) {
606  double sigma_CMS = 0.001 * caeffic.avgi;
607  double error_CMS = 0.001 * caeffic.sd;
608  runInfo().setInternalXSec(GenRunInfoProduct::XSec(sigma_CMS, error_CMS));
609  }
610 
611  //-- print out generated event summary
612  call_caend(2);
613 
614  //-- write out some information from Pythia to the screen
615  call_pystat(1);
616 
617  return;
618  }
void setInternalXSec(const XSec &xsec)
GenRunInfoProduct & runInfo()
void call_caend(int mode)
void setExternalXSecNLO(const XSec &xsec)
void setExternalXSecLO(const XSec &xsec)
#define caeffic

Member Data Documentation

double gen::Cascade2Hadronizer::fComEnergy
private

Definition at line 68 of file Cascade2Hadronizer.h.

Referenced by cascadePrintParameters(), and initializeForInternalPartons().

bool gen::Cascade2Hadronizer::fConvertToPDG
private

Definition at line 80 of file Cascade2Hadronizer.h.

Referenced by Cascade2Hadronizer(), and finalizeEvent().

bool gen::Cascade2Hadronizer::fDisplayPythiaBanner
private

Definition at line 77 of file Cascade2Hadronizer.h.

Referenced by Cascade2Hadronizer().

bool gen::Cascade2Hadronizer::fDisplayPythiaCards
private

Definition at line 78 of file Cascade2Hadronizer.h.

Referenced by Cascade2Hadronizer().

double gen::Cascade2Hadronizer::fextCrossSection
private

Definition at line 69 of file Cascade2Hadronizer.h.

Referenced by cascadePrintParameters(), and statistics().

double gen::Cascade2Hadronizer::fextCrossSectionError
private

Definition at line 70 of file Cascade2Hadronizer.h.

Referenced by cascadePrintParameters(), and statistics().

double gen::Cascade2Hadronizer::fFilterEfficiency
private

Definition at line 71 of file Cascade2Hadronizer.h.

Referenced by cascadePrintParameters().

bool gen::Cascade2Hadronizer::fHepMCVerbosity
private

Definition at line 74 of file Cascade2Hadronizer.h.

Referenced by finalizeEvent().

unsigned int gen::Cascade2Hadronizer::fMaxEventsToPrint
private

Definition at line 73 of file Cascade2Hadronizer.h.

Referenced by finalizeEvent().

edm::ParameterSet gen::Cascade2Hadronizer::fParameters
private

Definition at line 63 of file Cascade2Hadronizer.h.

Referenced by Cascade2Hadronizer(), and initializeForInternalPartons().

Pythia6Service* gen::Cascade2Hadronizer::fPy6Service
private
unsigned int gen::Cascade2Hadronizer::fPythiaListVerbosity
private

Definition at line 75 of file Cascade2Hadronizer.h.

Referenced by finalizeEvent().

const std::vector< std::string > gen::Cascade2Hadronizer::theSharedResources
staticprivate