2d8d4543 |
1 | // definition of c++ Class THerwig6 to be used in ROOT |
2 | // this is a c++ interface to the F77 Herwig6 program |
3 | // author: j. g. contreras jgcn@moni.mda.cinvestav.mx |
4 | // date: december 22, 2000 |
884ccf6a |
5 | // Class THerwig6 is an interface to the Herwig program |
6 | // |
7 | // C----------------------------------------------------------------------- |
8 | // C H E R W I G |
9 | // C |
10 | // C a Monte Carlo event generator for simulating |
11 | // C +---------------------------------------------------+ |
12 | // C | Hadron Emission Reactions With Interfering Gluons | |
13 | // C +---------------------------------------------------+ |
14 | // C I.G. Knowles(*), G. Marchesini(+), M.H. Seymour($) and B.R. Webber(#) |
15 | // C----------------------------------------------------------------------- |
16 | // C with Minimal Supersymmetric Standard Model Matrix Elements by |
17 | // C S. Moretti($) and K. Odagiri($) |
18 | // C----------------------------------------------------------------------- |
19 | // C R parity violating Supersymmetric Decays and Matrix Elements by |
20 | // C P. Richardson(&) |
21 | // C----------------------------------------------------------------------- |
22 | // C matrix element corrections to top decay and Drell-Yan type processes |
23 | // C by G. Corcella(+) |
24 | // C----------------------------------------------------------------------- |
25 | // C Deep Inelastic Scattering and Heavy Flavour Electroproduction by |
26 | // C G. Abbiendi(@) and L. Stanco(%) |
27 | // C----------------------------------------------------------------------- |
28 | // C and Jet Photoproduction in Lepton-Hadron Collisions by J. Chyla(~) |
29 | // C----------------------------------------------------------------------- |
30 | // C(*) Department of Physics & Astronomy, University of Edinburgh |
31 | // C(+) Dipartimento di Fisica, Universita di Milano |
32 | // C($) Rutherford Appleton Laboratory |
33 | // C(#) Cavendish Laboratory, Cambridge |
34 | // C(&) Department of Physics, University of Oxford |
35 | // C(@) Dipartimento di Fisica, Universita di Bologna |
36 | // C(%) Dipartimento di Fisica, Universita di Padova |
37 | // C(~) Institute of Physics, Prague |
38 | // C----------------------------------------------------------------------- |
39 | // C Version 6.100 - 16th December 1999 |
40 | // C----------------------------------------------------------------------- |
41 | // C Main reference: |
42 | // C G.Marchesini, B.R.Webber, G.Abbiendi, I.G.Knowles, M.H.Seymour, |
43 | // C and L.Stanco, Computer Physics Communications 67 (1992) 465. |
44 | // C----------------------------------------------------------------------- |
45 | // C Please send e-mail about this program to one of the authors at the |
46 | // C following Internet addresses: |
47 | // C I.Knowles@ed.ac.uk Giuseppe.Marchesini@mi.infn.it |
48 | // C M.Seymour@rl.ac.uk webber@hep.phy.cam.ac.uk |
49 | // C----------------------------------------------------------------------- |
50 | |
2d8d4543 |
51 | |
2d8d4543 |
52 | #include "THerwig6.h" |
53 | #include "TClonesArray.h" |
54 | #include "TParticle.h" |
884ccf6a |
55 | #include "TObjArray.h" |
2d8d4543 |
56 | |
57 | |
58 | ClassImp(THerwig6) |
59 | |
60 | extern "C" { |
61 | void* herwig6_common_block_address_(char*, int len); |
62 | void herwig6_open_fortran_file_ (int* lun, char* name, int); |
63 | void herwig6_close_fortran_file_(int* lun); |
64 | } |
65 | |
66 | |
67 | THerwig6::THerwig6() : TGenerator("Herwig6","Herwig6") { |
68 | |
69 | // THerwig6 constructor: creates a TClonesArray in which it will store all |
70 | // particles. Note that there may be only one functional THerwig6 object |
71 | // at a time, so it's not use to create more than one instance of it. |
72 | |
73 | delete fParticles; // was allocated as TObjArray in TGenerator |
74 | |
75 | fParticles = new TClonesArray("TParticle",50); |
76 | |
77 | // initialize common-blocks |
78 | fHepevt = (Hepevt_t*) herwig6_common_block_address_((char*)"HEPEVT",6); |
79 | fHwbeam = (Hwbeam_t*) herwig6_common_block_address_((char*)"HWBEAM",6); |
80 | fHwbmch = (Hwbmch_t*) herwig6_common_block_address_((char*)"HWBMCH",6); |
81 | fHwproc = (Hwproc_t*) herwig6_common_block_address_((char*)"HWPROC",6); |
82 | fHwpram = (Hwpram_t*) herwig6_common_block_address_((char*)"HWPRAM",6); |
83 | fHwprch = (Hwprch_t*) herwig6_common_block_address_((char*)"HWPRCH",6); |
84 | fHwpart = (Hwpart_t*) herwig6_common_block_address_((char*)"HWPART",6); |
85 | fHwparp = (Hwparp_t*) herwig6_common_block_address_((char*)"HWPARP",6); |
86 | fHwbosc = (Hwbosc_t*) herwig6_common_block_address_((char*)"HWBOSC",6); |
87 | fHwparc = (Hwparc_t*) herwig6_common_block_address_((char*)"HWPARC",6); |
88 | fHwbrch = (Hwbrch_t*) herwig6_common_block_address_((char*)"HWBRCH",6); |
89 | fHwevnt = (Hwevnt_t*) herwig6_common_block_address_((char*)"HWEVNT",6); |
90 | fHwhard = (Hwhard_t*) herwig6_common_block_address_((char*)"HWHARD",6); |
91 | fHwprop = (Hwprop_t*) herwig6_common_block_address_((char*)"HWPROP",6); |
92 | fHwunam = (Hwunam_t*) herwig6_common_block_address_((char*)"HWUNAM",6); |
93 | fHwupdt = (Hwupdt_t*) herwig6_common_block_address_((char*)"HWUPDT",6); |
94 | fHwuwts = (Hwuwts_t*) herwig6_common_block_address_((char*)"HWUWTS",6); |
95 | fHwuclu = (Hwuclu_t*) herwig6_common_block_address_((char*)"HWUCLU",6); |
96 | fHwdist = (Hwdist_t*) herwig6_common_block_address_((char*)"HWDIST",6); |
97 | fHwqdks = (Hwqdks_t*) herwig6_common_block_address_((char*)"HWQDKS",6); |
98 | fHwusud = (Hwusud_t*) herwig6_common_block_address_((char*)"HWUSUD",6); |
99 | fHwsusy = (Hwsusy_t*) herwig6_common_block_address_((char*)"HWSUSY",6); |
100 | fHwrpar = (Hwrpar_t*) herwig6_common_block_address_((char*)"HWRPAR",6); |
101 | fHwminb = (Hwminb_t*) herwig6_common_block_address_((char*)"HWMINB",6); |
102 | fHwclus = (Hwclus_t*) herwig6_common_block_address_((char*)"HWCLUS",6); |
103 | } |
104 | |
105 | //------------------------------------------------------------------------------ |
106 | THerwig6::~THerwig6() |
107 | { |
bbc19b09 |
108 | // Destructor. The data members of TGenerator are delete by itself |
2d8d4543 |
109 | } |
110 | |
111 | //______________________________________________________________________________ |
112 | void THerwig6::GenerateEvent() |
113 | { |
114 | |
115 | //initialize event |
116 | hwuine_(); |
117 | // generate hard subprocess |
118 | hwepro_(); |
119 | // generate parton cascades |
120 | hwbgen_(); |
121 | // do heavy objects decay |
122 | hwdhob_(); |
123 | // do cluster formation |
124 | hwcfor_(); |
125 | // do cluster decays |
126 | hwcdec_(); |
127 | // do unstable particle decays |
128 | hwdhad_(); |
129 | // do heavy flavor hadrons decay |
130 | hwdhvy_(); |
131 | // add soft underlying event |
132 | hwmevt_(); |
133 | // finish event |
134 | hwufne_(); |
135 | } |
136 | |
137 | //______________________________________________________________________________ |
138 | void THerwig6::OpenFortranFile(int lun, char* name) { |
139 | herwig6_open_fortran_file_(&lun, name, strlen(name)); |
140 | } |
141 | |
142 | //______________________________________________________________________________ |
143 | void THerwig6::CloseFortranFile(int lun) { |
144 | herwig6_close_fortran_file_(&lun); |
145 | } |
146 | |
147 | void THerwig6::Initialize(const char *beam, const char *target, double pbeam1, double pbeam2, int iproc) |
148 | |
149 | { |
150 | // perform the initialization for Herwig6 |
151 | // sets correct title. |
152 | // after calling this method all parameters are set to their default |
153 | // values. If you want to modify any parameter you have to set the new |
154 | // value after calling Initialize and before PrepareRun. |
155 | |
156 | char cbeam[8]; |
157 | strncpy(cbeam,beam,8); |
158 | char ctarget[8]; |
159 | strncpy(ctarget,target,8); |
160 | printf("\n Initializing Herwig !! \n"); |
161 | if ( (!strncmp(beam, "E+" ,2)) && |
162 | (!strncmp(beam, "E-" ,2)) && |
163 | (!strncmp(beam, "MU+" ,3)) && |
164 | (!strncmp(beam, "MU-" ,3)) && |
165 | (!strncmp(beam, "NUE" ,3)) && |
166 | (!strncmp(beam, "NUEB" ,4)) && |
167 | (!strncmp(beam, "NUMU" ,4)) && |
168 | (!strncmp(beam, "NMUB" ,4)) && |
169 | (!strncmp(beam, "NTAU" ,4)) && |
170 | (!strncmp(beam, "NTAB" ,4)) && |
171 | (!strncmp(beam, "GAMA" ,4)) && |
172 | (!strncmp(beam, "P ",8)) && |
173 | (!strncmp(beam, "PBAR ",8)) && |
174 | (!strncmp(beam, "N" ,1)) && |
175 | (!strncmp(beam, "NBAR" ,4)) && |
176 | (!strncmp(beam, "PI+" ,3)) && |
177 | (!strncmp(beam, "PI-" ,3)) ) { |
178 | printf("WARNING! In THerwig6:Initialize():\n"); |
179 | printf(" specified beam=%s is unrecognized .\n",beam); |
180 | printf(" resetting to \"P\" ."); |
181 | sprintf(cbeam,"P"); |
182 | } |
183 | |
184 | if ( (!strncmp(target, "E+" ,2)) && |
185 | (!strncmp(target, "E-" ,2)) && |
186 | (!strncmp(target, "MU+" ,3)) && |
187 | (!strncmp(target, "MU-" ,3)) && |
188 | (!strncmp(target, "NUE" ,3)) && |
189 | (!strncmp(target, "NUEB" ,4)) && |
190 | (!strncmp(target, "NUMU" ,4)) && |
191 | (!strncmp(target, "NMUB" ,4)) && |
192 | (!strncmp(target, "NTAU" ,4)) && |
193 | (!strncmp(target, "NTAB" ,4)) && |
194 | (!strncmp(target, "GAMA" ,4)) && |
195 | (!strncmp(target, "P ",8)) && |
196 | (!strncmp(target, "PBAR ",8)) && |
197 | (!strncmp(target, "N" ,1)) && |
198 | (!strncmp(target, "NBAR" ,4)) && |
199 | (!strncmp(target, "PI+" ,3)) && |
200 | (!strncmp(target, "PI-" ,3)) ) { |
201 | printf("WARNING! In THerwig6:Initialize():\n"); |
202 | printf(" specified target=%s is unrecognized .\n",target); |
203 | printf(" resetting to \"P\" ."); |
204 | sprintf(ctarget,"P"); |
205 | } |
206 | |
207 | // initialization: |
208 | // type of beams |
209 | strncpy(fHwbmch->PART1,beam,8); |
210 | strncpy(fHwbmch->PART2,target,8); |
211 | // momentum of beams |
212 | fHwproc->PBEAM1=pbeam1; |
213 | fHwproc->PBEAM2=pbeam2; |
214 | // process to generate |
215 | fHwproc->IPROC=iproc; |
216 | // not used in the class definition |
217 | fHwproc->MAXEV=1; |
218 | |
219 | // reset all parameters |
220 | hwigin_(); |
221 | |
222 | // set correct title |
223 | char atitle[132]; |
224 | double win=pbeam1+pbeam2; |
225 | printf("\n %s - %s at %g GeV",beam,target,win); |
226 | sprintf(atitle,"%s-%s at %g GeV",cbeam,ctarget,win); |
227 | SetTitle(atitle); |
228 | } |
229 | |
230 | void THerwig6::PrepareRun() |
231 | { |
232 | // compute parameter dependent constants |
233 | hwuinc_(); |
234 | // initialize elementary processes |
235 | hweini_(); |
236 | } |
237 | |
238 | //______________________________________________________________________________ |
239 | TObjArray* THerwig6::ImportParticles(Option_t *option) |
240 | { |
241 | // |
242 | // Default primary creation method. It reads the /HEPEVT/ common block which |
243 | // has been filled by the GenerateEvent method. If the event generator does |
244 | // not use the HEPEVT common block, This routine has to be overloaded by |
245 | // the subclasses. |
246 | // The default action is to store only the stable particles (ISTHEP = 1) |
247 | // This can be demanded explicitly by setting the option = "Final" |
248 | // If the option = "All", all the particles are stored. |
249 | // |
250 | fParticles->Clear(); |
251 | Int_t numpart = fHepevt->NHEP; |
252 | TClonesArray &a = *((TClonesArray*)fParticles); |
253 | if (!strcmp(option,"") || !strcmp(option,"Final")) { |
254 | for (Int_t i = 0; i<=numpart; i++) { |
255 | if (fHepevt->ISTHEP[i] == 1) { |
256 | // |
257 | // Use the common block values for the TParticle constructor |
258 | // |
259 | new(a[i]) TParticle( |
260 | fHepevt->IDHEP[i], |
261 | fHepevt->ISTHEP[i], |
262 | fHepevt->JMOHEP[i][0]-1, |
263 | fHepevt->JMOHEP[i][1]-1, |
264 | fHepevt->JDAHEP[i][0]-1, |
265 | fHepevt->JDAHEP[i][1]-1, |
266 | |
267 | fHepevt->PHEP[i][0], |
268 | fHepevt->PHEP[i][1], |
269 | fHepevt->PHEP[i][2], |
270 | fHepevt->PHEP[i][3], |
271 | fHepevt->VHEP[i][0], |
272 | fHepevt->VHEP[i][1], |
273 | fHepevt->VHEP[i][2], |
274 | fHepevt->VHEP[i][3]); |
275 | } |
276 | } |
277 | } |
278 | else if (!strcmp(option,"All")) { |
279 | for (Int_t i = 0; i<=numpart; i++) { |
280 | new(a[i]) TParticle( |
281 | fHepevt->IDHEP[i], |
282 | fHepevt->ISTHEP[i], |
283 | fHepevt->JMOHEP[i][0]-1, |
284 | fHepevt->JMOHEP[i][1]-1, |
285 | fHepevt->JDAHEP[i][0]-1, |
286 | fHepevt->JDAHEP[i][1]-1, |
287 | |
288 | fHepevt->PHEP[i][0], |
289 | fHepevt->PHEP[i][1], |
290 | fHepevt->PHEP[i][2], |
291 | fHepevt->PHEP[i][3], |
292 | fHepevt->VHEP[i][0], |
293 | fHepevt->VHEP[i][1], |
294 | fHepevt->VHEP[i][2], |
295 | fHepevt->VHEP[i][3]); |
296 | } |
297 | } |
298 | return fParticles; |
299 | } |
300 | |
301 | //______________________________________________________________________________ |
302 | Int_t THerwig6::ImportParticles(TClonesArray *particles, Option_t *option) |
303 | { |
304 | // |
305 | // Default primary creation method. It reads the /HEPEVT/ common block which |
306 | // has been filled by the GenerateEvent method. If the event generator does |
307 | // not use the HEPEVT common block, This routine has to be overloaded by |
308 | // the subclasses. |
309 | // The function loops on the generated particles and store them in |
310 | // the TClonesArray pointed by the argument particles. |
311 | // The default action is to store only the stable particles (ISTHEP = 1) |
312 | // This can be demanded explicitly by setting the option = "Final" |
313 | // If the option = "All", all the particles are stored. |
314 | // |
315 | if (particles == 0) return 0; |
884ccf6a |
316 | TClonesArray &refParticles = *particles; |
317 | refParticles.Clear(); |
2d8d4543 |
318 | Int_t numpart = fHepevt->NHEP; |
319 | if (!strcmp(option,"") || !strcmp(option,"Final")) { |
320 | for (Int_t i = 0; i< numpart; i++) { |
321 | if (fHepevt->ISTHEP[i] == 1) { |
322 | // |
323 | // Use the common block values for the TParticle constructor |
324 | // |
884ccf6a |
325 | new(refParticles[i]) TParticle( |
2d8d4543 |
326 | fHepevt->IDHEP[i], |
327 | fHepevt->ISTHEP[i], |
328 | fHepevt->JMOHEP[i][0]-1, |
329 | fHepevt->JMOHEP[i][1]-1, |
330 | fHepevt->JDAHEP[i][0]-1, |
331 | fHepevt->JDAHEP[i][1]-1, |
332 | |
333 | fHepevt->PHEP[i][0], |
334 | fHepevt->PHEP[i][1], |
335 | fHepevt->PHEP[i][2], |
336 | fHepevt->PHEP[i][3], |
337 | fHepevt->VHEP[i][0], |
338 | fHepevt->VHEP[i][1], |
339 | fHepevt->VHEP[i][2], |
340 | fHepevt->VHEP[i][3]); |
341 | } |
342 | } |
343 | } |
344 | else if (!strcmp(option,"All")) { |
345 | for (Int_t i = 0; i< numpart; i++) { |
884ccf6a |
346 | new(refParticles[i]) TParticle( |
2d8d4543 |
347 | fHepevt->IDHEP[i], |
348 | fHepevt->ISTHEP[i], |
349 | fHepevt->JMOHEP[i][0]-1, |
350 | fHepevt->JMOHEP[i][1]-1, |
351 | fHepevt->JDAHEP[i][0]-1, |
352 | fHepevt->JDAHEP[i][1]-1, |
353 | |
354 | fHepevt->PHEP[i][0], |
355 | fHepevt->PHEP[i][1], |
356 | fHepevt->PHEP[i][2], |
357 | fHepevt->PHEP[i][3], |
358 | fHepevt->VHEP[i][0], |
359 | fHepevt->VHEP[i][1], |
360 | fHepevt->VHEP[i][2], |
361 | fHepevt->VHEP[i][3]); |
362 | } |
363 | } |
364 | return numpart; |
365 | } |
366 | |
367 | void THerwig6::Hwigin() |
368 | { |
369 | hwigin_(); |
370 | } |
371 | |
372 | void THerwig6::Hwuinc() |
373 | { |
374 | hwuinc_(); |
375 | } |
376 | |
377 | void THerwig6::Hwusta(char* name) |
378 | |
379 | { |
380 | hwusta_(name,8); |
381 | } |
382 | |
383 | void THerwig6::Hweini() |
384 | |
385 | { |
386 | hweini_(); |
387 | } |
388 | |
389 | void THerwig6::Hwuine() |
390 | |
391 | { |
392 | hwuine_(); |
393 | } |
394 | |
395 | void THerwig6::Hwepro() |
396 | |
397 | { |
398 | hwepro_(); |
399 | } |
400 | |
401 | void THerwig6::Hwbgen() |
402 | |
403 | { |
404 | hwbgen_(); |
405 | } |
406 | |
407 | void THerwig6::Hwdhob() |
408 | |
409 | { |
410 | hwdhob_(); |
411 | } |
412 | |
413 | void THerwig6::Hwcfor() |
414 | |
415 | { |
416 | hwcfor_(); |
417 | } |
418 | |
419 | void THerwig6::Hwcdec() |
420 | |
421 | { |
422 | hwcdec_(); |
423 | } |
424 | |
425 | void THerwig6::Hwdhad() |
426 | |
427 | { |
428 | hwdhad_(); |
429 | } |
430 | |
431 | void THerwig6::Hwdhvy() |
432 | |
433 | { |
434 | hwdhvy_(); |
435 | } |
436 | |
437 | void THerwig6::Hwmevt() |
438 | |
439 | { |
440 | hwmevt_(); |
441 | } |
442 | |
443 | void THerwig6::Hwufne() |
444 | |
445 | { |
446 | hwufne_(); |
447 | } |
448 | |
449 | void THerwig6::Hwefin() |
450 | |
451 | { |
452 | hwefin_(); |
453 | } |
454 | |
455 | void THerwig6::SetupTest() |
456 | { |
457 | // exampe of running herwig and generating one event |
458 | // after changing some options |
459 | Initialize("P","PBAR",900.,900.,1500); |
460 | // here you can set some parameters |
461 | SetPTMIN(15.); // Min pt in hadronic jet production |
462 | SetYJMIN(-4.); // Min jet rapidity |
463 | SetYJMAX(4.); // Max jet rapidity |
464 | // after you set your wished parameters |
465 | // herwig can do its work |
466 | PrepareRun(); |
884ccf6a |
467 | int nEvToGenerate=1; |
468 | for (int i=0;i<nEvToGenerate;i++) |
2d8d4543 |
469 | { |
470 | GenerateEvent(); |
471 | // do your stuff. For ex: |
884ccf6a |
472 | int nOfPar=GetNumberOfParticles(); // from TGenerator |
473 | for (int j=0; j<nOfPar; j++) |
2d8d4543 |
474 | { |
475 | TParticle* p=GetParticle(j); |
476 | // here you do whatever you want with the particle |
477 | p->Print(); |
478 | }; |
479 | }; |
480 | } |
481 | |
482 | |
483 | |
484 | |
485 | |