001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031 #include "generatorMods/WGRAD_Module.hh"
032
033
034
035
036 #include <iostream>
037
038
039
040
041 #include "BaBar/Cdf.hh"
042 #include "inc/bcs.h"
043 #include "evt/evt.h"
044
045 #include "stdhep_i/CdfHepevt.hh"
046
047 #include "pythia_i/Pythia.hh"
048
049
050
051
052
053 extern "C" {
054 void upinit_(int*, float*);
055 void upevnt_();
056 }
057
058
059
060
061 #include "r_n/CdfRn.hh"
062 #include <sstream>
063 using std::ostringstream ;
064
065 const long WGRAD_Module::_defaultRandomSeed1 = 9228;
066 const long WGRAD_Module::_defaultRandomSeed2 = 1097;
067
068 const char* WGRAD_Module::genId = "WGRAD";
069
070
071
072
073
074 WGRAD_Module::WGRAD_Module()
075 : AbsGenModule( WGRAD_Module::genId,
076 "W production including O(alpha) EW radiative corrections"),
077 _debug("debug",this,false),
078 _usePythia("usePythia",this,true),
079 _useLesHouchesModule("useLesHouchesModule",this,false),
080 _beamType("BeamType",this,1),
081 _W_charge("W_Charge",this,1),
082 _widthTreatment("widthTreatment",this,2),
083 _decayLepton("DecayLepton",this,2),
084 _QED_radType("QED_RadType",this,2),
085 _fsrType("fsrType",this,1),
086 _smearingRecombination("SmearingRecombination",this,0),
087 _order("Order",this,2),
088 _scale("Scale",this,0),
089 _fsrCollinearCut("fsrCollinearCut",this,0),
090 _photonEnergyCut("PhotonEnergyCut",this,0.0001),
091 _photonCollinearCut("PhotonCollinearCut",this,0.0001),
092 _pdflibGroup("pdflibGroup",this,3),
093 _pdflibSet("pdflibSet",this,54),
094 _wMass("W_Mass",this,80.3),
095 _wWidth("W_Width",this,2.1),
096 _CME("CME",this,2000.0),
097 _lepton_ptmin("Lepton_ptmin",this,0.),
098 _lepton_ymax("Lepton_ymax",this,100.),
099 _neutrino_ptmin("Neutrino_ptmin",this,0.),
100 _neutrino_ymax("Neutrino_ymax",this,100.),
101 _photon_ptmin("Photon_ptmin",this,0.),
102 _photon_ymax("Photon_ymax",this,100.),
103 _tmass_low("mT_low",this,0.),
104 _tmass_high("mT_high",this,2000.),
105 _itmaxGrid("itmaxGrid",this,1),
106 _ncallGrid("ncallGrid",this,2000),
107 _itmaxPrecision("itmaxPrecision",this,2),
108 _ncallPrecision("ncallPrecision",this,5000),
109 _rndmSeed("randomSeed",this,4567),
110
111
112
113
114
115
116
117
118
119 _randomSeed1("RandomSeed1",this,WGRAD_Module::_defaultRandomSeed1),
120 _randomSeed2("RandomSeed2",this,WGRAD_Module::_defaultRandomSeed2),
121 _pythiaMenu(new PythiaMenu(this,0,"PythiaMenu"))
122 {
123 ostringstream debugDesc;
124 debugDesc << "\tPrint out debug information ?";
125 _debug.addDescription(debugDesc.str());
126 commands()->append(&_debug);
127
128 ostringstream usePythiaDesc;
129 usePythiaDesc << "\tUse Pythia for PS and underlying event sim. ?";
130 _usePythia.addDescription(usePythiaDesc.str());
131 _useLesHouchesModule.addDescription("\t Use Les Houches Modules for all interfacing");
132 commands()->append(&_usePythia);
133 commands()->append(&_useLesHouchesModule);
134
135
136
137
138 _cardsMenu.initialize("cardsMenu",this);
139 _cardsMenu.initTitle("cardsMenu");
140 commands()->append(&_cardsMenu);
141
142 _cardsMenu.commands()->append(&_beamType);
143 _cardsMenu.commands()->append(&_W_charge);
144 _cardsMenu.commands()->append(&_widthTreatment);
145 _cardsMenu.commands()->append(&_decayLepton);
146 _cardsMenu.commands()->append(&_QED_radType);
147 _cardsMenu.commands()->append(&_fsrType);
148 _cardsMenu.commands()->append(&_smearingRecombination);
149 _cardsMenu.commands()->append(&_order);
150 _cardsMenu.commands()->append(&_scale);
151 _cardsMenu.commands()->append(&_fsrCollinearCut);
152 _cardsMenu.commands()->append(&_photonEnergyCut);
153 _cardsMenu.commands()->append(&_photonCollinearCut);
154 _cardsMenu.commands()->append(&_pdflibGroup);
155 _cardsMenu.commands()->append(&_pdflibSet);
156 _cardsMenu.commands()->append(&_wMass);
157 _cardsMenu.commands()->append(&_wWidth);
158 _cardsMenu.commands()->append(&_CME);
159 _cardsMenu.commands()->append(&_lepton_ptmin);
160 _cardsMenu.commands()->append(&_lepton_ymax);
161 _cardsMenu.commands()->append(&_neutrino_ptmin);
162 _cardsMenu.commands()->append(&_neutrino_ymax);
163 _cardsMenu.commands()->append(&_photon_ptmin);
164 _cardsMenu.commands()->append(&_photon_ymax);
165 _cardsMenu.commands()->append(&_tmass_low);
166 _cardsMenu.commands()->append(&_tmass_high);
167 _cardsMenu.commands()->append(&_itmaxGrid);
168 _cardsMenu.commands()->append(&_ncallGrid);
169 _cardsMenu.commands()->append(&_itmaxPrecision);
170 _cardsMenu.commands()->append(&_ncallPrecision);
171 _cardsMenu.commands()->append(&_rndmSeed);
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189 _pythiaMenu->initialize("PythiaMenu",this);
190 _pythiaMenu->initTitle("Pythia Menu");
191 commands()->append(_pythiaMenu);
192
193
194 _randomNumberMenu.initialize("RandomNumberMenu",this);
195 _randomNumberMenu.initTitle("Fake event random number menu");
196 commands()->append(&_randomNumberMenu);
197
198
199 _randomNumberMenu.commands()->append(&_randomSeed1);
200 _randomNumberMenu.commands()->append(&_randomSeed2);
201
202 ostringstream tmpSstream1;
203 ostringstream tmpSstream2;
204
205
206 tmpSstream1 << " \t\t\tSeed #1 for the random number generator"
207 << "\n\t\t\t(default " << _randomSeed1.value() << ").";
208 _randomSeed1.addDescription(tmpSstream1.str());
209 tmpSstream2 << " \t\t\tSeed #2 for the random number generator"
210 << "\n\t\t\t(default " << _randomSeed2.value() << ").";
211 _randomSeed2.addDescription(tmpSstream2.str());
212
213 }
214
215
216
217
218
219 WGRAD_Module::~WGRAD_Module()
220 {
221 delete _pythiaMenu;
222 }
223
224
225
226
227
228 AppResult WGRAD_Module::genBeginJob( )
229 {
230 Pythia* pythia = Pythia::Instance();
231
232 CdfRn* rn = CdfRn::Instance();
233 if ( !rn->isReadingFromFile() ) {
234 rn->SetEngineSeeds(_randomSeed1.value(), _randomSeed2.value(),"WGRAD");
235 }
236
237
238 std::cout << " WGRAD_Module::genBeginJob : passing cuts and parameters to WGRAD ..." << std::endl;
239
240
241 wgrad_set_external_();
242
243
244 int wgrad_use_pythia[1];
245 if (_usePythia.value())
246 {
247 wgrad_use_pythia[0]=1;
248 }
249 else
250 {
251 wgrad_use_pythia[0]=0;
252 }
253 wgrad_use_pythia_(wgrad_use_pythia);
254
255
256 int wgrad_switches[10];
257 wgrad_switches[0] = _beamType.value();
258 wgrad_switches[1] = _W_charge.value();
259 wgrad_switches[2] = _decayLepton.value();
260 wgrad_switches[3] = _QED_radType.value();
261 wgrad_switches[4] = _fsrType.value();
262 wgrad_switches[5] = _smearingRecombination.value();
263 wgrad_switches[6] = _order.value();
264 wgrad_switches[7] = _scale.value();
265 wgrad_switches[8] = _fsrCollinearCut.value();
266 wgrad_switches[9] = _widthTreatment.value();
267
268 wgrad_set_switches_(wgrad_switches);
269
270
271 double wgrad_soft_collinear_cuts[2];
272 wgrad_soft_collinear_cuts[0] = _photonEnergyCut.value();
273 wgrad_soft_collinear_cuts[1] = _photonCollinearCut.value();
274
275 wgrad_set_soft_collinear_cuts_(wgrad_soft_collinear_cuts);
276
277
278 int wgrad_pdflib[2];
279 wgrad_pdflib[0] = _pdflibGroup.value();
280 wgrad_pdflib[1] = _pdflibSet.value();
281
282 wgrad_set_pdflib_(wgrad_pdflib);
283
284
285 double wgrad_properties[3];
286 wgrad_properties[0]=_wMass.value();
287 wgrad_properties[1]=_wWidth.value();
288 wgrad_properties[2]=_CME.value();
289
290 wgrad_set_properties_(wgrad_properties);
291
292
293 double wgrad_kinematic_cuts[8];
294 wgrad_kinematic_cuts[0] = _lepton_ptmin.value();
295 wgrad_kinematic_cuts[1] = _lepton_ymax.value();
296 wgrad_kinematic_cuts[2] = _neutrino_ptmin.value();
297 wgrad_kinematic_cuts[3] = _neutrino_ymax.value();
298 wgrad_kinematic_cuts[4] = _photon_ptmin.value();
299 wgrad_kinematic_cuts[5] = _photon_ymax.value();
300 wgrad_kinematic_cuts[6] = _tmass_low.value();
301 wgrad_kinematic_cuts[7] = _tmass_high.value();
302
303 wgrad_set_kinematic_cuts_(wgrad_kinematic_cuts);
304
305
306 int wgrad_grid[4];
307 wgrad_grid[0] = _itmaxGrid.value();
308 wgrad_grid[1] = _ncallGrid.value();
309 wgrad_grid[2] = _itmaxPrecision.value();
310 wgrad_grid[3] = _ncallPrecision.value();
311
312 wgrad_set_grid_pars_(wgrad_grid);
313
314
315 int wgrad_rndm_seed[1];
316 wgrad_rndm_seed[0] = _rndmSeed.value();
317 wgrad_set_rndm_seed_(wgrad_rndm_seed);
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337 wgrad_begin_();
338
339 std::cout << " WGRAD_Module::genBeginJob : WGRAD initialised. " << std::endl;
340
341 if(!_useLesHouchesModule.value()) {
342
343 pythia->setPythiaUid("WGRAD");
344
345
346 std::string special_frame = "USER";
347 std::string target = "dummy";
348 double winval = 1;
349 std::cout << " WGRAD_Module::genBeginJob : calling pythia->Pyinit " << std::endl;
350 pythia->Pyinit(special_frame,target,&winval);
351 }
352
353 return AppResult::OK;
354 }
355
356 AppResult WGRAD_Module::genBeginRun( AbsEvent* run )
357 {
358 return AppResult::OK;
359 }
360
361 AppResult WGRAD_Module::genEndJob()
362 {
363
364
365 wgrad_set_external_();
366
367 wgrad_end_();
368
369 return AppResult::OK;
370 }
371
372 AppResult WGRAD_Module::genEndRun( AbsEvent* run )
373 {
374 return AppResult::OK;
375 }
376
377 int WGRAD_Module::callGenerator( AbsEvent* anEvent )
378 {
379
380 wgrad_evt_();
381
382
383 CdfHepevt* hepevt = CdfHepevt::Instance();
384 hepevt->clear();
385 hepevt->clearCommon();
386
387
388 double wgrad_event_weight[1];
389 wgrad_get_event_weight_(wgrad_event_weight);
390
391
392 if(_useLesHouchesModule.value()) return 0;
393
394
395 if (!_usePythia.value())
396 {
397
398 int wgrad_particle_codes[3];
399 wgrad_get_particle_codes_(wgrad_particle_codes);
400 double wgrad_charged_lepton[4];
401 wgrad_get_charged_lepton_(wgrad_charged_lepton);
402 double wgrad_neutrino[4];
403 wgrad_get_neutrino_(wgrad_neutrino);
404 double wgrad_photon[4];
405 wgrad_get_photon_(wgrad_photon);
406
407 if (_debug.value())
408 {
409 std::cout << " WGRAD_Module::callGenerator : Charged Lepton code, px, py, pz, E = " << wgrad_particle_codes[0] << " , "
410 << wgrad_charged_lepton[0] << " , " << wgrad_charged_lepton[1] << " , "
411 << wgrad_charged_lepton[2] << " , " << wgrad_charged_lepton[3] << std::endl;
412 std::cout << " WGRAD_Module::callGenerator : Neutrino code, px, py, pz, E = " << wgrad_particle_codes[1] << " , "
413 << wgrad_neutrino[0] << " , " << wgrad_neutrino[1] << " , "
414 << wgrad_neutrino[2] << " , " << wgrad_neutrino[3] << std::endl;
415 std::cout << " WGRAD_Module::callGenerator : Photon code, px, py, pz, E = " << wgrad_particle_codes[2] << " , "
416 << wgrad_photon[0] << " , " << wgrad_photon[1] << " , "
417 << wgrad_photon[2] << " , " << wgrad_photon[3] << std::endl;
418 }
419
420
421
422 int nPart = 3;
423 if (wgrad_photon[3] == 0.0) nPart = 2;
424 if (_debug.value()) std::cout << " WGRAD_Module::callGenerator : nPart = " << nPart << std::endl;
425
426 CdfHepevt* hepevt = CdfHepevt::Instance();
427
428 for (int iPart = 0; iPart < nPart; iPart++)
429 {
430 hepevt->HepevtPtr()->IDHEP[iPart] = wgrad_particle_codes[iPart];
431
432 hepevt->HepevtPtr()->ISTHEP[iPart] = 1;
433 hepevt->HepevtPtr()->JMOHEP[iPart][0] = 0;
434 hepevt->HepevtPtr()->JMOHEP[iPart][1] = 0;
435
436 hepevt->HepevtPtr()->JDAHEP[iPart][0] = 0;
437 hepevt->HepevtPtr()->JDAHEP[iPart][1] = 0;
438
439 if (iPart==0)
440 {
441 hepevt->HepevtPtr()->PHEP[iPart][0] = wgrad_charged_lepton[0];
442 hepevt->HepevtPtr()->PHEP[iPart][1] = wgrad_charged_lepton[1];
443 hepevt->HepevtPtr()->PHEP[iPart][2] = wgrad_charged_lepton[2];
444 hepevt->HepevtPtr()->PHEP[iPart][3] = wgrad_charged_lepton[3];
445 }
446 else if (iPart==1)
447 {
448 hepevt->HepevtPtr()->PHEP[iPart][0] = wgrad_neutrino[0];
449 hepevt->HepevtPtr()->PHEP[iPart][1] = wgrad_neutrino[1];
450 hepevt->HepevtPtr()->PHEP[iPart][2] = wgrad_neutrino[2];
451 hepevt->HepevtPtr()->PHEP[iPart][3] = wgrad_neutrino[3];
452 }
453 else if (iPart==2)
454 {
455 hepevt->HepevtPtr()->PHEP[iPart][0] = wgrad_photon[0];
456 hepevt->HepevtPtr()->PHEP[iPart][1] = wgrad_photon[1];
457 hepevt->HepevtPtr()->PHEP[iPart][2] = wgrad_photon[2];
458 hepevt->HepevtPtr()->PHEP[iPart][3] = wgrad_photon[3];
459 }
460
461 hepevt->HepevtPtr()->VHEP[iPart][0] = 0.;
462 hepevt->HepevtPtr()->VHEP[iPart][1] = 0.;
463 hepevt->HepevtPtr()->VHEP[iPart][2] = 0.;
464 hepevt->HepevtPtr()->VHEP[iPart][3] = 0.;
465 }
466 hepevt->HepevtPtr()->NHEP = nPart;
467 }
468 else
469 {
470
471 Pythia* pythia = Pythia::Instance();
472
473
474 pythia->Pyevnt();
475
476 pythia->addEvent();
477 int mevlist = pythia->EventListLevel();
478 if (pythia->events() >= _pythiaMenu->firstlistevent() &&
479 pythia->events() <= _pythiaMenu->lastlistevent())
480 {
481 std::cout << "PYEVNT event number " << pythia->events() << std::endl;
482 pythia->Pylist(&mevlist);
483 }
484
485 int mconv = 1;
486
487 pythia->Lunhep(&mconv);
488 }
489
490 return 0;
491 }
492
493 void WGRAD_Module::fillHepevt() {
494
495 }
496
Send problems or questions to cdfcode@fnal.gov