CMS 3D CMS Logo

ExhumeHadronizer.cc
Go to the documentation of this file.
2 
5 
9 
10 #include "HepPID/ParticleIDTranslations.hh"
11 
12 #include "HepMC/GenEvent.h"
13 #include "HepMC/PdfInfo.h"
14 #include "HepMC/HEPEVT_Wrapper.h"
15 #include "HepMC/IO_HEPEVT.h"
16 
17 //ExHuME headers
23 
24 #include <string>
25 #include <sstream>
26 
27 HepMC::IO_HEPEVT conv;
28 
29 namespace gen {
30  extern "C" {
31  extern struct {
32  int mstu[200];
33  double paru[200];
34  int mstj[200];
35  double parj[200];
36  } pydat1_;
37 #define pydat1 pydat1_
38 
39  extern struct {
40  int mstp[200];
41  double parp[200];
42  int msti[200];
43  double pari[200];
44  } pypars_;
45 #define pypars pypars_
46 
47  extern struct {
48  int mint[400];
49  double vint[400];
50  } pyint1_;
51 #define pyint1 pyint1_
52  }
53 
54  extern "C" {
55  void pylist_(int*);
56  int pycomp_(int&);
57  void pygive_(const char*, int);
58  }
59 #define pylist pylist_
60 #define pycomp pycomp_
61 #define pygive pygive_
62 
63  inline void call_pylist(int mode) { pylist(&mode); }
64  inline bool call_pygive(const std::string& line) {
65  int numWarn = pydat1.mstu[26]; // # warnings
66  int numErr = pydat1.mstu[22]; // # errors
67 
68  pygive(line.c_str(), line.length());
69 
70  return (pydat1.mstu[26] == numWarn) && (pydat1.mstu[22] == numErr);
71  }
72 
75 
78  pythia6Service_(new Pythia6Service(pset)),
79  randomEngine_(nullptr),
80  comEnergy_(pset.getParameter<double>("comEnergy")),
81  myPSet_(pset),
82  hepMCVerbosity_(pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity", false)),
83  maxEventsToPrint_(pset.getUntrackedParameter<int>("maxEventsToPrint", 0)),
84  pythiaListVerbosity_(pset.getUntrackedParameter<int>("pythiaPylistVerbosity", 0)),
85  exhumeEvent_(nullptr) {
86  convertToPDG_ = false;
87  if (pset.exists("doPDGConvert")) {
88  convertToPDG_ = pset.getParameter<bool>("doPDGConvert");
89  }
90 
91  //pythia6Hadronizer_ = new Pythia6Hadronizer(pset);
92  }
93 
95  //delete pythia6Hadronizer_;
96  delete pythia6Service_;
97  delete exhumeEvent_;
98  delete exhumeProcess_;
99  }
100 
101  void ExhumeHadronizer::doSetRandomEngine(CLHEP::HepRandomEngine* v) {
103  randomEngine_ = v;
104  if (exhumeEvent_) {
106  }
107  }
108 
110  //pythia6Hadronizer_->finalizeEvent();
111 
112  event()->set_signal_process_id(pypars.msti[0]);
113  event()->set_event_scale(pypars.pari[16]);
114 
115  HepMC::PdfInfo pdf;
116  pdf.set_id1(pyint1.mint[14] == 21 ? 0 : pyint1.mint[14]);
117  pdf.set_id2(pyint1.mint[15] == 21 ? 0 : pyint1.mint[15]);
118  pdf.set_x1(pyint1.vint[40]);
119  pdf.set_x2(pyint1.vint[41]);
120  pdf.set_pdf1(pyint1.vint[38] / pyint1.vint[40]);
121  pdf.set_pdf2(pyint1.vint[39] / pyint1.vint[41]);
122  pdf.set_scalePDF(pyint1.vint[50]);
123 
124  event()->set_pdf_info(pdf);
125 
126  event()->weights().push_back(pyint1.vint[96]);
127 
128  // convert particle IDs Py6->PDG, if requested
129  if (convertToPDG_) {
130  for (HepMC::GenEvent::particle_iterator part = event()->particles_begin(); part != event()->particles_end();
131  ++part) {
132  (*part)->set_pdg_id(HepPID::translatePythiatoPDT((*part)->pdg_id()));
133  }
134  }
135 
136  // service printouts, if requested
137  //
138  if (maxEventsToPrint_ > 0) {
142  if (hepMCVerbosity_) {
143  std::cout << "Event process = " << pypars.msti[0] << std::endl << "----------------------" << std::endl;
144  event()->print();
145  }
146  }
147 
148  return;
149  }
150 
153 
155 
156  // generate event
157 
160 
161  event().reset(conv.read_next_event());
162 
163  return true;
164  }
165 
166  bool ExhumeHadronizer::hadronize() { return false; }
167 
168  bool ExhumeHadronizer::decay() { return true; }
169 
170  bool ExhumeHadronizer::residualDecay() { return true; }
171 
173 
176 
178 
179  return true;
180  }
181 
184 
185  // pythia6Service_->setGeneralParams();
186 
187  //Exhume Initialization
188  edm::ParameterSet processPSet = myPSet_.getParameter<edm::ParameterSet>("ExhumeProcess");
189  std::string processType = processPSet.getParameter<std::string>("ProcessType");
190  int sigID = -1;
191  if (processType == "Higgs") {
193  int higgsDecay = processPSet.getParameter<int>("HiggsDecay");
194  (static_cast<Exhume::Higgs*>(exhumeProcess_))->SetHiggsDecay(higgsDecay);
195  sigID = 100 + higgsDecay;
196  } else if (processType == "QQ") {
198  int quarkType = processPSet.getParameter<int>("QuarkType");
199  double thetaMin = processPSet.getParameter<double>("ThetaMin");
200  ((Exhume::QQ*)exhumeProcess_)->SetQuarkType(quarkType);
201  (static_cast<Exhume::QQ*>(exhumeProcess_))->SetThetaMin(thetaMin);
202  sigID = 200 + quarkType;
203  } else if (processType == "GG") {
205  double thetaMin = processPSet.getParameter<double>("ThetaMin");
206  (static_cast<Exhume::GG*>(exhumeProcess_))->SetThetaMin(thetaMin);
207  sigID = 300;
208  } else if (processType == "DiPhoton") {
210  double thetaMin = processPSet.getParameter<double>("ThetaMin");
211  (static_cast<Exhume::DiPhoton*>(exhumeProcess_))->SetThetaMin(thetaMin);
212  sigID = 400;
213  } else {
214  sigID = -1;
215  throw edm::Exception(edm::errors::Configuration, "ExhumeError") << " No valid Exhume Process";
216  }
217 
218  pypars.msti[0] = sigID;
220 
221  double massRangeLow = processPSet.getParameter<double>("MassRangeLow");
222  double massRangeHigh = processPSet.getParameter<double>("MassRangeHigh");
223  exhumeEvent_->SetMassRange(massRangeLow, massRangeHigh);
225 
226  return true;
227  }
228 
229  bool ExhumeHadronizer::declareStableParticles(const std::vector<int>& _pdg) {
230  std::vector<int> pdg = _pdg;
231  //return pythia6Hadronizer_->declareStableParticles(pdg);
232 
233  for (size_t i = 0; i < pdg.size(); i++) {
234  int pyCode = pycomp(pdg[i]);
235  std::ostringstream pyCard;
236  pyCard << "MDCY(" << pyCode << ",1)=0";
237  std::cout << pyCard.str() << std::endl;
238  call_pygive(pyCard.str());
239  }
240 
241  return true;
242  }
243 
244  bool ExhumeHadronizer::declareSpecialSettings(const std::vector<std::string>&) { return true; }
245 
247  std::ostringstream footer_str;
248 
250  double eff = exhumeEvent_->GetEfficiency();
252 
253  footer_str << "\n"
254  << " You have just been ExHuMEd."
255  << "\n"
256  << "\n";
257  footer_str << " The cross section for process " << name << " is " << cs << " fb"
258  << "\n"
259  << "\n";
260  footer_str << " The efficiency of event generation was " << eff << "%"
261  << "\n"
262  << "\n";
263 
264  edm::LogInfo("") << footer_str.str();
265 
266  if (!runInfo().internalXSec()) {
268  }
269 
270  return;
271  }
272 
273  const char* ExhumeHadronizer::classname() const { return "gen::ExhumeHadronizer"; }
274 
275 } // namespace gen
gen::ExhumeHadronizer::declareSpecialSettings
bool declareSpecialSettings(const std::vector< std::string > &)
Definition: ExhumeHadronizer.cc:244
Exhume::CrossSection::Hadronise
void Hadronise()
gen::ExhumeHadronizer::exhumeEvent_
Exhume::Event * exhumeEvent_
Definition: ExhumeHadronizer.h:81
gen::ExhumeHadronizer::hadronize
bool hadronize()
Definition: ExhumeHadronizer.cc:166
gen::mint
int mint[400]
Definition: ExhumeHadronizer.cc:48
electrons_cff.bool
bool
Definition: electrons_cff.py:393
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
gen::ExhumeHadronizer::initializeForExternalPartons
bool initializeForExternalPartons()
Definition: ExhumeHadronizer.cc:172
funct::false
false
Definition: Factorize.h:29
gen::ExhumeHadronizer::ExhumeHadronizer
ExhumeHadronizer(edm::ParameterSet const &ps)
Definition: ExhumeHadronizer.cc:76
gen::parj
double parj[200]
Definition: ExhumeHadronizer.cc:35
gen::ExhumeHadronizer::generatePartonsAndHadronize
bool generatePartonsAndHadronize()
Definition: ExhumeHadronizer.cc:151
gen::pycomp_
int pycomp_(int &)
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:47
conv
HepMC::IO_HEPEVT conv
Definition: ExhumeHadronizer.cc:27
pyint1
#define pyint1
Definition: ExhumeHadronizer.cc:51
Exhume::Higgs
Definition: Higgs.h:13
gather_cfg.cout
cout
Definition: gather_cfg.py:144
Exhume::Event::Generate
void Generate()
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
pypars
#define pypars
Definition: ExhumeHadronizer.cc:45
gen::mstj
int mstj[200]
Definition: ExhumeHadronizer.cc:34
gen::FortranInstance::kFortranInstance
static const std::string kFortranInstance
Definition: FortranInstance.h:88
Exhume::Event::GetEfficiency
double GetEfficiency()
Definition: Event.h:66
gen::ExhumeHadronizer::decay
bool decay()
Definition: ExhumeHadronizer.cc:168
gen::ExhumeHadronizer::initializeForInternalPartons
bool initializeForInternalPartons()
Definition: ExhumeHadronizer.cc:182
DiPhoton.h
gen::ExhumeHadronizer::residualDecay
bool residualDecay()
Definition: ExhumeHadronizer.cc:170
GenRunInfoProduct::setInternalXSec
void setInternalXSec(const XSec &xsec)
Definition: GenRunInfoProduct.h:26
gen::Pythia6Service::setRandomEngine
void setRandomEngine(CLHEP::HepRandomEngine *v)
Definition: Pythia6Service.h:46
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
gen::ExhumeHadronizer::theSharedResources
static const std::vector< std::string > theSharedResources
Definition: ExhumeHadronizer.h:62
gen::BaseHadronizer
Definition: BaseHadronizer.h:46
pylist
#define pylist
Definition: ExhumeHadronizer.cc:59
gen::ExhumeHadronizer::convertToPDG_
bool convertToPDG_
Definition: ExhumeHadronizer.h:78
gen::Pythia6Service::setGeneralParams
void setGeneralParams()
Definition: Pythia6Service.cc:157
gen::FortranCallback::getInstance
static FortranCallback * getInstance()
Definition: FortranCallback.h:52
ExhumeHadronizer.h
Higgs.h
gen::pyint1_
struct gen::@696 pyint1_
Exhume::Event
Definition: Event.h:17
Exhume::Event::SetMassRange
void SetMassRange(const double &Min_, const double &Max_)
Definition: Event.h:52
part
part
Definition: HCALResponse.h:20
gen::ExhumeHadronizer::maxEventsToPrint_
unsigned int maxEventsToPrint_
Definition: ExhumeHadronizer.h:75
gen::parp
double parp[200]
Definition: ExhumeHadronizer.cc:41
gen::msti
int msti[200]
Definition: ExhumeHadronizer.cc:42
hltExoticaValidator_cfi.DiPhoton
DiPhoton
Definition: hltExoticaValidator_cfi.py:216
gen::FortranInstance::InstanceWrapper
Definition: FortranInstance.h:54
SharedResourceNames.h
gen
Definition: PythiaDecays.h:13
gen::paru
double paru[200]
Definition: ExhumeHadronizer.cc:33
FortranInstance.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Exhume::QQ
Definition: QQ.h:11
muonRecoAnalyzer_cfi.thetaMin
thetaMin
Definition: muonRecoAnalyzer_cfi.py:22
pygive
#define pygive
Definition: ExhumeHadronizer.cc:61
gen::FortranCallback::resetIterationsPerEvent
void resetIterationsPerEvent()
Definition: FortranCallback.h:23
pycomp
#define pycomp
Definition: ExhumeHadronizer.cc:60
gen::ExhumeHadronizer::pythia6Service_
Pythia6Service * pythia6Service_
Definition: ExhumeHadronizer.h:64
Exhume::GG
Definition: GG.h:11
edm::ParameterSet
Definition: ParameterSet.h:47
gen::pypars_
struct gen::@695 pypars_
Exhume::Event::SetParameterSpace
void SetParameterSpace()
gen::ExhumeHadronizer::pythiaListVerbosity_
unsigned int pythiaListVerbosity_
Definition: ExhumeHadronizer.h:76
gen::v
double v[5][pyjets_maxn]
Definition: Cascade2Hadronizer.cc:76
createfilelist.int
int
Definition: createfilelist.py:10
gen::call_pylist
void call_pylist(int mode)
Definition: ExhumeHadronizer.cc:63
gen::ExhumeHadronizer::statistics
void statistics()
Definition: ExhumeHadronizer.cc:246
gen::ExhumeHadronizer::~ExhumeHadronizer
~ExhumeHadronizer() override
Definition: ExhumeHadronizer.cc:94
Event.h
Exhume::Event::CrossSectionCalculation
double CrossSectionCalculation()
gen::ExhumeHadronizer::finalizeEvent
void finalizeEvent()
Definition: ExhumeHadronizer.cc:109
Exhume::CrossSection::GetName
std::string GetName()
Definition: CrossSection.h:105
gen::pylist_
void pylist_(int *)
Exhume::Event::SetRandomEngine
void SetRandomEngine(CLHEP::HepRandomEngine *engine)
Definition: Event.h:22
gen::ExhumeHadronizer::exhumeProcess_
Exhume::CrossSection * exhumeProcess_
Definition: ExhumeHadronizer.h:82
gen::ExhumeHadronizer::myPSet_
edm::ParameterSet myPSet_
Definition: ExhumeHadronizer.h:72
gen::BaseHadronizer::event
std::unique_ptr< HepMC::GenEvent > & event()
Definition: BaseHadronizer.h:86
gen::mstu
int mstu[200]
Definition: ExhumeHadronizer.cc:32
QQ.h
gen::ExhumeHadronizer::doSetRandomEngine
void doSetRandomEngine(CLHEP::HepRandomEngine *v) override
Definition: ExhumeHadronizer.cc:101
edm::SharedResourceNames::kPythia6
static const std::string kPythia6
Definition: SharedResourceNames.h:26
gen::ExhumeHadronizer::declareStableParticles
bool declareStableParticles(const std::vector< int > &)
Definition: ExhumeHadronizer.cc:229
Exception
Definition: hltDiff.cc:246
gen::vint
double vint[400]
Definition: ExhumeHadronizer.cc:49
Pythia6Service.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
pdg
Definition: pdg_functions.h:28
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
gen::ExhumeHadronizer::randomEngine_
CLHEP::HepRandomEngine * randomEngine_
Definition: ExhumeHadronizer.h:66
gen::pydat1_
struct gen::@694 pydat1_
gen::Pythia6Service
Definition: Pythia6Service.h:24
FortranCallback.h
gen::ExhumeHadronizer::readSettings
bool readSettings(int)
Definition: ExhumeHadronizer.cc:174
mps_splice.line
line
Definition: mps_splice.py:76
GG.h
gen::BaseHadronizer::runInfo
GenRunInfoProduct & runInfo()
Definition: BaseHadronizer.h:85
gen::ExhumeHadronizer::classname
const char * classname() const
Definition: ExhumeHadronizer.cc:273
gen::pygive_
void pygive_(const char *, int)
gen::call_pygive
bool call_pygive(const std::string &line)
Definition: ExhumeHadronizer.cc:64
edm::errors::Configuration
Definition: EDMException.h:36
pydat1
#define pydat1
Definition: ExhumeHadronizer.cc:37
gen::mstp
int mstp[200]
Definition: ExhumeHadronizer.cc:40
gen::pari
double pari[200]
Definition: ExhumeHadronizer.cc:43
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
gen::ExhumeHadronizer::hepMCVerbosity_
bool hepMCVerbosity_
Definition: ExhumeHadronizer.h:74