CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
31 extern "C" {
32 extern struct {
33  int mstu[200];
34  double paru[200];
35  int mstj[200];
36  double parj[200];
37 } pydat1_;
38 #define pydat1 pydat1_
39 
40 extern struct {
41  int mstp[200];
42  double parp[200];
43  int msti[200];
44  double pari[200];
45 } pypars_;
46 #define pypars pypars_
47 
48 extern struct {
49  int mint[400];
50  double vint[400];
51 } pyint1_;
52 #define pyint1 pyint1_
53 }
54 
55 extern "C" {
56  void pylist_(int*);
57  int pycomp_(int&);
58  void pygive_(const char*, int);
59 }
60 #define pylist pylist_
61 #define pycomp pycomp_
62 #define pygive pygive_
63 
64 inline void call_pylist( int mode ){ pylist( &mode ); }
65 inline bool call_pygive(const std::string &line)
66 {
67  int numWarn = pydat1.mstu[26]; // # warnings
68  int numErr = pydat1.mstu[22]; // # errors
69 
70  pygive(line.c_str(), line.length());
71 
72  return (pydat1.mstu[26] == numWarn)&&(pydat1.mstu[22] == numErr);
73 }
74 
76  : BaseHadronizer(pset),
77  pythia6Service_(new Pythia6Service(pset)),
78  randomEngine_(&getEngineReference()),
79  comEnergy_(pset.getParameter<double>("comEnergy")),
80  myPSet_(pset),
81  hepMCVerbosity_(pset.getUntrackedParameter<bool>("pythiaHepMCVerbosity",false)),
82  maxEventsToPrint_(pset.getUntrackedParameter<int>("maxEventsToPrint", 0)),
83  pythiaListVerbosity_(pset.getUntrackedParameter<int>("pythiaPylistVerbosity", 0))
84 {
85 
86  convertToPDG_ = false;
87  if ( pset.exists( "doPDGConvert" ) )
88  {
89  convertToPDG_ = pset.getParameter<bool>("doPDGConvert");
90  }
91 
92  //pythia6Hadronizer_ = new Pythia6Hadronizer(pset);
93 }
94 
96  //delete pythia6Hadronizer_;
97  delete pythia6Service_;
98  delete exhumeEvent_;
99  delete exhumeProcess_;
100 }
101 
103 {
104  //pythia6Hadronizer_->finalizeEvent();
105 
106  event()->set_signal_process_id( pypars.msti[0] );
107  event()->set_event_scale( pypars.pari[16] );
108 
109  HepMC::PdfInfo pdf;
110  pdf.set_id1( pyint1.mint[14] == 21 ? 0 : pyint1.mint[14] );
111  pdf.set_id2( pyint1.mint[15] == 21 ? 0 : pyint1.mint[15] );
112  pdf.set_x1( pyint1.vint[40] );
113  pdf.set_x2( pyint1.vint[41] );
114  pdf.set_pdf1( pyint1.vint[38] / pyint1.vint[40] );
115  pdf.set_pdf2( pyint1.vint[39] / pyint1.vint[41] );
116  pdf.set_scalePDF( pyint1.vint[50] );
117 
118  event()->set_pdf_info( pdf ) ;
119 
120  event()->weights().push_back( pyint1.vint[96] );
121 
122  // convert particle IDs Py6->PDG, if requested
123  if(convertToPDG_) {
124  for ( HepMC::GenEvent::particle_iterator part = event()->particles_begin();
125  part != event()->particles_end(); ++part) {
126  (*part)->set_pdg_id(HepPID::translatePythiatoPDT((*part)->pdg_id()));
127  }
128  }
129 
130  // service printouts, if requested
131  //
132  if (maxEventsToPrint_ > 0)
133  {
136  if (hepMCVerbosity_)
137  {
138  std::cout << "Event process = " << pypars.msti[0] << std::endl
139  << "----------------------" << std::endl;
140  event()->print();
141  }
142  }
143 
144  return;
145 }
146 
148 {
150 
152 
153  // generate event
154 
157 
158  event().reset( conv.read_next_event() );
159 
160  return true;
161 }
162 
164 {
165  return false;
166 }
167 
169 {
170  return true;
171 }
172 
174 {
175  return true;
176 }
177 
179 {
180  return false;
181 }
182 
184 {
185 
187 
189 
190  return true;
191 
192 }
193 
195 {
197 
198  // pythia6Service_->setGeneralParams();
199 
200  //Exhume Initialization
201  edm::ParameterSet processPSet = myPSet_.getParameter<edm::ParameterSet>("ExhumeProcess");
202  std::string processType = processPSet.getParameter<std::string>("ProcessType");
203  int sigID = -1;
204  if(processType == "Higgs"){
206  int higgsDecay = processPSet.getParameter<int>("HiggsDecay");
207  (static_cast<Exhume::Higgs*>(exhumeProcess_))->SetHiggsDecay(higgsDecay);
208  sigID = 100 + higgsDecay;
209  } else if(processType == "QQ"){
211  int quarkType = processPSet.getParameter<int>("QuarkType");
212  double thetaMin = processPSet.getParameter<double>("ThetaMin");
213  ((Exhume::QQ*)exhumeProcess_)->SetQuarkType(quarkType);
214  (static_cast<Exhume::QQ*>(exhumeProcess_))->SetThetaMin(thetaMin);
215  sigID = 200 + quarkType;
216  } else if(processType == "GG"){
218  double thetaMin = processPSet.getParameter<double>("ThetaMin");
219  (static_cast<Exhume::GG*>(exhumeProcess_))->SetThetaMin(thetaMin);
220  sigID = 300;
221  } else if(processType == "DiPhoton"){
223  double thetaMin = processPSet.getParameter<double>("ThetaMin");
224  (static_cast<Exhume::DiPhoton*>(exhumeProcess_))->SetThetaMin(thetaMin);
225  sigID = 400;
226  } else{
227  sigID = -1;
228  throw edm::Exception(edm::errors::Configuration,"ExhumeError") <<" No valid Exhume Process";
229  }
230 
231  pypars.msti[0] = sigID;
232  //exhumeEvent_ = new Exhume::Event(*exhumeProcess_,&getEngineReference());
234 
235  double massRangeLow = processPSet.getParameter<double>("MassRangeLow");
236  double massRangeHigh = processPSet.getParameter<double>("MassRangeHigh");
237  exhumeEvent_->SetMassRange(massRangeLow,massRangeHigh);
239 
240  return true;
241 }
242 
243 bool ExhumeHadronizer::declareStableParticles(const std::vector<int>& _pdg )
244 {
245  std::vector<int> pdg = _pdg;
246  //return pythia6Hadronizer_->declareStableParticles(pdg);
247 
248  for ( size_t i=0; i < pdg.size(); i++ )
249  {
250  int pyCode = pycomp( pdg[i] );
251  std::ostringstream pyCard ;
252  pyCard << "MDCY(" << pyCode << ",1)=0";
253  std::cout << pyCard.str() << std::endl;
254  call_pygive( pyCard.str() );
255  }
256 
257  return true;
258 
259 }
260 
261 bool ExhumeHadronizer::declareSpecialSettings( const std::vector<std::string>& )
262 {
263  return true;
264 }
265 
267 {
268  std::ostringstream footer_str;
269 
271  double eff = exhumeEvent_->GetEfficiency();
273 
274  footer_str << "\n" <<" You have just been ExHuMEd." << "\n" << "\n";
275  footer_str << " The cross section for process " << name
276  << " is " << cs << " fb" << "\n" << "\n";
277  footer_str << " The efficiency of event generation was " << eff << "%" << "\n" << "\n";
278 
279  edm::LogInfo("") << footer_str.str();
280 
281  if ( !runInfo().internalXSec() )
282  {
283  runInfo().setInternalXSec( cs );
284  }
285 
286  return;
287 }
288 
289 const char* ExhumeHadronizer::classname() const
290 {
291  return "gen::ExhumeHadronizer";
292 }
293 
294 } // namespace gen
#define pydat1
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
auto_ptr< ClusterSequence > cs
Exhume::Event * exhumeEvent_
double CrossSectionCalculation()
ExhumeHadronizer(edm::ParameterSet const &ps)
int mint[400]
static HepMC::IO_HEPEVT conv
int mstp[200]
bool call_pygive(const std::string &line)
bool exists(std::string const &parameterName) const
checks if a parameter exists
double parp[200]
int mstj[200]
std::string GetName()
Definition: CrossSection.h:144
void pylist_(int *)
void setInternalXSec(const XSec &xsec)
void pygive_(const char *, int)
std::auto_ptr< HepMC::GenEvent > & event()
unsigned int maxEventsToPrint_
double GetEfficiency()
Definition: Event.h:66
CLHEP::HepRandomEngine & getEngineReference()
#define pycomp
GenRunInfoProduct & runInfo()
struct gen::@347 pydat1_
void call_pylist(int mode)
#define pylist
Definition: QQ.h:11
void SetMassRange(const double &Min_, const double &Max_)
Definition: Event.h:48
#define pyint1
int msti[200]
unsigned int pythiaListVerbosity_
int mstu[200]
Pythia6Service * pythia6Service_
const char * classname() const
void SetParameterSpace()
static FortranCallback * getInstance()
int pycomp_(int &)
#define pypars
Definition: GG.h:11
double paru[200]
edm::ParameterSet myPSet_
part
Definition: HCALResponse.h:20
#define pygive
bool declareStableParticles(const std::vector< int > &)
double pari[200]
struct gen::@348 pypars_
Exhume::CrossSection * exhumeProcess_
double vint[400]
CLHEP::HepRandomEngine * randomEngine_
tuple cout
Definition: gather_cfg.py:121
struct gen::@349 pyint1_
bool declareSpecialSettings(const std::vector< std::string > &)
double parj[200]