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 {
186 
188 
189  //Exhume Initialization
190  edm::ParameterSet processPSet = myPSet_.getParameter<edm::ParameterSet>("ExhumeProcess");
191  std::string processType = processPSet.getParameter<std::string>("ProcessType");
192  int sigID = -1;
193  if(processType == "Higgs"){
195  int higgsDecay = processPSet.getParameter<int>("HiggsDecay");
196  (static_cast<Exhume::Higgs*>(exhumeProcess_))->SetHiggsDecay(higgsDecay);
197  sigID = 100 + higgsDecay;
198  } else if(processType == "QQ"){
200  int quarkType = processPSet.getParameter<int>("QuarkType");
201  double thetaMin = processPSet.getParameter<double>("ThetaMin");
202  ((Exhume::QQ*)exhumeProcess_)->SetQuarkType(quarkType);
203  (static_cast<Exhume::QQ*>(exhumeProcess_))->SetThetaMin(thetaMin);
204  sigID = 200 + quarkType;
205  } else if(processType == "GG"){
207  double thetaMin = processPSet.getParameter<double>("ThetaMin");
208  (static_cast<Exhume::GG*>(exhumeProcess_))->SetThetaMin(thetaMin);
209  sigID = 300;
210  } else if(processType == "DiPhoton"){
212  double thetaMin = processPSet.getParameter<double>("ThetaMin");
213  (static_cast<Exhume::DiPhoton*>(exhumeProcess_))->SetThetaMin(thetaMin);
214  sigID = 400;
215  } else{
216  sigID = -1;
217  throw edm::Exception(edm::errors::Configuration,"ExhumeError") <<" No valid Exhume Process";
218  }
219 
220  pypars.msti[0] = sigID;
221  //exhumeEvent_ = new Exhume::Event(*exhumeProcess_,&getEngineReference());
223 
224  double massRangeLow = processPSet.getParameter<double>("MassRangeLow");
225  double massRangeHigh = processPSet.getParameter<double>("MassRangeHigh");
226  exhumeEvent_->SetMassRange(massRangeLow,massRangeHigh);
228 
229  return true;
230 }
231 
232 bool ExhumeHadronizer::declareStableParticles( std::vector<int> pdg )
233 {
234  //return pythia6Hadronizer_->declareStableParticles(pdg);
235 
236  for ( size_t i=0; i < pdg.size(); i++ )
237  {
238  int pyCode = pycomp( pdg[i] );
239  std::ostringstream pyCard ;
240  pyCard << "MDCY(" << pyCode << ",1)=0";
241  std::cout << pyCard.str() << std::endl;
242  call_pygive( pyCard.str() );
243  }
244 
245  return true;
246 
247 }
248 
249 bool ExhumeHadronizer::declareSpecialSettings( const std::vector<std::string> )
250 {
251  return true;
252 }
253 
255 {
256  std::ostringstream footer_str;
257 
258  double cs = exhumeEvent_->CrossSectionCalculation();
259  double eff = exhumeEvent_->GetEfficiency();
260  std::string name = exhumeProcess_->GetName();
261 
262  footer_str << "\n" <<" You have just been ExHuMEd." << "\n" << "\n";
263  footer_str << " The cross section for process " << name
264  << " is " << cs << " fb" << "\n" << "\n";
265  footer_str << " The efficiency of event generation was " << eff << "%" << "\n" << "\n";
266 
267  edm::LogInfo("") << footer_str.str();
268 
269  if ( !runInfo().internalXSec() )
270  {
271  runInfo().setInternalXSec( cs );
272  }
273 
274  return;
275 }
276 
277 const char* ExhumeHadronizer::classname() const
278 {
279  return "gen::ExhumeHadronizer";
280 }
281 
282 } // namespace gen
#define pydat1
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
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
bool declareSpecialSettings(const std::vector< std::string >)
CLHEP::HepRandomEngine & getEngineReference()
#define pycomp
GenRunInfoProduct & runInfo()
void call_pylist(int mode)
Definition: QQ.h:11
void SetMassRange(const double &Min_, const double &Max_)
Definition: Event.h:48
#define pyint1
int msti[200]
tuple pset
Definition: CrabTask.py:85
unsigned int pythiaListVerbosity_
int mstu[200]
Pythia6Service * pythia6Service_
const char * classname() const
void SetParameterSpace()
struct gen::@242 pydat1_
static FortranCallback * getInstance()
int pycomp_(int &)
#define pypars
Definition: GG.h:11
struct gen::@244 pyint1_
double paru[200]
edm::ParameterSet myPSet_
struct gen::@243 pypars_
part
Definition: HCALResponse.h:21
int mode
Definition: AMPTWrapper.h:139
#define pygive
double pari[200]
#define pylist
Exhume::CrossSection * exhumeProcess_
double vint[400]
CLHEP::HepRandomEngine * randomEngine_
tuple cout
Definition: gather_cfg.py:41
bool declareStableParticles(const std::vector< int >)
double parj[200]