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
5 // Class THerwig6 is an interface to the Herwig program
7 // 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
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-----------------------------------------------------------------------
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-----------------------------------------------------------------------
53 #include "TClonesArray.h"
54 #include "TParticle.h"
55 #include "TObjArray.h"
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);
67 THerwig6::THerwig6() : TGenerator("Herwig6","Herwig6") {
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.
73 delete fParticles; // was allocated as TObjArray in TGenerator
75 fParticles = new TClonesArray("TParticle",50);
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);
105 //------------------------------------------------------------------------------
106 THerwig6::~THerwig6()
108 // Destructor. The data members of TGenerator are delete by itself
111 //______________________________________________________________________________
112 void THerwig6::GenerateEvent()
117 // generate hard subprocess
119 // generate parton cascades
121 // do heavy objects decay
123 // do cluster formation
127 // do unstable particle decays
129 // do heavy flavor hadrons decay
131 // add soft underlying event
137 //______________________________________________________________________________
138 void THerwig6::OpenFortranFile(int lun, char* name) {
139 herwig6_open_fortran_file_(&lun, name, strlen(name));
142 //______________________________________________________________________________
143 void THerwig6::CloseFortranFile(int lun) {
144 herwig6_close_fortran_file_(&lun);
147 void THerwig6::Initialize(const char *beam, const char *target, double pbeam1, double pbeam2, int iproc)
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.
157 strncpy(cbeam,beam,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\" .");
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");
209 strncpy(fHwbmch->PART1,beam,8);
210 strncpy(fHwbmch->PART2,target,8);
212 fHwproc->PBEAM1=pbeam1;
213 fHwproc->PBEAM2=pbeam2;
214 // process to generate
215 fHwproc->IPROC=iproc;
216 // not used in the class definition
219 // reset all parameters
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);
230 void THerwig6::PrepareRun()
232 // compute parameter dependent constants
234 // initialize elementary processes
238 //______________________________________________________________________________
239 TObjArray* THerwig6::ImportParticles(Option_t *option)
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
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.
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) {
257 // Use the common block values for the TParticle constructor
262 fHepevt->JMOHEP[i][0]-1,
263 fHepevt->JMOHEP[i][1]-1,
264 fHepevt->JDAHEP[i][0]-1,
265 fHepevt->JDAHEP[i][1]-1,
274 fHepevt->VHEP[i][3]);
278 else if (!strcmp(option,"All")) {
279 for (Int_t i = 0; i<=numpart; 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,
295 fHepevt->VHEP[i][3]);
301 //______________________________________________________________________________
302 Int_t THerwig6::ImportParticles(TClonesArray *particles, Option_t *option)
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
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.
315 if (particles == 0) return 0;
316 TClonesArray &refParticles = *particles;
317 refParticles.Clear();
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) {
323 // Use the common block values for the TParticle constructor
325 new(refParticles[i]) TParticle(
328 fHepevt->JMOHEP[i][0]-1,
329 fHepevt->JMOHEP[i][1]-1,
330 fHepevt->JDAHEP[i][0]-1,
331 fHepevt->JDAHEP[i][1]-1,
340 fHepevt->VHEP[i][3]);
344 else if (!strcmp(option,"All")) {
345 for (Int_t i = 0; i< numpart; i++) {
346 new(refParticles[i]) TParticle(
349 fHepevt->JMOHEP[i][0]-1,
350 fHepevt->JMOHEP[i][1]-1,
351 fHepevt->JDAHEP[i][0]-1,
352 fHepevt->JDAHEP[i][1]-1,
361 fHepevt->VHEP[i][3]);
367 void THerwig6::Hwigin()
372 void THerwig6::Hwuinc()
377 void THerwig6::Hwusta(char* name)
383 void THerwig6::Hweini()
389 void THerwig6::Hwuine()
395 void THerwig6::Hwepro()
401 void THerwig6::Hwbgen()
407 void THerwig6::Hwdhob()
413 void THerwig6::Hwcfor()
419 void THerwig6::Hwcdec()
425 void THerwig6::Hwdhad()
431 void THerwig6::Hwdhvy()
437 void THerwig6::Hwmevt()
443 void THerwig6::Hwufne()
449 void THerwig6::Hwefin()
455 void THerwig6::SetupTest()
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
468 for (int i=0;i<nEvToGenerate;i++)
471 // do your stuff. For ex:
472 int nOfPar=GetNumberOfParticles(); // from TGenerator
473 for (int j=0; j<nOfPar; j++)
475 TParticle* p=GetParticle(j);
476 // here you do whatever you want with the particle